UNPKG

@kondi/uplot

Version:

A small, fast chart for time series, lines, areas, ohlc & bars

2 lines 52.9 kB
/*! https://github.com/leeoniya/uPlot (v1.6.33-spannulls.1) */ var uPlot=function(){"use strict";function e(e,t,l,n){let i;l=l||0;let s=2147483647>=(n=n||t.length-1);for(;n-l>1;)i=s?l+n>>1:b((l+n)/2),e>t[i]?l=i:n=i;return e-t[l]>t[n]-e?n:l}function t(e){return(t,l,n)=>{let i=-1,s=-1;for(let s=l;n>=s;s++)if(e(t[s])){i=s;break}for(let i=n;i>=l;i--)if(e(t[i])){s=i;break}return[i,s]}}const l=e=>null!=e,n=e=>null!=e&&e>0,i=t(l),s=t(n);function o(e,t,l,n){2==l&&(n=!0);let i=T(e),s=T(t);e==t&&(-1==i?(e*=l,t/=l):(e/=l,t*=l));let o=10==l?S:z,r=1==i?b:v,u=1==s?v:b,a=o(w(e)),f=o(w(t)),c=r(a),h=u(f),p=M(l,c),d=M(l,h);return 10==l&&(0>c&&(p=j(p,-c)),0>h&&(d=j(d,-h))),n?(e=p*i,t=d*s):(e=U(e,M(l,b(a)),!1),t=L(t,M(l,b(f)),!1)),[e,t]}function r(e,t,l,n){let i=o(e,t,l,n);return 0==e&&(i[0]=0),0==t&&(i[1]=0),i}const u={mode:3,pad:.1},a={pad:0,soft:null,mode:0},f={min:a,max:a};function c(e,t,l,n){return ee(l)?p(e,t,l):(a.pad=l,a.soft=n?0:null,a.mode=n?3:0,p(e,t,f))}function h(e,t){return null==e?t:e}function p(e,t,l){let n=l.min,i=l.max,s=h(n.pad,0),o=h(i.pad,0),r=h(n.hard,-E),u=h(i.hard,E),a=h(n.soft,E),f=h(i.soft,-E),c=h(n.mode,0),p=h(i.mode,0),d=t-e,m=S(d),g=y(w(e),w(t)),x=S(g),_=w(x-m);(1e-24>d||_>10)&&(d=0,0!=e&&0!=t||(d=1e-24,2==c&&a!=E&&(s=0),2==p&&f!=-E&&(o=0)));let v=d||g||1e3,T=S(v),z=M(10,b(T)),D=j(U(e-v*(0==d?0==e?.1:1:s),z/10),24),P=a>e||1!=c&&(3!=c||D>a)&&(2!=c||a>D)?E:a,A=y(r,P>D&&e>=P?P:k(P,D)),C=j(L(t+v*(0==d?0==t?.1:1:o),z/10),24),W=t>f||1!=p&&(3!=p||f>C)&&(2!=p||C>f)?-E:f,Y=k(u,C>W&&W>=t?W:y(W,C));return A==Y&&0==A&&(Y=100),[A,Y]}const d=new Intl.NumberFormat,m=e=>d.format(e),g=Math,x=g.PI,w=g.abs,b=g.floor,_=g.round,v=g.ceil,k=g.min,y=g.max,M=g.pow,T=g.sign,S=g.log10,z=g.log2,D=(e,t=1)=>g.asinh(e/t),E=1/0;function P(e){return 1+(0|S((e^e>>31)-(e>>31)))}function A(e,t,l){return k(y(e,t),l)}function C(e){return"function"==typeof e}function W(e){return C(e)?e:()=>e}const Y=e=>e,H=(e,t)=>t,R=()=>null,F=()=>!0,N=(e,t)=>e==t,G=/\.\d*?(?=9{6,}|0{6,})/gm,I=e=>{if(X(e)||V.has(e))return e;const t=""+e,l=t.match(G);if(null==l)return e;let n=l[0].length-1;if(-1!=t.indexOf("e-")){let[e,l]=t.split("e");return+`${I(e)}e${l}`}return j(e,n)};function O(e,t,l=!0){return l?I(j(I(e/t))*t):j(e/t)*t}function L(e,t,l=!0){return l?I(v(I(e/t))*t):v(e/t)*t}function U(e,t,l=!0){return l?I(b(I(e/t))*t):b(e/t)*t}function j(e,t=0){if(X(e))return e;let l=10**t;return _(e*l*(1+Number.EPSILON))/l}const V=new Map;function B(e){return((""+e).split(".")[1]||"").length}function Z(e,t,l,n){let i=[],s=n.map(B);for(let o=t;l>o;o++){let t=w(o),l=j(M(e,o),t);for(let r=0;n.length>r;r++){let u=10==e?+`${n[r]}e${o}`:n[r]*l,a=(0>o?t:0)+(s[r]>o?s[r]:0),f=10==e?u:j(u,a);i.push(f),V.set(f,a)}}return i}const $={},J=[],q=[null,null],K=Array.isArray,X=Number.isInteger;function Q(e){return"string"==typeof e}function ee(e){let t=!1;if(null!=e){let l=e.constructor;t=null==l||l==Object}return t}function te(e){return null!=e&&"object"==typeof e}const le=Object.getPrototypeOf(Uint8Array),ne="__proto__";function ie(e,t=ee){let l;if(K(e)){let n=e.find(e=>null!=e);if(K(n)||t(n)){l=Array(e.length);for(let n=0;e.length>n;n++)l[n]=ie(e[n],t)}else l=e.slice()}else if(e instanceof le)l=e.slice();else if(t(e)){l={};for(let n in e)n!=ne&&(l[n]=ie(e[n],t))}else l=e;return l}function se(e){let t=arguments;for(let l=1;t.length>l;l++){let n=t[l];for(let t in n)t!=ne&&(ee(e[t])?se(e[t],ie(n[t])):e[t]=ie(n[t]))}return e}function oe(e,t,l){for(let n,i=0,s=-1;t.length>i;i++){let o=t[i];if(o>s){for(n=o-1;n>=0&&null==e[n];)e[n--]=null;for(n=o+1;l>n&&null==e[n];)e[s=n++]=null}}}const re="undefined"==typeof queueMicrotask?e=>Promise.resolve().then(e):queueMicrotask,ue="width",ae="height",fe="top",ce="bottom",he="left",pe="right",de="#000",me=de+"0",ge="mousemove",xe="mousedown",we="mouseup",be="mouseenter",_e="mouseleave",ve="dblclick",ke="change",ye="dppxchange",Me="--",Te="u-off",Se="u-label",ze="undefined"!=typeof window,De=ze?document:null,Ee=ze?window:null;let Pe,Ae;function Ce(e,t){if(null!=t){let l=e.classList;!l.contains(t)&&l.add(t)}}function We(e,t){let l=e.classList;l.contains(t)&&l.remove(t)}function Ye(e,t,l){e.style[t]=l+"px"}function He(e,t,l,n){let i=De.createElement(e);return null!=t&&Ce(i,t),null!=l&&l.insertBefore(i,n),i}function Re(e,t){return He("div",e,t)}const Fe=new WeakMap;function Ne(e,t,l,n,i){let s="translate("+t+"px,"+l+"px)";s!=Fe.get(e)&&(e.style.transform=s,Fe.set(e,s),0>t||0>l||t>n||l>i?Ce(e,Te):We(e,Te))}const Ge=new WeakMap;function Ie(e,t,l){let n=t+l;n!=Ge.get(e)&&(Ge.set(e,n),e.style.background=t,e.style.borderColor=l)}const Oe=new WeakMap;function Le(e,t,l,n){let i=t+""+l;i!=Oe.get(e)&&(Oe.set(e,i),e.style.height=l+"px",e.style.width=t+"px",e.style.marginLeft=n?-t/2+"px":0,e.style.marginTop=n?-l/2+"px":0)}const Ue={passive:!0},je={...Ue,capture:!0};function Ve(e,t,l,n){t.addEventListener(e,l,n?je:Ue)}function Be(e,t,l){t.removeEventListener(e,l,Ue)}ze&&function e(){let t=devicePixelRatio;Pe!=t&&(Pe=t,Ae&&Be(ke,Ae,e),Ae=matchMedia(`(min-resolution: ${Pe-.001}dppx) and (max-resolution: ${Pe+.001}dppx)`),Ve(ke,Ae,e),Ee.dispatchEvent(new CustomEvent(ye)))}();const Ze=["January","February","March","April","May","June","July","August","September","October","November","December"],$e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Je(e){return e.slice(0,3)}const qe=$e.map(Je),Ke=Ze.map(Je),Xe={MMMM:Ze,MMM:Ke,WWWW:$e,WWW:qe};function Qe(e){return(10>e?"0":"")+e}const et={YYYY:e=>e.getFullYear(),YY:e=>(e.getFullYear()+"").slice(2),MMMM:(e,t)=>t.MMMM[e.getMonth()],MMM:(e,t)=>t.MMM[e.getMonth()],MM:e=>Qe(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>Qe(e.getDate()),D:e=>e.getDate(),WWWW:(e,t)=>t.WWWW[e.getDay()],WWW:(e,t)=>t.WWW[e.getDay()],HH:e=>Qe(e.getHours()),H:e=>e.getHours(),h:e=>{let t=e.getHours();return 0==t?12:t>12?t-12:t},AA:e=>12>e.getHours()?"AM":"PM",aa:e=>12>e.getHours()?"am":"pm",a:e=>12>e.getHours()?"a":"p",mm:e=>Qe(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>Qe(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>function(e){return(10>e?"00":100>e?"0":"")+e}(e.getMilliseconds())};function tt(e,t){t=t||Xe;let l,n=[],i=/\{([a-z]+)\}|[^{]+/gi;for(;l=i.exec(e);)n.push("{"==l[0][0]?et[l[1]]:l[0]);return e=>{let l="";for(let i=0;n.length>i;i++)l+="string"==typeof n[i]?n[i]:n[i](e,t);return l}}const lt=(new Intl.DateTimeFormat).resolvedOptions().timeZone,nt="2-digit",it={weekday:"short",year:"numeric",month:nt,day:nt,hour:nt,minute:nt,second:nt,fractionalSecondDigits:3,timeZoneName:"longOffset"},st={};class ot extends Date{tz=null;#e=!1;#t=null;constructor(...e){super(...e),e[0]instanceof ot&&(this.tz=e[0].tz,this.#t=e[0].#t,this.#e=e[0].#e)}#l(e,t,l,n,i=0){let s=this.#t;return this.#e?e.call(this):null==s?t.call(this):+s.slice(l,n)+i}setTimeZone(e){if(this.tz=e,"UTC"==e||"Etc/UTC"==e)this.#e=!0;else{let t=function(e){return null==st[e]&&(st[e]=new Intl.DateTimeFormat("sv",{...it,timeZone:e}).format),st[e]}(e),l=t(this);l.endsWith("GMT")&&(l+="+00:00"),this.#t=l}}getFullYear(){return this.#l(this.getUTCFullYear,super.getFullYear,-33,-29)}getMonth(){return this.#l(this.getUTCMonth,super.getMonth,-28,-26,-1)}getDate(){return this.#l(this.getUTCDate,super.getDate,-25,-23)}getHours(){return this.#l(this.getUTCHours,super.getHours,-22,-20)}getMinutes(){return this.#l(this.getUTCMinutes,super.getMinutes,-19,-17)}getSeconds(){return this.#l(this.getUTCSeconds,super.getSeconds,-16,-14)}getMilliseconds(){return this.#l(this.getUTCMilliseconds,super.getMilliseconds,-13,-10)}getDay(){let e=this.#t;return this.#e?this.getUTCDay():null==e?super.getDay():"s"==e[0]?0:"m"==e[0]?1:"i"==e[1]?2:"o"==e[0]?3:"o"==e[1]?4:"f"==e[0]?5:"l"==e[0]?6:-1}getTimezoneOffset(){let e=this.#t;return this.#e?0:null==e?super.getTimezoneOffset():(60*+e.slice(-5,-3)+ +e.slice(-2))*("-"==e.at(-6)?-1:1)}}function rt(e,t){let l=e.getTime()-(e.getMilliseconds()+1e3*e.getSeconds()+6e4*e.getMinutes()+36e5*e.getHours()+864e5*(4==t?e.getDate()-1:5==t?function(e){let t=e.getFullYear(),l=e.getMonth()+1;return 31*--l-(l>1?(1054267675>>3*l-6&7)-(3&t||!(t%25)&&15&t?0:1):0)+e.getDate()}(e)-1:0)),n=new ot(l);n.setTimeZone(e.tz);let i=n.getHours();return i>0&&(n=new ot(l+36e5*(i>12?24-i:-i)),n.setTimeZone(e.tz)),n}const ut=e=>e%1==0,at=[1,2,2.5,5],ft=Z(10,-32,0,at),ct=Z(10,0,32,at),ht=ct.filter(ut),pt=ft.concat(ct),dt="{YYYY}",mt="\n"+dt,gt="{M}/{D}",xt="\n"+gt,wt=xt+"/{YY}",bt="{aa}",_t="{h}:{mm}"+bt,vt="\n"+_t,kt=":{ss}",yt=null;function Mt(e){let t=1e3*e,l=60*t,n=60*l,i=24*n,s=30*i,o=365*i;return[(1==e?Z(10,0,3,at).filter(ut):Z(10,-3,0,at)).concat([t,5*t,10*t,15*t,30*t,l,5*l,10*l,15*l,30*l,n,2*n,3*n,4*n,6*n,8*n,12*n,i,2*i,3*i,4*i,5*i,6*i,7*i,8*i,9*i,10*i,15*i,s,2*s,3*s,4*s,6*s,o,2*o,5*o,10*o,25*o,50*o,100*o]),[[o,dt,yt,yt,yt,yt,yt,yt,1],[28*i,"{MMM}",mt,yt,yt,yt,yt,yt,1],[i,gt,mt,yt,yt,yt,yt,yt,1],[n,"{h}"+bt,wt,yt,xt,yt,yt,yt,1],[l,_t,wt,yt,xt,yt,yt,yt,1],[t,kt,wt+" "+_t,yt,xt+" "+_t,yt,vt,yt,1],[e,kt+".{fff}",wt+" "+_t,yt,xt+" "+_t,yt,vt,yt,1]],function(t){return(l,r,u,a,f)=>{let c=[],h=f>=o,p=f>=s&&o>f,d=f>=i&&s>f,m=f>n&&i>f,g=t(u),x=j(g*e,3),w=j(rt(g,h||p?5:d?4:3)*e,3);if(d){let l=f/i,s=w+f*b((g.getDate()-1)/l);for(;;){let i=t(s),o=i.getHours();if(0!=o&&(s+=o>12?n:-n,i=t(s)),(i.getDate()-1)%l>0&&(i=rt(i,4),s=i.getTime()*e,.7*f>s-c[c.length-1]&&c.pop()),s>a)break;u>s||c.push(s),s+=f}}else if(p||h){let l=1,n=1,r=0,d=0;p?(l=f/s,n=32,r=4,d=g.getMonth()):h&&(l=f/o,n=366,r=5,d=g.getYear());let m=w+(f=l*n*i)*b(d/n);for(;m=rt(t(m),r).getTime()*e,m<=a;)u>m||c.push(m),m+=f}else if(m){let e=f/n,l=w+f*b(g.getHours()/e);for(;t(l).getHours()%e>0&&(l+=t(l-n).getHours()%e==0?-n:n),l<=a;)u>l||c.push(l),l+=f}else{let e=w+L(x-w,f);for(;e<=a;)u>e||c.push(e),e+=f;c.push(e)}return c}}]}const[Tt,St,zt]=Mt(1),[Dt,Et,Pt]=Mt(.001);function At(e,t){return e.map(e=>e.map((l,n)=>0==n||8==n||null==l?l:t(1==n||0==e[8]?l:e[1]+l)))}function Ct(e,t){return(l,n,i,s,o)=>{let r,u,a,f,c,h,p=t.find(e=>o>=e[0])||t[t.length-1];return n.map(t=>{let l=e(t),n=l.getFullYear(),i=l.getMonth(),s=l.getDate(),o=l.getHours(),d=l.getMinutes(),m=l.getSeconds(),g=n!=r&&p[2]||i!=u&&p[3]||s!=a&&p[4]||o!=f&&p[5]||d!=c&&p[6]||m!=h&&p[7]||p[1];return r=n,u=i,a=s,f=o,c=d,h=m,g(l)})}}function Wt(e,t){return t(e)}function Yt(e,t){return(l,n,i,s)=>null==s?Me:t(e(n))}Z(2,-53,53,[1]);const Ht={show:!0,live:!0,isolate:!1,mount:()=>{},markers:{show:!0,width:2,stroke:function(e,t){let l=e.series[t];return l.width?l.stroke(e,t):l.points.width?l.points.stroke(e,t):null},fill:function(e,t){return e.series[t].fill(e,t)},dash:"solid"},idx:null,idxs:null,values:[]},Rt=[0,0];function Ft(e,t,l,n=!0){return e=>{0==e.button&&(!n||e.target==t)&&l(e)}}function Nt(e,t,l,n=!0){return e=>{(!n||e.target==t)&&l(e)}}const Gt={show:!0,x:!0,y:!0,lock:!1,move:function(e,t,l){return Rt[0]=t,Rt[1]=l,Rt},points:{one:!1,show:function(e,t){let l=e.cursor.points,n=Re(),i=l.size(e,t);Ye(n,ue,i),Ye(n,ae,i);let s=i/-2;Ye(n,"marginLeft",s),Ye(n,"marginTop",s);let o=l.width(e,t,i);return o&&Ye(n,"borderWidth",o),n},size:function(e,t){return e.series[t].points.size},width:0,stroke:function(e,t){let l=e.series[t].points;return l._stroke||l._fill},fill:function(e,t){let l=e.series[t].points;return l._fill||l._stroke}},bind:{mousedown:Ft,mouseup:Ft,click:Ft,dblclick:Ft,mousemove:Nt,mouseleave:Nt,mouseenter:Nt},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(e,t)=>{t.stopPropagation(),t.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(e,t,l,n,i)=>n-i,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},It={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Ot=se({},It,{filter:H}),Lt=se({},Ot,{size:10}),Ut=se({},It,{show:!1}),jt='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',Vt="bold "+jt,Bt={show:!0,scale:"x",stroke:de,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:Vt,side:2,grid:Ot,ticks:Lt,border:Ut,font:jt,lineGap:1.5,rotate:0},Zt={show:!0,scale:"x",auto:!1,sorted:1,min:E,max:-E,idxs:[]};function $t(e,t){return t.map(e=>null==e?"":m(e))}function Jt(e,t,l,n,i,s,o){let r=[],u=V.get(i)||0;for(let e=l=o?l:j(L(l,i),u);n>=e;e=j(e+i,u))r.push(Object.is(e,-0)?0:e);return r}function qt(t,l,n,i,s){const o=[],r=t.scales[t.axes[l].scale].log,u=b((10==r?S:z)(n));s=M(r,u),10==r&&(s=pt[e(s,pt)]);let a=n,f=s*r;10==r&&(f=pt[e(f,pt)]);do{o.push(a),a+=s,10!=r||V.has(a)||(a=j(a,V.get(s))),f>a||(f=(s=a)*r,10==r&&(f=pt[e(f,pt)]))}while(i>=a);return o}function Kt(e,t,l,n,i){let s=e.scales[e.axes[t].scale].asinh,o=n>s?qt(e,t,y(s,l),n,i):[s],r=0>n||l>0?[]:[0];return(-s>l?qt(e,t,y(s,-n),-l,i):[s]).reverse().map(e=>-e).concat(r,o)}const Xt=/./,Qt=/[12357]/,el=/[125]/,tl=/1/,ll=(e,t,l,n)=>e.map((e,i)=>4==t&&0==e||i%n==0&&l.test(e.toExponential()[0>e?1:0])?e:null);function nl(e,t,l){let n=e.axes[l],i=n.scale,s=e.scales[i],o=e.valToPos,r=n._space,u=o(10,i),a=o(9,i)-u<r?o(7,i)-u<r?o(5,i)-u<r?tl:el:Qt:Xt;if(a==tl){let e=w(o(1,i)-u);if(r>e)return ll(t.slice().reverse(),s.distr,a,v(r/e)).reverse()}return ll(t,s.distr,a,1)}function il(e,t,l){let n=e.axes[l],i=n.scale,s=n._space,o=e.valToPos,r=w(o(1,i)-o(2,i));return s>r?ll(t.slice().reverse(),3,Xt,v(s/r)).reverse():t}function sl(e,t,l,n){return null==n?Me:null==t?"":m(t)}const ol={show:!0,scale:"y",stroke:de,space:30,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:Vt,side:3,grid:Ot,ticks:Lt,border:Ut,font:jt,lineGap:1.5,rotate:0},rl={scale:null,auto:!0,sorted:0,min:E,max:-E},ul=(e,t,l,n,i)=>i,al={show:!0,auto:!0,sorted:0,gaps:ul,alpha:1,facets:[se({},rl,{scale:"x"}),se({},rl,{scale:"y"})]},fl={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,spanNulls:!1,gaps:ul,alpha:1,points:{show:function(e,t){let{scale:l,idxs:n}=e.series[0],i=e._data[0],s=e.valToPos(i[n[0]],l,!0),o=e.valToPos(i[n[1]],l,!0);return w(o-s)/(e.series[t].points.space*e.pxRatio)>=n[1]-n[0]},filter:null},values:null,min:E,max:-E,idxs:[],path:null,clip:null};function cl(e,t,l){return l/10}const hl={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},pl=se({},hl,{time:!1,ori:1}),dl={};function ml(e){let t=dl[e];return t||(t={key:e,plots:[],sub(e){t.plots.push(e)},unsub(e){t.plots=t.plots.filter(t=>t!=e)},pub(e,l,n,i,s,o,r){for(let u=0;t.plots.length>u;u++)t.plots[u]!=l&&t.plots[u].pub(e,l,n,i,s,o,r)}},null!=e&&(dl[e]=t)),t}function gl(e,t,l){const n=e.mode,i=e.series[t],s=2==n?e._data[t]:e._data,o=e.scales,r=e.bbox;let u=s[0],a=2==n?s[1]:s[t],f=2==n?o[i.facets[0].scale]:o[e.series[0].scale],c=2==n?o[i.facets[1].scale]:o[i.scale],h=r.left,p=r.top,d=r.width,m=r.height,g=e.valToPosH,x=e.valToPosV;return 0==f.ori?l(i,u,a,f,c,g,x,h,p,d,m,Ml,Sl,Dl,Pl,Cl):l(i,u,a,f,c,x,g,p,h,m,d,Tl,zl,El,Al,Wl)}function xl(e,t){let l=0,n=0,i=h(e.bands,J);for(let e=0;i.length>e;e++){let s=i[e];s.series[0]==t?l=s.dir:s.series[1]==t&&(n|=1==s.dir?1:2)}return[l,1==n?-1:2==n?1:3==n?2:0]}function wl(e,t,l,n,i){let s=e.series[t],o=e.scales[2==e.mode?s.facets[1].scale:s.scale];return-1==i?o.min:1==i?o.max:3==o.distr?1==o.dir?o.min:o.max:0}function bl(e,t,l,n,i,s){return gl(e,t,(e,t,o,r,u,a,f,c,h,p,d)=>{let m=e.pxRound;const g=0==r.ori?Sl:zl;let x,w;1==r.dir*(0==r.ori?1:-1)?(x=l,w=n):(x=n,w=l);let b=m(a(t[x],r,p,c)),_=m(f(o[x],u,d,h)),v=m(a(t[w],r,p,c)),k=m(f(1==s?u.max:u.min,u,d,h)),y=new Path2D(i);return g(y,v,k),g(y,b,k),g(y,b,_),y})}function _l(e,t,l,n,i,s){let o=null;if(e.length>0){o=new Path2D;const r=0==t?Dl:El;let u=l;for(let t=0;e.length>t;t++){let l=e[t];if(l[1]>l[0]){let e=l[0]-u;e>0&&r(o,u,n,e,n+s),u=l[1]}}let a=l+i-u,f=10;a>0&&r(o,u,n-f/2,a,n+s+f)}return o}function vl(e,t,l,n,i,s,o,r){let u=[],a=e.length;for(let f=1==i?l:n;f>=l&&n>=f;f+=i){let c=t[f];if(isNaN(c)||!r&&null===c){let r=f,c=f;if(1==i)for(;++f<=n&&null===t[f];)c=f;else for(;--f>=l&&null===t[f];)c=f;let h=s(e[r]),p=c==r?h:s(e[c]),d=r-i;h=o>0||0>d||d>=a?h:s(e[d]);let m=c+i;p=0>o||0>m||m>=a?p:s(e[m]),h>p||u.push([h,p])}}return u}function kl(e){return 0==e?Y:1==e?_:t=>O(t,e)}function yl(e){let t=0==e?Ml:Tl,l=0==e?(e,t,l,n,i,s)=>{e.arcTo(t,l,n,i,s)}:(e,t,l,n,i,s)=>{e.arcTo(l,t,i,n,s)},n=0==e?(e,t,l,n,i)=>{e.rect(t,l,n,i)}:(e,t,l,n,i)=>{e.rect(l,t,i,n)};return(e,i,s,o,r,u=0,a=0)=>{0==u&&0==a?n(e,i,s,o,r):(u=k(u,o/2,r/2),a=k(a,o/2,r/2),t(e,i+u,s),l(e,i+o,s,i+o,s+r,u),l(e,i+o,s+r,i,s+r,a),l(e,i,s+r,i,s,a),l(e,i,s,i+o,s,u),e.closePath())}}const Ml=(e,t,l)=>{e.moveTo(t,l)},Tl=(e,t,l)=>{e.moveTo(l,t)},Sl=(e,t,l)=>{e.lineTo(t,l)},zl=(e,t,l)=>{e.lineTo(l,t)},Dl=yl(0),El=yl(1),Pl=(e,t,l,n,i,s)=>{e.arc(t,l,n,i,s)},Al=(e,t,l,n,i,s)=>{e.arc(l,t,n,i,s)},Cl=(e,t,l,n,i,s,o)=>{e.bezierCurveTo(t,l,n,i,s,o)},Wl=(e,t,l,n,i,s,o)=>{e.bezierCurveTo(l,t,i,n,o,s)};function Yl(){return(e,t,l,n,i)=>{let{pxRatio:s}=e;return gl(e,t,(t,o,r,u,a,f,c,h,p,d,m)=>{let g,w,{pxRound:b,points:_}=t;0==u.ori?(g=Ml,w=Pl):(g=Tl,w=Al);const v=j(_.width*s,3);let k=(_.size-_.width)/2*s,y=j(2*k,3),M=new Path2D,T=new Path2D,{left:S,top:z,width:D,height:E}=e.bbox;Dl(T,S-y,z-y,D+2*y,E+2*y);const P=e=>{if(null!=r[e]){let t=b(f(o[e],u,d,h)),l=b(c(r[e],a,m,p));g(M,t+k,l),w(M,t,l,k,0,2*x)}};if(i)i.forEach(P);else for(let e=l;n>=e;e++)P(e);return{stroke:v>0?M:null,fill:M,clip:T,flags:3}})}}function Hl(e){return(t,l,n,i,s,o)=>{n!=i&&(s!=n&&o!=n&&e(t,l,n),s!=i&&o!=i&&e(t,l,i),e(t,l,o))}}const Rl=Hl(Sl),Fl=Hl(zl);function Nl(e){const t=h(e?.alignGaps,0);return(e,l,n,s)=>gl(e,l,(o,r,u,a,f,c,h,p,d,m,g)=>{[n,s]=i(u,n,s);let x,w,b=o.pxRound,_=e=>b(c(e,a,m,p)),v=e=>b(h(e,f,g,d));0==a.ori?(x=Sl,w=Rl):(x=zl,w=Fl);const k=a.dir*(0==a.ori?1:-1),y={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},M=y.stroke;let T=!1;if(s-n<4*m)for(let e=1==k?n:s;e>=n&&s>=e;e+=k){let t=u[e];null===t?T=!0:null!=t&&x(M,_(r[e]),v(t))}else{let t,l,i,o=t=>e.posToVal(t,a.key,!0),f=null,c=null,h=_(r[1==k?n:s]),p=_(r[n]),d=_(r[s]),m=o(1==k?p+1:d-1);for(let e=1==k?n:s;e>=n&&s>=e;e+=k){let n=r[e],i=(1==k?m>n:n>m)?h:_(n),s=u[e];i==h?null!=s?(l=s,null==f?(x(M,i,v(l)),t=f=c=l):f>l?f=l:l>c&&(c=l)):null===s&&(T=!0):(null!=f&&w(M,h,v(f),v(c),v(t),v(l)),null!=s?(l=s,x(M,i,v(l)),f=c=t=l):(f=c=null,null===s&&(T=!0)),h=i,m=o(h+k))}null!=f&&f!=c&&i!=h&&w(M,h,v(f),v(c),v(t),v(l))}let[S,z]=xl(e,l);if(null!=o.fill||0!=S){let t=y.fill=new Path2D(M),i=v(o.fillTo(e,l,o.min,o.max,S)),u=_(r[n]),a=_(r[s]);-1==k&&([a,u]=[u,a]),x(t,a,i),x(t,u,i)}if(!o.spanGaps){let i=[];T&&i.push(...vl(r,u,n,s,k,_,t,o.spanNulls)),y.gaps=i=o.gaps(e,l,n,s,i),y.clip=_l(i,a.ori,p,d,m,g)}return 0!=z&&(y.band=2==z?[bl(e,l,n,s,M,-1),bl(e,l,n,s,M,1)]:bl(e,l,n,s,M,z)),y})}function Gl(e,t,l,n,i,s,o=E){if(e.length>1){let r=null;for(let u=0,a=1/0;e.length>u;u++)if(void 0!==t[u]){if(null!=r){let t=w(e[u]-e[r]);a>t&&(a=t,o=w(l(e[u],n,i,s)-l(e[r],n,i,s)))}r=u}}return o}function Il(e,t,l,n,i){const s=e.length;if(2>s)return null;const o=new Path2D;if(l(o,e[0],t[0]),2==s)n(o,e[1],t[1]);else{let l=Array(s),n=Array(s-1),r=Array(s-1),u=Array(s-1);for(let l=0;s-1>l;l++)r[l]=t[l+1]-t[l],u[l]=e[l+1]-e[l],n[l]=r[l]/u[l];l[0]=n[0];for(let e=1;s-1>e;e++)0===n[e]||0===n[e-1]||n[e-1]>0!=n[e]>0?l[e]=0:(l[e]=3*(u[e-1]+u[e])/((2*u[e]+u[e-1])/n[e-1]+(u[e]+2*u[e-1])/n[e]),isFinite(l[e])||(l[e]=0));l[s-1]=n[s-2];for(let n=0;s-1>n;n++)i(o,e[n]+u[n]/3,t[n]+l[n]*u[n]/3,e[n+1]-u[n]/3,t[n+1]-l[n+1]*u[n]/3,e[n+1],t[n+1])}return o}const Ol=new Set;function Ll(){for(let e of Ol)e.syncRect(!0)}ze&&(Ve("resize",Ee,Ll),Ve("scroll",Ee,Ll,!0),Ve(ye,Ee,()=>{ln.pxRatio=Pe}));const Ul=Nl(),jl=Yl();function Vl(e,t,l,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map((e,n)=>Bl(e,n,t,l))}function Bl(e,t,l,n){return se({},0==t?l:n,e)}function Zl(e,t,l){return null==t?q:[t,l]}const $l=Zl;function Jl(e,t,l){return null==t?q:c(t,l,.1,!0)}function ql(e,t,l,n){return null==t?q:o(t,l,e.scales[n].log,!0)}const Kl=ql;function Xl(e,t,l,n){return null==t?q:r(t,l,e.scales[n].log,!0)}const Ql=Xl;function en(t,l,n,i,s){let o=y(P(t),P(l)),r=l-t,u=e(s/i*r,n);do{let e=n[u],t=i*e/r;if(t>=s&&17>=o+(5>e?V.get(e):0))return[e,t]}while(++u<n.length);return[0,0]}function tn(e,t){let l,n;return[e=e.replace(/(\d+)px/,(e,i)=>(l=_((n=+i)*t))+"px"),l,n]}function ln(t,a,f){let p=t.pxRatio??Pe;function d(e){p=m.pxRatio=e??Pe,ke.forEach(e=>function(e,t){e.show&&[e.font,e.labelFont].forEach(e=>{let l=j(e[2]*t,1);e[0]=e[0].replace(/[0-9.]+px/,l+"px"),e[1]=l})}(e,p)),vl(m.width,m.height,!0)}const m={mode:h(t.mode,1),pxRatio:p,setPxRatio:d};m.setPxRatio=d;const b=m.mode;function T(e,t,l,n){let i=t.valToPct(e);return n+l*(-1==t.dir?1-i:i)}function z(e,t,l,n){let i=t.valToPct(e);return n+l*(-1==t.dir?i:1-i)}function P(e,t,l,n){return 0==t.ori?T(e,t,l,n):z(e,t,l,n)}m.valToPosH=T,m.valToPosV=z;let Y=!1;m.status=0;const G=m.root=Re("uplot");null!=t.id&&(G.id=t.id),Ce(G,t.class),t.title&&(Re("u-title",G).textContent=t.title);const I=He("canvas"),L=m.ctx=I.getContext("2d"),U=Re("u-wrap",G);Ve("click",U,e=>{e.target===X&&(Ln!=Nn||Un!=Gn)&&Xn.click(m,e)},!0);const Z=m.under=Re("u-under",U);U.appendChild(I);const X=m.over=Re("u-over",U),le=+h((t=ie(t)).pxAlign,1),ne=kl(le);(t.plugins||[]).forEach(e=>{e.opts&&(t=e.opts(m,t)||t)});const oe=t.ms||.001,de=m.series=1==b?Vl(t.series||[],Zt,fl,!1):function(e,t){return e.map((e,l)=>0==l?{}:se({},t,e))}(t.series||[null],al),ke=m.axes=Vl(t.axes||[],Bt,ol,!0),ze=m.scales={},Ae=m.bands=t.bands||[];Ae.forEach(e=>{e.fill=W(e.fill||null),e.dir=h(e.dir,-1)});const Fe=2==b?de[1].facets[0].scale:de[0].scale,Ge={axes:function(){for(let e=0;ke.length>e;e++){let t=ke[e];if(!t.show||!t._show)continue;let l,n,i=t.side,s=i%2,o=t.stroke(m,e),r=0==i||3==i?-1:1,[u,a]=t._found;if(null!=t.label){let f=_((t._lpos+t.labelGap*r)*p);bn(t.labelFont[0],o,"center",2==i?fe:ce),L.save(),1==s?(l=n=0,L.translate(f,_(tl+rl/2)),L.rotate((3==i?-x:x)/2)):(l=_(el+ll/2),n=f);let c=C(t.label)?t.label(m,e,u,a):t.label;L.fillText(c,l,n),L.restore()}if(0==a)continue;let f=ze[t.scale],c=0==s?ll:rl,h=0==s?el:tl,d=t._splits,g=2==f.distr?d.map(e=>dn[e]):d,w=2==f.distr?dn[d[1]]-dn[d[0]]:u,b=t.ticks,v=t.border,k=b.show?b.size:0,y=_(k*p),M=_((2==t.alignTo?t._size-k-t.gap:t.gap)*p),T=t._rotate*-x/180,S=ne(t._pos*p),z=S+(y+M)*r;n=0==s?z:0,l=1==s?z:0,bn(t.font[0],o,1==t.align?he:2==t.align?pe:T>0?he:0>T?pe:0==s?"center":3==i?pe:he,T||1==s?"middle":2==i?fe:ce);let D=t.font[1]*t.lineGap,E=d.map(e=>ne(P(e,f,c,h))),A=t._values;for(let e=0;A.length>e;e++){let t=A[e];if(null!=t){0==s?l=E[e]:n=E[e],t=""+t;let i=-1==t.indexOf("\n")?[t]:t.split(/\n/gm);for(let e=0;i.length>e;e++){let t=i[e];T?(L.save(),L.translate(l,n+e*D),L.rotate(T),L.fillText(t,0,0),L.restore()):L.fillText(t,l,n+e*D)}}}b.show&&Dn(E,b.filter(m,g,e,a,w),s,i,S,y,j(b.width*p,3),b.stroke(m,e),b.dash,b.cap);let W=t.grid;W.show&&Dn(E,W.filter(m,g,e,a,w),s,0==s?2:1,0==s?tl:el,0==s?rl:ll,j(W.width*p,3),W.stroke(m,e),W.dash,W.cap),v.show&&Dn([S],[1],0==s?1:0,0==s?1:2,1==s?tl:el,1==s?rl:ll,j(v.width*p,3),v.stroke(m,e),v.dash,v.cap)}Yi("drawAxes")},series:function(){if(Gl>0){let e=de.some(e=>e._focus)&&pn!=zl.alpha;e&&(L.globalAlpha=pn=zl.alpha),de.forEach((e,t)=>{if(t>0&&e.show&&(kn(t,!1),kn(t,!0),null==e._paths)){let l=pn;pn!=e.alpha&&(L.globalAlpha=pn=e.alpha);let n=2==b?[0,a[t][0].length-1]:function(e){let t=A(Il-1,0,Gl-1),l=A(Ll+1,0,Gl-1);for(;null==e[t]&&t>0;)t--;for(;null==e[l]&&Gl-1>l;)l++;return[t,l]}(a[t]);e._paths=e.paths(m,t,n[0],n[1]),pn!=l&&(L.globalAlpha=pn=l)}}),de.forEach((e,t)=>{if(t>0&&e.show){let l=pn;pn!=e.alpha&&(L.globalAlpha=pn=e.alpha),null!=e._paths&&yn(t,!1);{let l=null!=e._paths?e._paths.gaps:null,n=e.points.show(m,t,Il,Ll,l),i=e.points.filter(m,t,n,l);(n||i)&&(e.points._paths=e.points.paths(m,t,Il,Ll,i),yn(t,!0))}pn!=l&&(L.globalAlpha=pn=l),Yi("drawSeries",t)}}),e&&(L.globalAlpha=pn=1)}}},Oe=(t.drawOrder||["axes","series"]).map(e=>Ge[e]);function Ue(e){const t=3==e.distr?t=>S(t>0?t:e.clamp(m,t,e.min,e.max,e.key)):4==e.distr?t=>D(t,e.asinh):100==e.distr?t=>e.fwd(t):e=>e;return l=>{let n=t(l),{_min:i,_max:s}=e;return(n-i)/(s-i)}}function je(e){let l=ze[e];if(null==l){let n=(t.scales||$)[e]||$;if(null!=n.from){je(n.from);let t=se({},ze[n.from],n,{key:e});t.valToPct=Ue(t),ze[e]=t}else{l=ze[e]=se({},e==Fe?hl:pl,n),l.key=e;let t=l.time,i=l.range,s=K(i);if((e!=Fe||2==b&&!t)&&(!s||null!=i[0]&&null!=i[1]||(i={min:null==i[0]?u:{mode:1,hard:i[0],soft:i[0]},max:null==i[1]?u:{mode:1,hard:i[1],soft:i[1]}},s=!1),!s&&ee(i))){let e=i;i=(t,l,n)=>null==l?q:c(l,n,e)}l.range=W(i||(t?$l:e==Fe?3==l.distr?Kl:4==l.distr?Ql:Zl:3==l.distr?ql:4==l.distr?Xl:Jl)),l.auto=W(!s&&l.auto),l.clamp=W(l.clamp||cl),l._min=l._max=null,l.valToPct=Ue(l)}}}je("x"),je("y"),1==b&&de.forEach(e=>{je(e.scale)}),ke.forEach(e=>{je(e.scale)});for(let e in t.scales)je(e);const Ze=ze[Fe],$e=Ze.distr;let Je,qe;0==Ze.ori?(Ce(G,"u-hz"),Je=T,qe=z):(Ce(G,"u-vt"),Je=z,qe=T);const Ke={};for(let e in ze){let t=ze[e];null==t.min&&null==t.max||(Ke[e]={min:t.min,max:t.max},t.min=t.max=null)}const Xe=t.tzDate||(e=>new Date(_(e/oe))),Qe=t.fmtDate||tt,et=1==oe?zt(Xe):Pt(Xe),lt=Ct(Xe,At(1==oe?St:Et,Qe)),nt=Yt(Xe,Wt("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",Qe)),it=[],st=m.legend=se({},Ht,t.legend),ot=m.cursor=se({},Gt,{drag:{y:2==b}},t.cursor),rt=st.show,ut=ot.show,at=st.markers;let ft,ct,dt;st.idxs=it,at.width=W(at.width),at.dash=W(at.dash),at.stroke=W(at.stroke),at.fill=W(at.fill);let mt,gt=[],xt=[],wt=!1,bt={};if(st.live){const e=de[1]?de[1].values:null;wt=null!=e,mt=wt?e(m,1,0):{_:0};for(let e in mt)bt[e]=Me}if(rt)if(ft=He("table","u-legend",G),dt=He("tbody",null,ft),st.mount(m,ft),wt){ct=He("thead",null,ft,dt);let e=He("tr",null,ct);for(var _t in He("th",null,e),mt)He("th",Se,e).textContent=_t}else Ce(ft,"u-inline"),st.live&&Ce(ft,"u-live");const vt={show:!0},kt={show:!1},yt=new Map;function Mt(e,t,l,n=!0){const i=yt.get(t)||{},s=ot.bind[e](m,t,l,n);s&&(Ve(e,t,i[e]=s),yt.set(t,i))}function Rt(e,t){const l=yt.get(t)||{};for(let n in l)null!=e&&n!=e||(Be(n,t,l[n]),delete l[n]);null==e&&yt.delete(t)}let Ft=0,Nt=0,It=0,Ot=0,Lt=0,Ut=0,jt=Lt,Vt=Ut,Xt=It,Qt=Ot,el=0,tl=0,ll=0,rl=0;m.bbox={};let ul=!1,dl=!1,gl=!1,xl=!1,bl=!1,_l=!1;function vl(e,t,l){(l||e!=m.width||t!=m.height)&&yl(e,t),An(!1),gl=!0,dl=!0,$n()}function yl(e,t){m.width=Ft=It=e,m.height=Nt=Ot=t,Lt=Ut=0,function(){let e=!1,t=!1,l=!1,n=!1;ke.forEach(i=>{if(i.show&&i._show){let{side:s,_size:o}=i,r=o+(null!=i.label?i.labelSize:0);r>0&&(s%2?(It-=r,3==s?(Lt+=r,n=!0):l=!0):(Ot-=r,0==s?(Ut+=r,e=!0):t=!0))}}),Hl[0]=e,Hl[1]=l,Hl[2]=t,Hl[3]=n,It-=Nl[1]+Nl[3],Lt+=Nl[3],Ot-=Nl[2]+Nl[0],Ut+=Nl[0]}(),function(){let e=Lt+It,t=Ut+Ot,l=Lt,n=Ut;function i(i,s){switch(i){case 1:return e+=s,e-s;case 2:return t+=s,t-s;case 3:return l-=s,l+s;case 0:return n-=s,n+s}}ke.forEach(e=>{if(e.show&&e._show){let t=e.side;e._pos=i(t,e._size),null!=e.label&&(e._lpos=i(t,e.labelSize))}})}();let l=m.bbox;el=l.left=O(Lt*p,.5),tl=l.top=O(Ut*p,.5),ll=l.width=O(It*p,.5),rl=l.height=O(Ot*p,.5)}const Ml=3;if(m.setSize=function({width:e,height:t}){vl(e,t)},null==ot.dataIdx){let e=ot.hover,t=e.skip=new Set(e.skip??[]);t.add(void 0);let l=e.prox=W(e.prox),n=e.bias??=0;ot.dataIdx=(e,i,s,o)=>{if(0==i)return s;let r=s,u=l(e,i,s,o)??E,f=u>=0&&E>u,c=0==Ze.ori?It:Ot,h=ot.left,p=a[0],d=a[i];if(t.has(d[s])){r=null;let e,l=null,i=null;if(0==n||-1==n)for(e=s;null==l&&--e>=Il;)t.has(d[e])||(l=e);if(0==n||1==n)for(e=s;null==i&&++e<=Ll;)t.has(d[e])||(i=e);if(null!=l||null!=i)if(f){let e=h-(null==l?-1/0:Je(p[l],Ze,c,0)),t=(null==i?1/0:Je(p[i],Ze,c,0))-h;e>t?t>u||(r=i):e>u||(r=l)}else r=null==i?l:null==l||s-l>i-s?i:l}else f&&w(h-Je(p[s],Ze,c,0))>u&&(r=null);return r}}const Tl=e=>{ot.event=e};ot.idxs=it,ot._lock=!1;let Sl=ot.points;Sl.show=W(Sl.show),Sl.size=W(Sl.size),Sl.stroke=W(Sl.stroke),Sl.width=W(Sl.width),Sl.fill=W(Sl.fill);const zl=m.focus=se({},t.focus||{alpha:.3},ot.focus),Dl=zl.prox>=0,El=Dl&&Sl.one;let Pl=[],Al=[],Cl=[];function Wl(e,t){let l=Sl.show(m,t);if(l instanceof HTMLElement)return Ce(l,"u-cursor-pt"),Ce(l,e.class),Ne(l,-10,-10,It,Ot),X.insertBefore(l,Pl[t]),l}function Yl(e,t){if(1==b||t>0){let t=1==b&&ze[e.scale].time,l=e.value;e.value=t?Q(l)?Yt(Xe,Wt(l,Qe)):l||nt:l||sl,e.label=e.label||(t?"Time":"Value")}if(El||t>0){e.width=null==e.width?1:e.width,e.paths=e.paths||Ul||R,e.fillTo=W(e.fillTo||wl),e.pxAlign=+h(e.pxAlign,le),e.pxRound=kl(e.pxAlign),e.stroke=W(e.stroke||null),e.fill=W(e.fill||null),e._stroke=e._fill=e._paths=e._focus=null;let t=function(e){return j(1*(3+2*(e||1)),3)}(y(1,e.width)),l=e.points=se({},{size:t,width:y(1,.2*t),stroke:e.stroke,space:2*t,paths:jl,_stroke:null,_fill:null},e.points);l.show=W(l.show),l.filter=W(l.filter),l.fill=W(l.fill),l.stroke=W(l.stroke),l.paths=W(l.paths),l.pxAlign=e.pxAlign}if(rt){let l=function(e,t){if(0==t&&(wt||!st.live||2==b))return q;let l=[],n=He("tr","u-series",dt,dt.childNodes[t]);Ce(n,e.class),e.show||Ce(n,Te);let i=He("th",null,n);if(at.show){let e=Re("u-marker",i);if(t>0){let l=at.width(m,t);l&&(e.style.border=l+"px "+at.dash(m,t)+" "+at.stroke(m,t)),e.style.background=at.fill(m,t)}}let s=Re(Se,i);for(var o in e.label instanceof HTMLElement?s.appendChild(e.label):s.textContent=e.label,t>0&&(at.show||(s.style.color=e.width>0?at.stroke(m,t):at.fill(m,t)),Mt("click",i,t=>{if(ot._lock)return;Tl(t);let l=de.indexOf(e);if((t.ctrlKey||t.metaKey)!=st.isolate){let e=de.some((e,t)=>t>0&&t!=l&&e.show);de.forEach((t,n)=>{n>0&&si(n,e?n==l?vt:kt:vt,!0,Ri.setSeries)})}else si(l,{show:!e.show},!0,Ri.setSeries)},!1),Dl&&Mt(be,i,t=>{ot._lock||(Tl(t),si(de.indexOf(e),ai,!0,Ri.setSeries))},!1)),mt){let e=He("td","u-value",n);e.textContent="--",l.push(e)}return[n,l]}(e,t);gt.splice(t,0,l[0]),xt.splice(t,0,l[1]),st.values.push(null)}if(ut){it.splice(t,0,null);let l=null;El?0==t&&(l=Wl(e,t)):t>0&&(l=Wl(e,t)),Pl.splice(t,0,l),Al.splice(t,0,0),Cl.splice(t,0,0)}Yi("addSeries",t)}m.addSeries=function(e,t){t=null==t?de.length:t,e=1==b?Bl(e,t,Zt,fl):Bl(e,t,{},al),de.splice(t,0,e),Yl(de[t],t)},m.delSeries=function(e){if(de.splice(e,1),rt){st.values.splice(e,1),xt.splice(e,1);let t=gt.splice(e,1)[0];Rt(null,t.firstChild),t.remove()}ut&&(it.splice(e,1),Pl.splice(e,1)[0].remove(),Al.splice(e,1),Cl.splice(e,1)),Yi("delSeries",e)};const Hl=[!1,!1,!1,!1];function Rl(e,t,l){let[n,i,s,o]=l,r=t%2,u=0;return 0==r&&(o||i)&&(u=0==t&&!n||2==t&&!s?_(Bt.size/3):0),1==r&&(n||s)&&(u=1==t&&!i||3==t&&!o?_(ol.size/2):0),u}const Fl=m.padding=(t.padding||[Rl,Rl,Rl,Rl]).map(e=>W(h(e,Rl))),Nl=m._padding=Fl.map((e,t)=>e(m,t,Hl,0));let Gl,Il=null,Ll=null;const ln=1==b?de[0].idxs:null;let nn,sn,on,rn,un,an,fn,cn,hn,pn,dn=null,mn=!1;function gn(e,t){if(m.data=m._data=a=null==e?[]:e,2==b){Gl=0;for(let e=1;de.length>e;e++)Gl+=a[e][0].length}else{0==a.length&&(m.data=m._data=a=[[]]),dn=a[0],Gl=dn.length;let e=a;if(2==$e){e=a.slice();let t=e[0]=Array(Gl);for(let e=0;Gl>e;e++)t[e]=e}m._data=a=e}if(An(!0),Yi("setData"),2==$e&&(gl=!0),!1!==t){let e=Ze;e.auto(m,mn)?xn():ii(Fe,e.min,e.max),xl=xl||ot.left>=0,_l=!0,$n()}}function xn(){let e,t;mn=!0,1==b&&(Gl>0?(Il=ln[0]=0,Ll=ln[1]=Gl-1,e=a[0][Il],t=a[0][Ll],2==$e?(e=Il,t=Ll):e==t&&(3==$e?[e,t]=o(e,e,Ze.log,!1):4==$e?[e,t]=r(e,e,Ze.log,!1):Ze.time?t=e+_(86400/oe):[e,t]=c(e,t,.1,!0))):(Il=ln[0]=e=null,Ll=ln[1]=t=null)),ii(Fe,e,t)}function wn(e,t,l,n,i,s){e??=me,l??=J,n??="butt",i??=me,s??="round",e!=nn&&(L.strokeStyle=nn=e),i!=sn&&(L.fillStyle=sn=i),t!=on&&(L.lineWidth=on=t),s!=un&&(L.lineJoin=un=s),n!=an&&(L.lineCap=an=n),l!=rn&&L.setLineDash(rn=l)}function bn(e,t,l,n){t!=sn&&(L.fillStyle=sn=t),e!=fn&&(L.font=fn=e),l!=cn&&(L.textAlign=cn=l),n!=hn&&(L.textBaseline=hn=n)}function _n(e,t,o,r,u=0){if(r.length>0&&e.auto(m,mn)&&(null==t||null==t.min)){let t=h(Il,0),a=h(Ll,r.length-1),f=null==o.min?function(e,t,o,r=0,u=!1){let a=u?s:i,f=u?n:l;[t,o]=a(e,t,o);let c=e[t],h=e[t];if(t>-1)if(1==r)c=e[t],h=e[o];else if(-1==r)c=e[o],h=e[t];else for(let l=t;o>=l;l++){let t=e[l];f(t)&&(c>t?c=t:t>h&&(h=t))}return[c??E,h??-E]}(r,t,a,u,3==e.distr):[o.min,o.max];e.min=k(e.min,o.min=f[0]),e.max=y(e.max,o.max=f[1])}}m.setData=gn;const vn={min:null,max:null};function kn(e,t){let l=t?de[e].points:de[e];l._stroke=l.stroke(m,e),l._fill=l.fill(m,e)}function yn(e,t){let l=t?de[e].points:de[e],{stroke:n,fill:i,clip:s,flags:o,_stroke:r=l._stroke,_fill:u=l._fill,_width:f=l.width}=l._paths;f=j(f*p,3);let c=null,d=f%2/2;t&&null==u&&(u=f>0?"#fff":r);let g=1==l.pxAlign&&d>0;if(g&&L.translate(d,d),!t){let e=el-f/2,t=tl-f/2,l=ll+f,n=rl+f;c=new Path2D,c.rect(e,t,l,n)}t?Tn(r,f,l.dash,l.cap,u,n,i,o,s):function(e,t,l,n,i,s,o,r,u,f,c){let p=!1;0!=u&&Ae.forEach((d,g)=>{if(d.series[0]==e){let e,x=de[d.series[1]],w=a[d.series[1]],b=(x._paths||$).band;K(b)&&(b=1==d.dir?b[0]:b[1]);let _=null;x.show&&b&&function(e,t,l){for(t=h(t,0),l=h(l,e.length-1);l>=t;){if(null!=e[t])return!0;t++}return!1}(w,Il,Ll)?(_=d.fill(m,g)||s,e=x._paths.clip):b=null,Tn(t,l,n,i,_,o,r,u,f,c,e,b),p=!0}}),p||Tn(t,l,n,i,s,o,r,u,f,c)}(e,r,f,l.dash,l.cap,u,n,i,o,c,s),g&&L.translate(-d,-d)}const Mn=3;function Tn(e,t,l,n,i,s,o,r,u,a,f,c){wn(e,t,l,n,i),(u||a||c)&&(L.save(),u&&L.clip(u),a&&L.clip(a)),c?(r&Mn)==Mn?(L.clip(c),f&&L.clip(f),zn(i,o),Sn(e,s,t)):2&r?(zn(i,o),L.clip(c),Sn(e,s,t)):1&r&&(L.save(),L.clip(c),f&&L.clip(f),zn(i,o),L.restore(),Sn(e,s,t)):(zn(i,o),Sn(e,s,t)),(u||a||c)&&L.restore()}function Sn(e,t,l){l>0&&(t instanceof Map?t.forEach((e,t)=>{L.strokeStyle=nn=t,L.stroke(e)}):null!=t&&e&&L.stroke(t))}function zn(e,t){t instanceof Map?t.forEach((e,t)=>{L.fillStyle=sn=t,L.fill(e)}):null!=t&&e&&L.fill(t)}function Dn(e,t,l,n,i,s,o,r,u,a){let f=o%2/2;1==le&&L.translate(f,f),wn(r,o,u,a,r),L.beginPath();let c,h,p,d,m=i+(0==n||3==n?-s:s);0==l?(h=i,d=m):(c=i,p=m);for(let n=0;e.length>n;n++)null!=t[n]&&(0==l?c=p=e[n]:h=d=e[n],L.moveTo(c,h),L.lineTo(p,d));L.stroke(),1==le&&L.translate(-f,-f)}function En(e){let t=!0;return ke.forEach((l,n)=>{if(!l.show)return;let i=ze[l.scale];if(null==i.min)return void(l._show&&(t=!1,l._show=!1,An(!1)));l._show||(t=!1,l._show=!0,An(!1));let s=l.side,o=s%2,{min:r,max:u}=i,[a,f]=function(e,t,l,n){let i,s=ke[e];if(n>0){let o=s._space=s.space(m,e,t,l,n);i=en(t,l,s._incrs=s.incrs(m,e,t,l,n,o),n,o)}else i=[0,0];return s._found=i}(n,r,u,0==o?It:Ot);if(0==f)return;let c=l._splits=l.splits(m,n,r,u,a,f,2==i.distr),h=2==i.distr?c.map(e=>dn[e]):c,p=2==i.distr?dn[c[1]]-dn[c[0]]:a,d=l._values=l.values(m,l.filter(m,h,n,f,p),n,f,p);l._rotate=2==s?l.rotate(m,d,n,f):0;let g=l._size;l._size=v(l.size(m,d,n,e)),null!=g&&l._size!=g&&(t=!1)}),t}function Pn(e){let t=!0;return Fl.forEach((l,n)=>{let i=l(m,n,Hl,e);i!=Nl[n]&&(t=!1),Nl[n]=i}),t}function An(e){de.forEach((t,l)=>{l>0&&(t._paths=null,e&&(1==b?(t.min=null,t.max=null):t.facets.forEach(e=>{e.min=null,e.max=null})))})}let Cn,Wn,Yn,Hn,Rn,Fn,Nn,Gn,In,On,Ln,Un,jn=!1,Vn=!1,Bn=[];function Zn(){Vn=!1;for(let e=0;Bn.length>e;e++)Yi(...Bn[e]);Bn.length=0}function $n(){jn||(re(Jn),jn=!0)}function Jn(){if(ul&&(function(){for(let e in ze){let t=ze[e];null==Ke[e]&&(null==t.min||null!=Ke[Fe]&&t.auto(m,mn))&&(Ke[e]=vn)}for(let e in ze){let t=ze[e];null==Ke[e]&&null!=t.from&&null!=Ke[t.from]&&(Ke[e]=vn)}null!=Ke[Fe]&&An(!0);let t={};for(let e in Ke){let l=Ke[e];if(null!=l){let n=t[e]=ie(ze[e],te);if(null!=l.min)se(n,l);else if(e!=Fe||2==b)if(0==Gl&&null==n.from){let t=n.range(m,null,null,e);n.min=t[0],n.max=t[1]}else n.min=E,n.max=-E}}if(Gl>0){de.forEach((l,n)=>{if(1==b){let i=l.scale,s=Ke[i];if(null==s)return;let o=t[i];if(0==n){let t=o.range(m,o.min,o.max,i);o.min=t[0],o.max=t[1],Il=e(o.min,a[0]),Ll=e(o.max,a[0]),Ll-Il>1&&(o.min>a[0][Il]&&Il++,a[0][Ll]>o.max&&Ll--),l.min=dn[Il],l.max=dn[Ll]}else l.show&&l.auto&&_n(o,s,l,a[n],l.sorted);l.idxs[0]=Il,l.idxs[1]=Ll}else if(n>0&&l.show&&l.auto){let[e,i]=l.facets,s=e.scale,o=i.scale,[r,u]=a[n],f=t[s],c=t[o];null!=f&&_n(f,Ke[s],e,r,e.sorted),null!=c&&_n(c,Ke[o],i,u,i.sorted),l.min=i.min,l.max=i.max}});for(let e in t){let l=t[e],n=Ke[e];if(null==l.from&&(null==n||null==n.min)){let t=l.range(m,l.min==E?null:l.min,l.max==-E?null:l.max,e);l.min=t[0],l.max=t[1]}}}for(let e in t){let l=t[e];if(null!=l.from){let n=t[l.from];if(null==n.min)l.min=l.max=null;else{let t=l.range(m,n.min,n.max,e);l.min=t[0],l.max=t[1]}}}let l={},n=!1;for(let e in t){let i=t[e],s=ze[e];if(s.min!=i.min||s.max!=i.max){s.min=i.min,s.max=i.max;let t=s.distr;s._min=3==t?S(s.min):4==t?D(s.min,s.asinh):100==t?s.fwd(s.min):s.min,s._max=3==t?S(s.max):4==t?D(s.max,s.asinh):100==t?s.fwd(s.max):s.max,l[e]=n=!0}}if(n){de.forEach((e,t)=>{2==b?t>0&&l.y&&(e._paths=null):l[e.scale]&&(e._paths=null)});for(let e in l)gl=!0,Yi("setScale",e);ut&&ot.left>=0&&(xl=_l=!0)}for(let e in Ke)Ke[e]=null}(),ul=!1),gl&&(function(){let e=!1,t=0;for(;!e;){t++;let l=En(t),n=Pn(t);e=t==Ml||l&&n,e||(yl(m.width,m.height),dl=!0)}}(),gl=!1),dl){if(Ye(Z,he,Lt),Ye(Z,fe,Ut),Ye(Z,ue,It),Ye(Z,ae,Ot),Ye(X,he,Lt),Ye(X,fe,Ut),Ye(X,ue,It),Ye(X,ae,Ot),Ye(U,ue,Ft),Ye(U,ae,Nt),I.width=_(Ft*p),I.height=_(Nt*p),ke.forEach(({_el:e,_show:t,_size:l,_pos:n,side:i})=>{if(null!=e)if(t){let t=i%2==1;Ye(e,t?"left":"top",n-(3===i||0===i?l:0)),Ye(e,t?"width":"height",l),Ye(e,t?"top":"left",t?Ut:Lt),Ye(e,t?"height":"width",t?Ot:It),We(e,Te)}else Ce(e,Te)}),nn=sn=on=un=an=fn=cn=hn=rn=null,pn=1,bi(!0),Lt!=jt||Ut!=Vt||It!=Xt||Ot!=Qt){An(!1);let e=It/Xt,t=Ot/Qt;if(ut&&!xl&&ot.left>=0){ot.left*=e,ot.top*=t,Yn&&Ne(Yn,_(ot.left),0,It,Ot),Hn&&Ne(Hn,0,_(ot.top),It,Ot);for(let l=0;Pl.length>l;l++){let n=Pl[l];null!=n&&(Al[l]*=e,Cl[l]*=t,Ne(n,v(Al[l]),v(Cl[l]),It,Ot))}}if(ti.show&&!bl&&ti.left>=0&&ti.width>0){ti.left*=e,ti.width*=e,ti.top*=t,ti.height*=t;for(let e in ki)Ye(li,e,ti[e])}jt=Lt,Vt=Ut,Xt=It,Qt=Ot}Yi("setSize"),dl=!1}Ft>0&&Nt>0&&(L.clearRect(0,0,I.width,I.height),Yi("drawClear"),Oe.forEach(e=>e()),Yi("draw")),ti.show&&bl&&(ni(ti),bl=!1),ut&&xl&&(xi(null,!0,!1),xl=!1),st.show&&st.live&&_l&&(mi(),_l=!1),Y||(Y=!0,m.status=1,Yi("ready")),mn=!1,jn=!1}function qn(t,l){let n=ze[t];if(null==n.from){if(0==Gl){let e=n.range(m,l.min,l.max,t);l.min=e[0],l.max=e[1]}if(l.min>l.max){let e=l.min;l.min=l.max,l.max=e}if(Gl>1&&null!=l.min&&null!=l.max&&1e-16>l.max-l.min)return;t==Fe&&2==n.distr&&Gl>0&&(l.min=e(l.min,a[0]),l.max=e(l.max,a[0]),l.min==l.max&&l.max++),Ke[t]=l,ul=!0,$n()}}m.batch=function(e,t=!1){jn=!0,Vn=t,e(m),Jn(),t&&Bn.length>0&&queueMicrotask(Zn)},m.redraw=(e,t)=>{gl=t||!1,!1!==e?ii(Fe,Ze.min,Ze.max):$n()},m.setScale=qn;let Kn=!1;const Xn=ot.drag;let Qn=Xn.x,ei=Xn.y;ut&&(ot.x&&(Cn=Re("u-cursor-x",X)),ot.y&&(Wn=Re("u-cursor-y",X)),0==Ze.ori?(Yn=Cn,Hn=Wn):(Yn=Wn,Hn=Cn),Ln=ot.left,Un=ot.top);const ti=m.select=se({show:!0,over:!0,left:0,width:0,top:0,height:0},t.select),li=ti.show?Re("u-select",ti.over?X:Z):null;function ni(e,t){if(ti.show){for(let t in e)ti[t]=e[t],t in ki&&Ye(li,t,e[t]);!1!==t&&Yi("setSelect")}}function ii(e,t,l){qn(e,{min:t,max:l})}function si(e,t,l,n){null!=t.focus&&function(e){if(e!=ui){let t=null==e,l=1!=zl.alpha;de.forEach((n,i)=>{if(1==b||i>0){let s=t||0==i||i==e;n._focus=t?null:s,l&&function(e,t){de[e].alpha=t,ut&&null!=Pl[e]&&(Pl[e].style.opacity=t),rt&&gt[e]&&(gt[e].style.opacity=t)}(i,s?1:zl.alpha)}}),ui=e,l&&$n()}}(e),null!=t.show&&de.forEach((l,n)=>{0>=n||e!=n&&null!=e||(l.show=t.show,function(e){if(de[e].show)rt&&We(gt[e],Te);else if(rt&&Ce(gt[e],Te),ut){let t=El?Pl[0]:Pl[e];null!=t&&Ne(t,-10,-10,It,Ot)}}(n),2==b?(ii(l.facets[0].scale,null,null),ii(l.facets[1].scale,null,null)):ii(l.scale,null,null),$n())}),!1!==l&&Yi("setSeries",e,t),n&&Gi("setSeries",m,e,t)}let oi,ri,ui;m.setSelect=ni,m.setSeries=si,m.addBand=function(e,t){e.fill=W(e.fill||null),e.dir=h(e.dir,-1),Ae.splice(t=null==t?Ae.length:t,0,e)},m.setBand=function(e,t){se(Ae[e],t)},m.delBand=function(e){null==e?Ae.length=0:Ae.splice(e,1)};const ai={focus:!0};function fi(e,t,l){let n=ze[t];l&&(e=e/p-(1==n.ori?Ut:Lt));let i=It;1==n.ori&&(i=Ot,e=i-e),-1==n.dir&&(e=i-e);let s=n._min,o=s+e/i*(n._max-s),r=n.distr;return 3==r?M(10,o):4==r?((e,t=1)=>g.sinh(e)*t)(o,n.asinh):100==r?n.bwd(o):o}function ci(e,t){Ye(li,he,ti.left=e),Ye(li,ue,ti.width=t)}function hi(e,t){Ye(li,fe,ti.top=e),Ye(li,ae,ti.height=t)}rt&&Dl&&Mt(_e,ft,e=>{ot._lock||(Tl(e),null!=ui&&si(null,ai,!0,Ri.setSeries))}),m.valToIdx=t=>e(t,a[0]),m.posToIdx=function(t,l){return e(fi(t,Fe,l),a[0],Il,Ll)},m.posToVal=fi,m.valToPos=(e,t,l)=>0==ze[t].ori?T(e,ze[t],l?ll:It,l?el:0):z(e,ze[t],l?rl:Ot,l?tl:0),m.setCursor=(e,t,l)=>{Ln=e.left,Un=e.top,xi(null,t,l)};let pi=0==Ze.ori?ci:hi,di=1==Ze.ori?ci:hi;function mi(e,t){if(null!=e&&(e.idxs?e.idxs.forEach((e,t)=>{it[t]=e}):(e=>void 0===e)(e.idx)||it.fill(e.idx),st.idx=it[0]),rt&&st.live){for(let e=0;de.length>e;e++)(e>0||1==b&&!wt)&&gi(e,it[e]);!function(){if(rt&&st.live)for(let e=2==b?1:0;de.length>e;e++){if(0==e&&wt)continue;let t=st.values[e],l=0;for(let n in t)xt[e][l++].firstChild.nodeValue=t[n]}}()}_l=!1,!1!==t&&Yi("setLegend")}function gi(e,t){let l,n=de[e],i=0==e&&2==$e?dn:a[e];wt?l=n.values(m,e,t)??bt:(l=n.value(m,null==t?null:i[t],e,t),l=null==l?bt:{_:l}),st.values[e]=l}function xi(t,l,n){let i;In=Ln,On=Un,[Ln,Un]=ot.move(m,Ln,Un),ot.left=Ln,ot.top=Un,ut&&(Yn&&Ne(Yn,_(Ln),0,It,Ot),Hn&&Ne(Hn,0,_(Un),It,Ot)),oi=E,ri=null;let s=0==Ze.ori?It:Ot,o=1==Ze.ori?It:Ot;if(0>Ln||0==Gl||Il>Ll){i=ot.idx=null;for(let e=0;de.length>e;e++){let t=Pl[e];null!=t&&Ne(t,-10,-10,It,Ot)}Dl&&si(null,ai,!0,null==t&&Ri.setSeries),st.live&&(it.fill(i),_l=!0)}else{let t,l,n;1==b&&(t=0==Ze.ori?Ln:Un,l=fi(t,Fe),i=ot.idx=e(l,a[0],Il,Ll),n=Je(a[0][i],Ze,s,0));let r=-10,u=-10,f=0,c=0,h=!0,p="",d="";for(let e=2==b?1:0;de.length>e;e++){let t=de[e],g=it[e],x=null==g?null:1==b?a[e][g]:a[e][1][g],_=ot.dataIdx(m,e,i,l),k=null==_?null:1==b?a[e][_]:a[e][1][_];if(_l=_l||k!=x||_!=g,it[e]=_,e>0&&t.show){let l=null==_?-10:_==i?n:Je(1==b?a[0][_]:a[e][0][_],Ze,s,0),g=null==k?-10:qe(k,1==b?ze[t.scale]:ze[t.facets[1].scale],o,0);if(Dl&&null!=k){let l=1==Ze.ori?Ln:Un,n=w(zl.dist(m,e,_,g,l));if(oi>n){let i=zl.bias;if(0!=i){let s=fi(l,t.scale),o=0>s?-1:1;o!=(0>k?-1:1)||(1==o?1==i?s>k:k>s:1==i?k>s:s>k)||(oi=n,ri=e)}else oi=n,ri=e}}if(_l||El){let t,n;0==Ze.ori?(t=l,n=g):(t=g,n=l);let i,s,o,a,x,w,b=!0,_=Sl.bbox;if(null!=_){b=!1;let t=_(m,e);o=t.left,a=t.top,i=t.width,s=t.height}else o=t,a=n,i=s=Sl.size(m,e);if(w=Sl.fill(m,e),x=Sl.stroke(m,e),El)e!=ri||oi>zl.prox||(r=o,u=a,f=i,c=s,h=b,p=w,d=x);else{let t=Pl[e];null!=t&&(Al[e]=o,Cl[e]=a,Le(t,i,s,b),Ie(t,w,x),Ne(t,v(o),v(a),It,Ot))}}}}if(El){let e=zl.prox;if(_l||(null==ui?e>=oi:oi>e||ri!=ui)){let e=Pl[0];null!=e&&(Al[0]=r,Cl[0]=u,Le(e,f,c,h),Ie(e,p,d),Ne(e,v(r),v(u),It,Ot))}}}if(ti.show&&Kn)if(null!=t){let[e,l]=Ri.scales,[n,i]=Ri.match,[r,u]=t.cursor.sync.scales,a=t.cursor.drag;if(Qn=a._x,ei=a._y,Qn||ei){let a,f,c,h,p,{left:d,top:m,width:g,height:x}=t.select,b=t.scales[r].ori,_=t.posToVal,v=null!=e&&n(e,r),y=null!=l&&i(l,u);v&&Qn?(0==b?(a=d,f=g):(a=m,f=x),c=ze[e],h=Je(_(a,r),c,s,0),p=Je(_(a+f,r),c,s,0),pi(k(h,p),w(p-h))):pi(0,s),y&&ei?(1==b?(a=d,f=g):(a=m,f=x),c=ze[l],h=qe(_(a,u),c,o,0),p=qe(_(a+f,u),c,o,0),di(k(h,p),w(p-h))):di(0,o)}else yi()}else{let e=w(In-Rn),t=w(On-Fn);if(1==Ze.ori){let l=e;e=t,t=l}Qn=Xn.x&&e>=Xn.dist,ei=Xn.y&&t>=Xn.dist;let l,n,i=Xn.uni;null!=i?Qn&&ei&&(Qn=e>=i,ei=t>=i,Qn||ei||(t>e?ei=!0:Qn=!0)):Xn.x&&Xn.y&&(Qn||ei)&&(Qn=ei=!0),Qn&&(0==Ze.ori?(l=Nn,n=Ln):(l=Gn,n=Un),pi(k(l,n),w(n-l)),ei||di(0,o)),ei&&(1==Ze.ori?(l=Nn,n=Ln):(l=Gn,n=Un),di(k(l,n),w(n-l)),Qn||pi(0,s)),Qn||ei||(pi(0,0),di(0,0))}if(Xn._x=Qn,Xn._y=ei,null==t){if(n){if(null!=Fi){let[e,t]=Ri.scales;Ri.values[0]=null!=e?fi(0==Ze.ori?Ln:Un,e):null,Ri.values[1]=null!=t?fi(1==Ze.ori?Ln:Un,t):null}Gi(ge,m,Ln,Un,It,Ot,i)}if(Dl){let e=n&&Ri.setSeries,t=zl.prox;null==ui?oi>t||si(ri,ai,!0,e):oi>t?si(null,ai,!0,e):ri!=ui&&si(ri,ai,!0,e)}}_l&&(st.idx=i,mi()),!1!==l&&Yi("setCursor")}m.setLegend=mi;let wi=null;function bi(e=!1){e?wi=null:(wi=X.getBoundingClientRect(),Yi("syncRect",wi))}function _i(e,t,l,n,i,s){ot._lock||Kn&&null!=e&&0==e.movementX&&0==e.movementY||(vi(e,t,l,n,i,s,0,!1,null!=e),null!=e?xi(null,!0,!0):xi(t,!0,!1))}function vi(e,t,l,n,i,s,o,r,u){if(null==wi&&bi(!1),Tl(e),null!=e)l=e.clientX-wi.left,n=e.clientY-wi.top;else{if(0>l||0>n)return Ln=-10,void(Un=-10);let[e,o]=Ri.scales,r=t.cursor.sync,[u,a]=r.values,[f,c]=r.scales,[h,p]=Ri.match,d=t.axes[0].side%2==1,m=0==Ze.ori?It:Ot,g=1==Ze.ori?It:Ot,x=d?s:i,w=d?i:s,b=d?n:l,_=d?l:n;if(l=null!=f?h(e,f)?P(u,ze[e],m,0):-10:m*(b/x),n=null!=c?p(o,c)?P(a,ze[o],g,0):-10:g*(_/w),1==Ze.ori){let e=l;l=n,n=e}}!u||null!=t&&t.cursor.event.type!=ge||(l>1&&It-1>l||(l=O(l,It)),n>1&&Ot-1>n||(n=O(n,Ot))),r?(Rn=l,Fn=n,[Nn,Gn]=ot.move(m,l,n)):(Ln=l,Un=n)}Object.defineProperty(m,"rect",{get:()=>(null==wi&&bi(!1),wi)});const ki={width:0,height:0,left:0,top:0};function yi(){ni(ki,!1)}let Mi,Ti,Si,zi;function Di(e,t,l,n,i,s){Kn=!0,Qn=ei=Xn._x=Xn._y=!1,vi(e,t,l,n,i,s,0,!0,!1),null!=e&&(Mt(we,De,Ei,!1),Gi(xe,m,Nn,Gn,It,Ot,null));let{left:o,top:r,width:u,height:a}=ti;Mi=o,Ti=r,Si=u,zi=a}function Ei(e,t,l,n,i,s){Kn=Xn._x=Xn._y=!1,vi(e,t,l,n,i,s,0,!1,!0);let{left:o,top:r,width:u,height:a}=ti,f=u>0||a>0,c=Mi!=o||Ti!=r||Si!=u||zi!=a;if(f&&c&&ni(ti),Xn.setScale&&f&&c){let e=o,t=u,l=r,n=a;if(1==Ze.ori&&(e=r,t=a,l=o,n=u),Qn&&ii(Fe,fi(e,Fe),fi(e+t,Fe)),ei)for(let e in ze){let t=ze[e];e!=Fe&&null==t.from&&t.min!=E&&ii(e,fi(l+n,e),fi(l,e))}yi()}else ot.lock&&(ot._lock=!ot._lock,xi(t,!0,null!=e));null!=e&&(Rt(we,De),Gi(we,m,Ln,Un,It,Ot,null))}function Pi(e){ot._lock||(Tl(e),xn(),yi(),null!=e&&Gi(ve,m,Ln,Un,It,Ot,null))}function Ai(){d()}Ve(ye,Ee,Ai);const Ci={};Ci.mousedown=Di,Ci.mousemove=_i,Ci.mouseup=Ei,Ci.dblclick=Pi,Ci.setSeries=(e,t,l,n)=>{-1!=(l=(0,Ri.match[2])(m,t,l))&&si(l,n,!0,!1)},ut&&(Mt(xe,X,Di),Mt(ge,X,_i),Mt(be,X,e=>{Tl(e),bi(!1)}),Mt(_e,X,function(e){if(ot._lock)return;Tl(e);let t=Kn;if(Kn){let e,t,l=!0,n=!0,i=10;0==Ze.ori?(e=Qn,t=ei):(e=ei,t=Qn),e&&t&&(l=i>=Ln||Ln>=It-i,n=i>=Un||Un>=Ot-i),e&&l&&(Ln=Nn>Ln?0:It),t&&n&&(Un=Gn>Un?0:Ot),xi(null,!0,!0),Kn=!1}Ln=-10,Un=-10,it.fill(null),xi(null,!0,!0),t&&(Kn=t)}),Mt(ve,X,Pi),Ol.add(m),m.syncRect=bi);const Wi=m.hooks=t.hooks||{};function Yi(e,t,l){Vn?Bn.push([e,t,l]):e in Wi&&Wi[e].forEach(e=>{e.call(null,m,t,l)})}(t.plugins||[]).forEach(e=>{for(let t in e.hooks)Wi[t]=(Wi[t]||[]).concat(e.hooks[t])});const Hi=(e,t,l)=>l,Ri=se({key:null,setSeries:!1,filters:{pub:F,sub:F},scales:[Fe,de[1]?de[1].scale:null],match:[N,N,Hi],values:[null,null]},ot.sync);2==Ri.match.length&&Ri.match.push(Hi),ot.sync=Ri;const Fi=Ri.key,Ni=ml(Fi);function Gi(e,t,l,n,i,s,o){Ri.filters.pub(e,t,l,n,i,s,o)&&Ni.pub(e,t,l,n,i,s,o)}function Ii(){Yi("init",t,a),gn(a||t.data,!1),Ke[Fe]?qn(Fe,Ke[Fe]):xn(),bl=ti.show&&(ti.width>0||ti.height>0),xl=_l=!0,vl(t.width,t.height)}return Ni.sub(m),m.pub=function(e,t,l,n,i,s,o){Ri.filters.sub(e,t,l,n,i,s,o)&&Ci[e](null,t,l,n,i,s,o)},m.destroy=function(){Ni.unsub(m),Ol.delete(m),yt.clear(),Be(ye,Ee,Ai),G.remove(),ft?.remove(),Yi("destroy")},de.forEach(Yl),ke.forEach(function(e,t){if(e._show=e.show,e.show){let l=ze[e.scale];null==l&&(e.scale=e.side%2?de[1].scale:Fe,l=ze[e.scale]);let n=l.time;e.size=W(e.size),e.space=W(e.space),e.rotate=W(e.rotate),K(e.incrs)&&e.incrs.forEach(e=>{!V.has(e)&&V.set(e,B(e))}),e.incrs=W(e.incrs||(2==l.distr?ht:n?1==oe?Tt:Dt:pt)),e.splits=W(e.splits||(n&&1==l.distr?et:3==l.distr?qt:4==l.distr?Kt:Jt)),e.stroke=W(e.stroke),e.grid.stroke=W(e.grid.stroke),e.ticks.stroke=W(e.ticks.stroke),e.border.stroke=W(e.border.stroke);let i=e.values;e.values=K(i)&&!K(i[0])?W(i):n?K(i)?Ct(Xe,At(i,Qe)):Q(i)?function(e,t){let l=tt(t);return(t,n)=>n.map(t=>l(e(t)))}(Xe,i):i||lt:i||$t,e.filter=W(e.filter||(3>l.distr||10!=l.log?3==l.distr&&2==l.log?il:H:nl)),e.font=tn(e.font,p),e.labelFont=tn(e.labelFont,p),e._size=e.size(m,null,t,0),e._space=e._rotate=e._incrs=e._found=e._splits=e._values=null,e._size>0&&(Hl[t]=!0,e._el=Re("u-axis",U))}}),f?f instanceof HTMLElement?(f.appendChild(G),Ii()):f(m,Ii):Ii(),m}ln.assign=se,ln.fmtNum=m,ln.rangeNum=c,ln.rangeLog=o,ln.rangeAsinh=r,ln.orient=gl,ln.pxRatio=Pe,ln.join=function(e,t){if(function(e){let t=e[0][0],l=t.length;for(let n=1;e.length>n;n++){let i=e[n][0];if(i.length!=l)return!1;if(i!=t)for(let e=0;l>e;e++)if(i[e]!=t[e])return!1}return!0}(e)){let t=e[0].slice();for(let l=1;e.length>l;l++)t.push(...e[l].slice(1));return function(e,t=100){const l=e.length;if(1>=l)return!0;let n=0,i=l-1;for(;i>=n&&null==e[n];)n++;for(;i>=n&&null==e[i];)i--;if(n>=i)return!0;const s=y(1,b((i-n+1)/t));for(let t=e[n],l=n+s;i>=l;l+=s){const n=e[l];if(null!=n){if(t>=n)return!1;t=n}}return!0}(t[0])||(t=function(e){let t=e[0],l=t.length,n=Array(l);for(let e=0;n.length>e;e++)n[e]=e;n.sort((e,l)=>t[e]-t[l]);let i=[];for(let t=0;e.length>t;t++){let s=e[t],o=Array(l);for(let e=0;l>e;e++)o[e]=s[n[e]];i.push(o)}return i}(t)),t}let l=new Set;for(let t=0;e.length>t;t++){let n=e[t][0],i=n.length;for(let e=0;i>e;e++)l.add(n[e])}let n=[Array.from(l).sort((e,t)=>e-t)],i=n[0].length,s=new Map;for(let e=0;i>e;e++)s.set(n[0][e],e);for(let l=0;e.length>l;l++){let o=e[l],r=o[0];for(let e=1;o.length>e;e++){let u=o[e],a=Array(i).fill(void 0),f=t?t[l][e]:1,c=[];for(let e=0;u.length>e;e++){let t=u[e],l=s.get(r[e]);null===t?0!=f&&(a[l]=t,2==f&&c.push(l)):a[l]=t}oe(a,c,i),n.push(a)}}return n},ln.fmtDate=tt,ln.tzDate=function(e,t){if(null==t||t==lt)return"number"==typeof e?new Date(e):e;let l=new ot(e);return l.setTimeZone(t),l},ln.sync=ml;{ln.addGap=function(e,t,l){let n=e[e.length-1];n&&n[0]==t?n[1]=l:e.push([t,l])},ln.clipGaps=_l;let e=ln.paths={points:Yl};e.linear=Nl,e.stepped=function(e){const t=h(e.align,1),l=h(e.ascDesc,!1),n=h(e.alignGaps,0),s=h(e.extend,!1);return(e,o,r,u)=>{let{pxRatio:a}=e;return gl(e,o,(f,c,h,p,d,m,g,x,w,b,_)=>{[r,u]=i(h,r,u);let v=f.pxRound,{left:k,width:y}=e.bbox,M=e=>v(m(e,p,b,x)),T=e=>v(g(e,d,_,w)),S=0==p.ori?Sl:zl;const z={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},D=z.stroke,E=p.dir*(0==p.ori?1:-1);let P=T(h[1==E?r:u]),A=M(c[1==E?r:u]),C=A,W=A;s&&-1==t&&(W=k,S(D,W,P)),S(D,A,P);for(let e=1==E?r:u;e>=r&&u>=e;e+=E){let l=h[e];if(null==l)continue;let n=M(c[e]),i=T(l);1==t?S(D,n,P):S(D,C,i),S(D,n,i),P=i,C=n}let Y=C;s&&1==t&&(Y=k+y,S(D,Y,P));let[H,R]=xl(e,o);if(null!=f.fill||0!=H){let t=z.fill=new Path2D(D),l=T(f.fillTo(e,o,f.min,f.max,H));S(t,Y,l),S(t,W,l)}if(!f.spanGaps){let i=[];i.push(...vl(c,h,r,u,E,M,n,f.spanNulls));let s=f.width*a/2,d=l||1==t?s:-s,m=l||-1==t?-s:s;i.forEach(e=>{e[0]+=d,e[1]+=m}),z.gaps=i=f.gaps(e,o,r,u,i),z.clip=_l(i,p.ori,x,w,b,_)}return 0!=R&&(z.band=2==R?[b