diff --git "a/fracast.DpKYujZ5.js" "b/fracast.DpKYujZ5.js" new file mode 100644--- /dev/null +++ "b/fracast.DpKYujZ5.js" @@ -0,0 +1,18 @@ +var Pr=Object.defineProperty;var Ar=(i,t,e)=>t in i?Pr(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var v=(i,t,e)=>Ar(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&n(r)}).observe(document,{childList:!0,subtree:!0});function e(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(s){if(s.ep)return;s.ep=!0;const o=e(s);fetch(s.href,o)}})();/*! + * @kurkle/color v0.3.4 + * https://github.com/kurkle/color#readme + * (c) 2024 Jukka Kurkela + * Released under the MIT License + */function ze(i){return i+.5|0}const St=(i,t,e)=>Math.max(Math.min(i,e),t);function ge(i){return St(ze(i*2.55),0,255)}function Ot(i){return St(ze(i*255),0,255)}function yt(i){return St(ze(i/2.55)/100,0,1)}function Cn(i){return St(ze(i*100),0,100)}const at={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Ui=[..."0123456789ABCDEF"],Dr=i=>Ui[i&15],Cr=i=>Ui[(i&240)>>4]+Ui[i&15],Ve=i=>(i&240)>>4===(i&15),Or=i=>Ve(i.r)&&Ve(i.g)&&Ve(i.b)&&Ve(i.a);function Tr(i){var t=i.length,e;return i[0]==="#"&&(t===4||t===5?e={r:255&at[i[1]]*17,g:255&at[i[2]]*17,b:255&at[i[3]]*17,a:t===5?at[i[4]]*17:255}:(t===7||t===9)&&(e={r:at[i[1]]<<4|at[i[2]],g:at[i[3]]<<4|at[i[4]],b:at[i[5]]<<4|at[i[6]],a:t===9?at[i[7]]<<4|at[i[8]]:255})),e}const Fr=(i,t)=>i<255?t(i):"";function Er(i){var t=Or(i)?Dr:Cr;return i?"#"+t(i.r)+t(i.g)+t(i.b)+Fr(i.a,t):void 0}const Lr=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function to(i,t,e){const n=t*Math.min(e,1-e),s=(o,r=(o+i/30)%12)=>e-n*Math.max(Math.min(r-3,9-r,1),-1);return[s(0),s(8),s(4)]}function Ir(i,t,e){const n=(s,o=(s+i/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[n(5),n(3),n(1)]}function Rr(i,t,e){const n=to(i,1,.5);let s;for(t+e>1&&(s=1/(t+e),t*=s,e*=s),s=0;s<3;s++)n[s]*=1-t-e,n[s]+=t;return n}function zr(i,t,e,n,s){return i===s?(t-e)/n+(t.5?h/(2-o-r):h/(o+r),l=zr(e,n,s,h,o),l=l*60+.5),[l|0,c||0,a]}function un(i,t,e,n){return(Array.isArray(t)?i(t[0],t[1],t[2]):i(t,e,n)).map(Ot)}function fn(i,t,e){return un(to,i,t,e)}function Br(i,t,e){return un(Rr,i,t,e)}function Wr(i,t,e){return un(Ir,i,t,e)}function eo(i){return(i%360+360)%360}function Nr(i){const t=Lr.exec(i);let e=255,n;if(!t)return;t[5]!==n&&(e=t[6]?ge(+t[5]):Ot(+t[5]));const s=eo(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?n=Br(s,o,r):t[1]==="hsv"?n=Wr(s,o,r):n=fn(s,o,r),{r:n[0],g:n[1],b:n[2],a:e}}function Vr(i,t){var e=dn(i);e[0]=eo(e[0]+t),e=fn(e),i.r=e[0],i.g=e[1],i.b=e[2]}function jr(i){if(!i)return;const t=dn(i),e=t[0],n=Cn(t[1]),s=Cn(t[2]);return i.a<255?`hsla(${e}, ${n}%, ${s}%, ${yt(i.a)})`:`hsl(${e}, ${n}%, ${s}%)`}const On={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},Tn={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function Hr(){const i={},t=Object.keys(Tn),e=Object.keys(On);let n,s,o,r,a;for(n=0;n>16&255,o>>8&255,o&255]}return i}let je;function $r(i){je||(je=Hr(),je.transparent=[0,0,0,0]);const t=je[i.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const Ur=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Yr(i){const t=Ur.exec(i);let e=255,n,s,o;if(t){if(t[7]!==n){const r=+t[7];e=t[8]?ge(r):St(r*255,0,255)}return n=+t[1],s=+t[3],o=+t[5],n=255&(t[2]?ge(n):St(n,0,255)),s=255&(t[4]?ge(s):St(s,0,255)),o=255&(t[6]?ge(o):St(o,0,255)),{r:n,g:s,b:o,a:e}}}function qr(i){return i&&(i.a<255?`rgba(${i.r}, ${i.g}, ${i.b}, ${yt(i.a)})`:`rgb(${i.r}, ${i.g}, ${i.b})`)}const Di=i=>i<=.0031308?i*12.92:Math.pow(i,1/2.4)*1.055-.055,Qt=i=>i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4);function Xr(i,t,e){const n=Qt(yt(i.r)),s=Qt(yt(i.g)),o=Qt(yt(i.b));return{r:Ot(Di(n+e*(Qt(yt(t.r))-n))),g:Ot(Di(s+e*(Qt(yt(t.g))-s))),b:Ot(Di(o+e*(Qt(yt(t.b))-o))),a:i.a+e*(t.a-i.a)}}function He(i,t,e){if(i){let n=dn(i);n[t]=Math.max(0,Math.min(n[t]+n[t]*e,t===0?360:1)),n=fn(n),i.r=n[0],i.g=n[1],i.b=n[2]}}function io(i,t){return i&&Object.assign(t||{},i)}function Fn(i){var t={r:0,g:0,b:0,a:255};return Array.isArray(i)?i.length>=3&&(t={r:i[0],g:i[1],b:i[2],a:255},i.length>3&&(t.a=Ot(i[3]))):(t=io(i,{r:0,g:0,b:0,a:1}),t.a=Ot(t.a)),t}function Kr(i){return i.charAt(0)==="r"?Yr(i):Nr(i)}class Pe{constructor(t){if(t instanceof Pe)return t;const e=typeof t;let n;e==="object"?n=Fn(t):e==="string"&&(n=Tr(t)||$r(t)||Kr(t)),this._rgb=n,this._valid=!!n}get valid(){return this._valid}get rgb(){var t=io(this._rgb);return t&&(t.a=yt(t.a)),t}set rgb(t){this._rgb=Fn(t)}rgbString(){return this._valid?qr(this._rgb):void 0}hexString(){return this._valid?Er(this._rgb):void 0}hslString(){return this._valid?jr(this._rgb):void 0}mix(t,e){if(t){const n=this.rgb,s=t.rgb;let o;const r=e===o?.5:e,a=2*r-1,l=n.a-s.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-c,n.r=255&c*n.r+o*s.r+.5,n.g=255&c*n.g+o*s.g+.5,n.b=255&c*n.b+o*s.b+.5,n.a=r*n.a+(1-r)*s.a,this.rgb=n}return this}interpolate(t,e){return t&&(this._rgb=Xr(this._rgb,t._rgb,e)),this}clone(){return new Pe(this.rgb)}alpha(t){return this._rgb.a=Ot(t),this}clearer(t){const e=this._rgb;return e.a*=1-t,this}greyscale(){const t=this._rgb,e=ze(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=e,this}opaquer(t){const e=this._rgb;return e.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return He(this._rgb,2,t),this}darken(t){return He(this._rgb,2,-t),this}saturate(t){return He(this._rgb,1,t),this}desaturate(t){return He(this._rgb,1,-t),this}rotate(t){return Vr(this._rgb,t),this}}/*! + * Chart.js v4.5.1 + * https://www.chartjs.org + * (c) 2025 Chart.js Contributors + * Released under the MIT License + */function bt(){}const Gr=(()=>{let i=0;return()=>i++})();function O(i){return i==null}function N(i){if(Array.isArray&&Array.isArray(i))return!0;const t=Object.prototype.toString.call(i);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function T(i){return i!==null&&Object.prototype.toString.call(i)==="[object Object]"}function H(i){return(typeof i=="number"||i instanceof Number)&&isFinite(+i)}function rt(i,t){return H(i)?i:t}function A(i,t){return typeof i>"u"?t:i}const Jr=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100:+i/t,no=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100*t:+i;function z(i,t,e){if(i&&typeof i.call=="function")return i.apply(e,t)}function L(i,t,e,n){let s,o,r;if(N(i))for(o=i.length,s=0;si,x:i=>i.x,y:i=>i.y};function ta(i){const t=i.split("."),e=[];let n="";for(const s of t)n+=s,n.endsWith("\\")?n=n.slice(0,-1)+".":(e.push(n),n="");return e}function ea(i){const t=ta(i);return e=>{for(const n of t){if(n==="")break;e=e&&e[n]}return e}}function Ft(i,t){return(En[t]||(En[t]=ea(t)))(i)}function gn(i){return i.charAt(0).toUpperCase()+i.slice(1)}const De=i=>typeof i<"u",Et=i=>typeof i=="function",Ln=(i,t)=>{if(i.size!==t.size)return!1;for(const e of i)if(!t.has(e))return!1;return!0};function ia(i){return i.type==="mouseup"||i.type==="click"||i.type==="contextmenu"}const E=Math.PI,B=2*E,na=B+E,ui=Number.POSITIVE_INFINITY,sa=E/180,U=E/2,zt=E/4,In=E*2/3,Pt=Math.log10,mt=Math.sign;function we(i,t,e){return Math.abs(i-t)s-o).pop(),t}function ra(i){return typeof i=="symbol"||typeof i=="object"&&i!==null&&!(Symbol.toPrimitive in i||"toString"in i||"valueOf"in i)}function ie(i){return!ra(i)&&!isNaN(parseFloat(i))&&isFinite(i)}function aa(i,t){const e=Math.round(i);return e-t<=i&&e+t>=i}function oo(i,t,e){let n,s,o;for(n=0,s=i.length;nl&&c=Math.min(t,e)-n&&i<=Math.max(t,e)+n}function mn(i,t,e){e=e||(r=>i[r]1;)o=s+n>>1,e(o)?s=o:n=o;return{lo:s,hi:n}}const Mt=(i,t,e,n)=>mn(i,e,n?s=>{const o=i[s][t];return oi[s][t]mn(i,e,n=>i[n][t]>=e);function da(i,t,e){let n=0,s=i.length;for(;nn&&i[s-1]>e;)s--;return n>0||s{const n="_onData"+gn(e),s=i[e];Object.defineProperty(i,e,{configurable:!0,enumerable:!1,value(...o){const r=s.apply(this,o);return i._chartjs.listeners.forEach(a=>{typeof a[n]=="function"&&a[n](...o)}),r}})})}function Bn(i,t){const e=i._chartjs;if(!e)return;const n=e.listeners,s=n.indexOf(t);s!==-1&&n.splice(s,1),!(n.length>0)&&(ao.forEach(o=>{delete i[o]}),delete i._chartjs)}function lo(i){const t=new Set(i);return t.size===i.length?i:Array.from(t)}const co=(function(){return typeof window>"u"?function(i){return i()}:window.requestAnimationFrame})();function ho(i,t){let e=[],n=!1;return function(...s){e=s,n||(n=!0,co.call(window,()=>{n=!1,i.apply(t,e)}))}}function fa(i,t){let e;return function(...n){return t?(clearTimeout(e),e=setTimeout(i,t,n)):i.apply(this,n),t}}const bn=i=>i==="start"?"left":i==="end"?"right":"center",Z=(i,t,e)=>i==="start"?t:i==="end"?e:(t+e)/2,ga=(i,t,e,n)=>i===(n?"left":"right")?e:i==="center"?(t+e)/2:t;function uo(i,t,e){const n=t.length;let s=0,o=n;if(i._sorted){const{iScale:r,vScale:a,_parsed:l}=i,c=i.dataset&&i.dataset.options?i.dataset.options.spanGaps:null,h=r.axis,{min:d,max:u,minDefined:f,maxDefined:p}=r.getUserBounds();if(f){if(s=Math.min(Mt(l,h,d).lo,e?n:Mt(t,h,r.getPixelForValue(d)).lo),c){const g=l.slice(0,s+1).reverse().findIndex(m=>!O(m[a.axis]));s-=Math.max(0,g)}s=X(s,0,n-1)}if(p){let g=Math.max(Mt(l,r.axis,u,!0).hi+1,e?0:Mt(t,h,r.getPixelForValue(u),!0).hi+1);if(c){const m=l.slice(g-1).findIndex(b=>!O(b[a.axis]));g+=Math.max(0,m)}o=X(g,s,n)-s}else o=n-s}return{start:s,count:o}}function fo(i){const{xScale:t,yScale:e,_scaleRanges:n}=i,s={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!n)return i._scaleRanges=s,!0;const o=n.xmin!==t.min||n.xmax!==t.max||n.ymin!==e.min||n.ymax!==e.max;return Object.assign(n,s),o}const $e=i=>i===0||i===1,Wn=(i,t,e)=>-(Math.pow(2,10*(i-=1))*Math.sin((i-t)*B/e)),Nn=(i,t,e)=>Math.pow(2,-10*i)*Math.sin((i-t)*B/e)+1,ve={linear:i=>i,easeInQuad:i=>i*i,easeOutQuad:i=>-i*(i-2),easeInOutQuad:i=>(i/=.5)<1?.5*i*i:-.5*(--i*(i-2)-1),easeInCubic:i=>i*i*i,easeOutCubic:i=>(i-=1)*i*i+1,easeInOutCubic:i=>(i/=.5)<1?.5*i*i*i:.5*((i-=2)*i*i+2),easeInQuart:i=>i*i*i*i,easeOutQuart:i=>-((i-=1)*i*i*i-1),easeInOutQuart:i=>(i/=.5)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2),easeInQuint:i=>i*i*i*i*i,easeOutQuint:i=>(i-=1)*i*i*i*i+1,easeInOutQuint:i=>(i/=.5)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2),easeInSine:i=>-Math.cos(i*U)+1,easeOutSine:i=>Math.sin(i*U),easeInOutSine:i=>-.5*(Math.cos(E*i)-1),easeInExpo:i=>i===0?0:Math.pow(2,10*(i-1)),easeOutExpo:i=>i===1?1:-Math.pow(2,-10*i)+1,easeInOutExpo:i=>$e(i)?i:i<.5?.5*Math.pow(2,10*(i*2-1)):.5*(-Math.pow(2,-10*(i*2-1))+2),easeInCirc:i=>i>=1?i:-(Math.sqrt(1-i*i)-1),easeOutCirc:i=>Math.sqrt(1-(i-=1)*i),easeInOutCirc:i=>(i/=.5)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1),easeInElastic:i=>$e(i)?i:Wn(i,.075,.3),easeOutElastic:i=>$e(i)?i:Nn(i,.075,.3),easeInOutElastic(i){return $e(i)?i:i<.5?.5*Wn(i*2,.1125,.45):.5+.5*Nn(i*2-1,.1125,.45)},easeInBack(i){return i*i*((1.70158+1)*i-1.70158)},easeOutBack(i){return(i-=1)*i*((1.70158+1)*i+1.70158)+1},easeInOutBack(i){let t=1.70158;return(i/=.5)<1?.5*(i*i*(((t*=1.525)+1)*i-t)):.5*((i-=2)*i*(((t*=1.525)+1)*i+t)+2)},easeInBounce:i=>1-ve.easeOutBounce(1-i),easeOutBounce(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},easeInOutBounce:i=>i<.5?ve.easeInBounce(i*2)*.5:ve.easeOutBounce(i*2-1)*.5+.5};function xn(i){if(i&&typeof i=="object"){const t=i.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Vn(i){return xn(i)?i:new Pe(i)}function Ci(i){return xn(i)?i:new Pe(i).saturate(.5).darken(.1).hexString()}const pa=["x","y","borderWidth","radius","tension"],ma=["color","borderColor","backgroundColor"];function ba(i){i.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),i.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),i.set("animations",{colors:{type:"color",properties:ma},numbers:{type:"number",properties:pa}}),i.describe("animations",{_fallback:"animation"}),i.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>t|0}}}})}function xa(i){i.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const jn=new Map;function _a(i,t){t=t||{};const e=i+JSON.stringify(t);let n=jn.get(e);return n||(n=new Intl.NumberFormat(i,t),jn.set(e,n)),n}function Be(i,t,e){return _a(t,e).format(i)}const go={values(i){return N(i)?i:""+i},numeric(i,t,e){if(i===0)return"0";const n=this.chart.options.locale;let s,o=i;if(e.length>1){const c=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(c<1e-4||c>1e15)&&(s="scientific"),o=ya(i,e)}const r=Pt(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),l={notation:s,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),Be(i,n,l)},logarithmic(i,t,e){if(i===0)return"0";const n=e[t].significand||i/Math.pow(10,Math.floor(Pt(i)));return[1,2,3,5,10,15].includes(n)||t>.8*e.length?go.numeric.call(this,i,t,e):""}};function ya(i,t){let e=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(e)>=1&&i!==Math.floor(i)&&(e=i-Math.floor(i)),e}var wi={formatters:go};function wa(i){i.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:wi.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),i.route("scale.ticks","color","","color"),i.route("scale.grid","color","","borderColor"),i.route("scale.border","color","","borderColor"),i.route("scale.title","color","","color"),i.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),i.describe("scales",{_fallback:"scale"}),i.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}const Xt=Object.create(null),qi=Object.create(null);function Me(i,t){if(!t)return i;const e=t.split(".");for(let n=0,s=e.length;nn.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(n,s)=>Ci(s.backgroundColor),this.hoverBorderColor=(n,s)=>Ci(s.borderColor),this.hoverColor=(n,s)=>Ci(s.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return Oi(this,t,e)}get(t){return Me(this,t)}describe(t,e){return Oi(qi,t,e)}override(t,e){return Oi(Xt,t,e)}route(t,e,n,s){const o=Me(this,t),r=Me(this,n),a="_"+e;Object.defineProperties(o,{[a]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){const l=this[a],c=r[s];return T(l)?Object.assign({},c,l):A(l,c)},set(l){this[a]=l}}})}apply(t){t.forEach(e=>e(this))}}var V=new va({_scriptable:i=>!i.startsWith("on"),_indexable:i=>i!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[ba,xa,wa]);function Ma(i){return!i||O(i.size)||O(i.family)?null:(i.style?i.style+" ":"")+(i.weight?i.weight+" ":"")+i.size+"px "+i.family}function fi(i,t,e,n,s){let o=t[s];return o||(o=t[s]=i.measureText(s).width,e.push(s)),o>n&&(n=o),n}function ka(i,t,e,n){n=n||{};let s=n.data=n.data||{},o=n.garbageCollect=n.garbageCollect||[];n.font!==t&&(s=n.data={},o=n.garbageCollect=[],n.font=t),i.save(),i.font=t;let r=0;const a=e.length;let l,c,h,d,u;for(l=0;le.length){for(l=0;l0&&i.stroke()}}function kt(i,t,e){return e=e||.5,!t||i&&i.x>t.left-e&&i.xt.top-e&&i.y0&&o.strokeColor!=="";let l,c;for(i.save(),i.font=s.string,Aa(i,o),l=0;l+i||0;function _n(i,t){const e={},n=T(t),s=n?Object.keys(t):t,o=T(i)?n?r=>A(i[r],i[t[r]]):r=>i[r]:()=>i;for(const r of s)e[r]=Ea(o(r));return e}function mo(i){return _n(i,{top:"y",right:"x",bottom:"y",left:"x"})}function $t(i){return _n(i,["topLeft","topRight","bottomLeft","bottomRight"])}function et(i){const t=mo(i);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function q(i,t){i=i||{},t=t||V.font;let e=A(i.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let n=A(i.style,t.style);n&&!(""+n).match(Ta)&&(console.warn('Invalid font style specified: "'+n+'"'),n=void 0);const s={family:A(i.family,t.family),lineHeight:Fa(A(i.lineHeight,t.lineHeight),e),size:e,style:n,weight:A(i.weight,t.weight),string:""};return s.string=Ma(s),s}function pe(i,t,e,n){let s,o,r;for(s=0,o=i.length;se&&a===0?0:a+l;return{min:r(n,-Math.abs(o)),max:r(s,o)}}function Lt(i,t){return Object.assign(Object.create(i),t)}function yn(i,t=[""],e,n,s=()=>i[0]){const o=e||i;typeof n>"u"&&(n=yo("_fallback",i));const r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:i,_rootScopes:o,_fallback:n,_getTarget:s,override:a=>yn([a,...i],t,o,n)};return new Proxy(r,{deleteProperty(a,l){return delete a[l],delete a._keys,delete i[0][l],!0},get(a,l){return xo(a,l,()=>ja(l,t,i,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(i[0])},has(a,l){return Un(a).includes(l)},ownKeys(a){return Un(a)},set(a,l,c){const h=a._storage||(a._storage=s());return a[l]=h[l]=c,delete a._keys,!0}})}function ne(i,t,e,n){const s={_cacheable:!1,_proxy:i,_context:t,_subProxy:e,_stack:new Set,_descriptors:bo(i,n),setContext:o=>ne(i,o,e,n),override:o=>ne(i.override(o),t,e,n)};return new Proxy(s,{deleteProperty(o,r){return delete o[r],delete i[r],!0},get(o,r,a){return xo(o,r,()=>Ra(o,r,a))},getOwnPropertyDescriptor(o,r){return o._descriptors.allKeys?Reflect.has(i,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(i,r)},getPrototypeOf(){return Reflect.getPrototypeOf(i)},has(o,r){return Reflect.has(i,r)},ownKeys(){return Reflect.ownKeys(i)},set(o,r,a){return i[r]=a,delete o[r],!0}})}function bo(i,t={scriptable:!0,indexable:!0}){const{_scriptable:e=t.scriptable,_indexable:n=t.indexable,_allKeys:s=t.allKeys}=i;return{allKeys:s,scriptable:e,indexable:n,isScriptable:Et(e)?e:()=>e,isIndexable:Et(n)?n:()=>n}}const Ia=(i,t)=>i?i+gn(t):t,wn=(i,t)=>T(t)&&i!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function xo(i,t,e){if(Object.prototype.hasOwnProperty.call(i,t)||t==="constructor")return i[t];const n=e();return i[t]=n,n}function Ra(i,t,e){const{_proxy:n,_context:s,_subProxy:o,_descriptors:r}=i;let a=n[t];return Et(a)&&r.isScriptable(t)&&(a=za(t,a,i,e)),N(a)&&a.length&&(a=Ba(t,a,i,r.isIndexable)),wn(t,a)&&(a=ne(a,s,o&&o[t],r)),a}function za(i,t,e,n){const{_proxy:s,_context:o,_subProxy:r,_stack:a}=e;if(a.has(i))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+i);a.add(i);let l=t(o,r||n);return a.delete(i),wn(i,l)&&(l=vn(s._scopes,s,i,l)),l}function Ba(i,t,e,n){const{_proxy:s,_context:o,_subProxy:r,_descriptors:a}=e;if(typeof o.index<"u"&&n(i))return t[o.index%t.length];if(T(t[0])){const l=t,c=s._scopes.filter(h=>h!==l);t=[];for(const h of l){const d=vn(c,s,i,h);t.push(ne(d,o,r&&r[i],a))}}return t}function _o(i,t,e){return Et(i)?i(t,e):i}const Wa=(i,t)=>i===!0?t:typeof i=="string"?Ft(t,i):void 0;function Na(i,t,e,n,s){for(const o of t){const r=Wa(e,o);if(r){i.add(r);const a=_o(r._fallback,e,s);if(typeof a<"u"&&a!==e&&a!==n)return a}else if(r===!1&&typeof n<"u"&&e!==n)return null}return!1}function vn(i,t,e,n){const s=t._rootScopes,o=_o(t._fallback,e,n),r=[...i,...s],a=new Set;a.add(n);let l=$n(a,r,e,o||e,n);return l===null||typeof o<"u"&&o!==e&&(l=$n(a,r,o,l,n),l===null)?!1:yn(Array.from(a),[""],s,o,()=>Va(t,e,n))}function $n(i,t,e,n,s){for(;e;)e=Na(i,t,e,n,s);return e}function Va(i,t,e){const n=i._getTarget();t in n||(n[t]={});const s=n[t];return N(s)&&T(e)?e:s||{}}function ja(i,t,e,n){let s;for(const o of t)if(s=yo(Ia(o,i),e),typeof s<"u")return wn(i,s)?vn(e,n,i,s):s}function yo(i,t){for(const e of t){if(!e)continue;const n=e[i];if(typeof n<"u")return n}}function Un(i){let t=i._keys;return t||(t=i._keys=Ha(i._scopes)),t}function Ha(i){const t=new Set;for(const e of i)for(const n of Object.keys(e).filter(s=>!s.startsWith("_")))t.add(n);return Array.from(t)}function wo(i,t,e,n){const{iScale:s}=i,{key:o="r"}=this._parsing,r=new Array(n);let a,l,c,h;for(a=0,l=n;ati==="x"?"y":"x";function Ua(i,t,e,n){const s=i.skip?t:i,o=t,r=e.skip?t:e,a=Yi(o,s),l=Yi(r,o);let c=a/(a+l),h=l/(a+l);c=isNaN(c)?0:c,h=isNaN(h)?0:h;const d=n*c,u=n*h;return{previous:{x:o.x-d*(r.x-s.x),y:o.y-d*(r.y-s.y)},next:{x:o.x+u*(r.x-s.x),y:o.y+u*(r.y-s.y)}}}function Ya(i,t,e){const n=i.length;let s,o,r,a,l,c=se(i,0);for(let h=0;h!c.skip)),t.cubicInterpolationMode==="monotone")Xa(i,s);else{let c=n?i[i.length-1]:i[0];for(o=0,r=i.length;oi.ownerDocument.defaultView.getComputedStyle(i,null);function Ja(i,t){return ki(i).getPropertyValue(t)}const Za=["top","right","bottom","left"];function Ut(i,t,e){const n={};e=e?"-"+e:"";for(let s=0;s<4;s++){const o=Za[s];n[o]=parseFloat(i[t+"-"+o+e])||0}return n.width=n.left+n.right,n.height=n.top+n.bottom,n}const Qa=(i,t,e)=>(i>0||t>0)&&(!e||!e.shadowRoot);function tl(i,t){const e=i.touches,n=e&&e.length?e[0]:i,{offsetX:s,offsetY:o}=n;let r=!1,a,l;if(Qa(s,o,i.target))a=s,l=o;else{const c=t.getBoundingClientRect();a=n.clientX-c.left,l=n.clientY-c.top,r=!0}return{x:a,y:l,box:r}}function Vt(i,t){if("native"in i)return i;const{canvas:e,currentDevicePixelRatio:n}=t,s=ki(e),o=s.boxSizing==="border-box",r=Ut(s,"padding"),a=Ut(s,"border","width"),{x:l,y:c,box:h}=tl(i,e),d=r.left+(h&&a.left),u=r.top+(h&&a.top);let{width:f,height:p}=t;return o&&(f-=r.width+a.width,p-=r.height+a.height),{x:Math.round((l-d)/f*e.width/n),y:Math.round((c-u)/p*e.height/n)}}function el(i,t,e){let n,s;if(t===void 0||e===void 0){const o=i&&kn(i);if(!o)t=i.clientWidth,e=i.clientHeight;else{const r=o.getBoundingClientRect(),a=ki(o),l=Ut(a,"border","width"),c=Ut(a,"padding");t=r.width-c.width-l.width,e=r.height-c.height-l.height,n=gi(a.maxWidth,o,"clientWidth"),s=gi(a.maxHeight,o,"clientHeight")}}return{width:t,height:e,maxWidth:n||ui,maxHeight:s||ui}}const At=i=>Math.round(i*10)/10;function il(i,t,e,n){const s=ki(i),o=Ut(s,"margin"),r=gi(s.maxWidth,i,"clientWidth")||ui,a=gi(s.maxHeight,i,"clientHeight")||ui,l=el(i,t,e);let{width:c,height:h}=l;if(s.boxSizing==="content-box"){const u=Ut(s,"border","width"),f=Ut(s,"padding");c-=f.width+u.width,h-=f.height+u.height}return c=Math.max(0,c-o.width),h=Math.max(0,n?c/n:h-o.height),c=At(Math.min(c,r,l.maxWidth)),h=At(Math.min(h,a,l.maxHeight)),c&&!h&&(h=At(c/2)),(t!==void 0||e!==void 0)&&n&&l.height&&h>l.height&&(h=l.height,c=At(Math.floor(h*n))),{width:c,height:h}}function Yn(i,t,e){const n=t||1,s=At(i.height*n),o=At(i.width*n);i.height=At(i.height),i.width=At(i.width);const r=i.canvas;return r.style&&(e||!r.style.height&&!r.style.width)&&(r.style.height=`${i.height}px`,r.style.width=`${i.width}px`),i.currentDevicePixelRatio!==n||r.height!==s||r.width!==o?(i.currentDevicePixelRatio=n,r.height=s,r.width=o,i.ctx.setTransform(n,0,0,n,0,0),!0):!1}const nl=(function(){let i=!1;try{const t={get passive(){return i=!0,!1}};Mn()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return i})();function qn(i,t){const e=Ja(i,t),n=e&&e.match(/^(\d+)(\.\d+)?px$/);return n?+n[1]:void 0}function jt(i,t,e,n){return{x:i.x+e*(t.x-i.x),y:i.y+e*(t.y-i.y)}}function sl(i,t,e,n){return{x:i.x+e*(t.x-i.x),y:n==="middle"?e<.5?i.y:t.y:n==="after"?e<1?i.y:t.y:e>0?t.y:i.y}}function ol(i,t,e,n){const s={x:i.cp2x,y:i.cp2y},o={x:t.cp1x,y:t.cp1y},r=jt(i,s,e),a=jt(s,o,e),l=jt(o,t,e),c=jt(r,a,e),h=jt(a,l,e);return jt(c,h,e)}const rl=function(i,t){return{x(e){return i+i+t-e},setWidth(e){t=e},textAlign(e){return e==="center"?e:e==="right"?"left":"right"},xPlus(e,n){return e-n},leftForLtr(e,n){return e-n}}},al=function(){return{x(i){return i},setWidth(i){},textAlign(i){return i},xPlus(i,t){return i+t},leftForLtr(i,t){return i}}};function ee(i,t,e){return i?rl(t,e):al()}function Mo(i,t){let e,n;(t==="ltr"||t==="rtl")&&(e=i.canvas.style,n=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),i.prevTextDirection=n)}function ko(i,t){t!==void 0&&(delete i.prevTextDirection,i.canvas.style.setProperty("direction",t[0],t[1]))}function So(i){return i==="angle"?{between:Ce,compare:la,normalize:Q}:{between:vt,compare:(t,e)=>t-e,normalize:t=>t}}function Xn({start:i,end:t,count:e,loop:n,style:s}){return{start:i%e,end:t%e,loop:n&&(t-i+1)%e===0,style:s}}function ll(i,t,e){const{property:n,start:s,end:o}=e,{between:r,normalize:a}=So(n),l=t.length;let{start:c,end:h,loop:d}=i,u,f;if(d){for(c+=l,h+=l,u=0,f=l;ul(s,y,b)&&a(s,y)!==0,_=()=>a(o,b)===0||l(o,y,b),M=()=>g||w(),k=()=>!g||_();for(let S=h,P=h;S<=d;++S)x=t[S%r],!x.skip&&(b=c(x[n]),b!==y&&(g=l(b,s,o),m===null&&M()&&(m=a(b,s)===0?S:P),m!==null&&k()&&(p.push(Xn({start:m,end:S,loop:u,count:r,style:f})),m=null),P=S,y=b));return m!==null&&p.push(Xn({start:m,end:d,loop:u,count:r,style:f})),p}function Ao(i,t){const e=[],n=i.segments;for(let s=0;ss&&i[o%t].skip;)o--;return o%=t,{start:s,end:o}}function hl(i,t,e,n){const s=i.length,o=[];let r=t,a=i[t],l;for(l=t+1;l<=e;++l){const c=i[l%s];c.skip||c.stop?a.skip||(n=!1,o.push({start:t%s,end:(l-1)%s,loop:n}),t=r=c.stop?l:null):(r=l,a.skip&&(t=l)),a=c}return r!==null&&o.push({start:t%s,end:r%s,loop:n}),o}function dl(i,t){const e=i.points,n=i.options.spanGaps,s=e.length;if(!s)return[];const o=!!i._loop,{start:r,end:a}=cl(e,s,o,n);if(n===!0)return Kn(i,[{start:r,end:a,loop:o}],e,t);const l=aa({chart:t,initial:e.initial,numSteps:r,currentStep:Math.min(n-e.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=co.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((n,s)=>{if(!n.running||!n.items.length)return;const o=n.items;let r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>n.duration&&(n.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(s.draw(),this._notify(s,n,t,"progress")),o.length||(n.running=!1,this._notify(s,n,t,"complete"),n.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){const e=this._charts;let n=e.get(t);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,n)),n}listen(t,e,n){this._getAnims(t).listeners[e].push(n)}add(t,e){!e||!e.length||this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((n,s)=>Math.max(n,s._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!(!e||!e.running||!e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const n=e.items;let s=n.length-1;for(;s>=0;--s)n[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var xt=new pl;const Jn="transparent",ml={boolean(i,t,e){return e>.5?t:i},color(i,t,e){const n=Vn(i||Jn),s=n.valid&&Vn(t||Jn);return s&&s.valid?s.mix(n,e).hexString():t},number(i,t,e){return i+(t-i)*e}};class bl{constructor(t,e,n,s){const o=e[n];s=pe([t.to,s,o,t.from]);const r=pe([t.from,o,s]);this._active=!0,this._fn=t.fn||ml[t.type||typeof r],this._easing=ve[t.easing]||ve.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=n,this._from=r,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,n){if(this._active){this._notify(!1);const s=this._target[this._prop],o=n-this._start,r=this._duration-o;this._start=n,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=pe([t.to,e,s,t.from]),this._from=pe([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,n=this._duration,s=this._prop,o=this._from,r=this._loop,a=this._to;let l;if(this._active=o!==a&&(r||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,n)=>{t.push({res:e,rej:n})})}_notify(t){const e=t?"res":"rej",n=this._promises||[];for(let s=0;s{const o=t[s];if(!T(o))return;const r={};for(const a of e)r[a]=o[a];(N(o.properties)&&o.properties||[s]).forEach(a=>{(a===s||!n.has(a))&&n.set(a,r)})})}_animateOptions(t,e){const n=e.options,s=_l(t,n);if(!s)return[];const o=this._createAnimations(s,n);return n.$shared&&xl(t.options.$animations,n).then(()=>{t.options=n},()=>{}),o}_createAnimations(t,e){const n=this._properties,s=[],o=t.$animations||(t.$animations={}),r=Object.keys(e),a=Date.now();let l;for(l=r.length-1;l>=0;--l){const c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){s.push(...this._animateOptions(t,e));continue}const h=e[c];let d=o[c];const u=n.get(c);if(d)if(u&&d.active()){d.update(u,h,a);continue}else d.cancel();if(!u||!u.duration){t[c]=h;continue}o[c]=d=new bl(u,t,c,h),s.push(d)}return s}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}const n=this._createAnimations(t,e);if(n.length)return xt.add(this._chart,n),!0}}function xl(i,t){const e=[],n=Object.keys(t);for(let s=0;s0||!e&&o<0)return s.index}return null}function es(i,t){const{chart:e,_cachedMeta:n}=i,s=e._stacks||(e._stacks={}),{iScale:o,vScale:r,index:a}=n,l=o.axis,c=r.axis,h=Ml(o,r,n),d=t.length;let u;for(let f=0;fe[n].axis===t).shift()}function Pl(i,t){return Lt(i,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function Al(i,t,e){return Lt(i,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function le(i,t){const e=i.controller.index,n=i.vScale&&i.vScale.axis;if(n){t=t||i._parsed;for(const s of t){const o=s._stacks;if(!o||o[n]===void 0||o[n][e]===void 0)return;delete o[n][e],o[n]._visualValues!==void 0&&o[n]._visualValues[e]!==void 0&&delete o[n]._visualValues[e]}}}const Ei=i=>i==="reset"||i==="none",is=(i,t)=>t?i:Object.assign({},i),Dl=(i,t,e)=>i&&!t.hidden&&t._stacked&&{keys:Oo(e,!0),values:null};class ht{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=Ti(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&&le(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,n=this.getDataset(),s=(d,u,f,p)=>d==="x"?u:d==="r"?p:f,o=e.xAxisID=A(n.xAxisID,Fi(t,"x")),r=e.yAxisID=A(n.yAxisID,Fi(t,"y")),a=e.rAxisID=A(n.rAxisID,Fi(t,"r")),l=e.indexAxis,c=e.iAxisID=s(l,o,r,a),h=e.vAxisID=s(l,r,o,a);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(r),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(c),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&Bn(this._data,this),t._stacked&&le(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),n=this._data;if(T(e)){const s=this._cachedMeta;this._data=vl(e,s)}else if(n!==e){if(n){Bn(n,this);const s=this._cachedMeta;le(s),s._parsed=[]}e&&Object.isExtensible(e)&&ua(e,this),this._syncList=[],this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,n=this.getDataset();let s=!1;this._dataCheck();const o=e._stacked;e._stacked=Ti(e.vScale,e),e.stack!==n.stack&&(s=!0,le(e),e.stack=n.stack),this._resyncElements(t),(s||o!==e._stacked)&&(es(this,e._parsed),e._stacked=Ti(e.vScale,e))}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),n=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:n,_data:s}=this,{iScale:o,_stacked:r}=n,a=o.axis;let l=t===0&&e===s.length?!0:n._sorted,c=t>0&&n._parsed[t-1],h,d,u;if(this._parsing===!1)n._parsed=s,n._sorted=!0,u=s;else{N(s[t])?u=this.parseArrayData(n,s,t,e):T(s[t])?u=this.parseObjectData(n,s,t,e):u=this.parsePrimitiveData(n,s,t,e);const f=()=>d[a]===null||c&&d[a]g||d=0;--u)if(!p()){this.updateRangeFromParsed(c,t,f,l);break}}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,n=[];let s,o,r;for(s=0,o=e.length;s=0&&tthis.getContext(n,s,e),g=c.resolveNamedOptions(u,f,p,d);return g.$shared&&(g.$shared=l,o[r]=Object.freeze(is(g,l))),g}_resolveAnimations(t,e,n){const s=this.chart,o=this._cachedDataOpts,r=`animation-${e}`,a=o[r];if(a)return a;let l;if(s.options.animation!==!1){const h=this.chart.config,d=h.datasetAnimationScopeKeys(this._type,e),u=h.getOptionScopes(this.getDataset(),d);l=h.createResolver(u,this.getContext(t,n,e))}const c=new Co(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||Ei(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const n=this.resolveDataElementOptions(t,e),s=this._sharedOptions,o=this.getSharedOptions(n),r=this.includeOptions(e,o)||o!==s;return this.updateSharedOptions(o,e,n),{sharedOptions:o,includeOptions:r}}updateElement(t,e,n,s){Ei(s)?Object.assign(t,n):this._resolveAnimations(e,s).update(t,n)}updateSharedOptions(t,e,n){t&&!Ei(e)&&this._resolveAnimations(void 0,e).update(t,n)}_setStyle(t,e,n,s){t.active=s;const o=this.getStyle(e,s);this._resolveAnimations(e,n,s).update(t,{options:!s&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,n){this._setStyle(t,n,"active",!1)}setHoverStyle(t,e,n){this._setStyle(t,n,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,n=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const s=n.length,o=e.length,r=Math.min(o,s);r&&this.parse(0,r),o>s?this._insertElements(s,o-s,t):o{for(c.length+=e,a=c.length-1;a>=r;a--)c[a]=c[a-e]};for(l(o),a=t;as-o))}return i._cache.$bar}function Ol(i){const t=i.iScale,e=Cl(t,i.type);let n=t._length,s,o,r,a;const l=()=>{r===32767||r===-32768||(De(a)&&(n=Math.min(n,Math.abs(r-a)||n)),a=r)};for(s=0,o=e.length;s0?s[i-1]:null,a=iMath.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 To(i,t,e,n){return N(i)?El(i,t,e,n):t[e.axis]=e.parse(i,n),t}function ns(i,t,e,n){const s=i.iScale,o=i.vScale,r=s.getLabels(),a=s===o,l=[];let c,h,d,u;for(c=e,h=e+n;c=e?1:-1)}function Il(i){let t,e,n,s,o;return i.horizontal?(t=i.base>i.x,e="left",n="right"):(t=i.baseh.controller.options.grouped),o=n.options.stacked,r=[],a=this._cachedMeta.controller.getParsed(e),l=a&&a[n.axis],c=h=>{const d=h._parsed.find(f=>f[n.axis]===l),u=d&&d[h.vScale.axis];if(O(u)||isNaN(u))return!0};for(const h of s)if(!(e!==void 0&&c(h))&&((o===!1||r.indexOf(h.stack)===-1||o===void 0&&h.stack===void 0)&&r.push(h.stack),h.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,e=this.chart.options.indexAxis;return Object.keys(t).filter(n=>t[n].axis===e).shift()}_getAxis(){const t={},e=this.getFirstScaleIdForIndexAxis();for(const n of this.chart.data.datasets)t[A(this.chart.options.indexAxis==="x"?n.xAxisID:n.yAxisID,e)]=!0;return Object.keys(t)}_getStackIndex(t,e,n){const s=this._getStacks(t,n),o=e!==void 0?s.indexOf(e):-1;return o===-1?s.length-1:o}_getRuler(){const t=this.options,e=this._cachedMeta,n=e.iScale,s=[];let o,r;for(o=0,r=e.data.length;o=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart.data.labels||[],{xScale:s,yScale:o}=e,r=this.getParsed(t),a=s.getLabelForValue(r.x),l=o.getLabelForValue(r.y),c=r._custom;return{label:n[t]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,n,s){const o=s==="reset",{iScale:r,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(e,s),h=r.axis,d=a.axis;for(let u=e;uCe(y,a,l,!0)?1:Math.max(w,w*e,_,_*e),p=(y,w,_)=>Ce(y,a,l,!0)?-1:Math.min(w,w*e,_,_*e),g=f(0,c,d),m=f(U,h,u),b=p(E,c,d),x=p(E+U,h,u);n=(g-b)/2,s=(m-x)/2,o=-(g+b)/2,r=-(m+x)/2}return{ratioX:n,ratioY:s,offsetX:o,offsetY:r}}class Ht extends ht{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const n=this.getDataset().data,s=this._cachedMeta;if(this._parsing===!1)s._parsed=n;else{let o=l=>+n[l];if(T(n[t])){const{key:l="value"}=this._parsing;o=c=>+Ft(n[c],l)}let r,a;for(r=t,a=t+e;r0&&!isNaN(t)?B*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart,s=n.data.labels||[],o=Be(e._parsed[t],n.options.locale);return{label:s[t]||"",value:o}}getMaxBorderWidth(t){let e=0;const n=this.chart;let s,o,r,a,l;if(!t){for(s=0,o=n.data.datasets.length;st!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),v(Ht,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data,{labels:{pointStyle:n,textAlign:s,color:o,useBorderRadius:r,borderRadius:a}}=t.legend.options;return e.labels.length&&e.datasets.length?e.labels.map((l,c)=>{const d=t.getDatasetMeta(0).controller.getStyle(c);return{text:l,fillStyle:d.backgroundColor,fontColor:o,hidden:!t.getDataVisibility(c),lineDash:d.borderDash,lineDashOffset:d.borderDashOffset,lineJoin:d.borderJoinStyle,lineWidth:d.borderWidth,strokeStyle:d.borderColor,textAlign:s,pointStyle:n,borderRadius:r&&(a||d.borderRadius),index:c}}):[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}}});class ni extends ht{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:n,data:s=[],_dataset:o}=e,r=this.chart._animationsDisabled;let{start:a,count:l}=uo(e,s,r);this._drawStart=a,this._drawCount=l,fo(e)&&(a=0,l=s.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!o._decimated,n.points=s;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(n,void 0,{animated:!r,options:c},t),this.updateElements(s,a,l,t)}updateElements(t,e,n,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:h,includeOptions:d}=this._getSharedOptions(e,s),u=r.axis,f=a.axis,{spanGaps:p,segment:g}=this.options,m=ie(p)?p:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||s==="none",x=e+n,y=t.length;let w=e>0&&this.getParsed(e-1);for(let _=0;_=x){k.skip=!0;continue}const S=this.getParsed(_),P=O(S[f]),D=k[u]=r.getPixelForValue(S[u],_),C=k[f]=o||P?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,S,l):S[f],_);k.skip=isNaN(D)||isNaN(C)||P,k.stop=_>0&&Math.abs(S[u]-w[u])>m,g&&(k.parsed=S,k.raw=c.data[_]),d&&(k.options=h||this.resolveDataElementOptions(_,M.active?"active":s)),b||this.updateElement(M,_,k,s),w=S}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,n=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return n;const o=s[0].size(this.resolveDataElementOptions(0)),r=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(n,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}v(ni,"id","line"),v(ni,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),v(ni,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class ke extends ht{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,n=this.chart,s=n.data.labels||[],o=Be(e._parsed[t].r,n.options.locale);return{label:s[t]||"",value:o}}parseObjectData(t,e,n,s){return wo.bind(this)(t,e,n,s)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((n,s)=>{const o=this.getParsed(s).r;!isNaN(o)&&this.chart.getDataVisibility(s)&&(oe.max&&(e.max=o))}),e}_updateRadius(){const t=this.chart,e=t.chartArea,n=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(s/2,0),r=Math.max(n.cutoutPercentage?o/100*n.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,n,s){const o=s==="reset",r=this.chart,l=r.options.animation,c=this._cachedMeta.rScale,h=c.xCenter,d=c.yCenter,u=c.getIndexAngle(0)-.5*E;let f=u,p;const g=360/this.countVisibleElements();for(p=0;p{!isNaN(this.getParsed(s).r)&&this.chart.getDataVisibility(s)&&e++}),e}_computeAngle(t,e,n){return this.chart.getDataVisibility(t)?ct(this.resolveDataElementOptions(t,e).angle||n):0}}v(ke,"id","polarArea"),v(ke,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),v(ke,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:n,color:s}}=t.legend.options;return e.labels.map((o,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:n,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class Ki extends Ht{}v(Ki,"id","pie"),v(Ki,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});class si extends ht{getLabelAndValue(t){const e=this._cachedMeta.vScale,n=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(n[e.axis])}}parseObjectData(t,e,n,s){return wo.bind(this)(t,e,n,s)}update(t){const e=this._cachedMeta,n=e.dataset,s=e.data||[],o=e.iScale.getLabels();if(n.points=s,t!=="resize"){const r=this.resolveDatasetElementOptions(t);this.options.showLine||(r.borderWidth=0);const a={_loop:!0,_fullLoop:o.length===s.length,options:r};this.updateElement(n,void 0,a,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,n,s){const o=this._cachedMeta.rScale,r=s==="reset";for(let a=e;a0&&this.getParsed(e-1);for(let w=e;w0&&Math.abs(M[f]-y[f])>b,m&&(k.parsed=M,k.raw=c.data[w]),u&&(k.options=d||this.resolveDataElementOptions(w,_.active?"active":s)),x||this.updateElement(_,w,k,s),y=M}this.updateSharedOptions(d,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let a=0;for(let l=e.length-1;l>=0;--l)a=Math.max(a,e[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}const n=t.dataset,s=n.options&&n.options.borderWidth||0;if(!e.length)return s;const o=e[0].size(this.resolveDataElementOptions(0)),r=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(s,o,r)/2}}v(oi,"id","scatter"),v(oi,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),v(oi,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});var Nl=Object.freeze({__proto__:null,BarController:ei,BubbleController:ii,DoughnutController:Ht,LineController:ni,PieController:Ki,PolarAreaController:ke,RadarController:si,ScatterController:oi});function Wt(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Sn{constructor(t){v(this,"options");this.options=t||{}}static override(t){Object.assign(Sn.prototype,t)}init(){}formats(){return Wt()}parse(){return Wt()}format(){return Wt()}add(){return Wt()}diff(){return Wt()}startOf(){return Wt()}endOf(){return Wt()}}var Vl={_date:Sn};function jl(i,t,e,n){const{controller:s,data:o,_sorted:r}=i,a=s._cachedMeta.iScale,l=i.dataset&&i.dataset.options?i.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&r&&o.length){const c=a._reversePixels?ha:Mt;if(n){if(s._sharedOptions){const h=o[0],d=typeof h.getRange=="function"&&h.getRange(t);if(d){const u=c(o,t,e-d),f=c(o,t,e+d);return{lo:u.lo,hi:f.hi}}}}else{const h=c(o,t,e);if(l){const{vScale:d}=s._cachedMeta,{_parsed:u}=i,f=u.slice(0,h.lo+1).reverse().findIndex(g=>!O(g[d.axis]));h.lo-=Math.max(0,f);const p=u.slice(h.hi).findIndex(g=>!O(g[d.axis]));h.hi+=Math.max(0,p)}return h}}return{lo:0,hi:o.length-1}}function Si(i,t,e,n,s){const o=i.getSortedVisibleDatasetMetas(),r=e[t];for(let a=0,l=o.length;a{l[r]&&l[r](t[e],s)&&(o.push({element:l,datasetIndex:c,index:h}),a=a||l.inRange(t.x,t.y,s))}),n&&!a?[]:o}var Yl={modes:{index(i,t,e,n){const s=Vt(t,i),o=e.axis||"x",r=e.includeInvisible||!1,a=e.intersect?Ii(i,s,o,n,r):Ri(i,s,o,!1,n,r),l=[];return a.length?(i.getSortedVisibleDatasetMetas().forEach(c=>{const h=a[0].index,d=c.data[h];d&&!d.skip&&l.push({element:d,datasetIndex:c.index,index:h})}),l):[]},dataset(i,t,e,n){const s=Vt(t,i),o=e.axis||"xy",r=e.includeInvisible||!1;let a=e.intersect?Ii(i,s,o,n,r):Ri(i,s,o,!1,n,r);if(a.length>0){const l=a[0].datasetIndex,c=i.getDatasetMeta(l).data;a=[];for(let h=0;he.pos===t)}function as(i,t){return i.filter(e=>Fo.indexOf(e.pos)===-1&&e.box.axis===t)}function he(i,t){return i.sort((e,n)=>{const s=t?n:e,o=t?e:n;return s.weight===o.weight?s.index-o.index:s.weight-o.weight})}function ql(i){const t=[];let e,n,s,o,r,a;for(e=0,n=(i||[]).length;ec.box.fullSize),!0),n=he(ce(t,"left"),!0),s=he(ce(t,"right")),o=he(ce(t,"top"),!0),r=he(ce(t,"bottom")),a=as(t,"x"),l=as(t,"y");return{fullSize:e,leftAndTop:n.concat(o),rightAndBottom:s.concat(l).concat(r).concat(a),chartArea:ce(t,"chartArea"),vertical:n.concat(s).concat(l),horizontal:o.concat(r).concat(a)}}function ls(i,t,e,n){return Math.max(i[e],t[e])+Math.max(i[n],t[n])}function Eo(i,t){i.top=Math.max(i.top,t.top),i.left=Math.max(i.left,t.left),i.bottom=Math.max(i.bottom,t.bottom),i.right=Math.max(i.right,t.right)}function Jl(i,t,e,n){const{pos:s,box:o}=e,r=i.maxPadding;if(!T(s)){e.size&&(i[s]-=e.size);const d=n[e.stack]||{size:0,count:1};d.size=Math.max(d.size,e.horizontal?o.height:o.width),e.size=d.size/d.count,i[s]+=e.size}o.getPadding&&Eo(r,o.getPadding());const a=Math.max(0,t.outerWidth-ls(r,i,"left","right")),l=Math.max(0,t.outerHeight-ls(r,i,"top","bottom")),c=a!==i.w,h=l!==i.h;return i.w=a,i.h=l,e.horizontal?{same:c,other:h}:{same:h,other:c}}function Zl(i){const t=i.maxPadding;function e(n){const s=Math.max(t[n]-i[n],0);return i[n]+=s,s}i.y+=e("top"),i.x+=e("left"),e("right"),e("bottom")}function Ql(i,t){const e=t.maxPadding;function n(s){const o={left:0,top:0,right:0,bottom:0};return s.forEach(r=>{o[r]=Math.max(t[r],e[r])}),o}return n(i?["left","right"]:["top","bottom"])}function me(i,t,e,n){const s=[];let o,r,a,l,c,h;for(o=0,r=i.length,c=0;o{typeof g.beforeLayout=="function"&&g.beforeLayout()});const h=l.reduce((g,m)=>m.box.options&&m.box.options.display===!1?g:g+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:e,padding:s,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/h,hBoxMaxHeight:r/2}),u=Object.assign({},s);Eo(u,et(n));const f=Object.assign({maxPadding:u,w:o,h:r,x:s.left,y:s.top},s),p=Kl(l.concat(c),d);me(a.fullSize,f,d,p),me(l,f,d,p),me(c,f,d,p)&&me(l,f,d,p),Zl(f),cs(a.leftAndTop,f,d,p),f.x+=f.w,f.y+=f.h,cs(a.rightAndBottom,f,d,p),i.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},L(a.chartArea,g=>{const m=g.box;Object.assign(m,i.chartArea),m.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}};class Lo{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,n){}removeEventListener(t,e,n){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,n,s){return e=Math.max(0,e||t.width),n=n||t.height,{width:e,height:Math.max(0,s?Math.floor(e/s):n)}}isAttached(t){return!0}updateConfig(t){}}class tc extends Lo{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const ri="$chartjs",ec={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},hs=i=>i===null||i==="";function ic(i,t){const e=i.style,n=i.getAttribute("height"),s=i.getAttribute("width");if(i[ri]={initial:{height:n,width:s,style:{display:e.display,height:e.height,width:e.width}}},e.display=e.display||"block",e.boxSizing=e.boxSizing||"border-box",hs(s)){const o=qn(i,"width");o!==void 0&&(i.width=o)}if(hs(n))if(i.style.height==="")i.height=i.width/(t||2);else{const o=qn(i,"height");o!==void 0&&(i.height=o)}return i}const Io=nl?{passive:!0}:!1;function nc(i,t,e){i&&i.addEventListener(t,e,Io)}function sc(i,t,e){i&&i.canvas&&i.canvas.removeEventListener(t,e,Io)}function oc(i,t){const e=ec[i.type]||i.type,{x:n,y:s}=Vt(i,t);return{type:e,chart:t,native:i,x:n!==void 0?n:null,y:s!==void 0?s:null}}function pi(i,t){for(const e of i)if(e===t||e.contains(t))return!0}function rc(i,t,e){const n=i.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||pi(a.addedNodes,n),r=r&&!pi(a.removedNodes,n);r&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}function ac(i,t,e){const n=i.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||pi(a.removedNodes,n),r=r&&!pi(a.addedNodes,n);r&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}const Te=new Map;let ds=0;function Ro(){const i=window.devicePixelRatio;i!==ds&&(ds=i,Te.forEach((t,e)=>{e.currentDevicePixelRatio!==i&&t()}))}function lc(i,t){Te.size||window.addEventListener("resize",Ro),Te.set(i,t)}function cc(i){Te.delete(i),Te.size||window.removeEventListener("resize",Ro)}function hc(i,t,e){const n=i.canvas,s=n&&kn(n);if(!s)return;const o=ho((a,l)=>{const c=s.clientWidth;e(a,l),c{const l=a[0],c=l.contentRect.width,h=l.contentRect.height;c===0&&h===0||o(c,h)});return r.observe(s),lc(i,o),r}function zi(i,t,e){e&&e.disconnect(),t==="resize"&&cc(i)}function dc(i,t,e){const n=i.canvas,s=ho(o=>{i.ctx!==null&&e(oc(o,i))},i);return nc(n,t,s),s}class uc extends Lo{acquireContext(t,e){const n=t&&t.getContext&&t.getContext("2d");return n&&n.canvas===t?(ic(t,e),n):null}releaseContext(t){const e=t.canvas;if(!e[ri])return!1;const n=e[ri].initial;["height","width"].forEach(o=>{const r=n[o];O(r)?e.removeAttribute(o):e.setAttribute(o,r)});const s=n.style||{};return Object.keys(s).forEach(o=>{e.style[o]=s[o]}),e.width=e.width,delete e[ri],!0}addEventListener(t,e,n){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),r={attach:rc,detach:ac,resize:hc}[e]||dc;s[e]=r(t,e,n)}removeEventListener(t,e){const n=t.$proxies||(t.$proxies={}),s=n[e];if(!s)return;({attach:zi,detach:zi,resize:zi}[e]||sc)(t,e,s),n[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,n,s){return il(t,e,n,s)}isAttached(t){const e=t&&kn(t);return!!(e&&e.isConnected)}}function fc(i){return!Mn()||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?tc:uc}class dt{constructor(){v(this,"x");v(this,"y");v(this,"active",!1);v(this,"options");v(this,"$animations")}tooltipPosition(t){const{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}hasValue(){return ie(this.x)&&ie(this.y)}getProps(t,e){const n=this.$animations;if(!e||!n)return this;const s={};return t.forEach(o=>{s[o]=n[o]&&n[o].active()?n[o]._to:this[o]}),s}}v(dt,"defaults",{}),v(dt,"defaultRoutes");function gc(i,t){const e=i.options.ticks,n=pc(i),s=Math.min(e.maxTicksLimit||n,n),o=e.major.enabled?bc(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>s)return xc(t,c,o,r/s),c;const h=mc(o,t,s);if(r>0){let d,u;const f=r>1?Math.round((l-a)/(r-1)):null;for(Xe(t,c,h,O(f)?0:a-f,a),d=0,u=r-1;ds)return l}return Math.max(s,1)}function bc(i){const t=[];let e,n;for(e=0,n=i.length;ei==="left"?"right":i==="right"?"left":i,us=(i,t,e)=>t==="top"||t==="left"?i[t]+e:i[t]-e,fs=(i,t)=>Math.min(t||i,i);function gs(i,t){const e=[],n=i.length/t,s=i.length;let o=0;for(;or+a)))return l}function vc(i,t){L(i,e=>{const n=e.gc,s=n.length/2;let o;if(s>t){for(o=0;on?n:e,n=s&&e>n?e:n,{min:rt(e,rt(n,e)),max:rt(n,rt(e,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){z(this.options.beforeUpdate,[this])}update(t,e,n){const{beginAtZero:s,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=La(this,o,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a=o||n<=1||!this.isHorizontal()){this.labelRotation=s;return}const h=this._getLabelSizes(),d=h.widest.width,u=h.highest.height,f=X(this.chart.width-d,0,this.maxWidth);a=t.offset?this.maxWidth/n:f/(n-1),d+6>a&&(a=f/(n-(t.offset?.5:1)),l=this.maxHeight-de(t.grid)-e.padding-ps(t.title,this.chart.options.font),c=Math.sqrt(d*d+u*u),r=pn(Math.min(Math.asin(X((h.highest.height+6)/a,-1,1)),Math.asin(X(l/c,-1,1))-Math.asin(X(u/c,-1,1)))),r=Math.max(s,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){z(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){z(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:n,title:s,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const l=ps(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=de(o)+l):(t.height=this.maxHeight,t.width=de(o)+l),n.display&&this.ticks.length){const{first:c,last:h,widest:d,highest:u}=this._getLabelSizes(),f=n.padding*2,p=ct(this.labelRotation),g=Math.cos(p),m=Math.sin(p);if(a){const b=n.mirror?0:m*d.width+g*u.height;t.height=Math.min(this.maxHeight,t.height+b+f)}else{const b=n.mirror?0:g*d.width+m*u.height;t.width=Math.min(this.maxWidth,t.width+b+f)}this._calculatePadding(c,h,m,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,n,s){const{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const h=this.getPixelForTick(0)-this.left,d=this.right-this.getPixelForTick(this.ticks.length-1);let u=0,f=0;l?c?(u=s*t.width,f=n*e.height):(u=n*t.height,f=s*e.width):o==="start"?f=e.width:o==="end"?u=t.width:o!=="inner"&&(u=t.width/2,f=e.width/2),this.paddingLeft=Math.max((u-h+r)*this.width/(this.width-h),0),this.paddingRight=Math.max((f-d+r)*this.width/(this.width-d),0)}else{let h=e.height/2,d=t.height/2;o==="start"?(h=0,d=t.height):o==="end"&&(h=e.height,d=0),this.paddingTop=h+r,this.paddingBottom=d+r}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){z(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let e,n;for(e=0,n=t.length;e({width:r[P]||0,height:a[P]||0});return{first:S(0),last:S(e-1),widest:S(M),highest:S(k),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 ca(this._alignToPixels?Bt(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/n:l/s:l*s0}_computeGridLineItems(t){const e=this.axis,n=this.chart,s=this.options,{grid:o,position:r,border:a}=s,l=o.offset,c=this.isHorizontal(),d=this.ticks.length+(l?1:0),u=de(o),f=[],p=a.setContext(this.getContext()),g=p.display?p.width:0,m=g/2,b=function(W){return Bt(n,W,g)};let x,y,w,_,M,k,S,P,D,C,F,K;if(r==="top")x=b(this.bottom),k=this.bottom-u,P=x-m,C=b(t.top)+m,K=t.bottom;else if(r==="bottom")x=b(this.top),C=t.top,K=b(t.bottom)-m,k=x+m,P=this.top+u;else if(r==="left")x=b(this.right),M=this.right-u,S=x-m,D=b(t.left)+m,F=t.right;else if(r==="right")x=b(this.left),D=t.left,F=b(t.right)-m,M=x+m,S=this.left+u;else if(e==="x"){if(r==="center")x=b((t.top+t.bottom)/2+.5);else if(T(r)){const W=Object.keys(r)[0],$=r[W];x=b(this.chart.scales[W].getPixelForValue($))}C=t.top,K=t.bottom,k=x+m,P=k+u}else if(e==="y"){if(r==="center")x=b((t.left+t.right)/2);else if(T(r)){const W=Object.keys(r)[0],$=r[W];x=b(this.chart.scales[W].getPixelForValue($))}M=x-m,S=M-u,D=t.left,F=t.right}const ot=A(s.ticks.maxTicksLimit,d),I=Math.max(1,Math.ceil(d/ot));for(y=0;y0&&(Rt-=It/2);break}Ne={left:Rt,top:ae,width:It+Zt.width,height:re+Zt.height,color:I.backdropColor}}m.push({label:w,font:P,textOffset:F,options:{rotation:g,color:$,strokeColor:lt,strokeWidth:J,textAlign:Jt,textBaseline:K,translation:[_,M],backdrop:Ne}})}return m}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-ct(this.labelRotation))return t==="top"?"left":"right";let s="center";return e.align==="start"?s="left":e.align==="end"?s="right":e.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:n,mirror:s,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,l=r.widest.width;let c,h;return e==="left"?s?(h=this.right+o,n==="near"?c="left":n==="center"?(c="center",h+=l/2):(c="right",h+=l)):(h=this.right-a,n==="near"?c="right":n==="center"?(c="center",h-=l/2):(c="left",h=this.left)):e==="right"?s?(h=this.left+o,n==="near"?c="right":n==="center"?(c="center",h-=l/2):(c="left",h-=l)):(h=this.left+a,n==="near"?c="left":n==="center"?(c="center",h+=l/2):(c="right",h=this.right)):c="right",{textAlign:c,x:h}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;if(e==="left"||e==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(e==="top"||e==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:n,top:s,width:o,height:r}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(n,s,o,r),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const s=this.ticks.findIndex(o=>o.value===t);return s>=0?e.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){const e=this.options.grid,n=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(l,c,h)=>{!h.width||!h.color||(n.save(),n.lineWidth=h.width,n.strokeStyle=h.color,n.setLineDash(h.borderDash||[]),n.lineDashOffset=h.borderDashOffset,n.beginPath(),n.moveTo(l.x,l.y),n.lineTo(c.x,c.y),n.stroke(),n.restore())};if(e.display)for(o=0,r=s.length;o{this.draw(o)}}]:[{z:n,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",s=[];let o,r;for(o=0,r=e.length;o{const n=e.split("."),s=n.pop(),o=[i].concat(n).join("."),r=t[e].split("."),a=r.pop(),l=r.join(".");V.route(o,s,l,a)})}function Cc(i){return"id"in i&&"defaults"in i}class Oc{constructor(){this.controllers=new Ke(ht,"datasets",!0),this.elements=new Ke(dt,"elements"),this.plugins=new Ke(Object,"plugins"),this.scales=new Ke(Gt,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,n){[...e].forEach(s=>{const o=n||this._getRegistryForType(s);n||o.isForType(s)||o===this.plugins&&s.id?this._exec(t,o,s):L(s,r=>{const a=n||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,e,n){const s=gn(t);z(n["before"+s],[],n),e[t](n),z(n["after"+s],[],n)}_getRegistryForType(t){for(let e=0;eo.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(s(e,n),t,"stop"),this._notify(s(n,e),t,"start")}}function Fc(i){const t={},e=[],n=Object.keys(gt.plugins.items);for(let o=0;o1&&ms(i[0].toLowerCase());if(n)return n}throw new Error(`Cannot determine type of '${i}' axis. Please provide 'axis' or 'position' option.`)}function bs(i,t,e){if(e[t+"AxisID"]===i)return{axis:t}}function Wc(i,t){if(t.data&&t.data.datasets){const e=t.data.datasets.filter(n=>n.xAxisID===i||n.yAxisID===i);if(e.length)return bs(i,"x",e[0])||bs(i,"y",e[0])}return{}}function Nc(i,t){const e=Xt[i.type]||{scales:{}},n=t.scales||{},s=Gi(i.type,t),o=Object.create(null);return Object.keys(n).forEach(r=>{const a=n[r];if(!T(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=Ji(r,a,Wc(r,i),V.scales[a.type]),c=zc(l,s),h=e.scales||{};o[r]=ye(Object.create(null),[{axis:l},a,h[l],h[c]])}),i.data.datasets.forEach(r=>{const a=r.type||i.type,l=r.indexAxis||Gi(a,t),h=(Xt[a]||{}).scales||{};Object.keys(h).forEach(d=>{const u=Rc(d,l),f=r[u+"AxisID"]||u;o[f]=o[f]||Object.create(null),ye(o[f],[{axis:u},n[f],h[d]])})}),Object.keys(o).forEach(r=>{const a=o[r];ye(a,[V.scales[a.type],V.scale])}),o}function zo(i){const t=i.options||(i.options={});t.plugins=A(t.plugins,{}),t.scales=Nc(i,t)}function Bo(i){return i=i||{},i.datasets=i.datasets||[],i.labels=i.labels||[],i}function Vc(i){return i=i||{},i.data=Bo(i.data),zo(i),i}const xs=new Map,Wo=new Set;function Ge(i,t){let e=xs.get(i);return e||(e=t(),xs.set(i,e),Wo.add(e)),e}const ue=(i,t,e)=>{const n=Ft(t,e);n!==void 0&&i.add(n)};class jc{constructor(t){this._config=Vc(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=Bo(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(),zo(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Ge(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return Ge(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return Ge(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id,n=this.type;return Ge(`${n}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const n=this._scopeCache;let s=n.get(t);return(!s||e)&&(s=new Map,n.set(t,s)),s}getOptionScopes(t,e,n){const{options:s,type:o}=this,r=this._cachedScopes(t,n),a=r.get(e);if(a)return a;const l=new Set;e.forEach(h=>{t&&(l.add(t),h.forEach(d=>ue(l,t,d))),h.forEach(d=>ue(l,s,d)),h.forEach(d=>ue(l,Xt[o]||{},d)),h.forEach(d=>ue(l,V,d)),h.forEach(d=>ue(l,qi,d))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),Wo.has(e)&&r.set(e,c),c}chartOptionScopes(){const{options:t,type:e}=this;return[t,Xt[e]||{},V.datasets[e]||{},{type:e},V,qi]}resolveNamedOptions(t,e,n,s=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=_s(this._resolverCache,t,s);let l=r;if($c(r,e)){o.$shared=!1,n=Et(n)?n():n;const c=this.createResolver(t,n,a);l=ne(r,n,c)}for(const c of e)o[c]=l[c];return o}createResolver(t,e,n=[""],s){const{resolver:o}=_s(this._resolverCache,t,n);return T(e)?ne(o,e,void 0,s):o}}function _s(i,t,e){let n=i.get(t);n||(n=new Map,i.set(t,n));const s=e.join();let o=n.get(s);return o||(o={resolver:yn(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},n.set(s,o)),o}const Hc=i=>T(i)&&Object.getOwnPropertyNames(i).some(t=>Et(i[t]));function $c(i,t){const{isScriptable:e,isIndexable:n}=bo(i);for(const s of t){const o=e(s),r=n(s),a=(r||o)&&i[s];if(o&&(Et(a)||Hc(a))||r&&N(a))return!0}return!1}var Uc="4.5.1";const Yc=["top","bottom","left","right","chartArea"];function ys(i,t){return i==="top"||i==="bottom"||Yc.indexOf(i)===-1&&t==="x"}function ws(i,t){return function(e,n){return e[i]===n[i]?e[t]-n[t]:e[i]-n[i]}}function vs(i){const t=i.chart,e=t.options.animation;t.notifyPlugins("afterRender"),z(e&&e.onComplete,[i],t)}function qc(i){const t=i.chart,e=t.options.animation;z(e&&e.onProgress,[i],t)}function No(i){return Mn()&&typeof i=="string"?i=document.getElementById(i):i&&i.length&&(i=i[0]),i&&i.canvas&&(i=i.canvas),i}const ai={},Ms=i=>{const t=No(i);return Object.values(ai).filter(e=>e.canvas===t).pop()};function Xc(i,t,e){const n=Object.keys(i);for(const s of n){const o=+s;if(o>=t){const r=i[s];delete i[s],(e>0||o>t)&&(i[o+e]=r)}}}function Kc(i,t,e,n){return!e||i.type==="mouseout"?null:n?t:i}class wt{static register(...t){gt.add(...t),ks()}static unregister(...t){gt.remove(...t),ks()}constructor(t,e){const n=this.config=new jc(e),s=No(t),o=Ms(s);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const r=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||fc(s)),this.platform.updateConfig(n);const a=this.platform.acquireContext(s,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,h=l&&l.width;if(this.id=Gr(),this.ctx=a,this.canvas=l,this.width=h,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Tc,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=fa(d=>this.update(d),r.resizeDelay||0),this._dataChanges=[],ai[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}xt.listen(this,"complete",vs),xt.listen(this,"progress",qc),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:n,height:s,_aspectRatio:o}=this;return O(t)?e&&o?o:s?n/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return gt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Yn(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Hn(this.canvas,this.ctx),this}stop(){return xt.stop(this),this}resize(t,e){xt.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const n=this.options,s=this.canvas,o=n.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,t,e,o),a=n.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,Yn(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),z(n.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const e=this.options.scales||{};L(e,(n,s)=>{n.id=s})}buildOrUpdateScales(){const t=this.options,e=t.scales,n=this.scales,s=Object.keys(n).reduce((r,a)=>(r[a]=!1,r),{});let o=[];e&&(o=o.concat(Object.keys(e).map(r=>{const a=e[r],l=Ji(r,a),c=l==="r",h=l==="x";return{options:a,dposition:c?"chartArea":h?"bottom":"left",dtype:c?"radialLinear":h?"category":"linear"}}))),L(o,r=>{const a=r.options,l=a.id,c=Ji(l,a),h=A(a.type,r.dtype);(a.position===void 0||ys(a.position,c)!==ys(r.dposition))&&(a.position=r.dposition),s[l]=!0;let d=null;if(l in n&&n[l].type===h)d=n[l];else{const u=gt.getScale(h);d=new u({id:l,type:h,ctx:this.ctx,chart:this}),n[d.id]=d}d.init(a,t)}),L(s,(r,a)=>{r||delete n[a]}),L(n,r=>{tt.configure(this,r,r.options),tt.addBox(this,r)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,n=t.length;if(t.sort((s,o)=>s.index-o.index),n>e){for(let s=e;se.length&&delete this._stacks,t.forEach((n,s)=>{e.filter(o=>o===n._dataset).length===0&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let n,s;for(this._removeUnreferencedMetasets(),n=0,s=e.length;n{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const n=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let c=0,h=this.data.datasets.length;c{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(ws("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){L(this.scales,t=>{tt.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),n=new Set(t.events);(!Ln(e,n)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:n,start:s,count:o}of e){const r=n==="_removeElements"?-o:o;Xc(t,s,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,n=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),s=n(0);for(let o=1;oo.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;tt.update(this,this.width,this.height,t);const e=this.chartArea,n=e.width<=0||e.height<=0;this._layers=[],L(this.boxes,s=>{n&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,o)=>{s._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,n=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,n={meta:t,index:t.index,cancelable:!0},s=Do(this,t);this.notifyPlugins("beforeDatasetDraw",n)!==!1&&(s&&vi(e,s),t.controller.draw(),s&&Mi(e),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(t){return kt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,n,s){const o=Yl.modes[e];return typeof o=="function"?o(this,t,n,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],n=this._metasets;let s=n.filter(o=>o&&o._dataset===e).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},n.push(s)),s}getContext(){return this.$context||(this.$context=Lt(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const n=this.getDatasetMeta(t);return typeof n.hidden=="boolean"?!n.hidden:!e.hidden}setDatasetVisibility(t,e){const n=this.getDatasetMeta(t);n.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,n){const s=n?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,s);De(e)?(o.data[e].hidden=!n,this.update()):(this.setDatasetVisibility(t,n),r.update(o,{visible:n}),this.update(a=>a.datasetIndex===t?s:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),xt.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)};L(this.options.events,o=>n(o,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,n=(l,c)=>{e.addEventListener(this,l,c),t[l]=c},s=(l,c)=>{t[l]&&(e.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)};let r;const a=()=>{s("attach",a),this.attached=!0,this.resize(),n("resize",o),n("detach",r)};r=()=>{this.attached=!1,s("resize",o),this._stop(),this._resize(0,0),n("attach",a)},e.isAttached(this.canvas)?a():r()}unbindEvents(){L(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},L(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,n){const s=n?"set":"remove";let o,r,a,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+s+"DatasetHoverStyle"]()),a=0,l=t.length;a{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}});!hi(n,e)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,e))}notifyPlugins(t,e,n){return this._plugins.notify(this,t,e,n)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,n){const s=this.options.hover,o=(l,c)=>l.filter(h=>!c.some(d=>h.datasetIndex===d.datasetIndex&&h.index===d.index)),r=o(e,t),a=n?t:o(t,e);r.length&&this.updateHoverStyle(r,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const n={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},s=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",n,s)===!1)return;const o=this._handleEvent(t,e,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,s),(o||n.changed)&&this.render(),this}_handleEvent(t,e,n){const{_active:s=[],options:o}=this,r=e,a=this._getActiveElements(t,s,n,r),l=ia(t),c=Kc(t,this._lastEvent,n,l);n&&(this._lastEvent=null,z(o.onHover,[t,a,this],this),l&&z(o.onClick,[t,a,this],this));const h=!hi(a,s);return(h||e)&&(this._active=a,this._updateHoverStyles(a,s,e)),this._lastEvent=c,h}_getActiveElements(t,e,n,s){if(t.type==="mouseout")return[];if(!n)return e;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,s)}}v(wt,"defaults",V),v(wt,"instances",ai),v(wt,"overrides",Xt),v(wt,"registry",gt),v(wt,"version",Uc),v(wt,"getChart",Ms);function ks(){return L(wt.instances,i=>i._plugins.invalidate())}function Gc(i,t,e){const{startAngle:n,x:s,y:o,outerRadius:r,innerRadius:a,options:l}=t,{borderWidth:c,borderJoinStyle:h}=l,d=Math.min(c/r,Q(n-e));if(i.beginPath(),i.arc(s,o,r-c/2,n+d/2,e-d/2),a>0){const u=Math.min(c/a,Q(n-e));i.arc(s,o,a+c/2,e-u/2,n+u/2,!0)}else{const u=Math.min(c/2,r*Q(n-e));if(h==="round")i.arc(s,o,u,e-E/2,n+E/2,!0);else if(h==="bevel"){const f=2*u*u,p=-f*Math.cos(e+E/2)+s,g=-f*Math.sin(e+E/2)+o,m=f*Math.cos(n+E/2)+s,b=f*Math.sin(n+E/2)+o;i.lineTo(p,g),i.lineTo(m,b)}}i.closePath(),i.moveTo(0,0),i.rect(0,0,i.canvas.width,i.canvas.height),i.clip("evenodd")}function Jc(i,t,e){const{startAngle:n,pixelMargin:s,x:o,y:r,outerRadius:a,innerRadius:l}=t;let c=s/a;i.beginPath(),i.arc(o,r,a,n-c,e+c),l>s?(c=s/l,i.arc(o,r,l,e+c,n-c,!0)):i.arc(o,r,s,e+U,n-U),i.closePath(),i.clip()}function Zc(i){return _n(i,["outerStart","outerEnd","innerStart","innerEnd"])}function Qc(i,t,e,n){const s=Zc(i.options.borderRadius),o=(e-t)/2,r=Math.min(o,n*t/2),a=l=>{const c=(e-Math.min(o,l))*n/2;return X(l,0,Math.min(o,c))};return{outerStart:a(s.outerStart),outerEnd:a(s.outerEnd),innerStart:X(s.innerStart,0,r),innerEnd:X(s.innerEnd,0,r)}}function te(i,t,e,n){return{x:e+i*Math.cos(t),y:n+i*Math.sin(t)}}function mi(i,t,e,n,s,o){const{x:r,y:a,startAngle:l,pixelMargin:c,innerRadius:h}=t,d=Math.max(t.outerRadius+n+e-c,0),u=h>0?h+n+e+c:0;let f=0;const p=s-l;if(n){const I=h>0?h-n:0,W=d>0?d-n:0,$=(I+W)/2,lt=$!==0?p*$/($+n):p;f=(p-lt)/2}const g=Math.max(.001,p*d-e/E)/d,m=(p-g)/2,b=l+m+f,x=s-m-f,{outerStart:y,outerEnd:w,innerStart:_,innerEnd:M}=Qc(t,u,d,x-b),k=d-y,S=d-w,P=b+y/k,D=x-w/S,C=u+_,F=u+M,K=b+_/C,ot=x-M/F;if(i.beginPath(),o){const I=(P+D)/2;if(i.arc(r,a,d,P,I),i.arc(r,a,d,I,D),w>0){const J=te(S,D,r,a);i.arc(J.x,J.y,w,D,x+U)}const W=te(F,x,r,a);if(i.lineTo(W.x,W.y),M>0){const J=te(F,ot,r,a);i.arc(J.x,J.y,M,x+U,ot+Math.PI)}const $=(x-M/u+(b+_/u))/2;if(i.arc(r,a,u,x-M/u,$,!0),i.arc(r,a,u,$,b+_/u,!0),_>0){const J=te(C,K,r,a);i.arc(J.x,J.y,_,K+Math.PI,b-U)}const lt=te(k,b,r,a);if(i.lineTo(lt.x,lt.y),y>0){const J=te(k,P,r,a);i.arc(J.x,J.y,y,b-U,P)}}else{i.moveTo(r,a);const I=Math.cos(P)*d+r,W=Math.sin(P)*d+a;i.lineTo(I,W);const $=Math.cos(D)*d+r,lt=Math.sin(D)*d+a;i.lineTo($,lt)}i.closePath()}function th(i,t,e,n,s){const{fullCircles:o,startAngle:r,circumference:a}=t;let l=t.endAngle;if(o){mi(i,t,e,n,l,s);for(let c=0;c=E&&f===0&&h!=="miter"&&Gc(i,t,g),o||(mi(i,t,e,n,g,s),i.stroke())}class be extends dt{constructor(e){super();v(this,"circumference");v(this,"endAngle");v(this,"fullCircles");v(this,"innerRadius");v(this,"outerRadius");v(this,"pixelMargin");v(this,"startAngle");this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,n,s){const o=this.getProps(["x","y"],s),{angle:r,distance:a}=ro(o,{x:e,y:n}),{startAngle:l,endAngle:c,innerRadius:h,outerRadius:d,circumference:u}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],s),f=(this.options.spacing+this.options.borderWidth)/2,p=A(u,c-l),g=Ce(r,l,c)&&l!==c,m=p>=B||g,b=vt(a,h+f,d+f);return m&&b}getCenterPoint(e){const{x:n,y:s,startAngle:o,endAngle:r,innerRadius:a,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],e),{offset:c,spacing:h}=this.options,d=(o+r)/2,u=(a+l+h+c)/2;return{x:n+Math.cos(d)*u,y:s+Math.sin(d)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){const{options:n,circumference:s}=this,o=(n.offset||0)/4,r=(n.spacing||0)/2,a=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=s>B?Math.floor(s/B):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(E,s||0)),h=o*c;e.fillStyle=n.backgroundColor,e.strokeStyle=n.borderColor,th(e,this,h,r,a),eh(e,this,h,r,a),e.restore()}}v(be,"id","arc"),v(be,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1}),v(be,"defaultRoutes",{backgroundColor:"backgroundColor"}),v(be,"descriptors",{_scriptable:!0,_indexable:e=>e!=="borderDash"});function Vo(i,t,e=t){i.lineCap=A(e.borderCapStyle,t.borderCapStyle),i.setLineDash(A(e.borderDash,t.borderDash)),i.lineDashOffset=A(e.borderDashOffset,t.borderDashOffset),i.lineJoin=A(e.borderJoinStyle,t.borderJoinStyle),i.lineWidth=A(e.borderWidth,t.borderWidth),i.strokeStyle=A(e.borderColor,t.borderColor)}function ih(i,t,e){i.lineTo(e.x,e.y)}function nh(i){return i.stepped?Sa:i.tension||i.cubicInterpolationMode==="monotone"?Pa:ih}function jo(i,t,e={}){const n=i.length,{start:s=0,end:o=n-1}=e,{start:r,end:a}=t,l=Math.max(s,r),c=Math.min(o,a),h=sa&&o>a;return{count:n,start:l,loop:t.loop,ilen:c(r+(c?a-w:w))%o,y=()=>{g!==m&&(i.lineTo(h,m),i.lineTo(h,g),i.lineTo(h,b))};for(l&&(f=s[x(0)],i.moveTo(f.x,f.y)),u=0;u<=a;++u){if(f=s[x(u)],f.skip)continue;const w=f.x,_=f.y,M=w|0;M===p?(_m&&(m=_),h=(d*h+w)/++d):(y(),i.lineTo(w,_),p=M,d=0,g=m=_),b=_}y()}function Zi(i){const t=i.options,e=t.borderDash&&t.borderDash.length;return!i._decimated&&!i._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!e?oh:sh}function rh(i){return i.stepped?sl:i.tension||i.cubicInterpolationMode==="monotone"?ol:jt}function ah(i,t,e,n){let s=t._path;s||(s=t._path=new Path2D,t.path(s,e,n)&&s.closePath()),Vo(i,t.options),i.stroke(s)}function lh(i,t,e,n){const{segments:s,options:o}=t,r=Zi(t);for(const a of s)Vo(i,o,a.style),i.beginPath(),r(i,t,a,{start:e,end:e+n-1})&&i.closePath(),i.stroke()}const ch=typeof Path2D=="function";function hh(i,t,e,n){ch&&!t.options.segment?ah(i,t,e,n):lh(i,t,e,n)}class Dt extends dt{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const n=this.options;if((n.tension||n.cubicInterpolationMode==="monotone")&&!n.stepped&&!this._pointsUpdated){const s=n.spanGaps?this._loop:this._fullLoop;Ga(this._points,n,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=dl(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,n=t.length;return n&&e[t[n-1].end]}interpolate(t,e){const n=this.options,s=t[e],o=this.points,r=Ao(this,{property:e,start:s,end:s});if(!r.length)return;const a=[],l=rh(n);let c,h;for(c=0,h=r.length;ct!=="borderDash"&&t!=="fill"});function Ss(i,t,e,n){const s=i.options,{[e]:o}=i.getProps([e],n);return Math.abs(t-o)i.replace("rgb(","rgba(").replace(")",", 0.5)"));function $o(i){return Qi[i%Qi.length]}function Uo(i){return Ps[i%Ps.length]}function bh(i,t){return i.borderColor=$o(t),i.backgroundColor=Uo(t),++t}function xh(i,t){return i.backgroundColor=i.data.map(()=>$o(t++)),t}function _h(i,t){return i.backgroundColor=i.data.map(()=>Uo(t++)),t}function yh(i){let t=0;return(e,n)=>{const s=i.getDatasetMeta(n).controller;s instanceof Ht?t=xh(e,t):s instanceof ke?t=_h(e,t):s&&(t=bh(e,t))}}function As(i){let t;for(t in i)if(i[t].borderColor||i[t].backgroundColor)return!0;return!1}function wh(i){return i&&(i.borderColor||i.backgroundColor)}function vh(){return V.borderColor!=="rgba(0,0,0,0.1)"||V.backgroundColor!=="rgba(0,0,0,0.1)"}var Mh={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(i,t,e){if(!e.enabled)return;const{data:{datasets:n},options:s}=i.config,{elements:o}=s,r=As(n)||wh(s)||o&&As(o)||vh();if(!e.forceOverride&&r)return;const a=yh(i);n.forEach(a)}};function kh(i,t,e,n,s){const o=s.samples||n;if(o>=e)return i.slice(t,t+e);const r=[],a=(e-2)/(o-2);let l=0;const c=t+e-1;let h=t,d,u,f,p,g;for(r[l++]=i[h],d=0;df&&(f=p,u=i[x],g=x);r[l++]=u,h=g}return r[l++]=i[c],r}function Sh(i,t,e,n){let s=0,o=0,r,a,l,c,h,d,u,f,p,g;const m=[],b=t+e-1,x=i[t].x,w=i[b].x-x;for(r=t;rg&&(g=c,u=r),s=(o*s+a.x)/++o;else{const M=r-1;if(!O(d)&&!O(u)){const k=Math.min(d,u),S=Math.max(d,u);k!==f&&k!==M&&m.push({...i[k],x:s}),S!==f&&S!==M&&m.push({...i[S],x:s})}r>0&&M!==f&&m.push(i[M]),m.push(a),h=_,o=0,p=g=c,d=u=f=r}}return m}function Yo(i){if(i._decimated){const t=i._data;delete i._decimated,delete i._data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function Ds(i){i.data.datasets.forEach(t=>{Yo(t)})}function Ph(i,t){const e=t.length;let n=0,s;const{iScale:o}=i,{min:r,max:a,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(n=X(Mt(t,o.axis,r).lo,0,e-1)),c?s=X(Mt(t,o.axis,a).hi+1,n,e)-n:s=e-n,{start:n,count:s}}var Ah={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(i,t,e)=>{if(!e.enabled){Ds(i);return}const n=i.width;i.data.datasets.forEach((s,o)=>{const{_data:r,indexAxis:a}=s,l=i.getDatasetMeta(o),c=r||s.data;if(pe([a,i.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;const h=i.scales[l.xAxisID];if(h.type!=="linear"&&h.type!=="time"||i.options.parsing)return;let{start:d,count:u}=Ph(l,c);const f=e.threshold||4*n;if(u<=f){Yo(s);return}O(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=kh(c,d,u,n,e);break;case"min-max":p=Sh(c,d,u,n);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}s._decimated=p})},destroy(i){Ds(i)}};function Dh(i,t,e){const n=i.segments,s=i.points,o=t.points,r=[];for(const a of n){let{start:l,end:c}=a;c=Pi(l,c,s);const h=tn(e,s[l],s[c],a.loop);if(!t.segments){r.push({source:a,target:h,start:s[l],end:s[c]});continue}const d=Ao(t,h);for(const u of d){const f=tn(e,o[u.start],o[u.end],u.loop),p=Po(a,s,f);for(const g of p)r.push({source:g,target:u,start:{[e]:Cs(h,f,"start",Math.max)},end:{[e]:Cs(h,f,"end",Math.min)}})}}return r}function tn(i,t,e,n){if(n)return;let s=t[i],o=e[i];return i==="angle"&&(s=Q(s),o=Q(o)),{property:i,start:s,end:o}}function Ch(i,t){const{x:e=null,y:n=null}=i||{},s=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=Pi(r,a,s);const l=s[r],c=s[a];n!==null?(o.push({x:l.x,y:n}),o.push({x:c.x,y:n})):e!==null&&(o.push({x:e,y:l.y}),o.push({x:e,y:c.y}))}),o}function Pi(i,t,e){for(;t>i;t--){const n=e[t];if(!isNaN(n.x)&&!isNaN(n.y))break}return t}function Cs(i,t,e,n){return i&&t?n(i[e],t[e]):i?i[e]:t?t[e]:0}function qo(i,t){let e=[],n=!1;return N(i)?(n=!0,e=i):e=Ch(i,t),e.length?new Dt({points:e,options:{tension:0},_loop:n,_fullLoop:n}):null}function Os(i){return i&&i.fill!==!1}function Oh(i,t,e){let s=i[t].fill;const o=[t];let r;if(!e)return s;for(;s!==!1&&o.indexOf(s)===-1;){if(!H(s))return s;if(r=i[s],!r)return!1;if(r.visible)return s;o.push(s),s=r.fill}return!1}function Th(i,t,e){const n=Ih(i);if(T(n))return isNaN(n.value)?!1:n;let s=parseFloat(n);return H(s)&&Math.floor(s)===s?Fh(n[0],t,s,e):["origin","start","end","stack","shape"].indexOf(n)>=0&&n}function Fh(i,t,e,n){return(i==="-"||i==="+")&&(e=t+e),e===t||e<0||e>=n?!1:e}function Eh(i,t){let e=null;return i==="start"?e=t.bottom:i==="end"?e=t.top:T(i)?e=t.getPixelForValue(i.value):t.getBasePixel&&(e=t.getBasePixel()),e}function Lh(i,t,e){let n;return i==="start"?n=e:i==="end"?n=t.options.reverse?t.min:t.max:T(i)?n=i.value:n=t.getBaseValue(),n}function Ih(i){const t=i.options,e=t.fill;let n=A(e&&e.target,e);return n===void 0&&(n=!!t.backgroundColor),n===!1||n===null?!1:n===!0?"origin":n}function Rh(i){const{scale:t,index:e,line:n}=i,s=[],o=n.segments,r=n.points,a=zh(t,e);a.push(qo({x:null,y:t.bottom},n));for(let l=0;l=0;--r){const a=s[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),n&&a.fill&&Ni(i.ctx,a,o))}},beforeDatasetsDraw(i,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;const n=i.getSortedVisibleDatasetMetas();for(let s=n.length-1;s>=0;--s){const o=n[s].$filler;Os(o)&&Ni(i.ctx,o,i.chartArea)}},beforeDatasetDraw(i,t,e){const n=t.meta.$filler;!Os(n)||e.drawTime!=="beforeDatasetDraw"||Ni(i.ctx,n,i.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Ls=(i,t)=>{let{boxHeight:e=t,boxWidth:n=t}=i;return i.usePointStyle&&(e=Math.min(e,t),n=i.pointStyleWidth||Math.min(n,t)),{boxWidth:n,boxHeight:e,itemHeight:Math.max(t,e)}},Xh=(i,t)=>i!==null&&t!==null&&i.datasetIndex===t.datasetIndex&&i.index===t.index;class Is extends dt{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,n){this.maxWidth=t,this.maxHeight=e,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=z(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(n=>t.filter(n,this.chart.data))),t.sort&&(e=e.sort((n,s)=>t.sort(n,s,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display){this.width=this.height=0;return}const n=t.labels,s=q(n.font),o=s.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=Ls(n,o);let c,h;e.font=s.string,this.isHorizontal()?(c=this.maxWidth,h=this._fitRows(r,o,a,l)+10):(h=this.maxHeight,c=this._fitCols(r,s,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,n,s){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],h=s+a;let d=t;o.textAlign="left",o.textBaseline="middle";let u=-1,f=-h;return this.legendItems.forEach((p,g)=>{const m=n+e/2+o.measureText(p.text).width;(g===0||c[c.length-1]+m+2*a>r)&&(d+=h,c[c.length-(g>0?0:1)]=0,f+=h,u++),l[g]={left:0,top:f,row:u,width:m,height:s},c[c.length-1]+=m+a}),d}_fitCols(t,e,n,s){const{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],h=r-t;let d=a,u=0,f=0,p=0,g=0;return this.legendItems.forEach((m,b)=>{const{itemWidth:x,itemHeight:y}=Kh(n,e,o,m,s);b>0&&f+y+2*a>h&&(d+=u+a,c.push({width:u,height:f}),p+=u+a,g++,u=f=0),l[b]={left:p,top:f,col:g,width:x,height:y},u=Math.max(u,x),f+=y+a}),d+=u,c.push({width:u,height:f}),d}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:n,labels:{padding:s},rtl:o}}=this,r=ee(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=Z(n,this.left+s,this.right-this.lineWidths[a]);for(const c of e)a!==c.row&&(a=c.row,l=Z(n,this.left+s,this.right-this.lineWidths[a])),c.top+=this.top+t+s,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+s}else{let a=0,l=Z(n,this.top+t+s,this.bottom-this.columnSizes[a].height);for(const c of e)c.col!==a&&(a=c.col,l=Z(n,this.top+t+s,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+s,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;vi(t,this),this._draw(),Mi(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:n,ctx:s}=this,{align:o,labels:r}=t,a=V.color,l=ee(t.rtl,this.left,this.width),c=q(r.font),{padding:h}=r,d=c.size,u=d/2;let f;this.drawTitle(),s.textAlign=l.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:p,boxHeight:g,itemHeight:m}=Ls(r,d),b=function(M,k,S){if(isNaN(p)||p<=0||isNaN(g)||g<0)return;s.save();const P=A(S.lineWidth,1);if(s.fillStyle=A(S.fillStyle,a),s.lineCap=A(S.lineCap,"butt"),s.lineDashOffset=A(S.lineDashOffset,0),s.lineJoin=A(S.lineJoin,"miter"),s.lineWidth=P,s.strokeStyle=A(S.strokeStyle,a),s.setLineDash(A(S.lineDash,[])),r.usePointStyle){const D={radius:g*Math.SQRT2/2,pointStyle:S.pointStyle,rotation:S.rotation,borderWidth:P},C=l.xPlus(M,p/2),F=k+u;po(s,D,C,F,r.pointStyleWidth&&p)}else{const D=k+Math.max((d-g)/2,0),C=l.leftForLtr(M,p),F=$t(S.borderRadius);s.beginPath(),Object.values(F).some(K=>K!==0)?Oe(s,{x:C,y:D,w:p,h:g,radius:F}):s.rect(C,D,p,g),s.fill(),P!==0&&s.stroke()}s.restore()},x=function(M,k,S){Kt(s,S.text,M,k+m/2,c,{strikethrough:S.hidden,textAlign:l.textAlign(S.textAlign)})},y=this.isHorizontal(),w=this._computeTitleHeight();y?f={x:Z(o,this.left+h,this.right-n[0]),y:this.top+h+w,line:0}:f={x:this.left+h,y:Z(o,this.top+w+h,this.bottom-e[0].height),line:0},Mo(this.ctx,t.textDirection);const _=m+h;this.legendItems.forEach((M,k)=>{s.strokeStyle=M.fontColor,s.fillStyle=M.fontColor;const S=s.measureText(M.text).width,P=l.textAlign(M.textAlign||(M.textAlign=r.textAlign)),D=p+u+S;let C=f.x,F=f.y;l.setWidth(this.width),y?k>0&&C+D+h>this.right&&(F=f.y+=_,f.line++,C=f.x=Z(o,this.left+h,this.right-n[f.line])):k>0&&F+_>this.bottom&&(C=f.x=C+e[f.line].width+h,f.line++,F=f.y=Z(o,this.top+w+h,this.bottom-e[f.line].height));const K=l.x(C);if(b(K,F,M),C=ga(P,C+p+u,y?C+D:this.right,t.rtl),x(l.x(C),F,M),y)f.x+=D+h;else if(typeof M.text!="string"){const ot=c.lineHeight;f.y+=Ko(M,ot)+h}else f.y+=_}),ko(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,n=q(e.font),s=et(e.padding);if(!e.display)return;const o=ee(t.rtl,this.left,this.width),r=this.ctx,a=e.position,l=n.size/2,c=s.top+l;let h,d=this.left,u=this.width;if(this.isHorizontal())u=Math.max(...this.lineWidths),h=this.top+c,d=Z(t.align,d,this.right-u);else{const p=this.columnSizes.reduce((g,m)=>Math.max(g,m.height),0);h=c+Z(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}const f=Z(a,d,d+u);r.textAlign=o.textAlign(bn(a)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=n.string,Kt(r,e.text,f,h,n)}_computeTitleHeight(){const t=this.options.title,e=q(t.font),n=et(t.padding);return t.display?e.lineHeight+n.height:0}_getLegendItemAt(t,e){let n,s,o;if(vt(t,this.left,this.right)&&vt(e,this.top,this.bottom)){for(o=this.legendHitBoxes,n=0;no.length>r.length?o:r)),t+e.size/2+n.measureText(s).width}function Jh(i,t,e){let n=i;return typeof t.text!="string"&&(n=Ko(t,e)),n}function Ko(i,t){const e=i.text?i.text.length:0;return t*e}function Zh(i,t){return!!((i==="mousemove"||i==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(i==="click"||i==="mouseup"))}var Qh={id:"legend",_element:Is,start(i,t,e){const n=i.legend=new Is({ctx:i.ctx,options:e,chart:i});tt.configure(i,n,e),tt.addBox(i,n)},stop(i){tt.removeBox(i,i.legend),delete i.legend},beforeUpdate(i,t,e){const n=i.legend;tt.configure(i,n,e),n.options=e},afterUpdate(i){const t=i.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(i,t){t.replay||i.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(i,t,e){const n=t.datasetIndex,s=e.chart;s.isDatasetVisible(n)?(s.hide(n),t.hidden=!0):(s.show(n),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:i=>i.chart.options.color,boxWidth:40,padding:10,generateLabels(i){const t=i.data.datasets,{labels:{usePointStyle:e,pointStyle:n,textAlign:s,color:o,useBorderRadius:r,borderRadius:a}}=i.legend.options;return i._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(e?0:void 0),h=et(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(h.width+h.height)/4,strokeStyle:c.borderColor,pointStyle:n||c.pointStyle,rotation:c.rotation,textAlign:s||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:i=>i.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:i=>!i.startsWith("on"),labels:{_scriptable:i=>!["generateLabels","filter","sort"].includes(i)}}};class Pn extends dt{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=e;const s=N(n.text)?n.text.length:1;this._padding=et(n.padding);const o=s*q(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:e,left:n,bottom:s,right:o,options:r}=this,a=r.align;let l=0,c,h,d;return this.isHorizontal()?(h=Z(a,n,o),d=e+t,c=o-n):(r.position==="left"?(h=n+t,d=Z(a,s,e),l=E*-.5):(h=o-t,d=Z(a,e,s),l=E*.5),c=s-e),{titleX:h,titleY:d,maxWidth:c,rotation:l}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const n=q(e.font),o=n.lineHeight/2+this._padding.top,{titleX:r,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(o);Kt(t,e.text,0,0,n,{color:e.color,maxWidth:l,rotation:c,textAlign:bn(e.align),textBaseline:"middle",translation:[r,a]})}}function td(i,t){const e=new Pn({ctx:i.ctx,options:t,chart:i});tt.configure(i,e,t),tt.addBox(i,e),i.titleBlock=e}var ed={id:"title",_element:Pn,start(i,t,e){td(i,e)},stop(i){const t=i.titleBlock;tt.removeBox(i,t),delete i.titleBlock},beforeUpdate(i,t,e){const n=i.titleBlock;tt.configure(i,n,e),n.options=e},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Je=new WeakMap;var id={id:"subtitle",start(i,t,e){const n=new Pn({ctx:i.ctx,options:e,chart:i});tt.configure(i,n,e),tt.addBox(i,n),Je.set(i,n)},stop(i){tt.removeBox(i,Je.get(i)),Je.delete(i)},beforeUpdate(i,t,e){const n=Je.get(i);tt.configure(i,n,e),n.options=e},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const xe={average(i){if(!i.length)return!1;let t,e,n=new Set,s=0,o=0;for(t=0,e=i.length;ta+l)/n.size,y:s/o}},nearest(i,t){if(!i.length)return!1;let e=t.x,n=t.y,s=Number.POSITIVE_INFINITY,o,r,a;for(o=0,r=i.length;o-1?i.split(` +`):i}function nd(i,t){const{element:e,datasetIndex:n,index:s}=t,o=i.getDatasetMeta(n).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:i,label:r,parsed:o.getParsed(s),raw:i.data.datasets[n].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:n,element:e}}function Rs(i,t){const e=i.chart.ctx,{body:n,footer:s,title:o}=i,{boxWidth:r,boxHeight:a}=t,l=q(t.bodyFont),c=q(t.titleFont),h=q(t.footerFont),d=o.length,u=s.length,f=n.length,p=et(t.padding);let g=p.height,m=0,b=n.reduce((w,_)=>w+_.before.length+_.lines.length+_.after.length,0);if(b+=i.beforeBody.length+i.afterBody.length,d&&(g+=d*c.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),b){const w=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;g+=f*w+(b-f)*l.lineHeight+(b-1)*t.bodySpacing}u&&(g+=t.footerMarginTop+u*h.lineHeight+(u-1)*t.footerSpacing);let x=0;const y=function(w){m=Math.max(m,e.measureText(w).width+x)};return e.save(),e.font=c.string,L(i.title,y),e.font=l.string,L(i.beforeBody.concat(i.afterBody),y),x=t.displayColors?r+2+t.boxPadding:0,L(n,w=>{L(w.before,y),L(w.lines,y),L(w.after,y)}),x=0,e.font=h.string,L(i.footer,y),e.restore(),m+=p.width,{width:m,height:g}}function sd(i,t){const{y:e,height:n}=t;return ei.height-n/2?"bottom":"center"}function od(i,t,e,n){const{x:s,width:o}=n,r=e.caretSize+e.caretPadding;if(i==="left"&&s+o+r>t.width||i==="right"&&s-o-r<0)return!0}function rd(i,t,e,n){const{x:s,width:o}=e,{width:r,chartArea:{left:a,right:l}}=i;let c="center";return n==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),od(c,i,t,e)&&(c="center"),c}function zs(i,t,e){const n=e.yAlign||t.yAlign||sd(i,e);return{xAlign:e.xAlign||t.xAlign||rd(i,t,e,n),yAlign:n}}function ad(i,t){let{x:e,width:n}=i;return t==="right"?e-=n:t==="center"&&(e-=n/2),e}function ld(i,t,e){let{y:n,height:s}=i;return t==="top"?n+=e:t==="bottom"?n-=s+e:n-=s/2,n}function Bs(i,t,e,n){const{caretSize:s,caretPadding:o,cornerRadius:r}=i,{xAlign:a,yAlign:l}=e,c=s+o,{topLeft:h,topRight:d,bottomLeft:u,bottomRight:f}=$t(r);let p=ad(t,a);const g=ld(t,l,c);return l==="center"?a==="left"?p+=c:a==="right"&&(p-=c):a==="left"?p-=Math.max(h,u)+s:a==="right"&&(p+=Math.max(d,f)+s),{x:X(p,0,n.width-t.width),y:X(g,0,n.height-t.height)}}function Ze(i,t,e){const n=et(e.padding);return t==="center"?i.x+i.width/2:t==="right"?i.x+i.width-n.right:i.x+n.left}function Ws(i){return ft([],_t(i))}function cd(i,t,e){return Lt(i,{tooltip:t,tooltipItems:e,type:"tooltip"})}function Ns(i,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?i.override(e):i}const Go={beforeTitle:bt,title(i){if(i.length>0){const t=i[0],e=t.chart.data.labels,n=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(n>0&&t.dataIndex"u"?Go[t].call(e,n):s}class en extends dt{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,n=this.options.setContext(this.getContext()),s=n.enabled&&e.options.animation&&n.animations,o=new Co(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=cd(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:n}=e,s=it(n,"beforeTitle",this,t),o=it(n,"title",this,t),r=it(n,"afterTitle",this,t);let a=[];return a=ft(a,_t(s)),a=ft(a,_t(o)),a=ft(a,_t(r)),a}getBeforeBody(t,e){return Ws(it(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:n}=e,s=[];return L(t,o=>{const r={before:[],lines:[],after:[]},a=Ns(n,o);ft(r.before,_t(it(a,"beforeLabel",this,o))),ft(r.lines,it(a,"label",this,o)),ft(r.after,_t(it(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,e){return Ws(it(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:n}=e,s=it(n,"beforeFooter",this,t),o=it(n,"footer",this,t),r=it(n,"afterFooter",this,t);let a=[];return a=ft(a,_t(s)),a=ft(a,_t(o)),a=ft(a,_t(r)),a}_createItems(t){const e=this._active,n=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=e.length;lt.filter(h,d,u,n))),t.itemSort&&(a=a.sort((h,d)=>t.itemSort(h,d,n))),L(a,h=>{const d=Ns(t.callbacks,h);s.push(it(d,"labelColor",this,h)),o.push(it(d,"labelPointStyle",this,h)),r.push(it(d,"labelTextColor",this,h))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){const n=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=xe[n.position].call(this,s,this._eventPosition);r=this._createItems(n),this.title=this.getTitle(r,n),this.beforeBody=this.getBeforeBody(r,n),this.body=this.getBody(r,n),this.afterBody=this.getAfterBody(r,n),this.footer=this.getFooter(r,n);const l=this._size=Rs(this,n),c=Object.assign({},a,l),h=zs(this.chart,n,c),d=Bs(n,c,h,this.chart);this.xAlign=h.xAlign,this.yAlign=h.yAlign,o={opacity:1,x:d.x,y:d.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,n,s){const o=this.getCaretPosition(t,n,s);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,n){const{xAlign:s,yAlign:o}=this,{caretSize:r,cornerRadius:a}=n,{topLeft:l,topRight:c,bottomLeft:h,bottomRight:d}=$t(a),{x:u,y:f}=t,{width:p,height:g}=e;let m,b,x,y,w,_;return o==="center"?(w=f+g/2,s==="left"?(m=u,b=m-r,y=w+r,_=w-r):(m=u+p,b=m+r,y=w-r,_=w+r),x=m):(s==="left"?b=u+Math.max(l,h)+r:s==="right"?b=u+p-Math.max(c,d)-r:b=this.caretX,o==="top"?(y=f,w=y-r,m=b-r,x=b+r):(y=f+g,w=y+r,m=b+r,x=b-r),_=y),{x1:m,x2:b,x3:x,y1:y,y2:w,y3:_}}drawTitle(t,e,n){const s=this.title,o=s.length;let r,a,l;if(o){const c=ee(n.rtl,this.x,this.width);for(t.x=Ze(this,n.titleAlign,n),e.textAlign=c.textAlign(n.titleAlign),e.textBaseline="middle",r=q(n.titleFont),a=n.titleSpacing,e.fillStyle=n.titleColor,e.font=r.string,l=0;lx!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,Oe(t,{x:g,y:p,w:c,h:l,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),Oe(t,{x:m,y:p+1,w:c-2,h:l-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(g,p,c,l),t.strokeRect(g,p,c,l),t.fillStyle=r.backgroundColor,t.fillRect(m,p+1,c-2,l-2))}t.fillStyle=this.labelTextColors[n]}drawBody(t,e,n){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:h}=n,d=q(n.bodyFont);let u=d.lineHeight,f=0;const p=ee(n.rtl,this.x,this.width),g=function(S){e.fillText(S,p.x(t.x+f),t.y+u/2),t.y+=u+o},m=p.textAlign(r);let b,x,y,w,_,M,k;for(e.textAlign=r,e.textBaseline="middle",e.font=d.string,t.x=Ze(this,m,n),e.fillStyle=n.bodyColor,L(this.beforeBody,g),f=a&&m!=="right"?r==="center"?c/2+h:c+2+h:0,w=0,M=s.length;w0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,n=this.$animations,s=n&&n.x,o=n&&n.y;if(s||o){const r=xe[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=Rs(this,t),l=Object.assign({},r,this._size),c=zs(e,t,l),h=Bs(t,l,c,e);(s._to!==h.x||o._to!==h.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,h))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let n=this.opacity;if(!n)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;const r=et(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=n,this.drawBackground(o,t,s,e),Mo(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),ko(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const n=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!hi(n,s),r=this._positionChanged(s,e);(o||r)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,n=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],r=this._getActiveElements(t,o,e,n),a=this._positionChanged(r,t),l=e||!hi(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,n,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return e.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const r=this.chart.getElementsAtEventForMode(t,o.mode,o,n);return o.reverse&&r.reverse(),r}_positionChanged(t,e){const{caretX:n,caretY:s,options:o}=this,r=xe[o.position].call(this,t,e);return r!==!1&&(n!==r.x||s!==r.y)}}v(en,"positioners",xe);var hd={id:"tooltip",_element:en,positioners:xe,afterInit(i,t,e){e&&(i.tooltip=new en({chart:i,options:e}))},beforeUpdate(i,t,e){i.tooltip&&i.tooltip.initialize(e)},reset(i,t,e){i.tooltip&&i.tooltip.initialize(e)},afterDraw(i){const t=i.tooltip;if(t&&t._willRender()){const e={tooltip:t};if(i.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(i.ctx),i.notifyPlugins("afterTooltipDraw",e)}},afterEvent(i,t){if(i.tooltip){const e=t.replay;i.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(i,t)=>t.bodyFont.size,boxWidth:(i,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Go},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:i=>i!=="filter"&&i!=="itemSort"&&i!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},dd=Object.freeze({__proto__:null,Colors:Mh,Decimation:Ah,Filler:qh,Legend:Qh,SubTitle:id,Title:ed,Tooltip:hd});const ud=(i,t,e,n)=>(typeof t=="string"?(e=i.push(t)-1,n.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function fd(i,t,e,n){const s=i.indexOf(t);if(s===-1)return ud(i,t,e,n);const o=i.lastIndexOf(t);return s!==o?e:s}const gd=(i,t)=>i===null?null:X(Math.round(i),0,t);function Vs(i){const t=this.getLabels();return i>=0&&ie.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}v(nn,"id","category"),v(nn,"defaults",{ticks:{callback:Vs}});function pd(i,t){const e=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:h,maxDigits:d,includeBounds:u}=i,f=o||1,p=h-1,{min:g,max:m}=t,b=!O(r),x=!O(a),y=!O(c),w=(m-g)/(d+1);let _=Rn((m-g)/p/f)*f,M,k,S,P;if(_<1e-14&&!b&&!x)return[{value:g},{value:m}];P=Math.ceil(m/_)-Math.floor(g/_),P>p&&(_=Rn(P*_/p/f)*f),O(l)||(M=Math.pow(10,l),_=Math.ceil(_*M)/M),s==="ticks"?(k=Math.floor(g/_)*_,S=Math.ceil(m/_)*_):(k=g,S=m),b&&x&&o&&aa((a-r)/o,_/1e3)?(P=Math.round(Math.min((a-r)/_,h)),_=(a-r)/P,k=r,S=a):y?(k=b?r:k,S=x?a:S,P=c-1,_=(S-k)/P):(P=(S-k)/_,we(P,Math.round(P),_/1e3)?P=Math.round(P):P=Math.ceil(P));const D=Math.max(zn(_),zn(k));M=Math.pow(10,O(l)?D:l),k=Math.round(k*M)/M,S=Math.round(S*M)/M;let C=0;for(b&&(u&&k!==r?(e.push({value:r}),ka)break;e.push({value:F})}return x&&u&&S!==a?e.length&&we(e[e.length-1].value,a,js(a,w,i))?e[e.length-1].value=a:e.push({value:a}):(!x||S===a)&&e.push({value:S}),e}function js(i,t,{horizontal:e,minRotation:n}){const s=ct(n),o=(e?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+i).length;return Math.min(t/o,r)}class bi extends Gt{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 O(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:n}=this.getUserBounds();let{min:s,max:o}=this;const r=l=>s=e?s:l,a=l=>o=n?o:l;if(t){const l=mt(s),c=mt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:n}=t,s;return n?(s=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,s>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${s} ticks. Limiting to 1000.`),s=1e3)):(s=this.computeTickLimit(),e=e||11),e&&(s=Math.min(e,s)),s}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let n=this.getTickLimit();n=Math.max(2,n);const s={maxTicks:n,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==!1},o=this._range||this,r=pd(s,o);return t.bounds==="ticks"&&oo(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let e=this.min,n=this.max;if(super.configure(),this.options.offset&&t.length){const s=(n-e)/Math.max(t.length-1,1)/2;e-=s,n+=s}this._startValue=e,this._endValue=n,this._valueRange=n-e}getLabelForValue(t){return Be(t,this.chart.options.locale,this.options.ticks.format)}}class sn extends bi{determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=H(t)?t:0,this.max=H(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,n=ct(this.options.ticks.minRotation),s=(t?Math.sin(n):Math.cos(n))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}v(sn,"id","linear"),v(sn,"defaults",{ticks:{callback:wi.formatters.numeric}});const Fe=i=>Math.floor(Pt(i)),Nt=(i,t)=>Math.pow(10,Fe(i)+t);function Hs(i){return i/Math.pow(10,Fe(i))===1}function $s(i,t,e){const n=Math.pow(10,e),s=Math.floor(i/n);return Math.ceil(t/n)-s}function md(i,t){const e=t-i;let n=Fe(e);for(;$s(i,t,n)>10;)n++;for(;$s(i,t,n)<10;)n--;return Math.min(n,Fe(i))}function bd(i,{min:t,max:e}){t=rt(i.min,t);const n=[],s=Fe(t);let o=md(t,e),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((t-l)*r)/r,h=Math.floor((t-l)/a/10)*a*10;let d=Math.floor((c-h)/Math.pow(10,o)),u=rt(i.min,Math.round((l+h+d*Math.pow(10,o))*r)/r);for(;u=10?d=d<15?15:20:d++,d>=20&&(o++,d=2,r=o>=0?1:r),u=Math.round((l+h+d*Math.pow(10,o))*r)/r;const f=rt(i.max,u);return n.push({value:f,major:Hs(f),significand:d}),n}class on extends Gt{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const n=bi.prototype.parse.apply(this,[t,e]);if(n===0){this._zero=!0;return}return H(n)&&n>0?n:null}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=H(t)?Math.max(0,t):null,this.max=H(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!H(this._userMin)&&(this.min=t===Nt(this.min,0)?Nt(this.min,-1):Nt(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let n=this.min,s=this.max;const o=a=>n=t?n:a,r=a=>s=e?s:a;n===s&&(n<=0?(o(1),r(10)):(o(Nt(n,-1)),r(Nt(s,1)))),n<=0&&o(Nt(s,-1)),s<=0&&r(Nt(n,1)),this.min=n,this.max=s}buildTicks(){const t=this.options,e={min:this._userMin,max:this._userMax},n=bd(e,this);return t.bounds==="ticks"&&oo(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}getLabelForValue(t){return t===void 0?"0":Be(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Pt(t),this._valueRange=Pt(this.max)-Pt(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Pt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}v(on,"id","logarithmic"),v(on,"defaults",{ticks:{callback:wi.formatters.logarithmic,major:{enabled:!0}}});function rn(i){const t=i.ticks;if(t.display&&i.display){const e=et(t.backdropPadding);return A(t.font&&t.font.size,V.font.size)+e.height}return 0}function xd(i,t,e){return e=N(e)?e:[e],{w:ka(i,t.string,e),h:e.length*t.lineHeight}}function Us(i,t,e,n,s){return i===n||i===s?{start:t-e/2,end:t+e/2}:is?{start:t-e,end:t}:{start:t,end:t+e}}function _d(i){const t={l:i.left+i._padding.left,r:i.right-i._padding.right,t:i.top+i._padding.top,b:i.bottom-i._padding.bottom},e=Object.assign({},t),n=[],s=[],o=i._pointLabels.length,r=i.options.pointLabels,a=r.centerPointLabels?E/o:0;for(let l=0;lt.r&&(a=(n.end-t.r)/o,i.r=Math.max(i.r,t.r+a)),s.startt.b&&(l=(s.end-t.b)/r,i.b=Math.max(i.b,t.b+l))}function wd(i,t,e){const n=i.drawingArea,{extra:s,additionalAngle:o,padding:r,size:a}=e,l=i.getPointPosition(t,n+s+r,o),c=Math.round(pn(Q(l.angle+U))),h=Pd(l.y,a.h,c),d=kd(c),u=Sd(l.x,a.w,d);return{visible:!0,x:l.x,y:h,textAlign:d,left:u,top:h,right:u+a.w,bottom:h+a.h}}function vd(i,t){if(!t)return!0;const{left:e,top:n,right:s,bottom:o}=i;return!(kt({x:e,y:n},t)||kt({x:e,y:o},t)||kt({x:s,y:n},t)||kt({x:s,y:o},t))}function Md(i,t,e){const n=[],s=i._pointLabels.length,o=i.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:rn(o)/2,additionalAngle:r?E/s:0};let c;for(let h=0;h270||e<90)&&(i-=t),i}function Ad(i,t,e){const{left:n,top:s,right:o,bottom:r}=e,{backdropColor:a}=t;if(!O(a)){const l=$t(t.borderRadius),c=et(t.backdropPadding);i.fillStyle=a;const h=n-c.left,d=s-c.top,u=o-n+c.width,f=r-s+c.height;Object.values(l).some(p=>p!==0)?(i.beginPath(),Oe(i,{x:h,y:d,w:u,h:f,radius:l}),i.fill()):i.fillRect(h,d,u,f)}}function Dd(i,t){const{ctx:e,options:{pointLabels:n}}=i;for(let s=t-1;s>=0;s--){const o=i._pointLabelItems[s];if(!o.visible)continue;const r=n.setContext(i.getPointLabelContext(s));Ad(e,r,o);const a=q(r.font),{x:l,y:c,textAlign:h}=o;Kt(e,i._pointLabels[s],l,c+a.lineHeight/2,a,{color:r.color,textAlign:h,textBaseline:"middle"})}}function Jo(i,t,e,n){const{ctx:s}=i;if(e)s.arc(i.xCenter,i.yCenter,t,0,B);else{let o=i.getPointPosition(0,t);s.moveTo(o.x,o.y);for(let r=1;r{const s=z(this.options.pointLabels.callback,[e,n],this);return s||s===0?s:""}).filter((e,n)=>this.chart.getDataVisibility(n))}fit(){const t=this.options;t.display&&t.pointLabels.display?_d(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,n,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((n-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,n,s))}getIndexAngle(t){const e=B/(this._pointLabels.length||1),n=this.options.startAngle||0;return Q(t*e+ct(n))}getDistanceFromCenterForValue(t){if(O(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(O(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(d!==0||d===0&&this.min<0){l=this.getDistanceFromCenterForValue(h.value);const u=this.getContext(d),f=s.setContext(u),p=o.setContext(u);Cd(this,f,l,r,p)}}),n.display){for(t.save(),a=r-1;a>=0;a--){const h=n.setContext(this.getPointLabelContext(a)),{color:d,lineWidth:u}=h;!u||!d||(t.lineWidth=u,t.strokeStyle=d,t.setLineDash(h.borderDash),t.lineDashOffset=h.borderDashOffset,l=this.getDistanceFromCenterForValue(e.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,n=e.ticks;if(!n.display)return;const s=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!e.reverse)return;const c=n.setContext(this.getContext(l)),h=q(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=h.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const d=et(c.backdropPadding);t.fillRect(-r/2-d.left,-o-h.size/2-d.top,r+d.width,h.size+d.height)}Kt(t,a.label,0,-o,h,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}v(_e,"id","radialLinear"),v(_e,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:wi.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),v(_e,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),v(_e,"descriptors",{angleLines:{_fallback:"grid"}});const Ai={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}},st=Object.keys(Ai);function Ys(i,t){return i-t}function qs(i,t){if(O(t))return null;const e=i._adapter,{parser:n,round:s,isoWeekday:o}=i._parseOpts;let r=t;return typeof n=="function"&&(r=n(r)),H(r)||(r=typeof n=="string"?e.parse(r,n):e.parse(r)),r===null?null:(s&&(r=s==="week"&&(ie(o)||o===!0)?e.startOf(r,"isoWeek",o):e.startOf(r,s)),+r)}function Xs(i,t,e,n){const s=st.length;for(let o=st.indexOf(i);o=st.indexOf(e);o--){const r=st[o];if(Ai[r].common&&i._adapter.diff(s,n,r)>=t-1)return r}return st[e?st.indexOf(e):0]}function Fd(i){for(let t=st.indexOf(i)+1,e=st.length;t=t?e[n]:e[s];i[o]=!0}}function Ed(i,t,e,n){const s=i._adapter,o=+s.startOf(t[0].value,n),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,n))l=e[a],l>=0&&(t[l].major=!0);return t}function Gs(i,t,e){const n=[],s={},o=t.length;let r,a;for(r=0;r+t.value))}initOffsets(t=[]){let e=0,n=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?e=1-s:e=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?n=o:n=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;e=X(e,0,r),n=X(n,0,r),this._offsets={start:e,end:n,factor:1/(e+1+n)}}_generate(){const t=this._adapter,e=this.min,n=this.max,s=this.options,o=s.time,r=o.unit||Xs(o.minUnit,e,n,this._getLabelCapacity(e)),a=A(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=ie(l)||l===!0,h={};let d=e,u,f;if(c&&(d=+t.startOf(d,"isoWeek",l)),d=+t.startOf(d,c?"day":r),t.diff(n,e,r)>1e5*a)throw new Error(e+" and "+n+" are too far apart with stepSize of "+a+" "+r);const p=s.ticks.source==="data"&&this.getDataTimestamps();for(u=d,f=0;u+g)}getLabelForValue(t){const e=this._adapter,n=this.options.time;return n.tooltipFormat?e.format(t,n.tooltipFormat):e.format(t,n.displayFormats.datetime)}format(t,e){const s=this.options.time.displayFormats,o=this._unit,r=e||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,n,s){const o=this.options,r=o.ticks.callback;if(r)return z(r,[t,e,n],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,h=l&&a[l],d=c&&a[c],u=n[e],f=c&&d&&u&&u.major;return this._adapter.format(t,s||(f?d:h))}generateTickLabels(t){let e,n,s;for(e=0,n=t.length;e0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,n;if(t.length)return t;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(e=0,n=s.length;e=i[n].pos&&t<=i[s].pos&&({lo:n,hi:s}=Mt(i,"pos",t)),{pos:o,time:a}=i[n],{pos:r,time:l}=i[s]):(t>=i[n].time&&t<=i[s].time&&({lo:n,hi:s}=Mt(i,"time",t)),{time:o,pos:a}=i[n],{time:r,pos:l}=i[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class an extends Ee{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=Qe(e,this.min),this._tableRange=Qe(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:n}=this,s=[],o=[];let r,a,l,c,h;for(r=0,a=t.length;r=e&&c<=n&&s.push(c);if(s.length<2)return[{time:e,pos:0},{time:n,pos:1}];for(r=0,a=s.length;rs-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),n=this.getLabelTimestamps();return e.length&&n.length?t=this.normalize(e.concat(n)):t=e.length?e:n,t=this._cache.all=t,t}getDecimalForValue(t){return(Qe(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return Qe(this._table,n*this._tableRange+this._minPos,!0)}}v(an,"id","timeseries"),v(an,"defaults",Ee.defaults);var Ld=Object.freeze({__proto__:null,CategoryScale:nn,LinearScale:sn,LogarithmicScale:on,RadialLinearScale:_e,TimeScale:Ee,TimeSeriesScale:an});const Id=[Nl,mh,dd,Ld];wt.register(...Id);const ti=2048,Rd=16,zd=1e-5;function Js(i){return Number.isFinite(i)?i:0}function Bd(i){const t=Math.max(0,i.length-ti),e=i.slice(t),n=new Uint8Array(e.length);let s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let d=0;dr){const c=e[r],h=n[r];e[r]=e[a],n[r]=n[a],e[a]=c,n[a]=h}let l=t>>1;for(;l>0&&(a&l)!==0;)a^=l,l>>=1;a|=l}for(let r=2;r<=t;r*=2){const a=r/2,l=-2*Math.PI/r;for(let c=0;ch||!(m>s[g-1])||!(m>s[g+1])||m/a>=d&&u.push({score:m/a,bin:g})}u.sort((g,m)=>m.score-g.score||g.bin-m.bin);const f=new Int32Array(e.topK),p=Math.min(e.topK,u.length);for(let g=0;g0){const a=2*Math.PI*i[n]/o;e[r]=Math.sin(a),e[r+1]=Math.cos(a)}}return e}function jd(i,t,e,n,s=Rd){if(i.length!==t.length)throw new Error("Seasonal fill values and mask must have equal length");if(e.length===0||s<1)throw new Error("Seasonal fill requires one period and at least one phase bin");const o=new Float64Array(s),r=new Float64Array(s);let a=0,l=0;const c=Math.max(1,e[0]);for(let f=0;f=0;)n+=1,s=i.indexOf(e,s+e.length);return n}function Ud(i,t){if(t.dtype!=="F32"&&t.dtype!=="I8")throw new Error(`Tensor ${i} has unsupported dtype: ${String(t.dtype)}`);const e=t.dtype;if(!Array.isArray(t.shape)||t.shape.length===0||!t.shape.every(Zs)||t.shape.some(a=>a<0))throw new Error(`Tensor ${i} has invalid shape`);if(!Array.isArray(t.data_offsets)||t.data_offsets.length!==2||!t.data_offsets.every(Zs))throw new Error(`Tensor ${i} has invalid data offsets`);const[n,s]=t.data_offsets;if(n<0||sa*l,1)*Hd[e];if(s-n!==r)throw new Error(`Tensor ${i} byte length ${s-n} does not match shape ${JSON.stringify(t.shape)}`);return{dtype:e,shape:t.shape,dataOffsets:[n,s]}}function Yd(i){if(i.byteLength<8)throw new Error("Safetensors buffer is too short to contain a header length");const e=new DataView(i,0,8).getUint32(0,!0),n=8+e;if(e===0||n>i.byteLength)throw new Error(`Invalid safetensors header length: ${e}`);const s=new TextDecoder().decode(new Uint8Array(i,8,e));let o;try{o=JSON.parse(s)}catch(h){throw new Error(`Safetensors header is not valid JSON: ${h.message}`)}if(typeof o!="object"||o===null||Array.isArray(o))throw new Error("Safetensors header must be a JSON object");const r=Object.entries(o).filter(([h])=>h!=="__metadata__"),a=new Map;for(const[h,d]of r){if($d(s,h)!==1)throw new Error(`Safetensors header contains duplicate tensor name: ${h}`);if(typeof d!="object"||d===null||Array.isArray(d))throw new Error(`Tensor ${h} metadata must be an object`);const u=Ud(h,d),[f,p]=u.dataOffsets;if(n+p>i.byteLength)throw new Error(`Tensor ${h} extends beyond the safetensors buffer`);a.set(h,u)}if(a.size===0)throw new Error("Safetensors file contains no tensors");const l=[...a.values()].map(h=>h.dataOffsets).sort((h,d)=>h[0]-d[0]);let c;for(const h of l){if(c!==void 0&&h[0]=0&&(u+=i[g*t+d]*e[f+p])}l[h*t+d]=u}return l}function or(i,t,e,n,s){const o=new Float32Array(t*s.length),r=new Float32Array(e);for(let a=0;ag),c=tr(i,t,a),h=Vd(l,c);let d=or(Jd(i,e,l),o,7,s.inProjWeight,s.inProjBias);for(let p=0;p({dwWeight:R(i,`head.fc_blocks.${e}.dw_weight`),dwBias:R(i,`head.fc_blocks.${e}.dw_bias`),normWeight:R(i,`head.fc_blocks.${e}.norm.weight`)}));return{summaryWeight:R(i,"head.summary_proj.weight"),summaryBias:R(i,"head.summary_proj.bias"),queries:R(i,"head.queries"),decoderUpWeight:R(i,"head.decoder_ffns.0.up.weight"),decoderUpBias:R(i,"head.decoder_ffns.0.up.bias"),decoderDownWeight:R(i,"head.decoder_ffns.0.down.weight"),decoderDownBias:R(i,"head.decoder_ffns.0.down.bias"),decoderNormWeight:R(i,"head.decoder_norms.0.weight"),horizonBlocks:t,futureInWeight:R(i,"head.future_conv.in_proj.weight"),futureInBias:R(i,"head.future_conv.in_proj.bias"),futureBlock:{dwWeight:R(i,"head.future_conv.block.dw_weight"),dwBias:R(i,"head.future_conv.block.dw_bias"),pwWeight:R(i,"head.future_conv.block.pw.weight"),pwBias:R(i,"head.future_conv.block.pw.bias"),ffnUpWeight:R(i,"head.future_conv.block.ffn.up.weight"),ffnUpBias:R(i,"head.future_conv.block.ffn.up.bias"),ffnDownWeight:R(i,"head.future_conv.block.ffn.down.weight"),ffnDownBias:R(i,"head.future_conv.block.ffn.down.bias"),norm1Weight:R(i,"head.future_conv.block.norm1.weight"),norm2Weight:R(i,"head.future_conv.block.norm2.weight")},futureOutWeight:R(i,"head.future_conv.out_proj.weight"),futureOutBias:R(i,"head.future_conv.out_proj.bias"),outWeight:R(i,"head.out_proj.weight"),outBias:R(i,"head.out_proj.bias")}}function nt(i,t,e){const n=i[t]??e;if(typeof n!="number"||!Number.isSafeInteger(n))throw new Error(`Fracast head config field ${t} must be an integer`);return n}function tu(i,t){const e=i[t];if(typeof e!="boolean")throw new Error(`Fracast head config field ${t} must be boolean`);return e}function eu(i,t,e){if(i.length!==t*e)throw new Error("Fracast head input shape is invalid");const n=new Float32Array(e*2);for(let s=0;ss.W+b),h=jd(t,e,l,c,s.head_phase_bins),d=a+s.head_future_conv_seed;let u=new Float32Array(d*r);const f=new Float32Array(6);for(let m=0;mr.W+b),h=Zo(c,r.W),d=new Float32Array(5+a*2);d.set(l,5);let u=new Float32Array(r.horizon*a);const f=new Float32Array(a),p=new Float32Array(a);for(let m=0;mt*e,1)}function hu(i,t){var s,o;const e=new Map,n=new Set;for(const r of Object.keys(t.quantMap).sort()){const a=t.quantMap[r];if(a===void 0)throw new Error(`Missing W8 mapping for ${r}`);if(a.scheme!==au)throw new Error(`Unsupported W8 scheme for ${r}: ${a.scheme}`);if(a.axis!==0||a.dtype!=="int8")throw new Error(`Unsupported W8 axis or dtype for ${r}`);const l=qd(i,a.qweight),c=ln(i,a.scale),h=(s=i.tensors.get(a.qweight))==null?void 0:s.shape,d=(o=i.tensors.get(a.scale))==null?void 0:o.shape;if(h===void 0||d===void 0)throw new Error(`Missing tensor metadata for W8 mapping ${r}`);const u=d.length===h.length&&d[0]===h[0]&&d.slice(1).every(m=>m===1)&&c.length===h[0],f=d.every(m=>m===1)&&c.length===1;if(!u&&!f)throw new Error(`W8 scale shape for ${r} does not match output channels`);const p=cu(h),g=new Float32Array(l.length);for(let m=0;mtypeof n!="number"))throw new Error("Fracast engine config field quantiles must be numeric");const e=t;if(e.length<1)throw new Error("Fracast engine requires at least one quantile");return e}function pu(i){const t=uu(i),e=du(i),n=Kd(e),s=Qd(e),o=t,r=gu(t),a=fu(t,"horizon");if(s.outBias.length!==r.length)throw new Error("Fracast output tensor and quantile config do not match");return{quantiles:r,predict(l){const c=Bd(l),h=Zd(c.values,c.mask,Float32Array.from(c.coverage),o,n),d=ou(h,c.values,c.mask,t,s);if(d.length!==a*r.length)throw new Error("Fracast head emitted an unexpected forecast shape");const u=new Float64Array(d.length);for(let f=0;fc.values.length),s=new Set(n).size===1?`${n[0]??0} points each`:`lengths ${n.join("/")}`,o=n.reduce((c,h)=>c+h,0),r=t>0?o/(t/1e3)/1e3:0,a=`${i.length} series · ${s} · ${lr(t)} · ${r.toFixed(1)}k points/s`;if(e===void 0)return a;if(typeof e=="number")return`${a} · horizon ${e}`;const l=Array.from(new Set(e));return l.length===1?`${a} · horizon ${l[0]}`:`${a} · horizons ${l.join("/")}`}function xu(i){const t=Math.max(2,(95-i)*.18);return Math.min(95,i+t)}const xi=8,_u=48,cn=8,Se=_u;function yu(i,t=2){return Array.from({length:t},(e,n)=>({name:`Series ${i+n}`,values:new Float64Array(0)}))}function cr(i,t){const n=t.split(/[\s,;]+/).filter(s=>s.length>0).map(s=>s.toLowerCase()==="nan"?Number.NaN:Number(s));if(n.length!Number.isNaN(s)&&!Number.isFinite(s)))throw new Error(`${i||"Series"} contains a non-numeric value.`);return{name:i.trim()||`Series ${n.length}`,values:Float64Array.from(n.slice(-2048))}}function wu(){return Float64Array.from({length:240},(i,t)=>42+15*Math.sin(2*Math.PI*t/24)+4*Math.sin(2*Math.PI*t/8)+.8*Math.sin(t/1.7))}function oe(i){return Number.isFinite(i)?Math.min(Se,Math.max(cn,Math.round(i))):cn}function hr(i,t){const e=oe(t),n=i.length-e;if(ns)throw new Error(`Forecast horizon ${n} exceeds native horizon ${s}.`);return i.slice(0,n*t)}function Mu(i){for(let t=i.length-1;t>=0;t-=1){const e=i[t];if(e!==null&&Number.isFinite(e))return e}return null}function ku(i){return Array.from(i,(t,e)=>({x:e+1,y:t===null||!Number.isFinite(t)?null:t}))}function Su(i,t){return Array.from(t,(e,n)=>({x:i+n+1,y:e===null||!Number.isFinite(e)?null:e}))}function Hi(i,t,e,n){if(i.length===0)throw new Error("Forecast connection needs history observations.");if(!Number.isSafeInteger(e)||e<1)throw new Error("Forecast quantile count must be positive.");if(t.length%e!==0)throw new Error("Native forecast length does not match the quantile count.");if(n<0||n>=e)throw new Error("Forecast quantile index is out of range.");const s=t.length/e,o={x:i.length,y:Mu(i)},r=Array.from({length:s},(a,l)=>({x:i.length+l+1,y:t[l*e+n]}));return[o,...r]}const An=[{id:"traffic",label:"Traffic",source:"Synthetic: 24- and 8-period traffic waveform",description:"Daily-style traffic cycle with a shorter harmonic and small ripple.",series:[{name:"Traffic",values:wu()}]}];function Pu(i){return An.find(t=>t.id===i)}function j(i,t){const e=document.createElement(i);return t!==void 0&&(e.className=t),e}const Yt=document.querySelector("#status"),Au=document.querySelector("#progress-bar"),Dn=document.querySelector("#progress-track"),Du=document.querySelector("#series"),Cu=document.querySelector("#empty-series"),dr=document.querySelector("#plots"),ur=document.querySelector("#plot-empty"),We=document.querySelector("#preset"),Ou=document.querySelector("#preset-source"),_i=document.querySelector("#run"),fr=document.querySelector("#add"),fe=document.querySelector("#activity"),Qs=["#17786f","#a85820","#5d63a8","#8f2f57","#477a2c","#8a6c1f"];let pt,Tu=0,gr=0,yi,Tt=!1;const $i=[],Y=new Map;function pr(i){return Array.from(i,t=>t.toFixed(3)).join(", ")}function qt(){Cu.hidden=Y.size>0,ur.hidden=Y.size>0;const i=Y.size>0&&Tt===!1&&Array.from(Y.values()).every(t=>{try{return cr(document.getElementById(t.name).value,t.input.value),!0}catch{return!1}});_i.textContent=Y.size>0&&Tt===!1?"Forecast":"Load preset",_i.disabled=Y.size===0||Tt||!i}function mr(i,t,e){if(Y.size>=6)return;const n=Tu++,s=j("article","series-card");s.dataset.series=String(n);const o=j("div","series-head"),r=j("label");r.htmlFor=`name-${n}`,r.textContent="Name";const a=j("input","name");a.id=`name-${n}`,a.value=i,a.maxLength=24;const l=j("button","remove");l.type="button",l.title="Remove series",l.textContent="Remove",o.append(r,a,l);const c=j("label");c.htmlFor=`values-${n}`,c.textContent="Observations";const h=j("textarea");h.id=`values-${n}`,h.rows=4,h.spellcheck=!1,h.value=pr(t);const d=j("p","source-note");d.textContent=e?`${e.source} · held-out truth ${e.truth.length}`:"Custom input · no held-out truth";const u=j("div","series-horizon"),f=j("div","series-horizon-head"),p=j("label");p.htmlFor=`horizon-${n}`,p.textContent="Forecast horizon";const g=j("output","series-horizon-value");g.id=`horizon-value-${n}`,g.value=String(Se);const m=j("input","series-horizon-range");m.id=`horizon-${n}`,m.type="range",m.min=String(cn),m.max=String(Se),m.step="1",m.value=String(Se),m.setAttribute("aria-describedby",g.id),f.append(p,g),u.append(f,m),s.append(o,c,h,d,u),Du.append(s);const b={root:s,name:a.id,input:h,source:d,horizon:m,horizonValue:g,preset:e===void 0?void 0:{...e}};Y.set(n,b),h.addEventListener("input",()=>{b.preset=void 0,d.textContent="Custom input · no held-out truth",qt()}),m.addEventListener("input",()=>{b.horizonValue.value=String(oe(Number(m.value)))}),m.addEventListener("change",()=>{const x=oe(Number(m.value));m.value=String(x),b.horizonValue.value=String(x),b.preset!==void 0&&Lu(b),Sr().catch(()=>{})}),l.addEventListener("click",()=>{Y.size<=1||(Y.delete(n),s.remove(),qt(),yr(_r()))}),qt()}function Fu(){for(const i of Y.values())i.root.remove();Y.clear(),qt()}function Eu(){for(const i of An){const t=j("option");t.value=i.id,t.textContent=i.label,We.append(t)}}function br(){return Pu(We.value)??An[0]}function xr(){const i=br();Ou.textContent=`${i.source}. ${i.description}`}function Lu(i){if(i.preset===void 0)return;const t=oe(Number(i.horizon.value)),e=hr(i.preset.fullValues,t);i.preset.truth=e.truth,i.input.value=pr(e.input),i.source.textContent=`${i.preset.source} · held-out truth ${t}`}function Iu(){const i=br();Tt=!1,Fu();for(const t of i.series){const e=hr(t.values,Se);mr(t.name,e.input,{fullValues:t.values,source:i.source,truth:e.truth})}}function Ru(){const i=Y.size===0?2:1;for(const t of yu(Y.size+1,i))mr(t.name,t.values);Tt=!1,qt()}function _r(){return Array.from(Y.entries()).map(([i,t])=>{var n;const e=cr(document.getElementById(t.name).value,t.input.value);return{id:i,state:{...e,source:t.source.textContent??"Custom input",horizon:oe(Number(t.horizon.value)),truth:(n=t.preset)==null?void 0:n.truth}}})}function zu(i,t,e){const n=j("article","chart-card"),s=j("div","chart-head"),o=j("h3","chart-title");o.textContent=`${i+1}. ${t}`;const r=j("span","chart-source");r.textContent=e;const a=j("div","chart-body"),l=j("canvas");return l.setAttribute("role","img"),l.setAttribute("aria-label",`Forecast for ${t}`),s.append(o,r),a.append(l),n.append(s,a),dr.append(n),l}function yr(i){for(const t of $i)t.destroy();$i.length=0,dr.replaceChildren(),ur.hidden=i.length>0,i.length!==0&&i.forEach(({state:t},e)=>{const n=Qs[e%Qs.length],s=zu(e,t.name,t.source),o=Array.from(t.values,u=>Number.isFinite(u)?u:null),r=(pt==null?void 0:pt.quantiles.length)??9,a=0,l=Math.floor(r/2),c=r-1,h=[{label:"Input",data:ku(o),borderColor:n,borderWidth:1.8,pointRadius:0,tension:.25}];if(t.forecast&&pt){const u=Hi(o,t.forecast,r,a),f=Hi(o,t.forecast,r,l),p=Hi(o,t.forecast,r,c);h.push({label:"10%",data:u,borderColor:"transparent",pointRadius:0,fill:"+1",backgroundColor:`${n}22`}),h.push({label:"90%",data:p,borderColor:"transparent",pointRadius:0}),h.push({label:"Forecast",data:f,borderColor:n,borderDash:[5,3],borderWidth:2,pointRadius:0,tension:.25})}t.truth!==void 0&&h.push({label:"Ground truth",data:Su(o.length,Array.from(t.truth)),borderColor:"#5c686f",borderWidth:2.2,pointRadius:0,tension:.25});const d={type:"line",data:{datasets:h},options:{animation:!1,maintainAspectRatio:!1,interaction:{mode:"nearest",intersect:!1},plugins:{legend:{labels:{boxWidth:12,usePointStyle:!0}},tooltip:{filter:u=>u.dataset.label!==void 0&&u.dataset.label.includes("%")===!1}},scales:{x:{type:"linear",title:{display:!0,text:"Time index"}},y:{title:{display:!0,text:"Value"}}}}};$i.push(new wt(s,d))})}function Ie(i,t="info"){var o;const e=j("li",`activity-item ${t}`),n=j("span","activity-time");n.textContent=new Date().toLocaleTimeString("en-GB",{hour12:!1});const s=j("span");for(s.textContent=i,e.append(n,s),fe.append(e);fe.children.length>12;)(o=fe.firstElementChild)==null||o.remove();fe.scrollTop=fe.scrollHeight}function Re(i){gr=i,Au.style.width=`${Math.round(i)}%`}function wr(i){window.clearInterval(yi),Re(4),Dn.classList.add("visible"),Yt.textContent=i,yi=window.setInterval(()=>{Re(xu(gr))},120)}function vr(){window.clearInterval(yi),Re(100),window.setTimeout(()=>{Dn.classList.remove("visible"),Re(0)},450)}function Mr(i){window.clearInterval(yi),Dn.classList.remove("visible"),Re(0),Yt.textContent=i}function kr(){return new Promise(i=>{requestAnimationFrame(()=>window.setTimeout(i,30))})}function Bu(){if(!pt)throw new Error("Checkpoint is still loading.");const i=_r(),t=performance.now();for(const o of i){const r=pt.predict(o.state.values);o.state.forecast=vu(r,pt.quantiles.length,o.state.horizon)}const e=performance.now()-t;yr(i);const n=i.map(o=>o.state.horizon),s=bu(i.map(o=>o.state),e,n);return Yt.textContent=`Forecast complete · ${s}`,s}function hn(i){_i.disabled=i,fr.disabled=i,We.disabled=i;for(const t of Y.values())t.horizon.disabled=i}async function Sr(){if(!pt)throw new Error("Checkpoint is still loading.");hn(!0),wr("Forecasting...");try{await kr(),Ie(Bu(),"info"),vr()}catch(i){const t=i instanceof Error?i.message:"Forecast failed";throw Mr(t),Ie(`Forecast failed · ${t}`,"error"),i}finally{hn(!1)}}_i.addEventListener("click",()=>{(async()=>{try{(Y.size===0||Tt)&&Iu(),await Sr()}catch{}})()});fr.addEventListener("click",()=>{if(!pt){Yt.textContent="Checkpoint is still loading.";return}if(Y.size>=6){Yt.textContent="Up to six series are supported.";return}Ru(),Yt.textContent=`${Y.size} series ready · enter observations to forecast.`});We.addEventListener("change",()=>{Tt=!0,xr(),qt()});function Wu(){Eu(),We.value="traffic",Tt=!1,qt(),xr()}async function Nu(){Wu(),Ie("Playground ready · downloading W8 checkpoint");const i=performance.now();wr("Loading W8 checkpoint...");const[t,e,n]=await Promise.all([fetch("./config.json").then(o=>{if(!o.ok)throw new Error(`config.json ${o.status}`);return o.json()}),fetch("./w8_manifest.json").then(o=>{if(!o.ok)throw new Error(`w8_manifest.json ${o.status}`);return o.json()}),fetch("./model.int8.safetensors").then(o=>{if(!o.ok)throw new Error(`model.int8.safetensors ${o.status}`);return o.arrayBuffer()})]);await kr(),pt=pu({config:t,weights:n,w8Manifest:e});const s=mu(performance.now()-i,n.byteLength);Yt.textContent=`${s} · Load preset`,Ie(s),vr(),hn(!1)}Nu().catch(i=>{const t=i instanceof Error?i.message:"Loading failed";Mr(t),Ie(`Checkpoint loading failed · ${t}`,"error")});