uplot-plus 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/components/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAA4B,MAAM,kBAAkB,CAAC;AAU/E;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EACtB,IAAW,EACX,SAAS,EACT,QAAQ,EACR,MAAW,GACZ,EAAE,YAAY,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAoI1C"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/components/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAA4B,MAAM,kBAAkB,CAAC;AAU/E;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EACtB,IAAW,EACX,SAAS,EACT,QAAQ,EACR,MAAW,GACZ,EAAE,YAAY,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAqI1C"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("react/jsx-runtime"),z=require("react");var X=(e=>(e[e.Top=0]="Top",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left",e))(X||{}),_=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e))(_||{}),Y=(e=>(e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward",e))(Y||{}),U=(e=>(e[e.Linear=1]="Linear",e[e.Ordinal=2]="Ordinal",e[e.Log=3]="Log",e[e.Asinh=4]="Asinh",e))(U||{}),me=(e=>(e[e.Ascending=1]="Ascending",e[e.Descending=-1]="Descending",e[e.Unsorted=0]="Unsorted",e))(me||{});function he(e){return e%2}var Z=(e=>(e[e.None=0]="None",e[e.Scales=1]="Scales",e[e.Axes=2]="Axes",e[e.Paths=4]="Paths",e[e.Cursor=8]="Cursor",e[e.Select=16]="Select",e[e.Size=32]="Size",e[e.Full=63]="Full",e))(Z||{});const O=Math,De=O.PI,fe=O.abs,ne=O.floor,B=O.round,ye=O.ceil,Ue=O.min,be=O.max,pe=O.pow,Ke=O.sign,J=O.log10,xe=O.log2,It=(e,t=1)=>O.sinh(e)*t,Ee=(e,t=1)=>O.asinh(e/t),N=1/0,at=Number.isInteger;function ze(e,t){return e[t]??0}function ie(e,t,n=0,s=t.length-1){let o;const i=s<=2147483647;for(;s-n>1;)o=i?n+s>>1:ne((n+s)/2),ze(t,o)<e?n=o:s=o;return e-ze(t,n)<=ze(t,s)-e?n:s}const ct=e=>e!=null,ut=e=>e!=null&&e>0;function ft(e){return(t,n,s)=>{let o=-1,i=-1;for(let l=n;l<=s;l++)if(e(t[l])){o=l;break}for(let l=s;l>=n;l--)if(e(t[l])){i=l;break}return[o,i]}}const Ae=ft(ct),ht=ft(ut);function At(e,t,n,s=me.Unsorted,o=!1){const i=o?ht:Ae,l=o?ut:ct,[r,a]=i(e,t,n);let c=e[r]??N,u=e[r]??-N;if(r>-1)if(s===me.Ascending)c=e[r]??N,u=e[a]??-N;else if(s===me.Descending)c=e[a]??N,u=e[r]??-N;else for(let d=r;d<=a;d++){const f=e[d];f!=null&&l(f)&&(f<c?c=f:f>u&&(u=f))}return[c,u]}function re(e,t=0){if(at(e))return e;const n=10**t,s=e*n*(1+Number.EPSILON);return B(s)/n}const we=new Map;function Pt(e){return(String(e).split(".")[1]??"").length}const Lt=/\.\d*?(?=9{6,}|0{6,})/gm;function ke(e){if(at(e)||we.has(e))return e;const t=`${e}`,n=t.match(Lt);if(n==null)return e;const s=n[0].length-1;if(t.indexOf("e-")!==-1){const o=t.split("e"),i=o[0]??"0",l=o[1]??"0";return+`${ke(+i)}e${l}`}return re(e,s)}function Ge(e,t,n=!0){return n?ke(ye(ke(e/t))*t):ye(e/t)*t}function dt(e,t,n=!0){return n?ke(ne(ke(e/t))*t):ne(e/t)*t}function gt(e,t,n,s){const o=[],i=s.map(Pt);for(let l=t;l<n;l++){const r=fe(l);for(let a=0;a<s.length;a++){const c=s[a]??0,u=i[a]??0,d=+`${c}e${l}`,f=(l>=0?0:r)+(l>=u?0:u),g=d;o.push(g),we.set(g,f)}}return o}const Rt=new Intl.NumberFormat,pt=e=>Rt.format(e),Dt=.1,se={mode:3,pad:Dt,soft:null},Se={pad:0,soft:null,mode:0},zt={min:Se,max:Se};function Me(e,t,n,s){let o;typeof n=="number"?(Se.pad=n,Se.soft=null,Se.mode=0,o=zt):o=n;const i=o.min,l=o.max,r=i.pad,a=l.pad,c=i.hard??-N,u=l.hard??N,d=i.soft??N,f=l.soft??-N,g=i.mode,x=l.mode;let M=t-e;const L=J(M),h=be(fe(e),fe(t)),I=J(h),P=fe(I-L);(M<1e-24||P>10)&&(M=0,(e===0||t===0)&&(M=1e-24));const R=M||h||1e3,T=J(R),v=pe(10,ne(T)),S=R*(M===0?e===0?.1:1:r),b=re(dt(e-S,v/10),24),C=e>=d&&(g===1||g===3&&b<=d||g===2&&b>=d)?d:N,D=be(c,b<C&&e>=C?C:Ue(C,b)),p=R*(M===0?t===0?.1:1:a),m=re(Ge(t+p,v/10),24),w=t<=f&&(x===1||x===3&&m>=f||x===2&&m<=f)?f:-N,y=Ue(u,m>w&&t<=w?w:be(w,m));return D===y&&D===0?[-1,1]:[D,y]}function Ft(e,t,n,s){n===2&&(s=!0);const o=Ke(e),i=Ke(t);e===t&&(o===-1?(e*=n,t/=n):(e/=n,t*=n));const l=n===10?J:xe,r=o===1?ne:ye,a=i===1?ye:ne,c=l(fe(e)),u=l(fe(t)),d=r(c),f=a(u);let g=pe(n,d),x=pe(n,f);return n===10&&(d<0&&(g=re(g,-d)),f<0&&(x=re(x,-f))),s?(e=g*o,t=x*i):(e=dt(e,pe(n,ne(c)),!1),t=Ge(t,pe(n,ne(u)),!1)),[e,t]}function Ne(e){return(J((e^e>>31)-(e>>31))|0)+1}function Ht(e,t,n,s,o){const i=be(Ne(e),Ne(t)),l=t-e;let r=be(0,ie(o/s*l,n)-1);do{const a=n[r]??0,c=s*a/l;if(c>=o*.9&&i+(a<5?we.get(a)??0:0)<=17)return[a,c]}while(++r<n.length);return[0,0]}function Et(e){return{id:e.id,min:e.min??null,max:e.max??null,distr:e.distr??U.Linear,log:e.log??10,asinh:e.asinh??1,ori:e.ori??(e.id==="x"?_.Horizontal:_.Vertical),dir:e.dir??Y.Forward,time:e.time??!1,auto:e.auto??!0,range:e.range??null,_min:null,_max:null}}function le(e){e._min=null,e._max=null}function mt(e){if(e._min!=null)return e._min;const{min:t,distr:n}=e;if(t==null)return 0;if(n===U.Log){const s=t>0?t:1e-10;e._min=(e.log===10?J:xe)(s)}else n===U.Asinh?e._min=Ee(t,e.asinh):e._min=t;return e._min}function wt(e){if(e._max!=null)return e._max;const{max:t,distr:n}=e;if(t==null)return 0;if(n===U.Log){const s=t>0?t:1e-10;e._max=(e.log===10?J:xe)(s)}else n===U.Asinh?e._max=Ee(t,e.asinh):e._max=t;return e._max}function Gt(e,t){if(t.min==null||t.max==null)return 0;const n=mt(t),o=wt(t)-n;if(o===0)return 0;const{distr:i}=t;if(i===U.Log){const l=t.log===10?J:xe,r=e>0?e:1e-10;return(l(r)-n)/o}return i===U.Asinh?(Ee(e,t.asinh)-n)/o:(e-n)/o}function _t(e,t){if(t.min==null||t.max==null)return 0;const n=mt(t),s=wt(t);if(s===n)return t.min;const{distr:o}=t;return o===U.Log?Math.pow(t.log,n+e*(s-n)):o===U.Asinh?It(n+e*(s-n),t.asinh):n+e*(s-n)}function V(e,t,n,s){const o=Gt(e,t);let i;return t.ori===_.Horizontal?i=t.dir===Y.Forward?o:1-o:i=t.dir===Y.Forward?1-o:o,s+i*n}function te(e,t,n,s){if(n===0)return t.min??0;let o=(e-s)/n;return t.ori===_.Horizontal?t.dir===Y.Backward&&(o=1-o):t.dir!==Y.Backward&&(o=1-o),_t(o,t)}class Vt{constructor(){this.scales=new Map,this.groupXScales=new Map}addScale(t){this.scales.set(t.id,Et(t))}removeScale(t){this.scales.delete(t)}getScale(t){return this.scales.get(t)}getAllScales(){return this.scales.values()}setGroupXScale(t,n){this.groupXScales.set(t,n)}getGroupXScaleKey(t){return this.groupXScales.get(t)}setRange(t,n,s){const o=this.scales.get(t);o&&(o.min=n,o.max=s,le(o))}autoRangeX(t){var s,o,i,l,r,a;const n=new Map;for(const[c,u]of this.groupXScales){const d=this.scales.get(u);if(!d||!d.auto)continue;const f=t[c];if(!f||f.x.length===0)continue;const g=f.x[0],x=f.x[f.x.length-1];if(g==null||x==null)continue;const M=n.get(u);M?(M.dataMin=Math.min(M.dataMin,g),M.dataMax=Math.max(M.dataMax,x)):n.set(u,{dataMin:g,dataMax:x})}for(const[c,{dataMin:u,dataMax:d}]of n){const f=this.scales.get(c);if(f){if(f.range){const[g,x]=Me(u,d,{min:{pad:((s=f.range.min)==null?void 0:s.pad)??0,soft:((o=f.range.min)==null?void 0:o.soft)??null,mode:((i=f.range.min)==null?void 0:i.mode)??0},max:{pad:((l=f.range.max)==null?void 0:l.pad)??0,soft:((r=f.range.max)==null?void 0:r.soft)??null,mode:((a=f.range.max)==null?void 0:a.mode)??0}});f.min=g,f.max=x}else u===d?[f.min,f.max]=Me(u,d,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}}):(f.min=u,f.max=d);le(f)}}}autoRange(t,n,s){var r,a,c,u,d,f,g,x,M,L,h,I;const o=new Map;for(const[P,R]of this.groupXScales){const T=this.scales.get(R);if(!T||!T.auto)continue;const v=t[P];if(!v||v.x.length===0)continue;const S=v.x[0],b=v.x[v.x.length-1];if(S==null||b==null)continue;const C=o.get(R);C?(C.dataMin=Math.min(C.dataMin,S),C.dataMax=Math.max(C.dataMax,b)):o.set(R,{dataMin:S,dataMax:b})}for(const[P,{dataMin:R,dataMax:T}]of o){const v=this.scales.get(P);if(v){if(v.range){const[S,b]=Me(R,T,{min:{pad:((r=v.range.min)==null?void 0:r.pad)??0,soft:((a=v.range.min)==null?void 0:a.soft)??null,mode:((c=v.range.min)==null?void 0:c.mode)??0},max:{pad:((u=v.range.max)==null?void 0:u.pad)??0,soft:((d=v.range.max)==null?void 0:d.soft)??null,mode:((f=v.range.max)==null?void 0:f.mode)??0}});v.min=S,v.max=b}else R===T?[v.min,v.max]=Me(R,T,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}}):(v.min=R,v.max=T);le(v)}}const i=new Map,l=new Map;for(const{group:P,index:R,yScale:T}of n){const v=t[P];if(!v)continue;const S=v.series[R];if(!S||S.length===0)continue;const b=s.windows.get(P),C=b?b[0]:0,D=b?b[1]:S.length-1,p=this.scales.get(T),m=(p==null?void 0:p.distr)===U.Log,[w,y]=s.getCachedMinMax(P,R,C,D,0,m),k=i.get(T),A=l.get(T);i.set(T,k!=null?Math.min(k,w):w),l.set(T,A!=null?Math.max(A,y):y)}for(const[P,R]of i){const T=this.scales.get(P);if(!T||!T.auto)continue;const v=l.get(P)??-N;if(R===N)continue;let S,b;if(T.distr===U.Log)[S,b]=Ft(R,v,T.log,!1);else{const C=T.range??{min:se,max:se};[S,b]=Me(R,v,{min:{pad:((g=C.min)==null?void 0:g.pad)??se.pad,soft:((x=C.min)==null?void 0:x.soft)??se.soft,mode:((M=C.min)==null?void 0:M.mode)??se.mode},max:{pad:((L=C.max)==null?void 0:L.pad)??se.pad,soft:((h=C.max)==null?void 0:h.soft)??se.soft,mode:((I=C.max)==null?void 0:I.mode)??se.mode}})}T.min=S,T.max=b,le(T)}}}const $t=1024;class Bt{constructor(t,n=$t){this.data=t,this.len=t.length,this.blockSize=n,this.nBlocks=Math.ceil(t.length/n),this.blocks=new Float64Array(this.nBlocks*2),this.buildAll()}buildAll(){const{data:t,blockSize:n,nBlocks:s,blocks:o,len:i}=this;for(let l=0;l<s;l++){const r=l*n,a=Math.min(r+n,i);let c=1/0,u=-1/0;for(let d=r;d<a;d++){const f=t[d];f!=null&&(f<c&&(c=f),f>u&&(u=f))}o[l*2]=c,o[l*2+1]=u}}rangeMinMax(t,n){const{data:s,blockSize:o,blocks:i}=this;let l=1/0,r=-1/0;const a=Math.floor(t/o),c=Math.floor(n/o);if(a===c){for(let f=t;f<=n;f++){const g=s[f];g!=null&&(g<l&&(l=g),g>r&&(r=g))}return[l,r]}const u=(a+1)*o-1;for(let f=t;f<=u;f++){const g=s[f];g!=null&&(g<l&&(l=g),g>r&&(r=g))}for(let f=a+1;f<c;f++){const g=i[f*2]??1/0,x=i[f*2+1]??-1/0;g<l&&(l=g),x>r&&(r=x)}const d=c*o;for(let f=d;f<=n;f++){const g=s[f];g!=null&&(g<l&&(l=g),g>r&&(r=g))}return[l,r]}updateBlock(t){const{data:n,blockSize:s,blocks:o,len:i}=this;if(t>=this.nBlocks)return;const l=t*s,r=Math.min(l+s,i);let a=1/0,c=-1/0;for(let u=l;u<r;u++){const d=n[u];d!=null&&(d<a&&(a=d),d>c&&(c=d))}o[t*2]=a,o[t*2+1]=c}grow(t){const n=this.nBlocks;if(this.len=t,this.nBlocks=Math.ceil(t/this.blockSize),this.nBlocks>n){const o=new Float64Array(this.nBlocks*2);o.set(this.blocks),this.blocks=o}const s=Math.max(0,n-1);for(let o=s;o<this.nBlocks;o++)this.updateBlock(o)}setData(t){this.data=t}}class Wt{constructor(){this.data=[],this.windows=new Map,this.minMaxCache=new Map,this.blockTrees=new Map}setData(t){this.data=t,this.windows.clear();for(const n of this.minMaxCache.values())n.clear();this.minMaxCache.clear(),this.blockTrees.clear()}getOrBuildTree(t,n){const s=`${t}:${n}`;let o=this.blockTrees.get(s);if(o)return o;const i=this.data[t];if(!i)return;const l=i.series[n];if(!(!l||l.length===0))return o=new Bt(l),this.blockTrees.set(s,o),o}updateWindows(t){var s;let n=!1;for(let o=0;o<this.data.length;o++){const i=this.data[o],l=t(o),r=this.windows.get(o);let a,c;if(!i||!l||l.min==null||l.max==null)a=0,c=Math.max(0,((i==null?void 0:i.x.length)??1)-1);else{const u=i.x;if(u.length===0)a=0,c=0;else{a=ie(l.min,u),c=ie(l.max,u);const d=u[a],f=u[c];a>0&&d!=null&&d>l.min&&a--,c<u.length-1&&f!=null&&f<l.max&&c++}}(!r||r[0]!==a||r[1]!==c)&&(n=!0,(s=this.minMaxCache.get(o))==null||s.clear()),this.windows.set(o,[a,c])}return n}getWindow(t){var n;return this.windows.get(t)??[0,(((n=this.data[t])==null?void 0:n.x.length)||1)-1]}getXValues(t){var n;return((n=this.data[t])==null?void 0:n.x)??[]}getYValues(t,n){var s;return((s=this.data[t])==null?void 0:s.series[n])??[]}getCachedMinMax(t,n,s,o,i,l){let r=this.minMaxCache.get(t);const a=`${n}:${s}:${o}`;if(r){const g=r.get(a);if(g!=null)return g}else r=new Map,this.minMaxCache.set(t,r);const c=this.data[t];if(!c)return[1/0,-1/0];const u=c.series[n];if(!u||u.length===0)return[1/0,-1/0];let d;const f=!l&&i===me.Unsorted?this.getOrBuildTree(t,n):void 0;return f?d=f.rangeMinMax(s,o):d=At(u,s,o,i,l),r.set(a,d),d}getBlockTree(t,n){return this.getOrBuildTree(t,n)}appendData(t,n,s){var l;const o=this.data[t];if(!o)return;const i=o.x;if(Array.isArray(i)){for(let r=0;r<n.length;r++){const a=n[r];a!=null&&i.push(a)}for(let r=0;r<o.series.length;r++){const a=o.series[r];if(!a||!Array.isArray(a))continue;const c=s[r];if(c)for(let d=0;d<c.length;d++)a.push(c[d]??null);const u=this.blockTrees.get(`${t}:${r}`);u&&(u.setData(a),u.grow(a.length))}(l=this.minMaxCache.get(t))==null||l.clear()}}static toTypedX(t){for(const n of t)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return t}}class jt{constructor(){this.state={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1}}hide(){this.state.left=-10,this.state.top=-10,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(t,n,s,o,i,l,r,a){this.state.left=t,this.state.top=n;let c=1/0,u=-1,d=-1,f=-1;const g=new Map;for(const x of i){if(x.show===!1)continue;let M=g.get(x.group);M==null&&(M=[],g.set(x.group,M)),M.push(x)}for(let x=0;x<o.length;x++){const M=o[x];if(M==null)continue;const L=M.x;if(L.length===0)continue;const h=a(x);if(h==null)continue;const I=l(h);if(I==null||I.min==null||I.max==null)continue;const[P,R]=r(x),T=s.width,v=s.left,S=te(t+v,I,T,v),b=ie(S,L,P,R),C=[b];b>P&&C.push(b-1),b<R&&C.push(b+1);const D=new Map;for(const p of C){const m=L[p];if(m==null)continue;const w=V(m,I,T,v);for(const y of g.get(x)??[]){const k=M.series[y.index];if(k==null)continue;const A=k[p];if(A==null)continue;let F=D.get(y.yScale);if(F==null&&!D.has(y.yScale)&&(F=l(y.yScale),D.set(y.yScale,F)),F==null||F.min==null||F.max==null)continue;const H=s.height,E=s.top,$=V(A,F,H,E),W=t+v-w,j=n+E-$,K=W*W+j*j;if(K<c&&(c=K,u=x,d=y.index,f=p,K===0))break}if(c===0)break}}this.state.activeGroup=u,this.state.activeSeriesIdx=d,this.state.activeDataIdx=f}syncToValue(t,n){const s=n.dataStore.data;if(s.length===0)return;const o=s[0];if(o==null)return;const i=n.scaleManager.getGroupXScaleKey(0);if(i==null)return;const l=n.scaleManager.getScale(i);if(l==null||l.min==null||l.max==null)return;const[r,a]=n.dataStore.getWindow(0),c=ie(t,o.x,r,a),u=o.x[c];if(u==null)return;const d=V(u,l,n.plotBox.width,n.plotBox.left);this.state.left=d-n.plotBox.left,this.state.activeGroup=0,this.state.activeDataIdx=c;let f=0,g=n.plotBox.height/2;for(const x of n.seriesConfigs){if(x.group!==0||x.show===!1)continue;const M=o.series[x.index];if(M==null)continue;const L=M[c];if(L==null)continue;const h=n.scaleManager.getScale(x.yScale);if(!(h==null||h.min==null||h.max==null)){g=V(L,h,n.plotBox.height,n.plotBox.top)-n.plotBox.top,f=x.index;break}}this.state.top=g,this.state.activeSeriesIdx=f}}class Xt{constructor(){this.flags=Z.None,this.frameId=null,this.callback=null}mark(t){this.flags|=t,this.scheduleFrame()}has(t){return(this.flags&t)!==0}get dirty(){return this.flags}clear(){this.flags=Z.None}onRedraw(t){this.callback=t}scheduleFrame(){this.frameId==null&&(this.frameId=requestAnimationFrame(()=>{this.frameId=null;const t=this.callback;t!=null&&t(),this.clear()}))}cancel(){this.frameId!=null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}dispose(){this.cancel(),this.callback=null,this.flags=Z.None}}function Pe(e,t,n){e.lineTo(t,n)}function Le(e,t,n){e.lineTo(n,t)}function _e(e,t,n,s,o,i){const l=[];let r=-1;const a=o===Y.Forward?n:s,c=o===Y.Forward?s:n,u=o;for(let d=a;o===Y.Forward?d<=c:d>=c;d+=u)if(t[d]===null||t[d]===void 0){if(r===-1){const f=Math.max(n,Math.min(d-o,s));r=i(e[f])}}else r!==-1&&(l.push([r,i(e[d])]),r=-1);return r!==-1&&l.push([r,i(e[s])]),l}function Ve(e,t,n,s,o,i){const l=new Path2D;let r=t===_.Horizontal?n:s;const a=t===_.Horizontal?n+o:s+i,c=t===_.Horizontal?s:n,u=t===_.Horizontal?i:o;for(const[d,f]of e)d>r&&(t===_.Horizontal?l.rect(r,c,d-r,u):l.rect(c,r,u,d-r)),r=f;return r<a&&(t===_.Horizontal?l.rect(r,c,a-r,u):l.rect(c,r,u,a-r)),l}function xt(e){return(t,n,s,o,i,l)=>{s!==o&&(i!==s&&l!==s&&e(t,n,s),i!==o&&l!==o&&e(t,n,o),e(t,n,l))}}const Yt=xt(Pe),Ut=xt(Le);function vt(){return(e,t,n,s,o,i,l,r,a,c,u,d,f)=>{const g=(f==null?void 0:f.spanGaps)??!1;if([a,c]=(s.distr===U.Log?ht:Ae)(t,a,c),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const M=S=>d(V(S,n,o,l)),L=S=>d(V(S,s,i,r));let h,I;n.ori===_.Horizontal?(h=Pe,I=Yt):(h=Le,I=Ut);const P={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},R=P.stroke;let T=!1;if(c-a>=o*4){const S=A=>te(A,n,o,l);let b=null,C=0,D=0,p=0,m=M(e[u===Y.Forward?a:c]);const w=M(e[a]),y=M(e[c]);let k=S(u===Y.Forward?w+1:y-1);for(let A=u===Y.Forward?a:c;A>=a&&A<=c;A+=u){const F=e[A],E=(u===Y.Forward?F<k:F>k)?m:M(F),$=t[A];E===m?$!=null?(p=$,b==null?(h(R,E,L(p)),D=b=C=p):p<b?b=p:p>C&&(C=p)):$===null&&!g&&(T=!0):(b!=null&&I(R,m,L(b),L(C),L(D),L(p)),$!=null?(p=$,h(R,E,L(p)),b=C=D=p):(b=null,C=0,$===null&&!g&&(T=!0)),m=E,k=S(m+u))}b!=null&&(b!==C?I(R,m,L(b),L(C),L(D),L(p)):h(R,m,L(p)))}else for(let S=u===Y.Forward?a:c;S>=a&&S<=c;S+=u){const b=t[S];b===null&&!g?T=!0:b!=null&&h(R,M(e[S]),L(b))}{const S=P.fill=new Path2D(R),b=(f==null?void 0:f.fillTo)??s.min??0,C=L(b);let D=l,p=l+o;u===Y.Backward&&([p,D]=[D,p]),h(S,p,C),h(S,D,C)}if(T){const S=_e(e,t,a,c,u,M);P.gaps=S,P.clip=Ve(S,n.ori,l,r,o,i)}return P}}const qe=new WeakMap;function Oe(e,t,n){return typeof t=="string"?t:Kt(e,t,n)}function Kt(e,t,n){const s=qe.get(t);if(s!=null&&s.top===n.top&&s.height===n.height)return s.grad;const o=e.createLinearGradient(0,n.top,0,n.top+n.height);for(const[i,l]of t.stops)o.addColorStop(i,l);return qe.set(t,{grad:o,top:n.top,height:n.height}),o}function Nt(e,t,n,s,o){if(t.show===!1)return;const i=t.alpha??1;e.save(),i<1&&(e.globalAlpha=i),n.clip&&e.clip(n.clip);const l=o??{top:0,width:e.canvas.width/s,height:e.canvas.height/s};if(t.fill&&n.fill&&(e.fillStyle=Oe(e,t.fill,l),e.fill(n.fill)),t.stroke){const r=(t.width??1)*s;e.strokeStyle=Oe(e,t.stroke,l),e.lineWidth=r,e.lineJoin=t.join??"round",e.lineCap=t.cap??"butt",t.dash&&e.setLineDash(t.dash.map(d=>d*s));const a=t.pxAlign??1,c=r%2/2;a===1&&c>0&&e.translate(c,c),e.stroke(n.stroke)}e.restore()}const qt=vt(),Ze=64;class Ot{constructor(){this.ctx=null,this.pxRatio=1,this.pathCache=new Map,this.pathCacheSize=0,this.bandCache=new Map,this.lruHead=null,this.lruTail=null,this.lruMap=new Map,this.snapshotCanvas=null,this.snapshotValid=!1,this.cachedFillStyle="",this.cachedStrokeStyle="",this.cachedLineWidth=-1,this.cachedFont="",this.cachedTextAlign="",this.cachedTextBaseline="",this.cachedGlobalAlpha=-1}lruKey(t,n,s){return`${t}:${n}:${s}`}lruUnlink(t){t.prev!=null?t.prev.next=t.next:this.lruHead=t.next,t.next!=null?t.next.prev=t.prev:this.lruTail=t.prev,t.prev=null,t.next=null}lruAppend(t){t.prev=this.lruTail,t.next=null,this.lruTail!=null?this.lruTail.next=t:this.lruHead=t,this.lruTail=t}setContext(t,n){this.ctx=t,this.pxRatio=n,this.resetPropertyCache()}resetPropertyCache(){this.cachedFillStyle="",this.cachedStrokeStyle="",this.cachedLineWidth=-1,this.cachedFont="",this.cachedTextAlign="",this.cachedTextBaseline="",this.cachedGlobalAlpha=-1}setFillStyle(t,n){n!==this.cachedFillStyle&&(t.fillStyle=n,this.cachedFillStyle=n)}setStrokeStyle(t,n){n!==this.cachedStrokeStyle&&(t.strokeStyle=n,this.cachedStrokeStyle=n)}setLineWidth(t,n){n!==this.cachedLineWidth&&(t.lineWidth=n,this.cachedLineWidth=n)}setFont(t,n){n!==this.cachedFont&&(t.font=n,this.cachedFont=n)}setTextAlign(t,n){n!==this.cachedTextAlign&&(t.textAlign=n,this.cachedTextAlign=n)}setTextBaseline(t,n){n!==this.cachedTextBaseline&&(t.textBaseline=n,this.cachedTextBaseline=n)}setGlobalAlpha(t,n){n!==this.cachedGlobalAlpha&&(t.globalAlpha=n,this.cachedGlobalAlpha=n)}saveSnapshot(t,n,s){const o=t.canvas;(this.snapshotCanvas==null||this.snapshotCanvas.width!==n||this.snapshotCanvas.height!==s)&&(this.snapshotCanvas=typeof OffscreenCanvas<"u"?new OffscreenCanvas(n,s):document.createElement("canvas"),this.snapshotCanvas.width=n,this.snapshotCanvas.height=s);const i=this.snapshotCanvas.getContext("2d");i!=null&&typeof i.drawImage=="function"&&(i.clearRect(0,0,n,s),i.drawImage(o,0,0),this.snapshotValid=!0)}restoreSnapshot(t){return!this.snapshotValid||this.snapshotCanvas==null||typeof t.drawImage!="function"?!1:(t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(this.snapshotCanvas,0,0),!0)}invalidateSnapshot(){this.snapshotValid=!1}windowKey(t,n){return`${t}:${n}`}getCachedPaths(t,n,s,o){const i=this.pathCache.get(t);if(i==null)return;const l=i.get(n);if(l==null)return;const r=this.windowKey(s,o),a=l.get(r);if(a!=null){const c=this.lruMap.get(this.lruKey(t,n,r));c!=null&&c!==this.lruTail&&(this.lruUnlink(c),this.lruAppend(c))}return a}setCachedPaths(t,n,s,o,i){if(this.pathCacheSize>=Ze){const u=Ze>>2;let d=this.lruHead;for(let f=0;f<u&&d!=null;f++){const g=d.next,x=this.pathCache.get(d.group);if(x!=null){const M=x.get(d.index);M!=null&&(M.delete(d.key),this.pathCacheSize--,M.size===0&&x.delete(d.index),x.size===0&&this.pathCache.delete(d.group))}this.lruMap.delete(this.lruKey(d.group,d.index,d.key)),d=g}this.lruHead=d,d!=null?d.prev=null:this.lruTail=null}let l=this.pathCache.get(t);l==null&&(l=new Map,this.pathCache.set(t,l));let r=l.get(n);r==null&&(r=new Map,l.set(n,r));const a=this.windowKey(s,o),c=this.lruKey(t,n,a);if(!r.has(a)){this.pathCacheSize++;const u={group:t,index:n,key:a,prev:null,next:null};this.lruAppend(u),this.lruMap.set(c,u)}r.set(a,i)}invalidateSeries(t,n){const s=this.pathCache.get(t);if(s==null)return;const o=s.get(n);if(o!=null){this.pathCacheSize-=o.size;for(const i of o.keys()){const l=this.lruKey(t,n,i),r=this.lruMap.get(l);r!=null&&(this.lruUnlink(r),this.lruMap.delete(l))}s.delete(n)}}clearGroupCache(t){const n=this.pathCache.get(t);if(n!=null){for(const[s,o]of n.entries()){this.pathCacheSize-=o.size;for(const i of o.keys()){const l=this.lruKey(t,s,i),r=this.lruMap.get(l);r!=null&&(this.lruUnlink(r),this.lruMap.delete(l))}}this.pathCache.delete(t)}for(const s of this.bandCache.keys())s.startsWith(`${t}:`)&&this.bandCache.delete(s);this.snapshotValid=!1}clearCache(){this.pathCache.clear(),this.pathCacheSize=0,this.lruHead=null,this.lruTail=null,this.lruMap.clear(),this.bandCache.clear(),this.snapshotValid=!1}bandKey(t,n,s,o,i){return`${t}:${n}:${s}:${o}:${i}`}getCachedBandPath(t,n,s,o,i){return this.bandCache.get(this.bandKey(t,n,s,o,i))}setCachedBandPath(t,n,s,o,i,l){this.bandCache.set(this.bandKey(t,n,s,o,i),l)}drawSeries(t,n,s){const o=this.ctx;if(o==null||t.config.show===!1)return;const i=t.config.group,l=t.config.index,[r,a]=t.window;let c=this.getCachedPaths(i,l,r,a);if(c==null){const u=t.config.paths??qt,d=t.xScale.dir,f=M=>B(M),g=t.config.fillTo,x=typeof g=="function"?g(t.yScale.min??0,t.yScale.max??0):g;c=u(t.dataX,t.dataY,t.xScale,t.yScale,n.width,n.height,n.left,n.top,r,a,d,f,{fillTo:x,spanGaps:t.config.spanGaps}),this.setCachedPaths(i,l,r,a,c)}Nt(o,t.config,c,s,n)}draw(t,n,s,o){const i=this.ctx;if(i==null)return;const l=this.pxRatio;i.clearRect(0,0,t*l,n*l),i.save(),i.scale(l,l),i.beginPath(),i.rect(s.left,s.top,s.width,s.height),i.clip();for(const r of o)this.drawSeries(r,s,1);i.restore(),this.resetPropertyCache()}}const Mt=[1,2,2.5,5],Zt=gt(10,-32,0,Mt),Jt=gt(10,0,32,Mt),ae=Zt.concat(Jt);function Qt(e,t,n,s,o){if(n<=0||t<e)return[];const i=[],l=we.get(n)??0,r=o?e:re(Ge(e,n),l);for(let a=r;a<=t;a=re(a+n,l))i.push(Object.is(a,-0)?0:a);return i}function Je(e){return e.map(t=>pt(t))}function en(e,t,n){if(e<=0||t<=0||e>=t)return[];const s=[],i=ne((n===10?J:xe)(e));let l=pe(n,i);n===10&&(l=ae[ie(l,ae)]??l);let r=l,a=l*n;n===10&&(a=ae[ie(a,ae)]??a);let c=0;do{if(r>=e&&s.push(r),r=r+l,n===10&&!we.has(r)){const u=we.get(l)??0;r=re(r,u)}r>=a*(1-1e-10)&&(l=r,a=l*n,n===10&&(a=ae[ie(a,ae)]??a))}while(r<=t&&++c<1e4);return s}function tn(e,t){const n=t===10?J:xe;return e.map(s=>{if(s===0)return!0;if(s<0)return!1;const o=n(s);return fe(o-Math.round(o))<1e-10})}function nn(e,t){const s=pt(Math.max(Math.abs(e),Math.abs(t))).length*7;return Math.max(50,s+16)}function sn(e,t,n,s){if(s<=0)return[0,0];const o=he(e.side)===_.Vertical,i=e.space??(o?30:nn(t,n)),l=e.incrs??ae;return Ht(t,n,l,s,i)}const on=50;function ln(e,t,n){var r,a;if(e.size!=null)return e.size;const s=((r=e.ticks)==null?void 0:r.show)!==!1?((a=e.ticks)==null?void 0:a.size)??10:0,o=e.gap??5,i=12;if(he(e.side)===_.Vertical&&t!=null){let c=0;for(const d of t)d.length>c&&(c=d.length);const u=c*7;return Math.max(50,s+o+u+4)}return Math.max(50,s+o+i+3)}function rn(e){return{config:e,_show:e.show!==!1,_size:e.size??on,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const ge=60,ce=3600,oe=86400,ue=2592e3,Ce=31536e3,an=[1,5,10,15,30,ge,5*ge,10*ge,15*ge,30*ge,ce,2*ce,3*ce,4*ce,6*ce,12*ce,oe,2*oe,3*oe,7*oe,14*oe,ue,2*ue,3*ue,6*ue,Ce];function cn(e,t,n,s){const o=[];if(n<=0||e>=t)return o;let i;if(n>=Ce){const l=new Date(e*1e3);for(l.setUTCMonth(0,1),l.setUTCHours(0,0,0,0),i=l.getTime()/1e3,i<e&&(l.setUTCFullYear(l.getUTCFullYear()+1),i=l.getTime()/1e3);i<=t;)o.push(i),l.setUTCFullYear(l.getUTCFullYear()+Math.round(n/Ce)),i=l.getTime()/1e3;return o}if(n>=ue){const l=new Date(e*1e3);l.setUTCDate(1),l.setUTCHours(0,0,0,0),i=l.getTime()/1e3;const r=Math.max(1,Math.round(n/ue));if(i<e&&(l.setUTCMonth(l.getUTCMonth()+1),i=l.getTime()/1e3),r>1){const a=l.getUTCMonth(),c=Math.ceil((a+1)/r)*r;l.setUTCMonth(c-1),i=l.getTime()/1e3}for(;i<=t;)o.push(i),l.setUTCMonth(l.getUTCMonth()+r),i=l.getTime()/1e3;return o}if(n>=oe){const l=new Date(e*1e3);l.setUTCHours(0,0,0,0),i=l.getTime()/1e3,i<e&&(i+=oe)}else i=Math.ceil(e/n)*n;for(let l=0;;l++){const r=i+l*n;if(r>t)break;o.push(r)}return o}const Qe=new Map;function un(e,t){const n=JSON.stringify(e)+(t??"");let s=Qe.get(n);return s==null&&(s=new Intl.DateTimeFormat(void 0,{...e,timeZone:t}),Qe.set(n,s)),s}function Q(e,t,n){const s=new Date(e*1e3);return un(t,n).format(s)}function fn(e,t){return Q(e,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function hn(e,t){return Q(e,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function dn(e,t){return Q(e,{hour:"2-digit",minute:"2-digit",hour12:!1},t)}function gn(e,t){return Q(e,{month:"short",day:"numeric"},t)}function pn(e,t){return Q(e,{year:"numeric"},t)}function mn(e,t){return Q(e,{year:"numeric",month:"short"},t)}function wn(e,t,n){let s;return t>=Ce?s=pn:t>=ue?s=mn:t>=oe?s=gn:t>=ce?s=dn:t>=ge?s=hn:s=fn,e.map(o=>s(o,n))}function xn(e,t,n,s,o){const i=t-e;if(i<=0||s<=0)return[0,0];for(const r of n){const a=i/r,c=s/a;if(c>=o)return[r,c]}const l=n[n.length-1]??Ce;return[l,s/(i/l)]}const vn=3;function Mn(e,t,n,s,o){let i=!0;for(const l of e){const r=l.config;if(r.show===!1)continue;const a=t(r.scale);if(!a||a.min==null||a.max==null){l._show&&(i=!1,l._show=!1);continue}else l._show||(i=!1,l._show=!0);const c=r.side,d=he(c)===_.Horizontal?n:s,{min:f,max:g}=a;let x,M;if(a.time){const h=r.space??80;[x,M]=xn(f,g,an,d,h)}else[x,M]=sn(r,f,g,d);if(l._incr=x,l._space=M,M===0)continue;if(r.splits)l._splits=r.splits(f,g,x,M);else if(a.time)l._splits=cn(f,g,x);else if(a.distr===U.Log)l._splits=en(f,g,a.log);else{const h=a.distr===U.Ordinal;l._splits=Qt(f,g,x,M,h)}if(r.values)l._values=r.values(l._splits,M,x);else if(a.time)l._values=wn(l._splits,x);else if(a.distr===U.Log){const h=tn(l._splits,a.log),I=Je(l._splits);l._values=I.map((P,R)=>h[R]?P:"")}else l._values=Je(l._splits);l._rotate=c===X.Bottom?r.rotate??0:0;const L=l._size;l._size=ye(ln(r,l._values)),L!==l._size&&(i=!1)}return i}function et(e,t,n){let s=e,o=t,i=0,l=0;for(const r of n){if(!r._show)continue;const a=r.config.side,c=he(a)===_.Vertical,u=r.config.label!=null?r.config.labelSize??20:0,d=r._size+u;d>0&&(c?(s-=d,a===X.Left&&(i+=d)):(o-=d,a===X.Top&&(l+=d)))}return{left:i,top:l,width:Math.max(s,0),height:Math.max(o,0)}}function bn(e,t){let n=t.top,s=t.left+t.width,o=t.top+t.height,i=t.left;function l(r,a){switch(r){case X.Top:return n-=a,n+a;case X.Right:{const c=s;return s+=a,c}case X.Bottom:{const c=o;return o+=a,c}case X.Left:return i-=a,i+a;default:return 0}}for(const r of e){if(!r._show)continue;const a=r.config.side;if(r._pos=l(a,r._size),r.config.label!=null){const c=r.config.labelSize??20;r._lpos=l(a,c)}}}function Sn(e,t,n,s){for(const r of n)r._size=0;let o=!1,i=0,l={left:0,top:0,width:e,height:t};for(;!o;){i++;const r=Mn(n,s,l.width,l.height);o=i===vn||r,o||(l=et(e,t,n))}return l=et(e,t,n),bn(n,l),l}const tt="top",nt="bottom",yn="left",kn="right";function st(e,t){return t===1?e:e.replace(/(\d+(?:\.\d+)?)px/,(n,s)=>`${Math.round(Number(s)*t)}px`)}function ot(e,t,n,s,o,i,l,r,a,c,u){const d=r%2/2;e.save(),e.translate(d,d),e.strokeStyle=a,e.lineWidth=r,c.length>0&&e.setLineDash(c),e.beginPath();let f=0,g=0,x=0,M=0;const L=i+(o===X.Top||o===X.Left?-l:l);s===_.Horizontal?(g=i,M=L):(f=i,x=L);for(let h=0;h<t.length;h++)n[h]!=null&&(s===_.Horizontal?f=x=t[h]??0:g=M=t[h]??0,e.moveTo(f,g),e.lineTo(x,M));e.stroke(),e.restore()}function Cn(e,t,n,s,o){const i=B(s.left*o),l=B(s.top*o),r=B(s.width*o),a=B(s.height*o);for(const c of t){if(!c._show)continue;const u=c.config,d=u.side,f=he(d),g=n(u.scale);if(!g||g.min==null||g.max==null)continue;const x=u.stroke??"#000",M=d===X.Top||d===X.Left?-1:1,L=c._splits,h=c._values;if(!L||!h||c._space===0)continue;const I=f===_.Horizontal?s.width:s.height,P=f===_.Horizontal?s.left:s.top,R=L.map(C=>B(V(C,g,I,P)*o)),T=h.map(C=>C===""?null:C),v=u.grid;if((v==null?void 0:v.show)!==!1){const C=(v==null?void 0:v.stroke)??"rgba(0,0,0,0.12)",D=B(((v==null?void 0:v.width)??2)*o),p=((v==null?void 0:v.dash)??[]).map(y=>y*o),m=f===_.Horizontal?l:i,w=f===_.Horizontal?a:r;ot(e,R,T,f,2,m,w,D,C,p)}const S=u.ticks;if((S==null?void 0:S.show)!==!1){const C=(S==null?void 0:S.stroke)??x,D=B(((S==null?void 0:S.width)??1)*o),p=B(((S==null?void 0:S.size)??10)*o),m=((S==null?void 0:S.dash)??[]).map(y=>y*o),w=B(c._pos*o);ot(e,R,T,f,d,w,p,D,C,m)}{const C=(S==null?void 0:S.show)!==!1?((S==null?void 0:S.size)??10)*o:0,D=B((u.gap??5)*o),p=B(c._pos*o),m=(C+D)*M,w=p+m,y=st(u.font??"12px system-ui, sans-serif",o),k=f===_.Horizontal?"center":d===X.Left?kn:yn,A=f===_.Horizontal?d===X.Bottom?tt:nt:"middle";e.font=y,e.fillStyle=x,e.textAlign=k,e.textBaseline=A;const F=c._rotate*-De/180;if(F!==0){const H=Math.cos(F),E=Math.sin(F);for(let $=0;$<h.length;$++){const W=h[$];if(W==null||W==="")continue;const j=R[$]??0;e.setTransform(H,E,-E,H,j,w),e.fillText(W,0,0)}e.setTransform(1,0,0,1,0,0)}else for(let H=0;H<h.length;H++){const E=h[H];if(E==null||E==="")continue;const $=R[H]??0,W=f===_.Horizontal?$:w,j=f===_.Horizontal?w:$;e.fillText(E,W,j)}}if(u.label!=null){const C=st(u.labelFont??"bold 12px system-ui, sans-serif",o);e.font=C,e.fillStyle=x,e.textAlign="center",e.textBaseline=d===X.Bottom?tt:nt;const D=B((c._lpos+(u.labelGap??0)*M)*o);f===_.Vertical?(e.save(),e.translate(D,B(l+a/2)),e.rotate((d===X.Left?-De:De)/2),e.fillText(u.label,0,0),e.restore()):e.fillText(u.label,B(i+r/2),D)}const b=u.border;if((b==null?void 0:b.show)!==!1&&b!=null){const C=b.stroke??x,D=B((b.width??1)*o),p=(b.dash??[]).map(w=>w*o),m=B(c._pos*o);e.strokeStyle=C,e.lineWidth=D,p.length>0&&e.setLineDash(p),e.beginPath(),f===_.Horizontal?(e.moveTo(i,m),e.lineTo(i+r,m)):(e.moveTo(m,l),e.lineTo(m,l+a)),e.stroke(),p.length>0&&e.setLineDash([])}}}const Tn={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function lt(e,t,n,s,o,i,l,r,a){var P;if(t.left<0||t.top<0)return;const c={...Tn,...a},u=s,d=B(n.left*u),f=B(n.top*u),g=B(n.width*u),x=B(n.height*u),M=B(c.width*u),L=M%2/2,h=B((n.left+t.left)*u)+L,I=B((n.top+t.top)*u)+L;if(e.save(),e.strokeStyle=c.stroke,e.lineWidth=M,e.setLineDash(c.dash.map(R=>R*u)),c.showX&&(e.beginPath(),e.moveTo(h,f),e.lineTo(h,f+x),e.stroke()),c.showY&&(e.beginPath(),e.moveTo(d,I),e.lineTo(d+g,I),e.stroke()),e.setLineDash([]),t.activeGroup>=0&&t.activeDataIdx>=0){const R=t.activeGroup,T=t.activeSeriesIdx,v=t.activeDataIdx,S=o[R];if(S!=null&&T>=0&&T<S.series.length&&v<S.x.length){const b=S.x[v],C=S.series[T],D=C!=null?C[v]:null;if(b!=null&&D!=null){let p=c.stroke,m=!0;for(const w of i)if(w.group===R&&w.index===T){const y=w.stroke;p=(typeof y=="string"?y:void 0)??c.stroke,m=((P=w.cursor)==null?void 0:P.show)!==!1;break}if(m){const w=r(R),y=w!=null?l(w):void 0,k=In(i,R,T),A=k!=null?l(k):void 0;if(y!=null&&A!=null&&y.min!=null&&y.max!=null&&A.min!=null&&A.max!=null){const F=B(V(b,y,n.width,n.left)*u),H=B(V(D,A,n.height,n.top)*u),E=c.pointRadius*u,$=B(2*u);e.beginPath(),e.arc(F,H,E,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.strokeStyle=p,e.lineWidth=$,e.stroke()}}}}}e.restore()}function In(e,t,n){for(const s of e)if(s.group===t&&s.index===n)return s.yScale}const An={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function it(e,t,n,s,o){if(!t.show||t.width<=0)return;const i={...An,...o},l=s,r=B((n.left+t.left)*l),a=B((n.top+t.top)*l),c=B(t.width*l),u=B(t.height*l);e.save(),e.fillStyle=i.fill,e.fillRect(r,a,c,u),i.width>0&&(e.strokeStyle=i.stroke,e.lineWidth=B(i.width*l),e.strokeRect(r,a,c,u)),e.restore()}function Pn(e,t,n,s,o,i,l,r,a,c,u,d){const f=u/2*l,g=Math.max(1,B(u*.2))*l,x=(c==null?void 0:c.stroke)??d,M=(c==null?void 0:c.fill)??"#fff";e.save(),e.strokeStyle=x,e.fillStyle=M,e.lineWidth=g,(c==null?void 0:c.dash)!=null&&e.setLineDash(c.dash.map(L=>L*l));for(let L=r;L<=a;L++){const h=n[L];if(h==null)continue;const I=t[L];if(I==null)continue;const P=B(V(I,s,i.width,i.left)*l),R=B(V(h,o,i.height,i.top)*l);e.beginPath(),e.arc(P,R,f,0,Math.PI*2),e.fill(),e.stroke()}e.restore()}function Ln(e,t,n,s,o,i,l){if(typeof e=="function")return e(t,n,s,o,i);if(e===!0)return!0;if(e===!1)return!1;const r=o-s;return r>0&&r<=i/l}function Rn(e,t,n,s,o,i,l,r,a){if(r>a||r<0)return null;const c=g=>V(g,s,i.width,i.left)*l,u=g=>V(g,o,i.height,i.top)*l,d=new Path2D;let f=!1;for(let g=r;g<=a;g++){const x=t[g],M=e[g];if(x==null||M==null)continue;const L=c(M),h=u(x);f?d.lineTo(L,h):(d.moveTo(L,h),f=!0)}if(!f)return null;for(let g=a;g>=r;g--){const x=n[g],M=e[g];x==null||M==null||d.lineTo(c(M),u(x))}return d.closePath(),d}function Dn(e,t,n){e.save(),e.fillStyle=t.fill??"rgba(0, 120, 255, 0.1)",e.fill(n),e.restore()}function Fe(e,t,n,s){return{ctx:e,plotBox:t,pxRatio:n,getScale:s,valToX:(l,r="x")=>{const a=s(r);return a==null||a.min==null||a.max==null?null:V(l,a,t.width,t.left)},valToY:(l,r)=>{const a=s(r);return a==null||a.min==null||a.max==null?null:V(l,a,t.height,t.top)}}}function zn(){const e={scaleManager:new Vt,dataStore:new Wt,renderer:new Ot,cursorManager:new jt,selectState:{show:!1,left:0,top:0,width:0,height:0},scaleConfigs:[],seriesConfigs:[],axisConfigs:[],bandConfigs:[],axisStates:[],width:0,height:0,pxRatio:typeof window<"u"&&window.devicePixelRatio||1,plotBox:{left:0,top:0,width:0,height:0},canvas:null,listeners:new Set,scheduler:new Xt,drawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:.15,wheelZoom:!1,revision:0,eventCallbacks:{},_prevScaleRanges:new Map,registerScale(t){e.scaleConfigs=e.scaleConfigs.filter(n=>n.id!==t.id),e.scaleConfigs.push(t),e.scaleManager.addScale(t)},unregisterScale(t){e.scaleConfigs=e.scaleConfigs.filter(n=>n.id!==t),e.scaleManager.removeScale(t)},registerSeries(t){e.seriesConfigs=e.seriesConfigs.filter(n=>!(n.group===t.group&&n.index===t.index)),e.seriesConfigs.push(t)},unregisterSeries(t,n){e.seriesConfigs=e.seriesConfigs.filter(s=>!(s.group===t&&s.index===n))},toggleSeries(t,n){const s=e.seriesConfigs.find(o=>o.group===t&&o.index===n);s!=null&&(s.show=s.show===!1,e.revision++,e.renderer.invalidateSeries(t,n),e.scheduleRedraw())},setFocus(t){e.focusedSeries=t,e.scheduleRedraw()},setSize(t,n){e.width=t,e.height=n,e.canvas&&(e.canvas.width=t*e.pxRatio,e.canvas.height=n*e.pxRatio,e.canvas.style.width=`${t}px`,e.canvas.style.height=`${n}px`),e.renderer.clearCache(),e.scheduleRedraw()},scheduleRedraw(){e.scheduler.mark(Z.Full)},scheduleCursorRedraw(){e.scheduler.mark(Z.Cursor)},subscribe(t){return e.listeners.add(t),()=>{e.listeners.delete(t)}},redraw(){const{scaleManager:t,dataStore:n,renderer:s,seriesConfigs:o,width:i,height:l,pxRatio:r,canvas:a,scheduler:c}=e;if(a==null||i===0||l===0)return;const u=a.getContext("2d");if(u==null)return;s.setContext(u,r);const f=(c.dirty&~(Z.Cursor|Z.Select))===0,g=h=>t.getScale(h);if(f&&s.restoreSnapshot(u)){if(lt(u,e.cursorManager.state,e.plotBox,r,n.data,o,g,h=>t.getGroupXScaleKey(h)),it(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const h=Fe(u,e.plotBox,r,g);for(const I of e.cursorDrawHooks)try{I(h,e.cursorManager.state)}catch(P){console.warn("[uPlot+] draw hook error:",P)}u.restore()}for(const h of e.listeners)h();return}t.autoRangeX(n.data),n.updateWindows(h=>{const I=t.getGroupXScaleKey(h);return I!=null?t.getScale(I):void 0});const x=o.map(h=>({group:h.group,index:h.index,yScale:h.yScale}));t.autoRange(n.data,x,n),Fn(e),e.axisStates.length>0?e.plotBox=Sn(i,l,e.axisStates,g):e.plotBox={left:10,top:10,width:i-20,height:l-20},u.clearRect(0,0,i*r,l*r),e.axisStates.length>0&&Cn(u,e.axisStates,g,e.plotBox,r);const M=[];for(const h of o){const I=t.getGroupXScaleKey(h.group),P=I!=null?t.getScale(I):void 0,R=t.getScale(h.yScale);P==null||R==null||M.push({config:h,dataX:n.getXValues(h.group),dataY:n.getYValues(h.group,h.index),xScale:P,yScale:R,window:n.getWindow(h.group)})}u.save(),u.scale(r,r),u.beginPath(),u.rect(e.plotBox.left,e.plotBox.top,e.plotBox.width,e.plotBox.height),u.clip();for(let h=0;h<M.length;h++){const I=M[h];I!=null&&(e.focusedSeries!=null&&h!==e.focusedSeries?(u.globalAlpha=e.focusAlpha,s.drawSeries(I,e.plotBox,1),u.globalAlpha=1):s.drawSeries(I,e.plotBox,1))}const L=new Map;for(const h of o)L.set(`${h.group}-${h.index}`,h);for(const h of e.bandConfigs){const I=t.getGroupXScaleKey(h.group),P=I!=null?t.getScale(I):void 0,R=L.get(`${h.group}-${h.series[0]}`),T=L.get(`${h.group}-${h.series[1]}`);if(P==null||R==null||T==null)continue;const v=t.getScale(R.yScale);if(v==null)continue;const[S,b]=n.getWindow(h.group),C=h.series[0],D=h.series[1];let p=s.getCachedBandPath(h.group,C,D,S,b);p==null&&(p=Rn(n.getXValues(h.group),n.getYValues(h.group,C),n.getYValues(h.group,D),P,v,e.plotBox,r,S,b)??void 0,p!=null&&s.setCachedBandPath(h.group,C,D,S,b,p)),p!=null&&Dn(u,h,p)}for(const h of M){const I=h.config;if(I.show===!1)continue;const P=I.points,R=I.width??1,T=(P==null?void 0:P.size)??3+R*2,v=(P==null?void 0:P.space)??T*2,[S,b]=h.window;Ln(P==null?void 0:P.show,I.group,I.index,S,b,e.plotBox.width,v)&&Pn(u,h.dataX,h.dataY,h.xScale,h.yScale,e.plotBox,r,S,b,P,T,(typeof I.stroke=="string"?I.stroke:null)??"#000")}if(u.restore(),e.drawHooks.size>0){u.save(),u.beginPath(),u.rect(e.plotBox.left*r,e.plotBox.top*r,e.plotBox.width*r,e.plotBox.height*r),u.clip(),u.scale(r,r);const h=Fe(u,e.plotBox,r,g);for(const I of e.drawHooks)try{I(h)}catch(P){console.warn("[uPlot+] draw hook error:",P)}u.restore()}if(e.cursorManager.state.left>=0&&(s.saveSnapshot(u,i*r,l*r),e.cursorManager.update(e.cursorManager.state.left,e.cursorManager.state.top,e.plotBox,n.data,o,g,h=>n.getWindow(h),h=>t.getGroupXScaleKey(h))),lt(u,e.cursorManager.state,e.plotBox,r,n.data,o,g,h=>t.getGroupXScaleKey(h)),it(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const h=Fe(u,e.plotBox,r,g);for(const I of e.cursorDrawHooks)try{I(h,e.cursorManager.state)}catch(P){console.warn("[uPlot+] draw hook error:",P)}u.restore()}for(const h of e.listeners)h();if(e._prevScaleRanges.size>0&&e.eventCallbacks.onScaleChange!=null)for(const h of t.getAllScales()){if(h.min==null||h.max==null)continue;const I=e._prevScaleRanges.get(h.id);if(I==null||I.min!==h.min||I.max!==h.max)try{e.eventCallbacks.onScaleChange(h.id,h.min,h.max)}catch(P){console.warn("[uPlot+] event callback error:",P)}}e._prevScaleRanges.clear();for(const h of t.getAllScales())h.min!=null&&h.max!=null&&e._prevScaleRanges.set(h.id,{min:h.min,max:h.max})}};return e.scheduler.onRedraw(()=>e.redraw()),e}function Fn(e){const{axisConfigs:t,axisStates:n}=e,s=new Map;for(const o of n)s.set(`${o.config.scale}:${o.config.side}`,o);e.axisStates=t.map(o=>{const i=`${o.scale}:${o.side}`,l=s.get(i);return l!=null?(l.config=o,l):rn(o)})}function Hn(){const e=z.useRef(null);return e.current===null&&(e.current=zn()),e.current}const bt=z.createContext(null);function ee(){const e=z.useContext(bt);if(!e)throw new Error("useChart must be used within a <Chart> component");return e}function En(e,t){z.useEffect(()=>{if(t!=null)return Gn(e,t)},[e,t])}function Gn(e,t){let n=null;const s={show:!1,left:0,top:0,width:0,height:0};let o=null,i=null,l=!1;function r(p){const m=t.getBoundingClientRect(),w=e.plotBox,y=p.clientX-m.left-w.left,k=p.clientY-m.top-w.top;return{cx:y,cy:k}}function a(p,m){const w=e.plotBox;return p>=0&&p<=w.width&&m>=0&&m<=w.height}function c(p,m){const w=t.getBoundingClientRect(),y=p-w.left,k=m-w.top,A=e.plotBox;for(const F of e.axisStates){const H=F.config,E=H.side;if(F._size<=0)continue;const W=k>=A.top&&k<=A.top+A.height,j=y>=A.left&&y<=A.left+A.width;if(E===X.Left&&y<A.left&&W||E===X.Right&&y>A.left+A.width&&W||E===X.Top&&k<A.top&&j||E===X.Bottom&&k>A.top+A.height&&j){const q=he(E);return{scaleId:H.scale,ori:q}}}return null}function u(p,m,w){const y=e.cursorManager.state;let k=null;if(y.activeGroup>=0&&y.activeDataIdx>=0){const A=e.dataStore.data[y.activeGroup];if(A!=null){const F=A.x[y.activeDataIdx],H=A.series[y.activeSeriesIdx],E=H!=null?H[y.activeDataIdx]:void 0;if(F!=null&&E!=null){const $=e.plotBox,W=e.scaleManager.getGroupXScaleKey(y.activeGroup),j=W!=null?e.scaleManager.getScale(W):void 0,K=e.seriesConfigs.find(Ye=>Ye.group===y.activeGroup&&Ye.index===y.activeSeriesIdx),q=K!=null?e.scaleManager.getScale(K.yScale):void 0;let de=m,Re=w;(j==null?void 0:j.min)!=null&&j.max!=null&&(de=V(F,j,$.width,$.left)-$.left),(q==null?void 0:q.min)!=null&&q.max!=null&&(Re=V(E,q,$.height,$.top)-$.top);const je=m-de,Xe=w-Re;k={group:y.activeGroup,seriesIdx:y.activeSeriesIdx,dataIdx:y.activeDataIdx,xVal:F,yVal:E,pxX:de,pxY:Re,dist:Math.sqrt(je*je+Xe*Xe)}}}}return{plotX:m,plotY:w,point:k,srcEvent:p}}function d(p){const m=e.plotBox,w=p.left/m.width,y=(p.left+p.width)/m.width,k={};for(const A of e.scaleManager.getAllScales()){if(A.ori!==_.Horizontal||A.min==null||A.max==null)continue;const F=te(m.left+w*m.width,A,m.width,m.left),H=te(m.left+y*m.width,A,m.width,m.left);k[A.id]={min:Math.min(F,H),max:Math.max(F,H)}}return{left:w,right:y,ranges:k}}function f(){const p=e.eventCallbacks.onScaleChange;if(p!=null)for(const m of e.scaleManager.getAllScales()){if(m.min==null||m.max==null)continue;const w=e._prevScaleRanges.get(m.id);(w==null||w.min!==m.min||w.max!==m.max)&&p(m.id,m.min,m.max)}}function g(p,m){if(i!=null){const A=t.getBoundingClientRect(),F=p.clientY-A.top,H=e.plotBox,E=(F-i.startY)/H.height,$=i.startMax-i.startMin,W=e.scaleManager.getScale(i.scaleId);W!=null&&(W.min=i.startMin+E*$,W.max=i.startMax+E*$,W.auto=!1,le(W),e.renderer.clearCache(),e.scheduleRedraw());return}const w=r(p);if(w==null)return;const{cx:y,cy:k}=w;if(!a(y,k)&&n==null){e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),e.scheduleCursorRedraw();return}if(e.cursorManager.update(y,k,e.plotBox,e.dataStore.data,e.seriesConfigs,A=>e.scaleManager.getScale(A),A=>e.dataStore.getWindow(A),A=>e.scaleManager.getGroupXScaleKey(A)),e.focusAlpha<1){const A=e.cursorManager.state;if(A.activeGroup>=0&&A.activeSeriesIdx>=0){const F=e.seriesConfigs.findIndex(H=>H.group===A.activeGroup&&H.index===A.activeSeriesIdx);F>=0&&e.focusedSeries!==F&&(e.focusedSeries=F,e.scheduleRedraw())}}if(m!=null&&e.eventCallbacks.onCursorMove!=null&&a(y,k))try{e.eventCallbacks.onCursorMove(u(m,y,k))}catch(A){console.warn("[uPlot+] event callback error:",A)}if(n!=null){const A=n.x,F=e.plotBox,H=Math.max(0,Math.min(y,F.width));s.show=!0,s.left=Math.min(A,H),s.top=0,s.width=Math.abs(H-A),s.height=F.height,e.selectState=s}n!=null?e.scheduler.mark(Z.Cursor|Z.Select):e.scheduleCursorRedraw()}function x(p){g(p,p)}function M(p){if(p.button!==0)return;const m=c(p.clientX,p.clientY);if(m!=null&&m.ori===_.Vertical){const y=e.scaleManager.getScale(m.scaleId);if(y!=null&&y.min!=null&&y.max!=null){const k=t.getBoundingClientRect();i={scaleId:m.scaleId,startY:p.clientY-k.top,startMin:y.min,startMax:y.max},p.preventDefault();return}}const w=r(p);w!=null&&a(w.cx,w.cy)&&(n={x:w.cx,y:w.cy},l=!1,s.show=!1,s.left=0,s.width=0,e.selectState=s)}function L(p){if(i!=null){f(),i=null;return}if(n!=null){if(s.width>5){l=!0;let m=!0;if(e.eventCallbacks.onSelect!=null){const w=d(s);let y;try{y=e.eventCallbacks.onSelect(w)}catch(k){console.warn("[uPlot+] event callback error:",k)}y===!1&&(m=!1)}m&&(S(s),f())}n=null,s.show=!1,s.left=0,s.width=0,e.selectState=s,e.scheduleRedraw()}}function h(p){L()}function I(p){if(l){l=!1;return}const m=e.eventCallbacks.onClick;if(m==null)return;const w=r(p);if(w!=null&&a(w.cx,w.cy))try{m(u(p,w.cx,w.cy))}catch(y){console.warn("[uPlot+] event callback error:",y)}}function P(p){const m=e.eventCallbacks.onContextMenu;if(m==null)return;const w=r(p);if(w!=null&&a(w.cx,w.cy)){p.preventDefault();try{m(u(p,w.cx,w.cy))}catch(y){console.warn("[uPlot+] event callback error:",y)}}}function R(p){var m,w;e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),n!=null&&(n=null,s.show=!1,s.width=0,e.selectState=s),i!=null&&(i=null),e.scheduleCursorRedraw();try{(w=(m=e.eventCallbacks).onCursorLeave)==null||w.call(m)}catch(y){console.warn("[uPlot+] event callback error:",y)}}function T(p){if(e.eventCallbacks.onDblClick!=null){const m=r(p);if(m!=null&&a(m.cx,m.cy)){let w;try{w=e.eventCallbacks.onDblClick(u(p,m.cx,m.cy))}catch(y){console.warn("[uPlot+] event callback error:",y)}if(w===!1)return}}for(const m of e.scaleConfigs)e.scaleManager.addScale(m);e.renderer.clearCache(),e.scheduleRedraw()}function v(p){if(!e.wheelZoom)return;const m=r(p);if(m==null||!a(m.cx,m.cy))return;p.preventDefault();const w=Math.max(.1,Math.min(10,1-p.deltaY*.001)),y=e.plotBox;for(const k of e.scaleManager.getAllScales()){if(k.ori!==_.Horizontal||k.min==null||k.max==null)continue;const A=te(m.cx+y.left,k,y.width,y.left),F=A-(A-k.min)*w,H=A+(k.max-A)*w;k.min=Math.min(F,H),k.max=Math.max(F,H),k.auto=!1,le(k)}e.renderer.clearCache(),e.scheduleRedraw(),f()}function S(p){const m=e.plotBox,w=p.left/m.width,y=(p.left+p.width)/m.width;for(const k of e.scaleManager.getAllScales()){if(k.ori!==_.Horizontal||k.min==null||k.max==null)continue;const A=te(m.left+w*m.width,k,m.width,m.left),F=te(m.left+y*m.width,k,m.width,m.left);k.min=Math.min(A,F),k.max=Math.max(A,F),k.auto=!1,le(k)}e.renderer.clearCache()}function b(p){if(p.touches.length===2){const y=p.touches[0],k=p.touches[1],A=k.clientX-y.clientX,F=k.clientY-y.clientY;o={dist:Math.sqrt(A*A+F*F),midX:(y.clientX+k.clientX)/2,midY:(y.clientY+k.clientY)/2},n=null;return}const m=p.touches[0];if(m==null)return;const w=r(m);w!=null&&a(w.cx,w.cy)&&(n={x:w.cx,y:w.cy},l=!1)}function C(p){if(p.touches.length===2&&o!=null){p.preventDefault();const w=p.touches[0],y=p.touches[1],k=y.clientX-w.clientX,A=y.clientY-w.clientY,F=Math.sqrt(k*k+A*A),H=F/o.dist,E=t.getBoundingClientRect(),$=e.plotBox,W=o.midX-E.left-$.left;for(const j of e.scaleManager.getAllScales()){if(j.ori!==_.Horizontal||j.min==null||j.max==null)continue;const K=te(W+$.left,j,$.width,$.left),q=K-(K-j.min)/H,de=K+(j.max-K)/H;j.min=Math.min(q,de),j.max=Math.max(q,de),j.auto=!1,le(j)}o.dist=F,e.renderer.clearCache(),e.scheduleRedraw(),f();return}const m=p.touches[0];m!=null&&(g(m,p),n!=null&&p.preventDefault())}function D(p){if(o!=null){o=null;return}p.changedTouches[0]!=null&&L()}return t.addEventListener("mousemove",x),t.addEventListener("mousedown",M),t.addEventListener("mouseup",h),t.addEventListener("click",I),t.addEventListener("contextmenu",P),t.addEventListener("mouseleave",R),t.addEventListener("dblclick",T),t.addEventListener("wheel",v,{passive:!1}),t.addEventListener("touchstart",b,{passive:!0}),t.addEventListener("touchmove",C,{passive:!1}),t.addEventListener("touchend",D),()=>{t.removeEventListener("mousemove",x),t.removeEventListener("mousedown",M),t.removeEventListener("mouseup",h),t.removeEventListener("click",I),t.removeEventListener("contextmenu",P),t.removeEventListener("mouseleave",R),t.removeEventListener("dblclick",T),t.removeEventListener("wheel",v),t.removeEventListener("touchstart",b),t.removeEventListener("touchmove",C),t.removeEventListener("touchend",D)}}const He=new Map;function _n(e){let t=He.get(e);return t==null&&(t=new Vn(e),He.set(e,t)),t}class Vn{constructor(t){this.members=new Set,this.publishing=!1,this.syncedStores=new WeakSet,this.key=t}join(t){this.members.add(t)}leave(t){this.members.delete(t),this.members.size===0&&He.delete(this.key)}pub(t){if(this.publishing)return;if(this.syncedStores.has(t)){this.syncedStores.delete(t);return}this.publishing=!0;const n=t.cursorManager.state,{activeGroup:s,activeDataIdx:o}=n;if(s<0||o<0){for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.hide(),r.scheduleCursorRedraw());this.publishing=!1;return}const l=t.dataStore.getXValues(s)[o];if(l==null){this.publishing=!1;return}for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.syncToValue(l,r),r.scheduleCursorRedraw());this.publishing=!1}}function $n(e,t){z.useEffect(()=>{if(t==null)return;const n=_n(t);n.join(e);let s=-1,o=-1;const i=e.subscribe(()=>{const{activeGroup:l,activeDataIdx:r}=e.cursorManager.state;l===s&&r===o||(s=l,o=r,n.pub(e))});return()=>{i(),n.leave(e)}},[e,t])}function $e({width:e,height:t,data:n,children:s,className:o,pxRatio:i,onDraw:l,onCursorDraw:r,syncKey:a,cursor:c,onClick:u,onContextMenu:d,onDblClick:f,onCursorMove:g,onCursorLeave:x,onScaleChange:M,onSelect:L}){var m;const h=Hn(),[I,P]=z.useState(null),R=i??(typeof window<"u"&&window.devicePixelRatio||1),T=(c==null?void 0:c.wheelZoom)??!1,v=((m=c==null?void 0:c.focus)==null?void 0:m.alpha)??((c==null?void 0:c.focus)!=null?.15:1);z.useEffect(()=>{h.wheelZoom=T,h.focusAlpha=v},[h,T,v]),h.eventCallbacks.onClick=u,h.eventCallbacks.onContextMenu=d,h.eventCallbacks.onDblClick=f,h.eventCallbacks.onCursorMove=g,h.eventCallbacks.onCursorLeave=x,h.eventCallbacks.onScaleChange=M,h.eventCallbacks.onSelect=L,En(h,I),$n(h,a);const S=z.useCallback(w=>{h.canvas=w,w&&h.scheduleRedraw()},[h]),b=z.useCallback(w=>{P(w)},[]);z.useEffect(()=>{h.pxRatio=R,h.setSize(e,t)},[h,e,t,R]),z.useEffect(()=>()=>{h.canvas=null,h.scheduler.cancel(),h.focusedSeries=null},[h]),z.useEffect(()=>{if(I==null||typeof ResizeObserver>"u")return;const w=new ResizeObserver(y=>{const k=y[0];if(k==null)return;const{width:A,height:F}=k.contentRect;A>0&&F>0&&(A!==h.width||F!==h.height)&&h.setSize(Math.round(A),Math.round(F))});return w.observe(I),()=>{w.disconnect()}},[h,I]);const C=z.useRef(n);z.useEffect(()=>{if(n===C.current&&h.dataStore.data.length>0)return;C.current=n,h.dataStore.setData(n),h.renderer.clearCache();const w="x";h.scaleManager.getScale(w)||h.registerScale({id:w,auto:!0});for(let y=0;y<n.length;y++)h.scaleManager.setGroupXScale(y,w);h.scheduleRedraw()},[h,n]);const D=z.useRef(l);D.current=l,z.useEffect(()=>{const w=y=>{var k;(k=D.current)==null||k.call(D,y)};return h.drawHooks.add(w),()=>{h.drawHooks.delete(w)}},[h]);const p=z.useRef(r);return p.current=r,z.useEffect(()=>{const w=(y,k)=>{var A;(A=p.current)==null||A.call(p,y,k)};return h.cursorDrawHooks.add(w),()=>{h.cursorDrawHooks.delete(w)}},[h]),G.jsx(bt.Provider,{value:h,children:G.jsxs("div",{className:o,style:{position:"relative",display:"flex",flexDirection:"column",width:`${e}px`},children:[G.jsx("div",{ref:b,style:{position:"relative",width:`${e}px`,height:`${t}px`,cursor:"crosshair",order:0},children:G.jsx("canvas",{ref:S,style:{position:"absolute",left:0,top:0}})}),s]})})}function rt(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Bn(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const o of s)if(e[o]!==t[o])return!1;return!0}function Be(e,t){if(e===null)return!1;const n=e,s=t,o=Object.keys(n),i=Object.keys(s);if(o.length!==i.length)return!1;for(const l of i){const r=n[l],a=s[l];if(r!==a)if(rt(r)&&rt(a)){if(!Bn(r,a))return!1}else return!1}return!0}function Te(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const o=n.current;return t.registerScale({...o}),t.scheduleRedraw(),()=>{t.unregisterScale(o.id),t.scheduleRedraw()}},[t,e.id]);const s=z.useRef(null);return z.useEffect(()=>{Be(s.current,e)||(s.current=e,t.scaleConfigs=t.scaleConfigs.map(o=>o.id===e.id?{...e}:o),t.scaleManager.addScale({...e}),t.renderer.clearCache(),t.scheduleRedraw())}),null}function We(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const o=n.current;return t.registerSeries({...o,show:o.show??!0}),t.renderer.clearCache(),t.scheduleRedraw(),()=>{t.unregisterSeries(o.group,o.index),t.renderer.clearCache(),t.scheduleRedraw()}},[t,e.group,e.index]);const s=z.useRef(null);return z.useEffect(()=>{Be(s.current,e)||(s.current=e,t.seriesConfigs=t.seriesConfigs.map(o=>o.group===e.group&&o.index===e.index?{...e,show:e.show??!0}:o),t.renderer.invalidateSeries(e.group,e.index),t.scheduleRedraw())}),null}function Wn(e){return{...e,side:e.side??(e.scale==="x"?X.Bottom:X.Left),show:e.show??!0}}function Ie(e){const t=ee(),n=Wn(e),s=z.useRef(n);s.current=n,z.useEffect(()=>{const i=s.current;return t.axisConfigs=t.axisConfigs.filter(l=>!(l.scale===i.scale&&l.side===i.side)),t.axisConfigs.push(i),t.scheduleRedraw(),()=>{t.axisConfigs=t.axisConfigs.filter(l=>!(l.scale===i.scale&&l.side===i.side)),t.scheduleRedraw()}},[t,n.scale,n.side]);const o=z.useRef(null);return z.useEffect(()=>{Be(o.current,e)||(o.current=e,t.axisConfigs=t.axisConfigs.map(i=>i.scale===n.scale&&i.side===n.side?n:i),t.scheduleRedraw())}),null}function jn({series:e,group:t,fill:n,dir:s}){const o=ee(),i=z.useRef(null),l=e[0],r=e[1];return z.useEffect(()=>{const a={series:[l,r],group:t,fill:n,dir:s};return i.current!=null&&(o.bandConfigs=o.bandConfigs.filter(c=>c!==i.current)),i.current=a,o.bandConfigs.push(a),o.scheduleRedraw(),()=>{o.bandConfigs=o.bandConfigs.filter(c=>c!==i.current),i.current=null,o.scheduleRedraw()}},[o,l,r,t,n,s]),null}const Xn={width:12,height:3,borderRadius:1,display:"inline-block"},Yn={fontWeight:600},Un={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},Kn=z.memo(function({group:t,index:n,label:s,color:o,isHidden:i,valueStr:l,store:r}){const a=z.useCallback(()=>{r.toggleSeries(t,n)},[r,t,n]);return G.jsxs("span",{onClick:a,style:{...Un,opacity:i?.4:1},children:[G.jsx("span",{style:{...Xn,backgroundColor:o}}),G.jsx("span",{children:s}),l&&G.jsx("span",{style:Yn,children:l})]})});function Nn({show:e=!0,position:t="bottom",className:n}){const s=ee(),o=z.useRef({activeGroup:-1,activeDataIdx:-1,seriesCount:0,revision:-1}),i=z.useCallback(u=>s.subscribe(u),[s]),l=z.useCallback(()=>{const{activeGroup:u,activeDataIdx:d}=s.cursorManager.state,f=s.seriesConfigs.length,{revision:g}=s,x=o.current;if(x.activeGroup===u&&x.activeDataIdx===d&&x.seriesCount===f&&x.revision===g)return x;const M={activeGroup:u,activeDataIdx:d,seriesCount:f,revision:g};return o.current=M,M},[s]),r=z.useSyncExternalStore(i,l);if(!e)return null;const{activeGroup:a,activeDataIdx:c}=r;return G.jsx("div",{className:n,style:{display:"flex",flexWrap:"wrap",justifyContent:"center",order:t==="top"?-1:1,padding:"4px 0"},children:s.seriesConfigs.map(u=>{const d=typeof u.stroke=="string"?u.stroke:"#000";let f="";if(c>=0&&a>=0){const x=s.dataStore.getYValues(u.group,u.index)[c];x!=null&&(f=typeof x=="number"?x.toPrecision(4):String(x))}return G.jsx(Kn,{group:u.group,index:u.index,label:u.label??`Series ${u.index}`,color:d,isHidden:u.show===!1,valueStr:f,store:s},`${u.group}:${u.index}`)})})}function qn({show:e=!0,className:t,children:n,offset:s={}}){var w,y;const o=ee(),i=z.useRef({left:-10,top:-10,activeGroup:-1,activeDataIdx:-1,revision:-1}),l=z.useRef(null),r=z.useCallback(k=>o.subscribe(k),[o]),a=z.useCallback(()=>{const k=o.cursorManager.state,{revision:A}=o,F=i.current;if(F.left===k.left&&F.top===k.top&&F.activeGroup===k.activeGroup&&F.activeDataIdx===k.activeDataIdx&&F.revision===A)return F;const H={left:k.left,top:k.top,activeGroup:k.activeGroup,activeDataIdx:k.activeDataIdx,revision:A};return i.current=H,H},[o]),c=z.useSyncExternalStore(r,a);if(!e||c.activeDataIdx<0||c.activeGroup<0||c.left<0)return null;const{activeGroup:u,activeDataIdx:d}=c,f=o.plotBox,g=o.dataStore.data[u],x=g!=null?g.x[d]??null:null,M=x!=null?parseFloat(x.toPrecision(6)).toString():"",L=[];for(const k of o.seriesConfigs){if(k.show===!1)continue;const A=o.dataStore.getYValues(k.group,k.index),F=k.group===u?A[d]:null;L.push({label:k.label??`Series ${k.index}`,value:F,color:typeof k.stroke=="string"?k.stroke:"#000",group:k.group,index:k.index})}const h={x,xLabel:M,items:L,left:c.left+f.left,top:c.top+f.top},I=s.x??12,P=s.y??-12,R=((w=l.current)==null?void 0:w.offsetWidth)??0,T=((y=l.current)==null?void 0:y.offsetHeight)??0,v=c.left+f.left,S=c.top+f.top,b=f.left+f.width,C=f.top+f.height,D=Math.max(f.left,Math.min(v+I,b-R)),p=Math.max(f.top,Math.min(S+P,C-T)),m={position:"absolute",left:D,top:p,pointerEvents:"none",zIndex:100};return n?G.jsx("div",{ref:l,className:t,style:m,children:n(h)}):G.jsxs("div",{ref:l,className:t,style:{...m,background:"rgba(0,0,0,0.85)",color:"#fff",padding:"6px 10px",borderRadius:4,fontSize:12,fontFamily:"sans-serif",whiteSpace:"nowrap",lineHeight:1.5},children:[G.jsx("div",{style:{fontWeight:600,marginBottom:2},children:M}),L.map(k=>G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[G.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:k.color,display:"inline-block"}}),G.jsxs("span",{children:[k.label,":"]}),G.jsx("span",{style:{fontWeight:600},children:k.value!=null?k.value.toPrecision(4):"—"})]},`${k.group}:${k.index}`))]})}function On({width:e,height:t,data:n,onRangeChange:s,initialRange:o,className:i,colors:l,grips:r=!1}){const a=z.useRef(null),[c,u]=z.useState(()=>{if(o!=null&&n.length>0){const T=n[0];if(T!=null&&T.x.length>1){const v=T.x[0],b=T.x[T.x.length-1]-v;if(b>0)return[Math.max(0,(o[0]-v)/b),Math.min(1,(o[1]-v)/b)]}}return[.25,.75]}),d=z.useRef(null);z.useEffect(()=>{if(s==null||n.length===0)return;const T=n[0];if(T==null||T.x.length<2)return;const v=T.x[0],b=T.x[T.x.length-1]-v,C=v+c[0]*b,D=v+c[1]*b,p=d.current,m=Math.max(1e-10,Math.abs(D-C)*1e-12);p!=null&&Math.abs(p[0]-C)<m&&Math.abs(p[1]-D)<m||(d.current=[C,D],s(C,D))},[c,n,s]);const f=z.useRef(null),g=z.useCallback(T=>{const v=a.current;if(v==null)return 0;const S=v.getBoundingClientRect();return Math.max(0,Math.min(1,(T-S.left)/S.width))},[]),x=z.useCallback(T=>{const v=a.current;if(v==null)return;const S=g(T.clientX),b=v.getBoundingClientRect().width,C=b>0?8/b:0;let D;if(Math.abs(S-c[0])<C)D="left";else if(Math.abs(S-c[1])<C)D="right";else if(S>=c[0]&&S<=c[1])D="move";else{const p=c[1]-c[0],m=p/2,w=Math.max(0,Math.min(1-p,S-m));u([w,w+p]),D="move"}f.current={mode:D,startX:T.clientX,startFrac:[...c]},v.setPointerCapture(T.pointerId),T.preventDefault()},[c,g]),M=z.useCallback(T=>{const v=f.current;if(v==null)return;const S=g(T.clientX),b=g(v.startX),C=S-b;if(v.mode==="move"){const D=v.startFrac[1]-v.startFrac[0];let p=v.startFrac[0]+C;p=Math.max(0,Math.min(1-D,p)),u([p,p+D])}else if(v.mode==="left"){const D=Math.max(0,Math.min(v.startFrac[1]-.01,v.startFrac[0]+C));u([D,v.startFrac[1]])}else{const D=Math.min(1,Math.max(v.startFrac[0]+.01,v.startFrac[1]+C));u([v.startFrac[0],D])}},[g]),L=z.useCallback(T=>{f.current=null;const v=a.current;v!=null&&v.releasePointerCapture(T.pointerId)},[]),h=`${c[0]*100}%`,I=`${(c[1]-c[0])*100}%`,P=n[0],R=P!=null?P.series.length:0;return G.jsxs("div",{className:i,style:{position:"relative",width:e,height:t},children:[G.jsxs($e,{width:e,height:t,data:n,children:[G.jsx(Te,{id:"x"}),G.jsx(Te,{id:"y"}),G.jsx(Ie,{scale:"x",show:!1}),G.jsx(Ie,{scale:"y",show:!1}),Array.from({length:R},(T,v)=>G.jsx(We,{group:0,index:v,yScale:"y",stroke:l!=null&&l[v]!=null?l[v]:`hsl(${v*137}, 60%, 50%)`,width:1},v))]}),G.jsxs("div",{ref:a,onPointerDown:x,onPointerMove:M,onPointerUp:L,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[G.jsx("div",{style:{position:"absolute",top:0,left:0,width:h,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),G.jsx("div",{style:{position:"absolute",top:0,left:`${c[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),G.jsx("div",{style:{position:"absolute",top:0,left:h,width:I,height:"100%",borderLeft:"2px solid rgba(0,100,255,0.8)",borderRight:"2px solid rgba(0,100,255,0.8)",boxSizing:"border-box",cursor:"grab",pointerEvents:"none"},children:r&&G.jsxs(G.Fragment,{children:[G.jsx("div",{style:{position:"absolute",left:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}}),G.jsx("div",{style:{position:"absolute",right:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}})]})})]})]})}function ve(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const s=o=>n.current(o);return t.drawHooks.add(s),()=>{t.drawHooks.delete(s)}},[t])}function Zn(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const s=(o,i)=>n.current(o,i);return t.cursorDrawHooks.add(s),()=>{t.cursorDrawHooks.delete(s)}},[t])}function Jn({lanes:e,laneHeight:t=24,gap:n=2,scaleId:s="x"}){const o=ee();return ve(({ctx:i,plotBox:l,pxRatio:r})=>{const a=o.scaleManager.getScale(s);if(a==null||a.min==null||a.max==null)return;i.save(),i.beginPath(),i.rect(l.left*r,l.top*r,l.width*r,l.height*r),i.clip();const c=(t+n)*r,u=t*r,d=l.top*r;for(let f=0;f<e.length;f++){const g=e[f];if(g==null)continue;const x=d+f*c;i.fillStyle="#666",i.font=`${11*r}px sans-serif`,i.textAlign="right",i.textBaseline="middle",i.fillText(g.label,(l.left-6)*r,x+u/2);for(const M of g.segments){const L=V(M.start,a,l.width,l.left)*r,I=V(M.end,a,l.width,l.left)*r-L;I<=0||(i.fillStyle=M.color??"#4dabf7",i.fillRect(L,x,I,u),M.label!=null&&I>20*r&&(i.fillStyle="#fff",i.font=`${10*r}px sans-serif`,i.textAlign="center",i.textBaseline="middle",i.fillText(M.label,L+I/2,x+u/2,I-4*r)))}}i.restore()}),null}function Qn({data:e,width:t=150,height:n=30,stroke:s="#03a9f4",fill:o,lineWidth:i=1,paths:l,fillTo:r,className:a}){return G.jsx("div",{style:{pointerEvents:"none"},className:a,children:G.jsxs($e,{width:t,height:n,data:e,children:[G.jsx(Te,{id:"x"}),G.jsx(Te,{id:"y"}),G.jsx(Ie,{scale:"x",show:!1}),G.jsx(Ie,{scale:"y",show:!1}),G.jsx(We,{group:0,index:0,yScale:"y",stroke:s,fill:o,width:i,paths:l,fillTo:r})]})})}function St(e,t,n,s={}){const{ctx:o,plotBox:i}=e,l=V(n,t,i.height,i.top);o.beginPath(),o.moveTo(i.left,l),o.lineTo(i.left+i.width,l),o.strokeStyle=s.stroke??"red",o.lineWidth=s.width??1,s.dash&&o.setLineDash(s.dash),o.stroke(),s.dash&&o.setLineDash([])}function yt(e,t,n,s={}){const{ctx:o,plotBox:i}=e,l=V(n,t,i.width,i.left);o.beginPath(),o.moveTo(l,i.top),o.lineTo(l,i.top+i.height),o.strokeStyle=s.stroke??"red",o.lineWidth=s.width??1,s.dash&&o.setLineDash(s.dash),o.stroke(),s.dash&&o.setLineDash([])}function es(e,t,n,s,o,i,l={}){const{ctx:r,plotBox:a}=e,c=V(s,t,a.width,a.left),u=V(o,n,a.height,a.top);r.font=l.font??"12px sans-serif",r.fillStyle=l.fill??"#000",r.textBaseline="bottom",r.fillText(i,c,u-4)}function kt(e,t,n,s,o={}){const{ctx:i,plotBox:l}=e,r=V(s,t,l.height,l.top),a=V(n,t,l.height,l.top);i.fillStyle=o.fill??"rgba(255,0,0,0.1)",i.fillRect(l.left,Math.min(r,a),l.width,Math.abs(a-r)),o.stroke&&(i.strokeStyle=o.stroke,i.lineWidth=o.width??1,o.dash&&i.setLineDash(o.dash),i.strokeRect(l.left,Math.min(r,a),l.width,Math.abs(a-r)),o.dash&&i.setLineDash([]))}function ts(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=s.yScale??"y",i=n.getScale(o);if(i!=null&&(St(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const l=n.valToY(s.value,o);if(l==null)return;const{ctx:r,plotBox:a}=n;r.font=s.labelFont??"11px sans-serif",r.fillStyle=s.stroke??"red",r.textAlign="left",r.textBaseline="bottom",r.fillText(s.label,a.left+4,l-4)}}),null}function ns(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=s.xScale??"x",i=n.getScale(o);if(i!=null&&(yt(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const l=n.valToX(s.value,o);if(l==null)return;const{ctx:r,plotBox:a}=n;r.font=s.labelFont??"11px sans-serif",r.fillStyle=s.stroke??"red",r.textAlign="center",r.textBaseline="bottom",r.fillText(s.label,l,a.top-4)}}),null}function ss(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=n.getScale(s.yScale??"y");o!=null&&kt(n,o,s.yMin,s.yMax,{fill:s.fill,stroke:s.stroke,width:s.strokeWidth,dash:s.dash})}),null}function os(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=n.valToX(s.x,s.xScale??"x"),i=n.valToY(s.y,s.yScale??"y");if(o==null||i==null)return;const{ctx:l}=n;l.font=s.font??"12px sans-serif",l.fillStyle=s.fill??"#000",l.textAlign=s.align??"left",l.textBaseline=s.baseline??"bottom",l.fillText(s.text,o,i-4)}),null}function ls(e,t){const{window:n,batchSize:s=1}=t,o=t.autoStart??!0,[i,l]=z.useState(e),[r,a]=z.useState(!1),[c,u]=z.useState(0),d=z.useRef(0),f=z.useRef(0),g=z.useRef(0),x=z.useRef(new Map),M=z.useRef(0),L=z.useRef(n);L.current=n;const h=z.useCallback((T,v,...S)=>{let b=x.current.get(T);b==null&&(b={x:[],series:S.map(()=>[])},x.current.set(T,b)),b.x.push(...v);for(let C=0;C<S.length;C++){let D=b.series[C];D==null&&(D=[],b.series[C]=D),D.push(...S[C]??[])}M.current===0&&(M.current=requestAnimationFrame(()=>{M.current=0;const C=x.current;x.current=new Map;const D=L.current;l(p=>{const m=p.slice();for(const[w,{x:y,series:k}]of C){const A=m[w];if(A==null)continue;const F=A.x,H=Math.max(0,F.length+y.length-D),E=H>0?F.slice(H).concat(y):F.concat(y),$=A.series.map((W,j)=>{const K=W,q=k[j]??[];return H>0?K.slice(H).concat(q):K.concat(q)});m[w]={x:E,series:$}}return m})}))},[]),I=z.useCallback((T,...v)=>{h(0,T,...v)},[h]),P=z.useCallback(()=>{a(!0)},[]),R=z.useCallback(()=>{a(!1)},[]);return z.useEffect(()=>{if(!r){d.current!==0&&(cancelAnimationFrame(d.current),d.current=0);return}g.current=performance.now(),f.current=0;const T=v=>{f.current++;const S=v-g.current;S>=1e3&&(u(Math.round(f.current*1e3/S)),f.current=0,g.current=v),d.current=requestAnimationFrame(T)};return d.current=requestAnimationFrame(T),()=>{d.current!==0&&(cancelAnimationFrame(d.current),d.current=0)}},[r]),z.useEffect(()=>()=>{M.current!==0&&cancelAnimationFrame(M.current)},[]),z.useEffect(()=>{o&&a(!0)},[o]),{data:i,push:I,pushGroup:h,start:P,stop:R,running:r,fps:c}}function is(e){return(t,n,s,o,i,l,r,a,c,u,d,f,g)=>{const x=(g==null?void 0:g.align)??e??1,M=(g==null?void 0:g.spanGaps)??!1;if([c,u]=Ae(n,c,u),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const L=C=>f(V(C,s,i,r)),h=C=>f(V(C,o,l,a)),I=s.ori===_.Horizontal?Pe:Le,P={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},R=P.stroke;let T=!1;const v=d===Y.Forward?c:u;let S=h(n[v]),b=L(t[v]);I(R,b,S);for(let C=v;C>=c&&C<=u;C+=d){const D=n[C];if(D==null){D===null&&!M&&(T=!0);continue}const p=L(t[C]),m=h(D);if(x===1)I(R,p,S);else if(x===-1)I(R,b,m);else{const w=f((b+p)/2);I(R,w,S),I(R,w,m)}I(R,p,m),S=m,b=p}{const C=P.fill=new Path2D(R),D=(g==null?void 0:g.fillTo)??o.min??0,p=h(D);let m=r,w=r+i;d===Y.Backward&&([w,m]=[m,w]),I(C,w,p),I(C,m,p)}if(T){const C=_e(t,n,c,u,d,L);P.gaps=C,P.clip=Ve(C,s.ori,r,a,i,l)}return P}}function rs(){return(e,t,n,s,o,i,l,r,a,c,u,d,f)=>{const g=(f==null?void 0:f.barWidth)??.6,x=(f==null?void 0:f.barGap)??0,M=(f==null?void 0:f.barRadius)??0,L=(f==null?void 0:f.barGroupIdx)??0,h=(f==null?void 0:f.barGroupCount)??1,I=w=>d(V(w,n,o,l)),P=w=>d(V(w,s,i,r));let R=o;if(c>a){let w=1/0,y=-1;for(let k=a;k<=c;k++)if(t[k]!=null){if(y>=0){const A=e[k],F=e[y],H=Math.abs(I(A)-I(F));H<w&&(w=H)}y=k}w<1/0&&(R=w)}const T=R*(1-g),v=Math.max(0,T+x),S=Math.max(1,d(R-v)),b=h>1?Math.max(1,d(S/Math.max(1,h))):S,C=(f==null?void 0:f.fillTo)??s.min??0,D=P(C),p=new Path2D,m=n.ori===_.Horizontal;for(let w=u===Y.Forward?a:c;w>=a&&w<=c;w+=u){const y=t[w];if(y==null)continue;const k=I(e[w]),A=P(y),F=h>1?(L-(h-1)/2)*b:0,H=d(k-b/2+F),E=Math.min(A,D),W=Math.max(A,D)-E;if(W!==0)if(M>0){const j=Math.min(M*b,W/2);as(p,m,H,E,b,W,j,y<C)}else m?p.rect(H,E,b,W):p.rect(E,H,W,b)}return{stroke:p,fill:p,clip:null,band:null,gaps:null}}}function as(e,t,n,s,o,i,l,r){l=Math.min(l,o/2,i/2),t?r?(e.moveTo(n,s),e.lineTo(n+o,s),e.lineTo(n+o,s+i-l),e.arc(n+o-l,s+i-l,l,0,Math.PI/2),e.lineTo(n+l,s+i),e.arc(n+l,s+i-l,l,Math.PI/2,Math.PI),e.closePath()):(e.moveTo(n,s+i),e.lineTo(n,s+l),e.arc(n+l,s+l,l,Math.PI,Math.PI*1.5),e.lineTo(n+o-l,s),e.arc(n+o-l,s+l,l,Math.PI*1.5,0),e.lineTo(n+o,s+i),e.closePath()):r?(e.moveTo(s,n),e.lineTo(s,n+o),e.lineTo(s+i-l,n+o),e.arc(s+i-l,n+o-l,l,Math.PI/2,0,!0),e.lineTo(s+i,n+l),e.arc(s+i-l,n+l,l,0,-Math.PI/2,!0),e.closePath()):(e.moveTo(s+i,n),e.lineTo(s+l,n),e.arc(s+l,n+l,l,-Math.PI/2,Math.PI,!0),e.lineTo(s,n+o-l),e.arc(s+l,n+o-l,l,Math.PI,Math.PI/2,!0),e.lineTo(s+i,n+o),e.closePath())}function Ct(e){return(t,n,s,o,i,l,r,a,c,u,d,f,g)=>{const x=(g==null?void 0:g.spanGaps)??!1;if([c,u]=Ae(n,c,u),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const M=b=>f(V(b,s,i,r)),L=b=>f(V(b,o,l,a)),h=s.ori===_.Horizontal?Pe:Le,I=[],P=[];let R=!1;for(let b=d===Y.Forward?c:u;b>=c&&b<=u;b+=d){const C=n[b];C!=null?(I.push(M(t[b])),P.push(L(C))):C===null&&!x&&(R=!0)}const T=s.ori===_.Horizontal,v=e(I,P,T,f),S={stroke:v??new Path2D,fill:null,clip:null,band:null,gaps:null};if(v!=null){const b=S.fill=new Path2D(v),C=(g==null?void 0:g.fillTo)??o.min??0,D=L(C);let p=r,m=r+i;d===Y.Backward&&([m,p]=[p,m]),h(b,m,D),h(b,p,D)}if(R){const b=_e(t,n,c,u,d,M);S.gaps=b,S.clip=Ve(b,s.ori,r,a,i,l)}return S}}function cs(){return Ct(us)}const us=(e,t,n,s)=>{const o=e.length;if(o<2)return null;const i=new Path2D,l=e[0]??0,r=t[0]??0;if(n?i.moveTo(l,r):i.moveTo(r,l),o===2){const f=e[1]??0,g=t[1]??0;return n?i.lineTo(f,g):i.lineTo(g,f),i}const a=new Array(o),c=new Array(o-1),u=new Array(o-1),d=new Array(o-1);for(let f=0;f<o-1;f++)u[f]=(t[f+1]??0)-(t[f]??0),d[f]=(e[f+1]??0)-(e[f]??0),c[f]=d[f]!==0?(u[f]??0)/(d[f]??1):0;a[0]=c[0]??0;for(let f=1;f<o-1;f++){const g=c[f]??0,x=c[f-1]??0;if(g===0||x===0||x>0!=g>0)a[f]=0;else{const M=d[f]??1,L=d[f-1]??1;a[f]=3*(L+M)/((2*M+L)/x+(M+2*L)/g),isFinite(a[f]??0)||(a[f]=0)}}a[o-1]=c[o-2]??0;for(let f=0;f<o-1;f++){const g=d[f]??1,x=e[f]??0,M=t[f]??0,L=e[f+1]??0,h=t[f+1]??0,I=a[f]??0,P=a[f+1]??0,R=x+g/3,T=M+I*g/3,v=L-g/3,S=h-P*g/3;n?i.bezierCurveTo(R,T,v,S,L,h):i.bezierCurveTo(T,R,S,v,h,L)}return i};function fs(){return Ct(hs)}const hs=(e,t,n,s)=>{const o=e.length;if(o<2)return null;const i=new Path2D,l=s(e[0]??0),r=s(t[0]??0);if(n?i.moveTo(l,r):i.moveTo(r,l),o===2){const a=s(e[1]??0),c=s(t[1]??0);return n?i.lineTo(a,c):i.lineTo(c,a),i}for(let a=0;a<o-1;a++){const c=a===0?0:a-1,u=e[c]??0,d=t[c]??0,f=e[a]??0,g=t[a]??0,x=e[a+1]??0,M=t[a+1]??0,L=a+2<o?e[a+2]??0:x,h=a+2<o?t[a+2]??0:M,I=Math.hypot(u-f,d-g),P=Math.hypot(f-x,g-M),R=Math.hypot(x-L,M-h),T=Math.sqrt(R),v=R,S=Math.sqrt(P),b=P,C=Math.sqrt(I),D=I,p=2*D+3*C*S+b,m=2*v+3*T*S+b,w=3*C*(C+S),y=3*T*(T+S);let k,A,F,H;if(w>0){const E=1/w;k=(-b*u+p*f+D*x)*E,A=(-b*d+p*g+D*M)*E}else k=f,A=g;if(y>0){const E=1/y;F=(v*f+m*x-b*L)*E,H=(v*g+m*M-b*h)*E}else F=x,H=M;n?i.bezierCurveTo(k,A,F,H,x,M):i.bezierCurveTo(A,k,H,F,M,x)}return i};function ds(e=4){return(t,n,s,o,i,l,r,a,c,u,d,f,g)=>{const x=P=>f(V(P,s,i,r)),M=P=>f(V(P,o,l,a)),L=e/2,h=new Path2D,I=s.ori===_.Horizontal;for(let P=d===Y.Forward?c:u;P>=c&&P<=u;P+=d){const R=n[P];if(R==null)continue;const T=x(t[P]),v=M(R);I?(h.moveTo(T+L,v),h.arc(T,v,L,0,Math.PI*2)):(h.moveTo(v+L,T),h.arc(v,T,L,0,Math.PI*2))}return{stroke:h,fill:h,clip:null,band:null,gaps:null}}}function gs(e){return({ctx:t,plotBox:n,pxRatio:s})=>{const{xValues:o,open:i,high:l,low:r,close:a,xScale:c,yScale:u,upColor:d="#26a69a",downColor:f="#ef5350",bodyWidth:g=.6,wickWidth:x=1}=e;if(c.min==null||c.max==null||u.min==null||u.max==null)return;const M=o.length;if(M===0)return;const h=Math.max(2,n.width/M*g)*s/2;t.save();for(let I=0;I<M;I++){const P=o[I],R=i[I],T=l[I],v=r[I],S=a[I];if(P==null||R==null||T==null||v==null||S==null)continue;const b=V(P,c,n.width,n.left)*s,C=V(R,u,n.height,n.top)*s,D=V(T,u,n.height,n.top)*s,p=V(v,u,n.height,n.top)*s,m=V(S,u,n.height,n.top)*s,y=S>=R?d:f;t.strokeStyle=y,t.lineWidth=x*s,t.beginPath(),t.moveTo(b,D),t.lineTo(b,p),t.stroke();const k=Math.min(C,m),A=Math.abs(m-C);t.fillStyle=y,t.fillRect(b-h,k,h*2,Math.max(A,1*s))}t.restore()}}function ps(e,t,n=0){const s=t??e.series.map((c,u)=>u),o=e.x.length,i=[],l=new Float64Array(o);for(let c=0;c<s.length;c++){const u=s[c];if(u==null)continue;const d=e.series[u];if(d==null)continue;const f=new Array(o);for(let g=0;g<o;g++){const x=d[g];x!=null?(l[g]=l[g]+x,f[g]=l[g]):f[g]=null}i.push(f)}const r=[];for(let c=0;c<e.series.length;c++){const u=s.indexOf(c),d=u>=0?i[u]:void 0;d!=null?r.push(d):r.push(e.series[c]??[])}const a=[];for(let c=s.length-1;c>0;c--){const u=s[c],d=s[c-1];u!=null&&d!=null&&a.push({group:n,series:[u,d]})}return{group:{x:e.x,series:r},bands:a}}function ms(e){const t=new Set;for(const[i]of e)for(let l=0;l<i.length;l++){const r=i[l];r!=null&&t.add(r)}const n=Float64Array.from([...t].sort((i,l)=>i-l)),s=new Map;for(let i=0;i<n.length;i++){const l=n[i];l!=null&&s.set(l,i)}const o=[];for(const[i,l]of e){const r=new Array(n.length).fill(null);for(let a=0;a<i.length;a++){const c=i[a];if(c==null)continue;const u=s.get(c);u!=null&&(r[u]=l[a]??null)}o.push(r)}return[{x:n,series:o}]}function ws(e){const t=(e==null?void 0:e.decimals)??1;return n=>n.map(s=>{const o=Math.abs(s);return o>=1e9?(s/1e9).toFixed(t)+"B":o>=1e6?(s/1e6).toFixed(t)+"M":o>=1e3?(s/1e3).toFixed(t)+"K":s.toFixed(o>=1?0:t)})}function xs(e,t=0){return n=>n.map(s=>s.toFixed(t)+e)}function vs(e){const t=(e==null?void 0:e.utc)??!1;return n=>n.map(s=>t?Q(s,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):Q(s,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function Ms(e){const t=e!=null&&e.utc?"UTC":void 0,n=(e==null?void 0:e.format)??"short";return s=>s.map(o=>Q(o,{month:n},t))}function bs(e){const{tz:t,...n}=e??{};return s=>s.map(o=>Q(o,n,t))}function Ss(e,t=0){return n=>n.map(s=>{const o=Math.round(s)-t;return e[o]??String(s)})}function Tt(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(e);if(t)return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)];const n=/^#([0-9a-f])([0-9a-f])([0-9a-f])/i.exec(e);if(n)return[parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];const s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i.exec(e);return s?[Number(s[1]),Number(s[2]),Number(s[3])]:null}function ys(e,t=.8,n=0){const s=Tt(e);if(s==null)return{type:"linear",stops:[[0,e],[1,e]]};const[o,i,l]=s;return{type:"linear",stops:[[0,`rgba(${o},${i},${l},${t})`],[1,`rgba(${o},${i},${l},${n})`]]}}function ks(e,t){const n=Tt(e);if(n==null)return e;const[s,o,i]=n;return`rgba(${s},${o},${i},${t})`}function Cs(e,t=65,n=50){const s=[];for(let i=0;i<e;i++){const l=i*137.508%360;s.push(`hsl(${l.toFixed(1)},${t}%,${n}%)`)}return s}exports.AnnotationLabel=os;exports.Axis=Ie;exports.Band=jn;exports.Chart=$e;exports.Direction=Y;exports.Distribution=U;exports.HLine=ts;exports.Legend=Nn;exports.Orientation=_;exports.Region=ss;exports.Scale=Te;exports.Series=We;exports.Side=X;exports.SortOrder=me;exports.Sparkline=Qn;exports.Timeline=Jn;exports.Tooltip=qn;exports.VLine=ns;exports.ZoomRanger=On;exports.alignData=ms;exports.bars=rs;exports.catmullRom=fs;exports.drawCandlesticks=gs;exports.drawHLine=St;exports.drawLabel=es;exports.drawRegion=kt;exports.drawVLine=yt;exports.fadeGradient=ys;exports.fmtCompact=ws;exports.fmtDateStr=bs;exports.fmtHourMin=vs;exports.fmtLabels=Ss;exports.fmtMonthName=Ms;exports.fmtSuffix=xs;exports.linear=vt;exports.monotoneCubic=cs;exports.palette=Cs;exports.points=ds;exports.posToVal=te;exports.sideOrientation=he;exports.stackGroup=ps;exports.stepped=is;exports.useChart=ee;exports.useCursorDrawHook=Zn;exports.useDrawHook=ve;exports.useStreamingData=ls;exports.valToPos=V;exports.withAlpha=ks;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("react/jsx-runtime"),z=require("react");var X=(e=>(e[e.Top=0]="Top",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left",e))(X||{}),_=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e))(_||{}),Y=(e=>(e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward",e))(Y||{}),U=(e=>(e[e.Linear=1]="Linear",e[e.Ordinal=2]="Ordinal",e[e.Log=3]="Log",e[e.Asinh=4]="Asinh",e))(U||{}),me=(e=>(e[e.Ascending=1]="Ascending",e[e.Descending=-1]="Descending",e[e.Unsorted=0]="Unsorted",e))(me||{});function he(e){return e%2}var Z=(e=>(e[e.None=0]="None",e[e.Scales=1]="Scales",e[e.Axes=2]="Axes",e[e.Paths=4]="Paths",e[e.Cursor=8]="Cursor",e[e.Select=16]="Select",e[e.Size=32]="Size",e[e.Full=63]="Full",e))(Z||{});const O=Math,De=O.PI,fe=O.abs,ne=O.floor,B=O.round,ye=O.ceil,Ue=O.min,be=O.max,pe=O.pow,Ke=O.sign,J=O.log10,xe=O.log2,It=(e,t=1)=>O.sinh(e)*t,Ee=(e,t=1)=>O.asinh(e/t),N=1/0,at=Number.isInteger;function ze(e,t){return e[t]??0}function ie(e,t,n=0,s=t.length-1){let o;const i=s<=2147483647;for(;s-n>1;)o=i?n+s>>1:ne((n+s)/2),ze(t,o)<e?n=o:s=o;return e-ze(t,n)<=ze(t,s)-e?n:s}const ct=e=>e!=null,ut=e=>e!=null&&e>0;function ft(e){return(t,n,s)=>{let o=-1,i=-1;for(let l=n;l<=s;l++)if(e(t[l])){o=l;break}for(let l=s;l>=n;l--)if(e(t[l])){i=l;break}return[o,i]}}const Ae=ft(ct),ht=ft(ut);function At(e,t,n,s=me.Unsorted,o=!1){const i=o?ht:Ae,l=o?ut:ct,[r,a]=i(e,t,n);let c=e[r]??N,u=e[r]??-N;if(r>-1)if(s===me.Ascending)c=e[r]??N,u=e[a]??-N;else if(s===me.Descending)c=e[a]??N,u=e[r]??-N;else for(let d=r;d<=a;d++){const f=e[d];f!=null&&l(f)&&(f<c?c=f:f>u&&(u=f))}return[c,u]}function re(e,t=0){if(at(e))return e;const n=10**t,s=e*n*(1+Number.EPSILON);return B(s)/n}const we=new Map;function Pt(e){return(String(e).split(".")[1]??"").length}const Lt=/\.\d*?(?=9{6,}|0{6,})/gm;function ke(e){if(at(e)||we.has(e))return e;const t=`${e}`,n=t.match(Lt);if(n==null)return e;const s=n[0].length-1;if(t.indexOf("e-")!==-1){const o=t.split("e"),i=o[0]??"0",l=o[1]??"0";return+`${ke(+i)}e${l}`}return re(e,s)}function Ge(e,t,n=!0){return n?ke(ye(ke(e/t))*t):ye(e/t)*t}function dt(e,t,n=!0){return n?ke(ne(ke(e/t))*t):ne(e/t)*t}function gt(e,t,n,s){const o=[],i=s.map(Pt);for(let l=t;l<n;l++){const r=fe(l);for(let a=0;a<s.length;a++){const c=s[a]??0,u=i[a]??0,d=+`${c}e${l}`,f=(l>=0?0:r)+(l>=u?0:u),g=d;o.push(g),we.set(g,f)}}return o}const Rt=new Intl.NumberFormat,pt=e=>Rt.format(e),Dt=.1,se={mode:3,pad:Dt,soft:null},Se={pad:0,soft:null,mode:0},zt={min:Se,max:Se};function Me(e,t,n,s){let o;typeof n=="number"?(Se.pad=n,Se.soft=null,Se.mode=0,o=zt):o=n;const i=o.min,l=o.max,r=i.pad,a=l.pad,c=i.hard??-N,u=l.hard??N,d=i.soft??N,f=l.soft??-N,g=i.mode,x=l.mode;let M=t-e;const L=J(M),h=be(fe(e),fe(t)),I=J(h),P=fe(I-L);(M<1e-24||P>10)&&(M=0,(e===0||t===0)&&(M=1e-24));const R=M||h||1e3,T=J(R),v=pe(10,ne(T)),S=R*(M===0?e===0?.1:1:r),b=re(dt(e-S,v/10),24),C=e>=d&&(g===1||g===3&&b<=d||g===2&&b>=d)?d:N,D=be(c,b<C&&e>=C?C:Ue(C,b)),p=R*(M===0?t===0?.1:1:a),m=re(Ge(t+p,v/10),24),w=t<=f&&(x===1||x===3&&m>=f||x===2&&m<=f)?f:-N,y=Ue(u,m>w&&t<=w?w:be(w,m));return D===y&&D===0?[-1,1]:[D,y]}function Ft(e,t,n,s){n===2&&(s=!0);const o=Ke(e),i=Ke(t);e===t&&(o===-1?(e*=n,t/=n):(e/=n,t*=n));const l=n===10?J:xe,r=o===1?ne:ye,a=i===1?ye:ne,c=l(fe(e)),u=l(fe(t)),d=r(c),f=a(u);let g=pe(n,d),x=pe(n,f);return n===10&&(d<0&&(g=re(g,-d)),f<0&&(x=re(x,-f))),s?(e=g*o,t=x*i):(e=dt(e,pe(n,ne(c)),!1),t=Ge(t,pe(n,ne(u)),!1)),[e,t]}function Ne(e){return(J((e^e>>31)-(e>>31))|0)+1}function Ht(e,t,n,s,o){const i=be(Ne(e),Ne(t)),l=t-e;let r=be(0,ie(o/s*l,n)-1);do{const a=n[r]??0,c=s*a/l;if(c>=o*.9&&i+(a<5?we.get(a)??0:0)<=17)return[a,c]}while(++r<n.length);return[0,0]}function Et(e){return{id:e.id,min:e.min??null,max:e.max??null,distr:e.distr??U.Linear,log:e.log??10,asinh:e.asinh??1,ori:e.ori??(e.id==="x"?_.Horizontal:_.Vertical),dir:e.dir??Y.Forward,time:e.time??!1,auto:e.auto??!0,range:e.range??null,_min:null,_max:null}}function le(e){e._min=null,e._max=null}function mt(e){if(e._min!=null)return e._min;const{min:t,distr:n}=e;if(t==null)return 0;if(n===U.Log){const s=t>0?t:1e-10;e._min=(e.log===10?J:xe)(s)}else n===U.Asinh?e._min=Ee(t,e.asinh):e._min=t;return e._min}function wt(e){if(e._max!=null)return e._max;const{max:t,distr:n}=e;if(t==null)return 0;if(n===U.Log){const s=t>0?t:1e-10;e._max=(e.log===10?J:xe)(s)}else n===U.Asinh?e._max=Ee(t,e.asinh):e._max=t;return e._max}function Gt(e,t){if(t.min==null||t.max==null)return 0;const n=mt(t),o=wt(t)-n;if(o===0)return 0;const{distr:i}=t;if(i===U.Log){const l=t.log===10?J:xe,r=e>0?e:1e-10;return(l(r)-n)/o}return i===U.Asinh?(Ee(e,t.asinh)-n)/o:(e-n)/o}function _t(e,t){if(t.min==null||t.max==null)return 0;const n=mt(t),s=wt(t);if(s===n)return t.min;const{distr:o}=t;return o===U.Log?Math.pow(t.log,n+e*(s-n)):o===U.Asinh?It(n+e*(s-n),t.asinh):n+e*(s-n)}function V(e,t,n,s){const o=Gt(e,t);let i;return t.ori===_.Horizontal?i=t.dir===Y.Forward?o:1-o:i=t.dir===Y.Forward?1-o:o,s+i*n}function te(e,t,n,s){if(n===0)return t.min??0;let o=(e-s)/n;return t.ori===_.Horizontal?t.dir===Y.Backward&&(o=1-o):t.dir!==Y.Backward&&(o=1-o),_t(o,t)}class Vt{constructor(){this.scales=new Map,this.groupXScales=new Map}addScale(t){this.scales.set(t.id,Et(t))}removeScale(t){this.scales.delete(t)}getScale(t){return this.scales.get(t)}getAllScales(){return this.scales.values()}setGroupXScale(t,n){this.groupXScales.set(t,n)}getGroupXScaleKey(t){return this.groupXScales.get(t)}setRange(t,n,s){const o=this.scales.get(t);o&&(o.min=n,o.max=s,le(o))}autoRangeX(t){var s,o,i,l,r,a;const n=new Map;for(const[c,u]of this.groupXScales){const d=this.scales.get(u);if(!d||!d.auto)continue;const f=t[c];if(!f||f.x.length===0)continue;const g=f.x[0],x=f.x[f.x.length-1];if(g==null||x==null)continue;const M=n.get(u);M?(M.dataMin=Math.min(M.dataMin,g),M.dataMax=Math.max(M.dataMax,x)):n.set(u,{dataMin:g,dataMax:x})}for(const[c,{dataMin:u,dataMax:d}]of n){const f=this.scales.get(c);if(f){if(f.range){const[g,x]=Me(u,d,{min:{pad:((s=f.range.min)==null?void 0:s.pad)??0,soft:((o=f.range.min)==null?void 0:o.soft)??null,mode:((i=f.range.min)==null?void 0:i.mode)??0},max:{pad:((l=f.range.max)==null?void 0:l.pad)??0,soft:((r=f.range.max)==null?void 0:r.soft)??null,mode:((a=f.range.max)==null?void 0:a.mode)??0}});f.min=g,f.max=x}else u===d?[f.min,f.max]=Me(u,d,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}}):(f.min=u,f.max=d);le(f)}}}autoRange(t,n,s){var r,a,c,u,d,f,g,x,M,L,h,I;const o=new Map;for(const[P,R]of this.groupXScales){const T=this.scales.get(R);if(!T||!T.auto)continue;const v=t[P];if(!v||v.x.length===0)continue;const S=v.x[0],b=v.x[v.x.length-1];if(S==null||b==null)continue;const C=o.get(R);C?(C.dataMin=Math.min(C.dataMin,S),C.dataMax=Math.max(C.dataMax,b)):o.set(R,{dataMin:S,dataMax:b})}for(const[P,{dataMin:R,dataMax:T}]of o){const v=this.scales.get(P);if(v){if(v.range){const[S,b]=Me(R,T,{min:{pad:((r=v.range.min)==null?void 0:r.pad)??0,soft:((a=v.range.min)==null?void 0:a.soft)??null,mode:((c=v.range.min)==null?void 0:c.mode)??0},max:{pad:((u=v.range.max)==null?void 0:u.pad)??0,soft:((d=v.range.max)==null?void 0:d.soft)??null,mode:((f=v.range.max)==null?void 0:f.mode)??0}});v.min=S,v.max=b}else R===T?[v.min,v.max]=Me(R,T,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}}):(v.min=R,v.max=T);le(v)}}const i=new Map,l=new Map;for(const{group:P,index:R,yScale:T}of n){const v=t[P];if(!v)continue;const S=v.series[R];if(!S||S.length===0)continue;const b=s.windows.get(P),C=b?b[0]:0,D=b?b[1]:S.length-1,p=this.scales.get(T),m=(p==null?void 0:p.distr)===U.Log,[w,y]=s.getCachedMinMax(P,R,C,D,0,m),k=i.get(T),A=l.get(T);i.set(T,k!=null?Math.min(k,w):w),l.set(T,A!=null?Math.max(A,y):y)}for(const[P,R]of i){const T=this.scales.get(P);if(!T||!T.auto)continue;const v=l.get(P)??-N;if(R===N)continue;let S,b;if(T.distr===U.Log)[S,b]=Ft(R,v,T.log,!1);else{const C=T.range??{min:se,max:se};[S,b]=Me(R,v,{min:{pad:((g=C.min)==null?void 0:g.pad)??se.pad,soft:((x=C.min)==null?void 0:x.soft)??se.soft,mode:((M=C.min)==null?void 0:M.mode)??se.mode},max:{pad:((L=C.max)==null?void 0:L.pad)??se.pad,soft:((h=C.max)==null?void 0:h.soft)??se.soft,mode:((I=C.max)==null?void 0:I.mode)??se.mode}})}T.min=S,T.max=b,le(T)}}}const $t=1024;class Bt{constructor(t,n=$t){this.data=t,this.len=t.length,this.blockSize=n,this.nBlocks=Math.ceil(t.length/n),this.blocks=new Float64Array(this.nBlocks*2),this.buildAll()}buildAll(){const{data:t,blockSize:n,nBlocks:s,blocks:o,len:i}=this;for(let l=0;l<s;l++){const r=l*n,a=Math.min(r+n,i);let c=1/0,u=-1/0;for(let d=r;d<a;d++){const f=t[d];f!=null&&(f<c&&(c=f),f>u&&(u=f))}o[l*2]=c,o[l*2+1]=u}}rangeMinMax(t,n){const{data:s,blockSize:o,blocks:i}=this;let l=1/0,r=-1/0;const a=Math.floor(t/o),c=Math.floor(n/o);if(a===c){for(let f=t;f<=n;f++){const g=s[f];g!=null&&(g<l&&(l=g),g>r&&(r=g))}return[l,r]}const u=(a+1)*o-1;for(let f=t;f<=u;f++){const g=s[f];g!=null&&(g<l&&(l=g),g>r&&(r=g))}for(let f=a+1;f<c;f++){const g=i[f*2]??1/0,x=i[f*2+1]??-1/0;g<l&&(l=g),x>r&&(r=x)}const d=c*o;for(let f=d;f<=n;f++){const g=s[f];g!=null&&(g<l&&(l=g),g>r&&(r=g))}return[l,r]}updateBlock(t){const{data:n,blockSize:s,blocks:o,len:i}=this;if(t>=this.nBlocks)return;const l=t*s,r=Math.min(l+s,i);let a=1/0,c=-1/0;for(let u=l;u<r;u++){const d=n[u];d!=null&&(d<a&&(a=d),d>c&&(c=d))}o[t*2]=a,o[t*2+1]=c}grow(t){const n=this.nBlocks;if(this.len=t,this.nBlocks=Math.ceil(t/this.blockSize),this.nBlocks>n){const o=new Float64Array(this.nBlocks*2);o.set(this.blocks),this.blocks=o}const s=Math.max(0,n-1);for(let o=s;o<this.nBlocks;o++)this.updateBlock(o)}setData(t){this.data=t}}class Wt{constructor(){this.data=[],this.windows=new Map,this.minMaxCache=new Map,this.blockTrees=new Map}setData(t){this.data=t,this.windows.clear();for(const n of this.minMaxCache.values())n.clear();this.minMaxCache.clear(),this.blockTrees.clear()}getOrBuildTree(t,n){const s=`${t}:${n}`;let o=this.blockTrees.get(s);if(o)return o;const i=this.data[t];if(!i)return;const l=i.series[n];if(!(!l||l.length===0))return o=new Bt(l),this.blockTrees.set(s,o),o}updateWindows(t){var s;let n=!1;for(let o=0;o<this.data.length;o++){const i=this.data[o],l=t(o),r=this.windows.get(o);let a,c;if(!i||!l||l.min==null||l.max==null)a=0,c=Math.max(0,((i==null?void 0:i.x.length)??1)-1);else{const u=i.x;if(u.length===0)a=0,c=0;else{a=ie(l.min,u),c=ie(l.max,u);const d=u[a],f=u[c];a>0&&d!=null&&d>l.min&&a--,c<u.length-1&&f!=null&&f<l.max&&c++}}(!r||r[0]!==a||r[1]!==c)&&(n=!0,(s=this.minMaxCache.get(o))==null||s.clear()),this.windows.set(o,[a,c])}return n}getWindow(t){var n;return this.windows.get(t)??[0,(((n=this.data[t])==null?void 0:n.x.length)||1)-1]}getXValues(t){var n;return((n=this.data[t])==null?void 0:n.x)??[]}getYValues(t,n){var s;return((s=this.data[t])==null?void 0:s.series[n])??[]}getCachedMinMax(t,n,s,o,i,l){let r=this.minMaxCache.get(t);const a=`${n}:${s}:${o}`;if(r){const g=r.get(a);if(g!=null)return g}else r=new Map,this.minMaxCache.set(t,r);const c=this.data[t];if(!c)return[1/0,-1/0];const u=c.series[n];if(!u||u.length===0)return[1/0,-1/0];let d;const f=!l&&i===me.Unsorted?this.getOrBuildTree(t,n):void 0;return f?d=f.rangeMinMax(s,o):d=At(u,s,o,i,l),r.set(a,d),d}getBlockTree(t,n){return this.getOrBuildTree(t,n)}appendData(t,n,s){var l;const o=this.data[t];if(!o)return;const i=o.x;if(Array.isArray(i)){for(let r=0;r<n.length;r++){const a=n[r];a!=null&&i.push(a)}for(let r=0;r<o.series.length;r++){const a=o.series[r];if(!a||!Array.isArray(a))continue;const c=s[r];if(c)for(let d=0;d<c.length;d++)a.push(c[d]??null);const u=this.blockTrees.get(`${t}:${r}`);u&&(u.setData(a),u.grow(a.length))}(l=this.minMaxCache.get(t))==null||l.clear()}}static toTypedX(t){for(const n of t)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return t}}class jt{constructor(){this.state={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1}}hide(){this.state.left=-10,this.state.top=-10,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(t,n,s,o,i,l,r,a){this.state.left=t,this.state.top=n;let c=1/0,u=-1,d=-1,f=-1;const g=new Map;for(const x of i){if(x.show===!1)continue;let M=g.get(x.group);M==null&&(M=[],g.set(x.group,M)),M.push(x)}for(let x=0;x<o.length;x++){const M=o[x];if(M==null)continue;const L=M.x;if(L.length===0)continue;const h=a(x);if(h==null)continue;const I=l(h);if(I==null||I.min==null||I.max==null)continue;const[P,R]=r(x),T=s.width,v=s.left,S=te(t+v,I,T,v),b=ie(S,L,P,R),C=[b];b>P&&C.push(b-1),b<R&&C.push(b+1);const D=new Map;for(const p of C){const m=L[p];if(m==null)continue;const w=V(m,I,T,v);for(const y of g.get(x)??[]){const k=M.series[y.index];if(k==null)continue;const A=k[p];if(A==null)continue;let F=D.get(y.yScale);if(F==null&&!D.has(y.yScale)&&(F=l(y.yScale),D.set(y.yScale,F)),F==null||F.min==null||F.max==null)continue;const H=s.height,E=s.top,$=V(A,F,H,E),W=t+v-w,j=n+E-$,K=W*W+j*j;if(K<c&&(c=K,u=x,d=y.index,f=p,K===0))break}if(c===0)break}}this.state.activeGroup=u,this.state.activeSeriesIdx=d,this.state.activeDataIdx=f}syncToValue(t,n){const s=n.dataStore.data;if(s.length===0)return;const o=s[0];if(o==null)return;const i=n.scaleManager.getGroupXScaleKey(0);if(i==null)return;const l=n.scaleManager.getScale(i);if(l==null||l.min==null||l.max==null)return;const[r,a]=n.dataStore.getWindow(0),c=ie(t,o.x,r,a),u=o.x[c];if(u==null)return;const d=V(u,l,n.plotBox.width,n.plotBox.left);this.state.left=d-n.plotBox.left,this.state.activeGroup=0,this.state.activeDataIdx=c;let f=0,g=n.plotBox.height/2;for(const x of n.seriesConfigs){if(x.group!==0||x.show===!1)continue;const M=o.series[x.index];if(M==null)continue;const L=M[c];if(L==null)continue;const h=n.scaleManager.getScale(x.yScale);if(!(h==null||h.min==null||h.max==null)){g=V(L,h,n.plotBox.height,n.plotBox.top)-n.plotBox.top,f=x.index;break}}this.state.top=g,this.state.activeSeriesIdx=f}}class Xt{constructor(){this.flags=Z.None,this.frameId=null,this.callback=null}mark(t){this.flags|=t,this.scheduleFrame()}has(t){return(this.flags&t)!==0}get dirty(){return this.flags}clear(){this.flags=Z.None}onRedraw(t){this.callback=t}scheduleFrame(){this.frameId==null&&(this.frameId=requestAnimationFrame(()=>{this.frameId=null;const t=this.callback;t!=null&&t(),this.clear()}))}cancel(){this.frameId!=null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}dispose(){this.cancel(),this.callback=null,this.flags=Z.None}}function Pe(e,t,n){e.lineTo(t,n)}function Le(e,t,n){e.lineTo(n,t)}function _e(e,t,n,s,o,i){const l=[];let r=-1;const a=o===Y.Forward?n:s,c=o===Y.Forward?s:n,u=o;for(let d=a;o===Y.Forward?d<=c:d>=c;d+=u)if(t[d]===null||t[d]===void 0){if(r===-1){const f=Math.max(n,Math.min(d-o,s));r=i(e[f])}}else r!==-1&&(l.push([r,i(e[d])]),r=-1);return r!==-1&&l.push([r,i(e[s])]),l}function Ve(e,t,n,s,o,i){const l=new Path2D;let r=t===_.Horizontal?n:s;const a=t===_.Horizontal?n+o:s+i,c=t===_.Horizontal?s:n,u=t===_.Horizontal?i:o;for(const[d,f]of e)d>r&&(t===_.Horizontal?l.rect(r,c,d-r,u):l.rect(c,r,u,d-r)),r=f;return r<a&&(t===_.Horizontal?l.rect(r,c,a-r,u):l.rect(c,r,u,a-r)),l}function xt(e){return(t,n,s,o,i,l)=>{s!==o&&(i!==s&&l!==s&&e(t,n,s),i!==o&&l!==o&&e(t,n,o),e(t,n,l))}}const Yt=xt(Pe),Ut=xt(Le);function vt(){return(e,t,n,s,o,i,l,r,a,c,u,d,f)=>{const g=(f==null?void 0:f.spanGaps)??!1;if([a,c]=(s.distr===U.Log?ht:Ae)(t,a,c),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const M=S=>d(V(S,n,o,l)),L=S=>d(V(S,s,i,r));let h,I;n.ori===_.Horizontal?(h=Pe,I=Yt):(h=Le,I=Ut);const P={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},R=P.stroke;let T=!1;if(c-a>=o*4){const S=A=>te(A,n,o,l);let b=null,C=0,D=0,p=0,m=M(e[u===Y.Forward?a:c]);const w=M(e[a]),y=M(e[c]);let k=S(u===Y.Forward?w+1:y-1);for(let A=u===Y.Forward?a:c;A>=a&&A<=c;A+=u){const F=e[A],E=(u===Y.Forward?F<k:F>k)?m:M(F),$=t[A];E===m?$!=null?(p=$,b==null?(h(R,E,L(p)),D=b=C=p):p<b?b=p:p>C&&(C=p)):$===null&&!g&&(T=!0):(b!=null&&I(R,m,L(b),L(C),L(D),L(p)),$!=null?(p=$,h(R,E,L(p)),b=C=D=p):(b=null,C=0,$===null&&!g&&(T=!0)),m=E,k=S(m+u))}b!=null&&(b!==C?I(R,m,L(b),L(C),L(D),L(p)):h(R,m,L(p)))}else for(let S=u===Y.Forward?a:c;S>=a&&S<=c;S+=u){const b=t[S];b===null&&!g?T=!0:b!=null&&h(R,M(e[S]),L(b))}{const S=P.fill=new Path2D(R),b=(f==null?void 0:f.fillTo)??s.min??0,C=L(b);let D=l,p=l+o;u===Y.Backward&&([p,D]=[D,p]),h(S,p,C),h(S,D,C)}if(T){const S=_e(e,t,a,c,u,M);P.gaps=S,P.clip=Ve(S,n.ori,l,r,o,i)}return P}}const qe=new WeakMap;function Oe(e,t,n){return typeof t=="string"?t:Kt(e,t,n)}function Kt(e,t,n){const s=qe.get(t);if(s!=null&&s.top===n.top&&s.height===n.height)return s.grad;const o=e.createLinearGradient(0,n.top,0,n.top+n.height);for(const[i,l]of t.stops)o.addColorStop(i,l);return qe.set(t,{grad:o,top:n.top,height:n.height}),o}function Nt(e,t,n,s,o){if(t.show===!1)return;const i=t.alpha??1;e.save(),i<1&&(e.globalAlpha=i),n.clip&&e.clip(n.clip);const l=o??{top:0,width:e.canvas.width/s,height:e.canvas.height/s};if(t.fill&&n.fill&&(e.fillStyle=Oe(e,t.fill,l),e.fill(n.fill)),t.stroke){const r=(t.width??1)*s;e.strokeStyle=Oe(e,t.stroke,l),e.lineWidth=r,e.lineJoin=t.join??"round",e.lineCap=t.cap??"butt",t.dash&&e.setLineDash(t.dash.map(d=>d*s));const a=t.pxAlign??1,c=r%2/2;a===1&&c>0&&e.translate(c,c),e.stroke(n.stroke)}e.restore()}const qt=vt(),Ze=64;class Ot{constructor(){this.ctx=null,this.pxRatio=1,this.pathCache=new Map,this.pathCacheSize=0,this.bandCache=new Map,this.lruHead=null,this.lruTail=null,this.lruMap=new Map,this.snapshotCanvas=null,this.snapshotValid=!1,this.cachedFillStyle="",this.cachedStrokeStyle="",this.cachedLineWidth=-1,this.cachedFont="",this.cachedTextAlign="",this.cachedTextBaseline="",this.cachedGlobalAlpha=-1}lruKey(t,n,s){return`${t}:${n}:${s}`}lruUnlink(t){t.prev!=null?t.prev.next=t.next:this.lruHead=t.next,t.next!=null?t.next.prev=t.prev:this.lruTail=t.prev,t.prev=null,t.next=null}lruAppend(t){t.prev=this.lruTail,t.next=null,this.lruTail!=null?this.lruTail.next=t:this.lruHead=t,this.lruTail=t}setContext(t,n){this.ctx=t,this.pxRatio=n,this.resetPropertyCache()}resetPropertyCache(){this.cachedFillStyle="",this.cachedStrokeStyle="",this.cachedLineWidth=-1,this.cachedFont="",this.cachedTextAlign="",this.cachedTextBaseline="",this.cachedGlobalAlpha=-1}setFillStyle(t,n){n!==this.cachedFillStyle&&(t.fillStyle=n,this.cachedFillStyle=n)}setStrokeStyle(t,n){n!==this.cachedStrokeStyle&&(t.strokeStyle=n,this.cachedStrokeStyle=n)}setLineWidth(t,n){n!==this.cachedLineWidth&&(t.lineWidth=n,this.cachedLineWidth=n)}setFont(t,n){n!==this.cachedFont&&(t.font=n,this.cachedFont=n)}setTextAlign(t,n){n!==this.cachedTextAlign&&(t.textAlign=n,this.cachedTextAlign=n)}setTextBaseline(t,n){n!==this.cachedTextBaseline&&(t.textBaseline=n,this.cachedTextBaseline=n)}setGlobalAlpha(t,n){n!==this.cachedGlobalAlpha&&(t.globalAlpha=n,this.cachedGlobalAlpha=n)}saveSnapshot(t,n,s){const o=t.canvas;(this.snapshotCanvas==null||this.snapshotCanvas.width!==n||this.snapshotCanvas.height!==s)&&(this.snapshotCanvas=typeof OffscreenCanvas<"u"?new OffscreenCanvas(n,s):document.createElement("canvas"),this.snapshotCanvas.width=n,this.snapshotCanvas.height=s);const i=this.snapshotCanvas.getContext("2d");i!=null&&typeof i.drawImage=="function"&&(i.clearRect(0,0,n,s),i.drawImage(o,0,0),this.snapshotValid=!0)}restoreSnapshot(t){return!this.snapshotValid||this.snapshotCanvas==null||typeof t.drawImage!="function"?!1:(t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(this.snapshotCanvas,0,0),!0)}invalidateSnapshot(){this.snapshotValid=!1}windowKey(t,n){return`${t}:${n}`}getCachedPaths(t,n,s,o){const i=this.pathCache.get(t);if(i==null)return;const l=i.get(n);if(l==null)return;const r=this.windowKey(s,o),a=l.get(r);if(a!=null){const c=this.lruMap.get(this.lruKey(t,n,r));c!=null&&c!==this.lruTail&&(this.lruUnlink(c),this.lruAppend(c))}return a}setCachedPaths(t,n,s,o,i){if(this.pathCacheSize>=Ze){const u=Ze>>2;let d=this.lruHead;for(let f=0;f<u&&d!=null;f++){const g=d.next,x=this.pathCache.get(d.group);if(x!=null){const M=x.get(d.index);M!=null&&(M.delete(d.key),this.pathCacheSize--,M.size===0&&x.delete(d.index),x.size===0&&this.pathCache.delete(d.group))}this.lruMap.delete(this.lruKey(d.group,d.index,d.key)),d=g}this.lruHead=d,d!=null?d.prev=null:this.lruTail=null}let l=this.pathCache.get(t);l==null&&(l=new Map,this.pathCache.set(t,l));let r=l.get(n);r==null&&(r=new Map,l.set(n,r));const a=this.windowKey(s,o),c=this.lruKey(t,n,a);if(!r.has(a)){this.pathCacheSize++;const u={group:t,index:n,key:a,prev:null,next:null};this.lruAppend(u),this.lruMap.set(c,u)}r.set(a,i)}invalidateSeries(t,n){const s=this.pathCache.get(t);if(s==null)return;const o=s.get(n);if(o!=null){this.pathCacheSize-=o.size;for(const i of o.keys()){const l=this.lruKey(t,n,i),r=this.lruMap.get(l);r!=null&&(this.lruUnlink(r),this.lruMap.delete(l))}s.delete(n)}}clearGroupCache(t){const n=this.pathCache.get(t);if(n!=null){for(const[s,o]of n.entries()){this.pathCacheSize-=o.size;for(const i of o.keys()){const l=this.lruKey(t,s,i),r=this.lruMap.get(l);r!=null&&(this.lruUnlink(r),this.lruMap.delete(l))}}this.pathCache.delete(t)}for(const s of this.bandCache.keys())s.startsWith(`${t}:`)&&this.bandCache.delete(s);this.snapshotValid=!1}clearCache(){this.pathCache.clear(),this.pathCacheSize=0,this.lruHead=null,this.lruTail=null,this.lruMap.clear(),this.bandCache.clear(),this.snapshotValid=!1}bandKey(t,n,s,o,i){return`${t}:${n}:${s}:${o}:${i}`}getCachedBandPath(t,n,s,o,i){return this.bandCache.get(this.bandKey(t,n,s,o,i))}setCachedBandPath(t,n,s,o,i,l){this.bandCache.set(this.bandKey(t,n,s,o,i),l)}drawSeries(t,n,s){const o=this.ctx;if(o==null||t.config.show===!1)return;const i=t.config.group,l=t.config.index,[r,a]=t.window;let c=this.getCachedPaths(i,l,r,a);if(c==null){const u=t.config.paths??qt,d=t.xScale.dir,f=M=>B(M),g=t.config.fillTo,x=typeof g=="function"?g(t.yScale.min??0,t.yScale.max??0):g;c=u(t.dataX,t.dataY,t.xScale,t.yScale,n.width,n.height,n.left,n.top,r,a,d,f,{fillTo:x,spanGaps:t.config.spanGaps}),this.setCachedPaths(i,l,r,a,c)}Nt(o,t.config,c,s,n)}draw(t,n,s,o){const i=this.ctx;if(i==null)return;const l=this.pxRatio;i.clearRect(0,0,t*l,n*l),i.save(),i.scale(l,l),i.beginPath(),i.rect(s.left,s.top,s.width,s.height),i.clip();for(const r of o)this.drawSeries(r,s,1);i.restore(),this.resetPropertyCache()}}const Mt=[1,2,2.5,5],Zt=gt(10,-32,0,Mt),Jt=gt(10,0,32,Mt),ae=Zt.concat(Jt);function Qt(e,t,n,s,o){if(n<=0||t<e)return[];const i=[],l=we.get(n)??0,r=o?e:re(Ge(e,n),l);for(let a=r;a<=t;a=re(a+n,l))i.push(Object.is(a,-0)?0:a);return i}function Je(e){return e.map(t=>pt(t))}function en(e,t,n){if(e<=0||t<=0||e>=t)return[];const s=[],i=ne((n===10?J:xe)(e));let l=pe(n,i);n===10&&(l=ae[ie(l,ae)]??l);let r=l,a=l*n;n===10&&(a=ae[ie(a,ae)]??a);let c=0;do{if(r>=e&&s.push(r),r=r+l,n===10&&!we.has(r)){const u=we.get(l)??0;r=re(r,u)}r>=a*(1-1e-10)&&(l=r,a=l*n,n===10&&(a=ae[ie(a,ae)]??a))}while(r<=t&&++c<1e4);return s}function tn(e,t){const n=t===10?J:xe;return e.map(s=>{if(s===0)return!0;if(s<0)return!1;const o=n(s);return fe(o-Math.round(o))<1e-10})}function nn(e,t){const s=pt(Math.max(Math.abs(e),Math.abs(t))).length*7;return Math.max(50,s+16)}function sn(e,t,n,s){if(s<=0)return[0,0];const o=he(e.side)===_.Vertical,i=e.space??(o?30:nn(t,n)),l=e.incrs??ae;return Ht(t,n,l,s,i)}const on=50;function ln(e,t,n){var r,a;if(e.size!=null)return e.size;const s=((r=e.ticks)==null?void 0:r.show)!==!1?((a=e.ticks)==null?void 0:a.size)??10:0,o=e.gap??5,i=12;if(he(e.side)===_.Vertical&&t!=null){let c=0;for(const d of t)d.length>c&&(c=d.length);const u=c*7;return Math.max(50,s+o+u+4)}return Math.max(50,s+o+i+3)}function rn(e){return{config:e,_show:e.show!==!1,_size:e.size??on,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const ge=60,ce=3600,oe=86400,ue=2592e3,Ce=31536e3,an=[1,5,10,15,30,ge,5*ge,10*ge,15*ge,30*ge,ce,2*ce,3*ce,4*ce,6*ce,12*ce,oe,2*oe,3*oe,7*oe,14*oe,ue,2*ue,3*ue,6*ue,Ce];function cn(e,t,n,s){const o=[];if(n<=0||e>=t)return o;let i;if(n>=Ce){const l=new Date(e*1e3);for(l.setUTCMonth(0,1),l.setUTCHours(0,0,0,0),i=l.getTime()/1e3,i<e&&(l.setUTCFullYear(l.getUTCFullYear()+1),i=l.getTime()/1e3);i<=t;)o.push(i),l.setUTCFullYear(l.getUTCFullYear()+Math.round(n/Ce)),i=l.getTime()/1e3;return o}if(n>=ue){const l=new Date(e*1e3);l.setUTCDate(1),l.setUTCHours(0,0,0,0),i=l.getTime()/1e3;const r=Math.max(1,Math.round(n/ue));if(i<e&&(l.setUTCMonth(l.getUTCMonth()+1),i=l.getTime()/1e3),r>1){const a=l.getUTCMonth(),c=Math.ceil((a+1)/r)*r;l.setUTCMonth(c-1),i=l.getTime()/1e3}for(;i<=t;)o.push(i),l.setUTCMonth(l.getUTCMonth()+r),i=l.getTime()/1e3;return o}if(n>=oe){const l=new Date(e*1e3);l.setUTCHours(0,0,0,0),i=l.getTime()/1e3,i<e&&(i+=oe)}else i=Math.ceil(e/n)*n;for(let l=0;;l++){const r=i+l*n;if(r>t)break;o.push(r)}return o}const Qe=new Map;function un(e,t){const n=JSON.stringify(e)+(t??"");let s=Qe.get(n);return s==null&&(s=new Intl.DateTimeFormat(void 0,{...e,timeZone:t}),Qe.set(n,s)),s}function Q(e,t,n){const s=new Date(e*1e3);return un(t,n).format(s)}function fn(e,t){return Q(e,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function hn(e,t){return Q(e,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function dn(e,t){return Q(e,{hour:"2-digit",minute:"2-digit",hour12:!1},t)}function gn(e,t){return Q(e,{month:"short",day:"numeric"},t)}function pn(e,t){return Q(e,{year:"numeric"},t)}function mn(e,t){return Q(e,{year:"numeric",month:"short"},t)}function wn(e,t,n){let s;return t>=Ce?s=pn:t>=ue?s=mn:t>=oe?s=gn:t>=ce?s=dn:t>=ge?s=hn:s=fn,e.map(o=>s(o,n))}function xn(e,t,n,s,o){const i=t-e;if(i<=0||s<=0)return[0,0];for(const r of n){const a=i/r,c=s/a;if(c>=o)return[r,c]}const l=n[n.length-1]??Ce;return[l,s/(i/l)]}const vn=3;function Mn(e,t,n,s,o){let i=!0;for(const l of e){const r=l.config;if(r.show===!1)continue;const a=t(r.scale);if(!a||a.min==null||a.max==null){l._show&&(i=!1,l._show=!1);continue}else l._show||(i=!1,l._show=!0);const c=r.side,d=he(c)===_.Horizontal?n:s,{min:f,max:g}=a;let x,M;if(a.time){const h=r.space??80;[x,M]=xn(f,g,an,d,h)}else[x,M]=sn(r,f,g,d);if(l._incr=x,l._space=M,M===0)continue;if(r.splits)l._splits=r.splits(f,g,x,M);else if(a.time)l._splits=cn(f,g,x);else if(a.distr===U.Log)l._splits=en(f,g,a.log);else{const h=a.distr===U.Ordinal;l._splits=Qt(f,g,x,M,h)}if(r.values)l._values=r.values(l._splits,M,x);else if(a.time)l._values=wn(l._splits,x);else if(a.distr===U.Log){const h=tn(l._splits,a.log),I=Je(l._splits);l._values=I.map((P,R)=>h[R]?P:"")}else l._values=Je(l._splits);l._rotate=c===X.Bottom?r.rotate??0:0;const L=l._size;l._size=ye(ln(r,l._values)),L!==l._size&&(i=!1)}return i}function et(e,t,n){let s=e,o=t,i=0,l=0;for(const r of n){if(!r._show)continue;const a=r.config.side,c=he(a)===_.Vertical,u=r.config.label!=null?r.config.labelSize??20:0,d=r._size+u;d>0&&(c?(s-=d,a===X.Left&&(i+=d)):(o-=d,a===X.Top&&(l+=d)))}return{left:i,top:l,width:Math.max(s,0),height:Math.max(o,0)}}function bn(e,t){let n=t.top,s=t.left+t.width,o=t.top+t.height,i=t.left;function l(r,a){switch(r){case X.Top:return n-=a,n+a;case X.Right:{const c=s;return s+=a,c}case X.Bottom:{const c=o;return o+=a,c}case X.Left:return i-=a,i+a;default:return 0}}for(const r of e){if(!r._show)continue;const a=r.config.side;if(r._pos=l(a,r._size),r.config.label!=null){const c=r.config.labelSize??20;r._lpos=l(a,c)}}}function Sn(e,t,n,s){for(const r of n)r._size=0;let o=!1,i=0,l={left:0,top:0,width:e,height:t};for(;!o;){i++;const r=Mn(n,s,l.width,l.height);o=i===vn||r,o||(l=et(e,t,n))}return l=et(e,t,n),bn(n,l),l}const tt="top",nt="bottom",yn="left",kn="right";function st(e,t){return t===1?e:e.replace(/(\d+(?:\.\d+)?)px/,(n,s)=>`${Math.round(Number(s)*t)}px`)}function ot(e,t,n,s,o,i,l,r,a,c,u){const d=r%2/2;e.save(),e.translate(d,d),e.strokeStyle=a,e.lineWidth=r,c.length>0&&e.setLineDash(c),e.beginPath();let f=0,g=0,x=0,M=0;const L=i+(o===X.Top||o===X.Left?-l:l);s===_.Horizontal?(g=i,M=L):(f=i,x=L);for(let h=0;h<t.length;h++)n[h]!=null&&(s===_.Horizontal?f=x=t[h]??0:g=M=t[h]??0,e.moveTo(f,g),e.lineTo(x,M));e.stroke(),e.restore()}function Cn(e,t,n,s,o){const i=B(s.left*o),l=B(s.top*o),r=B(s.width*o),a=B(s.height*o);for(const c of t){if(!c._show)continue;const u=c.config,d=u.side,f=he(d),g=n(u.scale);if(!g||g.min==null||g.max==null)continue;const x=u.stroke??"#000",M=d===X.Top||d===X.Left?-1:1,L=c._splits,h=c._values;if(!L||!h||c._space===0)continue;const I=f===_.Horizontal?s.width:s.height,P=f===_.Horizontal?s.left:s.top,R=L.map(C=>B(V(C,g,I,P)*o)),T=h.map(C=>C===""?null:C),v=u.grid;if((v==null?void 0:v.show)!==!1){const C=(v==null?void 0:v.stroke)??"rgba(0,0,0,0.12)",D=B(((v==null?void 0:v.width)??2)*o),p=((v==null?void 0:v.dash)??[]).map(y=>y*o),m=f===_.Horizontal?l:i,w=f===_.Horizontal?a:r;ot(e,R,T,f,2,m,w,D,C,p)}const S=u.ticks;if((S==null?void 0:S.show)!==!1){const C=(S==null?void 0:S.stroke)??x,D=B(((S==null?void 0:S.width)??1)*o),p=B(((S==null?void 0:S.size)??10)*o),m=((S==null?void 0:S.dash)??[]).map(y=>y*o),w=B(c._pos*o);ot(e,R,T,f,d,w,p,D,C,m)}{const C=(S==null?void 0:S.show)!==!1?((S==null?void 0:S.size)??10)*o:0,D=B((u.gap??5)*o),p=B(c._pos*o),m=(C+D)*M,w=p+m,y=st(u.font??"12px system-ui, sans-serif",o),k=f===_.Horizontal?"center":d===X.Left?kn:yn,A=f===_.Horizontal?d===X.Bottom?tt:nt:"middle";e.font=y,e.fillStyle=x,e.textAlign=k,e.textBaseline=A;const F=c._rotate*-De/180;if(F!==0){const H=Math.cos(F),E=Math.sin(F);for(let $=0;$<h.length;$++){const W=h[$];if(W==null||W==="")continue;const j=R[$]??0;e.setTransform(H,E,-E,H,j,w),e.fillText(W,0,0)}e.setTransform(1,0,0,1,0,0)}else for(let H=0;H<h.length;H++){const E=h[H];if(E==null||E==="")continue;const $=R[H]??0,W=f===_.Horizontal?$:w,j=f===_.Horizontal?w:$;e.fillText(E,W,j)}}if(u.label!=null){const C=st(u.labelFont??"bold 12px system-ui, sans-serif",o);e.font=C,e.fillStyle=x,e.textAlign="center",e.textBaseline=d===X.Bottom?tt:nt;const D=B((c._lpos+(u.labelGap??0)*M)*o);f===_.Vertical?(e.save(),e.translate(D,B(l+a/2)),e.rotate((d===X.Left?-De:De)/2),e.fillText(u.label,0,0),e.restore()):e.fillText(u.label,B(i+r/2),D)}const b=u.border;if((b==null?void 0:b.show)!==!1&&b!=null){const C=b.stroke??x,D=B((b.width??1)*o),p=(b.dash??[]).map(w=>w*o),m=B(c._pos*o);e.strokeStyle=C,e.lineWidth=D,p.length>0&&e.setLineDash(p),e.beginPath(),f===_.Horizontal?(e.moveTo(i,m),e.lineTo(i+r,m)):(e.moveTo(m,l),e.lineTo(m,l+a)),e.stroke(),p.length>0&&e.setLineDash([])}}}const Tn={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function lt(e,t,n,s,o,i,l,r,a){var P;if(t.left<0||t.top<0)return;const c={...Tn,...a},u=s,d=B(n.left*u),f=B(n.top*u),g=B(n.width*u),x=B(n.height*u),M=B(c.width*u),L=M%2/2,h=B((n.left+t.left)*u)+L,I=B((n.top+t.top)*u)+L;if(e.save(),e.strokeStyle=c.stroke,e.lineWidth=M,e.setLineDash(c.dash.map(R=>R*u)),c.showX&&(e.beginPath(),e.moveTo(h,f),e.lineTo(h,f+x),e.stroke()),c.showY&&(e.beginPath(),e.moveTo(d,I),e.lineTo(d+g,I),e.stroke()),e.setLineDash([]),t.activeGroup>=0&&t.activeDataIdx>=0){const R=t.activeGroup,T=t.activeSeriesIdx,v=t.activeDataIdx,S=o[R];if(S!=null&&T>=0&&T<S.series.length&&v<S.x.length){const b=S.x[v],C=S.series[T],D=C!=null?C[v]:null;if(b!=null&&D!=null){let p=c.stroke,m=!0;for(const w of i)if(w.group===R&&w.index===T){const y=w.stroke;p=(typeof y=="string"?y:void 0)??c.stroke,m=((P=w.cursor)==null?void 0:P.show)!==!1;break}if(m){const w=r(R),y=w!=null?l(w):void 0,k=In(i,R,T),A=k!=null?l(k):void 0;if(y!=null&&A!=null&&y.min!=null&&y.max!=null&&A.min!=null&&A.max!=null){const F=B(V(b,y,n.width,n.left)*u),H=B(V(D,A,n.height,n.top)*u),E=c.pointRadius*u,$=B(2*u);e.beginPath(),e.arc(F,H,E,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.strokeStyle=p,e.lineWidth=$,e.stroke()}}}}}e.restore()}function In(e,t,n){for(const s of e)if(s.group===t&&s.index===n)return s.yScale}const An={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function it(e,t,n,s,o){if(!t.show||t.width<=0)return;const i={...An,...o},l=s,r=B((n.left+t.left)*l),a=B((n.top+t.top)*l),c=B(t.width*l),u=B(t.height*l);e.save(),e.fillStyle=i.fill,e.fillRect(r,a,c,u),i.width>0&&(e.strokeStyle=i.stroke,e.lineWidth=B(i.width*l),e.strokeRect(r,a,c,u)),e.restore()}function Pn(e,t,n,s,o,i,l,r,a,c,u,d){const f=u/2*l,g=Math.max(1,B(u*.2))*l,x=(c==null?void 0:c.stroke)??d,M=(c==null?void 0:c.fill)??"#fff";e.save(),e.strokeStyle=x,e.fillStyle=M,e.lineWidth=g,(c==null?void 0:c.dash)!=null&&e.setLineDash(c.dash.map(L=>L*l));for(let L=r;L<=a;L++){const h=n[L];if(h==null)continue;const I=t[L];if(I==null)continue;const P=B(V(I,s,i.width,i.left)*l),R=B(V(h,o,i.height,i.top)*l);e.beginPath(),e.arc(P,R,f,0,Math.PI*2),e.fill(),e.stroke()}e.restore()}function Ln(e,t,n,s,o,i,l){if(typeof e=="function")return e(t,n,s,o,i);if(e===!0)return!0;if(e===!1)return!1;const r=o-s;return r>0&&r<=i/l}function Rn(e,t,n,s,o,i,l,r,a){if(r>a||r<0)return null;const c=g=>V(g,s,i.width,i.left)*l,u=g=>V(g,o,i.height,i.top)*l,d=new Path2D;let f=!1;for(let g=r;g<=a;g++){const x=t[g],M=e[g];if(x==null||M==null)continue;const L=c(M),h=u(x);f?d.lineTo(L,h):(d.moveTo(L,h),f=!0)}if(!f)return null;for(let g=a;g>=r;g--){const x=n[g],M=e[g];x==null||M==null||d.lineTo(c(M),u(x))}return d.closePath(),d}function Dn(e,t,n){e.save(),e.fillStyle=t.fill??"rgba(0, 120, 255, 0.1)",e.fill(n),e.restore()}function Fe(e,t,n,s){return{ctx:e,plotBox:t,pxRatio:n,getScale:s,valToX:(l,r="x")=>{const a=s(r);return a==null||a.min==null||a.max==null?null:V(l,a,t.width,t.left)},valToY:(l,r)=>{const a=s(r);return a==null||a.min==null||a.max==null?null:V(l,a,t.height,t.top)}}}function zn(){const e={scaleManager:new Vt,dataStore:new Wt,renderer:new Ot,cursorManager:new jt,selectState:{show:!1,left:0,top:0,width:0,height:0},scaleConfigs:[],seriesConfigs:[],axisConfigs:[],bandConfigs:[],axisStates:[],width:0,height:0,pxRatio:typeof window<"u"&&window.devicePixelRatio||1,plotBox:{left:0,top:0,width:0,height:0},canvas:null,listeners:new Set,scheduler:new Xt,drawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:.15,wheelZoom:!1,revision:0,eventCallbacks:{},_prevScaleRanges:new Map,registerScale(t){e.scaleConfigs=e.scaleConfigs.filter(n=>n.id!==t.id),e.scaleConfigs.push(t),e.scaleManager.addScale(t)},unregisterScale(t){e.scaleConfigs=e.scaleConfigs.filter(n=>n.id!==t),e.scaleManager.removeScale(t)},registerSeries(t){e.seriesConfigs=e.seriesConfigs.filter(n=>!(n.group===t.group&&n.index===t.index)),e.seriesConfigs.push(t)},unregisterSeries(t,n){e.seriesConfigs=e.seriesConfigs.filter(s=>!(s.group===t&&s.index===n))},toggleSeries(t,n){const s=e.seriesConfigs.find(o=>o.group===t&&o.index===n);s!=null&&(s.show=s.show===!1,e.revision++,e.renderer.invalidateSeries(t,n),e.scheduleRedraw())},setFocus(t){e.focusedSeries=t,e.scheduleRedraw()},setSize(t,n){e.width=t,e.height=n,e.canvas&&(e.canvas.width=t*e.pxRatio,e.canvas.height=n*e.pxRatio,e.canvas.style.width=`${t}px`,e.canvas.style.height=`${n}px`),e.renderer.clearCache(),e.scheduleRedraw()},scheduleRedraw(){e.scheduler.mark(Z.Full)},scheduleCursorRedraw(){e.scheduler.mark(Z.Cursor)},subscribe(t){return e.listeners.add(t),()=>{e.listeners.delete(t)}},redraw(){const{scaleManager:t,dataStore:n,renderer:s,seriesConfigs:o,width:i,height:l,pxRatio:r,canvas:a,scheduler:c}=e;if(a==null||i===0||l===0)return;const u=a.getContext("2d");if(u==null)return;s.setContext(u,r);const f=(c.dirty&~(Z.Cursor|Z.Select))===0,g=h=>t.getScale(h);if(f&&s.restoreSnapshot(u)){if(lt(u,e.cursorManager.state,e.plotBox,r,n.data,o,g,h=>t.getGroupXScaleKey(h)),it(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const h=Fe(u,e.plotBox,r,g);for(const I of e.cursorDrawHooks)try{I(h,e.cursorManager.state)}catch(P){console.warn("[uPlot+] draw hook error:",P)}u.restore()}for(const h of e.listeners)h();return}t.autoRangeX(n.data),n.updateWindows(h=>{const I=t.getGroupXScaleKey(h);return I!=null?t.getScale(I):void 0});const x=o.map(h=>({group:h.group,index:h.index,yScale:h.yScale}));t.autoRange(n.data,x,n),Fn(e),e.axisStates.length>0?e.plotBox=Sn(i,l,e.axisStates,g):e.plotBox={left:10,top:10,width:i-20,height:l-20},u.clearRect(0,0,i*r,l*r),e.axisStates.length>0&&Cn(u,e.axisStates,g,e.plotBox,r);const M=[];for(const h of o){const I=t.getGroupXScaleKey(h.group),P=I!=null?t.getScale(I):void 0,R=t.getScale(h.yScale);P==null||R==null||M.push({config:h,dataX:n.getXValues(h.group),dataY:n.getYValues(h.group,h.index),xScale:P,yScale:R,window:n.getWindow(h.group)})}u.save(),u.scale(r,r),u.beginPath(),u.rect(e.plotBox.left,e.plotBox.top,e.plotBox.width,e.plotBox.height),u.clip();for(let h=0;h<M.length;h++){const I=M[h];I!=null&&(e.focusedSeries!=null&&h!==e.focusedSeries?(u.globalAlpha=e.focusAlpha,s.drawSeries(I,e.plotBox,1),u.globalAlpha=1):s.drawSeries(I,e.plotBox,1))}const L=new Map;for(const h of o)L.set(`${h.group}-${h.index}`,h);for(const h of e.bandConfigs){const I=t.getGroupXScaleKey(h.group),P=I!=null?t.getScale(I):void 0,R=L.get(`${h.group}-${h.series[0]}`),T=L.get(`${h.group}-${h.series[1]}`);if(P==null||R==null||T==null)continue;const v=t.getScale(R.yScale);if(v==null)continue;const[S,b]=n.getWindow(h.group),C=h.series[0],D=h.series[1];let p=s.getCachedBandPath(h.group,C,D,S,b);p==null&&(p=Rn(n.getXValues(h.group),n.getYValues(h.group,C),n.getYValues(h.group,D),P,v,e.plotBox,r,S,b)??void 0,p!=null&&s.setCachedBandPath(h.group,C,D,S,b,p)),p!=null&&Dn(u,h,p)}for(const h of M){const I=h.config;if(I.show===!1)continue;const P=I.points,R=I.width??1,T=(P==null?void 0:P.size)??3+R*2,v=(P==null?void 0:P.space)??T*2,[S,b]=h.window;Ln(P==null?void 0:P.show,I.group,I.index,S,b,e.plotBox.width,v)&&Pn(u,h.dataX,h.dataY,h.xScale,h.yScale,e.plotBox,r,S,b,P,T,(typeof I.stroke=="string"?I.stroke:null)??"#000")}if(u.restore(),e.drawHooks.size>0){u.save(),u.beginPath(),u.rect(e.plotBox.left*r,e.plotBox.top*r,e.plotBox.width*r,e.plotBox.height*r),u.clip(),u.scale(r,r);const h=Fe(u,e.plotBox,r,g);for(const I of e.drawHooks)try{I(h)}catch(P){console.warn("[uPlot+] draw hook error:",P)}u.restore()}if(e.cursorManager.state.left>=0&&(s.saveSnapshot(u,i*r,l*r),e.cursorManager.update(e.cursorManager.state.left,e.cursorManager.state.top,e.plotBox,n.data,o,g,h=>n.getWindow(h),h=>t.getGroupXScaleKey(h))),lt(u,e.cursorManager.state,e.plotBox,r,n.data,o,g,h=>t.getGroupXScaleKey(h)),it(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const h=Fe(u,e.plotBox,r,g);for(const I of e.cursorDrawHooks)try{I(h,e.cursorManager.state)}catch(P){console.warn("[uPlot+] draw hook error:",P)}u.restore()}for(const h of e.listeners)h();if(e._prevScaleRanges.size>0&&e.eventCallbacks.onScaleChange!=null)for(const h of t.getAllScales()){if(h.min==null||h.max==null)continue;const I=e._prevScaleRanges.get(h.id);if(I==null||I.min!==h.min||I.max!==h.max)try{e.eventCallbacks.onScaleChange(h.id,h.min,h.max)}catch(P){console.warn("[uPlot+] event callback error:",P)}}e._prevScaleRanges.clear();for(const h of t.getAllScales())h.min!=null&&h.max!=null&&e._prevScaleRanges.set(h.id,{min:h.min,max:h.max})}};return e.scheduler.onRedraw(()=>e.redraw()),e}function Fn(e){const{axisConfigs:t,axisStates:n}=e,s=new Map;for(const o of n)s.set(`${o.config.scale}:${o.config.side}`,o);e.axisStates=t.map(o=>{const i=`${o.scale}:${o.side}`,l=s.get(i);return l!=null?(l.config=o,l):rn(o)})}function Hn(){const e=z.useRef(null);return e.current===null&&(e.current=zn()),e.current}const bt=z.createContext(null);function ee(){const e=z.useContext(bt);if(!e)throw new Error("useChart must be used within a <Chart> component");return e}function En(e,t){z.useEffect(()=>{if(t!=null)return Gn(e,t)},[e,t])}function Gn(e,t){let n=null;const s={show:!1,left:0,top:0,width:0,height:0};let o=null,i=null,l=!1;function r(p){const m=t.getBoundingClientRect(),w=e.plotBox,y=p.clientX-m.left-w.left,k=p.clientY-m.top-w.top;return{cx:y,cy:k}}function a(p,m){const w=e.plotBox;return p>=0&&p<=w.width&&m>=0&&m<=w.height}function c(p,m){const w=t.getBoundingClientRect(),y=p-w.left,k=m-w.top,A=e.plotBox;for(const F of e.axisStates){const H=F.config,E=H.side;if(F._size<=0)continue;const W=k>=A.top&&k<=A.top+A.height,j=y>=A.left&&y<=A.left+A.width;if(E===X.Left&&y<A.left&&W||E===X.Right&&y>A.left+A.width&&W||E===X.Top&&k<A.top&&j||E===X.Bottom&&k>A.top+A.height&&j){const q=he(E);return{scaleId:H.scale,ori:q}}}return null}function u(p,m,w){const y=e.cursorManager.state;let k=null;if(y.activeGroup>=0&&y.activeDataIdx>=0){const A=e.dataStore.data[y.activeGroup];if(A!=null){const F=A.x[y.activeDataIdx],H=A.series[y.activeSeriesIdx],E=H!=null?H[y.activeDataIdx]:void 0;if(F!=null&&E!=null){const $=e.plotBox,W=e.scaleManager.getGroupXScaleKey(y.activeGroup),j=W!=null?e.scaleManager.getScale(W):void 0,K=e.seriesConfigs.find(Ye=>Ye.group===y.activeGroup&&Ye.index===y.activeSeriesIdx),q=K!=null?e.scaleManager.getScale(K.yScale):void 0;let de=m,Re=w;(j==null?void 0:j.min)!=null&&j.max!=null&&(de=V(F,j,$.width,$.left)-$.left),(q==null?void 0:q.min)!=null&&q.max!=null&&(Re=V(E,q,$.height,$.top)-$.top);const je=m-de,Xe=w-Re;k={group:y.activeGroup,seriesIdx:y.activeSeriesIdx,dataIdx:y.activeDataIdx,xVal:F,yVal:E,pxX:de,pxY:Re,dist:Math.sqrt(je*je+Xe*Xe)}}}}return{plotX:m,plotY:w,point:k,srcEvent:p}}function d(p){const m=e.plotBox,w=p.left/m.width,y=(p.left+p.width)/m.width,k={};for(const A of e.scaleManager.getAllScales()){if(A.ori!==_.Horizontal||A.min==null||A.max==null)continue;const F=te(m.left+w*m.width,A,m.width,m.left),H=te(m.left+y*m.width,A,m.width,m.left);k[A.id]={min:Math.min(F,H),max:Math.max(F,H)}}return{left:w,right:y,ranges:k}}function f(){const p=e.eventCallbacks.onScaleChange;if(p!=null)for(const m of e.scaleManager.getAllScales()){if(m.min==null||m.max==null)continue;const w=e._prevScaleRanges.get(m.id);(w==null||w.min!==m.min||w.max!==m.max)&&p(m.id,m.min,m.max)}}function g(p,m){if(i!=null){const A=t.getBoundingClientRect(),F=p.clientY-A.top,H=e.plotBox,E=(F-i.startY)/H.height,$=i.startMax-i.startMin,W=e.scaleManager.getScale(i.scaleId);W!=null&&(W.min=i.startMin+E*$,W.max=i.startMax+E*$,W.auto=!1,le(W),e.renderer.clearCache(),e.scheduleRedraw());return}const w=r(p);if(w==null)return;const{cx:y,cy:k}=w;if(!a(y,k)&&n==null){e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),e.scheduleCursorRedraw();return}if(e.cursorManager.update(y,k,e.plotBox,e.dataStore.data,e.seriesConfigs,A=>e.scaleManager.getScale(A),A=>e.dataStore.getWindow(A),A=>e.scaleManager.getGroupXScaleKey(A)),e.focusAlpha<1){const A=e.cursorManager.state;if(A.activeGroup>=0&&A.activeSeriesIdx>=0){const F=e.seriesConfigs.findIndex(H=>H.group===A.activeGroup&&H.index===A.activeSeriesIdx);F>=0&&e.focusedSeries!==F&&(e.focusedSeries=F,e.scheduleRedraw())}}if(m!=null&&e.eventCallbacks.onCursorMove!=null&&a(y,k))try{e.eventCallbacks.onCursorMove(u(m,y,k))}catch(A){console.warn("[uPlot+] event callback error:",A)}if(n!=null){const A=n.x,F=e.plotBox,H=Math.max(0,Math.min(y,F.width));s.show=!0,s.left=Math.min(A,H),s.top=0,s.width=Math.abs(H-A),s.height=F.height,e.selectState=s}n!=null?e.scheduler.mark(Z.Cursor|Z.Select):e.scheduleCursorRedraw()}function x(p){g(p,p)}function M(p){if(p.button!==0)return;const m=c(p.clientX,p.clientY);if(m!=null&&m.ori===_.Vertical){const y=e.scaleManager.getScale(m.scaleId);if(y!=null&&y.min!=null&&y.max!=null){const k=t.getBoundingClientRect();i={scaleId:m.scaleId,startY:p.clientY-k.top,startMin:y.min,startMax:y.max},p.preventDefault();return}}const w=r(p);w!=null&&a(w.cx,w.cy)&&(n={x:w.cx,y:w.cy},l=!1,s.show=!1,s.left=0,s.width=0,e.selectState=s)}function L(p){if(i!=null){f(),i=null;return}if(n!=null){if(s.width>5){l=!0;let m=!0;if(e.eventCallbacks.onSelect!=null){const w=d(s);let y;try{y=e.eventCallbacks.onSelect(w)}catch(k){console.warn("[uPlot+] event callback error:",k)}y===!1&&(m=!1)}m&&(S(s),f())}n=null,s.show=!1,s.left=0,s.width=0,e.selectState=s,e.scheduleRedraw()}}function h(p){L()}function I(p){if(l){l=!1;return}const m=e.eventCallbacks.onClick;if(m==null)return;const w=r(p);if(w!=null&&a(w.cx,w.cy))try{m(u(p,w.cx,w.cy))}catch(y){console.warn("[uPlot+] event callback error:",y)}}function P(p){const m=e.eventCallbacks.onContextMenu;if(m==null)return;const w=r(p);if(w!=null&&a(w.cx,w.cy)){p.preventDefault();try{m(u(p,w.cx,w.cy))}catch(y){console.warn("[uPlot+] event callback error:",y)}}}function R(p){var m,w;e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),n!=null&&(n=null,s.show=!1,s.width=0,e.selectState=s),i!=null&&(i=null),e.scheduleCursorRedraw();try{(w=(m=e.eventCallbacks).onCursorLeave)==null||w.call(m)}catch(y){console.warn("[uPlot+] event callback error:",y)}}function T(p){if(e.eventCallbacks.onDblClick!=null){const m=r(p);if(m!=null&&a(m.cx,m.cy)){let w;try{w=e.eventCallbacks.onDblClick(u(p,m.cx,m.cy))}catch(y){console.warn("[uPlot+] event callback error:",y)}if(w===!1)return}}for(const m of e.scaleConfigs)e.scaleManager.addScale(m);e.renderer.clearCache(),e.scheduleRedraw()}function v(p){if(!e.wheelZoom)return;const m=r(p);if(m==null||!a(m.cx,m.cy))return;p.preventDefault();const w=Math.max(.1,Math.min(10,1-p.deltaY*.001)),y=e.plotBox;for(const k of e.scaleManager.getAllScales()){if(k.ori!==_.Horizontal||k.min==null||k.max==null)continue;const A=te(m.cx+y.left,k,y.width,y.left),F=A-(A-k.min)*w,H=A+(k.max-A)*w;k.min=Math.min(F,H),k.max=Math.max(F,H),k.auto=!1,le(k)}e.renderer.clearCache(),e.scheduleRedraw(),f()}function S(p){const m=e.plotBox,w=p.left/m.width,y=(p.left+p.width)/m.width;for(const k of e.scaleManager.getAllScales()){if(k.ori!==_.Horizontal||k.min==null||k.max==null)continue;const A=te(m.left+w*m.width,k,m.width,m.left),F=te(m.left+y*m.width,k,m.width,m.left);k.min=Math.min(A,F),k.max=Math.max(A,F),k.auto=!1,le(k)}e.renderer.clearCache()}function b(p){if(p.touches.length===2){const y=p.touches[0],k=p.touches[1],A=k.clientX-y.clientX,F=k.clientY-y.clientY;o={dist:Math.sqrt(A*A+F*F),midX:(y.clientX+k.clientX)/2,midY:(y.clientY+k.clientY)/2},n=null;return}const m=p.touches[0];if(m==null)return;const w=r(m);w!=null&&a(w.cx,w.cy)&&(n={x:w.cx,y:w.cy},l=!1)}function C(p){if(p.touches.length===2&&o!=null){p.preventDefault();const w=p.touches[0],y=p.touches[1],k=y.clientX-w.clientX,A=y.clientY-w.clientY,F=Math.sqrt(k*k+A*A),H=F/o.dist,E=t.getBoundingClientRect(),$=e.plotBox,W=o.midX-E.left-$.left;for(const j of e.scaleManager.getAllScales()){if(j.ori!==_.Horizontal||j.min==null||j.max==null)continue;const K=te(W+$.left,j,$.width,$.left),q=K-(K-j.min)/H,de=K+(j.max-K)/H;j.min=Math.min(q,de),j.max=Math.max(q,de),j.auto=!1,le(j)}o.dist=F,e.renderer.clearCache(),e.scheduleRedraw(),f();return}const m=p.touches[0];m!=null&&(g(m,p),n!=null&&p.preventDefault())}function D(p){if(o!=null){o=null;return}p.changedTouches[0]!=null&&L()}return t.addEventListener("mousemove",x),t.addEventListener("mousedown",M),t.addEventListener("mouseup",h),t.addEventListener("click",I),t.addEventListener("contextmenu",P),t.addEventListener("mouseleave",R),t.addEventListener("dblclick",T),t.addEventListener("wheel",v,{passive:!1}),t.addEventListener("touchstart",b,{passive:!0}),t.addEventListener("touchmove",C,{passive:!1}),t.addEventListener("touchend",D),()=>{t.removeEventListener("mousemove",x),t.removeEventListener("mousedown",M),t.removeEventListener("mouseup",h),t.removeEventListener("click",I),t.removeEventListener("contextmenu",P),t.removeEventListener("mouseleave",R),t.removeEventListener("dblclick",T),t.removeEventListener("wheel",v),t.removeEventListener("touchstart",b),t.removeEventListener("touchmove",C),t.removeEventListener("touchend",D)}}const He=new Map;function _n(e){let t=He.get(e);return t==null&&(t=new Vn(e),He.set(e,t)),t}class Vn{constructor(t){this.members=new Set,this.publishing=!1,this.syncedStores=new WeakSet,this.key=t}join(t){this.members.add(t)}leave(t){this.members.delete(t),this.members.size===0&&He.delete(this.key)}pub(t){if(this.publishing)return;if(this.syncedStores.has(t)){this.syncedStores.delete(t);return}this.publishing=!0;const n=t.cursorManager.state,{activeGroup:s,activeDataIdx:o}=n;if(s<0||o<0){for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.hide(),r.scheduleCursorRedraw());this.publishing=!1;return}const l=t.dataStore.getXValues(s)[o];if(l==null){this.publishing=!1;return}for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.syncToValue(l,r),r.scheduleCursorRedraw());this.publishing=!1}}function $n(e,t){z.useEffect(()=>{if(t==null)return;const n=_n(t);n.join(e);let s=-1,o=-1;const i=e.subscribe(()=>{const{activeGroup:l,activeDataIdx:r}=e.cursorManager.state;l===s&&r===o||(s=l,o=r,n.pub(e))});return()=>{i(),n.leave(e)}},[e,t])}function $e({width:e,height:t,data:n,children:s,className:o,pxRatio:i,onDraw:l,onCursorDraw:r,syncKey:a,cursor:c,onClick:u,onContextMenu:d,onDblClick:f,onCursorMove:g,onCursorLeave:x,onScaleChange:M,onSelect:L}){var m;const h=Hn(),[I,P]=z.useState(null),R=i??(typeof window<"u"&&window.devicePixelRatio||1),T=(c==null?void 0:c.wheelZoom)??!1,v=((m=c==null?void 0:c.focus)==null?void 0:m.alpha)??((c==null?void 0:c.focus)!=null?.15:1);z.useEffect(()=>{h.wheelZoom=T,h.focusAlpha=v},[h,T,v]),h.eventCallbacks.onClick=u,h.eventCallbacks.onContextMenu=d,h.eventCallbacks.onDblClick=f,h.eventCallbacks.onCursorMove=g,h.eventCallbacks.onCursorLeave=x,h.eventCallbacks.onScaleChange=M,h.eventCallbacks.onSelect=L,En(h,I),$n(h,a);const S=z.useCallback(w=>{h.canvas=w,w&&h.scheduleRedraw()},[h]),b=z.useCallback(w=>{P(w)},[]);z.useEffect(()=>{h.pxRatio=R,h.setSize(e,t)},[h,e,t,R]),z.useEffect(()=>()=>{h.canvas=null,h.scheduler.cancel(),h.focusedSeries=null},[h]),z.useEffect(()=>{if(I==null||typeof ResizeObserver>"u")return;const w=new ResizeObserver(y=>{const k=y[0];if(k==null)return;const{width:A,height:F}=k.contentRect;A>0&&F>0&&(A!==h.width||F!==h.height)&&h.setSize(Math.round(A),Math.round(F))});return w.observe(I),()=>{w.disconnect()}},[h,I]);const C=z.useRef(n);z.useEffect(()=>{if(n===C.current&&h.dataStore.data.length>0)return;C.current=n,h.dataStore.setData(n),h.renderer.clearCache();const w="x";h.scaleManager.getScale(w)||h.registerScale({id:w,auto:!0});for(let y=0;y<n.length;y++)h.scaleManager.setGroupXScale(y,w);h.scheduleRedraw()},[h,n]);const D=z.useRef(l);D.current=l,z.useEffect(()=>{const w=y=>{var k;(k=D.current)==null||k.call(D,y)};return h.drawHooks.add(w),()=>{h.drawHooks.delete(w)}},[h]);const p=z.useRef(r);return p.current=r,z.useEffect(()=>{const w=(y,k)=>{var A;(A=p.current)==null||A.call(p,y,k)};return h.cursorDrawHooks.add(w),()=>{h.cursorDrawHooks.delete(w)}},[h]),G.jsx(bt.Provider,{value:h,children:G.jsxs("div",{className:o,style:{position:"relative",display:"flex",flexDirection:"column",width:`${e}px`},children:[G.jsx("div",{ref:b,style:{position:"relative",width:`${e}px`,height:`${t}px`,cursor:"crosshair",order:0},children:G.jsx("canvas",{ref:S,style:{position:"absolute",left:0,top:0}})}),s]})})}function rt(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Bn(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const o of s)if(e[o]!==t[o])return!1;return!0}function Be(e,t){if(e===null)return!1;const n=e,s=t,o=Object.keys(n),i=Object.keys(s);if(o.length!==i.length)return!1;for(const l of i){const r=n[l],a=s[l];if(r!==a)if(rt(r)&&rt(a)){if(!Bn(r,a))return!1}else return!1}return!0}function Te(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const o=n.current;return t.registerScale({...o}),t.scheduleRedraw(),()=>{t.unregisterScale(o.id),t.scheduleRedraw()}},[t,e.id]);const s=z.useRef(null);return z.useEffect(()=>{Be(s.current,e)||(s.current=e,t.scaleConfigs=t.scaleConfigs.map(o=>o.id===e.id?{...e}:o),t.scaleManager.addScale({...e}),t.renderer.clearCache(),t.scheduleRedraw())}),null}function We(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const o=n.current;return t.registerSeries({...o,show:o.show??!0}),t.renderer.clearCache(),t.scheduleRedraw(),()=>{t.unregisterSeries(o.group,o.index),t.renderer.clearCache(),t.scheduleRedraw()}},[t,e.group,e.index]);const s=z.useRef(null);return z.useEffect(()=>{Be(s.current,e)||(s.current=e,t.seriesConfigs=t.seriesConfigs.map(o=>o.group===e.group&&o.index===e.index?{...e,show:e.show??!0}:o),t.renderer.invalidateSeries(e.group,e.index),t.scheduleRedraw())}),null}function Wn(e){return{...e,side:e.side??(e.scale==="x"?X.Bottom:X.Left),show:e.show??!0}}function Ie(e){const t=ee(),n=Wn(e),s=z.useRef(n);s.current=n,z.useEffect(()=>{const i=s.current;return t.axisConfigs=t.axisConfigs.filter(l=>!(l.scale===i.scale&&l.side===i.side)),t.axisConfigs.push(i),t.scheduleRedraw(),()=>{t.axisConfigs=t.axisConfigs.filter(l=>!(l.scale===i.scale&&l.side===i.side)),t.scheduleRedraw()}},[t,n.scale,n.side]);const o=z.useRef(null);return z.useEffect(()=>{Be(o.current,e)||(o.current=e,t.axisConfigs=t.axisConfigs.map(i=>i.scale===n.scale&&i.side===n.side?n:i),t.scheduleRedraw())}),null}function jn({series:e,group:t,fill:n,dir:s}){const o=ee(),i=z.useRef(null),l=e[0],r=e[1];return z.useEffect(()=>{const a={series:[l,r],group:t,fill:n,dir:s};return i.current!=null&&(o.bandConfigs=o.bandConfigs.filter(c=>c!==i.current)),i.current=a,o.bandConfigs.push(a),o.scheduleRedraw(),()=>{o.bandConfigs=o.bandConfigs.filter(c=>c!==i.current),i.current=null,o.scheduleRedraw()}},[o,l,r,t,n,s]),null}const Xn={width:12,height:3,borderRadius:1,display:"inline-block"},Yn={fontWeight:600},Un={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},Kn=z.memo(function({group:t,index:n,label:s,color:o,isHidden:i,valueStr:l,store:r}){const a=z.useCallback(()=>{r.toggleSeries(t,n)},[r,t,n]);return G.jsxs("span",{onClick:a,style:{...Un,opacity:i?.4:1},children:[G.jsx("span",{style:{...Xn,backgroundColor:o}}),G.jsx("span",{children:s}),l&&G.jsx("span",{style:Yn,children:l})]})});function Nn({show:e=!0,position:t="bottom",className:n}){const s=ee(),o=z.useRef({activeGroup:-1,activeDataIdx:-1,seriesCount:0,revision:-1}),i=z.useCallback(u=>s.subscribe(u),[s]),l=z.useCallback(()=>{const{activeGroup:u,activeDataIdx:d}=s.cursorManager.state,f=s.seriesConfigs.length,{revision:g}=s,x=o.current;if(x.activeGroup===u&&x.activeDataIdx===d&&x.seriesCount===f&&x.revision===g)return x;const M={activeGroup:u,activeDataIdx:d,seriesCount:f,revision:g};return o.current=M,M},[s]),r=z.useSyncExternalStore(i,l);if(!e)return null;const{activeGroup:a,activeDataIdx:c}=r;return G.jsx("div",{className:n,style:{display:"flex",flexWrap:"wrap",justifyContent:"center",order:t==="top"?-1:1,padding:"4px 0"},children:s.seriesConfigs.map(u=>{const d=typeof u.stroke=="string"?u.stroke:"#000";let f="";if(c>=0&&a>=0){const x=s.dataStore.getYValues(u.group,u.index)[c];x!=null&&(f=typeof x=="number"?x.toPrecision(4):String(x))}return G.jsx(Kn,{group:u.group,index:u.index,label:u.label??`Series ${u.index}`,color:d,isHidden:u.show===!1,valueStr:f,store:s},`${u.group}:${u.index}`)})})}function qn({show:e=!0,className:t,children:n,offset:s={}}){var w,y;const o=ee(),i=z.useRef({left:-10,top:-10,activeGroup:-1,activeDataIdx:-1,revision:-1}),l=z.useRef(null),r=z.useCallback(k=>o.subscribe(k),[o]),a=z.useCallback(()=>{const k=o.cursorManager.state,{revision:A}=o,F=i.current;if(F.left===k.left&&F.top===k.top&&F.activeGroup===k.activeGroup&&F.activeDataIdx===k.activeDataIdx&&F.revision===A)return F;const H={left:k.left,top:k.top,activeGroup:k.activeGroup,activeDataIdx:k.activeDataIdx,revision:A};return i.current=H,H},[o]),c=z.useSyncExternalStore(r,a);if(!e||c.activeDataIdx<0||c.activeGroup<0||c.left<0)return null;const{activeGroup:u,activeDataIdx:d}=c,f=o.plotBox,g=o.dataStore.data[u],x=g!=null?g.x[d]??null:null,M=x!=null?parseFloat(x.toPrecision(6)).toString():"",L=[];for(const k of o.seriesConfigs){if(k.show===!1)continue;const A=o.dataStore.getYValues(k.group,k.index),F=k.group===u?A[d]:null;L.push({label:k.label??`Series ${k.index}`,value:F,color:typeof k.stroke=="string"?k.stroke:"#000",group:k.group,index:k.index})}const h={x,xLabel:M,items:L,left:c.left+f.left,top:c.top+f.top},I=s.x??12,P=s.y??-12,R=((w=l.current)==null?void 0:w.offsetWidth)??0,T=((y=l.current)==null?void 0:y.offsetHeight)??0,v=c.left+f.left,S=c.top+f.top,b=f.left+f.width,C=f.top+f.height,D=Math.max(f.left,Math.min(v+I,b-R)),p=Math.max(f.top,Math.min(S+P,C-T)),m={position:"absolute",left:D,top:p,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100};return n?G.jsx("div",{ref:l,className:t,style:m,children:n(h)}):G.jsxs("div",{ref:l,className:t,style:{...m,background:"rgba(0,0,0,0.85)",color:"#fff",padding:"6px 10px",borderRadius:4,fontSize:12,fontFamily:"sans-serif",whiteSpace:"nowrap",lineHeight:1.5},children:[G.jsx("div",{style:{fontWeight:600,marginBottom:2},children:M}),L.map(k=>G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[G.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:k.color,display:"inline-block"}}),G.jsxs("span",{children:[k.label,":"]}),G.jsx("span",{style:{fontWeight:600},children:k.value!=null?k.value.toPrecision(4):"—"})]},`${k.group}:${k.index}`))]})}function On({width:e,height:t,data:n,onRangeChange:s,initialRange:o,className:i,colors:l,grips:r=!1}){const a=z.useRef(null),[c,u]=z.useState(()=>{if(o!=null&&n.length>0){const T=n[0];if(T!=null&&T.x.length>1){const v=T.x[0],b=T.x[T.x.length-1]-v;if(b>0)return[Math.max(0,(o[0]-v)/b),Math.min(1,(o[1]-v)/b)]}}return[.25,.75]}),d=z.useRef(null);z.useEffect(()=>{if(s==null||n.length===0)return;const T=n[0];if(T==null||T.x.length<2)return;const v=T.x[0],b=T.x[T.x.length-1]-v,C=v+c[0]*b,D=v+c[1]*b,p=d.current,m=Math.max(1e-10,Math.abs(D-C)*1e-12);p!=null&&Math.abs(p[0]-C)<m&&Math.abs(p[1]-D)<m||(d.current=[C,D],s(C,D))},[c,n,s]);const f=z.useRef(null),g=z.useCallback(T=>{const v=a.current;if(v==null)return 0;const S=v.getBoundingClientRect();return Math.max(0,Math.min(1,(T-S.left)/S.width))},[]),x=z.useCallback(T=>{const v=a.current;if(v==null)return;const S=g(T.clientX),b=v.getBoundingClientRect().width,C=b>0?8/b:0;let D;if(Math.abs(S-c[0])<C)D="left";else if(Math.abs(S-c[1])<C)D="right";else if(S>=c[0]&&S<=c[1])D="move";else{const p=c[1]-c[0],m=p/2,w=Math.max(0,Math.min(1-p,S-m));u([w,w+p]),D="move"}f.current={mode:D,startX:T.clientX,startFrac:[...c]},v.setPointerCapture(T.pointerId),T.preventDefault()},[c,g]),M=z.useCallback(T=>{const v=f.current;if(v==null)return;const S=g(T.clientX),b=g(v.startX),C=S-b;if(v.mode==="move"){const D=v.startFrac[1]-v.startFrac[0];let p=v.startFrac[0]+C;p=Math.max(0,Math.min(1-D,p)),u([p,p+D])}else if(v.mode==="left"){const D=Math.max(0,Math.min(v.startFrac[1]-.01,v.startFrac[0]+C));u([D,v.startFrac[1]])}else{const D=Math.min(1,Math.max(v.startFrac[0]+.01,v.startFrac[1]+C));u([v.startFrac[0],D])}},[g]),L=z.useCallback(T=>{f.current=null;const v=a.current;v!=null&&v.releasePointerCapture(T.pointerId)},[]),h=`${c[0]*100}%`,I=`${(c[1]-c[0])*100}%`,P=n[0],R=P!=null?P.series.length:0;return G.jsxs("div",{className:i,style:{position:"relative",width:e,height:t},children:[G.jsxs($e,{width:e,height:t,data:n,children:[G.jsx(Te,{id:"x"}),G.jsx(Te,{id:"y"}),G.jsx(Ie,{scale:"x",show:!1}),G.jsx(Ie,{scale:"y",show:!1}),Array.from({length:R},(T,v)=>G.jsx(We,{group:0,index:v,yScale:"y",stroke:l!=null&&l[v]!=null?l[v]:`hsl(${v*137}, 60%, 50%)`,width:1},v))]}),G.jsxs("div",{ref:a,onPointerDown:x,onPointerMove:M,onPointerUp:L,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[G.jsx("div",{style:{position:"absolute",top:0,left:0,width:h,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),G.jsx("div",{style:{position:"absolute",top:0,left:`${c[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),G.jsx("div",{style:{position:"absolute",top:0,left:h,width:I,height:"100%",borderLeft:"2px solid rgba(0,100,255,0.8)",borderRight:"2px solid rgba(0,100,255,0.8)",boxSizing:"border-box",cursor:"grab",pointerEvents:"none"},children:r&&G.jsxs(G.Fragment,{children:[G.jsx("div",{style:{position:"absolute",left:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}}),G.jsx("div",{style:{position:"absolute",right:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}})]})})]})]})}function ve(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const s=o=>n.current(o);return t.drawHooks.add(s),()=>{t.drawHooks.delete(s)}},[t])}function Zn(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const s=(o,i)=>n.current(o,i);return t.cursorDrawHooks.add(s),()=>{t.cursorDrawHooks.delete(s)}},[t])}function Jn({lanes:e,laneHeight:t=24,gap:n=2,scaleId:s="x"}){const o=ee();return ve(({ctx:i,plotBox:l,pxRatio:r})=>{const a=o.scaleManager.getScale(s);if(a==null||a.min==null||a.max==null)return;i.save(),i.beginPath(),i.rect(l.left*r,l.top*r,l.width*r,l.height*r),i.clip();const c=(t+n)*r,u=t*r,d=l.top*r;for(let f=0;f<e.length;f++){const g=e[f];if(g==null)continue;const x=d+f*c;i.fillStyle="#666",i.font=`${11*r}px sans-serif`,i.textAlign="right",i.textBaseline="middle",i.fillText(g.label,(l.left-6)*r,x+u/2);for(const M of g.segments){const L=V(M.start,a,l.width,l.left)*r,I=V(M.end,a,l.width,l.left)*r-L;I<=0||(i.fillStyle=M.color??"#4dabf7",i.fillRect(L,x,I,u),M.label!=null&&I>20*r&&(i.fillStyle="#fff",i.font=`${10*r}px sans-serif`,i.textAlign="center",i.textBaseline="middle",i.fillText(M.label,L+I/2,x+u/2,I-4*r)))}}i.restore()}),null}function Qn({data:e,width:t=150,height:n=30,stroke:s="#03a9f4",fill:o,lineWidth:i=1,paths:l,fillTo:r,className:a}){return G.jsx("div",{style:{pointerEvents:"none"},className:a,children:G.jsxs($e,{width:t,height:n,data:e,children:[G.jsx(Te,{id:"x"}),G.jsx(Te,{id:"y"}),G.jsx(Ie,{scale:"x",show:!1}),G.jsx(Ie,{scale:"y",show:!1}),G.jsx(We,{group:0,index:0,yScale:"y",stroke:s,fill:o,width:i,paths:l,fillTo:r})]})})}function St(e,t,n,s={}){const{ctx:o,plotBox:i}=e,l=V(n,t,i.height,i.top);o.beginPath(),o.moveTo(i.left,l),o.lineTo(i.left+i.width,l),o.strokeStyle=s.stroke??"red",o.lineWidth=s.width??1,s.dash&&o.setLineDash(s.dash),o.stroke(),s.dash&&o.setLineDash([])}function yt(e,t,n,s={}){const{ctx:o,plotBox:i}=e,l=V(n,t,i.width,i.left);o.beginPath(),o.moveTo(l,i.top),o.lineTo(l,i.top+i.height),o.strokeStyle=s.stroke??"red",o.lineWidth=s.width??1,s.dash&&o.setLineDash(s.dash),o.stroke(),s.dash&&o.setLineDash([])}function es(e,t,n,s,o,i,l={}){const{ctx:r,plotBox:a}=e,c=V(s,t,a.width,a.left),u=V(o,n,a.height,a.top);r.font=l.font??"12px sans-serif",r.fillStyle=l.fill??"#000",r.textBaseline="bottom",r.fillText(i,c,u-4)}function kt(e,t,n,s,o={}){const{ctx:i,plotBox:l}=e,r=V(s,t,l.height,l.top),a=V(n,t,l.height,l.top);i.fillStyle=o.fill??"rgba(255,0,0,0.1)",i.fillRect(l.left,Math.min(r,a),l.width,Math.abs(a-r)),o.stroke&&(i.strokeStyle=o.stroke,i.lineWidth=o.width??1,o.dash&&i.setLineDash(o.dash),i.strokeRect(l.left,Math.min(r,a),l.width,Math.abs(a-r)),o.dash&&i.setLineDash([]))}function ts(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=s.yScale??"y",i=n.getScale(o);if(i!=null&&(St(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const l=n.valToY(s.value,o);if(l==null)return;const{ctx:r,plotBox:a}=n;r.font=s.labelFont??"11px sans-serif",r.fillStyle=s.stroke??"red",r.textAlign="left",r.textBaseline="bottom",r.fillText(s.label,a.left+4,l-4)}}),null}function ns(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=s.xScale??"x",i=n.getScale(o);if(i!=null&&(yt(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const l=n.valToX(s.value,o);if(l==null)return;const{ctx:r,plotBox:a}=n;r.font=s.labelFont??"11px sans-serif",r.fillStyle=s.stroke??"red",r.textAlign="center",r.textBaseline="bottom",r.fillText(s.label,l,a.top-4)}}),null}function ss(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=n.getScale(s.yScale??"y");o!=null&&kt(n,o,s.yMin,s.yMax,{fill:s.fill,stroke:s.stroke,width:s.strokeWidth,dash:s.dash})}),null}function os(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=n.valToX(s.x,s.xScale??"x"),i=n.valToY(s.y,s.yScale??"y");if(o==null||i==null)return;const{ctx:l}=n;l.font=s.font??"12px sans-serif",l.fillStyle=s.fill??"#000",l.textAlign=s.align??"left",l.textBaseline=s.baseline??"bottom",l.fillText(s.text,o,i-4)}),null}function ls(e,t){const{window:n,batchSize:s=1}=t,o=t.autoStart??!0,[i,l]=z.useState(e),[r,a]=z.useState(!1),[c,u]=z.useState(0),d=z.useRef(0),f=z.useRef(0),g=z.useRef(0),x=z.useRef(new Map),M=z.useRef(0),L=z.useRef(n);L.current=n;const h=z.useCallback((T,v,...S)=>{let b=x.current.get(T);b==null&&(b={x:[],series:S.map(()=>[])},x.current.set(T,b)),b.x.push(...v);for(let C=0;C<S.length;C++){let D=b.series[C];D==null&&(D=[],b.series[C]=D),D.push(...S[C]??[])}M.current===0&&(M.current=requestAnimationFrame(()=>{M.current=0;const C=x.current;x.current=new Map;const D=L.current;l(p=>{const m=p.slice();for(const[w,{x:y,series:k}]of C){const A=m[w];if(A==null)continue;const F=A.x,H=Math.max(0,F.length+y.length-D),E=H>0?F.slice(H).concat(y):F.concat(y),$=A.series.map((W,j)=>{const K=W,q=k[j]??[];return H>0?K.slice(H).concat(q):K.concat(q)});m[w]={x:E,series:$}}return m})}))},[]),I=z.useCallback((T,...v)=>{h(0,T,...v)},[h]),P=z.useCallback(()=>{a(!0)},[]),R=z.useCallback(()=>{a(!1)},[]);return z.useEffect(()=>{if(!r){d.current!==0&&(cancelAnimationFrame(d.current),d.current=0);return}g.current=performance.now(),f.current=0;const T=v=>{f.current++;const S=v-g.current;S>=1e3&&(u(Math.round(f.current*1e3/S)),f.current=0,g.current=v),d.current=requestAnimationFrame(T)};return d.current=requestAnimationFrame(T),()=>{d.current!==0&&(cancelAnimationFrame(d.current),d.current=0)}},[r]),z.useEffect(()=>()=>{M.current!==0&&cancelAnimationFrame(M.current)},[]),z.useEffect(()=>{o&&a(!0)},[o]),{data:i,push:I,pushGroup:h,start:P,stop:R,running:r,fps:c}}function is(e){return(t,n,s,o,i,l,r,a,c,u,d,f,g)=>{const x=(g==null?void 0:g.align)??e??1,M=(g==null?void 0:g.spanGaps)??!1;if([c,u]=Ae(n,c,u),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const L=C=>f(V(C,s,i,r)),h=C=>f(V(C,o,l,a)),I=s.ori===_.Horizontal?Pe:Le,P={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},R=P.stroke;let T=!1;const v=d===Y.Forward?c:u;let S=h(n[v]),b=L(t[v]);I(R,b,S);for(let C=v;C>=c&&C<=u;C+=d){const D=n[C];if(D==null){D===null&&!M&&(T=!0);continue}const p=L(t[C]),m=h(D);if(x===1)I(R,p,S);else if(x===-1)I(R,b,m);else{const w=f((b+p)/2);I(R,w,S),I(R,w,m)}I(R,p,m),S=m,b=p}{const C=P.fill=new Path2D(R),D=(g==null?void 0:g.fillTo)??o.min??0,p=h(D);let m=r,w=r+i;d===Y.Backward&&([w,m]=[m,w]),I(C,w,p),I(C,m,p)}if(T){const C=_e(t,n,c,u,d,L);P.gaps=C,P.clip=Ve(C,s.ori,r,a,i,l)}return P}}function rs(){return(e,t,n,s,o,i,l,r,a,c,u,d,f)=>{const g=(f==null?void 0:f.barWidth)??.6,x=(f==null?void 0:f.barGap)??0,M=(f==null?void 0:f.barRadius)??0,L=(f==null?void 0:f.barGroupIdx)??0,h=(f==null?void 0:f.barGroupCount)??1,I=w=>d(V(w,n,o,l)),P=w=>d(V(w,s,i,r));let R=o;if(c>a){let w=1/0,y=-1;for(let k=a;k<=c;k++)if(t[k]!=null){if(y>=0){const A=e[k],F=e[y],H=Math.abs(I(A)-I(F));H<w&&(w=H)}y=k}w<1/0&&(R=w)}const T=R*(1-g),v=Math.max(0,T+x),S=Math.max(1,d(R-v)),b=h>1?Math.max(1,d(S/Math.max(1,h))):S,C=(f==null?void 0:f.fillTo)??s.min??0,D=P(C),p=new Path2D,m=n.ori===_.Horizontal;for(let w=u===Y.Forward?a:c;w>=a&&w<=c;w+=u){const y=t[w];if(y==null)continue;const k=I(e[w]),A=P(y),F=h>1?(L-(h-1)/2)*b:0,H=d(k-b/2+F),E=Math.min(A,D),W=Math.max(A,D)-E;if(W!==0)if(M>0){const j=Math.min(M*b,W/2);as(p,m,H,E,b,W,j,y<C)}else m?p.rect(H,E,b,W):p.rect(E,H,W,b)}return{stroke:p,fill:p,clip:null,band:null,gaps:null}}}function as(e,t,n,s,o,i,l,r){l=Math.min(l,o/2,i/2),t?r?(e.moveTo(n,s),e.lineTo(n+o,s),e.lineTo(n+o,s+i-l),e.arc(n+o-l,s+i-l,l,0,Math.PI/2),e.lineTo(n+l,s+i),e.arc(n+l,s+i-l,l,Math.PI/2,Math.PI),e.closePath()):(e.moveTo(n,s+i),e.lineTo(n,s+l),e.arc(n+l,s+l,l,Math.PI,Math.PI*1.5),e.lineTo(n+o-l,s),e.arc(n+o-l,s+l,l,Math.PI*1.5,0),e.lineTo(n+o,s+i),e.closePath()):r?(e.moveTo(s,n),e.lineTo(s,n+o),e.lineTo(s+i-l,n+o),e.arc(s+i-l,n+o-l,l,Math.PI/2,0,!0),e.lineTo(s+i,n+l),e.arc(s+i-l,n+l,l,0,-Math.PI/2,!0),e.closePath()):(e.moveTo(s+i,n),e.lineTo(s+l,n),e.arc(s+l,n+l,l,-Math.PI/2,Math.PI,!0),e.lineTo(s,n+o-l),e.arc(s+l,n+o-l,l,Math.PI,Math.PI/2,!0),e.lineTo(s+i,n+o),e.closePath())}function Ct(e){return(t,n,s,o,i,l,r,a,c,u,d,f,g)=>{const x=(g==null?void 0:g.spanGaps)??!1;if([c,u]=Ae(n,c,u),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const M=b=>f(V(b,s,i,r)),L=b=>f(V(b,o,l,a)),h=s.ori===_.Horizontal?Pe:Le,I=[],P=[];let R=!1;for(let b=d===Y.Forward?c:u;b>=c&&b<=u;b+=d){const C=n[b];C!=null?(I.push(M(t[b])),P.push(L(C))):C===null&&!x&&(R=!0)}const T=s.ori===_.Horizontal,v=e(I,P,T,f),S={stroke:v??new Path2D,fill:null,clip:null,band:null,gaps:null};if(v!=null){const b=S.fill=new Path2D(v),C=(g==null?void 0:g.fillTo)??o.min??0,D=L(C);let p=r,m=r+i;d===Y.Backward&&([m,p]=[p,m]),h(b,m,D),h(b,p,D)}if(R){const b=_e(t,n,c,u,d,M);S.gaps=b,S.clip=Ve(b,s.ori,r,a,i,l)}return S}}function cs(){return Ct(us)}const us=(e,t,n,s)=>{const o=e.length;if(o<2)return null;const i=new Path2D,l=e[0]??0,r=t[0]??0;if(n?i.moveTo(l,r):i.moveTo(r,l),o===2){const f=e[1]??0,g=t[1]??0;return n?i.lineTo(f,g):i.lineTo(g,f),i}const a=new Array(o),c=new Array(o-1),u=new Array(o-1),d=new Array(o-1);for(let f=0;f<o-1;f++)u[f]=(t[f+1]??0)-(t[f]??0),d[f]=(e[f+1]??0)-(e[f]??0),c[f]=d[f]!==0?(u[f]??0)/(d[f]??1):0;a[0]=c[0]??0;for(let f=1;f<o-1;f++){const g=c[f]??0,x=c[f-1]??0;if(g===0||x===0||x>0!=g>0)a[f]=0;else{const M=d[f]??1,L=d[f-1]??1;a[f]=3*(L+M)/((2*M+L)/x+(M+2*L)/g),isFinite(a[f]??0)||(a[f]=0)}}a[o-1]=c[o-2]??0;for(let f=0;f<o-1;f++){const g=d[f]??1,x=e[f]??0,M=t[f]??0,L=e[f+1]??0,h=t[f+1]??0,I=a[f]??0,P=a[f+1]??0,R=x+g/3,T=M+I*g/3,v=L-g/3,S=h-P*g/3;n?i.bezierCurveTo(R,T,v,S,L,h):i.bezierCurveTo(T,R,S,v,h,L)}return i};function fs(){return Ct(hs)}const hs=(e,t,n,s)=>{const o=e.length;if(o<2)return null;const i=new Path2D,l=s(e[0]??0),r=s(t[0]??0);if(n?i.moveTo(l,r):i.moveTo(r,l),o===2){const a=s(e[1]??0),c=s(t[1]??0);return n?i.lineTo(a,c):i.lineTo(c,a),i}for(let a=0;a<o-1;a++){const c=a===0?0:a-1,u=e[c]??0,d=t[c]??0,f=e[a]??0,g=t[a]??0,x=e[a+1]??0,M=t[a+1]??0,L=a+2<o?e[a+2]??0:x,h=a+2<o?t[a+2]??0:M,I=Math.hypot(u-f,d-g),P=Math.hypot(f-x,g-M),R=Math.hypot(x-L,M-h),T=Math.sqrt(R),v=R,S=Math.sqrt(P),b=P,C=Math.sqrt(I),D=I,p=2*D+3*C*S+b,m=2*v+3*T*S+b,w=3*C*(C+S),y=3*T*(T+S);let k,A,F,H;if(w>0){const E=1/w;k=(-b*u+p*f+D*x)*E,A=(-b*d+p*g+D*M)*E}else k=f,A=g;if(y>0){const E=1/y;F=(v*f+m*x-b*L)*E,H=(v*g+m*M-b*h)*E}else F=x,H=M;n?i.bezierCurveTo(k,A,F,H,x,M):i.bezierCurveTo(A,k,H,F,M,x)}return i};function ds(e=4){return(t,n,s,o,i,l,r,a,c,u,d,f,g)=>{const x=P=>f(V(P,s,i,r)),M=P=>f(V(P,o,l,a)),L=e/2,h=new Path2D,I=s.ori===_.Horizontal;for(let P=d===Y.Forward?c:u;P>=c&&P<=u;P+=d){const R=n[P];if(R==null)continue;const T=x(t[P]),v=M(R);I?(h.moveTo(T+L,v),h.arc(T,v,L,0,Math.PI*2)):(h.moveTo(v+L,T),h.arc(v,T,L,0,Math.PI*2))}return{stroke:h,fill:h,clip:null,band:null,gaps:null}}}function gs(e){return({ctx:t,plotBox:n,pxRatio:s})=>{const{xValues:o,open:i,high:l,low:r,close:a,xScale:c,yScale:u,upColor:d="#26a69a",downColor:f="#ef5350",bodyWidth:g=.6,wickWidth:x=1}=e;if(c.min==null||c.max==null||u.min==null||u.max==null)return;const M=o.length;if(M===0)return;const h=Math.max(2,n.width/M*g)*s/2;t.save();for(let I=0;I<M;I++){const P=o[I],R=i[I],T=l[I],v=r[I],S=a[I];if(P==null||R==null||T==null||v==null||S==null)continue;const b=V(P,c,n.width,n.left)*s,C=V(R,u,n.height,n.top)*s,D=V(T,u,n.height,n.top)*s,p=V(v,u,n.height,n.top)*s,m=V(S,u,n.height,n.top)*s,y=S>=R?d:f;t.strokeStyle=y,t.lineWidth=x*s,t.beginPath(),t.moveTo(b,D),t.lineTo(b,p),t.stroke();const k=Math.min(C,m),A=Math.abs(m-C);t.fillStyle=y,t.fillRect(b-h,k,h*2,Math.max(A,1*s))}t.restore()}}function ps(e,t,n=0){const s=t??e.series.map((c,u)=>u),o=e.x.length,i=[],l=new Float64Array(o);for(let c=0;c<s.length;c++){const u=s[c];if(u==null)continue;const d=e.series[u];if(d==null)continue;const f=new Array(o);for(let g=0;g<o;g++){const x=d[g];x!=null?(l[g]=l[g]+x,f[g]=l[g]):f[g]=null}i.push(f)}const r=[];for(let c=0;c<e.series.length;c++){const u=s.indexOf(c),d=u>=0?i[u]:void 0;d!=null?r.push(d):r.push(e.series[c]??[])}const a=[];for(let c=s.length-1;c>0;c--){const u=s[c],d=s[c-1];u!=null&&d!=null&&a.push({group:n,series:[u,d]})}return{group:{x:e.x,series:r},bands:a}}function ms(e){const t=new Set;for(const[i]of e)for(let l=0;l<i.length;l++){const r=i[l];r!=null&&t.add(r)}const n=Float64Array.from([...t].sort((i,l)=>i-l)),s=new Map;for(let i=0;i<n.length;i++){const l=n[i];l!=null&&s.set(l,i)}const o=[];for(const[i,l]of e){const r=new Array(n.length).fill(null);for(let a=0;a<i.length;a++){const c=i[a];if(c==null)continue;const u=s.get(c);u!=null&&(r[u]=l[a]??null)}o.push(r)}return[{x:n,series:o}]}function ws(e){const t=(e==null?void 0:e.decimals)??1;return n=>n.map(s=>{const o=Math.abs(s);return o>=1e9?(s/1e9).toFixed(t)+"B":o>=1e6?(s/1e6).toFixed(t)+"M":o>=1e3?(s/1e3).toFixed(t)+"K":s.toFixed(o>=1?0:t)})}function xs(e,t=0){return n=>n.map(s=>s.toFixed(t)+e)}function vs(e){const t=(e==null?void 0:e.utc)??!1;return n=>n.map(s=>t?Q(s,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):Q(s,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function Ms(e){const t=e!=null&&e.utc?"UTC":void 0,n=(e==null?void 0:e.format)??"short";return s=>s.map(o=>Q(o,{month:n},t))}function bs(e){const{tz:t,...n}=e??{};return s=>s.map(o=>Q(o,n,t))}function Ss(e,t=0){return n=>n.map(s=>{const o=Math.round(s)-t;return e[o]??String(s)})}function Tt(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(e);if(t)return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)];const n=/^#([0-9a-f])([0-9a-f])([0-9a-f])/i.exec(e);if(n)return[parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];const s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i.exec(e);return s?[Number(s[1]),Number(s[2]),Number(s[3])]:null}function ys(e,t=.8,n=0){const s=Tt(e);if(s==null)return{type:"linear",stops:[[0,e],[1,e]]};const[o,i,l]=s;return{type:"linear",stops:[[0,`rgba(${o},${i},${l},${t})`],[1,`rgba(${o},${i},${l},${n})`]]}}function ks(e,t){const n=Tt(e);if(n==null)return e;const[s,o,i]=n;return`rgba(${s},${o},${i},${t})`}function Cs(e,t=65,n=50){const s=[];for(let i=0;i<e;i++){const l=i*137.508%360;s.push(`hsl(${l.toFixed(1)},${t}%,${n}%)`)}return s}exports.AnnotationLabel=os;exports.Axis=Ie;exports.Band=jn;exports.Chart=$e;exports.Direction=Y;exports.Distribution=U;exports.HLine=ts;exports.Legend=Nn;exports.Orientation=_;exports.Region=ss;exports.Scale=Te;exports.Series=We;exports.Side=X;exports.SortOrder=me;exports.Sparkline=Qn;exports.Timeline=Jn;exports.Tooltip=qn;exports.VLine=ns;exports.ZoomRanger=On;exports.alignData=ms;exports.bars=rs;exports.catmullRom=fs;exports.drawCandlesticks=gs;exports.drawHLine=St;exports.drawLabel=es;exports.drawRegion=kt;exports.drawVLine=yt;exports.fadeGradient=ys;exports.fmtCompact=ws;exports.fmtDateStr=bs;exports.fmtHourMin=vs;exports.fmtLabels=Ss;exports.fmtMonthName=Ms;exports.fmtSuffix=xs;exports.linear=vt;exports.monotoneCubic=cs;exports.palette=Cs;exports.points=ds;exports.posToVal=te;exports.sideOrientation=he;exports.stackGroup=ps;exports.stepped=is;exports.useChart=ee;exports.useCursorDrawHook=Zn;exports.useDrawHook=ve;exports.useStreamingData=ls;exports.valToPos=V;exports.withAlpha=ks;
package/dist/index.js CHANGED
@@ -2395,6 +2395,7 @@ function us({
2395
2395
  position: "absolute",
2396
2396
  left: z,
2397
2397
  top: p,
2398
+ whiteSpace: "nowrap",
2398
2399
  pointerEvents: "none",
2399
2400
  zIndex: 100
2400
2401
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uplot-plus",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "High-performance React charting library with multi-x-axis support",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",