u*o?u/a:c/o:c*o0}_computeGridLineItems(t){const n=this.axis,a=this.chart,o=this.options,{grid:r,position:i,border:u}=o,c=r.offset,l=this.isHorizontal(),p=this.ticks.length+(c?1:0),A=cb(r),b=[],T=u.setContext(this.getContext()),f=T.display?T.width:0,S=f/2,z=function(k){return jl(a,k,f)};let m,I,L,g,C,D,v,j,y,U,Y,H;if(i==="top")m=z(this.bottom),D=this.bottom-A,j=m-S,U=z(t.top)+S,H=t.bottom;else if(i==="bottom")m=z(this.top),U=t.top,H=z(t.bottom)-S,D=m+S,j=this.top+A;else if(i==="left")m=z(this.right),C=this.right-A,v=m-S,y=z(t.left)+S,Y=t.right;else if(i==="right")m=z(this.left),y=t.left,Y=z(t.right)-S,C=m+S,v=this.left+A;else if(n==="x"){if(i==="center")m=z((t.top+t.bottom)/2+.5);else if(r1(i)){const k=Object.keys(i)[0],X=i[k];m=z(this.chart.scales[k].getPixelForValue(X))}U=t.top,H=t.bottom,D=m+S,j=D+A}else if(n==="y"){if(i==="center")m=z((t.left+t.right)/2);else if(r1(i)){const k=Object.keys(i)[0],X=i[k];m=z(this.chart.scales[k].getPixelForValue(X))}C=m-S,v=C-A,y=t.left,Y=t.right}const B=On(o.ticks.maxTicksLimit,p),q=Math.max(1,Math.ceil(p/B));for(I=0;Ir.value===t);return o>=0?n.setContext(this.getContext(o)).lineWidth:0}drawGrid(t){const n=this.options.grid,a=this.ctx,o=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let r,i;const u=(c,l,d)=>{!d.width||!d.color||(a.save(),a.lineWidth=d.width,a.strokeStyle=d.color,a.setLineDash(d.borderDash||[]),a.lineDashOffset=d.borderDashOffset,a.beginPath(),a.moveTo(c.x,c.y),a.lineTo(l.x,l.y),a.stroke(),a.restore())};if(n.display)for(r=0,i=o.length;r{this.draw(r)}}]:[{z:a,draw:r=>{this.drawBackground(),this.drawGrid(r),this.drawTitle()}},{z:o,draw:()=>{this.drawBorder()}},{z:n,draw:r=>{this.drawLabels(r)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),a=this.axis+"AxisID",o=[];let r,i;for(r=0,i=n.length;r{const a=n.split("."),o=a.pop(),r=[e].concat(a).join("."),i=t[n].split("."),u=i.pop(),c=i.join(".");Rn.route(r,o,c,u)})}function Dl0(e){return"id"in e&&"defaults"in e}class Cl0{constructor(){this.controllers=new vh(pO,"datasets",!0),this.elements=new vh(xK,"elements"),this.plugins=new vh(Object,"plugins"),this.scales=new vh(cL,"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,n,a){[...n].forEach(o=>{const r=a||this._getRegistryForType(o);a||r.isForType(o)||r===this.plugins&&o.id?this._exec(t,r,o):Ta(o,i=>{const u=a||this._getRegistryForType(i);this._exec(t,u,i)})})}_exec(t,n,a){const o=n6(t);An(a["before"+o],[],a),n[t](a),An(a["after"+o],[],a)}_getRegistryForType(t){for(let n=0;nr.filter(u=>!i.some(c=>u.plugin.id===c.plugin.id));this._notify(o(n,a),t,"stop"),this._notify(o(a,n),t,"start")}}function vl0(e){const t={},n=[],a=Object.keys(Vi.plugins.items);for(let r=0;r1&&Bk(e[0].toLowerCase());if(a)return a}throw new Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function kk(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function Bl0(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(a=>a.xAxisID===e||a.yAxisID===e);if(n.length)return kk(e,"x",n[0])||kk(e,"y",n[0])}return{}}function kl0(e,t){const n=Yd[e.type]||{scales:{}},a=t.scales||{},o=VD(e.type,t),r=Object.create(null);return Object.keys(a).forEach(i=>{const u=a[i];if(!r1(u))return console.error(`Invalid scale configuration for scale: ${i}`);if(u._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${i}`);const c=GD(i,u,Bl0(i,e),Rn.scales[u.type]),l=xl0(c,o),d=n.scales||{};r[i]=cO(Object.create(null),[{axis:c},u,d[c],d[l]])}),e.data.datasets.forEach(i=>{const u=i.type||e.type,c=i.indexAxis||VD(u,t),d=(Yd[u]||{}).scales||{};Object.keys(d).forEach(p=>{const A=ql0(p,c),b=i[A+"AxisID"]||A;r[b]=r[b]||Object.create(null),cO(r[b],[{axis:A},a[b],d[p]])})}),Object.keys(r).forEach(i=>{const u=r[i];cO(u,[Rn.scales[u.type],Rn.scale])}),r}function UK(e){const t=e.options||(e.options={});t.plugins=On(t.plugins,{}),t.scales=kl0(e,t)}function BK(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function jl0(e){return e=e||{},e.data=BK(e.data),UK(e),e}const jk=new Map,kK=new Set;function Ph(e,t){let n=jk.get(e);return n||(n=t(),jk.set(e,n),kK.add(n)),n}const lb=(e,t,n)=>{const a=AA(t,n);a!==void 0&&e.add(a)};class Fl0{constructor(t){this._config=jl0(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=BK(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(),UK(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Ph(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,n){return Ph(`${t}.transition.${n}`,()=>[[`datasets.${t}.transitions.${n}`,`transitions.${n}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,n){return Ph(`${t}-${n}`,()=>[[`datasets.${t}.elements.${n}`,`datasets.${t}`,`elements.${n}`,""]])}pluginScopeKeys(t){const n=t.id,a=this.type;return Ph(`${a}-plugin-${n}`,()=>[[`plugins.${n}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const a=this._scopeCache;let o=a.get(t);return(!o||n)&&(o=new Map,a.set(t,o)),o}getOptionScopes(t,n,a){const{options:o,type:r}=this,i=this._cachedScopes(t,a),u=i.get(n);if(u)return u;const c=new Set;n.forEach(d=>{t&&(c.add(t),d.forEach(p=>lb(c,t,p))),d.forEach(p=>lb(c,o,p)),d.forEach(p=>lb(c,Yd[r]||{},p)),d.forEach(p=>lb(c,Rn,p)),d.forEach(p=>lb(c,HD,p))});const l=Array.from(c);return l.length===0&&l.push(Object.create(null)),kK.has(n)&&i.set(n,l),l}chartOptionScopes(){const{options:t,type:n}=this;return[t,Yd[n]||{},Rn.datasets[n]||{},{type:n},Rn,HD]}resolveNamedOptions(t,n,a,o=[""]){const r={$shared:!0},{resolver:i,subPrefixes:u}=Fk(this._resolverCache,t,o);let c=i;if(Yl0(i,n)){r.$shared=!1,a=tl(a)?a():a;const l=this.createResolver(t,a,u);c=bA(i,a,l)}for(const l of n)r[l]=c[l];return r}createResolver(t,n,a=[""],o){const{resolver:r}=Fk(this._resolverCache,t,a);return r1(n)?bA(r,n,void 0,o):r}}function Fk(e,t,n){let a=e.get(t);a||(a=new Map,e.set(t,a));const o=n.join();let r=a.get(o);return r||(r={resolver:o6(t,n),subPrefixes:n.filter(u=>!u.toLowerCase().includes("hover"))},a.set(o,r)),r}const Hl0=e=>r1(e)&&Object.getOwnPropertyNames(e).reduce((t,n)=>t||tl(e[n]),!1);function Yl0(e,t){const{isScriptable:n,isIndexable:a}=IK(e);for(const o of t){const r=n(o),i=a(o),u=(i||r)&&e[o];if(r&&(tl(u)||Hl0(u))||i&&ta(u))return!0}return!1}var Vl0="4.3.0";const Gl0=["top","bottom","left","right","chartArea"];function Hk(e,t){return e==="top"||e==="bottom"||Gl0.indexOf(e)===-1&&t==="x"}function Yk(e,t){return function(n,a){return n[e]===a[e]?n[t]-a[t]:n[e]-a[e]}}function Vk(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),An(n&&n.onComplete,[e],t)}function $l0(e){const t=e.chart,n=t.options.animation;An(n&&n.onProgress,[e],t)}function jK(e){return DK()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const Im={},Gk=e=>{const t=jK(e);return Object.values(Im).filter(n=>n.canvas===t).pop()};function Xl0(e,t,n){const a=Object.keys(e);for(const o of a){const r=+o;if(r>=t){const i=e[o];delete e[o],(n>0||r>t)&&(e[r+n]=i)}}}function Kl0(e,t,n,a){return!n||e.type==="mouseout"?null:a?t:e}function Jl0(e){const{xScale:t,yScale:n}=e;if(t&&n)return{left:t.left,right:t.right,top:n.top,bottom:n.bottom}}var ic;let c6=(ic=class{static register(...t){Vi.add(...t),$k()}static unregister(...t){Vi.remove(...t),$k()}constructor(t,n){const a=this.config=new Fl0(n),o=jK(t),r=Gk(o);if(r)throw new Error("Canvas is already in use. Chart with ID '"+r.id+"' must be destroyed before the canvas with ID '"+r.canvas.id+"' can be reused.");const i=a.createResolver(a.chartOptionScopes(),this.getContext());this.platform=new(a.platform||Al0(o)),this.platform.updateConfig(a);const u=this.platform.acquireContext(o,i.aspectRatio),c=u&&u.canvas,l=c&&c.height,d=c&&c.width;if(this.id=Mu0(),this.ctx=u,this.canvas=c,this.width=d,this.height=l,this._options=i,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 yl0,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=yu0(p=>this.update(p),i.resizeDelay||0),this._dataChanges=[],Im[this.id]=this,!u||!c){console.error("Failed to create chart: can't acquire context from the given item");return}Xs.listen(this,"complete",Vk),Xs.listen(this,"progress",$l0),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:a,height:o,_aspectRatio:r}=this;return sa(t)?n&&r?r:o?a/o: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 Vi}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Tk(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Ak(this.canvas,this.ctx),this}stop(){return Xs.stop(this),this}resize(t,n){Xs.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const a=this.options,o=this.canvas,r=a.maintainAspectRatio&&this.aspectRatio,i=this.platform.getMaximumSize(o,t,n,r),u=a.devicePixelRatio||this.platform.getDevicePixelRatio(),c=this.width?"resize":"attach";this.width=i.width,this.height=i.height,this._aspectRatio=this.aspectRatio,Tk(this,u,!0)&&(this.notifyPlugins("resize",{size:i}),An(a.onResize,[this,i],this),this.attached&&this._doResize(c)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};Ta(n,(a,o)=>{a.id=o})}buildOrUpdateScales(){const t=this.options,n=t.scales,a=this.scales,o=Object.keys(a).reduce((i,u)=>(i[u]=!1,i),{});let r=[];n&&(r=r.concat(Object.keys(n).map(i=>{const u=n[i],c=GD(i,u),l=c==="r",d=c==="x";return{options:u,dposition:l?"chartArea":d?"bottom":"left",dtype:l?"radialLinear":d?"category":"linear"}}))),Ta(r,i=>{const u=i.options,c=u.id,l=GD(c,u),d=On(u.type,i.dtype);(u.position===void 0||Hk(u.position,l)!==Hk(i.dposition))&&(u.position=i.dposition),o[c]=!0;let p=null;if(c in a&&a[c].type===d)p=a[c];else{const A=Vi.getScale(d);p=new A({id:c,type:d,ctx:this.ctx,chart:this}),a[p.id]=p}p.init(u,t)}),Ta(o,(i,u)=>{i||delete a[u]}),Ta(a,i=>{Ch.configure(this,i,i.options),Ch.addBox(this,i)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,a=t.length;if(t.sort((o,r)=>o.index-r.index),a>n){for(let o=n;on.length&&delete this._stacks,t.forEach((a,o)=>{n.filter(r=>r===a._dataset).length===0&&this._destroyDatasetMeta(o)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let a,o;for(this._removeUnreferencedMetasets(),a=0,o=n.length;a{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const n=this.config;n.update();const a=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),o=this._animationsDisabled=!a.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const r=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let i=0;for(let l=0,d=this.data.datasets.length;l{l.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Yk("z","_idx"));const{_active:u,_lastEvent:c}=this;c?this._eventHandler(c,!0):u.length&&this._updateHoverStyles(u,u,!0),this.render()}_updateScales(){Ta(this.scales,t=>{Ch.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),a=new Set(t.events);(!rk(n,a)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:a,start:o,count:r}of n){const i=a==="_removeElements"?-r:r;Xl0(t,o,i)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,a=r=>new Set(t.filter(i=>i[0]===r).map((i,u)=>u+","+i.splice(1).join(","))),o=a(0);for(let r=1;rr.split(",")).map(r=>({method:r[1],start:+r[2],count:+r[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;Ch.update(this,this.width,this.height,t);const n=this.chartArea,a=n.width<=0||n.height<=0;this._layers=[],Ta(this.boxes,o=>{a&&o.position==="chartArea"||(o.configure&&o.configure(),this._layers.push(...o._layers()))},this),this._layers.forEach((o,r)=>{o._idx=r}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,a=this.data.datasets.length;n=0;--n)this._drawDataset(t[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const n=this.ctx,a=t._clip,o=!a.disabled,r=Jl0(t)||this.chartArea,i={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",i)!==!1&&(o&&NK(n,{left:a.left===!1?0:r.left-a.left,right:a.right===!1?this.width:r.right+a.right,top:a.top===!1?0:r.top-a.top,bottom:a.bottom===!1?this.height:r.bottom+a.bottom}),t.controller.draw(),o&&LK(n),i.cancelable=!1,this.notifyPlugins("afterDatasetDraw",i))}isPointInArea(t){return zK(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,a,o){const r=Gc0.modes[n];return typeof r=="function"?r(this,t,a,o):[]}getDatasetMeta(t){const n=this.data.datasets[t],a=this._metasets;let o=a.filter(r=>r&&r._dataset===n).pop();return o||(o={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:t,_dataset:n,_parsed:[],_sorted:!1},a.push(o)),o}getContext(){return this.$context||(this.$context=ET(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const a=this.getDatasetMeta(t);return typeof a.hidden=="boolean"?!a.hidden:!n.hidden}setDatasetVisibility(t,n){const a=this.getDatasetMeta(t);a.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,a){const o=a?"show":"hide",r=this.getDatasetMeta(t),i=r.controller._resolveAnimations(void 0,o);hM(n)?(r.data[n].hidden=!a,this.update()):(this.setDatasetVisibility(t,a),i.update(r,{visible:a}),this.update(u=>u.datasetIndex===t?o:void 0))}hide(t,n){this._updateVisibility(t,n,!1)}show(t,n){this._updateVisibility(t,n,!0)}_destroyDatasetMeta(t){const n=this._metasets[t];n&&n.controller&&n.controller._destroy(),delete this._metasets[t]}_stop(){let t,n;for(this.stop(),Xs.remove(this),t=0,n=this.data.datasets.length;t