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