@htmlbricks/hb-chartjs 0.61.17 → 0.61.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main.iife.js CHANGED
@@ -16,5 +16,5 @@
16
16
  * Released under the MIT License
17
17
  */class Th{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,n,s){const o=e.listeners[s],r=e.duration;o.forEach(a=>a({chart:t,initial:e.initial,numSteps:r,currentStep:Math.min(n-e.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=To.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((n,s)=>{if(!n.running||!n.items.length)return;const o=n.items;let r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>n.duration&&(n.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(s.draw(),this._notify(s,n,t,"progress")),o.length||(n.running=!1,this._notify(s,n,t,"complete"),n.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){const e=this._charts;let n=e.get(t);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,n)),n}listen(t,e,n){this._getAnims(t).listeners[e].push(n)}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((n,s)=>Math.max(n,s._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 n=e.items;let s=n.length-1;for(;s>=0;--s)n[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var Tt=new Th;const lr="transparent",Eh={boolean(i,t,e){return e>.5?t:i},color(i,t,e){const n=zo(i||lr),s=n.valid&&zo(t||lr);return s&&s.valid?s.mix(n,e).hexString():t},number(i,t,e){return i+(t-i)*e}};class Lh{constructor(t,e,n,s){const o=e[n];s=Ke([t.to,s,o,t.from]);const r=Ke([t.from,o,s]);this._active=!0,this._fn=t.fn||Eh[t.type||typeof r],this._easing=Ye[t.easing]||Ye.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=n,this._from=r,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,n){if(this._active){this._notify(!1);const s=this._target[this._prop],o=n-this._start,r=this._duration-o;this._start=n,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=Ke([t.to,e,s,t.from]),this._from=Ke([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,n=this._duration,s=this._prop,o=this._from,r=this._loop,a=this._to;let l;if(this._active=o!==a&&(r||e<n),!this._active){this._target[s]=a,this._notify(!0);return}if(e<0){this._target[s]=o;return}l=e/n%2,l=r&&l>1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[s]=this._fn(o,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,n)=>{t.push({res:e,rej:n})})}_notify(t){const e=t?"res":"rej",n=this._promises||[];for(let s=0;s<n.length;s++)n[s][e]()}}class cr{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!O(t))return;const e=Object.keys(W.animation),n=this._properties;Object.getOwnPropertyNames(t).forEach(s=>{const o=t[s];if(!O(o))return;const r={};for(const a of e)r[a]=o[a];(B(o.properties)&&o.properties||[s]).forEach(a=>{(a===s||!n.has(a))&&n.set(a,r)})})}_animateOptions(t,e){const n=e.options,s=Ih(t,n);if(!s)return[];const o=this._createAnimations(s,n);return n.$shared&&Rh(t.options.$animations,n).then(()=>{t.options=n},()=>{}),o}_createAnimations(t,e){const n=this._properties,s=[],o=t.$animations||(t.$animations={}),r=Object.keys(e),a=Date.now();let l;for(l=r.length-1;l>=0;--l){const c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){s.push(...this._animateOptions(t,e));continue}const h=e[c];let u=o[c];const f=n.get(c);if(u)if(f&&u.active()){u.update(f,h,a);continue}else u.cancel();if(!f||!f.duration){t[c]=h;continue}o[c]=u=new Lh(f,t,c,h),s.push(u)}return s}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}const n=this._createAnimations(t,e);if(n.length)return Tt.add(this._chart,n),!0}}function Rh(i,t){const e=[],n=Object.keys(t);for(let s=0;s<n.length;s++){const o=i[n[s]];o&&o.active()&&e.push(o.wait())}return Promise.all(e)}function Ih(i,t){if(!t)return;let e=i.options;if(!e){i.options=t;return}return e.$shared&&(i.options=e=Object.assign({},e,{$shared:!1,$animations:{}})),e}function hr(i,t){const e=i&&i.options||{},n=e.reverse,s=e.min===void 0?t:0,o=e.max===void 0?t:0;return{start:n?o:s,end:n?s:o}}function Fh(i,t,e){if(e===!1)return!1;const n=hr(i,e),s=hr(t,e);return{top:s.end,right:n.end,bottom:s.start,left:n.start}}function zh(i){let t,e,n,s;return O(i)?(t=i.top,e=i.right,n=i.bottom,s=i.left):t=e=n=s=i,{top:t,right:e,bottom:n,left:s,disabled:i===!1}}function ur(i,t){const e=[],n=i._getSortedDatasetMetas(t);let s,o;for(s=0,o=n.length;s<o;++s)e.push(n[s].index);return e}function fr(i,t,e,n={}){const s=i.keys,o=n.mode==="single";let r,a,l,c;if(t===null)return;let h=!1;for(r=0,a=s.length;r<a;++r){if(l=+s[r],l===e){if(h=!0,n.all)continue;break}c=i.values[l],V(c)&&(o||t===0||vt(t)===vt(c))&&(t+=c)}return!h&&!n.all?0:t}function $h(i,t){const{iScale:e,vScale:n}=t,s=e.axis==="x"?"x":"y",o=n.axis==="x"?"x":"y",r=Object.keys(i),a=new Array(r.length);let l,c,h;for(l=0,c=r.length;l<c;++l)h=r[l],a[l]={[s]:h,[o]:i[h]};return a}function Bn(i,t){const e=i&&i.options.stacked;return e||e===void 0&&t.stack!==void 0}function Bh(i,t,e){return`${i.id}.${t.id}.${e.stack||e.type}`}function Nh(i){const{min:t,max:e,minDefined:n,maxDefined:s}=i.getUserBounds();return{min:n?t:Number.NEGATIVE_INFINITY,max:s?e:Number.POSITIVE_INFINITY}}function Vh(i,t,e){const n=i[t]||(i[t]={});return n[e]||(n[e]={})}function dr(i,t,e,n){for(const s of t.getMatchingVisibleMetas(n).reverse()){const o=i[s.index];if(e&&o>0||!e&&o<0)return s.index}return null}function gr(i,t){const{chart:e,_cachedMeta:n}=i,s=e._stacks||(e._stacks={}),{iScale:o,vScale:r,index:a}=n,l=o.axis,c=r.axis,h=Bh(o,r,n),u=t.length;let f;for(let d=0;d<u;++d){const g=t[d],{[l]:p,[c]:m}=g,b=g._stacks||(g._stacks={});f=b[c]=Vh(s,h,p),f[a]=m,f._top=dr(f,r,!0,n.type),f._bottom=dr(f,r,!1,n.type);const _=f._visualValues||(f._visualValues={});_[a]=m}}function Nn(i,t){const e=i.scales;return Object.keys(e).filter(n=>e[n].axis===t).shift()}function Wh(i,t){return Xt(i,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function Hh(i,t,e){return Xt(i,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function Ge(i,t){const e=i.controller.index,n=i.vScale&&i.vScale.axis;if(n){t=t||i._parsed;for(const s of t){const o=s._stacks;if(!o||o[n]===void 0||o[n][e]===void 0)return;delete o[n][e],o[n]._visualValues!==void 0&&o[n]._visualValues[e]!==void 0&&delete o[n]._visualValues[e]}}}const Vn=i=>i==="reset"||i==="none",pr=(i,t)=>t?i:Object.assign({},i),jh=(i,t,e)=>i&&!t.hidden&&t._stacked&&{keys:ur(e,!0),values:null};class qt{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=Bn(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&Ge(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,n=this.getDataset(),s=(u,f,d,g)=>u==="x"?f:u==="r"?g:d,o=e.xAxisID=P(n.xAxisID,Nn(t,"x")),r=e.yAxisID=P(n.yAxisID,Nn(t,"y")),a=e.rAxisID=P(n.rAxisID,Nn(t,"r")),l=e.indexAxis,c=e.iAxisID=s(l,o,r,a),h=e.vAxisID=s(l,r,o,a);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(r),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(c),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&Ao(this._data,this),t._stacked&&Ge(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),n=this._data;if(O(e)){const s=this._cachedMeta;this._data=$h(e,s)}else if(n!==e){if(n){Ao(n,this);const s=this._cachedMeta;Ge(s),s._parsed=[]}e&&Object.isExtensible(e)&&Cc(e,this),this._syncList=[],this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,n=this.getDataset();let s=!1;this._dataCheck();const o=e._stacked;e._stacked=Bn(e.vScale,e),e.stack!==n.stack&&(s=!0,Ge(e),e.stack=n.stack),this._resyncElements(t),(s||o!==e._stacked)&&(gr(this,e._parsed),e._stacked=Bn(e.vScale,e))}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),n=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:n,_data:s}=this,{iScale:o,_stacked:r}=n,a=o.axis;let l=t===0&&e===s.length?!0:n._sorted,c=t>0&&n._parsed[t-1],h,u,f;if(this._parsing===!1)n._parsed=s,n._sorted=!0,f=s;else{B(s[t])?f=this.parseArrayData(n,s,t,e):O(s[t])?f=this.parseObjectData(n,s,t,e):f=this.parsePrimitiveData(n,s,t,e);const d=()=>u[a]===null||c&&u[a]<c[a];for(h=0;h<e;++h)n._parsed[h+t]=u=f[h],l&&(d()&&(l=!1),c=u);n._sorted=l}r&&gr(this,f)}parsePrimitiveData(t,e,n,s){const{iScale:o,vScale:r}=t,a=o.axis,l=r.axis,c=o.getLabels(),h=o===r,u=new Array(s);let f,d,g;for(f=0,d=s;f<d;++f)g=f+n,u[f]={[a]:h||o.parse(c[g],g),[l]:r.parse(e[g],g)};return u}parseArrayData(t,e,n,s){const{xScale:o,yScale:r}=t,a=new Array(s);let l,c,h,u;for(l=0,c=s;l<c;++l)h=l+n,u=e[h],a[l]={x:o.parse(u[0],h),y:r.parse(u[1],h)};return a}parseObjectData(t,e,n,s){const{xScale:o,yScale:r}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=new Array(s);let h,u,f,d;for(h=0,u=s;h<u;++h)f=h+n,d=e[f],c[h]={x:o.parse(jt(d,a),f),y:r.parse(jt(d,l),f)};return c}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,e,n){const s=this.chart,o=this._cachedMeta,r=e[t.axis],a={keys:ur(s,!0),values:e._stacks[t.axis]._visualValues};return fr(a,r,o.index,{mode:n})}updateRangeFromParsed(t,e,n,s){const o=n[e.axis];let r=o===null?NaN:o;const a=s&&n._stacks[e.axis];s&&a&&(s.values=a,r=fr(s,o,this._cachedMeta.index)),t.min=Math.min(t.min,r),t.max=Math.max(t.max,r)}getMinMax(t,e){const n=this._cachedMeta,s=n._parsed,o=n._sorted&&t===n.iScale,r=s.length,a=this._getOtherScale(t),l=jh(e,n,this.chart),c={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:h,max:u}=Nh(a);let f,d;function g(){d=s[f];const p=d[a.axis];return!V(d[t.axis])||h>p||u<p}for(f=0;f<r&&!(!g()&&(this.updateRangeFromParsed(c,t,d,l),o));++f);if(o){for(f=r-1;f>=0;--f)if(!g()){this.updateRangeFromParsed(c,t,d,l);break}}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,n=[];let s,o,r;for(s=0,o=e.length;s<o;++s)r=e[s][t.axis],V(r)&&n.push(r);return n}getMaxOverflow(){return!1}getLabelAndValue(t){const e=this._cachedMeta,n=e.iScale,s=e.vScale,o=this.getParsed(t);return{label:n?""+n.getLabelForValue(o[n.axis]):"",value:s?""+s.getLabelForValue(o[s.axis]):""}}_update(t){const e=this._cachedMeta;this.update(t||"default"),e._clip=zh(P(this.options.clip,Fh(e.xScale,e.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,e=this.chart,n=this._cachedMeta,s=n.data||[],o=e.chartArea,r=[],a=this._drawStart||0,l=this._drawCount||s.length-a,c=this.options.drawActiveElementsOnTop;let h;for(n.dataset&&n.dataset.draw(t,o,a,l),h=a;h<a+l;++h){const u=s[h];u.hidden||(u.active&&c?r.push(u):u.draw(t,o))}for(h=0;h<r.length;++h)r[h].draw(t,o)}getStyle(t,e){const n=e?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(n):this.resolveDataElementOptions(t||0,n)}getContext(t,e,n){const s=this.getDataset();let o;if(t>=0&&t<this._cachedMeta.data.length){const r=this._cachedMeta.data[t];o=r.$context||(r.$context=Hh(this.getContext(),t,r)),o.parsed=this.getParsed(t),o.raw=s.data[t],o.index=o.dataIndex=t}else o=this.$context||(this.$context=Wh(this.chart.getContext(),this.index)),o.dataset=s,o.index=o.datasetIndex=this.index;return o.active=!!e,o.mode=n,o}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,e){return this._resolveElementOptions(this.dataElementType.id,e,t)}_resolveElementOptions(t,e="default",n){const s=e==="active",o=this._cachedDataOpts,r=t+"-"+e,a=o[r],l=this.enableOptionSharing&&We(n);if(a)return pr(a,l);const c=this.chart.config,h=c.datasetElementScopeKeys(this._type,t),u=s?[`${t}Hover`,"hover",t,""]:[t,""],f=c.getOptionScopes(this.getDataset(),h),d=Object.keys(W.elements[t]),g=()=>this.getContext(n,s,e),p=c.resolveNamedOptions(f,d,g,u);return p.$shared&&(p.$shared=l,o[r]=Object.freeze(pr(p,l))),p}_resolveAnimations(t,e,n){const s=this.chart,o=this._cachedDataOpts,r=`animation-${e}`,a=o[r];if(a)return a;let l;if(s.options.animation!==!1){const h=this.chart.config,u=h.datasetAnimationScopeKeys(this._type,e),f=h.getOptionScopes(this.getDataset(),u);l=h.createResolver(f,this.getContext(t,n,e))}const c=new cr(s,l&&l.animations);return l&&l._cacheable&&(o[r]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Vn(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const n=this.resolveDataElementOptions(t,e),s=this._sharedOptions,o=this.getSharedOptions(n),r=this.includeOptions(e,o)||o!==s;return this.updateSharedOptions(o,e,n),{sharedOptions:o,includeOptions:r}}updateElement(t,e,n,s){Vn(s)?Object.assign(t,n):this._resolveAnimations(e,s).update(t,n)}updateSharedOptions(t,e,n){t&&!Vn(e)&&this._resolveAnimations(void 0,e).update(t,n)}_setStyle(t,e,n,s){t.active=s;const o=this.getStyle(e,s);this._resolveAnimations(e,n,s).update(t,{options:!s&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,n){this._setStyle(t,n,"active",!1)}setHoverStyle(t,e,n){this._setStyle(t,n,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,n=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const s=n.length,o=e.length,r=Math.min(o,s);r&&this.parse(0,r),o>s?this._insertElements(s,o-s,t):o<s&&this._removeElements(o,s-o)}_insertElements(t,e,n=!0){const s=this._cachedMeta,o=s.data,r=t+e;let a;const l=c=>{for(c.length+=e,a=c.length-1;a>=r;a--)c[a]=c[a-e]};for(l(o),a=t;a<r;++a)o[a]=new this.dataElementType;this._parsing&&l(s._parsed),this.parse(t,e),n&&this.updateElements(o,t,e,"reset")}updateElements(t,e,n,s){}_removeElements(t,e){const n=this._cachedMeta;if(this._parsing){const s=n._parsed.splice(t,e);n._stacked&&Ge(n,s)}n.data.splice(t,e)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[e,n,s]=t;this[e](n,s)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,e){e&&this._sync(["_removeElements",t,e]);const n=arguments.length-2;n&&this._sync(["_insertElements",t,n])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}function Yh(i,t){if(!i._cache.$bar){const e=i.getMatchingVisibleMetas(t);let n=[];for(let s=0,o=e.length;s<o;s++)n=n.concat(e[s].controller.getAllParsedValues(i));i._cache.$bar=Oo(n.sort((s,o)=>s-o))}return i._cache.$bar}function Uh(i){const t=i.iScale,e=Yh(t,i.type);let n=t._length,s,o,r,a;const l=()=>{r===32767||r===-32768||(We(a)&&(n=Math.min(n,Math.abs(r-a)||n)),a=r)};for(s=0,o=e.length;s<o;++s)r=t.getPixelForValue(e[s]),l();for(a=void 0,s=0,o=t.ticks.length;s<o;++s)r=t.getPixelForTick(s),l();return n}function Xh(i,t,e,n){const s=e.barThickness;let o,r;return A(s)?(o=t.min*e.categoryPercentage,r=e.barPercentage):(o=s*n,r=1),{chunk:o/n,ratio:r,start:t.pixels[i]-o/2}}function qh(i,t,e,n){const s=t.pixels,o=s[i];let r=i>0?s[i-1]:null,a=i<s.length-1?s[i+1]:null;const l=e.categoryPercentage;r===null&&(r=o-(a===null?t.end-t.start:a-o)),a===null&&(a=o+o-r);const c=o-(o-Math.min(r,a))/2*l;return{chunk:Math.abs(a-r)/2*l/n,ratio:e.barPercentage,start:c}}function Kh(i,t,e,n){const s=e.parse(i[0],n),o=e.parse(i[1],n),r=Math.min(s,o),a=Math.max(s,o);let l=r,c=a;Math.abs(r)>Math.abs(a)&&(l=a,c=r),t[e.axis]=c,t._custom={barStart:l,barEnd:c,start:s,end:o,min:r,max:a}}function mr(i,t,e,n){return B(i)?Kh(i,t,e,n):t[e.axis]=e.parse(i,n),t}function br(i,t,e,n){const s=i.iScale,o=i.vScale,r=s.getLabels(),a=s===o,l=[];let c,h,u,f;for(c=e,h=e+n;c<h;++c)f=t[c],u={},u[s.axis]=a||s.parse(r[c],c),l.push(mr(f,u,o,c));return l}function Wn(i){return i&&i.barStart!==void 0&&i.barEnd!==void 0}function Gh(i,t,e){return i!==0?vt(i):(t.isHorizontal()?1:-1)*(t.min>=e?1:-1)}function Zh(i){let t,e,n,s,o;return i.horizontal?(t=i.base>i.x,e="left",n="right"):(t=i.base<i.y,e="bottom",n="top"),t?(s="end",o="start"):(s="start",o="end"),{start:e,end:n,reverse:t,top:s,bottom:o}}function Jh(i,t,e,n){let s=t.borderSkipped;const o={};if(!s){i.borderSkipped=o;return}if(s===!0){i.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}const{start:r,end:a,reverse:l,top:c,bottom:h}=Zh(i);s==="middle"&&e&&(i.enableBorderRadius=!0,(e._top||0)===n?s=c:(e._bottom||0)===n?s=h:(o[_r(h,r,a,l)]=!0,s=c)),o[_r(s,r,a,l)]=!0,i.borderSkipped=o}function _r(i,t,e,n){return n?(i=Qh(i,t,e),i=xr(i,e,t)):i=xr(i,t,e),i}function Qh(i,t,e){return i===t?e:i===e?t:i}function xr(i,t,e){return i==="start"?t:i==="end"?e:i}function tu(i,{inflateAmount:t},e){i.inflateAmount=t==="auto"?e===1?.33:0:t}class eu extends qt{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(t,e,n,s){return br(t,e,n,s)}parseArrayData(t,e,n,s){return br(t,e,n,s)}parseObjectData(t,e,n,s){const{iScale:o,vScale:r}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=o.axis==="x"?a:l,h=r.axis==="x"?a:l,u=[];let f,d,g,p;for(f=n,d=n+s;f<d;++f)p=e[f],g={},g[o.axis]=o.parse(jt(p,c),f),u.push(mr(jt(p,h),g,r,f));return u}updateRangeFromParsed(t,e,n,s){super.updateRangeFromParsed(t,e,n,s);const o=n._custom;o&&e===this._cachedMeta.vScale&&(t.min=Math.min(t.min,o.min),t.max=Math.max(t.max,o.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const e=this._cachedMeta,{iScale:n,vScale:s}=e,o=this.getParsed(t),r=o._custom,a=Wn(r)?"["+r.start+", "+r.end+"]":""+s.getLabelForValue(o[s.axis]);return{label:""+n.getLabelForValue(o[n.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();const t=this._cachedMeta;t.stack=this.getDataset().stack}update(t){const e=this._cachedMeta;this.updateElements(e.data,0,e.data.length,t)}updateElements(t,e,n,s){const o=s==="reset",{index:r,_cachedMeta:{vScale:a}}=this,l=a.getBasePixel(),c=a.isHorizontal(),h=this._getRuler(),{sharedOptions:u,includeOptions:f}=this._getSharedOptions(e,s);for(let d=e;d<e+n;d++){const g=this.getParsed(d),p=o||A(g[a.axis])?{base:l,head:l}:this._calculateBarValuePixels(d),m=this._calculateBarIndexPixels(d,h),b=(g._stacks||{})[a.axis],_={horizontal:c,base:p.base,enableBorderRadius:!b||Wn(g._custom)||r===b._top||r===b._bottom,x:c?p.head:m.center,y:c?m.center:p.head,height:c?m.size:Math.abs(p.size),width:c?Math.abs(p.size):m.size};f&&(_.options=u||this.resolveDataElementOptions(d,t[d].active?"active":s));const y=_.options||t[d].options;Jh(_,y,b,r),tu(_,y,h.ratio),this.updateElement(t[d],d,_,s)}}_getStacks(t,e){const{iScale:n}=this._cachedMeta,s=n.getMatchingVisibleMetas(this._type).filter(h=>h.controller.options.grouped),o=n.options.stacked,r=[],a=this._cachedMeta.controller.getParsed(e),l=a&&a[n.axis],c=h=>{const u=h._parsed.find(d=>d[n.axis]===l),f=u&&u[h.vScale.axis];if(A(f)||isNaN(f))return!0};for(const h of s)if(!(e!==void 0&&c(h))&&((o===!1||r.indexOf(h.stack)===-1||o===void 0&&h.stack===void 0)&&r.push(h.stack),h.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,e=this.chart.options.indexAxis;return Object.keys(t).filter(n=>t[n].axis===e).shift()}_getAxis(){const t={},e=this.getFirstScaleIdForIndexAxis();for(const n of this.chart.data.datasets)t[P(this.chart.options.indexAxis==="x"?n.xAxisID:n.yAxisID,e)]=!0;return Object.keys(t)}_getStackIndex(t,e,n){const s=this._getStacks(t,n),o=e!==void 0?s.indexOf(e):-1;return o===-1?s.length-1:o}_getRuler(){const t=this.options,e=this._cachedMeta,n=e.iScale,s=[];let o,r;for(o=0,r=e.data.length;o<r;++o)s.push(n.getPixelForValue(this.getParsed(o)[n.axis],o));const a=t.barThickness;return{min:a||Uh(e),pixels:s,start:n._startPixel,end:n._endPixel,stackCount:this._getStackCount(),scale:n,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:e,_stacked:n,index:s},options:{base:o,minBarLength:r}}=this,a=o||0,l=this.getParsed(t),c=l._custom,h=Wn(c);let u=l[e.axis],f=0,d=n?this.applyStack(e,l,n):u,g,p;d!==u&&(f=d-u,d=u),h&&(u=c.barStart,d=c.barEnd-c.barStart,u!==0&&vt(u)!==vt(c.barEnd)&&(f=0),f+=u);const m=!A(o)&&!h?o:f;let b=e.getPixelForValue(m);if(this.chart.getDataVisibility(t)?g=e.getPixelForValue(f+d):g=b,p=g-b,Math.abs(p)<r){p=Gh(p,e,a)*r,u===a&&(b-=p/2);const _=e.getPixelForDecimal(0),y=e.getPixelForDecimal(1),v=Math.min(_,y),x=Math.max(_,y);b=Math.max(Math.min(b,x),v),g=b+p,n&&!h&&(l._stacks[e.axis]._visualValues[s]=e.getValueForPixel(g)-e.getValueForPixel(b))}if(b===e.getPixelForValue(a)){const _=vt(p)*e.getLineWidthForValue(a)/2;b+=_,p-=_}return{size:p,base:b,head:g,center:g+p/2}}_calculateBarIndexPixels(t,e){const n=e.scale,s=this.options,o=s.skipNull,r=P(s.maxBarThickness,1/0);let a,l;const c=this._getAxisCount();if(e.grouped){const h=o?this._getStackCount(t):e.stackCount,u=s.barThickness==="flex"?qh(t,e,s,h*c):Xh(t,e,s,h*c),f=this.chart.options.indexAxis==="x"?this.getDataset().xAxisID:this.getDataset().yAxisID,d=this._getAxis().indexOf(P(f,this.getFirstScaleIdForIndexAxis())),g=this._getStackIndex(this.index,this._cachedMeta.stack,o?t:void 0)+d;a=u.start+u.chunk*g+u.chunk/2,l=Math.min(r,u.chunk*u.ratio)}else a=n.getPixelForValue(this.getParsed(t)[n.axis],t),l=Math.min(r,e.min*e.ratio);return{base:a-l/2,head:a+l/2,center:a,size:l}}draw(){const t=this._cachedMeta,e=t.vScale,n=t.data,s=n.length;let o=0;for(;o<s;++o)this.getParsed(o)[e.axis]!==null&&!n[o].hidden&&n[o].draw(this._ctx)}}class iu extends qt{static id="bubble";static defaults={datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}};static overrides={scales:{x:{type:"linear"},y:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,e,n,s){const o=super.parsePrimitiveData(t,e,n,s);for(let r=0;r<o.length;r++)o[r]._custom=this.resolveDataElementOptions(r+n).radius;return o}parseArrayData(t,e,n,s){const o=super.parseArrayData(t,e,n,s);for(let r=0;r<o.length;r++){const a=e[n+r];o[r]._custom=P(a[2],this.resolveDataElementOptions(r+n).radius)}return o}parseObjectData(t,e,n,s){const o=super.parseObjectData(t,e,n,s);for(let r=0;r<o.length;r++){const a=e[n+r];o[r]._custom=P(a&&a.r&&+a.r,this.resolveDataElementOptions(r+n).radius)}return o}getMaxOverflow(){const t=this._cachedMeta.data;let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart.data.labels||[],{xScale:s,yScale:o}=e,r=this.getParsed(t),a=s.getLabelForValue(r.x),l=o.getLabelForValue(r.y),c=r._custom;return{label:n[t]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,n,s){const o=s==="reset",{iScale:r,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(e,s),h=r.axis,u=a.axis;for(let f=e;f<e+n;f++){const d=t[f],g=!o&&this.getParsed(f),p={},m=p[h]=o?r.getPixelForDecimal(.5):r.getPixelForValue(g[h]),b=p[u]=o?a.getBasePixel():a.getPixelForValue(g[u]);p.skip=isNaN(m)||isNaN(b),c&&(p.options=l||this.resolveDataElementOptions(f,d.active?"active":s),o&&(p.options.radius=0)),this.updateElement(d,f,p,s)}}resolveDataElementOptions(t,e){const n=this.getParsed(t);let s=super.resolveDataElementOptions(t,e);s.$shared&&(s=Object.assign({},s,{$shared:!1}));const o=s.radius;return e!=="active"&&(s.radius=0),s.radius+=P(n&&n._custom,o),s}}function nu(i,t,e){let n=1,s=1,o=0,r=0;if(t<$){const a=i,l=a+t,c=Math.cos(a),h=Math.sin(a),u=Math.cos(l),f=Math.sin(l),d=(y,v,x)=>je(y,a,l,!0)?1:Math.max(v,v*e,x,x*e),g=(y,v,x)=>je(y,a,l,!0)?-1:Math.min(v,v*e,x,x*e),p=d(0,c,u),m=d(H,h,f),b=g(E,c,u),_=g(E+H,h,f);n=(p-b)/2,s=(m-_)/2,o=-(p+b)/2,r=-(m+_)/2}return{ratioX:n,ratioY:s,offsetX:o,offsetY:r}}class yr extends qt{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:n,color:s}}=t.legend.options;return e.labels.map((o,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:n,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}}};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 n=this.getDataset().data,s=this._cachedMeta;if(this._parsing===!1)s._parsed=n;else{let o=l=>+n[l];if(O(n[t])){const{key:l="value"}=this._parsing;o=c=>+jt(n[c],l)}let r,a;for(r=t,a=t+e;r<a;++r)s._parsed[r]=o(r)}}_getRotation(){return _t(this.options.rotation-90)}_getCircumference(){return _t(this.options.circumference)}_getRotationExtents(){let t=$,e=-$;for(let n=0;n<this.chart.data.datasets.length;++n)if(this.chart.isDatasetVisible(n)&&this.chart.getDatasetMeta(n).type===this._type){const s=this.chart.getDatasetMeta(n).controller,o=s._getRotation(),r=s._getCircumference();t=Math.min(t,o),e=Math.max(e,o+r)}return{rotation:t,circumference:e-t}}update(t){const e=this.chart,{chartArea:n}=e,s=this._cachedMeta,o=s.data,r=this.getMaxBorderWidth()+this.getMaxOffset(o)+this.options.spacing,a=Math.max((Math.min(n.width,n.height)-r)/2,0),l=Math.min(dc(this.options.cutout,a),1),c=this._getRingWeight(this.index),{circumference:h,rotation:u}=this._getRotationExtents(),{ratioX:f,ratioY:d,offsetX:g,offsetY:p}=nu(u,h,l),m=(n.width-r)/f,b=(n.height-r)/d,_=Math.max(Math.min(m,b)/2,0),y=xo(this.options.radius,_),v=Math.max(y*l,0),x=(y-v)/this._getVisibleDatasetWeightTotal();this.offsetX=g*y,this.offsetY=p*y,s.total=this.calculateTotal(),this.outerRadius=y-x*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-x*c,0),this.updateElements(o,0,o.length,t)}_circumference(t,e){const n=this.options,s=this._cachedMeta,o=this._getCircumference();return e&&n.animation.animateRotate||!this.chart.getDataVisibility(t)||s._parsed[t]===null||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*o/$)}updateElements(t,e,n,s){const o=s==="reset",r=this.chart,a=r.chartArea,c=r.options.animation,h=(a.left+a.right)/2,u=(a.top+a.bottom)/2,f=o&&c.animateScale,d=f?0:this.innerRadius,g=f?0:this.outerRadius,{sharedOptions:p,includeOptions:m}=this._getSharedOptions(e,s);let b=this._getRotation(),_;for(_=0;_<e;++_)b+=this._circumference(_,o);for(_=e;_<e+n;++_){const y=this._circumference(_,o),v=t[_],x={x:h+this.offsetX,y:u+this.offsetY,startAngle:b,endAngle:b+y,circumference:y,outerRadius:g,innerRadius:d};m&&(x.options=p||this.resolveDataElementOptions(_,v.active?"active":s)),b+=y,this.updateElement(v,_,x,s)}}calculateTotal(){const t=this._cachedMeta,e=t.data;let n=0,s;for(s=0;s<e.length;s++){const o=t._parsed[s];o!==null&&!isNaN(o)&&this.chart.getDataVisibility(s)&&!e[s].hidden&&(n+=Math.abs(o))}return n}calculateCircumference(t){const e=this._cachedMeta.total;return e>0&&!isNaN(t)?$*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart,s=n.data.labels||[],o=Ue(e._parsed[t],n.options.locale);return{label:s[t]||"",value:o}}getMaxBorderWidth(t){let e=0;const n=this.chart;let s,o,r,a,l;if(!t){for(s=0,o=n.data.datasets.length;s<o;++s)if(n.isDatasetVisible(s)){r=n.getDatasetMeta(s),t=r.data,a=r.controller;break}}if(!t)return 0;for(s=0,o=t.length;s<o;++s)l=a.resolveDataElementOptions(s),l.borderAlign!=="inner"&&(e=Math.max(e,l.borderWidth||0,l.hoverBorderWidth||0));return e}getMaxOffset(t){let e=0;for(let n=0,s=t.length;n<s;++n){const o=this.resolveDataElementOptions(n);e=Math.max(e,o.offset||0,o.hoverOffset||0)}return e}_getRingWeightOffset(t){let e=0;for(let n=0;n<t;++n)this.chart.isDatasetVisible(n)&&(e+=this._getRingWeight(n));return e}_getRingWeight(t){return Math.max(P(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}class su extends qt{static id="line";static defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:n,data:s=[],_dataset:o}=e,r=this.chart._animationsDisabled;let{start:a,count:l}=Lo(e,s,r);this._drawStart=a,this._drawCount=l,Ro(e)&&(a=0,l=s.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!o._decimated,n.points=s;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(n,void 0,{animated:!r,options:c},t),this.updateElements(s,a,l,t)}updateElements(t,e,n,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:h,includeOptions:u}=this._getSharedOptions(e,s),f=r.axis,d=a.axis,{spanGaps:g,segment:p}=this.options,m=ke(g)?g:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||s==="none",_=e+n,y=t.length;let v=e>0&&this.getParsed(e-1);for(let x=0;x<y;++x){const w=t[x],M=b?w:{};if(x<e||x>=_){M.skip=!0;continue}const k=this.getParsed(x),S=A(k[d]),D=M[f]=r.getPixelForValue(k[f],x),C=M[d]=o||S?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,k,l):k[d],x);M.skip=isNaN(D)||isNaN(C)||S,M.stop=x>0&&Math.abs(k[f]-v[f])>m,p&&(M.parsed=k,M.raw=c.data[x]),u&&(M.options=h||this.resolveDataElementOptions(x,w.active?"active":s)),b||this.updateElement(w,x,M,s),v=k}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,n=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return n;const o=s[0].size(this.resolveDataElementOptions(0)),r=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(n,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}class ou extends qt{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:n,color:s}}=t.legend.options;return e.labels.map((o,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:n,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart,s=n.data.labels||[],o=Ue(e._parsed[t].r,n.options.locale);return{label:s[t]||"",value:o}}parseObjectData(t,e,n,s){return Ko.bind(this)(t,e,n,s)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((n,s)=>{const o=this.getParsed(s).r;!isNaN(o)&&this.chart.getDataVisibility(s)&&(o<e.min&&(e.min=o),o>e.max&&(e.max=o))}),e}_updateRadius(){const t=this.chart,e=t.chartArea,n=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(s/2,0),r=Math.max(n.cutoutPercentage?o/100*n.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,n,s){const o=s==="reset",r=this.chart,l=r.options.animation,c=this._cachedMeta.rScale,h=c.xCenter,u=c.yCenter,f=c.getIndexAngle(0)-.5*E;let d=f,g;const p=360/this.countVisibleElements();for(g=0;g<e;++g)d+=this._computeAngle(g,s,p);for(g=e;g<e+n;g++){const m=t[g];let b=d,_=d+this._computeAngle(g,s,p),y=r.getDataVisibility(g)?c.getDistanceFromCenterForValue(this.getParsed(g).r):0;d=_,o&&(l.animateScale&&(y=0),l.animateRotate&&(b=_=f));const v={x:h,y:u,innerRadius:0,outerRadius:y,startAngle:b,endAngle:_,options:this.resolveDataElementOptions(g,m.active?"active":s)};this.updateElement(m,g,v,s)}}countVisibleElements(){const t=this._cachedMeta;let e=0;return t.data.forEach((n,s)=>{!isNaN(this.getParsed(s).r)&&this.chart.getDataVisibility(s)&&e++}),e}_computeAngle(t,e,n){return this.chart.getDataVisibility(t)?_t(this.resolveDataElementOptions(t,e).angle||n):0}}class ru extends yr{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}}class au extends qt{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(t){const e=this._cachedMeta.vScale,n=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(n[e.axis])}}parseObjectData(t,e,n,s){return Ko.bind(this)(t,e,n,s)}update(t){const e=this._cachedMeta,n=e.dataset,s=e.data||[],o=e.iScale.getLabels();if(n.points=s,t!=="resize"){const r=this.resolveDatasetElementOptions(t);this.options.showLine||(r.borderWidth=0);const a={_loop:!0,_fullLoop:o.length===s.length,options:r};this.updateElement(n,void 0,a,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,n,s){const o=this._cachedMeta.rScale,r=s==="reset";for(let a=e;a<e+n;a++){const l=t[a],c=this.resolveDataElementOptions(a,l.active?"active":s),h=o.getPointPositionForValue(a,this.getParsed(a).r),u=r?o.xCenter:h.x,f=r?o.yCenter:h.y,d={x:u,y:f,angle:h.angle,skip:isNaN(u)||isNaN(f),options:c};this.updateElement(l,a,d,s)}}}class lu extends qt{static id="scatter";static defaults={datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1};static overrides={interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}};getLabelAndValue(t){const e=this._cachedMeta,n=this.chart.data.labels||[],{xScale:s,yScale:o}=e,r=this.getParsed(t),a=s.getLabelForValue(r.x),l=o.getLabelForValue(r.y);return{label:n[t]||"",value:"("+a+", "+l+")"}}update(t){const e=this._cachedMeta,{data:n=[]}=e,s=this.chart._animationsDisabled;let{start:o,count:r}=Lo(e,n,s);if(this._drawStart=o,this._drawCount=r,Ro(e)&&(o=0,r=n.length),this.options.showLine){this.datasetElementType||this.addElements();const{dataset:a,_dataset:l}=e;a._chart=this.chart,a._datasetIndex=this.index,a._decimated=!!l._decimated,a.points=n;const c=this.resolveDatasetElementOptions(t);c.segment=this.options.segment,this.updateElement(a,void 0,{animated:!s,options:c},t)}else this.datasetElementType&&(delete e.dataset,this.datasetElementType=!1);this.updateElements(n,o,r,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,e,n,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,h=this.resolveDataElementOptions(e,s),u=this.getSharedOptions(h),f=this.includeOptions(s,u),d=r.axis,g=a.axis,{spanGaps:p,segment:m}=this.options,b=ke(p)?p:Number.POSITIVE_INFINITY,_=this.chart._animationsDisabled||o||s==="none";let y=e>0&&this.getParsed(e-1);for(let v=e;v<e+n;++v){const x=t[v],w=this.getParsed(v),M=_?x:{},k=A(w[g]),S=M[d]=r.getPixelForValue(w[d],v),D=M[g]=o||k?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,w,l):w[g],v);M.skip=isNaN(S)||isNaN(D)||k,M.stop=v>0&&Math.abs(w[d]-y[d])>b,m&&(M.parsed=w,M.raw=c.data[v]),f&&(M.options=u||this.resolveDataElementOptions(v,x.active?"active":s)),_||this.updateElement(x,v,M,s),y=w}this.updateSharedOptions(u,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let a=0;for(let l=e.length-1;l>=0;--l)a=Math.max(a,e[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}const n=t.dataset,s=n.options&&n.options.borderWidth||0;if(!e.length)return s;const o=e[0].size(this.resolveDataElementOptions(0)),r=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(s,o,r)/2}}function ce(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Hn{static override(t){Object.assign(Hn.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return ce()}parse(){return ce()}format(){return ce()}add(){return ce()}diff(){return ce()}startOf(){return ce()}endOf(){return ce()}}var cu={_date:Hn};function hu(i,t,e,n){const{controller:s,data:o,_sorted:r}=i,a=s._cachedMeta.iScale,l=i.dataset&&i.dataset.options?i.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&r&&o.length){const c=a._reversePixels?Pc:At;if(n){if(s._sharedOptions){const h=o[0],u=typeof h.getRange=="function"&&h.getRange(t);if(u){const f=c(o,t,e-u),d=c(o,t,e+u);return{lo:f.lo,hi:d.hi}}}}else{const h=c(o,t,e);if(l){const{vScale:u}=s._cachedMeta,{_parsed:f}=i,d=f.slice(0,h.lo+1).reverse().findIndex(p=>!A(p[u.axis]));h.lo-=Math.max(0,d);const g=f.slice(h.hi).findIndex(p=>!A(p[u.axis]));h.hi+=Math.max(0,g)}return h}}return{lo:0,hi:o.length-1}}function $i(i,t,e,n,s){const o=i.getSortedVisibleDatasetMetas(),r=e[t];for(let a=0,l=o.length;a<l;++a){const{index:c,data:h}=o[a],{lo:u,hi:f}=hu(o[a],t,r,s);for(let d=u;d<=f;++d){const g=h[d];g.skip||n(g,c,d)}}}function uu(i){const t=i.indexOf("x")!==-1,e=i.indexOf("y")!==-1;return function(n,s){const o=t?Math.abs(n.x-s.x):0,r=e?Math.abs(n.y-s.y):0;return Math.sqrt(Math.pow(o,2)+Math.pow(r,2))}}function jn(i,t,e,n,s){const o=[];return!s&&!i.isPointInArea(t)||$i(i,e,t,function(a,l,c){!s&&!Ot(a,i.chartArea,0)||a.inRange(t.x,t.y,n)&&o.push({element:a,datasetIndex:l,index:c})},!0),o}function fu(i,t,e,n){let s=[];function o(r,a,l){const{startAngle:c,endAngle:h}=r.getProps(["startAngle","endAngle"],n),{angle:u}=Do(r,{x:t.x,y:t.y});je(u,c,h)&&s.push({element:r,datasetIndex:a,index:l})}return $i(i,e,t,o),s}function du(i,t,e,n,s,o){let r=[];const a=uu(e);let l=Number.POSITIVE_INFINITY;function c(h,u,f){const d=h.inRange(t.x,t.y,s);if(n&&!d)return;const g=h.getCenterPoint(s);if(!(!!o||i.isPointInArea(g))&&!d)return;const m=a(t,g);m<l?(r=[{element:h,datasetIndex:u,index:f}],l=m):m===l&&r.push({element:h,datasetIndex:u,index:f})}return $i(i,e,t,c),r}function Yn(i,t,e,n,s,o){return!o&&!i.isPointInArea(t)?[]:e==="r"&&!n?fu(i,t,e,s):du(i,t,e,n,s,o)}function vr(i,t,e,n,s){const o=[],r=e==="x"?"inXRange":"inYRange";let a=!1;return $i(i,e,t,(l,c,h)=>{l[r]&&l[r](t[e],s)&&(o.push({element:l,datasetIndex:c,index:h}),a=a||l.inRange(t.x,t.y,s))}),n&&!a?[]:o}var gu={modes:{index(i,t,e,n){const s=ae(t,i),o=e.axis||"x",r=e.includeInvisible||!1,a=e.intersect?jn(i,s,o,n,r):Yn(i,s,o,!1,n,r),l=[];return a.length?(i.getSortedVisibleDatasetMetas().forEach(c=>{const h=a[0].index,u=c.data[h];u&&!u.skip&&l.push({element:u,datasetIndex:c.index,index:h})}),l):[]},dataset(i,t,e,n){const s=ae(t,i),o=e.axis||"xy",r=e.includeInvisible||!1;let a=e.intersect?jn(i,s,o,n,r):Yn(i,s,o,!1,n,r);if(a.length>0){const l=a[0].datasetIndex,c=i.getDatasetMeta(l).data;a=[];for(let h=0;h<c.length;++h)a.push({element:c[h],datasetIndex:l,index:h})}return a},point(i,t,e,n){const s=ae(t,i),o=e.axis||"xy",r=e.includeInvisible||!1;return jn(i,s,o,n,r)},nearest(i,t,e,n){const s=ae(t,i),o=e.axis||"xy",r=e.includeInvisible||!1;return Yn(i,s,o,e.intersect,n,r)},x(i,t,e,n){const s=ae(t,i);return vr(i,s,"x",e.intersect,n)},y(i,t,e,n){const s=ae(t,i);return vr(i,s,"y",e.intersect,n)}}};const wr=["left","top","right","bottom"];function Ze(i,t){return i.filter(e=>e.pos===t)}function Mr(i,t){return i.filter(e=>wr.indexOf(e.pos)===-1&&e.box.axis===t)}function Je(i,t){return i.sort((e,n)=>{const s=t?n:e,o=t?e:n;return s.weight===o.weight?s.index-o.index:s.weight-o.weight})}function pu(i){const t=[];let e,n,s,o,r,a;for(e=0,n=(i||[]).length;e<n;++e)s=i[e],{position:o,options:{stack:r,stackWeight:a=1}}=s,t.push({index:e,box:s,pos:o,horizontal:s.isHorizontal(),weight:s.weight,stack:r&&o+r,stackWeight:a});return t}function mu(i){const t={};for(const e of i){const{stack:n,pos:s,stackWeight:o}=e;if(!n||!wr.includes(s))continue;const r=t[n]||(t[n]={count:0,placed:0,weight:0,size:0});r.count++,r.weight+=o}return t}function bu(i,t){const e=mu(i),{vBoxMaxWidth:n,hBoxMaxHeight:s}=t;let o,r,a;for(o=0,r=i.length;o<r;++o){a=i[o];const{fullSize:l}=a.box,c=e[a.stack],h=c&&a.stackWeight/c.weight;a.horizontal?(a.width=h?h*n:l&&t.availableWidth,a.height=s):(a.width=n,a.height=h?h*s:l&&t.availableHeight)}return e}function _u(i){const t=pu(i),e=Je(t.filter(c=>c.box.fullSize),!0),n=Je(Ze(t,"left"),!0),s=Je(Ze(t,"right")),o=Je(Ze(t,"top"),!0),r=Je(Ze(t,"bottom")),a=Mr(t,"x"),l=Mr(t,"y");return{fullSize:e,leftAndTop:n.concat(o),rightAndBottom:s.concat(l).concat(r).concat(a),chartArea:Ze(t,"chartArea"),vertical:n.concat(s).concat(l),horizontal:o.concat(r).concat(a)}}function kr(i,t,e,n){return Math.max(i[e],t[e])+Math.max(i[n],t[n])}function Sr(i,t){i.top=Math.max(i.top,t.top),i.left=Math.max(i.left,t.left),i.bottom=Math.max(i.bottom,t.bottom),i.right=Math.max(i.right,t.right)}function xu(i,t,e,n){const{pos:s,box:o}=e,r=i.maxPadding;if(!O(s)){e.size&&(i[s]-=e.size);const u=n[e.stack]||{size:0,count:1};u.size=Math.max(u.size,e.horizontal?o.height:o.width),e.size=u.size/u.count,i[s]+=e.size}o.getPadding&&Sr(r,o.getPadding());const a=Math.max(0,t.outerWidth-kr(r,i,"left","right")),l=Math.max(0,t.outerHeight-kr(r,i,"top","bottom")),c=a!==i.w,h=l!==i.h;return i.w=a,i.h=l,e.horizontal?{same:c,other:h}:{same:h,other:c}}function yu(i){const t=i.maxPadding;function e(n){const s=Math.max(t[n]-i[n],0);return i[n]+=s,s}i.y+=e("top"),i.x+=e("left"),e("right"),e("bottom")}function vu(i,t){const e=t.maxPadding;function n(s){const o={left:0,top:0,right:0,bottom:0};return s.forEach(r=>{o[r]=Math.max(t[r],e[r])}),o}return n(i?["left","right"]:["top","bottom"])}function Qe(i,t,e,n){const s=[];let o,r,a,l,c,h;for(o=0,r=i.length,c=0;o<r;++o){a=i[o],l=a.box,l.update(a.width||t.w,a.height||t.h,vu(a.horizontal,t));const{same:u,other:f}=xu(t,e,a,n);c|=u&&s.length,h=h||f,l.fullSize||s.push(a)}return c&&Qe(s,t,e,n)||h}function Bi(i,t,e,n,s){i.top=e,i.left=t,i.right=t+n,i.bottom=e+s,i.width=n,i.height=s}function Pr(i,t,e,n){const s=e.padding;let{x:o,y:r}=t;for(const a of i){const l=a.box,c=n[a.stack]||{placed:0,weight:1},h=a.stackWeight/c.weight||1;if(a.horizontal){const u=t.w*h,f=c.size||l.height;We(c.start)&&(r=c.start),l.fullSize?Bi(l,s.left,r,e.outerWidth-s.right-s.left,f):Bi(l,t.left+c.placed,r,u,f),c.start=r,c.placed+=u,r=l.bottom}else{const u=t.h*h,f=c.size||l.width;We(c.start)&&(o=c.start),l.fullSize?Bi(l,o,s.top,f,e.outerHeight-s.bottom-s.top):Bi(l,o,t.top+c.placed,f,u),c.start=o,c.placed+=u,o=l.right}}t.x=o,t.y=r}var J={addBox(i,t){i.boxes||(i.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(e){t.draw(e)}}]},i.boxes.push(t)},removeBox(i,t){const e=i.boxes?i.boxes.indexOf(t):-1;e!==-1&&i.boxes.splice(e,1)},configure(i,t,e){t.fullSize=e.fullSize,t.position=e.position,t.weight=e.weight},update(i,t,e,n){if(!i)return;const s=Z(i.options.layout.padding),o=Math.max(t-s.width,0),r=Math.max(e-s.height,0),a=_u(i.boxes),l=a.vertical,c=a.horizontal;I(i.boxes,p=>{typeof p.beforeLayout=="function"&&p.beforeLayout()});const h=l.reduce((p,m)=>m.box.options&&m.box.options.display===!1?p:p+1,0)||1,u=Object.freeze({outerWidth:t,outerHeight:e,padding:s,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/h,hBoxMaxHeight:r/2}),f=Object.assign({},s);Sr(f,Z(n));const d=Object.assign({maxPadding:f,w:o,h:r,x:s.left,y:s.top},s),g=bu(l.concat(c),u);Qe(a.fullSize,d,u,g),Qe(l,d,u,g),Qe(c,d,u,g)&&Qe(l,d,u,g),yu(d),Pr(a.leftAndTop,d,u,g),d.x+=d.w,d.y+=d.h,Pr(a.rightAndBottom,d,u,g),i.chartArea={left:d.left,top:d.top,right:d.left+d.w,bottom:d.top+d.h,height:d.h,width:d.w},I(a.chartArea,p=>{const m=p.box;Object.assign(m,i.chartArea),m.update(d.w,d.h,{left:0,top:0,right:0,bottom:0})})}};class Dr{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,n){}removeEventListener(t,e,n){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,n,s){return e=Math.max(0,e||t.width),n=n||t.height,{width:e,height:Math.max(0,s?Math.floor(e/s):n)}}isAttached(t){return!0}updateConfig(t){}}class wu extends Dr{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const Ni="$chartjs",Mu={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},Cr=i=>i===null||i==="";function ku(i,t){const e=i.style,n=i.getAttribute("height"),s=i.getAttribute("width");if(i[Ni]={initial:{height:n,width:s,style:{display:e.display,height:e.height,width:e.width}}},e.display=e.display||"block",e.boxSizing=e.boxSizing||"border-box",Cr(s)){const o=Jo(i,"width");o!==void 0&&(i.width=o)}if(Cr(n))if(i.style.height==="")i.height=i.width/(t||2);else{const o=Jo(i,"height");o!==void 0&&(i.height=o)}return i}const Ar=xh?{passive:!0}:!1;function Su(i,t,e){i&&i.addEventListener(t,e,Ar)}function Pu(i,t,e){i&&i.canvas&&i.canvas.removeEventListener(t,e,Ar)}function Du(i,t){const e=Mu[i.type]||i.type,{x:n,y:s}=ae(i,t);return{type:e,chart:t,native:i,x:n!==void 0?n:null,y:s!==void 0?s:null}}function Vi(i,t){for(const e of i)if(e===t||e.contains(t))return!0}function Cu(i,t,e){const n=i.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||Vi(a.addedNodes,n),r=r&&!Vi(a.removedNodes,n);r&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}function Au(i,t,e){const n=i.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||Vi(a.removedNodes,n),r=r&&!Vi(a.addedNodes,n);r&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}const ti=new Map;let Or=0;function Tr(){const i=window.devicePixelRatio;i!==Or&&(Or=i,ti.forEach((t,e)=>{e.currentDevicePixelRatio!==i&&t()}))}function Ou(i,t){ti.size||window.addEventListener("resize",Tr),ti.set(i,t)}function Tu(i){ti.delete(i),ti.size||window.removeEventListener("resize",Tr)}function Eu(i,t,e){const n=i.canvas,s=n&&$n(n);if(!s)return;const o=Eo((a,l)=>{const c=s.clientWidth;e(a,l),c<s.clientWidth&&e()},window),r=new ResizeObserver(a=>{const l=a[0],c=l.contentRect.width,h=l.contentRect.height;c===0&&h===0||o(c,h)});return r.observe(s),Ou(i,o),r}function Un(i,t,e){e&&e.disconnect(),t==="resize"&&Tu(i)}function Lu(i,t,e){const n=i.canvas,s=Eo(o=>{i.ctx!==null&&e(Du(o,i))},i);return Su(n,t,s),s}class Ru extends Dr{acquireContext(t,e){const n=t&&t.getContext&&t.getContext("2d");return n&&n.canvas===t?(ku(t,e),n):null}releaseContext(t){const e=t.canvas;if(!e[Ni])return!1;const n=e[Ni].initial;["height","width"].forEach(o=>{const r=n[o];A(r)?e.removeAttribute(o):e.setAttribute(o,r)});const s=n.style||{};return Object.keys(s).forEach(o=>{e.style[o]=s[o]}),e.width=e.width,delete e[Ni],!0}addEventListener(t,e,n){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),r={attach:Cu,detach:Au,resize:Eu}[e]||Lu;s[e]=r(t,e,n)}removeEventListener(t,e){const n=t.$proxies||(t.$proxies={}),s=n[e];if(!s)return;({attach:Un,detach:Un,resize:Un}[e]||Pu)(t,e,s),n[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,n,s){return _h(t,e,n,s)}isAttached(t){const e=t&&$n(t);return!!(e&&e.isConnected)}}function Iu(i){return!zn()||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?wu:Ru}let Et=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}hasValue(){return ke(this.x)&&ke(this.y)}getProps(t,e){const n=this.$animations;if(!e||!n)return this;const s={};return t.forEach(o=>{s[o]=n[o]&&n[o].active()?n[o]._to:this[o]}),s}};function Fu(i,t){const e=i.options.ticks,n=zu(i),s=Math.min(e.maxTicksLimit||n,n),o=e.major.enabled?Bu(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>s)return Nu(t,c,o,r/s),c;const h=$u(o,t,s);if(r>0){let u,f;const d=r>1?Math.round((l-a)/(r-1)):null;for(Wi(t,c,h,A(d)?0:a-d,a),u=0,f=r-1;u<f;u++)Wi(t,c,h,o[u],o[u+1]);return Wi(t,c,h,l,A(d)?t.length:l+d),c}return Wi(t,c,h),c}function zu(i){const t=i.options.offset,e=i._tickSize(),n=i._length/e+(t?0:1),s=i._maxLength/e;return Math.floor(Math.min(n,s))}function $u(i,t,e){const n=Vu(i),s=t.length/e;if(!n)return Math.max(s,1);const o=vc(n);for(let r=0,a=o.length-1;r<a;r++){const l=o[r];if(l>s)return l}return Math.max(s,1)}function Bu(i){const t=[];let e,n;for(e=0,n=i.length;e<n;e++)i[e].major&&t.push(e);return t}function Nu(i,t,e,n){let s=0,o=e[0],r;for(n=Math.ceil(n),r=0;r<i.length;r++)r===o&&(t.push(i[r]),s++,o=e[s*n])}function Wi(i,t,e,n,s){const o=P(n,0),r=Math.min(P(s,i.length),i.length);let a=0,l,c,h;for(e=Math.ceil(e),s&&(l=s-n,e=l/Math.floor(l/e)),h=o;h<0;)a++,h=Math.round(o+a*e);for(c=Math.max(o,0);c<r;c++)c===h&&(t.push(i[c]),a++,h=Math.round(o+a*e))}function Vu(i){const t=i.length;let e,n;if(t<2)return!1;for(n=i[0],e=1;e<t;++e)if(i[e]-i[e-1]!==n)return!1;return n}const Wu=i=>i==="left"?"right":i==="right"?"left":i,Er=(i,t,e)=>t==="top"||t==="left"?i[t]+e:i[t]-e,Lr=(i,t)=>Math.min(t||i,i);function Rr(i,t){const e=[],n=i.length/t,s=i.length;let o=0;for(;o<s;o+=n)e.push(i[Math.floor(o)]);return e}function Hu(i,t,e){const n=i.ticks.length,s=Math.min(t,n-1),o=i._startPixel,r=i._endPixel,a=1e-6;let l=i.getPixelForTick(s),c;if(!(e&&(n===1?c=Math.max(l-o,r-l):t===0?c=(i.getPixelForTick(1)-l)/2:c=(l-i.getPixelForTick(s-1))/2,l+=s<t?c:-c,l<o-a||l>r+a)))return l}function ju(i,t){I(i,e=>{const n=e.gc,s=n.length/2;let o;if(s>t){for(o=0;o<s;++o)delete e.data[n[o]];n.splice(0,s)}})}function ei(i){return i.drawTicks?i.tickLength:0}function Ir(i,t){if(!i.display)return 0;const e=Y(i.font,t),n=Z(i.padding);return(B(i.text)?i.text.length:1)*e.lineHeight+n.height}function Yu(i,t){return Xt(i,{scale:t,type:"scale"})}function Uu(i,t,e){return Xt(i,{tick:e,index:t,type:"tick"})}function Xu(i,t,e){let n=Dn(i);return(e&&t!=="right"||!e&&t==="right")&&(n=Wu(n)),n}function qu(i,t,e,n){const{top:s,left:o,bottom:r,right:a,chart:l}=i,{chartArea:c,scales:h}=l;let u=0,f,d,g;const p=r-s,m=a-o;if(i.isHorizontal()){if(d=G(n,o,a),O(e)){const b=Object.keys(e)[0],_=e[b];g=h[b].getPixelForValue(_)+p-t}else e==="center"?g=(c.bottom+c.top)/2+p-t:g=Er(i,e,t);f=a-o}else{if(O(e)){const b=Object.keys(e)[0],_=e[b];d=h[b].getPixelForValue(_)-m+t}else e==="center"?d=(c.left+c.right)/2-m+t:d=Er(i,e,t);g=G(n,r,s),u=e==="left"?-H:H}return{titleX:d,titleY:g,maxWidth:f,rotation:u}}class he extends Et{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:n,_suggestedMax:s}=this;return t=ct(t,Number.POSITIVE_INFINITY),e=ct(e,Number.NEGATIVE_INFINITY),n=ct(n,Number.POSITIVE_INFINITY),s=ct(s,Number.NEGATIVE_INFINITY),{min:ct(t,n),max:ct(e,s),minDefined:V(t),maxDefined:V(e)}}getMinMax(t){let{min:e,max:n,minDefined:s,maxDefined:o}=this.getUserBounds(),r;if(s&&o)return{min:e,max:n};const a=this.getMatchingVisibleMetas();for(let l=0,c=a.length;l<c;++l)r=a[l].controller.getMinMax(this,t),s||(e=Math.min(e,r.min)),o||(n=Math.max(n,r.max));return e=o&&e>n?n:e,n=s&&e>n?e:n,{min:ct(e,ct(n,e)),max:ct(n,ct(e,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){z(this.options.beforeUpdate,[this])}update(t,e,n){const{beginAtZero:s,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Gc(this,o,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a<this.ticks.length;this._convertTicksToLabels(l?Rr(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),r.display&&(r.autoSkip||r.source==="auto")&&(this.ticks=Fu(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),l&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,e,n;this.isHorizontal()?(e=this.left,n=this.right):(e=this.top,n=this.bottom,t=!t),this._startPixel=e,this._endPixel=n,this._reversePixels=t,this._length=n-e,this._alignToPixels=this.options.alignToPixels}afterUpdate(){z(this.options.afterUpdate,[this])}beforeSetDimensions(){z(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){z(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),z(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){z(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const e=this.options.ticks;let n,s,o;for(n=0,s=t.length;n<s;n++)o=t[n],o.label=z(e.callback,[o.value,n,t],this)}afterTickToLabelConversion(){z(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){z(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,e=t.ticks,n=Lr(this.ticks.length,t.ticks.maxTicksLimit),s=e.minRotation||0,o=e.maxRotation;let r=s,a,l,c;if(!this._isVisible()||!e.display||s>=o||n<=1||!this.isHorizontal()){this.labelRotation=s;return}const h=this._getLabelSizes(),u=h.widest.width,f=h.highest.height,d=X(this.chart.width-u,0,this.maxWidth);a=t.offset?this.maxWidth/n:d/(n-1),u+6>a&&(a=d/(n-(t.offset?.5:1)),l=this.maxHeight-ei(t.grid)-e.padding-Ir(t.title,this.chart.options.font),c=Math.sqrt(u*u+f*f),r=kn(Math.min(Math.asin(X((h.highest.height+6)/a,-1,1)),Math.asin(X(l/c,-1,1))-Math.asin(X(f/c,-1,1)))),r=Math.max(s,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){z(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){z(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:n,title:s,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const l=Ir(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=ei(o)+l):(t.height=this.maxHeight,t.width=ei(o)+l),n.display&&this.ticks.length){const{first:c,last:h,widest:u,highest:f}=this._getLabelSizes(),d=n.padding*2,g=_t(this.labelRotation),p=Math.cos(g),m=Math.sin(g);if(a){const b=n.mirror?0:m*u.width+p*f.height;t.height=Math.min(this.maxHeight,t.height+b+d)}else{const b=n.mirror?0:p*u.width+m*f.height;t.width=Math.min(this.maxWidth,t.width+b+d)}this._calculatePadding(c,h,m,p)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,n,s){const{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const h=this.getPixelForTick(0)-this.left,u=this.right-this.getPixelForTick(this.ticks.length-1);let f=0,d=0;l?c?(f=s*t.width,d=n*e.height):(f=n*t.height,d=s*e.width):o==="start"?d=e.width:o==="end"?f=t.width:o!=="inner"&&(f=t.width/2,d=e.width/2),this.paddingLeft=Math.max((f-h+r)*this.width/(this.width-h),0),this.paddingRight=Math.max((d-u+r)*this.width/(this.width-u),0)}else{let h=e.height/2,u=t.height/2;o==="start"?(h=0,u=t.height):o==="end"&&(h=e.height,u=0),this.paddingTop=h+r,this.paddingBottom=u+r}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){z(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let e,n;for(e=0,n=t.length;e<n;e++)A(t[e].label)&&(t.splice(e,1),n--,e--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const e=this.options.ticks.sampleSize;let n=this.ticks;e<n.length&&(n=Rr(n,e)),this._labelSizes=t=this._computeLabelSizes(n,n.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,e,n){const{ctx:s,_longestTextCache:o}=this,r=[],a=[],l=Math.floor(e/Lr(e,n));let c=0,h=0,u,f,d,g,p,m,b,_,y,v,x;for(u=0;u<e;u+=l){if(g=t[u].label,p=this._resolveTickFontOptions(u),s.font=m=p.string,b=o[m]=o[m]||{data:{},gc:[]},_=p.lineHeight,y=v=0,!A(g)&&!B(g))y=Oi(s,b.data,b.gc,y,g),v=_;else if(B(g))for(f=0,d=g.length;f<d;++f)x=g[f],!A(x)&&!B(x)&&(y=Oi(s,b.data,b.gc,y,x),v+=_);r.push(y),a.push(v),c=Math.max(y,c),h=Math.max(v,h)}ju(o,e);const w=r.indexOf(c),M=a.indexOf(h),k=S=>({width:r[S]||0,height:a[S]||0});return{first:k(0),last:k(e-1),widest:k(w),highest:k(M),widths:r,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return Sc(this._alignToPixels?ne(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&t<e.length){const n=e[t];return n.$context||(n.$context=Uu(this.getContext(),t,n))}return this.$context||(this.$context=Yu(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,e=_t(this.labelRotation),n=Math.abs(Math.cos(e)),s=Math.abs(Math.sin(e)),o=this._getLabelSizes(),r=t.autoSkipPadding||0,a=o?o.widest.width+r:0,l=o?o.highest.height+r:0;return this.isHorizontal()?l*n>a*s?a/n:l/s:l*s<a*n?l/n:a/s}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const e=this.axis,n=this.chart,s=this.options,{grid:o,position:r,border:a}=s,l=o.offset,c=this.isHorizontal(),u=this.ticks.length+(l?1:0),f=ei(o),d=[],g=a.setContext(this.getContext()),p=g.display?g.width:0,m=p/2,b=function(N){return ne(n,N,p)};let _,y,v,x,w,M,k,S,D,C,T,q;if(r==="top")_=b(this.bottom),M=this.bottom-f,S=_-m,C=b(t.top)+m,q=t.bottom;else if(r==="bottom")_=b(this.top),C=t.top,q=b(t.bottom)-m,M=_+m,S=this.top+f;else if(r==="left")_=b(this.right),w=this.right-f,k=_-m,D=b(t.left)+m,T=t.right;else if(r==="right")_=b(this.left),D=t.left,T=b(t.right)-m,w=_+m,k=this.left+f;else if(e==="x"){if(r==="center")_=b((t.top+t.bottom)/2+.5);else if(O(r)){const N=Object.keys(r)[0],j=r[N];_=b(this.chart.scales[N].getPixelForValue(j))}C=t.top,q=t.bottom,M=_+m,S=M+f}else if(e==="y"){if(r==="center")_=b((t.left+t.right)/2);else if(O(r)){const N=Object.keys(r)[0],j=r[N];_=b(this.chart.scales[N].getPixelForValue(j))}w=_-m,k=w-f,D=t.left,T=t.right}const ht=P(s.ticks.maxTicksLimit,u),F=Math.max(1,Math.ceil(u/ht));for(y=0;y<u;y+=F){const N=this.getContext(y),j=o.setContext(N),xt=a.setContext(N),Q=j.lineWidth,Ae=j.color,tn=xt.dash||[],Oe=xt.dashOffset,oi=j.tickWidth,fe=j.tickColor,ri=j.tickBorderDash||[],de=j.tickBorderDashOffset;v=Hu(this,y,l),v!==void 0&&(x=ne(n,v,Q),c?w=k=D=T=x:M=S=C=q=x,d.push({tx1:w,ty1:M,tx2:k,ty2:S,x1:D,y1:C,x2:T,y2:q,width:Q,color:Ae,borderDash:tn,borderDashOffset:Oe,tickWidth:oi,tickColor:fe,tickBorderDash:ri,tickBorderDashOffset:de}))}return this._ticksLength=u,this._borderValue=_,d}_computeLabelItems(t){const e=this.axis,n=this.options,{position:s,ticks:o}=n,r=this.isHorizontal(),a=this.ticks,{align:l,crossAlign:c,padding:h,mirror:u}=o,f=ei(n.grid),d=f+h,g=u?-h:d,p=-_t(this.labelRotation),m=[];let b,_,y,v,x,w,M,k,S,D,C,T,q="middle";if(s==="top")w=this.bottom-g,M=this._getXAxisLabelAlignment();else if(s==="bottom")w=this.top+g,M=this._getXAxisLabelAlignment();else if(s==="left"){const F=this._getYAxisLabelAlignment(f);M=F.textAlign,x=F.x}else if(s==="right"){const F=this._getYAxisLabelAlignment(f);M=F.textAlign,x=F.x}else if(e==="x"){if(s==="center")w=(t.top+t.bottom)/2+d;else if(O(s)){const F=Object.keys(s)[0],N=s[F];w=this.chart.scales[F].getPixelForValue(N)+d}M=this._getXAxisLabelAlignment()}else if(e==="y"){if(s==="center")x=(t.left+t.right)/2-d;else if(O(s)){const F=Object.keys(s)[0],N=s[F];x=this.chart.scales[F].getPixelForValue(N)}M=this._getYAxisLabelAlignment(f).textAlign}e==="y"&&(l==="start"?q="top":l==="end"&&(q="bottom"));const ht=this._getLabelSizes();for(b=0,_=a.length;b<_;++b){y=a[b],v=y.label;const F=o.setContext(this.getContext(b));k=this.getPixelForTick(b)+o.labelOffset,S=this._resolveTickFontOptions(b),D=S.lineHeight,C=B(v)?v.length:1;const N=C/2,j=F.color,xt=F.textStrokeColor,Q=F.textStrokeWidth;let Ae=M;r?(x=k,M==="inner"&&(b===_-1?Ae=this.options.reverse?"left":"right":b===0?Ae=this.options.reverse?"right":"left":Ae="center"),s==="top"?c==="near"||p!==0?T=-C*D+D/2:c==="center"?T=-ht.highest.height/2-N*D+D:T=-ht.highest.height+D/2:c==="near"||p!==0?T=D/2:c==="center"?T=ht.highest.height/2-N*D:T=ht.highest.height-C*D,u&&(T*=-1),p!==0&&!F.showLabelBackdrop&&(x+=D/2*Math.sin(p))):(w=k,T=(1-C)*D/2);let tn;if(F.showLabelBackdrop){const Oe=Z(F.backdropPadding),oi=ht.heights[b],fe=ht.widths[b];let ri=T-Oe.top,de=0-Oe.left;switch(q){case"middle":ri-=oi/2;break;case"bottom":ri-=oi;break}switch(M){case"center":de-=fe/2;break;case"right":de-=fe;break;case"inner":b===_-1?de-=fe:b>0&&(de-=fe/2);break}tn={left:de,top:ri,width:fe+Oe.width,height:oi+Oe.height,color:F.backdropColor}}m.push({label:v,font:S,textOffset:T,options:{rotation:p,color:j,strokeColor:xt,strokeWidth:Q,textAlign:Ae,textBaseline:q,translation:[x,w],backdrop:tn}})}return m}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-_t(this.labelRotation))return t==="top"?"left":"right";let s="center";return e.align==="start"?s="left":e.align==="end"?s="right":e.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:n,mirror:s,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,l=r.widest.width;let c,h;return e==="left"?s?(h=this.right+o,n==="near"?c="left":n==="center"?(c="center",h+=l/2):(c="right",h+=l)):(h=this.right-a,n==="near"?c="right":n==="center"?(c="center",h-=l/2):(c="left",h=this.left)):e==="right"?s?(h=this.left+o,n==="near"?c="right":n==="center"?(c="center",h-=l/2):(c="left",h-=l)):(h=this.left+a,n==="near"?c="left":n==="center"?(c="center",h+=l/2):(c="right",h=this.right)):c="right",{textAlign:c,x:h}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;if(e==="left"||e==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(e==="top"||e==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:n,top:s,width:o,height:r}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(n,s,o,r),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const s=this.ticks.findIndex(o=>o.value===t);return s>=0?e.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){const e=this.options.grid,n=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(l,c,h)=>{!h.width||!h.color||(n.save(),n.lineWidth=h.width,n.strokeStyle=h.color,n.setLineDash(h.borderDash||[]),n.lineDashOffset=h.borderDashOffset,n.beginPath(),n.moveTo(l.x,l.y),n.lineTo(c.x,c.y),n.stroke(),n.restore())};if(e.display)for(o=0,r=s.length;o<r;++o){const l=s[o];e.drawOnChartArea&&a({x:l.x1,y:l.y1},{x:l.x2,y:l.y2},l),e.drawTicks&&a({x:l.tx1,y:l.ty1},{x:l.tx2,y:l.ty2},{color:l.tickColor,width:l.tickWidth,borderDash:l.tickBorderDash,borderDashOffset:l.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:e,options:{border:n,grid:s}}=this,o=n.setContext(this.getContext()),r=n.display?o.width:0;if(!r)return;const a=s.setContext(this.getContext(0)).lineWidth,l=this._borderValue;let c,h,u,f;this.isHorizontal()?(c=ne(t,this.left,r)-r/2,h=ne(t,this.right,a)+a/2,u=f=l):(u=ne(t,this.top,r)-r/2,f=ne(t,this.bottom,a)+a/2,c=h=l),e.save(),e.lineWidth=o.width,e.strokeStyle=o.color,e.beginPath(),e.moveTo(c,u),e.lineTo(h,f),e.stroke(),e.restore()}drawLabels(t){if(!this.options.ticks.display)return;const n=this.ctx,s=this._computeLabelArea();s&&Ti(n,s);const o=this.getLabelItems(t);for(const r of o){const a=r.options,l=r.font,c=r.label,h=r.textOffset;se(n,c,0,h,l,a)}s&&Ei(n)}drawTitle(){const{ctx:t,options:{position:e,title:n,reverse:s}}=this;if(!n.display)return;const o=Y(n.font),r=Z(n.padding),a=n.align;let l=o.lineHeight/2;e==="bottom"||e==="center"||O(e)?(l+=r.bottom,B(n.text)&&(l+=o.lineHeight*(n.text.length-1))):l+=r.top;const{titleX:c,titleY:h,maxWidth:u,rotation:f}=qu(this,l,e,a);se(t,n.text,0,0,o,{color:n.color,maxWidth:u,rotation:f,textAlign:Xu(a,e,s),textBaseline:"middle",translation:[c,h]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,e=t.ticks&&t.ticks.z||0,n=P(t.grid&&t.grid.z,-1),s=P(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==he.prototype.draw?[{z:e,draw:o=>{this.draw(o)}}]:[{z:n,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",s=[];let o,r;for(o=0,r=e.length;o<r;++o){const a=e[o];a[n]===this.id&&(!t||a.type===t)&&s.push(a)}return s}_resolveTickFontOptions(t){const e=this.options.ticks.setContext(this.getContext(t));return Y(e.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class Hi{constructor(t,e,n){this.type=t,this.scope=e,this.override=n,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const e=Object.getPrototypeOf(t);let n;Zu(e)&&(n=this.register(e));const s=this.items,o=t.id,r=this.scope+"."+o;if(!o)throw new Error("class does not have id: "+t);return o in s||(s[o]=t,Ku(t,r,n),this.override&&W.override(t.id,t.overrides)),r}get(t){return this.items[t]}unregister(t){const e=this.items,n=t.id,s=this.scope;n in e&&delete e[n],s&&n in W[s]&&(delete W[s][n],this.override&&delete ie[n])}}function Ku(i,t,e){const n=Ne(Object.create(null),[e?W.get(e):{},W.get(t),i.defaults]);W.set(t,n),i.defaultRoutes&&Gu(t,i.defaultRoutes),i.descriptors&&W.describe(t,i.descriptors)}function Gu(i,t){Object.keys(t).forEach(e=>{const n=e.split("."),s=n.pop(),o=[i].concat(n).join("."),r=t[e].split("."),a=r.pop(),l=r.join(".");W.route(o,s,l,a)})}function Zu(i){return"id"in i&&"defaults"in i}class Ju{constructor(){this.controllers=new Hi(qt,"datasets",!0),this.elements=new Hi(Et,"elements"),this.plugins=new Hi(Object,"plugins"),this.scales=new Hi(he,"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,n){[...e].forEach(s=>{const o=n||this._getRegistryForType(s);n||o.isForType(s)||o===this.plugins&&s.id?this._exec(t,o,s):I(s,r=>{const a=n||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,e,n){const s=Mn(t);z(n["before"+s],[],n),e[t](n),z(n["after"+s],[],n)}_getRegistryForType(t){for(let e=0;e<this._typedRegistries.length;e++){const n=this._typedRegistries[e];if(n.isForType(t))return n}return this.plugins}_get(t,e,n){const s=e.get(t);if(s===void 0)throw new Error('"'+t+'" is not a registered '+n+".");return s}}var wt=new Ju;class Qu{constructor(){this._init=[]}notify(t,e,n,s){e==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install"));const o=s?this._descriptors(t).filter(s):this._descriptors(t),r=this._notify(o,t,e,n);return e==="afterDestroy"&&(this._notify(o,t,"stop"),this._notify(this._init,t,"uninstall")),r}_notify(t,e,n,s){s=s||{};for(const o of t){const r=o.plugin,a=r[n],l=[e,s,o.options];if(z(a,l,r)===!1&&s.cancelable)return!1}return!0}invalidate(){A(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const e=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),e}_createDescriptors(t,e){const n=t&&t.config,s=P(n.options&&n.options.plugins,{}),o=tf(n);return s===!1&&!e?[]:nf(t,o,s,e)}_notifyStateChanges(t){const e=this._oldCache||[],n=this._cache,s=(o,r)=>o.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(s(e,n),t,"stop"),this._notify(s(n,e),t,"start")}}function tf(i){const t={},e=[],n=Object.keys(wt.plugins.items);for(let o=0;o<n.length;o++)e.push(wt.getPlugin(n[o]));const s=i.plugins||[];for(let o=0;o<s.length;o++){const r=s[o];e.indexOf(r)===-1&&(e.push(r),t[r.id]=!0)}return{plugins:e,localIds:t}}function ef(i,t){return!t&&i===!1?null:i===!0?{}:i}function nf(i,{plugins:t,localIds:e},n,s){const o=[],r=i.getContext();for(const a of t){const l=a.id,c=ef(n[l],s);c!==null&&o.push({plugin:a,options:sf(i.config,{plugin:a,local:e[l]},c,r)})}return o}function sf(i,{plugin:t,local:e},n,s){const o=i.pluginScopeKeys(t),r=i.getOptionScopes(n,o);return e&&t.defaults&&r.push(t.defaults),i.createResolver(r,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Xn(i,t){const e=W.datasets[i]||{};return((t.datasets||{})[i]||{}).indexAxis||t.indexAxis||e.indexAxis||"x"}function of(i,t){let e=i;return i==="_index_"?e=t:i==="_value_"&&(e=t==="x"?"y":"x"),e}function rf(i,t){return i===t?"_index_":"_value_"}function Fr(i){if(i==="x"||i==="y"||i==="r")return i}function af(i){if(i==="top"||i==="bottom")return"x";if(i==="left"||i==="right")return"y"}function qn(i,...t){if(Fr(i))return i;for(const e of t){const n=e.axis||af(e.position)||i.length>1&&Fr(i[0].toLowerCase());if(n)return n}throw new Error(`Cannot determine type of '${i}' axis. Please provide 'axis' or 'position' option.`)}function zr(i,t,e){if(e[t+"AxisID"]===i)return{axis:t}}function lf(i,t){if(t.data&&t.data.datasets){const e=t.data.datasets.filter(n=>n.xAxisID===i||n.yAxisID===i);if(e.length)return zr(i,"x",e[0])||zr(i,"y",e[0])}return{}}function cf(i,t){const e=ie[i.type]||{scales:{}},n=t.scales||{},s=Xn(i.type,t),o=Object.create(null);return Object.keys(n).forEach(r=>{const a=n[r];if(!O(a))return console.error(`Invalid scale configuration for scale: ${r}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);const l=qn(r,a,lf(r,i),W.scales[a.type]),c=rf(l,s),h=e.scales||{};o[r]=Ve(Object.create(null),[{axis:l},a,h[l],h[c]])}),i.data.datasets.forEach(r=>{const a=r.type||i.type,l=r.indexAxis||Xn(a,t),h=(ie[a]||{}).scales||{};Object.keys(h).forEach(u=>{const f=of(u,l),d=r[f+"AxisID"]||f;o[d]=o[d]||Object.create(null),Ve(o[d],[{axis:f},n[d],h[u]])})}),Object.keys(o).forEach(r=>{const a=o[r];Ve(a,[W.scales[a.type],W.scale])}),o}function $r(i){const t=i.options||(i.options={});t.plugins=P(t.plugins,{}),t.scales=cf(i,t)}function Br(i){return i=i||{},i.datasets=i.datasets||[],i.labels=i.labels||[],i}function hf(i){return i=i||{},i.data=Br(i.data),$r(i),i}const Nr=new Map,Vr=new Set;function ji(i,t){let e=Nr.get(i);return e||(e=t(),Nr.set(i,e),Vr.add(e)),e}const ii=(i,t,e)=>{const n=jt(t,e);n!==void 0&&i.add(n)};class uf{constructor(t){this._config=hf(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Br(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(),$r(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return ji(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return ji(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return ji(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id,n=this.type;return ji(`${n}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const n=this._scopeCache;let s=n.get(t);return(!s||e)&&(s=new Map,n.set(t,s)),s}getOptionScopes(t,e,n){const{options:s,type:o}=this,r=this._cachedScopes(t,n),a=r.get(e);if(a)return a;const l=new Set;e.forEach(h=>{t&&(l.add(t),h.forEach(u=>ii(l,t,u))),h.forEach(u=>ii(l,s,u)),h.forEach(u=>ii(l,ie[o]||{},u)),h.forEach(u=>ii(l,W,u)),h.forEach(u=>ii(l,On,u))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),Vr.has(e)&&r.set(e,c),c}chartOptionScopes(){const{options:t,type:e}=this;return[t,ie[e]||{},W.datasets[e]||{},{type:e},W,On]}resolveNamedOptions(t,e,n,s=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=Wr(this._resolverCache,t,s);let l=r;if(df(r,e)){o.$shared=!1,n=Yt(n)?n():n;const c=this.createResolver(t,n,a);l=Se(r,n,c)}for(const c of e)o[c]=l[c];return o}createResolver(t,e,n=[""],s){const{resolver:o}=Wr(this._resolverCache,t,n);return O(e)?Se(o,e,void 0,s):o}}function Wr(i,t,e){let n=i.get(t);n||(n=new Map,i.set(t,n));const s=e.join();let o=n.get(s);return o||(o={resolver:Rn(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},n.set(s,o)),o}const ff=i=>O(i)&&Object.getOwnPropertyNames(i).some(t=>Yt(i[t]));function df(i,t){const{isScriptable:e,isIndexable:n}=Ho(i);for(const s of t){const o=e(s),r=n(s),a=(r||o)&&i[s];if(o&&(Yt(a)||ff(a))||r&&B(a))return!0}return!1}var gf="4.5.0";const pf=["top","bottom","left","right","chartArea"];function Hr(i,t){return i==="top"||i==="bottom"||pf.indexOf(i)===-1&&t==="x"}function jr(i,t){return function(e,n){return e[i]===n[i]?e[t]-n[t]:e[i]-n[i]}}function Yr(i){const t=i.chart,e=t.options.animation;t.notifyPlugins("afterRender"),z(e&&e.onComplete,[i],t)}function mf(i){const t=i.chart,e=t.options.animation;z(e&&e.onProgress,[i],t)}function Ur(i){return zn()&&typeof i=="string"?i=document.getElementById(i):i&&i.length&&(i=i[0]),i&&i.canvas&&(i=i.canvas),i}const Yi={},Xr=i=>{const t=Ur(i);return Object.values(Yi).filter(e=>e.canvas===t).pop()};function bf(i,t,e){const n=Object.keys(i);for(const s of n){const o=+s;if(o>=t){const r=i[s];delete i[s],(e>0||o>t)&&(i[o+e]=r)}}}function _f(i,t,e,n){return!e||i.type==="mouseout"?null:n?t:i}class Kn{static defaults=W;static instances=Yi;static overrides=ie;static registry=wt;static version=gf;static getChart=Xr;static register(...t){wt.add(...t),qr()}static unregister(...t){wt.remove(...t),qr()}constructor(t,e){const n=this.config=new uf(e),s=Ur(t),o=Xr(s);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const r=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||Iu(s)),this.platform.updateConfig(n);const a=this.platform.acquireContext(s,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,h=l&&l.width;if(this.id=fc(),this.ctx=a,this.canvas=l,this.width=h,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Qu,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Ac(u=>this.update(u),r.resizeDelay||0),this._dataChanges=[],Yi[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}Tt.listen(this,"complete",Yr),Tt.listen(this,"progress",mf),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:n,height:s,_aspectRatio:o}=this;return A(t)?e&&o?o:s?n/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return wt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Zo(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return No(this.canvas,this.ctx),this}stop(){return Tt.stop(this),this}resize(t,e){Tt.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const n=this.options,s=this.canvas,o=n.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,t,e,o),a=n.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,Zo(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),z(n.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const e=this.options.scales||{};I(e,(n,s)=>{n.id=s})}buildOrUpdateScales(){const t=this.options,e=t.scales,n=this.scales,s=Object.keys(n).reduce((r,a)=>(r[a]=!1,r),{});let o=[];e&&(o=o.concat(Object.keys(e).map(r=>{const a=e[r],l=qn(r,a),c=l==="r",h=l==="x";return{options:a,dposition:c?"chartArea":h?"bottom":"left",dtype:c?"radialLinear":h?"category":"linear"}}))),I(o,r=>{const a=r.options,l=a.id,c=qn(l,a),h=P(a.type,r.dtype);(a.position===void 0||Hr(a.position,c)!==Hr(r.dposition))&&(a.position=r.dposition),s[l]=!0;let u=null;if(l in n&&n[l].type===h)u=n[l];else{const f=wt.getScale(h);u=new f({id:l,type:h,ctx:this.ctx,chart:this}),n[u.id]=u}u.init(a,t)}),I(s,(r,a)=>{r||delete n[a]}),I(n,r=>{J.configure(this,r,r.options),J.addBox(this,r)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,n=t.length;if(t.sort((s,o)=>s.index-o.index),n>e){for(let s=e;s<n;++s)this._destroyDatasetMeta(s);t.splice(e,n-e)}this._sortedMetasets=t.slice(0).sort(jr("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:e}}=this;t.length>e.length&&delete this._stacks,t.forEach((n,s)=>{e.filter(o=>o===n._dataset).length===0&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let n,s;for(this._removeUnreferencedMetasets(),n=0,s=e.length;n<s;n++){const o=e[n];let r=this.getDatasetMeta(n);const a=o.type||this.config.type;if(r.type&&r.type!==a&&(this._destroyDatasetMeta(n),r=this.getDatasetMeta(n)),r.type=a,r.indexAxis=o.indexAxis||Xn(a,this.options),r.order=o.order||0,r.index=n,r.label=""+o.label,r.visible=this.isDatasetVisible(n),r.controller)r.controller.updateIndex(n),r.controller.linkScales();else{const l=wt.getController(a),{datasetElementType:c,dataElementType:h}=W.datasets[a];Object.assign(l,{dataElementType:wt.getElement(h),datasetElementType:c&&wt.getElement(c)}),r.controller=new l(this,n),t.push(r.controller)}}return this._updateMetasets(),t}_resetElements(){I(this.data.datasets,(t,e)=>{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const n=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let c=0,h=this.data.datasets.length;c<h;c++){const{controller:u}=this.getDatasetMeta(c),f=!s&&o.indexOf(u)===-1;u.buildOrUpdateElements(f),r=Math.max(+u.getMaxOverflow(),r)}r=this._minPadding=n.layout.autoPadding?r:0,this._updateLayout(r),s||I(o,c=>{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(jr("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){I(this.scales,t=>{J.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),n=new Set(t.events);(!wo(e,n)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:n,start:s,count:o}of e){const r=n==="_removeElements"?-o:o;bf(t,s,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,n=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),s=n(0);for(let o=1;o<e;o++)if(!wo(s,n(o)))return;return Array.from(s).map(o=>o.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;J.update(this,this.width,this.height,t);const e=this.chartArea,n=e.width<=0||e.height<=0;this._layers=[],I(this.boxes,s=>{n&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,o)=>{s._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,n=this.data.datasets.length;e<n;++e)this.getDatasetMeta(e).controller.configure();for(let e=0,n=this.data.datasets.length;e<n;++e)this._updateDataset(e,Yt(t)?t({datasetIndex:e}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,e){const n=this.getDatasetMeta(t),s={meta:n,index:t,mode:e,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",s)!==!1&&(n.controller._update(e),s.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",s))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(Tt.has(this)?this.attached&&!Tt.running(this)&&Tt.start(this):(this.draw(),Yr({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:n,height:s}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(n,s)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;const e=this._layers;for(t=0;t<e.length&&e[t].z<=0;++t)e[t].draw(this.chartArea);for(this._drawDatasets();t<e.length;++t)e[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const e=this._sortedMetasets,n=[];let s,o;for(s=0,o=e.length;s<o;++s){const r=e[s];(!t||r.visible)&&n.push(r)}return n}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;const t=this.getSortedVisibleDatasetMetas();for(let e=t.length-1;e>=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,n={meta:t,index:t.index,cancelable:!0},s=ar(this,t);this.notifyPlugins("beforeDatasetDraw",n)!==!1&&(s&&Ti(e,s),t.controller.draw(),s&&Ei(e),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(t){return Ot(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,n,s){const o=gu.modes[e];return typeof o=="function"?o(this,t,n,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],n=this._metasets;let s=n.filter(o=>o&&o._dataset===e).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},n.push(s)),s}getContext(){return this.$context||(this.$context=Xt(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const n=this.getDatasetMeta(t);return typeof n.hidden=="boolean"?!n.hidden:!e.hidden}setDatasetVisibility(t,e){const n=this.getDatasetMeta(t);n.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,n){const s=n?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,s);We(e)?(o.data[e].hidden=!n,this.update()):(this.setDatasetVisibility(t,n),r.update(o,{visible:n}),this.update(a=>a.datasetIndex===t?s:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),Tt.remove(this),t=0,e=this.data.datasets.length;t<e;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:e}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),No(t,e),this.platform.releaseContext(e),this.canvas=null,this.ctx=null),delete Yi[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,e=this.platform,n=(o,r)=>{e.addEventListener(this,o,r),t[o]=r},s=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};I(this.options.events,o=>n(o,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,n=(l,c)=>{e.addEventListener(this,l,c),t[l]=c},s=(l,c)=>{t[l]&&(e.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)};let r;const a=()=>{s("attach",a),this.attached=!0,this.resize(),n("resize",o),n("detach",r)};r=()=>{this.attached=!1,s("resize",o),this._stop(),this._resize(0,0),n("attach",a)},e.isAttached(this.canvas)?a():r()}unbindEvents(){I(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},I(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,n){const s=n?"set":"remove";let o,r,a,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+s+"DatasetHoverStyle"]()),a=0,l=t.length;a<l;++a){r=t[a];const c=r&&this.getDatasetMeta(r.datasetIndex).controller;c&&c[s+"HoverStyle"](r.element,r.datasetIndex,r.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const e=this._active||[],n=t.map(({datasetIndex:o,index:r})=>{const a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!Si(n,e)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,e))}notifyPlugins(t,e,n){return this._plugins.notify(this,t,e,n)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,n){const s=this.options.hover,o=(l,c)=>l.filter(h=>!c.some(u=>h.datasetIndex===u.datasetIndex&&h.index===u.index)),r=o(e,t),a=n?t:o(t,e);r.length&&this.updateHoverStyle(r,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const n={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},s=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",n,s)===!1)return;const o=this._handleEvent(t,e,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,s),(o||n.changed)&&this.render(),this}_handleEvent(t,e,n){const{_active:s=[],options:o}=this,r=e,a=this._getActiveElements(t,s,n,r),l=_c(t),c=_f(t,this._lastEvent,n,l);n&&(this._lastEvent=null,z(o.onHover,[t,a,this],this),l&&z(o.onClick,[t,a,this],this));const h=!Si(a,s);return(h||e)&&(this._active=a,this._updateHoverStyles(a,s,e)),this._lastEvent=c,h}_getActiveElements(t,e,n,s){if(t.type==="mouseout")return[];if(!n)return e;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,s)}}function qr(){return I(Kn.instances,i=>i._plugins.invalidate())}function xf(i,t,e){const{startAngle:n,x:s,y:o,outerRadius:r,innerRadius:a,options:l}=t,{borderWidth:c,borderJoinStyle:h}=l,u=Math.min(c/r,K(n-e));if(i.beginPath(),i.arc(s,o,r-c/2,n+u/2,e-u/2),a>0){const f=Math.min(c/a,K(n-e));i.arc(s,o,a+c/2,e-f/2,n+f/2,!0)}else{const f=Math.min(c/2,r*K(n-e));if(h==="round")i.arc(s,o,f,e-E/2,n+E/2,!0);else if(h==="bevel"){const d=2*f*f,g=-d*Math.cos(e+E/2)+s,p=-d*Math.sin(e+E/2)+o,m=d*Math.cos(n+E/2)+s,b=d*Math.sin(n+E/2)+o;i.lineTo(g,p),i.lineTo(m,b)}}i.closePath(),i.moveTo(0,0),i.rect(0,0,i.canvas.width,i.canvas.height),i.clip("evenodd")}function yf(i,t,e){const{startAngle:n,pixelMargin:s,x:o,y:r,outerRadius:a,innerRadius:l}=t;let c=s/a;i.beginPath(),i.arc(o,r,a,n-c,e+c),l>s?(c=s/l,i.arc(o,r,l,e+c,n-c,!0)):i.arc(o,r,s,e+H,n-H),i.closePath(),i.clip()}function vf(i){return Ln(i,["outerStart","outerEnd","innerStart","innerEnd"])}function wf(i,t,e,n){const s=vf(i.options.borderRadius),o=(e-t)/2,r=Math.min(o,n*t/2),a=l=>{const c=(e-Math.min(o,l))*n/2;return X(l,0,Math.min(o,c))};return{outerStart:a(s.outerStart),outerEnd:a(s.outerEnd),innerStart:X(s.innerStart,0,r),innerEnd:X(s.innerEnd,0,r)}}function Ce(i,t,e,n){return{x:e+i*Math.cos(t),y:n+i*Math.sin(t)}}function Ui(i,t,e,n,s,o){const{x:r,y:a,startAngle:l,pixelMargin:c,innerRadius:h}=t,u=Math.max(t.outerRadius+n+e-c,0),f=h>0?h+n+e+c:0;let d=0;const g=s-l;if(n){const F=h>0?h-n:0,N=u>0?u-n:0,j=(F+N)/2,xt=j!==0?g*j/(j+n):g;d=(g-xt)/2}const p=Math.max(.001,g*u-e/E)/u,m=(g-p)/2,b=l+m+d,_=s-m-d,{outerStart:y,outerEnd:v,innerStart:x,innerEnd:w}=wf(t,f,u,_-b),M=u-y,k=u-v,S=b+y/M,D=_-v/k,C=f+x,T=f+w,q=b+x/C,ht=_-w/T;if(i.beginPath(),o){const F=(S+D)/2;if(i.arc(r,a,u,S,F),i.arc(r,a,u,F,D),v>0){const Q=Ce(k,D,r,a);i.arc(Q.x,Q.y,v,D,_+H)}const N=Ce(T,_,r,a);if(i.lineTo(N.x,N.y),w>0){const Q=Ce(T,ht,r,a);i.arc(Q.x,Q.y,w,_+H,ht+Math.PI)}const j=(_-w/f+(b+x/f))/2;if(i.arc(r,a,f,_-w/f,j,!0),i.arc(r,a,f,j,b+x/f,!0),x>0){const Q=Ce(C,q,r,a);i.arc(Q.x,Q.y,x,q+Math.PI,b-H)}const xt=Ce(M,b,r,a);if(i.lineTo(xt.x,xt.y),y>0){const Q=Ce(M,S,r,a);i.arc(Q.x,Q.y,y,b-H,S)}}else{i.moveTo(r,a);const F=Math.cos(S)*u+r,N=Math.sin(S)*u+a;i.lineTo(F,N);const j=Math.cos(D)*u+r,xt=Math.sin(D)*u+a;i.lineTo(j,xt)}i.closePath()}function Mf(i,t,e,n,s){const{fullCircles:o,startAngle:r,circumference:a}=t;let l=t.endAngle;if(o){Ui(i,t,e,n,l,s);for(let c=0;c<o;++c)i.fill();isNaN(a)||(l=r+(a%$||$))}return Ui(i,t,e,n,l,s),i.fill(),l}function kf(i,t,e,n,s){const{fullCircles:o,startAngle:r,circumference:a,options:l}=t,{borderWidth:c,borderJoinStyle:h,borderDash:u,borderDashOffset:f,borderRadius:d}=l,g=l.borderAlign==="inner";if(!c)return;i.setLineDash(u||[]),i.lineDashOffset=f,g?(i.lineWidth=c*2,i.lineJoin=h||"round"):(i.lineWidth=c,i.lineJoin=h||"bevel");let p=t.endAngle;if(o){Ui(i,t,e,n,p,s);for(let m=0;m<o;++m)i.stroke();isNaN(a)||(p=r+(a%$||$))}g&&yf(i,t,p),l.selfJoin&&p-r>=E&&d===0&&h!=="miter"&&xf(i,t,p),o||(Ui(i,t,e,n,p,s),i.stroke())}class Sf extends Et{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:"backgroundColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;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,n){const s=this.getProps(["x","y"],n),{angle:o,distance:r}=Do(s,{x:t,y:e}),{startAngle:a,endAngle:l,innerRadius:c,outerRadius:h,circumference:u}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],n),f=(this.options.spacing+this.options.borderWidth)/2,d=P(u,l-a),g=je(o,a,l)&&a!==l,p=d>=$||g,m=Ct(r,c+f,h+f);return p&&m}getCenterPoint(t){const{x:e,y:n,startAngle:s,endAngle:o,innerRadius:r,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:l,spacing:c}=this.options,h=(s+o)/2,u=(r+a+c+l)/2;return{x:e+Math.cos(h)*u,y:n+Math.sin(h)*u}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:n}=this,s=(e.offset||0)/4,o=(e.spacing||0)/2,r=e.circular;if(this.pixelMargin=e.borderAlign==="inner"?.33:0,this.fullCircles=n>$?Math.floor(n/$):0,n===0||this.innerRadius<0||this.outerRadius<0)return;t.save();const a=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(a)*s,Math.sin(a)*s);const l=1-Math.sin(Math.min(E,n||0)),c=s*l;t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,Mf(t,this,c,o,r),kf(t,this,c,o,r),t.restore()}}function Kr(i,t,e=t){i.lineCap=P(e.borderCapStyle,t.borderCapStyle),i.setLineDash(P(e.borderDash,t.borderDash)),i.lineDashOffset=P(e.borderDashOffset,t.borderDashOffset),i.lineJoin=P(e.borderJoinStyle,t.borderJoinStyle),i.lineWidth=P(e.borderWidth,t.borderWidth),i.strokeStyle=P(e.borderColor,t.borderColor)}function Pf(i,t,e){i.lineTo(e.x,e.y)}function Df(i){return i.stepped?Vc:i.tension||i.cubicInterpolationMode==="monotone"?Wc:Pf}function Gr(i,t,e={}){const n=i.length,{start:s=0,end:o=n-1}=e,{start:r,end:a}=t,l=Math.max(s,r),c=Math.min(o,a),h=s<r&&o<r||s>a&&o>a;return{count:n,start:l,loop:t.loop,ilen:c<l&&!h?n+c-l:c-l}}function Cf(i,t,e,n){const{points:s,options:o}=t,{count:r,start:a,loop:l,ilen:c}=Gr(s,e,n),h=Df(o);let{move:u=!0,reverse:f}=n||{},d,g,p;for(d=0;d<=c;++d)g=s[(a+(f?c-d:d))%r],!g.skip&&(u?(i.moveTo(g.x,g.y),u=!1):h(i,p,g,f,o.stepped),p=g);return l&&(g=s[(a+(f?c:0))%r],h(i,p,g,f,o.stepped)),!!l}function Af(i,t,e,n){const s=t.points,{count:o,start:r,ilen:a}=Gr(s,e,n),{move:l=!0,reverse:c}=n||{};let h=0,u=0,f,d,g,p,m,b;const _=v=>(r+(c?a-v:v))%o,y=()=>{p!==m&&(i.lineTo(h,m),i.lineTo(h,p),i.lineTo(h,b))};for(l&&(d=s[_(0)],i.moveTo(d.x,d.y)),f=0;f<=a;++f){if(d=s[_(f)],d.skip)continue;const v=d.x,x=d.y,w=v|0;w===g?(x<p?p=x:x>m&&(m=x),h=(u*h+v)/++u):(y(),i.lineTo(v,x),g=w,u=0,p=m=x),b=x}y()}function Gn(i){const t=i.options,e=t.borderDash&&t.borderDash.length;return!i._decimated&&!i._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!e?Af:Cf}function Of(i){return i.stepped?yh:i.tension||i.cubicInterpolationMode==="monotone"?vh:le}function Tf(i,t,e,n){let s=t._path;s||(s=t._path=new Path2D,t.path(s,e,n)&&s.closePath()),Kr(i,t.options),i.stroke(s)}function Ef(i,t,e,n){const{segments:s,options:o}=t,r=Gn(t);for(const a of s)Kr(i,o,a.style),i.beginPath(),r(i,t,a,{start:e,end:e+n-1})&&i.closePath(),i.stroke()}const Lf=typeof Path2D=="function";function Rf(i,t,e,n){Lf&&!t.options.segment?Tf(i,t,e,n):Ef(i,t,e,n)}class Xi extends Et{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const n=this.options;if((n.tension||n.cubicInterpolationMode==="monotone")&&!n.stepped&&!this._pointsUpdated){const s=n.spanGaps?this._loop:this._fullLoop;fh(this._points,n,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Dh(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,n=t.length;return n&&e[t[n-1].end]}interpolate(t,e){const n=this.options,s=t[e],o=this.points,r=sr(this,{property:e,start:s,end:s});if(!r.length)return;const a=[],l=Of(n);let c,h;for(c=0,h=r.length;c<h;++c){const{start:u,end:f}=r[c],d=o[u],g=o[f];if(d===g){a.push(d);continue}const p=Math.abs((s-d[e])/(g[e]-d[e])),m=l(d,g,p,n.stepped);m[e]=t[e],a.push(m)}return a.length===1?a[0]:a}pathSegment(t,e,n){return Gn(this)(t,this,e,n)}path(t,e,n){const s=this.segments,o=Gn(this);let r=this._loop;e=e||0,n=n||this.points.length-e;for(const a of s)r&=o(t,this,a,{start:e,end:e+n-1});return!!r}draw(t,e,n,s){const o=this.options||{};(this.points||[]).length&&o.borderWidth&&(t.save(),Rf(t,this,n,s),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function Zr(i,t,e,n){const s=i.options,{[e]:o}=i.getProps([e],n);return Math.abs(t-o)<s.radius+s.hitRadius}class If extends Et{static id="point";parsed;skip;stop;static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};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,n){const s=this.options,{x:o,y:r}=this.getProps(["x","y"],n);return Math.pow(t-o,2)+Math.pow(e-r,2)<Math.pow(s.hitRadius+s.radius,2)}inXRange(t,e){return Zr(this,t,"x",e)}inYRange(t,e){return Zr(this,t,"y",e)}getCenterPoint(t){const{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}size(t){t=t||this.options||{};let e=t.radius||0;e=Math.max(e,e&&t.hoverRadius||0);const n=e&&t.borderWidth||0;return(e+n)*2}draw(t,e){const n=this.options;this.skip||n.radius<.1||!Ot(this,e,this.size(n)/2)||(t.strokeStyle=n.borderColor,t.lineWidth=n.borderWidth,t.fillStyle=n.backgroundColor,En(t,n,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}}function Jr(i,t){const{x:e,y:n,base:s,width:o,height:r}=i.getProps(["x","y","base","width","height"],t);let a,l,c,h,u;return i.horizontal?(u=r/2,a=Math.min(e,s),l=Math.max(e,s),c=n-u,h=n+u):(u=o/2,a=e-u,l=e+u,c=Math.min(n,s),h=Math.max(n,s)),{left:a,top:c,right:l,bottom:h}}function Kt(i,t,e,n){return i?0:X(t,e,n)}function Ff(i,t,e){const n=i.options.borderWidth,s=i.borderSkipped,o=Wo(n);return{t:Kt(s.top,o.top,0,e),r:Kt(s.right,o.right,0,t),b:Kt(s.bottom,o.bottom,0,e),l:Kt(s.left,o.left,0,t)}}function zf(i,t,e){const{enableBorderRadius:n}=i.getProps(["enableBorderRadius"]),s=i.options.borderRadius,o=oe(s),r=Math.min(t,e),a=i.borderSkipped,l=n||O(s);return{topLeft:Kt(!l||a.top||a.left,o.topLeft,0,r),topRight:Kt(!l||a.top||a.right,o.topRight,0,r),bottomLeft:Kt(!l||a.bottom||a.left,o.bottomLeft,0,r),bottomRight:Kt(!l||a.bottom||a.right,o.bottomRight,0,r)}}function $f(i){const t=Jr(i),e=t.right-t.left,n=t.bottom-t.top,s=Ff(i,e/2,n/2),o=zf(i,e/2,n/2);return{outer:{x:t.left,y:t.top,w:e,h:n,radius:o},inner:{x:t.left+s.l,y:t.top+s.t,w:e-s.l-s.r,h:n-s.t-s.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(s.t,s.l)),topRight:Math.max(0,o.topRight-Math.max(s.t,s.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(s.b,s.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(s.b,s.r))}}}}function Zn(i,t,e,n){const s=t===null,o=e===null,a=i&&!(s&&o)&&Jr(i,n);return a&&(s||Ct(t,a.left,a.right))&&(o||Ct(e,a.top,a.bottom))}function Bf(i){return i.topLeft||i.topRight||i.bottomLeft||i.bottomRight}function Nf(i,t){i.rect(t.x,t.y,t.w,t.h)}function Jn(i,t,e={}){const n=i.x!==e.x?-t:0,s=i.y!==e.y?-t:0,o=(i.x+i.w!==e.x+e.w?t:0)-n,r=(i.y+i.h!==e.y+e.h?t:0)-s;return{x:i.x+n,y:i.y+s,w:i.w+o,h:i.h+r,radius:i.radius}}class Vf extends Et{static id="bar";static defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:e,options:{borderColor:n,backgroundColor:s}}=this,{inner:o,outer:r}=$f(this),a=Bf(r.radius)?qe:Nf;t.save(),(r.w!==o.w||r.h!==o.h)&&(t.beginPath(),a(t,Jn(r,e,o)),t.clip(),a(t,Jn(o,-e,r)),t.fillStyle=n,t.fill("evenodd")),t.beginPath(),a(t,Jn(o,e)),t.fillStyle=s,t.fill(),t.restore()}inRange(t,e,n){return Zn(this,t,e,n)}inXRange(t,e){return Zn(this,t,null,e)}inYRange(t,e){return Zn(this,null,t,e)}getCenterPoint(t){const{x:e,y:n,base:s,horizontal:o}=this.getProps(["x","y","base","horizontal"],t);return{x:o?(e+s)/2:e,y:o?n:(n+s)/2}}getRange(t){return t==="x"?this.width/2:this.height/2}}function Wf(i,t,e,n,s){const o=s.samples||n;if(o>=e)return i.slice(t,t+e);const r=[],a=(e-2)/(o-2);let l=0;const c=t+e-1;let h=t,u,f,d,g,p;for(r[l++]=i[h],u=0;u<o-2;u++){let m=0,b=0,_;const y=Math.floor((u+1)*a)+1+t,v=Math.min(Math.floor((u+2)*a)+1,e)+t,x=v-y;for(_=y;_<v;_++)m+=i[_].x,b+=i[_].y;m/=x,b/=x;const w=Math.floor(u*a)+1+t,M=Math.min(Math.floor((u+1)*a)+1,e)+t,{x:k,y:S}=i[h];for(d=g=-1,_=w;_<M;_++)g=.5*Math.abs((k-m)*(i[_].y-S)-(k-i[_].x)*(b-S)),g>d&&(d=g,f=i[_],p=_);r[l++]=f,h=p}return r[l++]=i[c],r}function Hf(i,t,e,n){let s=0,o=0,r,a,l,c,h,u,f,d,g,p;const m=[],b=t+e-1,_=i[t].x,v=i[b].x-_;for(r=t;r<t+e;++r){a=i[r],l=(a.x-_)/v*n,c=a.y;const x=l|0;if(x===h)c<g?(g=c,u=r):c>p&&(p=c,f=r),s=(o*s+a.x)/++o;else{const w=r-1;if(!A(u)&&!A(f)){const M=Math.min(u,f),k=Math.max(u,f);M!==d&&M!==w&&m.push({...i[M],x:s}),k!==d&&k!==w&&m.push({...i[k],x:s})}r>0&&w!==d&&m.push(i[w]),m.push(a),h=x,o=0,g=p=c,u=f=d=r}}return m}function Qr(i){if(i._decimated){const t=i._data;delete i._decimated,delete i._data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function ta(i){i.data.datasets.forEach(t=>{Qr(t)})}function jf(i,t){const e=t.length;let n=0,s;const{iScale:o}=i,{min:r,max:a,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(n=X(At(t,o.axis,r).lo,0,e-1)),c?s=X(At(t,o.axis,a).hi+1,n,e)-n:s=e-n,{start:n,count:s}}var Yf={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(i,t,e)=>{if(!e.enabled){ta(i);return}const n=i.width;i.data.datasets.forEach((s,o)=>{const{_data:r,indexAxis:a}=s,l=i.getDatasetMeta(o),c=r||s.data;if(Ke([a,i.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;const h=i.scales[l.xAxisID];if(h.type!=="linear"&&h.type!=="time"||i.options.parsing)return;let{start:u,count:f}=jf(l,c);const d=e.threshold||4*n;if(f<=d){Qr(s);return}A(r)&&(s._data=c,delete s.data,Object.defineProperty(s,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(p){this._data=p}}));let g;switch(e.algorithm){case"lttb":g=Wf(c,u,f,n,e);break;case"min-max":g=Hf(c,u,f,n);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}s._decimated=g})},destroy(i){ta(i)}};function Uf(i,t,e){const n=i.segments,s=i.points,o=t.points,r=[];for(const a of n){let{start:l,end:c}=a;c=qi(l,c,s);const h=Qn(e,s[l],s[c],a.loop);if(!t.segments){r.push({source:a,target:h,start:s[l],end:s[c]});continue}const u=sr(t,h);for(const f of u){const d=Qn(e,o[f.start],o[f.end],f.loop),g=nr(a,s,d);for(const p of g)r.push({source:p,target:f,start:{[e]:ea(h,d,"start",Math.max)},end:{[e]:ea(h,d,"end",Math.min)}})}}return r}function Qn(i,t,e,n){if(n)return;let s=t[i],o=e[i];return i==="angle"&&(s=K(s),o=K(o)),{property:i,start:s,end:o}}function Xf(i,t){const{x:e=null,y:n=null}=i||{},s=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=qi(r,a,s);const l=s[r],c=s[a];n!==null?(o.push({x:l.x,y:n}),o.push({x:c.x,y:n})):e!==null&&(o.push({x:e,y:l.y}),o.push({x:e,y:c.y}))}),o}function qi(i,t,e){for(;t>i;t--){const n=e[t];if(!isNaN(n.x)&&!isNaN(n.y))break}return t}function ea(i,t,e,n){return i&&t?n(i[e],t[e]):i?i[e]:t?t[e]:0}function ia(i,t){let e=[],n=!1;return B(i)?(n=!0,e=i):e=Xf(i,t),e.length?new Xi({points:e,options:{tension:0},_loop:n,_fullLoop:n}):null}function na(i){return i&&i.fill!==!1}function qf(i,t,e){let s=i[t].fill;const o=[t];let r;if(!e)return s;for(;s!==!1&&o.indexOf(s)===-1;){if(!V(s))return s;if(r=i[s],!r)return!1;if(r.visible)return s;o.push(s),s=r.fill}return!1}function Kf(i,t,e){const n=Qf(i);if(O(n))return isNaN(n.value)?!1:n;let s=parseFloat(n);return V(s)&&Math.floor(s)===s?Gf(n[0],t,s,e):["origin","start","end","stack","shape"].indexOf(n)>=0&&n}function Gf(i,t,e,n){return(i==="-"||i==="+")&&(e=t+e),e===t||e<0||e>=n?!1:e}function Zf(i,t){let e=null;return i==="start"?e=t.bottom:i==="end"?e=t.top:O(i)?e=t.getPixelForValue(i.value):t.getBasePixel&&(e=t.getBasePixel()),e}function Jf(i,t,e){let n;return i==="start"?n=e:i==="end"?n=t.options.reverse?t.min:t.max:O(i)?n=i.value:n=t.getBaseValue(),n}function Qf(i){const t=i.options,e=t.fill;let n=P(e&&e.target,e);return n===void 0&&(n=!!t.backgroundColor),n===!1||n===null?!1:n===!0?"origin":n}function td(i){const{scale:t,index:e,line:n}=i,s=[],o=n.segments,r=n.points,a=ed(t,e);a.push(ia({x:null,y:t.bottom},n));for(let l=0;l<o.length;l++){const c=o[l];for(let h=c.start;h<=c.end;h++)id(s,r[h],a)}return new Xi({points:s,options:{}})}function ed(i,t){const e=[],n=i.getMatchingVisibleMetas("line");for(let s=0;s<n.length;s++){const o=n[s];if(o.index===t)break;o.hidden||e.unshift(o.dataset)}return e}function id(i,t,e){const n=[];for(let s=0;s<e.length;s++){const o=e[s],{first:r,last:a,point:l}=nd(o,t,"x");if(!(!l||r&&a)){if(r)n.unshift(l);else if(i.push(l),!a)break}}i.push(...n)}function nd(i,t,e){const n=i.interpolate(t,e);if(!n)return{};const s=n[e],o=i.segments,r=i.points;let a=!1,l=!1;for(let c=0;c<o.length;c++){const h=o[c],u=r[h.start][e],f=r[h.end][e];if(Ct(s,u,f)){a=s===u,l=s===f;break}}return{first:a,last:l,point:n}}class sa{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,n){const{x:s,y:o,radius:r}=this;return e=e||{start:0,end:$},t.arc(s,o,r,e.end,e.start,!0),!n.bounds}interpolate(t){const{x:e,y:n,radius:s}=this,o=t.angle;return{x:e+Math.cos(o)*s,y:n+Math.sin(o)*s,angle:o}}}function sd(i){const{chart:t,fill:e,line:n}=i;if(V(e))return od(t,e);if(e==="stack")return td(i);if(e==="shape")return!0;const s=rd(i);return s instanceof sa?s:ia(s,n)}function od(i,t){const e=i.getDatasetMeta(t);return e&&i.isDatasetVisible(t)?e.dataset:null}function rd(i){return(i.scale||{}).getPointPositionForValue?ld(i):ad(i)}function ad(i){const{scale:t={},fill:e}=i,n=Zf(e,t);if(V(n)){const s=t.isHorizontal();return{x:s?n:null,y:s?null:n}}return null}function ld(i){const{scale:t,fill:e}=i,n=t.options,s=t.getLabels().length,o=n.reverse?t.max:t.min,r=Jf(e,t,o),a=[];if(n.grid.circular){const l=t.getPointPositionForValue(0,o);return new sa({x:l.x,y:l.y,radius:t.getDistanceFromCenterForValue(r)})}for(let l=0;l<s;++l)a.push(t.getPointPositionForValue(l,r));return a}function ts(i,t,e){const n=sd(t),{chart:s,index:o,line:r,scale:a,axis:l}=t,c=r.options,h=c.fill,u=c.backgroundColor,{above:f=u,below:d=u}=h||{},g=s.getDatasetMeta(o),p=ar(s,g);n&&r.points.length&&(Ti(i,e),cd(i,{line:r,target:n,above:f,below:d,area:e,scale:a,axis:l,clip:p}),Ei(i))}function cd(i,t){const{line:e,target:n,above:s,below:o,area:r,scale:a,clip:l}=t,c=e._loop?"angle":t.axis;i.save();let h=o;o!==s&&(c==="x"?(oa(i,n,r.top),es(i,{line:e,target:n,color:s,scale:a,property:c,clip:l}),i.restore(),i.save(),oa(i,n,r.bottom)):c==="y"&&(ra(i,n,r.left),es(i,{line:e,target:n,color:o,scale:a,property:c,clip:l}),i.restore(),i.save(),ra(i,n,r.right),h=s)),es(i,{line:e,target:n,color:h,scale:a,property:c,clip:l}),i.restore()}function oa(i,t,e){const{segments:n,points:s}=t;let o=!0,r=!1;i.beginPath();for(const a of n){const{start:l,end:c}=a,h=s[l],u=s[qi(l,c,s)];o?(i.moveTo(h.x,h.y),o=!1):(i.lineTo(h.x,e),i.lineTo(h.x,h.y)),r=!!t.pathSegment(i,a,{move:r}),r?i.closePath():i.lineTo(u.x,e)}i.lineTo(t.first().x,e),i.closePath(),i.clip()}function ra(i,t,e){const{segments:n,points:s}=t;let o=!0,r=!1;i.beginPath();for(const a of n){const{start:l,end:c}=a,h=s[l],u=s[qi(l,c,s)];o?(i.moveTo(h.x,h.y),o=!1):(i.lineTo(e,h.y),i.lineTo(h.x,h.y)),r=!!t.pathSegment(i,a,{move:r}),r?i.closePath():i.lineTo(e,u.y)}i.lineTo(e,t.first().y),i.closePath(),i.clip()}function es(i,t){const{line:e,target:n,property:s,color:o,scale:r,clip:a}=t,l=Uf(e,n,s);for(const{source:c,target:h,start:u,end:f}of l){const{style:{backgroundColor:d=o}={}}=c,g=n!==!0;i.save(),i.fillStyle=d,hd(i,r,a,g&&Qn(s,u,f)),i.beginPath();const p=!!e.pathSegment(i,c);let m;if(g){p?i.closePath():aa(i,n,f,s);const b=!!n.pathSegment(i,h,{move:p,reverse:!0});m=p&&b,m||aa(i,n,u,s)}i.closePath(),i.fill(m?"evenodd":"nonzero"),i.restore()}}function hd(i,t,e,n){const s=t.chart.chartArea,{property:o,start:r,end:a}=n||{};if(o==="x"||o==="y"){let l,c,h,u;o==="x"?(l=r,c=s.top,h=a,u=s.bottom):(l=s.left,c=r,h=s.right,u=a),i.beginPath(),e&&(l=Math.max(l,e.left),h=Math.min(h,e.right),c=Math.max(c,e.top),u=Math.min(u,e.bottom)),i.rect(l,c,h-l,u-c),i.clip()}}function aa(i,t,e,n){const s=t.interpolate(e,n);s&&i.lineTo(s.x,s.y)}var ud={id:"filler",afterDatasetsUpdate(i,t,e){const n=(i.data.datasets||[]).length,s=[];let o,r,a,l;for(r=0;r<n;++r)o=i.getDatasetMeta(r),a=o.dataset,l=null,a&&a.options&&a instanceof Xi&&(l={visible:i.isDatasetVisible(r),index:r,fill:Kf(a,r,n),chart:i,axis:o.controller.options.indexAxis,scale:o.vScale,line:a}),o.$filler=l,s.push(l);for(r=0;r<n;++r)l=s[r],!(!l||l.fill===!1)&&(l.fill=qf(s,r,e.propagate))},beforeDraw(i,t,e){const n=e.drawTime==="beforeDraw",s=i.getSortedVisibleDatasetMetas(),o=i.chartArea;for(let r=s.length-1;r>=0;--r){const a=s[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),n&&a.fill&&ts(i.ctx,a,o))}},beforeDatasetsDraw(i,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;const n=i.getSortedVisibleDatasetMetas();for(let s=n.length-1;s>=0;--s){const o=n[s].$filler;na(o)&&ts(i.ctx,o,i.chartArea)}},beforeDatasetDraw(i,t,e){const n=t.meta.$filler;!na(n)||e.drawTime!=="beforeDatasetDraw"||ts(i.ctx,n,i.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const la=(i,t)=>{let{boxHeight:e=t,boxWidth:n=t}=i;return i.usePointStyle&&(e=Math.min(e,t),n=i.pointStyleWidth||Math.min(n,t)),{boxWidth:n,boxHeight:e,itemHeight:Math.max(t,e)}},fd=(i,t)=>i!==null&&t!==null&&i.datasetIndex===t.datasetIndex&&i.index===t.index;class ca extends Et{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,n){this.maxWidth=t,this.maxHeight=e,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=z(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(n=>t.filter(n,this.chart.data))),t.sort&&(e=e.sort((n,s)=>t.sort(n,s,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display){this.width=this.height=0;return}const n=t.labels,s=Y(n.font),o=s.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=la(n,o);let c,h;e.font=s.string,this.isHorizontal()?(c=this.maxWidth,h=this._fitRows(r,o,a,l)+10):(h=this.maxHeight,c=this._fitCols(r,s,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,n,s){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],h=s+a;let u=t;o.textAlign="left",o.textBaseline="middle";let f=-1,d=-h;return this.legendItems.forEach((g,p)=>{const m=n+e/2+o.measureText(g.text).width;(p===0||c[c.length-1]+m+2*a>r)&&(u+=h,c[c.length-(p>0?0:1)]=0,d+=h,f++),l[p]={left:0,top:d,row:f,width:m,height:s},c[c.length-1]+=m+a}),u}_fitCols(t,e,n,s){const{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],h=r-t;let u=a,f=0,d=0,g=0,p=0;return this.legendItems.forEach((m,b)=>{const{itemWidth:_,itemHeight:y}=dd(n,e,o,m,s);b>0&&d+y+2*a>h&&(u+=f+a,c.push({width:f,height:d}),g+=f+a,p++,f=d=0),l[b]={left:g,top:d,col:p,width:_,height:y},f=Math.max(f,_),d+=y+a}),u+=f,c.push({width:f,height:d}),u}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:n,labels:{padding:s},rtl:o}}=this,r=De(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=G(n,this.left+s,this.right-this.lineWidths[a]);for(const c of e)a!==c.row&&(a=c.row,l=G(n,this.left+s,this.right-this.lineWidths[a])),c.top+=this.top+t+s,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+s}else{let a=0,l=G(n,this.top+t+s,this.bottom-this.columnSizes[a].height);for(const c of e)c.col!==a&&(a=c.col,l=G(n,this.top+t+s,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+s,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;Ti(t,this),this._draw(),Ei(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:n,ctx:s}=this,{align:o,labels:r}=t,a=W.color,l=De(t.rtl,this.left,this.width),c=Y(r.font),{padding:h}=r,u=c.size,f=u/2;let d;this.drawTitle(),s.textAlign=l.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:g,boxHeight:p,itemHeight:m}=la(r,u),b=function(w,M,k){if(isNaN(g)||g<=0||isNaN(p)||p<0)return;s.save();const S=P(k.lineWidth,1);if(s.fillStyle=P(k.fillStyle,a),s.lineCap=P(k.lineCap,"butt"),s.lineDashOffset=P(k.lineDashOffset,0),s.lineJoin=P(k.lineJoin,"miter"),s.lineWidth=S,s.strokeStyle=P(k.strokeStyle,a),s.setLineDash(P(k.lineDash,[])),r.usePointStyle){const D={radius:p*Math.SQRT2/2,pointStyle:k.pointStyle,rotation:k.rotation,borderWidth:S},C=l.xPlus(w,g/2),T=M+f;Vo(s,D,C,T,r.pointStyleWidth&&g)}else{const D=M+Math.max((u-p)/2,0),C=l.leftForLtr(w,g),T=oe(k.borderRadius);s.beginPath(),Object.values(T).some(q=>q!==0)?qe(s,{x:C,y:D,w:g,h:p,radius:T}):s.rect(C,D,g,p),s.fill(),S!==0&&s.stroke()}s.restore()},_=function(w,M,k){se(s,k.text,w,M+m/2,c,{strikethrough:k.hidden,textAlign:l.textAlign(k.textAlign)})},y=this.isHorizontal(),v=this._computeTitleHeight();y?d={x:G(o,this.left+h,this.right-n[0]),y:this.top+h+v,line:0}:d={x:this.left+h,y:G(o,this.top+v+h,this.bottom-e[0].height),line:0},Qo(this.ctx,t.textDirection);const x=m+h;this.legendItems.forEach((w,M)=>{s.strokeStyle=w.fontColor,s.fillStyle=w.fontColor;const k=s.measureText(w.text).width,S=l.textAlign(w.textAlign||(w.textAlign=r.textAlign)),D=g+f+k;let C=d.x,T=d.y;l.setWidth(this.width),y?M>0&&C+D+h>this.right&&(T=d.y+=x,d.line++,C=d.x=G(o,this.left+h,this.right-n[d.line])):M>0&&T+x>this.bottom&&(C=d.x=C+e[d.line].width+h,d.line++,T=d.y=G(o,this.top+v+h,this.bottom-e[d.line].height));const q=l.x(C);if(b(q,T,w),C=Oc(S,C+g+f,y?C+D:this.right,t.rtl),_(l.x(C),T,w),y)d.x+=D+h;else if(typeof w.text!="string"){const ht=c.lineHeight;d.y+=ha(w,ht)+h}else d.y+=x}),tr(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,n=Y(e.font),s=Z(e.padding);if(!e.display)return;const o=De(t.rtl,this.left,this.width),r=this.ctx,a=e.position,l=n.size/2,c=s.top+l;let h,u=this.left,f=this.width;if(this.isHorizontal())f=Math.max(...this.lineWidths),h=this.top+c,u=G(t.align,u,this.right-f);else{const g=this.columnSizes.reduce((p,m)=>Math.max(p,m.height),0);h=c+G(t.align,this.top,this.bottom-g-t.labels.padding-this._computeTitleHeight())}const d=G(a,u,u+f);r.textAlign=o.textAlign(Dn(a)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=n.string,se(r,e.text,d,h,n)}_computeTitleHeight(){const t=this.options.title,e=Y(t.font),n=Z(t.padding);return t.display?e.lineHeight+n.height:0}_getLegendItemAt(t,e){let n,s,o;if(Ct(t,this.left,this.right)&&Ct(e,this.top,this.bottom)){for(o=this.legendHitBoxes,n=0;n<o.length;++n)if(s=o[n],Ct(t,s.left,s.left+s.width)&&Ct(e,s.top,s.top+s.height))return this.legendItems[n]}return null}handleEvent(t){const e=this.options;if(!md(t.type,e))return;const n=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const s=this._hoveredItem,o=fd(s,n);s&&!o&&z(e.onLeave,[t,s,this],this),this._hoveredItem=n,n&&!o&&z(e.onHover,[t,n,this],this)}else n&&z(e.onClick,[t,n,this],this)}}function dd(i,t,e,n,s){const o=gd(n,i,t,e),r=pd(s,n,t.lineHeight);return{itemWidth:o,itemHeight:r}}function gd(i,t,e,n){let s=i.text;return s&&typeof s!="string"&&(s=s.reduce((o,r)=>o.length>r.length?o:r)),t+e.size/2+n.measureText(s).width}function pd(i,t,e){let n=i;return typeof t.text!="string"&&(n=ha(t,e)),n}function ha(i,t){const e=i.text?i.text.length:0;return t*e}function md(i,t){return!!((i==="mousemove"||i==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(i==="click"||i==="mouseup"))}var bd={id:"legend",_element:ca,start(i,t,e){const n=i.legend=new ca({ctx:i.ctx,options:e,chart:i});J.configure(i,n,e),J.addBox(i,n)},stop(i){J.removeBox(i,i.legend),delete i.legend},beforeUpdate(i,t,e){const n=i.legend;J.configure(i,n,e),n.options=e},afterUpdate(i){const t=i.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(i,t){t.replay||i.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(i,t,e){const n=t.datasetIndex,s=e.chart;s.isDatasetVisible(n)?(s.hide(n),t.hidden=!0):(s.show(n),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:i=>i.chart.options.color,boxWidth:40,padding:10,generateLabels(i){const t=i.data.datasets,{labels:{usePointStyle:e,pointStyle:n,textAlign:s,color:o,useBorderRadius:r,borderRadius:a}}=i.legend.options;return i._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(e?0:void 0),h=Z(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(h.width+h.height)/4,strokeStyle:c.borderColor,pointStyle:n||c.pointStyle,rotation:c.rotation,textAlign:s||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:i=>i.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:i=>!i.startsWith("on"),labels:{_scriptable:i=>!["generateLabels","filter","sort"].includes(i)}}};class is extends Et{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 n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=e;const s=B(n.text)?n.text.length:1;this._padding=Z(n.padding);const o=s*Y(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:e,left:n,bottom:s,right:o,options:r}=this,a=r.align;let l=0,c,h,u;return this.isHorizontal()?(h=G(a,n,o),u=e+t,c=o-n):(r.position==="left"?(h=n+t,u=G(a,s,e),l=E*-.5):(h=o-t,u=G(a,e,s),l=E*.5),c=s-e),{titleX:h,titleY:u,maxWidth:c,rotation:l}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const n=Y(e.font),o=n.lineHeight/2+this._padding.top,{titleX:r,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(o);se(t,e.text,0,0,n,{color:e.color,maxWidth:l,rotation:c,textAlign:Dn(e.align),textBaseline:"middle",translation:[r,a]})}}function _d(i,t){const e=new is({ctx:i.ctx,options:t,chart:i});J.configure(i,e,t),J.addBox(i,e),i.titleBlock=e}var xd={id:"title",_element:is,start(i,t,e){_d(i,e)},stop(i){const t=i.titleBlock;J.removeBox(i,t),delete i.titleBlock},beforeUpdate(i,t,e){const n=i.titleBlock;J.configure(i,n,e),n.options=e},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Ki=new WeakMap;var yd={id:"subtitle",start(i,t,e){const n=new is({ctx:i.ctx,options:e,chart:i});J.configure(i,n,e),J.addBox(i,n),Ki.set(i,n)},stop(i){J.removeBox(i,Ki.get(i)),Ki.delete(i)},beforeUpdate(i,t,e){const n=Ki.get(i);J.configure(i,n,e),n.options=e},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const ni={average(i){if(!i.length)return!1;let t,e,n=new Set,s=0,o=0;for(t=0,e=i.length;t<e;++t){const a=i[t].element;if(a&&a.hasValue()){const l=a.tooltipPosition();n.add(l.x),s+=l.y,++o}}return o===0||n.size===0?!1:{x:[...n].reduce((a,l)=>a+l)/n.size,y:s/o}},nearest(i,t){if(!i.length)return!1;let e=t.x,n=t.y,s=Number.POSITIVE_INFINITY,o,r,a;for(o=0,r=i.length;o<r;++o){const l=i[o].element;if(l&&l.hasValue()){const c=l.getCenterPoint(),h=Sn(t,c);h<s&&(s=h,a=l)}}if(a){const l=a.tooltipPosition();e=l.x,n=l.y}return{x:e,y:n}}};function Mt(i,t){return t&&(B(t)?Array.prototype.push.apply(i,t):i.push(t)),i}function Lt(i){return(typeof i=="string"||i instanceof String)&&i.indexOf(`
18
18
  `)>-1?i.split(`
19
- `):i}function vd(i,t){const{element:e,datasetIndex:n,index:s}=t,o=i.getDatasetMeta(n).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:i,label:r,parsed:o.getParsed(s),raw:i.data.datasets[n].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:n,element:e}}function ua(i,t){const e=i.chart.ctx,{body:n,footer:s,title:o}=i,{boxWidth:r,boxHeight:a}=t,l=Y(t.bodyFont),c=Y(t.titleFont),h=Y(t.footerFont),u=o.length,f=s.length,d=n.length,g=Z(t.padding);let p=g.height,m=0,b=n.reduce((v,x)=>v+x.before.length+x.lines.length+x.after.length,0);if(b+=i.beforeBody.length+i.afterBody.length,u&&(p+=u*c.lineHeight+(u-1)*t.titleSpacing+t.titleMarginBottom),b){const v=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;p+=d*v+(b-d)*l.lineHeight+(b-1)*t.bodySpacing}f&&(p+=t.footerMarginTop+f*h.lineHeight+(f-1)*t.footerSpacing);let _=0;const y=function(v){m=Math.max(m,e.measureText(v).width+_)};return e.save(),e.font=c.string,I(i.title,y),e.font=l.string,I(i.beforeBody.concat(i.afterBody),y),_=t.displayColors?r+2+t.boxPadding:0,I(n,v=>{I(v.before,y),I(v.lines,y),I(v.after,y)}),_=0,e.font=h.string,I(i.footer,y),e.restore(),m+=g.width,{width:m,height:p}}function wd(i,t){const{y:e,height:n}=t;return e<n/2?"top":e>i.height-n/2?"bottom":"center"}function Md(i,t,e,n){const{x:s,width:o}=n,r=e.caretSize+e.caretPadding;if(i==="left"&&s+o+r>t.width||i==="right"&&s-o-r<0)return!0}function kd(i,t,e,n){const{x:s,width:o}=e,{width:r,chartArea:{left:a,right:l}}=i;let c="center";return n==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),Md(c,i,t,e)&&(c="center"),c}function fa(i,t,e){const n=e.yAlign||t.yAlign||wd(i,e);return{xAlign:e.xAlign||t.xAlign||kd(i,t,e,n),yAlign:n}}function Sd(i,t){let{x:e,width:n}=i;return t==="right"?e-=n:t==="center"&&(e-=n/2),e}function Pd(i,t,e){let{y:n,height:s}=i;return t==="top"?n+=e:t==="bottom"?n-=s+e:n-=s/2,n}function da(i,t,e,n){const{caretSize:s,caretPadding:o,cornerRadius:r}=i,{xAlign:a,yAlign:l}=e,c=s+o,{topLeft:h,topRight:u,bottomLeft:f,bottomRight:d}=oe(r);let g=Sd(t,a);const p=Pd(t,l,c);return l==="center"?a==="left"?g+=c:a==="right"&&(g-=c):a==="left"?g-=Math.max(h,f)+s:a==="right"&&(g+=Math.max(u,d)+s),{x:X(g,0,n.width-t.width),y:X(p,0,n.height-t.height)}}function Gi(i,t,e){const n=Z(e.padding);return t==="center"?i.x+i.width/2:t==="right"?i.x+i.width-n.right:i.x+n.left}function ga(i){return Mt([],Lt(i))}function Dd(i,t,e){return Xt(i,{tooltip:t,tooltipItems:e,type:"tooltip"})}function pa(i,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?i.override(e):i}const ma={beforeTitle:Dt,title(i){if(i.length>0){const t=i[0],e=t.chart.data.labels,n=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(n>0&&t.dataIndex<n)return e[t.dataIndex]}return""},afterTitle:Dt,beforeBody:Dt,beforeLabel:Dt,label(i){if(this&&this.options&&this.options.mode==="dataset")return i.label+": "+i.formattedValue||i.formattedValue;let t=i.dataset.label||"";t&&(t+=": ");const e=i.formattedValue;return A(e)||(t+=e),t},labelColor(i){const e=i.chart.getDatasetMeta(i.datasetIndex).controller.getStyle(i.dataIndex);return{borderColor:e.borderColor,backgroundColor:e.backgroundColor,borderWidth:e.borderWidth,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(i){const e=i.chart.getDatasetMeta(i.datasetIndex).controller.getStyle(i.dataIndex);return{pointStyle:e.pointStyle,rotation:e.rotation}},afterLabel:Dt,afterBody:Dt,beforeFooter:Dt,footer:Dt,afterFooter:Dt};function st(i,t,e,n){const s=i[t].call(e,n);return typeof s>"u"?ma[t].call(e,n):s}class ba extends Et{static positioners=ni;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,n=this.options.setContext(this.getContext()),s=n.enabled&&e.options.animation&&n.animations,o=new cr(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=Dd(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:n}=e,s=st(n,"beforeTitle",this,t),o=st(n,"title",this,t),r=st(n,"afterTitle",this,t);let a=[];return a=Mt(a,Lt(s)),a=Mt(a,Lt(o)),a=Mt(a,Lt(r)),a}getBeforeBody(t,e){return ga(st(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:n}=e,s=[];return I(t,o=>{const r={before:[],lines:[],after:[]},a=pa(n,o);Mt(r.before,Lt(st(a,"beforeLabel",this,o))),Mt(r.lines,st(a,"label",this,o)),Mt(r.after,Lt(st(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,e){return ga(st(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:n}=e,s=st(n,"beforeFooter",this,t),o=st(n,"footer",this,t),r=st(n,"afterFooter",this,t);let a=[];return a=Mt(a,Lt(s)),a=Mt(a,Lt(o)),a=Mt(a,Lt(r)),a}_createItems(t){const e=this._active,n=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=e.length;l<c;++l)a.push(vd(this.chart,e[l]));return t.filter&&(a=a.filter((h,u,f)=>t.filter(h,u,f,n))),t.itemSort&&(a=a.sort((h,u)=>t.itemSort(h,u,n))),I(a,h=>{const u=pa(t.callbacks,h);s.push(st(u,"labelColor",this,h)),o.push(st(u,"labelPointStyle",this,h)),r.push(st(u,"labelTextColor",this,h))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){const n=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=ni[n.position].call(this,s,this._eventPosition);r=this._createItems(n),this.title=this.getTitle(r,n),this.beforeBody=this.getBeforeBody(r,n),this.body=this.getBody(r,n),this.afterBody=this.getAfterBody(r,n),this.footer=this.getFooter(r,n);const l=this._size=ua(this,n),c=Object.assign({},a,l),h=fa(this.chart,n,c),u=da(n,c,h,this.chart);this.xAlign=h.xAlign,this.yAlign=h.yAlign,o={opacity:1,x:u.x,y:u.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,n,s){const o=this.getCaretPosition(t,n,s);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,n){const{xAlign:s,yAlign:o}=this,{caretSize:r,cornerRadius:a}=n,{topLeft:l,topRight:c,bottomLeft:h,bottomRight:u}=oe(a),{x:f,y:d}=t,{width:g,height:p}=e;let m,b,_,y,v,x;return o==="center"?(v=d+p/2,s==="left"?(m=f,b=m-r,y=v+r,x=v-r):(m=f+g,b=m+r,y=v-r,x=v+r),_=m):(s==="left"?b=f+Math.max(l,h)+r:s==="right"?b=f+g-Math.max(c,u)-r:b=this.caretX,o==="top"?(y=d,v=y-r,m=b-r,_=b+r):(y=d+p,v=y+r,m=b+r,_=b-r),x=y),{x1:m,x2:b,x3:_,y1:y,y2:v,y3:x}}drawTitle(t,e,n){const s=this.title,o=s.length;let r,a,l;if(o){const c=De(n.rtl,this.x,this.width);for(t.x=Gi(this,n.titleAlign,n),e.textAlign=c.textAlign(n.titleAlign),e.textBaseline="middle",r=Y(n.titleFont),a=n.titleSpacing,e.fillStyle=n.titleColor,e.font=r.string,l=0;l<o;++l)e.fillText(s[l],c.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+a,l+1===o&&(t.y+=n.titleMarginBottom-a)}}_drawColorBox(t,e,n,s,o){const r=this.labelColors[n],a=this.labelPointStyles[n],{boxHeight:l,boxWidth:c}=o,h=Y(o.bodyFont),u=Gi(this,"left",o),f=s.x(u),d=l<h.lineHeight?(h.lineHeight-l)/2:0,g=e.y+d;if(o.usePointStyle){const p={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},m=s.leftForLtr(f,c)+c/2,b=g+l/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,En(t,p,m,b),t.strokeStyle=r.borderColor,t.fillStyle=r.backgroundColor,En(t,p,m,b)}else{t.lineWidth=O(r.borderWidth)?Math.max(...Object.values(r.borderWidth)):r.borderWidth||1,t.strokeStyle=r.borderColor,t.setLineDash(r.borderDash||[]),t.lineDashOffset=r.borderDashOffset||0;const p=s.leftForLtr(f,c),m=s.leftForLtr(s.xPlus(f,1),c-2),b=oe(r.borderRadius);Object.values(b).some(_=>_!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,qe(t,{x:p,y:g,w:c,h:l,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),qe(t,{x:m,y:g+1,w:c-2,h:l-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(p,g,c,l),t.strokeRect(p,g,c,l),t.fillStyle=r.backgroundColor,t.fillRect(m,g+1,c-2,l-2))}t.fillStyle=this.labelTextColors[n]}drawBody(t,e,n){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:h}=n,u=Y(n.bodyFont);let f=u.lineHeight,d=0;const g=De(n.rtl,this.x,this.width),p=function(k){e.fillText(k,g.x(t.x+d),t.y+f/2),t.y+=f+o},m=g.textAlign(r);let b,_,y,v,x,w,M;for(e.textAlign=r,e.textBaseline="middle",e.font=u.string,t.x=Gi(this,m,n),e.fillStyle=n.bodyColor,I(this.beforeBody,p),d=a&&m!=="right"?r==="center"?c/2+h:c+2+h:0,v=0,w=s.length;v<w;++v){for(b=s[v],_=this.labelTextColors[v],e.fillStyle=_,I(b.before,p),y=b.lines,a&&y.length&&(this._drawColorBox(e,t,v,g,n),f=Math.max(u.lineHeight,l)),x=0,M=y.length;x<M;++x)p(y[x]),f=u.lineHeight;I(b.after,p)}d=0,f=u.lineHeight,I(this.afterBody,p),t.y-=o}drawFooter(t,e,n){const s=this.footer,o=s.length;let r,a;if(o){const l=De(n.rtl,this.x,this.width);for(t.x=Gi(this,n.footerAlign,n),t.y+=n.footerMarginTop,e.textAlign=l.textAlign(n.footerAlign),e.textBaseline="middle",r=Y(n.footerFont),e.fillStyle=n.footerColor,e.font=r.string,a=0;a<o;++a)e.fillText(s[a],l.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+n.footerSpacing}}drawBackground(t,e,n,s){const{xAlign:o,yAlign:r}=this,{x:a,y:l}=t,{width:c,height:h}=n,{topLeft:u,topRight:f,bottomLeft:d,bottomRight:g}=oe(s.cornerRadius);e.fillStyle=s.backgroundColor,e.strokeStyle=s.borderColor,e.lineWidth=s.borderWidth,e.beginPath(),e.moveTo(a+u,l),r==="top"&&this.drawCaret(t,e,n,s),e.lineTo(a+c-f,l),e.quadraticCurveTo(a+c,l,a+c,l+f),r==="center"&&o==="right"&&this.drawCaret(t,e,n,s),e.lineTo(a+c,l+h-g),e.quadraticCurveTo(a+c,l+h,a+c-g,l+h),r==="bottom"&&this.drawCaret(t,e,n,s),e.lineTo(a+d,l+h),e.quadraticCurveTo(a,l+h,a,l+h-d),r==="center"&&o==="left"&&this.drawCaret(t,e,n,s),e.lineTo(a,l+u),e.quadraticCurveTo(a,l,a+u,l),e.closePath(),e.fill(),s.borderWidth>0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,n=this.$animations,s=n&&n.x,o=n&&n.y;if(s||o){const r=ni[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=ua(this,t),l=Object.assign({},r,this._size),c=fa(e,t,l),h=da(t,l,c,e);(s._to!==h.x||o._to!==h.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,h))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let n=this.opacity;if(!n)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;const r=Z(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=n,this.drawBackground(o,t,s,e),Qo(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),tr(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const n=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!Si(n,s),r=this._positionChanged(s,e);(o||r)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,n=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],r=this._getActiveElements(t,o,e,n),a=this._positionChanged(r,t),l=e||!Si(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,n,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return e.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const r=this.chart.getElementsAtEventForMode(t,o.mode,o,n);return o.reverse&&r.reverse(),r}_positionChanged(t,e){const{caretX:n,caretY:s,options:o}=this,r=ni[o.position].call(this,t,e);return r!==!1&&(n!==r.x||s!==r.y)}}var Cd={id:"tooltip",_element:ba,positioners:ni,afterInit(i,t,e){e&&(i.tooltip=new ba({chart:i,options:e}))},beforeUpdate(i,t,e){i.tooltip&&i.tooltip.initialize(e)},reset(i,t,e){i.tooltip&&i.tooltip.initialize(e)},afterDraw(i){const t=i.tooltip;if(t&&t._willRender()){const e={tooltip:t};if(i.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(i.ctx),i.notifyPlugins("afterTooltipDraw",e)}},afterEvent(i,t){if(i.tooltip){const e=t.replay;i.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(i,t)=>t.bodyFont.size,boxWidth:(i,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:ma},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:i=>i!=="filter"&&i!=="itemSort"&&i!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const Ad=(i,t,e,n)=>(typeof t=="string"?(e=i.push(t)-1,n.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function Od(i,t,e,n){const s=i.indexOf(t);if(s===-1)return Ad(i,t,e,n);const o=i.lastIndexOf(t);return s!==o?e:s}const Td=(i,t)=>i===null?null:X(Math.round(i),0,t);function _a(i){const t=this.getLabels();return i>=0&&i<t.length?t[i]:i}class Ed extends he{static id="category";static defaults={ticks:{callback:_a}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const n=this.getLabels();for(const{index:s,label:o}of e)n[s]===o&&n.splice(s,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(A(t))return null;const n=this.getLabels();return e=isFinite(e)&&n[e]===t?e:Od(n,t,P(e,t),this._addedLabels),Td(e,n.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:n,max:s}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(n=0),e||(s=this.getLabels().length-1)),this.min=n,this.max=s}buildTicks(){const t=this.min,e=this.max,n=this.options.offset,s=[];let o=this.getLabels();o=t===0&&e===o.length-1?o:o.slice(t,e+1),this._valueRange=Math.max(o.length-(n?0:1),1),this._startValue=this.min-(n?.5:0);for(let r=t;r<=e;r++)s.push({value:r});return s}getLabelForValue(t){return _a.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function Ld(i,t){const e=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:h,maxDigits:u,includeBounds:f}=i,d=o||1,g=h-1,{min:p,max:m}=t,b=!A(r),_=!A(a),y=!A(c),v=(m-p)/(u+1);let x=ko((m-p)/g/d)*d,w,M,k,S;if(x<1e-14&&!b&&!_)return[{value:p},{value:m}];S=Math.ceil(m/x)-Math.floor(p/x),S>g&&(x=ko(S*x/g/d)*d),A(l)||(w=Math.pow(10,l),x=Math.ceil(x*w)/w),s==="ticks"?(M=Math.floor(p/x)*x,k=Math.ceil(m/x)*x):(M=p,k=m),b&&_&&o&&Mc((a-r)/o,x/1e3)?(S=Math.round(Math.min((a-r)/x,h)),x=(a-r)/S,M=r,k=a):y?(M=b?r:M,k=_?a:k,S=c-1,x=(k-M)/S):(S=(k-M)/x,He(S,Math.round(S),x/1e3)?S=Math.round(S):S=Math.ceil(S));const D=Math.max(Po(x),Po(M));w=Math.pow(10,A(l)?D:l),M=Math.round(M*w)/w,k=Math.round(k*w)/w;let C=0;for(b&&(f&&M!==r?(e.push({value:r}),M<r&&C++,He(Math.round((M+C*x)*w)/w,r,xa(r,v,i))&&C++):M<r&&C++);C<S;++C){const T=Math.round((M+C*x)*w)/w;if(_&&T>a)break;e.push({value:T})}return _&&f&&k!==a?e.length&&He(e[e.length-1].value,a,xa(a,v,i))?e[e.length-1].value=a:e.push({value:a}):(!_||k===a)&&e.push({value:k}),e}function xa(i,t,{horizontal:e,minRotation:n}){const s=_t(n),o=(e?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+i).length;return Math.min(t/o,r)}class Zi extends he{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return A(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:n}=this.getUserBounds();let{min:s,max:o}=this;const r=l=>s=e?s:l,a=l=>o=n?o:l;if(t){const l=vt(s),c=vt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:n}=t,s;return n?(s=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,s>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${s} ticks. Limiting to 1000.`),s=1e3)):(s=this.computeTickLimit(),e=e||11),e&&(s=Math.min(e,s)),s}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let n=this.getTickLimit();n=Math.max(2,n);const s={maxTicks:n,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==!1},o=this._range||this,r=Ld(s,o);return t.bounds==="ticks"&&So(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let e=this.min,n=this.max;if(super.configure(),this.options.offset&&t.length){const s=(n-e)/Math.max(t.length-1,1)/2;e-=s,n+=s}this._startValue=e,this._endValue=n,this._valueRange=n-e}getLabelForValue(t){return Ue(t,this.chart.options.locale,this.options.ticks.format)}}class Rd extends Zi{static id="linear";static defaults={ticks:{callback:Ai.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=V(t)?t:0,this.max=V(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,n=_t(this.options.ticks.minRotation),s=(t?Math.sin(n):Math.cos(n))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const si=i=>Math.floor(Ut(i)),ue=(i,t)=>Math.pow(10,si(i)+t);function ya(i){return i/Math.pow(10,si(i))===1}function va(i,t,e){const n=Math.pow(10,e),s=Math.floor(i/n);return Math.ceil(t/n)-s}function Id(i,t){const e=t-i;let n=si(e);for(;va(i,t,n)>10;)n++;for(;va(i,t,n)<10;)n--;return Math.min(n,si(i))}function Fd(i,{min:t,max:e}){t=ct(i.min,t);const n=[],s=si(t);let o=Id(t,e),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((t-l)*r)/r,h=Math.floor((t-l)/a/10)*a*10;let u=Math.floor((c-h)/Math.pow(10,o)),f=ct(i.min,Math.round((l+h+u*Math.pow(10,o))*r)/r);for(;f<e;)n.push({value:f,major:ya(f),significand:u}),u>=10?u=u<15?15:20:u++,u>=20&&(o++,u=2,r=o>=0?1:r),f=Math.round((l+h+u*Math.pow(10,o))*r)/r;const d=ct(i.max,f);return n.push({value:d,major:ya(d),significand:u}),n}class zd extends he{static id="logarithmic";static defaults={ticks:{callback:Ai.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const n=Zi.prototype.parse.apply(this,[t,e]);if(n===0){this._zero=!0;return}return V(n)&&n>0?n:null}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=V(t)?Math.max(0,t):null,this.max=V(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!V(this._userMin)&&(this.min=t===ue(this.min,0)?ue(this.min,-1):ue(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let n=this.min,s=this.max;const o=a=>n=t?n:a,r=a=>s=e?s:a;n===s&&(n<=0?(o(1),r(10)):(o(ue(n,-1)),r(ue(s,1)))),n<=0&&o(ue(s,-1)),s<=0&&r(ue(n,1)),this.min=n,this.max=s}buildTicks(){const t=this.options,e={min:this._userMin,max:this._userMax},n=Fd(e,this);return t.bounds==="ticks"&&So(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}getLabelForValue(t){return t===void 0?"0":Ue(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Ut(t),this._valueRange=Ut(this.max)-Ut(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Ut(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function ns(i){const t=i.ticks;if(t.display&&i.display){const e=Z(t.backdropPadding);return P(t.font&&t.font.size,W.font.size)+e.height}return 0}function $d(i,t,e){return e=B(e)?e:[e],{w:Nc(i,t.string,e),h:e.length*t.lineHeight}}function wa(i,t,e,n,s){return i===n||i===s?{start:t-e/2,end:t+e/2}:i<n||i>s?{start:t-e,end:t}:{start:t,end:t+e}}function Bd(i){const t={l:i.left+i._padding.left,r:i.right-i._padding.right,t:i.top+i._padding.top,b:i.bottom-i._padding.bottom},e=Object.assign({},t),n=[],s=[],o=i._pointLabels.length,r=i.options.pointLabels,a=r.centerPointLabels?E/o:0;for(let l=0;l<o;l++){const c=r.setContext(i.getPointLabelContext(l));s[l]=c.padding;const h=i.getPointPosition(l,i.drawingArea+s[l],a),u=Y(c.font),f=$d(i.ctx,u,i._pointLabels[l]);n[l]=f;const d=K(i.getIndexAngle(l)+a),g=Math.round(kn(d)),p=wa(g,h.x,f.w,0,180),m=wa(g,h.y,f.h,90,270);Nd(e,t,d,p,m)}i.setCenterPoint(t.l-e.l,e.r-t.r,t.t-e.t,e.b-t.b),i._pointLabelItems=Hd(i,n,s)}function Nd(i,t,e,n,s){const o=Math.abs(Math.sin(e)),r=Math.abs(Math.cos(e));let a=0,l=0;n.start<t.l?(a=(t.l-n.start)/o,i.l=Math.min(i.l,t.l-a)):n.end>t.r&&(a=(n.end-t.r)/o,i.r=Math.max(i.r,t.r+a)),s.start<t.t?(l=(t.t-s.start)/r,i.t=Math.min(i.t,t.t-l)):s.end>t.b&&(l=(s.end-t.b)/r,i.b=Math.max(i.b,t.b+l))}function Vd(i,t,e){const n=i.drawingArea,{extra:s,additionalAngle:o,padding:r,size:a}=e,l=i.getPointPosition(t,n+s+r,o),c=Math.round(kn(K(l.angle+H))),h=Ud(l.y,a.h,c),u=jd(c),f=Yd(l.x,a.w,u);return{visible:!0,x:l.x,y:h,textAlign:u,left:f,top:h,right:f+a.w,bottom:h+a.h}}function Wd(i,t){if(!t)return!0;const{left:e,top:n,right:s,bottom:o}=i;return!(Ot({x:e,y:n},t)||Ot({x:e,y:o},t)||Ot({x:s,y:n},t)||Ot({x:s,y:o},t))}function Hd(i,t,e){const n=[],s=i._pointLabels.length,o=i.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:ns(o)/2,additionalAngle:r?E/s:0};let c;for(let h=0;h<s;h++){l.padding=e[h],l.size=t[h];const u=Vd(i,h,l);n.push(u),a==="auto"&&(u.visible=Wd(u,c),u.visible&&(c=u))}return n}function jd(i){return i===0||i===180?"center":i<180?"left":"right"}function Yd(i,t,e){return e==="right"?i-=t:e==="center"&&(i-=t/2),i}function Ud(i,t,e){return e===90||e===270?i-=t/2:(e>270||e<90)&&(i-=t),i}function Xd(i,t,e){const{left:n,top:s,right:o,bottom:r}=e,{backdropColor:a}=t;if(!A(a)){const l=oe(t.borderRadius),c=Z(t.backdropPadding);i.fillStyle=a;const h=n-c.left,u=s-c.top,f=o-n+c.width,d=r-s+c.height;Object.values(l).some(g=>g!==0)?(i.beginPath(),qe(i,{x:h,y:u,w:f,h:d,radius:l}),i.fill()):i.fillRect(h,u,f,d)}}function qd(i,t){const{ctx:e,options:{pointLabels:n}}=i;for(let s=t-1;s>=0;s--){const o=i._pointLabelItems[s];if(!o.visible)continue;const r=n.setContext(i.getPointLabelContext(s));Xd(e,r,o);const a=Y(r.font),{x:l,y:c,textAlign:h}=o;se(e,i._pointLabels[s],l,c+a.lineHeight/2,a,{color:r.color,textAlign:h,textBaseline:"middle"})}}function Ma(i,t,e,n){const{ctx:s}=i;if(e)s.arc(i.xCenter,i.yCenter,t,0,$);else{let o=i.getPointPosition(0,t);s.moveTo(o.x,o.y);for(let r=1;r<n;r++)o=i.getPointPosition(r,t),s.lineTo(o.x,o.y)}}function Kd(i,t,e,n,s){const o=i.ctx,r=t.circular,{color:a,lineWidth:l}=t;!r&&!n||!a||!l||e<0||(o.save(),o.strokeStyle=a,o.lineWidth=l,o.setLineDash(s.dash||[]),o.lineDashOffset=s.dashOffset,o.beginPath(),Ma(i,e,r,n),o.closePath(),o.stroke(),o.restore())}function Gd(i,t,e){return Xt(i,{label:e,index:t,type:"pointLabel"})}class Zd extends Zi{static id="radialLinear";static defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ai.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=Z(ns(this.options)/2),e=this.width=this.maxWidth-t.width,n=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+n/2+t.top),this.drawingArea=Math.floor(Math.min(e,n)/2)}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!1);this.min=V(t)&&!isNaN(t)?t:0,this.max=V(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/ns(this.options))}generateTickLabels(t){Zi.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,n)=>{const s=z(this.options.pointLabels.callback,[e,n],this);return s||s===0?s:""}).filter((e,n)=>this.chart.getDataVisibility(n))}fit(){const t=this.options;t.display&&t.pointLabels.display?Bd(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,n,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((n-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,n,s))}getIndexAngle(t){const e=$/(this._pointLabels.length||1),n=this.options.startAngle||0;return K(t*e+_t(n))}getDistanceFromCenterForValue(t){if(A(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(A(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t<e.length){const n=e[t];return Gd(this.getContext(),t,n)}}getPointPosition(t,e,n=0){const s=this.getIndexAngle(t)-H+n;return{x:Math.cos(s)*e+this.xCenter,y:Math.sin(s)*e+this.yCenter,angle:s}}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:n,right:s,bottom:o}=this._pointLabelItems[t];return{left:e,top:n,right:s,bottom:o}}drawBackground(){const{backgroundColor:t,grid:{circular:e}}=this.options;if(t){const n=this.ctx;n.save(),n.beginPath(),Ma(this,this.getDistanceFromCenterForValue(this._endValue),e,this._pointLabels.length),n.closePath(),n.fillStyle=t,n.fill(),n.restore()}}drawGrid(){const t=this.ctx,e=this.options,{angleLines:n,grid:s,border:o}=e,r=this._pointLabels.length;let a,l,c;if(e.pointLabels.display&&qd(this,r),s.display&&this.ticks.forEach((h,u)=>{if(u!==0||u===0&&this.min<0){l=this.getDistanceFromCenterForValue(h.value);const f=this.getContext(u),d=s.setContext(f),g=o.setContext(f);Kd(this,d,l,r,g)}}),n.display){for(t.save(),a=r-1;a>=0;a--){const h=n.setContext(this.getPointLabelContext(a)),{color:u,lineWidth:f}=h;!f||!u||(t.lineWidth=f,t.strokeStyle=u,t.setLineDash(h.borderDash),t.lineDashOffset=h.borderDashOffset,l=this.getDistanceFromCenterForValue(e.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,n=e.ticks;if(!n.display)return;const s=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!e.reverse)return;const c=n.setContext(this.getContext(l)),h=Y(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=h.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const u=Z(c.backdropPadding);t.fillRect(-r/2-u.left,-o-h.size/2-u.top,r+u.width,h.size+u.height)}se(t,a.label,0,-o,h,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}const Ji={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}},ot=Object.keys(Ji);function ka(i,t){return i-t}function Sa(i,t){if(A(t))return null;const e=i._adapter,{parser:n,round:s,isoWeekday:o}=i._parseOpts;let r=t;return typeof n=="function"&&(r=n(r)),V(r)||(r=typeof n=="string"?e.parse(r,n):e.parse(r)),r===null?null:(s&&(r=s==="week"&&(ke(o)||o===!0)?e.startOf(r,"isoWeek",o):e.startOf(r,s)),+r)}function Pa(i,t,e,n){const s=ot.length;for(let o=ot.indexOf(i);o<s-1;++o){const r=Ji[ot[o]],a=r.steps?r.steps:Number.MAX_SAFE_INTEGER;if(r.common&&Math.ceil((e-t)/(a*r.size))<=n)return ot[o]}return ot[s-1]}function Jd(i,t,e,n,s){for(let o=ot.length-1;o>=ot.indexOf(e);o--){const r=ot[o];if(Ji[r].common&&i._adapter.diff(s,n,r)>=t-1)return r}return ot[e?ot.indexOf(e):0]}function Qd(i){for(let t=ot.indexOf(i)+1,e=ot.length;t<e;++t)if(Ji[ot[t]].common)return ot[t]}function Da(i,t,e){if(!e)i[t]=!0;else if(e.length){const{lo:n,hi:s}=Pn(e,t),o=e[n]>=t?e[n]:e[s];i[o]=!0}}function tg(i,t,e,n){const s=i._adapter,o=+s.startOf(t[0].value,n),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,n))l=e[a],l>=0&&(t[l].major=!0);return t}function Ca(i,t,e){const n=[],s={},o=t.length;let r,a;for(r=0;r<o;++r)a=t[r],s[a]=r,n.push({value:a,major:!1});return o===0||!e?n:tg(i,n,s,e)}class ss extends he{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};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 n=t.time||(t.time={}),s=this._adapter=new cu._date(t.adapters.date);s.init(e),Ve(n.displayFormats,s.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return t===void 0?null:Sa(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,n=t.time.unit||"day";let{min:s,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function l(c){!r&&!isNaN(c.min)&&(s=Math.min(s,c.min)),!a&&!isNaN(c.max)&&(o=Math.max(o,c.max))}(!r||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),s=V(s)&&!isNaN(s)?s:+e.startOf(Date.now(),n),o=V(o)&&!isNaN(o)?o:+e.endOf(Date.now(),n)+1,this.min=Math.min(s,o-1),this.max=Math.max(s+1,o)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],n=t[t.length-1]),{min:e,max:n}}buildTicks(){const t=this.options,e=t.time,n=t.ticks,s=n.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const o=this.min,r=this.max,a=Dc(s,o,r);return this._unit=e.unit||(n.autoSkip?Pa(e.minUnit,this.min,this.max,this._getLabelCapacity(o)):Jd(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=!n.major.enabled||this._unit==="year"?void 0:Qd(this._unit),this.initOffsets(s),t.reverse&&a.reverse(),Ca(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let e=0,n=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?e=1-s:e=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?n=o:n=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;e=X(e,0,r),n=X(n,0,r),this._offsets={start:e,end:n,factor:1/(e+1+n)}}_generate(){const t=this._adapter,e=this.min,n=this.max,s=this.options,o=s.time,r=o.unit||Pa(o.minUnit,e,n,this._getLabelCapacity(e)),a=P(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=ke(l)||l===!0,h={};let u=e,f,d;if(c&&(u=+t.startOf(u,"isoWeek",l)),u=+t.startOf(u,c?"day":r),t.diff(n,e,r)>1e5*a)throw new Error(e+" and "+n+" are too far apart with stepSize of "+a+" "+r);const g=s.ticks.source==="data"&&this.getDataTimestamps();for(f=u,d=0;f<n;f=+t.add(f,a,r),d++)Da(h,f,g);return(f===n||s.bounds==="ticks"||d===1)&&Da(h,f,g),Object.keys(h).sort(ka).map(p=>+p)}getLabelForValue(t){const e=this._adapter,n=this.options.time;return n.tooltipFormat?e.format(t,n.tooltipFormat):e.format(t,n.displayFormats.datetime)}format(t,e){const s=this.options.time.displayFormats,o=this._unit,r=e||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,n,s){const o=this.options,r=o.ticks.callback;if(r)return z(r,[t,e,n],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,h=l&&a[l],u=c&&a[c],f=n[e],d=c&&u&&f&&f.major;return this._adapter.format(t,s||(d?u:h))}generateTickLabels(t){let e,n,s;for(e=0,n=t.length;e<n;++e)s=t[e],s.label=this._tickFormatFunction(s.value,e,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const e=this._offsets,n=this.getDecimalForValue(t);return this.getPixelForDecimal((e.start+n)*e.factor)}getValueForPixel(t){const e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return this.min+n*(this.max-this.min)}_getLabelSize(t){const e=this.options.ticks,n=this.ctx.measureText(t).width,s=_t(this.isHorizontal()?e.maxRotation:e.minRotation),o=Math.cos(s),r=Math.sin(s),a=this._resolveTickFontOptions(0).size;return{w:n*o+a*r,h:n*r+a*o}}_getLabelCapacity(t){const e=this.options.time,n=e.displayFormats,s=n[e.unit]||n.millisecond,o=this._tickFormatFunction(t,0,Ca(this,[t],this._majorUnit),s),r=this._getLabelSize(o),a=Math.floor(this.isHorizontal()?this.width/r.w:this.height/r.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,n;if(t.length)return t;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(e=0,n=s.length;e<n;++e)t=t.concat(s[e].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let e,n;if(t.length)return t;const s=this.getLabels();for(e=0,n=s.length;e<n;++e)t.push(Sa(this,s[e]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return Oo(t.sort(ka))}}function Qi(i,t,e){let n=0,s=i.length-1,o,r,a,l;e?(t>=i[n].pos&&t<=i[s].pos&&({lo:n,hi:s}=At(i,"pos",t)),{pos:o,time:a}=i[n],{pos:r,time:l}=i[s]):(t>=i[n].time&&t<=i[s].time&&({lo:n,hi:s}=At(i,"time",t)),{time:o,pos:a}=i[n],{time:r,pos:l}=i[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class eg extends ss{static id="timeseries";static defaults=ss.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=Qi(e,this.min),this._tableRange=Qi(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:n}=this,s=[],o=[];let r,a,l,c,h;for(r=0,a=t.length;r<a;++r)c=t[r],c>=e&&c<=n&&s.push(c);if(s.length<2)return[{time:e,pos:0},{time:n,pos:1}];for(r=0,a=s.length;r<a;++r)h=s[r+1],l=s[r-1],c=s[r],Math.round((h+l)/2)!==c&&o.push({time:c,pos:r/(a-1)});return o}_generate(){const t=this.min,e=this.max;let n=super.getDataTimestamps();return(!n.includes(t)||!n.length)&&n.splice(0,0,t),(!n.includes(e)||n.length===1)&&n.push(e),n.sort((s,o)=>s-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),n=this.getLabelTimestamps();return e.length&&n.length?t=this.normalize(e.concat(n)):t=e.length?e:n,t=this._cache.all=t,t}getDecimalForValue(t){return(Qi(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return Qi(this._table,n*this._tableRange+this._minPos,!0)}}var ig=Ol('<div part="container" class="chart-container svelte-32pzn6" id="chart-container"><canvas id="canvas" class="svelte-32pzn6"></canvas></div>');const ng={hash:"svelte-32pzn6",code:'@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");:host {font-family:"Roboto", sans-serif;width:100%;height:auto;}.chart-container.svelte-32pzn6 {position:relative;margin:auto;width:100%;height:100%;overflow:hidden;}#canvas.svelte-32pzn6 {margin:auto;display:block;max-width:100%;max-height:100%;width:100%;height:auto;}'};function Aa(i,t){xs(t,!0),Fl(i,ng);const e=t.$$host;Kn.register(Sf,Xi,Vf,If,eu,iu,yr,su,ru,ou,au,lu,Ed,Rd,zd,Zd,ss,eg,Yf,ud,bd,xd,Cd,yd);function n(m,b){t.$$host.dispatchEvent(new CustomEvent(m,{detail:b}))}let s=ao(t,"id",7,""),o=ao(t,"data",7,void 0),r=null,a=!1,l=kt(void 0);Bs(()=>{o()&&typeof o()=="string"&&(o(JSON.parse(o())),h())});function c(m){const b=U(l)?.getElementsAtEventForMode(m,"nearest",{intersect:!0},!0);let _={};if(b?.length){const y=b[0];_.label=U(l)?.data?.labels?.[y.index],_.value=U(l)?.data.datasets[y.datasetIndex].data[y.index]}n("chartClick",_)}function h(){if(a&&o()&&e?.shadowRoot?.getElementById("canvas")){U(l)&&(U(l).destroy(),dt(l,void 0));const m=e?.shadowRoot?.getElementById("chart-container"),b=m?.clientWidth??0,_=m?.clientHeight??0,y=b>0&&_>0?b/_:void 0,v={responsive:!0,maintainAspectRatio:!0,...y?{aspectRatio:y}:{}};dt(l,new Kn(e?.shadowRoot?.getElementById("canvas"),{type:o().type,data:o().data,options:{...o().options||{},...v}}),!0)}}const u=ho(()=>{console.log("handleResize");const m=U(l)?.canvas||void 0;if(!(!U(l)||!m||!m.isConnected))try{h()}catch(b){console.warn("Chart resize failed",b)}},100);ro(()=>{a=!0,e?.shadowRoot?.getElementById("chart-container")&&(r=new ResizeObserver(()=>{u()}),r.observe(e.shadowRoot.getElementById("chart-container"))),window.addEventListener("resize",u),h()}),Il(()=>{console.log("onDestroy"),window.removeEventListener("resize",u),r&&(r.disconnect(),r=null),U(l)&&(U(l).destroy(),dt(l,void 0))});var f={get id(){return s()},set id(m=""){s(m),fn()},get data(){return o()},set data(m=void 0){o(m),fn()}},d=ig(),g=fl(d),p=al(()=>ho(c,200));return g.__click=function(...m){U(p)?.apply(this,m)},Ja(d),no(i,d),ys(f)}Cl(["click"]),customElements.define("hb-chartjs",Nl(Aa,{id:{},data:{}},[],[],!0)),os.Component=Aa,Object.defineProperty(os,Symbol.toStringTag,{value:"Module"})})(this.chartjs=this.chartjs||{});
19
+ `):i}function vd(i,t){const{element:e,datasetIndex:n,index:s}=t,o=i.getDatasetMeta(n).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:i,label:r,parsed:o.getParsed(s),raw:i.data.datasets[n].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:n,element:e}}function ua(i,t){const e=i.chart.ctx,{body:n,footer:s,title:o}=i,{boxWidth:r,boxHeight:a}=t,l=Y(t.bodyFont),c=Y(t.titleFont),h=Y(t.footerFont),u=o.length,f=s.length,d=n.length,g=Z(t.padding);let p=g.height,m=0,b=n.reduce((v,x)=>v+x.before.length+x.lines.length+x.after.length,0);if(b+=i.beforeBody.length+i.afterBody.length,u&&(p+=u*c.lineHeight+(u-1)*t.titleSpacing+t.titleMarginBottom),b){const v=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;p+=d*v+(b-d)*l.lineHeight+(b-1)*t.bodySpacing}f&&(p+=t.footerMarginTop+f*h.lineHeight+(f-1)*t.footerSpacing);let _=0;const y=function(v){m=Math.max(m,e.measureText(v).width+_)};return e.save(),e.font=c.string,I(i.title,y),e.font=l.string,I(i.beforeBody.concat(i.afterBody),y),_=t.displayColors?r+2+t.boxPadding:0,I(n,v=>{I(v.before,y),I(v.lines,y),I(v.after,y)}),_=0,e.font=h.string,I(i.footer,y),e.restore(),m+=g.width,{width:m,height:p}}function wd(i,t){const{y:e,height:n}=t;return e<n/2?"top":e>i.height-n/2?"bottom":"center"}function Md(i,t,e,n){const{x:s,width:o}=n,r=e.caretSize+e.caretPadding;if(i==="left"&&s+o+r>t.width||i==="right"&&s-o-r<0)return!0}function kd(i,t,e,n){const{x:s,width:o}=e,{width:r,chartArea:{left:a,right:l}}=i;let c="center";return n==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),Md(c,i,t,e)&&(c="center"),c}function fa(i,t,e){const n=e.yAlign||t.yAlign||wd(i,e);return{xAlign:e.xAlign||t.xAlign||kd(i,t,e,n),yAlign:n}}function Sd(i,t){let{x:e,width:n}=i;return t==="right"?e-=n:t==="center"&&(e-=n/2),e}function Pd(i,t,e){let{y:n,height:s}=i;return t==="top"?n+=e:t==="bottom"?n-=s+e:n-=s/2,n}function da(i,t,e,n){const{caretSize:s,caretPadding:o,cornerRadius:r}=i,{xAlign:a,yAlign:l}=e,c=s+o,{topLeft:h,topRight:u,bottomLeft:f,bottomRight:d}=oe(r);let g=Sd(t,a);const p=Pd(t,l,c);return l==="center"?a==="left"?g+=c:a==="right"&&(g-=c):a==="left"?g-=Math.max(h,f)+s:a==="right"&&(g+=Math.max(u,d)+s),{x:X(g,0,n.width-t.width),y:X(p,0,n.height-t.height)}}function Gi(i,t,e){const n=Z(e.padding);return t==="center"?i.x+i.width/2:t==="right"?i.x+i.width-n.right:i.x+n.left}function ga(i){return Mt([],Lt(i))}function Dd(i,t,e){return Xt(i,{tooltip:t,tooltipItems:e,type:"tooltip"})}function pa(i,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?i.override(e):i}const ma={beforeTitle:Dt,title(i){if(i.length>0){const t=i[0],e=t.chart.data.labels,n=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(n>0&&t.dataIndex<n)return e[t.dataIndex]}return""},afterTitle:Dt,beforeBody:Dt,beforeLabel:Dt,label(i){if(this&&this.options&&this.options.mode==="dataset")return i.label+": "+i.formattedValue||i.formattedValue;let t=i.dataset.label||"";t&&(t+=": ");const e=i.formattedValue;return A(e)||(t+=e),t},labelColor(i){const e=i.chart.getDatasetMeta(i.datasetIndex).controller.getStyle(i.dataIndex);return{borderColor:e.borderColor,backgroundColor:e.backgroundColor,borderWidth:e.borderWidth,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(i){const e=i.chart.getDatasetMeta(i.datasetIndex).controller.getStyle(i.dataIndex);return{pointStyle:e.pointStyle,rotation:e.rotation}},afterLabel:Dt,afterBody:Dt,beforeFooter:Dt,footer:Dt,afterFooter:Dt};function st(i,t,e,n){const s=i[t].call(e,n);return typeof s>"u"?ma[t].call(e,n):s}class ba extends Et{static positioners=ni;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,n=this.options.setContext(this.getContext()),s=n.enabled&&e.options.animation&&n.animations,o=new cr(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=Dd(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:n}=e,s=st(n,"beforeTitle",this,t),o=st(n,"title",this,t),r=st(n,"afterTitle",this,t);let a=[];return a=Mt(a,Lt(s)),a=Mt(a,Lt(o)),a=Mt(a,Lt(r)),a}getBeforeBody(t,e){return ga(st(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:n}=e,s=[];return I(t,o=>{const r={before:[],lines:[],after:[]},a=pa(n,o);Mt(r.before,Lt(st(a,"beforeLabel",this,o))),Mt(r.lines,st(a,"label",this,o)),Mt(r.after,Lt(st(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,e){return ga(st(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:n}=e,s=st(n,"beforeFooter",this,t),o=st(n,"footer",this,t),r=st(n,"afterFooter",this,t);let a=[];return a=Mt(a,Lt(s)),a=Mt(a,Lt(o)),a=Mt(a,Lt(r)),a}_createItems(t){const e=this._active,n=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=e.length;l<c;++l)a.push(vd(this.chart,e[l]));return t.filter&&(a=a.filter((h,u,f)=>t.filter(h,u,f,n))),t.itemSort&&(a=a.sort((h,u)=>t.itemSort(h,u,n))),I(a,h=>{const u=pa(t.callbacks,h);s.push(st(u,"labelColor",this,h)),o.push(st(u,"labelPointStyle",this,h)),r.push(st(u,"labelTextColor",this,h))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){const n=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=ni[n.position].call(this,s,this._eventPosition);r=this._createItems(n),this.title=this.getTitle(r,n),this.beforeBody=this.getBeforeBody(r,n),this.body=this.getBody(r,n),this.afterBody=this.getAfterBody(r,n),this.footer=this.getFooter(r,n);const l=this._size=ua(this,n),c=Object.assign({},a,l),h=fa(this.chart,n,c),u=da(n,c,h,this.chart);this.xAlign=h.xAlign,this.yAlign=h.yAlign,o={opacity:1,x:u.x,y:u.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,n,s){const o=this.getCaretPosition(t,n,s);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,n){const{xAlign:s,yAlign:o}=this,{caretSize:r,cornerRadius:a}=n,{topLeft:l,topRight:c,bottomLeft:h,bottomRight:u}=oe(a),{x:f,y:d}=t,{width:g,height:p}=e;let m,b,_,y,v,x;return o==="center"?(v=d+p/2,s==="left"?(m=f,b=m-r,y=v+r,x=v-r):(m=f+g,b=m+r,y=v-r,x=v+r),_=m):(s==="left"?b=f+Math.max(l,h)+r:s==="right"?b=f+g-Math.max(c,u)-r:b=this.caretX,o==="top"?(y=d,v=y-r,m=b-r,_=b+r):(y=d+p,v=y+r,m=b+r,_=b-r),x=y),{x1:m,x2:b,x3:_,y1:y,y2:v,y3:x}}drawTitle(t,e,n){const s=this.title,o=s.length;let r,a,l;if(o){const c=De(n.rtl,this.x,this.width);for(t.x=Gi(this,n.titleAlign,n),e.textAlign=c.textAlign(n.titleAlign),e.textBaseline="middle",r=Y(n.titleFont),a=n.titleSpacing,e.fillStyle=n.titleColor,e.font=r.string,l=0;l<o;++l)e.fillText(s[l],c.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+a,l+1===o&&(t.y+=n.titleMarginBottom-a)}}_drawColorBox(t,e,n,s,o){const r=this.labelColors[n],a=this.labelPointStyles[n],{boxHeight:l,boxWidth:c}=o,h=Y(o.bodyFont),u=Gi(this,"left",o),f=s.x(u),d=l<h.lineHeight?(h.lineHeight-l)/2:0,g=e.y+d;if(o.usePointStyle){const p={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},m=s.leftForLtr(f,c)+c/2,b=g+l/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,En(t,p,m,b),t.strokeStyle=r.borderColor,t.fillStyle=r.backgroundColor,En(t,p,m,b)}else{t.lineWidth=O(r.borderWidth)?Math.max(...Object.values(r.borderWidth)):r.borderWidth||1,t.strokeStyle=r.borderColor,t.setLineDash(r.borderDash||[]),t.lineDashOffset=r.borderDashOffset||0;const p=s.leftForLtr(f,c),m=s.leftForLtr(s.xPlus(f,1),c-2),b=oe(r.borderRadius);Object.values(b).some(_=>_!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,qe(t,{x:p,y:g,w:c,h:l,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),qe(t,{x:m,y:g+1,w:c-2,h:l-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(p,g,c,l),t.strokeRect(p,g,c,l),t.fillStyle=r.backgroundColor,t.fillRect(m,g+1,c-2,l-2))}t.fillStyle=this.labelTextColors[n]}drawBody(t,e,n){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:h}=n,u=Y(n.bodyFont);let f=u.lineHeight,d=0;const g=De(n.rtl,this.x,this.width),p=function(k){e.fillText(k,g.x(t.x+d),t.y+f/2),t.y+=f+o},m=g.textAlign(r);let b,_,y,v,x,w,M;for(e.textAlign=r,e.textBaseline="middle",e.font=u.string,t.x=Gi(this,m,n),e.fillStyle=n.bodyColor,I(this.beforeBody,p),d=a&&m!=="right"?r==="center"?c/2+h:c+2+h:0,v=0,w=s.length;v<w;++v){for(b=s[v],_=this.labelTextColors[v],e.fillStyle=_,I(b.before,p),y=b.lines,a&&y.length&&(this._drawColorBox(e,t,v,g,n),f=Math.max(u.lineHeight,l)),x=0,M=y.length;x<M;++x)p(y[x]),f=u.lineHeight;I(b.after,p)}d=0,f=u.lineHeight,I(this.afterBody,p),t.y-=o}drawFooter(t,e,n){const s=this.footer,o=s.length;let r,a;if(o){const l=De(n.rtl,this.x,this.width);for(t.x=Gi(this,n.footerAlign,n),t.y+=n.footerMarginTop,e.textAlign=l.textAlign(n.footerAlign),e.textBaseline="middle",r=Y(n.footerFont),e.fillStyle=n.footerColor,e.font=r.string,a=0;a<o;++a)e.fillText(s[a],l.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+n.footerSpacing}}drawBackground(t,e,n,s){const{xAlign:o,yAlign:r}=this,{x:a,y:l}=t,{width:c,height:h}=n,{topLeft:u,topRight:f,bottomLeft:d,bottomRight:g}=oe(s.cornerRadius);e.fillStyle=s.backgroundColor,e.strokeStyle=s.borderColor,e.lineWidth=s.borderWidth,e.beginPath(),e.moveTo(a+u,l),r==="top"&&this.drawCaret(t,e,n,s),e.lineTo(a+c-f,l),e.quadraticCurveTo(a+c,l,a+c,l+f),r==="center"&&o==="right"&&this.drawCaret(t,e,n,s),e.lineTo(a+c,l+h-g),e.quadraticCurveTo(a+c,l+h,a+c-g,l+h),r==="bottom"&&this.drawCaret(t,e,n,s),e.lineTo(a+d,l+h),e.quadraticCurveTo(a,l+h,a,l+h-d),r==="center"&&o==="left"&&this.drawCaret(t,e,n,s),e.lineTo(a,l+u),e.quadraticCurveTo(a,l,a+u,l),e.closePath(),e.fill(),s.borderWidth>0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,n=this.$animations,s=n&&n.x,o=n&&n.y;if(s||o){const r=ni[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=ua(this,t),l=Object.assign({},r,this._size),c=fa(e,t,l),h=da(t,l,c,e);(s._to!==h.x||o._to!==h.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,h))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let n=this.opacity;if(!n)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;const r=Z(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=n,this.drawBackground(o,t,s,e),Qo(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),tr(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const n=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!Si(n,s),r=this._positionChanged(s,e);(o||r)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,n=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],r=this._getActiveElements(t,o,e,n),a=this._positionChanged(r,t),l=e||!Si(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,n,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return e.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const r=this.chart.getElementsAtEventForMode(t,o.mode,o,n);return o.reverse&&r.reverse(),r}_positionChanged(t,e){const{caretX:n,caretY:s,options:o}=this,r=ni[o.position].call(this,t,e);return r!==!1&&(n!==r.x||s!==r.y)}}var Cd={id:"tooltip",_element:ba,positioners:ni,afterInit(i,t,e){e&&(i.tooltip=new ba({chart:i,options:e}))},beforeUpdate(i,t,e){i.tooltip&&i.tooltip.initialize(e)},reset(i,t,e){i.tooltip&&i.tooltip.initialize(e)},afterDraw(i){const t=i.tooltip;if(t&&t._willRender()){const e={tooltip:t};if(i.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(i.ctx),i.notifyPlugins("afterTooltipDraw",e)}},afterEvent(i,t){if(i.tooltip){const e=t.replay;i.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(i,t)=>t.bodyFont.size,boxWidth:(i,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:ma},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:i=>i!=="filter"&&i!=="itemSort"&&i!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const Ad=(i,t,e,n)=>(typeof t=="string"?(e=i.push(t)-1,n.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function Od(i,t,e,n){const s=i.indexOf(t);if(s===-1)return Ad(i,t,e,n);const o=i.lastIndexOf(t);return s!==o?e:s}const Td=(i,t)=>i===null?null:X(Math.round(i),0,t);function _a(i){const t=this.getLabels();return i>=0&&i<t.length?t[i]:i}class Ed extends he{static id="category";static defaults={ticks:{callback:_a}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const n=this.getLabels();for(const{index:s,label:o}of e)n[s]===o&&n.splice(s,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(A(t))return null;const n=this.getLabels();return e=isFinite(e)&&n[e]===t?e:Od(n,t,P(e,t),this._addedLabels),Td(e,n.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:n,max:s}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(n=0),e||(s=this.getLabels().length-1)),this.min=n,this.max=s}buildTicks(){const t=this.min,e=this.max,n=this.options.offset,s=[];let o=this.getLabels();o=t===0&&e===o.length-1?o:o.slice(t,e+1),this._valueRange=Math.max(o.length-(n?0:1),1),this._startValue=this.min-(n?.5:0);for(let r=t;r<=e;r++)s.push({value:r});return s}getLabelForValue(t){return _a.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function Ld(i,t){const e=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:h,maxDigits:u,includeBounds:f}=i,d=o||1,g=h-1,{min:p,max:m}=t,b=!A(r),_=!A(a),y=!A(c),v=(m-p)/(u+1);let x=ko((m-p)/g/d)*d,w,M,k,S;if(x<1e-14&&!b&&!_)return[{value:p},{value:m}];S=Math.ceil(m/x)-Math.floor(p/x),S>g&&(x=ko(S*x/g/d)*d),A(l)||(w=Math.pow(10,l),x=Math.ceil(x*w)/w),s==="ticks"?(M=Math.floor(p/x)*x,k=Math.ceil(m/x)*x):(M=p,k=m),b&&_&&o&&Mc((a-r)/o,x/1e3)?(S=Math.round(Math.min((a-r)/x,h)),x=(a-r)/S,M=r,k=a):y?(M=b?r:M,k=_?a:k,S=c-1,x=(k-M)/S):(S=(k-M)/x,He(S,Math.round(S),x/1e3)?S=Math.round(S):S=Math.ceil(S));const D=Math.max(Po(x),Po(M));w=Math.pow(10,A(l)?D:l),M=Math.round(M*w)/w,k=Math.round(k*w)/w;let C=0;for(b&&(f&&M!==r?(e.push({value:r}),M<r&&C++,He(Math.round((M+C*x)*w)/w,r,xa(r,v,i))&&C++):M<r&&C++);C<S;++C){const T=Math.round((M+C*x)*w)/w;if(_&&T>a)break;e.push({value:T})}return _&&f&&k!==a?e.length&&He(e[e.length-1].value,a,xa(a,v,i))?e[e.length-1].value=a:e.push({value:a}):(!_||k===a)&&e.push({value:k}),e}function xa(i,t,{horizontal:e,minRotation:n}){const s=_t(n),o=(e?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+i).length;return Math.min(t/o,r)}class Zi extends he{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return A(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:n}=this.getUserBounds();let{min:s,max:o}=this;const r=l=>s=e?s:l,a=l=>o=n?o:l;if(t){const l=vt(s),c=vt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:n}=t,s;return n?(s=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,s>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${s} ticks. Limiting to 1000.`),s=1e3)):(s=this.computeTickLimit(),e=e||11),e&&(s=Math.min(e,s)),s}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let n=this.getTickLimit();n=Math.max(2,n);const s={maxTicks:n,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==!1},o=this._range||this,r=Ld(s,o);return t.bounds==="ticks"&&So(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let e=this.min,n=this.max;if(super.configure(),this.options.offset&&t.length){const s=(n-e)/Math.max(t.length-1,1)/2;e-=s,n+=s}this._startValue=e,this._endValue=n,this._valueRange=n-e}getLabelForValue(t){return Ue(t,this.chart.options.locale,this.options.ticks.format)}}class Rd extends Zi{static id="linear";static defaults={ticks:{callback:Ai.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=V(t)?t:0,this.max=V(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,n=_t(this.options.ticks.minRotation),s=(t?Math.sin(n):Math.cos(n))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const si=i=>Math.floor(Ut(i)),ue=(i,t)=>Math.pow(10,si(i)+t);function ya(i){return i/Math.pow(10,si(i))===1}function va(i,t,e){const n=Math.pow(10,e),s=Math.floor(i/n);return Math.ceil(t/n)-s}function Id(i,t){const e=t-i;let n=si(e);for(;va(i,t,n)>10;)n++;for(;va(i,t,n)<10;)n--;return Math.min(n,si(i))}function Fd(i,{min:t,max:e}){t=ct(i.min,t);const n=[],s=si(t);let o=Id(t,e),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((t-l)*r)/r,h=Math.floor((t-l)/a/10)*a*10;let u=Math.floor((c-h)/Math.pow(10,o)),f=ct(i.min,Math.round((l+h+u*Math.pow(10,o))*r)/r);for(;f<e;)n.push({value:f,major:ya(f),significand:u}),u>=10?u=u<15?15:20:u++,u>=20&&(o++,u=2,r=o>=0?1:r),f=Math.round((l+h+u*Math.pow(10,o))*r)/r;const d=ct(i.max,f);return n.push({value:d,major:ya(d),significand:u}),n}class zd extends he{static id="logarithmic";static defaults={ticks:{callback:Ai.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const n=Zi.prototype.parse.apply(this,[t,e]);if(n===0){this._zero=!0;return}return V(n)&&n>0?n:null}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=V(t)?Math.max(0,t):null,this.max=V(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!V(this._userMin)&&(this.min=t===ue(this.min,0)?ue(this.min,-1):ue(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let n=this.min,s=this.max;const o=a=>n=t?n:a,r=a=>s=e?s:a;n===s&&(n<=0?(o(1),r(10)):(o(ue(n,-1)),r(ue(s,1)))),n<=0&&o(ue(s,-1)),s<=0&&r(ue(n,1)),this.min=n,this.max=s}buildTicks(){const t=this.options,e={min:this._userMin,max:this._userMax},n=Fd(e,this);return t.bounds==="ticks"&&So(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}getLabelForValue(t){return t===void 0?"0":Ue(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Ut(t),this._valueRange=Ut(this.max)-Ut(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Ut(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function ns(i){const t=i.ticks;if(t.display&&i.display){const e=Z(t.backdropPadding);return P(t.font&&t.font.size,W.font.size)+e.height}return 0}function $d(i,t,e){return e=B(e)?e:[e],{w:Nc(i,t.string,e),h:e.length*t.lineHeight}}function wa(i,t,e,n,s){return i===n||i===s?{start:t-e/2,end:t+e/2}:i<n||i>s?{start:t-e,end:t}:{start:t,end:t+e}}function Bd(i){const t={l:i.left+i._padding.left,r:i.right-i._padding.right,t:i.top+i._padding.top,b:i.bottom-i._padding.bottom},e=Object.assign({},t),n=[],s=[],o=i._pointLabels.length,r=i.options.pointLabels,a=r.centerPointLabels?E/o:0;for(let l=0;l<o;l++){const c=r.setContext(i.getPointLabelContext(l));s[l]=c.padding;const h=i.getPointPosition(l,i.drawingArea+s[l],a),u=Y(c.font),f=$d(i.ctx,u,i._pointLabels[l]);n[l]=f;const d=K(i.getIndexAngle(l)+a),g=Math.round(kn(d)),p=wa(g,h.x,f.w,0,180),m=wa(g,h.y,f.h,90,270);Nd(e,t,d,p,m)}i.setCenterPoint(t.l-e.l,e.r-t.r,t.t-e.t,e.b-t.b),i._pointLabelItems=Hd(i,n,s)}function Nd(i,t,e,n,s){const o=Math.abs(Math.sin(e)),r=Math.abs(Math.cos(e));let a=0,l=0;n.start<t.l?(a=(t.l-n.start)/o,i.l=Math.min(i.l,t.l-a)):n.end>t.r&&(a=(n.end-t.r)/o,i.r=Math.max(i.r,t.r+a)),s.start<t.t?(l=(t.t-s.start)/r,i.t=Math.min(i.t,t.t-l)):s.end>t.b&&(l=(s.end-t.b)/r,i.b=Math.max(i.b,t.b+l))}function Vd(i,t,e){const n=i.drawingArea,{extra:s,additionalAngle:o,padding:r,size:a}=e,l=i.getPointPosition(t,n+s+r,o),c=Math.round(kn(K(l.angle+H))),h=Ud(l.y,a.h,c),u=jd(c),f=Yd(l.x,a.w,u);return{visible:!0,x:l.x,y:h,textAlign:u,left:f,top:h,right:f+a.w,bottom:h+a.h}}function Wd(i,t){if(!t)return!0;const{left:e,top:n,right:s,bottom:o}=i;return!(Ot({x:e,y:n},t)||Ot({x:e,y:o},t)||Ot({x:s,y:n},t)||Ot({x:s,y:o},t))}function Hd(i,t,e){const n=[],s=i._pointLabels.length,o=i.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:ns(o)/2,additionalAngle:r?E/s:0};let c;for(let h=0;h<s;h++){l.padding=e[h],l.size=t[h];const u=Vd(i,h,l);n.push(u),a==="auto"&&(u.visible=Wd(u,c),u.visible&&(c=u))}return n}function jd(i){return i===0||i===180?"center":i<180?"left":"right"}function Yd(i,t,e){return e==="right"?i-=t:e==="center"&&(i-=t/2),i}function Ud(i,t,e){return e===90||e===270?i-=t/2:(e>270||e<90)&&(i-=t),i}function Xd(i,t,e){const{left:n,top:s,right:o,bottom:r}=e,{backdropColor:a}=t;if(!A(a)){const l=oe(t.borderRadius),c=Z(t.backdropPadding);i.fillStyle=a;const h=n-c.left,u=s-c.top,f=o-n+c.width,d=r-s+c.height;Object.values(l).some(g=>g!==0)?(i.beginPath(),qe(i,{x:h,y:u,w:f,h:d,radius:l}),i.fill()):i.fillRect(h,u,f,d)}}function qd(i,t){const{ctx:e,options:{pointLabels:n}}=i;for(let s=t-1;s>=0;s--){const o=i._pointLabelItems[s];if(!o.visible)continue;const r=n.setContext(i.getPointLabelContext(s));Xd(e,r,o);const a=Y(r.font),{x:l,y:c,textAlign:h}=o;se(e,i._pointLabels[s],l,c+a.lineHeight/2,a,{color:r.color,textAlign:h,textBaseline:"middle"})}}function Ma(i,t,e,n){const{ctx:s}=i;if(e)s.arc(i.xCenter,i.yCenter,t,0,$);else{let o=i.getPointPosition(0,t);s.moveTo(o.x,o.y);for(let r=1;r<n;r++)o=i.getPointPosition(r,t),s.lineTo(o.x,o.y)}}function Kd(i,t,e,n,s){const o=i.ctx,r=t.circular,{color:a,lineWidth:l}=t;!r&&!n||!a||!l||e<0||(o.save(),o.strokeStyle=a,o.lineWidth=l,o.setLineDash(s.dash||[]),o.lineDashOffset=s.dashOffset,o.beginPath(),Ma(i,e,r,n),o.closePath(),o.stroke(),o.restore())}function Gd(i,t,e){return Xt(i,{label:e,index:t,type:"pointLabel"})}class Zd extends Zi{static id="radialLinear";static defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ai.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=Z(ns(this.options)/2),e=this.width=this.maxWidth-t.width,n=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+n/2+t.top),this.drawingArea=Math.floor(Math.min(e,n)/2)}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!1);this.min=V(t)&&!isNaN(t)?t:0,this.max=V(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/ns(this.options))}generateTickLabels(t){Zi.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,n)=>{const s=z(this.options.pointLabels.callback,[e,n],this);return s||s===0?s:""}).filter((e,n)=>this.chart.getDataVisibility(n))}fit(){const t=this.options;t.display&&t.pointLabels.display?Bd(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,n,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((n-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,n,s))}getIndexAngle(t){const e=$/(this._pointLabels.length||1),n=this.options.startAngle||0;return K(t*e+_t(n))}getDistanceFromCenterForValue(t){if(A(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(A(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t<e.length){const n=e[t];return Gd(this.getContext(),t,n)}}getPointPosition(t,e,n=0){const s=this.getIndexAngle(t)-H+n;return{x:Math.cos(s)*e+this.xCenter,y:Math.sin(s)*e+this.yCenter,angle:s}}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:n,right:s,bottom:o}=this._pointLabelItems[t];return{left:e,top:n,right:s,bottom:o}}drawBackground(){const{backgroundColor:t,grid:{circular:e}}=this.options;if(t){const n=this.ctx;n.save(),n.beginPath(),Ma(this,this.getDistanceFromCenterForValue(this._endValue),e,this._pointLabels.length),n.closePath(),n.fillStyle=t,n.fill(),n.restore()}}drawGrid(){const t=this.ctx,e=this.options,{angleLines:n,grid:s,border:o}=e,r=this._pointLabels.length;let a,l,c;if(e.pointLabels.display&&qd(this,r),s.display&&this.ticks.forEach((h,u)=>{if(u!==0||u===0&&this.min<0){l=this.getDistanceFromCenterForValue(h.value);const f=this.getContext(u),d=s.setContext(f),g=o.setContext(f);Kd(this,d,l,r,g)}}),n.display){for(t.save(),a=r-1;a>=0;a--){const h=n.setContext(this.getPointLabelContext(a)),{color:u,lineWidth:f}=h;!f||!u||(t.lineWidth=f,t.strokeStyle=u,t.setLineDash(h.borderDash),t.lineDashOffset=h.borderDashOffset,l=this.getDistanceFromCenterForValue(e.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,n=e.ticks;if(!n.display)return;const s=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!e.reverse)return;const c=n.setContext(this.getContext(l)),h=Y(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=h.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const u=Z(c.backdropPadding);t.fillRect(-r/2-u.left,-o-h.size/2-u.top,r+u.width,h.size+u.height)}se(t,a.label,0,-o,h,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}const Ji={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}},ot=Object.keys(Ji);function ka(i,t){return i-t}function Sa(i,t){if(A(t))return null;const e=i._adapter,{parser:n,round:s,isoWeekday:o}=i._parseOpts;let r=t;return typeof n=="function"&&(r=n(r)),V(r)||(r=typeof n=="string"?e.parse(r,n):e.parse(r)),r===null?null:(s&&(r=s==="week"&&(ke(o)||o===!0)?e.startOf(r,"isoWeek",o):e.startOf(r,s)),+r)}function Pa(i,t,e,n){const s=ot.length;for(let o=ot.indexOf(i);o<s-1;++o){const r=Ji[ot[o]],a=r.steps?r.steps:Number.MAX_SAFE_INTEGER;if(r.common&&Math.ceil((e-t)/(a*r.size))<=n)return ot[o]}return ot[s-1]}function Jd(i,t,e,n,s){for(let o=ot.length-1;o>=ot.indexOf(e);o--){const r=ot[o];if(Ji[r].common&&i._adapter.diff(s,n,r)>=t-1)return r}return ot[e?ot.indexOf(e):0]}function Qd(i){for(let t=ot.indexOf(i)+1,e=ot.length;t<e;++t)if(Ji[ot[t]].common)return ot[t]}function Da(i,t,e){if(!e)i[t]=!0;else if(e.length){const{lo:n,hi:s}=Pn(e,t),o=e[n]>=t?e[n]:e[s];i[o]=!0}}function tg(i,t,e,n){const s=i._adapter,o=+s.startOf(t[0].value,n),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,n))l=e[a],l>=0&&(t[l].major=!0);return t}function Ca(i,t,e){const n=[],s={},o=t.length;let r,a;for(r=0;r<o;++r)a=t[r],s[a]=r,n.push({value:a,major:!1});return o===0||!e?n:tg(i,n,s,e)}class ss extends he{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};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 n=t.time||(t.time={}),s=this._adapter=new cu._date(t.adapters.date);s.init(e),Ve(n.displayFormats,s.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return t===void 0?null:Sa(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,n=t.time.unit||"day";let{min:s,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function l(c){!r&&!isNaN(c.min)&&(s=Math.min(s,c.min)),!a&&!isNaN(c.max)&&(o=Math.max(o,c.max))}(!r||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),s=V(s)&&!isNaN(s)?s:+e.startOf(Date.now(),n),o=V(o)&&!isNaN(o)?o:+e.endOf(Date.now(),n)+1,this.min=Math.min(s,o-1),this.max=Math.max(s+1,o)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],n=t[t.length-1]),{min:e,max:n}}buildTicks(){const t=this.options,e=t.time,n=t.ticks,s=n.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const o=this.min,r=this.max,a=Dc(s,o,r);return this._unit=e.unit||(n.autoSkip?Pa(e.minUnit,this.min,this.max,this._getLabelCapacity(o)):Jd(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=!n.major.enabled||this._unit==="year"?void 0:Qd(this._unit),this.initOffsets(s),t.reverse&&a.reverse(),Ca(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let e=0,n=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?e=1-s:e=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?n=o:n=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;e=X(e,0,r),n=X(n,0,r),this._offsets={start:e,end:n,factor:1/(e+1+n)}}_generate(){const t=this._adapter,e=this.min,n=this.max,s=this.options,o=s.time,r=o.unit||Pa(o.minUnit,e,n,this._getLabelCapacity(e)),a=P(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=ke(l)||l===!0,h={};let u=e,f,d;if(c&&(u=+t.startOf(u,"isoWeek",l)),u=+t.startOf(u,c?"day":r),t.diff(n,e,r)>1e5*a)throw new Error(e+" and "+n+" are too far apart with stepSize of "+a+" "+r);const g=s.ticks.source==="data"&&this.getDataTimestamps();for(f=u,d=0;f<n;f=+t.add(f,a,r),d++)Da(h,f,g);return(f===n||s.bounds==="ticks"||d===1)&&Da(h,f,g),Object.keys(h).sort(ka).map(p=>+p)}getLabelForValue(t){const e=this._adapter,n=this.options.time;return n.tooltipFormat?e.format(t,n.tooltipFormat):e.format(t,n.displayFormats.datetime)}format(t,e){const s=this.options.time.displayFormats,o=this._unit,r=e||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,n,s){const o=this.options,r=o.ticks.callback;if(r)return z(r,[t,e,n],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,h=l&&a[l],u=c&&a[c],f=n[e],d=c&&u&&f&&f.major;return this._adapter.format(t,s||(d?u:h))}generateTickLabels(t){let e,n,s;for(e=0,n=t.length;e<n;++e)s=t[e],s.label=this._tickFormatFunction(s.value,e,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const e=this._offsets,n=this.getDecimalForValue(t);return this.getPixelForDecimal((e.start+n)*e.factor)}getValueForPixel(t){const e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return this.min+n*(this.max-this.min)}_getLabelSize(t){const e=this.options.ticks,n=this.ctx.measureText(t).width,s=_t(this.isHorizontal()?e.maxRotation:e.minRotation),o=Math.cos(s),r=Math.sin(s),a=this._resolveTickFontOptions(0).size;return{w:n*o+a*r,h:n*r+a*o}}_getLabelCapacity(t){const e=this.options.time,n=e.displayFormats,s=n[e.unit]||n.millisecond,o=this._tickFormatFunction(t,0,Ca(this,[t],this._majorUnit),s),r=this._getLabelSize(o),a=Math.floor(this.isHorizontal()?this.width/r.w:this.height/r.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,n;if(t.length)return t;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(e=0,n=s.length;e<n;++e)t=t.concat(s[e].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let e,n;if(t.length)return t;const s=this.getLabels();for(e=0,n=s.length;e<n;++e)t.push(Sa(this,s[e]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return Oo(t.sort(ka))}}function Qi(i,t,e){let n=0,s=i.length-1,o,r,a,l;e?(t>=i[n].pos&&t<=i[s].pos&&({lo:n,hi:s}=At(i,"pos",t)),{pos:o,time:a}=i[n],{pos:r,time:l}=i[s]):(t>=i[n].time&&t<=i[s].time&&({lo:n,hi:s}=At(i,"time",t)),{time:o,pos:a}=i[n],{time:r,pos:l}=i[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class eg extends ss{static id="timeseries";static defaults=ss.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=Qi(e,this.min),this._tableRange=Qi(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:n}=this,s=[],o=[];let r,a,l,c,h;for(r=0,a=t.length;r<a;++r)c=t[r],c>=e&&c<=n&&s.push(c);if(s.length<2)return[{time:e,pos:0},{time:n,pos:1}];for(r=0,a=s.length;r<a;++r)h=s[r+1],l=s[r-1],c=s[r],Math.round((h+l)/2)!==c&&o.push({time:c,pos:r/(a-1)});return o}_generate(){const t=this.min,e=this.max;let n=super.getDataTimestamps();return(!n.includes(t)||!n.length)&&n.splice(0,0,t),(!n.includes(e)||n.length===1)&&n.push(e),n.sort((s,o)=>s-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),n=this.getLabelTimestamps();return e.length&&n.length?t=this.normalize(e.concat(n)):t=e.length?e:n,t=this._cache.all=t,t}getDecimalForValue(t){return(Qi(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return Qi(this._table,n*this._tableRange+this._minPos,!0)}}var ig=Ol('<div part="container" class="chart-container svelte-32pzn6" id="chart-container"><canvas id="canvas" class="svelte-32pzn6"></canvas></div>');const ng={hash:"svelte-32pzn6",code:'@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");:host {font-family:"Roboto", sans-serif;width:100%;height:auto;}.chart-container.svelte-32pzn6 {position:relative;margin:auto;width:100%;height:100%;overflow:hidden;}#canvas.svelte-32pzn6 {margin:auto;display:block;max-width:100%;max-height:100%;width:100%;height:auto;}'};function Aa(i,t){xs(t,!0),Fl(i,ng);const e=t.$$host;Kn.register(Sf,Xi,Vf,If,eu,iu,yr,su,ru,ou,au,lu,Ed,Rd,zd,Zd,ss,eg,Yf,ud,bd,xd,Cd,yd);function n(m,b){t.$$host.dispatchEvent(new CustomEvent(m,{detail:b}))}let s=ao(t,"id",7,""),o=ao(t,"data",7,void 0),r=null,a=!1,l=kt(void 0);Bs(()=>{o()&&typeof o()=="string"&&(o(JSON.parse(o())),h())});function c(m){const b=U(l)?.getElementsAtEventForMode(m,"nearest",{intersect:!0},!0);let _=[];if(b?.length)for(const y of b){const v=U(l)?.data?.labels?.[y.index],x=U(l)?.data.datasets[y.datasetIndex].data[y.index];_.push({label:v,value:x})}n("chartClick",_)}function h(){if(a&&o()&&e?.shadowRoot?.getElementById("canvas")){U(l)&&(U(l).destroy(),dt(l,void 0));const m=e?.shadowRoot?.getElementById("chart-container"),b=m?.clientWidth??0,_=m?.clientHeight??0,y=b>0&&_>0?b/_:void 0,v={responsive:!0,maintainAspectRatio:!0,...y?{aspectRatio:y}:{}};dt(l,new Kn(e?.shadowRoot?.getElementById("canvas"),{type:o().type,data:o().data,options:{...o().options||{},...v}}),!0)}}const u=ho(()=>{console.log("handleResize");const m=U(l)?.canvas||void 0;if(!(!U(l)||!m||!m.isConnected))try{h()}catch(b){console.warn("Chart resize failed",b)}},100);ro(()=>{a=!0,e?.shadowRoot?.getElementById("chart-container")&&(r=new ResizeObserver(()=>{u()}),r.observe(e.shadowRoot.getElementById("chart-container"))),window.addEventListener("resize",u),h()}),Il(()=>{console.log("onDestroy"),window.removeEventListener("resize",u),r&&(r.disconnect(),r=null),U(l)&&(U(l).destroy(),dt(l,void 0))});var f={get id(){return s()},set id(m=""){s(m),fn()},get data(){return o()},set data(m=void 0){o(m),fn()}},d=ig(),g=fl(d),p=al(()=>ho(c,200));return g.__click=function(...m){U(p)?.apply(this,m)},Ja(d),no(i,d),ys(f)}Cl(["click"]),customElements.define("hb-chartjs",Nl(Aa,{id:{},data:{}},[],[],!0)),os.Component=Aa,Object.defineProperty(os,Symbol.toStringTag,{value:"Module"})})(this.chartjs=this.chartjs||{});
20
20
  //# sourceMappingURL=main.iife.js.map