uplot-plus 0.3.2 → 0.5.3
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.
- package/README.md +107 -225
- package/dist/index.cjs +1 -1
- package/dist/index.js +2717 -2210
- package/dist/src/annotations.d.ts.map +1 -1
- package/dist/src/axes/layout.d.ts.map +1 -1
- package/dist/src/colors.d.ts.map +1 -1
- package/dist/src/components/Axis.d.ts +0 -3
- package/dist/src/components/Axis.d.ts.map +1 -1
- package/dist/src/components/Band.d.ts.map +1 -1
- package/dist/src/components/BoxWhisker.d.ts +24 -0
- package/dist/src/components/BoxWhisker.d.ts.map +1 -0
- package/dist/src/components/Candlestick.d.ts +18 -0
- package/dist/src/components/Candlestick.d.ts.map +1 -0
- package/dist/src/components/Chart.d.ts +1 -1
- package/dist/src/components/Chart.d.ts.map +1 -1
- package/dist/src/components/FloatingLegend.d.ts.map +1 -1
- package/dist/src/components/Heatmap.d.ts +14 -0
- package/dist/src/components/Heatmap.d.ts.map +1 -0
- package/dist/src/components/HoverLabel.d.ts.map +1 -1
- package/dist/src/components/Legend.d.ts.map +1 -1
- package/dist/src/components/Scale.d.ts +0 -3
- package/dist/src/components/Scale.d.ts.map +1 -1
- package/dist/src/components/Series.d.ts +0 -3
- package/dist/src/components/Series.d.ts.map +1 -1
- package/dist/src/components/Sparkline.d.ts.map +1 -1
- package/dist/src/components/Tooltip.d.ts.map +1 -1
- package/dist/src/components/Vector.d.ts +16 -0
- package/dist/src/components/Vector.d.ts.map +1 -0
- package/dist/src/components/ZoomRanger.d.ts.map +1 -1
- package/dist/src/components/annotations/HLine.d.ts.map +1 -1
- package/dist/src/components/annotations/Region.d.ts.map +1 -1
- package/dist/src/components/annotations/VLine.d.ts.map +1 -1
- package/dist/src/components/annotations/useAnnotationDraw.d.ts +8 -0
- package/dist/src/components/annotations/useAnnotationDraw.d.ts.map +1 -0
- package/dist/src/components/overlay/SeriesPanel.d.ts +1 -1
- package/dist/src/components/overlay/SeriesPanel.d.ts.map +1 -1
- package/dist/src/core/DataStore.d.ts.map +1 -1
- package/dist/src/core/Scale.d.ts +5 -0
- package/dist/src/core/Scale.d.ts.map +1 -1
- package/dist/src/core/ScaleManager.d.ts.map +1 -1
- package/dist/src/hooks/useChart.d.ts +33 -3
- package/dist/src/hooks/useChart.d.ts.map +1 -1
- package/dist/src/hooks/useChartStore.d.ts +51 -5
- package/dist/src/hooks/useChartStore.d.ts.map +1 -1
- package/dist/src/hooks/useInteraction.d.ts +1 -2
- package/dist/src/hooks/useInteraction.d.ts.map +1 -1
- package/dist/src/hooks/useRegisterConfig.d.ts +16 -0
- package/dist/src/hooks/useRegisterConfig.d.ts.map +1 -0
- package/dist/src/index.d.ts +14 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/math/lttb.d.ts +23 -0
- package/dist/src/math/lttb.d.ts.map +1 -0
- package/dist/src/math/utils.d.ts +2 -0
- package/dist/src/math/utils.d.ts.map +1 -1
- package/dist/src/paths/bars.d.ts +2 -0
- package/dist/src/paths/bars.d.ts.map +1 -1
- package/dist/src/paths/lttbLinear.d.ts +12 -0
- package/dist/src/paths/lttbLinear.d.ts.map +1 -0
- package/dist/src/paths/utils.d.ts +0 -5
- package/dist/src/paths/utils.d.ts.map +1 -1
- package/dist/src/rendering/drawRangeBox.d.ts +29 -0
- package/dist/src/rendering/drawRangeBox.d.ts.map +1 -0
- package/dist/src/time/timeIncrs.d.ts.map +1 -1
- package/dist/src/time/timeSplits.d.ts +1 -1
- package/dist/src/time/timeSplits.d.ts.map +1 -1
- package/dist/src/types/chart.d.ts +6 -31
- package/dist/src/types/chart.d.ts.map +1 -1
- package/dist/src/types/downsample.d.ts +11 -0
- package/dist/src/types/downsample.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +3 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/interaction.d.ts +62 -0
- package/dist/src/types/interaction.d.ts.map +1 -0
- package/dist/src/types/series.d.ts +1 -1
- package/dist/src/types/series.d.ts.map +1 -1
- package/package.json +4 -3
- package/dist/src/hooks/useStreamingData.d.ts +0 -48
- package/dist/src/hooks/useStreamingData.d.ts.map +0 -1
- package/dist/src/paths/candlestick.d.ts +0 -35
- package/dist/src/paths/candlestick.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react/jsx-runtime"),A=require("react");var Y=(e=>(e[e.Top=0]="Top",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left",e))(Y||{}),X=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e))(X||{}),N=(e=>(e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward",e))(N||{}),U=(e=>(e[e.Linear=1]="Linear",e[e.Ordinal=2]="Ordinal",e[e.Log=3]="Log",e[e.Asinh=4]="Asinh",e))(U||{}),xe=(e=>(e[e.Ascending=1]="Ascending",e[e.Descending=-1]="Descending",e[e.Unsorted=0]="Unsorted",e))(xe||{});function pe(e){return e%2}var te=(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))(te||{});const q=Math,Fe=q.PI,ge=q.abs,oe=q.floor,B=q.round,ke=q.ceil,We=q.min,be=q.max,ve=q.pow,tt=q.sign,ne=q.log10,Me=q.log2,Ut=(e,t=1)=>q.sinh(e)*t,je=(e,t=1)=>q.asinh(e/t),K=1/0,yt=Number.isInteger;function ze(e,t){return e[t]??0}function ae(e,t,n=0,s=t.length-1){let o;const r=s<=2147483647;for(;s-n>1;)o=r?n+s>>1:oe((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,kt=e=>e!=null&&e>0;function Tt(e){return(t,n,s)=>{let o=-1,r=-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])){r=l;break}return[o,r]}}const De=Tt(Ct),It=Tt(kt);function Kt(e,t,n,s=xe.Unsorted,o=!1){const r=o?It:De,l=o?kt:Ct,[i,a]=r(e,t,n);let h=e[i]??K,c=e[i]??-K;if(i>-1)if(s===xe.Ascending)h=e[i]??K,c=e[a]??-K;else if(s===xe.Descending)h=e[a]??K,c=e[i]??-K;else for(let d=i;d<=a;d++){const u=e[d];u!=null&&l(u)&&(u<h?h=u:u>c&&(c=u))}return[h,c]}function ce(e,t=0){if(yt(e))return e;const n=10**t,s=e*n*(1+Number.EPSILON);return B(s)/n}const Se=new Map;function Zt(e){return(String(e).split(".")[1]??"").length}const qt=/\.\d*?(?=9{6,}|0{6,})/gm;function Te(e){if(yt(e)||Se.has(e))return e;const t=`${e}`,n=t.match(qt);if(n==null)return e;const s=n[0].length-1;if(t.indexOf("e-")!==-1){const o=t.split("e"),r=o[0]??"0",l=o[1]??"0";return+`${Te(+r)}e${l}`}return ce(e,s)}function Xe(e,t,n=!0){return n?Te(ke(Te(e/t))*t):ke(e/t)*t}function Lt(e,t,n=!0){return n?Te(oe(Te(e/t))*t):oe(e/t)*t}function At(e,t,n,s){const o=[],r=s.map(Zt);for(let l=t;l<n;l++){const i=ge(l);for(let a=0;a<s.length;a++){const h=s[a]??0,c=r[a]??0,d=+`${h}e${l}`,u=(l>=0?0:i)+(l>=c?0:c),f=d;o.push(f),Se.set(f,u)}}return o}function Z(e,t,n){return We(be(e,t),n)}const Jt=new Intl.NumberFormat,Pt=e=>Jt.format(e);function nt(e,t,n){for(;t<=n;){if(e[t]!=null)return!0;t++}return!1}const Qt=.1,le={mode:3,pad:Qt,soft:null},Ce={pad:0,soft:null,mode:0},en={min:Ce,max:Ce};function He(e,t,n,s){let o;typeof n=="number"?(Ce.pad=n,Ce.soft=null,Ce.mode=0,o=en):o=n;const r=o.min,l=o.max,i=r.pad,a=l.pad,h=r.hard??-K,c=l.hard??K,d=r.soft??K,u=l.soft??-K,f=r.mode,m=l.mode;let S=t-e;const L=ne(S),g=be(ge(e),ge(t)),b=ne(g),P=ge(b-L);(S<1e-24||P>10)&&(S=0,(e===0||t===0)&&(S=1e-24));const k=S||g||1e3,z=ne(k),D=ve(10,oe(z)),M=k*(S===0?e===0?.1:1:i),y=ce(Lt(e-M,D/10),24),I=f===1||f===3&&y<=d||f===2&&y>=d,R=e>=d&&I?d:K,v=be(h,y<R&&e>=R?R:We(R,y)),p=k*(S===0?t===0?.1:1:a),x=ce(Xe(t+p,D/10),24),w=m===1||m===3&&x>=u||m===2&&x<=u,T=t<=u&&w?u:-K,C=We(c,x>T&&t<=T?T:be(T,x));return v===C&&v===0?[-1,1]:[v,C]}function tn(e,t,n,s){n===2&&(s=!0);const o=tt(e),r=tt(t);e===t&&(o===-1?(e*=n,t/=n):(e/=n,t*=n));const l=n===10?ne:Me,i=o===1?oe:ke,a=r===1?ke:oe,h=l(ge(e)),c=l(ge(t)),d=i(h),u=a(c);let f=ve(n,d),m=ve(n,u);return n===10&&(d<0&&(f=ce(f,-d)),u<0&&(m=ce(m,-u))),s?(e=f*o,t=m*r):(e=Lt(e,ve(n,oe(h)),!1),t=Xe(t,ve(n,oe(c)),!1)),[e,t]}function st(e){return(ne((e^e>>31)-(e>>31))|0)+1}function nn(e,t,n,s,o){const r=be(st(e),st(t)),l=t-e;let i=be(0,ae(o/s*l,n)-1);do{const a=n[i]??0,h=s*a/l;if(h>=o*.9&&r+(a<5?Se.get(a)??0:0)<=17)return[a,h]}while(++i<n.length);return[0,0]}function sn(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"?X.Horizontal:X.Vertical),dir:e.dir??N.Forward,time:e.time??!1,auto:e.auto??!0,range:e.range??null,_discrete:!1,_cfgMin:e.min??null,_cfgMax:e.max??null,_min:null,_max:null}}function he(e){e._min=null,e._max=null}function Rt(e){if(e._min!=null)return e._min;const{min:t,distr:n}=e;if(t==null)return 0;if(n===U.Log){t<=0&&console.warn(`[uPlot+] Log scale "${e.id}": min value ${t} <= 0, clamping to 1e-10`);const s=t>0?t:1e-10;e._min=(e.log===10?ne:Me)(s)}else n===U.Asinh?e._min=je(t,e.asinh):e._min=t;return e._min}function Dt(e){if(e._max!=null)return e._max;const{max:t,distr:n}=e;if(t==null)return 0;if(n===U.Log){t<=0&&console.warn(`[uPlot+] Log scale "${e.id}": max value ${t} <= 0, clamping to 1e-10`);const s=t>0?t:1e-10;e._max=(e.log===10?ne:Me)(s)}else n===U.Asinh?e._max=je(t,e.asinh):e._max=t;return e._max}function on(e,t){if(t.min==null||t.max==null)return 0;const n=Rt(t),o=Dt(t)-n;if(o===0)return 0;const{distr:r}=t;if(r===U.Log){const l=t.log===10?ne:Me,i=e>0?e:1e-10;return(l(i)-n)/o}return r===U.Asinh?(je(e,t.asinh)-n)/o:(e-n)/o}function ln(e,t){if(t.min==null||t.max==null)return 0;const n=Rt(t),s=Dt(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?Ut(n+e*(s-n),t.asinh):n+e*(s-n)}function j(e,t,n,s){const o=on(e,t);let r;return t.ori===X.Horizontal?r=t.dir===N.Forward?o:1-o:r=t.dir===N.Forward?1-o:o,s+r*n}function se(e,t,n,s){if(n===0)return t.min??0;let o=(e-s)/n;return t.ori===X.Horizontal?t.dir===N.Backward&&(o=1-o):t.dir!==N.Backward&&(o=1-o),ln(o,t)}class rn{constructor(){this.scales=new Map,this.groupXScales=new Map}addScale(t){this.scales.set(t.id,sn(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,he(o))}autoRangeX(t){var s,o,r,l,i,a;const n=new Map;for(const[h,c]of this.groupXScales){const d=this.scales.get(c);if(!d||!d.auto)continue;const u=t[h];if(!u||u.x.length===0)continue;const f=u.x[0],m=u.x[u.x.length-1];if(f==null||m==null)continue;const S=n.get(c);S?(S.dataMin=Math.min(S.dataMin,f),S.dataMax=Math.max(S.dataMax,m),S.groups.push(h)):n.set(c,{dataMin:f,dataMax:m,groups:[h]})}for(const[h,{dataMin:c,dataMax:d,groups:u}]of n){const f=this.scales.get(h);if(!f)continue;let m=!0,S=K;for(const L of u){const g=t[L];if(g){for(let b=0;b<g.x.length;b++)if(Number.isInteger(g.x[b])||(m=!1),b>0){const P=g.x[b]-g.x[b-1];P>0&&P<S&&(S=P)}}}if(f._discrete=m,f.range){const[L,g]=He(c,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:((r=f.range.min)==null?void 0:r.mode)??0},max:{pad:((l=f.range.max)==null?void 0:l.pad)??0,soft:((i=f.range.max)==null?void 0:i.soft)??null,mode:((a=f.range.max)==null?void 0:a.mode)??0}});f.min=L,f.max=g}else if(c===d)[f.min,f.max]=He(c,d,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}});else if(S<K){const L=S/2;f.min=c-L,f.max=d+L}else f.min=c,f.max=d;f._cfgMin!=null&&(f.min=f._cfgMin),f._cfgMax!=null&&(f.max=f._cfgMax),he(f)}}autoRange(t,n,s){var l,i,a,h,c,d;const o=new Map,r=new Map;for(const{group:u,index:f,yScale:m}of n){const S=t[u];if(!S)continue;const L=S.series[f];if(!L||L.length===0)continue;const g=s.windows.get(u),b=g?g[0]:0,P=g?g[1]:L.length-1,k=this.scales.get(m),z=(k==null?void 0:k.distr)===U.Log,[D,M]=s.getCachedMinMax(u,f,b,P,0,z),y=o.get(m),I=r.get(m);o.set(m,y!=null?Math.min(y,D):D),r.set(m,I!=null?Math.max(I,M):M)}for(const[u,f]of o){const m=this.scales.get(u);if(!m||!m.auto)continue;const S=r.get(u)??-K;if(f===K)continue;let L,g;if(m.distr===U.Log)[L,g]=tn(f,S,m.log,!1);else{const b=m.range??{min:le,max:le};[L,g]=He(f,S,{min:{pad:((l=b.min)==null?void 0:l.pad)??le.pad,soft:((i=b.min)==null?void 0:i.soft)??le.soft,mode:((a=b.min)==null?void 0:a.mode)??le.mode},max:{pad:((h=b.max)==null?void 0:h.pad)??le.pad,soft:((c=b.max)==null?void 0:c.soft)??le.soft,mode:((d=b.max)==null?void 0:d.mode)??le.mode}})}m._cfgMin!=null&&(L=m._cfgMin),m._cfgMax!=null&&(g=m._cfgMax),m.min=L,m.max=g,he(m)}}}const an=1024;class cn{constructor(t,n=an){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:r}=this;for(let l=0;l<s;l++){const i=l*n,a=Math.min(i+n,r);let h=1/0,c=-1/0;for(let d=i;d<a;d++){const u=t[d];u!=null&&(u<h&&(h=u),u>c&&(c=u))}o[l*2]=h,o[l*2+1]=c}}rangeMinMax(t,n){const{data:s,blockSize:o,blocks:r}=this;let l=1/0,i=-1/0;const a=Math.floor(t/o),h=Math.floor(n/o);if(a===h){for(let u=t;u<=n;u++){const f=s[u];f!=null&&(f<l&&(l=f),f>i&&(i=f))}return[l,i]}const c=(a+1)*o-1;for(let u=t;u<=c;u++){const f=s[u];f!=null&&(f<l&&(l=f),f>i&&(i=f))}for(let u=a+1;u<h;u++){const f=r[u*2]??1/0,m=r[u*2+1]??-1/0;f<l&&(l=f),m>i&&(i=m)}const d=h*o;for(let u=d;u<=n;u++){const f=s[u];f!=null&&(f<l&&(l=f),f>i&&(i=f))}return[l,i]}updateBlock(t){const{data:n,blockSize:s,blocks:o,len:r}=this;if(t>=this.nBlocks)return;const l=t*s,i=Math.min(l+s,r);let a=1/0,h=-1/0;for(let c=l;c<i;c++){const d=n[c];d!=null&&(d<a&&(a=d),d>h&&(h=d))}o[t*2]=a,o[t*2+1]=h}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 un{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 r=this.data[t];if(!r)return;const l=r.series[n];if(!(!l||l.length===0))return o=new cn(l),this.blockTrees.set(s,o),o}updateWindows(t){var s;let n=!1;for(let o=0;o<this.data.length;o++){const r=this.data[o],l=t(o),i=this.windows.get(o);let a,h;if(!r||!l||l.min==null||l.max==null)a=0,h=Math.max(0,((r==null?void 0:r.x.length)??1)-1);else{const c=r.x;if(c.length===0)a=0,h=0;else{a=ae(l.min,c),h=ae(l.max,c);const d=c[a],u=c[h];a>0&&d!=null&&d>l.min&&a--,h<c.length-1&&u!=null&&u<l.max&&h++}}(!i||i[0]!==a||i[1]!==h)&&(n=!0,(s=this.minMaxCache.get(o))==null||s.clear()),this.windows.set(o,[a,h])}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,r,l){let i=this.minMaxCache.get(t);const a=`${n}:${s}:${o}`;if(i){const f=i.get(a);if(f!=null)return f}else i=new Map,this.minMaxCache.set(t,i);const h=this.data[t];if(!h)return[1/0,-1/0];const c=h.series[n];if(!c||c.length===0)return[1/0,-1/0];let d;const u=!l&&r===xe.Unsorted?this.getOrBuildTree(t,n):void 0;return u?d=u.rangeMinMax(s,o):d=Kt(c,s,o,r,l),i.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;let r;Array.isArray(o.x)?r=o.x:(r=Array.from(o.x),o.x=r);for(let i=0;i<n.length;i++){const a=n[i];a!=null&&r.push(a)}for(let i=0;i<o.series.length;i++){let a=o.series[i];if(!a)continue;Array.isArray(a)||(a=Array.from(a),o.series[i]=a);const h=s[i];if(h){const d=a;for(let u=0;u<h.length;u++)d.push(h[u]??null)}const c=this.blockTrees.get(`${t}:${i}`);c&&(c.setData(a),c.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}}const Pe=-10;class fn{constructor(){this.state={left:Pe,top:Pe,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1},this._groupedConfigs=new Map,this._groupedConfigsSource=null}getGroupedConfigs(t){if(this._groupedConfigsSource!==t){this._groupedConfigsSource=t,this._groupedConfigs.clear();for(const n of t){if(n.show===!1)continue;let s=this._groupedConfigs.get(n.group);s==null&&(s=[],this._groupedConfigs.set(n.group,s)),s.push(n)}}return this._groupedConfigs}invalidateGroupedConfigs(){this._groupedConfigsSource=null}hide(){this.state.left=Pe,this.state.top=Pe,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(t,n,s,o,r,l,i,a){this.state.left=t,this.state.top=n;let h=1/0,c=-1,d=-1,u=-1;const f=this.getGroupedConfigs(r);for(let m=0;m<o.length;m++){const S=o[m];if(S==null)continue;const L=S.x;if(L.length===0)continue;const g=a(m);if(g==null)continue;const b=l(g);if(b==null||b.min==null||b.max==null)continue;const[P,k]=i(m),z=s.width,D=s.left,M=se(t+D,b,z,D),y=ae(M,L,P,k),I=[y];y>P&&I.push(y-1),y<k&&I.push(y+1);const R=new Map;for(const v of I){const p=L[v];if(p==null)continue;const x=j(p,b,z,D);for(const w of f.get(m)??[]){const T=S.series[w.index];if(T==null)continue;const C=T[v];if(C==null)continue;let _=R.get(w.yScale);if(_==null&&!R.has(w.yScale)&&(_=l(w.yScale),R.set(w.yScale,_)),_==null||_.min==null||_.max==null)continue;const F=s.height,E=s.top,H=j(C,_,F,E),$=t+D-x,G=n+E-H,V=$*$+G*G;if(V<h&&(h=V,c=m,d=w.index,u=v,V===0))break}if(h===0)break}}this.state.activeGroup=c,this.state.activeSeriesIdx=d,this.state.activeDataIdx=u}syncToValue(t,n){const s=n.dataStore.data;if(s.length===0)return;const o=s[0];if(o==null)return;const r=n.scaleManager.getGroupXScaleKey(0);if(r==null)return;const l=n.scaleManager.getScale(r);if(l==null||l.min==null||l.max==null)return;const[i,a]=n.dataStore.getWindow(0),h=ae(t,o.x,i,a),c=o.x[h];if(c==null)return;const d=j(c,l,n.plotBox.width,n.plotBox.left);this.state.left=d-n.plotBox.left,this.state.activeGroup=0,this.state.activeDataIdx=h;let u=0,f=n.plotBox.height/2;for(const m of n.seriesConfigs){if(m.group!==0||m.show===!1)continue;const S=o.series[m.index];if(S==null)continue;const L=S[h];if(L==null)continue;const g=n.scaleManager.getScale(m.yScale);if(!(g==null||g.min==null||g.max==null)){f=j(L,g,n.plotBox.height,n.plotBox.top)-n.plotBox.top,u=m.index;break}}this.state.top=f,this.state.activeSeriesIdx=u}}class hn{constructor(){this.flags=te.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=te.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=te.None}}const Be={width:1},dn={width:0,fill:"auto",fillTo:0,points:{show:!1},cursor:{show:!1}},gn={width:0,cursor:{show:!1}};function _e(e,t,n){e.lineTo(t,n)}function Ee(e,t,n){e.lineTo(n,t)}function Ye(e,t,n,s,o,r){const l=[];let i=-1;const a=o===N.Forward?n:s,h=o===N.Forward?s:n,c=o;for(let d=a;o===N.Forward?d<=h:d>=h;d+=c)if(t[d]===null||t[d]===void 0){if(i===-1){const u=Z(d-o,n,s);i=r(e[u])}}else i!==-1&&(l.push([i,r(e[d])]),i=-1);return i!==-1&&l.push([i,r(e[s])]),l}function Ne(e,t,n,s,o,r){const l=new Path2D;let i=t===X.Horizontal?n:s;const a=t===X.Horizontal?n+o:s+r,h=t===X.Horizontal?s:n,c=t===X.Horizontal?r:o;for(const[d,u]of e)d>i&&(t===X.Horizontal?l.rect(i,h,d-i,c):l.rect(h,i,c,d-i)),i=u;return i<a&&(t===X.Horizontal?l.rect(i,h,a-i,c):l.rect(h,i,c,a-i)),l}function _t(e){return(t,n,s,o,r,l)=>{s!==o&&(r!==s&&l!==s&&e(t,n,s),r!==o&&l!==o&&e(t,n,o),e(t,n,l))}}const pn=_t(_e),mn=_t(Ee);function Et(){const e=(t,n,s,o,r,l,i,a,h,c,d,u,f)=>{const m=(f==null?void 0:f.spanGaps)??!1;if([h,c]=(o.distr===U.Log?It:De)(n,h,c),h===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const L=y=>u(j(y,s,r,i)),g=y=>u(j(y,o,l,a));let b,P;s.ori===X.Horizontal?(b=_e,P=pn):(b=Ee,P=mn);const k={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},z=k.stroke;let D=!1;if(c-h>=r*4){const y=_=>se(_,s,r,i);let I=null,R=0,v=0,p=0,x=L(t[d===N.Forward?h:c]);const w=L(t[h]),T=L(t[c]);let C=y(d===N.Forward?w+1:T-1);for(let _=d===N.Forward?h:c;_>=h&&_<=c;_+=d){const F=t[_],H=(d===N.Forward?F<C:F>C)?x:L(F),$=n[_];H===x?$!=null?(p=$,I==null?(b(z,H,g(p)),v=I=R=p):p<I?I=p:p>R&&(R=p)):$===null&&!m&&(D=!0):(I!=null&&P(z,x,g(I),g(R),g(v),g(p)),$!=null?(p=$,b(z,H,g(p)),I=R=v=p):(I=null,R=0,$===null&&!m&&(D=!0)),x=H,C=y(x+d))}I!=null&&(I!==R?P(z,x,g(I),g(R),g(v),g(p)):b(z,x,g(p)))}else for(let y=d===N.Forward?h:c;y>=h&&y<=c;y+=d){const I=n[y];I===null&&!m?D=!0:I!=null&&b(z,L(t[y]),g(I))}{const y=k.fill=new Path2D(z),I=(f==null?void 0:f.fillTo)??o.min??0,R=g(I);let v=i,p=i+r;d===N.Backward&&([p,v]=[v,p]),b(y,p,R),b(y,v,R)}if(D){const y=Ye(t,n,h,c,d,L);k.gaps=y,k.clip=Ne(y,s.ori,i,a,r,l)}return k};return e.defaults=Be,e}const ot=new WeakMap;function lt(e,t,n){return typeof t=="string"?t:wn(e,t,n)}function wn(e,t,n){const s=ot.get(t);if(s!=null&&s.left===n.left&&s.top===n.top&&s.width===n.width&&s.height===n.height)return s.grad;const o=e.createLinearGradient(0,n.top,0,n.top+n.height);for(const[r,l]of t.stops)o.addColorStop(r,l);return ot.set(t,{grad:o,left:n.left,top:n.top,width:n.width,height:n.height}),o}function vn(e,t,n,s,o){if(t.show===!1)return;const r=t.alpha??1;e.save(),r<1&&(e.globalAlpha=r),n.clip&&e.clip(n.clip);const l=o??{left:0,top:0,width:e.canvas.width/s,height:e.canvas.height/s};if(t.fill&&n.fill&&(e.fillStyle=lt(e,t.fill,l),e.fill(n.fill)),t.stroke){const i=(t.width??1)*s;e.strokeStyle=lt(e,t.stroke,l),e.lineWidth=i,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,h=i%2/2;a===1&&h>0&&e.translate(h,h),e.stroke(n.stroke)}e.restore()}const xn=Et(),rt=64;class bn{constructor(){this.ctx=null,this.pxRatio=1,this.pathCache=new Map,this.bandCache=new Map,this.scaleStamp="",this.snapshotCanvas=null,this.snapshotValid=!1}setContext(t,n){this.ctx=t,this.pxRatio=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 r=this.snapshotCanvas.getContext("2d");r!=null&&typeof r.drawImage=="function"&&(r.clearRect(0,0,n,s),r.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}checkScaleStamp(t){let n="";const s=new Set;for(const o of t)for(const r of[o.xScale,o.yScale])s.has(r.id)||(s.add(r.id),n+=`${r.id}:${r.min}:${r.max};`);n!==this.scaleStamp&&(this.scaleStamp!==""&&this.clearCache(),this.scaleStamp=n)}cacheKey(t,n,s,o){return`${t}:${n}:${s}:${o}`}promote(t,n){this.pathCache.delete(t),this.pathCache.set(t,n)}getCachedPaths(t,n,s,o){const r=this.cacheKey(t,n,s,o),l=this.pathCache.get(r);if(l!=null)return this.promote(r,l),l;const i=`${t}:${n}:`;for(const[a,h]of this.pathCache){if(!a.startsWith(i))continue;const c=a.slice(i.length),d=c.indexOf(":"),u=+c.slice(0,d),f=+c.slice(d+1);if(u<=s&&f>=o)return this.promote(a,h),h}}setCachedPaths(t,n,s,o,r){if(this.pathCache.size>=rt){const i=rt>>2,a=this.pathCache.keys();for(let h=0;h<i;h++){const c=a.next().value;c!=null&&this.pathCache.delete(c)}}const l=this.cacheKey(t,n,s,o);this.pathCache.delete(l),this.pathCache.set(l,r)}invalidateSeries(t,n){const s=`${t}:${n}:`;for(const o of this.pathCache.keys())o.startsWith(s)&&this.pathCache.delete(o)}clearGroupCache(t){const n=`${t}:`;for(const s of this.pathCache.keys())s.startsWith(n)&&this.pathCache.delete(s);for(const s of this.bandCache.keys())s.startsWith(n)&&this.bandCache.delete(s);this.invalidateSnapshot()}clearCache(){this.pathCache.clear(),this.bandCache.clear(),this.invalidateSnapshot()}bandKey(t,n,s,o,r){return`${t}:${n}:${s}:${o}:${r}`}getCachedBandPath(t,n,s,o,r){return this.bandCache.get(this.bandKey(t,n,s,o,r))}setCachedBandPath(t,n,s,o,r,l){this.bandCache.set(this.bandKey(t,n,s,o,r),l)}drawSeries(t,n,s){const o=this.ctx;if(o==null||t.config.show===!1)return;const r=t.config.group,l=t.config.index,[i,a]=t.window;let h=this.getCachedPaths(r,l,i,a);if(h==null){const c=t.config.paths??xn,d=t.xScale.dir,u=k=>B(k),f=a-i,m=Math.max(1,Math.ceil(f*.1)),S=t.dataX.length,L=Math.max(0,i-m),g=Math.min(S-1,a+m),b=t.config.fillTo;let P;typeof b=="function"?P=b(t.yScale.min??0,t.yScale.max??0):b===0&&t.yScale.distr===U.Log?P=1:P=b,h=c(t.dataX,t.dataY,t.xScale,t.yScale,n.width,n.height,n.left,n.top,L,g,d,u,{fillTo:P,spanGaps:t.config.spanGaps}),this.setCachedPaths(r,l,L,g,h)}vn(o,t.config,h,s,n)}draw(t,n,s,o){const r=this.ctx;if(r==null)return;const l=this.pxRatio;r.clearRect(0,0,t*l,n*l),r.save(),r.scale(l,l),r.beginPath(),r.rect(s.left,s.top,s.width,s.height),r.clip();for(const i of o)this.drawSeries(i,s,1);r.restore()}}const Ft=[1,2,2.5,5],Sn=At(10,-32,0,Ft),Mn=At(10,0,32,Ft),ue=Sn.concat(Mn);function yn(e,t,n,s,o){if(n<=0||t<e)return[];const r=[],l=Se.get(n)??0,i=o?Math.ceil(e/n)*n:ce(Xe(e,n),l);for(let a=i;a<=t;a=ce(a+n,l))r.push(Object.is(a,-0)?0:a);return r}function it(e){return e.map(t=>Pt(t))}function Cn(e,t,n){if(e<=0||t<=0||e>=t)return[];const s=[],r=oe((n===10?ne:Me)(e));let l=ve(n,r);n===10&&(l=ue[ae(l,ue)]??l);let i=l,a=l*n;n===10&&(a=ue[ae(a,ue)]??a);let h=0;do{if(i>=e&&s.push(i),i=i+l,n===10&&!Se.has(i)){const c=Se.get(l)??0;i=ce(i,c)}i>=a*(1-1e-10)&&(l=i,a=l*n,n===10&&(a=ue[ae(a,ue)]??a))}while(i<=t&&++h<1e4);return s}function kn(e,t){const n=t===10?ne:Me;return e.map(s=>{if(s===0)return!0;if(s<0)return!1;const o=n(s);return ge(o-Math.round(o))<1e-10})}const Tn=7,In=50,Ln=16;function An(e,t){const s=Pt(Math.max(Math.abs(e),Math.abs(t))).length*Tn;return Math.max(In,s+Ln)}function Pn(e,t,n,s){if(s<=0)return[0,0];const o=pe(e.side)===X.Vertical,r=e.space??(o?30:An(t,n)),l=e.incrs??ue;return nn(t,n,l,s,r)}const Rn=50;function Dn(e,t,n){var i,a;if(e.size!=null)return e.size;const s=((i=e.ticks)==null?void 0:i.show)!==!1?((a=e.ticks)==null?void 0:a.size)??10:0,o=e.gap??5,r=12;if(pe(e.side)===X.Vertical&&t!=null){let h=0;for(const d of t)d.length>h&&(h=d.length);const c=h*7;return Math.max(50,s+o+c+4)}return Math.max(50,s+o+r+3)}function _n(e){return{config:e,_show:e.show!==!1,_size:e.size??Rn,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const we=60,fe=3600,ie=86400,En=604800,de=2592e3,Ie=31536e3,Fn=[1,5,10,15,30,we,5*we,10*we,15*we,30*we,fe,2*fe,3*fe,4*fe,6*fe,12*fe,ie,2*ie,3*ie,7*ie,14*ie,de,2*de,3*de,6*de,Ie];function zn(e,t,n,s){const o=[];if(n<=0||e>=t)return o;let r;if(n>=Ie){const l=new Date(e*1e3);for(l.setUTCMonth(0,1),l.setUTCHours(0,0,0,0),r=l.getTime()/1e3,r<e&&(l.setUTCFullYear(l.getUTCFullYear()+1),r=l.getTime()/1e3);r<=t;)o.push(r),l.setUTCFullYear(l.getUTCFullYear()+Math.round(n/Ie)),r=l.getTime()/1e3;return o}if(n>=de){const l=new Date(e*1e3);l.setUTCDate(1),l.setUTCHours(0,0,0,0),r=l.getTime()/1e3;const i=Math.max(1,Math.round(n/de));if(r<e&&(l.setUTCMonth(l.getUTCMonth()+1),r=l.getTime()/1e3),i>1){const a=l.getUTCMonth(),h=Math.ceil((a+1)/i)*i;l.setUTCMonth(h-1),r=l.getTime()/1e3}for(;r<=t;)o.push(r),l.setUTCMonth(l.getUTCMonth()+i),r=l.getTime()/1e3;return o}if(n>=ie){const l=new Date(e*1e3);l.setUTCHours(0,0,0,0),r=l.getTime()/1e3,r<e&&(r+=ie)}else r=Math.ceil(e/n)*n;for(let l=0;;l++){const i=r+l*n;if(i>t)break;o.push(i)}return o}const at=new Map;function Hn(e,t){const n=JSON.stringify(e)+(t??"");let s=at.get(n);return s==null&&(s=new Intl.DateTimeFormat(void 0,{...e,timeZone:t}),at.set(n,s)),s}function ee(e,t,n){const s=new Date(e*1e3);return Hn(t,n).format(s)}function Gn(e,t){return ee(e,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function $n(e,t){return ee(e,{year:"numeric",month:"2-digit",day:"2-digit"},t)}function Wn(e,t){return ee(e,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function Vn(e,t){return ee(e,{hour:"2-digit",minute:"2-digit",hour12:!1},t)}function jn(e,t){return ee(e,{month:"short",day:"numeric"},t)}function Xn(e,t){return ee(e,{year:"numeric"},t)}function Bn(e,t){return ee(e,{year:"numeric",month:"short"},t)}function Yn(e,t,n){let s;return t>=Ie?s=Xn:t>=de?s=Bn:t>=En?s=$n:t>=ie?s=jn:t>=fe?s=Vn:t>=we?s=Wn:s=Gn,e.map(o=>s(o,n))}function Nn(e,t,n,s,o){const r=t-e;if(r<=0||s<=0)return[0,0];for(const i of n){const a=r/i,h=s/a;if(h>=o)return[i,h]}const l=n[n.length-1]??Ie;return[l,s/(r/l)]}const On=3;function Un(e,t,n,s,o){let r=!0;for(const l of e){const i=l.config;if(i.show===!1)continue;const a=t(i.scale);if(!a||a.min==null||a.max==null){l._show&&(r=!1,l._show=!1);continue}else l._show||(r=!1,l._show=!0);const h=i.side,d=pe(h)===X.Horizontal?n:s,{min:u,max:f}=a;let m,S;if(a.time){const g=i.space??80;[m,S]=Nn(u,f,Fn,d,g)}else[m,S]=Pn(i,u,f,d);if(a._discrete&&m>0&&m<1&&(m=1),l._incr=m,l._space=S,S===0)continue;if(i.splits)l._splits=i.splits(u,f,m,S);else if(a.time)l._splits=zn(u,f,m);else if(a.distr===U.Log)l._splits=Cn(u,f,a.log);else{const g=a.distr===U.Ordinal||a._discrete;l._splits=yn(u,f,m,S,g)}if(i.values)l._values=i.values(l._splits,S,m);else if(a.time)l._values=Yn(l._splits,m);else if(a.distr===U.Log){const g=kn(l._splits,a.log),b=it(l._splits);l._values=b.map((P,k)=>g[k]?P:"")}else l._values=it(l._splits);l._rotate=h===Y.Bottom?i.rotate??0:0;const L=l._size;l._size=ke(Dn(i,l._values)),L!==l._size&&(r=!1)}return r}function ct(e,t,n,s=0){let o=e,r=t-s,l=0,i=s;for(const h of n){if(!h._show)continue;const c=h.config.side,d=pe(c)===X.Vertical,u=h.config.label!=null?h.config.labelSize??20:0,f=h._size+u;f>0&&(d?(o-=f,c===Y.Left&&(l+=f)):(r-=f,c===Y.Top&&(i+=f)))}return!n.some(h=>h._show&&h.config.side===Y.Top)&&i<=s&&(i+=8,r-=8),{left:l,top:i,width:Math.max(o,0),height:Math.max(r,0)}}function Kn(e,t){let n=t.top,s=t.left+t.width,o=t.top+t.height,r=t.left;function l(i,a){switch(i){case Y.Top:return n-=a,n+a;case Y.Right:{const h=s;return s+=a,h}case Y.Bottom:{const h=o;return o+=a,h}case Y.Left:return r-=a,r+a;default:return 0}}for(const i of e){if(!i._show)continue;const a=i.config.side;if(i._pos=l(a,i._size),i.config.label!=null){const h=i.config.labelSize??20;i._lpos=l(a,h)}}}function Zn(e,t,n,s,o=0){for(const a of n)a._size=0;let r=!1,l=0,i={left:0,top:0,width:e,height:t};for(;!r;){l++;const a=Un(n,s,i.width,i.height);r=l===On||a,r||(i=ct(e,t,n,o))}return i=ct(e,t,n,o),Kn(n,i),i}const ut="top",ft="bottom",qn="left",Jn="right";function Ge(e,t){return t===1?e:e.replace(/(\d+(?:\.\d+)?)px/,(n,s)=>`${Math.round(Number(s)*t)}px`)}function ht(e,t,n,s,o,r,l,i,a,h,c){const d=i%2/2;e.save(),e.translate(d,d),e.strokeStyle=a,e.lineWidth=i,h.length>0&&e.setLineDash(h),e.beginPath();let u=0,f=0,m=0,S=0;const L=r+(o===Y.Top||o===Y.Left?-l:l);s===X.Horizontal?(f=r,S=L):(u=r,m=L);for(let g=0;g<t.length;g++)n[g]!=null&&(s===X.Horizontal?u=m=t[g]??0:f=S=t[g]??0,e.moveTo(u,f),e.lineTo(m,S));e.stroke(),e.restore()}function Qn(e,t,n,s,o,r){const l=B(s.left*o),i=B(s.top*o),a=B(s.width*o),h=B(s.height*o);for(const c of t){if(!c._show)continue;const d=c.config,u=d.side,f=pe(u),m=n(d.scale);if(!m||m.min==null||m.max==null)continue;const S=d.stroke??"#000",L=u===Y.Top||u===Y.Left?-1:1,g=c._splits,b=c._values;if(!g||!b||c._space===0)continue;const P=f===X.Horizontal?s.width:s.height,k=f===X.Horizontal?s.left:s.top,z=g.map(R=>B(j(R,m,P,k)*o)),D=b.map(R=>R===""?null:R),M=d.grid;if((M==null?void 0:M.show)!==!1){const R=(M==null?void 0:M.stroke)??"rgba(0,0,0,0.12)",v=B(((M==null?void 0:M.width)??2)*o),p=((M==null?void 0:M.dash)??[]).map(T=>T*o),x=f===X.Horizontal?i:l,w=f===X.Horizontal?h:a;ht(e,z,D,f,2,x,w,v,R,p)}const y=d.ticks;if((y==null?void 0:y.show)!==!1){const R=(y==null?void 0:y.stroke)??S,v=B(((y==null?void 0:y.width)??1)*o),p=B(((y==null?void 0:y.size)??10)*o),x=((y==null?void 0:y.dash)??[]).map(T=>T*o),w=B(c._pos*o);ht(e,z,D,f,u,w,p,v,R,x)}{const R=(y==null?void 0:y.show)!==!1?((y==null?void 0:y.size)??10)*o:0,v=B((d.gap??5)*o),p=B(c._pos*o),x=(R+v)*L,w=p+x,T=Ge(d.font??"12px system-ui, sans-serif",o),C=f===X.Horizontal?"center":u===Y.Left?Jn:qn,_=f===X.Horizontal?u===Y.Bottom?ut:ft:"middle";e.font=T,e.fillStyle=S,e.textAlign=C,e.textBaseline=_;const F=c._rotate*-Fe/180;if(F!==0){const E=Math.cos(F),H=Math.sin(F);for(let $=0;$<b.length;$++){const G=b[$];if(G==null||G==="")continue;const V=z[$]??0;e.setTransform(E,H,-H,E,V,w),e.fillText(G,0,0)}e.setTransform(1,0,0,1,0,0)}else for(let E=0;E<b.length;E++){const H=b[E];if(H==null||H==="")continue;const $=z[E]??0,G=f===X.Horizontal?$:w,V=f===X.Horizontal?w:$;e.fillText(H,G,V)}}if(d.label!=null){const R=Ge(d.labelFont??"bold 12px system-ui, sans-serif",o);e.font=R,e.fillStyle=S,e.textAlign="center",e.textBaseline=u===Y.Bottom?ut:ft;const v=B((c._lpos+(d.labelGap??0)*L)*o);f===X.Vertical?(e.save(),e.translate(v,B(i+h/2)),e.rotate((u===Y.Left?-Fe:Fe)/2),e.fillText(d.label,0,0),e.restore()):e.fillText(d.label,B(l+a/2),v)}const I=d.border;if((I==null?void 0:I.show)!==!1&&I!=null){const R=I.stroke??S,v=B((I.width??1)*o),p=(I.dash??[]).map(w=>w*o),x=B(c._pos*o);e.strokeStyle=R,e.lineWidth=v,p.length>0&&e.setLineDash(p),e.beginPath(),f===X.Horizontal?(e.moveTo(l,x),e.lineTo(l+a,x)):(e.moveTo(x,i),e.lineTo(x,i+h)),e.stroke(),p.length>0&&e.setLineDash([])}}if(r!=null){const c=Ge("bold 14px system-ui, sans-serif",o);e.font=c,e.fillStyle="#000",e.textAlign="center",e.textBaseline="top",e.fillText(r,B(l+a/2),B(4*o))}}const es=2,ts="#fff",ns={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function dt(e,t,n,s,o,r,l,i,a,h){var k,z;if(t.left<0||t.top<0)return;const c={...ns,...a},d=s,u=B(n.left*d),f=B(n.top*d),m=B(n.width*d),S=B(n.height*d),L=B(c.width*d),g=L%2/2,b=B((n.left+t.left)*d)+g,P=B((n.top+t.top)*d)+g;if(e.save(),e.strokeStyle=c.stroke,e.lineWidth=L,e.setLineDash(c.dash.map(D=>D*d)),c.showX&&(e.beginPath(),e.moveTo(b,f),e.lineTo(b,f+S),e.stroke()),c.showY&&(e.beginPath(),e.moveTo(u,P),e.lineTo(u+m,P),e.stroke()),e.setLineDash([]),t.activeGroup>=0&&t.activeDataIdx>=0){const D=t.activeGroup,M=t.activeSeriesIdx,y=t.activeDataIdx,I=o[D];if(I!=null&&M>=0&&M<I.series.length&&y<I.x.length){const R=I.x[y],v=I.series[M],p=v!=null?v[y]:null;if(R!=null&&p!=null){let x=c.stroke,w=!0;const T=h==null?void 0:h.get(`${D}:${M}`);if(T!=null){const C=T.stroke;x=(typeof C=="string"?C:void 0)??c.stroke,w=((k=T.cursor)==null?void 0:k.show)!==!1}if(w){const C=i(D),_=C!=null?l(C):void 0,F=((z=h==null?void 0:h.get(`${D}:${M}`))==null?void 0:z.yScale)??ss(r,D,M),E=F!=null?l(F):void 0;if(_!=null&&E!=null&&_.min!=null&&_.max!=null&&E.min!=null&&E.max!=null){const H=B(j(R,_,n.width,n.left)*d),$=B(j(p,E,n.height,n.top)*d),G=c.pointRadius*d,V=B(es*d);e.beginPath(),e.arc(H,$,G,0,Math.PI*2),e.fillStyle=ts,e.fill(),e.strokeStyle=x,e.lineWidth=V,e.stroke()}}}}}e.restore()}function ss(e,t,n){for(const s of e)if(s.group===t&&s.index===n)return s.yScale}const os={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function gt(e,t,n,s,o){if(!t.show||t.width<=0)return;const r={...os,...o},l=s,i=B((n.left+t.left)*l),a=B((n.top+t.top)*l),h=B(t.width*l),c=B(t.height*l);e.save(),e.fillStyle=r.fill,e.fillRect(i,a,h,c),r.width>0&&(e.strokeStyle=r.stroke,e.lineWidth=B(r.width*l),e.strokeRect(i,a,h,c)),e.restore()}function ls(e,t,n,s,o,r,l,i,a,h,c,d){const u=c/2*l,f=Math.max(1,B(c*.2))*l,m=(h==null?void 0:h.stroke)??d,S=(h==null?void 0:h.fill)??"#fff";e.save(),e.strokeStyle=m,e.fillStyle=S,e.lineWidth=f,(h==null?void 0:h.dash)!=null&&e.setLineDash(h.dash.map(L=>L*l));for(let L=i;L<=a;L++){const g=n[L];if(g==null)continue;const b=t[L];if(b==null)continue;const P=B(j(b,s,r.width,r.left)*l),k=B(j(g,o,r.height,r.top)*l);e.beginPath(),e.arc(P,k,u,0,Math.PI*2),e.fill(),e.stroke()}e.restore()}function rs(e,t,n,s,o,r,l){if(typeof e=="function")return e(t,n,s,o,r);if(e===!0)return!0;if(e===!1)return!1;const i=o-s;return i>0&&i<=r/l}function is(e,t,n,s,o,r,l,i,a){if(i>a||i<0||!nt(t,i,a)&&!nt(n,i,a))return null;const h=f=>j(f,s,r.width,r.left)*l,c=f=>j(f,o,r.height,r.top)*l,d=new Path2D;let u=!1;for(let f=i;f<=a;f++){const m=t[f],S=e[f];if(m==null||S==null)continue;const L=h(S),g=c(m);u?d.lineTo(L,g):(d.moveTo(L,g),u=!0)}if(!u)return null;for(let f=a;f>=i;f--){const m=n[f],S=e[f];m==null||S==null||d.lineTo(h(S),c(m))}return d.closePath(),d}function as(e,t,n){e.save(),e.fillStyle=t.fill??"rgba(0, 120, 255, 0.1)",e.fill(n),e.restore()}function cs(e){const t=e.dataStore.data;if(t.length===0)return;if(!e.scaleManager.getScale("x")){const l={id:"x",auto:!0};e.scaleConfigs.push(l),e.scaleManager.addScale(l)}for(let l=0;l<t.length;l++)e.scaleManager.getGroupXScaleKey(l)||e.scaleManager.setGroupXScale(l,"x");const n=new Set(e.scaleConfigs.map(l=>l.id)),s=new Set;for(const l of e.seriesConfigs)s.add(l.yScale);s.size===0&&!n.has("y")&&s.add("y");for(const l of s)if(!n.has(l)){const i={id:l,auto:!0};e.scaleConfigs.push(i),e.scaleManager.addScale(i),n.add(l)}e.axisConfigs.some(l=>l.scale==="x")||e.axisConfigs.push({scale:"x",side:Y.Bottom,show:!0,label:e.xlabel??"X Axis"});const r=new Set(e.axisConfigs.map(l=>l.scale));for(const l of s)r.has(l)||(e.axisConfigs.push({scale:l,side:Y.Left,show:!0,label:e.ylabel??"Y Axis"}),r.add(l))}function $e(e,t,n,s){return{ctx:e,plotBox:t,pxRatio:n,getScale:s,valToX:(l,i="x")=>{const a=s(i);return a==null||a.min==null||a.max==null?null:j(l,a,t.width,t.left)},valToY:(l,i)=>{const a=s(i);return a==null||a.min==null||a.max==null?null:j(l,a,t.height,t.top)}}}function pt(e){e.seriesConfigMap.clear();for(const t of e.seriesConfigs)e.seriesConfigMap.set(`${t.group}:${t.index}`,t)}function us(){const e={scaleManager:new rn,dataStore:new un,renderer:new bn,cursorManager:new fn,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,cursorListeners:new Set,scheduler:new hn,drawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:.15,wheelZoom:!1,title:void 0,xlabel:void 0,ylabel:void 0,revision:0,eventCallbacks:{},_prevScaleRanges:new Map,seriesConfigMap: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),pt(e)},unregisterSeries(t,n){e.seriesConfigs=e.seriesConfigs.filter(s=>!(s.group===t&&s.index===n)),pt(e)},toggleSeries(t,n){const s=e.seriesConfigMap.get(`${t}:${n}`);s!=null&&(s.show=s.show===!1,e.revision++,e.cursorManager.invalidateGroupedConfigs(),e.renderer.invalidateSeries(t,n),e.renderer.invalidateSnapshot(),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(te.Full)},scheduleCursorRedraw(){e.scheduler.mark(te.Cursor)},subscribe(t){return e.listeners.add(t),()=>{e.listeners.delete(t)}},subscribeCursor(t){return e.cursorListeners.add(t),()=>{e.cursorListeners.delete(t)}},redraw(){const{scaleManager:t,dataStore:n,renderer:s,seriesConfigs:o,width:r,height:l,pxRatio:i,canvas:a,scheduler:h}=e;if(a==null||r===0||l===0)return;const c=a.getContext("2d");if(c==null)return;s.setContext(c,i);const u=(h.dirty&~(te.Cursor|te.Select))===0,f=g=>t.getScale(g);if(u&&s.restoreSnapshot(c)){if(dt(c,e.cursorManager.state,e.plotBox,i,n.data,o,f,g=>t.getGroupXScaleKey(g),void 0,e.seriesConfigMap),gt(c,e.selectState,e.plotBox,i),e.cursorDrawHooks.size>0){c.save(),c.scale(i,i);const g=$e(c,e.plotBox,i,f);for(const b of e.cursorDrawHooks)try{b(g,e.cursorManager.state)}catch(P){console.warn("[uPlot+] draw hook error:",P)}c.restore()}for(const g of e.cursorListeners)g();return}cs(e),t.autoRangeX(n.data),n.updateWindows(g=>{const b=t.getGroupXScaleKey(g);return b!=null?t.getScale(b):void 0});const m=o.map(g=>({group:g.group,index:g.index,yScale:g.yScale}));if(t.autoRange(n.data,m,n),fs(e),e.axisStates.length>0){const g=e.title!=null?20:0;e.plotBox=Zn(r,l,e.axisStates,f,g)}else e.plotBox={left:10,top:10,width:r-20,height:l-20};c.clearRect(0,0,r*i,l*i),e.axisStates.length>0&&Qn(c,e.axisStates,f,e.plotBox,i,e.title);const S=[];for(const g of o){const b=t.getGroupXScaleKey(g.group),P=b!=null?t.getScale(b):void 0,k=t.getScale(g.yScale);P==null||k==null||S.push({config:g,dataX:n.getXValues(g.group),dataY:n.getYValues(g.group,g.index),xScale:P,yScale:k,window:n.getWindow(g.group)})}s.checkScaleStamp(S),c.save(),c.scale(i,i),c.beginPath(),c.rect(e.plotBox.left,e.plotBox.top,e.plotBox.width,e.plotBox.height),c.clip();for(let g=0;g<S.length;g++){const b=S[g];b!=null&&(e.focusedSeries!=null&&g!==e.focusedSeries?(c.globalAlpha=e.focusAlpha,s.drawSeries(b,e.plotBox,1),c.globalAlpha=1):s.drawSeries(b,e.plotBox,1))}const L=new Map;for(const g of o)L.set(`${g.group}-${g.index}`,g);for(const g of e.bandConfigs){const b=t.getGroupXScaleKey(g.group),P=b!=null?t.getScale(b):void 0,k=L.get(`${g.group}-${g.series[0]}`),z=L.get(`${g.group}-${g.series[1]}`);if(P==null||k==null||z==null)continue;const D=t.getScale(k.yScale);if(D==null)continue;const[M,y]=n.getWindow(g.group),I=g.series[0],R=g.series[1];let v=s.getCachedBandPath(g.group,I,R,M,y);v==null&&(v=is(n.getXValues(g.group),n.getYValues(g.group,I),n.getYValues(g.group,R),P,D,e.plotBox,i,M,y)??void 0,v!=null&&s.setCachedBandPath(g.group,I,R,M,y,v)),v!=null&&as(c,g,v)}for(const g of S){const b=g.config;if(b.show===!1)continue;const P=b.points,k=b.width??1,z=(P==null?void 0:P.size)??3+k*2,D=(P==null?void 0:P.space)??z*2,[M,y]=g.window;rs(P==null?void 0:P.show,b.group,b.index,M,y,e.plotBox.width,D)&&ls(c,g.dataX,g.dataY,g.xScale,g.yScale,e.plotBox,i,M,y,P,z,(typeof b.stroke=="string"?b.stroke:null)??"#000")}if(c.restore(),e.drawHooks.size>0){c.save(),c.beginPath(),c.rect(e.plotBox.left*i,e.plotBox.top*i,e.plotBox.width*i,e.plotBox.height*i),c.clip(),c.scale(i,i);const g=$e(c,e.plotBox,i,f);for(const b of e.drawHooks)try{b(g)}catch(P){console.warn("[uPlot+] draw hook error:",P)}c.restore()}if(e.cursorManager.state.left>=0&&(s.saveSnapshot(c,r*i,l*i),e.cursorManager.update(e.cursorManager.state.left,e.cursorManager.state.top,e.plotBox,n.data,o,f,g=>n.getWindow(g),g=>t.getGroupXScaleKey(g))),dt(c,e.cursorManager.state,e.plotBox,i,n.data,o,f,g=>t.getGroupXScaleKey(g),void 0,e.seriesConfigMap),gt(c,e.selectState,e.plotBox,i),e.cursorDrawHooks.size>0){c.save(),c.scale(i,i);const g=$e(c,e.plotBox,i,f);for(const b of e.cursorDrawHooks)try{b(g,e.cursorManager.state)}catch(P){console.warn("[uPlot+] draw hook error:",P)}c.restore()}for(const g of e.listeners)g();for(const g of e.cursorListeners)g();if(e._prevScaleRanges.size>0&&e.eventCallbacks.onScaleChange!=null)for(const g of t.getAllScales()){if(g.min==null||g.max==null)continue;const b=e._prevScaleRanges.get(g.id);if(b==null||b.min!==g.min||b.max!==g.max)try{e.eventCallbacks.onScaleChange(g.id,g.min,g.max)}catch(P){console.warn("[uPlot+] event callback error:",P)}}e._prevScaleRanges.clear();for(const g of t.getAllScales())g.min!=null&&g.max!=null&&e._prevScaleRanges.set(g.id,{min:g.min,max:g.max})}};return e.scheduler.onRedraw(()=>e.redraw()),e}function fs(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 r=`${o.scale}:${o.side}`,l=s.get(r);return l!=null?(l.config=o,l):_n(o)})}function hs(){const e=A.useRef(null);return e.current===null&&(e.current=us()),e.current}const zt=A.createContext(null);function Q(){const e=A.useContext(zt);if(!e)throw new Error("useChart must be used within a <Chart> component");return e}const ds=5,gs=.001,ps=.1,ms=10;function ws(e,t){A.useEffect(()=>{if(t!=null)return vs(e,t)},[e,t])}function vs(e,t){let n=null;const s={show:!1,left:0,top:0,width:0,height:0};let o=null,r=null,l=!1;function i(v){const p=t.getBoundingClientRect(),x=e.plotBox,w=v.clientX-p.left-x.left,T=v.clientY-p.top-x.top;return{cx:w,cy:T}}function a(v,p){const x=e.plotBox;return v>=0&&v<=x.width&&p>=0&&p<=x.height}function h(v,p){const x=t.getBoundingClientRect(),w=v-x.left,T=p-x.top,C=e.plotBox;for(const _ of e.axisStates){const F=_.config,E=F.side;if(_._size<=0)continue;const $=T>=C.top&&T<=C.top+C.height,G=w>=C.left&&w<=C.left+C.width;if(E===Y.Left&&w<C.left&&$||E===Y.Right&&w>C.left+C.width&&$||E===Y.Top&&T<C.top&&G||E===Y.Bottom&&T>C.top+C.height&&G){const O=pe(E);return{scaleId:F.scale,ori:O}}}return null}function c(v,p,x){const w=e.cursorManager.state;let T=null;if(w.activeGroup>=0&&w.activeDataIdx>=0){const C=e.dataStore.data[w.activeGroup];if(C!=null){const _=C.x[w.activeDataIdx],F=C.series[w.activeSeriesIdx],E=F!=null?F[w.activeDataIdx]:void 0;if(_!=null&&E!=null){const H=e.plotBox,$=e.scaleManager.getGroupXScaleKey(w.activeGroup),G=$!=null?e.scaleManager.getScale($):void 0,V=e.seriesConfigMap.get(`${w.activeGroup}:${w.activeSeriesIdx}`),O=V!=null?e.scaleManager.getScale(V.yScale):void 0;let J=p,me=x;(G==null?void 0:G.min)!=null&&G.max!=null&&(J=j(_,G,H.width,H.left)-H.left),(O==null?void 0:O.min)!=null&&O.max!=null&&(me=j(E,O,H.height,H.top)-H.top);const Qe=p-J,et=x-me;T={group:w.activeGroup,seriesIdx:w.activeSeriesIdx,dataIdx:w.activeDataIdx,xVal:_,yVal:E,pxX:J,pxY:me,dist:Math.sqrt(Qe*Qe+et*et)}}}}return{plotX:p,plotY:x,point:T,srcEvent:v}}function d(v){const p=e.plotBox,x=v.left/p.width,w=(v.left+v.width)/p.width,T={};for(const C of e.scaleManager.getAllScales()){if(C.ori!==X.Horizontal||C.min==null||C.max==null)continue;const _=se(p.left+x*p.width,C,p.width,p.left),F=se(p.left+w*p.width,C,p.width,p.left);T[C.id]={min:Math.min(_,F),max:Math.max(_,F)}}return{left:x,right:w,ranges:T}}function u(){const v=e.eventCallbacks.onScaleChange;if(v!=null)for(const p of e.scaleManager.getAllScales()){if(p.min==null||p.max==null)continue;const x=e._prevScaleRanges.get(p.id);(x==null||x.min!==p.min||x.max!==p.max)&&v(p.id,p.min,p.max)}}function f(v,p){if(r!=null){const C=t.getBoundingClientRect(),_=v.clientY-C.top,F=e.plotBox,E=(_-r.startY)/F.height,H=r.startMax-r.startMin,$=e.scaleManager.getScale(r.scaleId);$!=null&&($.min=r.startMin+E*H,$.max=r.startMax+E*H,$.auto=!1,he($),e.renderer.clearCache(),e.scheduleRedraw());return}const x=i(v);if(x==null)return;const{cx:w,cy:T}=x;if(!a(w,T)&&n==null){e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),e.scheduleCursorRedraw();return}if(e.cursorManager.update(w,T,e.plotBox,e.dataStore.data,e.seriesConfigs,C=>e.scaleManager.getScale(C),C=>e.dataStore.getWindow(C),C=>e.scaleManager.getGroupXScaleKey(C)),e.focusAlpha<1){const C=e.cursorManager.state;if(C.activeGroup>=0&&C.activeSeriesIdx>=0){const _=e.seriesConfigs.findIndex(F=>F.group===C.activeGroup&&F.index===C.activeSeriesIdx);_>=0&&e.focusedSeries!==_&&(e.focusedSeries=_,e.scheduleRedraw())}}if(p!=null&&e.eventCallbacks.onCursorMove!=null&&a(w,T))try{e.eventCallbacks.onCursorMove(c(p,w,T))}catch(C){console.warn("[uPlot+] event callback error:",C)}if(n!=null){const C=n.x,_=e.plotBox,F=Z(w,0,_.width);s.show=!0,s.left=Math.min(C,F),s.top=0,s.width=Math.abs(F-C),s.height=_.height,e.selectState=s}n!=null?e.scheduler.mark(te.Cursor|te.Select):e.scheduleCursorRedraw()}function m(v){f(v,v)}function S(v){if(v.button!==0)return;const p=h(v.clientX,v.clientY);if(p!=null&&p.ori===X.Vertical){const w=e.scaleManager.getScale(p.scaleId);if(w!=null&&w.min!=null&&w.max!=null){const T=t.getBoundingClientRect();r={scaleId:p.scaleId,startY:v.clientY-T.top,startMin:w.min,startMax:w.max},v.preventDefault();return}}const x=i(v);x!=null&&a(x.cx,x.cy)&&(n={x:x.cx,y:x.cy},l=!1,s.show=!1,s.left=0,s.width=0,e.selectState=s)}function L(v){if(r!=null){u(),r=null;return}if(n!=null){if(s.width>ds){l=!0;let p=!0;if(e.eventCallbacks.onSelect!=null){const x=d(s);let w;try{w=e.eventCallbacks.onSelect(x)}catch(T){console.warn("[uPlot+] event callback error:",T)}w===!1&&(p=!1)}p&&(M(s),u())}n=null,s.show=!1,s.left=0,s.width=0,e.selectState=s,e.scheduleRedraw()}}function g(v){L()}function b(v){if(l){l=!1;return}const p=e.eventCallbacks.onClick;if(p==null)return;const x=i(v);if(x!=null&&a(x.cx,x.cy))try{p(c(v,x.cx,x.cy))}catch(w){console.warn("[uPlot+] event callback error:",w)}}function P(v){const p=e.eventCallbacks.onContextMenu;if(p==null)return;const x=i(v);if(x!=null&&a(x.cx,x.cy)){v.preventDefault();try{p(c(v,x.cx,x.cy))}catch(w){console.warn("[uPlot+] event callback error:",w)}}}function k(v){var p,x;e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),n!=null&&(n=null,s.show=!1,s.width=0,e.selectState=s),r!=null&&(r=null),e.scheduleCursorRedraw();try{(x=(p=e.eventCallbacks).onCursorLeave)==null||x.call(p)}catch(w){console.warn("[uPlot+] event callback error:",w)}}function z(v){if(e.eventCallbacks.onDblClick!=null){const p=i(v);if(p!=null&&a(p.cx,p.cy)){let x;try{x=e.eventCallbacks.onDblClick(c(v,p.cx,p.cy))}catch(w){console.warn("[uPlot+] event callback error:",w)}if(x===!1)return}}for(const p of e.scaleConfigs)e.scaleManager.addScale(p);e.renderer.clearCache(),e.scheduleRedraw()}function D(v){const p=e.wheelZoom;if(!p)return;let x=!1,w=!1;if(p===!0||p==="x")x=!0;else if(p==="y")w=!0;else if(p==="xy")x=!0,w=!0;else if(typeof p=="object"){if(p.x){const F=typeof p.x=="object"?p.x.key:void 0;x=F==null||v[`${F}Key`]}if(p.y){const F=typeof p.y=="object"?p.y.key:void 0;w=F==null||v[`${F}Key`]}}if(!x&&!w)return;const T=i(v);if(T==null||!a(T.cx,T.cy))return;v.preventDefault();const C=Z(1-v.deltaY*gs,ps,ms),_=e.plotBox;for(const F of e.scaleManager.getAllScales()){if(F.min==null||F.max==null)continue;const E=F.ori===X.Horizontal;if(E&&!x||!E&&!w)continue;const H=E?_.width:_.height,$=E?_.left:_.top,G=E?T.cx+_.left:T.cy+_.top,V=se(G,F,H,$),O=V-(V-F.min)*C,J=V+(F.max-V)*C;F.min=Math.min(O,J),F.max=Math.max(O,J),F.auto=!1,he(F)}e.scheduleRedraw(),u()}function M(v){const p=e.plotBox,x=v.left/p.width,w=(v.left+v.width)/p.width;for(const T of e.scaleManager.getAllScales()){if(T.ori!==X.Horizontal||T.min==null||T.max==null)continue;const C=se(p.left+x*p.width,T,p.width,p.left),_=se(p.left+w*p.width,T,p.width,p.left);T.min=Math.min(C,_),T.max=Math.max(C,_),T.auto=!1,he(T)}}function y(v){if(v.touches.length===2){const w=v.touches[0],T=v.touches[1],C=T.clientX-w.clientX,_=T.clientY-w.clientY;o={dist:Math.sqrt(C*C+_*_),midX:(w.clientX+T.clientX)/2,midY:(w.clientY+T.clientY)/2},n=null;return}const p=v.touches[0];if(p==null)return;const x=i(p);x!=null&&a(x.cx,x.cy)&&(n={x:x.cx,y:x.cy},l=!1)}function I(v){if(v.touches.length===2&&o!=null){v.preventDefault();const x=v.touches[0],w=v.touches[1],T=w.clientX-x.clientX,C=w.clientY-x.clientY,_=Math.sqrt(T*T+C*C),F=_/o.dist,E=t.getBoundingClientRect(),H=e.plotBox,$=o.midX-E.left-H.left;for(const G of e.scaleManager.getAllScales()){if(G.ori!==X.Horizontal||G.min==null||G.max==null)continue;const V=se($+H.left,G,H.width,H.left),O=V-(V-G.min)/F,J=V+(G.max-V)/F;G.min=Math.min(O,J),G.max=Math.max(O,J),G.auto=!1,he(G)}o.dist=_,e.renderer.clearCache(),e.scheduleRedraw(),u();return}const p=v.touches[0];p!=null&&(f(p,v),n!=null&&v.preventDefault())}function R(v){if(o!=null){o=null;return}v.changedTouches[0]!=null&&L()}return t.addEventListener("mousemove",m),t.addEventListener("mousedown",S),t.addEventListener("mouseup",g),t.addEventListener("click",b),t.addEventListener("contextmenu",P),t.addEventListener("mouseleave",k),t.addEventListener("dblclick",z),t.addEventListener("wheel",D,{passive:!1}),t.addEventListener("touchstart",y,{passive:!0}),t.addEventListener("touchmove",I,{passive:!1}),t.addEventListener("touchend",R),()=>{t.removeEventListener("mousemove",m),t.removeEventListener("mousedown",S),t.removeEventListener("mouseup",g),t.removeEventListener("click",b),t.removeEventListener("contextmenu",P),t.removeEventListener("mouseleave",k),t.removeEventListener("dblclick",z),t.removeEventListener("wheel",D),t.removeEventListener("touchstart",y),t.removeEventListener("touchmove",I),t.removeEventListener("touchend",R)}}const Ve=new Map;function xs(e){let t=Ve.get(e);return t==null&&(t=new bs(e),Ve.set(e,t)),t}class bs{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&&Ve.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 i of this.members)i!==t&&(this.syncedStores.add(i),i.cursorManager.hide(),i.scheduleCursorRedraw());this.publishing=!1;return}const l=t.dataStore.getXValues(s)[o];if(l==null){this.publishing=!1;return}for(const i of this.members)i!==t&&(this.syncedStores.add(i),i.cursorManager.syncToValue(l,i),i.scheduleCursorRedraw());this.publishing=!1}}function Ss(e,t){A.useEffect(()=>{if(t==null)return;const n=xs(t);n.join(e);let s=-1,o=-1;const r=e.subscribe(()=>{const{activeGroup:l,activeDataIdx:i}=e.cursorManager.state;l===s&&i===o||(s=l,o=i,n.pub(e))});return()=>{r(),n.leave(e)}},[e,t])}function Ht(e){return e instanceof Float64Array?e:new Float64Array(e)}function Gt(e){return e instanceof Float64Array||e.some(t=>t==null)?e:new Float64Array(e)}function mt(e){return{x:Ht(e.x),series:[Gt(e.y)]}}function Ms(e){return{x:Ht(e.x),series:e.series.map(Gt)}}function Oe(e){if(!Array.isArray(e))return[mt(e)];if(e.length===0)return[];const t=e[0];return t==null?[]:"series"in t?e.map(Ms):e.map(mt)}function Ue({width:e,height:t,data:n,children:s,className:o,pxRatio:r,title:l,xlabel:i,ylabel:a,onDraw:h,onCursorDraw:c,syncKey:d,cursor:u,onClick:f,onContextMenu:m,onDblClick:S,onCursorMove:L,onCursorLeave:g,onScaleChange:b,onSelect:P}){var F;const k=hs(),[z,D]=A.useState(null),M=r??(typeof window<"u"&&window.devicePixelRatio||1),y=u==null?void 0:u.wheelZoom,I=typeof y=="object"?JSON.stringify(y):y,R=((F=u==null?void 0:u.focus)==null?void 0:F.alpha)??((u==null?void 0:u.focus)!=null?.15:1);A.useEffect(()=>{k.wheelZoom=y,k.focusAlpha=R},[k,I,R]),A.useEffect(()=>{k.title=l,k.xlabel=i,k.ylabel=a},[k,l,i,a]);const v=A.useRef(k.eventCallbacks);v.current=k.eventCallbacks,A.useEffect(()=>{const E=v.current;E.onClick=f,E.onContextMenu=m,E.onDblClick=S,E.onCursorMove=L,E.onCursorLeave=g,E.onScaleChange=b,E.onSelect=P}),ws(k,z),Ss(k,d);const p=A.useCallback(E=>{k.canvas=E,E&&k.scheduleRedraw()},[k]),x=A.useCallback(E=>{D(E)},[]);A.useEffect(()=>{k.pxRatio=M,k.setSize(e,t)},[k,e,t,M]),A.useEffect(()=>()=>{k.canvas=null,k.scheduler.cancel(),k.focusedSeries=null},[k]),A.useEffect(()=>{if(z==null||typeof ResizeObserver>"u")return;const E=new ResizeObserver(H=>{const $=H[0];if($==null)return;const{width:G,height:V}=$.contentRect;G>0&&V>0&&(G!==k.width||V!==k.height)&&k.setSize(Math.round(G),Math.round(V))});return E.observe(z),()=>{E.disconnect()}},[k,z]);const w=A.useMemo(()=>Oe(n),[n]),T=A.useRef(n);A.useEffect(()=>{n===T.current&&k.dataStore.data.length>0||(T.current=n,k.dataStore.setData(w),k.renderer.clearCache(),k.scheduleRedraw())},[k,n,w]);const C=A.useRef(h);C.current=h,A.useEffect(()=>{const E=H=>{var $;($=C.current)==null||$.call(C,H)};return k.drawHooks.add(E),()=>{k.drawHooks.delete(E)}},[k]);const _=A.useRef(c);return _.current=c,A.useEffect(()=>{const E=(H,$)=>{var G;(G=_.current)==null||G.call(_,H,$)};return k.cursorDrawHooks.add(E),()=>{k.cursorDrawHooks.delete(E)}},[k]),W.jsx(zt.Provider,{value:k,children:W.jsxs("div",{className:o,style:{position:"relative",display:"flex",flexDirection:"column",width:`${e}px`},children:[W.jsx("div",{ref:x,style:{position:"relative",width:`${e}px`,height:`${t}px`,cursor:"crosshair",order:0},children:W.jsx("canvas",{ref:p,style:{position:"absolute",left:0,top:0}})}),s]})})}function wt(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function ys(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 Ke(e,t){if(e===null)return!1;const n=e,s=t,o=Object.keys(n),r=Object.keys(s);if(o.length!==r.length)return!1;for(const l of r){const i=n[l],a=s[l];if(i!==a)if(wt(i)&&wt(a)){if(!ys(i,a))return!1}else return!1}return!0}function Le(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const o=n.current;return t.registerScale({...o}),t.scheduleRedraw(),()=>{t.unregisterScale(o.id),t.scheduleRedraw()}},[t,e.id]);const s=A.useRef(null);return A.useEffect(()=>{Ke(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 $t(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 Cs(e,t=.8,n=0){const s=$t(e);if(s==null)return{type:"linear",stops:[[0,e],[1,e]]};const[o,r,l]=s;return{type:"linear",stops:[[0,`rgba(${o},${r},${l},${t})`],[1,`rgba(${o},${r},${l},${n})`]]}}function Wt(e,t){const n=$t(e);if(n==null)return e;const[s,o,r]=n;return`rgba(${s},${o},${r},${t})`}function ks(e,t=65,n=50){const s=[];for(let r=0;r<e;r++){const l=r*137.508%360;s.push(`hsl(${l.toFixed(1)},${t}%,${n}%)`)}return s}const vt=["#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085","#c0392b","#2980b9","#27ae60","#f1c40f","#8e44ad","#d35400"];function xt(e,t){var l;const n=(l=e.paths)==null?void 0:l.defaults,s=e.stroke??vt[t%vt.length]??"#000",o=e.fill??(n==null?void 0:n.fill),r=o==="auto"&&typeof s=="string"?Wt(s,.5):o==="auto"?void 0:o;return{...n,...e,yScale:e.yScale??"y",show:e.show??!0,stroke:s,fill:r}}function Ze(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const o=n.current;return t.registerSeries(xt(o,t.seriesConfigs.length)),t.renderer.clearGroupCache(o.group),t.scheduleRedraw(),()=>{t.unregisterSeries(o.group,o.index),t.renderer.clearGroupCache(o.group),t.scheduleRedraw()}},[t,e.group,e.index]);const s=A.useRef(null);return A.useEffect(()=>{if(!Ke(s.current,e)){s.current=e,t.seriesConfigs=t.seriesConfigs.map((o,r)=>o.group===e.group&&o.index===e.index?xt(e,r):o),t.seriesConfigMap.clear();for(const o of t.seriesConfigs)t.seriesConfigMap.set(`${o.group}:${o.index}`,o);t.renderer.invalidateSeries(e.group,e.index),t.scheduleRedraw()}}),null}function Ts(e){return{...e,side:e.side??(e.scale==="x"?Y.Bottom:Y.Left),show:e.show??!0}}function Ae(e){const t=Q(),n=Ts(e),s=A.useRef(n);s.current=n,A.useEffect(()=>{const r=s.current;return t.axisConfigs=t.axisConfigs.filter(l=>!(l.scale===r.scale&&l.side===r.side)),t.axisConfigs.push(r),t.scheduleRedraw(),()=>{t.axisConfigs=t.axisConfigs.filter(l=>!(l.scale===r.scale&&l.side===r.side)),t.scheduleRedraw()}},[t,n.scale,n.side]);const o=A.useRef(null);return A.useEffect(()=>{Ke(o.current,e)||(o.current=e,t.axisConfigs=t.axisConfigs.map(r=>r.scale===n.scale&&r.side===n.side?n:r),t.scheduleRedraw())}),null}function Is({series:e,group:t,fill:n,dir:s}){const o=Q(),r=A.useRef(null),l=e[0],i=e[1];return A.useEffect(()=>{const a={series:[l,i],group:t,fill:n,dir:s};return r.current!=null&&(o.bandConfigs=o.bandConfigs.filter(h=>h!==r.current)),r.current=a,o.bandConfigs.push(a),o.scheduleRedraw(),()=>{o.bandConfigs=o.bandConfigs.filter(h=>h!==r.current),r.current=null,o.scheduleRedraw()}},[o,l,i,t,n,s]),null}const Ls={width:12,height:3,borderRadius:1,display:"inline-block"},As={fontWeight:600},Vt={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},Ps={...Vt,opacity:1},Rs={...Vt,opacity:.4},bt=new Map,Ds=A.memo(function({group:t,index:n,label:s,color:o,isHidden:r,valueStr:l,store:i}){const a=A.useCallback(()=>{i.toggleSeries(t,n)},[i,t,n]);let h=bt.get(o);return h==null&&(h={...Ls,backgroundColor:o},bt.set(o,h)),W.jsxs("span",{onClick:a,style:r?Rs:Ps,children:[W.jsx("span",{style:h}),W.jsx("span",{children:s}),l&&W.jsx("span",{style:As,children:l})]})});function _s({show:e=!0,position:t="bottom",className:n}){const s=Q(),o=A.useRef({activeGroup:-1,activeDataIdx:-1,seriesCount:0,revision:-1}),r=A.useCallback(c=>s.subscribeCursor(c),[s]),l=A.useCallback(()=>{const{activeGroup:c,activeDataIdx:d}=s.cursorManager.state,u=s.seriesConfigs.length,{revision:f}=s,m=o.current;if(m.activeGroup===c&&m.activeDataIdx===d&&m.seriesCount===u&&m.revision===f)return m;const S={activeGroup:c,activeDataIdx:d,seriesCount:u,revision:f};return o.current=S,S},[s]),i=A.useSyncExternalStore(r,l);if(!e)return null;const{activeGroup:a,activeDataIdx:h}=i;return W.jsx("div",{className:n,style:{display:"flex",flexWrap:"wrap",justifyContent:"center",order:t==="top"?-1:1,padding:"4px 0"},children:s.seriesConfigs.map(c=>{if(c.legend===!1)return null;const d=typeof c.stroke=="string"?c.stroke:"#000";let u="";if(h>=0&&a>=0&&c.group===a){const m=s.dataStore.getYValues(c.group,c.index)[h];m!=null&&(u=typeof m=="number"?m.toPrecision(4):String(m))}return W.jsx(Ds,{group:c.group,index:c.index,label:c.label??`Series ${c.index}`,color:d,isHidden:c.show===!1,valueStr:u,store:s},`${c.group}:${c.index}`)})})}const Es={position:"absolute",zIndex:50,background:"rgba(255,255,255,0.92)",border:"1px solid #ccc",borderRadius:4,padding:"4px 6px",fontSize:12,fontFamily:"sans-serif",userSelect:"none",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",whiteSpace:"nowrap"},Fs={width:12,height:3,borderRadius:1,display:"inline-block",flexShrink:0},zs={fontWeight:600},Hs={display:"flex",alignItems:"center",gap:4,padding:"1px 4px"},qe=A.memo(function({label:t,color:n,value:s,isHidden:o,onClick:r}){return W.jsxs("div",{onClick:r,style:{...Hs,opacity:o?.4:1,cursor:r?"pointer":"default"},children:[W.jsx("span",{style:{...Fs,backgroundColor:n}}),W.jsx("span",{children:t}),s&&W.jsx("span",{style:zs,children:s})]})}),Re=A.forwardRef(function({left:t,top:n,children:s,className:o,style:r,onMouseDown:l,onMouseEnter:i,onMouseLeave:a},h){return W.jsx("div",{ref:h,className:o,onMouseDown:l,onMouseEnter:i,onMouseLeave:a,style:{...Es,left:t,top:n,...r},children:s})});function Gs(e,t,n,s,o){if(o<0||s<0)return"";const l=e.dataStore.getYValues(t,n)[o];return l==null?"":typeof l=="number"?l.toPrecision(4):String(l)}function $s({show:e=!0,className:t,children:n,offset:s={}}){var p,x;const o=Q(),r=A.useRef({left:-10,top:-10,activeGroup:-1,activeDataIdx:-1,revision:-1}),l=A.useRef(null),i=A.useCallback(w=>o.subscribeCursor(w),[o]),a=A.useCallback(()=>{const w=o.cursorManager.state,{revision:T}=o,C=r.current;if(C.left===w.left&&C.top===w.top&&C.activeGroup===w.activeGroup&&C.activeDataIdx===w.activeDataIdx&&C.revision===T)return C;const _={left:w.left,top:w.top,activeGroup:w.activeGroup,activeDataIdx:w.activeDataIdx,revision:T};return r.current=_,_},[o]),h=A.useSyncExternalStore(i,a);if(!e||h.activeDataIdx<0||h.activeGroup<0||h.left<0)return null;const{activeGroup:c,activeDataIdx:d}=h,u=o.plotBox,f=o.dataStore.data[c],m=f!=null?f.x[d]??null:null,S=m!=null?parseFloat(m.toPrecision(6)).toString():"",L=[];for(const w of o.seriesConfigs){if(w.show===!1||w.legend===!1)continue;const T=o.dataStore.getYValues(w.group,w.index),C=w.group===c?T[d]:null;L.push({label:w.label??`Series ${w.index}`,value:C,color:typeof w.stroke=="string"?w.stroke:"#000",group:w.group,index:w.index})}const g={x:m,xLabel:S,items:L,left:h.left+u.left,top:h.top+u.top},b=s.x??12,P=s.y??-12,k=((p=l.current)==null?void 0:p.offsetWidth)??0,z=((x=l.current)==null?void 0:x.offsetHeight)??0,D=h.left+u.left,M=h.top+u.top,y=u.left+u.width,I=u.top+u.height,R=Z(D+b,u.left,y-k),v=Z(M+P,u.top,I-z);return n?W.jsx("div",{ref:l,className:t,style:{position:"absolute",left:R,top:v,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100},children:n(g)}):W.jsxs(Re,{ref:l,left:R,top:v,className:t,style:{pointerEvents:"none",zIndex:100},children:[W.jsx("div",{style:{fontWeight:600,marginBottom:2,padding:"0 4px"},children:S}),L.map(w=>W.jsx(qe,{label:w.label,color:w.color,value:w.value!=null?w.value.toPrecision(4):"—"},`${w.group}:${w.index}`))]})}const Ws=8,St=.01,Vs=[.25,.75];function js({width:e,height:t,data:n,onRangeChange:s,initialRange:o,className:r,colors:l,grips:i=!1}){const a=A.useRef(null),h=A.useMemo(()=>Oe(n),[n]),[c,d]=A.useState(()=>{if(o!=null&&h.length>0){const D=h[0];if(D!=null&&D.x.length>1){const M=D.x[0],I=D.x[D.x.length-1]-M;if(I>0)return[Math.max(0,(o[0]-M)/I),Math.min(1,(o[1]-M)/I)]}}return Vs}),u=A.useRef(null);A.useEffect(()=>{if(s==null||h.length===0)return;const D=h[0];if(D==null||D.x.length<2)return;const M=D.x[0],I=D.x[D.x.length-1]-M,R=M+c[0]*I,v=M+c[1]*I,p=u.current,x=Math.max(1e-10,Math.abs(v-R)*1e-12);p!=null&&Math.abs(p[0]-R)<x&&Math.abs(p[1]-v)<x||(u.current=[R,v],s(R,v))},[c,h,s]);const f=A.useRef(null),m=A.useCallback(D=>{const M=a.current;if(M==null)return 0;const y=M.getBoundingClientRect();return Z((D-y.left)/y.width,0,1)},[]),S=A.useCallback(D=>{const M=a.current;if(M==null)return;const y=m(D.clientX),I=M.getBoundingClientRect().width,R=I>0?Ws/I:0;let v;if(Math.abs(y-c[0])<R)v="left";else if(Math.abs(y-c[1])<R)v="right";else if(y>=c[0]&&y<=c[1])v="move";else{const p=c[1]-c[0],x=p/2,w=Z(y-x,0,1-p);d([w,w+p]),v="move"}f.current={mode:v,startX:D.clientX,startFrac:[...c]},M.setPointerCapture(D.pointerId),D.preventDefault()},[c,m]),L=A.useCallback(D=>{const M=f.current;if(M==null)return;const y=m(D.clientX),I=m(M.startX),R=y-I;if(M.mode==="move"){const v=M.startFrac[1]-M.startFrac[0],p=Z(M.startFrac[0]+R,0,1-v);d([p,p+v])}else if(M.mode==="left"){const v=Z(M.startFrac[0]+R,0,M.startFrac[1]-St);d([v,M.startFrac[1]])}else{const v=Z(M.startFrac[1]+R,M.startFrac[0]+St,1);d([M.startFrac[0],v])}},[m]),g=A.useCallback(D=>{f.current=null;const M=a.current;M!=null&&M.releasePointerCapture(D.pointerId)},[]),b=`${c[0]*100}%`,P=`${(c[1]-c[0])*100}%`,k=h[0],z=k!=null?k.series.length:0;return W.jsxs("div",{className:r,style:{position:"relative",width:e,height:t},children:[W.jsxs(Ue,{width:e,height:t,data:n,children:[W.jsx(Le,{id:"x"}),W.jsx(Le,{id:"y"}),W.jsx(Ae,{scale:"x",show:!1}),W.jsx(Ae,{scale:"y",show:!1}),Array.from({length:z},(D,M)=>W.jsx(Ze,{group:0,index:M,yScale:"y",stroke:l!=null&&l[M]!=null?l[M]:`hsl(${M*137}, 60%, 50%)`,width:1},M))]}),W.jsxs("div",{ref:a,onPointerDown:S,onPointerMove:L,onPointerUp:g,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[W.jsx("div",{style:{position:"absolute",top:0,left:0,width:b,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),W.jsx("div",{style:{position:"absolute",top:0,left:`${c[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),W.jsx("div",{style:{position:"absolute",top:0,left:b,width:P,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:i&&W.jsxs(W.Fragment,{children:[W.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"}}),W.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 ye(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const s=o=>n.current(o);return t.drawHooks.add(s),()=>{t.drawHooks.delete(s)}},[t])}function Xs(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const s=(o,r)=>n.current(o,r);return t.cursorDrawHooks.add(s),()=>{t.cursorDrawHooks.delete(s)}},[t])}function Bs({lanes:e,laneHeight:t=24,gap:n=2,scaleId:s="x"}){const o=Q();return ye(({ctx:r,plotBox:l,pxRatio:i})=>{const a=o.scaleManager.getScale(s);if(a==null||a.min==null||a.max==null)return;r.save(),r.beginPath(),r.rect(l.left*i,l.top*i,l.width*i,l.height*i),r.clip();const h=(t+n)*i,c=t*i,d=l.top*i;for(let u=0;u<e.length;u++){const f=e[u];if(f==null)continue;const m=d+u*h;r.fillStyle="#666",r.font=`${11*i}px sans-serif`,r.textAlign="right",r.textBaseline="middle",r.fillText(f.label,(l.left-6)*i,m+c/2);for(const S of f.segments){const L=j(S.start,a,l.width,l.left)*i,b=j(S.end,a,l.width,l.left)*i-L;b<=0||(r.fillStyle=S.color??"#4dabf7",r.fillRect(L,m,b,c),S.label!=null&&b>20*i&&(r.fillStyle="#fff",r.font=`${10*i}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(S.label,L+b/2,m+c/2,b-4*i)))}}r.restore()}),null}function Ys({data:e,width:t=150,height:n=30,stroke:s="#03a9f4",fill:o,lineWidth:r=1,paths:l,fillTo:i,className:a}){return W.jsx("div",{style:{pointerEvents:"none"},className:a,children:W.jsxs(Ue,{width:t,height:n,data:e,children:[W.jsx(Le,{id:"x"}),W.jsx(Le,{id:"y"}),W.jsx(Ae,{scale:"x",show:!1}),W.jsx(Ae,{scale:"y",show:!1}),W.jsx(Ze,{group:0,index:0,yScale:"y",stroke:s,fill:o,width:r,paths:l,fillTo:i})]})})}const re=8;function Mt(e,t,n,s){if(e!=null&&typeof e=="object")return e;switch(e){case"top-left":return{x:t.left+re,y:t.top+re};case"bottom-left":return{x:t.left+re,y:t.top+t.height-s-re};case"bottom-right":return{x:t.left+t.width-n-re,y:t.top+t.height-s-re};case"top-right":default:return{x:t.left+t.width-n-re,y:t.top+re}}}function Ns({mode:e="draggable",position:t="top-right",offset:n={x:12,y:-12},idleOpacity:s=.3,show:o=!0,className:r}){var v,p;const l=Q(),i=A.useRef(null),[a,h]=A.useState(null),[c,d]=A.useState(!1),u=A.useRef(!1),f=A.useRef(!1),m=A.useRef({dx:0,dy:0}),S=A.useRef(!1),L=A.useRef(null),g=A.useCallback(x=>l.subscribeCursor(x),[l]),b=A.useCallback(()=>{const{activeGroup:x,activeDataIdx:w,left:T,top:C}=l.cursorManager.state,_=l.seriesConfigs.length,{revision:F}=l,{left:E,top:H,width:$,height:G}=l.plotBox,V=i.current;if(V!=null&&V.activeGroup===x&&V.activeDataIdx===w&&V.cursorLeft===T&&V.cursorTop===C&&V.seriesCount===_&&V.revision===F&&V.plotLeft===E&&V.plotTop===H&&V.plotWidth===$&&V.plotHeight===G)return V;const O={activeGroup:x,activeDataIdx:w,cursorLeft:T,cursorTop:C,seriesCount:_,revision:F,plotLeft:E,plotTop:H,plotWidth:$,plotHeight:G};return i.current=O,O},[l]),P=A.useSyncExternalStore(g,b);e==="draggable"&&!S.current&&P.plotWidth>0&&(S.current=!0,a==null&&h(Mt(t,l.plotBox,0,0))),A.useLayoutEffect(()=>{if(e!=="draggable"||!S.current||L.current==null)return;const x=L.current,w=x.offsetWidth,T=x.offsetHeight;w===0&&T===0||typeof t!="object"&&h(Mt(t,l.plotBox,w,T))},[S.current]);const k=A.useCallback((x,w)=>{f.current||l.toggleSeries(x,w)},[l]),z=A.useCallback(x=>{if(e!=="draggable")return;x.stopPropagation(),x.preventDefault(),u.current=!0,f.current=!1;const w=x.currentTarget.getBoundingClientRect();m.current={dx:x.clientX-w.left,dy:x.clientY-w.top}},[e]);if(A.useEffect(()=>{if(!o||e!=="draggable")return;const x=T=>{var F;if(!u.current)return;f.current=!0;const C=(F=l.canvas)==null?void 0:F.parentElement;if(!C)return;const _=C.getBoundingClientRect();h({x:T.clientX-_.left-m.current.dx,y:T.clientY-_.top-m.current.dy})},w=()=>{u.current=!1};return window.addEventListener("mousemove",x),window.addEventListener("mouseup",w),()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",w)}},[l,o,e]),!o)return null;const{activeGroup:D,activeDataIdx:M,cursorLeft:y,cursorTop:I}=P,R=l.seriesConfigs.filter(x=>x.legend!==!1).map(x=>{const w=typeof x.stroke=="string"?x.stroke:"#000",T=Gs(l,x.group,x.index,D,M),C=e==="draggable";return W.jsx(qe,{label:x.label??`Series ${x.index}`,color:w,value:T,isHidden:x.show===!1,onClick:C?()=>k(x.group,x.index):void 0},`${x.group}:${x.index}`)});if(e==="cursor"){if(y<0)return null;const x=((v=L.current)==null?void 0:v.offsetWidth)??0,w=((p=L.current)==null?void 0:p.offsetHeight)??0,T=P.plotLeft+P.plotWidth,C=P.plotTop+P.plotHeight,_=Z(y+P.plotLeft+n.x,P.plotLeft,T-x),F=Z(I+P.plotTop+n.y,P.plotTop,C-w);return W.jsx(Re,{ref:L,left:_,top:F,className:r,style:{pointerEvents:"none"},children:R})}return a==null?null:W.jsx(Re,{ref:L,left:a.x,top:a.y,className:r,onMouseDown:z,onMouseEnter:()=>d(!0),onMouseLeave:()=>{d(!1),f.current=!1},style:{pointerEvents:"auto",cursor:u.current?"grabbing":"grab",opacity:c||u.current?1:s,transition:"opacity 0.2s ease"},children:R})}function Os({delay:e=1e3,show:t=!0,className:n}){var z,D;const s=Q(),o=A.useRef(null),[r,l]=A.useState(!1),i=A.useRef(-1),a=A.useRef(0),h=A.useRef(null),c=A.useCallback(M=>s.subscribe(M),[s]),d=A.useCallback(()=>{const{left:M,top:y,activeSeriesIdx:I,activeGroup:R}=s.cursorManager.state,{left:v,top:p,width:x,height:w}=s.plotBox,T=o.current;if(T!=null&&T.cursorLeft===M&&T.cursorTop===y&&T.activeSeriesIdx===I&&T.activeGroup===R&&T.plotLeft===v&&T.plotTop===p&&T.plotWidth===x&&T.plotHeight===w)return T;const C={cursorLeft:M,cursorTop:y,activeSeriesIdx:I,activeGroup:R,plotLeft:v,plotTop:p,plotWidth:x,plotHeight:w};return o.current=C,C},[s]),u=A.useSyncExternalStore(c,d);if(A.useEffect(()=>{const M=u.activeSeriesIdx;M!==i.current&&(i.current=M,l(!1),window.clearTimeout(a.current),M>=0&&(a.current=window.setTimeout(()=>l(!0),e)))},[u.activeSeriesIdx,e]),A.useEffect(()=>()=>{window.clearTimeout(a.current)},[]),!t||!r||u.cursorLeft<0)return null;const f=s.seriesConfigs.find(M=>M.group===u.activeGroup&&M.index===u.activeSeriesIdx);if(!(f!=null&&f.label)||f.legend===!1)return null;const m=typeof f.stroke=="string"?f.stroke:"#000",S=((z=h.current)==null?void 0:z.offsetWidth)??80,L=((D=h.current)==null?void 0:D.offsetHeight)??24,g=u.cursorLeft+u.plotLeft,b=u.cursorTop+u.plotTop,P=Z(g-S/2,u.plotLeft,u.plotLeft+u.plotWidth-S),k=Z(b-L-12,u.plotTop,u.plotTop+u.plotHeight-L);return W.jsx(Re,{ref:h,left:P,top:k,className:n,style:{pointerEvents:"none"},children:W.jsx(qe,{label:f.label,color:m})})}const Us=4;function jt(e,t,n,s={}){const{ctx:o,plotBox:r}=e,l=j(n,t,r.height,r.top);o.beginPath(),o.moveTo(r.left,l),o.lineTo(r.left+r.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 Xt(e,t,n,s={}){const{ctx:o,plotBox:r}=e,l=j(n,t,r.width,r.left);o.beginPath(),o.moveTo(l,r.top),o.lineTo(l,r.top+r.height),o.strokeStyle=s.stroke??"red",o.lineWidth=s.width??1,s.dash&&o.setLineDash(s.dash),o.stroke(),s.dash&&o.setLineDash([])}function Ks(e,t,n,s,o,r,l={}){const{ctx:i,plotBox:a}=e,h=j(s,t,a.width,a.left),c=j(o,n,a.height,a.top);i.font=l.font??"12px sans-serif",i.fillStyle=l.fill??"#000",i.textBaseline="bottom",i.fillText(r,h,c-Us)}function Bt(e,t,n,s,o={}){const{ctx:r,plotBox:l}=e,i=j(s,t,l.height,l.top),a=j(n,t,l.height,l.top);r.fillStyle=o.fill??"rgba(255,0,0,0.1)",r.fillRect(l.left,Math.min(i,a),l.width,Math.abs(a-i)),o.stroke&&(r.strokeStyle=o.stroke,r.lineWidth=o.width??1,o.dash&&r.setLineDash(o.dash),r.strokeRect(l.left,Math.min(i,a),l.width,Math.abs(a-i)),o.dash&&r.setLineDash([]))}function Zs(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),ye(n=>{const s=t.current,o=s.yScale??"y",r=n.getScale(o);if(r!=null&&(jt(n,r,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:i,plotBox:a}=n;i.font=s.labelFont??"11px sans-serif",i.fillStyle=s.stroke??"red",i.textAlign="left",i.textBaseline="bottom",i.fillText(s.label,a.left+4,l-4)}}),null}function qs(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),ye(n=>{const s=t.current,o=s.xScale??"x",r=n.getScale(o);if(r!=null&&(Xt(n,r,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:i,plotBox:a}=n;i.font=s.labelFont??"11px sans-serif",i.fillStyle=s.stroke??"red",i.textAlign="center",i.textBaseline="bottom",i.fillText(s.label,l,a.top-4)}}),null}function Js(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),ye(n=>{const s=t.current,o=n.getScale(s.yScale??"y");o!=null&&Bt(n,o,s.yMin,s.yMax,{fill:s.fill,stroke:s.stroke,width:s.strokeWidth,dash:s.dash})}),null}function Qs(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),ye(n=>{const s=t.current,o=n.valToX(s.x,s.xScale??"x"),r=n.valToY(s.y,s.yScale??"y");if(o==null||r==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,r-4)}),null}function eo(e,t){const{window:n,batchSize:s=1}=t,o=t.autoStart??!0,[r,l]=A.useState(()=>Oe(e)),[i,a]=A.useState(!1),[h,c]=A.useState(0),d=A.useRef(0),u=A.useRef(0),f=A.useRef(0),m=A.useRef(new Map),S=A.useRef(0),L=A.useRef(n);L.current=n;const g=A.useRef(s);g.current=s;const b=A.useCallback((D,M,...y)=>{let I=m.current.get(D);I==null&&(I={x:[],series:y.map(()=>[])},m.current.set(D,I)),I.x.push(...M);for(let v=0;v<y.length;v++){let p=I.series[v];p==null&&(p=[],I.series[v]=p),p.push(...y[v]??[])}const R=I.x.length;S.current===0&&R>=g.current&&(S.current=requestAnimationFrame(()=>{S.current=0;const v=m.current;m.current=new Map;const p=L.current;l(x=>{const w=x.slice();for(const[T,{x:C,series:_}]of v){const F=w[T];if(F==null)continue;const E=F.x,H=Math.max(0,E.length+C.length-p),$=H>0?E.slice(H).concat(C):E.concat(C),G=F.series.map((V,O)=>{const J=V,me=_[O]??[];return H>0?J.slice(H).concat(me):J.concat(me)});w[T]={x:$,series:G}}return w})}))},[]),P=A.useCallback((D,...M)=>{b(0,D,...M)},[b]),k=A.useCallback(()=>{a(!0)},[]),z=A.useCallback(()=>{a(!1)},[]);return A.useEffect(()=>{if(!i){d.current!==0&&(cancelAnimationFrame(d.current),d.current=0);return}f.current=performance.now(),u.current=0;const D=M=>{u.current++;const y=M-f.current;y>=1e3&&(c(Math.round(u.current*1e3/y)),u.current=0,f.current=M),d.current=requestAnimationFrame(D)};return d.current=requestAnimationFrame(D),()=>{d.current!==0&&(cancelAnimationFrame(d.current),d.current=0)}},[i]),A.useEffect(()=>()=>{S.current!==0&&cancelAnimationFrame(S.current)},[]),A.useEffect(()=>{o&&a(!0)},[o]),{data:r,push:P,pushGroup:b,start:k,stop:z,running:i,fps:h}}function to(e){const t=(n,s,o,r,l,i,a,h,c,d,u,f,m)=>{const S=(m==null?void 0:m.align)??e??1,L=(m==null?void 0:m.spanGaps)??!1;if([c,d]=De(s,c,d),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const g=R=>f(j(R,o,l,a)),b=R=>f(j(R,r,i,h)),P=o.ori===X.Horizontal?_e:Ee,k={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},z=k.stroke;let D=!1;const M=u===N.Forward?c:d;let y=b(s[M]),I=g(n[M]);P(z,I,y);for(let R=M;R>=c&&R<=d;R+=u){const v=s[R];if(v==null){v===null&&!L&&(D=!0);continue}const p=g(n[R]),x=b(v);if(S===1)P(z,p,y);else if(S===-1)P(z,I,x);else{const w=f((I+p)/2);P(z,w,y),P(z,w,x)}P(z,p,x),y=x,I=p}{const R=k.fill=new Path2D(z),v=(m==null?void 0:m.fillTo)??r.min??0,p=b(v);let x=a,w=a+l;u===N.Backward&&([w,x]=[x,w]),P(R,w,p),P(R,x,p)}if(D){const R=Ye(n,s,c,d,u,g);k.gaps=R,k.clip=Ne(R,o.ori,a,h,l,i)}return k};return t.defaults=Be,t}function Je(e){return e.defaults=dn,e}function Yt(){return Je((t,n,s,o,r,l,i,a,h,c,d,u,f)=>{const m=(f==null?void 0:f.barWidth)??.6,S=(f==null?void 0:f.barGap)??0,L=(f==null?void 0:f.barRadius)??0,g=(f==null?void 0:f.barGroupIdx)??0,b=(f==null?void 0:f.barGroupCount)??1,P=w=>u(j(w,s,r,i)),k=w=>u(j(w,o,l,a));let z=r;if(c>h){let w=1/0,T=-1;for(let C=h;C<=c;C++)if(n[C]!=null){if(T>=0){const _=t[C],F=t[T],E=Math.abs(P(_)-P(F));E<w&&(w=E)}T=C}w<1/0&&(z=w)}const D=z*(1-m),M=Math.max(0,D+S),y=Math.max(1,u(z-M)),I=b>1?Math.max(1,u(y/Math.max(1,b))):y,R=(f==null?void 0:f.fillTo)??o.min??0,v=k(R),p=new Path2D,x=s.ori===X.Horizontal;for(let w=d===N.Forward?h:c;w>=h&&w<=c;w+=d){const T=n[w];if(T==null)continue;const C=P(t[w]),_=k(T),F=b>1?(g-(b-1)/2)*I:0,E=u(C-I/2+F),H=Math.min(_,v),G=Math.max(_,v)-H;if(G!==0)if(L>0){const V=Math.min(L*I,G/2);Nt(p,x,E,H,I,G,V,T<R)}else x?p.rect(E,H,I,G):p.rect(H,E,G,I)}return{stroke:p,fill:p,clip:null,band:null,gaps:null}})}function no(e,t){const n=Yt();return Je((o,r,l,i,a,h,c,d,u,f,m,S,L)=>{const g={...L,barGroupIdx:e,barGroupCount:t};return n(o,r,l,i,a,h,c,d,u,f,m,S,g)})}function so(){return Je((t,n,s,o,r,l,i,a,h,c,d,u,f)=>{const m=(f==null?void 0:f.barWidth)??.8,S=(f==null?void 0:f.barGap)??0,L=(f==null?void 0:f.barRadius)??0,g=v=>u(j(v,s,r,i)),b=v=>u(j(v,o,l,a));let P=r;if(c>h){let v=1/0,p=-1;for(let x=h;x<=c;x++)if(n[x]!=null){if(p>=0){const w=t[x],T=t[p],C=Math.abs(g(w)-g(T));C<v&&(v=C)}p=x}v<1/0&&(P=v)}const k=P*(1-m),z=Math.max(0,k+S),D=Math.max(1,u(P-z)),M=(f==null?void 0:f.fillTo)??o.min??0,y=b(M),I=new Path2D,R=s.ori===X.Horizontal;for(let v=d===N.Forward?h:c;v>=h&&v<=c;v+=d){const p=n[v];if(p==null)continue;const x=g(t[v]),w=b(p),T=u(x-D/2),C=Math.min(w,y),F=Math.max(w,y)-C;if(F!==0)if(L>0){const E=Math.min(L*D,F/2);Nt(I,R,T,C,D,F,E,p<M)}else R?I.rect(T,C,D,F):I.rect(C,T,F,D)}return{stroke:I,fill:I,clip:null,band:null,gaps:null}})}function Nt(e,t,n,s,o,r,l,i){l=Math.min(l,o/2,r/2),t?i?(e.moveTo(n,s),e.lineTo(n+o,s),e.lineTo(n+o,s+r-l),e.arc(n+o-l,s+r-l,l,0,Math.PI/2),e.lineTo(n+l,s+r),e.arc(n+l,s+r-l,l,Math.PI/2,Math.PI),e.closePath()):(e.moveTo(n,s+r),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+r),e.closePath()):i?(e.moveTo(s,n),e.lineTo(s,n+o),e.lineTo(s+r-l,n+o),e.arc(s+r-l,n+o-l,l,Math.PI/2,0,!0),e.lineTo(s+r,n+l),e.arc(s+r-l,n+l,l,0,-Math.PI/2,!0),e.closePath()):(e.moveTo(s+r,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+r,n+o),e.closePath())}function Ot(e){const t=(n,s,o,r,l,i,a,h,c,d,u,f,m)=>{const S=(m==null?void 0:m.spanGaps)??!1;if([c,d]=De(s,c,d),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const L=I=>f(j(I,o,l,a)),g=I=>f(j(I,r,i,h)),b=o.ori===X.Horizontal?_e:Ee,P=[],k=[];let z=!1;for(let I=u===N.Forward?c:d;I>=c&&I<=d;I+=u){const R=s[I];R!=null?(P.push(L(n[I])),k.push(g(R))):R===null&&!S&&(z=!0)}const D=o.ori===X.Horizontal,M=e(P,k,D,f),y={stroke:M??new Path2D,fill:null,clip:null,band:null,gaps:null};if(M!=null){const I=y.fill=new Path2D(M),R=(m==null?void 0:m.fillTo)??r.min??0,v=g(R);let p=a,x=a+l;u===N.Backward&&([x,p]=[p,x]),b(I,x,v),b(I,p,v)}if(z){const I=Ye(n,s,c,d,u,L);y.gaps=I,y.clip=Ne(I,o.ori,a,h,l,i)}return y};return t.defaults=Be,t}function oo(){return Ot(lo)}const lo=(e,t,n,s)=>{const o=e.length;if(o<2)return null;const r=new Path2D,l=e[0]??0,i=t[0]??0;if(n?r.moveTo(l,i):r.moveTo(i,l),o===2){const u=e[1]??0,f=t[1]??0;return n?r.lineTo(u,f):r.lineTo(f,u),r}const a=new Array(o),h=new Array(o-1),c=new Array(o-1),d=new Array(o-1);for(let u=0;u<o-1;u++)c[u]=(t[u+1]??0)-(t[u]??0),d[u]=(e[u+1]??0)-(e[u]??0),h[u]=d[u]!==0?(c[u]??0)/(d[u]??1):0;a[0]=h[0]??0;for(let u=1;u<o-1;u++){const f=h[u]??0,m=h[u-1]??0;if(f===0||m===0||m>0!=f>0)a[u]=0;else{const S=d[u]??1,L=d[u-1]??1;a[u]=3*(L+S)/((2*S+L)/m+(S+2*L)/f),isFinite(a[u]??0)||(a[u]=0)}}a[o-1]=h[o-2]??0;for(let u=0;u<o-1;u++){const f=d[u]??1,m=e[u]??0,S=t[u]??0,L=e[u+1]??0,g=t[u+1]??0,b=a[u]??0,P=a[u+1]??0,k=m+f/3,z=S+b*f/3,D=L-f/3,M=g-P*f/3;n?r.bezierCurveTo(k,z,D,M,L,g):r.bezierCurveTo(z,k,M,D,g,L)}return r};function ro(){return Ot(io)}const io=(e,t,n,s)=>{const o=e.length;if(o<2)return null;const r=new Path2D,l=s(e[0]??0),i=s(t[0]??0);if(n?r.moveTo(l,i):r.moveTo(i,l),o===2){const a=s(e[1]??0),h=s(t[1]??0);return n?r.lineTo(a,h):r.lineTo(h,a),r}for(let a=0;a<o-1;a++){const h=a===0?0:a-1,c=e[h]??0,d=t[h]??0,u=e[a]??0,f=t[a]??0,m=e[a+1]??0,S=t[a+1]??0,L=a+2<o?e[a+2]??0:m,g=a+2<o?t[a+2]??0:S,b=Math.hypot(c-u,d-f),P=Math.hypot(u-m,f-S),k=Math.hypot(m-L,S-g),z=Math.sqrt(k),D=k,M=Math.sqrt(P),y=P,I=Math.sqrt(b),R=b,v=2*R+3*I*M+y,p=2*D+3*z*M+y,x=3*I*(I+M),w=3*z*(z+M);let T,C,_,F;if(x>0){const E=1/x;T=(-y*c+v*u+R*m)*E,C=(-y*d+v*f+R*S)*E}else T=u,C=f;if(w>0){const E=1/w;_=(D*u+p*m-y*L)*E,F=(D*f+p*S-y*g)*E}else _=m,F=S;n?r.bezierCurveTo(T,C,_,F,m,S):r.bezierCurveTo(C,T,F,_,S,m)}return r};function ao(e=4){const t=(n,s,o,r,l,i,a,h,c,d,u,f,m)=>{const S=k=>f(j(k,o,l,a)),L=k=>f(j(k,r,i,h)),g=e/2,b=new Path2D,P=o.ori===X.Horizontal;for(let k=u===N.Forward?c:d;k>=c&&k<=d;k+=u){const z=s[k];if(z==null)continue;const D=S(n[k]),M=L(z);P?(b.moveTo(D+g,M),b.arc(D,M,g,0,Math.PI*2)):(b.moveTo(M+g,D),b.arc(M,D,g,0,Math.PI*2))}return{stroke:b,fill:b,clip:null,band:null,gaps:null}};return t.defaults=gn,t}function co(e){return({ctx:t,plotBox:n,pxRatio:s})=>{const{xValues:o,open:r,high:l,low:i,close:a,xScale:h,yScale:c,upColor:d="#26a69a",downColor:u="#ef5350",bodyWidth:f=.6,wickWidth:m=1}=e;if(h.min==null||h.max==null||c.min==null||c.max==null)return;const S=o.length;if(S===0)return;const g=Math.max(2,n.width/S*f)*s/2;t.save();for(let b=0;b<S;b++){const P=o[b],k=r[b],z=l[b],D=i[b],M=a[b];if(P==null||k==null||z==null||D==null||M==null)continue;const y=j(P,h,n.width,n.left)*s,I=j(k,c,n.height,n.top)*s,R=j(z,c,n.height,n.top)*s,v=j(D,c,n.height,n.top)*s,p=j(M,c,n.height,n.top)*s,w=M>=k?d:u;t.strokeStyle=w,t.lineWidth=m*s,t.beginPath(),t.moveTo(y,R),t.lineTo(y,v),t.stroke();const T=Math.min(I,p),C=Math.abs(p-I);t.fillStyle=w,t.fillRect(y-g,T,g*2,Math.max(C,1*s))}t.restore()}}function uo(e,t,n=0){const s=t??e.series.map((c,d)=>d),o=e.x.length,r=[],l=new Float64Array(o);for(let c=0;c<s.length;c++){const d=s[c];if(d==null)continue;const u=e.series[d];if(u==null)continue;const f=new Array(o);for(let m=0;m<o;m++){const S=u[m];S!=null?(l[m]=l[m]+S,f[m]=l[m]):f[m]=null}r.push(f)}const i=new Map;for(let c=0;c<s.length;c++){const d=s[c];d!=null&&i.set(d,c)}const a=[];for(let c=0;c<e.series.length;c++){const d=i.get(c)??-1,u=d>=0?r[d]:void 0;u!=null?a.push(u):a.push(e.series[c]??[])}const h=[];for(let c=s.length-1;c>0;c--){const d=s[c],u=s[c-1];d!=null&&u!=null&&h.push({group:n,series:[d,u]})}return{group:{x:e.x,series:a},bands:h}}function fo(e){const t=new Set;for(const[r]of e)for(let l=0;l<r.length;l++){const i=r[l];i!=null&&t.add(i)}const n=Float64Array.from([...t].sort((r,l)=>r-l)),s=new Map;for(let r=0;r<n.length;r++){const l=n[r];l!=null&&s.set(l,r)}const o=[];for(const[r,l]of e){const i=new Array(n.length).fill(null);for(let a=0;a<r.length;a++){const h=r[a];if(h==null)continue;const c=s.get(h);c!=null&&(i[c]=l[a]??null)}o.push(i)}return[{x:n,series:o}]}function ho(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 go(e,t=0){return n=>n.map(s=>s.toFixed(t)+e)}function po(e,t=0){return n=>n.map(s=>e+s.toFixed(t))}function mo(e,t,n=0){return s=>s.map(o=>e+o.toFixed(n)+t)}function wo(e){const t=(e==null?void 0:e.utc)??!1;return n=>n.map(s=>t?ee(s,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):ee(s,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function vo(e){const t=e!=null&&e.utc?"UTC":void 0,n=(e==null?void 0:e.format)??"short";return s=>s.map(o=>ee(o,{month:n},t))}function xo(e){const{tz:t,...n}=e??{};return s=>s.map(o=>ee(o,n,t))}function bo(e,t=0){return n=>n.map(s=>{const o=Math.round(s)-t;return e[o]??String(s)})}exports.AnnotationLabel=Qs;exports.Axis=Ae;exports.Band=Is;exports.Chart=Ue;exports.Direction=N;exports.Distribution=U;exports.FloatingLegend=Ns;exports.HLine=Zs;exports.HoverLabel=Os;exports.Legend=_s;exports.Orientation=X;exports.Region=Js;exports.Scale=Le;exports.Series=Ze;exports.Side=Y;exports.SortOrder=xe;exports.Sparkline=Ys;exports.Timeline=Bs;exports.Tooltip=$s;exports.VLine=qs;exports.ZoomRanger=js;exports.alignData=fo;exports.bars=Yt;exports.catmullRom=ro;exports.drawCandlesticks=co;exports.drawHLine=jt;exports.drawLabel=Ks;exports.drawRegion=Bt;exports.drawVLine=Xt;exports.fadeGradient=Cs;exports.fmtCompact=ho;exports.fmtDateStr=xo;exports.fmtHourMin=wo;exports.fmtLabels=bo;exports.fmtMonthName=vo;exports.fmtPrefix=po;exports.fmtSuffix=go;exports.fmtWrap=mo;exports.groupedBars=no;exports.linear=Et;exports.monotoneCubic=oo;exports.palette=ks;exports.points=ao;exports.posToVal=se;exports.sideOrientation=pe;exports.stackGroup=uo;exports.stackedBars=so;exports.stepped=to;exports.useChart=Q;exports.useCursorDrawHook=Xs;exports.useDrawHook=ye;exports.useStreamingData=eo;exports.valToPos=j;exports.withAlpha=Wt;
|
|
1
|
+
"use strict";var wn=Object.defineProperty;var Sn=(t,e,n)=>e in t?wn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var j=(t,e,n)=>Sn(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react/jsx-runtime"),D=require("react");function vn(t=.15){return e=>{e.focusAlpha=t}}const Rt=[["leftDrag","zoomX"],["leftDblclick","reset"],["wheel","zoomX"],["xGutterDrag","panX"],["yGutterDrag","panY"],["pinch","zoomX"],["touchDrag","zoomX"]];var Y=(t=>(t[t.Top=0]="Top",t[t.Right=1]="Right",t[t.Bottom=2]="Bottom",t[t.Left=3]="Left",t))(Y||{}),H=(t=>(t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical",t))(H||{}),O=(t=>(t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward",t))(O||{}),K=(t=>(t[t.Linear=1]="Linear",t[t.Ordinal=2]="Ordinal",t[t.Log=3]="Log",t[t.Asinh=4]="Asinh",t))(K||{}),xt=(t=>(t[t.Ascending=1]="Ascending",t[t.Descending=-1]="Descending",t[t.Unsorted=0]="Unsorted",t))(xt||{});function St(t){return t%2}var tt=(t=>(t[t.None=0]="None",t[t.Scales=1]="Scales",t[t.Axes=2]="Axes",t[t.Paths=4]="Paths",t[t.Cursor=8]="Cursor",t[t.Select=16]="Select",t[t.Size=32]="Size",t[t.Full=63]="Full",t))(tt||{});const J=Math,Xt=J.PI,et=J.abs,st=J.floor,B=J.round,It=J.ceil,te=J.min,yt=J.max,pt=J.pow,be=J.sign,nt=J.log10,kt=J.log2,bn=(t,e=1)=>J.sinh(t)*e,oe=(t,e=1)=>J.asinh(t/e),q=1/0,je=Number.isInteger;function jt(t,e){return t[e]??0}function ft(t,e,n=0,o=e.length-1){let s;const r=o<=2147483647;for(;o-n>1;)s=r?n+o>>1:st((n+o)/2),jt(e,s)<t?n=s:o=s;return t-jt(e,n)<=jt(e,o)-t?n:o}const Ye=t=>t!=null,Ne=t=>t!=null&&t>0;function Ue(t){return(e,n,o)=>{let s=-1,r=-1;for(let i=n;i<=o;i++)if(t(e[i])){s=i;break}for(let i=o;i>=n;i--)if(t(e[i])){r=i;break}return[s,r]}}const Ht=Ue(Ye),Oe=Ue(Ne);function Mn(t,e,n,o=xt.Unsorted,s=!1){const r=s?Oe:Ht,i=s?Ne:Ye,[l,c]=r(t,e,n);let f=t[l]??q,a=t[l]??-q;if(l>-1)if(o===xt.Ascending)f=t[l]??q,a=t[c]??-q;else if(o===xt.Descending)f=t[c]??q,a=t[l]??-q;else for(let d=l;d<=c;d++){const u=t[d];u!=null&&i(u)&&(u<f?f=u:u>a&&(a=u))}return[f,a]}function it(t,e=0){if(je(t))return t;const n=10**e,o=t*n*(1+Number.EPSILON);return B(o)/n}const Ct=new Map;function xn(t){return(String(t).split(".")[1]??"").length}const yn=/\.\d*?(?=9{6,}|0{6,})/gm;function wt(t){if(je(t)||Ct.has(t))return t;const e=`${t}`,n=e.match(yn);if(n==null)return t;const o=n[0].length-1;if(e.indexOf("e-")!==-1){const s=e.split("e"),r=s[0]??"0",i=s[1]??"0";return+`${wt(+r)}e${i}`}return it(t,o)}function Cn(t,e,n=!0){return n?wt(it(wt(t/e))*e):it(t/e)*e}function se(t,e,n=!0){return n?wt(It(wt(t/e))*e):It(t/e)*e}function Ke(t,e,n=!0){return n?wt(st(wt(t/e))*e):st(t/e)*e}function kn(t){return t===0?e=>e:t===1?B:e=>Cn(e,t)}function qe(t,e,n,o){const s=[],r=o.map(xn);for(let i=e;i<n;i++){const l=et(i);for(let c=0;c<o.length;c++){const f=o[c]??0,a=r[c]??0,d=+`${f}e${i}`,u=(i>=0?0:l)+(i>=a?0:a),h=d;s.push(h),Ct.set(h,u)}}return s}function Z(t,e,n){return te(yt(t,e),n)}const Tn=new Intl.NumberFormat,Ze=t=>Tn.format(t);function Me(t,e,n){for(;e<=n;){if(t[e]!=null)return!0;e++}return!1}const An=.1,ct={mode:3,pad:An,soft:null},At={pad:0,soft:null,mode:0},In={min:At,max:At};function Yt(t,e,n,o){let s;typeof n=="number"?(At.pad=n,At.soft=null,At.mode=0,s=In):s=n;const r=s.min,i=s.max,l=r.pad,c=i.pad,f=r.hard??-q,a=i.hard??q,d=r.soft??q,u=i.soft??-q,h=r.mode,p=i.mode;let w=e-t;const x=nt(w),g=yt(et(t),et(e)),S=nt(g),C=et(S-x);(w<1e-24||C>10)&&(w=0,(t===0||e===0)&&(w=1e-24));const M=w||g||1e3,P=nt(M),A=pt(10,st(P)),k=M*(w===0?t===0?.1:1:l),T=it(Ke(t-k,A/10),24),I=h===1||h===3&&T<=d||h===2&&T>=d,L=t>=d&&I?d:q,m=yt(f,T<L&&t>=L?L:te(L,T)),b=M*(w===0?e===0?.1:1:c),v=it(se(e+b,A/10),24),y=p===1||p===3&&v>=u||p===2&&v<=u,_=e<=u&&y?u:-q,E=te(a,v>_&&e<=_?_:yt(_,v));return m===E&&m===0?[-1,1]:[m,E]}function Je(t,e,n,o){n===2&&(o=!0);const s=be(t),r=be(e);t===e&&(s===-1?(t*=n,e/=n):(t/=n,e*=n));const i=n===10?nt:kt,l=s===1?st:It,c=r===1?It:st,f=i(et(t)),a=i(et(e)),d=l(f),u=c(a);let h=pt(n,d),p=pt(n,u);return n===10&&(d<0&&(h=it(h,-d)),u<0&&(p=it(p,-u))),o?(t=h*s,e=p*r):(t=Ke(t,pt(n,st(f)),!1),e=se(e,pt(n,st(a)),!1)),[t,e]}function Ln(t,e,n,o){const s=Je(t,e,n,o);return t===0&&(s[0]=0),e===0&&(s[1]=0),s}function xe(t){return(nt((t^t>>31)-(t>>31))|0)+1}function Pn(t,e,n,o,s){const r=yt(xe(t),xe(e)),i=e-t;let l=yt(0,ft(s/o*i,n)-1);do{const c=n[l]??0,f=o*c/i;if(f>=s*.9&&r+(c<5?Ct.get(c)??0:0)<=17)return[c,f]}while(++l<n.length);return[0,0]}function En(t){return{id:t.id,min:t.min??null,max:t.max??null,distr:t.distr??K.Linear,log:t.log??10,asinh:t.asinh??1,ori:t.ori??(t.id==="x"?H.Horizontal:H.Vertical),dir:t.dir??O.Forward,time:t.time??!1,auto:t.auto??!0,range:t.range??null,_discrete:!1,_cfgMin:t.min??null,_cfgMax:t.max??null,_min:null,_max:null}}function N(t){return t.min!=null&&t.max!=null}function rt(t){t._min=null,t._max=null}function Qe(t){if(t._min!=null)return t._min;const{min:e,distr:n}=t;if(e==null)return 0;if(n===K.Log){e<=0&&console.warn(`[uPlot+] Log scale "${t.id}": min value ${e} <= 0, clamping to 1e-10`);const o=e>0?e:1e-10;t._min=(t.log===10?nt:kt)(o)}else n===K.Asinh?t._min=oe(e,t.asinh):t._min=e;return t._min}function tn(t){if(t._max!=null)return t._max;const{max:e,distr:n}=t;if(e==null)return 0;if(n===K.Log){e<=0&&console.warn(`[uPlot+] Log scale "${t.id}": max value ${e} <= 0, clamping to 1e-10`);const o=e>0?e:1e-10;t._max=(t.log===10?nt:kt)(o)}else n===K.Asinh?t._max=oe(e,t.asinh):t._max=e;return t._max}function _n(t,e){if(e.min==null||e.max==null)return 0;const n=Qe(e),s=tn(e)-n;if(s===0)return 0;const{distr:r}=e;if(r===K.Log){const i=e.log===10?nt:kt,l=t>0?t:1e-10;return(i(l)-n)/s}return r===K.Asinh?(oe(t,e.asinh)-n)/s:(t-n)/s}function Dn(t,e){if(e.min==null||e.max==null)return 0;const n=Qe(e),o=tn(e);if(o===n)return e.min;const{distr:s}=e;return s===K.Log?Math.pow(e.log,n+t*(o-n)):s===K.Asinh?bn(n+t*(o-n),e.asinh):n+t*(o-n)}function X(t,e,n,o){const s=_n(t,e);let r;return e.ori===H.Horizontal?r=e.dir===O.Forward?s:1-s:r=e.dir===O.Forward?1-s:s,o+r*n}function lt(t,e,n,o){if(n===0)return e.min??0;let s=(t-o)/n;return e.ori===H.Horizontal?e.dir===O.Backward&&(s=1-s):e.dir!==O.Backward&&(s=1-s),Dn(s,e)}class Fn{constructor(){j(this,"scales",new Map);j(this,"groupXScales",new Map)}addScale(e){this.scales.set(e.id,En(e))}removeScale(e){this.scales.delete(e)}getScale(e){return this.scales.get(e)}getAllScales(){return this.scales.values()}setGroupXScale(e,n){this.groupXScales.set(e,n)}getGroupXScaleKey(e){return this.groupXScales.get(e)}setRange(e,n,o){const s=this.scales.get(e);s&&(s.min=n,s.max=o,rt(s))}autoRangeX(e){var o,s,r,i,l,c;const n=new Map;for(const[f,a]of this.groupXScales){const d=this.scales.get(a);if(!d||!d.auto)continue;const u=e[f];if(!u||u.x.length===0)continue;const h=u.x[0],p=u.x[u.x.length-1];if(h==null||p==null)continue;const w=n.get(a);w?(w.dataMin=Math.min(w.dataMin,h),w.dataMax=Math.max(w.dataMax,p),w.groups.push(f)):n.set(a,{dataMin:h,dataMax:p,groups:[f]})}for(const[f,{dataMin:a,dataMax:d,groups:u}]of n){const h=this.scales.get(f);if(!h)continue;let p=!0,w=q;for(const x of u){const g=e[x];if(g){for(let S=0;S<g.x.length;S++)if(Number.isInteger(g.x[S])||(p=!1),S>0){const C=g.x[S]-g.x[S-1];C>0&&C<w&&(w=C)}}}if(h._discrete=p,h.range){const[x,g]=Yt(a,d,{min:{pad:((o=h.range.min)==null?void 0:o.pad)??0,soft:((s=h.range.min)==null?void 0:s.soft)??null,mode:((r=h.range.min)==null?void 0:r.mode)??0},max:{pad:((i=h.range.max)==null?void 0:i.pad)??0,soft:((l=h.range.max)==null?void 0:l.soft)??null,mode:((c=h.range.max)==null?void 0:c.mode)??0}});h.min=x,h.max=g}else if(a===d)[h.min,h.max]=Yt(a,d,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}});else if(w<q){const x=w/2;h.min=a-x,h.max=d+x}else h.min=a,h.max=d;h._cfgMin!=null&&(h.min=h._cfgMin),h._cfgMax!=null&&(h.max=h._cfgMax),rt(h)}}autoRange(e,n,o){var i,l,c,f,a,d;const s=new Map,r=new Map;for(const{group:u,index:h,yScale:p}of n){const w=e[u];if(!w)continue;const x=w.series[h];if(!x||x.length===0)continue;const g=o.windows.get(u),S=g?g[0]:0,C=g?g[1]:x.length-1,M=this.scales.get(p),P=(M==null?void 0:M.distr)===K.Log,[A,k]=o.getCachedMinMax(u,h,S,C,0,P),T=s.get(p),I=r.get(p);s.set(p,T!=null?Math.min(T,A):A),r.set(p,I!=null?Math.max(I,k):k)}for(const[u,h]of s){const p=this.scales.get(u);if(!p||!p.auto)continue;const w=r.get(u)??-q;if(h===q)continue;let x,g;if(p.distr===K.Log)[x,g]=Je(h,w,p.log,!1);else if(p.distr===K.Asinh)[x,g]=Ln(h,w,p.log,!1);else{const S=p.range??{min:ct,max:ct};[x,g]=Yt(h,w,{min:{pad:((i=S.min)==null?void 0:i.pad)??ct.pad,soft:((l=S.min)==null?void 0:l.soft)??ct.soft,mode:((c=S.min)==null?void 0:c.mode)??ct.mode},max:{pad:((f=S.max)==null?void 0:f.pad)??ct.pad,soft:((a=S.max)==null?void 0:a.soft)??ct.soft,mode:((d=S.max)==null?void 0:d.mode)??ct.mode}})}p._cfgMin!=null&&(x=p._cfgMin),p._cfgMax!=null&&(g=p._cfgMax),p.min=x,p.max=g,rt(p)}}}const Rn=1024;class zn{constructor(e,n=Rn){j(this,"blocks");j(this,"nBlocks");j(this,"blockSize");j(this,"data");j(this,"len");this.data=e,this.len=e.length,this.blockSize=n,this.nBlocks=Math.ceil(e.length/n),this.blocks=new Float64Array(this.nBlocks*2),this.buildAll()}buildAll(){const{data:e,blockSize:n,nBlocks:o,blocks:s,len:r}=this;for(let i=0;i<o;i++){const l=i*n,c=Math.min(l+n,r);let f=1/0,a=-1/0;for(let d=l;d<c;d++){const u=e[d];u!=null&&(u<f&&(f=u),u>a&&(a=u))}s[i*2]=f,s[i*2+1]=a}}rangeMinMax(e,n){const{data:o,blockSize:s,blocks:r}=this;let i=1/0,l=-1/0;const c=Math.floor(e/s),f=Math.floor(n/s);if(c===f){for(let u=e;u<=n;u++){const h=o[u];h!=null&&(h<i&&(i=h),h>l&&(l=h))}return[i,l]}const a=(c+1)*s-1;for(let u=e;u<=a;u++){const h=o[u];h!=null&&(h<i&&(i=h),h>l&&(l=h))}for(let u=c+1;u<f;u++){const h=r[u*2]??1/0,p=r[u*2+1]??-1/0;h<i&&(i=h),p>l&&(l=p)}const d=f*s;for(let u=d;u<=n;u++){const h=o[u];h!=null&&(h<i&&(i=h),h>l&&(l=h))}return[i,l]}updateBlock(e){const{data:n,blockSize:o,blocks:s,len:r}=this;if(e>=this.nBlocks)return;const i=e*o,l=Math.min(i+o,r);let c=1/0,f=-1/0;for(let a=i;a<l;a++){const d=n[a];d!=null&&(d<c&&(c=d),d>f&&(f=d))}s[e*2]=c,s[e*2+1]=f}grow(e){const n=this.nBlocks;if(this.len=e,this.nBlocks=Math.ceil(e/this.blockSize),this.nBlocks>n){const s=new Float64Array(this.nBlocks*2);s.set(this.blocks),this.blocks=s}const o=Math.max(0,n-1);for(let s=o;s<this.nBlocks;s++)this.updateBlock(s)}setData(e){this.data=e}}class Hn{constructor(){j(this,"data",[]);j(this,"windows",new Map);j(this,"minMaxCache",new Map);j(this,"blockTrees",new Map)}setData(e){this.data=e,this.windows.clear();for(const n of this.minMaxCache.values())n.clear();this.minMaxCache.clear(),this.blockTrees.clear()}getOrBuildTree(e,n){const o=`${e}:${n}`;let s=this.blockTrees.get(o);if(s)return s;const r=this.data[e];if(!r)return;const i=r.series[n];if(!(!i||i.length===0))return s=new zn(i),this.blockTrees.set(o,s),s}updateWindows(e){var o;let n=!1;for(let s=0;s<this.data.length;s++){const r=this.data[s],i=e(s),l=this.windows.get(s);let c,f;if(!r||!i||!N(i))c=0,f=Math.max(0,((r==null?void 0:r.x.length)??1)-1);else{const a=r.x;if(a.length===0)c=0,f=0;else{c=ft(i.min,a),f=ft(i.max,a);const d=a[c],u=a[f];c>0&&d!=null&&d>i.min&&c--,f<a.length-1&&u!=null&&u<i.max&&f++}}(!l||l[0]!==c||l[1]!==f)&&(n=!0,(o=this.minMaxCache.get(s))==null||o.clear()),this.windows.set(s,[c,f])}return n}getWindow(e){var n;return this.windows.get(e)??[0,(((n=this.data[e])==null?void 0:n.x.length)||1)-1]}getXValues(e){var n;return((n=this.data[e])==null?void 0:n.x)??[]}getYValues(e,n){var o;return((o=this.data[e])==null?void 0:o.series[n])??[]}getCachedMinMax(e,n,o,s,r,i){let l=this.minMaxCache.get(e);const c=`${n}:${o}:${s}`;if(l){const h=l.get(c);if(h!=null)return h}else l=new Map,this.minMaxCache.set(e,l);const f=this.data[e];if(!f)return[1/0,-1/0];const a=f.series[n];if(!a||a.length===0)return[1/0,-1/0];let d;const u=!i&&r===xt.Unsorted?this.getOrBuildTree(e,n):void 0;return u?d=u.rangeMinMax(o,s):d=Mn(a,o,s,r,i),l.set(c,d),d}getBlockTree(e,n){return this.getOrBuildTree(e,n)}appendData(e,n,o){var i;const s=this.data[e];if(!s)return;let r;Array.isArray(s.x)?r=s.x:(r=Array.from(s.x),s.x=r);for(let l=0;l<n.length;l++){const c=n[l];c!=null&&r.push(c)}for(let l=0;l<s.series.length;l++){let c=s.series[l];if(!c)continue;Array.isArray(c)||(c=Array.from(c),s.series[l]=c);const f=o[l];if(f){const d=c;for(let u=0;u<f.length;u++)d.push(f[u]??null)}const a=this.blockTrees.get(`${e}:${l}`);a&&(a.setData(c),a.grow(c.length))}(i=this.minMaxCache.get(e))==null||i.clear()}static toTypedX(e){for(const n of e)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return e}}const Et=-10;class Wn{constructor(){j(this,"state",{left:Et,top:Et,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1});j(this,"_groupedConfigs",new Map);j(this,"_groupedConfigsSource",null)}getGroupedConfigs(e){if(this._groupedConfigsSource!==e){this._groupedConfigsSource=e,this._groupedConfigs.clear();for(const n of e){if(n.show===!1)continue;let o=this._groupedConfigs.get(n.group);o==null&&(o=[],this._groupedConfigs.set(n.group,o)),o.push(n)}}return this._groupedConfigs}invalidateGroupedConfigs(){this._groupedConfigsSource=null}hide(){this.state.left=Et,this.state.top=Et,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(e,n,o,s,r,i,l,c){this.state.left=e,this.state.top=n;let f=1/0,a=-1,d=-1,u=-1;const h=this.getGroupedConfigs(r);for(let p=0;p<s.length;p++){const w=s[p];if(w==null)continue;const x=w.x;if(x.length===0)continue;const g=c(p);if(g==null)continue;const S=i(g);if(S==null||!N(S))continue;const[C,M]=l(p),P=o.width,A=o.left,k=lt(e+A,S,P,A),T=ft(k,x,C,M),I=[T];T>C&&I.push(T-1),T<M&&I.push(T+1);const L=new Map;for(const m of I){const b=x[m];if(b==null)continue;const v=X(b,S,P,A);for(const y of h.get(p)??[]){const _=w.series[y.index];if(_==null)continue;const E=_[m];if(E==null)continue;let R=L.get(y.yScale);if(R==null&&!L.has(y.yScale)&&(R=i(y.yScale),L.set(y.yScale,R)),R==null||!N(R))continue;const z=o.height,F=o.top,$=X(E,R,z,F),G=e+A-v,V=n+F-$,U=G*G+V*V;if(U<f&&(f=U,a=p,d=y.index,u=m,U===0))break}if(f===0)break}}this.state.activeGroup=a,this.state.activeSeriesIdx=d,this.state.activeDataIdx=u}syncToValue(e,n){const o=n.dataStore.data;if(o.length===0)return;const s=o[0];if(s==null)return;const r=n.scaleManager.getGroupXScaleKey(0);if(r==null)return;const i=n.scaleManager.getScale(r);if(i==null||!N(i))return;const[l,c]=n.dataStore.getWindow(0),f=ft(e,s.x,l,c),a=s.x[f];if(a==null)return;const d=X(a,i,n.plotBox.width,n.plotBox.left);this.state.left=d-n.plotBox.left,this.state.activeGroup=0,this.state.activeDataIdx=f;let u=0,h=n.plotBox.height/2;for(const p of n.seriesConfigs){if(p.group!==0||p.show===!1)continue;const w=s.series[p.index];if(w==null)continue;const x=w[f];if(x==null)continue;const g=n.scaleManager.getScale(p.yScale);if(!(g==null||!N(g))){h=X(x,g,n.plotBox.height,n.plotBox.top)-n.plotBox.top,u=p.index;break}}this.state.top=h,this.state.activeSeriesIdx=u}}class $n{constructor(){j(this,"flags",tt.None);j(this,"frameId",null);j(this,"callback",null)}mark(e){this.flags|=e,this.scheduleFrame()}has(e){return(this.flags&e)!==0}get dirty(){return this.flags}clear(){this.flags=tt.None}onRedraw(e){this.callback=e}scheduleFrame(){this.frameId==null&&(this.frameId=requestAnimationFrame(()=>{this.frameId=null;const e=this.callback;e!=null&&e(),this.clear()}))}cancel(){this.frameId!=null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}dispose(){this.cancel(),this.callback=null,this.flags=tt.None}}const Wt={width:1},Gn={width:0,fill:"auto",fillTo:0,points:{show:!1},cursor:{show:!1}},Vn={width:0,cursor:{show:!1}};function $t(t,e,n){t.lineTo(e,n)}function Gt(t,e,n){t.lineTo(n,e)}function ie(t,e,n,o,s,r){const i=[];let l=-1;const c=s===O.Forward?n:o,f=s===O.Forward?o:n,a=s;for(let d=c;s===O.Forward?d<=f:d>=f;d+=a)if(e[d]===null||e[d]===void 0){if(l===-1){const u=Z(d-s,n,o);l=r(t[u])}}else l!==-1&&(i.push([l,r(t[d])]),l=-1);return l!==-1&&i.push([l,r(t[o])]),i}function re(t,e,n,o,s,r){const i=new Path2D;let l=e===H.Horizontal?n:o;const c=e===H.Horizontal?n+s:o+r,f=e===H.Horizontal?o:n,a=e===H.Horizontal?r:s;for(const[d,u]of t)d>l&&(e===H.Horizontal?i.rect(l,f,d-l,a):i.rect(f,l,a,d-l)),l=u;return l<c&&(e===H.Horizontal?i.rect(l,f,c-l,a):i.rect(f,l,a,c-l)),i}function en(t){return(e,n,o,s,r,i)=>{o!==s&&(r!==o&&i!==o&&t(e,n,o),r!==s&&i!==s&&t(e,n,s),t(e,n,i))}}const Bn=en($t),Xn=en(Gt);function nn(){const t=(e,n,o,s,r,i,l,c,f,a,d,u,h)=>{const p=(h==null?void 0:h.spanGaps)??!1;if([f,a]=(s.distr===K.Log?Oe:Ht)(n,f,a),f===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const x=T=>u(X(T,o,r,l)),g=T=>u(X(T,s,i,c));let S,C;o.ori===H.Horizontal?(S=$t,C=Bn):(S=Gt,C=Xn);const M={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},P=M.stroke;let A=!1;if(a-f>=r*4){const T=R=>lt(R,o,r,l);let I=null,L=0,m=0,b=0,v=x(e[d===O.Forward?f:a]);const y=x(e[f]),_=x(e[a]);let E=T(d===O.Forward?y+1:_-1);for(let R=d===O.Forward?f:a;R>=f&&R<=a;R+=d){const z=e[R],$=(d===O.Forward?z<E:z>E)?v:x(z),G=n[R];$===v?G!=null?(b=G,I==null?(S(P,$,g(b)),m=I=L=b):b<I?I=b:b>L&&(L=b)):G===null&&!p&&(A=!0):(I!=null&&C(P,v,g(I),g(L),g(m),g(b)),G!=null?(b=G,S(P,$,g(b)),I=L=m=b):(I=null,L=0,G===null&&!p&&(A=!0)),v=$,E=T(v+d))}I!=null&&(I!==L?C(P,v,g(I),g(L),g(m),g(b)):S(P,v,g(b)))}else for(let T=d===O.Forward?f:a;T>=f&&T<=a;T+=d){const I=n[T];I===null&&!p?A=!0:I!=null&&S(P,x(e[T]),g(I))}{const T=M.fill=new Path2D(P),I=(h==null?void 0:h.fillTo)??s.min??0,L=g(I);let m=x(e[f]),b=x(e[a]);d===O.Backward&&([b,m]=[m,b]),S(T,b,L),S(T,m,L)}if(A){const T=ie(e,n,f,a,d,x);M.gaps=T,M.clip=re(T,o.ori,l,c,r,i)}return M};return t.defaults=Wt,t}function le(t,e,n){const o=t.length;if(n=Math.max(2,Math.round(n)),o<=n){const u=new Uint32Array(o),h=new Float64Array(o),p=new Array(o);for(let w=0;w<o;w++)u[w]=w,h[w]=t[w],p[w]=e[w]??null;return{indices:u,x:h,y:p}}const s=[];let r=-1,i=0;for(let u=0;u<o;u++)e[u]!=null?(r===-1&&(r=u),i++):r!==-1&&(s.push([r,u-1]),r=-1);if(r!==-1&&s.push([r,o-1]),i===0)return{indices:new Uint32Array(0),x:new Float64Array(0),y:[]};if(i<=n){const u=new Uint32Array(i),h=new Float64Array(i),p=new Array(i);let w=0;for(let x=0;x<o;x++)e[x]!=null&&(u[w]=x,h[w]=t[x],p[w]=e[x],w++);return{indices:u,x:h,y:p}}const l=[];for(const[u,h]of s){const p=h-u+1,w=Math.max(2,Math.round(n*(p/i))),x=jn(t,e,u,h,w);for(const g of x)l.push(g)}const c=l.length,f=new Uint32Array(c),a=new Float64Array(c),d=new Array(c);for(let u=0;u<c;u++){const h=l[u];f[u]=h,a[u]=t[h],d[u]=e[h]}return{indices:f,x:a,y:d}}function jn(t,e,n,o,s){const r=o-n+1;if(r<=s){const a=[];for(let d=n;d<=o;d++)a.push(d);return a}const i=[];i.push(n);const l=s-2,c=(r-2)/l;let f=n;for(let a=0;a<l;a++){const d=n+1+Math.floor(a*c),u=Math.min(n+1+Math.floor((a+1)*c)-1,o-1);let h=0,p=0,w=0;if(a<l-1){const M=n+1+Math.floor((a+1)*c),P=Math.min(n+1+Math.floor((a+2)*c)-1,o-1);for(let A=M;A<=P;A++)h+=t[A],p+=e[A],w++}else h=t[o],p=e[o],w=1;w>0&&(h/=w,p/=w);const x=t[f],g=e[f];let S=d,C=-1;for(let M=d;M<=u;M++){const P=t[M],A=e[M],k=Math.abs(x*(A-p)+P*(p-g)+h*(g-A));k>C&&(C=k,S=M)}i.push(S),f=S}return i.push(o),i}function Yn(t,e){const n=t.x.length;if(e=Math.max(2,Math.round(e)),n<=e)return t;const o=new Set;for(const c of t.series){const f=le(t.x,c,e);for(let a=0;a<f.indices.length;a++)o.add(f.indices[a])}const s=Array.from(o).sort((c,f)=>c-f),r=s.length,i=new Float64Array(r);for(let c=0;c<r;c++)i[c]=t.x[s[c]];const l=[];for(const c of t.series)if(Array.isArray(c)&&c.some(a=>a===null)){const a=new Array(r);for(let d=0;d<r;d++)a[d]=c[s[d]]??null;l.push(a)}else{const a=new Float64Array(r);for(let d=0;d<r;d++)a[d]=c[s[d]];l.push(a)}return{x:i,series:l}}function Nn(t){const n=nn(),o=(s,r,i,l,c,f,a,d,u,h,p,w,x)=>{const g=h-u+1,S=Math.round(c*1);if(g>S*2){const C=h-u+1,M=new Float64Array(C),P=new Array(C);for(let k=0;k<C;k++)M[k]=s[u+k],P[k]=r[u+k]??null;const A=le(M,P,S);return n(A.x,A.y,i,l,c,f,a,d,0,A.x.length-1,p,w,x)}return n(s,r,i,l,c,f,a,d,u,h,p,w,x)};return o.defaults=Wt,o}const ye=new WeakMap;function Ce(t,e,n){return typeof e=="string"?e:Un(t,e,n)}function Un(t,e,n){const o=ye.get(e);if(o!=null&&o.left===n.left&&o.top===n.top&&o.width===n.width&&o.height===n.height)return o.grad;const s=t.createLinearGradient(0,n.top,0,n.top+n.height);for(const[r,i]of e.stops)s.addColorStop(r,i);return ye.set(e,{grad:s,left:n.left,top:n.top,width:n.width,height:n.height}),s}function On(t,e,n,o,s){if(e.show===!1)return;const r=e.alpha??1;t.save(),r<1&&(t.globalAlpha=r),n.clip&&t.clip(n.clip);const i=s??{left:0,top:0,width:t.canvas.width/o,height:t.canvas.height/o};if(e.fill&&n.fill&&(t.fillStyle=Ce(t,e.fill,i),t.fill(n.fill)),e.stroke){const l=(e.width??1)*o;t.strokeStyle=Ce(t,e.stroke,i),t.lineWidth=l,t.lineJoin=e.join??"round",t.lineCap=e.cap??"butt",e.dash&&t.setLineDash(e.dash.map(d=>d*o));const c=e.pxAlign??0,f=l%2/2;c===1&&f>0&&t.translate(f,f),t.stroke(n.stroke)}t.restore()}const Kn=Nn(),ke=64;class qn{constructor(){j(this,"ctx",null);j(this,"pxRatio",1);j(this,"pathCache",new Map);j(this,"bandCache",new Map);j(this,"scaleStamp","");j(this,"snapshotCanvas",null);j(this,"snapshotValid",!1)}setContext(e,n){this.ctx=e,this.pxRatio=n}saveSnapshot(e,n,o){const s=e.canvas;(this.snapshotCanvas==null||this.snapshotCanvas.width!==n||this.snapshotCanvas.height!==o)&&(this.snapshotCanvas=typeof OffscreenCanvas<"u"?new OffscreenCanvas(n,o):document.createElement("canvas"),this.snapshotCanvas.width=n,this.snapshotCanvas.height=o);const r=this.snapshotCanvas.getContext("2d");r!=null&&typeof r.drawImage=="function"&&(r.clearRect(0,0,n,o),r.drawImage(s,0,0),this.snapshotValid=!0)}restoreSnapshot(e){return!this.snapshotValid||this.snapshotCanvas==null||typeof e.drawImage!="function"?!1:(e.clearRect(0,0,e.canvas.width,e.canvas.height),e.drawImage(this.snapshotCanvas,0,0),!0)}invalidateSnapshot(){this.snapshotValid=!1}checkScaleStamp(e){let n="";const o=new Set;for(const s of e)for(const r of[s.xScale,s.yScale])o.has(r.id)||(o.add(r.id),n+=`${r.id}:${r.min}:${r.max};`);n!==this.scaleStamp&&(this.scaleStamp!==""&&this.clearCache(),this.scaleStamp=n)}cacheKey(e,n,o,s){return`${e}:${n}:${o}:${s}`}promote(e,n){this.pathCache.delete(e),this.pathCache.set(e,n)}getCachedPaths(e,n,o,s){const r=this.cacheKey(e,n,o,s),i=this.pathCache.get(r);if(i!=null)return this.promote(r,i),i;const l=`${e}:${n}:`;for(const[c,f]of this.pathCache){if(!c.startsWith(l))continue;const a=c.slice(l.length),d=a.indexOf(":"),u=+a.slice(0,d),h=+a.slice(d+1);if(u<=o&&h>=s)return this.promote(c,f),f}}setCachedPaths(e,n,o,s,r){if(this.pathCache.size>=ke){const l=ke>>2,c=this.pathCache.keys();for(let f=0;f<l;f++){const a=c.next().value;a!=null&&this.pathCache.delete(a)}}const i=this.cacheKey(e,n,o,s);this.pathCache.delete(i),this.pathCache.set(i,r)}invalidateSeries(e,n){const o=`${e}:${n}:`;for(const s of this.pathCache.keys())s.startsWith(o)&&this.pathCache.delete(s)}clearGroupCache(e){const n=`${e}:`;for(const o of this.pathCache.keys())o.startsWith(n)&&this.pathCache.delete(o);for(const o of this.bandCache.keys())o.startsWith(n)&&this.bandCache.delete(o);this.invalidateSnapshot()}clearCache(){this.pathCache.clear(),this.bandCache.clear(),this.invalidateSnapshot()}bandKey(e,n,o,s,r){return`${e}:${n}:${o}:${s}:${r}`}getCachedBandPath(e,n,o,s,r){return this.bandCache.get(this.bandKey(e,n,o,s,r))}setCachedBandPath(e,n,o,s,r,i){this.bandCache.set(this.bandKey(e,n,o,s,r),i)}drawSeries(e,n,o){const s=this.ctx;if(s==null||e.config.show===!1)return;const r=e.config.group,i=e.config.index,[l,c]=e.window;let f=this.getCachedPaths(r,i,l,c);if(f==null){const a=e.config.paths??Kn,d=e.xScale.dir,u=kn(e.config.pxAlign??0),h=c-l,p=Math.max(1,Math.ceil(h*.1)),w=e.dataX.length,x=Math.max(0,l-p),g=Math.min(w-1,c+p),S=e.config.fillTo;let C;typeof S=="function"?C=S(e.yScale.min??0,e.yScale.max??0):S===0&&e.yScale.distr===K.Log?C=1:C=S,f=a(e.dataX,e.dataY,e.xScale,e.yScale,n.width,n.height,n.left,n.top,x,g,d,u,{fillTo:C,spanGaps:e.config.spanGaps}),this.setCachedPaths(r,i,x,g,f)}On(s,e.config,f,o,n)}draw(e,n,o,s){const r=this.ctx;if(r==null)return;const i=this.pxRatio;r.clearRect(0,0,e*i,n*i),r.save(),r.scale(i,i),r.beginPath(),r.rect(o.left,o.top,o.width,o.height),r.clip();for(const l of s)this.drawSeries(l,o,1);r.restore()}}const on=[1,2,2.5,5],Zn=qe(10,-32,0,on),Jn=qe(10,0,32,on),dt=Zn.concat(Jn);function Qn(t,e,n,o,s){if(n<=0||e<t)return[];const r=[],i=Ct.get(n)??0,l=s?Math.ceil(t/n)*n:it(se(t,n),i);for(let c=l;c<=e;c=it(c+n,i))r.push(Object.is(c,-0)?0:c);return r}function Nt(t){return t.map(e=>Ze(e))}function to(t,e,n){if(t<=0||e<=0||t>=e)return[];const o=[],r=st((n===10?nt:kt)(t));let i=pt(n,r);n===10&&(i=dt[ft(i,dt)]??i);let l=i,c=i*n;n===10&&(c=dt[ft(c,dt)]??c);let f=0;do{if(l>=t&&o.push(l),l=l+i,n===10&&!Ct.has(l)){const a=Ct.get(i)??0;l=it(l,a)}l>=c*(1-1e-10)&&(i=l,c=i*n,n===10&&(c=dt[ft(c,dt)]??c))}while(l<=e&&++f<1e4);return o}function eo(t,e,n=1){const o=[];if(Math.max(et(t),et(e))===0)return[0];if(t<0){const i=et(t);let l=pt(10,st(nt(Math.max(i,n))));for(;l>=n;){const c=-l;c>=t&&c<=e&&o.push(c),l/=10}}if(t<=0&&e>=0&&o.push(0),e>0){let i=n;const l=e;for(;i<=l;)i>=t&&i<=e&&o.push(i),i*=10}o.sort((i,l)=>i-l);const r=[];for(const i of o){const l=r[r.length-1];(r.length===0||l!=null&&et(i-l)>1e-10)&&r.push(i)}return r}function no(t,e){const n=e===10?nt:kt;return t.map(o=>{if(o===0)return!0;if(o<0)return!1;const s=n(o);return et(s-Math.round(s))<1e-10})}const oo=7,so=50,io=16;function ro(t,e){const o=Ze(Math.max(Math.abs(t),Math.abs(e))).length*oo;return Math.max(so,o+io)}function lo(t,e,n,o){if(o<=0)return[0,0];const s=St(t.side)===H.Vertical,r=t.space??(s?30:ro(e,n)),i=t.incrs??dt;return Pn(e,n,i,o,r)}const co=50;function ao(t,e,n){var l,c;if(t.size!=null)return t.size;const o=((l=t.ticks)==null?void 0:l.show)!==!1?((c=t.ticks)==null?void 0:c.size)??10:0,s=t.gap??5,r=12;if(St(t.side)===H.Vertical&&e!=null){let f=0;for(const d of e)d.length>f&&(f=d.length);const a=f*7;return Math.max(50,o+s+a+4)}return Math.max(50,o+s+r+3)}function uo(t){return{config:t,_show:t.show!==!1,_size:t.size??co,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const fo=1,Mt=60,gt=3600,ut=86400,ho=604800,mt=2592e3,Lt=31536e3,go=[fo,5,10,15,30,Mt,5*Mt,10*Mt,15*Mt,30*Mt,gt,2*gt,3*gt,4*gt,6*gt,12*gt,ut,2*ut,3*ut,7*ut,14*ut,mt,2*mt,3*mt,6*mt,Lt];function po(t,e,n){const o=[];if(n<=0||t>=e)return o;let s;if(n>=Lt){const r=new Date(t*1e3);for(r.setUTCMonth(0,1),r.setUTCHours(0,0,0,0),s=r.getTime()/1e3,s<t&&(r.setUTCFullYear(r.getUTCFullYear()+1),s=r.getTime()/1e3);s<=e;)o.push(s),r.setUTCFullYear(r.getUTCFullYear()+Math.round(n/Lt)),s=r.getTime()/1e3;return o}if(n>=mt){const r=new Date(t*1e3);r.setUTCDate(1),r.setUTCHours(0,0,0,0),s=r.getTime()/1e3;const i=Math.max(1,Math.round(n/mt));if(s<t&&(r.setUTCMonth(r.getUTCMonth()+1),s=r.getTime()/1e3),i>1){const l=r.getUTCMonth(),c=Math.ceil((l+1)/i)*i;r.setUTCMonth(c-1),s=r.getTime()/1e3}for(;s<=e;)o.push(s),r.setUTCMonth(r.getUTCMonth()+i),s=r.getTime()/1e3;return o}if(n>=ut){const r=new Date(t*1e3);r.setUTCHours(0,0,0,0),s=r.getTime()/1e3,s<t&&(s+=ut)}else s=Math.ceil(t/n)*n;for(let r=0;;r++){const i=s+r*n;if(i>e)break;o.push(i)}return o}const Te=new Map;function mo(t,e){const n=JSON.stringify(t)+(e??"");let o=Te.get(n);return o==null&&(o=new Intl.DateTimeFormat(void 0,{...t,timeZone:e}),Te.set(n,o)),o}function ot(t,e,n){const o=new Date(t*1e3);return mo(e,n).format(o)}function wo(t,e){return ot(t,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e)}function So(t,e){return ot(t,{year:"numeric",month:"2-digit",day:"2-digit"},e)}function vo(t,e){return ot(t,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e)}function bo(t,e){return ot(t,{hour:"2-digit",minute:"2-digit",hour12:!1},e)}function Mo(t,e){return ot(t,{month:"short",day:"numeric"},e)}function xo(t,e){return ot(t,{year:"numeric"},e)}function yo(t,e){return ot(t,{year:"numeric",month:"short"},e)}function Co(t,e,n){let o;return e>=Lt?o=xo:e>=mt?o=yo:e>=ho?o=So:e>=ut?o=Mo:e>=gt?o=bo:e>=Mt?o=vo:o=wo,t.map(s=>o(s,n))}function ko(t,e,n,o,s){const r=e-t;if(r<=0||o<=0)return[0,0];for(const l of n){const c=r/l,f=o/c;if(f>=s)return[l,f]}const i=n[n.length-1]??Lt;return[i,o/(r/i)]}const To=3;function Ao(t,e,n,o,s){let r=!0;for(const i of t){const l=i.config;if(l.show===!1)continue;const c=e(l.scale);if(!c||!N(c)){i._show&&(r=!1,i._show=!1);continue}else i._show||(r=!1,i._show=!0);const f=l.side,d=St(f)===H.Horizontal?n:o,u=c.min,h=c.max;let p,w;if(c.time){const g=l.space??80;[p,w]=ko(u,h,go,d,g)}else[p,w]=lo(l,u,h,d);if(c._discrete&&p>0&&p<1&&(p=1),i._incr=p,i._space=w,w===0)continue;if(l.splits)i._splits=l.splits(u,h,p,w);else if(c.time)i._splits=po(u,h,p);else if(c.distr===K.Log)i._splits=to(u,h,c.log);else if(c.distr===K.Asinh)i._splits=eo(u,h,c.asinh);else{const g=c.distr===K.Ordinal||c._discrete;i._splits=Qn(u,h,p,w,g)}if(l.values)i._values=l.values(i._splits,w,p);else if(c.time)i._values=Co(i._splits,p);else if(c.distr===K.Log){const g=no(i._splits,c.log),S=Nt(i._splits);i._values=S.map((C,M)=>g[M]?C:"")}else c.distr,K.Asinh,i._values=Nt(i._splits);i._rotate=f===Y.Bottom?l.rotate??0:0;const x=i._size;i._size=It(ao(l,i._values)),x!==i._size&&(r=!1)}return r}function Ae(t,e,n,o=0){let s=t,r=e-o,i=0,l=o;for(const f of n){if(!f._show)continue;const a=f.config.side,d=St(a)===H.Vertical,u=f.config.label!=null?f.config.labelSize??20:0,h=f._size+u;h>0&&(d?(s-=h,a===Y.Left&&(i+=h)):(r-=h,a===Y.Top&&(l+=h)))}return!n.some(f=>f._show&&f.config.side===Y.Top)&&l<=o&&(l+=8,r-=8),{left:i,top:l,width:Math.max(s,0),height:Math.max(r,0)}}function Io(t,e){let n=e.top,o=e.left+e.width,s=e.top+e.height,r=e.left;function i(l,c){switch(l){case Y.Top:return n-=c,n+c;case Y.Right:{const f=o;return o+=c,f}case Y.Bottom:{const f=s;return s+=c,f}case Y.Left:return r-=c,r+c;default:return 0}}for(const l of t){if(!l._show)continue;const c=l.config.side;if(l._pos=i(c,l._size),l.config.label!=null){const f=l.config.labelSize??20;l._lpos=i(c,f)}}}function Lo(t,e,n,o,s=0){for(const c of n)c._size=0;let r=!1,i=0,l={left:0,top:0,width:t,height:e};for(;!r;){i++;const c=Ao(n,o,l.width,l.height);r=i===To||c,r||(l=Ae(t,e,n,s))}return l=Ae(t,e,n,s),Io(n,l),l}const Ie="top",Le="bottom",Po="left",Eo="right";function Ut(t,e){return e===1?t:t.replace(/(\d+(?:\.\d+)?)px/,(n,o)=>`${Math.round(Number(o)*e)}px`)}function Pe(t,e,n,o,s,r,i,l,c,f,a){const d=l%2/2;t.save(),t.translate(d,d),t.strokeStyle=c,t.lineWidth=l,f.length>0&&t.setLineDash(f),t.beginPath();let u=0,h=0,p=0,w=0;const x=r+(s===Y.Top||s===Y.Left?-i:i);o===H.Horizontal?(h=r,w=x):(u=r,p=x);for(let g=0;g<e.length;g++)n[g]!=null&&(o===H.Horizontal?u=p=e[g]??0:h=w=e[g]??0,t.moveTo(u,h),t.lineTo(p,w));t.stroke(),t.restore()}function _o(t,e,n,o,s,r){const i=B(o.left*s),l=B(o.top*s),c=B(o.width*s),f=B(o.height*s);for(const a of e){if(!a._show)continue;const d=a.config,u=d.side,h=St(u),p=n(d.scale);if(!p||!N(p))continue;const w=d.stroke??"#000",x=u===Y.Top||u===Y.Left?-1:1,g=a._splits,S=a._values;if(!g||!S||a._space===0)continue;const C=h===H.Horizontal?o.width:o.height,M=h===H.Horizontal?o.left:o.top,P=g.map(L=>B(X(L,p,C,M)*s)),A=S.map(L=>L===""?null:L),k=d.grid;if((k==null?void 0:k.show)!==!1){const L=(k==null?void 0:k.stroke)??"rgba(0,0,0,0.12)",m=B(((k==null?void 0:k.width)??2)*s),b=((k==null?void 0:k.dash)??[]).map(_=>_*s),v=h===H.Horizontal?l:i,y=h===H.Horizontal?f:c;Pe(t,P,A,h,2,v,y,m,L,b)}const T=d.ticks;if((T==null?void 0:T.show)!==!1){const L=(T==null?void 0:T.stroke)??w,m=B(((T==null?void 0:T.width)??1)*s),b=B(((T==null?void 0:T.size)??10)*s),v=((T==null?void 0:T.dash)??[]).map(_=>_*s),y=B(a._pos*s);Pe(t,P,A,h,u,y,b,m,L,v)}{const L=(T==null?void 0:T.show)!==!1?((T==null?void 0:T.size)??10)*s:0,m=B((d.gap??5)*s),b=B(a._pos*s),v=(L+m)*x,y=b+v,_=Ut(d.font??"12px system-ui, sans-serif",s),E=h===H.Horizontal?"center":u===Y.Left?Eo:Po,R=h===H.Horizontal?u===Y.Bottom?Ie:Le:"middle";t.font=_,t.fillStyle=w,t.textAlign=E,t.textBaseline=R;const z=a._rotate*-Xt/180;if(z!==0){const F=Math.cos(z),$=Math.sin(z);for(let G=0;G<S.length;G++){const V=S[G];if(V==null||V==="")continue;const U=P[G]??0;t.setTransform(F,$,-$,F,U,y),t.fillText(V,0,0)}t.setTransform(1,0,0,1,0,0)}else for(let F=0;F<S.length;F++){const $=S[F];if($==null||$==="")continue;const G=P[F]??0,V=h===H.Horizontal?G:y,U=h===H.Horizontal?y:G;t.fillText($,V,U)}}if(d.label!=null){const L=Ut(d.labelFont??"bold 12px system-ui, sans-serif",s);t.font=L,t.fillStyle=w,t.textAlign="center",t.textBaseline=u===Y.Bottom?Ie:Le;const m=B((a._lpos+(d.labelGap??0)*x)*s);h===H.Vertical?(t.save(),t.translate(m,B(l+f/2)),t.rotate((u===Y.Left?-Xt:Xt)/2),t.fillText(d.label,0,0),t.restore()):t.fillText(d.label,B(i+c/2),m)}const I=d.border;if((I==null?void 0:I.show)!==!1&&I!=null){const L=I.stroke??w,m=B((I.width??1)*s),b=(I.dash??[]).map(y=>y*s),v=B(a._pos*s);t.strokeStyle=L,t.lineWidth=m,b.length>0&&t.setLineDash(b),t.beginPath(),h===H.Horizontal?(t.moveTo(i,v),t.lineTo(i+c,v)):(t.moveTo(v,l),t.lineTo(v,l+f)),t.stroke(),b.length>0&&t.setLineDash([])}}if(r!=null){const a=Ut("bold 14px system-ui, sans-serif",s);t.font=a,t.fillStyle="#000",t.textAlign="center",t.textBaseline="top",t.fillText(r,B(i+c/2),B(4*s))}}const Do=2,Fo="#fff",Ro={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function Ee(t,e,n,o,s,r,i,l,c,f){var M;if(e.left<0||e.top<0)return;const a={...Ro,...c},d=o,u=B(n.left*d),h=B(n.top*d),p=B(n.width*d),w=B(n.height*d),x=B(a.width*d),g=x%2/2,S=B((n.left+e.left)*d)+g,C=B((n.top+e.top)*d)+g;if(t.save(),t.strokeStyle=a.stroke,t.lineWidth=x,t.setLineDash(a.dash.map(P=>P*d)),a.showX&&(t.beginPath(),t.moveTo(S,h),t.lineTo(S,h+w),t.stroke()),a.showY&&(t.beginPath(),t.moveTo(u,C),t.lineTo(u+p,C),t.stroke()),t.setLineDash([]),e.activeGroup>=0&&e.activeDataIdx>=0){const P=e.activeGroup,A=e.activeSeriesIdx,k=e.activeDataIdx,T=s[P];if(T!=null&&A>=0&&A<T.series.length&&k<T.x.length){const I=T.x[k],L=T.series[A],m=L!=null?L[k]:null;if(I!=null&&m!=null){let b=a.stroke,v=!0;const y=f==null?void 0:f.get(`${P}:${A}`);if(y!=null){const _=y.stroke;b=(typeof _=="string"?_:void 0)??a.stroke,v=((M=y.cursor)==null?void 0:M.show)!==!1}if(v){const _=l(P),E=_!=null?i(_):void 0,R=(y==null?void 0:y.yScale)??zo(r,P,A),z=R!=null?i(R):void 0;if(E!=null&&z!=null&&N(E)&&N(z)){const F=B(X(I,E,n.width,n.left)*d),$=B(X(m,z,n.height,n.top)*d),G=a.pointRadius*d,V=B(Do*d);t.beginPath(),t.arc(F,$,G,0,Math.PI*2),t.fillStyle=Fo,t.fill(),t.strokeStyle=b,t.lineWidth=V,t.stroke()}}}}}t.restore()}function zo(t,e,n){for(const o of t)if(o.group===e&&o.index===n)return o.yScale}const Ho={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function _e(t,e,n,o,s){if(!e.show||e.width<=0)return;const r={...Ho,...s},i=o,l=B((n.left+e.left)*i),c=B((n.top+e.top)*i),f=B(e.width*i),a=B(e.height*i);t.save(),t.fillStyle=r.fill,t.fillRect(l,c,f,a),r.width>0&&(t.strokeStyle=r.stroke,t.lineWidth=B(r.width*i),t.strokeRect(l,c,f,a)),t.restore()}function Wo(t,e,n,o,s,r,i,l,c,f,a,d){const u=a/2*i,h=Math.max(1,B(a*.2))*i,p=(f==null?void 0:f.stroke)??d,w=(f==null?void 0:f.fill)??"#fff";t.save(),t.strokeStyle=p,t.fillStyle=w,t.lineWidth=h,(f==null?void 0:f.dash)!=null&&t.setLineDash(f.dash.map(x=>x*i));for(let x=l;x<=c;x++){const g=n[x];if(g==null)continue;const S=e[x];if(S==null)continue;const C=B(X(S,o,r.width,r.left)*i),M=B(X(g,s,r.height,r.top)*i);t.beginPath(),t.arc(C,M,u,0,Math.PI*2),t.fill(),t.stroke()}t.restore()}function $o(t,e,n,o,s,r,i){if(typeof t=="function")return t(e,n,o,s,r);if(t===!0)return!0;if(t===!1)return!1;const l=s-o;return l>0&&l<=r/i}function Go(t,e,n,o,s,r,i,l,c){if(l>c||l<0||!Me(e,l,c)&&!Me(n,l,c))return null;const f=h=>X(h,o,r.width,r.left)*i,a=h=>X(h,s,r.height,r.top)*i,d=new Path2D;let u=!1;for(let h=l;h<=c;h++){const p=e[h],w=t[h];if(p==null||w==null)continue;const x=f(w),g=a(p);u?d.lineTo(x,g):(d.moveTo(x,g),u=!0)}if(!u)return null;for(let h=c;h>=l;h--){const p=n[h],w=t[h];p==null||w==null||d.lineTo(f(w),a(p))}return d.closePath(),d}function Vo(t,e,n){t.save(),t.fillStyle=e.fill??"rgba(0, 120, 255, 0.1)",t.fill(n),t.restore()}function Bo(t){const e=t.dataStore.data;if(e.length===0)return;if(!t.scaleManager.getScale("x")){const i={id:"x",auto:!0};t.scaleConfigs.push(i),t.scaleManager.addScale(i)}for(let i=0;i<e.length;i++)t.scaleManager.getGroupXScaleKey(i)||t.scaleManager.setGroupXScale(i,"x");const n=new Set(t.scaleConfigs.map(i=>i.id)),o=new Set;for(const i of t.seriesConfigs)o.add(i.yScale);o.size===0&&!n.has("y")&&o.add("y");for(const i of o)if(!n.has(i)){const l={id:i,auto:!0};t.scaleConfigs.push(l),t.scaleManager.addScale(l),n.add(i)}t.axisConfigs.some(i=>i.scale==="x")||t.axisConfigs.push({scale:"x",side:Y.Bottom,show:!0,label:t.xlabel??"X Axis"});const r=new Set(t.axisConfigs.map(i=>i.scale));for(const i of o)r.has(i)||(t.axisConfigs.push({scale:i,side:Y.Left,show:!0,label:t.ylabel??"Y Axis"}),r.add(i))}function Ot(t,e,n,o){return{ctx:t,plotBox:e,pxRatio:n,getScale:o,valToX:(i,l="x")=>{const c=o(l);return c==null||!N(c)?null:X(i,c,e.width,e.left)},valToY:(i,l)=>{const c=o(l);return c==null||!N(c)?null:X(i,c,e.height,e.top)}}}const Xo={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1,plotLeft:0,plotTop:0,plotWidth:0,plotHeight:0,seriesCount:0,revision:-1};function De(t){const{left:e,top:n,activeGroup:o,activeSeriesIdx:s,activeDataIdx:r}=t.cursorManager.state,{left:i,top:l,width:c,height:f}=t.plotBox,a=t.seriesConfigs.length,{revision:d}=t,u=t.snapshot;u.left===e&&u.top===n&&u.activeGroup===o&&u.activeSeriesIdx===s&&u.activeDataIdx===r&&u.plotLeft===i&&u.plotTop===l&&u.plotWidth===c&&u.plotHeight===f&&u.seriesCount===a&&u.revision===d||(t.snapshot={left:e,top:n,activeGroup:o,activeSeriesIdx:s,activeDataIdx:r,plotLeft:i,plotTop:l,plotWidth:c,plotHeight:f,seriesCount:a,revision:d})}function Kt(t){t.seriesConfigMap.clear();for(const e of t.seriesConfigs)t.seriesConfigMap.set(`${e.group}:${e.index}`,e)}function jo(){const t={scaleManager:new Fn,dataStore:new Hn,renderer:new qn,cursorManager:new Wn,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,cursorListeners:new Set,scheduler:new $n,drawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:1,actionMap:new Map(Rt),title:void 0,xlabel:void 0,ylabel:void 0,snapshot:Xo,revision:0,eventCallbacks:{},_prevScaleRanges:new Map,seriesConfigMap:new Map,registerScale(e){t.scaleConfigs=t.scaleConfigs.filter(n=>n.id!==e.id),t.scaleConfigs.push(e),t.scaleManager.addScale(e)},unregisterScale(e){t.scaleConfigs=t.scaleConfigs.filter(n=>n.id!==e),t.scaleManager.removeScale(e)},registerSeries(e){t.seriesConfigs=t.seriesConfigs.filter(n=>!(n.group===e.group&&n.index===e.index)),t.seriesConfigs.push(e),Kt(t),t.renderer.clearGroupCache(e.group)},unregisterSeries(e,n){t.seriesConfigs=t.seriesConfigs.filter(o=>!(o.group===e&&o.index===n)),Kt(t),t.renderer.clearGroupCache(e)},toggleSeries(e,n){const o=t.seriesConfigMap.get(`${e}:${n}`);o!=null&&(o.show=o.show===!1,t.revision++,t.cursorManager.invalidateGroupedConfigs(),t.renderer.invalidateSeries(e,n),t.renderer.invalidateSnapshot(),t.scheduleRedraw())},setFocus(e){t.focusedSeries=e,t.scheduleRedraw()},setSize(e,n){t.width===e&&t.height===n||(t.width=e,t.height=n,t.canvas&&(t.canvas.width=e*t.pxRatio,t.canvas.height=n*t.pxRatio,t.canvas.style.width=`${e}px`,t.canvas.style.height=`${n}px`),t.renderer.clearCache())},scheduleRedraw(){t.scheduler.mark(tt.Full)},scheduleCursorRedraw(){t.scheduler.mark(tt.Cursor)},subscribe(e){return t.listeners.add(e),()=>{t.listeners.delete(e)}},subscribeCursor(e){return t.cursorListeners.add(e),()=>{t.cursorListeners.delete(e)}},redraw(){const{scaleManager:e,dataStore:n,renderer:o,seriesConfigs:s,width:r,height:i,pxRatio:l,canvas:c,scheduler:f}=t;if(c==null||r===0||i===0)return;const a=c.getContext("2d");if(a==null)return;o.setContext(a,l);const u=(f.dirty&~(tt.Cursor|tt.Select))===0,h=g=>e.getScale(g);if(u&&o.restoreSnapshot(a)){if(Ee(a,t.cursorManager.state,t.plotBox,l,n.data,s,h,g=>e.getGroupXScaleKey(g),void 0,t.seriesConfigMap),_e(a,t.selectState,t.plotBox,l),t.cursorDrawHooks.size>0){a.save(),a.scale(l,l);const g=Ot(a,t.plotBox,l,h);for(const S of t.cursorDrawHooks)try{S(g,t.cursorManager.state)}catch(C){console.warn("[uPlot+] draw hook error:",C)}a.restore()}De(t);for(const g of t.cursorListeners)g();return}Bo(t),e.autoRangeX(n.data),n.updateWindows(g=>{const S=e.getGroupXScaleKey(g);return S!=null?e.getScale(S):void 0});const p=s.map(g=>({group:g.group,index:g.index,yScale:g.yScale}));if(e.autoRange(n.data,p,n),Yo(t),t.axisStates.length>0){const g=t.title!=null?20:0;t.plotBox=Lo(r,i,t.axisStates,h,g)}else t.plotBox={left:10,top:10,width:r-20,height:i-20};a.clearRect(0,0,r*l,i*l),t.axisStates.length>0&&_o(a,t.axisStates,h,t.plotBox,l,t.title);const w=[];for(const g of s){const S=e.getGroupXScaleKey(g.group),C=S!=null?e.getScale(S):void 0,M=e.getScale(g.yScale);C==null||M==null||w.push({config:g,dataX:n.getXValues(g.group),dataY:n.getYValues(g.group,g.index),xScale:C,yScale:M,window:n.getWindow(g.group)})}o.checkScaleStamp(w),a.save(),a.scale(l,l),a.beginPath(),a.rect(t.plotBox.left,t.plotBox.top,t.plotBox.width,t.plotBox.height),a.clip();for(let g=0;g<w.length;g++){const S=w[g];S!=null&&(t.focusedSeries!=null&&g!==t.focusedSeries?(a.globalAlpha=t.focusAlpha,o.drawSeries(S,t.plotBox,1),a.globalAlpha=1):o.drawSeries(S,t.plotBox,1))}const x=new Map;for(const g of s)x.set(`${g.group}-${g.index}`,g);for(const g of t.bandConfigs){const S=e.getGroupXScaleKey(g.group),C=S!=null?e.getScale(S):void 0,M=x.get(`${g.group}-${g.series[0]}`),P=x.get(`${g.group}-${g.series[1]}`);if(C==null||M==null||P==null)continue;const A=e.getScale(M.yScale);if(A==null)continue;const[k,T]=n.getWindow(g.group),I=g.series[0],L=g.series[1];let m=o.getCachedBandPath(g.group,I,L,k,T);m==null&&(m=Go(n.getXValues(g.group),n.getYValues(g.group,I),n.getYValues(g.group,L),C,A,t.plotBox,l,k,T)??void 0,m!=null&&o.setCachedBandPath(g.group,I,L,k,T,m)),m!=null&&Vo(a,g,m)}for(const g of w){const S=g.config;if(S.show===!1)continue;const C=S.points,M=S.width??1,P=(C==null?void 0:C.size)??3+M*2,A=(C==null?void 0:C.space)??P*2,[k,T]=g.window;$o(C==null?void 0:C.show,S.group,S.index,k,T,t.plotBox.width,A)&&Wo(a,g.dataX,g.dataY,g.xScale,g.yScale,t.plotBox,l,k,T,C,P,(typeof S.stroke=="string"?S.stroke:null)??"#000")}if(a.restore(),t.drawHooks.size>0){a.save(),a.beginPath(),a.rect(t.plotBox.left*l,t.plotBox.top*l,t.plotBox.width*l,t.plotBox.height*l),a.clip(),a.scale(l,l);const g=Ot(a,t.plotBox,l,h);for(const S of t.drawHooks)try{S(g)}catch(C){console.warn("[uPlot+] draw hook error:",C)}a.restore()}if(t.cursorManager.state.left>=0&&(o.saveSnapshot(a,r*l,i*l),t.cursorManager.update(t.cursorManager.state.left,t.cursorManager.state.top,t.plotBox,n.data,s,h,g=>n.getWindow(g),g=>e.getGroupXScaleKey(g))),Ee(a,t.cursorManager.state,t.plotBox,l,n.data,s,h,g=>e.getGroupXScaleKey(g),void 0,t.seriesConfigMap),_e(a,t.selectState,t.plotBox,l),t.cursorDrawHooks.size>0){a.save(),a.scale(l,l);const g=Ot(a,t.plotBox,l,h);for(const S of t.cursorDrawHooks)try{S(g,t.cursorManager.state)}catch(C){console.warn("[uPlot+] draw hook error:",C)}a.restore()}De(t);for(const g of t.listeners)g();for(const g of t.cursorListeners)g();if(t._prevScaleRanges.size>0&&t.eventCallbacks.onScaleChange!=null)for(const g of e.getAllScales()){if(!N(g))continue;const S=t._prevScaleRanges.get(g.id);if(S==null||S.min!==g.min||S.max!==g.max)try{t.eventCallbacks.onScaleChange(g.id,g.min,g.max)}catch(C){console.warn("[uPlot+] event callback error:",C)}}t._prevScaleRanges.clear();for(const g of e.getAllScales())N(g)&&t._prevScaleRanges.set(g.id,{min:g.min,max:g.max})},getSnapshot:()=>t.snapshot,updateScale(e){t.scaleConfigs=t.scaleConfigs.map(n=>n.id===e.id?e:n),t.scaleManager.addScale(e),t.renderer.clearCache()},updateSeries(e){t.seriesConfigs=t.seriesConfigs.map(n=>n.group===e.group&&n.index===e.index?e:n),Kt(t),t.renderer.invalidateSeries(e.group,e.index)},registerAxis(e){t.axisConfigs=t.axisConfigs.filter(n=>!(n.scale===e.scale&&n.side===e.side)),t.axisConfigs.push(e)},unregisterAxis(e,n){t.axisConfigs=t.axisConfigs.filter(o=>!(o.scale===e&&o.side===n))},updateAxis(e){t.axisConfigs=t.axisConfigs.map(n=>n.scale===e.scale&&n.side===e.side?e:n)},registerBand(e){t.bandConfigs.push(e)},unregisterBand(e){t.bandConfigs=t.bandConfigs.filter(n=>n!==e)},setData(e){t.dataStore.setData(e),t.renderer.clearCache()},setCanvas(e){t.canvas=e},setLabels(e,n,o){t.title=e,t.xlabel=n,t.ylabel=o},redrawSync(){t.scheduler.cancel(),t.scheduler.mark(tt.Full),t.redraw(),t.scheduler.clear()}};return t.scheduler.onRedraw(()=>t.redraw()),t}function Yo(t){const{axisConfigs:e,axisStates:n}=t,o=new Map;for(const s of n)o.set(`${s.config.scale}:${s.config.side}`,s);t.axisStates=e.map(s=>{const r=`${s.scale}:${s.side}`,i=o.get(r);return i!=null?(i.config=s,i):uo(s)})}function No(){const t=D.useRef(null);return t.current===null&&(t.current=jo()),t.current}const sn=D.createContext(null);function Q(){const t=D.useContext(sn);if(!t)throw new Error("useChart must be used within a <Chart> component");return t}function Uo(t="cursor"){const e=Q(),n=t==="full"?e.subscribe:e.subscribeCursor,o=D.useSyncExternalStore(n,e.getSnapshot);return{left:o.left,top:o.top,activeGroup:o.activeGroup,activeSeriesIdx:o.activeSeriesIdx,activeDataIdx:o.activeDataIdx,plotLeft:o.plotLeft,plotTop:o.plotTop,plotWidth:o.plotWidth,plotHeight:o.plotHeight,seriesCount:o.seriesCount,revision:o.revision,getScale:s=>e.scaleManager.getScale(s),getPlotBox:()=>e.plotBox,getSeriesConfigs:()=>e.seriesConfigs,getDataX:s=>e.dataStore.getXValues(s),getDataY:(s,r)=>e.dataStore.getYValues(s,r),toggleSeries:(s,r)=>e.toggleSeries(s,r),setFocus:s=>e.setFocus(s)}}const Fe=5,rn=.001,Oo=.1,Ko=10;function ce(t,e){const n=t.shiftKey?"shift":t.altKey?"alt":t.ctrlKey?"ctrl":"",o=t.button===1?"Middle":t.button===2?"Right":"Left";return n?`${n}${o}${e}`:`${o.toLowerCase()}${e}`}function qo(t){return ce(t,"Drag")}function Zo(t){return ce(t,"Click")}function Jo(t){return ce(t,"Dblclick")}function Qo(t){const e=t.shiftKey?"shift":t.altKey?"alt":t.ctrlKey?"ctrl":"";return e?`${e}Wheel`:"wheel"}function ts(t){const e=t.shiftKey?"shift":t.altKey?"alt":t.ctrlKey?"ctrl":"",n=t.key.length===1?t.key.toUpperCase():t.key;return e?`${e}Key${n}`:`key${n}`}function es(t,e,n,o,s=!0){const r=t.get(e);if(r!=null)return r;if(s){for(const[i,l]of t)if(typeof i=="function"&&i(n,o))return l}}function ns(t,e){const n=[];for(const o of t.scaleManager.getAllScales())N(o)&&(e!=null&&!e(o.ori)||n.push({id:o.id,ori:o.ori,startMin:o.min,startMax:o.max}));return n}function Tt(t){const e=t.eventCallbacks.onScaleChange;if(e!=null)for(const n of t.scaleManager.getAllScales()){if(!N(n))continue;const o=t._prevScaleRanges.get(n.id);(o==null||o.min!==n.min||o.max!==n.max)&&e(n.id,n.min,n.max)}}function qt(t,e,n,o){if(!(e instanceof WheelEvent))return;const s=Z(1-e.deltaY*rn,Oo,Ko),r=t.plotBox;for(const i of t.scaleManager.getAllScales()){if(!N(i)||!o(i.ori))continue;const l=i.ori===H.Horizontal,c=l?r.width:r.height,f=l?r.left:r.top,a=l?n.cx+r.left:n.cy+r.top,d=lt(a,i,c,f),u=d-(d-i.min)*s,h=d+(i.max-d)*s;i.min=Math.min(u,h),i.max=Math.max(u,h),i.auto=!1,rt(i)}t.scheduleRedraw(),Tt(t)}function Zt(t,e,n){const o={show:!1,left:0,top:0,width:0,height:0},s=e.cx,r=e.cy;return{onMove(i,l,c){const f=t.plotBox,a=Z(c.cx,0,f.width),d=Z(c.cy,0,f.height);o.show=!0,o.left=Math.min(s,a),o.top=Math.min(r,d),o.width=Math.abs(a-s),o.height=Math.abs(d-r),n(H.Vertical)||(o.top=0,o.height=f.height),n(H.Horizontal)||(o.left=0,o.width=f.width),t.selectState=o,t.scheduler.mark(tt.Cursor|tt.Select)},onEnd(i,l,c){const f=n(H.Horizontal)&&o.width>Fe,a=n(H.Vertical)&&o.height>Fe;if(f||a){let d=!0;if(t.eventCallbacks.onSelect!=null){const u=is(t,o);let h;try{h=t.eventCallbacks.onSelect(u)}catch(p){console.warn("[uPlot+] event callback error:",p)}h===!1&&(d=!1)}d&&(os(t,o,n),Tt(t))}o.show=!1,o.left=0,o.width=0,t.selectState=o,t.scheduleRedraw()}}}function os(t,e,n){const o=t.plotBox;for(const s of t.scaleManager.getAllScales()){if(!N(s)||!n(s.ori))continue;const r=s.ori===H.Horizontal,i=r?o.width:o.height,l=r?o.left:o.top,c=r?e.left:e.top,f=r?e.width:e.height,a=c/i,d=(c+f)/i,u=lt(l+a*i,s,i,l),h=lt(l+d*i,s,i,l);s.min=Math.min(u,h),s.max=Math.max(u,h),s.auto=!1,rt(s)}}function Jt(t,e,n,o){const s=ns(t,n),r=e.clientX,i=e.clientY;return{onMove(l,c){const f=t.plotBox,a=c;for(const d of s){const u=t.scaleManager.getScale(d.id);if(u==null)continue;const h=d.ori===H.Horizontal,p=h?f.width:f.height,w=h?a.clientX-r:a.clientY-i,x=h?-1:1,g=d.startMax-d.startMin;u.min=d.startMin+x*(w/p)*g,u.max=d.startMax+x*(w/p)*g,u.auto=!1,rt(u)}t.renderer.clearCache(),t.scheduleRedraw()},onEnd(){Tt(t)}}}function Re(t,e,n){var a;if(n.scaleId==null||n.ori==null)return;const o=t.scaleManager.getScale(n.scaleId);if(o==null||!N(o))return;const s=n.ori===H.Vertical,r=(a=e.target.closest("div"))==null?void 0:a.getBoundingClientRect();if(r==null)return;const i=s?e.clientY-r.top:e.clientX-r.left,l=o.min,c=o.max,f=n.scaleId;return{onMove(d,u){var A;const h=t.plotBox,p=u,w=(A=p.target.closest("div"))==null?void 0:A.getBoundingClientRect();if(w==null)return;const x=s?h.height:h.width,S=((s?p.clientY-w.top:p.clientX-w.left)-i)/x,C=s?1:-1,M=c-l,P=t.scaleManager.getScale(f);P!=null&&(P.min=l+C*S*M,P.max=c+C*S*M,P.auto=!1,rt(P),t.renderer.clearCache(),t.scheduleRedraw())},onEnd(){Tt(t)}}}function Qt(t,e,n){if(!(e instanceof WheelEvent))return;const o=e.deltaY*rn*10;for(const s of t.scaleManager.getAllScales()){if(!N(s)||!n(s.ori))continue;const r=s.max-s.min;s.min+=o*r,s.max+=o*r,s.auto=!1,rt(s)}t.renderer.clearCache(),t.scheduleRedraw(),Tt(t)}const _t=t=>t===H.Horizontal,Dt=t=>t===H.Vertical,Ft=()=>!0;function ss(t){switch(t){case"zoomX":return(e,n,o)=>{if(n instanceof WheelEvent){qt(e,n,o,_t);return}return Zt(e,o,_t)};case"zoomY":return(e,n,o)=>{if(n instanceof WheelEvent){qt(e,n,o,Dt);return}return Zt(e,o,Dt)};case"zoomXY":return(e,n,o)=>{if(n instanceof WheelEvent){qt(e,n,o,Ft);return}return Zt(e,o,Ft)};case"panX":return(e,n,o)=>{if(n instanceof WheelEvent){Qt(e,n,_t);return}return o.scaleId!=null?Re(e,n,o):Jt(e,n,_t)};case"panY":return(e,n,o)=>{if(n instanceof WheelEvent){Qt(e,n,Dt);return}return o.scaleId!=null?Re(e,n,o):Jt(e,n,Dt)};case"panXY":return(e,n,o)=>{if(n instanceof WheelEvent){Qt(e,n,Ft);return}return Jt(e,n,Ft)};case"reset":return e=>{for(const n of e.scaleConfigs)e.scaleManager.addScale(n);e.renderer.clearCache(),e.scheduleRedraw()};case"none":return()=>{};default:return}}function ze(t){return typeof t=="function"?t:ss(t)}function is(t,e){const n=t.plotBox,o=e.left/n.width,s=(e.left+e.width)/n.width,r={};for(const i of t.scaleManager.getAllScales()){if(i.ori!==H.Horizontal||!N(i))continue;const l=lt(n.left+o*n.width,i,n.width,n.left),c=lt(n.left+s*n.width,i,n.width,n.left);r[i.id]={min:Math.min(l,c),max:Math.max(l,c)}}return{left:o,right:s,ranges:r}}function rs(t,e){D.useEffect(()=>{if(e!=null)return ls(t,e)},[t,e])}function ls(t,e){let n=null,o=!1,s=null,r=-1,i=-1;function l(m){const b=e.getBoundingClientRect(),v=t.plotBox;return{cx:m.clientX-b.left-v.left,cy:m.clientY-b.top-v.top}}function c(m,b){const v=t.plotBox;return m>=0&&m<=v.width&&b>=0&&b<=v.height}function f(m,b){const v=e.getBoundingClientRect(),y=m-v.left,_=b-v.top,E=t.plotBox;for(const R of t.axisStates){const z=R.config,F=z.side;if(R._size<=0)continue;const G=_>=E.top&&_<=E.top+E.height,V=y>=E.left&&y<=E.left+E.width;if(F===Y.Left&&y<E.left&&G||F===Y.Right&&y>E.left+E.width&&G||F===Y.Top&&_<E.top&&V||F===Y.Bottom&&_>E.top+E.height&&V)return{scaleId:z.scale,ori:St(F)}}return null}function a(m){const{cx:b,cy:v}=l(m);return{cx:b,cy:v,inPlot:c(b,v)}}function d(m,b,v){const y=t.cursorManager.state;let _=null;if(y.activeGroup>=0&&y.activeDataIdx>=0){const E=t.dataStore.data[y.activeGroup];if(E!=null){const R=E.x[y.activeDataIdx],z=E.series[y.activeSeriesIdx],F=z!=null?z[y.activeDataIdx]:void 0;if(R!=null&&F!=null){const $=t.plotBox,G=t.scaleManager.getGroupXScaleKey(y.activeGroup),V=G!=null?t.scaleManager.getScale(G):void 0,U=t.seriesConfigMap.get(`${y.activeGroup}:${y.activeSeriesIdx}`),vt=U!=null?t.scaleManager.getScale(U.yScale):void 0;let bt=b,Bt=v;V!=null&&N(V)&&(bt=X(R,V,$.width,$.left)-$.left),vt!=null&&N(vt)&&(Bt=X(F,vt,$.height,$.top)-$.top);const Se=b-bt,ve=v-Bt;_={group:y.activeGroup,seriesIdx:y.activeSeriesIdx,dataIdx:y.activeDataIdx,xVal:R,yVal:F,pxX:bt,pxY:Bt,dist:Math.sqrt(Se*Se+ve*ve)}}}}return{plotX:b,plotY:v,point:_,srcEvent:m}}function u(m,b,v,y=!0){const _=es(t.actionMap,m,b,v,y);if(!(_==null||_==="none"))return ze(_)}function h(m,b){const{cx:v,cy:y}=l(m);if(!c(v,y)&&n==null){r=-1,i=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw();return}const _=v!==r||y!==i;if(r=v,i=y,t.cursorManager.update(v,y,t.plotBox,t.dataStore.data,t.seriesConfigs,E=>t.scaleManager.getScale(E),E=>t.dataStore.getWindow(E),E=>t.scaleManager.getGroupXScaleKey(E)),_){const E={cx:v,cy:y,inPlot:c(v,y)},R=t.actionMap.get("hover");if(R!=null&&R!=="none"){const z=ze(R);if(z!=null&&z(t,b??m,E),t.focusAlpha<1){const F=t.cursorManager.state;if(F.activeGroup>=0&&F.activeSeriesIdx>=0){const $=t.seriesConfigs.findIndex(G=>G.group===F.activeGroup&&G.index===F.activeSeriesIdx);$>=0&&t.focusedSeries!==$&&(t.focusedSeries=$,t.scheduleRedraw())}}}}if(b!=null&&t.eventCallbacks.onCursorMove!=null&&c(v,y))try{t.eventCallbacks.onCursorMove(d(b,v,y))}catch(E){console.warn("[uPlot+] event callback error:",E)}t.scheduleCursorRedraw()}function p(){document.activeElement!==e&&e.focus()}function w(m){const b=a(m),v=f(m.clientX,m.clientY);let y;if(v!=null&&m.button===0)y=v.ori===H.Horizontal?"xGutterDrag":"yGutterDrag",b.scaleId=v.scaleId,b.ori=v.ori;else if(y=qo(m),!b.inPlot)return;b.action=y;const _=u(y,m,b,!1);if(_==null)return;(m.button!==0||v!=null)&&m.preventDefault();const E=_(t,m,b);E!=null&&(n=E,o=!1)}function x(m){if(n!=null){o=!0,n.onMove(t,m,a(m)),h(m,m);return}h(m,m)}function g(m){if(n!=null){n.onEnd(t,m,a(m)),n=null;return}}function S(m){if(o){o=!1;return}const b=a(m);if(!b.inPlot)return;const v=Zo(m);b.action=v;const y=u(v,m,b);y!=null&&y(t,m,b);const _=t.eventCallbacks.onClick;if(_!=null)try{_(d(m,b.cx,b.cy))}catch(E){console.warn("[uPlot+] event callback error:",E)}}function C(m){if(n!=null){m.preventDefault();return}const b=a(m);if(!b.inPlot)return;m.preventDefault(),b.action="rightClick";const v=u("rightClick",m,b);v!=null&&v(t,m,b);const y=t.eventCallbacks.onContextMenu;if(y!=null)try{y(d(m,b.cx,b.cy))}catch(_){console.warn("[uPlot+] event callback error:",_)}}function M(m){var b,v;r=-1,i=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),n!=null&&(n=null),t.scheduleCursorRedraw();try{(v=(b=t.eventCallbacks).onCursorLeave)==null||v.call(b)}catch(y){console.warn("[uPlot+] event callback error:",y)}}function P(m){const b=a(m);if(!b.inPlot)return;if(t.eventCallbacks.onDblClick!=null){let _;try{_=t.eventCallbacks.onDblClick(d(m,b.cx,b.cy))}catch(E){console.warn("[uPlot+] event callback error:",E)}if(_===!1)return}const v=Jo(m);b.action=v;const y=u(v,m,b,!1);y!=null&&y(t,m,b)}function A(m){const b=a(m);if(!b.inPlot)return;const v=Qo(m);b.action=v;const y=u(v,m,b);y!=null&&(m.preventDefault(),y(t,m,b))}function k(m){if(m.touches.length===2){const E=m.touches[0],R=m.touches[1],z=R.clientX-E.clientX,F=R.clientY-E.clientY;s={dist:Math.sqrt(z*z+F*F),midX:(E.clientX+R.clientX)/2,midY:(E.clientY+R.clientY)/2},n=null;return}const b=m.touches[0];if(b==null)return;const v=a(b);if(!v.inPlot)return;const y=u("touchDrag",m,v);if(y==null)return;const _=y(t,m,v);_!=null&&(n=_,o=!1)}function T(m){if(m.touches.length===2&&s!=null){m.preventDefault();const v=m.touches[0],y=m.touches[1],_=y.clientX-v.clientX,E=y.clientY-v.clientY,R=Math.sqrt(_*_+E*E),z=a({clientX:s.midX,clientY:s.midY});if(u("pinch",m,z)!=null){const $=R/s.dist,G=t.plotBox;for(const V of t.scaleManager.getAllScales()){if(V.ori!==H.Horizontal||!N(V))continue;const U=lt(z.cx+G.left,V,G.width,G.left),vt=U-(U-V.min)/$,bt=U+(V.max-U)/$;V.min=Math.min(vt,bt),V.max=Math.max(vt,bt),V.auto=!1,rt(V)}s.dist=R,t.renderer.clearCache(),t.scheduleRedraw(),Tt(t)}return}const b=m.touches[0];if(b!=null){if(n!=null){o=!0,n.onMove(t,m,a(b)),h(b,m),m.preventDefault();return}h(b,m)}}function I(m){if(s!=null){s=null;return}const b=m.changedTouches[0];b!=null&&n!=null&&(n.onEnd(t,m,a(b)),n=null)}function L(m){const b={cx:r,cy:i,inPlot:r>=0&&i>=0},v=ts(m);b.action=v;const y=u(v,m,b);y!=null&&(m.preventDefault(),y(t,m,b))}return e.addEventListener("mouseenter",p),e.addEventListener("mousemove",x),e.addEventListener("mousedown",w),e.addEventListener("mouseup",g),e.addEventListener("click",S),e.addEventListener("contextmenu",C),e.addEventListener("mouseleave",M),e.addEventListener("dblclick",P),e.addEventListener("wheel",A,{passive:!1}),e.addEventListener("touchstart",k,{passive:!0}),e.addEventListener("touchmove",T,{passive:!1}),e.addEventListener("touchend",I),e.addEventListener("keydown",L),()=>{e.removeEventListener("mouseenter",p),e.removeEventListener("mousemove",x),e.removeEventListener("mousedown",w),e.removeEventListener("mouseup",g),e.removeEventListener("click",S),e.removeEventListener("contextmenu",C),e.removeEventListener("mouseleave",M),e.removeEventListener("dblclick",P),e.removeEventListener("wheel",A),e.removeEventListener("touchstart",k),e.removeEventListener("touchmove",T),e.removeEventListener("touchend",I),e.removeEventListener("keydown",L)}}const ee=new Map;function cs(t){let e=ee.get(t);return e==null&&(e=new as(t),ee.set(t,e)),e}class as{constructor(e){j(this,"key");j(this,"members",new Set);j(this,"publishing",!1);j(this,"syncedStores",new WeakSet);this.key=e}join(e){this.members.add(e)}leave(e){this.members.delete(e),this.members.size===0&&ee.delete(this.key)}pub(e){if(this.publishing)return;if(this.syncedStores.has(e)){this.syncedStores.delete(e);return}this.publishing=!0;const n=e.cursorManager.state,{activeGroup:o,activeDataIdx:s}=n;if(o<0||s<0){for(const l of this.members)l!==e&&(this.syncedStores.add(l),l.cursorManager.hide(),l.scheduleCursorRedraw());this.publishing=!1;return}const i=e.dataStore.getXValues(o)[s];if(i==null){this.publishing=!1;return}for(const l of this.members)l!==e&&(this.syncedStores.add(l),l.cursorManager.syncToValue(i,l),l.scheduleCursorRedraw());this.publishing=!1}}function us(t,e){D.useEffect(()=>{if(e==null)return;const n=cs(e);n.join(t);let o=-1,s=-1;const r=t.subscribeCursor(()=>{const{activeGroup:i,activeDataIdx:l}=t.cursorManager.state;i===o&&l===s||(o=i,s=l,n.pub(t))});return()=>{r(),n.leave(t)}},[t,e])}function ln(t){return t instanceof Float64Array?t:new Float64Array(t)}function cn(t){return t instanceof Float64Array||t.some(e=>e==null)?t:new Float64Array(t)}function He(t){return{x:ln(t.x),series:[cn(t.y)]}}function fs(t){return{x:ln(t.x),series:t.series.map(cn)}}function ne(t){if(!Array.isArray(t))return[He(t)];if(t.length===0)return[];const e=t[0];return e==null?[]:"series"in e?t.map(fs):t.map(He)}function ae({width:t,height:e,data:n,children:o,className:s,pxRatio:r,title:i,xlabel:l,ylabel:c,onDraw:f,onCursorDraw:a,syncKey:d,actions:u,onClick:h,onContextMenu:p,onDblClick:w,onCursorMove:x,onCursorLeave:g,onScaleChange:S,onSelect:C}){const M=No(),[P,A]=D.useState(null),k=r??(typeof window<"u"&&window.devicePixelRatio||1);D.useEffect(()=>{M.actionMap=u!=null?new Map([...Rt,...u]):new Map(Rt)},[M,u]),D.useEffect(()=>{M.setLabels(i,l,c)},[M,i,l,c]);const T=M.eventCallbacks;T.onClick=h,T.onContextMenu=p,T.onDblClick=w,T.onCursorMove=x,T.onCursorLeave=g,T.onScaleChange=S,T.onSelect=C,rs(M,P),us(M,d);const I=D.useRef(null),L=F=>{I.current!==F&&(I.current=F,M.setCanvas(F),F&&M.scheduleRedraw())},m=D.useRef(null),b=F=>{m.current!==F&&(m.current=F,A(F))};D.useLayoutEffect(()=>{M.pxRatio=k,M.setSize(t,e),M.redrawSync()},[M,t,e,k]),D.useEffect(()=>()=>{M.setCanvas(null),M.scheduler.cancel(),M.focusedSeries=null,M.eventCallbacks={}},[M]),D.useEffect(()=>{if(P==null||typeof ResizeObserver>"u")return;const F=new ResizeObserver($=>{const G=$[0];if(G==null)return;const{width:V,height:U}=G.contentRect;V>0&&U>0&&(V!==M.width||U!==M.height)&&(M.setSize(Math.round(V),Math.round(U)),M.scheduleRedraw())});return F.observe(P),()=>{F.disconnect()}},[M,P]);const v=D.useRef(void 0),y=D.useRef(ne(n));n!==v.current&&(v.current=n,y.current=ne(n));const _=y.current,E=D.useRef(n);D.useEffect(()=>{n===E.current&&M.dataStore.data.length>0||(E.current=n,M.setData(_),M.scheduleRedraw())},[M,n,_]);const R=D.useRef(f);R.current=f,D.useEffect(()=>{const F=$=>{var G;(G=R.current)==null||G.call(R,$)};return M.drawHooks.add(F),()=>{M.drawHooks.delete(F)}},[M]);const z=D.useRef(a);return z.current=a,D.useEffect(()=>{const F=($,G)=>{var V;(V=z.current)==null||V.call(z,$,G)};return M.cursorDrawHooks.add(F),()=>{M.cursorDrawHooks.delete(F)}},[M]),W.jsx(sn.Provider,{value:M,children:W.jsxs("div",{className:s,style:{position:"relative",display:"flex",flexDirection:"column",width:`${t}px`},children:[W.jsx("div",{ref:b,tabIndex:-1,style:{position:"relative",width:`${t}px`,height:`${e}px`,cursor:"crosshair",outline:"none",order:0},children:W.jsx("canvas",{ref:L,style:{position:"absolute",left:0,top:0}})}),o]})})}function We(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function hs(t,e){const n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(const s of o)if(t[s]!==e[s])return!1;return!0}function ds(t,e){if(t===null)return!1;const n=t,o=e,s=Object.keys(n),r=Object.keys(o);if(s.length!==r.length)return!1;for(const i of r){const l=n[i],c=o[i];if(l!==c)if(We(l)&&We(c)){if(!hs(l,c))return!1}else return!1}return!0}function ue(t,e,n,o,s){const r=Q(),i=D.useRef(t);i.current=t,D.useEffect(()=>{const c=i.current;return n(r,c),r.scheduleRedraw(),()=>{o(r,c),r.scheduleRedraw()}},[r,...e]);const l=D.useRef(null);D.useEffect(()=>{ds(l.current,t)||(l.current=t,s(r,t),r.scheduleRedraw())})}function gs(t){return ue(t,[t.id],(e,n)=>e.registerScale(n),(e,n)=>e.unregisterScale(n.id),(e,n)=>e.updateScale(n)),null}function ps(t,e,n){e/=100,n/=100;const o=(1-Math.abs(2*n-1))*e,s=o*(1-Math.abs(t/60%2-1)),r=n-o/2;let i=0,l=0,c=0;return t<60?(i=o,l=s):t<120?(i=s,l=o):t<180?(l=o,c=s):t<240?(l=s,c=o):t<300?(i=s,c=o):(i=o,c=s),[Math.round((i+r)*255),Math.round((l+r)*255),Math.round((c+r)*255)]}function an(t){const e=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(t);if(e)return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)];const n=/^#([0-9a-f])([0-9a-f])([0-9a-f])/i.exec(t);if(n)return[parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];const o=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i.exec(t);if(o)return[Number(o[1]),Number(o[2]),Number(o[3])];const s=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%/i.exec(t);return s?ps(Number(s[1]),Number(s[2]),Number(s[3])):null}function ms(t,e=.8,n=0){const o=an(t);if(o==null)return{type:"linear",stops:[[0,t],[1,t]]};const[s,r,i]=o;return{type:"linear",stops:[[0,`rgba(${s},${r},${i},${e})`],[1,`rgba(${s},${r},${i},${n})`]]}}function un(t,e){const n=an(t);if(n==null)return t;const[o,s,r]=n;return`rgba(${o},${s},${r},${e})`}function ws(t,e=65,n=50){const o=[];for(let r=0;r<t;r++){const i=r*137.508%360;o.push(`hsl(${i.toFixed(1)},${e}%,${n}%)`)}return o}const $e=["#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085","#c0392b","#2980b9","#27ae60","#f1c40f","#8e44ad","#d35400"];function Ge(t,e){var i;const n=(i=t.paths)==null?void 0:i.defaults,o=t.stroke??$e[e%$e.length]??"#000",s=t.fill??(n==null?void 0:n.fill),r=s==="auto"&&typeof o=="string"?un(o,.5):s==="auto"?void 0:s;return{...n,...t,yScale:t.yScale??"y",show:t.show??!0,stroke:o,fill:r}}function fe(t){return ue(t,[t.group,t.index],(e,n)=>e.registerSeries(Ge(n,e.seriesConfigs.length)),(e,n)=>e.unregisterSeries(n.group,n.index),(e,n)=>{const o=e.seriesConfigs.findIndex(s=>s.group===n.group&&s.index===n.index);e.updateSeries(Ge(n,o>=0?o:e.seriesConfigs.length))}),null}function Ss(t){return{...t,side:t.side??(t.scale==="x"?Y.Bottom:Y.Left),show:t.show??!0}}function Pt(t){const e=Ss(t);return ue(e,[e.scale,e.side],(n,o)=>n.registerAxis(o),(n,o)=>n.unregisterAxis(o.scale,o.side),(n,o)=>n.updateAxis(o)),null}function vs({series:t,group:e,fill:n,dir:o}){const s=Q(),r=D.useRef(null),i=t[0],l=t[1];return D.useEffect(()=>{const c={series:[i,l],group:e,fill:n,dir:o};return r.current!=null&&s.unregisterBand(r.current),r.current=c,s.registerBand(c),s.scheduleRedraw(),()=>{r.current!=null&&s.unregisterBand(r.current),r.current=null,s.scheduleRedraw()}},[s,i,l,e,n,o]),null}const bs={width:12,height:3,borderRadius:1,display:"inline-block"},Ms={fontWeight:600},fn={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},xs={...fn,opacity:1},ys={...fn,opacity:.4},Ve=new Map,Cs={display:"flex",flexWrap:"wrap",justifyContent:"center",order:-1,padding:"4px 0"},ks={display:"flex",flexWrap:"wrap",justifyContent:"center",order:1,padding:"4px 0"};function Ts({group:t,index:e,label:n,color:o,isHidden:s,valueStr:r,store:i}){let l=Ve.get(o);return l==null&&(l={...bs,backgroundColor:o},Ve.set(o,l)),W.jsxs("span",{onClick:()=>i.toggleSeries(t,e),style:s?ys:xs,children:[W.jsx("span",{style:l}),W.jsx("span",{children:n}),r&&W.jsx("span",{style:Ms,children:r})]})}function As({show:t=!0,position:e="bottom",className:n}){const o=Q(),s=D.useSyncExternalStore(o.subscribeCursor,o.getSnapshot);if(!t)return null;const{activeGroup:r,activeDataIdx:i}=s;return W.jsx("div",{className:n,style:e==="top"?Cs:ks,children:o.seriesConfigs.map(l=>{if(l.legend===!1)return null;const c=typeof l.stroke=="string"?l.stroke:"#000";let f="";if(i>=0&&r>=0&&l.group===r){const d=o.dataStore.getYValues(l.group,l.index)[i];d!=null&&(f=typeof d=="number"?d.toPrecision(4):String(d))}return W.jsx(Ts,{group:l.group,index:l.index,label:l.label??`Series ${l.index}`,color:c,isHidden:l.show===!1,valueStr:f,store:o},`${l.group}:${l.index}`)})})}const Is={position:"absolute",zIndex:50,background:"rgba(255,255,255,0.92)",border:"1px solid #ccc",borderRadius:4,padding:"4px 6px",fontSize:12,fontFamily:"sans-serif",userSelect:"none",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",whiteSpace:"nowrap"},Ls={width:12,height:3,borderRadius:1,display:"inline-block",flexShrink:0},Ps={fontWeight:600},Vt={display:"flex",alignItems:"center",gap:4,padding:"1px 4px"},Es={...Vt,opacity:1,cursor:"pointer"},_s={...Vt,opacity:1,cursor:"default"},Ds={...Vt,opacity:.4,cursor:"pointer"},Fs={...Vt,opacity:.4,cursor:"default"},Be=new Map;function Rs(t){let e=Be.get(t);return e==null&&(e={...Ls,backgroundColor:t},Be.set(t,e)),e}function he({label:t,color:e,value:n,isHidden:o,onClick:s}){const r=o?s?Ds:Fs:s?Es:_s;return W.jsxs("div",{onClick:s,style:r,children:[W.jsx("span",{style:Rs(e)}),W.jsx("span",{children:t}),n&&W.jsx("span",{style:Ps,children:n})]})}const zt=D.forwardRef(function({left:e,top:n,children:o,className:s,style:r,onMouseDown:i,onMouseEnter:l,onMouseLeave:c},f){return W.jsx("div",{ref:f,className:s,onMouseDown:i,onMouseEnter:l,onMouseLeave:c,style:{...Is,left:e,top:n,...r},children:o})});function zs(t,e,n,o,s){if(s<0||o<0)return"";const i=t.dataStore.getYValues(e,n)[s];return i==null?"":typeof i=="number"?i.toPrecision(4):String(i)}const Hs={},Ws={pointerEvents:"none",zIndex:100},$s={fontWeight:600,marginBottom:2,padding:"0 4px"};function Gs({show:t=!0,className:e,children:n,offset:o=Hs}){var I,L;const s=Q(),r=D.useSyncExternalStore(s.subscribeCursor,s.getSnapshot),i=D.useRef(null);if(!t||r.activeDataIdx<0||r.activeGroup<0||r.left<0)return null;const{activeGroup:l,activeDataIdx:c}=r,f=s.plotBox,a=s.dataStore.data[l],d=a!=null?a.x[c]??null:null,u=d!=null?parseFloat(d.toPrecision(6)).toString():"",h=[];for(const m of s.seriesConfigs){if(m.show===!1||m.legend===!1)continue;const b=s.dataStore.getYValues(m.group,m.index),v=m.group===l?b[c]:null;h.push({label:m.label??`Series ${m.index}`,value:v,color:typeof m.stroke=="string"?m.stroke:"#000",group:m.group,index:m.index})}const p={x:d,xLabel:u,items:h,left:r.left+f.left,top:r.top+f.top},w=o.x??12,x=o.y??-12,g=((I=i.current)==null?void 0:I.offsetWidth)??0,S=((L=i.current)==null?void 0:L.offsetHeight)??0,C=r.left+f.left,M=r.top+f.top,P=f.left+f.width,A=f.top+f.height,k=Z(C+w,f.left,P-g),T=Z(M+x,f.top,A-S);return n?W.jsx("div",{ref:i,className:e,style:{position:"absolute",left:k,top:T,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100},children:n(p)}):W.jsxs(zt,{ref:i,left:k,top:T,className:e,style:Ws,children:[W.jsx("div",{style:$s,children:u}),h.map(m=>W.jsx(he,{label:m.label,color:m.color,value:m.value!=null?m.value.toPrecision(4):"—"},`${m.group}:${m.index}`))]})}const Vs=8,Xe=.01,Bs=[.25,.75];function Xs({width:t,height:e,data:n,onRangeChange:o,initialRange:s,className:r,colors:i,grips:l=!1}){const c=D.useRef(null),f=D.useMemo(()=>ne(n),[n]),[a,d]=D.useState(()=>{if(s!=null&&f.length>0){const A=f[0];if(A!=null&&A.x.length>1){const k=A.x[0],I=A.x[A.x.length-1]-k;if(I>0)return[Math.max(0,(s[0]-k)/I),Math.min(1,(s[1]-k)/I)]}}return Bs}),u=D.useRef(null);D.useEffect(()=>{if(o==null||f.length===0)return;const A=f[0];if(A==null||A.x.length<2)return;const k=A.x[0],I=A.x[A.x.length-1]-k,L=k+a[0]*I,m=k+a[1]*I,b=u.current,v=Math.max(1e-10,Math.abs(m-L)*1e-12);b!=null&&Math.abs(b[0]-L)<v&&Math.abs(b[1]-m)<v||(u.current=[L,m],o(L,m))},[a,f,o]);const h=D.useRef(null),p=D.useCallback(A=>{const k=c.current;if(k==null)return 0;const T=k.getBoundingClientRect();return Z((A-T.left)/T.width,0,1)},[]),w=D.useCallback(A=>{const k=c.current;if(k==null)return;const T=p(A.clientX),I=k.getBoundingClientRect().width,L=I>0?Vs/I:0;let m;if(Math.abs(T-a[0])<L)m="left";else if(Math.abs(T-a[1])<L)m="right";else if(T>=a[0]&&T<=a[1])m="move";else{const b=a[1]-a[0],v=b/2,y=Z(T-v,0,1-b);d([y,y+b]),m="move"}h.current={mode:m,startX:A.clientX,startFrac:[...a]},k.setPointerCapture(A.pointerId),A.preventDefault()},[a,p]),x=D.useCallback(A=>{const k=h.current;if(k==null)return;const T=p(A.clientX),I=p(k.startX),L=T-I;if(k.mode==="move"){const m=k.startFrac[1]-k.startFrac[0],b=Z(k.startFrac[0]+L,0,1-m);d([b,b+m])}else if(k.mode==="left"){const m=Z(k.startFrac[0]+L,0,k.startFrac[1]-Xe);d([m,k.startFrac[1]])}else{const m=Z(k.startFrac[1]+L,k.startFrac[0]+Xe,1);d([k.startFrac[0],m])}},[p]),g=D.useCallback(A=>{h.current=null;const k=c.current;k!=null&&k.releasePointerCapture(A.pointerId)},[]),S=`${a[0]*100}%`,C=`${(a[1]-a[0])*100}%`,M=f[0],P=M!=null?M.series.length:0;return W.jsxs("div",{className:r,style:{position:"relative",width:t,height:e},children:[W.jsxs(ae,{width:t,height:e,data:n,children:[W.jsx(Pt,{scale:"x",show:!1}),W.jsx(Pt,{scale:"y",show:!1}),Array.from({length:P},(A,k)=>W.jsx(fe,{group:0,index:k,yScale:"y",stroke:i!=null&&i[k]!=null?i[k]:`hsl(${k*137}, 60%, 50%)`,width:1},`0:${k}`))]}),W.jsxs("div",{ref:c,onPointerDown:w,onPointerMove:x,onPointerUp:g,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[W.jsx("div",{style:{position:"absolute",top:0,left:0,width:S,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),W.jsx("div",{style:{position:"absolute",top:0,left:`${a[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),W.jsx("div",{style:{position:"absolute",top:0,left:S,width:C,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:l&&W.jsxs(W.Fragment,{children:[W.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"}}),W.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 ht(t){const e=Q(),n=D.useRef(t);n.current=t,D.useEffect(()=>{const o=s=>n.current(s);return e.drawHooks.add(o),()=>{e.drawHooks.delete(o)}},[e])}function js(t){const e=Q(),n=D.useRef(t);n.current=t,D.useEffect(()=>{const o=(s,r)=>n.current(s,r);return e.cursorDrawHooks.add(o),()=>{e.cursorDrawHooks.delete(o)}},[e])}function Ys({lanes:t,laneHeight:e=24,gap:n=2,scaleId:o="x"}){const s=Q();return ht(({ctx:r,plotBox:i,pxRatio:l})=>{const c=s.scaleManager.getScale(o);if(c==null||!N(c))return;r.save(),r.beginPath(),r.rect(i.left*l,i.top*l,i.width*l,i.height*l),r.clip();const f=(e+n)*l,a=e*l,d=i.top*l;for(let u=0;u<t.length;u++){const h=t[u];if(h==null)continue;const p=d+u*f;r.fillStyle="#666",r.font=`${11*l}px sans-serif`,r.textAlign="right",r.textBaseline="middle",r.fillText(h.label,(i.left-6)*l,p+a/2);for(const w of h.segments){const x=X(w.start,c,i.width,i.left)*l,S=X(w.end,c,i.width,i.left)*l-x;S<=0||(r.fillStyle=w.color??"#4dabf7",r.fillRect(x,p,S,a),w.label!=null&&S>20*l&&(r.fillStyle="#fff",r.font=`${10*l}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(w.label,x+S/2,p+a/2,S-4*l)))}}r.restore()}),null}function Ns({data:t,width:e=150,height:n=30,stroke:o="#03a9f4",fill:s,lineWidth:r=1,paths:i,fillTo:l,className:c}){return W.jsx("div",{style:{pointerEvents:"none"},className:c,children:W.jsxs(ae,{width:e,height:n,data:t,children:[W.jsx(Pt,{scale:"x",show:!1}),W.jsx(Pt,{scale:"y",show:!1}),W.jsx(fe,{group:0,index:0,yScale:"y",stroke:o,fill:s,width:r,paths:i,fillTo:l})]})})}const at=8,Us={x:12,y:-12},Os={pointerEvents:"none"};function Ks(t,e,n,o){if(t!=null&&typeof t=="object")return t;switch(t){case"top-left":return{x:e.left+at,y:e.top+at};case"bottom-left":return{x:e.left+at,y:e.top+e.height-o-at};case"bottom-right":return{x:e.left+e.width-n-at,y:e.top+e.height-o-at};case"top-right":default:return{x:e.left+e.width-n-at,y:e.top+at}}}function qs({mode:t="draggable",position:e="top-right",offset:n=Us,idleOpacity:o=.3,show:s=!0,className:r}){var m,b;const i=Q(),l=D.useSyncExternalStore(i.subscribeCursor,i.getSnapshot),[c,f]=D.useState(null),[a,d]=D.useState(!1),[u,h]=D.useState(!1),p=D.useRef(!1),w=D.useRef(!1),x=D.useRef({dx:0,dy:0}),[g,S]=D.useState(!1),C=D.useRef(null);D.useLayoutEffect(()=>{if(t!=="draggable"||g||l.plotWidth<=0)return;S(!0);const v=C.current,y=(v==null?void 0:v.offsetWidth)??0,_=(v==null?void 0:v.offsetHeight)??0;f(Ks(e,i.plotBox,y,_))},[t,g,l.plotWidth,e,i.plotBox]);const M=(v,y)=>{w.current||i.toggleSeries(v,y)},P=v=>{if(t!=="draggable")return;v.stopPropagation(),v.preventDefault(),p.current=!0,h(!0),w.current=!1;const y=v.currentTarget.getBoundingClientRect();x.current={dx:v.clientX-y.left,dy:v.clientY-y.top}};if(D.useEffect(()=>{if(!s||t!=="draggable")return;const v=_=>{var z;if(!p.current)return;w.current=!0;const E=(z=i.canvas)==null?void 0:z.parentElement;if(!E)return;const R=E.getBoundingClientRect();f({x:_.clientX-R.left-x.current.dx,y:_.clientY-R.top-x.current.dy})},y=()=>{p.current=!1,h(!1)};return window.addEventListener("mousemove",v),window.addEventListener("mouseup",y),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",y)}},[i,s,t]),!s)return null;const{activeGroup:A,activeDataIdx:k,left:T,top:I}=l,L=i.seriesConfigs.filter(v=>v.legend!==!1).map(v=>{const y=typeof v.stroke=="string"?v.stroke:"#000",_=zs(i,v.group,v.index,A,k),E=t==="draggable";return W.jsx(he,{label:v.label??`Series ${v.index}`,color:y,value:_,isHidden:v.show===!1,onClick:E?()=>M(v.group,v.index):void 0},`${v.group}:${v.index}`)});if(t==="cursor"){if(T<0)return null;const v=((m=C.current)==null?void 0:m.offsetWidth)??0,y=((b=C.current)==null?void 0:b.offsetHeight)??0,_=l.plotLeft+l.plotWidth,E=l.plotTop+l.plotHeight,R=Z(T+l.plotLeft+n.x,l.plotLeft,_-v),z=Z(I+l.plotTop+n.y,l.plotTop,E-y);return W.jsx(zt,{ref:C,left:R,top:z,className:r,style:Os,children:L})}return c==null?null:W.jsx(zt,{ref:C,left:c.x,top:c.y,className:r,onMouseDown:P,onMouseEnter:()=>d(!0),onMouseLeave:()=>{d(!1),w.current=!1},style:{pointerEvents:"auto",cursor:u?"grabbing":"grab",opacity:a||u?1:o,transition:"opacity 0.2s ease"},children:L})}const Zs={pointerEvents:"none"};function Js({delay:t=1e3,show:e=!0,className:n}){var S,C;const o=Q(),s=D.useSyncExternalStore(o.subscribe,o.getSnapshot),[r,i]=D.useState(!1),l=D.useRef(-1),c=D.useRef(0),f=D.useRef(null);if(D.useEffect(()=>{const M=s.activeSeriesIdx;M!==l.current&&(l.current=M,i(!1),window.clearTimeout(c.current),M>=0&&(c.current=window.setTimeout(()=>i(!0),t)))},[s.activeSeriesIdx,t]),D.useEffect(()=>()=>{window.clearTimeout(c.current)},[]),!e||!r||s.left<0)return null;const a=o.seriesConfigs.find(M=>M.group===s.activeGroup&&M.index===s.activeSeriesIdx);if(!(a!=null&&a.label)||a.legend===!1)return null;const d=typeof a.stroke=="string"?a.stroke:"#000",u=((S=f.current)==null?void 0:S.offsetWidth)??80,h=((C=f.current)==null?void 0:C.offsetHeight)??24,p=s.left+s.plotLeft,w=s.top+s.plotTop,x=Z(p-u/2,s.plotLeft,s.plotLeft+s.plotWidth-u),g=Z(w-h-12,s.plotTop,s.plotTop+s.plotHeight-h);return W.jsx(zt,{ref:f,left:x,top:g,className:n,style:Zs,children:W.jsx(he,{label:a.label,color:d})})}function hn(t,e,n,o,s,r,i,l,c){const f=i/2;if(c.wickColor!=null&&(t.strokeStyle=c.wickColor,t.lineWidth=c.wickWidth??1,t.beginPath(),t.moveTo(e,n),t.lineTo(e,o),t.stroke()),c.capWidth!=null&&c.capWidth>0){const u=c.capWidth/2;t.strokeStyle=c.wickColor??"#555",t.lineWidth=c.wickWidth??1,t.beginPath(),t.moveTo(e-u,n),t.lineTo(e+u,n),t.moveTo(e-u,o),t.lineTo(e+u,o),t.stroke()}const a=Math.min(s,r),d=Math.abs(r-s);t.fillStyle=c.bodyFill,t.fillRect(e-f,a,i,d),c.bodyStroke!=null&&(t.strokeStyle=c.bodyStroke,t.lineWidth=c.bodyStrokeWidth??1.5,t.strokeRect(e-f,a,i,d)),l!=null&&c.midColor!=null&&(t.strokeStyle=c.midColor,t.lineWidth=c.midWidth??2.5,t.beginPath(),t.moveTo(e-f,l),t.lineTo(e+f,l),t.stroke())}function Qs({boxes:t,yScale:e="y",boxWidth:n=.5,fill:o="rgba(52, 152, 219, 0.4)",stroke:s="#2980b9",medianColor:r="#e74c3c",whiskerColor:i="#555"}){return ht(({ctx:l,plotBox:c,valToX:f,valToY:a})=>{const d=c.width/t.length*n,u=d*.3;for(let h=0;h<t.length;h++){const p=t[h];if(p==null)continue;const w=f(h+1),x=a(p.min,e),g=a(p.q1,e),S=a(p.median,e),C=a(p.q3,e),M=a(p.max,e);w==null||x==null||g==null||S==null||C==null||M==null||hn(l,w,x,M,g,C,d,S,{wickColor:i,bodyFill:o,bodyStroke:s,capWidth:u,midColor:r})}}),null}function ti(t){const e=Math.max(0,Math.min(1,t)),n=[[0,15,30,80],[.15,30,100,200],[.3,40,190,210],[.45,50,200,80],[.6,230,220,40],[.75,240,140,30],[.9,220,40,30],[1,120,10,10]];let o=n[0],s=n[n.length-1];for(let f=0;f<n.length-1;f++){const a=n[f],d=n[f+1];if(a!=null&&d!=null&&e>=a[0]&&e<=d[0]){o=a,s=d;break}}const r=s[0]===o[0]?0:(e-o[0])/(s[0]-o[0]),i=Math.round(o[1]+r*(s[1]-o[1])),l=Math.round(o[2]+r*(s[2]-o[2])),c=Math.round(o[3]+r*(s[3]-o[3]));return`rgb(${i},${l},${c})`}function ei({grid:t,xRange:e,yRange:n,colorMap:o=ti,yScale:s="y"}){return ht(({ctx:r,valToX:i,valToY:l})=>{var g;if(t.length===0)return;const c=t.length,f=((g=t[0])==null?void 0:g.length)??0;if(f===0)return;const a=(e==null?void 0:e[0])??0,d=(e==null?void 0:e[1])??c,u=(n==null?void 0:n[0])??0,h=(n==null?void 0:n[1])??f,p=(d-a)/c,w=(h-u)/f;let x=0;for(const S of t)for(const C of S)C>x&&(x=C);if(x!==0)for(let S=0;S<c;S++){const C=t[S];if(C==null)continue;const M=i(a+S*p),P=i(a+(S+1)*p);if(M==null||P==null)continue;const A=P-M;for(let k=0;k<f;k++){const T=C[k]??0,I=u+k*w,L=u+(k+1)*w,m=l(L,s),b=l(I,s);if(m==null||b==null)continue;const v=b-m;r.fillStyle=o(T/x),r.fillRect(M,m,A,v)}}}),null}function ni(t,e,n,o,s){const r=(o-90)*(Math.PI/180),i=s,l=i*.35,c=Math.PI/6,f=e+Math.cos(r)*i,a=n+Math.sin(r)*i,d=e-Math.cos(r)*i*.5,u=n-Math.sin(r)*i*.5;t.beginPath(),t.moveTo(d,u),t.lineTo(f,a),t.stroke(),t.beginPath(),t.moveTo(f,a),t.lineTo(f-l*Math.cos(r-c),a-l*Math.sin(r-c)),t.moveTo(f,a),t.lineTo(f-l*Math.cos(r+c),a-l*Math.sin(r+c)),t.stroke()}function oi({directions:t,group:e=0,index:n=0,color:o="#c0392b",minSize:s=4,maxSize:r=10}){const i=Q();return ht(({ctx:l,valToX:c,valToY:f})=>{var g;const a=i.dataStore.data[e];if(a==null)return;const d=a.x,u=a.series[n];if(u==null)return;let h=1/0,p=-1/0;for(let S=0;S<u.length;S++){const C=u[S];C!=null&&(C<h&&(h=C),C>p&&(p=C))}const w=p-h||1,x=((g=i.seriesConfigs.find(S=>S.group===e&&S.index===n))==null?void 0:g.yScale)??"y";l.strokeStyle=o,l.lineWidth=1.5,l.lineCap="round";for(let S=0;S<d.length;S++){const C=u[S],M=t[S];if(C==null||M==null)continue;const P=c(d[S]),A=f(C,x);if(P==null||A==null)continue;const k=(C-h)/w,T=s+k*(r-s);ni(l,P,A,M,T)}}),null}const si=4;function de(t,e){t.strokeStyle=e.stroke??"red",t.lineWidth=e.width??1,e.dash&&t.setLineDash(e.dash)}function ge(t,e){e.dash&&t.setLineDash([])}function dn(t,e,n,o={}){const{ctx:s,plotBox:r}=t,i=X(n,e,r.height,r.top);s.beginPath(),s.moveTo(r.left,i),s.lineTo(r.left+r.width,i),de(s,o),s.stroke(),ge(s,o)}function gn(t,e,n,o={}){const{ctx:s,plotBox:r}=t,i=X(n,e,r.width,r.left);s.beginPath(),s.moveTo(i,r.top),s.lineTo(i,r.top+r.height),de(s,o),s.stroke(),ge(s,o)}function ii(t,e,n,o,s,r,i={}){const{ctx:l,plotBox:c}=t,f=X(o,e,c.width,c.left),a=X(s,n,c.height,c.top);l.font=i.font??"12px sans-serif",l.fillStyle=i.fill??"#000",l.textBaseline="bottom",l.fillText(r,f,a-si)}function pn(t,e,n,o,s={}){const{ctx:r,plotBox:i}=t,l=X(o,e,i.height,i.top),c=X(n,e,i.height,i.top);r.fillStyle=s.fill??"rgba(255,0,0,0.1)",r.fillRect(i.left,Math.min(l,c),i.width,Math.abs(c-l)),s.stroke&&(de(r,s),r.strokeRect(i.left,Math.min(l,c),i.width,Math.abs(c-l)),ge(r,s))}function pe(t,e,n){const o=D.useRef(t);D.useLayoutEffect(()=>{o.current=t},[t]),ht(s=>{const r=s.getScale(e);r!=null&&n(s,r,o.current)})}function ri(t){return pe(t,t.yScale??"y",(e,n,o)=>{if(dn(e,n,o.value,{stroke:o.stroke,width:o.width,dash:o.dash}),o.label!=null){const s=e.valToY(o.value,o.yScale??"y");if(s==null)return;const{ctx:r,plotBox:i}=e;r.font=o.labelFont??"11px sans-serif",r.fillStyle=o.stroke??"red",r.textAlign="left",r.textBaseline="bottom",r.fillText(o.label,i.left+4,s-4)}}),null}function li(t){return pe(t,t.xScale??"x",(e,n,o)=>{if(gn(e,n,o.value,{stroke:o.stroke,width:o.width,dash:o.dash}),o.label!=null){const s=e.valToX(o.value,o.xScale??"x");if(s==null)return;const{ctx:r,plotBox:i}=e;r.font=o.labelFont??"11px sans-serif",r.fillStyle=o.stroke??"red",r.textAlign="center",r.textBaseline="bottom",r.fillText(o.label,s,i.top-4)}}),null}function ci(t){return pe(t,t.yScale??"y",(e,n,o)=>{pn(e,n,o.yMin,o.yMax,{fill:o.fill,stroke:o.stroke,width:o.strokeWidth,dash:o.dash})}),null}function ai(t){const e=D.useRef(t);return D.useLayoutEffect(()=>{e.current=t}),ht(n=>{const o=e.current,s=n.valToX(o.x,o.xScale??"x"),r=n.valToY(o.y,o.yScale??"y");if(s==null||r==null)return;const{ctx:i}=n;i.font=o.font??"12px sans-serif",i.fillStyle=o.fill??"#000",i.textAlign=o.align??"left",i.textBaseline=o.baseline??"bottom",i.fillText(o.text,s,r-4)}),null}function ui(t){const e=(n,o,s,r,i,l,c,f,a,d,u,h,p)=>{const w=(p==null?void 0:p.align)??t??1,x=(p==null?void 0:p.spanGaps)??!1;if([a,d]=Ht(o,a,d),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const g=L=>h(X(L,s,i,c)),S=L=>h(X(L,r,l,f)),C=s.ori===H.Horizontal?$t:Gt,M={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},P=M.stroke;let A=!1;const k=u===O.Forward?a:d;let T=S(o[k]),I=g(n[k]);C(P,I,T);for(let L=k;L>=a&&L<=d;L+=u){const m=o[L];if(m==null){m===null&&!x&&(A=!0);continue}const b=g(n[L]),v=S(m);if(w===1)C(P,b,T);else if(w===-1)C(P,I,v);else{const y=h((I+b)/2);C(P,y,T),C(P,y,v)}C(P,b,v),T=v,I=b}{const L=M.fill=new Path2D(P),m=(p==null?void 0:p.fillTo)??r.min??0,b=S(m);let v=g(n[a]),y=g(n[d]);u===O.Backward&&([y,v]=[v,y]),C(L,y,b),C(L,v,b)}if(A){const L=ie(n,o,a,d,u,g);M.gaps=L,M.clip=re(L,s.ori,c,f,i,l)}return M};return e.defaults=Wt,e}function me(t){return t.defaults=Gn,t}function we(){return me((e,n,o,s,r,i,l,c,f,a,d,u,h)=>{const p=(h==null?void 0:h.barWidth)??.6,w=(h==null?void 0:h.barGap)??0,x=(h==null?void 0:h.barRadius)??0,g=(h==null?void 0:h.barGroupIdx)??0,S=(h==null?void 0:h.barGroupCount)??1,C=y=>u(X(y,o,r,l)),M=y=>u(X(y,s,i,c));let P=r;if(a>f){let y=1/0,_=-1;for(let E=f;E<=a;E++)if(n[E]!=null){if(_>=0){const R=e[E],z=e[_],F=Math.abs(C(R)-C(z));F<y&&(y=F)}_=E}y<1/0&&(P=y)}const A=P*(1-p),k=Math.max(0,A+w),T=Math.max(1,u(P-k)),I=S>1?Math.max(1,u(T/Math.max(1,S))):T,L=(h==null?void 0:h.fillTo)??s.min??0,m=M(L),b=new Path2D,v=o.ori===H.Horizontal;for(let y=d===O.Forward?f:a;y>=f&&y<=a;y+=d){const _=n[y];if(_==null)continue;const E=C(e[y]),R=M(_),z=S>1?(g-(S-1)/2)*I:0,F=u(E-I/2+z),$=Math.min(R,m),V=Math.max(R,m)-$;if(V!==0)if(x>0){const U=Math.min(x*I,V/2);di(b,v,F,$,I,V,U,_<L)}else v?b.rect(F,$,I,V):b.rect($,F,V,I)}return{stroke:b,fill:b,clip:null,band:null,gaps:null}})}function fi(t,e){const n=we();return me((s,r,i,l,c,f,a,d,u,h,p,w,x)=>{const g={...x,barGroupIdx:t,barGroupCount:e};return n(s,r,i,l,c,f,a,d,u,h,p,w,g)})}function hi(){const t=we();return me((n,o,s,r,i,l,c,f,a,d,u,h,p)=>{const w={barWidth:.8,...p};return t(n,o,s,r,i,l,c,f,a,d,u,h,w)})}function di(t,e,n,o,s,r,i,l){i=Math.min(i,s/2,r/2),e?l?(t.moveTo(n,o),t.lineTo(n+s,o),t.lineTo(n+s,o+r-i),t.arc(n+s-i,o+r-i,i,0,Math.PI/2),t.lineTo(n+i,o+r),t.arc(n+i,o+r-i,i,Math.PI/2,Math.PI),t.closePath()):(t.moveTo(n,o+r),t.lineTo(n,o+i),t.arc(n+i,o+i,i,Math.PI,Math.PI*1.5),t.lineTo(n+s-i,o),t.arc(n+s-i,o+i,i,Math.PI*1.5,0),t.lineTo(n+s,o+r),t.closePath()):l?(t.moveTo(o,n),t.lineTo(o,n+s),t.lineTo(o+r-i,n+s),t.arc(o+r-i,n+s-i,i,Math.PI/2,0,!0),t.lineTo(o+r,n+i),t.arc(o+r-i,n+i,i,0,-Math.PI/2,!0),t.closePath()):(t.moveTo(o+r,n),t.lineTo(o+i,n),t.arc(o+i,n+i,i,-Math.PI/2,Math.PI,!0),t.lineTo(o,n+s-i),t.arc(o+i,n+s-i,i,Math.PI,Math.PI/2,!0),t.lineTo(o+r,n+s),t.closePath())}function mn(t){const e=(n,o,s,r,i,l,c,f,a,d,u,h,p)=>{const w=(p==null?void 0:p.spanGaps)??!1;if([a,d]=Ht(o,a,d),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const x=I=>h(X(I,s,i,c)),g=I=>h(X(I,r,l,f)),S=s.ori===H.Horizontal?$t:Gt,C=[],M=[];let P=!1;for(let I=u===O.Forward?a:d;I>=a&&I<=d;I+=u){const L=o[I];L!=null?(C.push(x(n[I])),M.push(g(L))):L===null&&!w&&(P=!0)}const A=s.ori===H.Horizontal,k=t(C,M,A,h),T={stroke:k??new Path2D,fill:null,clip:null,band:null,gaps:null};if(k!=null){const I=T.fill=new Path2D(k),L=(p==null?void 0:p.fillTo)??r.min??0,m=g(L);let b=x(n[a]),v=x(n[d]);u===O.Backward&&([v,b]=[b,v]),S(I,v,m),S(I,b,m)}if(P){const I=ie(n,o,a,d,u,x);T.gaps=I,T.clip=re(I,s.ori,c,f,i,l)}return T};return e.defaults=Wt,e}function gi(){return mn(pi)}const pi=(t,e,n,o)=>{const s=t.length;if(s<2)return null;const r=new Path2D,i=t[0]??0,l=e[0]??0;if(n?r.moveTo(i,l):r.moveTo(l,i),s===2){const u=t[1]??0,h=e[1]??0;return n?r.lineTo(u,h):r.lineTo(h,u),r}const c=new Array(s),f=new Array(s-1),a=new Array(s-1),d=new Array(s-1);for(let u=0;u<s-1;u++)a[u]=(e[u+1]??0)-(e[u]??0),d[u]=(t[u+1]??0)-(t[u]??0),f[u]=d[u]!==0?(a[u]??0)/(d[u]??1):0;c[0]=f[0]??0;for(let u=1;u<s-1;u++){const h=f[u]??0,p=f[u-1]??0;if(h===0||p===0||p>0!=h>0)c[u]=0;else{const w=d[u]??1,x=d[u-1]??1;c[u]=3*(x+w)/((2*w+x)/p+(w+2*x)/h),isFinite(c[u]??0)||(c[u]=0)}}c[s-1]=f[s-2]??0;for(let u=0;u<s-1;u++){const h=d[u]??1,p=t[u]??0,w=e[u]??0,x=t[u+1]??0,g=e[u+1]??0,S=c[u]??0,C=c[u+1]??0,M=p+h/3,P=w+S*h/3,A=x-h/3,k=g-C*h/3;n?r.bezierCurveTo(M,P,A,k,x,g):r.bezierCurveTo(P,M,k,A,g,x)}return r};function mi(){return mn(wi)}const wi=(t,e,n,o)=>{const s=t.length;if(s<2)return null;const r=new Path2D,i=o(t[0]??0),l=o(e[0]??0);if(n?r.moveTo(i,l):r.moveTo(l,i),s===2){const c=o(t[1]??0),f=o(e[1]??0);return n?r.lineTo(c,f):r.lineTo(f,c),r}for(let c=0;c<s-1;c++){const f=c===0?0:c-1,a=t[f]??0,d=e[f]??0,u=t[c]??0,h=e[c]??0,p=t[c+1]??0,w=e[c+1]??0,x=c+2<s?t[c+2]??0:p,g=c+2<s?e[c+2]??0:w,S=Math.hypot(a-u,d-h),C=Math.hypot(u-p,h-w),M=Math.hypot(p-x,w-g),P=Math.sqrt(M),A=M,k=Math.sqrt(C),T=C,I=Math.sqrt(S),L=S,m=2*L+3*I*k+T,b=2*A+3*P*k+T,v=3*I*(I+k),y=3*P*(P+k);let _,E,R,z;if(v>0){const F=1/v;_=(-T*a+m*u+L*p)*F,E=(-T*d+m*h+L*w)*F}else _=u,E=h;if(y>0){const F=1/y;R=(A*u+b*p-T*x)*F,z=(A*h+b*w-T*g)*F}else R=p,z=w;n?r.bezierCurveTo(_,E,R,z,p,w):r.bezierCurveTo(E,_,z,R,w,p)}return r};function Si(t=4){const e=(n,o,s,r,i,l,c,f,a,d,u,h,p)=>{const w=M=>h(X(M,s,i,c)),x=M=>h(X(M,r,l,f)),g=t/2,S=new Path2D,C=s.ori===H.Horizontal;for(let M=u===O.Forward?a:d;M>=a&&M<=d;M+=u){const P=o[M];if(P==null)continue;const A=w(n[M]),k=x(P);C?(S.moveTo(A+g,k),S.arc(A,k,g,0,Math.PI*2)):(S.moveTo(k+g,A),S.arc(k,A,g,0,Math.PI*2))}return{stroke:S,fill:S,clip:null,band:null,gaps:null}};return e.defaults=Vn,e}function vi({group:t=0,series:e=[0,1,2,3],yScale:n="y",upColor:o="#26a69a",downColor:s="#ef5350",bodyWidth:r=.6,wickWidth:i=1}){const l=Q();return ht(({ctx:c,plotBox:f,valToX:a,valToY:d})=>{const u=l.dataStore.data[t];if(u==null)return;const h=u.x,p=u.series[e[0]],w=u.series[e[1]],x=u.series[e[2]],g=u.series[e[3]];if(p==null||w==null||x==null||g==null)return;const S=h.length;if(S===0)return;const C=Math.max(2,f.width/S*r);for(let M=0;M<S;M++){const P=h[M],A=p[M],k=w[M],T=x[M],I=g[M];if(P==null||A==null||k==null||T==null||I==null)continue;const L=a(P),m=d(k,n),b=d(T,n),v=d(A,n),y=d(I,n);if(L==null||m==null||b==null||v==null||y==null)continue;const E=I>=A?o:s;hn(c,L,m,b,v,y,C,null,{wickColor:E,wickWidth:i,bodyFill:E})}}),null}function bi(t,e,n=0){const o=e??t.series.map((a,d)=>d),s=t.x.length,r=[],i=new Float64Array(s);for(let a=0;a<o.length;a++){const d=o[a];if(d==null)continue;const u=t.series[d];if(u==null)continue;const h=new Array(s);for(let p=0;p<s;p++){const w=u[p];w!=null?(i[p]=i[p]+w,h[p]=i[p]):h[p]=null}r.push(h)}const l=new Map;for(let a=0;a<o.length;a++){const d=o[a];d!=null&&l.set(d,a)}const c=[];for(let a=0;a<t.series.length;a++){const d=l.get(a)??-1,u=d>=0?r[d]:void 0;u!=null?c.push(u):c.push(t.series[a]??[])}const f=[];for(let a=o.length-1;a>0;a--){const d=o[a],u=o[a-1];d!=null&&u!=null&&f.push({group:n,series:[d,u]})}return{group:{x:t.x,series:c},bands:f}}function Mi(t){const e=new Set;for(const[r]of t)for(let i=0;i<r.length;i++){const l=r[i];l!=null&&e.add(l)}const n=Float64Array.from([...e].sort((r,i)=>r-i)),o=new Map;for(let r=0;r<n.length;r++){const i=n[r];i!=null&&o.set(i,r)}const s=[];for(const[r,i]of t){const l=new Array(n.length).fill(null);for(let c=0;c<r.length;c++){const f=r[c];if(f==null)continue;const a=o.get(f);a!=null&&(l[a]=i[c]??null)}s.push(l)}return[{x:n,series:s}]}function xi(t){const e=(t==null?void 0:t.decimals)??1;return n=>n.map(o=>{const s=Math.abs(o);return s>=1e9?(o/1e9).toFixed(e)+"B":s>=1e6?(o/1e6).toFixed(e)+"M":s>=1e3?(o/1e3).toFixed(e)+"K":o.toFixed(s>=1?0:e)})}function yi(t,e=0){return n=>n.map(o=>o.toFixed(e)+t)}function Ci(t,e=0){return n=>n.map(o=>t+o.toFixed(e))}function ki(t,e,n=0){return o=>o.map(s=>t+s.toFixed(n)+e)}function Ti(t){const e=(t==null?void 0:t.utc)??!1;return n=>n.map(o=>e?ot(o,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):ot(o,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function Ai(t){const e=t!=null&&t.utc?"UTC":void 0,n=(t==null?void 0:t.format)??"short";return o=>o.map(s=>ot(s,{month:n},e))}function Ii(t){const{tz:e,...n}=t??{};return o=>o.map(s=>ot(s,n,e))}function Li(t,e=0){return n=>n.map(o=>{const s=Math.round(o)-e;return t[s]??String(o)})}exports.AnnotationLabel=ai;exports.Axis=Pt;exports.Band=vs;exports.BoxWhisker=Qs;exports.Candlestick=vi;exports.Chart=ae;exports.DEFAULT_ACTIONS=Rt;exports.Direction=O;exports.Distribution=K;exports.FloatingLegend=qs;exports.HLine=ri;exports.Heatmap=ei;exports.HoverLabel=Js;exports.Legend=As;exports.Orientation=H;exports.Region=ci;exports.Scale=gs;exports.Series=fe;exports.Side=Y;exports.SortOrder=xt;exports.Sparkline=Ns;exports.Timeline=Ys;exports.Tooltip=Gs;exports.VLine=li;exports.Vector=oi;exports.ZoomRanger=Xs;exports.alignData=Mi;exports.bars=we;exports.catmullRom=mi;exports.drawHLine=dn;exports.drawLabel=ii;exports.drawRegion=pn;exports.drawVLine=gn;exports.fadeGradient=ms;exports.fmtCompact=xi;exports.fmtDateStr=Ii;exports.fmtHourMin=Ti;exports.fmtLabels=Li;exports.fmtMonthName=Ai;exports.fmtPrefix=Ci;exports.fmtSuffix=yi;exports.fmtWrap=ki;exports.focus=vn;exports.groupedBars=fi;exports.linear=nn;exports.lttb=le;exports.lttbGroup=Yn;exports.monotoneCubic=gi;exports.palette=ws;exports.points=Si;exports.posToVal=lt;exports.sideOrientation=St;exports.stackGroup=bi;exports.stackedBars=hi;exports.stepped=ui;exports.useChart=Uo;exports.useCursorDrawHook=js;exports.useDrawHook=ht;exports.valToPos=X;exports.withAlpha=un;
|