From adbd95b89413edc837043ca1668e7c8622513cf2 Mon Sep 17 00:00:00 2001 From: rakshitranga <61892635+rakshitranga@users.noreply.github.com> Date: Tue, 9 Apr 2024 21:45:02 -0400 Subject: [PATCH] one more attempt --- docs/assets/{index-a37fde6a.js => index-b168d8d6.js} | 2 +- docs/index.html | 2 +- src/App.svelte | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename docs/assets/{index-a37fde6a.js => index-b168d8d6.js} (99%) diff --git a/docs/assets/index-a37fde6a.js b/docs/assets/index-b168d8d6.js similarity index 99% rename from docs/assets/index-a37fde6a.js rename to docs/assets/index-b168d8d6.js index 9a2ec96..a735604 100644 --- a/docs/assets/index-a37fde6a.js +++ b/docs/assets/index-b168d8d6.js @@ -25,4 +25,4 @@ From previous: `);return this._state!==null&&(this._stack=n),n}finally{Eo=!1}}}, * Released under the MIT License */class Tg{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const o=e.listeners[s],r=e.duration;o.forEach(a=>a({chart:t,initial:e.initial,numSteps:r,currentStep:Math.min(i-e.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=lu.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 r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>i.duration&&(i.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(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,e===0&&(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 se=new Tg;const nl="transparent",Eg={boolean(n,t,e){return e>.5?t:n},color(n,t,e){const i=qa(n||nl),s=i.valid&&qa(t||nl);return s&&s.valid?s.mix(i,e).hexString():t},number(n,t,e){return n+(t-n)*e}};class Rg{constructor(t,e,i,s){const o=e[i];s=qn([t.to,s,o,t.from]);const r=qn([t.from,o,s]);this._active=!0,this._fn=t.fn||Eg[t.type||typeof r],this._easing=si[t.easing]||si.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=r,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,r=this._duration-o;this._start=i,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=qn([t.to,e,s,t.from]),this._from=qn([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,r=this._loop,a=this._to;let l;if(this._active=o!==a&&(r||e1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[s]=this._fn(o,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,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(!Y(o))return;const r={};for(const a of e)r[a]=o[a];(nt(o.properties)&&o.properties||[s]).forEach(a=>{(a===s||!i.has(a))&&i.set(a,r)})})}_animateOptions(t,e){const i=e.options,s=Ig(t,i);if(!s)return[];const o=this._createAnimations(s,i);return i.$shared&&Lg(t.options.$animations,i).then(()=>{t.options=i},()=>{}),o}_createAnimations(t,e){const i=this._properties,s=[],o=t.$animations||(t.$animations={}),r=Object.keys(e),a=Date.now();let l;for(l=r.length-1;l>=0;--l){const c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){s.push(...this._animateOptions(t,e));continue}const u=e[c];let h=o[c];const f=i.get(c);if(h)if(f&&h.active()){h.update(f,u,a);continue}else h.cancel();if(!f||!f.duration){t[c]=u;continue}o[c]=h=new Rg(f,t,c,u),s.push(h)}return s}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}const i=this._createAnimations(t,e);if(i.length)return se.add(this._chart,i),!0}}function Lg(n,t){const e=[],i=Object.keys(t);for(let s=0;s0||!e&&o<0)return s.index}return null}function al(n,t){const{chart:e,_cachedMeta:i}=n,s=e._stacks||(e._stacks={}),{iScale:o,vScale:r,index:a}=i,l=o.axis,c=r.axis,u=$g(o,r,i),h=t.length;let f;for(let d=0;de[i].axis===t).shift()}function Vg(n,t){return Fe(n,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function Hg(n,t,e){return Fe(n,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function Fn(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||o[i]===void 0||o[i][e]===void 0)return;delete o[i][e],o[i]._visualValues!==void 0&&o[i]._visualValues[e]!==void 0&&delete o[i]._visualValues[e]}}}const fo=n=>n==="reset"||n==="none",ll=(n,t)=>t?n:Object.assign({},n),Wg=(n,t,e)=>n&&!t.hidden&&t._stacked&&{keys:Ou(e,!0),values:null};class Wt{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=ol(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&&Fn(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(h,f,d,p)=>h==="x"?f:h==="r"?p:d,o=e.xAxisID=H(i.xAxisID,ho(t,"x")),r=e.yAxisID=H(i.yAxisID,ho(t,"y")),a=e.rAxisID=H(i.rAxisID,ho(t,"r")),l=e.indexAxis,c=e.iAxisID=s(l,o,r,a),u=e.vAxisID=s(l,r,o,a);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(r),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(c),e.vScale=this.getScaleForId(u)}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&&Ha(this._data,this),t._stacked&&Fn(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(Y(e))this._data=zg(e);else if(i!==e){if(i){Ha(i,this);const s=this._cachedMeta;Fn(s),s._parsed=[]}e&&Object.isExtensible(e)&&Ap(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=ol(e.vScale,e),e.stack!==i.stack&&(s=!0,Fn(e),e.stack=i.stack),this._resyncElements(t),(s||o!==e._stacked)&&al(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:r}=i,a=o.axis;let l=t===0&&e===s.length?!0:i._sorted,c=t>0&&i._parsed[t-1],u,h,f;if(this._parsing===!1)i._parsed=s,i._sorted=!0,f=s;else{nt(s[t])?f=this.parseArrayData(i,s,t,e):Y(s[t])?f=this.parseObjectData(i,s,t,e):f=this.parsePrimitiveData(i,s,t,e);const d=()=>h[a]===null||c&&h[a]g||h=0;--f)if(!p()){this.updateRangeFromParsed(c,t,d,l);break}}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,o,r;for(s=0,o=e.length;s=0&&tthis.getContext(i,s,e),g=c.resolveNamedOptions(f,d,p,h);return g.$shared&&(g.$shared=l,o[r]=Object.freeze(ll(g,l))),g}_resolveAnimations(t,e,i){const s=this.chart,o=this._cachedDataOpts,r=`animation-${e}`,a=o[r];if(a)return a;let l;if(s.options.animation!==!1){const u=this.chart.config,h=u.datasetAnimationScopeKeys(this._type,e),f=u.getOptionScopes(this.getDataset(),h);l=u.createResolver(f,this.getContext(t,i,e))}const c=new Pu(s,l&&l.animations);return l&&l._cacheable&&(o[r]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||fo(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const i=this.resolveDataElementOptions(t,e),s=this._sharedOptions,o=this.getSharedOptions(i),r=this.includeOptions(e,o)||o!==s;return this.updateSharedOptions(o,e,i),{sharedOptions:o,includeOptions:r}}updateElement(t,e,i,s){fo(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!fo(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[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const s=i.length,o=e.length,r=Math.min(o,s);r&&this.parse(0,r),o>s?this._insertElements(s,o-s,t):o{for(c.length+=e,a=c.length-1;a>=r;a--)c[a]=c[a-e]};for(l(o),a=t;as-o))}return n._cache.$bar}function qg(n){const t=n.iScale,e=Kg(t,n.type);let i=t._length,s,o,r,a;const l=()=>{r===32767||r===-32768||(bi(a)&&(i=Math.min(i,Math.abs(r-a)||i)),a=r)};for(s=0,o=e.length;s0?s[n-1]:null,a=nMath.abs(a)&&(l=a,c=r),t[e.axis]=c,t._custom={barStart:l,barEnd:c,start:s,end:o,min:r,max:a}}function Au(n,t,e,i){return nt(n)?Xg(n,t,e,i):t[e.axis]=e.parse(n,i),t}function cl(n,t,e,i){const s=n.iScale,o=n.vScale,r=s.getLabels(),a=s===o,l=[];let c,u,h,f;for(c=e,u=e+i;c=e?1:-1)}function Qg(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,r=[],a=l=>{const c=l.controller.getParsed(e),u=c&&c[l.vScale.axis];if(X(u)||isNaN(u))return!0};for(const l of s)if(!(e!==void 0&&a(l))&&((o===!1||r.indexOf(l.stack)===-1||o===void 0&&l.stack===void 0)&&r.push(l.stack),l.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const s=this._getStacks(t,i),o=e!==void 0?s.indexOf(e):-1;return o===-1?s.length-1:o}_getRuler(){const t=this.options,e=this._cachedMeta,i=e.iScale,s=[];let o,r;for(o=0,r=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,r=this.getParsed(t),a=s.getLabelForValue(r.x),l=o.getLabelForValue(r.y),c=r._custom;return{label:i[t]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const o=s==="reset",{iScale:r,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(e,s),u=r.axis,h=a.axis;for(let f=e;f_i(y,a,l,!0)?1:Math.max(v,v*e,x,x*e),p=(y,v,x)=>_i(y,a,l,!0)?-1:Math.min(v,v*e,x,x*e),g=d(0,c,h),b=d(ht,u,f),m=p(rt,c,h),_=p(rt+ht,u,f);i=(g-m)/2,s=(b-_)/2,o=-(g+m)/2,r=-(b+_)/2}return{ratioX:i,ratioY:s,offsetX:o,offsetY:r}}class Ke extends Wt{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(this._parsing===!1)s._parsed=i;else{let o=l=>+i[l];if(Y(i[t])){const{key:l="value"}=this._parsing;o=c=>+Le(i[c],l)}let r,a;for(r=t,a=t+e;r0&&!isNaN(t)?ot*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],o=Ci(e._parsed[t],i.options.locale);return{label:s[t]||"",value:o}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,o,r,a,l;if(!t){for(s=0,o=i.data.datasets.length;st!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),A(Ke,"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,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}}});class cs extends Wt{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:o}=e,r=this.chart._animationsDisabled;let{start:a,count:l}=uu(e,s,r);this._drawStart=a,this._drawCount=l,hu(e)&&(a=0,l=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!o._decimated,i.points=s;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:c},t),this.updateElements(s,a,l,t)}updateElements(t,e,i,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:u,includeOptions:h}=this._getSharedOptions(e,s),f=r.axis,d=a.axis,{spanGaps:p,segment:g}=this.options,b=Pn(p)?p:Number.POSITIVE_INFINITY,m=this.chart._animationsDisabled||o||s==="none",_=e+i,y=t.length;let v=e>0&&this.getParsed(e-1);for(let x=0;x=_){M.skip=!0;continue}const k=this.getParsed(x),w=X(k[d]),O=M[f]=r.getPixelForValue(k[f],x),D=M[d]=o||w?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,k,l):k[d],x);M.skip=isNaN(O)||isNaN(D)||w,M.stop=x>0&&Math.abs(k[f]-v[f])>b,g&&(M.parsed=k,M.raw=c.data[x]),h&&(M.options=u||this.resolveDataElementOptions(x,S.active?"active":s)),m||this.updateElement(S,x,M,s),v=k}}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)),r=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}A(cs,"id","line"),A(cs,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),A(cs,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class ri extends Wt{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],o=Ci(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:o}}parseObjectData(t,e,i,s){return yu.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((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=Math.max(i.cutoutPercentage?o/100*i.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,i,s){const o=s==="reset",r=this.chart,l=r.options.animation,c=this._cachedMeta.rScale,u=c.xCenter,h=c.yCenter,f=c.getIndexAngle(0)-.5*rt;let d=f,p;const g=360/this.countVisibleElements();for(p=0;p{!isNaN(this.getParsed(s).r)&&this.chart.getDataVisibility(s)&&e++}),e}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?Ht(this.resolveDataElementOptions(t,e).angle||i):0}}A(ri,"id","polarArea"),A(ri,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),A(ri,"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,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(r),index:r}})}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}}});class tr extends Ke{}A(tr,"id","pie"),A(tr,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});class us extends Wt{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 yu.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,t!=="resize"){const r=this.resolveDatasetElementOptions(t);this.options.showLine||(r.borderWidth=0);const a={_loop:!0,_fullLoop:o.length===s.length,options:r};this.updateElement(i,void 0,a,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const o=this._cachedMeta.rScale,r=s==="reset";for(let a=e;a0&&this.getParsed(e-1);for(let v=e;v0&&Math.abs(S[d]-y[d])>m,b&&(M.parsed=S,M.raw=c.data[v]),f&&(M.options=h||this.resolveDataElementOptions(v,x.active?"active":s)),_||this.updateElement(x,v,M,s),y=S}this.updateSharedOptions(h,s,u)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let a=0;for(let l=e.length-1;l>=0;--l)a=Math.max(a,e[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}const i=t.dataset,s=i.options&&i.options.borderWidth||0;if(!e.length)return s;const o=e[0].size(this.resolveDataElementOptions(0)),r=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(s,o,r)/2}}A(hs,"id","scatter"),A(hs,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),A(hs,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});var nm=Object.freeze({__proto__:null,BarController:as,BubbleController:ls,DoughnutController:Ke,LineController:cs,PieController:tr,PolarAreaController:ri,RadarController:us,ScatterController:hs});function je(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Vr{constructor(t){A(this,"options");this.options=t||{}}static override(t){Object.assign(Vr.prototype,t)}init(){}formats(){return je()}parse(){return je()}format(){return je()}add(){return je()}diff(){return je()}startOf(){return je()}endOf(){return je()}}var im={_date:Vr};function sm(n,t,e,i){const{controller:s,data:o,_sorted:r}=n,a=s._cachedMeta.iScale;if(a&&t===a.axis&&t!=="r"&&r&&o.length){const l=a._reversePixels?Pp:fe;if(i){if(s._sharedOptions){const c=o[0],u=typeof c.getRange=="function"&&c.getRange(t);if(u){const h=l(o,t,e-u),f=l(o,t,e+u);return{lo:h.lo,hi:f.hi}}}}else return l(o,t,e)}return{lo:0,hi:o.length-1}}function Pi(n,t,e,i,s){const o=n.getSortedVisibleDatasetMetas(),r=e[t];for(let a=0,l=o.length;a{l[r](t[e],s)&&(o.push({element:l,datasetIndex:c,index:u}),a=a||l.inRange(t.x,t.y,s))}),i&&!a?[]:o}var lm={evaluateInteractionItems:Pi,modes:{index(n,t,e,i){const s=Ve(t,n),o=e.axis||"x",r=e.includeInvisible||!1,a=e.intersect?go(n,s,o,i,r):mo(n,s,o,!1,i,r),l=[];return a.length?(n.getSortedVisibleDatasetMetas().forEach(c=>{const u=a[0].index,h=c.data[u];h&&!h.skip&&l.push({element:h,datasetIndex:c.index,index:u})}),l):[]},dataset(n,t,e,i){const s=Ve(t,n),o=e.axis||"xy",r=e.includeInvisible||!1;let a=e.intersect?go(n,s,o,i,r):mo(n,s,o,!1,i,r);if(a.length>0){const l=a[0].datasetIndex,c=n.getDatasetMeta(l).data;a=[];for(let u=0;ue.pos===t)}function dl(n,t){return n.filter(e=>Du.indexOf(e.pos)===-1&&e.box.axis===t)}function zn(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 cm(n){const t=[];let e,i,s,o,r,a;for(e=0,i=(n||[]).length;ec.box.fullSize),!0),i=zn(Bn(t,"left"),!0),s=zn(Bn(t,"right")),o=zn(Bn(t,"top"),!0),r=zn(Bn(t,"bottom")),a=dl(t,"x"),l=dl(t,"y");return{fullSize:e,leftAndTop:i.concat(o),rightAndBottom:s.concat(l).concat(r).concat(a),chartArea:Bn(t,"chartArea"),vertical:i.concat(s).concat(l),horizontal:o.concat(r).concat(a)}}function pl(n,t,e,i){return Math.max(n[e],t[e])+Math.max(n[i],t[i])}function Tu(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 dm(n,t,e,i){const{pos:s,box:o}=e,r=n.maxPadding;if(!Y(s)){e.size&&(n[s]-=e.size);const h=i[e.stack]||{size:0,count:1};h.size=Math.max(h.size,e.horizontal?o.height:o.width),e.size=h.size/h.count,n[s]+=e.size}o.getPadding&&Tu(r,o.getPadding());const a=Math.max(0,t.outerWidth-pl(r,n,"left","right")),l=Math.max(0,t.outerHeight-pl(r,n,"top","bottom")),c=a!==n.w,u=l!==n.h;return n.w=a,n.h=l,e.horizontal?{same:c,other:u}:{same:u,other:c}}function pm(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 gm(n,t){const e=t.maxPadding;function i(s){const o={left:0,top:0,right:0,bottom:0};return s.forEach(r=>{o[r]=Math.max(t[r],e[r])}),o}return i(n?["left","right"]:["top","bottom"])}function Un(n,t,e,i){const s=[];let o,r,a,l,c,u;for(o=0,r=n.length,c=0;o{typeof g.beforeLayout=="function"&&g.beforeLayout()});const u=l.reduce((g,b)=>b.box.options&&b.box.options.display===!1?g:g+1,0)||1,h=Object.freeze({outerWidth:t,outerHeight:e,padding:s,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/u,hBoxMaxHeight:r/2}),f=Object.assign({},s);Tu(f,Mt(i));const d=Object.assign({maxPadding:f,w:o,h:r,x:s.left,y:s.top},s),p=hm(l.concat(c),h);Un(a.fullSize,d,h,p),Un(l,d,h,p),Un(c,d,h,p)&&Un(l,d,h,p),pm(d),gl(a.leftAndTop,d,h,p),d.x+=d.w,d.y+=d.h,gl(a.rightAndBottom,d,h,p),n.chartArea={left:d.left,top:d.top,right:d.left+d.w,bottom:d.top+d.h,height:d.h,width:d.w},Z(a.chartArea,g=>{const b=g.box;Object.assign(b,n.chartArea),b.update(d.w,d.h,{left:0,top:0,right:0,bottom:0})})}};class Eu{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 mm extends Eu{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const fs="$chartjs",bm={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},ml=n=>n===null||n==="";function _m(n,t){const e=n.style,i=n.getAttribute("height"),s=n.getAttribute("width");if(n[fs]={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",ml(s)){const o=Za(n,"width");o!==void 0&&(n.width=o)}if(ml(i))if(n.style.height==="")n.height=n.width/(t||2);else{const o=Za(n,"height");o!==void 0&&(n.height=o)}return n}const Ru=xg?{passive:!0}:!1;function ym(n,t,e){n.addEventListener(t,e,Ru)}function xm(n,t,e){n.canvas.removeEventListener(t,e,Ru)}function vm(n,t){const e=bm[n.type]||n.type,{x:i,y:s}=Ve(n,t);return{type:e,chart:t,native:n,x:i!==void 0?i:null,y:s!==void 0?s:null}}function Ls(n,t){for(const e of n)if(e===t||e.contains(t))return!0}function wm(n,t,e){const i=n.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||Ls(a.addedNodes,i),r=r&&!Ls(a.removedNodes,i);r&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}function km(n,t,e){const i=n.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||Ls(a.removedNodes,i),r=r&&!Ls(a.addedNodes,i);r&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}const xi=new Map;let bl=0;function Lu(){const n=window.devicePixelRatio;n!==bl&&(bl=n,xi.forEach((t,e)=>{e.currentDevicePixelRatio!==n&&t()}))}function Sm(n,t){xi.size||window.addEventListener("resize",Lu),xi.set(n,t)}function Mm(n){xi.delete(n),xi.size||window.removeEventListener("resize",Lu)}function Cm(n,t,e){const i=n.canvas,s=i&&Nr(i);if(!s)return;const o=cu((a,l)=>{const c=s.clientWidth;e(a,l),c{const l=a[0],c=l.contentRect.width,u=l.contentRect.height;c===0&&u===0||o(c,u)});return r.observe(s),Sm(n,o),r}function bo(n,t,e){e&&e.disconnect(),t==="resize"&&Mm(n)}function Pm(n,t,e){const i=n.canvas,s=cu(o=>{n.ctx!==null&&e(vm(o,n))},n);return ym(i,t,s),s}class Om extends Eu{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(_m(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[fs])return!1;const i=e[fs].initial;["height","width"].forEach(o=>{const r=i[o];X(r)?e.removeAttribute(o):e.setAttribute(o,r)});const s=i.style||{};return Object.keys(s).forEach(o=>{e.style[o]=s[o]}),e.width=e.width,delete e[fs],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),r={attach:wm,detach:km,resize:Cm}[e]||Pm;s[e]=r(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];if(!s)return;({attach:bo,detach:bo,resize:bo}[e]||xm)(t,e,s),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return yg(t,e,i,s)}isAttached(t){const e=Nr(t);return!!(e&&e.isConnected)}}function Am(n){return!vu()||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas?mm:Om}class qt{constructor(){A(this,"x");A(this,"y");A(this,"active",!1);A(this,"options");A(this,"$animations")}tooltipPosition(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}hasValue(){return Pn(this.x)&&Pn(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}}A(qt,"defaults",{}),A(qt,"defaultRoutes");function Dm(n,t){const e=n.options.ticks,i=Tm(n),s=Math.min(e.maxTicksLimit||i,i),o=e.major.enabled?Rm(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>s)return Lm(t,c,o,r/s),c;const u=Em(o,t,s);if(r>0){let h,f;const d=r>1?Math.round((l-a)/(r-1)):null;for(qi(t,c,u,X(d)?0:a-d,a),h=0,f=r-1;hs)return l}return Math.max(s,1)}function Rm(n){const t=[];let e,i;for(e=0,i=n.length;en==="left"?"right":n==="right"?"left":n,_l=(n,t,e)=>t==="top"||t==="left"?n[t]+e:n[t]-e,yl=(n,t)=>Math.min(t||n,n);function xl(n,t){const e=[],i=n.length/t,s=n.length;let o=0;for(;or+a)))return l}function zm(n,t){Z(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:Lt(e,Lt(i,e)),max:Lt(i,Lt(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(){et(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:o,ticks:r}=this.options,a=r.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=Qp(this,o,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a=o||i<=1||!this.isHorizontal()){this.labelRotation=s;return}const u=this._getLabelSizes(),h=u.widest.width,f=u.highest.height,d=gt(this.chart.width-h,0,this.maxWidth);a=t.offset?this.maxWidth/i:d/(i-1),h+6>a&&(a=d/(i-(t.offset?.5:1)),l=this.maxHeight-$n(t.grid)-e.padding-vl(t.title,this.chart.options.font),c=Math.sqrt(h*h+f*f),r=Rr(Math.min(Math.asin(gt((u.highest.height+6)/a,-1,1)),Math.asin(gt(l/c,-1,1))-Math.asin(gt(f/c,-1,1)))),r=Math.max(s,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){et(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){et(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const l=vl(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=$n(o)+l):(t.height=this.maxHeight,t.width=$n(o)+l),i.display&&this.ticks.length){const{first:c,last:u,widest:h,highest:f}=this._getLabelSizes(),d=i.padding*2,p=Ht(this.labelRotation),g=Math.cos(p),b=Math.sin(p);if(a){const m=i.mirror?0:b*h.width+g*f.height;t.height=Math.min(this.maxHeight,t.height+m+d)}else{const m=i.mirror?0:g*h.width+b*f.height;t.width=Math.min(this.maxWidth,t.width+m+d)}this._calculatePadding(c,u,b,g)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const u=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let f=0,d=0;l?c?(f=s*t.width,d=i*e.height):(f=i*t.height,d=s*e.width):o==="start"?d=e.width:o==="end"?f=t.width:o!=="inner"&&(f=t.width/2,d=e.width/2),this.paddingLeft=Math.max((f-u+r)*this.width/(this.width-u),0),this.paddingRight=Math.max((d-h+r)*this.width/(this.width-h),0)}else{let u=e.height/2,h=t.height/2;o==="start"?(u=0,h=t.height):o==="end"&&(u=e.height,h=0),this.paddingTop=u+r,this.paddingBottom=h+r}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){et(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let e,i;for(e=0,i=t.length;e({width:r[w]||0,height:a[w]||0});return{first:k(0),last:k(e-1),widest:k(S),highest:k(M),widths:r,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return Cp(this._alignToPixels?$e(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&&ta*s?a/i:l/s:l*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:o,position:r,border:a}=s,l=o.offset,c=this.isHorizontal(),h=this.ticks.length+(l?1:0),f=$n(o),d=[],p=a.setContext(this.getContext()),g=p.display?p.width:0,b=g/2,m=function(q){return $e(i,q,g)};let _,y,v,x,S,M,k,w,O,D,R,N;if(r==="top")_=m(this.bottom),M=this.bottom-f,w=_-b,D=m(t.top)+b,N=t.bottom;else if(r==="bottom")_=m(this.top),D=t.top,N=m(t.bottom)-b,M=_+b,w=this.top+f;else if(r==="left")_=m(this.right),S=this.right-f,k=_-b,O=m(t.left)+b,R=t.right;else if(r==="right")_=m(this.left),O=t.left,R=m(t.right)-b,S=_+b,k=this.left+f;else if(e==="x"){if(r==="center")_=m((t.top+t.bottom)/2+.5);else if(Y(r)){const q=Object.keys(r)[0],U=r[q];_=m(this.chart.scales[q].getPixelForValue(U))}D=t.top,N=t.bottom,M=_+b,w=M+f}else if(e==="y"){if(r==="center")_=m((t.left+t.right)/2);else if(Y(r)){const q=Object.keys(r)[0],U=r[q];_=m(this.chart.scales[q].getPixelForValue(U))}S=_-b,k=S-f,O=t.left,R=t.right}const W=H(s.ticks.maxTicksLimit,h),K=Math.max(1,Math.ceil(h/W));for(y=0;yo.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,r;const a=(l,c,u)=>{!u.width||!u.color||(i.save(),i.lineWidth=u.width,i.strokeStyle=u.color,i.setLineDash(u.borderDash||[]),i.lineDashOffset=u.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,r=s.length;o{this.draw(o)}}]:[{z:i,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let o,r;for(o=0,r=e.length;o{const i=e.split("."),s=i.pop(),o=[n].concat(i).join("."),r=t[e].split("."),a=r.pop(),l=r.join(".");ut.route(o,s,l,a)})}function Km(n){return"id"in n&&"defaults"in n}class qm{constructor(){this.controllers=new Ui(Wt,"datasets",!0),this.elements=new Ui(qt,"elements"),this.plugins=new Ui(Object,"plugins"),this.scales=new Ui(rn,"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):Z(s,r=>{const a=i||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,e,i){const s=Er(t);et(i["before"+s],[],i),e[t](i),et(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;eo.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function Ym(n){const t={},e=[],i=Object.keys(Yt.plugins.items);for(let o=0;o1&&wl(n[0].toLowerCase());if(i)return i}throw new Error(`Cannot determine type of '${n}' axis. Please provide 'axis' or 'position' option.`)}function kl(n,t,e){if(e[t+"AxisID"]===n)return{axis:t}}function eb(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 kl(n,"x",e[0])||kl(n,"y",e[0])}return{}}function nb(n,t){const e=nn[n.type]||{scales:{}},i=t.scales||{},s=er(n.type,t),o=Object.create(null);return Object.keys(i).forEach(r=>{const a=i[r];if(!Y(a))return console.error(`Invalid scale configuration for scale: ${r}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);const l=nr(r,a,eb(r,n),ut.scales[a.type]),c=Jm(l,s),u=e.scales||{};o[r]=ni(Object.create(null),[{axis:l},a,u[l],u[c]])}),n.data.datasets.forEach(r=>{const a=r.type||n.type,l=r.indexAxis||er(a,t),u=(nn[a]||{}).scales||{};Object.keys(u).forEach(h=>{const f=Zm(h,l),d=r[f+"AxisID"]||f;o[d]=o[d]||Object.create(null),ni(o[d],[{axis:f},i[d],u[h]])})}),Object.keys(o).forEach(r=>{const a=o[r];ni(a,[ut.scales[a.type],ut.scale])}),o}function Iu(n){const t=n.options||(n.options={});t.plugins=H(t.plugins,{}),t.scales=nb(n,t)}function Fu(n){return n=n||{},n.datasets=n.datasets||[],n.labels=n.labels||[],n}function ib(n){return n=n||{},n.data=Fu(n.data),Iu(n),n}const Sl=new Map,Bu=new Set;function Yi(n,t){let e=Sl.get(n);return e||(e=t(),Sl.set(n,e),Bu.add(e)),e}const jn=(n,t,e)=>{const i=Le(t,e);i!==void 0&&n.add(i)};class sb{constructor(t){this._config=ib(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=Fu(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(),Iu(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Yi(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return Yi(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return Yi(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id,i=this.type;return Yi(`${i}-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,r=this._cachedScopes(t,i),a=r.get(e);if(a)return a;const l=new Set;e.forEach(u=>{t&&(l.add(t),u.forEach(h=>jn(l,t,h))),u.forEach(h=>jn(l,s,h)),u.forEach(h=>jn(l,nn[o]||{},h)),u.forEach(h=>jn(l,ut,h)),u.forEach(h=>jn(l,Zo,h))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),Bu.has(e)&&r.set(e,c),c}chartOptionScopes(){const{options:t,type:e}=this;return[t,nn[e]||{},ut.datasets[e]||{},{type:e},ut,Zo]}resolveNamedOptions(t,e,i,s=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=Ml(this._resolverCache,t,s);let l=r;if(rb(r,e)){o.$shared=!1,i=Ie(i)?i():i;const c=this.createResolver(t,i,a);l=On(r,i,c)}for(const c of e)o[c]=l[c];return o}createResolver(t,e,i=[""],s){const{resolver:o}=Ml(this._resolverCache,t,i);return Y(e)?On(o,e,void 0,s):o}}function Ml(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:zr(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},i.set(s,o)),o}const ob=n=>Y(n)&&Object.getOwnPropertyNames(n).reduce((t,e)=>t||Ie(n[e]),!1);function rb(n,t){const{isScriptable:e,isIndexable:i}=gu(n);for(const s of t){const o=e(s),r=i(s),a=(r||o)&&n[s];if(o&&(Ie(a)||ob(a))||r&&nt(a))return!0}return!1}var ab="4.4.0";const lb=["top","bottom","left","right","chartArea"];function Cl(n,t){return n==="top"||n==="bottom"||lb.indexOf(n)===-1&&t==="x"}function Pl(n,t){return function(e,i){return e[n]===i[n]?e[t]-i[t]:e[n]-i[n]}}function Ol(n){const t=n.chart,e=t.options.animation;t.notifyPlugins("afterRender"),et(e&&e.onComplete,[n],t)}function cb(n){const t=n.chart,e=t.options.animation;et(e&&e.onProgress,[n],t)}function zu(n){return vu()&&typeof n=="string"?n=document.getElementById(n):n&&n.length&&(n=n[0]),n&&n.canvas&&(n=n.canvas),n}const ds={},Al=n=>{const t=zu(n);return Object.values(ds).filter(e=>e.canvas===t).pop()};function ub(n,t,e){const i=Object.keys(n);for(const s of i){const o=+s;if(o>=t){const r=n[s];delete n[s],(e>0||o>t)&&(n[o+e]=r)}}}function hb(n,t,e,i){return!e||n.type==="mouseout"?null:i?t:n}function Xi(n,t,e){return n.options.clip?n[e]:t[e]}function fb(n,t){const{xScale:e,yScale:i}=n;return e&&i?{left:Xi(e,t,"left"),right:Xi(e,t,"right"),top:Xi(i,t,"top"),bottom:Xi(i,t,"bottom")}:t}class ae{static register(...t){Yt.add(...t),Dl()}static unregister(...t){Yt.remove(...t),Dl()}constructor(t,e){const i=this.config=new sb(e),s=zu(t),o=Al(s);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const r=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||Am(s)),this.platform.updateConfig(i);const a=this.platform.acquireContext(s,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,u=l&&l.width;if(this.id=pp(),this.ctx=a,this.canvas=l,this.width=u,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Um,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Dp(h=>this.update(h),r.resizeDelay||0),this._dataChanges=[],ds[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}se.listen(this,"complete",Ol),se.listen(this,"progress",cb),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:o}=this;return X(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 Yt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Qa(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Ya(this.canvas,this.ctx),this}stop(){return se.stop(this),this}resize(t,e){se.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,o=i.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,t,e,o),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,Qa(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),et(i.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const e=this.options.scales||{};Z(e,(i,s)=>{i.id=s})}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce((r,a)=>(r[a]=!1,r),{});let o=[];e&&(o=o.concat(Object.keys(e).map(r=>{const a=e[r],l=nr(r,a),c=l==="r",u=l==="x";return{options:a,dposition:c?"chartArea":u?"bottom":"left",dtype:c?"radialLinear":u?"category":"linear"}}))),Z(o,r=>{const a=r.options,l=a.id,c=nr(l,a),u=H(a.type,r.dtype);(a.position===void 0||Cl(a.position,c)!==Cl(r.dposition))&&(a.position=r.dposition),s[l]=!0;let h=null;if(l in i&&i[l].type===u)h=i[l];else{const f=Yt.getScale(u);h=new f({id:l,type:u,ctx:this.ctx,chart:this}),i[h.id]=h}h.init(a,t)}),Z(s,(r,a)=>{r||delete i[a]}),Z(i,r=>{wt.configure(this,r,r.options),wt.addBox(this,r)})}_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)=>{e.filter(o=>o===i._dataset).length===0&&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(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let c=0,u=this.data.datasets.length;c{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Pl("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){Z(this.scales,t=>{wt.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);(!$a(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){const r=i==="_removeElements"?-o:o;ub(t,s,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.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(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;wt.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],Z(this.boxes,s=>{i&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,o)=>{s._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,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=fb(t,this.chartArea),r={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",r)!==!1&&(s&&Ks(e,{left:i.left===!1?0:o.left-i.left,right:i.right===!1?this.width:o.right+i.right,top:i.top===!1?0:o.top-i.top,bottom:i.bottom===!1?this.height:o.bottom+i.bottom}),t.controller.draw(),s&&qs(e),r.cancelable=!1,this.notifyPlugins("afterDatasetDraw",r))}isPointInArea(t){return de(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,i,s){const o=lm.modes[e];return typeof o=="function"?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=Fe(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 typeof i.hidden=="boolean"?!i.hidden:!e.hidden}setDatasetVisibility(t,e){const i=this.getDatasetMeta(t);i.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,s);bi(e)?(o.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),r.update(o,{visible:i}),this.update(a=>a.datasetIndex===t?s:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),se.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,r),t[o]=r},s=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};Z(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 r;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",o),i("detach",r)};r=()=>{this.attached=!1,s("resize",o),this._stop(),this._resize(0,0),i("attach",a)},e.isAttached(this.canvas)?a():r()}unbindEvents(){Z(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},Z(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,r,a,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+s+"DatasetHoverStyle"]()),a=0,l=t.length;a{const a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!As(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 this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,i){const s=this.options.hover,o=(l,c)=>l.filter(u=>!c.some(h=>u.datasetIndex===h.datasetIndex&&u.index===h.index)),r=o(e,t),a=i?t:o(t,e);r.length&&this.updateHoverStyle(r,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},s=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",i,s)===!1)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=e,a=this._getActiveElements(t,s,i,r),l=xp(t),c=hb(t,this._lastEvent,i,l);i&&(this._lastEvent=null,et(o.onHover,[t,a,this],this),l&&et(o.onClick,[t,a,this],this));const u=!As(a,s);return(u||e)&&(this._active=a,this._updateHoverStyles(a,s,e)),this._lastEvent=c,u}_getActiveElements(t,e,i,s){if(t.type==="mouseout")return[];if(!i)return e;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,s)}}A(ae,"defaults",ut),A(ae,"instances",ds),A(ae,"overrides",nn),A(ae,"registry",Yt),A(ae,"version",ab),A(ae,"getChart",Al);function Dl(){return Z(ae.instances,n=>n._plugins.invalidate())}function db(n,t,e){const{startAngle:i,pixelMargin:s,x:o,y:r,outerRadius:a,innerRadius:l}=t;let c=s/a;n.beginPath(),n.arc(o,r,a,i-c,e+c),l>s?(c=s/l,n.arc(o,r,l,e+c,i-c,!0)):n.arc(o,r,s,e+ht,i-ht),n.closePath(),n.clip()}function pb(n){return Br(n,["outerStart","outerEnd","innerStart","innerEnd"])}function gb(n,t,e,i){const s=pb(n.options.borderRadius),o=(e-t)/2,r=Math.min(o,i*t/2),a=l=>{const c=(e-Math.min(o,l))*i/2;return gt(l,0,Math.min(o,c))};return{outerStart:a(s.outerStart),outerEnd:a(s.outerEnd),innerStart:gt(s.innerStart,0,r),innerEnd:gt(s.innerEnd,0,r)}}function fn(n,t,e,i){return{x:e+n*Math.cos(t),y:i+n*Math.sin(t)}}function Is(n,t,e,i,s,o){const{x:r,y:a,startAngle:l,pixelMargin:c,innerRadius:u}=t,h=Math.max(t.outerRadius+i+e-c,0),f=u>0?u+i+e+c:0;let d=0;const p=s-l;if(i){const K=u>0?u-i:0,q=h>0?h-i:0,U=(K+q)/2,G=U!==0?p*U/(U+i):p;d=(p-G)/2}const g=Math.max(.001,p*h-e/rt)/h,b=(p-g)/2,m=l+b+d,_=s-b-d,{outerStart:y,outerEnd:v,innerStart:x,innerEnd:S}=gb(t,f,h,_-m),M=h-y,k=h-v,w=m+y/M,O=_-v/k,D=f+x,R=f+S,N=m+x/D,W=_-S/R;if(n.beginPath(),o){const K=(w+O)/2;if(n.arc(r,a,h,w,K),n.arc(r,a,h,K,O),v>0){const tt=fn(k,O,r,a);n.arc(tt.x,tt.y,v,O,_+ht)}const q=fn(R,_,r,a);if(n.lineTo(q.x,q.y),S>0){const tt=fn(R,W,r,a);n.arc(tt.x,tt.y,S,_+ht,W+Math.PI)}const U=(_-S/f+(m+x/f))/2;if(n.arc(r,a,f,_-S/f,U,!0),n.arc(r,a,f,U,m+x/f,!0),x>0){const tt=fn(D,N,r,a);n.arc(tt.x,tt.y,x,N+Math.PI,m-ht)}const G=fn(M,m,r,a);if(n.lineTo(G.x,G.y),y>0){const tt=fn(M,w,r,a);n.arc(tt.x,tt.y,y,m-ht,w)}}else{n.moveTo(r,a);const K=Math.cos(w)*h+r,q=Math.sin(w)*h+a;n.lineTo(K,q);const U=Math.cos(O)*h+r,G=Math.sin(O)*h+a;n.lineTo(U,G)}n.closePath()}function mb(n,t,e,i,s){const{fullCircles:o,startAngle:r,circumference:a}=t;let l=t.endAngle;if(o){Is(n,t,e,i,l,s);for(let c=0;c=ot||_i(r,l,c),b=he(a,u+d,h+d);return g&&b}getCenterPoint(e){const{x:i,y:s,startAngle:o,endAngle:r,innerRadius:a,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],e),{offset:c,spacing:u}=this.options,h=(o+r)/2,f=(a+l+u+c)/2;return{x:i+Math.cos(h)*f,y:s+Math.sin(h)*f}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){const{options:i,circumference:s}=this,o=(i.offset||0)/4,r=(i.spacing||0)/2,a=i.circular;if(this.pixelMargin=i.borderAlign==="inner"?.33:0,this.fullCircles=s>ot?Math.floor(s/ot):0,s===0||this.innerRadius<0||this.outerRadius<0)return;e.save();const l=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(l)*o,Math.sin(l)*o);const c=1-Math.sin(Math.min(rt,s||0)),u=o*c;e.fillStyle=i.backgroundColor,e.strokeStyle=i.borderColor,mb(e,this,u,r,a),bb(e,this,u,r,a),e.restore()}}A(Yn,"id","arc"),A(Yn,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0}),A(Yn,"defaultRoutes",{backgroundColor:"backgroundColor"}),A(Yn,"descriptors",{_scriptable:!0,_indexable:e=>e!=="borderDash"});function $u(n,t,e=t){n.lineCap=H(e.borderCapStyle,t.borderCapStyle),n.setLineDash(H(e.borderDash,t.borderDash)),n.lineDashOffset=H(e.borderDashOffset,t.borderDashOffset),n.lineJoin=H(e.borderJoinStyle,t.borderJoinStyle),n.lineWidth=H(e.borderWidth,t.borderWidth),n.strokeStyle=H(e.borderColor,t.borderColor)}function _b(n,t,e){n.lineTo(e.x,e.y)}function yb(n){return n.stepped?Vp:n.tension||n.cubicInterpolationMode==="monotone"?Hp:_b}function ju(n,t,e={}){const i=n.length,{start:s=0,end:o=i-1}=e,{start:r,end:a}=t,l=Math.max(s,r),c=Math.min(o,a),u=sa&&o>a;return{count:i,start:l,loop:t.loop,ilen:c(r+(c?a-v:v))%o,y=()=>{g!==b&&(n.lineTo(u,b),n.lineTo(u,g),n.lineTo(u,m))};for(l&&(d=s[_(0)],n.moveTo(d.x,d.y)),f=0;f<=a;++f){if(d=s[_(f)],d.skip)continue;const v=d.x,x=d.y,S=v|0;S===p?(xb&&(b=x),u=(h*u+v)/++h):(y(),n.lineTo(v,x),p=S,h=0,g=b=x),m=x}y()}function ir(n){const t=n.options,e=t.borderDash&&t.borderDash.length;return!n._decimated&&!n._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!e?vb:xb}function wb(n){return n.stepped?vg:n.tension||n.cubicInterpolationMode==="monotone"?wg:He}function kb(n,t,e,i){let s=t._path;s||(s=t._path=new Path2D,t.path(s,e,i)&&s.closePath()),$u(n,t.options),n.stroke(s)}function Sb(n,t,e,i){const{segments:s,options:o}=t,r=ir(t);for(const a of s)$u(n,o,a.style),n.beginPath(),r(n,t,a,{start:e,end:e+i-1})&&n.closePath(),n.stroke()}const Mb=typeof Path2D=="function";function Cb(n,t,e,i){Mb&&!t.options.segment?kb(n,t,e,i):Sb(n,t,e,i)}class Ce extends qt{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;if((i.tension||i.cubicInterpolationMode==="monotone")&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;dg(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Og(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],o=this.points,r=Cu(this,{property:e,start:s,end:s});if(!r.length)return;const a=[],l=wb(i);let c,u;for(c=0,u=r.length;ct!=="borderDash"&&t!=="fill"});function Tl(n,t,e,i){const s=n.options,{[e]:o}=n.getProps([e],i);return Math.abs(t-o)n.replace("rgb(","rgba(").replace(")",", 0.5)"));function Vu(n){return sr[n%sr.length]}function Hu(n){return El[n%El.length]}function Rb(n,t){return n.borderColor=Vu(t),n.backgroundColor=Hu(t),++t}function Lb(n,t){return n.backgroundColor=n.data.map(()=>Vu(t++)),t}function Ib(n,t){return n.backgroundColor=n.data.map(()=>Hu(t++)),t}function Fb(n){let t=0;return(e,i)=>{const s=n.getDatasetMeta(i).controller;s instanceof Ke?t=Lb(e,t):s instanceof ri?t=Ib(e,t):s&&(t=Rb(e,t))}}function Rl(n){let t;for(t in n)if(n[t].borderColor||n[t].backgroundColor)return!0;return!1}function Bb(n){return n&&(n.borderColor||n.backgroundColor)}var zb={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&&(Rl(i)||Bb(s)||o&&Rl(o)))return;const r=Fb(n);i.forEach(r)}};function $b(n,t,e,i,s){const o=s.samples||i;if(o>=e)return n.slice(t,t+e);const r=[],a=(e-2)/(o-2);let l=0;const c=t+e-1;let u=t,h,f,d,p,g;for(r[l++]=n[u],h=0;hd&&(d=p,f=n[_],g=_);r[l++]=f,u=g}return r[l++]=n[c],r}function jb(n,t,e,i){let s=0,o=0,r,a,l,c,u,h,f,d,p,g;const b=[],m=t+e-1,_=n[t].x,v=n[m].x-_;for(r=t;rg&&(g=c,f=r),s=(o*s+a.x)/++o;else{const S=r-1;if(!X(h)&&!X(f)){const M=Math.min(h,f),k=Math.max(h,f);M!==d&&M!==S&&b.push({...n[M],x:s}),k!==d&&k!==S&&b.push({...n[k],x:s})}r>0&&S!==d&&b.push(n[S]),b.push(a),u=x,o=0,p=g=c,h=f=d=r}}return b}function Wu(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 Ll(n){n.data.datasets.forEach(t=>{Wu(t)})}function Nb(n,t){const e=t.length;let i=0,s;const{iScale:o}=n,{min:r,max:a,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(i=gt(fe(t,o.axis,r).lo,0,e-1)),c?s=gt(fe(t,o.axis,a).hi+1,i,e)-i:s=e-i,{start:i,count:s}}var Vb={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(n,t,e)=>{if(!e.enabled){Ll(n);return}const i=n.width;n.data.datasets.forEach((s,o)=>{const{_data:r,indexAxis:a}=s,l=n.getDatasetMeta(o),c=r||s.data;if(qn([a,n.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;const u=n.scales[l.xAxisID];if(u.type!=="linear"&&u.type!=="time"||n.options.parsing)return;let{start:h,count:f}=Nb(l,c);const d=e.threshold||4*i;if(f<=d){Wu(s);return}X(r)&&(s._data=c,delete s.data,Object.defineProperty(s,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(g){this._data=g}}));let p;switch(e.algorithm){case"lttb":p=$b(c,h,f,i,e);break;case"min-max":p=jb(c,h,f,i);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}s._decimated=p})},destroy(n){Ll(n)}};function Hb(n,t,e){const i=n.segments,s=n.points,o=t.points,r=[];for(const a of i){let{start:l,end:c}=a;c=Hr(l,c,s);const u=or(e,s[l],s[c],a.loop);if(!t.segments){r.push({source:a,target:u,start:s[l],end:s[c]});continue}const h=Cu(t,u);for(const f of h){const d=or(e,o[f.start],o[f.end],f.loop),p=Mu(a,s,d);for(const g of p)r.push({source:g,target:f,start:{[e]:Il(u,d,"start",Math.max)},end:{[e]:Il(u,d,"end",Math.min)}})}}return r}function or(n,t,e,i){if(i)return;let s=t[n],o=e[n];return n==="angle"&&(s=It(s),o=It(o)),{property:n,start:s,end:o}}function Wb(n,t){const{x:e=null,y:i=null}=n||{},s=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=Hr(r,a,s);const l=s[r],c=s[a];i!==null?(o.push({x:l.x,y:i}),o.push({x:c.x,y:i})):e!==null&&(o.push({x:e,y:l.y}),o.push({x:e,y:c.y}))}),o}function Hr(n,t,e){for(;t>n;t--){const i=e[t];if(!isNaN(i.x)&&!isNaN(i.y))break}return t}function Il(n,t,e,i){return n&&t?i(n[e],t[e]):n?n[e]:t?t[e]:0}function Ku(n,t){let e=[],i=!1;return nt(n)?(i=!0,e=n):e=Wb(n,t),e.length?new Ce({points:e,options:{tension:0},_loop:i,_fullLoop:i}):null}function Fl(n){return n&&n.fill!==!1}function Kb(n,t,e){let s=n[t].fill;const o=[t];let r;if(!e)return s;for(;s!==!1&&o.indexOf(s)===-1;){if(!ct(s))return s;if(r=n[s],!r)return!1;if(r.visible)return s;o.push(s),s=r.fill}return!1}function qb(n,t,e){const i=Gb(n);if(Y(i))return isNaN(i.value)?!1:i;let s=parseFloat(i);return ct(s)&&Math.floor(s)===s?Ub(i[0],t,s,e):["origin","start","end","stack","shape"].indexOf(i)>=0&&i}function Ub(n,t,e,i){return(n==="-"||n==="+")&&(e=t+e),e===t||e<0||e>=i?!1:e}function Yb(n,t){let e=null;return n==="start"?e=t.bottom:n==="end"?e=t.top:Y(n)?e=t.getPixelForValue(n.value):t.getBasePixel&&(e=t.getBasePixel()),e}function Xb(n,t,e){let i;return n==="start"?i=e:n==="end"?i=t.options.reverse?t.min:t.max:Y(n)?i=n.value:i=t.getBaseValue(),i}function Gb(n){const t=n.options,e=t.fill;let i=H(e&&e.target,e);return i===void 0&&(i=!!t.backgroundColor),i===!1||i===null?!1:i===!0?"origin":i}function Qb(n){const{scale:t,index:e,line:i}=n,s=[],o=i.segments,r=i.points,a=Zb(t,e);a.push(Ku({x:null,y:t.bottom},i));for(let l=0;l=0;--r){const a=s[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),i&&a.fill&&xo(n.ctx,a,o))}},beforeDatasetsDraw(n,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;const i=n.getSortedVisibleDatasetMetas();for(let s=i.length-1;s>=0;--s){const o=i[s].$filler;Fl(o)&&xo(n.ctx,o,n.chartArea)}},beforeDatasetDraw(n,t,e){const i=t.meta.$filler;!Fl(i)||e.drawTime!=="beforeDatasetDraw"||xo(n.ctx,i,n.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const jl=(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)}},c0=(n,t)=>n!==null&&t!==null&&n.datasetIndex===t.datasetIndex&&n.index===t.index;class Nl extends qt{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=et(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){this.width=this.height=0;return}const i=t.labels,s=ft(i.font),o=s.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=jl(i,o);let c,u;e.font=s.string,this.isHorizontal()?(c=this.maxWidth,u=this._fitRows(r,o,a,l)+10):(u=this.maxHeight,c=this._fitCols(r,s,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],u=s+a;let h=t;o.textAlign="left",o.textBaseline="middle";let f=-1,d=-u;return this.legendItems.forEach((p,g)=>{const b=i+e/2+o.measureText(p.text).width;(g===0||c[c.length-1]+b+2*a>r)&&(h+=u,c[c.length-(g>0?0:1)]=0,d+=u,f++),l[g]={left:0,top:d,row:f,width:b,height:s},c[c.length-1]+=b+a}),h}_fitCols(t,e,i,s){const{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],u=r-t;let h=a,f=0,d=0,p=0,g=0;return this.legendItems.forEach((b,m)=>{const{itemWidth:_,itemHeight:y}=u0(i,e,o,b,s);m>0&&d+y+2*a>u&&(h+=f+a,c.push({width:f,height:d}),p+=f+a,g++,f=d=0),l[m]={left:p,top:d,col:g,width:_,height:y},f=Math.max(f,_),d+=y+a}),h+=f,c.push({width:f,height:d}),h}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:o}}=this,r=kn(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=yt(i,this.left+s,this.right-this.lineWidths[a]);for(const c of e)a!==c.row&&(a=c.row,l=yt(i,this.left+s,this.right-this.lineWidths[a])),c.top+=this.top+t+s,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+s}else{let a=0,l=yt(i,this.top+t+s,this.bottom-this.columnSizes[a].height);for(const c of e)c.col!==a&&(a=c.col,l=yt(i,this.top+t+s,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+s,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;Ks(t,this),this._draw(),qs(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:o,labels:r}=t,a=ut.color,l=kn(t.rtl,this.left,this.width),c=ft(r.font),{padding:u}=r,h=c.size,f=h/2;let d;this.drawTitle(),s.textAlign=l.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:p,boxHeight:g,itemHeight:b}=jl(r,h),m=function(S,M,k){if(isNaN(p)||p<=0||isNaN(g)||g<0)return;s.save();const w=H(k.lineWidth,1);if(s.fillStyle=H(k.fillStyle,a),s.lineCap=H(k.lineCap,"butt"),s.lineDashOffset=H(k.lineDashOffset,0),s.lineJoin=H(k.lineJoin,"miter"),s.lineWidth=w,s.strokeStyle=H(k.strokeStyle,a),s.setLineDash(H(k.lineDash,[])),r.usePointStyle){const O={radius:g*Math.SQRT2/2,pointStyle:k.pointStyle,rotation:k.rotation,borderWidth:w},D=l.xPlus(S,p/2),R=M+f;du(s,O,D,R,r.pointStyleWidth&&p)}else{const O=M+Math.max((h-g)/2,0),D=l.leftForLtr(S,p),R=Xe(k.borderRadius);s.beginPath(),Object.values(R).some(N=>N!==0)?yi(s,{x:D,y:O,w:p,h:g,radius:R}):s.rect(D,O,p,g),s.fill(),w!==0&&s.stroke()}s.restore()},_=function(S,M,k){sn(s,k.text,S,M+b/2,c,{strikethrough:k.hidden,textAlign:l.textAlign(k.textAlign)})},y=this.isHorizontal(),v=this._computeTitleHeight();y?d={x:yt(o,this.left+u,this.right-i[0]),y:this.top+u+v,line:0}:d={x:this.left+u,y:yt(o,this.top+v+u,this.bottom-e[0].height),line:0},wu(this.ctx,t.textDirection);const x=b+u;this.legendItems.forEach((S,M)=>{s.strokeStyle=S.fontColor,s.fillStyle=S.fontColor;const k=s.measureText(S.text).width,w=l.textAlign(S.textAlign||(S.textAlign=r.textAlign)),O=p+f+k;let D=d.x,R=d.y;l.setWidth(this.width),y?M>0&&D+O+u>this.right&&(R=d.y+=x,d.line++,D=d.x=yt(o,this.left+u,this.right-i[d.line])):M>0&&R+x>this.bottom&&(D=d.x=D+e[d.line].width+u,d.line++,R=d.y=yt(o,this.top+v+u,this.bottom-e[d.line].height));const N=l.x(D);if(m(N,R,S),D=Tp(w,D+p+f,y?D+O:this.right,t.rtl),_(l.x(D),R,S),y)d.x+=O+u;else if(typeof S.text!="string"){const W=c.lineHeight;d.y+=Uu(S,W)+u}else d.y+=x}),ku(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=ft(e.font),s=Mt(e.padding);if(!e.display)return;const o=kn(t.rtl,this.left,this.width),r=this.ctx,a=e.position,l=i.size/2,c=s.top+l;let u,h=this.left,f=this.width;if(this.isHorizontal())f=Math.max(...this.lineWidths),u=this.top+c,h=yt(t.align,h,this.right-f);else{const p=this.columnSizes.reduce((g,b)=>Math.max(g,b.height),0);u=c+yt(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}const d=yt(a,h,h+f);r.textAlign=o.textAlign(Ir(a)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=i.string,sn(r,e.text,d,u,i)}_computeTitleHeight(){const t=this.options.title,e=ft(t.font),i=Mt(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,o;if(he(t,this.left,this.right)&&he(e,this.top,this.bottom)){for(o=this.legendHitBoxes,i=0;io.length>r.length?o:r)),t+e.size/2+i.measureText(s).width}function f0(n,t,e){let i=n;return typeof t.text!="string"&&(i=Uu(t,e)),i}function Uu(n,t){const e=n.text?n.text.length:0;return t*e}function d0(n,t){return!!((n==="mousemove"||n==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(n==="click"||n==="mouseup"))}var p0={id:"legend",_element:Nl,start(n,t,e){const i=n.legend=new Nl({ctx:n.ctx,options:e,chart:n});wt.configure(n,i,e),wt.addBox(n,i)},stop(n){wt.removeBox(n,n.legend),delete n.legend},beforeUpdate(n,t,e){const i=n.legend;wt.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:r,borderRadius:a}}=n.legend.options;return n._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(e?0:void 0),u=Mt(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:(u.width+u.height)/4,strokeStyle:c.borderColor,pointStyle:i||c.pointStyle,rotation:c.rotation,textAlign:s||c.textAlign,borderRadius:r&&(a||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 Wr extends qt{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){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=e;const s=nt(i.text)?i.text.length:1;this._padding=Mt(i.padding);const o=s*ft(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:e,left:i,bottom:s,right:o,options:r}=this,a=r.align;let l=0,c,u,h;return this.isHorizontal()?(u=yt(a,i,o),h=e+t,c=o-i):(r.position==="left"?(u=i+t,h=yt(a,s,e),l=rt*-.5):(u=o-t,h=yt(a,e,s),l=rt*.5),c=s-e),{titleX:u,titleY:h,maxWidth:c,rotation:l}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=ft(e.font),o=i.lineHeight/2+this._padding.top,{titleX:r,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(o);sn(t,e.text,0,0,i,{color:e.color,maxWidth:l,rotation:c,textAlign:Ir(e.align),textBaseline:"middle",translation:[r,a]})}}function g0(n,t){const e=new Wr({ctx:n.ctx,options:t,chart:n});wt.configure(n,e,t),wt.addBox(n,e),n.titleBlock=e}var m0={id:"title",_element:Wr,start(n,t,e){g0(n,e)},stop(n){const t=n.titleBlock;wt.removeBox(n,t),delete n.titleBlock},beforeUpdate(n,t,e){const i=n.titleBlock;wt.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 Gi=new WeakMap;var b0={id:"subtitle",start(n,t,e){const i=new Wr({ctx:n.ctx,options:e,chart:n});wt.configure(n,i,e),wt.addBox(n,i),Gi.set(n,i)},stop(n){wt.removeBox(n,Gi.get(n)),Gi.delete(n)},beforeUpdate(n,t,e){const i=Gi.get(n);wt.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 Xn={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}function _0(n,t){const{element:e,datasetIndex:i,index:s}=t,o=n.getDatasetMeta(i).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:n,label:r,parsed:o.getParsed(s),raw:n.data.datasets[i].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:e}}function Vl(n,t){const e=n.chart.ctx,{body:i,footer:s,title:o}=n,{boxWidth:r,boxHeight:a}=t,l=ft(t.bodyFont),c=ft(t.titleFont),u=ft(t.footerFont),h=o.length,f=s.length,d=i.length,p=Mt(t.padding);let g=p.height,b=0,m=i.reduce((v,x)=>v+x.before.length+x.lines.length+x.after.length,0);if(m+=n.beforeBody.length+n.afterBody.length,h&&(g+=h*c.lineHeight+(h-1)*t.titleSpacing+t.titleMarginBottom),m){const v=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;g+=d*v+(m-d)*l.lineHeight+(m-1)*t.bodySpacing}f&&(g+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let _=0;const y=function(v){b=Math.max(b,e.measureText(v).width+_)};return e.save(),e.font=c.string,Z(n.title,y),e.font=l.string,Z(n.beforeBody.concat(n.afterBody),y),_=t.displayColors?r+2+t.boxPadding:0,Z(i,v=>{Z(v.before,y),Z(v.lines,y),Z(v.after,y)}),_=0,e.font=u.string,Z(n.footer,y),e.restore(),b+=p.width,{width:b,height:g}}function y0(n,t){const{y:e,height:i}=t;return en.height-i/2?"bottom":"center"}function x0(n,t,e,i){const{x:s,width:o}=i,r=e.caretSize+e.caretPadding;if(n==="left"&&s+o+r>t.width||n==="right"&&s-o-r<0)return!0}function v0(n,t,e,i){const{x:s,width:o}=e,{width:r,chartArea:{left:a,right:l}}=n;let c="center";return i==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),x0(c,n,t,e)&&(c="center"),c}function Hl(n,t,e){const i=e.yAlign||t.yAlign||y0(n,e);return{xAlign:e.xAlign||t.xAlign||v0(n,t,e,i),yAlign:i}}function w0(n,t){let{x:e,width:i}=n;return t==="right"?e-=i:t==="center"&&(e-=i/2),e}function k0(n,t,e){let{y:i,height:s}=n;return t==="top"?i+=e:t==="bottom"?i-=s+e:i-=s/2,i}function Wl(n,t,e,i){const{caretSize:s,caretPadding:o,cornerRadius:r}=n,{xAlign:a,yAlign:l}=e,c=s+o,{topLeft:u,topRight:h,bottomLeft:f,bottomRight:d}=Xe(r);let p=w0(t,a);const g=k0(t,l,c);return l==="center"?a==="left"?p+=c:a==="right"&&(p-=c):a==="left"?p-=Math.max(u,f)+s:a==="right"&&(p+=Math.max(h,d)+s),{x:gt(p,0,i.width-t.width),y:gt(g,0,i.height-t.height)}}function Qi(n,t,e){const i=Mt(e.padding);return t==="center"?n.x+n.width/2:t==="right"?n.x+n.width-i.right:n.x+i.left}function Kl(n){return Ut([],oe(n))}function S0(n,t,e){return Fe(n,{tooltip:t,tooltipItems:e,type:"tooltip"})}function ql(n,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?n.override(e):n}const Yu={beforeTitle:ie,title(n){if(n.length>0){const t=n[0],e=t.chart.data.labels,i=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex"u"?Yu[t].call(e,i):s}class rr extends qt{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 Pu(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=S0(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:i}=e,s=Ot(i,"beforeTitle",this,t),o=Ot(i,"title",this,t),r=Ot(i,"afterTitle",this,t);let a=[];return a=Ut(a,oe(s)),a=Ut(a,oe(o)),a=Ut(a,oe(r)),a}getBeforeBody(t,e){return Kl(Ot(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:i}=e,s=[];return Z(t,o=>{const r={before:[],lines:[],after:[]},a=ql(i,o);Ut(r.before,oe(Ot(a,"beforeLabel",this,o))),Ut(r.lines,Ot(a,"label",this,o)),Ut(r.after,oe(Ot(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,e){return Kl(Ot(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,s=Ot(i,"beforeFooter",this,t),o=Ot(i,"footer",this,t),r=Ot(i,"afterFooter",this,t);let a=[];return a=Ut(a,oe(s)),a=Ut(a,oe(o)),a=Ut(a,oe(r)),a}_createItems(t){const e=this._active,i=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=e.length;lt.filter(u,h,f,i))),t.itemSort&&(a=a.sort((u,h)=>t.itemSort(u,h,i))),Z(a,u=>{const h=ql(t.callbacks,u);s.push(Ot(h,"labelColor",this,u)),o.push(Ot(h,"labelPointStyle",this,u)),r.push(Ot(h,"labelTextColor",this,u))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=Xn[i.position].call(this,s,this._eventPosition);r=this._createItems(i),this.title=this.getTitle(r,i),this.beforeBody=this.getBeforeBody(r,i),this.body=this.getBody(r,i),this.afterBody=this.getAfterBody(r,i),this.footer=this.getFooter(r,i);const l=this._size=Vl(this,i),c=Object.assign({},a,l),u=Hl(this.chart,i,c),h=Wl(i,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,o={opacity:1,x:h.x,y:h.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&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:r,cornerRadius:a}=i,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:h}=Xe(a),{x:f,y:d}=t,{width:p,height:g}=e;let b,m,_,y,v,x;return o==="center"?(v=d+g/2,s==="left"?(b=f,m=b-r,y=v+r,x=v-r):(b=f+p,m=b+r,y=v-r,x=v+r),_=b):(s==="left"?m=f+Math.max(l,u)+r:s==="right"?m=f+p-Math.max(c,h)-r:m=this.caretX,o==="top"?(y=d,v=y-r,b=m-r,_=m+r):(y=d+g,v=y+r,b=m+r,_=m-r),x=y),{x1:b,x2:m,x3:_,y1:y,y2:v,y3:x}}drawTitle(t,e,i){const s=this.title,o=s.length;let r,a,l;if(o){const c=kn(i.rtl,this.x,this.width);for(t.x=Qi(this,i.titleAlign,i),e.textAlign=c.textAlign(i.titleAlign),e.textBaseline="middle",r=ft(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=r.string,l=0;l_!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,yi(t,{x:g,y:p,w:c,h:l,radius:m}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),yi(t,{x:b,y:p+1,w:c-2,h:l-2,radius:m}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(g,p,c,l),t.strokeRect(g,p,c,l),t.fillStyle=r.backgroundColor,t.fillRect(b,p+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=i,h=ft(i.bodyFont);let f=h.lineHeight,d=0;const p=kn(i.rtl,this.x,this.width),g=function(k){e.fillText(k,p.x(t.x+d),t.y+f/2),t.y+=f+o},b=p.textAlign(r);let m,_,y,v,x,S,M;for(e.textAlign=r,e.textBaseline="middle",e.font=h.string,t.x=Qi(this,b,i),e.fillStyle=i.bodyColor,Z(this.beforeBody,g),d=a&&b!=="right"?r==="center"?c/2+u:c+2+u:0,v=0,S=s.length;v0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,s=i&&i.x,o=i&&i.y;if(s||o){const r=Xn[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=Vl(this,t),l=Object.assign({},r,this._size),c=Hl(e,t,l),u=Wl(t,l,c,e);(s._to!==u.x||o._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,u))}}_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 r=Mt(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,s,e),wu(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),ku(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!As(i,s),r=this._positionChanged(s,e);(o||r)&&(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||[],r=this._getActiveElements(t,o,e,i),a=this._positionChanged(r,t),l=e||!As(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,i,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return e;const r=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&r.reverse(),r}_positionChanged(t,e){const{caretX:i,caretY:s,options:o}=this,r=Xn[o.position].call(this,t,e);return r!==!1&&(i!==r.x||s!==r.y)}}A(rr,"positioners",Xn);var M0={id:"tooltip",_element:rr,positioners:Xn,afterInit(n,t,e){e&&(n.tooltip=new rr({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(n.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(n.ctx),n.notifyPlugins("afterTooltipDraw",e)}},afterEvent(n,t){if(n.tooltip){const e=t.replay;n.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(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:Yu},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:n=>n!=="filter"&&n!=="itemSort"&&n!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},C0=Object.freeze({__proto__:null,Colors:zb,Decimation:Vb,Filler:l0,Legend:p0,SubTitle:b0,Title:m0,Tooltip:M0});const P0=(n,t,e,i)=>(typeof t=="string"?(e=n.push(t)-1,i.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function O0(n,t,e,i){const s=n.indexOf(t);if(s===-1)return P0(n,t,e,i);const o=n.lastIndexOf(t);return s!==o?e:s}const A0=(n,t)=>n===null?null:gt(Math.round(n),0,t);function Ul(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}}A(ar,"id","category"),A(ar,"defaults",{ticks:{callback:Ul}});function D0(n,t){const e=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:u,maxDigits:h,includeBounds:f}=n,d=o||1,p=u-1,{min:g,max:b}=t,m=!X(r),_=!X(a),y=!X(c),v=(b-g)/(h+1);let x=Na((b-g)/p/d)*d,S,M,k,w;if(x<1e-14&&!m&&!_)return[{value:g},{value:b}];w=Math.ceil(b/x)-Math.floor(g/x),w>p&&(x=Na(w*x/p/d)*d),X(l)||(S=Math.pow(10,l),x=Math.ceil(x*S)/S),s==="ticks"?(M=Math.floor(g/x)*x,k=Math.ceil(b/x)*x):(M=g,k=b),m&&_&&o&&Sp((a-r)/o,x/1e3)?(w=Math.round(Math.min((a-r)/x,u)),x=(a-r)/w,M=r,k=a):y?(M=m?r:M,k=_?a:k,w=c-1,x=(k-M)/w):(w=(k-M)/x,ii(w,Math.round(w),x/1e3)?w=Math.round(w):w=Math.ceil(w));const O=Math.max(Va(x),Va(M));S=Math.pow(10,X(l)?O:l),M=Math.round(M*S)/S,k=Math.round(k*S)/S;let D=0;for(m&&(f&&M!==r?(e.push({value:r}),Ma)break;e.push({value:R})}return _&&f&&k!==a?e.length&&ii(e[e.length-1].value,a,Yl(a,v,n))?e[e.length-1].value=a:e.push({value:a}):(!_||k===a)&&e.push({value:k}),e}function Yl(n,t,{horizontal:e,minRotation:i}){const s=Ht(i),o=(e?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+n).length;return Math.min(t/o,r)}class Fs extends rn{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 X(t)||(typeof t=="number"||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 r=l=>s=e?s:l,a=l=>o=i?o:l;if(t){const l=Qt(s),c=Qt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:i}=t,s;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 s={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:e.includeBounds!==!1},o=this._range||this,r=D0(s,o);return t.bounds==="ticks"&&su(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let e=this.min,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 Ci(t,this.chart.options.locale,this.options.ticks.format)}}class lr extends Fs{determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=ct(t)?t:0,this.max=ct(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=Ht(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 t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}A(lr,"id","linear"),A(lr,"defaults",{ticks:{callback:Ws.formatters.numeric}});const vi=n=>Math.floor(Me(n)),Ne=(n,t)=>Math.pow(10,vi(n)+t);function Xl(n){return n/Math.pow(10,vi(n))===1}function Gl(n,t,e){const i=Math.pow(10,e),s=Math.floor(n/i);return Math.ceil(t/i)-s}function T0(n,t){const e=t-n;let i=vi(e);for(;Gl(n,t,i)>10;)i++;for(;Gl(n,t,i)<10;)i--;return Math.min(i,vi(n))}function E0(n,{min:t,max:e}){t=Lt(n.min,t);const i=[],s=vi(t);let o=T0(t,e),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((t-l)*r)/r,u=Math.floor((t-l)/a/10)*a*10;let h=Math.floor((c-u)/Math.pow(10,o)),f=Lt(n.min,Math.round((l+u+h*Math.pow(10,o))*r)/r);for(;f=10?h=h<15?15:20:h++,h>=20&&(o++,h=2,r=o>=0?1:r),f=Math.round((l+u+h*Math.pow(10,o))*r)/r;const d=Lt(n.max,f);return i.push({value:d,major:Xl(d),significand:h}),i}class cr extends rn{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const i=Fs.prototype.parse.apply(this,[t,e]);if(i===0){this._zero=!0;return}return ct(i)&&i>0?i:null}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=ct(t)?Math.max(0,t):null,this.max=ct(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!ct(this._userMin)&&(this.min=t===Ne(this.min,0)?Ne(this.min,-1):Ne(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const o=a=>i=t?i:a,r=a=>s=e?s:a;i===s&&(i<=0?(o(1),r(10)):(o(Ne(i,-1)),r(Ne(s,1)))),i<=0&&o(Ne(s,-1)),s<=0&&r(Ne(i,1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e={min:this._userMin,max:this._userMax},i=E0(e,this);return t.bounds==="ticks"&&su(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 t===void 0?"0":Ci(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Me(t),this._valueRange=Me(this.max)-Me(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Me(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}A(cr,"id","logarithmic"),A(cr,"defaults",{ticks:{callback:Ws.formatters.logarithmic,major:{enabled:!0}}});function ur(n){const t=n.ticks;if(t.display&&n.display){const e=Mt(t.backdropPadding);return H(t.font&&t.font.size,ut.font.size)+e.height}return 0}function R0(n,t,e){return e=nt(e)?e:[e],{w:Np(n,t.string,e),h:e.length*t.lineHeight}}function Ql(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 L0(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,r=n.options.pointLabels,a=r.centerPointLabels?rt/o:0;for(let l=0;lt.r&&(a=(i.end-t.r)/o,n.r=Math.max(n.r,t.r+a)),s.startt.b&&(l=(s.end-t.b)/r,n.b=Math.max(n.b,t.b+l))}function F0(n,t,e){const i=n.drawingArea,{extra:s,additionalAngle:o,padding:r,size:a}=e,l=n.getPointPosition(t,i+s+r,o),c=Math.round(Rr(It(l.angle+ht))),u=N0(l.y,a.h,c),h=$0(c),f=j0(l.x,a.w,h);return{visible:!0,x:l.x,y:u,textAlign:h,left:f,top:u,right:f+a.w,bottom:u+a.h}}function B0(n,t){if(!t)return!0;const{left:e,top:i,right:s,bottom:o}=n;return!(de({x:e,y:i},t)||de({x:e,y:o},t)||de({x:s,y:i},t)||de({x:s,y:o},t))}function z0(n,t,e){const i=[],s=n._pointLabels.length,o=n.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:ur(o)/2,additionalAngle:r?rt/s:0};let c;for(let u=0;u270||e<90)&&(n-=t),n}function V0(n,t,e){const{left:i,top:s,right:o,bottom:r}=e,{backdropColor:a}=t;if(!X(a)){const l=Xe(t.borderRadius),c=Mt(t.backdropPadding);n.fillStyle=a;const u=i-c.left,h=s-c.top,f=o-i+c.width,d=r-s+c.height;Object.values(l).some(p=>p!==0)?(n.beginPath(),yi(n,{x:u,y:h,w:f,h:d,radius:l}),n.fill()):n.fillRect(u,h,f,d)}}function H0(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 r=i.setContext(n.getPointLabelContext(s));V0(e,r,o);const a=ft(r.font),{x:l,y:c,textAlign:u}=o;sn(e,n._pointLabels[s],l,c+a.lineHeight/2,a,{color:r.color,textAlign:u,textBaseline:"middle"})}}function Xu(n,t,e,i){const{ctx:s}=n;if(e)s.arc(n.xCenter,n.yCenter,t,0,ot);else{let o=n.getPointPosition(0,t);s.moveTo(o.x,o.y);for(let r=1;r{const s=et(this.options.pointLabels.callback,[e,i],this);return s||s===0?s:""}).filter((e,i)=>this.chart.getDataVisibility(i))}fit(){const t=this.options;t.display&&t.pointLabels.display?L0(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){const e=ot/(this._pointLabels.length||1),i=this.options.startAngle||0;return It(t*e+Ht(i))}getDistanceFromCenterForValue(t){if(X(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(X(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(h!==0){l=this.getDistanceFromCenterForValue(u.value);const f=this.getContext(h),d=s.setContext(f),p=o.setContext(f);W0(this,d,l,r,p)}}),i.display){for(t.save(),a=r-1;a>=0;a--){const u=i.setContext(this.getPointLabelContext(a)),{color:h,lineWidth:f}=u;!f||!h||(t.lineWidth=f,t.strokeStyle=h,t.setLineDash(u.borderDash),t.lineDashOffset=u.borderDashOffset,l=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&!e.reverse)return;const c=i.setContext(this.getContext(l)),u=ft(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=u.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const h=Mt(c.backdropPadding);t.fillRect(-r/2-h.left,-o-u.size/2-h.top,r+h.width,u.size+h.height)}sn(t,a.label,0,-o,u,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}A(Gn,"id","radialLinear"),A(Gn,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ws.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),A(Gn,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),A(Gn,"descriptors",{angleLines:{_fallback:"grid"}});const Ys={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}},Tt=Object.keys(Ys);function Zl(n,t){return n-t}function Jl(n,t){if(X(t))return null;const e=n._adapter,{parser:i,round:s,isoWeekday:o}=n._parseOpts;let r=t;return typeof i=="function"&&(r=i(r)),ct(r)||(r=typeof i=="string"?e.parse(r,i):e.parse(r)),r===null?null:(s&&(r=s==="week"&&(Pn(o)||o===!0)?e.startOf(r,"isoWeek",o):e.startOf(r,s)),+r)}function tc(n,t,e,i){const s=Tt.length;for(let o=Tt.indexOf(n);o=Tt.indexOf(e);o--){const r=Tt[o];if(Ys[r].common&&n._adapter.diff(s,i,r)>=t-1)return r}return Tt[e?Tt.indexOf(e):0]}function U0(n){for(let t=Tt.indexOf(n)+1,e=Tt.length;t=t?e[i]:e[s];n[o]=!0}}function Y0(n,t,e,i){const s=n._adapter,o=+s.startOf(t[0].value,i),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,i))l=e[a],l>=0&&(t[l].major=!0);return t}function nc(n,t,e){const i=[],s={},o=t.length;let r,a;for(r=0;r+t.value))}initOffsets(t=[]){let e=0,i=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?e=1-s:e=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?i=o:i=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;e=gt(e,0,r),i=gt(i,0,r),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,r=o.unit||tc(o.minUnit,e,i,this._getLabelCapacity(e)),a=H(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=Pn(l)||l===!0,u={};let h=e,f,d;if(c&&(h=+t.startOf(h,"isoWeek",l)),h=+t.startOf(h,c?"day":r),t.diff(i,e,r)>1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+r);const p=s.ticks.source==="data"&&this.getDataTimestamps();for(f=h,d=0;f+g)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}format(t,e){const s=this.options.time.displayFormats,o=this._unit,r=e||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,i,s){const o=this.options,r=o.ticks.callback;if(r)return et(r,[t,e,i],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],h=c&&a[c],f=i[e],d=c&&h&&f&&f.major;return this._adapter.format(t,s||(d?h:u))}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,i;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}=fe(n,"pos",t)),{pos:o,time:a}=n[i],{pos:r,time:l}=n[s]):(t>=n[i].time&&t<=n[s].time&&({lo:i,hi:s}=fe(n,"time",t)),{time:o,pos:a}=n[i],{time:r,pos:l}=n[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class hr extends wi{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=Zi(e,this.min),this._tableRange=Zi(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],o=[];let r,a,l,c,u;for(r=0,a=t.length;r=e&&c<=i&&s.push(c);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(r=0,a=s.length;rs-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),i=this.getLabelTimestamps();return e.length&&i.length?t=this.normalize(e.concat(i)):t=e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(Zi(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return Zi(this._table,i*this._tableRange+this._minPos,!0)}}A(hr,"id","timeseries"),A(hr,"defaults",wi.defaults);var X0=Object.freeze({__proto__:null,CategoryScale:ar,LinearScale:lr,LogarithmicScale:cr,RadialLinearScale:Gn,TimeScale:wi,TimeSeriesScale:hr});const G0=[nm,Eb,C0,X0];ae.register(...G0);function Q0(n){let t,e,i;return{c(){t=T("canvas"),e=V(),i=T("p"),i.textContent="Carbon Stats for the past 10 days",C(t,"id","myChart"),C(t,"class","mx-2"),C(i,"class","text-center")},m(s,o){I(s,t,o),n[3](t),I(s,e,o),I(s,i,o)},p:E,i:E,o:E,d(s){s&&(L(t),L(e),L(i)),n[3](null)}}}function Z0(n,t,e){let{chartValues:i}=t,{chartLabels:s}=t,o,r,a=-10;gc(async c=>{o=r.getContext("2d"),new ae(o,{type:"line",data:{labels:s.slice(a),datasets:[{label:"My Carbon Emissions",backgroundColor:"#283D34",borderColor:"#283D34",data:i.slice(a)}]}})});function l(c){So[c?"unshift":"push"](()=>{r=c,e(0,r)})}return n.$$set=c=>{"chartValues"in c&&e(1,i=c.chartValues),"chartLabels"in c&&e(2,s=c.chartLabels)},[r,i,s,l]}class J0 extends $t{constructor(t){super(),zt(this,t,Z0,Q0,Pt,{chartValues:1,chartLabels:2})}}function t_(n){return{c:E,m:E,p:E,i:E,o:E,d:E}}function e_(n){let t,e,i;return e=new J0({props:{chartValues:n[2][1],chartLabels:n[2][0]}}),{c(){t=T("section"),lt(e.$$.fragment)},m(s,o){I(s,t,o),it(e,t,null),i=!0},p:E,i(s){i||($(e.$$.fragment,s),i=!0)},o(s){j(e.$$.fragment,s),i=!1},d(s){s&&L(t),st(e)}}}function n_(n){let t;return{c(){t=T("div"),t.innerHTML=' Loading...',C(t,"role","status")},m(e,i){I(e,t,i)},p:E,i:E,o:E,d(e){e&&L(t)}}}function i_(n){let t,e,i,s,o,r,a,l;s=new Zc({});let c={ctx:n,current:null,token:null,hasCatch:!1,pending:n_,then:e_,catch:t_,value:2,blocks:[,,,]};return Sn(n[0],c),a=new Ns({}),{c(){t=T("main"),e=T("h1"),e.textContent="Emission Stats 📈",i=V(),lt(s.$$.fragment),o=V(),c.block.c(),r=V(),lt(a.$$.fragment),C(e,"class","m-4 p-4 rounded-lg"),C(t,"class","main")},m(u,h){I(u,t,h),P(t,e),P(t,i),it(s,t,null),P(t,o),c.block.m(t,c.anchor=null),c.mount=()=>t,c.anchor=r,P(t,r),it(a,t,null),l=!0},p(u,[h]){n=u,Si(c,n,h)},i(u){l||($(s.$$.fragment,u),$(c.block),$(a.$$.fragment,u),l=!0)},o(u){j(s.$$.fragment,u);for(let h=0;h<3;h+=1){const f=c.blocks[h];j(f)}j(a.$$.fragment,u),l=!1},d(u){u&&L(t),st(s),c.block.d(),c.token=null,c=null,st(a)}}}function s_(n){return[(async()=>await St.stats.toArray().then(i=>{let s=[],o=[];for(let r in i)s.push(i[r].day),o.push(i[r].emissionsTotal);return[s,o]}))().then(i=>i)]}class o_ extends $t{constructor(t){super(),zt(this,t,s_,i_,Pt,{})}}function r_(n){let t,e;return t=new o_({}),{c(){lt(t.$$.fragment)},m(i,s){it(t,i,s),e=!0},i(i){e||($(t.$$.fragment,i),e=!0)},o(i){j(t.$$.fragment,i),e=!1},d(i){st(t,i)}}}function a_(n){let t,e;return t=new Kd({}),{c(){lt(t.$$.fragment)},m(i,s){it(t,i,s),e=!0},i(i){e||($(t.$$.fragment,i),e=!0)},o(i){j(t.$$.fragment,i),e=!1},d(i){st(t,i)}}}function l_(n){let t,e;return t=new Od({}),{c(){lt(t.$$.fragment)},m(i,s){it(t,i,s),e=!0},i(i){e||($(t.$$.fragment,i),e=!0)},o(i){j(t.$$.fragment,i),e=!1},d(i){st(t,i)}}}function c_(n){let t,e;return t=new bd({}),{c(){lt(t.$$.fragment)},m(i,s){it(t,i,s),e=!0},i(i){e||($(t.$$.fragment,i),e=!0)},o(i){j(t.$$.fragment,i),e=!1},d(i){st(t,i)}}}function u_(n){let t,e,i,s,o,r,a,l,c;return e=new Ti({props:{path:"/stats",$$slots:{default:[r_]},$$scope:{ctx:n}}}),s=new Ti({props:{path:"/achievements",$$slots:{default:[a_]},$$scope:{ctx:n}}}),r=new Ti({props:{path:"/profile",$$slots:{default:[l_]},$$scope:{ctx:n}}}),l=new Ti({props:{path:"/",$$slots:{default:[c_]},$$scope:{ctx:n}}}),{c(){t=T("div"),lt(e.$$.fragment),i=V(),lt(s.$$.fragment),o=V(),lt(r.$$.fragment),a=V(),lt(l.$$.fragment)},m(u,h){I(u,t,h),it(e,t,null),P(t,i),it(s,t,null),P(t,o),it(r,t,null),P(t,a),it(l,t,null),c=!0},p(u,h){const f={};h&2&&(f.$$scope={dirty:h,ctx:u}),e.$set(f);const d={};h&2&&(d.$$scope={dirty:h,ctx:u}),s.$set(d);const p={};h&2&&(p.$$scope={dirty:h,ctx:u}),r.$set(p);const g={};h&2&&(g.$$scope={dirty:h,ctx:u}),l.$set(g)},i(u){c||($(e.$$.fragment,u),$(s.$$.fragment,u),$(r.$$.fragment,u),$(l.$$.fragment,u),c=!0)},o(u){j(e.$$.fragment,u),j(s.$$.fragment,u),j(r.$$.fragment,u),j(l.$$.fragment,u),c=!1},d(u){u&&L(t),st(e),st(s),st(r),st(l)}}}function h_(n){let t,e;return t=new Zh({props:{url:n[0],$$slots:{default:[u_]},$$scope:{ctx:n}}}),{c(){lt(t.$$.fragment)},m(i,s){it(t,i,s),e=!0},p(i,[s]){const o={};s&1&&(o.url=i[0]),s&2&&(o.$$scope={dirty:s,ctx:i}),t.$set(o)},i(i){e||($(t.$$.fragment,i),e=!0)},o(i){j(t.$$.fragment,i),e=!1},d(i){st(t,i)}}}function f_(n,t,e){let{url:i=""}=t;return n.$$set=s=>{"url"in s&&e(0,i=s.url)},[i]}class d_ extends $t{constructor(t){super(),zt(this,t,f_,h_,Pt,{url:0})}}new d_({target:document.getElementById("app")}); +`):n}function _0(n,t){const{element:e,datasetIndex:i,index:s}=t,o=n.getDatasetMeta(i).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:n,label:r,parsed:o.getParsed(s),raw:n.data.datasets[i].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:e}}function Vl(n,t){const e=n.chart.ctx,{body:i,footer:s,title:o}=n,{boxWidth:r,boxHeight:a}=t,l=ft(t.bodyFont),c=ft(t.titleFont),u=ft(t.footerFont),h=o.length,f=s.length,d=i.length,p=Mt(t.padding);let g=p.height,b=0,m=i.reduce((v,x)=>v+x.before.length+x.lines.length+x.after.length,0);if(m+=n.beforeBody.length+n.afterBody.length,h&&(g+=h*c.lineHeight+(h-1)*t.titleSpacing+t.titleMarginBottom),m){const v=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;g+=d*v+(m-d)*l.lineHeight+(m-1)*t.bodySpacing}f&&(g+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let _=0;const y=function(v){b=Math.max(b,e.measureText(v).width+_)};return e.save(),e.font=c.string,Z(n.title,y),e.font=l.string,Z(n.beforeBody.concat(n.afterBody),y),_=t.displayColors?r+2+t.boxPadding:0,Z(i,v=>{Z(v.before,y),Z(v.lines,y),Z(v.after,y)}),_=0,e.font=u.string,Z(n.footer,y),e.restore(),b+=p.width,{width:b,height:g}}function y0(n,t){const{y:e,height:i}=t;return en.height-i/2?"bottom":"center"}function x0(n,t,e,i){const{x:s,width:o}=i,r=e.caretSize+e.caretPadding;if(n==="left"&&s+o+r>t.width||n==="right"&&s-o-r<0)return!0}function v0(n,t,e,i){const{x:s,width:o}=e,{width:r,chartArea:{left:a,right:l}}=n;let c="center";return i==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),x0(c,n,t,e)&&(c="center"),c}function Hl(n,t,e){const i=e.yAlign||t.yAlign||y0(n,e);return{xAlign:e.xAlign||t.xAlign||v0(n,t,e,i),yAlign:i}}function w0(n,t){let{x:e,width:i}=n;return t==="right"?e-=i:t==="center"&&(e-=i/2),e}function k0(n,t,e){let{y:i,height:s}=n;return t==="top"?i+=e:t==="bottom"?i-=s+e:i-=s/2,i}function Wl(n,t,e,i){const{caretSize:s,caretPadding:o,cornerRadius:r}=n,{xAlign:a,yAlign:l}=e,c=s+o,{topLeft:u,topRight:h,bottomLeft:f,bottomRight:d}=Xe(r);let p=w0(t,a);const g=k0(t,l,c);return l==="center"?a==="left"?p+=c:a==="right"&&(p-=c):a==="left"?p-=Math.max(u,f)+s:a==="right"&&(p+=Math.max(h,d)+s),{x:gt(p,0,i.width-t.width),y:gt(g,0,i.height-t.height)}}function Qi(n,t,e){const i=Mt(e.padding);return t==="center"?n.x+n.width/2:t==="right"?n.x+n.width-i.right:n.x+i.left}function Kl(n){return Ut([],oe(n))}function S0(n,t,e){return Fe(n,{tooltip:t,tooltipItems:e,type:"tooltip"})}function ql(n,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?n.override(e):n}const Yu={beforeTitle:ie,title(n){if(n.length>0){const t=n[0],e=t.chart.data.labels,i=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex"u"?Yu[t].call(e,i):s}class rr extends qt{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 Pu(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=S0(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:i}=e,s=Ot(i,"beforeTitle",this,t),o=Ot(i,"title",this,t),r=Ot(i,"afterTitle",this,t);let a=[];return a=Ut(a,oe(s)),a=Ut(a,oe(o)),a=Ut(a,oe(r)),a}getBeforeBody(t,e){return Kl(Ot(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:i}=e,s=[];return Z(t,o=>{const r={before:[],lines:[],after:[]},a=ql(i,o);Ut(r.before,oe(Ot(a,"beforeLabel",this,o))),Ut(r.lines,Ot(a,"label",this,o)),Ut(r.after,oe(Ot(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,e){return Kl(Ot(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,s=Ot(i,"beforeFooter",this,t),o=Ot(i,"footer",this,t),r=Ot(i,"afterFooter",this,t);let a=[];return a=Ut(a,oe(s)),a=Ut(a,oe(o)),a=Ut(a,oe(r)),a}_createItems(t){const e=this._active,i=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=e.length;lt.filter(u,h,f,i))),t.itemSort&&(a=a.sort((u,h)=>t.itemSort(u,h,i))),Z(a,u=>{const h=ql(t.callbacks,u);s.push(Ot(h,"labelColor",this,u)),o.push(Ot(h,"labelPointStyle",this,u)),r.push(Ot(h,"labelTextColor",this,u))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=Xn[i.position].call(this,s,this._eventPosition);r=this._createItems(i),this.title=this.getTitle(r,i),this.beforeBody=this.getBeforeBody(r,i),this.body=this.getBody(r,i),this.afterBody=this.getAfterBody(r,i),this.footer=this.getFooter(r,i);const l=this._size=Vl(this,i),c=Object.assign({},a,l),u=Hl(this.chart,i,c),h=Wl(i,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,o={opacity:1,x:h.x,y:h.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&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:r,cornerRadius:a}=i,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:h}=Xe(a),{x:f,y:d}=t,{width:p,height:g}=e;let b,m,_,y,v,x;return o==="center"?(v=d+g/2,s==="left"?(b=f,m=b-r,y=v+r,x=v-r):(b=f+p,m=b+r,y=v-r,x=v+r),_=b):(s==="left"?m=f+Math.max(l,u)+r:s==="right"?m=f+p-Math.max(c,h)-r:m=this.caretX,o==="top"?(y=d,v=y-r,b=m-r,_=m+r):(y=d+g,v=y+r,b=m+r,_=m-r),x=y),{x1:b,x2:m,x3:_,y1:y,y2:v,y3:x}}drawTitle(t,e,i){const s=this.title,o=s.length;let r,a,l;if(o){const c=kn(i.rtl,this.x,this.width);for(t.x=Qi(this,i.titleAlign,i),e.textAlign=c.textAlign(i.titleAlign),e.textBaseline="middle",r=ft(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=r.string,l=0;l_!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,yi(t,{x:g,y:p,w:c,h:l,radius:m}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),yi(t,{x:b,y:p+1,w:c-2,h:l-2,radius:m}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(g,p,c,l),t.strokeRect(g,p,c,l),t.fillStyle=r.backgroundColor,t.fillRect(b,p+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=i,h=ft(i.bodyFont);let f=h.lineHeight,d=0;const p=kn(i.rtl,this.x,this.width),g=function(k){e.fillText(k,p.x(t.x+d),t.y+f/2),t.y+=f+o},b=p.textAlign(r);let m,_,y,v,x,S,M;for(e.textAlign=r,e.textBaseline="middle",e.font=h.string,t.x=Qi(this,b,i),e.fillStyle=i.bodyColor,Z(this.beforeBody,g),d=a&&b!=="right"?r==="center"?c/2+u:c+2+u:0,v=0,S=s.length;v0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,s=i&&i.x,o=i&&i.y;if(s||o){const r=Xn[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=Vl(this,t),l=Object.assign({},r,this._size),c=Hl(e,t,l),u=Wl(t,l,c,e);(s._to!==u.x||o._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,u))}}_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 r=Mt(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,s,e),wu(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),ku(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!As(i,s),r=this._positionChanged(s,e);(o||r)&&(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||[],r=this._getActiveElements(t,o,e,i),a=this._positionChanged(r,t),l=e||!As(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,i,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return e;const r=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&r.reverse(),r}_positionChanged(t,e){const{caretX:i,caretY:s,options:o}=this,r=Xn[o.position].call(this,t,e);return r!==!1&&(i!==r.x||s!==r.y)}}A(rr,"positioners",Xn);var M0={id:"tooltip",_element:rr,positioners:Xn,afterInit(n,t,e){e&&(n.tooltip=new rr({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(n.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(n.ctx),n.notifyPlugins("afterTooltipDraw",e)}},afterEvent(n,t){if(n.tooltip){const e=t.replay;n.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(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:Yu},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:n=>n!=="filter"&&n!=="itemSort"&&n!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},C0=Object.freeze({__proto__:null,Colors:zb,Decimation:Vb,Filler:l0,Legend:p0,SubTitle:b0,Title:m0,Tooltip:M0});const P0=(n,t,e,i)=>(typeof t=="string"?(e=n.push(t)-1,i.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function O0(n,t,e,i){const s=n.indexOf(t);if(s===-1)return P0(n,t,e,i);const o=n.lastIndexOf(t);return s!==o?e:s}const A0=(n,t)=>n===null?null:gt(Math.round(n),0,t);function Ul(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}}A(ar,"id","category"),A(ar,"defaults",{ticks:{callback:Ul}});function D0(n,t){const e=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:u,maxDigits:h,includeBounds:f}=n,d=o||1,p=u-1,{min:g,max:b}=t,m=!X(r),_=!X(a),y=!X(c),v=(b-g)/(h+1);let x=Na((b-g)/p/d)*d,S,M,k,w;if(x<1e-14&&!m&&!_)return[{value:g},{value:b}];w=Math.ceil(b/x)-Math.floor(g/x),w>p&&(x=Na(w*x/p/d)*d),X(l)||(S=Math.pow(10,l),x=Math.ceil(x*S)/S),s==="ticks"?(M=Math.floor(g/x)*x,k=Math.ceil(b/x)*x):(M=g,k=b),m&&_&&o&&Sp((a-r)/o,x/1e3)?(w=Math.round(Math.min((a-r)/x,u)),x=(a-r)/w,M=r,k=a):y?(M=m?r:M,k=_?a:k,w=c-1,x=(k-M)/w):(w=(k-M)/x,ii(w,Math.round(w),x/1e3)?w=Math.round(w):w=Math.ceil(w));const O=Math.max(Va(x),Va(M));S=Math.pow(10,X(l)?O:l),M=Math.round(M*S)/S,k=Math.round(k*S)/S;let D=0;for(m&&(f&&M!==r?(e.push({value:r}),Ma)break;e.push({value:R})}return _&&f&&k!==a?e.length&&ii(e[e.length-1].value,a,Yl(a,v,n))?e[e.length-1].value=a:e.push({value:a}):(!_||k===a)&&e.push({value:k}),e}function Yl(n,t,{horizontal:e,minRotation:i}){const s=Ht(i),o=(e?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+n).length;return Math.min(t/o,r)}class Fs extends rn{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 X(t)||(typeof t=="number"||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 r=l=>s=e?s:l,a=l=>o=i?o:l;if(t){const l=Qt(s),c=Qt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:i}=t,s;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 s={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:e.includeBounds!==!1},o=this._range||this,r=D0(s,o);return t.bounds==="ticks"&&su(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let e=this.min,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 Ci(t,this.chart.options.locale,this.options.ticks.format)}}class lr extends Fs{determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=ct(t)?t:0,this.max=ct(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=Ht(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 t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}A(lr,"id","linear"),A(lr,"defaults",{ticks:{callback:Ws.formatters.numeric}});const vi=n=>Math.floor(Me(n)),Ne=(n,t)=>Math.pow(10,vi(n)+t);function Xl(n){return n/Math.pow(10,vi(n))===1}function Gl(n,t,e){const i=Math.pow(10,e),s=Math.floor(n/i);return Math.ceil(t/i)-s}function T0(n,t){const e=t-n;let i=vi(e);for(;Gl(n,t,i)>10;)i++;for(;Gl(n,t,i)<10;)i--;return Math.min(i,vi(n))}function E0(n,{min:t,max:e}){t=Lt(n.min,t);const i=[],s=vi(t);let o=T0(t,e),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((t-l)*r)/r,u=Math.floor((t-l)/a/10)*a*10;let h=Math.floor((c-u)/Math.pow(10,o)),f=Lt(n.min,Math.round((l+u+h*Math.pow(10,o))*r)/r);for(;f=10?h=h<15?15:20:h++,h>=20&&(o++,h=2,r=o>=0?1:r),f=Math.round((l+u+h*Math.pow(10,o))*r)/r;const d=Lt(n.max,f);return i.push({value:d,major:Xl(d),significand:h}),i}class cr extends rn{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const i=Fs.prototype.parse.apply(this,[t,e]);if(i===0){this._zero=!0;return}return ct(i)&&i>0?i:null}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=ct(t)?Math.max(0,t):null,this.max=ct(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!ct(this._userMin)&&(this.min=t===Ne(this.min,0)?Ne(this.min,-1):Ne(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const o=a=>i=t?i:a,r=a=>s=e?s:a;i===s&&(i<=0?(o(1),r(10)):(o(Ne(i,-1)),r(Ne(s,1)))),i<=0&&o(Ne(s,-1)),s<=0&&r(Ne(i,1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e={min:this._userMin,max:this._userMax},i=E0(e,this);return t.bounds==="ticks"&&su(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 t===void 0?"0":Ci(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Me(t),this._valueRange=Me(this.max)-Me(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Me(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}A(cr,"id","logarithmic"),A(cr,"defaults",{ticks:{callback:Ws.formatters.logarithmic,major:{enabled:!0}}});function ur(n){const t=n.ticks;if(t.display&&n.display){const e=Mt(t.backdropPadding);return H(t.font&&t.font.size,ut.font.size)+e.height}return 0}function R0(n,t,e){return e=nt(e)?e:[e],{w:Np(n,t.string,e),h:e.length*t.lineHeight}}function Ql(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 L0(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,r=n.options.pointLabels,a=r.centerPointLabels?rt/o:0;for(let l=0;lt.r&&(a=(i.end-t.r)/o,n.r=Math.max(n.r,t.r+a)),s.startt.b&&(l=(s.end-t.b)/r,n.b=Math.max(n.b,t.b+l))}function F0(n,t,e){const i=n.drawingArea,{extra:s,additionalAngle:o,padding:r,size:a}=e,l=n.getPointPosition(t,i+s+r,o),c=Math.round(Rr(It(l.angle+ht))),u=N0(l.y,a.h,c),h=$0(c),f=j0(l.x,a.w,h);return{visible:!0,x:l.x,y:u,textAlign:h,left:f,top:u,right:f+a.w,bottom:u+a.h}}function B0(n,t){if(!t)return!0;const{left:e,top:i,right:s,bottom:o}=n;return!(de({x:e,y:i},t)||de({x:e,y:o},t)||de({x:s,y:i},t)||de({x:s,y:o},t))}function z0(n,t,e){const i=[],s=n._pointLabels.length,o=n.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:ur(o)/2,additionalAngle:r?rt/s:0};let c;for(let u=0;u270||e<90)&&(n-=t),n}function V0(n,t,e){const{left:i,top:s,right:o,bottom:r}=e,{backdropColor:a}=t;if(!X(a)){const l=Xe(t.borderRadius),c=Mt(t.backdropPadding);n.fillStyle=a;const u=i-c.left,h=s-c.top,f=o-i+c.width,d=r-s+c.height;Object.values(l).some(p=>p!==0)?(n.beginPath(),yi(n,{x:u,y:h,w:f,h:d,radius:l}),n.fill()):n.fillRect(u,h,f,d)}}function H0(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 r=i.setContext(n.getPointLabelContext(s));V0(e,r,o);const a=ft(r.font),{x:l,y:c,textAlign:u}=o;sn(e,n._pointLabels[s],l,c+a.lineHeight/2,a,{color:r.color,textAlign:u,textBaseline:"middle"})}}function Xu(n,t,e,i){const{ctx:s}=n;if(e)s.arc(n.xCenter,n.yCenter,t,0,ot);else{let o=n.getPointPosition(0,t);s.moveTo(o.x,o.y);for(let r=1;r{const s=et(this.options.pointLabels.callback,[e,i],this);return s||s===0?s:""}).filter((e,i)=>this.chart.getDataVisibility(i))}fit(){const t=this.options;t.display&&t.pointLabels.display?L0(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){const e=ot/(this._pointLabels.length||1),i=this.options.startAngle||0;return It(t*e+Ht(i))}getDistanceFromCenterForValue(t){if(X(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(X(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(h!==0){l=this.getDistanceFromCenterForValue(u.value);const f=this.getContext(h),d=s.setContext(f),p=o.setContext(f);W0(this,d,l,r,p)}}),i.display){for(t.save(),a=r-1;a>=0;a--){const u=i.setContext(this.getPointLabelContext(a)),{color:h,lineWidth:f}=u;!f||!h||(t.lineWidth=f,t.strokeStyle=h,t.setLineDash(u.borderDash),t.lineDashOffset=u.borderDashOffset,l=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&!e.reverse)return;const c=i.setContext(this.getContext(l)),u=ft(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=u.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const h=Mt(c.backdropPadding);t.fillRect(-r/2-h.left,-o-u.size/2-h.top,r+h.width,u.size+h.height)}sn(t,a.label,0,-o,u,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}A(Gn,"id","radialLinear"),A(Gn,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ws.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),A(Gn,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),A(Gn,"descriptors",{angleLines:{_fallback:"grid"}});const Ys={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}},Tt=Object.keys(Ys);function Zl(n,t){return n-t}function Jl(n,t){if(X(t))return null;const e=n._adapter,{parser:i,round:s,isoWeekday:o}=n._parseOpts;let r=t;return typeof i=="function"&&(r=i(r)),ct(r)||(r=typeof i=="string"?e.parse(r,i):e.parse(r)),r===null?null:(s&&(r=s==="week"&&(Pn(o)||o===!0)?e.startOf(r,"isoWeek",o):e.startOf(r,s)),+r)}function tc(n,t,e,i){const s=Tt.length;for(let o=Tt.indexOf(n);o=Tt.indexOf(e);o--){const r=Tt[o];if(Ys[r].common&&n._adapter.diff(s,i,r)>=t-1)return r}return Tt[e?Tt.indexOf(e):0]}function U0(n){for(let t=Tt.indexOf(n)+1,e=Tt.length;t=t?e[i]:e[s];n[o]=!0}}function Y0(n,t,e,i){const s=n._adapter,o=+s.startOf(t[0].value,i),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,i))l=e[a],l>=0&&(t[l].major=!0);return t}function nc(n,t,e){const i=[],s={},o=t.length;let r,a;for(r=0;r+t.value))}initOffsets(t=[]){let e=0,i=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?e=1-s:e=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?i=o:i=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;e=gt(e,0,r),i=gt(i,0,r),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,r=o.unit||tc(o.minUnit,e,i,this._getLabelCapacity(e)),a=H(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=Pn(l)||l===!0,u={};let h=e,f,d;if(c&&(h=+t.startOf(h,"isoWeek",l)),h=+t.startOf(h,c?"day":r),t.diff(i,e,r)>1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+r);const p=s.ticks.source==="data"&&this.getDataTimestamps();for(f=h,d=0;f+g)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}format(t,e){const s=this.options.time.displayFormats,o=this._unit,r=e||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,i,s){const o=this.options,r=o.ticks.callback;if(r)return et(r,[t,e,i],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],h=c&&a[c],f=i[e],d=c&&h&&f&&f.major;return this._adapter.format(t,s||(d?h:u))}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,i;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}=fe(n,"pos",t)),{pos:o,time:a}=n[i],{pos:r,time:l}=n[s]):(t>=n[i].time&&t<=n[s].time&&({lo:i,hi:s}=fe(n,"time",t)),{time:o,pos:a}=n[i],{time:r,pos:l}=n[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class hr extends wi{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=Zi(e,this.min),this._tableRange=Zi(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],o=[];let r,a,l,c,u;for(r=0,a=t.length;r=e&&c<=i&&s.push(c);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(r=0,a=s.length;rs-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),i=this.getLabelTimestamps();return e.length&&i.length?t=this.normalize(e.concat(i)):t=e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(Zi(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return Zi(this._table,i*this._tableRange+this._minPos,!0)}}A(hr,"id","timeseries"),A(hr,"defaults",wi.defaults);var X0=Object.freeze({__proto__:null,CategoryScale:ar,LinearScale:lr,LogarithmicScale:cr,RadialLinearScale:Gn,TimeScale:wi,TimeSeriesScale:hr});const G0=[nm,Eb,C0,X0];ae.register(...G0);function Q0(n){let t,e,i;return{c(){t=T("canvas"),e=V(),i=T("p"),i.textContent="Carbon Stats for the past 10 days",C(t,"id","myChart"),C(t,"class","mx-2"),C(i,"class","text-center")},m(s,o){I(s,t,o),n[3](t),I(s,e,o),I(s,i,o)},p:E,i:E,o:E,d(s){s&&(L(t),L(e),L(i)),n[3](null)}}}function Z0(n,t,e){let{chartValues:i}=t,{chartLabels:s}=t,o,r,a=-10;gc(async c=>{o=r.getContext("2d"),new ae(o,{type:"line",data:{labels:s.slice(a),datasets:[{label:"My Carbon Emissions",backgroundColor:"#283D34",borderColor:"#283D34",data:i.slice(a)}]}})});function l(c){So[c?"unshift":"push"](()=>{r=c,e(0,r)})}return n.$$set=c=>{"chartValues"in c&&e(1,i=c.chartValues),"chartLabels"in c&&e(2,s=c.chartLabels)},[r,i,s,l]}class J0 extends $t{constructor(t){super(),zt(this,t,Z0,Q0,Pt,{chartValues:1,chartLabels:2})}}function t_(n){return{c:E,m:E,p:E,i:E,o:E,d:E}}function e_(n){let t,e,i;return e=new J0({props:{chartValues:n[2][1],chartLabels:n[2][0]}}),{c(){t=T("section"),lt(e.$$.fragment)},m(s,o){I(s,t,o),it(e,t,null),i=!0},p:E,i(s){i||($(e.$$.fragment,s),i=!0)},o(s){j(e.$$.fragment,s),i=!1},d(s){s&&L(t),st(e)}}}function n_(n){let t;return{c(){t=T("div"),t.innerHTML=' Loading...',C(t,"role","status")},m(e,i){I(e,t,i)},p:E,i:E,o:E,d(e){e&&L(t)}}}function i_(n){let t,e,i,s,o,r,a,l;s=new Zc({});let c={ctx:n,current:null,token:null,hasCatch:!1,pending:n_,then:e_,catch:t_,value:2,blocks:[,,,]};return Sn(n[0],c),a=new Ns({}),{c(){t=T("main"),e=T("h1"),e.textContent="Emission Stats 📈",i=V(),lt(s.$$.fragment),o=V(),c.block.c(),r=V(),lt(a.$$.fragment),C(e,"class","m-4 p-4 rounded-lg"),C(t,"class","main")},m(u,h){I(u,t,h),P(t,e),P(t,i),it(s,t,null),P(t,o),c.block.m(t,c.anchor=null),c.mount=()=>t,c.anchor=r,P(t,r),it(a,t,null),l=!0},p(u,[h]){n=u,Si(c,n,h)},i(u){l||($(s.$$.fragment,u),$(c.block),$(a.$$.fragment,u),l=!0)},o(u){j(s.$$.fragment,u);for(let h=0;h<3;h+=1){const f=c.blocks[h];j(f)}j(a.$$.fragment,u),l=!1},d(u){u&&L(t),st(s),c.block.d(),c.token=null,c=null,st(a)}}}function s_(n){return[(async()=>await St.stats.toArray().then(i=>{let s=[],o=[];for(let r in i)s.push(i[r].day),o.push(i[r].emissionsTotal);return[s,o]}))().then(i=>i)]}class o_ extends $t{constructor(t){super(),zt(this,t,s_,i_,Pt,{})}}function r_(n){let t,e;return t=new o_({}),{c(){lt(t.$$.fragment)},m(i,s){it(t,i,s),e=!0},i(i){e||($(t.$$.fragment,i),e=!0)},o(i){j(t.$$.fragment,i),e=!1},d(i){st(t,i)}}}function a_(n){let t,e;return t=new Kd({}),{c(){lt(t.$$.fragment)},m(i,s){it(t,i,s),e=!0},i(i){e||($(t.$$.fragment,i),e=!0)},o(i){j(t.$$.fragment,i),e=!1},d(i){st(t,i)}}}function l_(n){let t,e;return t=new Od({}),{c(){lt(t.$$.fragment)},m(i,s){it(t,i,s),e=!0},i(i){e||($(t.$$.fragment,i),e=!0)},o(i){j(t.$$.fragment,i),e=!1},d(i){st(t,i)}}}function c_(n){let t,e;return t=new bd({}),{c(){lt(t.$$.fragment)},m(i,s){it(t,i,s),e=!0},i(i){e||($(t.$$.fragment,i),e=!0)},o(i){j(t.$$.fragment,i),e=!1},d(i){st(t,i)}}}function u_(n){let t,e,i,s,o,r,a,l,c;return e=new Ti({props:{path:"/stats",$$slots:{default:[r_]},$$scope:{ctx:n}}}),s=new Ti({props:{path:"/achievements",$$slots:{default:[a_]},$$scope:{ctx:n}}}),r=new Ti({props:{path:"/profile",$$slots:{default:[l_]},$$scope:{ctx:n}}}),l=new Ti({props:{path:"/",$$slots:{default:[c_]},$$scope:{ctx:n}}}),{c(){t=T("div"),lt(e.$$.fragment),i=V(),lt(s.$$.fragment),o=V(),lt(r.$$.fragment),a=V(),lt(l.$$.fragment)},m(u,h){I(u,t,h),it(e,t,null),P(t,i),it(s,t,null),P(t,o),it(r,t,null),P(t,a),it(l,t,null),c=!0},p(u,h){const f={};h&2&&(f.$$scope={dirty:h,ctx:u}),e.$set(f);const d={};h&2&&(d.$$scope={dirty:h,ctx:u}),s.$set(d);const p={};h&2&&(p.$$scope={dirty:h,ctx:u}),r.$set(p);const g={};h&2&&(g.$$scope={dirty:h,ctx:u}),l.$set(g)},i(u){c||($(e.$$.fragment,u),$(s.$$.fragment,u),$(r.$$.fragment,u),$(l.$$.fragment,u),c=!0)},o(u){j(e.$$.fragment,u),j(s.$$.fragment,u),j(r.$$.fragment,u),j(l.$$.fragment,u),c=!1},d(u){u&&L(t),st(e),st(s),st(r),st(l)}}}function h_(n){let t,e;return t=new Zh({props:{url:n[0],basepath:"/CarbonQuest",$$slots:{default:[u_]},$$scope:{ctx:n}}}),{c(){lt(t.$$.fragment)},m(i,s){it(t,i,s),e=!0},p(i,[s]){const o={};s&1&&(o.url=i[0]),s&2&&(o.$$scope={dirty:s,ctx:i}),t.$set(o)},i(i){e||($(t.$$.fragment,i),e=!0)},o(i){j(t.$$.fragment,i),e=!1},d(i){st(t,i)}}}function f_(n,t,e){let{url:i=""}=t;return n.$$set=s=>{"url"in s&&e(0,i=s.url)},[i]}class d_ extends $t{constructor(t){super(),zt(this,t,f_,h_,Pt,{url:0})}}new d_({target:document.getElementById("app")}); diff --git a/docs/index.html b/docs/index.html index bd84f60..1e2a80b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -7,7 +7,7 @@ CarbonQuest - + diff --git a/src/App.svelte b/src/App.svelte index 886e71d..5e1a3d8 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -10,7 +10,7 @@ export let url = ""; - +