import{r as pn,a as Tt,e as $e,c as Ue,i as z,d as F,b as X,v as C,u as Ye,l as mn,f as Mt,g as B,h as Et,s as ct,j as ft,k as L,_ as Xe,t as tt,m as bn,n as xn,T as U,o as qt,p as Jt,H as Z,P as ot,q as Ke,w as Ge,x as St,y as qe,z as gt,A as _n,B as Rt,C as pt,D as Je,E as j,F as O,G as yn,I as Ze,J as Qe,K as vn,L as ti,M as ei,N as kn,O as J,Q as E,R as Mn,S as Y,U as _e,V as ii,W as Sn,X as mt,Y as Zt,Z as bt,$ as Qt,a0 as V,a1 as ye,a2 as $,a3 as wt,a4 as wn,a5 as Dn,a6 as si,a7 as te,a8 as ni,a9 as Pn,aa as Cn,ab as ee,ac as An,ad as Ln,ae as oi,af as ai,ag as ri,ah as ie,ai as On,aj as ht,ak as Tn,al as En,am as Rn,an as li,ao as zn,ap as Fn,aq as In,ar as Bn,as as Vn,at as ve,au as zt,av as Nn,aw as xt,ax as Hn,ay as Ft,az as Dt,aA as ci,aB as Wn,aC as hi,aD as jn,aE as $n,aF as at,aG as di,aH as ui,aI as Un,aJ as ke,aK as fi,aL as se,aM as It,aN as Yn,aO as Xn,aP as Kn}from"./chunks/helpers.segment.js";import"@kurkle/color";class Gn{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const a=e.duration;e.listeners[s].forEach(r=>r({chart:t,initial:e.initial,numSteps:a,currentStep:Math.min(i-e.start,a)}))}_refresh(){this._request||(this._running=!0,this._request=pn.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const o=i.items;let l,a=o.length-1,r=!1;for(;a>=0;--a)l=o[a],l._active?(l._total>i.duration&&(i.duration=l._total),l.tick(t),r=!0):(o[a]=o[o.length-1],o.pop());r&&(s.draw(),this._notify(s,i,t,"progress")),o.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=o.length}),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){!e||!e.length||this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((i,s)=>Math.max(i,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 i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var it=new Gn;const gi="transparent",qn={boolean:(n,t,e)=>e>.5?t:n,color(n,t,e){const i=Ue(n||gi),s=i.valid&&Ue(t||gi);return s&&s.valid?s.mix(i,e).hexString():t},number:(n,t,e)=>n+(t-n)*e};class pi{constructor(t,e,i,s){const o=e[i];s=Tt([t.to,s,o,t.from]);const a=Tt([t.from,o,s]);this._active=!0,this._fn=t.fn||qn[t.type||typeof a],this._easing=$e[t.easing]||$e.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=a,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],o=i-this._start,a=this._duration-o;this._start=i,this._duration=Math.floor(Math.max(a,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=Tt([t.to,e,s,t.from]),this._from=Tt([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,o=this._from,a=this._loop,r=this._to;let l;if(this._active=o!==r&&(a||e1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[s]=this._fn(o,r,l))}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,i)=>{t.push({res:e,rej:i})})}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let s=0;s{const o=t[s];if(!z(o))return;const a={};for(const r of e)a[r]=o[r];(X(o.properties)&&o.properties||[s]).forEach(r=>{(r===s||!i.has(r))&&i.set(r,a)})})}_animateOptions(t,e){const i=e.options,s=Zn(t,i);if(!s)return[];const o=this._createAnimations(s,i);return i.$shared&&Jn(t.options.$animations,i).then(()=>{t.options=i},()=>{}),o}_createAnimations(t,e){const i=this._properties,s=[],o=t.$animations||(t.$animations={}),a=Object.keys(e),r=Date.now();let l;for(l=a.length-1;l>=0;--l){const c=a[l];if("$"===c.charAt(0))continue;if("options"===c){s.push(...this._animateOptions(t,e));continue}const h=e[c];let d=o[c];const u=i.get(c);if(d){if(u&&d.active()){d.update(u,h,r);continue}d.cancel()}u&&u.duration?(o[c]=d=new pi(u,t,c,h),s.push(d)):t[c]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(it.add(this._chart,i),!0):void 0}}function Jn(n,t){const e=[],i=Object.keys(t);for(let s=0;s0||!e&&o<0)return s.index}return null}function vi(n,t){const{chart:e,_cachedMeta:i}=n,s=e._stacks||(e._stacks={}),{iScale:o,vScale:a,index:r}=i,l=o.axis,c=a.axis,h=io(o,a,i),d=t.length;let u;for(let f=0;fe[i].axis===t).shift()}function oo(n,t){return ft(n,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function ao(n,t,e){return ft(n,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function Bt(n,t){const e=n.controller.index,i=n.vScale&&n.vScale.axis;if(i){t=t||n._parsed;for(const s of t){const o=s._stacks;if(!o||void 0===o[i]||void 0===o[i][e])return;delete o[i][e],void 0!==o[i]._visualValues&&void 0!==o[i]._visualValues[e]&&delete o[i]._visualValues[e]}}}const we=n=>"reset"===n||"none"===n,ki=(n,t)=>t?n:Object.assign({},n),ro=(n,t,e)=>n&&!t.hidden&&t._stacked&&{keys:bi(e,!0),values:null};class rt{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=_i(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&&Bt(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(d,u,f,g)=>"x"===d?u:"r"===d?g:f,o=e.xAxisID=C(i.xAxisID,Se(t,"x")),a=e.yAxisID=C(i.yAxisID,Se(t,"y")),r=e.rAxisID=C(i.rAxisID,Se(t,"r")),l=e.indexAxis,c=e.iAxisID=s(l,o,a,r),h=e.vAxisID=s(l,a,o,r);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(a),e.rScale=this.getScaleForId(r),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&&Ye(this._data,this),t._stacked&&Bt(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(z(e))this._data=eo(e);else if(i!==e){if(i){Ye(i,this);const s=this._cachedMeta;Bt(s),s._parsed=[]}e&&Object.isExtensible(e)&&mn(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,i=this.getDataset();let s=!1;this._dataCheck();const o=e._stacked;e._stacked=_i(e.vScale,e),e.stack!==i.stack&&(s=!0,Bt(e),e.stack=i.stack),this._resyncElements(t),(s||o!==e._stacked)&&vi(this,e._parsed)}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:i,_data:s}=this,{iScale:o,_stacked:a}=i,r=o.axis;let h,d,u,l=0===t&&e===s.length||i._sorted,c=t>0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=s,i._sorted=!0,u=s;else{u=X(s[t])?this.parseArrayData(i,s,t,e):z(s[t])?this.parseObjectData(i,s,t,e):this.parsePrimitiveData(i,s,t,e);const f=()=>null===d[r]||c&&d[r]p||d=0;--u)if(!g()){this.updateRangeFromParsed(c,t,f,l);break}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,o,a;for(s=0,o=e.length;s=0&&tthis.getContext(i,s,e),d);return p.$shared&&(p.$shared=l,o[a]=Object.freeze(ki(p,l))),p}_resolveAnimations(t,e,i){const s=this.chart,o=this._cachedDataOpts,a=`animation-${e}`,r=o[a];if(r)return r;let l;if(!1!==s.options.animation){const h=this.chart.config,d=h.datasetAnimationScopeKeys(this._type,e),u=h.getOptionScopes(this.getDataset(),d);l=h.createResolver(u,this.getContext(t,i,e))}const c=new Me(s,l&&l.animations);return l&&l._cacheable&&(o[a]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||we(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const i=this.resolveDataElementOptions(t,e),s=this._sharedOptions,o=this.getSharedOptions(i),a=this.includeOptions(e,o)||o!==s;return this.updateSharedOptions(o,e,i),{sharedOptions:o,includeOptions:a}}updateElement(t,e,i,s){we(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!we(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const o=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[r,l,c]of this._syncList)this[r](l,c);this._syncList=[];const s=i.length,o=e.length,a=Math.min(o,s);a&&this.parse(0,a),o>s?this._insertElements(s,o-s,t):o{for(c.length+=e,r=c.length-1;r>=a;r--)c[r]=c[r-e]};for(l(o),r=t;rs-o))}return n._cache.$bar}function co(n){const t=n.iScale,e=lo(t,n.type);let s,o,a,r,i=t._length;const l=()=>{32767===a||-32768===a||(Et(r)&&(i=Math.min(i,Math.abs(a-r)||i)),r=a)};for(s=0,o=e.length;s0?s[n-1]:null,r=nMath.abs(r)&&(l=r,c=a),t[e.axis]=c,t._custom={barStart:l,barEnd:c,start:s,end:o,min:a,max:r}}function Mi(n,t,e,i){return X(n)?fo(n,t,e,i):t[e.axis]=e.parse(n,i),t}function Si(n,t,e,i){const s=n.iScale,o=n.vScale,a=s.getLabels(),r=s===o,l=[];let c,h,d,u;for(c=e,h=e+i;c=e?1:-1)}function po(n){let t,e,i,s,o;return n.horizontal?(t=n.base>n.x,e="left",i="right"):(t=n.basel.controller.options.grouped),o=i.options.stacked,a=[],r=l=>{const c=l.controller.getParsed(e),h=c&&c[l.vScale.axis];if(L(h)||isNaN(h))return!0};for(const l of s)if((void 0===e||!r(l))&&((!1===o||-1===a.indexOf(l.stack)||void 0===o&&void 0===l.stack)&&a.push(l.stack),l.index===t))break;return a.length||a.push(void 0),a}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const s=this._getStacks(t,i),o=void 0!==e?s.indexOf(e):-1;return-1===o?s.length-1:o}_getRuler(){const t=this.options,e=this._cachedMeta,i=e.iScale,s=[];let o,a;for(o=0,a=e.data.length;o=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart.data.labels||[],{xScale:s,yScale:o}=e,a=this.getParsed(t),r=s.getLabelForValue(a.x),l=o.getLabelForValue(a.y),c=a._custom;return{label:i[t]||"",value:"("+r+", "+l+(c?", "+c:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const o="reset"===s,{iScale:a,vScale:r}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(e,s),h=a.axis,d=r.axis;for(let u=e;uJt(v,r,l,!0)?1:Math.max(y,y*e,_,_*e),g=(v,y,_)=>Jt(v,r,l,!0)?-1:Math.min(y,y*e,_,_*e),p=f(0,c,d),b=f(Z,h,u),m=g(ot,c,d),x=g(ot+Z,h,u);i=(p-m)/2,s=(b-x)/2,o=-(p+m)/2,a=-(b+x)/2}return{ratioX:i,ratioY:s,offsetX:o,offsetY:a}}class ne extends rt{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=>"spacing"!==t,_indexable:t=>"spacing"!==t&&!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:i,color:s}}=t.legend.options;return e.labels.map((o,a)=>{const l=t.getDatasetMeta(0).controller.getStyle(a);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(a),index:a}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.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 i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let a,r,o=l=>+i[l];if(z(i[t])){const{key:l="value"}=this._parsing;o=c=>+Mt(i[c],l)}for(a=t,r=t+e;a0&&!isNaN(t)?U*(Math.abs(t)/e):0}getLabelAndValue(t){const i=this.chart,s=i.data.labels||[],o=qt(this._cachedMeta._parsed[t],i.options.locale);return{label:s[t]||"",value:o}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,o,a,r,l;if(!t)for(s=0,o=i.data.datasets.length;s0&&this.getParsed(e-1);for(let _=0;_=x){M.skip=!0;continue}const S=this.getParsed(_),w=L(S[f]),D=M[u]=a.getPixelForValue(S[u],_),P=M[f]=o||w?r.getBasePixel():r.getPixelForValue(l?this.applyStack(r,S,l):S[f],_);M.skip=isNaN(D)||isNaN(P)||w,M.stop=_>0&&Math.abs(S[u]-y[u])>b,p&&(M.parsed=S,M.raw=c.data[_]),d&&(M.options=h||this.resolveDataElementOptions(_,k.active?"active":s)),m||this.updateElement(k,_,M,s),y=S}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const o=s[0].size(this.resolveDataElementOptions(0)),a=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,o,a)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}class Pe extends rt{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:i,color:s}}=t.legend.options;return e.labels.map((o,a)=>{const l=t.getDatasetMeta(0).controller.getStyle(a);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(a),index:a}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.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 i=this.chart,s=i.data.labels||[],o=qt(this._cachedMeta._parsed[t].r,i.options.locale);return{label:s[t]||"",value:o}}parseObjectData(t,e,i,s){return qe.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return this._cachedMeta.data.forEach((i,s)=>{const o=this.getParsed(s).r;!isNaN(o)&&this.chart.getDataVisibility(s)&&(oe.max&&(e.max=o))}),e}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(s/2,0),r=(o-Math.max(i.cutoutPercentage?o/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=o-r*this.index,this.innerRadius=this.outerRadius-r}updateElements(t,e,i,s){const o="reset"===s,a=this.chart,l=a.options.animation,c=this._cachedMeta.rScale,h=c.xCenter,d=c.yCenter,u=c.getIndexAngle(0)-.5*ot;let g,f=u;const p=360/this.countVisibleElements();for(g=0;g{!isNaN(this.getParsed(s).r)&&this.chart.getDataVisibility(s)&&e++}),e}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?tt(this.resolveDataElementOptions(t,e).angle||i):0}}class Li extends ne{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}}class Oi extends rt{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,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}parseObjectData(t,e,i,s){return qe.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],o=e.iScale.getLabels();if(i.points=s,"resize"!==t){const a=this.resolveDatasetElementOptions(t);this.options.showLine||(a.borderWidth=0),this.updateElement(i,void 0,{_loop:!0,_fullLoop:o.length===s.length,options:a},t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const o=this._cachedMeta.rScale,a="reset"===s;for(let r=e;r0&&this.getParsed(e-1);for(let y=e;y0&&Math.abs(k[f]-v[f])>m,b&&(M.parsed=k,M.raw=c.data[y]),u&&(M.options=d||this.resolveDataElementOptions(y,_.active?"active":s)),x||this.updateElement(_,y,M,s),v=k}this.updateSharedOptions(d,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let r=0;for(let l=e.length-1;l>=0;--l)r=Math.max(r,e[l].size(this.resolveDataElementOptions(l))/2);return r>0&&r}const i=t.dataset,s=i.options&&i.options.borderWidth||0;if(!e.length)return s;const o=e[0].size(this.resolveDataElementOptions(0)),a=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(s,o,a)/2}}var Ei=Object.freeze({__proto__:null,BarController:Pi,BubbleController:Ci,DoughnutController:ne,LineController:Ai,PieController:Li,PolarAreaController:Pe,RadarController:Oi,ScatterController:Ti});function _t(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class je{static override(t){Object.assign(je.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return _t()}parse(){return _t()}format(){return _t()}add(){return _t()}diff(){return _t()}startOf(){return _t()}endOf(){return _t()}}var Ri={_date:je};function yo(n,t,e,i){const{controller:s,data:o,_sorted:a}=n,r=s._cachedMeta.iScale;if(r&&t===r.axis&&"r"!==t&&a&&o.length){const l=r._reversePixels?_n:Rt;if(!i)return l(o,t,e);if(s._sharedOptions){const c=o[0],h="function"==typeof c.getRange&&c.getRange(t);if(h){const d=l(o,t,e-h),u=l(o,t,e+h);return{lo:d.lo,hi:u.hi}}}}return{lo:0,hi:o.length-1}}function Vt(n,t,e,i,s){const o=n.getSortedVisibleDatasetMetas(),a=e[t];for(let r=0,l=o.length;r{l[a](t[e],s)&&(o.push({element:l,datasetIndex:c,index:h}),r=r||l.inRange(t.x,t.y,s))}),i&&!r?[]:o}var Fi={evaluateInteractionItems:Vt,modes:{index(n,t,e,i){const s=gt(t,n),o=e.axis||"x",a=e.includeInvisible||!1,r=e.intersect?Ce(n,s,o,i,a):Ae(n,s,o,!1,i,a),l=[];return r.length?(n.getSortedVisibleDatasetMetas().forEach(c=>{const h=r[0].index,d=c.data[h];d&&!d.skip&&l.push({element:d,datasetIndex:c.index,index:h})}),l):[]},dataset(n,t,e,i){const s=gt(t,n),o=e.axis||"xy",a=e.includeInvisible||!1;let r=e.intersect?Ce(n,s,o,i,a):Ae(n,s,o,!1,i,a);if(r.length>0){const l=r[0].datasetIndex,c=n.getDatasetMeta(l).data;r=[];for(let h=0;hCe(n,gt(t,n),e.axis||"xy",i,e.includeInvisible||!1),nearest:(n,t,e,i)=>Ae(n,gt(t,n),e.axis||"xy",e.intersect,i,e.includeInvisible||!1),x:(n,t,e,i)=>zi(n,gt(t,n),"x",e.intersect,i),y:(n,t,e,i)=>zi(n,gt(t,n),"y",e.intersect,i)}};const Ii=["left","top","right","bottom"];function Nt(n,t){return n.filter(e=>e.pos===t)}function Bi(n,t){return n.filter(e=>-1===Ii.indexOf(e.pos)&&e.box.axis===t)}function Ht(n,t){return n.sort((e,i)=>{const s=t?i:e,o=t?e:i;return s.weight===o.weight?s.index-o.index:s.weight-o.weight})}function So(n){const t=[];let e,i,s,o,a,r;for(e=0,i=(n||[]).length;ec.box.fullSize),!0),i=Ht(Nt(t,"left"),!0),s=Ht(Nt(t,"right")),o=Ht(Nt(t,"top"),!0),a=Ht(Nt(t,"bottom")),r=Bi(t,"x"),l=Bi(t,"y");return{fullSize:e,leftAndTop:i.concat(o),rightAndBottom:s.concat(l).concat(a).concat(r),chartArea:Nt(t,"chartArea"),vertical:i.concat(s).concat(l),horizontal:o.concat(a).concat(r)}}function Vi(n,t,e,i){return Math.max(n[e],t[e])+Math.max(n[i],t[i])}function Ni(n,t){n.top=Math.max(n.top,t.top),n.left=Math.max(n.left,t.left),n.bottom=Math.max(n.bottom,t.bottom),n.right=Math.max(n.right,t.right)}function Co(n,t,e,i){const{pos:s,box:o}=e,a=n.maxPadding;if(!z(s)){e.size&&(n[s]-=e.size);const d=i[e.stack]||{size:0,count:1};d.size=Math.max(d.size,e.horizontal?o.height:o.width),e.size=d.size/d.count,n[s]+=e.size}o.getPadding&&Ni(a,o.getPadding());const r=Math.max(0,t.outerWidth-Vi(a,n,"left","right")),l=Math.max(0,t.outerHeight-Vi(a,n,"top","bottom")),c=r!==n.w,h=l!==n.h;return n.w=r,n.h=l,e.horizontal?{same:c,other:h}:{same:h,other:c}}function Ao(n){const t=n.maxPadding;function e(i){const s=Math.max(t[i]-n[i],0);return n[i]+=s,s}n.y+=e("top"),n.x+=e("left"),e("right"),e("bottom")}function Lo(n,t){const e=t.maxPadding;return function i(s){const o={left:0,top:0,right:0,bottom:0};return s.forEach(a=>{o[a]=Math.max(t[a],e[a])}),o}(n?["left","right"]:["top","bottom"])}function Wt(n,t,e,i){const s=[];let o,a,r,l,c,h;for(o=0,a=n.length,c=0;o{"function"==typeof p.beforeLayout&&p.beforeLayout()});const h=l.reduce((p,b)=>b.box.options&&!1===b.box.options.display?p:p+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:e,padding:s,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/h,hBoxMaxHeight:a/2}),u=Object.assign({},s);Ni(u,j(i));const f=Object.assign({maxPadding:u,w:o,h:a,x:s.left,y:s.top},s),g=Do(l.concat(c),d);Wt(r.fullSize,f,d,g),Wt(l,f,d,g),Wt(c,f,d,g)&&Wt(l,f,d,g),Ao(f),Hi(r.leftAndTop,f,d,g),f.x+=f.w,f.y+=f.h,Hi(r.rightAndBottom,f,d,g),n.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},O(r.chartArea,p=>{const b=p.box;Object.assign(b,n.chartArea),b.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}};class Le{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,s){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,s?Math.floor(e/s):i)}}isAttached(t){return!0}updateConfig(t){}}class Wi extends Le{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const ae="$chartjs",Oo={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},ji=n=>null===n||""===n;function To(n,t){const e=n.style,i=n.getAttribute("height"),s=n.getAttribute("width");if(n[ae]={initial:{height:i,width:s,style:{display:e.display,height:e.height,width:e.width}}},e.display=e.display||"block",e.boxSizing=e.boxSizing||"border-box",ji(s)){const o=Qe(n,"width");void 0!==o&&(n.width=o)}if(ji(i))if(""===n.style.height)n.height=n.width/(t||2);else{const o=Qe(n,"height");void 0!==o&&(n.height=o)}return n}const $i=!!vn&&{passive:!0};function Eo(n,t,e){n.addEventListener(t,e,$i)}function Ro(n,t,e){n.canvas.removeEventListener(t,e,$i)}function zo(n,t){const e=Oo[n.type]||n.type,{x:i,y:s}=gt(n,t);return{type:e,chart:t,native:n,x:void 0!==i?i:null,y:void 0!==s?s:null}}function re(n,t){for(const e of n)if(e===t||e.contains(t))return!0}function Fo(n,t,e){const i=n.canvas,s=new MutationObserver(o=>{let a=!1;for(const r of o)a=a||re(r.addedNodes,i),a=a&&!re(r.removedNodes,i);a&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}function Io(n,t,e){const i=n.canvas,s=new MutationObserver(o=>{let a=!1;for(const r of o)a=a||re(r.removedNodes,i),a=a&&!re(r.addedNodes,i);a&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}const jt=new Map;let Ui=0;function Yi(){const n=window.devicePixelRatio;n!==Ui&&(Ui=n,jt.forEach((t,e)=>{e.currentDevicePixelRatio!==n&&t()}))}function Bo(n,t){jt.size||window.addEventListener("resize",Yi),jt.set(n,t)}function Vo(n){jt.delete(n),jt.size||window.removeEventListener("resize",Yi)}function No(n,t,e){const i=n.canvas,s=i&&Ze(i);if(!s)return;const o=ti((r,l)=>{const c=s.clientWidth;e(r,l),c{const l=r[0],c=l.contentRect.width,h=l.contentRect.height;0===c&&0===h||o(c,h)});return a.observe(s),Bo(n,o),a}function Oe(n,t,e){e&&e.disconnect(),"resize"===t&&Vo(n)}function Ho(n,t,e){const i=n.canvas,s=ti(o=>{null!==n.ctx&&e(zo(o,n))},n);return Eo(i,t,s),s}class Xi extends Le{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(To(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[ae])return!1;const i=e[ae].initial;["height","width"].forEach(o=>{const a=i[o];L(a)?e.removeAttribute(o):e.setAttribute(o,a)});const s=i.style||{};return Object.keys(s).forEach(o=>{e.style[o]=s[o]}),e.width=e.width,delete e[ae],!0}addEventListener(t,e,i){this.removeEventListener(t,e),(t.$proxies||(t.$proxies={}))[e]=({attach:Fo,detach:Io,resize:No}[e]||Ho)(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];s&&(({attach:Oe,detach:Oe,resize:Oe}[e]||Ro)(t,e,s),i[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return yn(t,e,i,s)}isAttached(t){const e=Ze(t);return!(!e||!e.isConnected)}}function Ki(n){return!ei()||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas?Wi:Xi}class st{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}hasValue(){return St(this.x)&&St(this.y)}getProps(t,e){const i=this.$animations;if(!e||!i)return this;const s={};return t.forEach(o=>{s[o]=i[o]&&i[o].active()?i[o]._to:this[o]}),s}}function Wo(n,t){const e=n.options.ticks,i=jo(n),s=Math.min(e.maxTicksLimit||i,i),o=e.major.enabled?Uo(t):[],a=o.length,r=o[0],l=o[a-1],c=[];if(a>s)return Yo(t,c,o,a/s),c;const h=$o(o,t,s);if(a>0){let d,u;const f=a>1?Math.round((l-r)/(a-1)):null;for(le(t,c,h,L(f)?0:r-f,r),d=0,u=a-1;ds)return l}return Math.max(s,1)}function Uo(n){const t=[];let e,i;for(e=0,i=n.length;e"left"===n?"right":"right"===n?"left":n,Gi=(n,t,e)=>"top"===t||"left"===t?n[t]+e:n[t]-e,qi=(n,t)=>Math.min(t||n,n);function Ji(n,t){const e=[],i=n.length/t,s=n.length;let o=0;for(;oa+r)))return l}function qo(n,t){O(n,e=>{const i=e.gc,s=i.length/2;let o;if(s>t){for(o=0;oi?i:e,i=s&&e>i?e:i,{min:J(e,J(i,e)),max:J(i,J(e,i))}}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(){E(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:o,ticks:a}=this.options,r=a.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Mn(this,o,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=r=o||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),d=h.widest.width,u=h.highest.height,f=Y(this.chart.width-d,0,this.maxWidth);r=t.offset?this.maxWidth/i:f/(i-1),d+6>r&&(r=f/(i-(t.offset?.5:1)),l=this.maxHeight-$t(t.grid)-e.padding-Zi(t.title,this.chart.options.font),c=Math.sqrt(d*d+u*u),a=_e(Math.min(Math.asin(Y((h.highest.height+6)/r,-1,1)),Math.asin(Y(l/c,-1,1))-Math.asin(Y(u/c,-1,1)))),a=Math.max(s,Math.min(o,a))),this.labelRotation=a}afterCalculateLabelRotation(){E(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){E(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:o}}=this,a=this._isVisible(),r=this.isHorizontal();if(a){const l=Zi(s,e.options.font);if(r?(t.width=this.maxWidth,t.height=$t(o)+l):(t.height=this.maxHeight,t.width=$t(o)+l),i.display&&this.ticks.length){const{first:c,last:h,widest:d,highest:u}=this._getLabelSizes(),f=2*i.padding,g=tt(this.labelRotation),p=Math.cos(g),b=Math.sin(g);r?t.height=Math.min(this.maxHeight,t.height+(i.mirror?0:b*d.width+p*u.height)+f):t.width=Math.min(this.maxWidth,t.width+(i.mirror?0:p*d.width+b*u.height)+f),this._calculatePadding(c,h,b,p)}}this._handleMargins(),r?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:o,padding:a},position:r}=this.options,l=0!==this.labelRotation,c="top"!==r&&"x"===this.axis;if(this.isHorizontal()){const h=this.getPixelForTick(0)-this.left,d=this.right-this.getPixelForTick(this.ticks.length-1);let u=0,f=0;l?c?(u=s*t.width,f=i*e.height):(u=i*t.height,f=s*e.width):"start"===o?f=e.width:"end"===o?u=t.width:"inner"!==o&&(u=t.width/2,f=e.width/2),this.paddingLeft=Math.max((u-h+a)*this.width/(this.width-h),0),this.paddingRight=Math.max((f-d+a)*this.width/(this.width-d),0)}else{let h=e.height/2,d=t.height/2;"start"===o?(h=0,d=t.height):"end"===o&&(h=e.height,d=0),this.paddingTop=h+a,this.paddingBottom=d+a}}_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(){E(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e({width:a[w]||0,height:r[w]||0});return{first:S(0),last:S(e-1),widest:S(k),highest:S(M),widths:a,heights:r}}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 Sn(this._alignToPixels?mt(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&&tr*s?r/i:l/s:l*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:o,position:a,border:r}=s,l=o.offset,c=this.isHorizontal(),d=this.ticks.length+(l?1:0),u=$t(o),f=[],g=r.setContext(this.getContext()),p=g.display?g.width:0,b=p/2,m=function(R){return mt(i,R,p)};let x,v,y,_,k,M,S,w,D,P,A,N;if("top"===a)x=m(this.bottom),M=this.bottom-u,w=x-b,P=m(t.top)+b,N=t.bottom;else if("bottom"===a)x=m(this.top),P=t.top,N=m(t.bottom)-b,M=x+b,w=this.top+u;else if("left"===a)x=m(this.right),k=this.right-u,S=x-b,D=m(t.left)+b,A=t.right;else if("right"===a)x=m(this.left),D=t.left,A=m(t.right)-b,k=x+b,S=this.left+u;else if("x"===e){if("center"===a)x=m((t.top+t.bottom)/2+.5);else if(z(a)){const R=Object.keys(a)[0];x=m(this.chart.scales[R].getPixelForValue(a[R]))}P=t.top,N=t.bottom,M=x+b,w=M+u}else if("y"===e){if("center"===a)x=m((t.left+t.right)/2);else if(z(a)){const R=Object.keys(a)[0];x=m(this.chart.scales[R].getPixelForValue(a[R]))}k=x-b,S=k-u,D=t.left,A=t.right}const q=C(s.ticks.maxTicksLimit,d),T=Math.max(1,Math.ceil(d/q));for(v=0;vo.value===t);return s>=0?e.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,a;const r=(l,c,h)=>{!h.width||!h.color||(i.save(),i.lineWidth=h.width,i.strokeStyle=h.color,i.setLineDash(h.borderDash||[]),i.lineDashOffset=h.borderDashOffset,i.beginPath(),i.moveTo(l.x,l.y),i.lineTo(c.x,c.y),i.stroke(),i.restore())};if(e.display)for(o=0,a=s.length;o{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]:[{z:e,draw:o=>{this.draw(o)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let o,a;for(o=0,a=e.length;o{const i=e.split("."),s=i.pop(),o=[n].concat(i).join("."),a=t[e].split("."),r=a.pop(),l=a.join(".");F.route(o,s,l,r)})}function sa(n){return"id"in n&&"defaults"in n}class na{constructor(){this.controllers=new ce(rt,"datasets",!0),this.elements=new ce(st,"elements"),this.plugins=new ce(Object,"plugins"),this.scales=new ce(ut,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach(s=>{const o=i||this._getRegistryForType(s);i||o.isForType(s)||o===this.plugins&&s.id?this._exec(t,o,s):O(s,a=>{const r=i||this._getRegistryForType(a);this._exec(t,r,a)})})}_exec(t,e,i){const s=Dn(t);E(i["before"+s],[],i),e[t](i),E(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;eo.filter(r=>!a.some(l=>r.plugin.id===l.plugin.id));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function aa(n){const t={},e=[],i=Object.keys(et.plugins.items);for(let o=0;o1&&Qi(n[0].toLowerCase());if(i)return i}throw new Error(`Cannot determine type of '${n}' axis. Please provide 'axis' or 'position' option.`)}function ts(n,t,e){if(e[t+"AxisID"]===n)return{axis:t}}function fa(n,t){if(t.data&&t.data.datasets){const e=t.data.datasets.filter(i=>i.xAxisID===n||i.yAxisID===n);if(e.length)return ts(n,"x",e[0])||ts(n,"y",e[0])}return{}}function ga(n,t){const e=wt[n.type]||{scales:{}},i=t.scales||{},s=Te(n.type,t),o=Object.create(null);return Object.keys(i).forEach(a=>{const r=i[a];if(!z(r))return console.error(`Invalid scale configuration for scale: ${a}`);if(r._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${a}`);const l=Ee(a,r,fa(a,n),F.scales[r.type]),c=da(l,s),h=e.scales||{};o[a]=ee(Object.create(null),[{axis:l},r,h[l],h[c]])}),n.data.datasets.forEach(a=>{const r=a.type||n.type,l=a.indexAxis||Te(r,t),h=(wt[r]||{}).scales||{};Object.keys(h).forEach(d=>{const u=ha(d,l),f=a[u+"AxisID"]||u;o[f]=o[f]||Object.create(null),ee(o[f],[{axis:u},i[f],h[d]])})}),Object.keys(o).forEach(a=>{const r=o[a];ee(r,[F.scales[r.type],F.scale])}),o}function es(n){const t=n.options||(n.options={});t.plugins=C(t.plugins,{}),t.scales=ga(n,t)}function is(n){return(n=n||{}).datasets=n.datasets||[],n.labels=n.labels||[],n}function pa(n){return(n=n||{}).data=is(n.data),es(n),n}const ss=new Map,ns=new Set;function he(n,t){let e=ss.get(n);return e||(e=t(),ss.set(n,e),ns.add(e)),e}const Ut=(n,t,e)=>{const i=Mt(t,e);void 0!==i&&n.add(i)};class ma{constructor(t){this._config=pa(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=is(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(),es(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return he(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return he(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return he(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id;return he(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return(!s||e)&&(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:o}=this,a=this._cachedScopes(t,i),r=a.get(e);if(r)return r;const l=new Set;e.forEach(h=>{t&&(l.add(t),h.forEach(d=>Ut(l,t,d))),h.forEach(d=>Ut(l,s,d)),h.forEach(d=>Ut(l,wt[o]||{},d)),h.forEach(d=>Ut(l,F,d)),h.forEach(d=>Ut(l,si,d))});const c=Array.from(l);return 0===c.length&&c.push(Object.create(null)),ns.has(e)&&a.set(e,c),c}chartOptionScopes(){const{options:t,type:e}=this;return[t,wt[e]||{},F.datasets[e]||{},{type:e},F,si]}resolveNamedOptions(t,e,i,s=[""]){const o={$shared:!0},{resolver:a,subPrefixes:r}=os(this._resolverCache,t,s);let l=a;if(xa(a,e)){o.$shared=!1,i=te(i)?i():i;const c=this.createResolver(t,i,r);l=ni(a,i,c)}for(const c of e)o[c]=l[c];return o}createResolver(t,e,i=[""],s){const{resolver:o}=os(this._resolverCache,t,i);return z(e)?ni(o,e,void 0,s):o}}function os(n,t,e){let i=n.get(t);i||(i=new Map,n.set(t,i));const s=e.join();let o=i.get(s);return o||(o={resolver:Pn(t,e),subPrefixes:e.filter(r=>!r.toLowerCase().includes("hover"))},i.set(s,o)),o}const ba=n=>z(n)&&Object.getOwnPropertyNames(n).reduce((t,e)=>t||te(n[e]),!1);function xa(n,t){const{isScriptable:e,isIndexable:i}=Cn(n);for(const s of t){const o=e(s),a=i(s),r=(a||o)&&n[s];if(o&&(te(r)||ba(r))||a&&X(r))return!0}return!1}var _a="4.3.0";const ya=["top","bottom","left","right","chartArea"];function as(n,t){return"top"===n||"bottom"===n||-1===ya.indexOf(n)&&"x"===t}function rs(n,t){return function(e,i){return e[n]===i[n]?e[t]-i[t]:e[n]-i[n]}}function ls(n){const t=n.chart,e=t.options.animation;t.notifyPlugins("afterRender"),E(e&&e.onComplete,[n],t)}function va(n){const t=n.chart,e=t.options.animation;E(e&&e.onProgress,[n],t)}function cs(n){return ei()&&"string"==typeof n?n=document.getElementById(n):n&&n.length&&(n=n[0]),n&&n.canvas&&(n=n.canvas),n}const de={},hs=n=>{const t=cs(n);return Object.values(de).filter(e=>e.canvas===t).pop()};function ka(n,t,e){const i=Object.keys(n);for(const s of i){const o=+s;if(o>=t){const a=n[s];delete n[s],(e>0||o>t)&&(n[o+e]=a)}}}function Ma(n,t,e,i){return e&&"mouseout"!==n.type?i?t:n:null}function Sa(n){const{xScale:t,yScale:e}=n;if(t&&e)return{left:t.left,right:t.right,top:e.top,bottom:e.bottom}}class ds{static defaults=F;static instances=de;static overrides=wt;static registry=et;static version=_a;static getChart=hs;static register(...t){et.add(...t),us()}static unregister(...t){et.remove(...t),us()}constructor(t,e){const i=this.config=new ma(e),s=cs(t),o=hs(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 a=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||Ki(s)),this.platform.updateConfig(i);const r=this.platform.acquireContext(s,a.aspectRatio),l=r&&r.canvas,c=l&&l.height,h=l&&l.width;this.id=An(),this.ctx=r,this.canvas=l,this.width=h,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new oa,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Ln(d=>this.update(d),a.resizeDelay||0),this._dataChanges=[],de[this.id]=this,r&&l?(it.listen(this,"complete",ls),it.listen(this,"progress",va),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:o}=this;return L(t)?e&&o?o:s?i/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 et}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():oi(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return ai(this.canvas,this.ctx),this}stop(){return it.stop(this),this}resize(t,e){it.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,a=this.platform.getMaximumSize(this.canvas,t,e,i.maintainAspectRatio&&this.aspectRatio),r=i.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,oi(this,r,!0)&&(this.notifyPlugins("resize",{size:a}),E(i.onResize,[this,a],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){O(this.options.scales||{},(i,s)=>{i.id=s})}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce((a,r)=>(a[r]=!1,a),{});let o=[];e&&(o=o.concat(Object.keys(e).map(a=>{const r=e[a],l=Ee(a,r),c="r"===l,h="x"===l;return{options:r,dposition:c?"chartArea":h?"bottom":"left",dtype:c?"radialLinear":h?"category":"linear"}}))),O(o,a=>{const r=a.options,l=r.id,c=Ee(l,r),h=C(r.type,a.dtype);(void 0===r.position||as(r.position,c)!==as(a.dposition))&&(r.position=a.dposition),s[l]=!0;let d=null;l in i&&i[l].type===h?d=i[l]:(d=new(et.getScale(h))({id:l,type:h,ctx:this.ctx,chart:this}),i[d.id]=d),d.init(r,t)}),O(s,(a,r)=>{a||delete i[r]}),O(i,a=>{H.configure(this,a,a.options),H.addBox(this,a)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort((s,o)=>s.index-o.index),i>e){for(let s=e;se.length&&delete this._stacks,t.forEach((i,s)=>{0===e.filter(o=>o===i._dataset).length&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let a=0;for(let c=0,h=this.data.datasets.length;c{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(rs("z","_idx"));const{_active:r,_lastEvent:l}=this;l?this._eventHandler(l,!0):r.length&&this._updateHoverStyles(r,r,!0),this.render()}_updateScales(){O(this.scales,t=>{H.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);(!ri(e,i)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:o}of e)ka(t,s,"_removeElements"===i?-o:o)}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=o=>new Set(t.filter(a=>a[0]===o).map((a,r)=>r+","+a.splice(1).join(","))),s=i(0);for(let o=1;oo.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;H.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],O(this.boxes,s=>{i&&"chartArea"===s.position||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,o)=>{s._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let e=0,i=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,o=Sa(t)||this.chartArea,a={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",a)&&(s&&Zt(e,{left:!1===i.left?0:o.left-i.left,right:!1===i.right?this.width:o.right+i.right,top:!1===i.top?0:o.top-i.top,bottom:!1===i.bottom?this.height:o.bottom+i.bottom}),t.controller.draw(),s&&Qt(e),a.cancelable=!1,this.notifyPlugins("afterDatasetDraw",a))}isPointInArea(t){return pt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,i,s){const o=Fi.modes[e];return"function"==typeof o?o(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.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},i.push(s)),s}getContext(){return this.$context||(this.$context=ft(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",o=this.getDatasetMeta(t),a=o.controller._resolveAnimations(void 0,s);Et(e)?(o.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),a.update(o,{visible:i}),this.update(r=>r.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(),it.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,a),t[o]=a},s=(o,a,r)=>{o.offsetX=a,o.offsetY=r,this._eventHandler(o)};O(this.options.events,o=>i(o,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(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 a;const r=()=>{s("attach",r),this.attached=!0,this.resize(),i("resize",o),i("detach",a)};a=()=>{this.attached=!1,s("resize",o),this._stop(),this._resize(0,0),i("attach",r)},e.isAttached(this.canvas)?r():a()}unbindEvents(){O(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},O(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let o,a,r,l;for("dataset"===e&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+s+"DatasetHoverStyle"]()),r=0,l=t.length;r{const r=this.getDatasetMeta(o);if(!r)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:r.data[a],index:a}});!ie(i,e)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}isPluginEnabled(t){return 1===this._plugins._cache.filter(e=>e.plugin.id===t).length}_updateHoverStyles(t,e,i){const s=this.options.hover,o=(l,c)=>l.filter(h=>!c.some(d=>h.datasetIndex===d.datasetIndex&&h.index===d.index)),a=o(e,t),r=i?t:o(t,e);a.length&&this.updateHoverStyle(a,s.mode,!1),r.length&&s.mode&&this.updateHoverStyle(r,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},s=a=>(a.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const o=this._handleEvent(t,e,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(o||i.changed)&&this.render(),this}_handleEvent(t,e,i){const{_active:s=[],options:o}=this,r=this._getActiveElements(t,s,i,e),l=On(t),c=Ma(t,this._lastEvent,i,l);i&&(this._lastEvent=null,E(o.onHover,[t,r,this],this),l&&E(o.onClick,[t,r,this],this));const h=!ie(r,s);return(h||e)&&(this._active=r,this._updateHoverStyles(r,s,e)),this._lastEvent=c,h}_getActiveElements(t,e,i,s){if("mouseout"===t.type)return[];if(!i)return e;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,s)}}function us(){return O(ds.instances,n=>n._plugins.invalidate())}function wa(n,t,e){const{startAngle:i,pixelMargin:s,x:o,y:a,outerRadius:r,innerRadius:l}=t;let c=s/r;n.beginPath(),n.arc(o,a,r,i-c,e+c),l>s?(c=s/l,n.arc(o,a,l,e+c,i-c,!0)):n.arc(o,a,s,e+Z,i-Z),n.closePath(),n.clip()}function Da(n){return Tn(n,["outerStart","outerEnd","innerStart","innerEnd"])}function Pa(n,t,e,i){const s=Da(n.options.borderRadius),o=(e-t)/2,a=Math.min(o,i*t/2),r=l=>{const c=(e-Math.min(o,l))*i/2;return Y(l,0,Math.min(o,c))};return{outerStart:r(s.outerStart),outerEnd:r(s.outerEnd),innerStart:Y(s.innerStart,0,a),innerEnd:Y(s.innerEnd,0,a)}}function Pt(n,t,e,i){return{x:e+n*Math.cos(t),y:i+n*Math.sin(t)}}function ue(n,t,e,i,s,o){const{x:a,y:r,startAngle:l,pixelMargin:c,innerRadius:h}=t,d=Math.max(t.outerRadius+i+e-c,0),u=h>0?h+i+e+c:0;let f=0;const g=s-l;if(i){const I=((h>0?h-i:0)+(d>0?d-i:0))/2;f=(g-(0!==I?g*I/(I+i):g))/2}const b=(g-Math.max(.001,g*d-e/ot)/d)/2,m=l+b+f,x=s-b-f,{outerStart:v,outerEnd:y,innerStart:_,innerEnd:k}=Pa(t,u,d,x-m),M=d-v,S=d-y,w=m+v/M,D=x-y/S,P=u+_,A=u+k,N=m+_/P,q=x-k/A;if(n.beginPath(),o){const T=(w+D)/2;if(n.arc(a,r,d,w,T),n.arc(a,r,d,T,D),y>0){const W=Pt(S,D,a,r);n.arc(W.x,W.y,y,D,x+Z)}const R=Pt(A,x,a,r);if(n.lineTo(R.x,R.y),k>0){const W=Pt(A,q,a,r);n.arc(W.x,W.y,k,x+Z,q+Math.PI)}const I=(x-k/u+(m+_/u))/2;if(n.arc(a,r,u,x-k/u,I,!0),n.arc(a,r,u,I,m+_/u,!0),_>0){const W=Pt(P,N,a,r);n.arc(W.x,W.y,_,N+Math.PI,m-Z)}const Q=Pt(M,m,a,r);if(n.lineTo(Q.x,Q.y),v>0){const W=Pt(M,w,a,r);n.arc(W.x,W.y,v,m-Z,w)}}else{n.moveTo(a,r);const T=Math.cos(w)*d+a,R=Math.sin(w)*d+r;n.lineTo(T,R);const I=Math.cos(D)*d+a,Q=Math.sin(D)*d+r;n.lineTo(I,Q)}n.closePath()}function Ca(n,t,e,i,s){const{fullCircles:o,startAngle:a,circumference:r}=t;let l=t.endAngle;if(o){ue(n,t,e,i,l,s);for(let c=0;c"borderDash"!==t};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,i){const s=this.getProps(["x","y"],i),{angle:o,distance:a}=Je(s,{x:t,y:e}),{startAngle:r,endAngle:l,innerRadius:c,outerRadius:h,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),u=(this.options.spacing+this.options.borderWidth)/2,g=C(d,l-r)>=U||Jt(o,r,l),p=ht(a,c+u,h+u);return g&&p}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:o,innerRadius:a,outerRadius:r}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:l,spacing:c}=this.options,h=(s+o)/2,d=(a+r+c+l)/2;return{x:e+Math.cos(h)*d,y:i+Math.sin(h)*d}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/4,o=(e.spacing||0)/2,a=e.circular;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>U?Math.floor(i/U):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();const r=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(r)*s,Math.sin(r)*s);const c=s*(1-Math.sin(Math.min(ot,i||0)));t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,Ca(t,this,c,o,a),Aa(t,this,c,o,a),t.restore()}}function gs(n,t,e=t){n.lineCap=C(e.borderCapStyle,t.borderCapStyle),n.setLineDash(C(e.borderDash,t.borderDash)),n.lineDashOffset=C(e.borderDashOffset,t.borderDashOffset),n.lineJoin=C(e.borderJoinStyle,t.borderJoinStyle),n.lineWidth=C(e.borderWidth,t.borderWidth),n.strokeStyle=C(e.borderColor,t.borderColor)}function La(n,t,e){n.lineTo(e.x,e.y)}function Oa(n){return n.stepped?Bn:n.tension||"monotone"===n.cubicInterpolationMode?Vn:La}function ps(n,t,e={}){const i=n.length,{start:s=0,end:o=i-1}=e,{start:a,end:r}=t,l=Math.max(s,a),c=Math.min(o,r);return{count:i,start:l,loop:t.loop,ilen:cr&&o>r)?i+c-l:c-l}}function Ta(n,t,e,i){const{points:s,options:o}=t,{count:a,start:r,loop:l,ilen:c}=ps(s,e,i),h=Oa(o);let f,g,p,{move:d=!0,reverse:u}=i||{};for(f=0;f<=c;++f)g=s[(r+(u?c-f:f))%a],!g.skip&&(d?(n.moveTo(g.x,g.y),d=!1):h(n,p,g,u,o.stepped),p=g);return l&&(g=s[(r+(u?c:0))%a],h(n,p,g,u,o.stepped)),!!l}function Ea(n,t,e,i){const s=t.points,{count:o,start:a,ilen:r}=ps(s,e,i),{move:l=!0,reverse:c}=i||{};let u,f,g,p,b,m,h=0,d=0;const x=y=>(a+(c?r-y:y))%o,v=()=>{p!==b&&(n.lineTo(h,b),n.lineTo(h,p),n.lineTo(h,m))};for(l&&(f=s[x(0)],n.moveTo(f.x,f.y)),u=0;u<=r;++u){if(f=s[x(u)],f.skip)continue;const y=f.x,_=f.y,k=0|y;k===g?(_b&&(b=_),h=(d*h+y)/++d):(v(),n.lineTo(y,_),g=k,d=0,p=b=_),m=_}v()}function Re(n){const t=n.options;return n._decimated||n._loop||t.tension||"monotone"===t.cubicInterpolationMode||t.stepped||t.borderDash&&t.borderDash.length?Ta:Ea}function Ra(n){return n.stepped?zn:n.tension||"monotone"===n.cubicInterpolationMode?Fn:In}function za(n,t,e,i){let s=t._path;s||(s=t._path=new Path2D,t.path(s,e,i)&&s.closePath()),gs(n,t.options),n.stroke(s)}function Fa(n,t,e,i){const{segments:s,options:o}=t,a=Re(t);for(const r of s)gs(n,o,r.style),n.beginPath(),a(n,t,r,{start:e,end:e+i-1})&&n.closePath(),n.stroke()}const Ia="function"==typeof Path2D;function Ba(n,t,e,i){Ia&&!t.options.segment?za(n,t,e,i):Fa(n,t,e,i)}class Yt extends st{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=>"borderDash"!==t&&"fill"!==t};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 i=this.options;!i.tension&&"monotone"!==i.cubicInterpolationMode||i.stepped||this._pointsUpdated||(En(this._points,i,t,i.spanGaps?this._loop:this._fullLoop,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=Rn(this,this.options.segment))}first(){const t=this.segments;return t.length&&this.points[t[0].start]}last(){const t=this.segments,i=t.length;return i&&this.points[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],o=this.points,a=li(this,{property:e,start:s,end:s});if(!a.length)return;const r=[],l=Ra(i);let c,h;for(c=0,h=a.length;cn.replace("rgb(","rgba(").replace(")",", 0.5)"));function ks(n){return Ie[n%Ie.length]}function Ms(n){return vs[n%vs.length]}function $a(n,t){return n.borderColor=ks(t),n.backgroundColor=Ms(t),++t}function Ua(n,t){return n.backgroundColor=n.data.map(()=>ks(t++)),t}function Ya(n,t){return n.backgroundColor=n.data.map(()=>Ms(t++)),t}function Xa(n){let t=0;return(e,i)=>{const s=n.getDatasetMeta(i).controller;s instanceof ne?t=Ua(e,t):s instanceof Pe?t=Ya(e,t):s&&(t=$a(e,t))}}function Ss(n){let t;for(t in n)if(n[t].borderColor||n[t].backgroundColor)return!0;return!1}function Ka(n){return n&&(n.borderColor||n.backgroundColor)}var ws={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(n,t,e){if(!e.enabled)return;const{data:{datasets:i},options:s}=n.config,{elements:o}=s;if(!e.forceOverride&&(Ss(i)||Ka(s)||o&&Ss(o)))return;const a=Xa(n);i.forEach(a)}};function Ga(n,t,e,i,s){const o=s.samples||i;if(o>=e)return n.slice(t,t+e);const a=[],r=(e-2)/(o-2);let l=0;const c=t+e-1;let d,u,f,g,p,h=t;for(a[l++]=n[h],d=0;df&&(f=g,u=n[x],p=x);a[l++]=u,h=p}return a[l++]=n[c],a}function qa(n,t,e,i){let a,r,l,c,h,d,u,f,g,p,s=0,o=0;const b=[],x=n[t].x,y=n[t+e-1].x-x;for(a=t;ap&&(p=c,u=a),s=(o*s+r.x)/++o;else{const k=a-1;if(!L(d)&&!L(u)){const M=Math.min(d,u),S=Math.max(d,u);M!==f&&M!==k&&b.push({...n[M],x:s}),S!==f&&S!==k&&b.push({...n[S],x:s})}a>0&&k!==f&&b.push(n[k]),b.push(r),h=_,o=0,g=p=c,d=u=f=a}}return b}function Ds(n){if(n._decimated){const t=n._data;delete n._decimated,delete n._data,Object.defineProperty(n,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function Ps(n){n.data.datasets.forEach(t=>{Ds(t)})}function Ja(n,t){const e=t.length;let s,i=0;const{iScale:o}=n,{min:a,max:r,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(i=Y(Rt(t,o.axis,a).lo,0,e-1)),s=c?Y(Rt(t,o.axis,r).hi+1,i,e)-i:e-i,{start:i,count:s}}var Cs={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(n,t,e)=>{if(!e.enabled)return void Ps(n);const i=n.width;n.data.datasets.forEach((s,o)=>{const{_data:a,indexAxis:r}=s,l=n.getDatasetMeta(o),c=a||s.data;if("y"===Tt([r,n.options.indexAxis])||!l.controller.supportsDecimation)return;const h=n.scales[l.xAxisID];if("linear"!==h.type&&"time"!==h.type||n.options.parsing)return;let g,{start:d,count:u}=Ja(l,c);if(u<=(e.threshold||4*i))Ds(s);else{switch(L(a)&&(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}})),e.algorithm){case"lttb":g=Ga(c,d,u,i,e);break;case"min-max":g=qa(c,d,u,i);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}s._decimated=g}})},destroy(n){Ps(n)}};function Za(n,t,e){const i=n.segments,s=n.points,o=t.points,a=[];for(const r of i){let{start:l,end:c}=r;c=Ve(l,c,s);const h=Be(e,s[l],s[c],r.loop);if(!t.segments){a.push({source:r,target:h,start:s[l],end:s[c]});continue}const d=li(t,h);for(const u of d){const f=Be(e,o[u.start],o[u.end],u.loop),g=Hn(r,s,f);for(const p of g)a.push({source:p,target:u,start:{[e]:As(h,f,"start",Math.max)},end:{[e]:As(h,f,"end",Math.min)}})}}return a}function Be(n,t,e,i){if(i)return;let s=t[n],o=e[n];return"angle"===n&&(s=Ft(s),o=Ft(o)),{property:n,start:s,end:o}}function Qa(n,t){const{x:e=null,y:i=null}=n||{},s=t.points,o=[];return t.segments.forEach(({start:a,end:r})=>{r=Ve(a,r,s);const l=s[a],c=s[r];null!==i?(o.push({x:l.x,y:i}),o.push({x:c.x,y:i})):null!==e&&(o.push({x:e,y:l.y}),o.push({x:e,y:c.y}))}),o}function Ve(n,t,e){for(;t>n;t--){const i=e[t];if(!isNaN(i.x)&&!isNaN(i.y))break}return t}function As(n,t,e,i){return n&&t?i(n[e],t[e]):n?n[e]:t?t[e]:0}function Ls(n,t){let e=[],i=!1;return X(n)?(i=!0,e=n):e=Qa(n,t),e.length?new Yt({points:e,options:{tension:0},_loop:i,_fullLoop:i}):null}function Os(n){return n&&!1!==n.fill}function tr(n,t,e){let s=n[t].fill;const o=[t];let a;if(!e)return s;for(;!1!==s&&-1===o.indexOf(s);){if(!B(s))return s;if(a=n[s],!a)return!1;if(a.visible)return s;o.push(s),s=a.fill}return!1}function er(n,t,e){const i=or(n);if(z(i))return!isNaN(i.value)&&i;let s=parseFloat(i);return B(s)&&Math.floor(s)===s?ir(i[0],t,s,e):["origin","start","end","stack","shape"].indexOf(i)>=0&&i}function ir(n,t,e,i){return("-"===n||"+"===n)&&(e=t+e),!(e===t||e<0||e>=i)&&e}function sr(n,t){let e=null;return"start"===n?e=t.bottom:"end"===n?e=t.top:z(n)?e=t.getPixelForValue(n.value):t.getBasePixel&&(e=t.getBasePixel()),e}function nr(n,t,e){let i;return i="start"===n?e:"end"===n?t.options.reverse?t.min:t.max:z(n)?n.value:t.getBaseValue(),i}function or(n){const t=n.options,e=t.fill;let i=C(e&&e.target,e);return void 0===i&&(i=!!t.backgroundColor),!1!==i&&null!==i&&(!0===i?"origin":i)}function ar(n){const{scale:t,index:e,line:i}=n,s=[],o=i.segments,a=i.points,r=rr(t,e);r.push(Ls({x:null,y:t.bottom},i));for(let l=0;l=0;--a){const r=s[a].$filler;r&&(r.line.updateControlPoints(o,r.axis),i&&r.fill&&Ne(n.ctx,r,o))}},beforeDatasetsDraw(n,t,e){if("beforeDatasetsDraw"!==e.drawTime)return;const i=n.getSortedVisibleDatasetMetas();for(let s=i.length-1;s>=0;--s){const o=i[s].$filler;Os(o)&&Ne(n.ctx,o,n.chartArea)}},beforeDatasetDraw(n,t,e){const i=t.meta.$filler;!Os(i)||"beforeDatasetDraw"!==e.drawTime||Ne(n.ctx,i,n.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Is=(n,t)=>{let{boxHeight:e=t,boxWidth:i=t}=n;return n.usePointStyle&&(e=Math.min(e,t),i=n.pointStyleWidth||Math.min(i,t)),{boxWidth:i,boxHeight:e,itemHeight:Math.max(t,e)}},br=(n,t)=>null!==n&&null!==t&&n.datasetIndex===t.datasetIndex&&n.index===t.index;class Bs extends st{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=E(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(i=>t.filter(i,this.chart.data))),t.sort&&(e=e.sort((i,s)=>t.sort(i,s,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=V(i.font),o=s.size,a=this._computeTitleHeight(),{boxWidth:r,itemHeight:l}=Is(i,o);let c,h;e.font=s.string,this.isHorizontal()?(c=this.maxWidth,h=this._fitRows(a,o,r,l)+10):(h=this.maxHeight,c=this._fitCols(a,s,r,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:o,maxWidth:a,options:{labels:{padding:r}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],h=s+r;let d=t;o.textAlign="left",o.textBaseline="middle";let u=-1,f=-h;return this.legendItems.forEach((g,p)=>{const b=i+e/2+o.measureText(g.text).width;(0===p||c[c.length-1]+b+2*r>a)&&(d+=h,c[c.length-(p>0?0:1)]=0,f+=h,u++),l[p]={left:0,top:f,row:u,width:b,height:s},c[c.length-1]+=b+r}),d}_fitCols(t,e,i,s){const{ctx:o,maxHeight:a,options:{labels:{padding:r}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],h=a-t;let d=r,u=0,f=0,g=0,p=0;return this.legendItems.forEach((b,m)=>{const{itemWidth:x,itemHeight:v}=xr(i,e,o,b,s);m>0&&f+v+2*r>h&&(d+=u+r,c.push({width:u,height:f}),g+=u+r,p++,u=f=0),l[m]={left:g,top:f,col:p,width:x,height:v},u=Math.max(u,x),f+=v+r}),d+=u,c.push({width:u,height:f}),d}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:o}}=this,a=Dt(o,this.left,this.width);if(this.isHorizontal()){let r=0,l=$(i,this.left+s,this.right-this.lineWidths[r]);for(const c of e)r!==c.row&&(r=c.row,l=$(i,this.left+s,this.right-this.lineWidths[r])),c.top+=this.top+t+s,c.left=a.leftForLtr(a.x(l),c.width),l+=c.width+s}else{let r=0,l=$(i,this.top+t+s,this.bottom-this.columnSizes[r].height);for(const c of e)c.col!==r&&(r=c.col,l=$(i,this.top+t+s,this.bottom-this.columnSizes[r].height)),c.top=l,c.left+=this.left+s,c.left=a.leftForLtr(a.x(c.left),c.width),l+=c.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;Zt(t,this),this._draw(),Qt(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:o,labels:a}=t,r=F.color,l=Dt(t.rtl,this.left,this.width),c=V(a.font),{padding:h}=a,d=c.size,u=d/2;let f;this.drawTitle(),s.textAlign=l.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:g,boxHeight:p,itemHeight:b}=Is(a,d),v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:$(o,this.left+h,this.right-i[0]),y:this.top+h+y,line:0}:{x:this.left+h,y:$(o,this.top+y+h,this.bottom-e[0].height),line:0},ci(this.ctx,t.textDirection);const _=b+h;this.legendItems.forEach((k,M)=>{s.strokeStyle=k.fontColor,s.fillStyle=k.fontColor;const S=s.measureText(k.text).width,w=l.textAlign(k.textAlign||(k.textAlign=a.textAlign)),D=g+u+S;let P=f.x,A=f.y;l.setWidth(this.width),v?M>0&&P+D+h>this.right&&(A=f.y+=_,f.line++,P=f.x=$(o,this.left+h,this.right-i[f.line])):M>0&&A+_>this.bottom&&(P=f.x=P+e[f.line].width+h,f.line++,A=f.y=$(o,this.top+y+h,this.bottom-e[f.line].height)),function(k,M,S){if(isNaN(g)||g<=0||isNaN(p)||p<0)return;s.save();const w=C(S.lineWidth,1);if(s.fillStyle=C(S.fillStyle,r),s.lineCap=C(S.lineCap,"butt"),s.lineDashOffset=C(S.lineDashOffset,0),s.lineJoin=C(S.lineJoin,"miter"),s.lineWidth=w,s.strokeStyle=C(S.strokeStyle,r),s.setLineDash(C(S.lineDash,[])),a.usePointStyle){const D={radius:p*Math.SQRT2/2,pointStyle:S.pointStyle,rotation:S.rotation,borderWidth:w},P=l.xPlus(k,g/2);jn(s,D,P,M+u,a.pointStyleWidth&&g)}else{const D=M+Math.max((d-p)/2,0),P=l.leftForLtr(k,g),A=xt(S.borderRadius);s.beginPath(),Object.values(A).some(N=>0!==N)?zt(s,{x:P,y:D,w:g,h:p,radius:A}):s.rect(P,D,g,p),s.fill(),0!==w&&s.stroke()}s.restore()}(l.x(P),A,k),P=Wn(w,P+g+u,v?P+D:this.right,t.rtl),function(k,M,S){bt(s,S.text,k,M+b/2,c,{strikethrough:S.hidden,textAlign:l.textAlign(S.textAlign)})}(l.x(P),A,k),v?f.x+=D+h:f.y+="string"!=typeof k.text?Vs(k,c.lineHeight):_}),hi(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=V(e.font),s=j(e.padding);if(!e.display)return;const o=Dt(t.rtl,this.left,this.width),a=this.ctx,r=e.position,c=s.top+i.size/2;let h,d=this.left,u=this.width;if(this.isHorizontal())u=Math.max(...this.lineWidths),h=this.top+c,d=$(t.align,d,this.right-u);else{const g=this.columnSizes.reduce((p,b)=>Math.max(p,b.height),0);h=c+$(t.align,this.top,this.bottom-g-t.labels.padding-this._computeTitleHeight())}const f=$(r,d,d+u);a.textAlign=o.textAlign(ye(r)),a.textBaseline="middle",a.strokeStyle=e.color,a.fillStyle=e.color,a.font=i.string,bt(a,e.text,f,h,i)}_computeTitleHeight(){const t=this.options.title,e=V(t.font),i=j(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,o;if(ht(t,this.left,this.right)&&ht(e,this.top,this.bottom))for(o=this.legendHitBoxes,i=0;io.length>a.length?o:a)),t+e.size/2+i.measureText(s).width}function yr(n,t,e){let i=n;return"string"!=typeof t.text&&(i=Vs(t,e)),i}function Vs(n,t){return t*(n.text?n.text.length+.5:0)}function vr(n,t){return!(("mousemove"!==n&&"mouseout"!==n||!t.onHover&&!t.onLeave)&&(!t.onClick||"click"!==n&&"mouseup"!==n))}var Ns={id:"legend",_element:Bs,start(n,t,e){const i=n.legend=new Bs({ctx:n.ctx,options:e,chart:n});H.configure(n,i,e),H.addBox(n,i)},stop(n){H.removeBox(n,n.legend),delete n.legend},beforeUpdate(n,t,e){const i=n.legend;H.configure(n,i,e),i.options=e},afterUpdate(n){const t=n.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(n,t){t.replay||n.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(n,t,e){const i=t.datasetIndex,s=e.chart;s.isDatasetVisible(i)?(s.hide(i),t.hidden=!0):(s.show(i),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:n=>n.chart.options.color,boxWidth:40,padding:10,generateLabels(n){const t=n.data.datasets,{labels:{usePointStyle:e,pointStyle:i,textAlign:s,color:o,useBorderRadius:a,borderRadius:r}}=n.legend.options;return n._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(e?0:void 0),h=j(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(h.width+h.height)/4,strokeStyle:c.borderColor,pointStyle:i||c.pointStyle,rotation:c.rotation,textAlign:s||c.textAlign,borderRadius:a&&(r||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:n=>n.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:n=>!n.startsWith("on"),labels:{_scriptable:n=>!["generateLabels","filter","sort"].includes(n)}}};class He extends st{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const s=X(i.text)?i.text.length:1;this._padding=j(i.padding);const o=s*V(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:o,options:a}=this,r=a.align;let c,h,d,l=0;return this.isHorizontal()?(h=$(r,i,o),d=e+t,c=o-i):("left"===a.position?(h=i+t,d=$(r,s,e),l=-.5*ot):(h=o-t,d=$(r,e,s),l=.5*ot),c=s-e),{titleX:h,titleY:d,maxWidth:c,rotation:l}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=V(e.font),o=i.lineHeight/2+this._padding.top,{titleX:a,titleY:r,maxWidth:l,rotation:c}=this._drawArgs(o);bt(t,e.text,0,0,i,{color:e.color,maxWidth:l,rotation:c,textAlign:ye(e.align),textBaseline:"middle",translation:[a,r]})}}function kr(n,t){const e=new He({ctx:n.ctx,options:t,chart:n});H.configure(n,e,t),H.addBox(n,e),n.titleBlock=e}var Hs={id:"title",_element:He,start(n,t,e){kr(n,e)},stop(n){H.removeBox(n,n.titleBlock),delete n.titleBlock},beforeUpdate(n,t,e){const i=n.titleBlock;H.configure(n,i,e),i.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 fe=new WeakMap;var Ws={id:"subtitle",start(n,t,e){const i=new He({ctx:n.ctx,options:e,chart:n});H.configure(n,i,e),H.addBox(n,i),fe.set(n,i)},stop(n){H.removeBox(n,fe.get(n)),fe.delete(n)},beforeUpdate(n,t,e){const i=fe.get(n);H.configure(n,i,e),i.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 Xt={average(n){if(!n.length)return!1;let t,e,i=0,s=0,o=0;for(t=0,e=n.length;t-1?n.split("\n"):n}function Mr(n,t){const{element:e,datasetIndex:i,index:s}=t,o=n.getDatasetMeta(i).controller,{label:a,value:r}=o.getLabelAndValue(s);return{chart:n,label:a,parsed:o.getParsed(s),raw:n.data.datasets[i].data[s],formattedValue:r,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:e}}function js(n,t){const e=n.chart.ctx,{body:i,footer:s,title:o}=n,{boxWidth:a,boxHeight:r}=t,l=V(t.bodyFont),c=V(t.titleFont),h=V(t.footerFont),d=o.length,u=s.length,f=i.length,g=j(t.padding);let p=g.height,b=0,m=i.reduce((y,_)=>y+_.before.length+_.lines.length+_.after.length,0);m+=n.beforeBody.length+n.afterBody.length,d&&(p+=d*c.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),m&&(p+=f*(t.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(m-f)*l.lineHeight+(m-1)*t.bodySpacing),u&&(p+=t.footerMarginTop+u*h.lineHeight+(u-1)*t.footerSpacing);let x=0;const v=function(y){b=Math.max(b,e.measureText(y).width+x)};return e.save(),e.font=c.string,O(n.title,v),e.font=l.string,O(n.beforeBody.concat(n.afterBody),v),x=t.displayColors?a+2+t.boxPadding:0,O(i,y=>{O(y.before,v),O(y.lines,v),O(y.after,v)}),x=0,e.font=h.string,O(n.footer,v),e.restore(),b+=g.width,{width:b,height:p}}function Sr(n,t){const{y:e,height:i}=t;return en.height-i/2?"bottom":"center"}function wr(n,t,e,i){const{x:s,width:o}=i,a=e.caretSize+e.caretPadding;if("left"===n&&s+o+a>t.width||"right"===n&&s-o-a<0)return!0}function Dr(n,t,e,i){const{x:s,width:o}=e,{width:a,chartArea:{left:r,right:l}}=n;let c="center";return"center"===i?c=s<=(r+l)/2?"left":"right":s<=o/2?c="left":s>=a-o/2&&(c="right"),wr(c,n,t,e)&&(c="center"),c}function $s(n,t,e){const i=e.yAlign||t.yAlign||Sr(n,e);return{xAlign:e.xAlign||t.xAlign||Dr(n,t,e,i),yAlign:i}}function Pr(n,t){let{x:e,width:i}=n;return"right"===t?e-=i:"center"===t&&(e-=i/2),e}function Cr(n,t,e){let{y:i,height:s}=n;return"top"===t?i+=e:i-="bottom"===t?s+e:s/2,i}function Us(n,t,e,i){const{caretSize:s,caretPadding:o,cornerRadius:a}=n,{xAlign:r,yAlign:l}=e,c=s+o,{topLeft:h,topRight:d,bottomLeft:u,bottomRight:f}=xt(a);let g=Pr(t,r);const p=Cr(t,l,c);return"center"===l?"left"===r?g+=c:"right"===r&&(g-=c):"left"===r?g-=Math.max(h,u)+s:"right"===r&&(g+=Math.max(d,f)+s),{x:Y(g,0,i.width-t.width),y:Y(p,0,i.height-t.height)}}function ge(n,t,e){const i=j(e.padding);return"center"===t?n.x+n.width/2:"right"===t?n.x+n.width-i.right:n.x+i.left}function Ys(n){return nt([],lt(n))}function Ar(n,t,e){return ft(n,{tooltip:t,tooltipItems:e,type:"tooltip"})}function Xs(n,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?n.override(e):n}const Ks={beforeTitle:at,title(n){if(n.length>0){const t=n[0],e=t.chart.data.labels,i=e?e.length:0;if(this&&this.options&&"dataset"===this.options.mode)return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex"u"?Ks[t].call(e,i):s}class Gs extends st{static positioners=Xt;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,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,o=new Me(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=Ar(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:i}=e,s=K(i,"beforeTitle",this,t),o=K(i,"title",this,t),a=K(i,"afterTitle",this,t);let r=[];return r=nt(r,lt(s)),r=nt(r,lt(o)),r=nt(r,lt(a)),r}getBeforeBody(t,e){return Ys(K(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:i}=e,s=[];return O(t,o=>{const a={before:[],lines:[],after:[]},r=Xs(i,o);nt(a.before,lt(K(r,"beforeLabel",this,o))),nt(a.lines,K(r,"label",this,o)),nt(a.after,lt(K(r,"afterLabel",this,o))),s.push(a)}),s}getAfterBody(t,e){return Ys(K(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,s=K(i,"beforeFooter",this,t),o=K(i,"footer",this,t),a=K(i,"afterFooter",this,t);let r=[];return r=nt(r,lt(s)),r=nt(r,lt(o)),r=nt(r,lt(a)),r}_createItems(t){const e=this._active,i=this.chart.data,s=[],o=[],a=[];let l,c,r=[];for(l=0,c=e.length;lt.filter(h,d,u,i))),t.itemSort&&(r=r.sort((h,d)=>t.itemSort(h,d,i))),O(r,h=>{const d=Xs(t.callbacks,h);s.push(K(d,"labelColor",this,h)),o.push(K(d,"labelPointStyle",this,h)),a.push(K(d,"labelTextColor",this,h))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=a,this.dataPoints=r,r}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let o,a=[];if(s.length){const r=Xt[i.position].call(this,s,this._eventPosition);a=this._createItems(i),this.title=this.getTitle(a,i),this.beforeBody=this.getBeforeBody(a,i),this.body=this.getBody(a,i),this.afterBody=this.getAfterBody(a,i),this.footer=this.getFooter(a,i);const l=this._size=js(this,i),c=Object.assign({},r,l),h=$s(this.chart,i,c),d=Us(i,c,h,this.chart);this.xAlign=h.xAlign,this.yAlign=h.yAlign,o={opacity:1,x:d.x,y:d.y,width:l.width,height:l.height,caretX:r.x,caretY:r.y}}else 0!==this.opacity&&(o={opacity:0});this._tooltipItems=a,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const o=this.getCaretPosition(t,i,s);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:o}=this,{caretSize:a,cornerRadius:r}=i,{topLeft:l,topRight:c,bottomLeft:h,bottomRight:d}=xt(r),{x:u,y:f}=t,{width:g,height:p}=e;let b,m,x,v,y,_;return"center"===o?(y=f+p/2,"left"===s?(b=u,m=b-a,v=y+a,_=y-a):(b=u+g,m=b+a,v=y-a,_=y+a),x=b):(m="left"===s?u+Math.max(l,h)+a:"right"===s?u+g-Math.max(c,d)-a:this.caretX,"top"===o?(v=f,y=v-a,b=m-a,x=m+a):(v=f+p,y=v+a,b=m+a,x=m-a),_=v),{x1:b,x2:m,x3:x,y1:v,y2:y,y3:_}}drawTitle(t,e,i){const s=this.title,o=s.length;let a,r,l;if(o){const c=Dt(i.rtl,this.x,this.width);for(t.x=ge(this,i.titleAlign,i),e.textAlign=c.textAlign(i.titleAlign),e.textBaseline="middle",a=V(i.titleFont),r=i.titleSpacing,e.fillStyle=i.titleColor,e.font=a.string,l=0;l0!==x)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,zt(t,{x:p,y:g,w:c,h:l,radius:m}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),zt(t,{x:b,y:g+1,w:c-2,h:l-2,radius:m}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(p,g,c,l),t.strokeRect(p,g,c,l),t.fillStyle=a.backgroundColor,t.fillRect(b,g+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:o,bodyAlign:a,displayColors:r,boxHeight:l,boxWidth:c,boxPadding:h}=i,d=V(i.bodyFont);let u=d.lineHeight,f=0;const g=Dt(i.rtl,this.x,this.width),p=function(S){e.fillText(S,g.x(t.x+f),t.y+u/2),t.y+=u+o},b=g.textAlign(a);let m,x,v,y,_,k,M;for(e.textAlign=a,e.textBaseline="middle",e.font=d.string,t.x=ge(this,b,i),e.fillStyle=i.bodyColor,O(this.beforeBody,p),f=r&&"right"!==b?"center"===a?c/2+h:c+2+h:0,y=0,k=s.length;y0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,s=i&&i.x,o=i&&i.y;if(s||o){const a=Xt[t.position].call(this,this._active,this._eventPosition);if(!a)return;const r=this._size=js(this,t),l=Object.assign({},a,this._size),c=$s(e,t,l),h=Us(t,l,c,e);(s._to!==h.x||o._to!==h.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=r.width,this.height=r.height,this.caretX=a.x,this.caretY=a.y,this._resolveAnimations().update(this,h))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const a=j(e.padding);e.enabled&&(this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length)&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,s,e),ci(t,e.textDirection),o.y+=a.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),hi(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map(({datasetIndex:r,index:l})=>{const c=this.chart.getDatasetMeta(r);if(!c)throw new Error("Cannot find a dataset at index "+r);return{datasetIndex:r,element:c.data[l],index:l}}),o=!ie(i,s),a=this._positionChanged(s,e);(o||a)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],a=this._getActiveElements(t,o,e,i),r=this._positionChanged(a,t),l=e||!ie(a,o)||r;return l&&(this._active=a,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,i,s){const o=this.options;if("mouseout"===t.type)return[];if(!s)return e;const a=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&a.reverse(),a}_positionChanged(t,e){const{caretX:i,caretY:s,options:o}=this,a=Xt[o.position].call(this,t,e);return!1!==a&&(i!==a.x||s!==a.y)}}var qs={id:"tooltip",_element:Gs,positioners:Xt,afterInit(n,t,e){e&&(n.tooltip=new Gs({chart:n,options:e}))},beforeUpdate(n,t,e){n.tooltip&&n.tooltip.initialize(e)},reset(n,t,e){n.tooltip&&n.tooltip.initialize(e)},afterDraw(n){const t=n.tooltip;if(t&&t._willRender()){const e={tooltip:t};if(!1===n.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0}))return;t.draw(n.ctx),n.notifyPlugins("afterTooltipDraw",e)}},afterEvent(n,t){n.tooltip&&n.tooltip.handleEvent(t.event,t.replay,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:(n,t)=>t.bodyFont.size,boxWidth:(n,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:Ks},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:n=>"filter"!==n&&"itemSort"!==n&&"external"!==n,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},Js=Object.freeze({__proto__:null,Colors:ws,Decimation:Cs,Filler:Fs,Legend:Ns,SubTitle:Ws,Title:Hs,Tooltip:qs});const Lr=(n,t,e,i)=>("string"==typeof t?(e=n.push(t)-1,i.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function Or(n,t,e,i){const s=n.indexOf(t);return-1===s?Lr(n,t,e,i):s!==n.lastIndexOf(t)?e:s}const Tr=(n,t)=>null===n?null:Y(Math.round(n),0,t);function Zs(n){const t=this.getLabels();return n>=0&&ne.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 Er(n,t){const e=[],{bounds:s,step:o,min:a,max:r,precision:l,count:c,maxTicks:h,maxDigits:d,includeBounds:u}=n,f=o||1,g=h-1,{min:p,max:b}=t,m=!L(a),x=!L(r),v=!L(c),y=(b-p)/(d+1);let k,M,S,w,_=ui((b-p)/g/f)*f;if(_<1e-14&&!m&&!x)return[{value:p},{value:b}];w=Math.ceil(b/_)-Math.floor(p/_),w>g&&(_=ui(w*_/g/f)*f),L(l)||(k=Math.pow(10,l),_=Math.ceil(_*k)/k),"ticks"===s?(M=Math.floor(p/_)*_,S=Math.ceil(b/_)*_):(M=p,S=b),m&&x&&o&&Un((r-a)/o,_/1e3)?(w=Math.round(Math.min((r-a)/_,h)),_=(r-a)/w,M=a,S=r):v?(M=m?a:M,S=x?r:S,w=c-1,_=(S-M)/w):(w=(S-M)/_,w=ke(w,Math.round(w),_/1e3)?Math.round(w):Math.ceil(w));const D=Math.max(fi(_),fi(M));k=Math.pow(10,L(l)?D:l),M=Math.round(M*k)/k,S=Math.round(S*k)/k;let P=0;for(m&&(u&&M!==a?(e.push({value:a}),Mr)break;e.push({value:A})}return x&&u&&S!==r?e.length&&ke(e[e.length-1].value,r,tn(r,y,n))?e[e.length-1].value=r:e.push({value:r}):(!x||S===r)&&e.push({value:S}),e}function tn(n,t,{horizontal:e,minRotation:i}){const s=tt(i),o=(e?Math.sin(s):Math.cos(s))||.001;return Math.min(t/o,.75*t*(""+n).length)}class pe extends ut{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 L(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:o}=this;const a=l=>s=e?s:l,r=l=>o=i?o:l;if(t){const l=ct(s),c=ct(o);l<0&&c<0?r(0):l>0&&c>0&&a(0)}if(s===o){let l=0===o?1:Math.abs(.05*o);r(o+l),t||a(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let s,{maxTicksLimit:e,stepSize:i}=t;return i?(s=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,s>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${i} 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 i=this.getTickLimit();i=Math.max(2,i);const a=Er({maxTicks:i,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:!1!==e.includeBounds},this._range||this);return"ticks"===t.bounds&&di(a,this,"value"),t.reverse?(a.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),a}configure(){const t=this.ticks;let e=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-e)/Math.max(t.length-1,1)/2;e-=s,i+=s}this._startValue=e,this._endValue=i,this._valueRange=i-e}getLabelForValue(t){return qt(t,this.chart.options.locale,this.options.ticks.format)}}class en extends pe{static id="linear";static defaults={ticks:{callback:se.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=B(t)?t:0,this.max=B(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=tt(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const Kt=n=>Math.floor(It(n)),yt=(n,t)=>Math.pow(10,Kt(n)+t);function sn(n){return n/Math.pow(10,Kt(n))==1}function nn(n,t,e){const i=Math.pow(10,e),s=Math.floor(n/i);return Math.ceil(t/i)-s}function Rr(n,t){let i=Kt(t-n);for(;nn(n,t,i)>10;)i++;for(;nn(n,t,i)<10;)i--;return Math.min(i,Kt(n))}function zr(n,{min:t,max:e}){t=J(n.min,t);const i=[],s=Kt(t);let o=Rr(t,e),a=o<0?Math.pow(10,Math.abs(o)):1;const r=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((t-l)*a)/a,h=Math.floor((t-l)/r/10)*r*10;let d=Math.floor((c-h)/Math.pow(10,o)),u=J(n.min,Math.round((l+h+d*Math.pow(10,o))*a)/a);for(;u=10?d=d<15?15:20:d++,d>=20&&(o++,d=2,a=o>=0?1:a),u=Math.round((l+h+d*Math.pow(10,o))*a)/a;const f=J(n.max,u);return i.push({value:f,major:sn(f),significand:d}),i}class on extends ut{static id="logarithmic";static defaults={ticks:{callback:se.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 i=pe.prototype.parse.apply(this,[t,e]);if(0!==i)return B(i)&&i>0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=B(t)?Math.max(0,t):null,this.max=B(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!B(this._userMin)&&(this.min=t===yt(this.min,0)?yt(this.min,-1):yt(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const o=r=>i=t?i:r,a=r=>s=e?s:r;i===s&&(i<=0?(o(1),a(10)):(o(yt(i,-1)),a(yt(s,1)))),i<=0&&o(yt(s,-1)),s<=0&&a(yt(i,1)),this.min=i,this.max=s}buildTicks(){const t=this.options,i=zr({min:this._userMin,max:this._userMax},this);return"ticks"===t.bounds&&di(i,this,"value"),t.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}getLabelForValue(t){return void 0===t?"0":qt(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=It(t),this._valueRange=It(this.max)-It(t)}getPixelForValue(t){return(void 0===t||0===t)&&(t=this.min),null===t||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(It(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function We(n){const t=n.ticks;if(t.display&&n.display){const e=j(t.backdropPadding);return C(t.font&&t.font.size,F.font.size)+e.height}return 0}function Fr(n,t,e){return e=X(e)?e:[e],{w:Yn(n,t.string,e),h:e.length*t.lineHeight}}function an(n,t,e,i,s){return n===i||n===s?{start:t-e/2,end:t+e/2}:ns?{start:t-e,end:t}:{start:t,end:t+e}}function Ir(n){const t={l:n.left+n._padding.left,r:n.right-n._padding.right,t:n.top+n._padding.top,b:n.bottom-n._padding.bottom},e=Object.assign({},t),i=[],s=[],o=n._pointLabels.length,a=n.options.pointLabels,r=a.centerPointLabels?ot/o:0;for(let l=0;lt.r&&(r=(i.end-t.r)/o,n.r=Math.max(n.r,t.r+r)),s.startt.b&&(l=(s.end-t.b)/a,n.b=Math.max(n.b,t.b+l))}function Vr(n,t,e){const i=n.drawingArea,{extra:s,additionalAngle:o,padding:a,size:r}=e,l=n.getPointPosition(t,i+s+a,o),c=Math.round(_e(Ft(l.angle+Z))),h=$r(l.y,r.h,c),d=Wr(c),u=jr(l.x,r.w,d);return{visible:!0,x:l.x,y:h,textAlign:d,left:u,top:h,right:u+r.w,bottom:h+r.h}}function Nr(n,t){if(!t)return!0;const{left:e,top:i,right:s,bottom:o}=n;return!(pt({x:e,y:i},t)||pt({x:e,y:o},t)||pt({x:s,y:i},t)||pt({x:s,y:o},t))}function Hr(n,t,e){const i=[],s=n._pointLabels.length,o=n.options,{centerPointLabels:a,display:r}=o.pointLabels,l={extra:We(o)/2,additionalAngle:a?ot/s:0};let c;for(let h=0;h270||e<90)&&(n-=t),n}function Ur(n,t,e){const{left:i,top:s,right:o,bottom:a}=e,{backdropColor:r}=t;if(!L(r)){const l=xt(t.borderRadius),c=j(t.backdropPadding);n.fillStyle=r;const h=i-c.left,d=s-c.top,u=o-i+c.width,f=a-s+c.height;Object.values(l).some(g=>0!==g)?(n.beginPath(),zt(n,{x:h,y:d,w:u,h:f,radius:l}),n.fill()):n.fillRect(h,d,u,f)}}function Yr(n,t){const{ctx:e,options:{pointLabels:i}}=n;for(let s=t-1;s>=0;s--){const o=n._pointLabelItems[s];if(!o.visible)continue;const a=i.setContext(n.getPointLabelContext(s));Ur(e,a,o);const r=V(a.font),{x:l,y:c,textAlign:h}=o;bt(e,n._pointLabels[s],l,c+r.lineHeight/2,r,{color:a.color,textAlign:h,textBaseline:"middle"})}}function rn(n,t,e,i){const{ctx:s}=n;if(e)s.arc(n.xCenter,n.yCenter,t,0,U);else{let o=n.getPointPosition(0,t);s.moveTo(o.x,o.y);for(let a=1;at,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=j(We(this.options)/2),e=this.width=this.maxWidth-t.width,i=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+i/2+t.top),this.drawingArea=Math.floor(Math.min(e,i)/2)}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!1);this.min=B(t)&&!isNaN(t)?t:0,this.max=B(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/We(this.options))}generateTickLabels(t){pe.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,i)=>{const s=E(this.options.pointLabels.callback,[e,i],this);return s||0===s?s:""}).filter((e,i)=>this.chart.getDataVisibility(i))}fit(){const t=this.options;t.display&&t.pointLabels.display?Ir(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,i,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((i-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,i,s))}getIndexAngle(t){return Ft(t*(U/(this._pointLabels.length||1))+tt(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(L(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(L(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{if(0!==d){l=this.getDistanceFromCenterForValue(h.value);const u=this.getContext(d),f=s.setContext(u),g=o.setContext(u);Xr(this,f,l,a,g)}}),i.display){for(t.save(),r=a-1;r>=0;r--){const h=i.setContext(this.getPointLabelContext(r)),{color:d,lineWidth:u}=h;!u||!d||(t.lineWidth=u,t.strokeStyle=d,t.setLineDash(h.borderDash),t.lineDashOffset=h.borderDashOffset,l=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),c=this.getPointPosition(r,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,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let o,a;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((r,l)=>{if(0===l&&!e.reverse)return;const c=i.setContext(this.getContext(l)),h=V(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=h.string,a=t.measureText(r.label).width,t.fillStyle=c.backdropColor;const d=j(c.backdropPadding);t.fillRect(-a/2-d.left,-o-h.size/2-d.top,a+d.width,h.size+d.height)}bt(t,r.label,0,-o,h,{color:c.color})}),t.restore()}drawTitle(){}}const me={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}},G=Object.keys(me);function Gr(n,t){return n-t}function cn(n,t){if(L(t))return null;const e=n._adapter,{parser:i,round:s,isoWeekday:o}=n._parseOpts;let a=t;return"function"==typeof i&&(a=i(a)),B(a)||(a="string"==typeof i?e.parse(a,i):e.parse(a)),null===a?null:(s&&(a="week"!==s||!St(o)&&!0!==o?e.startOf(a,s):e.startOf(a,"isoWeek",o)),+a)}function hn(n,t,e,i){const s=G.length;for(let o=G.indexOf(n);o=G.indexOf(e);o--){const a=G[o];if(me[a].common&&n._adapter.diff(s,i,a)>=t-1)return a}return G[e?G.indexOf(e):0]}function Jr(n){for(let t=G.indexOf(n)+1,e=G.length;t=t?e[i]:e[s]]=!0}}else n[t]=!0}function Zr(n,t,e,i){const s=n._adapter,o=+s.startOf(t[0].value,i),a=t[t.length-1].value;let r,l;for(r=o;r<=a;r=+s.add(r,1,i))l=e[r],l>=0&&(t[l].major=!0);return t}function un(n,t,e){const i=[],s={},o=t.length;let a,r;for(a=0;a+t.value))}initOffsets(t=[]){let s,o,e=0,i=0;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),e=1===t.length?1-s:(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),i=1===t.length?o:(o-this.getDecimalForValue(t[t.length-2]))/2);const a=t.length<3?.5:.25;e=Y(e,0,a),i=Y(i,0,a),this._offsets={start:e,end:i,factor:1/(e+1+i)}}_generate(){const t=this._adapter,e=this.min,i=this.max,s=this.options,o=s.time,a=o.unit||hn(o.minUnit,e,i,this._getLabelCapacity(e)),r=C(s.ticks.stepSize,1),l="week"===a&&o.isoWeekday,c=St(l)||!0===l,h={};let u,f,d=e;if(c&&(d=+t.startOf(d,"isoWeek",l)),d=+t.startOf(d,c?"day":a),t.diff(i,e,a)>1e5*r)throw new Error(e+" and "+i+" are too far apart with stepSize of "+r+" "+a);const g="data"===s.ticks.source&&this.getDataTimestamps();for(u=d,f=0;up-b).map(p=>+p)}getLabelForValue(t){const i=this.options.time;return this._adapter.format(t,i.tooltipFormat?i.tooltipFormat:i.displayFormats.datetime)}format(t,e){return this._adapter.format(t,e||this.options.time.displayFormats[this._unit])}_tickFormatFunction(t,e,i,s){const o=this.options,a=o.ticks.callback;if(a)return E(a,[t,e,i],this);const r=o.time.displayFormats,l=this._unit,c=this._majorUnit,d=c&&r[c],u=i[e];return this._adapter.format(t,s||(c&&d&&u&&u.major?d:l&&r[l]))}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?r:1}getDataTimestamps(){let e,i,t=this._cache.data||[];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,i=s.length;e=n[i].pos&&t<=n[s].pos&&({lo:i,hi:s}=Rt(n,"pos",t)),({pos:o,time:r}=n[i]),({pos:a,time:l}=n[s])):(t>=n[i].time&&t<=n[s].time&&({lo:i,hi:s}=Rt(n,"time",t)),({time:o,pos:r}=n[i]),({time:a,pos:l}=n[s]));const c=a-o;return c?r+(l-r)*(t-o)/c:r}class fn extends be{static id="timeseries";static defaults=be.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=xe(e,this.min),this._tableRange=xe(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],o=[];let a,r,l,c,h;for(a=0,r=t.length;a=e&&c<=i&&s.push(c);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(a=0,r=s.length;a