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=fb(r),b=[],T=u.setContext(this.getContext()),f=T.display?T.width:0,S=f/2,z=function(k){return Vl(a,k,f)};let m,L,I,g,D,C,P,j,y,B,Y,H;if(i==="top")m=z(this.bottom),C=this.bottom-A,j=m-S,B=z(t.top)+S,H=t.bottom;else if(i==="bottom")m=z(this.top),B=t.top,H=z(t.bottom)-S,C=m+S,j=this.top+A;else if(i==="left")m=z(this.right),D=this.right-A,P=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,D=m+S,P=this.left+A;else if(n==="x"){if(i==="center")m=z((t.top+t.bottom)/2+.5);else if(s1(i)){const k=Object.keys(i)[0],G=i[k];m=z(this.chart.scales[k].getPixelForValue(G))}B=t.top,H=t.bottom,C=m+S,j=C+A}else if(n==="y"){if(i==="center")m=z((t.left+t.right)/2);else if(s1(i)){const k=Object.keys(i)[0],G=i[k];m=z(this.chart.scales[k].getPixelForValue(G))}D=m-S,P=D-A,y=t.left,Y=t.right}const U=fn(o.ticks.maxTicksLimit,p),q=Math.max(1,Math.ceil(p/U));for(L=0;Lr.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(".");gn.route(r,o,c,u)})}function rd0(e){return"id"in e&&"defaults"in e}class id0{constructor(){this.controllers=new Bh(SO,"datasets",!0),this.elements=new Bh(nJ,"elements"),this.plugins=new Bh(Object,"plugins"),this.scales=new Bh(TL,"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=b6(t);Mn(a["before"+o],[],a),n[t](a),Mn(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 ud0(e){const t={},n=[],a=Object.keys($i.plugins.items);for(let r=0;r1&&o9(e[0].toLowerCase());if(a)return a}throw new Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function r9(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function bd0(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 r9(e,"x",n[0])||r9(e,"y",n[0])}return{}}function Od0(e,t){const n=Jd[e.type]||{scales:{}},a=t.scales||{},o=oC(e.type,t),r=Object.create(null);return Object.keys(a).forEach(i=>{const u=a[i];if(!s1(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=rC(i,u,bd0(i,e),gn.scales[u.type]),l=Ed0(c,o),d=n.scales||{};r[i]=fO(Object.create(null),[{axis:c},u,d[c],d[l]])}),e.data.datasets.forEach(i=>{const u=i.type||e.type,c=i.indexAxis||oC(u,t),d=(Jd[u]||{}).scales||{};Object.keys(d).forEach(p=>{const A=pd0(p,c),b=i[A+"AxisID"]||A;r[b]=r[b]||Object.create(null),fO(r[b],[{axis:A},a[b],d[p]])})}),Object.keys(r).forEach(i=>{const u=r[i];fO(u,[gn.scales[u.type],gn.scale])}),r}function aJ(e){const t=e.options||(e.options={});t.plugins=fn(t.plugins,{}),t.scales=Od0(e,t)}function oJ(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function Md0(e){return e=e||{},e.data=oJ(e.data),aJ(e),e}const i9=new Map,rJ=new Set;function kh(e,t){let n=i9.get(e);return n||(n=t(),i9.set(e,n),rJ.add(n)),n}const hb=(e,t,n)=>{const a=zA(t,n);a!==void 0&&e.add(a)};class Td0{constructor(t){this._config=Md0(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=oJ(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(),aJ(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return kh(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,n){return kh(`${t}.transition.${n}`,()=>[[`datasets.${t}.transitions.${n}`,`transitions.${n}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,n){return kh(`${t}-${n}`,()=>[[`datasets.${t}.elements.${n}`,`datasets.${t}`,`elements.${n}`,""]])}pluginScopeKeys(t){const n=t.id,a=this.type;return kh(`${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=>hb(c,t,p))),d.forEach(p=>hb(c,o,p)),d.forEach(p=>hb(c,Jd[r]||{},p)),d.forEach(p=>hb(c,gn,p)),d.forEach(p=>hb(c,nC,p))});const l=Array.from(c);return l.length===0&&l.push(Object.create(null)),rJ.has(n)&&i.set(n,l),l}chartOptionScopes(){const{options:t,type:n}=this;return[t,Jd[n]||{},gn.datasets[n]||{},{type:n},gn,nC]}resolveNamedOptions(t,n,a,o=[""]){const r={$shared:!0},{resolver:i,subPrefixes:u}=s9(this._resolverCache,t,o);let c=i;if(hd0(i,n)){r.$shared=!1,a=il(a)?a():a;const l=this.createResolver(t,a,u);c=NA(i,a,l)}for(const l of n)r[l]=c[l];return r}createResolver(t,n,a=[""],o){const{resolver:r}=s9(this._resolverCache,t,a);return s1(n)?NA(r,n,void 0,o):r}}function s9(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:M6(t,n),subPrefixes:n.filter(u=>!u.toLowerCase().includes("hover"))},a.set(o,r)),r}const fd0=e=>s1(e)&&Object.getOwnPropertyNames(e).reduce((t,n)=>t||il(e[n]),!1);function hd0(e,t){const{isScriptable:n,isIndexable:a}=HK(e);for(const o of t){const r=n(o),i=a(o),u=(i||r)&&e[o];if(r&&(il(u)||fd0(u))||i&&na(u))return!0}return!1}var md0="4.3.0";const Sd0=["top","bottom","left","right","chartArea"];function u9(e,t){return e==="top"||e==="bottom"||Sd0.indexOf(e)===-1&&t==="x"}function c9(e,t){return function(n,a){return n[e]===a[e]?n[t]-a[t]:n[e]-a[e]}}function l9(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),Mn(n&&n.onComplete,[e],t)}function zd0(e){const t=e.chart,n=t.options.animation;Mn(n&&n.onProgress,[e],t)}function iJ(e){return $K()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const vm={},d9=e=>{const t=iJ(e);return Object.values(vm).filter(n=>n.canvas===t).pop()};function Nd0(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 Ld0(e,t,n,a){return!n||e.type==="mouseout"?null:a?t:e}function Id0(e){const{xScale:t,yScale:n}=e;if(t&&n)return{left:t.left,right:t.right,top:n.top,bottom:n.bottom}}var uc;let S6=(uc=class{static register(...t){$i.add(...t),p9()}static unregister(...t){$i.remove(...t),p9()}constructor(t,n){const a=this.config=new Td0(n),o=iJ(t),r=d9(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||Fl0(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=Vu0(),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 sd0,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=sc0(p=>this.update(p),i.resizeDelay||0),this._dataChanges=[],vm[this.id]=this,!u||!c){console.error("Failed to create chart: can't acquire context from the given item");return}Zs.listen(this,"complete",l9),Zs.listen(this,"progress",zd0),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 $i}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():wk(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return yk(this.canvas,this.ctx),this}stop(){return Zs.stop(this),this}resize(t,n){Zs.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,wk(this,u,!0)&&(this.notifyPlugins("resize",{size:i}),Mn(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=rC(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=rC(c,u),d=fn(u.type,i.dtype);(u.position===void 0||u9(u.position,l)!==u9(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=$i.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=>{xh.configure(this,i,i.options),xh.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