uplot-plus 0.5.14 → 0.5.24

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.
Files changed (101) hide show
  1. package/README.md +38 -4
  2. package/dist/axes/layout.d.ts +3 -2
  3. package/dist/axes/layout.d.ts.map +1 -1
  4. package/dist/axes/ticks.d.ts +5 -3
  5. package/dist/axes/ticks.d.ts.map +1 -1
  6. package/dist/components/Band.d.ts.map +1 -1
  7. package/dist/components/BoxWhisker.d.ts +6 -1
  8. package/dist/components/BoxWhisker.d.ts.map +1 -1
  9. package/dist/components/Candlestick.d.ts +4 -1
  10. package/dist/components/Candlestick.d.ts.map +1 -1
  11. package/dist/components/Chart.d.ts +1 -1
  12. package/dist/components/Chart.d.ts.map +1 -1
  13. package/dist/components/FloatingLegend.d.ts +3 -8
  14. package/dist/components/FloatingLegend.d.ts.map +1 -1
  15. package/dist/components/Heatmap.d.ts.map +1 -1
  16. package/dist/components/Legend.d.ts.map +1 -1
  17. package/dist/components/Series.d.ts +1 -0
  18. package/dist/components/Series.d.ts.map +1 -1
  19. package/dist/components/Sparkline.d.ts +2 -1
  20. package/dist/components/Sparkline.d.ts.map +1 -1
  21. package/dist/components/ThemeProvider.d.ts +20 -0
  22. package/dist/components/ThemeProvider.d.ts.map +1 -0
  23. package/dist/components/Tooltip.d.ts.map +1 -1
  24. package/dist/components/Vector.d.ts +1 -1
  25. package/dist/components/Vector.d.ts.map +1 -1
  26. package/dist/components/ZoomRanger.d.ts.map +1 -1
  27. package/dist/components/annotations/AnnotationLabel.d.ts.map +1 -1
  28. package/dist/components/annotations/HLine.d.ts.map +1 -1
  29. package/dist/components/annotations/Region.d.ts.map +1 -1
  30. package/dist/components/annotations/VLine.d.ts.map +1 -1
  31. package/dist/components/overlay/SeriesPanel.d.ts +6 -9
  32. package/dist/components/overlay/SeriesPanel.d.ts.map +1 -1
  33. package/dist/components/overlay/tokens.d.ts +17 -0
  34. package/dist/components/overlay/tokens.d.ts.map +1 -0
  35. package/dist/core/DataStore.d.ts.map +1 -1
  36. package/dist/core/RenderScheduler.d.ts +2 -0
  37. package/dist/core/RenderScheduler.d.ts.map +1 -1
  38. package/dist/core/ScaleManager.d.ts.map +1 -1
  39. package/dist/core/normalizeData.d.ts.map +1 -1
  40. package/dist/formatters.d.ts +3 -0
  41. package/dist/formatters.d.ts.map +1 -1
  42. package/dist/hooks/useChartStore.d.ts +14 -9
  43. package/dist/hooks/useChartStore.d.ts.map +1 -1
  44. package/dist/hooks/useDraggableOverlay.d.ts +4 -9
  45. package/dist/hooks/useDraggableOverlay.d.ts.map +1 -1
  46. package/dist/hooks/useInteraction.d.ts.map +1 -1
  47. package/dist/index.cjs +1 -1
  48. package/dist/index.d.ts +6 -1
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +2638 -2120
  51. package/dist/math/lttb.d.ts.map +1 -1
  52. package/dist/math/stack.d.ts +3 -2
  53. package/dist/math/stack.d.ts.map +1 -1
  54. package/dist/math/utils.d.ts +1 -1
  55. package/dist/math/utils.d.ts.map +1 -1
  56. package/dist/paths/bars.d.ts +6 -3
  57. package/dist/paths/bars.d.ts.map +1 -1
  58. package/dist/paths/linear.d.ts.map +1 -1
  59. package/dist/paths/lttbLinear.d.ts.map +1 -1
  60. package/dist/paths/points.d.ts.map +1 -1
  61. package/dist/paths/spline.d.ts.map +1 -1
  62. package/dist/paths/stepped.d.ts.map +1 -1
  63. package/dist/paths/types.d.ts +2 -0
  64. package/dist/paths/types.d.ts.map +1 -1
  65. package/dist/paths/utils.d.ts.map +1 -1
  66. package/dist/rendering/CanvasRenderer.d.ts +3 -3
  67. package/dist/rendering/CanvasRenderer.d.ts.map +1 -1
  68. package/dist/rendering/drawAxes.d.ts +2 -2
  69. package/dist/rendering/drawAxes.d.ts.map +1 -1
  70. package/dist/rendering/drawBands.d.ts +5 -2
  71. package/dist/rendering/drawBands.d.ts.map +1 -1
  72. package/dist/rendering/drawCursor.d.ts +2 -2
  73. package/dist/rendering/drawCursor.d.ts.map +1 -1
  74. package/dist/rendering/drawSelect.d.ts +2 -2
  75. package/dist/rendering/drawSelect.d.ts.map +1 -1
  76. package/dist/rendering/theme.d.ts +45 -4
  77. package/dist/rendering/theme.d.ts.map +1 -1
  78. package/dist/time/fmtDate.d.ts +8 -8
  79. package/dist/time/fmtDate.d.ts.map +1 -1
  80. package/dist/time/timeVals.d.ts +1 -1
  81. package/dist/time/timeVals.d.ts.map +1 -1
  82. package/dist/types/chart.d.ts +7 -0
  83. package/dist/types/chart.d.ts.map +1 -1
  84. package/dist/types/common.d.ts +12 -0
  85. package/dist/types/common.d.ts.map +1 -1
  86. package/dist/types/index.d.ts +4 -3
  87. package/dist/types/index.d.ts.map +1 -1
  88. package/dist/types/interaction.d.ts +6 -2
  89. package/dist/types/interaction.d.ts.map +1 -1
  90. package/dist/types/series.d.ts +10 -5
  91. package/dist/types/series.d.ts.map +1 -1
  92. package/dist/types/theme.d.ts +65 -0
  93. package/dist/types/theme.d.ts.map +1 -0
  94. package/dist/types/tooltip.d.ts +3 -8
  95. package/dist/types/tooltip.d.ts.map +1 -1
  96. package/dist/utils/at.d.ts +9 -0
  97. package/dist/utils/at.d.ts.map +1 -0
  98. package/dist/utils/estimatePanelSize.d.ts +2 -1
  99. package/dist/utils/estimatePanelSize.d.ts.map +1 -1
  100. package/dist/utils/shallowEqual.d.ts.map +1 -1
  101. package/package.json +3 -1
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var zn=Object.defineProperty;var $n=(t,e,n)=>e in t?zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Y=(t,e,n)=>$n(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),_=require("react"),Pe=require("@chenglou/pretext");function Bn(t=.15){return e=>{e.focusAlpha=t}}const Xt=[["leftDrag","zoomX"],["leftDblclick","reset"],["wheel","zoomX"],["xGutterDrag","panX"],["yGutterDrag","panY"],["pinch","zoomX"],["touchDrag","zoomX"]];var j=(t=>(t[t.Top=0]="Top",t[t.Right=1]="Right",t[t.Bottom=2]="Bottom",t[t.Left=3]="Left",t))(j||{}),$=(t=>(t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical",t))($||{}),K=(t=>(t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward",t))(K||{}),q=(t=>(t[t.Linear=1]="Linear",t[t.Ordinal=2]="Ordinal",t[t.Log=3]="Log",t[t.Asinh=4]="Asinh",t))(q||{}),Lt=(t=>(t[t.Ascending=1]="Ascending",t[t.Descending=-1]="Descending",t[t.Unsorted=0]="Unsorted",t))(Lt||{});function Ct(t){return t%2}var st=(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))(st||{});function Ee(t){if(t==="transparent")return!0;const e=t.match(/,\s*([\d.]+)\s*\)$/);return!!(e!=null&&e[1]!=null&&parseFloat(e[1])===0||t.startsWith("#")&&(t.length===5&&t[4]==="0"||t.length===9&&t.slice(7)==="00"))}function Ft(t){var r,i;const e=typeof t.stroke=="string"?t.stroke:null,n=typeof t.fill=="string"?t.fill:null,o=e!=null&&!Ee(e),s=n!=null&&!Ee(n);return((i=(r=t.paths)==null?void 0:r.defaults)==null?void 0:i.width)===0&&s||!o&&s?n:e??"#000"}const et=Math,qt=et.PI,rt=et.abs,at=et.floor,G=et.round,Rt=et.ceil,ae=et.min,It=et.max,yt=et.pow,_e=et.sign,lt=et.log10,Et=et.log2,Gn=(t,e=1)=>et.sinh(t)*e,fe=(t,e=1)=>et.asinh(t/e),Q=1/0,un=Number.isInteger;function Zt(t,e){return t[e]??0}function wt(t,e,n=0,o=e.length-1){let s;const l=o<=2147483647;for(;o-n>1;)s=l?n+o>>1:at((n+o)/2),Zt(e,s)<t?n=s:o=s;return t-Zt(e,n)<=Zt(e,o)-t?n:o}const fn=t=>t!=null,dn=t=>t!=null&&t>0;function hn(t){return(e,n,o)=>{let s=-1,l=-1;for(let r=n;r<=o;r++)if(t(e[r])){s=r;break}for(let r=o;r>=n;r--)if(t(e[r])){l=r;break}return[s,l]}}const Nt=hn(fn),gn=hn(dn);function Vn(t,e,n,o=Lt.Unsorted,s=!1){const l=s?gn:Nt,r=s?dn:fn,[i,a]=l(t,e,n);let d=t[i]??Q,c=t[i]??-Q;if(i>-1)if(o===Lt.Ascending)d=t[i]??Q,c=t[a]??-Q;else if(o===Lt.Descending)d=t[a]??Q,c=t[i]??-Q;else for(let h=i;h<=a;h++){const u=t[h];u!=null&&r(u)&&(u<d?d=u:u>c&&(c=u))}return[d,c]}function ct(t,e=0){if(un(t))return t;const n=10**e,o=t*n*(1+Number.EPSILON);return G(o)/n}const Pt=new Map;function Xn(t){return(String(t).split(".")[1]??"").length}const Nn=/\.\d*?(?=9{6,}|0{6,})/gm;function Mt(t){if(un(t)||Pt.has(t))return t;const e=`${t}`,n=e.match(Nn);if(n==null)return t;const o=n[0].length-1;if(e.indexOf("e-")!==-1){const s=e.split("e"),l=s[0]??"0",r=s[1]??"0";return+`${Mt(+l)}e${r}`}return ct(t,o)}function Yn(t,e,n=!0){return n?Mt(ct(Mt(t/e))*e):ct(t/e)*e}function de(t,e,n=!0){return n?Mt(Rt(Mt(t/e))*e):Rt(t/e)*e}function pn(t,e,n=!0){return n?Mt(at(Mt(t/e))*e):at(t/e)*e}function On(t){return t===0?e=>e:t===1?G:e=>Yn(e,t)}function mn(t,e,n,o){const s=[],l=o.map(Xn);for(let r=e;r<n;r++){const i=rt(r);for(let a=0;a<o.length;a++){const d=o[a]??0,c=l[a]??0,h=+`${d}e${r}`,u=(r>=0?0:i)+(r>=c?0:c),f=h;s.push(f),Pt.set(f,u)}}return s}function tt(t,e,n){return ae(It(t,e),n)}const jn=new Intl.NumberFormat,wn=t=>jn.format(t);function De(t,e,n){for(;e<=n;){if(t[e]!=null)return!0;e++}return!1}const Un=.1,ht={mode:3,pad:Un,soft:null},Dt={pad:0,soft:null,mode:0},Kn={min:Dt,max:Dt};function Jt(t,e,n,o){let s;typeof n=="number"?(Dt.pad=n,Dt.soft=null,Dt.mode=0,s=Kn):s=n;const l=s.min,r=s.max,i=l.pad,a=r.pad,d=l.hard??-Q,c=r.hard??Q,h=l.soft??Q,u=r.soft??-Q,f=l.mode,g=r.mode;let w=e-t;const v=lt(w),b=It(rt(t),rt(e)),y=lt(b),p=rt(y-v);(w<1e-24||p>10)&&(w=0,(t===0||e===0)&&(w=1e-24));const m=w||b||1e3,T=lt(m),M=yt(10,at(T)),C=m*(w===0?t===0?.1:1:i),I=ct(pn(t-C,M/10),24),A=f===1||f===3&&I<=h||f===2&&I>=h,x=t>=h&&A?h:Q,D=It(d,I<x&&t>=x?x:ae(x,I)),L=m*(w===0?e===0?.1:1:a),F=ct(de(e+L,M/10),24),R=g===1||g===3&&F>=u||g===2&&F<=u,z=e<=u&&R?u:-Q,S=ae(c,F>z&&e<=z?z:It(z,F));return D===S&&D===0?[-1,1]:[D,S]}function Sn(t,e,n,o){n===2&&(o=!0);const s=_e(t),l=_e(e);t===e&&(s===-1?(t*=n,e/=n):(t/=n,e*=n));const r=n===10?lt:Et,i=s===1?at:Rt,a=l===1?Rt:at,d=r(rt(t)),c=r(rt(e)),h=i(d),u=a(c);let f=yt(n,h),g=yt(n,u);return n===10&&(h<0&&(f=ct(f,-h)),u<0&&(g=ct(g,-u))),o?(t=f*s,e=g*l):(t=pn(t,yt(n,at(d)),!1),e=de(e,yt(n,at(c)),!1)),[t,e]}function qn(t,e,n,o){const s=Sn(t,e,n,o);return t===0&&(s[0]=0),e===0&&(s[1]=0),s}function Fe(t){return(lt((t^t>>31)-(t>>31))|0)+1}function Zn(t,e,n,o,s){const l=It(Fe(t),Fe(e)),r=e-t;let i=It(0,wt(s/o*r,n)-1);do{const a=n[i]??0,d=o*a/r;if(d>=s*.9&&l+(a<5?Pt.get(a)??0:0)<=17)return[a,d]}while(++i<n.length);return[0,0]}function Jn(t){return{id:t.id,min:t.min??null,max:t.max??null,distr:t.distr??q.Linear,log:t.log??10,asinh:t.asinh??1,ori:t.ori??(t.id==="x"?$.Horizontal:$.Vertical),dir:t.dir??K.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 U(t){return t.min!=null&&t.max!=null}function ut(t){t._min=null,t._max=null}function vn(t){if(t._min!=null)return t._min;const{min:e,distr:n}=t;if(e==null)return 0;if(n===q.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?lt:Et)(o)}else n===q.Asinh?t._min=fe(e,t.asinh):t._min=e;return t._min}function bn(t){if(t._max!=null)return t._max;const{max:e,distr:n}=t;if(e==null)return 0;if(n===q.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?lt:Et)(o)}else n===q.Asinh?t._max=fe(e,t.asinh):t._max=e;return t._max}function Qn(t,e){if(e.min==null||e.max==null)return 0;const n=vn(e),s=bn(e)-n;if(s===0)return 0;const{distr:l}=e;if(l===q.Log){const r=e.log===10?lt:Et,i=t>0?t:1e-10;return(r(i)-n)/s}return l===q.Asinh?(fe(t,e.asinh)-n)/s:(t-n)/s}function to(t,e){if(e.min==null||e.max==null)return 0;const n=vn(e),o=bn(e);if(o===n)return e.min;const{distr:s}=e;return s===q.Log?Math.pow(e.log,n+t*(o-n)):s===q.Asinh?Gn(n+t*(o-n),e.asinh):n+t*(o-n)}function X(t,e,n,o){const s=Qn(t,e);let l;return e.ori===$.Horizontal?l=e.dir===K.Forward?s:1-s:l=e.dir===K.Forward?1-s:s,o+l*n}function ft(t,e,n,o){if(n===0)return e.min??0;let s=(t-o)/n;return e.ori===$.Horizontal?e.dir===K.Backward&&(s=1-s):e.dir!==K.Backward&&(s=1-s),to(s,e)}class eo{constructor(){Y(this,"scales",new Map);Y(this,"groupXScales",new Map)}addScale(e){this.scales.set(e.id,Jn(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,ut(s))}autoRangeX(e){var o,s,l,r,i,a;const n=new Map;for(const[d,c]of this.groupXScales){const h=this.scales.get(c);if(!h||!h.auto)continue;const u=e[d];if(!u||u.x.length===0)continue;const f=u.x[0],g=u.x[u.x.length-1];if(f==null||g==null)continue;const w=n.get(c);w?(w.dataMin=Math.min(w.dataMin,f),w.dataMax=Math.max(w.dataMax,g),w.groups.push(d)):n.set(c,{dataMin:f,dataMax:g,groups:[d]})}for(const[d,{dataMin:c,dataMax:h,groups:u}]of n){const f=this.scales.get(d);if(!f)continue;let g=!0,w=Q;for(const v of u){const b=e[v];if(b){for(let y=0;y<b.x.length;y++)if(Number.isInteger(b.x[y])||(g=!1),y>0){const p=b.x[y]-b.x[y-1];p>0&&p<w&&(w=p)}}}if(f._discrete=g,f.range){const[v,b]=Jt(c,h,{min:{pad:((o=f.range.min)==null?void 0:o.pad)??0,soft:((s=f.range.min)==null?void 0:s.soft)??null,mode:((l=f.range.min)==null?void 0:l.mode)??0},max:{pad:((r=f.range.max)==null?void 0:r.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=v,f.max=b}else if(c===h)[f.min,f.max]=Jt(c,h,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}});else if(w<Q){const v=w/2;f.min=c-v,f.max=h+v}else f.min=c,f.max=h;f._cfgMin!=null&&(f.min=f._cfgMin),f._cfgMax!=null&&(f.max=f._cfgMax),ut(f)}}autoRange(e,n,o){var r,i,a,d,c,h;const s=new Map,l=new Map;for(const{group:u,index:f,yScale:g}of n){const w=e[u];if(!w)continue;const v=w.series[f];if(!v||v.length===0)continue;const b=o.windows.get(u),y=b?b[0]:0,p=b?b[1]:v.length-1,m=this.scales.get(g),T=(m==null?void 0:m.distr)===q.Log,[M,C]=o.getCachedMinMax(u,f,y,p,0,T),I=s.get(g),A=l.get(g);s.set(g,I!=null?Math.min(I,M):M),l.set(g,A!=null?Math.max(A,C):C)}for(const[u,f]of s){const g=this.scales.get(u);if(!g||!g.auto)continue;const w=l.get(u)??-Q;if(f===Q)continue;let v,b;if(g.distr===q.Log)[v,b]=Sn(f,w,g.log,!1);else if(g.distr===q.Asinh)[v,b]=qn(f,w,g.log,!1);else{const y=g.range??{min:ht,max:ht};[v,b]=Jt(f,w,{min:{pad:((r=y.min)==null?void 0:r.pad)??ht.pad,soft:((i=y.min)==null?void 0:i.soft)??ht.soft,mode:((a=y.min)==null?void 0:a.mode)??ht.mode},max:{pad:((d=y.max)==null?void 0:d.pad)??ht.pad,soft:((c=y.max)==null?void 0:c.soft)??ht.soft,mode:((h=y.max)==null?void 0:h.mode)??ht.mode}})}g._cfgMin!=null&&(v=g._cfgMin),g._cfgMax!=null&&(b=g._cfgMax),g.min=v,g.max=b,ut(g)}}}const no=1024;class oo{constructor(e,n=no){Y(this,"blocks");Y(this,"nBlocks");Y(this,"blockSize");Y(this,"data");Y(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:l}=this;for(let r=0;r<o;r++){const i=r*n,a=Math.min(i+n,l);let d=1/0,c=-1/0;for(let h=i;h<a;h++){const u=e[h];u!=null&&(u<d&&(d=u),u>c&&(c=u))}s[r*2]=d,s[r*2+1]=c}}rangeMinMax(e,n){const{data:o,blockSize:s,blocks:l}=this;let r=1/0,i=-1/0;const a=Math.floor(e/s),d=Math.floor(n/s);if(a===d){for(let u=e;u<=n;u++){const f=o[u];f!=null&&(f<r&&(r=f),f>i&&(i=f))}return[r,i]}const c=(a+1)*s-1;for(let u=e;u<=c;u++){const f=o[u];f!=null&&(f<r&&(r=f),f>i&&(i=f))}for(let u=a+1;u<d;u++){const f=l[u*2]??1/0,g=l[u*2+1]??-1/0;f<r&&(r=f),g>i&&(i=g)}const h=d*s;for(let u=h;u<=n;u++){const f=o[u];f!=null&&(f<r&&(r=f),f>i&&(i=f))}return[r,i]}updateBlock(e){const{data:n,blockSize:o,blocks:s,len:l}=this;if(e>=this.nBlocks)return;const r=e*o,i=Math.min(r+o,l);let a=1/0,d=-1/0;for(let c=r;c<i;c++){const h=n[c];h!=null&&(h<a&&(a=h),h>d&&(d=h))}s[e*2]=a,s[e*2+1]=d}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 so{constructor(){Y(this,"data",[]);Y(this,"windows",new Map);Y(this,"minMaxCache",new Map);Y(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 l=this.data[e];if(!l)return;const r=l.series[n];if(!(!r||r.length===0))return s=new oo(r),this.blockTrees.set(o,s),s}updateWindows(e){var o;let n=!1;for(let s=0;s<this.data.length;s++){const l=this.data[s],r=e(s),i=this.windows.get(s);let a,d;if(!l||!r||!U(r))a=0,d=Math.max(0,((l==null?void 0:l.x.length)??1)-1);else{const c=l.x;if(c.length===0)a=0,d=0;else{a=wt(r.min,c),d=wt(r.max,c);const h=c[a],u=c[d];a>0&&h!=null&&h>r.min&&a--,d<c.length-1&&u!=null&&u<r.max&&d++}}(!i||i[0]!==a||i[1]!==d)&&(n=!0,(o=this.minMaxCache.get(s))==null||o.clear()),this.windows.set(s,[a,d])}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,l,r){let i=this.minMaxCache.get(e);const a=`${n}:${o}:${s}`;if(i){const f=i.get(a);if(f!=null)return f}else i=new Map,this.minMaxCache.set(e,i);const d=this.data[e];if(!d)return[1/0,-1/0];const c=d.series[n];if(!c||c.length===0)return[1/0,-1/0];let h;const u=!r&&l===Lt.Unsorted?this.getOrBuildTree(e,n):void 0;return u?h=u.rangeMinMax(o,s):h=Vn(c,o,s,l,r),i.set(a,h),h}getBlockTree(e,n){return this.getOrBuildTree(e,n)}appendData(e,n,o){var r;const s=this.data[e];if(!s)return;let l;Array.isArray(s.x)?l=s.x:(l=Array.from(s.x),s.x=l);for(let i=0;i<n.length;i++){const a=n[i];a!=null&&l.push(a)}for(let i=0;i<s.series.length;i++){let a=s.series[i];if(!a)continue;Array.isArray(a)||(a=Array.from(a),s.series[i]=a);const d=o[i];if(d){const h=a;for(let u=0;u<d.length;u++)h.push(d[u]??null)}const c=this.blockTrees.get(`${e}:${i}`);c&&(c.setData(a),c.grow(a.length))}(r=this.minMaxCache.get(e))==null||r.clear()}static toTypedX(e){for(const n of e)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return e}}const zt=-10;class ro{constructor(){Y(this,"state",{left:zt,top:zt,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1});Y(this,"_groupedConfigs",new Map);Y(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=zt,this.state.top=zt,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(e,n,o,s,l,r,i,a){this.state.left=e,this.state.top=n;let d=1/0,c=-1,h=-1,u=-1;const f=this.getGroupedConfigs(l);for(let g=0;g<s.length;g++){const w=s[g];if(w==null)continue;const v=w.x;if(v.length===0)continue;const b=a(g);if(b==null)continue;const y=r(b);if(y==null||!U(y))continue;const[p,m]=i(g),T=o.width,M=o.left,C=ft(e+M,y,T,M),I=wt(C,v,p,m),A=[I];I>p&&A.push(I-1),I<m&&A.push(I+1);const x=new Map;for(const D of A){const L=v[D];if(L==null)continue;const F=X(L,y,T,M);for(const R of f.get(g)??[]){const z=w.series[R.index];if(z==null)continue;const S=z[D];if(S==null)continue;let k=x.get(R.yScale);if(k==null&&!x.has(R.yScale)&&(k=r(R.yScale),x.set(R.yScale,k)),k==null||!U(k))continue;const P=o.height,E=o.top,W=X(S,k,P,E),H=e+M-F,V=n+E-W,N=H*H+V*V;if(N<d&&(d=N,c=g,h=R.index,u=D,N===0))break}if(d===0)break}}this.state.activeGroup=c,this.state.activeSeriesIdx=h,this.state.activeDataIdx=u}syncToValue(e,n,o=0){const s=n.dataStore.data;if(s.length===0)return;const l=o<s.length?o:0,r=s[l];if(r==null)return;const i=n.scaleManager.getGroupXScaleKey(l);if(i==null)return;const a=n.scaleManager.getScale(i);if(a==null||!U(a))return;const[d,c]=n.dataStore.getWindow(l),h=wt(e,r.x,d,c),u=r.x[h];if(u==null)return;const f=X(u,a,n.plotBox.width,n.plotBox.left);this.state.left=f-n.plotBox.left,this.state.activeGroup=l,this.state.activeDataIdx=h;let g=0,w=n.plotBox.height/2;for(const v of n.seriesConfigs){if(v.group!==l||v.show===!1)continue;const b=r.series[v.index];if(b==null)continue;const y=b[h];if(y==null)continue;const p=n.scaleManager.getScale(v.yScale);if(!(p==null||!U(p))){w=X(y,p,n.plotBox.height,n.plotBox.top)-n.plotBox.top,g=v.index;break}}this.state.top=w,this.state.activeSeriesIdx=g}}class lo{constructor(){Y(this,"flags",st.None);Y(this,"frameId",null);Y(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=st.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=st.None}}const Yt={width:1},io={width:0,fill:"auto",fillTo:0,points:{show:!1},cursor:{show:!1}},ao={width:0,cursor:{show:!1}};function Ot(t,e,n){t.lineTo(e,n)}function jt(t,e,n){t.lineTo(n,e)}function he(t,e,n,o,s,l){const r=[];let i=-1;const a=s===K.Forward?n:o,d=s===K.Forward?o:n,c=s;for(let h=a;s===K.Forward?h<=d:h>=d;h+=c)if(e[h]===null||e[h]===void 0){if(i===-1){const u=tt(h-s,n,o);i=l(t[u])}}else i!==-1&&(r.push([i,l(t[h])]),i=-1);return i!==-1&&r.push([i,l(t[o])]),r}function ge(t,e,n,o,s,l){const r=new Path2D;let i=e===$.Horizontal?n:o;const a=e===$.Horizontal?n+s:o+l,d=e===$.Horizontal?o:n,c=e===$.Horizontal?l:s;for(const[h,u]of t)h>i&&(e===$.Horizontal?r.rect(i,d,h-i,c):r.rect(d,i,c,h-i)),i=u;return i<a&&(e===$.Horizontal?r.rect(i,d,a-i,c):r.rect(d,i,c,a-i)),r}function yn(t){return(e,n,o,s,l,r)=>{o!==s&&(l!==o&&r!==o&&t(e,n,o),l!==s&&r!==s&&t(e,n,s),t(e,n,r))}}const co=yn(Ot),uo=yn(jt);function xn(){const t=(e,n,o,s,l,r,i,a,d,c,h,u,f)=>{const g=(f==null?void 0:f.spanGaps)??!1;if([d,c]=(s.distr===q.Log?gn:Nt)(n,d,c),d===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=I=>u(X(I,o,l,i)),b=I=>u(X(I,s,r,a));let y,p;o.ori===$.Horizontal?(y=Ot,p=co):(y=jt,p=uo);const m={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},T=m.stroke;let M=!1;if(c-d>=l*4){const I=k=>ft(k,o,l,i);let A=null,x=0,D=0,L=0,F=v(e[h===K.Forward?d:c]);const R=v(e[d]),z=v(e[c]);let S=I(h===K.Forward?R+1:z-1);for(let k=h===K.Forward?d:c;k>=d&&k<=c;k+=h){const P=e[k],W=(h===K.Forward?P<S:P>S)?F:v(P),H=n[k];W===F?H!=null?(L=H,A==null?(y(T,W,b(L)),D=A=x=L):L<A?A=L:L>x&&(x=L)):H===null&&!g&&(M=!0):(A!=null&&p(T,F,b(A),b(x),b(D),b(L)),H!=null?(L=H,y(T,W,b(L)),A=x=D=L):(A=null,x=0,H===null&&!g&&(M=!0)),F=W,S=I(F+h))}A!=null&&(A!==x?p(T,F,b(A),b(x),b(D),b(L)):y(T,F,b(L)))}else for(let I=h===K.Forward?d:c;I>=d&&I<=c;I+=h){const A=n[I];A===null&&!g?M=!0:A!=null&&y(T,v(e[I]),b(A))}{const I=m.fill=new Path2D(T),A=(f==null?void 0:f.fillTo)??s.min??0,x=b(A);let D=v(e[d]),L=v(e[c]);h===K.Backward&&([L,D]=[D,L]),y(I,L,x),y(I,D,x)}if(M){const I=he(e,n,d,c,h,v);m.gaps=I,m.clip=ge(I,o.ori,i,a,l,r)}return m};return t.defaults=Yt,t}function pe(t,e,n){const o=t.length;if(n=Math.max(2,Math.round(n)),o<=n){const u=new Uint32Array(o),f=new Float64Array(o),g=new Array(o);for(let w=0;w<o;w++)u[w]=w,f[w]=t[w],g[w]=e[w]??null;return{indices:u,x:f,y:g}}const s=[];let l=-1,r=0;for(let u=0;u<o;u++)e[u]!=null?(l===-1&&(l=u),r++):l!==-1&&(s.push([l,u-1]),l=-1);if(l!==-1&&s.push([l,o-1]),r===0)return{indices:new Uint32Array(0),x:new Float64Array(0),y:[]};if(r<=n){const u=new Uint32Array(r),f=new Float64Array(r),g=new Array(r);let w=0;for(let v=0;v<o;v++)e[v]!=null&&(u[w]=v,f[w]=t[v],g[w]=e[v],w++);return{indices:u,x:f,y:g}}const i=[];for(const[u,f]of s){const g=f-u+1,w=Math.max(2,Math.round(n*(g/r))),v=fo(t,e,u,f,w);for(const b of v)i.push(b)}const a=i.length,d=new Uint32Array(a),c=new Float64Array(a),h=new Array(a);for(let u=0;u<a;u++){const f=i[u];d[u]=f,c[u]=t[f],h[u]=e[f]}return{indices:d,x:c,y:h}}function fo(t,e,n,o,s){const l=o-n+1;if(l<=s){const c=[];for(let h=n;h<=o;h++)c.push(h);return c}const r=[];r.push(n);const i=s-2,a=(l-2)/i;let d=n;for(let c=0;c<i;c++){const h=n+1+Math.floor(c*a),u=Math.min(n+1+Math.floor((c+1)*a)-1,o-1);let f=0,g=0,w=0;if(c<i-1){const m=n+1+Math.floor((c+1)*a),T=Math.min(n+1+Math.floor((c+2)*a)-1,o-1);for(let M=m;M<=T;M++)f+=t[M],g+=e[M],w++}else f=t[o],g=e[o],w=1;w>0&&(f/=w,g/=w);const v=t[d],b=e[d];let y=h,p=-1;for(let m=h;m<=u;m++){const T=t[m],M=e[m],C=Math.abs(v*(M-g)+T*(g-b)+f*(b-M));C>p&&(p=C,y=m)}r.push(y),d=y}return r.push(o),r}function ho(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 a of t.series){const d=pe(t.x,a,e);for(let c=0;c<d.indices.length;c++)o.add(d.indices[c])}const s=Array.from(o).sort((a,d)=>a-d),l=s.length,r=new Float64Array(l);for(let a=0;a<l;a++)r[a]=t.x[s[a]];const i=[];for(const a of t.series)if(Array.isArray(a)&&a.some(c=>c===null)){const c=new Array(l);for(let h=0;h<l;h++)c[h]=a[s[h]]??null;i.push(c)}else{const c=new Float64Array(l);for(let h=0;h<l;h++)c[h]=a[s[h]];i.push(c)}return{x:r,series:i}}function go(t){const n=xn(),o=(s,l,r,i,a,d,c,h,u,f,g,w,v)=>{const b=f-u+1,y=Math.round(a*1);if(b>y*2){const p=f-u+1,m=new Float64Array(p),T=new Array(p);for(let C=0;C<p;C++)m[C]=s[u+C],T[C]=l[u+C]??null;const M=pe(m,T,y);return n(M.x,M.y,r,i,a,d,c,h,0,M.x.length-1,g,w,v)}return n(s,l,r,i,a,d,c,h,u,f,g,w,v)};return o.defaults=Yt,o}const Re=new WeakMap;function He(t,e,n){return typeof e=="string"?e:po(t,e,n)}function po(t,e,n){const o=Re.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[l,r]of e.stops)s.addColorStop(l,r);return Re.set(e,{grad:s,left:n.left,top:n.top,width:n.width,height:n.height}),s}function mo(t,e,n,o,s){if(e.show===!1)return;const l=e.alpha??1;t.save(),l<1&&(t.globalAlpha=l),n.clip&&t.clip(n.clip);const r=s??{left:0,top:0,width:t.canvas.width/o,height:t.canvas.height/o};if(e.fill&&n.fill&&(t.fillStyle=He(t,e.fill,r),t.fill(n.fill)),e.stroke){const i=(e.width??1)*o;t.strokeStyle=He(t,e.stroke,r),t.lineWidth=i,t.lineJoin=e.join??"round",t.lineCap=e.cap??"butt",e.dash&&t.setLineDash(e.dash.map(h=>h*o));const a=e.pxAlign??0,d=i%2/2;a===1&&d>0&&t.translate(d,d),t.stroke(n.stroke)}t.restore()}const wo=go(),We=64;class So{constructor(){Y(this,"ctx",null);Y(this,"pxRatio",1);Y(this,"pathCache",new Map);Y(this,"bandCache",new Map);Y(this,"scaleStamp","");Y(this,"snapshotCanvas",null);Y(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 l=this.snapshotCanvas.getContext("2d");l!=null&&typeof l.drawImage=="function"&&(l.clearRect(0,0,n,o),l.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 l of[s.xScale,s.yScale])o.has(l.id)||(o.add(l.id),n+=`${l.id}:${l.min}:${l.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 l=this.cacheKey(e,n,o,s),r=this.pathCache.get(l);if(r!=null)return this.promote(l,r),r;const i=`${e}:${n}:`;for(const[a,d]of this.pathCache){if(!a.startsWith(i))continue;const c=a.slice(i.length),h=c.indexOf(":"),u=+c.slice(0,h),f=+c.slice(h+1);if(u<=o&&f>=s)return this.promote(a,d),d}}setCachedPaths(e,n,o,s,l){if(this.pathCache.size>=We){const i=We>>2,a=this.pathCache.keys();for(let d=0;d<i;d++){const c=a.next().value;c!=null&&this.pathCache.delete(c)}}const r=this.cacheKey(e,n,o,s);this.pathCache.delete(r),this.pathCache.set(r,l)}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,l){return`${e}:${n}:${o}:${s}:${l}`}getCachedBandPath(e,n,o,s,l){return this.bandCache.get(this.bandKey(e,n,o,s,l))}setCachedBandPath(e,n,o,s,l,r){this.bandCache.set(this.bandKey(e,n,o,s,l),r)}drawSeries(e,n,o){const s=this.ctx;if(s==null||e.config.show===!1)return;const l=e.config.group,r=e.config.index,[i,a]=e.window;let d=this.getCachedPaths(l,r,i,a);if(d==null){const c=e.config.paths??wo,h=e.xScale.dir,u=On(e.config.pxAlign??0),f=a-i,g=Math.max(1,Math.ceil(f*.1)),w=e.dataX.length,v=Math.max(0,i-g),b=Math.min(w-1,a+g),y=e.config.fillTo;let p;typeof y=="function"?p=y(e.yScale.min??0,e.yScale.max??0):y===0&&e.yScale.distr===q.Log?p=1:p=y,d=c(e.dataX,e.dataY,e.xScale,e.yScale,n.width,n.height,n.left,n.top,v,b,h,u,{fillTo:p,spanGaps:e.config.spanGaps}),this.setCachedPaths(l,r,v,b,d)}mo(s,e.config,d,o,n)}draw(e,n,o,s){const l=this.ctx;if(l==null)return;const r=this.pxRatio;l.clearRect(0,0,e*r,n*r),l.save(),l.scale(r,r),l.beginPath(),l.rect(o.left,o.top,o.width,o.height),l.clip();for(const i of s)this.drawSeries(i,o,1);l.restore()}}const Mn=[1,2,2.5,5],vo=mn(10,-32,0,Mn),bo=mn(10,0,32,Mn),vt=vo.concat(bo);function yo(t,e,n,o,s){if(n<=0||e<t)return[];const l=[],r=Pt.get(n)??0,i=s?Math.ceil(t/n)*n:ct(de(t,n),r);for(let a=i;a<=e;a=ct(a+n,r))l.push(Object.is(a,-0)?0:a);return l}function Qt(t){return t.map(e=>wn(e))}function xo(t,e,n){if(t<=0||e<=0||t>=e)return[];const o=[],l=at((n===10?lt:Et)(t));let r=yt(n,l);n===10&&(r=vt[wt(r,vt)]??r);let i=r,a=r*n;n===10&&(a=vt[wt(a,vt)]??a);let d=0;do{if(i>=t&&o.push(i),i=i+r,n===10&&!Pt.has(i)){const c=Pt.get(r)??0;i=ct(i,c)}i>=a*(1-1e-10)&&(r=i,a=r*n,n===10&&(a=vt[wt(a,vt)]??a))}while(i<=e&&++d<1e4);return o}function Mo(t,e,n=1){const o=[];if(Math.max(rt(t),rt(e))===0)return[0];if(t<0){const r=rt(t);let i=yt(10,at(lt(Math.max(r,n))));for(;i>=n;){const a=-i;a>=t&&a<=e&&o.push(a),i/=10}}if(t<=0&&e>=0&&o.push(0),e>0){let r=n;const i=e;for(;r<=i;)r>=t&&r<=e&&o.push(r),r*=10}o.sort((r,i)=>r-i);const l=[];for(const r of o){const i=l[l.length-1];(l.length===0||i!=null&&rt(r-i)>1e-10)&&l.push(r)}return l}function Co(t,e){const n=e===10?lt:Et;return t.map(o=>{if(o===0)return!0;if(o<0)return!1;const s=n(o);return rt(s-Math.round(s))<1e-10})}const ko=7,To=50,Ao=16;function Lo(t,e){const o=wn(Math.max(Math.abs(t),Math.abs(e))).length*ko;return Math.max(To,o+Ao)}function Io(t,e,n,o){if(o<=0)return[0,0];const s=Ct(t.side)===$.Vertical,l=t.space??(s?30:Lo(e,n)),r=t.incrs??vt;return Zn(e,n,r,o,l)}const Po=50;function Eo(t,e,n){var i,a;if(t.size!=null)return t.size;const o=((i=t.ticks)==null?void 0:i.show)!==!1?((a=t.ticks)==null?void 0:a.size)??10:0,s=t.gap??5,l=12;if(Ct(t.side)===$.Vertical&&e!=null){let d=0;for(const h of e)h.length>d&&(d=h.length);const c=d*7;return Math.max(50,o+s+c+4)}return Math.max(50,o+s+l+3)}function _o(t){return{config:t,_show:t.show!==!1,_size:t.size??Po,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const Do=1,At=60,bt=3600,mt=86400,Fo=604800,xt=2592e3,Ht=31536e3,Ro=[Do,5,10,15,30,At,5*At,10*At,15*At,30*At,bt,2*bt,3*bt,4*bt,6*bt,12*bt,mt,2*mt,3*mt,7*mt,14*mt,xt,2*xt,3*xt,6*xt,Ht];function Ho(t,e,n){const o=[];if(n<=0||t>=e)return o;let s;if(n>=Ht){const l=new Date(t*1e3);for(l.setUTCMonth(0,1),l.setUTCHours(0,0,0,0),s=l.getTime()/1e3,s<t&&(l.setUTCFullYear(l.getUTCFullYear()+1),s=l.getTime()/1e3);s<=e;)o.push(s),l.setUTCFullYear(l.getUTCFullYear()+Math.round(n/Ht)),s=l.getTime()/1e3;return o}if(n>=xt){const l=new Date(t*1e3);l.setUTCDate(1),l.setUTCHours(0,0,0,0),s=l.getTime()/1e3;const r=Math.max(1,Math.round(n/xt));if(s<t&&(l.setUTCMonth(l.getUTCMonth()+1),s=l.getTime()/1e3),r>1){const i=l.getUTCMonth(),a=Math.ceil((i+1)/r)*r;l.setUTCMonth(a-1),s=l.getTime()/1e3}for(;s<=e;)o.push(s),l.setUTCMonth(l.getUTCMonth()+r),s=l.getTime()/1e3;return o}if(n>=mt){const l=new Date(t*1e3);l.setUTCHours(0,0,0,0),s=l.getTime()/1e3,s<t&&(s+=mt)}else s=Math.ceil(t/n)*n;for(let l=0;;l++){const r=s+l*n;if(r>e)break;o.push(r)}return o}const ze=new Map;function Wo(t,e){const n=JSON.stringify(t)+(e??"");let o=ze.get(n);return o==null&&(o=new Intl.DateTimeFormat(void 0,{...t,timeZone:e}),ze.set(n,o)),o}function it(t,e,n){const o=new Date(t*1e3);return Wo(e,n).format(o)}function zo(t,e){return it(t,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e)}function $o(t,e){return it(t,{year:"numeric",month:"2-digit",day:"2-digit"},e)}function Bo(t,e){return it(t,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e)}function Go(t,e){return it(t,{hour:"2-digit",minute:"2-digit",hour12:!1},e)}function Vo(t,e){return it(t,{month:"short",day:"numeric"},e)}function Xo(t,e){return it(t,{year:"numeric"},e)}function No(t,e){return it(t,{year:"numeric",month:"short"},e)}function Yo(t,e,n){let o;return e>=Ht?o=Xo:e>=xt?o=No:e>=Fo?o=$o:e>=mt?o=Vo:e>=bt?o=Go:e>=At?o=Bo:o=zo,t.map(s=>o(s,n))}function Oo(t,e,n,o,s){const l=e-t;if(l<=0||o<=0)return[0,0];for(const i of n){const a=l/i,d=o/a;if(d>=s)return[i,d]}const r=n[n.length-1]??Ht;return[r,o/(l/r)]}const jo=3;function Uo(t,e,n,o,s){let l=!0;for(const r of t){const i=r.config;if(i.show===!1)continue;const a=e(i.scale);if(!a||!U(a)){r._show&&(l=!1,r._show=!1);continue}else r._show||(l=!1,r._show=!0);const d=i.side,h=Ct(d)===$.Horizontal?n:o,u=a.min,f=a.max;let g,w;if(a.time){const b=i.space??80;[g,w]=Oo(u,f,Ro,h,b)}else[g,w]=Io(i,u,f,h);if(a._discrete&&g>0&&g<1&&(g=1),r._incr=g,r._space=w,w===0)continue;if(i.splits)r._splits=i.splits(u,f,g,w);else if(a.time)r._splits=Ho(u,f,g);else if(a.distr===q.Log)r._splits=xo(u,f,a.log);else if(a.distr===q.Asinh)r._splits=Mo(u,f,a.asinh);else{const b=a.distr===q.Ordinal||a._discrete;r._splits=yo(u,f,g,w,b)}if(i.values)r._values=i.values(r._splits,w,g);else if(a.time)r._values=Yo(r._splits,g);else if(a.distr===q.Log){const b=Co(r._splits,a.log),y=Qt(r._splits);r._values=y.map((p,m)=>b[m]?p:"")}else a.distr,q.Asinh,r._values=Qt(r._splits);r._rotate=d===j.Bottom?i.rotate??0:0;const v=r._size;r._size=Rt(Eo(i,r._values)),v!==r._size&&(l=!1)}return l}function $e(t,e,n,o=0){let s=t,l=e-o,r=0,i=o;for(const d of n){if(!d._show)continue;const c=d.config.side,h=Ct(c)===$.Vertical,u=d.config.label!=null?d.config.labelSize??20:0,f=d._size+u;f>0&&(h?(s-=f,c===j.Left&&(r+=f)):(l-=f,c===j.Top&&(i+=f)))}return!n.some(d=>d._show&&d.config.side===j.Top)&&i<=o&&(i+=8,l-=8),{left:r,top:i,width:Math.max(s,0),height:Math.max(l,0)}}function Ko(t,e){let n=e.top,o=e.left+e.width,s=e.top+e.height,l=e.left;function r(i,a){switch(i){case j.Top:return n-=a,n+a;case j.Right:{const d=o;return o+=a,d}case j.Bottom:{const d=s;return s+=a,d}case j.Left:return l-=a,l+a;default:return 0}}for(const i of t){if(!i._show)continue;const a=i.config.side;if(i._pos=r(a,i._size),i.config.label!=null){const d=i.config.labelSize??20;i._lpos=r(a,d)}}}function qo(t,e,n,o,s=0){for(const a of n)a._size=0;let l=!1,r=0,i={left:0,top:0,width:t,height:e};for(;!l;){r++;const a=Uo(n,o,i.width,i.height);l=r===jo||a,l||(i=$e(t,e,n,s))}return i=$e(t,e,n,s),Ko(n,i),i}const Be="top",Ge="bottom",Zo="left",Jo="right";function te(t,e){return e===1?t:t.replace(/(\d+(?:\.\d+)?)px/,(n,o)=>`${Math.round(Number(o)*e)}px`)}function Ve(t,e,n,o,s,l,r,i,a,d,c){const h=i%2/2;t.save(),t.translate(h,h),t.strokeStyle=a,t.lineWidth=i,d.length>0&&t.setLineDash(d),t.beginPath();let u=0,f=0,g=0,w=0;const v=l+(s===j.Top||s===j.Left?-r:r);o===$.Horizontal?(f=l,w=v):(u=l,g=v);for(let b=0;b<e.length;b++)n[b]!=null&&(o===$.Horizontal?u=g=e[b]??0:f=w=e[b]??0,t.moveTo(u,f),t.lineTo(g,w));t.stroke(),t.restore()}function Qo(t,e,n,o,s,l,r){const i=r??{axisStroke:"#000",gridStroke:"rgba(0,0,0,0.12)",titleFill:"#000"},a=G(o.left*s),d=G(o.top*s),c=G(o.width*s),h=G(o.height*s);for(const u of e){if(!u._show)continue;const f=u.config,g=f.side,w=Ct(g),v=n(f.scale);if(!v||!U(v))continue;const b=f.stroke??i.axisStroke,y=g===j.Top||g===j.Left?-1:1,p=u._splits,m=u._values;if(!p||!m||u._space===0)continue;const T=w===$.Horizontal?o.width:o.height,M=w===$.Horizontal?o.left:o.top,C=p.map(L=>G(X(L,v,T,M)*s)),I=m.map(L=>L===""?null:L),A=f.grid;if((A==null?void 0:A.show)!==!1){const L=(A==null?void 0:A.stroke)??i.gridStroke,F=G(((A==null?void 0:A.width)??2)*s),R=((A==null?void 0:A.dash)??[]).map(k=>k*s),z=w===$.Horizontal?d:a,S=w===$.Horizontal?h:c;Ve(t,C,I,w,2,z,S,F,L,R)}const x=f.ticks;if((x==null?void 0:x.show)!==!1){const L=(x==null?void 0:x.stroke)??b,F=G(((x==null?void 0:x.width)??1)*s),R=G(((x==null?void 0:x.size)??10)*s),z=((x==null?void 0:x.dash)??[]).map(k=>k*s),S=G(u._pos*s);Ve(t,C,I,w,g,S,R,F,L,z)}{const L=(x==null?void 0:x.show)!==!1?((x==null?void 0:x.size)??10)*s:0,F=G((f.gap??5)*s),R=G(u._pos*s),z=(L+F)*y,S=R+z,k=te(f.font??"12px system-ui, sans-serif",s),P=w===$.Horizontal?"center":g===j.Left?Jo:Zo,E=w===$.Horizontal?g===j.Bottom?Be:Ge:"middle";t.font=k,t.fillStyle=b,t.textAlign=P,t.textBaseline=E;const W=u._rotate*-qt/180;if(W!==0){const H=Math.cos(W),V=Math.sin(W);for(let N=0;N<m.length;N++){const O=m[N];if(O==null||O==="")continue;const Z=C[N]??0;t.setTransform(H,V,-V,H,Z,S),t.fillText(O,0,0)}t.setTransform(1,0,0,1,0,0)}else for(let H=0;H<m.length;H++){const V=m[H];if(V==null||V==="")continue;const N=C[H]??0,O=w===$.Horizontal?N:S,Z=w===$.Horizontal?S:N;t.fillText(V,O,Z)}}if(f.label!=null){const L=te(f.labelFont??"bold 12px system-ui, sans-serif",s);t.font=L,t.fillStyle=b,t.textAlign="center",t.textBaseline=g===j.Bottom?Be:Ge;const F=G((u._lpos+(f.labelGap??0)*y)*s);w===$.Vertical?(t.save(),t.translate(F,G(d+h/2)),t.rotate((g===j.Left?-qt:qt)/2),t.fillText(f.label,0,0),t.restore()):t.fillText(f.label,G(a+c/2),F)}const D=f.border;if((D==null?void 0:D.show)!==!1&&D!=null){const L=D.stroke??b,F=G((D.width??1)*s),R=(D.dash??[]).map(S=>S*s),z=G(u._pos*s);t.strokeStyle=L,t.lineWidth=F,R.length>0&&t.setLineDash(R),t.beginPath(),w===$.Horizontal?(t.moveTo(a,z),t.lineTo(a+c,z)):(t.moveTo(z,d),t.lineTo(z,d+h)),t.stroke(),R.length>0&&t.setLineDash([])}}if(l!=null){const u=te("bold 14px system-ui, sans-serif",s);t.font=u,t.fillStyle=i.titleFill,t.textAlign="center",t.textBaseline="top",t.fillText(l,G(a+c/2),G(4*s))}}const ts=2,es="#fff",Xe={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function Ne(t,e,n,o,s,l,r,i,a,d,c){var M;if(e.left<0||e.top<0)return;const h={stroke:(c==null?void 0:c.cursorStroke)??Xe.stroke},u={...Xe,...h,...a},f=o,g=G(n.left*f),w=G(n.top*f),v=G(n.width*f),b=G(n.height*f),y=G(u.width*f),p=y%2/2,m=G((n.left+e.left)*f)+p,T=G((n.top+e.top)*f)+p;if(t.save(),t.strokeStyle=u.stroke,t.lineWidth=y,t.setLineDash(u.dash.map(C=>C*f)),u.showX&&(t.beginPath(),t.moveTo(m,w),t.lineTo(m,w+b),t.stroke()),u.showY&&(t.beginPath(),t.moveTo(g,T),t.lineTo(g+v,T),t.stroke()),t.setLineDash([]),e.activeGroup>=0&&e.activeDataIdx>=0){const C=e.activeGroup,I=e.activeSeriesIdx,A=e.activeDataIdx,x=s[C];if(x!=null&&I>=0&&I<x.series.length&&A<x.x.length){const D=x.x[A],L=x.series[I],F=L!=null?L[A]:null;if(D!=null&&F!=null){let R=u.stroke,z=!0;const S=d==null?void 0:d.get(`${C}:${I}`);if(S!=null){const k=S.stroke;R=(typeof k=="string"?k:void 0)??u.stroke,z=((M=S.cursor)==null?void 0:M.show)!==!1}if(z){const k=i(C),P=k!=null?r(k):void 0,E=(S==null?void 0:S.yScale)??ns(l,C,I),W=E!=null?r(E):void 0;if(P!=null&&W!=null&&U(P)&&U(W)){const H=G(X(D,P,n.width,n.left)*f),V=G(X(F,W,n.height,n.top)*f),N=u.pointRadius*f,O=G(ts*f);t.beginPath(),t.arc(H,V,N,0,Math.PI*2),t.fillStyle=(c==null?void 0:c.pointFill)??es,t.fill(),t.strokeStyle=R,t.lineWidth=O,t.stroke()}}}}}t.restore()}function ns(t,e,n){for(const o of t)if(o.group===e&&o.index===n)return o.yScale}const ee={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function Ye(t,e,n,o,s,l){if(!e.show||e.width<=0)return;const r={fill:(l==null?void 0:l.selectFill)??ee.fill,stroke:(l==null?void 0:l.selectStroke)??ee.stroke},i={...ee,...r,...s},a=o,d=G((n.left+e.left)*a),c=G((n.top+e.top)*a),h=G(e.width*a),u=G(e.height*a);t.save(),t.fillStyle=i.fill,t.fillRect(d,c,h,u),i.width>0&&(t.strokeStyle=i.stroke,t.lineWidth=G(i.width*a),t.strokeRect(d,c,h,u)),t.restore()}const gt={axisStroke:"#000",gridStroke:"rgba(0,0,0,0.12)",titleFill:"#000",cursorStroke:"#607D8B",pointFill:"#fff",selectFill:"rgba(0,0,0,0.07)",selectStroke:"rgba(0,0,0,0.15)"};function Oe(t){if(t==null)return gt;const e=getComputedStyle(t),n=(o,s)=>e.getPropertyValue(o).trim()||s;return{axisStroke:n("--uplot-axis-stroke",gt.axisStroke),gridStroke:n("--uplot-grid-stroke",gt.gridStroke),titleFill:n("--uplot-title-fill",gt.titleFill),cursorStroke:n("--uplot-cursor-stroke",gt.cursorStroke),pointFill:n("--uplot-point-fill",gt.pointFill),selectFill:n("--uplot-select-fill",gt.selectFill),selectStroke:n("--uplot-select-stroke",gt.selectStroke)}}function os(t,e,n,o,s,l,r,i,a,d,c,h){const u=c/2*r,f=Math.max(1,G(c*.2))*r,g=(d==null?void 0:d.stroke)??h,w=(d==null?void 0:d.fill)??"#fff";t.save(),t.strokeStyle=g,t.fillStyle=w,t.lineWidth=f,(d==null?void 0:d.dash)!=null&&t.setLineDash(d.dash.map(v=>v*r));for(let v=i;v<=a;v++){const b=n[v];if(b==null)continue;const y=e[v];if(y==null)continue;const p=G(X(y,o,l.width,l.left)*r),m=G(X(b,s,l.height,l.top)*r);t.beginPath(),t.arc(p,m,u,0,Math.PI*2),t.fill(),t.stroke()}t.restore()}function ss(t,e,n,o,s,l,r){if(typeof t=="function")return t(e,n,o,s,l);if(t===!0)return!0;if(t===!1)return!1;const i=s-o;return i>0&&i<=l/r}function rs(t,e,n,o,s,l,r,i,a){if(i>a||i<0||!De(e,i,a)&&!De(n,i,a))return null;const d=f=>X(f,o,l.width,l.left)*r,c=f=>X(f,s,l.height,l.top)*r,h=new Path2D;let u=!1;for(let f=i;f<=a;f++){const g=e[f],w=t[f];if(g==null||w==null)continue;const v=d(w),b=c(g);u?h.lineTo(v,b):(h.moveTo(v,b),u=!0)}if(!u)return null;for(let f=a;f>=i;f--){const g=n[f],w=t[f];g==null||w==null||h.lineTo(d(w),c(g))}return h.closePath(),h}function ls(t,e,n){t.save(),t.fillStyle=e.fill??"rgba(0, 120, 255, 0.1)",t.fill(n),t.restore()}function is(t){const e=t.dataStore.data;if(e.length===0)return;if(!t.scaleManager.getScale("x")){const r={id:"x",auto:!0};t.scaleConfigs.push(r),t.scaleManager.addScale(r)}for(let r=0;r<e.length;r++)t.scaleManager.getGroupXScaleKey(r)||t.scaleManager.setGroupXScale(r,"x");const n=new Set(t.scaleConfigs.map(r=>r.id)),o=new Set;for(const r of t.seriesConfigs)o.add(r.yScale);o.size===0&&!n.has("y")&&o.add("y");for(const r of o)if(!n.has(r)){const i={id:r,auto:!0};t.scaleConfigs.push(i),t.scaleManager.addScale(i),n.add(r)}if(!t.axisConfigs.some(r=>r.scale==="x"))t.axisConfigs.push({scale:"x",side:j.Bottom,show:!0,label:t.xlabel??"X Axis",_default:!0});else{const r=t.axisConfigs.find(i=>i.scale==="x"&&i._default===!0);r!=null&&(r.label=t.xlabel??"X Axis")}const l=new Set(t.axisConfigs.map(r=>r.scale));for(const r of o)if(!l.has(r))t.axisConfigs.push({scale:r,side:j.Left,show:!0,label:t.ylabel??"Y Axis",_default:!0}),l.add(r);else{const i=t.axisConfigs.find(a=>a.scale===r&&a._default===!0);i!=null&&(i.label=t.ylabel??"Y Axis")}}function $t(t,e,n,o){return{ctx:t,plotBox:e,pxRatio:n,getScale:o,valToX:(r,i="x")=>{const a=o(i);return a==null||!U(a)?null:X(r,a,e.width,e.left)},valToY:(r,i)=>{const a=o(i);return a==null||!U(a)?null:X(r,a,e.height,e.top)}}}const as={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1,plotLeft:0,plotTop:0,plotWidth:0,plotHeight:0,seriesCount:0,revision:-1};function je(t){const{left:e,top:n,activeGroup:o,activeSeriesIdx:s,activeDataIdx:l}=t.cursorManager.state,{left:r,top:i,width:a,height:d}=t.plotBox,c=t.seriesConfigs.length,{revision:h}=t,u=t.snapshot;u.left===e&&u.top===n&&u.activeGroup===o&&u.activeSeriesIdx===s&&u.activeDataIdx===l&&u.plotLeft===r&&u.plotTop===i&&u.plotWidth===a&&u.plotHeight===d&&u.seriesCount===c&&u.revision===h||(t.snapshot={left:e,top:n,activeGroup:o,activeSeriesIdx:s,activeDataIdx:l,plotLeft:r,plotTop:i,plotWidth:a,plotHeight:d,seriesCount:c,revision:h})}function ne(t){t.seriesConfigMap.clear();for(const e of t.seriesConfigs)t.seriesConfigMap.set(`${e.group}:${e.index}`,e)}function cs(){const t={scaleManager:new eo,dataStore:new so,renderer:new So,cursorManager:new ro,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 lo,drawHooks:new Set,unclippedDrawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:1,actionMap:new Map(Xt),title:void 0,xlabel:void 0,ylabel:void 0,snapshot:as,revision:0,eventCallbacks:{},themeCache:Oe(null),_prevScaleRanges:new Map,_prevPlotBox:null,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),ne(t),t.renderer.clearGroupCache(e.group)},unregisterSeries(e,n){t.seriesConfigs=t.seriesConfigs.filter(o=>!(o.group===e&&o.index===n)),ne(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,o){const s=o??t.pxRatio;t.width===e&&t.height===n&&t.pxRatio===s||(t.pxRatio=s,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(st.Full)},scheduleCursorRedraw(){t.scheduler.mark(st.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:l,height:r,pxRatio:i,canvas:a,scheduler:d}=t;if(a==null||l===0||r===0)return;const c=a.getContext("2d");if(c==null)return;o.setContext(c,i);const u=(d.dirty&~(st.Cursor|st.Select))===0,f=p=>e.getScale(p);if(u&&o.restoreSnapshot(c)){if(Ne(c,t.cursorManager.state,t.plotBox,i,n.data,s,f,p=>e.getGroupXScaleKey(p),void 0,t.seriesConfigMap,t.themeCache),Ye(c,t.selectState,t.plotBox,i,void 0,t.themeCache),t.cursorDrawHooks.size>0){c.save(),c.scale(i,i);const p=$t(c,t.plotBox,i,f);for(const m of t.cursorDrawHooks)try{m(p,t.cursorManager.state)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}je(t);for(const p of t.cursorListeners)p();return}t.themeCache=Oe(a),is(t),e.autoRangeX(n.data),n.updateWindows(p=>{const m=e.getGroupXScaleKey(p);return m!=null?e.getScale(m):void 0});const g=s.map(p=>({group:p.group,index:p.index,yScale:p.yScale}));if(e.autoRange(n.data,g,n),us(t),t.axisStates.length>0){const p=t.title!=null?20:0;t.plotBox=qo(l,r,t.axisStates,f,p)}else t.plotBox={left:10,top:10,width:l-20,height:r-20};const w=t._prevPlotBox,v=t.plotBox;w!=null&&(w.left!==v.left||w.top!==v.top||w.width!==v.width||w.height!==v.height)&&o.clearCache(),t._prevPlotBox={...v},c.clearRect(0,0,l*i,r*i),t.axisStates.length>0&&Qo(c,t.axisStates,f,t.plotBox,i,t.title,t.themeCache);const b=[];for(const p of s){const m=e.getGroupXScaleKey(p.group),T=m!=null?e.getScale(m):void 0,M=e.getScale(p.yScale);T==null||M==null||b.push({config:p,dataX:n.getXValues(p.group),dataY:n.getYValues(p.group,p.index),xScale:T,yScale:M,window:n.getWindow(p.group)})}o.checkScaleStamp(b),c.save(),c.scale(i,i),c.beginPath(),c.rect(t.plotBox.left,t.plotBox.top,t.plotBox.width,t.plotBox.height),c.clip();for(let p=0;p<b.length;p++){const m=b[p];m!=null&&(t.focusedSeries!=null&&p!==t.focusedSeries?(c.globalAlpha=t.focusAlpha,o.drawSeries(m,t.plotBox,1),c.globalAlpha=1):o.drawSeries(m,t.plotBox,1))}const y=new Map;for(const p of s)y.set(`${p.group}-${p.index}`,p);for(const p of t.bandConfigs){const m=e.getGroupXScaleKey(p.group),T=m!=null?e.getScale(m):void 0,M=y.get(`${p.group}-${p.series[0]}`),C=y.get(`${p.group}-${p.series[1]}`);if(T==null||M==null||C==null)continue;const I=e.getScale(M.yScale);if(I==null)continue;const[A,x]=n.getWindow(p.group),D=p.series[0],L=p.series[1];let F=o.getCachedBandPath(p.group,D,L,A,x);F==null&&(F=rs(n.getXValues(p.group),n.getYValues(p.group,D),n.getYValues(p.group,L),T,I,t.plotBox,i,A,x)??void 0,F!=null&&o.setCachedBandPath(p.group,D,L,A,x,F)),F!=null&&ls(c,p,F)}for(const p of b){const m=p.config;if(m.show===!1)continue;const T=m.points,M=m.width??1,C=(T==null?void 0:T.size)??3+M*2,I=(T==null?void 0:T.space)??C*2,[A,x]=p.window;ss(T==null?void 0:T.show,m.group,m.index,A,x,t.plotBox.width,I)&&os(c,p.dataX,p.dataY,p.xScale,p.yScale,t.plotBox,i,A,x,T,C,(typeof m.stroke=="string"?m.stroke:null)??"#000")}if(c.restore(),t.drawHooks.size>0){c.save(),c.beginPath(),c.rect(t.plotBox.left*i,t.plotBox.top*i,t.plotBox.width*i,t.plotBox.height*i),c.clip(),c.scale(i,i);const p=$t(c,t.plotBox,i,f);for(const m of t.drawHooks)try{m(p)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}if(t.unclippedDrawHooks.size>0){c.save(),c.scale(i,i);const p=$t(c,t.plotBox,i,f);for(const m of t.unclippedDrawHooks)try{m(p)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}if(t.cursorManager.state.left>=0&&(o.saveSnapshot(c,l*i,r*i),t.cursorManager.update(t.cursorManager.state.left,t.cursorManager.state.top,t.plotBox,n.data,s,f,p=>n.getWindow(p),p=>e.getGroupXScaleKey(p))),Ne(c,t.cursorManager.state,t.plotBox,i,n.data,s,f,p=>e.getGroupXScaleKey(p),void 0,t.seriesConfigMap,t.themeCache),Ye(c,t.selectState,t.plotBox,i,void 0,t.themeCache),t.cursorDrawHooks.size>0){c.save(),c.scale(i,i);const p=$t(c,t.plotBox,i,f);for(const m of t.cursorDrawHooks)try{m(p,t.cursorManager.state)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}je(t);for(const p of t.listeners)p();for(const p of t.cursorListeners)p();if(t._prevScaleRanges.size>0&&t.eventCallbacks.onScaleChange!=null)for(const p of e.getAllScales()){if(!U(p))continue;const m=t._prevScaleRanges.get(p.id);if(m==null||m.min!==p.min||m.max!==p.max)try{t.eventCallbacks.onScaleChange(p.id,p.min,p.max)}catch(T){console.warn("[uPlot+] event callback error:",T)}}t._prevScaleRanges.clear();for(const p of e.getAllScales())U(p)&&t._prevScaleRanges.set(p.id,{min:p.min,max:p.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),ne(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,t.scheduleRedraw()},redrawSync(){t.scheduler.cancel(),t.scheduler.mark(st.Full),t.redraw(),t.scheduler.clear()}};return t.scheduler.onRedraw(()=>t.redraw()),t}function us(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 l=`${s.scale}:${s.side}`,r=o.get(l);return r!=null?(r.config=s,r):_o(s)})}function fs(){const t=_.useRef(null);return t.current??(t.current=cs()),t.current}const Cn=_.createContext(null);function nt(){const t=_.useContext(Cn);if(!t)throw new Error("useChart must be used within a <Chart> component");return t}function ds(t="cursor"){const e=nt(),n=t==="full"?e.subscribe:e.subscribeCursor,o=_.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,l)=>e.dataStore.getYValues(s,l),toggleSeries:(s,l)=>e.toggleSeries(s,l),setFocus:s=>e.setFocus(s)}}const Ue=5,kn=.001,hs=.1,gs=10;function me(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 ps(t){return me(t,"Drag")}function ms(t){return me(t,"Click")}function ws(t){return me(t,"Dblclick")}function Ss(t){const e=t.shiftKey?"shift":t.altKey?"alt":t.ctrlKey?"ctrl":"";return e?`${e}Wheel`:"wheel"}function vs(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 bs(t,e,n,o,s=!0){const l=t.get(e);if(l!=null)return l;if(s){for(const[r,i]of t)if(typeof r=="function"&&r(n,o))return i}}function ys(t,e){const n=[];for(const o of t.scaleManager.getAllScales())U(o)&&(e!=null&&!e(o.ori)||n.push({id:o.id,ori:o.ori,dir:o.dir,startMin:o.min,startMax:o.max}));return n}function _t(t){const e=t.eventCallbacks.onScaleChange;if(e!=null)for(const n of t.scaleManager.getAllScales()){if(!U(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 oe(t,e,n,o){if(!(e instanceof WheelEvent))return;const s=tt(1-e.deltaY*kn,hs,gs),l=t.plotBox;for(const r of t.scaleManager.getAllScales()){if(!U(r)||!o(r.ori))continue;const i=r.ori===$.Horizontal,a=i?l.width:l.height,d=i?l.left:l.top,c=i?n.cx+l.left:n.cy+l.top,h=ft(c,r,a,d),u=h-(h-r.min)*s,f=h+(r.max-h)*s;r.min=Math.min(u,f),r.max=Math.max(u,f),r.auto=!1,ut(r)}t.scheduleRedraw(),_t(t)}function se(t,e,n){const o={show:!1,left:0,top:0,width:0,height:0},s=e.cx,l=e.cy;return{onMove(r,i,a){const d=t.plotBox,c=tt(a.cx,0,d.width),h=tt(a.cy,0,d.height);o.show=!0,o.left=Math.min(s,c),o.top=Math.min(l,h),o.width=Math.abs(c-s),o.height=Math.abs(h-l),n($.Vertical)||(o.top=0,o.height=d.height),n($.Horizontal)||(o.left=0,o.width=d.width),t.selectState=o,t.scheduler.mark(st.Cursor|st.Select)},onEnd(r,i,a){const d=n($.Horizontal)&&o.width>Ue,c=n($.Vertical)&&o.height>Ue;if(d||c){let h=!0;if(t.eventCallbacks.onSelect!=null){const u=Cs(t,o);let f;try{f=t.eventCallbacks.onSelect(u)}catch(g){console.warn("[uPlot+] event callback error:",g)}f===!1&&(h=!1)}h&&(xs(t,o,n),_t(t))}o.show=!1,o.left=0,o.width=0,t.selectState=o,t.scheduleRedraw()}}}function xs(t,e,n){const o=t.plotBox;for(const s of t.scaleManager.getAllScales()){if(!U(s)||!n(s.ori))continue;const l=s.ori===$.Horizontal,r=l?o.width:o.height,i=l?o.left:o.top,a=l?e.left:e.top,d=l?e.width:e.height,c=a/r,h=(a+d)/r,u=ft(i+c*r,s,r,i),f=ft(i+h*r,s,r,i);s.min=Math.min(u,f),s.max=Math.max(u,f),s.auto=!1,ut(s)}}function re(t,e,n,o){const s=ys(t,n),l=e.clientX,r=e.clientY;return{onMove(i,a){const d=t.plotBox,c=a;for(const h of s){const u=t.scaleManager.getScale(h.id);if(u==null)continue;const f=h.ori===$.Horizontal,g=f?d.width:d.height,w=f?c.clientX-l:c.clientY-r,v=(f?-1:1)*h.dir,b=h.startMax-h.startMin;u.min=h.startMin+v*(w/g)*b,u.max=h.startMax+v*(w/g)*b,u.auto=!1,ut(u)}t.renderer.clearCache(),t.scheduleRedraw()},onEnd(){_t(t)}}}function Ke(t,e,n){var c;if(n.scaleId==null||n.ori==null)return;const o=t.scaleManager.getScale(n.scaleId);if(o==null||!U(o))return;const s=n.ori===$.Vertical,l=(c=e.target.closest("div"))==null?void 0:c.getBoundingClientRect();if(l==null)return;const r=s?e.clientY-l.top:e.clientX-l.left,i=o.min,a=o.max,d=n.scaleId;return{onMove(h,u){const f=t.plotBox,g=u,w=s?f.height:f.width,b=((s?g.clientY-l.top:g.clientX-l.left)-r)/w,y=(s?1:-1)*o.dir,p=a-i,m=t.scaleManager.getScale(d);m!=null&&(m.min=i+y*b*p,m.max=a+y*b*p,m.auto=!1,ut(m),t.renderer.clearCache(),t.scheduleRedraw())},onEnd(){_t(t)}}}function le(t,e,n){if(!(e instanceof WheelEvent))return;const o=e.deltaY*kn*10;for(const s of t.scaleManager.getAllScales()){if(!U(s)||!n(s.ori))continue;const l=s.max-s.min;s.min+=o*l,s.max+=o*l,s.auto=!1,ut(s)}t.renderer.clearCache(),t.scheduleRedraw(),_t(t)}const Bt=t=>t===$.Horizontal,Gt=t=>t===$.Vertical,Vt=()=>!0;function Ms(t){switch(t){case"zoomX":return(e,n,o)=>{if(n instanceof WheelEvent){oe(e,n,o,Bt);return}return se(e,o,Bt)};case"zoomY":return(e,n,o)=>{if(n instanceof WheelEvent){oe(e,n,o,Gt);return}return se(e,o,Gt)};case"zoomXY":return(e,n,o)=>{if(n instanceof WheelEvent){oe(e,n,o,Vt);return}return se(e,o,Vt)};case"panX":return(e,n,o)=>{if(n instanceof WheelEvent){le(e,n,Bt);return}return o.scaleId!=null?Ke(e,n,o):re(e,n,Bt)};case"panY":return(e,n,o)=>{if(n instanceof WheelEvent){le(e,n,Gt);return}return o.scaleId!=null?Ke(e,n,o):re(e,n,Gt)};case"panXY":return(e,n,o)=>{if(n instanceof WheelEvent){le(e,n,Vt);return}return re(e,n,Vt)};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 qe(t){return typeof t=="function"?t:Ms(t)}function Cs(t,e){const n=t.plotBox,o=e.left/n.width,s=(e.left+e.width)/n.width,l={};for(const r of t.scaleManager.getAllScales()){if(r.ori!==$.Horizontal||!U(r))continue;const i=ft(n.left+o*n.width,r,n.width,n.left),a=ft(n.left+s*n.width,r,n.width,n.left);l[r.id]={min:Math.min(i,a),max:Math.max(i,a)}}return{left:o,right:s,ranges:l}}function ks(t,e){_.useEffect(()=>{if(e!=null)return Ts(t,e)},[t,e])}function Ts(t,e){let n=null,o=!1,s=null,l=-1,r=-1;function i(S){const k=e.getBoundingClientRect(),P=t.plotBox;return{cx:S.clientX-k.left-P.left,cy:S.clientY-k.top-P.top}}function a(S,k){const P=t.plotBox;return S>=0&&S<=P.width&&k>=0&&k<=P.height}function d(S,k){const P=e.getBoundingClientRect(),E=S-P.left,W=k-P.top,H=t.plotBox;for(const V of t.axisStates){const N=V.config,O=N.side;if(V._size<=0)continue;const ot=W>=H.top&&W<=H.top+H.height,J=E>=H.left&&E<=H.left+H.width;if(O===j.Left&&E<H.left&&ot||O===j.Right&&E>H.left+H.width&&ot||O===j.Top&&W<H.top&&J||O===j.Bottom&&W>H.top+H.height&&J)return{scaleId:N.scale,ori:Ct(O)}}return null}function c(S){const{cx:k,cy:P}=i(S);return{cx:k,cy:P,inPlot:a(k,P)}}function h(S){if(n==null){g();return}e.contains(S.target)||(o=!0,n.onMove(t,S,c(S)),y(S,S))}function u(S){g(),n!=null&&(e.contains(S.target)||(n.onEnd(t,S,c(S)),n=null,l=-1,r=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw()))}function f(){document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)}function g(){document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}function w(){n!=null&&(n=null,g(),t.cursorManager.hide(),t.scheduleCursorRedraw())}function v(S,k,P){const E=t.cursorManager.state;let W=null;if(E.activeGroup>=0&&E.activeDataIdx>=0){const H=t.dataStore.data[E.activeGroup];if(H!=null){const V=H.x[E.activeDataIdx],N=H.series[E.activeSeriesIdx],O=N!=null?N[E.activeDataIdx]:void 0;if(V!=null&&O!=null){const Z=t.plotBox,ot=t.scaleManager.getGroupXScaleKey(E.activeGroup),J=ot!=null?t.scaleManager.getScale(ot):void 0,dt=t.seriesConfigMap.get(`${E.activeGroup}:${E.activeSeriesIdx}`),kt=dt!=null?t.scaleManager.getScale(dt.yScale):void 0;let Tt=k,Kt=P;J!=null&&U(J)&&(Tt=X(V,J,Z.width,Z.left)-Z.left),kt!=null&&U(kt)&&(Kt=X(O,kt,Z.height,Z.top)-Z.top);const Le=k-Tt,Ie=P-Kt;W={group:E.activeGroup,seriesIdx:E.activeSeriesIdx,dataIdx:E.activeDataIdx,xVal:V,yVal:O,pxX:Tt,pxY:Kt,dist:Math.sqrt(Le*Le+Ie*Ie)}}}}return{plotX:k,plotY:P,point:W,srcEvent:S}}function b(S,k,P,E=!0){const W=bs(t.actionMap,S,k,P,E);if(!(W==null||W==="none"))return qe(W)}function y(S,k){const{cx:P,cy:E}=i(S);if(!a(P,E)&&n==null){l=-1,r=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw();return}const W=P!==l||E!==r;if(l=P,r=E,t.cursorManager.update(P,E,t.plotBox,t.dataStore.data,t.seriesConfigs,H=>t.scaleManager.getScale(H),H=>t.dataStore.getWindow(H),H=>t.scaleManager.getGroupXScaleKey(H)),W){const H={cx:P,cy:E,inPlot:a(P,E)},V=t.actionMap.get("hover");if(V!=null&&V!=="none"){const N=qe(V);if(N!=null&&N(t,k??S,H),t.focusAlpha<1){const O=t.cursorManager.state;if(O.activeGroup>=0&&O.activeSeriesIdx>=0){const Z=t.seriesConfigs.findIndex(ot=>ot.group===O.activeGroup&&ot.index===O.activeSeriesIdx);Z>=0&&t.focusedSeries!==Z&&(t.focusedSeries=Z,t.scheduleRedraw())}}}}if(k!=null&&t.eventCallbacks.onCursorMove!=null&&a(P,E))try{t.eventCallbacks.onCursorMove(v(k,P,E))}catch(H){console.warn("[uPlot+] event callback error:",H)}t.scheduleCursorRedraw()}function p(){document.activeElement!==e&&e.focus()}function m(S){const k=c(S),P=d(S.clientX,S.clientY);let E;if(P!=null&&S.button===0)E=P.ori===$.Horizontal?"xGutterDrag":"yGutterDrag",k.scaleId=P.scaleId,k.ori=P.ori;else if(E=ps(S),!k.inPlot)return;k.action=E;const W=b(E,S,k,!1);if(W==null)return;(S.button!==0||P!=null)&&S.preventDefault();const H=W(t,S,k);H!=null&&(n=H,o=!1,f())}function T(S){if(n!=null){o=!0,n.onMove(t,S,c(S)),y(S,S);return}y(S,S)}function M(S){if(n!=null){n.onEnd(t,S,c(S)),n=null;return}}function C(S){if(o){o=!1;return}const k=c(S);if(!k.inPlot)return;const P=ms(S);k.action=P;const E=b(P,S,k);E!=null&&E(t,S,k);const W=t.eventCallbacks.onClick;if(W!=null)try{W(v(S,k.cx,k.cy))}catch(H){console.warn("[uPlot+] event callback error:",H)}}function I(S){if(n!=null){S.preventDefault();return}const k=c(S);if(!k.inPlot)return;S.preventDefault(),k.action="rightClick";const P=b("rightClick",S,k);P!=null&&P(t,S,k);const E=t.eventCallbacks.onContextMenu;if(E!=null)try{E(v(S,k.cx,k.cy))}catch(W){console.warn("[uPlot+] event callback error:",W)}}function A(S){var k,P;if(n==null){l=-1,r=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw();try{(P=(k=t.eventCallbacks).onCursorLeave)==null||P.call(k)}catch(E){console.warn("[uPlot+] event callback error:",E)}}}function x(S){const k=c(S);if(!k.inPlot)return;if(t.eventCallbacks.onDblClick!=null){let W;try{W=t.eventCallbacks.onDblClick(v(S,k.cx,k.cy))}catch(H){console.warn("[uPlot+] event callback error:",H)}if(W===!1)return}const P=ws(S);k.action=P;const E=b(P,S,k,!1);E!=null&&E(t,S,k)}function D(S){const k=c(S);if(!k.inPlot)return;const P=Ss(S);k.action=P;const E=b(P,S,k);E!=null&&(S.preventDefault(),E(t,S,k))}function L(S){if(S.touches.length===2){const H=S.touches[0],V=S.touches[1],N=V.clientX-H.clientX,O=V.clientY-H.clientY;s={dist:Math.sqrt(N*N+O*O),midX:(H.clientX+V.clientX)/2,midY:(H.clientY+V.clientY)/2},n=null;return}const k=S.touches[0];if(k==null)return;const P=c(k);if(!P.inPlot)return;const E=b("touchDrag",S,P);if(E==null)return;const W=E(t,S,P);W!=null&&(n=W,o=!1)}function F(S){if(S.touches.length===2&&s!=null){S.preventDefault();const P=S.touches[0],E=S.touches[1],W=E.clientX-P.clientX,H=E.clientY-P.clientY,V=Math.sqrt(W*W+H*H),N=c({clientX:s.midX,clientY:s.midY});if(b("pinch",S,N)!=null){const Z=V/s.dist,ot=t.plotBox;for(const J of t.scaleManager.getAllScales()){if(J.ori!==$.Horizontal||!U(J))continue;const dt=ft(N.cx+ot.left,J,ot.width,ot.left),kt=dt-(dt-J.min)/Z,Tt=dt+(J.max-dt)/Z;J.min=Math.min(kt,Tt),J.max=Math.max(kt,Tt),J.auto=!1,ut(J)}s.dist=V,t.renderer.clearCache(),t.scheduleRedraw(),_t(t)}return}const k=S.touches[0];if(k!=null){if(n!=null){o=!0,n.onMove(t,S,c(k)),y(k,S),S.preventDefault();return}y(k,S)}}function R(S){if(s!=null){s=null;return}const k=S.changedTouches[0];k!=null&&n!=null&&(n.onEnd(t,S,c(k)),n=null)}function z(S){const k={cx:l,cy:r,inPlot:l>=0&&r>=0},P=vs(S);k.action=P;const E=b(P,S,k);E!=null&&(S.preventDefault(),E(t,S,k))}return e.addEventListener("mouseenter",p),e.addEventListener("mousemove",T),e.addEventListener("mousedown",m),e.addEventListener("mouseup",M),e.addEventListener("click",C),e.addEventListener("contextmenu",I),e.addEventListener("mouseleave",A),e.addEventListener("dblclick",x),e.addEventListener("wheel",D,{passive:!1}),e.addEventListener("touchstart",L,{passive:!0}),e.addEventListener("touchmove",F,{passive:!1}),e.addEventListener("touchend",R),e.addEventListener("keydown",z),window.addEventListener("blur",w),()=>{g(),e.removeEventListener("mouseenter",p),e.removeEventListener("mousemove",T),e.removeEventListener("mousedown",m),e.removeEventListener("mouseup",M),e.removeEventListener("click",C),e.removeEventListener("contextmenu",I),e.removeEventListener("mouseleave",A),e.removeEventListener("dblclick",x),e.removeEventListener("wheel",D),e.removeEventListener("touchstart",L),e.removeEventListener("touchmove",F),e.removeEventListener("touchend",R),e.removeEventListener("keydown",z),window.removeEventListener("blur",w)}}const ce=new Map;function As(t){let e=ce.get(t);return e==null&&(e=new Ls(t),ce.set(t,e)),e}class Ls{constructor(e){Y(this,"key");Y(this,"members",new Set);Y(this,"publishing",!1);Y(this,"syncedStores",new WeakSet);this.key=e}join(e){this.members.add(e)}leave(e){this.members.delete(e),this.members.size===0&&ce.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 i of this.members)i!==e&&(this.syncedStores.add(i),i.cursorManager.hide(),i.scheduleCursorRedraw());this.publishing=!1;return}const r=e.dataStore.getXValues(o)[s];if(r==null){this.publishing=!1;return}for(const i of this.members)i!==e&&(this.syncedStores.add(i),i.cursorManager.syncToValue(r,i,o),i.scheduleCursorRedraw());this.publishing=!1}}function Is(t,e){_.useEffect(()=>{if(e==null)return;const n=As(e);n.join(t);let o=-1,s=-1;const l=t.subscribeCursor(()=>{const{activeGroup:r,activeDataIdx:i}=t.cursorManager.state;r===o&&i===s||(o=r,s=i,n.pub(t))});return()=>{l(),n.leave(t)}},[t,e])}function Tn(t){return t instanceof Float64Array?t:new Float64Array(t)}function An(t){return t instanceof Float64Array||t.some(e=>e==null)?t:new Float64Array(t)}function Ze(t){return{x:Tn(t.x),series:[An(t.y)]}}function Ps(t){return{x:Tn(t.x),series:t.series.map(An)}}function Ln(t){if(!Array.isArray(t))return[Ze(t)];if(t.length===0)return[];const e=t[0];return e==null?[]:"series"in e?t.map(Ps):t.map(Ze)}function we({width:t,height:e,data:n,children:o,className:s,pxRatio:l,title:r,xlabel:i,ylabel:a,onDraw:d,onCursorDraw:c,syncKey:h,actions:u,onClick:f,onContextMenu:g,onDblClick:w,onCursorMove:v,onCursorLeave:b,onScaleChange:y,onSelect:p}){const m=fs(),[T,M]=_.useState(null),C=l??(typeof window<"u"&&window.devicePixelRatio||1);_.useEffect(()=>{m.actionMap=u!=null?new Map([...Xt,...u]):new Map(Xt)},[m,u]),_.useLayoutEffect(()=>{m.setLabels(r,i,a)},[m,r,i,a]),_.useEffect(()=>{const S=m.eventCallbacks;S.onClick=f,S.onContextMenu=g,S.onDblClick=w,S.onCursorMove=v,S.onCursorLeave=b,S.onScaleChange=y,S.onSelect=p},[m,f,g,w,v,b,y,p]),ks(m,T),Is(m,h);const I=_.useRef(null),A=_.useCallback(S=>{I.current!==S&&(I.current=S,m.setCanvas(S),S&&m.scheduleRedraw())},[m]),x=_.useRef(null),D=_.useCallback(S=>{x.current!==S&&(x.current=S,M(S))},[]),L=_.useRef(d);_.useLayoutEffect(()=>{L.current=d});const F=_.useRef(c);_.useLayoutEffect(()=>{F.current=c});const R=_.useRef(!1),z=_.useRef(n);return _.useLayoutEffect(()=>{n===z.current&&m.dataStore.data.length>0||(z.current=n,R.current=!0,m.setData(Ln(n)),m.scheduleRedraw())},[m,n]),_.useLayoutEffect(()=>{m.setSize(t,e,C),R.current&&m.redrawSync()},[m,t,e,C]),_.useEffect(()=>()=>{m.setCanvas(null),m.scheduler.cancel(),m.focusedSeries=null,m.eventCallbacks={}},[m]),_.useEffect(()=>{if(T==null||typeof ResizeObserver>"u")return;const S=new ResizeObserver(k=>{const P=k[0];if(P==null)return;const{width:E,height:W}=P.contentRect;E>0&&W>0&&(E!==m.width||W!==m.height)&&(m.setSize(Math.round(E),Math.round(W)),m.scheduleRedraw())});return S.observe(T),()=>{S.disconnect()}},[m,T]),_.useEffect(()=>{if(typeof MutationObserver>"u")return;const S=document.documentElement,k=new MutationObserver(()=>{m.renderer.invalidateSnapshot(),m.scheduleRedraw()});return k.observe(S,{attributes:!0,attributeFilter:["class"]}),()=>{k.disconnect()}},[m]),_.useLayoutEffect(()=>{const S=k=>{var P;(P=L.current)==null||P.call(L,k)};return m.drawHooks.add(S),()=>{m.drawHooks.delete(S)}},[m]),_.useLayoutEffect(()=>{const S=(k,P)=>{var E;(E=F.current)==null||E.call(F,k,P)};return m.cursorDrawHooks.add(S),()=>{m.cursorDrawHooks.delete(S)}},[m]),B.jsx(Cn.Provider,{value:m,children:B.jsxs("div",{className:s,style:{position:"relative",display:"flex",flexDirection:"column",width:`${t}px`},children:[B.jsx("div",{ref:D,tabIndex:0,style:{position:"relative",width:`${t}px`,height:`${e}px`,cursor:"crosshair",outline:"none",order:0},children:B.jsx("canvas",{ref:A,style:{position:"absolute",left:0,top:0}})}),o]})})}function Je(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function Es(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 _s(t,e){if(t===null)return!1;const n=t,o=e,s=Object.keys(n),l=Object.keys(o);if(s.length!==l.length)return!1;for(const r of l){const i=n[r],a=o[r];if(i!==a)if(Je(i)&&Je(a)){if(!Es(i,a))return!1}else return!1}return!0}function Se(t,e,n,o,s){const l=nt(),r=_.useRef(t);_.useLayoutEffect(()=>{r.current=t}),_.useLayoutEffect(()=>{const a=r.current;return n(l,a),l.scheduleRedraw(),()=>{o(l,a),l.scheduleRedraw()}},[l,...e]);const i=_.useRef(t);_.useLayoutEffect(()=>{_s(i.current,t)||(i.current=t,s(l,t),l.scheduleRedraw())})}function Ds(t){return Se(t,[t.id],(e,n)=>e.registerScale(n),(e,n)=>e.unregisterScale(n.id),(e,n)=>e.updateScale(n)),null}function Fs(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)),l=n-o/2;let r=0,i=0,a=0;return t<60?(r=o,i=s):t<120?(r=s,i=o):t<180?(i=o,a=s):t<240?(i=s,a=o):t<300?(r=s,a=o):(r=o,a=s),[Math.round((r+l)*255),Math.round((i+l)*255),Math.round((a+l)*255)]}function In(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?Fs(Number(s[1]),Number(s[2]),Number(s[3])):null}function Rs(t,e=.8,n=0){const o=In(t);if(o==null)return{type:"linear",stops:[[0,t],[1,t]]};const[s,l,r]=o;return{type:"linear",stops:[[0,`rgba(${s},${l},${r},${e})`],[1,`rgba(${s},${l},${r},${n})`]]}}function Pn(t,e){const n=In(t);if(n==null)return t;const[o,s,l]=n;return`rgba(${o},${s},${l},${e})`}function Hs(t,e=65,n=50){const o=[];for(let l=0;l<t;l++){const r=l*137.508%360;o.push(`hsl(${r.toFixed(1)},${e}%,${n}%)`)}return o}const Qe=["#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085","#c0392b","#2980b9","#27ae60","#f1c40f","#8e44ad","#d35400"];function tn(t,e){var r;const n=(r=t.paths)==null?void 0:r.defaults,o=t.stroke??Qe[e%Qe.length]??"#000",s=t.fill??(n==null?void 0:n.fill),l=s==="auto"&&typeof o=="string"?Pn(o,.5):s==="auto"?void 0:s;return{...n,...t,yScale:t.yScale??"y",show:t.show??!0,stroke:o,fill:l}}function ve(t){return Se(t,[t.group,t.index],(e,n)=>e.registerSeries(tn(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(tn(n,o>=0?o:e.seriesConfigs.length))}),null}function Ws(t){return{...t,side:t.side??(t.scale==="x"?j.Bottom:j.Left),show:t.show??!0}}function Wt(t){const e=Ws(t);return Se(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 zs({series:t,group:e,fill:n,dir:o}){const s=nt(),l=_.useRef(null),r=t[0],i=t[1];return _.useEffect(()=>{const a={series:[r,i],group:e,fill:n,dir:o};return l.current!=null&&s.unregisterBand(l.current),l.current=a,s.registerBand(a),s.scheduleRedraw(),()=>{l.current!=null&&s.unregisterBand(l.current),l.current=null,s.scheduleRedraw()}},[s,r,i,e,n,o]),null}const $s={width:12,height:3,borderRadius:1,display:"inline-block"},Bs={fontWeight:600},En={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},Gs={...En,opacity:1},Vs={...En,opacity:.4},en=new Map,Xs={display:"flex",flexWrap:"wrap",justifyContent:"center",order:-1,padding:"4px 0"},Ns={display:"flex",flexWrap:"wrap",justifyContent:"center",order:1,padding:"4px 0"};function Ys({group:t,index:e,label:n,color:o,isHidden:s,valueStr:l,store:r}){let i=en.get(o);return i==null&&(i={...$s,backgroundColor:o},en.set(o,i)),B.jsxs("span",{onClick:()=>r.toggleSeries(t,e),style:s?Vs:Gs,children:[B.jsx("span",{style:i}),B.jsx("span",{children:n}),l&&B.jsx("span",{style:Bs,children:l})]})}function Os({show:t=!0,position:e="bottom",className:n}){const o=nt(),s=_.useSyncExternalStore(o.subscribeCursor,o.getSnapshot);if(!t)return null;const{activeGroup:l,activeDataIdx:r}=s;return B.jsx("div",{className:n,style:e==="top"?Xs:Ns,children:o.seriesConfigs.map(i=>{if(i.legend===!1)return null;const a=Ft(i);let d="";if(r>=0&&l>=0&&i.group===l){const h=o.dataStore.getYValues(i.group,i.index)[r];h!=null&&(d=typeof h=="number"?h.toPrecision(4):String(h))}return B.jsx(Ys,{group:i.group,index:i.index,label:i.label??`Series ${i.index}`,color:a,isHidden:i.show===!1,valueStr:d,store:o},`${i.group}:${i.index}`)})})}const pt=8;function js(t,e,n,o){if(t!=null&&typeof t=="object")return t;switch(t){case"top-left":return{x:e.left+pt,y:e.top+pt};case"bottom-left":return{x:e.left+pt,y:e.top+e.height-o-pt};case"bottom-right":return{x:e.left+e.width-n-pt,y:e.top+e.height-o-pt};case"top-right":case void 0:default:return{x:e.left+e.width-n-pt,y:e.top+pt}}}function Us(t,e,n,o,s,l,r,i,a,d){if(t<0)return null;const c=tt(t+n+r,n,n+s-a),h=tt(e+o+i,o,o+l-d);return{x:c,y:h}}function nn(t,e,n,o,s,l,r){const i=Math.max(e,Math.min(t.x,e+o-l)),a=Math.max(n,Math.min(t.y,n+s-r));return i===t.x&&a===t.y?t:{x:i,y:a}}const Ks={pointerEvents:"none"};function qs(t,e,n){return{pointerEvents:"auto",cursor:t?"grabbing":"grab",opacity:e||t?1:n,transition:"opacity 0.2s ease"}}const Zs={};function _n({mode:t,show:e,position:n,offset:o,idleOpacity:s,estimatedSize:l}){const r=nt(),i=_.useSyncExternalStore(r.subscribeCursor,r.getSnapshot),[a,d]=_.useState(null),[c,h]=_.useState(!1),[u,f]=_.useState(!1),g=_.useRef(!1),w=_.useRef(!1),v=_.useRef({dx:0,dy:0}),[b,y]=_.useState(!1),p=_.useRef(null),[m,T]=_.useState({w:0,h:0});_.useLayoutEffect(()=>{if(t!=="cursor")return;const x=p.current;if(!x)return;const D=x.offsetWidth,L=x.offsetHeight;(D!==m.w||L!==m.h)&&T({w:D,h:L})}),_.useLayoutEffect(()=>{if(t!=="draggable"||b||i.plotWidth<=0)return;y(!0);const x=p.current,D=(x==null?void 0:x.offsetWidth)??l.w,L=(x==null?void 0:x.offsetHeight)??l.h;d(js(n,r.plotBox,D,L))},[t,b,i.plotWidth,n,r.plotBox,l]),_.useLayoutEffect(()=>{if(t!=="draggable"||!b||a==null||u||i.plotWidth<=0)return;const x=p.current;if(!x)return;const D=x.offsetWidth,L=x.offsetHeight,F=nn(a,i.plotLeft,i.plotTop,i.plotWidth,i.plotHeight,D,L);F!==a&&d(F)}),_.useEffect(()=>{if(!e||t!=="draggable")return;const x=L=>{var z;if(!g.current)return;w.current=!0;const F=(z=r.canvas)==null?void 0:z.parentElement;if(!F)return;const R=F.getBoundingClientRect();d({x:L.clientX-R.left-v.current.dx,y:L.clientY-R.top-v.current.dy})},D=()=>{g.current=!1,f(!1)};return window.addEventListener("mousemove",x),window.addEventListener("mouseup",D),()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",D)}},[r,e,t]);const M=x=>{if(t!=="draggable")return;x.stopPropagation(),x.preventDefault(),g.current=!0,f(!0),w.current=!1;const D=x.currentTarget.getBoundingClientRect();v.current={dx:x.clientX-D.left,dy:x.clientY-D.top}};let C=null;if(e)if(t==="cursor"){const x=m.w||l.w,D=m.h||l.h;C=Us(i.left,i.top,i.plotLeft,i.plotTop,i.plotWidth,i.plotHeight,o.x,o.y,x,D)}else a!=null&&(u?C=a:C=nn(a,i.plotLeft,i.plotTop,i.plotWidth,i.plotHeight,l.w,l.h));const I=t==="draggable"?qs(u,c,s):Ks;return{panelRef:p,renderPos:C,isDragging:u,hovered:c,didDrag:w,panelStyle:I,panelHandlers:t==="draggable"?{onMouseDown:M,onMouseEnter:()=>h(!0),onMouseLeave:()=>{h(!1),w.current=!1}}:Zs}}const on=1,Js=6,Qs=4,tr=4,er=12,sn=4,nr="12px sans-serif",rn="bold 12px sans-serif",ln=16,or={position:"absolute",zIndex:50,background:"var(--uplot-panel-bg, rgba(255,255,255,0.92))",border:"1px solid var(--uplot-panel-border, #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"},sr={width:12,height:3,borderRadius:1,display:"inline-block",flexShrink:0},rr={fontWeight:600},Ut={display:"flex",alignItems:"center",gap:4,padding:"1px 4px"},lr={...Ut,opacity:1,cursor:"pointer"},ir={...Ut,opacity:1,cursor:"default"},ar={...Ut,opacity:.4,cursor:"pointer"},cr={...Ut,opacity:.4,cursor:"default"},an=new Map;function ur(t){let e=an.get(t);return e==null&&(e={...sr,backgroundColor:t},an.set(t,e)),e}function be({label:t,color:e,value:n,isHidden:o,onClick:s}){const l=o?s?ar:cr:s?lr:ir;return B.jsxs("div",{onClick:s,style:l,children:[B.jsx("span",{style:ur(e)}),B.jsx("span",{children:t}),n&&B.jsx("span",{style:rr,children:n})]})}const ye=_.forwardRef(function({left:e,top:n,children:o,className:s,style:l,onMouseDown:r,onMouseEnter:i,onMouseLeave:a},d){return B.jsx("div",{ref:d,className:s,onMouseDown:r,onMouseEnter:i,onMouseLeave:a,style:{...or,left:e,top:n,...l},children:o})});function fr(t,e,n,o,s){if(s<0||o<0)return"";const r=t.dataStore.getYValues(e,n)[s];return r==null?"":typeof r=="number"?r.toPrecision(4):String(r)}function ie(t,e){const n=Pe.prepareWithSegments(t,e);let o=0;return Pe.walkLineRanges(n,Number.POSITIVE_INFINITY,s=>{s.width>o&&(o=s.width)}),o}function xe(t){let e=0;for(const s of t.rows){const l=ie(s.label,nr),r=s.value?ie(s.value,rn):0,i=tr*2+er+sn+l+(s.value?sn+r:0);i>e&&(e=i)}let n=0,o=0;return t.header&&(n=ie(t.header,rn)+8,o=ln+2),{w:on*2+Js*2+Math.max(e,n),h:on*2+Qs*2+o+t.rows.length*ln}}const dr={x:12,y:-12},hr={w:0,h:0},gr={zIndex:100},pr={fontWeight:600,marginBottom:2,padding:"0 4px"};function mr({show:t=!0,className:e,children:n,offset:o=dr,precision:s=2,mode:l="cursor",position:r="top-right",idleOpacity:i=.8}){const a=nt(),d=_.useSyncExternalStore(a.subscribeCursor,a.getSnapshot),{activeGroup:c,activeDataIdx:h}=d,u=a.plotBox,f=h>=0&&c>=0&&d.left>=0,g={x:o.x??12,y:o.y??-12};let w=null,v="";const b=[];if(f){const M=a.dataStore.data[c];w=M!=null?M.x[h]??null:null,v=w!=null?parseFloat(w.toFixed(s)).toString():"";for(const C of a.seriesConfigs){if(C.show===!1||C.legend===!1)continue;const I=a.dataStore.getYValues(C.group,C.index),A=C.group===c?I[h]:null;b.push({label:C.label??`Series ${C.index}`,value:A,color:Ft(C),group:C.group,index:C.index})}}else if(l==="draggable")for(const M of a.seriesConfigs)M.show===!1||M.legend===!1||b.push({label:M.label??`Series ${M.index}`,value:null,color:Ft(M),group:M.group,index:M.index});const y=b.length>0?xe({header:v||void 0,rows:b.map(M=>({label:M.label,value:M.value!=null?M.value.toPrecision(4):"—"}))}):hr,p=_n({mode:l,show:t,position:r,offset:g,idleOpacity:i,estimatedSize:y});if(!t||l==="cursor"&&!f||p.renderPos==null)return null;const m={x:w,xLabel:v,items:b,left:d.left+u.left,top:d.top+u.top},T={...p.panelStyle,...gr};return n?B.jsx("div",{ref:p.panelRef,className:e,style:{position:"absolute",left:p.renderPos.x,top:p.renderPos.y,whiteSpace:"nowrap",...T},...p.panelHandlers,children:n(m)}):B.jsxs(ye,{ref:p.panelRef,left:p.renderPos.x,top:p.renderPos.y,className:e,style:T,...p.panelHandlers,children:[v&&B.jsx("div",{style:pr,children:v}),b.map(M=>B.jsx(be,{label:M.label,color:M.color,value:M.value!=null?M.value.toPrecision(4):"—"},`${M.group}:${M.index}`))]})}const wr=8,cn=.01,ue=[.25,.75];function Sr(t,e,n){if(t==null)return ue;const o=n-e;return o<=0?ue:[Math.max(0,(t[0]-e)/o),Math.min(1,(t[1]-e)/o)]}function vr(t,e,n){const o=n-e;return[e+t[0]*o,e+t[1]*o]}function br(t,e,n){return Math.abs(t-e[0])<n?"left":Math.abs(t-e[1])<n?"right":t>=e[0]&&t<=e[1]?"move":"outside"}function yr(t,e,n){if(t==="move"){const s=e[1]-e[0],l=tt(e[0]+n,0,1-s);return[l,l+s]}if(t==="left")return[tt(e[0]+n,0,e[1]-cn),e[1]];const o=tt(e[1]+n,e[0]+cn,1);return[e[0],o]}function xr({width:t,height:e,data:n,onRangeChange:o,initialRange:s,className:l,colors:r,grips:i=!1}){const a=_.useRef(null),d=_.useMemo(()=>Ln(n),[n]),[c,h]=_.useState(()=>{if(s!=null&&d.length>0){const M=d[0];if(M!=null&&M.x.length>1)return Sr(s,M.x[0],M.x[M.x.length-1])}return ue}),u=_.useRef(null);_.useEffect(()=>{if(o==null||d.length===0)return;const M=d[0];if(M==null||M.x.length<2)return;const C=M.x[0],I=M.x[M.x.length-1],[A,x]=vr(c,C,I),D=u.current,L=Math.max(1e-10,Math.abs(x-A)*1e-12);D!=null&&Math.abs(D[0]-A)<L&&Math.abs(D[1]-x)<L||(u.current=[A,x],o(A,x))},[c,d,o]);const f=_.useRef(null),g=_.useCallback(M=>{const C=a.current;if(C==null)return 0;const I=C.getBoundingClientRect();return tt((M-I.left)/I.width,0,1)},[]),w=_.useCallback(M=>{const C=a.current;if(C==null)return;const I=g(M.clientX),A=C.getBoundingClientRect().width,x=A>0?wr/A:0,D=br(I,c,x);if(D==="outside"){const L=c[1]-c[0],F=L/2,R=tt(I-F,0,1-L),z=[R,R+L];h(z),f.current={mode:"move",startX:M.clientX,startFrac:z},C.setPointerCapture(M.pointerId),M.preventDefault();return}f.current={mode:D,startX:M.clientX,startFrac:[...c]},C.setPointerCapture(M.pointerId),M.preventDefault()},[c,g]),v=_.useCallback(M=>{const C=f.current;if(C==null)return;const I=g(M.clientX),A=g(C.startX),x=I-A;h(yr(C.mode,C.startFrac,x))},[g]),b=_.useCallback(M=>{f.current=null;const C=a.current;C!=null&&C.releasePointerCapture(M.pointerId)},[]),y=`${c[0]*100}%`,p=`${(c[1]-c[0])*100}%`,m=d[0],T=m!=null?m.series.length:0;return B.jsxs("div",{className:l,style:{position:"relative",width:t,height:e},children:[B.jsxs(we,{width:t,height:e,data:d,children:[B.jsx(Wt,{scale:"x",show:!1}),B.jsx(Wt,{scale:"y",show:!1}),Array.from({length:T},(M,C)=>B.jsx(ve,{group:0,index:C,yScale:"y",stroke:r!=null&&r[C]!=null?r[C]:`hsl(${C*137}, 60%, 50%)`,width:1},`0:${C}`))]}),B.jsxs("div",{ref:a,onPointerDown:w,onPointerMove:v,onPointerUp:b,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[B.jsx("div",{style:{position:"absolute",top:0,left:0,width:y,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),B.jsx("div",{style:{position:"absolute",top:0,left:`${c[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),B.jsx("div",{style:{position:"absolute",top:0,left:y,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&&B.jsxs(B.Fragment,{children:[B.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"}}),B.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 St(t,e){const n=nt(),o=_.useRef(t);_.useLayoutEffect(()=>{o.current=t});const s=(e==null?void 0:e.clipped)!==!1;_.useLayoutEffect(()=>{const l=i=>o.current(i),r=s?n.drawHooks:n.unclippedDrawHooks;return r.add(l),()=>{r.delete(l)}},[n,s])}function Mr(t){const e=nt(),n=_.useRef(t);_.useLayoutEffect(()=>{n.current=t}),_.useLayoutEffect(()=>{const o=(s,l)=>n.current(s,l);return e.cursorDrawHooks.add(o),()=>{e.cursorDrawHooks.delete(o)}},[e])}function Cr({lanes:t,laneHeight:e=24,gap:n=2,scaleId:o="x"}){const s=nt();return St(({ctx:l,plotBox:r,pxRatio:i})=>{const a=s.scaleManager.getScale(o);if(a==null||!U(a))return;l.save();const d=(e+n)*i,c=e*i,h=r.top*i;l.fillStyle="#666",l.font=`${11*i}px sans-serif`,l.textAlign="right",l.textBaseline="middle";for(let u=0;u<t.length;u++){const f=t[u];if(f==null)continue;const g=h+u*d;l.fillText(f.label,(r.left-6)*i,g+c/2)}l.beginPath(),l.rect(r.left*i,r.top*i,r.width*i,r.height*i),l.clip();for(let u=0;u<t.length;u++){const f=t[u];if(f==null)continue;const g=h+u*d;for(const w of f.segments){const v=X(w.start,a,r.width,r.left)*i,y=X(w.end,a,r.width,r.left)*i-v;y<=0||(l.fillStyle=w.color??"#4dabf7",l.fillRect(v,g,y,c),w.label!=null&&y>20*i&&(l.fillStyle="#fff",l.font=`${10*i}px sans-serif`,l.textAlign="center",l.textBaseline="middle",l.fillText(w.label,v+y/2,g+c/2,y-4*i)))}}l.restore()},{clipped:!1}),null}function kr({data:t,width:e=150,height:n=30,stroke:o="#03a9f4",fill:s,lineWidth:l=1,paths:r,fillTo:i,className:a}){return B.jsx("div",{style:{pointerEvents:"none"},className:a,children:B.jsxs(we,{width:e,height:n,data:t,children:[B.jsx(Wt,{scale:"x",show:!1}),B.jsx(Wt,{scale:"y",show:!1}),B.jsx(ve,{group:0,index:0,yScale:"y",stroke:o,fill:s,width:l,paths:r,fillTo:i})]})})}const Tr={x:12,y:-12},Ar={w:0,h:0};function Lr({mode:t="draggable",position:e="top-right",offset:n=Tr,idleOpacity:o=.3,show:s=!0,className:l}){const r=nt(),i=_.useSyncExternalStore(r.subscribeCursor,r.getSnapshot),{activeGroup:a,activeDataIdx:d}=i,c=[],h=r.seriesConfigs.filter(v=>v.legend!==!1).map(v=>{const b=Ft(v),y=fr(r,v.group,v.index,a,d),p=v.label??`Series ${v.index}`;return c.push({label:p,value:y}),{cfg:v,color:b,value:y,label:p}}),u=h.length>0?xe({rows:c}):Ar,f=_n({mode:t,show:s,position:e,offset:n,idleOpacity:o,estimatedSize:u});if(!s||f.renderPos==null)return null;const g=(v,b)=>{f.didDrag.current||r.toggleSeries(v,b)},w=t==="draggable";return B.jsx(ye,{ref:f.panelRef,left:f.renderPos.x,top:f.renderPos.y,className:l,style:f.panelStyle,...f.panelHandlers,children:h.map(({cfg:v,color:b,value:y,label:p})=>B.jsx(be,{label:p,color:b,value:y,isHidden:v.show===!1,onClick:w?()=>g(v.group,v.index):void 0},`${v.group}:${v.index}`))})}const Ir={pointerEvents:"none"};function Pr({delay:t=1e3,show:e=!0,className:n}){const o=nt(),s=_.useSyncExternalStore(o.subscribeCursor,o.getSnapshot),[l,r]=_.useState(!1),i=_.useRef(-1),a=_.useRef(0),d=_.useRef(null),[c,h]=_.useState({w:0,h:0});if(_.useLayoutEffect(()=>{const T=d.current;if(!T)return;const M=T.offsetWidth,C=T.offsetHeight;(M!==c.w||C!==c.h)&&h({w:M,h:C})}),_.useEffect(()=>{const T=s.activeSeriesIdx;T!==i.current&&(i.current=T,r(!1),window.clearTimeout(a.current),T>=0&&(a.current=window.setTimeout(()=>r(!0),t)))},[s.activeSeriesIdx,t]),_.useEffect(()=>()=>{window.clearTimeout(a.current)},[]),!e||!l||s.left<0)return null;const u=o.seriesConfigs.find(T=>T.group===s.activeGroup&&T.index===s.activeSeriesIdx);if(!(u!=null&&u.label)||u.legend===!1)return null;const f=Ft(u),g=xe({rows:[{label:u.label}]}),w=c.w||g.w,v=c.h||g.h,b=s.left+s.plotLeft,y=s.top+s.plotTop,p=tt(b-w/2,s.plotLeft,s.plotLeft+s.plotWidth-w),m=tt(y-v-12,s.plotTop,s.plotTop+s.plotHeight-v);return B.jsx(ye,{ref:d,left:p,top:m,className:n,style:Ir,children:B.jsx(be,{label:u.label,color:f})})}function Dn(t,e,n,o,s,l,r,i,a){const d=r/2;if(a.wickColor!=null&&(t.strokeStyle=a.wickColor,t.lineWidth=a.wickWidth??1,t.beginPath(),t.moveTo(e,n),t.lineTo(e,o),t.stroke()),a.capWidth!=null&&a.capWidth>0){const u=a.capWidth/2;t.strokeStyle=a.wickColor??"#555",t.lineWidth=a.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 c=Math.min(s,l),h=Math.abs(l-s);t.fillStyle=a.bodyFill,t.fillRect(e-d,c,r,h),a.bodyStroke!=null&&(t.strokeStyle=a.bodyStroke,t.lineWidth=a.bodyStrokeWidth??1.5,t.strokeRect(e-d,c,r,h)),i!=null&&a.midColor!=null&&(t.strokeStyle=a.midColor,t.lineWidth=a.midWidth??2.5,t.beginPath(),t.moveTo(e-d,i),t.lineTo(e+d,i),t.stroke())}function Er({boxes:t,yScale:e="y",boxWidth:n=.5,fill:o="rgba(52, 152, 219, 0.4)",stroke:s="#2980b9",medianColor:l="#e74c3c",whiskerColor:r="#555"}){return St(({ctx:i,plotBox:a,valToX:d,valToY:c})=>{const h=a.width/t.length*n,u=h*.3;for(let f=0;f<t.length;f++){const g=t[f];if(g==null)continue;const w=d(f+1),v=c(g.min,e),b=c(g.q1,e),y=c(g.median,e),p=c(g.q3,e),m=c(g.max,e);w==null||v==null||b==null||y==null||p==null||m==null||Dn(i,w,v,m,b,p,h,y,{wickColor:r,bodyFill:o,bodyStroke:s,capWidth:u,midColor:l})}}),null}function _r(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 d=0;d<n.length-1;d++){const c=n[d],h=n[d+1];if(c!=null&&h!=null&&e>=c[0]&&e<=h[0]){o=c,s=h;break}}const l=s[0]===o[0]?0:(e-o[0])/(s[0]-o[0]),r=Math.round(o[1]+l*(s[1]-o[1])),i=Math.round(o[2]+l*(s[2]-o[2])),a=Math.round(o[3]+l*(s[3]-o[3]));return`rgb(${r},${i},${a})`}function Dr({grid:t,xRange:e,yRange:n,colorMap:o=_r,yScale:s="y"}){return St(({ctx:l,valToX:r,valToY:i})=>{var b;if(t.length===0)return;const a=t.length,d=((b=t[0])==null?void 0:b.length)??0;if(d===0)return;const c=(e==null?void 0:e[0])??0,h=(e==null?void 0:e[1])??a,u=(n==null?void 0:n[0])??0,f=(n==null?void 0:n[1])??d,g=(h-c)/a,w=(f-u)/d;let v=0;for(const y of t)for(const p of y)p>v&&(v=p);if(v!==0)for(let y=0;y<a;y++){const p=t[y];if(p==null)continue;const m=r(c+y*g),T=r(c+(y+1)*g);if(m==null||T==null)continue;const M=T-m;for(let C=0;C<d;C++){const I=p[C]??0,A=u+C*w,x=u+(C+1)*w,D=i(x,s),L=i(A,s);if(D==null||L==null)continue;const F=L-D;l.fillStyle=o(I/v),l.fillRect(m,D,M,F)}}}),null}function Fr(t,e,n,o,s){const l=(o-90)*(Math.PI/180),r=s,i=r*.35,a=Math.PI/6,d=e+Math.cos(l)*r,c=n+Math.sin(l)*r,h=e-Math.cos(l)*r*.5,u=n-Math.sin(l)*r*.5;t.beginPath(),t.moveTo(h,u),t.lineTo(d,c),t.stroke(),t.beginPath(),t.moveTo(d,c),t.lineTo(d-i*Math.cos(l-a),c-i*Math.sin(l-a)),t.moveTo(d,c),t.lineTo(d-i*Math.cos(l+a),c-i*Math.sin(l+a)),t.stroke()}function Rr({directions:t,group:e=0,index:n=0,color:o="#c0392b",minSize:s=4,maxSize:l=10}){const r=nt();return St(({ctx:i,valToX:a,valToY:d})=>{var b;const c=r.dataStore.data[e];if(c==null)return;const h=c.x,u=c.series[n];if(u==null)return;let f=1/0,g=-1/0;for(let y=0;y<u.length;y++){const p=u[y];p!=null&&(p<f&&(f=p),p>g&&(g=p))}const w=g-f||1,v=((b=r.seriesConfigs.find(y=>y.group===e&&y.index===n))==null?void 0:b.yScale)??"y";i.strokeStyle=o,i.lineWidth=1.5,i.lineCap="round";for(let y=0;y<h.length;y++){const p=u[y],m=t[y];if(p==null||m==null)continue;const T=a(h[y]),M=d(p,v);if(T==null||M==null)continue;const C=(p-f)/w,I=s+C*(l-s);Fr(i,T,M,m,I)}}),null}const Hr=4;function Me(t,e){t.strokeStyle=e.stroke??"red",t.lineWidth=e.width??1,e.dash&&t.setLineDash(e.dash)}function Ce(t,e){e.dash&&t.setLineDash([])}function Fn(t,e,n,o={}){const{ctx:s,plotBox:l}=t,r=X(n,e,l.height,l.top);s.beginPath(),s.moveTo(l.left,r),s.lineTo(l.left+l.width,r),Me(s,o),s.stroke(),Ce(s,o)}function Rn(t,e,n,o={}){const{ctx:s,plotBox:l}=t,r=X(n,e,l.width,l.left);s.beginPath(),s.moveTo(r,l.top),s.lineTo(r,l.top+l.height),Me(s,o),s.stroke(),Ce(s,o)}function Wr(t,e,n,o,s,l,r={}){const{ctx:i,plotBox:a}=t,d=X(o,e,a.width,a.left),c=X(s,n,a.height,a.top);i.font=r.font??"12px sans-serif",i.fillStyle=r.fill??"#000",i.textBaseline="bottom",i.fillText(l,d,c-Hr)}function Hn(t,e,n,o,s={}){const{ctx:l,plotBox:r}=t,i=X(o,e,r.height,r.top),a=X(n,e,r.height,r.top);l.fillStyle=s.fill??"rgba(255,0,0,0.1)",l.fillRect(r.left,Math.min(i,a),r.width,Math.abs(a-i)),s.stroke&&(Me(l,s),l.strokeRect(r.left,Math.min(i,a),r.width,Math.abs(a-i)),Ce(l,s))}function ke(t,e,n){const o=_.useRef(t);_.useLayoutEffect(()=>{o.current=t},[t]),St(s=>{const l=s.getScale(e);l!=null&&n(s,l,o.current)})}function zr(t){return ke(t,t.yScale??"y",(e,n,o)=>{if(Fn(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:l,plotBox:r}=e;l.font=o.labelFont??"11px sans-serif",l.fillStyle=o.stroke??"red",l.textAlign="left",l.textBaseline="bottom",l.fillText(o.label,r.left+4,s-4)}}),null}function $r(t){return ke(t,t.xScale??"x",(e,n,o)=>{if(Rn(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:l,plotBox:r}=e;l.font=o.labelFont??"11px sans-serif",l.fillStyle=o.stroke??"red",l.textAlign="center",l.textBaseline="bottom",l.fillText(o.label,s,r.top-4)}}),null}function Br(t){return ke(t,t.yScale??"y",(e,n,o)=>{Hn(e,n,o.yMin,o.yMax,{fill:o.fill,stroke:o.stroke,width:o.strokeWidth,dash:o.dash})}),null}function Gr(t){const e=_.useRef(t);return _.useLayoutEffect(()=>{e.current=t}),St(n=>{const o=e.current,s=n.valToX(o.x,o.xScale??"x"),l=n.valToY(o.y,o.yScale??"y");if(s==null||l==null)return;const{ctx:r}=n;r.font=o.font??"12px sans-serif",r.fillStyle=o.fill??"#000",r.textAlign=o.align??"left",r.textBaseline=o.baseline??"bottom",r.fillText(o.text,s,l-4)}),null}function Vr(t){const e=(n,o,s,l,r,i,a,d,c,h,u,f,g)=>{const w=(g==null?void 0:g.align)??t??1,v=(g==null?void 0:g.spanGaps)??!1;if([c,h]=Nt(o,c,h),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const b=x=>f(X(x,s,r,a)),y=x=>f(X(x,l,i,d)),p=s.ori===$.Horizontal?Ot:jt,m={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},T=m.stroke;let M=!1;const C=u===K.Forward?c:h;let I=y(o[C]),A=b(n[C]);p(T,A,I);for(let x=C;x>=c&&x<=h;x+=u){const D=o[x];if(D==null){D===null&&!v&&(M=!0);continue}const L=b(n[x]),F=y(D);if(w===1)p(T,L,I);else if(w===-1)p(T,A,F);else{const R=f((A+L)/2);p(T,R,I),p(T,R,F)}p(T,L,F),I=F,A=L}{const x=m.fill=new Path2D(T),D=(g==null?void 0:g.fillTo)??l.min??0,L=y(D);let F=b(n[c]),R=b(n[h]);u===K.Backward&&([R,F]=[F,R]),p(x,R,L),p(x,F,L)}if(M){const x=he(n,o,c,h,u,b);m.gaps=x,m.clip=ge(x,s.ori,a,d,r,i)}return m};return e.defaults=Yt,e}function Te(t){return t.defaults=io,t}function Ae(){return Te((e,n,o,s,l,r,i,a,d,c,h,u,f)=>{const g=(f==null?void 0:f.barWidth)??.6,w=(f==null?void 0:f.barGap)??0,v=(f==null?void 0:f.barRadius)??0,b=(f==null?void 0:f.barGroupIdx)??0,y=(f==null?void 0:f.barGroupCount)??1,p=R=>u(X(R,o,l,i)),m=R=>u(X(R,s,r,a));let T=l;if(c>d){let R=1/0,z=-1;for(let S=d;S<=c;S++)if(n[S]!=null){if(z>=0){const k=e[S],P=e[z],E=Math.abs(p(k)-p(P));E<R&&(R=E)}z=S}R<1/0&&(T=R)}const M=T*(1-g),C=Math.max(0,M+w),I=Math.max(1,u(T-C)),A=y>1?Math.max(1,u(I/Math.max(1,y))):I,x=(f==null?void 0:f.fillTo)??s.min??0,D=m(x),L=new Path2D,F=o.ori===$.Horizontal;for(let R=h===K.Forward?d:c;R>=d&&R<=c;R+=h){const z=n[R];if(z==null)continue;const S=p(e[R]),k=m(z),P=y>1?(b-(y-1)/2)*A:0,E=u(S-A/2+P),W=Math.min(k,D),V=Math.max(k,D)-W;if(V!==0)if(v>0){const N=Math.min(v*A,V/2);Yr(L,F,E,W,A,V,N,z<x)}else F?L.rect(E,W,A,V):L.rect(W,E,V,A)}return{stroke:L,fill:L,clip:null,band:null,gaps:null}})}function Xr(t,e){const n=Ae();return Te((s,l,r,i,a,d,c,h,u,f,g,w,v)=>{const b={...v,barGroupIdx:t,barGroupCount:e};return n(s,l,r,i,a,d,c,h,u,f,g,w,b)})}function Nr(){const t=Ae();return Te((n,o,s,l,r,i,a,d,c,h,u,f,g)=>{const w={barWidth:.8,...g};return t(n,o,s,l,r,i,a,d,c,h,u,f,w)})}function Yr(t,e,n,o,s,l,r,i){r=Math.min(r,s/2,l/2),e?i?(t.moveTo(n,o),t.lineTo(n+s,o),t.lineTo(n+s,o+l-r),t.arc(n+s-r,o+l-r,r,0,Math.PI/2),t.lineTo(n+r,o+l),t.arc(n+r,o+l-r,r,Math.PI/2,Math.PI),t.closePath()):(t.moveTo(n,o+l),t.lineTo(n,o+r),t.arc(n+r,o+r,r,Math.PI,Math.PI*1.5),t.lineTo(n+s-r,o),t.arc(n+s-r,o+r,r,Math.PI*1.5,0),t.lineTo(n+s,o+l),t.closePath()):i?(t.moveTo(o,n),t.lineTo(o,n+s),t.lineTo(o+l-r,n+s),t.arc(o+l-r,n+s-r,r,Math.PI/2,0,!0),t.lineTo(o+l,n+r),t.arc(o+l-r,n+r,r,0,-Math.PI/2,!0),t.closePath()):(t.moveTo(o+l,n),t.lineTo(o+r,n),t.arc(o+r,n+r,r,-Math.PI/2,Math.PI,!0),t.lineTo(o,n+s-r),t.arc(o+r,n+s-r,r,Math.PI,Math.PI/2,!0),t.lineTo(o+l,n+s),t.closePath())}function Wn(t){const e=(n,o,s,l,r,i,a,d,c,h,u,f,g)=>{const w=(g==null?void 0:g.spanGaps)??!1;if([c,h]=Nt(o,c,h),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=A=>f(X(A,s,r,a)),b=A=>f(X(A,l,i,d)),y=s.ori===$.Horizontal?Ot:jt,p=[],m=[];let T=!1;for(let A=u===K.Forward?c:h;A>=c&&A<=h;A+=u){const x=o[A];x!=null?(p.push(v(n[A])),m.push(b(x))):x===null&&!w&&(T=!0)}const M=s.ori===$.Horizontal,C=t(p,m,M,f),I={stroke:C??new Path2D,fill:null,clip:null,band:null,gaps:null};if(C!=null){const A=I.fill=new Path2D(C),x=(g==null?void 0:g.fillTo)??l.min??0,D=b(x);let L=v(n[c]),F=v(n[h]);u===K.Backward&&([F,L]=[L,F]),y(A,F,D),y(A,L,D)}if(T){const A=he(n,o,c,h,u,v);I.gaps=A,I.clip=ge(A,s.ori,a,d,r,i)}return I};return e.defaults=Yt,e}function Or(){return Wn(jr)}const jr=(t,e,n,o)=>{const s=t.length;if(s<2)return null;const l=new Path2D,r=t[0]??0,i=e[0]??0;if(n?l.moveTo(r,i):l.moveTo(i,r),s===2){const u=t[1]??0,f=e[1]??0;return n?l.lineTo(u,f):l.lineTo(f,u),l}const a=new Array(s),d=new Array(s-1),c=new Array(s-1),h=new Array(s-1);for(let u=0;u<s-1;u++)c[u]=(e[u+1]??0)-(e[u]??0),h[u]=(t[u+1]??0)-(t[u]??0),d[u]=h[u]!==0?(c[u]??0)/(h[u]??1):0;a[0]=d[0]??0;for(let u=1;u<s-1;u++){const f=d[u]??0,g=d[u-1]??0;if(f===0||g===0||g>0!=f>0)a[u]=0;else{const w=h[u]??1,v=h[u-1]??1;a[u]=3*(v+w)/((2*w+v)/g+(w+2*v)/f),isFinite(a[u]??0)||(a[u]=0)}}a[s-1]=d[s-2]??0;for(let u=0;u<s-1;u++){const f=h[u]??1,g=t[u]??0,w=e[u]??0,v=t[u+1]??0,b=e[u+1]??0,y=a[u]??0,p=a[u+1]??0,m=g+f/3,T=w+y*f/3,M=v-f/3,C=b-p*f/3;n?l.bezierCurveTo(m,T,M,C,v,b):l.bezierCurveTo(T,m,C,M,b,v)}return l};function Ur(){return Wn(Kr)}const Kr=(t,e,n,o)=>{const s=t.length;if(s<2)return null;const l=new Path2D,r=o(t[0]??0),i=o(e[0]??0);if(n?l.moveTo(r,i):l.moveTo(i,r),s===2){const a=o(t[1]??0),d=o(e[1]??0);return n?l.lineTo(a,d):l.lineTo(d,a),l}for(let a=0;a<s-1;a++){const d=a===0?0:a-1,c=t[d]??0,h=e[d]??0,u=t[a]??0,f=e[a]??0,g=t[a+1]??0,w=e[a+1]??0,v=a+2<s?t[a+2]??0:g,b=a+2<s?e[a+2]??0:w,y=Math.hypot(c-u,h-f),p=Math.hypot(u-g,f-w),m=Math.hypot(g-v,w-b),T=Math.sqrt(m),M=m,C=Math.sqrt(p),I=p,A=Math.sqrt(y),x=y,D=2*x+3*A*C+I,L=2*M+3*T*C+I,F=3*A*(A+C),R=3*T*(T+C);let z,S,k,P;if(F>0){const E=1/F;z=(-I*c+D*u+x*g)*E,S=(-I*h+D*f+x*w)*E}else z=u,S=f;if(R>0){const E=1/R;k=(M*u+L*g-I*v)*E,P=(M*f+L*w-I*b)*E}else k=g,P=w;n?l.bezierCurveTo(z,S,k,P,g,w):l.bezierCurveTo(S,z,P,k,w,g)}return l};function qr(t=4){const e=(n,o,s,l,r,i,a,d,c,h,u,f,g)=>{const w=m=>f(X(m,s,r,a)),v=m=>f(X(m,l,i,d)),b=t/2,y=new Path2D,p=s.ori===$.Horizontal;for(let m=u===K.Forward?c:h;m>=c&&m<=h;m+=u){const T=o[m];if(T==null)continue;const M=w(n[m]),C=v(T);p?(y.moveTo(M+b,C),y.arc(M,C,b,0,Math.PI*2)):(y.moveTo(C+b,M),y.arc(C,M,b,0,Math.PI*2))}return{stroke:y,fill:y,clip:null,band:null,gaps:null}};return e.defaults=ao,e}function Zr({group:t=0,series:e=[0,1,2,3],yScale:n="y",upColor:o="#26a69a",downColor:s="#ef5350",bodyWidth:l=.6,wickWidth:r=1}){const i=nt();return St(({ctx:a,plotBox:d,valToX:c,valToY:h})=>{const u=i.dataStore.data[t];if(u==null)return;const f=u.x,g=u.series[e[0]],w=u.series[e[1]],v=u.series[e[2]],b=u.series[e[3]];if(g==null||w==null||v==null||b==null)return;const y=f.length;if(y===0)return;const p=Math.max(2,d.width/y*l);for(let m=0;m<y;m++){const T=f[m],M=g[m],C=w[m],I=v[m],A=b[m];if(T==null||M==null||C==null||I==null||A==null)continue;const x=c(T),D=h(C,n),L=h(I,n),F=h(M,n),R=h(A,n);if(x==null||D==null||L==null||F==null||R==null)continue;const S=A>=M?o:s;Dn(a,x,D,L,F,R,p,null,{wickColor:S,wickWidth:r,bodyFill:S})}}),null}function Jr(t,e,n=0){const o=e??t.series.map((c,h)=>h),s=t.x.length,l=[],r=new Float64Array(s);for(let c=0;c<o.length;c++){const h=o[c];if(h==null)continue;const u=t.series[h];if(u==null)continue;const f=new Array(s);for(let g=0;g<s;g++){const w=u[g];w!=null?(r[g]=r[g]+w,f[g]=r[g]):f[g]=null}l.push(f)}const i=new Map;for(let c=0;c<o.length;c++){const h=o[c];h!=null&&i.set(h,c)}const a=[];for(let c=0;c<t.series.length;c++){const h=i.get(c)??-1,u=h>=0?l[h]:void 0;u!=null?a.push(u):a.push(t.series[c]??[])}const d=[];for(let c=o.length-1;c>0;c--){const h=o[c],u=o[c-1];h!=null&&u!=null&&d.push({group:n,series:[h,u]})}return{group:{x:t.x,series:a},bands:d}}function Qr(t){const e=new Set;for(const[l]of t)for(let r=0;r<l.length;r++){const i=l[r];i!=null&&e.add(i)}const n=Float64Array.from([...e].sort((l,r)=>l-r)),o=new Map;for(let l=0;l<n.length;l++){const r=n[l];r!=null&&o.set(r,l)}const s=[];for(const[l,r]of t){const i=new Array(n.length).fill(null);for(let a=0;a<l.length;a++){const d=l[a];if(d==null)continue;const c=o.get(d);c!=null&&(i[c]=r[a]??null)}s.push(i)}return[{x:n,series:s}]}function tl(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 el(t,e=0){return n=>n.map(o=>o.toFixed(e)+t)}function nl(t,e=0){return n=>n.map(o=>t+o.toFixed(e))}function ol(t,e,n=0){return o=>o.map(s=>t+s.toFixed(n)+e)}function sl(t){const e=(t==null?void 0:t.utc)??!1;return n=>n.map(o=>e?it(o,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):it(o,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function rl(t){const e=t!=null&&t.utc?"UTC":void 0,n=(t==null?void 0:t.format)??"short";return o=>o.map(s=>it(s,{month:n},e))}function ll(t){const{tz:e,...n}=t??{};return o=>o.map(s=>it(s,n,e))}function il(t,e=0){return n=>n.map(o=>{const s=Math.round(o)-e;return t[s]??String(o)})}exports.AnnotationLabel=Gr;exports.Axis=Wt;exports.Band=zs;exports.BoxWhisker=Er;exports.Candlestick=Zr;exports.Chart=we;exports.DEFAULT_ACTIONS=Xt;exports.Direction=K;exports.Distribution=q;exports.FloatingLegend=Lr;exports.HLine=zr;exports.Heatmap=Dr;exports.HoverLabel=Pr;exports.Legend=Os;exports.Orientation=$;exports.Region=Br;exports.Scale=Ds;exports.Series=ve;exports.Side=j;exports.SortOrder=Lt;exports.Sparkline=kr;exports.Timeline=Cr;exports.Tooltip=mr;exports.VLine=$r;exports.Vector=Rr;exports.ZoomRanger=xr;exports.alignData=Qr;exports.bars=Ae;exports.catmullRom=Ur;exports.drawHLine=Fn;exports.drawLabel=Wr;exports.drawRegion=Hn;exports.drawVLine=Rn;exports.fadeGradient=Rs;exports.fmtCompact=tl;exports.fmtDateStr=ll;exports.fmtHourMin=sl;exports.fmtLabels=il;exports.fmtMonthName=rl;exports.fmtPrefix=nl;exports.fmtSuffix=el;exports.fmtWrap=ol;exports.focus=Bn;exports.groupedBars=Xr;exports.linear=xn;exports.lttb=pe;exports.lttbGroup=ho;exports.monotoneCubic=Or;exports.palette=Hs;exports.points=qr;exports.posToVal=ft;exports.sideOrientation=Ct;exports.stackGroup=Jr;exports.stackedBars=Nr;exports.stepped=Vr;exports.useChart=ds;exports.useCursorDrawHook=Mr;exports.useDrawHook=St;exports.valToPos=X;exports.withAlpha=Pn;
1
+ "use strict";var lo=Object.defineProperty;var ro=(t,e,n)=>e in t?lo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Y=(t,e,n)=>ro(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),D=require("react"),$e=require("@chenglou/pretext");function io(t=.15){return e=>{e.focusAlpha=t}}const Kt=[["leftDrag","zoomX"],["leftDblclick","reset"],["wheel","zoomX"],["xGutterDrag","panX"],["yGutterDrag","panY"],["pinch","zoomX"],["touchDrag","zoomX"]];var K=(t=>(t[t.Top=0]="Top",t[t.Right=1]="Right",t[t.Bottom=2]="Bottom",t[t.Left=3]="Left",t))(K||{}),G=(t=>(t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical",t))(G||{}),Z=(t=>(t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward",t))(Z||{}),Q=(t=>(t[t.Linear=1]="Linear",t[t.Ordinal=2]="Ordinal",t[t.Log=3]="Log",t[t.Asinh=4]="Asinh",t))(Q||{}),Et=(t=>(t[t.Ascending=1]="Ascending",t[t.Descending=-1]="Descending",t[t.Unsorted=0]="Unsorted",t))(Et||{});function Ft(t){return t%2===0?0:1}var lt=(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))(lt||{});function Be(t){if(t==="transparent")return!0;const e=t.match(/,\s*([\d.]+)\s*\)$/);return!!(e!=null&&e[1]!=null&&parseFloat(e[1])===0||t.startsWith("#")&&(t.length===5&&t[4]==="0"||t.length===9&&t.slice(7)==="00"))}function Ve(t){if(typeof t=="string")return t;if(t!=null&&t.stops.length>0){const e=t.stops[0];if(e!=null)return e[1]}return null}function Ht(t){var l,i;const e=Ve(t.stroke),n=Ve(t.fill),o=e!=null&&!Be(e),s=n!=null&&!Be(n);return((i=(l=t.paths)==null?void 0:l.defaults)==null?void 0:i.width)===0&&s||!o&&s?n:e??"#000"}const it=Math,le=it.PI,at=it.abs,ft=it.floor,X=it.round,zt=it.ceil,pe=it.min,It=it.max,kt=it.pow,Ge=it.sign,ct=it.log10,_t=it.log2,ao=(t,e=1)=>it.sinh(t)*e,ve=(t,e=1)=>it.asinh(t/e),st=1/0,yn=Number.isInteger;function re(t,e){return t[e]??0}function bt(t,e,n=0,o=e.length-1){let s;const r=o<=2147483647;for(;o-n>1;)s=r?n+o>>1:ft((n+o)/2),re(e,s)<t?n=s:o=s;return t-re(e,n)<=re(e,o)-t?n:o}const xn=t=>t!=null,Mn=t=>t!=null&&t>0;function kn(t){return(e,n,o)=>{let s=-1,r=-1;for(let l=n;l<=o;l++)if(t(e[l])){s=l;break}for(let l=o;l>=n;l--)if(t(e[l])){r=l;break}return[s,r]}}const Jt=kn(xn),Cn=kn(Mn);function co(t,e,n,o=Et.Unsorted,s=!1){const r=s?Cn:Jt,l=s?Mn:xn,[i,a]=r(t,e,n);let u=t[i]??st,c=t[i]??-st;if(i>-1)if(o===Et.Ascending)u=t[i]??st,c=t[a]??-st;else if(o===Et.Descending)u=t[a]??st,c=t[i]??-st;else for(let d=i;d<=a;d++){const f=t[d];f!=null&&l(f)&&(f<u?u=f:f>c&&(c=f))}return[u,c]}function dt(t,e=0){if(yn(t))return t;const n=10**e,o=t*n*(1+Number.EPSILON);return X(o)/n}const Dt=new Map;function uo(t){return(String(t).split(".")[1]??"").length}const fo=/\.\d*?(?=9{6,}|0{6,})/gm;function Tt(t){if(yn(t)||Dt.has(t))return t;const e=`${t}`,n=e.match(fo);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",l=s[1]??"0";return+`${Tt(+r)}e${l}`}return dt(t,o)}function ho(t,e,n=!0){return n?Tt(dt(Tt(t/e))*e):dt(t/e)*e}function be(t,e,n=!0){return n?Tt(zt(Tt(t/e))*e):zt(t/e)*e}function Tn(t,e,n=!0){return n?Tt(ft(Tt(t/e))*e):ft(t/e)*e}function go(t){return t===0?e=>e:t===1?X:e=>ho(e,t)}function Fn(t,e,n,o){const s=[],r=o.map(uo);for(let l=e;l<n;l++){const i=at(l);for(let a=0;a<o.length;a++){const u=o[a]??0,c=r[a]??0,d=+`${u}e${l}`,f=(l>=0?0:i)+(l>=c?0:c),h=d;s.push(h),Dt.set(h,f)}}return s}function rt(t,e,n){return pe(It(t,e),n)}const Ne=new Map;function An(t,e){const n=e??"";let o=Ne.get(n);return o==null&&(o=new Intl.NumberFormat(e),Ne.set(n,o)),o.format(t)}function je(t,e,n){for(;e<=n;){if(t[e]!=null)return!0;e++}return!1}const po=.1,mt={mode:3,pad:po,soft:null},Rt={pad:0,soft:null,mode:0},mo={min:Rt,max:Rt};function ie(t,e,n,o){let s;typeof n=="number"?(Rt.pad=n,Rt.soft=null,Rt.mode=0,s=mo):s=n;const r=s.min,l=s.max,i=r.pad,a=l.pad,u=r.hard??-st,c=l.hard??st,d=r.soft??st,f=l.soft??-st,h=r.mode,p=l.mode;let w=e-t;const m=ct(w),v=It(at(t),at(e)),M=ct(v),k=at(M-m);(w<1e-24||k>10)&&(w=0,(t===0||e===0)&&(w=1e-24));const F=w||v||1e3,C=ct(F),L=kt(10,ft(C)),g=F*(w===0?t===0?.1:1:i),S=dt(Tn(t-g,L/10),24),y=h===1||h===3&&S<=d||h===2&&S>=d,b=t>=d&&y?d:st,P=It(u,S<b&&t>=b?b:pe(b,S)),A=F*(w===0?e===0?.1:1:a),E=dt(be(e+A,L/10),24),W=p===1||p===3&&E>=f||p===2&&E<=f,H=e<=f&&W?f:-st,x=pe(c,E>H&&e<=H?H:It(H,E));return P===x&&P===0?[-1,1]:[P,x]}function Ln(t,e,n,o){n===2&&(o=!0);const s=Ge(t),r=Ge(e);t===e&&(s===-1?(t*=n,e/=n):(t/=n,e*=n));const l=n===10?ct:_t,i=s===1?ft:zt,a=r===1?zt:ft,u=l(at(t)),c=l(at(e)),d=i(u),f=a(c);let h=kt(n,d),p=kt(n,f);return n===10&&(d<0&&(h=dt(h,-d)),f<0&&(p=dt(p,-f))),o?(t=h*s,e=p*r):(t=Tn(t,kt(n,ft(u)),!1),e=be(e,kt(n,ft(c)),!1)),[t,e]}function wo(t,e,n,o){const s=Ln(t,e,n,o);return t===0&&(s[0]=0),e===0&&(s[1]=0),s}function Xe(t){return(ct((t^t>>31)-(t>>31))|0)+1}function So(t,e,n,o,s){const r=It(Xe(t),Xe(e)),l=e-t;let i=It(0,bt(s/o*l,n)-1);do{const a=n[i]??0,u=o*a/l;if(u>=s*.9&&r+(a<5?Dt.get(a)??0:0)<=17)return[a,u]}while(++i<n.length);return[0,0]}function vo(t){return{id:t.id,min:t.min??null,max:t.max??null,distr:t.distr??Q.Linear,log:t.log??10,asinh:t.asinh??1,ori:t.ori??(t.id==="x"?G.Horizontal:G.Vertical),dir:t.dir??Z.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 q(t){return t.min!=null&&t.max!=null}function ht(t){t._min=null,t._max=null}function Pn(t){if(t._min!=null)return t._min;const{min:e,distr:n}=t;if(e==null)return 0;if(n===Q.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?ct:_t)(o)}else n===Q.Asinh?t._min=ve(e,t.asinh):t._min=e;return t._min}function En(t){if(t._max!=null)return t._max;const{max:e,distr:n}=t;if(e==null)return 0;if(n===Q.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?ct:_t)(o)}else n===Q.Asinh?t._max=ve(e,t.asinh):t._max=e;return t._max}function bo(t,e){if(e.min==null||e.max==null)return 0;const n=Pn(e),s=En(e)-n;if(s===0)return 0;const{distr:r}=e;if(r===Q.Log){const l=e.log===10?ct:_t,i=t>0?t:1e-10;return(l(i)-n)/s}return r===Q.Asinh?(ve(t,e.asinh)-n)/s:(t-n)/s}function yo(t,e){if(e.min==null||e.max==null)return 0;const n=Pn(e),o=En(e);if(o===n)return e.min;const{distr:s}=e;return s===Q.Log?Math.pow(e.log,n+t*(o-n)):s===Q.Asinh?ao(n+t*(o-n),e.asinh):n+t*(o-n)}function U(t,e,n,o){const s=bo(t,e);let r;return e.ori===G.Horizontal?r=e.dir===Z.Forward?s:1-s:r=e.dir===Z.Forward?1-s:s,o+r*n}function gt(t,e,n,o){if(n===0)return e.min??0;let s=(t-o)/n;return e.ori===G.Horizontal?e.dir===Z.Backward&&(s=1-s):e.dir!==Z.Backward&&(s=1-s),yo(s,e)}function V(t,e){return t[e]}class xo{constructor(){Y(this,"scales",new Map);Y(this,"groupXScales",new Map)}addScale(e){this.scales.set(e.id,vo(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,ht(s))}autoRangeX(e){var o,s,r,l,i,a;const n=new Map;for(const[u,c]of this.groupXScales){const d=this.scales.get(c);if(!d||!d.auto)continue;const f=e[u];if(!f||f.x.length===0)continue;const h=f.x[0],p=f.x[f.x.length-1];if(h==null||p==null)continue;const w=n.get(c);w?(w.dataMin=Math.min(w.dataMin,h),w.dataMax=Math.max(w.dataMax,p),w.groups.push(u)):n.set(c,{dataMin:h,dataMax:p,groups:[u]})}for(const[u,{dataMin:c,dataMax:d,groups:f}]of n){const h=this.scales.get(u);if(!h)continue;let p=!0,w=st;for(const m of f){const v=e[m];if(v){for(let M=0;M<v.x.length;M++)if(Number.isInteger(v.x[M])||(p=!1),M>0){const k=V(v.x,M)-V(v.x,M-1);k>0&&k<w&&(w=k)}}}if(h._discrete=p,h.range){const[m,v]=ie(c,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:((l=h.range.max)==null?void 0:l.pad)??0,soft:((i=h.range.max)==null?void 0:i.soft)??null,mode:((a=h.range.max)==null?void 0:a.mode)??0}});h.min=m,h.max=v}else if(c===d)[h.min,h.max]=ie(c,d,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}});else if(w<st){const m=w/2;h.min=c-m,h.max=d+m}else h.min=c,h.max=d;h._cfgMin!=null&&(h.min=h._cfgMin),h._cfgMax!=null&&(h.max=h._cfgMax),ht(h)}}autoRange(e,n,o){var l,i,a,u,c,d;const s=new Map,r=new Map;for(const{group:f,index:h,yScale:p}of n){const w=e[f];if(!w)continue;const m=w.series[h];if(!m||m.length===0)continue;const v=o.windows.get(f),M=v?v[0]:0,k=v?v[1]:m.length-1,F=this.scales.get(p),C=(F==null?void 0:F.distr)===Q.Log,[L,g]=o.getCachedMinMax(f,h,M,k,0,C),S=s.get(p),y=r.get(p);s.set(p,S!=null?Math.min(S,L):L),r.set(p,y!=null?Math.max(y,g):g)}for(const[f,h]of s){const p=this.scales.get(f);if(!p||!p.auto)continue;const w=r.get(f)??-st;if(h===st)continue;let m,v;if(p.distr===Q.Log)[m,v]=Ln(h,w,p.log,!1);else if(p.distr===Q.Asinh)[m,v]=wo(h,w,p.log,!1);else{const M=p.range??{min:mt,max:mt};[m,v]=ie(h,w,{min:{pad:((l=M.min)==null?void 0:l.pad)??mt.pad,soft:((i=M.min)==null?void 0:i.soft)??mt.soft,mode:((a=M.min)==null?void 0:a.mode)??mt.mode},max:{pad:((u=M.max)==null?void 0:u.pad)??mt.pad,soft:((c=M.max)==null?void 0:c.soft)??mt.soft,mode:((d=M.max)==null?void 0:d.mode)??mt.mode}})}p._cfgMin!=null&&(m=p._cfgMin),p._cfgMax!=null&&(v=p._cfgMax),p.min=m,p.max=v,ht(p)}}}const Mo=1024;class ko{constructor(e,n=Mo){Y(this,"blocks");Y(this,"nBlocks");Y(this,"blockSize");Y(this,"data");Y(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 l=0;l<o;l++){const i=l*n,a=Math.min(i+n,r);let u=1/0,c=-1/0;for(let d=i;d<a;d++){const f=e[d];f!=null&&(f<u&&(u=f),f>c&&(c=f))}s[l*2]=u,s[l*2+1]=c}}rangeMinMax(e,n){const{data:o,blockSize:s,blocks:r}=this;let l=1/0,i=-1/0;const a=Math.floor(e/s),u=Math.floor(n/s);if(a===u){for(let f=e;f<=n;f++){const h=o[f];h!=null&&(h<l&&(l=h),h>i&&(i=h))}return[l,i]}const c=(a+1)*s-1;for(let f=e;f<=c;f++){const h=o[f];h!=null&&(h<l&&(l=h),h>i&&(i=h))}for(let f=a+1;f<u;f++){const h=r[f*2]??1/0,p=r[f*2+1]??-1/0;h<l&&(l=h),p>i&&(i=p)}const d=u*s;for(let f=d;f<=n;f++){const h=o[f];h!=null&&(h<l&&(l=h),h>i&&(i=h))}return[l,i]}updateBlock(e){const{data:n,blockSize:o,blocks:s,len:r}=this;if(e>=this.nBlocks)return;const l=e*o,i=Math.min(l+o,r);let a=1/0,u=-1/0;for(let c=l;c<i;c++){const d=n[c];d!=null&&(d<a&&(a=d),d>u&&(u=d))}s[e*2]=a,s[e*2+1]=u}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 Co{constructor(){Y(this,"data",[]);Y(this,"windows",new Map);Y(this,"minMaxCache",new Map);Y(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 l=r.series[n];if(!(!l||l.length===0))return s=new ko(l),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],l=e(s),i=this.windows.get(s);let a,u;if(!r||!l||!q(l))a=0,u=Math.max(0,((r==null?void 0:r.x.length)??1)-1);else{const c=r.x;if(c.length===0)a=0,u=0;else{a=bt(l.min,c),u=bt(l.max,c);const d=c[a],f=c[u];a>0&&d!=null&&d>l.min&&a--,u<c.length-1&&f!=null&&f<l.max&&u++}}(!i||i[0]!==a||i[1]!==u)&&(n=!0,(o=this.minMaxCache.get(s))==null||o.clear()),this.windows.set(s,[a,u])}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 s;const o=(s=this.data[e])==null?void 0:s.series[n];return o||[]}getCachedMinMax(e,n,o,s,r,l){let i=this.minMaxCache.get(e);const a=`${n}:${o}:${s}`;if(i){const h=i.get(a);if(h!=null)return h}else i=new Map,this.minMaxCache.set(e,i);const u=this.data[e];if(!u)return[1/0,-1/0];const c=u.series[n];if(!c||c.length===0)return[1/0,-1/0];let d;const f=!l&&r===Et.Unsorted?this.getOrBuildTree(e,n):void 0;return f?d=f.rangeMinMax(o,s):d=co(c,o,s,r,l),i.set(a,d),d}getBlockTree(e,n){return this.getOrBuildTree(e,n)}appendData(e,n,o){var l;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 i=0;i<n.length;i++){const a=n[i];a!=null&&r.push(a)}for(let i=0;i<s.series.length;i++){const a=s.series[i];if(!a)continue;let u;Array.isArray(a)?u=a:(u=Array.from(a),s.series[i]=u);const c=o[i];if(c)for(let f=0;f<c.length;f++)u.push(c[f]??null);const d=this.blockTrees.get(`${e}:${i}`);d&&(d.setData(u),d.grow(u.length))}(l=this.minMaxCache.get(e))==null||l.clear()}static toTypedX(e){for(const n of e)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return e}}const Gt=-10;class To{constructor(){Y(this,"state",{left:Gt,top:Gt,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1});Y(this,"_groupedConfigs",new Map);Y(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=Gt,this.state.top=Gt,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(e,n,o,s,r,l,i,a){this.state.left=e,this.state.top=n;let u=1/0,c=-1,d=-1,f=-1;const h=this.getGroupedConfigs(r);for(let p=0;p<s.length;p++){const w=s[p];if(w==null)continue;const m=w.x;if(m.length===0)continue;const v=a(p);if(v==null)continue;const M=l(v);if(M==null||!q(M))continue;const[k,F]=i(p),C=o.width,L=o.left,g=gt(e+L,M,C,L),S=bt(g,m,k,F),y=[S];S>k&&y.push(S-1),S<F&&y.push(S+1);const b=new Map;for(const P of y){const A=m[P];if(A==null)continue;const E=U(A,M,C,L);for(const W of h.get(p)??[]){const H=w.series[W.index];if(H==null)continue;const x=H[P];if(x==null)continue;let T=b.get(W.yScale);if(T==null&&!b.has(W.yScale)&&(T=l(W.yScale),b.set(W.yScale,T)),T==null||!q(T))continue;const I=o.height,_=o.top,$=U(x,T,I,_),R=e+L-E,N=n+_-$,z=R*R+N*N;if(z<u&&(u=z,c=p,d=W.index,f=P,z===0))break}if(u===0)break}}this.state.activeGroup=c,this.state.activeSeriesIdx=d,this.state.activeDataIdx=f}syncToValue(e,n,o=0){const s=n.dataStore.data;if(s.length===0)return;const r=o<s.length?o:0,l=s[r];if(l==null)return;const i=n.scaleManager.getGroupXScaleKey(r);if(i==null)return;const a=n.scaleManager.getScale(i);if(a==null||!q(a))return;const[u,c]=n.dataStore.getWindow(r),d=bt(e,l.x,u,c),f=l.x[d];if(f==null)return;const h=U(f,a,n.plotBox.width,n.plotBox.left);this.state.left=h-n.plotBox.left,this.state.activeGroup=r,this.state.activeDataIdx=d;let p=0,w=n.plotBox.height/2;for(const m of n.seriesConfigs){if(m.group!==r||m.show===!1)continue;const v=l.series[m.index];if(v==null)continue;const M=v[d];if(M==null)continue;const k=n.scaleManager.getScale(m.yScale);if(!(k==null||!q(k))){w=U(M,k,n.plotBox.height,n.plotBox.top)-n.plotBox.top,p=m.index;break}}this.state.top=w,this.state.activeSeriesIdx=p}}class Fo{constructor(){Y(this,"flags",lt.None);Y(this,"frameId",null);Y(this,"callback",null);Y(this,"consumed",lt.None)}mark(e){this.flags|=e,this.scheduleFrame()}has(e){return((this.flags|this.consumed)&e)!==0}get dirty(){return this.flags|this.consumed}clear(){this.flags=lt.None}onRedraw(e){this.callback=e}scheduleFrame(){this.frameId==null&&(this.frameId=requestAnimationFrame(()=>{this.frameId=null,this.consumed=this.flags,this.flags=lt.None;const e=this.callback;e!=null&&e(),this.consumed=lt.None}))}cancel(){this.frameId!=null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}dispose(){this.cancel(),this.callback=null,this.flags=lt.None}}const Qt={width:1},Ao={width:0,fill:"auto",fillTo:0,points:{show:!1},cursor:{show:!1}},Lo={width:0,cursor:{show:!1}};function te(t,e,n){t.lineTo(e,n)}function ee(t,e,n){t.lineTo(n,e)}function ye(t,e,n,o,s,r){const l=[];let i=-1;const a=s===Z.Forward?n:o,u=s===Z.Forward?o:n,c=s;for(let d=a;s===Z.Forward?d<=u:d>=u;d+=c)if(e[d]===null||e[d]===void 0){if(i===-1){const f=rt(d-s,n,o);i=r(V(t,f))}}else i!==-1&&(l.push([i,r(V(t,d))]),i=-1);return i!==-1&&l.push([i,r(V(t,o))]),l}function xe(t,e,n,o,s,r){const l=new Path2D;let i=e===G.Horizontal?n:o;const a=e===G.Horizontal?n+s:o+r,u=e===G.Horizontal?o:n,c=e===G.Horizontal?r:s;for(const[d,f]of t)d>i&&(e===G.Horizontal?l.rect(i,u,d-i,c):l.rect(u,i,c,d-i)),i=f;return i<a&&(e===G.Horizontal?l.rect(i,u,a-i,c):l.rect(u,i,c,a-i)),l}function In(t){return(e,n,o,s,r,l)=>{o!==s&&(r!==o&&l!==o&&t(e,n,o),r!==s&&l!==s&&t(e,n,s),t(e,n,l))}}const Po=In(te),Eo=In(ee);function Dn(){const t=(e,n,o,s,r,l,i,a,u,c,d,f,h)=>{const p=(h==null?void 0:h.spanGaps)??!1;if([u,c]=(s.distr===Q.Log?Cn:Jt)(n,u,c),u===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const m=S=>f(U(S,o,r,i)),v=S=>f(U(S,s,l,a));let M,k;o.ori===G.Horizontal?(M=te,k=Po):(M=ee,k=Eo);const F={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},C=F.stroke;let L=!1;if(c-u>=r*4){const S=T=>gt(T,o,r,i);let y=null,b=0,P=0,A=0,E=m(V(e,d===Z.Forward?u:c));const W=m(V(e,u)),H=m(V(e,c));let x=S(d===Z.Forward?W+1:H-1);for(let T=d===Z.Forward?u:c;T>=u&&T<=c;T+=d){const I=V(e,T),$=(d===Z.Forward?I<x:I>x)?E:m(I),R=n[T];$===E?R!=null?(A=R,y==null?(M(C,$,v(A)),P=y=b=A):A<y?y=A:A>b&&(b=A)):R===null&&!p&&(L=!0):(y!=null&&k(C,E,v(y),v(b),v(P),v(A)),R!=null?(A=R,M(C,$,v(A)),y=b=P=A):(y=null,b=0,R===null&&!p&&(L=!0)),E=$,x=S(E+d))}y!=null&&(y!==b?k(C,E,v(y),v(b),v(P),v(A)):M(C,E,v(A)))}else for(let S=d===Z.Forward?u:c;S>=u&&S<=c;S+=d){const y=n[S];y===null&&!p?L=!0:y!=null&&M(C,m(V(e,S)),v(y))}{const S=F.fill=new Path2D(C),y=h==null?void 0:h.fillToData;if(y!=null)for(let b=d===Z.Forward?c:u;b>=u&&b<=c;b-=d){const P=y[b],A=e[b];P!=null&&A!=null&&M(S,m(A),v(P))}else{const b=(h==null?void 0:h.fillTo)??s.min??0,P=v(b);let A=m(V(e,u)),E=m(V(e,c));d===Z.Backward&&([E,A]=[A,E]),M(S,E,P),M(S,A,P)}}if(L){const S=ye(e,n,u,c,d,m);F.gaps=S,F.clip=xe(S,o.ori,i,a,r,l)}return F};return t.defaults=Qt,t}function Me(t,e,n){const o=t.length;if(n=Math.max(2,Math.round(n)),o<=n){const f=new Uint32Array(o),h=new Float64Array(o),p=new Array(o);for(let w=0;w<o;w++)f[w]=w,h[w]=V(t,w),p[w]=e[w]??null;return{indices:f,x:h,y:p}}const s=[];let r=-1,l=0;for(let f=0;f<o;f++)e[f]!=null?(r===-1&&(r=f),l++):r!==-1&&(s.push([r,f-1]),r=-1);if(r!==-1&&s.push([r,o-1]),l===0)return{indices:new Uint32Array(0),x:new Float64Array(0),y:[]};if(l<=n){const f=new Uint32Array(l),h=new Float64Array(l),p=new Array(l);let w=0;for(let m=0;m<o;m++)e[m]!=null&&(f[w]=m,h[w]=V(t,m),p[w]=V(e,m),w++);return{indices:f,x:h,y:p}}const i=[];for(const[f,h]of s){const p=h-f+1,w=Math.max(2,Math.round(n*(p/l))),m=Io(t,e,f,h,w);for(const v of m)i.push(v)}const a=i.length,u=new Uint32Array(a),c=new Float64Array(a),d=new Array(a);for(let f=0;f<a;f++){const h=V(i,f);u[f]=h,c[f]=V(t,h),d[f]=V(e,h)}return{indices:u,x:c,y:d}}function Io(t,e,n,o,s){const r=o-n+1;if(r<=s){const c=[];for(let d=n;d<=o;d++)c.push(d);return c}const l=[];l.push(n);const i=s-2,a=(r-2)/i;let u=n;for(let c=0;c<i;c++){const d=n+1+Math.floor(c*a),f=Math.min(n+1+Math.floor((c+1)*a)-1,o-1);let h=0,p=0,w=0;if(c<i-1){const F=n+1+Math.floor((c+1)*a),C=Math.min(n+1+Math.floor((c+2)*a)-1,o-1);for(let L=F;L<=C;L++)h+=V(t,L),p+=V(e,L)??0,w++}else h=V(t,o),p=V(e,o)??0,w=1;w>0&&(h/=w,p/=w);const m=V(t,u),v=V(e,u)??0;let M=d,k=-1;for(let F=d;F<=f;F++){const C=V(t,F),L=V(e,F)??0,g=Math.abs(m*(L-p)+C*(p-v)+h*(v-L));g>k&&(k=g,M=F)}l.push(M),u=M}return l.push(o),l}function Do(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 a of t.series){const u=Me(t.x,a,e);for(let c=0;c<u.indices.length;c++)o.add(V(u.indices,c))}const s=Array.from(o).sort((a,u)=>a-u),r=s.length,l=new Float64Array(r);for(let a=0;a<r;a++)l[a]=V(t.x,V(s,a));const i=[];for(const a of t.series)if(Array.isArray(a)&&a.some(c=>c===null)){const c=new Array(r);for(let d=0;d<r;d++)c[d]=a[V(s,d)]??null;i.push(c)}else{const c=new Float64Array(r);for(let d=0;d<r;d++)c[d]=V(a,V(s,d))??0;i.push(c)}return{x:l,series:i}}function _o(t){const n=Dn(),o=(s,r,l,i,a,u,c,d,f,h,p,w,m)=>{const v=h-f+1,M=Math.round(a*1);if(v>M*2&&(m==null?void 0:m.fillToData)==null){const k=h-f+1,F=new Float64Array(k),C=new Array(k);for(let g=0;g<k;g++)F[g]=V(s,f+g),C[g]=r[f+g]??null;const L=Me(F,C,M);return n(L.x,L.y,l,i,a,u,c,d,0,L.x.length-1,p,w,m)}return n(s,r,l,i,a,u,c,d,f,h,p,w,m)};return o.defaults=Qt,o}const Oe=new WeakMap;function Ue(t,e,n){return typeof e=="string"?e:Wo(t,e,n)}function Wo(t,e,n){const o=Oe.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,l]of e.stops)s.addColorStop(r,l);return Oe.set(e,{grad:s,left:n.left,top:n.top,width:n.width,height:n.height}),s}function Ro(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 l=s??{left:0,top:0,width:t.canvas.width/o,height:t.canvas.height/o};if(e.fill&&n.fill&&(t.fillStyle=Ue(t,e.fill,l),t.fill(n.fill)),e.stroke){const i=(e.width??1)*o;t.strokeStyle=Ue(t,e.stroke,l),t.lineWidth=i,t.lineJoin=e.join??"round",t.lineCap=e.cap??"butt",e.dash&&t.setLineDash(e.dash.map(d=>d*o));const a=e.pxAlign??0,u=i%2/2;a===1&&u>0&&t.translate(u,u),t.stroke(n.stroke)}t.restore()}const Ho=_o(),Ye=64;class zo{constructor(){Y(this,"ctx",null);Y(this,"pxRatio",1);Y(this,"pathCache",new Map);Y(this,"bandCache",new Map);Y(this,"scaleStamp","");Y(this,"snapshotCanvas",null);Y(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),l=this.pathCache.get(r);if(l!=null)return this.promote(r,l),l;const i=`${e}:${n}:`;for(const[a,u]of this.pathCache){if(!a.startsWith(i))continue;const c=a.slice(i.length),d=c.indexOf(":"),f=+c.slice(0,d),h=+c.slice(d+1);if(f<=o&&h>=s)return this.promote(a,u),u}}setCachedPaths(e,n,o,s,r){if(this.pathCache.size>=Ye){const i=Ye>>2,a=this.pathCache.keys();for(let u=0;u<i;u++){const c=a.next().value;c!=null&&this.pathCache.delete(c)}}const l=this.cacheKey(e,n,o,s);this.pathCache.delete(l),this.pathCache.set(l,r)}invalidateSeries(e,n){const o=`${e}:${n}:`;for(const l of this.pathCache.keys())l.startsWith(o)&&this.pathCache.delete(l);const s=`${e}:`,r=String(n);for(const l of this.bandCache.keys()){if(!l.startsWith(s))continue;const i=l.split(":");(i[1]===r||i[2]===r)&&this.bandCache.delete(l)}}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,l){return`${e}:${n}:${o}:${s}:${r}:${l}`}getCachedBandPath(e,n,o,s,r,l){return this.bandCache.get(this.bandKey(e,n,o,s,r,l))}setCachedBandPath(e,n,o,s,r,l,i){this.bandCache.set(this.bandKey(e,n,o,s,r,l),i)}drawSeries(e,n,o){const s=this.ctx;if(s==null||e.config.show===!1)return;const r=e.config.group,l=e.config.index,[i,a]=e.window;let u=this.getCachedPaths(r,l,i,a);if(u==null){const c=e.config.paths??Ho,d=e.xScale.dir,f=go(e.config.pxAlign??0),h=a-i,p=Math.max(1,Math.ceil(h*.1)),w=e.dataX.length,m=Math.max(0,i-p),v=Math.min(w-1,a+p),M=e.config.fillTo;let k;typeof M=="function"?k=M(e.yScale.min??0,e.yScale.max??0):M===0&&e.yScale.distr===Q.Log?k=1:k=M,u=c(e.dataX,e.dataY,e.xScale,e.yScale,n.width,n.height,n.left,n.top,m,v,d,f,{fillTo:k,fillToData:e.config.fillToData,spanGaps:e.config.spanGaps}),this.setCachedPaths(r,l,m,v,u)}Ro(s,e.config,u,o,n)}draw(e,n,o,s){const r=this.ctx;if(r==null)return;const l=this.pxRatio;r.clearRect(0,0,e*l,n*l),r.save(),r.scale(l,l),r.beginPath(),r.rect(o.left,o.top,o.width,o.height),r.clip();for(const i of s)this.drawSeries(i,o,1);r.restore()}}const _n=[1,2,2.5,5],$o=Fn(10,-32,0,_n),Bo=Fn(10,0,32,_n),xt=$o.concat(Bo);function Vo(t,e,n,o,s){if(n<=0||e<t)return[];const r=[],l=Dt.get(n)??0,i=s?Math.ceil(t/n)*n:dt(be(t,n),l);for(let a=i;a<=e;a=dt(a+n,l))r.push(Object.is(a,-0)?0:a);return r}function ae(t,e){return t.map(n=>An(n,e))}function Go(t,e,n){if(t<=0||e<=0||t>=e)return[];const o=[],r=ft((n===10?ct:_t)(t));let l=kt(n,r);n===10&&(l=xt[bt(l,xt)]??l);let i=l,a=l*n;n===10&&(a=xt[bt(a,xt)]??a);let u=0;do{if(i>=t&&o.push(i),i=i+l,n===10&&!Dt.has(i)){const c=Dt.get(l)??0;i=dt(i,c)}i>=a*(1-1e-10)&&(l=i,a=l*n,n===10&&(a=xt[bt(a,xt)]??a))}while(i<=e&&++u<1e4);return o}function No(t,e,n=1){const o=[];if(Math.max(at(t),at(e))===0)return[0];if(t<0){const l=at(t);let i=kt(10,ft(ct(Math.max(l,n))));for(;i>=n;){const a=-i;a>=t&&a<=e&&o.push(a),i/=10}}if(t<=0&&e>=0&&o.push(0),e>0){let l=n;const i=e;for(;l<=i;)l>=t&&l<=e&&o.push(l),l*=10}o.sort((l,i)=>l-i);const r=[];for(const l of o){const i=r[r.length-1];(r.length===0||i!=null&&at(l-i)>1e-10)&&r.push(l)}return r}function jo(t,e){const n=e===10?ct:_t;return t.map(o=>{if(o===0)return!0;if(o<0)return!1;const s=n(o);return at(s-Math.round(s))<1e-10})}const Xo=50,Oo=16,Wn=7;function ne(t){const e=t.match(/(\d+(?:\.\d+)?)px/);return e!=null?Number(e[1]):12}function Rn(t){return t!=null?ne(t)*.58:Wn}function Uo(t,e,n=Wn,o){const r=An(Math.max(Math.abs(t),Math.abs(e)),o).length*n;return Math.max(Xo,r+Oo)}function Yo(t,e,n,o,s,r){if(o<=0)return[0,0];const l=Ft(t.side)===G.Vertical,i=s!=null?ne(s):12,a=t.space??(l?Math.ceil(i*2.5):Uo(e,n,Rn(s),r)),u=t.incrs??xt;return So(e,n,u,o,a)}const Ko=50;function Zo(t,e,n,o){var u,c;if(t.size!=null)return t.size;const s=((u=t.ticks)==null?void 0:u.show)!==!1?((c=t.ticks)==null?void 0:c.size)??10:0,r=t.gap??5,l=o!=null?ne(o):12,i=Rn(o);if(Ft(t.side)===G.Vertical&&e!=null){let d=0;for(const h of e)h.length>d&&(d=h.length);const f=d*i;return Math.max(50,s+r+f+4)}return Math.max(50,s+r+l+3)}function qo(t){return{config:t,_show:t.show!==!1,_size:t.size??Ko,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const Jo=1,Pt=60,Mt=3600,St=86400,Qo=604800,Ct=2592e3,$t=31536e3,ts=[Jo,5,10,15,30,Pt,5*Pt,10*Pt,15*Pt,30*Pt,Mt,2*Mt,3*Mt,4*Mt,6*Mt,12*Mt,St,2*St,3*St,7*St,14*St,Ct,2*Ct,3*Ct,6*Ct,$t];function es(t,e,n){const o=[];if(n<=0||t>=e)return o;let s;if(n>=$t){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/$t)),s=r.getTime()/1e3;return o}if(n>=Ct){const r=new Date(t*1e3);r.setUTCDate(1),r.setUTCHours(0,0,0,0),s=r.getTime()/1e3;const l=Math.max(1,Math.round(n/Ct));if(s<t&&(r.setUTCMonth(r.getUTCMonth()+1),s=r.getTime()/1e3),l>1){const i=r.getUTCMonth(),a=Math.ceil((i+1)/l)*l;r.setUTCMonth(a-1),s=r.getTime()/1e3}for(;s<=e;)o.push(s),r.setUTCMonth(r.getUTCMonth()+l),s=r.getTime()/1e3;return o}if(n>=St){const r=new Date(t*1e3);r.setUTCHours(0,0,0,0),s=r.getTime()/1e3,s<t&&(s+=St)}else s=Math.ceil(t/n)*n;for(let r=0;;r++){const l=s+r*n;if(l>e)break;o.push(l)}return o}const Ke=new Map;function ns(t,e,n){const o=JSON.stringify(t)+(e??"")+"\0"+(n??"");let s=Ke.get(o);return s==null&&(s=new Intl.DateTimeFormat(n,{...t,timeZone:e}),Ke.set(o,s)),s}function ut(t,e,n,o){const s=new Date(t*1e3);return ns(e,n,o).format(s)}function os(t,e,n){return ut(t,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e,n)}function ss(t,e,n){return ut(t,{year:"numeric",month:"2-digit",day:"2-digit"},e,n)}function ls(t,e,n){return ut(t,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e,n)}function rs(t,e,n){return ut(t,{hour:"2-digit",minute:"2-digit",hour12:!1},e,n)}function is(t,e,n){return ut(t,{month:"short",day:"numeric"},e,n)}function as(t,e,n){return ut(t,{year:"numeric"},e,n)}function cs(t,e,n){return ut(t,{year:"numeric",month:"short"},e,n)}function us(t,e,n,o){let s;return e>=$t?s=as:e>=Ct?s=cs:e>=Qo?s=ss:e>=St?s=is:e>=Mt?s=rs:e>=Pt?s=ls:s=os,t.map(r=>s(r,n,o))}function fs(t,e,n,o,s){const r=e-t;if(r<=0||o<=0)return[0,0];for(const i of n){const a=r/i,u=o/a;if(u>=s)return[i,u]}const l=n[n.length-1]??$t;return[l,o/(r/l)]}const ds=3;function hs(t,e,n,o,s,r,l,i){let a=!0;for(const u of t){const c=u.config;if(c.show===!1)continue;const d=e(c.scale);if(!d||!q(d)){u._show&&(a=!1,u._show=!1);continue}else u._show||(a=!1,u._show=!0);const f=c.side,p=Ft(f)===G.Horizontal?n:o,w=d.min,m=d.max;let v,M;if(d.time){const C=c.space??80;[v,M]=fs(w,m,ts,p,C)}else{const C=c.font??(r==null?void 0:r.tickFont);[v,M]=Yo(c,w,m,p,C,l)}if(d._discrete&&v>0&&v<1&&(v=1),u._incr=v,u._space=M,M===0)continue;if(c.splits)u._splits=c.splits(w,m,v,M);else if(d.time)u._splits=es(w,m,v);else if(d.distr===Q.Log)u._splits=Go(w,m,d.log);else if(d.distr===Q.Asinh)u._splits=No(w,m,d.asinh);else{const C=d.distr===Q.Ordinal||d._discrete;u._splits=Vo(w,m,v,M,C)}if(c.values)u._values=c.values(u._splits,M,v);else if(d.time)u._values=us(u._splits,v,i,l);else if(d.distr===Q.Log){const C=jo(u._splits,d.log),L=ae(u._splits,l);u._values=L.map((g,S)=>C[S]?g:"")}else d.distr,Q.Asinh,u._values=ae(u._splits,l);u._rotate=f===K.Bottom?c.rotate??0:0;const k=u._size,F=c.font??(r==null?void 0:r.tickFont);u._size=zt(Zo(c,u._values,s,F)),k!==u._size&&(a=!1)}return a}function Ze(t,e,n,o=0){let s=t,r=e-o,l=0,i=o;for(const u of n){if(!u._show)continue;const c=u.config.side,d=Ft(c)===G.Vertical,f=u.config.label!=null?u.config.labelSize??20:0,h=u._size+f;h>0&&(d?(s-=h,c===K.Left&&(l+=h)):(r-=h,c===K.Top&&(i+=h)))}return!n.some(u=>u._show&&u.config.side===K.Top)&&i<=o&&(i+=8,r-=8),{left:l,top:i,width:Math.max(s,0),height:Math.max(r,0)}}function gs(t,e){let n=e.top,o=e.left+e.width,s=e.top+e.height,r=e.left;function l(i,a){switch(i){case K.Top:return n-=a,n+a;case K.Right:{const u=o;return o+=a,u}case K.Bottom:{const u=s;return s+=a,u}case K.Left:return r-=a,r+a;default:return 0}}for(const i of t){if(!i._show)continue;const a=i.config.side;if(i._pos=l(a,i._size),i.config.label!=null){const u=i.config.labelSize??20;i._lpos=l(a,u)}}}function ps(t,e,n,o,s=0,r,l,i){for(const d of n)d._size=0;let a=!1,u=0,c={left:0,top:0,width:t,height:e};for(;!a;){u++;const d=hs(n,o,c.width,c.height,u,r,l,i);a=u===ds||d,a||(c=Ze(t,e,n,s))}return c=Ze(t,e,n,s),gs(n,c),c}const et={axisStroke:"#000",gridStroke:"rgba(0,0,0,0.12)",titleFill:"#000",tickFont:"12px system-ui, sans-serif",labelFont:"bold 12px system-ui, sans-serif",titleFont:"bold 14px system-ui, sans-serif",bandFill:"rgba(0, 120, 255, 0.1)",cursorStroke:"#607D8B",cursorWidth:1,cursorDash:[5,3],cursorPointRadius:4,pointFill:"#fff",selectFill:"rgba(0,0,0,0.07)",selectStroke:"rgba(0,0,0,0.15)",selectWidth:1,seriesColors:["#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085","#c0392b","#2980b9","#27ae60","#f1c40f","#8e44ad","#d35400"],candlestickUp:"#26a69a",candlestickDown:"#ef5350",boxFill:"rgba(52, 152, 219, 0.4)",boxStroke:"#2980b9",boxMedian:"#e74c3c",boxWhisker:"#555",vectorColor:"#c0392b",sparklineStroke:"#03a9f4",timelineLabel:"#666",timelineSegment:"#4dabf7",timelineText:"#fff",annotationStroke:"red",annotationFill:"rgba(255,0,0,0.1)",annotationFont:"11px sans-serif",annotationLabelFill:"#000",panelBg:"rgba(255,255,255,0.92)",panelBorder:"#ccc",panelShadow:"0 1px 4px rgba(0,0,0,0.12)",overlayFontFamily:"sans-serif",overlayFontSize:12,overlayHiddenOpacity:.4,overlayZ:50,tooltipZ:100,rangerAccent:"rgba(0,100,255,0.8)",rangerDim:"rgba(0,0,0,0.3)"},ms={axisStroke:"#ccc",gridStroke:"rgba(255,255,255,0.08)",titleFill:"#e0e0e0",cursor:{stroke:"#90caf9",pointFill:"#1e1e1e"},select:{fill:"rgba(255,255,255,0.06)",stroke:"rgba(255,255,255,0.15)"},overlay:{panelBg:"rgba(30,30,30,0.95)",panelBorder:"#555",panelShadow:"0 1px 4px rgba(0,0,0,0.4)"},ranger:{accent:"rgba(100,180,255,0.8)",dim:"rgba(0,0,0,0.5)"},annotation:{stroke:"#ff6b6b",fill:"rgba(255,100,100,0.15)",labelFill:"#e0e0e0"}},vt={axisStroke:"--uplot-axis-stroke",gridStroke:"--uplot-grid-stroke",titleFill:"--uplot-title-fill",tickFont:"--uplot-tick-font",labelFont:"--uplot-label-font",titleFont:"--uplot-title-font",bandFill:"--uplot-band-fill",cursorStroke:"--uplot-cursor-stroke",cursorWidth:"--uplot-cursor-width",cursorDash:"--uplot-cursor-dash",cursorPointRadius:"--uplot-cursor-point-radius",pointFill:"--uplot-point-fill",selectFill:"--uplot-select-fill",selectStroke:"--uplot-select-stroke",selectWidth:"--uplot-select-width",seriesColors:"--uplot-series-colors",candlestickUp:"--uplot-candlestick-up",candlestickDown:"--uplot-candlestick-down",boxFill:"--uplot-box-fill",boxStroke:"--uplot-box-stroke",boxMedian:"--uplot-box-median",boxWhisker:"--uplot-box-whisker",vectorColor:"--uplot-vector-color",sparklineStroke:"--uplot-sparkline-stroke",timelineLabel:"--uplot-timeline-label",timelineSegment:"--uplot-timeline-segment",timelineText:"--uplot-timeline-text",annotationStroke:"--uplot-annotation-stroke",annotationFill:"--uplot-annotation-fill",annotationFont:"--uplot-annotation-font",annotationLabelFill:"--uplot-annotation-label-fill",panelBg:"--uplot-panel-bg",panelBorder:"--uplot-panel-border",panelShadow:"--uplot-panel-shadow",overlayFontFamily:"--uplot-overlay-font-family",overlayFontSize:"--uplot-overlay-font-size",overlayHiddenOpacity:"--uplot-overlay-hidden-opacity",overlayZ:"--uplot-overlay-z",tooltipZ:"--uplot-tooltip-z",rangerAccent:"--uplot-ranger-accent",rangerDim:"--uplot-ranger-dim"},ws=new Set(["overlayFontSize"]);function ot(t){const e=vt[t],n=et[t],o=ws.has(t)?"px":"";return`var(${e}, ${Array.isArray(n)?n.join(","):`${n}${o}`})`}function qe(t){if(t==null)return et;const e=getComputedStyle(t),n=(i,a)=>e.getPropertyValue(vt[i]).trim()||a,o=(i,a)=>{const u=e.getPropertyValue(vt[i]).trim();if(u==="")return a;const c=parseFloat(u);return isNaN(c)?a:c},s=(i,a)=>{const u=e.getPropertyValue(vt[i]).trim();return u!==""?u.split(",").map(c=>c.trim()).filter(Boolean):a},r=(i,a)=>{const u=e.getPropertyValue(vt[i]).trim();if(u==="")return a;const c=u.split(",").map(d=>Number(d.trim())).filter(d=>!isNaN(d));return c.length>0?c:a},l=et;return{axisStroke:n("axisStroke",l.axisStroke),gridStroke:n("gridStroke",l.gridStroke),titleFill:n("titleFill",l.titleFill),tickFont:n("tickFont",l.tickFont),labelFont:n("labelFont",l.labelFont),titleFont:n("titleFont",l.titleFont),bandFill:n("bandFill",l.bandFill),cursorStroke:n("cursorStroke",l.cursorStroke),cursorWidth:o("cursorWidth",l.cursorWidth),cursorDash:r("cursorDash",l.cursorDash),cursorPointRadius:o("cursorPointRadius",l.cursorPointRadius),pointFill:n("pointFill",l.pointFill),selectFill:n("selectFill",l.selectFill),selectStroke:n("selectStroke",l.selectStroke),selectWidth:o("selectWidth",l.selectWidth),seriesColors:s("seriesColors",l.seriesColors),candlestickUp:n("candlestickUp",l.candlestickUp),candlestickDown:n("candlestickDown",l.candlestickDown),boxFill:n("boxFill",l.boxFill),boxStroke:n("boxStroke",l.boxStroke),boxMedian:n("boxMedian",l.boxMedian),boxWhisker:n("boxWhisker",l.boxWhisker),vectorColor:n("vectorColor",l.vectorColor),sparklineStroke:n("sparklineStroke",l.sparklineStroke),timelineLabel:n("timelineLabel",l.timelineLabel),timelineSegment:n("timelineSegment",l.timelineSegment),timelineText:n("timelineText",l.timelineText),annotationStroke:n("annotationStroke",l.annotationStroke),annotationFill:n("annotationFill",l.annotationFill),annotationFont:n("annotationFont",l.annotationFont),annotationLabelFill:n("annotationLabelFill",l.annotationLabelFill),panelBg:n("panelBg",l.panelBg),panelBorder:n("panelBorder",l.panelBorder),panelShadow:n("panelShadow",l.panelShadow),overlayFontFamily:n("overlayFontFamily",l.overlayFontFamily),overlayFontSize:o("overlayFontSize",l.overlayFontSize),overlayHiddenOpacity:o("overlayHiddenOpacity",l.overlayHiddenOpacity),overlayZ:o("overlayZ",l.overlayZ),tooltipZ:o("tooltipZ",l.tooltipZ),rangerAccent:n("rangerAccent",l.rangerAccent),rangerDim:n("rangerDim",l.rangerDim)}}function Hn(t){var s,r,l,i,a,u,c,d,f,h,p,w,m,v,M,k,F,C,L,g,S,y,b,P,A,E,W,H,x,T,I,_,$;const e={},n=(R,N)=>{N!=null&&(e[vt[R]]=N)},o=(R,N)=>{N!=null&&(e[vt[R]]=N.join(","))};return n("axisStroke",t.axisStroke),n("gridStroke",t.gridStroke),n("titleFill",t.titleFill),n("tickFont",t.tickFont),n("labelFont",t.labelFont),n("titleFont",t.titleFont),n("bandFill",t.bandFill),n("cursorStroke",(s=t.cursor)==null?void 0:s.stroke),n("cursorWidth",(r=t.cursor)==null?void 0:r.width),o("cursorDash",(l=t.cursor)==null?void 0:l.dash),n("cursorPointRadius",(i=t.cursor)==null?void 0:i.pointRadius),n("pointFill",(a=t.cursor)==null?void 0:a.pointFill),n("selectFill",(u=t.select)==null?void 0:u.fill),n("selectStroke",(c=t.select)==null?void 0:c.stroke),n("selectWidth",(d=t.select)==null?void 0:d.width),o("seriesColors",t.seriesColors),n("candlestickUp",(f=t.candlestick)==null?void 0:f.upColor),n("candlestickDown",(h=t.candlestick)==null?void 0:h.downColor),n("boxFill",(p=t.boxWhisker)==null?void 0:p.fill),n("boxStroke",(w=t.boxWhisker)==null?void 0:w.stroke),n("boxMedian",(m=t.boxWhisker)==null?void 0:m.medianColor),n("boxWhisker",(v=t.boxWhisker)==null?void 0:v.whiskerColor),n("vectorColor",(M=t.vector)==null?void 0:M.color),n("sparklineStroke",(k=t.sparkline)==null?void 0:k.stroke),n("timelineLabel",(F=t.timeline)==null?void 0:F.labelColor),n("timelineSegment",(C=t.timeline)==null?void 0:C.segmentColor),n("timelineText",(L=t.timeline)==null?void 0:L.segmentTextColor),n("annotationStroke",(g=t.annotation)==null?void 0:g.stroke),n("annotationFill",(S=t.annotation)==null?void 0:S.fill),n("annotationFont",(y=t.annotation)==null?void 0:y.font),n("annotationLabelFill",(b=t.annotation)==null?void 0:b.labelFill),n("panelBg",(P=t.overlay)==null?void 0:P.panelBg),n("panelBorder",(A=t.overlay)==null?void 0:A.panelBorder),n("panelShadow",(E=t.overlay)==null?void 0:E.panelShadow),n("overlayFontFamily",(W=t.overlay)==null?void 0:W.fontFamily),((H=t.overlay)==null?void 0:H.fontSize)!=null&&(e[vt.overlayFontSize]=`${t.overlay.fontSize}px`),n("overlayHiddenOpacity",(x=t.overlay)==null?void 0:x.hiddenOpacity),n("overlayZ",(T=t.overlay)==null?void 0:T.zIndex),n("tooltipZ",(I=t.overlay)==null?void 0:I.tooltipZIndex),n("rangerAccent",(_=t.ranger)==null?void 0:_.accent),n("rangerDim",($=t.ranger)==null?void 0:$.dim),e}const Je="top",Qe="bottom",Ss="left",vs="right";function ce(t,e){return e===1?t:t.replace(/(\d+(?:\.\d+)?)px/,(n,o)=>`${Math.round(Number(o)*e)}px`)}function tn(t,e,n,o,s,r,l,i,a,u,c){const d=i%2/2;t.save(),t.translate(d,d),t.strokeStyle=a,t.lineWidth=i,u.length>0&&t.setLineDash(u),t.beginPath();let f=0,h=0,p=0,w=0;const m=r+(s===K.Top||s===K.Left?-l:l);o===G.Horizontal?(h=r,w=m):(f=r,p=m);for(let v=0;v<e.length;v++)n[v]!=null&&(o===G.Horizontal?f=p=e[v]??0:h=w=e[v]??0,t.moveTo(f,h),t.lineTo(p,w));t.stroke(),t.restore()}function bs(t,e,n,o,s,r,l){const i=l??et,a=X(o.left*s),u=X(o.top*s),c=X(o.width*s),d=X(o.height*s);for(const f of e){if(!f._show)continue;const h=f.config,p=h.side,w=Ft(p),m=n(h.scale);if(!m||!q(m))continue;const v=h.stroke??i.axisStroke,M=p===K.Top||p===K.Left?-1:1,k=f._splits,F=f._values;if(!k||!F||f._space===0)continue;const C=w===G.Horizontal?o.width:o.height,L=w===G.Horizontal?o.left:o.top,g=k.map(A=>X(U(A,m,C,L)*s)),S=F.map(A=>A===""?null:A),y=h.grid;if((y==null?void 0:y.show)!==!1){const A=(y==null?void 0:y.stroke)??i.gridStroke,E=X(((y==null?void 0:y.width)??2)*s),W=((y==null?void 0:y.dash)??[]).map(T=>T*s),H=w===G.Horizontal?u:a,x=w===G.Horizontal?d:c;tn(t,g,S,w,2,H,x,E,A,W)}const b=h.ticks;if((b==null?void 0:b.show)!==!1){const A=(b==null?void 0:b.stroke)??v,E=X(((b==null?void 0:b.width)??1)*s),W=X(((b==null?void 0:b.size)??10)*s),H=((b==null?void 0:b.dash)??[]).map(T=>T*s),x=X(f._pos*s);tn(t,g,S,w,p,x,W,E,A,H)}{const A=(b==null?void 0:b.show)!==!1?((b==null?void 0:b.size)??10)*s:0,E=X((h.gap??5)*s),W=X(f._pos*s),H=(A+E)*M,x=W+H,T=ce(h.font??i.tickFont,s),I=w===G.Horizontal?"center":p===K.Left?vs:Ss,_=w===G.Horizontal?p===K.Bottom?Je:Qe:"middle";t.font=T,t.fillStyle=v,t.textAlign=I,t.textBaseline=_;const $=f._rotate*-le/180;if($!==0){const R=Math.cos($),N=Math.sin($);for(let z=0;z<F.length;z++){const j=F[z];if(j==null||j==="")continue;const O=g[z]??0;t.setTransform(R,N,-N,R,O,x),t.fillText(j,0,0)}t.setTransform(1,0,0,1,0,0)}else for(let R=0;R<F.length;R++){const N=F[R];if(N==null||N==="")continue;const z=g[R]??0,j=w===G.Horizontal?z:x,O=w===G.Horizontal?x:z;t.fillText(N,j,O)}}if(h.label!=null){const A=ce(h.labelFont??i.labelFont,s);t.font=A,t.fillStyle=v,t.textAlign="center",t.textBaseline=p===K.Bottom?Je:Qe;const E=X((f._lpos+(h.labelGap??0)*M)*s);w===G.Vertical?(t.save(),t.translate(E,X(u+d/2)),t.rotate((p===K.Left?-le:le)/2),t.fillText(h.label,0,0),t.restore()):t.fillText(h.label,X(a+c/2),E)}const P=h.border;if((P==null?void 0:P.show)!==!1&&P!=null){const A=P.stroke??v,E=X((P.width??1)*s),W=(P.dash??[]).map(x=>x*s),H=X(f._pos*s);t.strokeStyle=A,t.lineWidth=E,W.length>0&&t.setLineDash(W),t.beginPath(),w===G.Horizontal?(t.moveTo(a,H),t.lineTo(a+c,H)):(t.moveTo(H,u),t.lineTo(H,u+d)),t.stroke(),W.length>0&&t.setLineDash([])}}if(r!=null){const f=ce(i.titleFont,s);t.font=f,t.fillStyle=i.titleFill,t.textAlign="center",t.textBaseline="top",t.fillText(r,X(a+c/2),X(4*s))}}const ys=2,xs={stroke:et.cursorStroke,width:et.cursorWidth,dash:et.cursorDash,pointRadius:et.cursorPointRadius,showX:!0,showY:!0};function en(t,e,n,o,s,r,l,i,a,u,c){var g;if(e.left<0||e.top<0)return;const d=c??et,f={stroke:d.cursorStroke,width:d.cursorWidth,dash:d.cursorDash,pointRadius:d.cursorPointRadius},h={...xs,...f,...a},p=o,w=X(n.left*p),m=X(n.top*p),v=X(n.width*p),M=X(n.height*p),k=X(h.width*p),F=k%2/2,C=X((n.left+e.left)*p)+F,L=X((n.top+e.top)*p)+F;if(t.save(),t.strokeStyle=h.stroke,t.lineWidth=k,t.setLineDash(h.dash.map(S=>S*p)),h.showX&&(t.beginPath(),t.moveTo(C,m),t.lineTo(C,m+M),t.stroke()),h.showY&&(t.beginPath(),t.moveTo(w,L),t.lineTo(w+v,L),t.stroke()),t.setLineDash([]),e.activeGroup>=0&&e.activeDataIdx>=0){const S=e.activeGroup,y=e.activeSeriesIdx,b=e.activeDataIdx,P=s[S];if(P!=null&&y>=0&&y<P.series.length&&b<P.x.length){const A=P.x[b],E=P.series[y],W=E!=null?E[b]:null;if(A!=null&&W!=null){let H=h.stroke,x=!0;const T=u==null?void 0:u.get(`${S}:${y}`);if(T!=null){const I=T.stroke;H=(typeof I=="string"?I:void 0)??h.stroke,x=((g=T.cursor)==null?void 0:g.show)!==!1}if(x){const I=i(S),_=I!=null?l(I):void 0,$=(T==null?void 0:T.yScale)??Ms(r,S,y),R=$!=null?l($):void 0;if(_!=null&&R!=null&&q(_)&&q(R)){const N=X(U(A,_,n.width,n.left)*p),z=X(U(W,R,n.height,n.top)*p),j=h.pointRadius*p,O=X(ys*p);t.beginPath(),t.arc(N,z,j,0,Math.PI*2),t.fillStyle=d.pointFill,t.fill(),t.strokeStyle=H,t.lineWidth=O,t.stroke()}}}}}t.restore()}function Ms(t,e,n){for(const o of t)if(o.group===e&&o.index===n)return o.yScale}const ks={fill:et.selectFill,stroke:et.selectStroke,width:et.selectWidth};function nn(t,e,n,o,s,r){if(!e.show||e.width<=0)return;const l=r??et,i={fill:l.selectFill,stroke:l.selectStroke,width:l.selectWidth},a={...ks,...i,...s},u=o,c=X((n.left+e.left)*u),d=X((n.top+e.top)*u),f=X(e.width*u),h=X(e.height*u);t.save(),t.fillStyle=a.fill,t.fillRect(c,d,f,h),a.width>0&&(t.strokeStyle=a.stroke,t.lineWidth=X(a.width*u),t.strokeRect(c,d,f,h)),t.restore()}function Cs(t,e,n,o,s,r,l,i,a,u,c,d){const f=c/2*l,h=Math.max(1,X(c*.2))*l,p=(u==null?void 0:u.stroke)??d,w=(u==null?void 0:u.fill)??"#fff";t.save(),t.strokeStyle=p,t.fillStyle=w,t.lineWidth=h,(u==null?void 0:u.dash)!=null&&t.setLineDash(u.dash.map(m=>m*l));for(let m=i;m<=a;m++){const v=n[m];if(v==null)continue;const M=e[m];if(M==null)continue;const k=X(U(M,o,r.width,r.left)*l),F=X(U(v,s,r.height,r.top)*l);t.beginPath(),t.arc(k,F,f,0,Math.PI*2),t.fill(),t.stroke()}t.restore()}function Ts(t,e,n,o,s,r,l){if(typeof t=="function")return t(e,n,o,s,r);if(t===!0)return!0;if(t===!1)return!1;const i=s-o;return i>0&&i<=r/l}function Fs(t,e,n,o,s,r,l,i,a,u=0){if(i>a||i<0||!je(e,i,a)&&!je(n,i,a))return null;const c=f=>U(f,o,r.width,r.left)*l,d=f=>U(f,s,r.height,r.top)*l;return u===0?As(t,e,n,i,a,c,d):Ls(t,e,n,i,a,c,d,u)}function As(t,e,n,o,s,r,l){const i=new Path2D;let a=!1,u=o;for(;u<=s;){if(t[u]==null||e[u]==null||n[u]==null){u++;continue}let c=u;for(;c+1<=s&&t[c+1]!=null&&e[c+1]!=null&&n[c+1]!=null;)c++;{const d=t[u],f=e[u];d!=null&&f!=null&&i.moveTo(r(d),l(f))}for(let d=u+1;d<=c;d++){const f=t[d],h=e[d];f!=null&&h!=null&&i.lineTo(r(f),l(h))}for(let d=c;d>=u;d--){const f=t[d],h=n[d];f!=null&&h!=null&&i.lineTo(r(f),l(h))}i.closePath(),a=!0,u=c+1}return a?i:null}function Ls(t,e,n,o,s,r,l,i){const a=[];for(let h=o;h<=s;h++){const p=t[h],w=e[h],m=n[h];p==null||w==null||m==null||a.push({x:p,u:w,l:m})}if(a.length<2)return null;const u=new Path2D;let c=!1;const d=(h,p)=>i===1?h>p:p>h;let f=0;for(;f<a.length;){const h=a[f];if(h==null)break;if(!d(h.u,h.l)){f++;continue}const p=[],w=[],m=f>0?a[f-1]:void 0;if(m!=null){const C=on(m.x,m.u,m.l,h.x,h.u,h.l),L=sn(m.u,h.u,(C-m.x)/(h.x-m.x));p.push({px:r(C),py:l(L)}),w.push({px:r(C),py:l(L)})}let v=f;for(let C=a[v];C!=null&&d(C.u,C.l);C=a[++v])p.push({px:r(C.x),py:l(C.u)}),w.push({px:r(C.x),py:l(C.l)});const M=a[v],k=v>0?a[v-1]:void 0;if(M!=null&&k!=null){const C=on(k.x,k.u,k.l,M.x,M.u,M.l),L=sn(k.u,M.u,(C-k.x)/(M.x-k.x));p.push({px:r(C),py:l(L)}),w.push({px:r(C),py:l(L)})}const F=p[0];if(p.length>=2&&F!=null){u.moveTo(F.px,F.py);for(let C=1;C<p.length;C++){const L=p[C];L!=null&&u.lineTo(L.px,L.py)}for(let C=w.length-1;C>=0;C--){const L=w[C];L!=null&&u.lineTo(L.px,L.py)}u.closePath(),c=!0}f=v}return c?u:null}function on(t,e,n,o,s,r){const l=e-n,i=s-r,a=l/(l-i);return t+a*(o-t)}function sn(t,e,n){return t+n*(e-t)}function Ps(t,e,n,o){t.save(),t.fillStyle=e.fill??(o==null?void 0:o.bandFill)??"rgba(0, 120, 255, 0.1)",t.fill(n),t.restore()}function Es(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 l=0,i=0,a=0;return t<60?(l=o,i=s):t<120?(l=s,i=o):t<180?(i=o,a=s):t<240?(i=s,a=o):t<300?(l=s,a=o):(l=o,a=s),[Math.round((l+r)*255),Math.round((i+r)*255),Math.round((a+r)*255)]}function zn(t){const e=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(t);if(e&&e[1]!=null&&e[2]!=null&&e[3]!=null)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&&n[1]!=null&&n[2]!=null&&n[3]!=null)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&&o[1]!=null&&o[2]!=null&&o[3]!=null)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&&s[1]!=null&&s[2]!=null&&s[3]!=null?Es(Number(s[1]),Number(s[2]),Number(s[3])):null}function Is(t,e=.8,n=0){const o=zn(t);if(o==null)return{type:"linear",stops:[[0,t],[1,t]]};const[s,r,l]=o;return{type:"linear",stops:[[0,`rgba(${s},${r},${l},${e})`],[1,`rgba(${s},${r},${l},${n})`]]}}function ke(t,e){const n=zn(t);if(n==null)return t;const[o,s,r]=n;return`rgba(${o},${s},${r},${e})`}function Ds(t,e=65,n=50){const o=[];for(let r=0;r<t;r++){const l=r*137.508%360;o.push(`hsl(${l.toFixed(1)},${e}%,${n}%)`)}return o}function _s(t){const e=t.dataStore.data;if(e.length===0)return;if(!t.scaleManager.getScale("x")){const l={id:"x",auto:!0};t.scaleConfigs.push(l),t.scaleManager.addScale(l)}for(let l=0;l<e.length;l++)t.scaleManager.getGroupXScaleKey(l)||t.scaleManager.setGroupXScale(l,"x");const n=new Set(t.scaleConfigs.map(l=>l.id)),o=new Set;for(const l of t.seriesConfigs)o.add(l.yScale);o.size===0&&!n.has("y")&&o.add("y");for(const l of o)if(!n.has(l)){const i={id:l,auto:!0};t.scaleConfigs.push(i),t.scaleManager.addScale(i),n.add(l)}if(!t.axisConfigs.some(l=>l.scale==="x"))t.axisConfigs.push({scale:"x",side:K.Bottom,show:!0,label:t.xlabel??"X Axis",_default:!0});else{const l=t.axisConfigs.find(i=>i.scale==="x"&&i._default===!0);l!=null&&(l.label=t.xlabel??"X Axis")}const r=new Set(t.axisConfigs.map(l=>l.scale));for(const l of o)if(!r.has(l))t.axisConfigs.push({scale:l,side:K.Left,show:!0,label:t.ylabel??"Y Axis",_default:!0}),r.add(l);else{const i=t.axisConfigs.find(a=>a.scale===l&&a._default===!0);i!=null&&(i.label=t.ylabel??"Y Axis")}}function Nt(t,e,n,o){return{ctx:t,plotBox:e,pxRatio:n,getScale:o,valToX:(l,i="x")=>{const a=o(i);return a==null||!q(a)?null:U(l,a,e.width,e.left)},valToY:(l,i)=>{const a=o(i);return a==null||!q(a)?null:U(l,a,e.height,e.top)}}}const Ws={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1,plotLeft:0,plotTop:0,plotWidth:0,plotHeight:0,seriesCount:0,revision:-1};function ln(t){const{left:e,top:n,activeGroup:o,activeSeriesIdx:s,activeDataIdx:r}=t.cursorManager.state,{left:l,top:i,width:a,height:u}=t.plotBox,c=t.seriesConfigs.length,{revision:d}=t,f=t.snapshot;f.left===e&&f.top===n&&f.activeGroup===o&&f.activeSeriesIdx===s&&f.activeDataIdx===r&&f.plotLeft===l&&f.plotTop===i&&f.plotWidth===a&&f.plotHeight===u&&f.seriesCount===c&&f.revision===d||(t.snapshot={left:e,top:n,activeGroup:o,activeSeriesIdx:s,activeDataIdx:r,plotLeft:l,plotTop:i,plotWidth:a,plotHeight:u,seriesCount:c,revision:d})}function jt(t){t.seriesConfigMap.clear();for(const e of t.seriesConfigs)t.seriesConfigMap.set(`${e.group}:${e.index}`,e)}function Rs(){const t={scaleManager:new xo,dataStore:new Co,renderer:new zo,cursorManager:new To,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 Fo,drawHooks:new Set,unclippedDrawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:1,actionMap:new Map(Kt),title:void 0,xlabel:void 0,ylabel:void 0,locale:void 0,timezone:void 0,snapshot:Ws,revision:0,eventCallbacks:{},theme:qe(null),_prevScaleRanges:new Map,_prevPlotBox:null,_prevThemeKey:"",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){const n=t.seriesConfigs.find(o=>o.group===e.group&&o.index===e.index);e._internal&&n!=null&&!n._internal||(t.seriesConfigs=t.seriesConfigs.filter(o=>!(o.group===e.group&&o.index===e.index)),t.seriesConfigs.push(e),jt(t),t.renderer.clearGroupCache(e.group))},unregisterSeries(e,n){t.seriesConfigs=t.seriesConfigs.filter(o=>!(o.group===e&&o.index===n)),jt(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,o){const s=o??t.pxRatio;t.width===e&&t.height===n&&t.pxRatio===s||(t.pxRatio=s,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(lt.Full)},scheduleCursorRedraw(){t.scheduler.mark(lt.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:l,pxRatio:i,canvas:a,scheduler:u}=t;if(a==null||r===0||l===0)return;const c=a.getContext("2d");if(c==null)return;o.setContext(c,i);const f=(u.dirty&~(lt.Cursor|lt.Select))===0,h=g=>e.getScale(g);if(f&&o.restoreSnapshot(c)){if(en(c,t.cursorManager.state,t.plotBox,i,n.data,s,h,g=>e.getGroupXScaleKey(g),void 0,t.seriesConfigMap,t.theme),nn(c,t.selectState,t.plotBox,i,void 0,t.theme),t.cursorDrawHooks.size>0){c.save(),c.scale(i,i);const g=Nt(c,t.plotBox,i,h);for(const S of t.cursorDrawHooks)try{S(g,t.cursorManager.state)}catch(y){console.warn("[uPlot+] draw hook error:",y)}c.restore()}ln(t);for(const g of t.cursorListeners)g();return}t.theme=qe(a);const p=JSON.stringify(t.theme);p!==t._prevThemeKey&&(t._prevThemeKey=p,t.revision++);const w=t.theme.seriesColors;for(let g=0;g<s.length;g++){const S=s[g];if(S==null||!S._autoStroke)continue;const y=w[g%w.length]??"#000";if(S.stroke===y)continue;const b=S._autoFill&&typeof y=="string"?ke(y,.5):S.fill;s[g]={...S,stroke:y,fill:b}}jt(t),_s(t),e.autoRangeX(n.data),n.updateWindows(g=>{const S=e.getGroupXScaleKey(g);return S!=null?e.getScale(S):void 0});const m=s.filter(g=>g.show!==!1),v=new Set(m.map(g=>g.yScale)),M=s.filter(g=>g.show!==!1||!v.has(g.yScale)).map(g=>({group:g.group,index:g.index,yScale:g.yScale}));if(e.autoRange(n.data,M,n),Hs(t),t.axisStates.length>0){const g=ne(t.theme.titleFont),S=t.title!=null?Math.ceil(g*1.5)+4:0;t.plotBox=ps(r,l,t.axisStates,h,S,t.theme,t.locale,t.timezone)}else t.plotBox={left:10,top:10,width:r-20,height:l-20};const k=t._prevPlotBox,F=t.plotBox;k!=null&&(k.left!==F.left||k.top!==F.top||k.width!==F.width||k.height!==F.height)&&o.clearCache(),t._prevPlotBox={...F},c.clearRect(0,0,r*i,l*i),t.axisStates.length>0&&bs(c,t.axisStates,h,t.plotBox,i,t.title,t.theme);const C=[];for(const g of s){const S=e.getGroupXScaleKey(g.group),y=S!=null?e.getScale(S):void 0,b=e.getScale(g.yScale);y==null||b==null||C.push({config:g,dataX:n.getXValues(g.group),dataY:n.getYValues(g.group,g.index),xScale:y,yScale:b,window:n.getWindow(g.group)})}o.checkScaleStamp(C),c.save(),c.scale(i,i),c.beginPath(),c.rect(t.plotBox.left,t.plotBox.top,t.plotBox.width,t.plotBox.height),c.clip();for(let g=0;g<C.length;g++){const S=C[g];S!=null&&(t.focusedSeries!=null&&g!==t.focusedSeries?(c.globalAlpha=t.focusAlpha,o.drawSeries(S,t.plotBox,1),c.globalAlpha=1):o.drawSeries(S,t.plotBox,1))}const L=new Map;for(const g of s)L.set(`${g.group}-${g.index}`,g);for(const g of t.bandConfigs){const S=e.getGroupXScaleKey(g.group),y=S!=null?e.getScale(S):void 0,b=L.get(`${g.group}-${g.series[0]}`),P=L.get(`${g.group}-${g.series[1]}`);if(y==null||b==null||P==null)continue;const A=e.getScale(b.yScale);if(A==null)continue;const[E,W]=n.getWindow(g.group),H=g.series[0],x=g.series[1],T=g.dir??0;let I=o.getCachedBandPath(g.group,H,x,E,W,T);I==null&&(I=Fs(n.getXValues(g.group),n.getYValues(g.group,H),n.getYValues(g.group,x),y,A,t.plotBox,i,E,W,g.dir)??void 0,I!=null&&o.setCachedBandPath(g.group,H,x,E,W,T,I)),I!=null&&Ps(c,g,I,t.theme)}for(const g of C){const S=g.config;if(S.show===!1)continue;const y=S.points,b=S.width??1,P=(y==null?void 0:y.size)??3+b*2,A=(y==null?void 0:y.space)??P*2,[E,W]=g.window;Ts(y==null?void 0:y.show,S.group,S.index,E,W,t.plotBox.width,A)&&Cs(c,g.dataX,g.dataY,g.xScale,g.yScale,t.plotBox,i,E,W,y,P,(typeof S.stroke=="string"?S.stroke:null)??"#000")}if(c.restore(),t.drawHooks.size>0){c.save(),c.beginPath(),c.rect(t.plotBox.left*i,t.plotBox.top*i,t.plotBox.width*i,t.plotBox.height*i),c.clip(),c.scale(i,i);const g=Nt(c,t.plotBox,i,h);for(const S of t.drawHooks)try{S(g)}catch(y){console.warn("[uPlot+] draw hook error:",y)}c.restore()}if(t.unclippedDrawHooks.size>0){c.save(),c.scale(i,i);const g=Nt(c,t.plotBox,i,h);for(const S of t.unclippedDrawHooks)try{S(g)}catch(y){console.warn("[uPlot+] draw hook error:",y)}c.restore()}if(t.cursorManager.state.left>=0&&(o.saveSnapshot(c,r*i,l*i),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))),en(c,t.cursorManager.state,t.plotBox,i,n.data,s,h,g=>e.getGroupXScaleKey(g),void 0,t.seriesConfigMap,t.theme),nn(c,t.selectState,t.plotBox,i,void 0,t.theme),t.cursorDrawHooks.size>0){c.save(),c.scale(i,i);const g=Nt(c,t.plotBox,i,h);for(const S of t.cursorDrawHooks)try{S(g,t.cursorManager.state)}catch(y){console.warn("[uPlot+] draw hook error:",y)}c.restore()}ln(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(!q(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(y){console.warn("[uPlot+] event callback error:",y)}}t._prevScaleRanges.clear();for(const g of e.getAllScales())q(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),jt(t),t.renderer.invalidateSeries(e.group,e.index),t.revision++,t.cursorManager.invalidateGroupedConfigs(),t.renderer.invalidateSnapshot()},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(),t.revision++},setCanvas(e){t.canvas=e},setLabels(e,n,o,s,r){t.title=e,t.xlabel=n,t.ylabel=o,t.locale=s,t.timezone=r,t.scheduleRedraw()},redrawSync(){t.scheduler.cancel(),t.scheduler.mark(lt.Full),t.redraw(),t.scheduler.cancel(),t.scheduler.clear()}};return t.scheduler.onRedraw(()=>t.redraw()),t}function Hs(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}`,l=o.get(r);return l!=null?(l.config=s,l):qo(s)})}function zs(){const t=D.useRef(null);return t.current??(t.current=Rs()),t.current}const $n=D.createContext(null);function nt(){const t=D.useContext($n);if(!t)throw new Error("useChart must be used within a <Chart> component");return t}function $s(t="cursor"){const e=nt(),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 rn=5,Bn=.001,Bs=.1,Vs=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 Gs(t){return Ce(t,"Drag")}function Ns(t){return Ce(t,"Click")}function js(t){return Ce(t,"Dblclick")}function Xs(t){const e=t.shiftKey?"shift":t.altKey?"alt":t.ctrlKey?"ctrl":"";return e?`${e}Wheel`:"wheel"}function Os(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 Us(t,e,n,o,s=!0){const r=t.get(e);if(r!=null)return r;if(s){for(const[l,i]of t)if(typeof l=="function"&&l(n,o))return i}}function Ys(t,e){const n=[];for(const o of t.scaleManager.getAllScales())q(o)&&(e!=null&&!e(o.ori)||n.push({id:o.id,ori:o.ori,dir:o.dir,startMin:o.min,startMax:o.max}));return n}function Wt(t){const e=t.eventCallbacks.onScaleChange;if(e!=null)for(const n of t.scaleManager.getAllScales()){if(!q(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 ue(t,e,n,o){if(!(e instanceof WheelEvent))return;const s=rt(1-e.deltaY*Bn,Bs,Vs),r=t.plotBox;for(const l of t.scaleManager.getAllScales()){if(!q(l)||!o(l.ori))continue;const i=l.ori===G.Horizontal,a=i?r.width:r.height,u=i?r.left:r.top,c=i?n.cx+r.left:n.cy+r.top,d=gt(c,l,a,u),f=d-(d-l.min)*s,h=d+(l.max-d)*s;l.min=Math.min(f,h),l.max=Math.max(f,h),l.auto=!1,ht(l)}t.scheduleRedraw(),Wt(t)}function fe(t,e,n){const o={show:!1,left:0,top:0,width:0,height:0},s=e.cx,r=e.cy;return{onMove(l,i,a){const u=t.plotBox,c=rt(a.cx,0,u.width),d=rt(a.cy,0,u.height);o.show=!0,o.left=Math.min(s,c),o.top=Math.min(r,d),o.width=Math.abs(c-s),o.height=Math.abs(d-r),n(G.Vertical)||(o.top=0,o.height=u.height),n(G.Horizontal)||(o.left=0,o.width=u.width),t.selectState=o,t.scheduler.mark(lt.Cursor|lt.Select)},onEnd(l,i,a){const u=n(G.Horizontal)&&o.width>rn,c=n(G.Vertical)&&o.height>rn;if(u||c){let d=!0;if(t.eventCallbacks.onSelect!=null){const f=qs(t,o);let h;try{h=t.eventCallbacks.onSelect(f)}catch(p){console.warn("[uPlot+] event callback error:",p)}h===!1&&(d=!1)}d&&(Ks(t,o,n),Wt(t))}o.show=!1,o.left=0,o.width=0,t.selectState=o,t.scheduleRedraw()}}}function Ks(t,e,n){const o=t.plotBox;for(const s of t.scaleManager.getAllScales()){if(!q(s)||!n(s.ori))continue;const r=s.ori===G.Horizontal,l=r?o.width:o.height,i=r?o.left:o.top,a=r?e.left:e.top,u=r?e.width:e.height,c=a/l,d=(a+u)/l,f=gt(i+c*l,s,l,i),h=gt(i+d*l,s,l,i);s.min=Math.min(f,h),s.max=Math.max(f,h),s.auto=!1,ht(s)}}function de(t,e,n,o){const s=Ys(t,n);if(!(e instanceof MouseEvent))return{onMove(){},onEnd(){}};const r=e.clientX,l=e.clientY;return{onMove(i,a){if(!(a instanceof MouseEvent))return;const u=t.plotBox,c=a;for(const d of s){const f=t.scaleManager.getScale(d.id);if(f==null)continue;const h=d.ori===G.Horizontal,p=h?u.width:u.height,w=h?c.clientX-r:c.clientY-l,m=(h?-1:1)*d.dir,v=d.startMax-d.startMin;f.min=d.startMin+m*(w/p)*v,f.max=d.startMax+m*(w/p)*v,f.auto=!1,ht(f)}t.renderer.clearCache(),t.scheduleRedraw()},onEnd(){Wt(t)}}}function an(t,e,n){var c;if(n.scaleId==null||n.ori==null)return;const o=t.scaleManager.getScale(n.scaleId);if(o==null||!q(o))return;const s=n.ori===G.Vertical;if(!(e.target instanceof HTMLElement))return;const r=(c=e.target.closest("div"))==null?void 0:c.getBoundingClientRect();if(r==null||!(e instanceof MouseEvent))return;const l=s?e.clientY-r.top:e.clientX-r.left,i=o.min,a=o.max,u=n.scaleId;return{onMove(d,f){if(!(f instanceof MouseEvent))return;const h=t.plotBox,p=s?h.height:h.width,m=((s?f.clientY-r.top:f.clientX-r.left)-l)/p,v=(s?1:-1)*o.dir,M=a-i,k=t.scaleManager.getScale(u);k!=null&&(k.min=i+v*m*M,k.max=a+v*m*M,k.auto=!1,ht(k),t.renderer.clearCache(),t.scheduleRedraw())},onEnd(){Wt(t)}}}function he(t,e,n){if(!(e instanceof WheelEvent))return;const o=e.deltaY*Bn*10;for(const s of t.scaleManager.getAllScales()){if(!q(s)||!n(s.ori))continue;const r=s.max-s.min;s.min+=o*r,s.max+=o*r,s.auto=!1,ht(s)}t.renderer.clearCache(),t.scheduleRedraw(),Wt(t)}const Xt=t=>t===G.Horizontal,Ot=t=>t===G.Vertical,Ut=()=>!0;function Zs(t){switch(t){case"zoomX":return(e,n,o)=>{if(n instanceof WheelEvent){ue(e,n,o,Xt);return}return fe(e,o,Xt)};case"zoomY":return(e,n,o)=>{if(n instanceof WheelEvent){ue(e,n,o,Ot);return}return fe(e,o,Ot)};case"zoomXY":return(e,n,o)=>{if(n instanceof WheelEvent){ue(e,n,o,Ut);return}return fe(e,o,Ut)};case"panX":return(e,n,o)=>{if(n instanceof WheelEvent){he(e,n,Xt);return}return o.scaleId!=null?an(e,n,o):de(e,n,Xt)};case"panY":return(e,n,o)=>{if(n instanceof WheelEvent){he(e,n,Ot);return}return o.scaleId!=null?an(e,n,o):de(e,n,Ot)};case"panXY":return(e,n,o)=>{if(n instanceof WheelEvent){he(e,n,Ut);return}return de(e,n,Ut)};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 cn(t){return typeof t=="function"?t:Zs(t)}function qs(t,e){const n=t.plotBox,o=e.left/n.width,s=(e.left+e.width)/n.width,r={};for(const l of t.scaleManager.getAllScales()){if(l.ori!==G.Horizontal||!q(l))continue;const i=gt(n.left+o*n.width,l,n.width,n.left),a=gt(n.left+s*n.width,l,n.width,n.left);r[l.id]={min:Math.min(i,a),max:Math.max(i,a)}}return{left:o,right:s,ranges:r}}function Js(t,e){D.useEffect(()=>{if(e!=null)return Qs(t,e)},[t,e])}function Qs(t,e){let n=null,o=!1,s=null,r=-1,l=-1;function i(x){const T=e.getBoundingClientRect(),I=t.plotBox;return{cx:x.clientX-T.left-I.left,cy:x.clientY-T.top-I.top}}function a(x,T){const I=t.plotBox;return x>=0&&x<=I.width&&T>=0&&T<=I.height}function u(x,T){const I=e.getBoundingClientRect(),_=x-I.left,$=T-I.top,R=t.plotBox;for(const N of t.axisStates){const z=N.config,j=z.side;if(N._size<=0)continue;const J=$>=R.top&&$<=R.top+R.height,tt=_>=R.left&&_<=R.left+R.width;if(j===K.Left&&_<R.left&&J||j===K.Right&&_>R.left+R.width&&J||j===K.Top&&$<R.top&&tt||j===K.Bottom&&$>R.top+R.height&&tt)return{scaleId:z.scale,ori:Ft(j)}}return null}function c(x){const{cx:T,cy:I}=i(x);return{cx:T,cy:I,inPlot:a(T,I)}}function d(x){if(n==null){p();return}x.target instanceof Node&&e.contains(x.target)||(o=!0,n.onMove(t,x,c(x)),M(x,x))}function f(x){p(),n!=null&&(x.target instanceof Node&&e.contains(x.target)||(n.onEnd(t,x,c(x)),n=null,r=-1,l=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw()))}function h(){document.addEventListener("mousemove",d),document.addEventListener("mouseup",f)}function p(){document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",f)}function w(){n!=null&&(n=null,p(),t.cursorManager.hide(),t.scheduleCursorRedraw())}function m(x,T,I){const _=t.cursorManager.state;let $=null;if(_.activeGroup>=0&&_.activeDataIdx>=0){const R=t.dataStore.data[_.activeGroup];if(R!=null){const N=R.x[_.activeDataIdx],z=R.series[_.activeSeriesIdx],j=z!=null?z[_.activeDataIdx]:void 0;if(N!=null&&j!=null){const O=t.plotBox,J=t.scaleManager.getGroupXScaleKey(_.activeGroup),tt=J!=null?t.scaleManager.getScale(J):void 0,pt=t.seriesConfigMap.get(`${_.activeGroup}:${_.activeSeriesIdx}`),At=pt!=null?t.scaleManager.getScale(pt.yScale):void 0;let Lt=T,se=I;tt!=null&&q(tt)&&(Lt=U(N,tt,O.width,O.left)-O.left),At!=null&&q(At)&&(se=U(j,At,O.height,O.top)-O.top);const He=T-Lt,ze=I-se;$={group:_.activeGroup,seriesIdx:_.activeSeriesIdx,dataIdx:_.activeDataIdx,xVal:N,yVal:j,pxX:Lt,pxY:se,dist:Math.sqrt(He*He+ze*ze)}}}}return{plotX:T,plotY:I,point:$,srcEvent:x}}function v(x,T,I,_=!0){const $=Us(t.actionMap,x,T,I,_);if(!($==null||$==="none"))return cn($)}function M(x,T){const{cx:I,cy:_}=i(x);if(!a(I,_)&&n==null){r=-1,l=-1,e.style.cursor="",t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw();return}e.style.cursor="none";const $=I!==r||_!==l;if(r=I,l=_,t.cursorManager.update(I,_,t.plotBox,t.dataStore.data,t.seriesConfigs,R=>t.scaleManager.getScale(R),R=>t.dataStore.getWindow(R),R=>t.scaleManager.getGroupXScaleKey(R)),$){const R={cx:I,cy:_,inPlot:a(I,_)},N=t.actionMap.get("hover");if(N!=null&&N!=="none"){const z=cn(N);if(z!=null){const j=T??void 0;j!=null&&z(t,j,R)}if(t.focusAlpha<1){const j=t.cursorManager.state;if(j.activeGroup>=0&&j.activeSeriesIdx>=0){const O=t.seriesConfigs.findIndex(J=>J.group===j.activeGroup&&J.index===j.activeSeriesIdx);O>=0&&t.focusedSeries!==O&&(t.focusedSeries=O,t.scheduleRedraw())}}}}if(T!=null&&t.eventCallbacks.onCursorMove!=null&&a(I,_))try{t.eventCallbacks.onCursorMove(m(T,I,_))}catch(R){console.warn("[uPlot+] event callback error:",R)}t.scheduleCursorRedraw()}function k(){document.activeElement!==e&&e.focus()}function F(x){const T=c(x),I=u(x.clientX,x.clientY);let _;if(I!=null&&x.button===0)_=I.ori===G.Horizontal?"xGutterDrag":"yGutterDrag",T.scaleId=I.scaleId,T.ori=I.ori;else if(_=Gs(x),!T.inPlot)return;T.action=_;const $=v(_,x,T,!1);if($==null)return;(x.button!==0||I!=null)&&x.preventDefault();const R=$(t,x,T);R!=null&&(n=R,o=!1,h())}function C(x){if(n!=null){o=!0,n.onMove(t,x,c(x)),M(x,x);return}M(x,x)}function L(x){if(n!=null){n.onEnd(t,x,c(x)),n=null;return}}function g(x){if(o){o=!1;return}const T=c(x);if(!T.inPlot)return;const I=Ns(x);T.action=I;const _=v(I,x,T);_!=null&&_(t,x,T);const $=t.eventCallbacks.onClick;if($!=null)try{$(m(x,T.cx,T.cy))}catch(R){console.warn("[uPlot+] event callback error:",R)}}function S(x){if(n!=null){x.preventDefault();return}const T=c(x);if(!T.inPlot)return;x.preventDefault(),T.action="rightClick";const I=v("rightClick",x,T);I!=null&&I(t,x,T);const _=t.eventCallbacks.onContextMenu;if(_!=null)try{_(m(x,T.cx,T.cy))}catch($){console.warn("[uPlot+] event callback error:",$)}}function y(x){var T,I;if(n==null){r=-1,l=-1,e.style.cursor="",t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw();try{(I=(T=t.eventCallbacks).onCursorLeave)==null||I.call(T)}catch(_){console.warn("[uPlot+] event callback error:",_)}}}function b(x){const T=c(x);if(!T.inPlot)return;if(t.eventCallbacks.onDblClick!=null){let $;try{$=t.eventCallbacks.onDblClick(m(x,T.cx,T.cy))}catch(R){console.warn("[uPlot+] event callback error:",R)}if($===!1)return}const I=js(x);T.action=I;const _=v(I,x,T,!1);_!=null&&_(t,x,T)}function P(x){const T=c(x);if(!T.inPlot)return;const I=Xs(x);T.action=I;const _=v(I,x,T);_!=null&&(x.preventDefault(),_(t,x,T))}function A(x){if(x.touches.length===2){const R=x.touches[0],N=x.touches[1];if(R==null||N==null)return;const z=N.clientX-R.clientX,j=N.clientY-R.clientY;s={dist:Math.sqrt(z*z+j*j),midX:(R.clientX+N.clientX)/2,midY:(R.clientY+N.clientY)/2},n=null;return}const T=x.touches[0];if(T==null)return;const I=c(T);if(!I.inPlot)return;const _=v("touchDrag",x,I);if(_==null)return;const $=_(t,x,I);$!=null&&(n=$,o=!1)}function E(x){if(x.touches.length===2&&s!=null){x.preventDefault();const I=x.touches[0],_=x.touches[1];if(I==null||_==null)return;const $=_.clientX-I.clientX,R=_.clientY-I.clientY,N=Math.sqrt($*$+R*R),z=c({clientX:s.midX,clientY:s.midY});if(v("pinch",x,z)!=null){const O=N/s.dist,J=t.plotBox;for(const tt of t.scaleManager.getAllScales()){if(tt.ori!==G.Horizontal||!q(tt))continue;const pt=gt(z.cx+J.left,tt,J.width,J.left),At=pt-(pt-tt.min)/O,Lt=pt+(tt.max-pt)/O;tt.min=Math.min(At,Lt),tt.max=Math.max(At,Lt),tt.auto=!1,ht(tt)}s.dist=N,t.renderer.clearCache(),t.scheduleRedraw(),Wt(t)}return}const T=x.touches[0];if(T!=null){if(n!=null){o=!0,n.onMove(t,x,c(T)),M(T,x),x.preventDefault();return}M(T,x)}}function W(x){if(s!=null){s=null;return}const T=x.changedTouches[0];T!=null&&n!=null&&(n.onEnd(t,x,c(T)),n=null)}function H(x){const T={cx:r,cy:l,inPlot:r>=0&&l>=0},I=Os(x);T.action=I;const _=v(I,x,T);_!=null&&(x.preventDefault(),_(t,x,T))}return e.addEventListener("mouseenter",k),e.addEventListener("mousemove",C),e.addEventListener("mousedown",F),e.addEventListener("mouseup",L),e.addEventListener("click",g),e.addEventListener("contextmenu",S),e.addEventListener("mouseleave",y),e.addEventListener("dblclick",b),e.addEventListener("wheel",P,{passive:!1}),e.addEventListener("touchstart",A,{passive:!0}),e.addEventListener("touchmove",E,{passive:!1}),e.addEventListener("touchend",W),e.addEventListener("keydown",H),window.addEventListener("blur",w),()=>{p(),e.removeEventListener("mouseenter",k),e.removeEventListener("mousemove",C),e.removeEventListener("mousedown",F),e.removeEventListener("mouseup",L),e.removeEventListener("click",g),e.removeEventListener("contextmenu",S),e.removeEventListener("mouseleave",y),e.removeEventListener("dblclick",b),e.removeEventListener("wheel",P),e.removeEventListener("touchstart",A),e.removeEventListener("touchmove",E),e.removeEventListener("touchend",W),e.removeEventListener("keydown",H),window.removeEventListener("blur",w)}}const me=new Map;function tl(t){let e=me.get(t);return e==null&&(e=new el(t),me.set(t,e)),e}class el{constructor(e){Y(this,"key");Y(this,"members",new Set);Y(this,"publishing",!1);Y(this,"syncedStores",new WeakSet);this.key=e}join(e){this.members.add(e)}leave(e){this.members.delete(e),this.members.size===0&&me.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 i of this.members)i!==e&&(this.syncedStores.add(i),i.cursorManager.hide(),i.scheduleCursorRedraw());this.publishing=!1;return}const l=e.dataStore.getXValues(o)[s];if(l==null){this.publishing=!1;return}for(const i of this.members)i!==e&&(this.syncedStores.add(i),i.cursorManager.syncToValue(l,i,o),i.scheduleCursorRedraw());this.publishing=!1}}function nl(t,e){D.useEffect(()=>{if(e==null)return;const n=tl(e);n.join(t);let o=-1,s=-1;const r=t.subscribeCursor(()=>{const{activeGroup:l,activeDataIdx:i}=t.cursorManager.state;l===o&&i===s||(o=l,s=i,n.pub(t))});return()=>{r(),n.leave(t)}},[t,e])}function Vn(t){if(t instanceof Float64Array)return{x:t,validIndices:null};const e=t;let n=!1;for(let r=0;r<e.length;r++)if(e[r]==null){n=!0;break}if(!n){const r=[];for(const l of e)l!=null&&r.push(l);return{x:new Float64Array(r),validIndices:null}}const o=[],s=[];for(let r=0;r<e.length;r++){const l=e[r];l!=null&&(o.push(r),s.push(l))}return{x:new Float64Array(s),validIndices:o}}function Gn(t,e){if(t instanceof Float64Array){const o=new Float64Array(e.length);for(let s=0;s<e.length;s++){const r=e[s];r!=null&&(o[s]=t[r]??0)}return o}const n=t;return e.map(o=>n[o]??null)}function ol(t){return t.every(e=>e!=null)}function Nn(t){return t instanceof Float64Array?t:ol(t)?new Float64Array(t):t}function un(t){const{x:e,validIndices:n}=Vn(t.x),o=Nn(t.y);return{x:e,series:[n!=null?Gn(o,n):o]}}function sl(t){const{x:e,validIndices:n}=Vn(t.x),o=t.series.map(s=>{const r=Nn(s);return n!=null?Gn(r,n):r});return{x:e,series:o}}function jn(t){if(!Array.isArray(t))return[un(t)];if(t.length===0)return[];const e=t[0];return e==null?[]:"series"in e?t.filter(n=>"series"in n).map(sl):t.filter(n=>"y"in n).map(un)}const Xn=D.createContext(0);function ll({theme:t,children:e}){const n=D.useMemo(()=>Hn(t),[t]),o=D.useRef(0),s=D.useMemo(()=>++o.current,[t]);return B.jsx(Xn.Provider,{value:s,children:B.jsx("div",{style:n,children:e})})}function Te({width:t,height:e,data:n,children:o,className:s,pxRatio:r,title:l,xlabel:i,ylabel:a,onDraw:u,onCursorDraw:c,syncKey:d,actions:f,theme:h,locale:p,timezone:w,onClick:m,onContextMenu:v,onDblClick:M,onCursorMove:k,onCursorLeave:F,onScaleChange:C,onSelect:L}){const g=zs(),[S,y]=D.useState(null),b=r??(typeof window<"u"&&window.devicePixelRatio||1),P=D.useMemo(()=>h!=null?Hn(h):void 0,[h]),A=D.useRef(P);D.useEffect(()=>{A.current!==P&&(A.current=P,g.renderer.invalidateSnapshot(),g.scheduleRedraw())},[g,P]);const E=D.useContext(Xn),W=D.useRef(E);D.useEffect(()=>{W.current!==E&&(W.current=E,g.renderer.invalidateSnapshot(),g.scheduleRedraw())},[g,E]),D.useEffect(()=>{g.actionMap=f!=null?new Map([...Kt,...f]):new Map(Kt)},[g,f]),D.useLayoutEffect(()=>{g.setLabels(l,i,a,p,w)},[g,l,i,a,p,w]),D.useEffect(()=>{const z=g.eventCallbacks;z.onClick=m,z.onContextMenu=v,z.onDblClick=M,z.onCursorMove=k,z.onCursorLeave=F,z.onScaleChange=C,z.onSelect=L},[g,m,v,M,k,F,C,L]),Js(g,S),nl(g,d);const H=D.useRef(null),x=D.useCallback(z=>{H.current!==z&&(H.current=z,g.setCanvas(z),z&&(Object.defineProperty(z,"__chartStore",{value:g,configurable:!0}),g.scheduleRedraw()))},[g]),T=D.useRef(null),I=D.useCallback(z=>{T.current!==z&&(T.current=z,y(z))},[]),_=D.useRef(u);D.useLayoutEffect(()=>{_.current=u});const $=D.useRef(c);D.useLayoutEffect(()=>{$.current=c});const R=D.useRef(!1),N=D.useRef(n);return D.useLayoutEffect(()=>{n===N.current&&g.dataStore.data.length>0||(N.current=n,R.current=!0,g.setData(jn(n)),g.scheduleRedraw())},[g,n]),D.useLayoutEffect(()=>{g.setSize(t,e,b),R.current&&g.redrawSync()},[g,t,e,b]),D.useEffect(()=>()=>{g.setCanvas(null),g.scheduler.cancel(),g.focusedSeries=null,g.eventCallbacks={}},[g]),D.useEffect(()=>{if(S==null||typeof ResizeObserver>"u")return;const z=new ResizeObserver(j=>{const O=j[0];if(O==null)return;const{width:J,height:tt}=O.contentRect;J>0&&tt>0&&(J!==g.width||tt!==g.height)&&(g.setSize(Math.round(J),Math.round(tt)),g.scheduleRedraw())});return z.observe(S),()=>{z.disconnect()}},[g,S]),D.useEffect(()=>{if(typeof MutationObserver>"u")return;const z=document.documentElement,j=new MutationObserver(()=>{g.renderer.invalidateSnapshot(),g.scheduleRedraw()});return j.observe(z,{attributes:!0,attributeFilter:["class"]}),()=>{j.disconnect()}},[g]),D.useLayoutEffect(()=>{const z=j=>{var O;(O=_.current)==null||O.call(_,j)};return g.drawHooks.add(z),()=>{g.drawHooks.delete(z)}},[g]),D.useLayoutEffect(()=>{const z=(j,O)=>{var J;(J=$.current)==null||J.call($,j,O)};return g.cursorDrawHooks.add(z),()=>{g.cursorDrawHooks.delete(z)}},[g]),B.jsx($n.Provider,{value:g,children:B.jsxs("div",{className:s,style:{...P,position:"relative",display:"flex",flexDirection:"column",width:`${t}px`,isolation:"isolate"},children:[B.jsx("div",{ref:I,tabIndex:0,"data-testid":"chart-container",style:{position:"relative",width:`${t}px`,height:`${e}px`,cursor:"default",order:0,outline:"none"},children:B.jsx("canvas",{ref:x,style:{position:"absolute",left:0,top:0}})}),o]})})}function Yt(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function rl(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 il(t,e){if(t===null||!Yt(t)||!Yt(e))return!1;const n=t,o=e,s=Object.keys(n),r=Object.keys(o);if(s.length!==r.length)return!1;for(const l of r){const i=n[l],a=o[l];if(i!==a)if(Yt(i)&&Yt(a)){if(!rl(i,a))return!1}else return!1}return!0}function Fe(t,e,n,o,s){const r=nt(),l=D.useRef(t);D.useLayoutEffect(()=>{l.current=t}),D.useLayoutEffect(()=>{const a=l.current;return n(r,a),r.scheduleRedraw(),()=>{o(r,a),r.scheduleRedraw()}},[r,...e]);const i=D.useRef(t);D.useLayoutEffect(()=>{il(i.current,t)||(i.current=t,s(r,t),r.scheduleRedraw())})}function we(t){return Fe(t,[t.id],(e,n)=>e.registerScale(n),(e,n)=>e.unregisterScale(n.id),(e,n)=>e.updateScale(n)),null}function fn(t,e,n){var c;const o=(c=t.paths)==null?void 0:c.defaults,s=n??et.seriesColors,r=t.stroke==null,l=t.stroke??s[e%s.length]??"#000",i=t.fill??(o==null?void 0:o.fill),a=i==="auto"&&typeof l=="string",u=a?ke(l,.5):i==="auto"?void 0:i;return{...o,...t,yScale:t.yScale??"y",show:t.show??!0,stroke:l,fill:u,_autoStroke:r,_autoFill:a,_internal:t._internal}}function Vt(t){return Fe(t,[t.group,t.index],(e,n)=>e.registerSeries(fn(n,e.seriesConfigs.length,e.theme.seriesColors)),(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(fn(n,o>=0?o:e.seriesConfigs.length,e.theme.seriesColors))}),null}function al(t){return{...t,side:t.side??(t.scale==="x"?K.Bottom:K.Left),show:t.show??!0}}function Bt(t){const e=al(t);return Fe(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 cl({series:t,group:e,fill:n,dir:o}){const s=nt(),r=D.useRef(null),l=t[0],i=t[1];return D.useLayoutEffect(()=>{const a={series:[l,i],group:e,fill:n,dir:o};return r.current!=null&&s.unregisterBand(r.current),r.current=a,s.registerBand(a),s.scheduleRedraw(),()=>{r.current!=null&&s.unregisterBand(r.current),r.current=null,s.scheduleRedraw()}},[s,l,i,e,n,o]),null}const Ae=12,On=3,Un=1,Zt=4,dn=1,Yn=6,Kn=4,Zn=4,hn=16,ul=`${et.overlayFontSize}px ${et.overlayFontFamily}`,fl=`bold ${et.overlayFontSize}px ${et.overlayFontFamily}`;function dl(t){return`${t.overlayFontSize}px ${t.overlayFontFamily}`}function hl(t){return`bold ${t.overlayFontSize}px ${t.overlayFontFamily}`}const gl={position:"absolute",zIndex:ot("overlayZ"),background:ot("panelBg"),border:`1px solid ${ot("panelBorder")}`,borderRadius:4,padding:`${Kn}px ${Yn}px`,fontSize:ot("overlayFontSize"),fontFamily:ot("overlayFontFamily"),userSelect:"none",boxShadow:ot("panelShadow"),whiteSpace:"nowrap"},pl={width:Ae,height:On,borderRadius:Un,display:"inline-block",flexShrink:0},gn={fontWeight:600},oe={display:"flex",alignItems:"center",gap:Zt,padding:`1px ${Zn}px`,background:"none",border:"none",color:"inherit",font:"inherit",width:"100%",textAlign:"left"},ml={...oe,opacity:1,cursor:"pointer"},wl={...oe,opacity:1,cursor:"default"},Sl={...oe,opacity:ot("overlayHiddenOpacity"),cursor:"pointer"},vl={...oe,opacity:ot("overlayHiddenOpacity"),cursor:"default"},pn=new Map;function mn(t){let e=pn.get(t);return e==null&&(e={...pl,backgroundColor:t},pn.set(t,e)),e}function Le({label:t,color:e,value:n,isHidden:o,onClick:s}){const r=o?s?Sl:vl:s?ml:wl;return s!=null?B.jsxs("button",{type:"button",onClick:s,style:r,"aria-label":`Toggle ${t}`,children:[B.jsx("span",{style:mn(e)}),B.jsx("span",{children:t}),n&&B.jsx("span",{style:gn,children:n})]}):B.jsxs("div",{style:r,children:[B.jsx("span",{style:mn(e)}),B.jsx("span",{children:t}),n&&B.jsx("span",{style:gn,children:n})]})}const Pe=D.forwardRef(function({left:e,top:n,children:o,className:s,style:r,"data-testid":l,onMouseDown:i,onMouseEnter:a,onMouseLeave:u},c){return B.jsx("div",{ref:c,className:s,"data-testid":l,onMouseDown:i,onMouseEnter:a,onMouseLeave:u,style:{...gl,left:e,top:n,...r},children:o})});function wn(t,e=4){return t==null?"—":typeof t=="number"?t.toPrecision(e):String(t)}function qn(t,e,n,o,s,r=4){if(s<0||o<0||e!==o)return"";const i=t.dataStore.getYValues(e,n)[s];return i==null?"":typeof i=="number"?i.toPrecision(r):String(i)}const bl={width:Ae,height:On,borderRadius:Un,display:"inline-block"},yl={fontWeight:600},Jn={display:"inline-flex",alignItems:"center",gap:Zt,padding:"2px 8px",cursor:"pointer",fontSize:ot("overlayFontSize"),fontFamily:ot("overlayFontFamily"),background:"none",border:"none",color:"inherit"},xl={...Jn,opacity:1},Ml={...Jn,opacity:ot("overlayHiddenOpacity")},Sn=new Map,kl={display:"flex",flexWrap:"wrap",justifyContent:"center",order:-1,padding:"4px 0"},Cl={display:"flex",flexWrap:"wrap",justifyContent:"center",order:1,padding:"4px 0"};function Tl({group:t,index:e,label:n,color:o,isHidden:s,valueStr:r,store:l}){let i=Sn.get(o);return i==null&&(i={...bl,backgroundColor:o},Sn.set(o,i)),B.jsxs("button",{type:"button","data-testid":`legend-item-${t}-${e}`,onClick:()=>l.toggleSeries(t,e),"aria-pressed":!s,"aria-label":`Toggle ${n}`,style:s?Ml:xl,children:[B.jsx("span",{style:i}),B.jsx("span",{children:n}),r&&B.jsx("span",{style:yl,children:r})]})}function Fl({show:t=!0,position:e="bottom",className:n}){const o=nt(),s=D.useSyncExternalStore(o.subscribeCursor,o.getSnapshot);if(!t)return null;const{activeGroup:r,activeDataIdx:l}=s;return B.jsx("div",{className:n,"data-testid":"legend",style:e==="top"?kl:Cl,children:o.seriesConfigs.map(i=>{if(i.legend===!1||i._internal)return null;const a=Ht(i),u=qn(o,i.group,i.index,r,l);return B.jsx(Tl,{group:i.group,index:i.index,label:i.label??`Series ${i.index}`,color:a,isHidden:i.show===!1,valueStr:u,store:o},`${i.group}:${i.index}`)})})}const wt=8;function Al(t,e,n,o){if(t!=null&&typeof t=="object")return t;switch(t){case"top-left":return{x:e.left+wt,y:e.top+wt};case"bottom-left":return{x:e.left+wt,y:e.top+e.height-o-wt};case"bottom-right":return{x:e.left+e.width-n-wt,y:e.top+e.height-o-wt};case"top-right":case void 0:default:return{x:e.left+e.width-n-wt,y:e.top+wt}}}function Ll(t,e,n,o,s,r,l,i,a,u){if(t<0)return null;const c=rt(t+n+l,n,n+s-a),d=rt(e+o+i,o,o+r-u);return{x:c,y:d}}function vn(t,e,n,o,s,r,l){const i=Math.max(e,Math.min(t.x,e+o-r)),a=Math.max(n,Math.min(t.y,n+s-l));return i===t.x&&a===t.y?t:{x:i,y:a}}const Pl={pointerEvents:"none"};function El(t,e,n){return{pointerEvents:"auto",cursor:t?"grabbing":"grab",opacity:e||t?1:n,transition:"opacity 0.2s ease"}}const Il={};function Qn({mode:t,show:e,position:n,offset:o,idleOpacity:s,estimatedSize:r}){const l=nt(),i=D.useSyncExternalStore(l.subscribeCursor,l.getSnapshot),[a,u]=D.useState(null),[c,d]=D.useState(!1),[f,h]=D.useState(!1),p=D.useRef(!1),w=D.useRef(!1),m=D.useRef({dx:0,dy:0}),[v,M]=D.useState(!1),k=D.useRef(null),[F,C]=D.useState({w:0,h:0});D.useLayoutEffect(()=>{if(t!=="cursor")return;const b=k.current;if(!b)return;const P=b.offsetWidth,A=b.offsetHeight;(P!==F.w||A!==F.h)&&C({w:P,h:A})}),D.useLayoutEffect(()=>{if(t!=="draggable"||v||i.plotWidth<=0)return;M(!0);const b=k.current,P=(b==null?void 0:b.offsetWidth)??r.w,A=(b==null?void 0:b.offsetHeight)??r.h;u(Al(n,l.plotBox,P,A))},[t,v,i.plotWidth,n,l.plotBox,r]),D.useLayoutEffect(()=>{if(t!=="draggable"||!v||a==null||f||i.plotWidth<=0)return;const b=k.current;if(!b)return;const P=b.offsetWidth,A=b.offsetHeight,E=vn(a,i.plotLeft,i.plotTop,i.plotWidth,i.plotHeight,P,A);E!==a&&u(E)}),D.useEffect(()=>{if(!e||t!=="draggable")return;const b=A=>{var H;if(!p.current)return;w.current=!0;const E=(H=l.canvas)==null?void 0:H.parentElement;if(!E)return;const W=E.getBoundingClientRect();u({x:A.clientX-W.left-m.current.dx,y:A.clientY-W.top-m.current.dy})},P=()=>{p.current=!1,h(!1)};return window.addEventListener("mousemove",b),window.addEventListener("mouseup",P),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",P)}},[l,e,t]);const L=b=>{if(t!=="draggable"||(b.stopPropagation(),b.preventDefault(),p.current=!0,h(!0),w.current=!1,!(b.currentTarget instanceof HTMLElement)))return;const P=b.currentTarget.getBoundingClientRect();m.current={dx:b.clientX-P.left,dy:b.clientY-P.top}};let g=null;if(e)if(t==="cursor"){const b=F.w||r.w,P=F.h||r.h;g=Ll(i.left,i.top,i.plotLeft,i.plotTop,i.plotWidth,i.plotHeight,o.x??0,o.y??0,b,P)}else a!=null&&(f?g=a:g=vn(a,i.plotLeft,i.plotTop,i.plotWidth,i.plotHeight,r.w,r.h));const S=t==="draggable"?El(f,c,s):Pl;return{panelRef:k,renderPos:g,isDragging:f,hovered:c,didDrag:w,panelStyle:S,panelHandlers:t==="draggable"?{onMouseDown:L,onMouseEnter:()=>d(!0),onMouseLeave:()=>{d(!1),w.current=!1}}:Il}}function ge(t,e){const n=$e.prepareWithSegments(t,e);let o=0;return $e.walkLineRanges(n,Number.POSITIVE_INFINITY,s=>{s.width>o&&(o=s.width)}),o}function Ee(t,e){const n=e!=null?dl(e):ul,o=e!=null?hl(e):fl;let s=0;for(const i of t.rows){const a=ge(i.label,n),u=i.value?ge(i.value,o):0,c=Zn*2+Ae+Zt+a+(i.value?Zt+u:0);c>s&&(s=c)}let r=0,l=0;return t.header&&(r=ge(t.header,o)+8,l=hn+2),{w:dn*2+Yn*2+Math.max(s,r),h:dn*2+Kn*2+l+t.rows.length*hn}}const Dl={x:12,y:-12},_l={w:0,h:0},Wl={zIndex:ot("tooltipZ")},Rl={fontWeight:600,marginBottom:2,padding:"0 4px"};function Hl({show:t=!0,className:e,children:n,offset:o=Dl,precision:s=2,mode:r="cursor",position:l="top-right",idleOpacity:i=.8}){const a=nt(),u=D.useSyncExternalStore(a.subscribeCursor,a.getSnapshot),{activeGroup:c,activeDataIdx:d}=u,f=a.plotBox,h=d>=0&&c>=0&&u.left>=0,p={x:o.x??12,y:o.y??-12};let w=null,m="";const v=[];if(h){const L=a.dataStore.data[c];w=L!=null?L.x[d]??null:null,m=w!=null?parseFloat(w.toFixed(s)).toString():"";for(const g of a.seriesConfigs){if(g.show===!1||g.legend===!1||g._internal)continue;const S=a.dataStore.getYValues(g.group,g.index),y=g.group===c?S[d]??null:null;v.push({label:g.label??`Series ${g.index}`,value:y,color:Ht(g),group:g.group,index:g.index})}}else if(r==="draggable")for(const L of a.seriesConfigs)L.show===!1||L.legend===!1||L._internal||v.push({label:L.label??`Series ${L.index}`,value:null,color:Ht(L),group:L.group,index:L.index});const M=v.length>0?Ee({header:m||void 0,rows:v.map(L=>({label:L.label,value:wn(L.value)}))},a.theme):_l,k=Qn({mode:r,show:t,position:l,offset:p,idleOpacity:i,estimatedSize:M});if(!t||r==="cursor"&&!h||k.renderPos==null)return null;const F={x:w,xLabel:m,items:v,left:u.left+f.left,top:u.top+f.top},C={...k.panelStyle,...Wl};return n?B.jsx("div",{ref:k.panelRef,className:e,"data-testid":"tooltip-panel",style:{position:"absolute",left:k.renderPos.x,top:k.renderPos.y,whiteSpace:"nowrap",...C},...k.panelHandlers,children:n(F)}):B.jsxs(Pe,{ref:k.panelRef,left:k.renderPos.x,top:k.renderPos.y,className:e,style:C,"data-testid":"tooltip-panel",...k.panelHandlers,children:[m&&B.jsx("div",{style:Rl,children:m}),v.map(L=>B.jsx(Le,{label:L.label,color:L.color,value:wn(L.value)},`${L.group}:${L.index}`))]})}const zl=8,Se=.01,qt=[.25,.75];function bn(t,e,n){if(t==null)return qt;const o=n-e;return o<=0?qt:[Math.max(0,(t[0]-e)/o),Math.min(1,(t[1]-e)/o)]}function $l(t,e,n){const o=n-e;return[e+t[0]*o,e+t[1]*o]}function Bl(t,e,n){return Math.abs(t-e[0])<n?"left":Math.abs(t-e[1])<n?"right":t>=e[0]&&t<=e[1]?"move":"outside"}function Vl(t,e,n){if(t==="move"){const s=e[1]-e[0],r=rt(e[0]+n,0,1-s);return[r,r+s]}if(t==="left")return[rt(e[0]+n,0,e[1]-Se),e[1]];const o=rt(e[1]+n,e[0]+Se,1);return[e[0],o]}function Gl({width:t,height:e,data:n,onRangeChange:o,initialRange:s,className:r,colors:l,grips:i=!1}){const a=D.useRef(null),u=D.useMemo(()=>jn(n),[n]),[c,d]=D.useState(()=>{if(s!=null&&u.length>0){const S=u[0];if(S!=null&&S.x.length>1){const y=S.x[0],b=S.x[S.x.length-1];return y==null||b==null?qt:bn(s,y,b)}}return qt});D.useEffect(()=>{if(s==null||u.length===0)return;const S=u[0];if(S==null||S.x.length<2)return;const y=S.x[0],b=S.x[S.x.length-1];y==null||b==null||d(bn(s,y,b))},[s,u]);const f=D.useRef(null);D.useEffect(()=>{if(o==null||u.length===0)return;const S=u[0];if(S==null||S.x.length<2)return;const y=S.x[0],b=S.x[S.x.length-1];if(y==null||b==null)return;const[P,A]=$l(c,y,b),E=f.current,W=Math.max(1e-10,Math.abs(A-P)*1e-12);E!=null&&Math.abs(E[0]-P)<W&&Math.abs(E[1]-A)<W||(f.current=[P,A],o(P,A))},[c,u,o]);const h=D.useRef(null),p=D.useCallback(S=>{const y=a.current;if(y==null)return 0;const b=y.getBoundingClientRect();return rt((S-b.left)/b.width,0,1)},[]),w=D.useCallback(S=>{const y=a.current;if(y==null)return;const b=p(S.clientX),P=y.getBoundingClientRect().width,A=P>0?zl/P:0,E=Bl(b,c,A);if(E==="outside"){const W=c[1]-c[0],H=W/2,x=rt(b-H,0,1-W),T=[x,x+W];d(T),h.current={mode:"move",startX:S.clientX,startFrac:T},y.setPointerCapture(S.pointerId),S.preventDefault();return}h.current={mode:E,startX:S.clientX,startFrac:[...c]},y.setPointerCapture(S.pointerId),S.preventDefault()},[c,p]),m=D.useCallback(S=>{const y=h.current;if(y==null)return;const b=p(S.clientX),P=p(y.startX),A=b-P;d(Vl(y.mode,y.startFrac,A))},[p]),v=D.useCallback(S=>{h.current=null;const y=a.current;y!=null&&y.releasePointerCapture(S.pointerId)},[]),M=.02,k=D.useCallback(S=>{const y=S.shiftKey?M*5:M;S.key==="ArrowLeft"?(S.preventDefault(),S.altKey?d(b=>[b[0],Math.max(b[0]+Se,b[1]-y)]):d(b=>{const P=b[1]-b[0],A=Math.max(0,b[0]-y);return[A,A+P]})):S.key==="ArrowRight"&&(S.preventDefault(),S.altKey?d(b=>[b[0],Math.min(1,b[1]+y)]):d(b=>{const P=b[1]-b[0],A=Math.min(1-P,b[0]+y);return[A,A+P]}))},[]),F=`${c[0]*100}%`,C=`${(c[1]-c[0])*100}%`,L=u[0],g=L!=null?L.series.length:0;return B.jsxs("div",{className:r,"data-testid":"zoom-ranger",style:{position:"relative",width:t,height:e},children:[B.jsxs(Te,{width:t,height:e,data:u,children:[B.jsx(Bt,{scale:"x",show:!1}),B.jsx(Bt,{scale:"y",show:!1}),Array.from({length:g},(S,y)=>B.jsx(Vt,{group:0,index:y,yScale:"y",stroke:l!=null&&l[y]!=null?l[y]:`hsl(${y*137}, 60%, 50%)`,width:1},`0:${y}`))]}),B.jsxs("div",{ref:a,tabIndex:0,role:"slider","aria-label":"Zoom range","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(c[0]*100),"aria-valuetext":`${Math.round(c[0]*100)}% to ${Math.round(c[1]*100)}%`,onPointerDown:w,onPointerMove:m,onPointerUp:v,onKeyDown:k,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[B.jsx("div",{"data-testid":"zoom-ranger-dim-left",style:{position:"absolute",top:0,left:0,width:F,height:"100%",background:ot("rangerDim"),pointerEvents:"none"}}),B.jsx("div",{"data-testid":"zoom-ranger-dim-right",style:{position:"absolute",top:0,left:`${c[1]*100}%`,right:0,height:"100%",background:ot("rangerDim"),pointerEvents:"none"}}),B.jsx("div",{"data-testid":"zoom-ranger-selection",style:{position:"absolute",top:0,left:F,width:C,height:"100%",borderLeft:`2px solid ${ot("rangerAccent")}`,borderRight:`2px solid ${ot("rangerAccent")}`,boxSizing:"border-box",cursor:"grab",pointerEvents:"none"},children:i&&B.jsxs(B.Fragment,{children:[B.jsx("div",{"data-testid":"zoom-ranger-grip-left",style:{position:"absolute",left:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:ot("rangerAccent"),cursor:"ew-resize",pointerEvents:"auto"}}),B.jsx("div",{"data-testid":"zoom-ranger-grip-right",style:{position:"absolute",right:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:ot("rangerAccent"),cursor:"ew-resize",pointerEvents:"auto"}})]})})]})]})}function yt(t,e){const n=nt(),o=D.useRef(t);D.useLayoutEffect(()=>{o.current=t});const s=(e==null?void 0:e.clipped)!==!1;D.useLayoutEffect(()=>{const r=i=>o.current(i),l=s?n.drawHooks:n.unclippedDrawHooks;return l.add(r),()=>{l.delete(r)}},[n,s])}function Nl(t){const e=nt(),n=D.useRef(t);D.useLayoutEffect(()=>{n.current=t}),D.useLayoutEffect(()=>{const o=(s,r)=>n.current(s,r);return e.cursorDrawHooks.add(o),()=>{e.cursorDrawHooks.delete(o)}},[e])}function jl({lanes:t,laneHeight:e=24,gap:n=2,scaleId:o="x"}){const s=nt();return yt(({ctx:r,plotBox:l,pxRatio:i})=>{const a=s.scaleManager.getScale(o);if(a==null||!q(a))return;r.save();const u=(e+n)*i,c=e*i,d=l.top*i;r.fillStyle=s.theme.timelineLabel,r.font=`${11*i}px sans-serif`,r.textAlign="right",r.textBaseline="middle";for(let f=0;f<t.length;f++){const h=t[f];if(h==null)continue;const p=d+f*u;r.fillText(h.label,(l.left-6)*i,p+c/2)}r.beginPath(),r.rect(l.left*i,l.top*i,l.width*i,l.height*i),r.clip();for(let f=0;f<t.length;f++){const h=t[f];if(h==null)continue;const p=d+f*u;for(const w of h.segments){const m=U(w.start,a,l.width,l.left)*i,M=U(w.end,a,l.width,l.left)*i-m;M<=0||(r.fillStyle=w.color??s.theme.timelineSegment,r.fillRect(m,p,M,c),w.label!=null&&M>20*i&&(r.fillStyle=s.theme.timelineText,r.font=`${10*i}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(w.label,m+M/2,p+c/2,M-4*i)))}}r.restore()},{clipped:!1}),null}function Xl({stroke:t,fill:e,lineWidth:n,paths:o,fillTo:s}){const r=nt();return B.jsx(Vt,{group:0,index:0,yScale:"y",stroke:t??r.theme.sparklineStroke,fill:e,width:n,paths:o,fillTo:s})}function Ol({data:t,width:e=150,height:n=30,stroke:o,fill:s,lineWidth:r=1,paths:l,fillTo:i,className:a}){return B.jsx("div",{style:{pointerEvents:"none"},className:a,children:B.jsxs(Te,{width:e,height:n,data:t,children:[B.jsx(Bt,{scale:"x",show:!1}),B.jsx(Bt,{scale:"y",show:!1}),B.jsx(Xl,{stroke:o,fill:s,lineWidth:r,paths:l,fillTo:i})]})})}const Ul={x:12,y:-12},Yl={w:0,h:0};function Kl({mode:t="draggable",position:e="top-right",offset:n=Ul,idleOpacity:o=.3,show:s=!0,className:r}){const l=nt(),i=D.useSyncExternalStore(l.subscribeCursor,l.getSnapshot),{activeGroup:a,activeDataIdx:u}=i,c=[],d=l.seriesConfigs.filter(m=>m.legend!==!1&&!m._internal).map(m=>{const v=Ht(m),M=qn(l,m.group,m.index,a,u),k=m.label??`Series ${m.index}`;return c.push({label:k,value:M}),{cfg:m,color:v,value:M,label:k}}),f=d.length>0?Ee({rows:c},l.theme):Yl,h=Qn({mode:t,show:s,position:e,offset:n,idleOpacity:o,estimatedSize:f});if(!s||h.renderPos==null)return null;const p=(m,v)=>{h.didDrag.current||l.toggleSeries(m,v)},w=t==="draggable";return B.jsx(Pe,{ref:h.panelRef,left:h.renderPos.x,top:h.renderPos.y,className:r,style:h.panelStyle,"data-testid":"floating-legend",...h.panelHandlers,children:d.map(({cfg:m,color:v,value:M,label:k})=>B.jsx(Le,{label:k,color:v,value:M,isHidden:m.show===!1,onClick:w?()=>p(m.group,m.index):void 0},`${m.group}:${m.index}`))})}const Zl={pointerEvents:"none"};function ql({delay:t=1e3,show:e=!0,className:n}){const o=nt(),s=D.useSyncExternalStore(o.subscribeCursor,o.getSnapshot),[r,l]=D.useState(!1),i=D.useRef(-1),a=D.useRef(0),u=D.useRef(null),[c,d]=D.useState({w:0,h:0});if(D.useLayoutEffect(()=>{const C=u.current;if(!C)return;const L=C.offsetWidth,g=C.offsetHeight;(L!==c.w||g!==c.h)&&d({w:L,h:g})}),D.useEffect(()=>{const C=s.activeSeriesIdx;C!==i.current&&(i.current=C,l(!1),window.clearTimeout(a.current),C>=0&&(a.current=window.setTimeout(()=>l(!0),t)))},[s.activeSeriesIdx,t]),D.useEffect(()=>()=>{window.clearTimeout(a.current)},[]),!e||!r||s.left<0)return null;const f=o.seriesConfigs.find(C=>C.group===s.activeGroup&&C.index===s.activeSeriesIdx);if(!(f!=null&&f.label)||f.legend===!1)return null;const h=Ht(f),p=Ee({rows:[{label:f.label}]},o.theme),w=c.w||p.w,m=c.h||p.h,v=s.left+s.plotLeft,M=s.top+s.plotTop,k=rt(v-w/2,s.plotLeft,s.plotLeft+s.plotWidth-w),F=rt(M-m-12,s.plotTop,s.plotTop+s.plotHeight-m);return B.jsx(Pe,{ref:u,left:k,top:F,className:n,style:Zl,children:B.jsx(Le,{label:f.label,color:h})})}function to(t,e,n,o,s,r,l,i,a){const u=l/2;if(a.wickColor!=null&&(t.strokeStyle=a.wickColor,t.lineWidth=a.wickWidth??1,t.beginPath(),t.moveTo(e,n),t.lineTo(e,o),t.stroke()),a.capWidth!=null&&a.capWidth>0){const f=a.capWidth/2;t.strokeStyle=a.wickColor??"#555",t.lineWidth=a.wickWidth??1,t.beginPath(),t.moveTo(e-f,n),t.lineTo(e+f,n),t.moveTo(e-f,o),t.lineTo(e+f,o),t.stroke()}const c=Math.min(s,r),d=Math.abs(r-s);t.fillStyle=a.bodyFill,t.fillRect(e-u,c,l,d),a.bodyStroke!=null&&(t.strokeStyle=a.bodyStroke,t.lineWidth=a.bodyStrokeWidth??1.5,t.strokeRect(e-u,c,l,d)),i!=null&&a.midColor!=null&&(t.strokeStyle=a.midColor,t.lineWidth=a.midWidth??2.5,t.beginPath(),t.moveTo(e-u,i),t.lineTo(e+u,i),t.stroke())}function Jl({boxes:t,yScale:e="y",boxWidth:n=.5,fill:o,stroke:s,medianColor:r,whiskerColor:l,autoScales:i=!0,exposeUnderlyingSeries:a=!1}){const u=nt(),c=o??u.theme.boxFill,d=s??u.theme.boxStroke,f=r??u.theme.boxMedian,h=l??u.theme.boxWhisker;if(yt(({ctx:v,plotBox:M,valToX:k,valToY:F})=>{const C=M.width/t.length*n,L=C*.3;for(let g=0;g<t.length;g++){const S=t[g];if(S==null)continue;const y=k(g+1),b=F(S.min,e),P=F(S.q1,e),A=F(S.median,e),E=F(S.q3,e),W=F(S.max,e);y==null||b==null||P==null||A==null||E==null||W==null||to(v,y,b,W,P,E,C,A,{wickColor:h,bodyFill:c,bodyStroke:d,capWidth:L,midColor:f})}}),!i||t.length===0)return B.jsx(B.Fragment,{});let p=1/0,w=-1/0;for(const v of t)v.min<p&&(p=v.min),v.max>w&&(w=v.max);const m=(w-p)*.1||1;return B.jsxs(B.Fragment,{children:[B.jsx(we,{id:"x",auto:!1,min:.5,max:t.length+.5}),B.jsx(we,{id:e,auto:!1,min:p-m,max:w+m}),B.jsx(Vt,{group:0,index:0,yScale:e,show:!1,_internal:!a})]})}function Ql(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];if(o==null||s==null)return"rgb(0,0,0)";for(let u=0;u<n.length-1;u++){const c=n[u],d=n[u+1];if(c!=null&&d!=null&&e>=c[0]&&e<=d[0]){o=c,s=d;break}}const r=s[0]===o[0]?0:(e-o[0])/(s[0]-o[0]),l=Math.round(o[1]+r*(s[1]-o[1])),i=Math.round(o[2]+r*(s[2]-o[2])),a=Math.round(o[3]+r*(s[3]-o[3]));return`rgb(${l},${i},${a})`}function tr({grid:t,xRange:e,yRange:n,colorMap:o=Ql,yScale:s="y"}){return yt(({ctx:r,valToX:l,valToY:i})=>{var v;if(t.length===0)return;const a=t.length,u=((v=t[0])==null?void 0:v.length)??0;if(u===0)return;const c=(e==null?void 0:e[0])??0,d=(e==null?void 0:e[1])??a,f=(n==null?void 0:n[0])??0,h=(n==null?void 0:n[1])??u,p=(d-c)/a,w=(h-f)/u;let m=0;for(const M of t)for(const k of M)k>m&&(m=k);if(m!==0)for(let M=0;M<a;M++){const k=t[M];if(k==null)continue;const F=l(c+M*p),C=l(c+(M+1)*p);if(F==null||C==null)continue;const L=C-F;for(let g=0;g<u;g++){const S=k[g]??0,y=f+g*w,b=f+(g+1)*w,P=i(b,s),A=i(y,s);if(P==null||A==null)continue;const E=A-P;r.fillStyle=o(S/m),r.fillRect(F,P,L,E)}}}),null}function er(t,e,n,o,s){const r=(o-90)*(Math.PI/180),l=s,i=l*.35,a=Math.PI/6,u=e+Math.cos(r)*l,c=n+Math.sin(r)*l,d=e-Math.cos(r)*l*.5,f=n-Math.sin(r)*l*.5;t.beginPath(),t.moveTo(d,f),t.lineTo(u,c),t.stroke(),t.beginPath(),t.moveTo(u,c),t.lineTo(u-i*Math.cos(r-a),c-i*Math.sin(r-a)),t.moveTo(u,c),t.lineTo(u-i*Math.cos(r+a),c-i*Math.sin(r+a)),t.stroke()}function nr({directions:t,group:e=0,index:n=0,color:o,minSize:s=4,maxSize:r=10}){const l=nt(),i=o??l.theme.vectorColor;return yt(({ctx:a,valToX:u,valToY:c})=>{var M;const d=l.dataStore.data[e];if(d==null)return;const f=d.x,h=d.series[n];if(h==null)return;let p=1/0,w=-1/0;for(let k=0;k<h.length;k++){const F=h[k];F!=null&&(F<p&&(p=F),F>w&&(w=F))}const m=w-p||1,v=((M=l.seriesConfigs.find(k=>k.group===e&&k.index===n))==null?void 0:M.yScale)??"y";a.strokeStyle=i,a.lineWidth=1.5,a.lineCap="round";for(let k=0;k<f.length;k++){const F=h[k],C=t[k];if(F==null||C==null)continue;const L=f[k];if(L==null)continue;const g=u(L),S=c(F,v);if(g==null||S==null)continue;const y=(F-p)/m,b=s+y*(r-s);er(a,g,S,C,b)}}),null}const or=4;function Ie(t,e){t.strokeStyle=e.stroke??"red",t.lineWidth=e.width??1,e.dash&&t.setLineDash(e.dash)}function De(t,e){e.dash&&t.setLineDash([])}function eo(t,e,n,o={}){const{ctx:s,plotBox:r}=t,l=U(n,e,r.height,r.top);s.beginPath(),s.moveTo(r.left,l),s.lineTo(r.left+r.width,l),Ie(s,o),s.stroke(),De(s,o)}function no(t,e,n,o={}){const{ctx:s,plotBox:r}=t,l=U(n,e,r.width,r.left);s.beginPath(),s.moveTo(l,r.top),s.lineTo(l,r.top+r.height),Ie(s,o),s.stroke(),De(s,o)}function sr(t,e,n,o,s,r,l={}){const{ctx:i,plotBox:a}=t,u=U(o,e,a.width,a.left),c=U(s,n,a.height,a.top);i.font=l.font??"12px sans-serif",i.fillStyle=l.fill??"#000",i.textBaseline="bottom",i.fillText(r,u,c-or)}function oo(t,e,n,o,s={}){const{ctx:r,plotBox:l}=t,i=U(o,e,l.height,l.top),a=U(n,e,l.height,l.top);r.fillStyle=s.fill??"rgba(255,0,0,0.1)",r.fillRect(l.left,Math.min(i,a),l.width,Math.abs(a-i)),s.stroke&&(Ie(r,s),r.strokeRect(l.left,Math.min(i,a),l.width,Math.abs(a-i)),De(r,s))}function _e(t,e,n){const o=D.useRef(t);D.useLayoutEffect(()=>{o.current=t},[t]),yt(s=>{const r=s.getScale(e);r!=null&&n(s,r,o.current)})}function lr(t){const e=nt();return _e(t,t.yScale??"y",(n,o,s)=>{const r=e.theme;if(eo(n,o,s.value,{stroke:s.stroke??r.annotationStroke,width:s.width,dash:s.dash}),s.label!=null){const l=n.valToY(s.value,s.yScale??"y");if(l==null)return;const{ctx:i,plotBox:a}=n;i.font=s.labelFont??r.annotationFont,i.fillStyle=s.stroke??r.annotationStroke,i.textAlign="left",i.textBaseline="bottom",i.fillText(s.label,a.left+4,l-4)}}),null}function rr(t){const e=nt();return _e(t,t.xScale??"x",(n,o,s)=>{const r=e.theme;if(no(n,o,s.value,{stroke:s.stroke??r.annotationStroke,width:s.width,dash:s.dash}),s.label!=null){const l=n.valToX(s.value,s.xScale??"x");if(l==null)return;const{ctx:i,plotBox:a}=n;i.font=s.labelFont??r.annotationFont,i.fillStyle=s.stroke??r.annotationStroke,i.textAlign="center",i.textBaseline="bottom",i.fillText(s.label,l,a.top-4)}}),null}function ir(t){const e=nt();return _e(t,t.yScale??"y",(n,o,s)=>{oo(n,o,s.yMin,s.yMax,{fill:s.fill??e.theme.annotationFill,stroke:s.stroke,width:s.strokeWidth,dash:s.dash})}),null}function ar(t){const e=nt(),n=D.useRef(t);return D.useLayoutEffect(()=>{n.current=t}),yt(o=>{const s=n.current,r=o.valToX(s.x,s.xScale??"x"),l=o.valToY(s.y,s.yScale??"y");if(r==null||l==null)return;const i=e.theme,{ctx:a}=o;a.font=s.font??i.annotationFont,a.fillStyle=s.fill??i.annotationLabelFill,a.textAlign=s.align??"left",a.textBaseline=s.baseline??"bottom",a.fillText(s.text,r,l-4)}),null}function cr(t){const e=(n,o,s,r,l,i,a,u,c,d,f,h,p)=>{const w=(p==null?void 0:p.align)??t??1,m=(p==null?void 0:p.spanGaps)??!1;if([c,d]=Jt(o,c,d),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=b=>h(U(b,s,l,a)),M=b=>h(U(b,r,i,u)),k=s.ori===G.Horizontal?te:ee,F={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},C=F.stroke;let L=!1;const g=f===Z.Forward?c:d;let S=M(V(o,g)??0),y=v(V(n,g));k(C,y,S);for(let b=g;b>=c&&b<=d;b+=f){const P=o[b];if(P==null){P===null&&!m&&(L=!0);continue}const A=v(V(n,b)),E=M(P);if(w===1)k(C,A,S);else if(w===-1)k(C,y,E);else{const W=h((y+A)/2);k(C,W,S),k(C,W,E)}k(C,A,E),S=E,y=A}{const b=F.fill=new Path2D(C),P=p==null?void 0:p.fillToData;if(P!=null)for(let A=f===Z.Forward?d:c;A>=c&&A<=d;A-=f){const E=P[A],W=n[A];E!=null&&W!=null&&k(b,v(W),M(E))}else{const A=(p==null?void 0:p.fillTo)??r.min??0,E=M(A);let W=v(V(n,c)),H=v(V(n,d));f===Z.Backward&&([H,W]=[W,H]),k(b,H,E),k(b,W,E)}}if(L){const b=ye(n,o,c,d,f,v);F.gaps=b,F.clip=xe(b,s.ori,a,u,l,i)}return F};return e.defaults=Qt,e}function We(t){return t.defaults=Ao,t}function Re(){return We((e,n,o,s,r,l,i,a,u,c,d,f,h)=>{const p=(h==null?void 0:h.barWidth)??.6,w=(h==null?void 0:h.barGap)??0,m=(h==null?void 0:h.barRadius)??0,v=(h==null?void 0:h.barGroupIdx)??0,M=(h==null?void 0:h.barGroupCount)??1,k=H=>f(U(H,o,r,i)),F=H=>f(U(H,s,l,a));let C=r;if(c>u){let H=1/0,x=-1;for(let T=u;T<=c;T++)if(n[T]!=null){if(x>=0){const I=V(e,T),_=V(e,x),$=Math.abs(k(I)-k(_));$<H&&(H=$)}x=T}H<1/0&&(C=H)}const L=C*(1-p),g=Math.max(0,L+w),S=Math.max(1,f(C-g)),y=M>1?Math.max(1,f(S/Math.max(1,M))):S,b=(h==null?void 0:h.fillTo)??s.min??0,P=F(b),A=h==null?void 0:h.fillToData,E=new Path2D,W=o.ori===G.Horizontal;for(let H=d===Z.Forward?u:c;H>=u&&H<=c;H+=d){const x=n[H];if(x==null)continue;const T=k(V(e,H)),I=F(x),_=A!=null&&A[H]!=null?V(A,H)??b:b,$=A!=null&&A[H]!=null?F(_):P,R=M>1?(v-(M-1)/2)*y:0,N=f(T-y/2+R),z=Math.min(I,$),O=Math.max(I,$)-z;if(O!==0)if(m>0){const J=Math.min(m*y,O/2);dr(E,W,N,z,y,O,J,x<_)}else W?E.rect(N,z,y,O):E.rect(z,N,O,y)}return{stroke:E,fill:E,clip:null,band:null,gaps:null}})}function ur(t,e){const n=Re();return We((s,r,l,i,a,u,c,d,f,h,p,w,m)=>{const v={...m,barGroupIdx:t,barGroupCount:e};return n(s,r,l,i,a,u,c,d,f,h,p,w,v)})}function fr(t){const e=Re();return We((o,s,r,l,i,a,u,c,d,f,h,p,w)=>{const m={barWidth:.8,...w,...t!=null?{fillToData:t}:{}};return e(o,s,r,l,i,a,u,c,d,f,h,p,m)})}function dr(t,e,n,o,s,r,l,i){l=Math.min(l,s/2,r/2),e?i?(t.moveTo(n,o),t.lineTo(n+s,o),t.lineTo(n+s,o+r-l),t.arc(n+s-l,o+r-l,l,0,Math.PI/2),t.lineTo(n+l,o+r),t.arc(n+l,o+r-l,l,Math.PI/2,Math.PI),t.closePath()):(t.moveTo(n,o+r),t.lineTo(n,o+l),t.arc(n+l,o+l,l,Math.PI,Math.PI*1.5),t.lineTo(n+s-l,o),t.arc(n+s-l,o+l,l,Math.PI*1.5,0),t.lineTo(n+s,o+r),t.closePath()):i?(t.moveTo(o,n),t.lineTo(o,n+s),t.lineTo(o+r-l,n+s),t.arc(o+r-l,n+s-l,l,Math.PI/2,0,!0),t.lineTo(o+r,n+l),t.arc(o+r-l,n+l,l,0,-Math.PI/2,!0),t.closePath()):(t.moveTo(o+r,n),t.lineTo(o+l,n),t.arc(o+l,n+l,l,-Math.PI/2,Math.PI,!0),t.lineTo(o,n+s-l),t.arc(o+l,n+s-l,l,Math.PI,Math.PI/2,!0),t.lineTo(o+r,n+s),t.closePath())}function so(t){const e=(n,o,s,r,l,i,a,u,c,d,f,h,p)=>{const w=(p==null?void 0:p.spanGaps)??!1;if([c,d]=Jt(o,c,d),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const m=y=>h(U(y,s,l,a)),v=y=>h(U(y,r,i,u)),M=s.ori===G.Horizontal?te:ee,k=[],F=[];let C=!1;for(let y=f===Z.Forward?c:d;y>=c&&y<=d;y+=f){const b=o[y];b!=null?(k.push(m(V(n,y))),F.push(v(b))):b===null&&!w&&(C=!0)}const L=s.ori===G.Horizontal,g=t(k,F,L,h),S={stroke:g??new Path2D,fill:null,clip:null,band:null,gaps:null};if(g!=null){const y=S.fill=new Path2D(g),b=p==null?void 0:p.fillToData;if(b!=null)for(let P=f===Z.Forward?d:c;P>=c&&P<=d;P-=f){const A=b[P],E=n[P];A!=null&&E!=null&&M(y,m(E),v(A))}else{const P=(p==null?void 0:p.fillTo)??r.min??0,A=v(P);let E=m(V(n,c)),W=m(V(n,d));f===Z.Backward&&([W,E]=[E,W]),M(y,W,A),M(y,E,A)}}if(C){const y=ye(n,o,c,d,f,m);S.gaps=y,S.clip=xe(y,s.ori,a,u,l,i)}return S};return e.defaults=Qt,e}function hr(){return so(gr)}const gr=(t,e,n,o)=>{const s=t.length;if(s<2)return null;const r=new Path2D,l=t[0]??0,i=e[0]??0;if(n?r.moveTo(l,i):r.moveTo(i,l),s===2){const f=t[1]??0,h=e[1]??0;return n?r.lineTo(f,h):r.lineTo(h,f),r}const a=new Array(s),u=new Array(s-1),c=new Array(s-1),d=new Array(s-1);for(let f=0;f<s-1;f++)c[f]=(e[f+1]??0)-(e[f]??0),d[f]=(t[f+1]??0)-(t[f]??0),u[f]=d[f]!==0?(c[f]??0)/(d[f]??1):0;a[0]=u[0]??0;for(let f=1;f<s-1;f++){const h=u[f]??0,p=u[f-1]??0;if(h===0||p===0||p>0!=h>0)a[f]=0;else{const w=d[f]??1,m=d[f-1]??1;a[f]=3*(m+w)/((2*w+m)/p+(w+2*m)/h),isFinite(a[f]??0)||(a[f]=0)}}a[s-1]=u[s-2]??0;for(let f=0;f<s-1;f++){const h=d[f]??1,p=t[f]??0,w=e[f]??0,m=t[f+1]??0,v=e[f+1]??0,M=a[f]??0,k=a[f+1]??0,F=p+h/3,C=w+M*h/3,L=m-h/3,g=v-k*h/3;n?r.bezierCurveTo(F,C,L,g,m,v):r.bezierCurveTo(C,F,g,L,v,m)}return r};function pr(){return so(mr)}const mr=(t,e,n,o)=>{const s=t.length;if(s<2)return null;const r=new Path2D,l=o(t[0]??0),i=o(e[0]??0);if(n?r.moveTo(l,i):r.moveTo(i,l),s===2){const a=o(t[1]??0),u=o(e[1]??0);return n?r.lineTo(a,u):r.lineTo(u,a),r}for(let a=0;a<s-1;a++){const u=a===0?0:a-1,c=t[u]??0,d=e[u]??0,f=t[a]??0,h=e[a]??0,p=t[a+1]??0,w=e[a+1]??0,m=a+2<s?t[a+2]??0:p,v=a+2<s?e[a+2]??0:w,M=Math.hypot(c-f,d-h),k=Math.hypot(f-p,h-w),F=Math.hypot(p-m,w-v),C=Math.sqrt(F),L=F,g=Math.sqrt(k),S=k,y=Math.sqrt(M),b=M,P=2*b+3*y*g+S,A=2*L+3*C*g+S,E=3*y*(y+g),W=3*C*(C+g);let H,x,T,I;if(E>0){const _=1/E;H=(-S*c+P*f+b*p)*_,x=(-S*d+P*h+b*w)*_}else H=f,x=h;if(W>0){const _=1/W;T=(L*f+A*p-S*m)*_,I=(L*h+A*w-S*v)*_}else T=p,I=w;n?r.bezierCurveTo(H,x,T,I,p,w):r.bezierCurveTo(x,H,I,T,w,p)}return r};function wr(t=4){const e=(n,o,s,r,l,i,a,u,c,d,f,h,p)=>{const w=F=>h(U(F,s,l,a)),m=F=>h(U(F,r,i,u)),v=t/2,M=new Path2D,k=s.ori===G.Horizontal;for(let F=f===Z.Forward?c:d;F>=c&&F<=d;F+=f){const C=o[F];if(C==null)continue;const L=w(V(n,F)),g=m(C);k?(M.moveTo(L+v,g),M.arc(L,g,v,0,Math.PI*2)):(M.moveTo(g+v,L),M.arc(g,L,v,0,Math.PI*2))}return{stroke:M,fill:M,clip:null,band:null,gaps:null}};return e.defaults=Lo,e}function Sr({group:t=0,series:e=[0,1,2,3],yScale:n="y",upColor:o,downColor:s,bodyWidth:r=.6,wickWidth:l=1,exposeUnderlyingSeries:i=!1}){const a=nt(),u=o??a.theme.candlestickUp,c=s??a.theme.candlestickDown;return yt(({ctx:d,plotBox:f,valToX:h,valToY:p})=>{const w=a.dataStore.data[t];if(w==null)return;const m=w.x,v=w.series[e[0]],M=w.series[e[1]],k=w.series[e[2]],F=w.series[e[3]];if(v==null||M==null||k==null||F==null)return;const C=m.length;if(C===0)return;const L=Math.max(2,f.width/C*r);for(let g=0;g<C;g++){const S=m[g],y=v[g],b=M[g],P=k[g],A=F[g];if(S==null||y==null||b==null||P==null||A==null)continue;const E=h(S),W=p(b,n),H=p(P,n),x=p(y,n),T=p(A,n);if(E==null||W==null||H==null||x==null||T==null)continue;const _=A>=y?u:c;to(d,E,W,H,x,T,L,null,{wickColor:_,wickWidth:l,bodyFill:_})}}),B.jsx(B.Fragment,{children:e.map(d=>B.jsx(Vt,{group:t,index:d,yScale:n,show:!1,_internal:!i},d))})}function vr(t,e,n=0){const o=e??t.series.map((c,d)=>d),s=t.x.length,r=[],l=new Float64Array(s);for(let c=0;c<o.length;c++){const d=o[c];if(d==null)continue;const f=t.series[d];if(f==null)continue;const h=new Array(s);for(let p=0;p<s;p++){const w=f[p];w!=null?(l[p]=V(l,p)+w,h[p]=V(l,p)):h[p]=null}r.push(h)}const i=new Map;for(let c=0;c<o.length;c++){const d=o[c];d!=null&&i.set(d,c)}const a=[];for(let c=0;c<t.series.length;c++){const d=i.get(c)??-1,f=d>=0?r[d]:void 0;f!=null?a.push(f):a.push(t.series[c]??[])}const u=[];for(let c=o.length-1;c>0;c--){const d=o[c],f=o[c-1];d!=null&&f!=null&&u.push({group:n,series:[d,f]})}return{group:{x:t.x,series:a},bands:u}}function br(t){const e=new Set;for(const[r]of t)for(let l=0;l<r.length;l++){const i=r[l];i!=null&&e.add(i)}const n=Float64Array.from([...e].sort((r,l)=>r-l)),o=new Map;for(let r=0;r<n.length;r++){const l=n[r];l!=null&&o.set(l,r)}const s=[];for(const[r,l]of t){const i=new Array(n.length).fill(null);for(let a=0;a<r.length;a++){const u=r[a];if(u==null)continue;const c=o.get(u);c!=null&&(i[c]=l[a]??null)}s.push(i)}return[{x:n,series:s}]}function yr(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 xr(t,e=0){return n=>n.map(o=>o.toFixed(e)+t)}function Mr(t,e=0){return n=>n.map(o=>t+o.toFixed(e))}function kr(t,e,n=0){return o=>o.map(s=>t+s.toFixed(n)+e)}function Cr(t){const e=(t==null?void 0:t.utc)??!1,n=t==null?void 0:t.locale;return o=>o.map(s=>e?ut(s,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC",n):ut(s,{hour:"2-digit",minute:"2-digit",hour12:!1},void 0,n))}function Tr(t){const e=t!=null&&t.utc?"UTC":void 0,n=(t==null?void 0:t.format)??"short",o=t==null?void 0:t.locale;return s=>s.map(r=>ut(r,{month:n},e,o))}function Fr(t){const{tz:e,locale:n,...o}=t??{};return s=>s.map(r=>ut(r,o,e,n))}function Ar(t,e=0){return n=>n.map(o=>{const s=Math.round(o)-e;return t[s]??String(o)})}exports.AnnotationLabel=ar;exports.Axis=Bt;exports.Band=cl;exports.BoxWhisker=Jl;exports.Candlestick=Sr;exports.Chart=Te;exports.DARK_THEME=ms;exports.DEFAULT_ACTIONS=Kt;exports.Direction=Z;exports.Distribution=Q;exports.FloatingLegend=Kl;exports.HLine=lr;exports.Heatmap=tr;exports.HoverLabel=ql;exports.Legend=Fl;exports.Orientation=G;exports.Region=ir;exports.Scale=we;exports.Series=Vt;exports.Side=K;exports.SortOrder=Et;exports.Sparkline=Ol;exports.THEME_DEFAULTS=et;exports.ThemeProvider=ll;exports.Timeline=jl;exports.Tooltip=Hl;exports.VLine=rr;exports.Vector=nr;exports.ZoomRanger=Gl;exports.alignData=br;exports.at=V;exports.bars=Re;exports.catmullRom=pr;exports.drawHLine=eo;exports.drawLabel=sr;exports.drawRegion=oo;exports.drawVLine=no;exports.fadeGradient=Is;exports.fmtCompact=yr;exports.fmtDateStr=Fr;exports.fmtHourMin=Cr;exports.fmtLabels=Ar;exports.fmtMonthName=Tr;exports.fmtPrefix=Mr;exports.fmtSuffix=xr;exports.fmtWrap=kr;exports.focus=io;exports.groupedBars=ur;exports.linear=Dn;exports.lttb=Me;exports.lttbGroup=Do;exports.monotoneCubic=hr;exports.palette=Ds;exports.points=wr;exports.posToVal=gt;exports.sideOrientation=Ft;exports.stackGroup=vr;exports.stackedBars=fr;exports.stepped=cr;exports.useChart=$s;exports.useCursorDrawHook=Nl;exports.useDrawHook=yt;exports.valToPos=U;exports.withAlpha=ke;
package/dist/index.d.ts CHANGED
@@ -14,10 +14,14 @@ export { BoxWhisker } from './components/BoxWhisker';
14
14
  export { Heatmap } from './components/Heatmap';
15
15
  export { Vector } from './components/Vector';
16
16
  export { HLine, VLine, Region, AnnotationLabel } from './components/annotations';
17
+ export { ThemeProvider } from './components/ThemeProvider';
18
+ export type { ThemeProviderProps } from './components/ThemeProvider';
19
+ export { THEME_DEFAULTS, DARK_THEME } from './rendering/theme';
20
+ export type { ResolvedTheme } from './rendering/theme';
17
21
  export { useChart } from './hooks/useChart';
18
22
  export type { ChartAPI } from './hooks/useChart';
19
23
  export { useDrawHook, useCursorDrawHook } from './hooks/useDrawHook';
20
- export type { ChartProps, ChartData, XGroup, SeriesRef, DataArray, SimpleGroup, FullGroup, DataInput, ScaleConfig, SeriesConfig, AxisConfig, CursorState, SelectState, GridConfig, TickConfig, BorderConfig, PointsConfig, ActionList, ActionEntry, ActionKey, ReactionValue, ActionContext, DragContinuation, GradientConfig, ColorValue, } from './types';
24
+ export type { ChartProps, ChartData, XGroup, SeriesRef, DataArray, SimpleGroup, FullGroup, DataInput, ScaleConfig, SeriesConfig, AxisConfig, CursorState, SelectState, GridConfig, TickConfig, BorderConfig, PointsConfig, ActionList, ActionEntry, ActionKey, BuiltinAction, ReactionValue, BuiltinReaction, ActionContext, DragContinuation, GradientConfig, ColorValue, ChartTheme, CornerPosition, OverlayPosition, OverlayOffset, } from './types';
21
25
  export type { ChartSnapshot } from './hooks/useChartStore';
22
26
  export type { BandConfig } from './types/bands';
23
27
  export type { LegendConfig } from './types/legend';
@@ -50,6 +54,7 @@ export { drawHLine, drawVLine, drawLabel, drawRegion } from './annotations';
50
54
  export { valToPos, posToVal } from './core/Scale';
51
55
  export { DEFAULT_ACTIONS, focus } from './types/interaction';
52
56
  export { Side, Orientation, Direction, Distribution, SortOrder, sideOrientation } from './types';
57
+ export { at } from './utils/at';
53
58
  export { fmtCompact, fmtSuffix, fmtPrefix, fmtWrap, fmtHourMin, fmtMonthName, fmtDateStr, fmtLabels } from './formatters';
54
59
  export type { AxisValueFormatter } from './formatters';
55
60
  export { fadeGradient, withAlpha, palette } from './colors';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGjF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGrE,YAAY,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9E,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnF,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACzI,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACrF,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC1G,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG5E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG7D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAGjG,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1H,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG5D,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGjF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGrE,YAAY,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,UAAU,EACV,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9E,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnF,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACzI,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACrF,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC1G,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG5E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG7D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAGjG,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1H,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG5D,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}