@jigonzalez930209/scichart-engine 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(b,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],w):(b=typeof globalThis<"u"?globalThis:b||self,w(b.SciChartEngine={},b.React))})(this,function(b,w){"use strict";var it=Object.defineProperty;var nt=(b,w,I)=>w in b?it(b,w,{enumerable:!0,configurable:!0,writable:!0,value:I}):b[w]=I;var u=(b,w,I)=>nt(b,typeof w!="symbol"?w+"":w,I);class I{constructor(){u(this,"listeners",new Map)}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){const n=this.listeners.get(e);n&&n.delete(t)}emit(e,t){const n=this.listeners.get(e);n&&n.forEach(i=>{try{i(t)}catch(o){console.error(`[EventEmitter] Error in handler for "${String(e)}":`,o)}})}once(e,t){const n=i=>{this.off(e,n),t(i)};this.on(e,n)}clear(){this.listeners.clear()}listenerCount(e){var t;return((t=this.listeners.get(e))==null?void 0:t.size)??0}}const Ee={color:"#ff0055",width:1.5,opacity:1,pointSize:4};function O(c){return c?c instanceof Float32Array||c instanceof Float64Array?c:new Float32Array(c):new Float32Array(0)}class le{constructor(e){u(this,"id");u(this,"type");u(this,"data");u(this,"style");u(this,"visible");u(this,"cycle");u(this,"cachedBounds",null);u(this,"boundsNeedsUpdate",!0);u(this,"_needsBufferUpdate",!0);u(this,"smoothedData",null);u(this,"smoothingNeedsUpdate",!0);var t,n;if(!e)throw new Error("[Series] Options are required");this.id=e.id,this.type=e.type,this.data={x:O((t=e.data)==null?void 0:t.x),y:O((n=e.data)==null?void 0:n.y)},this.style={...Ee,...e.style},e.color&&(this.style.color=e.color),e.width&&(this.style.width=e.width),e.pointSize&&(this.style.pointSize=e.pointSize),this.visible=e.visible??!0,this.cycle=e.cycle,this.data.x.length!==this.data.y.length&&console.warn(`[Series "${this.id}"] X and Y arrays have different lengths:`,this.data.x.length,"vs",this.data.y.length)}getId(){return this.id}getType(){return this.type}getData(){return this.style.smoothing&&this.style.smoothing>0?this.getSmoothedData():this.data}getSmoothedData(){return(this.smoothingNeedsUpdate||!this.smoothedData)&&(this.smoothedData=this.applySmoothing(this.data,5),this.smoothingNeedsUpdate=!1),this.smoothedData}applySmoothing(e,t){const{x:n,y:i}=e,o=n.length;if(o<t)return{...e};const s=new Float32Array(o),r=Math.floor(t/2);for(let a=0;a<o;a++){let l=0,h=0;for(let f=a-r;f<=a+r;f++)f>=0&&f<o&&(l+=i[f],h++);s[a]=l/h}return{x:n,y:s}}getStyle(){return this.style}isVisible(){return this.visible}getCycle(){return this.cycle}getPointCount(){return this.data.x.length}getBounds(){return this.data.x.length===0?null:((this.boundsNeedsUpdate||this.cachedBounds===null)&&(this.cachedBounds=this.calculateBounds(),this.boundsNeedsUpdate=!1),this.cachedBounds)}calculateBounds(){const{x:e,y:t}=this.data;let n=1/0,i=-1/0,o=1/0,s=-1/0;for(let a=0;a<e.length;a++){const l=e[a],h=t[a];!isFinite(l)||!isFinite(h)||(l<n&&(n=l),l>i&&(i=l),h<o&&(o=h),h>s&&(s=h))}return{xMin:n,xMax:i,yMin:o,yMax:s}}updateData(e){if(e){if(e.append){const t=O(e.x),n=O(e.y);t.length>0&&n.length>0&&(this.data={x:this.appendArray(this.data.x,t),y:this.appendArray(this.data.y,n)})}else e.x&&(this.data.x=O(e.x)),e.y&&(this.data.y=O(e.y));this.boundsNeedsUpdate=!0,this.smoothingNeedsUpdate=!0,this._needsBufferUpdate=!0}}appendArray(e,t){const n=new e.constructor(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}setData(e,t){this.data={x:e,y:t},this.boundsNeedsUpdate=!0,this.smoothingNeedsUpdate=!0,this._needsBufferUpdate=!0}setStyle(e){const t=this.style.smoothing;this.style={...this.style,...e},this.style.smoothing!==t&&(this.smoothingNeedsUpdate=!0,this._needsBufferUpdate=!0)}get needsBufferUpdate(){return this._needsBufferUpdate}set needsBufferUpdate(e){this._needsBufferUpdate=e}setVisible(e){this.visible=e}setType(e){this.type=e}destroy(){this.data={x:new Float32Array(0),y:new Float32Array(0)},this.cachedBounds=null}}const ke=`
1
+ (function(M,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],C):(M=typeof globalThis<"u"?globalThis:M||self,C(M.SciChartEngine={},M.React))})(this,function(M,C){"use strict";var Nt=Object.defineProperty;var Wt=(M,C,_)=>C in M?Nt(M,C,{enumerable:!0,configurable:!0,writable:!0,value:_}):M[C]=_;var m=(M,C,_)=>Wt(M,typeof C!="symbol"?C+"":C,_);const _={top:20,right:30,bottom:55,left:75},fe=[{symbol:"p",factor:1e-12},{symbol:"n",factor:1e-9},{symbol:"µ",factor:1e-6},{symbol:"m",factor:.001},{symbol:"",factor:1},{symbol:"k",factor:1e3},{symbol:"M",factor:1e6},{symbol:"G",factor:1e9}];function oe(a){const e=Math.abs(a);if(e===0)return{symbol:"",factor:1};for(let t=fe.length-1;t>=0;t--){const i=fe[t],s=e/i.factor;if(s>=1&&s<1e3)return i}return{symbol:"",factor:1}}function q(a,e,t=2){const i=oe(a);return`${(a/i.factor).toFixed(t)} ${i.symbol}${e}`}function ge(a,e=3){return Math.abs(a)<.001||Math.abs(a)>=1e6?a.toExponential(e):a.toFixed(e)}function me(a,e=2){return a.toExponential(e)}function ye(a,e=.001){const t=a instanceof Array?new Float32Array(a):a;if(t.length<3)return[];const i=[];let s=0,n=1,o=Math.sign(t[1]-t[0]),r=0;for(let l=2;l<t.length;l++){const h=Math.sign(t[l]-t[l-1]);if(h!==0&&h!==o){if(r++,r>=2){const c=t[s],d=t[l];Math.abs(d-c)<e&&(i.push({number:n,startIndex:s,endIndex:l,direction:t[s+1]>t[s]?1:-1}),n++,s=l,r=0)}o=h}}return s<t.length-1&&i.push({number:n,startIndex:s,endIndex:t.length-1,direction:t[s+1]>t[s]?1:-1}),i}function pe(a){const e=[],t=360/Math.max(a,1);for(let i=0;i<a;i++){const s=i*t%360;e.push(`hsl(${s}, 70%, 55%)`)}return e}function be(a,e,t={}){const{minProminence:i=0,type:s="both"}=t,n=[],o=a instanceof Array?new Float32Array(a):a,r=e instanceof Array?new Float32Array(e):e;for(let l=1;l<r.length-1;l++){const h=r[l-1],c=r[l],d=r[l+1];if(c>h&&c>d){const u=Math.min(c-h,c-d);u>=i&&(s==="both"||s==="max")&&n.push({index:l,x:o[l],y:c,type:"max",prominence:u})}if(c<h&&c<d){const u=Math.min(h-c,d-c);u>=i&&(s==="both"||s==="min")&&n.push({index:l,x:o[l],y:c,type:"min",prominence:u})}}return n}function xe(a){let e=0,t=-1;const i=a instanceof Array?a:Array.from(a);for(let s=0;s<i.length;s++)isFinite(i[s])||(e++,t===-1&&(t=s));return{valid:e===0,invalidCount:e,firstInvalidIndex:t}}function re(a){const e=a instanceof Array?a:Array.from(a),t=e.length;if(t===0)return{min:0,max:0,mean:0,stdDev:0,count:0};let i=e[0],s=e[0],n=0;for(let h=0;h<t;h++){const c=e[h];c<i&&(i=c),c>s&&(s=c),n+=c}const o=n/t;let r=0;for(let h=0;h<t;h++){const c=e[h]-o;r+=c*c}const l=Math.sqrt(r/t);return{min:i,max:s,mean:o,stdDev:l,count:t}}function ve(a,e){const t=a instanceof Array?new Float32Array(a):a,i=new Float32Array(t.length),s=Math.floor(e/2);for(let n=0;n<t.length;n++){let o=0,r=0;for(let l=Math.max(0,n-s);l<=Math.min(t.length-1,n+s);l++)o+=t[l],r++;i[n]=o/r}return i}function Me(a,e,t){const i=a.length;if(t>=i||t<3)return{x:new Float32Array(a),y:new Float32Array(e)};const s=new Float32Array(t),n=new Float32Array(t);s[0]=a[0],n[0]=e[0];const o=(i-2)/(t-2);let r=0,l=1;for(let h=0;h<t-2;h++){const c=Math.floor((h+1)*o)+1,d=Math.floor((h+2)*o)+1,u=Math.min(Math.floor((h+3)*o)+1,i);let g=0,f=0,p=0;for(let v=d;v<u;v++)g+=a[v],f+=e[v],p++;p>0&&(g/=p,f/=p);let b=-1,x=c;for(let v=c;v<d&&v<i;v++){const T=Math.abs((a[r]-g)*(e[v]-e[r])-(a[r]-a[v])*(f-e[r]));T>b&&(b=T,x=v)}s[l]=a[x],n[l]=e[x],l++,r=x}return s[t-1]=a[i-1],n[t-1]=e[i-1],{x:s,y:n}}function $e(a,e,t,i){const s=a.length,n=new Float32Array(s);let o=0,r=s-1,l=1/0,h=1/0;for(let f=0;f<s;f++){const p=Math.abs(a[f]-t),b=Math.abs(a[f]-i);p<l&&(l=p,o=f),b<h&&(h=b,r=f)}const c=e[o],u=(e[r]-c)/(a[r]-a[o]),g=c-u*a[o];for(let f=0;f<s;f++)n[f]=e[f]-(u*a[f]+g);return n}function we(a,e){const t=e.length,i=a.map((n,o)=>[...n,e[o]]);for(let n=0;n<t;n++){let o=n;for(let h=n+1;h<t;h++)Math.abs(i[h][n])>Math.abs(i[o][n])&&(o=h);const r=i[n];i[n]=i[o],i[o]=r;const l=i[n][n];if(Math.abs(l)<1e-12)throw new Error("Matrix is singular or near-singular");for(let h=n+1;h<t;h++){const c=i[h][n]/l;for(let d=n;d<=t;d++)i[h][d]-=c*i[n][d]}}const s=new Array(t).fill(0);for(let n=t-1;n>=0;n--){let o=0;for(let r=n+1;r<t;r++)o+=i[n][r]*s[r];s[n]=(i[n][t]-o)/i[n][n]}return s}function X(a,e,t){const i=a.length;if(i===0)return 0;let s=0;for(let l=0;l<i;l++)s+=e[l];const n=s/i;let o=0,r=0;for(let l=0;l<i;l++){const h=e[l],c=t(a[l]);o+=(h-n)*(h-n),r+=(h-c)*(h-c)}return o===0?1:1-r/o}function Se(a,e,t,i){const s=a.length;if(s<2)return 0;let n=0;const o=t!==void 0?t:a[0],r=i!==void 0?i:a[s-1];for(let l=0;l<s-1;l++){const h=a[l],c=a[l+1];if(c<o)continue;if(h>r)break;const d=Math.max(h,o),u=Math.min(c,r);if(d<u){const g=e[l]+(e[l+1]-e[l])*((d-h)/(c-h)),f=e[l]+(e[l+1]-e[l])*((u-h)/(c-h));n+=(u-d)*(g+f)/2}}return n}function je(a,e){const t=a.length;if(t<2)return new Float32Array(0);const i=new Float32Array(t);for(let s=0;s<t-1;s++){const n=a[s+1]-a[s];i[s]=n!==0?(e[s+1]-e[s])/n:0}return i[t-1]=i[t-2],i}function Ve(a,e){const t=a.length;if(t<1)return new Float32Array(0);const i=new Float32Array(t);i[0]=0;for(let s=0;s<t-1;s++){const o=(a[s+1]-a[s])*(e[s]+e[s+1])/2;i[s+1]=i[s]+o}return i}function Te(a,e,t,i={}){if(a.length<2)throw new Error("At least 2 points are required for fitting");switch(t){case"linear":return G(a,e,i);case"polynomial":return He(a,e,i.degree??2,i);case"exponential":return qe(a,e,i);case"logarithmic":return Ge(a,e,i);case"power":return Ze(a,e,i);default:throw new Error(`Unsupported fit type: ${t}`)}}function G(a,e,t){const i=a.length;let s=0,n=0,o=0,r=0;for(let u=0;u<i;u++)s+=a[u],n+=e[u],o+=a[u]*e[u],r+=a[u]*a[u];const l=(i*o-s*n)/(i*r-s*s),h=(n-l*s)/i,c=u=>l*u+h,d=t.precision??4;return{type:"linear",coefficients:[l,h],equation:`y = ${l.toFixed(d)}x ${h>=0?"+":"-"} ${Math.abs(h).toFixed(d)}`,rSquared:X(a,e,c),predict:c}}function He(a,e,t,i){const s=a.length,n=t+1,o=Array.from({length:n},()=>new Array(n).fill(0)),r=new Array(n).fill(0);for(let u=0;u<n;u++){for(let f=0;f<n;f++){let p=0;for(let b=0;b<s;b++)p+=Math.pow(a[b],u+f);o[u][f]=p}let g=0;for(let f=0;f<s;f++)g+=e[f]*Math.pow(a[f],u);r[u]=g}const l=we(o,r),h=u=>{let g=0;for(let f=0;f<l.length;f++)g+=l[f]*Math.pow(u,f);return g},c=i.precision??4;let d="y = ";for(let u=l.length-1;u>=0;u--){const g=l[u];u<l.length-1?d+=g>=0?" + ":" - ":g<0&&(d+="-"),d+=`${Math.abs(g).toFixed(c)}${u>0?u>1?`x^${u}`:"x":""}`}return{type:"polynomial",coefficients:l,equation:d,rSquared:X(a,e,h),predict:h}}function qe(a,e,t){const i=a.length,s=[],n=[];for(let d=0;d<i;d++)e[d]>0&&(s.push(a[d]),n.push(Math.log(e[d])));const o=G(s,n,t),r=o.coefficients[0],l=Math.exp(o.coefficients[1]),h=d=>l*Math.exp(r*d),c=t.precision??4;return{type:"exponential",coefficients:[l,r],equation:`y = ${l.toFixed(c)} * e^(${r.toFixed(c)}x)`,rSquared:X(a,e,h),predict:h}}function Ge(a,e,t){const i=a.length,s=[],n=[];for(let d=0;d<i;d++)a[d]>0&&(s.push(Math.log(a[d])),n.push(e[d]));const o=G(s,n,t),r=o.coefficients[0],l=o.coefficients[1],h=d=>l+r*Math.log(d),c=t.precision??4;return{type:"logarithmic",coefficients:[l,r],equation:`y = ${l.toFixed(c)} ${r>=0?"+":"-"} ${Math.abs(r).toFixed(c)} * ln(x)`,rSquared:X(a,e,h),predict:h}}function Ze(a,e,t){const i=a.length,s=[],n=[];for(let d=0;d<i;d++)a[d]>0&&e[d]>0&&(s.push(Math.log(a[d])),n.push(Math.log(e[d])));const o=G(s,n,t),r=o.coefficients[0],l=Math.exp(o.coefficients[1]),h=d=>l*Math.pow(d,r),c=t.precision??4;return{type:"power",coefficients:[l,r],equation:`y = ${l.toFixed(c)} * x^(${r.toFixed(c)})`,rSquared:X(a,e,h),predict:h}}const Je=Object.freeze(Object.defineProperty({__proto__:null,calculateR2:X,calculateStats:re,cumulativeIntegral:Ve,derivative:je,detectCycles:ye,detectPeaks:be,downsampleLTTB:Me,fitData:Te,formatScientific:me,formatValue:ge,formatWithPrefix:q,generateCycleColors:pe,getBestPrefix:oe,integrate:Se,movingAverage:ve,solveLinearSystem:we,subtractBaseline:$e,validateData:xe},Symbol.toStringTag,{value:"Module"}));class Ce{constructor(){m(this,"listeners",new Map)}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){const i=this.listeners.get(e);i&&i.delete(t)}emit(e,t){const i=this.listeners.get(e);i&&i.forEach(s=>{try{s(t)}catch(n){console.error(`[EventEmitter] Error in handler for "${String(e)}":`,n)}})}once(e,t){const i=s=>{this.off(e,i),t(s)};this.on(e,i)}clear(){this.listeners.clear()}listenerCount(e){var t;return((t=this.listeners.get(e))==null?void 0:t.size)??0}}const Ke=`
2
2
  precision highp float;
3
3
  attribute vec2 position;
4
4
  uniform vec2 uScale;
@@ -8,14 +8,14 @@ void main() {
8
8
  vec2 pos = position * uScale + uTranslate;
9
9
  gl_Position = vec4(pos, 0.0, 1.0);
10
10
  }
11
- `,Re=`
11
+ `,Qe=`
12
12
  precision highp float;
13
13
  uniform vec4 uColor;
14
14
 
15
15
  void main() {
16
16
  gl_FragColor = uColor;
17
17
  }
18
- `,Be=`
18
+ `,et=`
19
19
  precision highp float;
20
20
  attribute vec2 position;
21
21
  uniform vec2 uScale;
@@ -27,19 +27,90 @@ void main() {
27
27
  gl_Position = vec4(pos, 0.0, 1.0);
28
28
  gl_PointSize = uPointSize;
29
29
  }
30
- `,Pe=`
30
+ `,tt=`
31
31
  precision highp float;
32
32
  uniform vec4 uColor;
33
+ uniform int uSymbol;
34
+
35
+ float sdCircle(vec2 p, float r) {
36
+ return length(p) - r;
37
+ }
38
+
39
+ float sdBox(vec2 p, vec2 b) {
40
+ vec2 d = abs(p) - b;
41
+ return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
42
+ }
43
+
44
+ float sdTriangle(vec2 p, float r) {
45
+ const float k = sqrt(3.0);
46
+ p.x = abs(p.x) - r;
47
+ p.y = p.y + r / k;
48
+ if (p.x + k * p.y > 0.0) p = vec2(p.x - k * p.y, -k * p.x - p.y) / 2.0;
49
+ p.x -= clamp(p.x, -2.0 * r, 0.0);
50
+ return -length(p) * sign(p.y);
51
+ }
52
+
53
+ float sdDiamond(vec2 p, float r) {
54
+ return (abs(p.x) + abs(p.y)) - r;
55
+ }
56
+
57
+ float sdCross(vec2 p, float r, float thickness) {
58
+ vec2 d = abs(p);
59
+ float s1 = sdBox(d, vec2(r, thickness));
60
+ float s2 = sdBox(d, vec2(thickness, r));
61
+ return min(s1, s2);
62
+ }
63
+
64
+ float sdX(vec2 p, float r, float thickness) {
65
+ float c = cos(0.785398); // 45 degrees
66
+ float s = sin(0.785398);
67
+ mat2 m = mat2(c, -s, s, c);
68
+ return sdCross(m * p, r, thickness);
69
+ }
70
+
71
+ float sdStar(vec2 p, float r, float rf) {
72
+ const vec2 k1 = vec2(0.80901699, -0.58778525);
73
+ const vec2 k2 = vec2(-k1.x, k1.y);
74
+ p.x = abs(p.x);
75
+ p -= 2.0 * max(dot(k1, p), 0.0) * k1;
76
+ p -= 2.0 * max(dot(k2, p), 0.0) * k2;
77
+ p.x = abs(p.x);
78
+ p.y -= r;
79
+ vec2 ba = rf * vec2(-k1.y, k1.x) - vec2(0, 1);
80
+ float h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);
81
+ return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);
82
+ }
33
83
 
34
84
  void main() {
35
- vec2 coord = gl_PointCoord - vec2(0.5);
36
- float dist = length(coord);
37
- if (dist > 0.5) discard;
38
- float alpha = 1.0 - smoothstep(0.4, 0.5, dist);
85
+ vec2 p = gl_PointCoord - vec2(0.5);
86
+ float d = 0.0;
87
+
88
+ // Symbols: 0:circle, 1:square, 2:diamond, 3:triangle, 4:triangleDown, 5:cross, 6:x, 7:star
89
+ if (uSymbol == 0) {
90
+ d = sdCircle(p, 0.45);
91
+ } else if (uSymbol == 1) {
92
+ d = sdBox(p, vec2(0.35));
93
+ } else if (uSymbol == 2) {
94
+ d = sdDiamond(p, 0.45);
95
+ } else if (uSymbol == 3) {
96
+ d = sdTriangle(vec2(p.x, p.y + 0.1), 0.4);
97
+ } else if (uSymbol == 4) {
98
+ d = sdTriangle(vec2(p.x, -p.y + 0.1), 0.4);
99
+ } else if (uSymbol == 5) {
100
+ d = sdCross(p, 0.45, 0.15);
101
+ } else if (uSymbol == 6) {
102
+ d = sdX(p, 0.45, 0.15);
103
+ } else if (uSymbol == 7) {
104
+ d = sdStar(p, 0.45, 0.4);
105
+ }
106
+
107
+ if (d > 0.02) discard; // Add small margin for antialiasing
108
+
109
+ float alpha = 1.0 - smoothstep(0.0, 0.02, d);
39
110
  gl_FragColor = vec4(uColor.rgb, uColor.a * alpha);
40
111
  }
41
- `;class W{constructor(e){u(this,"canvas");u(this,"gl");u(this,"dpr");u(this,"lineProgram");u(this,"pointProgram");u(this,"buffers",new Map);u(this,"bufferSizes",new Map);u(this,"isInitialized",!1);this.canvas=e,this.dpr=window.devicePixelRatio||1;const t=e.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance"});if(!t)throw new Error("WebGL not supported");this.gl=t,this.lineProgram=this.createProgram(ke,Re,!1),this.pointProgram=this.createProgram(Be,Pe,!0),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.isInitialized=!0,console.log("[NativeWebGL] Initialized successfully")}createShader(e,t){const{gl:n}=this,i=n.createShader(t);if(!i)throw new Error("Failed to create shader");if(n.shaderSource(i,e),n.compileShader(i),!n.getShaderParameter(i,n.COMPILE_STATUS)){const o=n.getShaderInfoLog(i);throw n.deleteShader(i),new Error(`Shader compilation error: ${o}`)}return i}createProgram(e,t,n){const{gl:i}=this,o=this.createShader(e,i.VERTEX_SHADER),s=this.createShader(t,i.FRAGMENT_SHADER),r=i.createProgram();if(!r)throw new Error("Failed to create program");if(i.attachShader(r,o),i.attachShader(r,s),i.linkProgram(r),!i.getProgramParameter(r,i.LINK_STATUS)){const m=i.getProgramInfoLog(r);throw new Error(`Program link error: ${m}`)}i.deleteShader(o),i.deleteShader(s);const a=i.getAttribLocation(r,"position"),l=i.getUniformLocation(r,"uScale"),h=i.getUniformLocation(r,"uTranslate"),f=i.getUniformLocation(r,"uColor");if(l===null||h===null||f===null)throw new Error("Failed to get uniform locations");const y={program:r,attributes:{position:a},uniforms:{uScale:l,uTranslate:h,uColor:f}};return n&&(y.uniforms.uPointSize=i.getUniformLocation(r,"uPointSize")??void 0),y}get available(){return this.isInitialized}createBuffer(e,t){const{gl:n}=this;let i=this.buffers.get(e);const o=this.bufferSizes.get(e)||0;if(i&&t.byteLength<=o)n.bindBuffer(n.ARRAY_BUFFER,i),n.bufferSubData(n.ARRAY_BUFFER,0,t);else{if(i&&n.deleteBuffer(i),i=n.createBuffer(),!i)throw new Error("Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,i),n.bufferData(n.ARRAY_BUFFER,t,n.DYNAMIC_DRAW),this.buffers.set(e,i),this.bufferSizes.set(e,t.byteLength)}}getBuffer(e){return this.buffers.get(e)}deleteBuffer(e){const t=this.buffers.get(e);t&&(this.gl.deleteBuffer(t),this.buffers.delete(e),this.bufferSizes.delete(e))}calculateUniforms(e){const t=e.xMax-e.xMin,n=e.yMax-e.yMin,i=t>0?2/t:1,o=n>0?2/n:1,s=-1-e.xMin*i,r=-1-e.yMin*o;return{scale:[i,o],translate:[s,r]}}render(e,t){if(!this.isInitialized)return;const{gl:n}=this,{bounds:i,backgroundColor:o=[.1,.1,.18,1]}=t,s=this.calculateUniforms(i);n.clearColor(o[0],o[1],o[2],o[3]),n.clear(n.COLOR_BUFFER_BIT);for(const r of e){if(!r.visible||r.count===0)continue;const a=V(r.style.color??"#ff0055");a[3]=r.style.opacity??1,r.type==="scatter"?this.renderPoints(r.buffer,r.count,s,a,(r.style.pointSize??4)*this.dpr):r.type==="line"?this.renderLine(r.buffer,r.count,s,a):r.type==="line+scatter"&&(this.renderLine(r.buffer,r.count,s,a),this.renderPoints(r.buffer,r.count,s,a,(r.style.pointSize??4)*this.dpr))}}renderLine(e,t,n,i){const{gl:o}=this,s=this.lineProgram;o.useProgram(s.program),o.bindBuffer(o.ARRAY_BUFFER,e),o.enableVertexAttribArray(s.attributes.position),o.vertexAttribPointer(s.attributes.position,2,o.FLOAT,!1,0,0),o.uniform2f(s.uniforms.uScale,n.scale[0],n.scale[1]),o.uniform2f(s.uniforms.uTranslate,n.translate[0],n.translate[1]),o.uniform4f(s.uniforms.uColor,i[0],i[1],i[2],i[3]),o.drawArrays(o.LINE_STRIP,0,t),o.disableVertexAttribArray(s.attributes.position)}renderPoints(e,t,n,i,o){const{gl:s}=this,r=this.pointProgram;s.useProgram(r.program),s.bindBuffer(s.ARRAY_BUFFER,e),s.enableVertexAttribArray(r.attributes.position),s.vertexAttribPointer(r.attributes.position,2,s.FLOAT,!1,0,0),s.uniform2f(r.uniforms.uScale,n.scale[0],n.scale[1]),s.uniform2f(r.uniforms.uTranslate,n.translate[0],n.translate[1]),s.uniform4f(r.uniforms.uColor,i[0],i[1],i[2],i[3]),r.uniforms.uPointSize&&s.uniform1f(r.uniforms.uPointSize,o),s.drawArrays(s.POINTS,0,t),s.disableVertexAttribArray(r.attributes.position)}resize(){const e=this.canvas.getBoundingClientRect(),t=e.width*this.dpr,n=e.height*this.dpr;(this.canvas.width!==t||this.canvas.height!==n)&&(this.canvas.width=t,this.canvas.height=n,this.gl.viewport(0,0,t,n))}getLimits(){const{gl:e}=this;return{maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxViewportDims:e.getParameter(e.MAX_VIEWPORT_DIMS),renderer:e.getParameter(e.RENDERER),vendor:e.getParameter(e.VENDOR)}}destroy(){const{gl:e}=this;this.buffers.forEach(t=>e.deleteBuffer(t)),this.buffers.clear(),this.bufferSizes.clear(),e.deleteProgram(this.lineProgram.program),e.deleteProgram(this.pointProgram.program),this.isInitialized=!1,console.log("[NativeWebGL] Destroyed")}}function V(c){if(c.startsWith("#")){const e=c.slice(1);if(e.length===3){const t=parseInt(e[0]+e[0],16)/255,n=parseInt(e[1]+e[1],16)/255,i=parseInt(e[2]+e[2],16)/255;return[t,n,i,1]}else if(e.length===6){const t=parseInt(e.slice(0,2),16)/255,n=parseInt(e.slice(2,4),16)/255,i=parseInt(e.slice(4,6),16)/255;return[t,n,i,1]}else if(e.length===8){const t=parseInt(e.slice(0,2),16)/255,n=parseInt(e.slice(2,4),16)/255,i=parseInt(e.slice(4,6),16)/255,o=parseInt(e.slice(6,8),16)/255;return[t,n,i,o]}}return[1,0,1,1]}function ce(c,e){const t=Math.min(c.length,e.length),n=new Float32Array(t*2);for(let i=0;i<t;i++)n[i*2]=c[i],n[i*2+1]=e[i];return n}class H{constructor(){u(this,"domain",[0,1]);u(this,"range",[0,100]);u(this,"type","linear")}setDomain(e,t){if(!isFinite(e)||!isFinite(t)){this.domain=[0,1];return}if(e===t){this.domain=[e-.5,t+.5];return}this.domain=[e,t]}setRange(e,t){this.range=[e,t]}transform(e){const[t,n]=this.domain,[i,o]=this.range,s=(e-t)/(n-t);return i+s*(o-i)}invert(e){const[t,n]=this.domain,[i,o]=this.range,s=(e-i)/(o-i);return t+s*(n-t)}ticks(e=10){const[t,n]=this.domain;if(!isFinite(t)||!isFinite(n)||t===n)return[];const i=Ae(t,n,e),o=Math.ceil(t/i)*i,s=[],r=100;let a=o;for(;a<=n+i*.5&&s.length<r;)s.push(Math.round(a*1e12)/1e12),a+=i;return s}}class ${constructor(){u(this,"domain",[1,1e3]);u(this,"range",[0,100]);u(this,"type","log");u(this,"base",10)}setDomain(e,t){const n=Math.max(e,1e-12),i=Math.max(t,1e-12*10);if(n===i){this.domain=[n/10,i*10];return}this.domain=[n,i]}setRange(e,t){this.range=[e,t]}transform(e){const[t,n]=this.domain,[i,o]=this.range;if(e<=0)return i;const s=Math.log(t)/Math.log(this.base),r=Math.log(n)/Math.log(this.base),l=(Math.log(e)/Math.log(this.base)-s)/(r-s);return i+l*(o-i)}invert(e){const[t,n]=this.domain,[i,o]=this.range,s=Math.log(t)/Math.log(this.base),r=Math.log(n)/Math.log(this.base),a=(e-i)/(o-i),l=s+a*(r-s);return Math.pow(this.base,l)}ticks(e=10){const[t,n]=this.domain,i=Math.floor(Math.log10(t)),o=Math.ceil(Math.log10(n)),s=[];for(let r=i;r<=o&&s.length<e;r++){const a=Math.pow(10,r);a>=t&&a<=n&&s.push(a)}return s}}function Ae(c,e,t){const n=e-c;if(n<=0||!isFinite(n))return 1;const i=n/t,o=Math.pow(10,Math.floor(Math.log10(i))),s=i/o;let r;return s<1.5?r=1:s<3?r=2:s<7?r=5:r=10,r*o}function Le(c){return c==="log"?new $:new H}const F={lineColor:"#666666",lineWidth:1,tickColor:"#888888",tickLength:6,labelColor:"#cccccc",labelSize:12,titleColor:"#ffffff",titleSize:14,fontFamily:"Inter, system-ui, sans-serif"},G={visible:!0,majorColor:"rgba(255, 255, 255, 0.12)",minorColor:"rgba(255, 255, 255, 0.05)",majorWidth:1,minorWidth:.5,majorDash:[4,4],minorDash:[2,4],showMinor:!0,minorDivisions:5},Z={visible:!0,position:"top-right",backgroundColor:"rgba(20, 20, 30, 0.9)",borderColor:"rgba(255, 255, 255, 0.15)",borderRadius:6,textColor:"#ffffff",fontSize:11,fontFamily:"Inter, system-ui, sans-serif",padding:10,itemGap:6,swatchSize:12},q={lineColor:"rgba(255, 255, 255, 0.5)",lineWidth:1,lineDash:[5,5],tooltipBackground:"rgba(20, 20, 30, 0.95)",tooltipBorder:"rgba(255, 255, 255, 0.2)",tooltipColor:"#ffffff",tooltipSize:11},J={name:"dark",backgroundColor:"#0b0e14",plotBorderColor:"#444c56",grid:{...G,majorColor:"rgba(255, 255, 255, 0.12)",minorColor:"rgba(255, 255, 255, 0.04)"},xAxis:{...F,labelColor:"#adbac7",titleColor:"#cdd9e5",lineColor:"#444c56",tickColor:"#444c56"},yAxis:{...F,labelColor:"#adbac7",titleColor:"#cdd9e5",lineColor:"#444c56",tickColor:"#444c56"},legend:Z,cursor:q},he={name:"midnight",backgroundColor:"#05050a",plotBorderColor:"#3a3a5a",grid:{...G,majorColor:"rgba(150, 150, 255, 0.2)",minorColor:"rgba(150, 150, 255, 0.08)"},xAxis:{...F,lineColor:"#5a5a8a",labelColor:"#b0b0e0",titleColor:"#d0d0f0",tickColor:"#5a5a8a"},yAxis:{...F,lineColor:"#5a5a8a",labelColor:"#b0b0e0",titleColor:"#d0d0f0",tickColor:"#5a5a8a"},legend:{...Z,backgroundColor:"rgba(15, 15, 30, 0.95)",borderColor:"rgba(100, 100, 255, 0.4)"},cursor:{...q,lineColor:"rgba(150, 150, 255, 0.7)"}},de={name:"light",backgroundColor:"#ffffff",plotBorderColor:"#cccccc",grid:{...G,majorColor:"rgba(0, 0, 0, 0.1)",minorColor:"rgba(0, 0, 0, 0.04)"},xAxis:{...F,lineColor:"#888888",tickColor:"#888888",labelColor:"#444444",titleColor:"#222222"},yAxis:{...F,lineColor:"#888888",tickColor:"#888888",labelColor:"#444444",titleColor:"#222222"},legend:{...Z,backgroundColor:"rgba(255, 255, 255, 0.95)",borderColor:"rgba(0, 0, 0, 0.15)",textColor:"#222222"},cursor:{...q,lineColor:"rgba(0, 0, 0, 0.4)",tooltipBackground:"rgba(50, 50, 60, 0.95)"}},ue={name:"electrochemistry",backgroundColor:"#0a1628",plotBorderColor:"#1e3a5f",grid:{...G,majorColor:"rgba(30, 136, 229, 0.15)",minorColor:"rgba(30, 136, 229, 0.06)",showMinor:!0,minorDivisions:2},xAxis:{...F,lineColor:"#1e88e5",tickColor:"#42a5f5",labelColor:"#90caf9",titleColor:"#bbdefb"},yAxis:{...F,lineColor:"#1e88e5",tickColor:"#42a5f5",labelColor:"#90caf9",titleColor:"#bbdefb"},legend:{...Z,backgroundColor:"rgba(10, 22, 40, 0.95)",borderColor:"rgba(30, 136, 229, 0.3)"},cursor:{...q,lineColor:"rgba(100, 180, 255, 0.6)"}};function _e(c,e){return{...c,...e,grid:{...c.grid,...e.grid},xAxis:{...c.xAxis,...e.xAxis},yAxis:{...c.yAxis,...e.yAxis},legend:{...c.legend,...e.legend},cursor:{...c.cursor,...e.cursor}}}function Q(c){switch(c){case"dark":return J;case"midnight":return he;case"light":return de;case"electrochemistry":case"electrochem":return ue;default:return console.warn(`[Theme] Unknown theme "${c}", using dark`),J}}const ee=J;class fe{constructor(e,t){u(this,"ctx");u(this,"theme");this.ctx=e,this.theme=t}setTheme(e){this.theme=e}clear(e,t){this.ctx.clearRect(0,0,e,t)}drawGrid(e,t,n){if(!this.theme.grid.visible)return;const{ctx:i}=this,o=this.theme.grid,s=t.ticks(8),r=n.ticks(6);if(i.strokeStyle=o.majorColor,i.lineWidth=o.majorWidth,i.setLineDash(o.majorDash),s.forEach(a=>{const l=t.transform(a);l>=e.x&&l<=e.x+e.width&&(i.beginPath(),i.moveTo(l,e.y),i.lineTo(l,e.y+e.height),i.stroke())}),r.forEach(a=>{const l=n.transform(a);l>=e.y&&l<=e.y+e.height&&(i.beginPath(),i.moveTo(e.x,l),i.lineTo(e.x+e.width,l),i.stroke())}),o.showMinor){i.strokeStyle=o.minorColor,i.lineWidth=o.minorWidth,i.setLineDash(o.minorDash);const a=this.generateMinorTicks(s,o.minorDivisions),l=this.generateMinorTicks(r,o.minorDivisions);a.forEach(h=>{const f=t.transform(h);f>=e.x&&f<=e.x+e.width&&(i.beginPath(),i.moveTo(f,e.y),i.lineTo(f,e.y+e.height),i.stroke())}),l.forEach(h=>{const f=n.transform(h);f>=e.y&&f<=e.y+e.height&&(i.beginPath(),i.moveTo(e.x,f),i.lineTo(e.x+e.width,f),i.stroke())})}i.setLineDash([])}drawXAxis(e,t,n){const{ctx:i}=this,o=this.theme.xAxis,s=t.ticks(8),r=e.y+e.height;i.strokeStyle=o.lineColor,i.lineWidth=o.lineWidth,i.beginPath(),i.moveTo(e.x,r),i.lineTo(e.x+e.width,r),i.stroke(),i.fillStyle=o.labelColor,i.font=`${o.labelSize}px ${o.fontFamily}`,i.textAlign="center",i.textBaseline="top",s.forEach(a=>{const l=t.transform(a);l>=e.x&&l<=e.x+e.width&&(i.strokeStyle=o.tickColor,i.beginPath(),i.moveTo(l,r),i.lineTo(l,r+o.tickLength),i.stroke(),i.fillText(this.formatXTick(a),l,r+o.tickLength+3))}),n&&(i.fillStyle=o.titleColor,i.font=`${o.titleSize}px ${o.fontFamily}`,i.textAlign="center",i.textBaseline="bottom",i.fillText(n,e.x+e.width/2,e.y+e.height+45))}drawYAxis(e,t,n){const{ctx:i}=this,o=this.theme.yAxis,s=t.ticks(6),r=e.x;i.strokeStyle=o.lineColor,i.lineWidth=o.lineWidth,i.beginPath(),i.moveTo(r,e.y),i.lineTo(r,e.y+e.height),i.stroke(),i.fillStyle=o.labelColor,i.font=`${o.labelSize}px ${o.fontFamily}`,i.textAlign="right",i.textBaseline="middle",s.forEach(a=>{const l=t.transform(a);l>=e.y&&l<=e.y+e.height&&(i.strokeStyle=o.tickColor,i.beginPath(),i.moveTo(r,l),i.lineTo(r-o.tickLength,l),i.stroke(),i.fillText(this.formatYTick(a),r-o.tickLength-3,l))}),n&&(i.save(),i.fillStyle=o.titleColor,i.font=`${o.titleSize}px ${o.fontFamily}`,i.textAlign="center",i.textBaseline="top",i.translate(15,e.y+e.height/2),i.rotate(-Math.PI/2),i.fillText(n,0,0),i.restore())}drawPlotBorder(e){const{ctx:t}=this;t.strokeStyle=this.theme.plotBorderColor,t.lineWidth=1,t.strokeRect(e.x,e.y,e.width,e.height)}drawLegend(e,t){if(t.length===0)return;const{ctx:n}=this,i=this.theme.legend;n.font=`${i.fontSize}px ${i.fontFamily}`;let o=0;const s=t.map(y=>{const m=y.getId(),g=n.measureText(m).width;return o=Math.max(o,g),{id:y.getId(),color:y.getStyle().color??"#ff0055",label:m}}),r=i.swatchSize+8+o+i.padding*2,a=s.length*(i.swatchSize+i.itemGap)-i.itemGap+i.padding*2;let l,h;switch(i.position){case"top-left":l=e.x+10,h=e.y+10;break;case"bottom-left":l=e.x+10,h=e.y+10;break;case"bottom-right":l=e.x+e.width-r-10,h=e.y+e.height-a-10;break;case"top-right":default:l=e.x+e.width-r-10,h=e.y+10;break}n.fillStyle=i.backgroundColor,n.strokeStyle=i.borderColor,n.lineWidth=1,n.beginPath();const f=i.borderRadius;n.moveTo(l+f,h),n.lineTo(l+r-f,h),n.arcTo(l+r,h,l+r,h+f,f),n.lineTo(l+r,h+a-f),n.arcTo(l+r,h+a,l+r-f,h+a,f),n.lineTo(l+f,h+a),n.arcTo(l,h+a,l,h+a-f,f),n.lineTo(l,h+f),n.arcTo(l,h,l+f,h,f),n.closePath(),n.fill(),n.stroke(),n.textAlign="left",n.textBaseline="middle",s.forEach((y,m)=>{const g=h+i.padding+m*(i.swatchSize+i.itemGap);n.fillStyle=y.color,n.fillRect(l+i.padding,g,i.swatchSize,i.swatchSize),n.fillStyle=i.textColor,n.fillText(y.label,l+i.padding+i.swatchSize+8,g+i.swatchSize/2)})}drawCursor(e,t){if(!t.enabled)return;const{ctx:n}=this,i=this.theme.cursor;t.x<e.x||t.x>e.x+e.width||t.y<e.y||t.y>e.y+e.height||(n.save(),n.beginPath(),n.rect(e.x,e.y,e.width,e.height),n.clip(),n.strokeStyle=i.lineColor,n.lineWidth=i.lineWidth,n.setLineDash(i.lineDash),t.crosshair?(n.beginPath(),n.moveTo(t.x,e.y),n.lineTo(t.x,e.y+e.height),n.stroke(),n.beginPath(),n.moveTo(e.x,t.y),n.lineTo(e.x+e.width,t.y),n.stroke()):(n.beginPath(),n.moveTo(t.x,e.y),n.lineTo(t.x,e.y+e.height),n.stroke()),n.restore(),t.tooltipText&&this.drawTooltip(t.x,t.y,t.tooltipText,e))}drawTooltip(e,t,n,i){const{ctx:o}=this,s=this.theme.cursor,r=n.split(`
42
- `),a=s.tooltipSize+5,l=8;o.font=`${s.tooltipSize}px ${this.theme.xAxis.fontFamily}`;let h=0;r.forEach(p=>{h=Math.max(h,o.measureText(p).width)});const f=h+l*2,y=r.length*a+l*2-5;let m=e+15,g=t-y-10;m+f>i.x+i.width&&(m=e-f-15),g<i.y&&(g=t+15),o.fillStyle=s.tooltipBackground,o.strokeStyle=s.tooltipBorder,o.lineWidth=1,o.beginPath();const x=4;o.moveTo(m+x,g),o.lineTo(m+f-x,g),o.arcTo(m+f,g,m+f,g+x,x),o.lineTo(m+f,g+y-x),o.arcTo(m+f,g+y,m+f-x,g+y,x),o.lineTo(m+x,g+y),o.arcTo(m,g+y,m,g+y-x,x),o.lineTo(m,g+x),o.arcTo(m,g,m+x,g,x),o.closePath(),o.fill(),o.stroke(),o.fillStyle=s.tooltipColor,o.textAlign="left",o.textBaseline="top",r.forEach((p,M)=>{o.fillText(p,m+l,g+l+M*a)})}drawSelectionRect(e){const{ctx:t}=this,n=this.theme.name.toLowerCase().includes("dark")||this.theme.name.toLowerCase().includes("midnight");t.save(),t.fillStyle=n?"rgba(0, 170, 255, 0.15)":"rgba(0, 100, 255, 0.1)",t.strokeStyle="#00aaff",t.lineWidth=1,t.setLineDash([5,5]),t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fill(),t.stroke(),t.restore()}generateMinorTicks(e,t){if(e.length<2)return[];const n=[];for(let i=0;i<e.length-1;i++){const o=(e[i+1]-e[i])/t;for(let s=1;s<t;s++)n.push(e[i]+o*s)}return n}formatXTick(e){return Math.abs(e)<.001&&e!==0?this.toScientificUnicode(e,1):e.toFixed(3).replace(/\.?0+$/,"")}formatYTick(e){if(e===0)return"0";const t=Math.abs(e);return t<1e-4||t>=1e4?this.toScientificUnicode(e,1):e.toPrecision(3)}toScientificUnicode(e,t){const n=e.toExponential(t),[i,o]=n.split("e"),s={0:"⁰",1:"¹",2:"²",3:"³",4:"⁴",5:"⁵",6:"⁶",7:"⁷",8:"⁸",9:"⁹","-":"⁻","+":"⁺"},r=o.replace(/[0-9\-+]/g,a=>s[a]||a);return`${i} × 10${r}`}}class De{constructor(e,t,n,i){u(this,"container");u(this,"callbacks");u(this,"getPlotArea");u(this,"getBounds");u(this,"isDragging",!1);u(this,"isBoxSelecting",!1);u(this,"selectionStart",{x:0,y:0});u(this,"lastMousePos",{x:0,y:0});u(this,"isPanMode",!0);u(this,"boundWheel");u(this,"boundMouseDown");u(this,"boundMouseMove");u(this,"boundMouseUp");u(this,"boundMouseLeave");u(this,"boundTouchStart");u(this,"boundTouchMove");u(this,"boundTouchEnd");this.container=e,this.callbacks=t,this.getPlotArea=n,this.getBounds=i,this.boundWheel=this.handleWheel.bind(this),this.boundMouseDown=this.handleMouseDown.bind(this),this.boundMouseMove=this.handleMouseMove.bind(this),this.boundMouseUp=this.handleMouseUp.bind(this),this.boundMouseLeave=this.handleMouseLeave.bind(this),this.boundTouchStart=this.handleTouchStart.bind(this),this.boundTouchMove=this.handleTouchMove.bind(this),this.boundTouchEnd=this.handleTouchEnd.bind(this),this.attachListeners()}attachListeners(){this.container.addEventListener("wheel",this.boundWheel,{passive:!1}),this.container.addEventListener("mousedown",this.boundMouseDown),this.container.addEventListener("mousemove",this.boundMouseMove),this.container.addEventListener("mouseup",this.boundMouseUp),this.container.addEventListener("mouseleave",this.boundMouseLeave),this.container.addEventListener("touchstart",this.boundTouchStart),this.container.addEventListener("touchmove",this.boundTouchMove),this.container.addEventListener("touchend",this.boundTouchEnd)}detachListeners(){this.container.removeEventListener("wheel",this.boundWheel),this.container.removeEventListener("mousedown",this.boundMouseDown),this.container.removeEventListener("mousemove",this.boundMouseMove),this.container.removeEventListener("mouseup",this.boundMouseUp),this.container.removeEventListener("mouseleave",this.boundMouseLeave),this.container.removeEventListener("touchstart",this.boundTouchStart),this.container.removeEventListener("touchmove",this.boundTouchMove),this.container.removeEventListener("touchend",this.boundTouchEnd)}setPanMode(e){this.isPanMode=e}handleWheel(e){const t=this.getPlotArea();if(t.width<=1||t.height<=1)return;e.preventDefault();const n=this.container.getBoundingClientRect(),i=e.clientX-n.left,o=e.clientY-n.top,s=this.getBounds();let r=!1,a=!1;if(i<t.x&&o>=t.y&&o<=t.y+t.height)a=!0;else if(o>t.y+t.height&&i>=t.x&&i<=t.x+t.width)r=!0;else if(i>=t.x&&i<=t.x+t.width&&o>=t.y&&o<=t.y+t.height)r=!0,a=!0;else return;const l=e.deltaY>0?1.1:.9,h=(i-t.x)/t.width,f=1-(o-t.y)/t.height,y=s.xMin+h*(s.xMax-s.xMin),m=s.yMin+f*(s.yMax-s.yMin),g=1e-12,x=1e15;let p=r?y-(y-s.xMin)*l:s.xMin,M=r?y+(s.xMax-y)*l:s.xMax,C=a?m-(m-s.yMin)*l:s.yMin,R=a?m+(s.yMax-m)*l:s.yMax;const A=M-p,_=R-C;(A<g||A>x)&&(p=s.xMin,M=s.xMax),(_<g||_>x)&&(C=s.yMin,R=s.yMax);const S={xMin:p,xMax:M,yMin:C,yMax:R};this.callbacks.onZoom(S)}handleMouseDown(e){const t=this.getPlotArea();if(t.width<=1||t.height<=1)return;const n=this.container.getBoundingClientRect(),i=e.clientX-n.left,o=e.clientY-n.top;i>=t.x&&i<=t.x+t.width&&o>=t.y&&o<=t.y+t.height&&(this.isPanMode?(this.isDragging=!0,this.lastMousePos={x:e.clientX,y:e.clientY},this.container.style.cursor="grabbing"):(this.isBoxSelecting=!0,this.selectionStart={x:i,y:o},this.container.style.cursor="crosshair"))}handleMouseMove(e){const t=this.container.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;if(this.callbacks.onCursorMove(n,i),this.isDragging){const o=e.clientX-this.lastMousePos.x,s=e.clientY-this.lastMousePos.y;this.callbacks.onPan(o,s),this.lastMousePos={x:e.clientX,y:e.clientY}}else if(this.isBoxSelecting){const o=Math.min(this.selectionStart.x,n),s=Math.min(this.selectionStart.y,i),r=Math.abs(n-this.selectionStart.x),a=Math.abs(i-this.selectionStart.y);this.callbacks.onBoxZoom({x:o,y:s,width:r,height:a})}}handleMouseUp(){this.isBoxSelecting&&this.callbacks.onBoxZoom(null),this.isDragging=!1,this.isBoxSelecting=!1,this.container.style.cursor=""}handleMouseLeave(){this.isDragging=!1,this.container.style.cursor="",this.callbacks.onCursorLeave()}handleTouchStart(e){if(e.touches.length===1){const t=e.touches[0];this.isDragging=!0,this.lastMousePos={x:t.clientX,y:t.clientY}}}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();const t=e.touches[0],n=t.clientX-this.lastMousePos.x,i=t.clientY-this.lastMousePos.y;this.callbacks.onPan(n,i),this.lastMousePos={x:t.clientX,y:t.clientY}}handleTouchEnd(){this.isDragging=!1}destroy(){this.detachListeners()}}const L={PAN:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M18 11V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"></path><path d="M14 10V4a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"></path><path d="M10 10.5V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"></path><path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"></path></svg>',RESET:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"></polyline><polyline points="1 20 1 14 7 14"></polyline><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path></svg>',LINE:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3v18h18"></path><path d="M18.7 8l-5.1 5.2-2.8-2.7L7 14.3"></path></svg>',SCATTER:'<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><circle cx="7" cy="14" r="2"></circle><circle cx="11" cy="10" r="2"></circle><circle cx="15" cy="13" r="2"></circle><circle cx="19" cy="8" r="2"></circle><path d="M3 3v18h18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>',BOTH:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3v18h18"></path><path d="M18.7 8l-5.1 5.2-2.8-2.7L7 14.3"></path><circle cx="7" cy="14.3" r="1" fill="currentColor"></circle><circle cx="10.8" cy="10.5" r="1" fill="currentColor"></circle><circle cx="13.6" cy="13.2" r="1" fill="currentColor"></circle><circle cx="18.7" cy="8" r="1" fill="currentColor"></circle></svg>',SMOOTH:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12c.5 0 .9-.3 1.2-.7l1.6-2.6c.3-.4.7-.7 1.2-.7h2c.5 0 .9.3 1.2.7l1.6 2.6c.3.4.7.7 1.2.7h2c.5 0 .9-.3 1.2-.7l1.6-2.6c.3-.4.7-.7 1.2-.7h2"></path></svg>',AUTOSCALE:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" y1="3" x2="14" y2="10"></line><line x1="3" y1="21" x2="10" y2="14"></line></svg>',EXPORT:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>'};class Fe{constructor(e,t,n){u(this,"container");u(this,"toolbar");u(this,"callbacks");u(this,"theme");u(this,"isSmoothing",!1);u(this,"isPanMode",!0);u(this,"currentType","line");this.callbacks=n,this.theme=t,this.container=document.createElement("div"),this.container.style.cssText=`
112
+ `;class Z{constructor(e){m(this,"canvas");m(this,"gl");m(this,"dpr");m(this,"lineProgram");m(this,"pointProgram");m(this,"buffers",new Map);m(this,"bufferSizes",new Map);m(this,"isInitialized",!1);this.canvas=e,this.dpr=window.devicePixelRatio||1;const t=e.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance"});if(!t)throw new Error("WebGL not supported");this.gl=t,this.lineProgram=this.createProgram(Ke,Qe,!1),this.pointProgram=this.createProgram(et,tt,!0),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.isInitialized=!0,console.log("[NativeWebGL] Initialized successfully")}setDPR(e){this.dpr=e,this.resize()}createShader(e,t){const{gl:i}=this,s=i.createShader(t);if(!s)throw new Error("Failed to create shader");if(i.shaderSource(s,e),i.compileShader(s),!i.getShaderParameter(s,i.COMPILE_STATUS)){const n=i.getShaderInfoLog(s);throw i.deleteShader(s),new Error(`Shader compilation error: ${n}`)}return s}createProgram(e,t,i){const{gl:s}=this,n=this.createShader(e,s.VERTEX_SHADER),o=this.createShader(t,s.FRAGMENT_SHADER),r=s.createProgram();if(!r)throw new Error("Failed to create program");if(s.attachShader(r,n),s.attachShader(r,o),s.linkProgram(r),!s.getProgramParameter(r,s.LINK_STATUS)){const g=s.getProgramInfoLog(r);throw new Error(`Program link error: ${g}`)}s.deleteShader(n),s.deleteShader(o);const l=s.getAttribLocation(r,"position"),h=s.getUniformLocation(r,"uScale"),c=s.getUniformLocation(r,"uTranslate"),d=s.getUniformLocation(r,"uColor");if(h===null||c===null||d===null)throw new Error("Failed to get uniform locations");const u={program:r,attributes:{position:l},uniforms:{uScale:h,uTranslate:c,uColor:d}};return i&&(u.uniforms.uPointSize=s.getUniformLocation(r,"uPointSize")??void 0,u.uniforms.uSymbol=s.getUniformLocation(r,"uSymbol")??void 0),u}get available(){return this.isInitialized}createBuffer(e,t){const{gl:i}=this;let s=this.buffers.get(e);const n=this.bufferSizes.get(e)||0;if(s&&t.byteLength<=n)i.bindBuffer(i.ARRAY_BUFFER,s),i.bufferSubData(i.ARRAY_BUFFER,0,t);else{if(s&&i.deleteBuffer(s),s=i.createBuffer(),!s)throw new Error("Failed to create buffer");i.bindBuffer(i.ARRAY_BUFFER,s),i.bufferData(i.ARRAY_BUFFER,t,i.DYNAMIC_DRAW),this.buffers.set(e,s),this.bufferSizes.set(e,t.byteLength)}}updateBuffer(e,t,i){const{gl:s}=this,n=this.buffers.get(e),o=this.bufferSizes.get(e)||0;return!n||i+t.byteLength>o?!1:(s.bindBuffer(s.ARRAY_BUFFER,n),s.bufferSubData(s.ARRAY_BUFFER,i,t),!0)}getBuffer(e){return this.buffers.get(e)}deleteBuffer(e){const t=this.buffers.get(e);t&&(this.gl.deleteBuffer(t),this.buffers.delete(e),this.bufferSizes.delete(e))}calculateUniforms(e){const t=e.xMax-e.xMin,i=e.yMax-e.yMin,s=t>0?2/t:1,n=i>0?2/i:1,o=-1-e.xMin*s,r=-1-e.yMin*n;return{scale:[s,n],translate:[o,r]}}render(e,t){if(!this.isInitialized)return;const{gl:i}=this,{bounds:s,backgroundColor:n=[.1,.1,.18,1],plotArea:o}=t,r=this.canvas.height,l=this.canvas.width,h=o?{x:o.x*this.dpr,y:r-(o.y+o.height)*this.dpr,width:o.width*this.dpr,height:o.height*this.dpr}:{x:0,y:0,width:l,height:r};i.viewport(0,0,l,r),i.disable(i.SCISSOR_TEST),i.clearColor(n[0],n[1],n[2],n[3]),i.clear(i.COLOR_BUFFER_BIT),i.viewport(h.x,h.y,h.width,h.height),i.enable(i.SCISSOR_TEST),i.scissor(h.x,h.y,h.width,h.height);const c=this.calculateUniforms(s);for(const d of e){if(!d.visible||d.count===0)continue;const u=d.yBounds?d.yBounds.min:s.yMin,f=(d.yBounds?d.yBounds.max:s.yMax)-u,p=f>0?2/f:1,b=-1-u*p,x={scale:[c.scale[0],p],translate:[c.translate[0],b]},v=J(d.style.color??"#ff0055");v[3]=d.style.opacity??1,d.type==="scatter"?this.renderPoints(d.buffer,d.count,x,v,(d.style.pointSize??4)*this.dpr,d.style.symbol):d.type==="line"?this.renderLine(d.buffer,d.count,x,v):d.type==="line+scatter"?(this.renderLine(d.buffer,d.count,x,v),this.renderPoints(d.buffer,d.count,x,v,(d.style.pointSize??4)*this.dpr,d.style.symbol)):d.type==="step"||d.type==="step+scatter"?(d.stepBuffer&&d.stepCount?this.renderLine(d.stepBuffer,d.stepCount,x,v):this.renderLine(d.buffer,d.count,x,v),d.type==="step+scatter"&&this.renderPoints(d.buffer,d.count,x,v,(d.style.pointSize??4)*this.dpr,d.style.symbol)):d.type==="band"&&this.renderBand(d.buffer,d.count,x,v)}}renderBand(e,t,i,s){const{gl:n}=this,o=this.lineProgram;n.useProgram(o.program),n.bindBuffer(n.ARRAY_BUFFER,e),n.enableVertexAttribArray(o.attributes.position),n.vertexAttribPointer(o.attributes.position,2,n.FLOAT,!1,0,0),n.uniform2f(o.uniforms.uScale,i.scale[0],i.scale[1]),n.uniform2f(o.uniforms.uTranslate,i.translate[0],i.translate[1]);const r=s[3]*.4;n.uniform4f(o.uniforms.uColor,s[0],s[1],s[2],r),n.drawArrays(n.TRIANGLE_STRIP,0,t),n.disableVertexAttribArray(o.attributes.position)}renderLine(e,t,i,s){const{gl:n}=this,o=this.lineProgram;n.useProgram(o.program),n.bindBuffer(n.ARRAY_BUFFER,e),n.enableVertexAttribArray(o.attributes.position),n.vertexAttribPointer(o.attributes.position,2,n.FLOAT,!1,0,0),n.uniform2f(o.uniforms.uScale,i.scale[0],i.scale[1]),n.uniform2f(o.uniforms.uTranslate,i.translate[0],i.translate[1]),n.uniform4f(o.uniforms.uColor,s[0],s[1],s[2],s[3]),n.drawArrays(n.LINE_STRIP,0,t),n.disableVertexAttribArray(o.attributes.position)}renderPoints(e,t,i,s,n,o="circle"){const{gl:r}=this,l=this.pointProgram;if(r.useProgram(l.program),r.bindBuffer(r.ARRAY_BUFFER,e),r.enableVertexAttribArray(l.attributes.position),r.vertexAttribPointer(l.attributes.position,2,r.FLOAT,!1,0,0),r.uniform2f(l.uniforms.uScale,i.scale[0],i.scale[1]),r.uniform2f(l.uniforms.uTranslate,i.translate[0],i.translate[1]),r.uniform4f(l.uniforms.uColor,s[0],s[1],s[2],s[3]),l.uniforms.uPointSize&&r.uniform1f(l.uniforms.uPointSize,n),l.uniforms.uSymbol){const h={circle:0,square:1,diamond:2,triangle:3,triangleDown:4,cross:5,x:6,star:7};r.uniform1i(l.uniforms.uSymbol,h[o]??0)}r.drawArrays(r.POINTS,0,t),r.disableVertexAttribArray(l.attributes.position)}resize(){const e=this.canvas.getBoundingClientRect(),t=e.width*this.dpr,i=e.height*this.dpr;(this.canvas.width!==t||this.canvas.height!==i)&&(this.canvas.width=t,this.canvas.height=i,this.gl.viewport(0,0,t,i))}getLimits(){const{gl:e}=this;return{maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxViewportDims:e.getParameter(e.MAX_VIEWPORT_DIMS),renderer:e.getParameter(e.RENDERER),vendor:e.getParameter(e.VENDOR)}}destroy(){const{gl:e}=this;this.buffers.forEach(t=>e.deleteBuffer(t)),this.buffers.clear(),this.bufferSizes.clear(),e.deleteProgram(this.lineProgram.program),e.deleteProgram(this.pointProgram.program),this.isInitialized=!1,console.log("[NativeWebGL] Destroyed")}}function J(a){if(a.startsWith("#")){const e=a.slice(1);if(e.length===3){const t=parseInt(e[0]+e[0],16)/255,i=parseInt(e[1]+e[1],16)/255,s=parseInt(e[2]+e[2],16)/255;return[t,i,s,1]}else if(e.length===6){const t=parseInt(e.slice(0,2),16)/255,i=parseInt(e.slice(2,4),16)/255,s=parseInt(e.slice(4,6),16)/255;return[t,i,s,1]}else if(e.length===8){const t=parseInt(e.slice(0,2),16)/255,i=parseInt(e.slice(2,4),16)/255,s=parseInt(e.slice(4,6),16)/255,n=parseInt(e.slice(6,8),16)/255;return[t,i,s,n]}}return[1,0,1,1]}function ae(a,e){const t=Math.min(a.length,e.length),i=new Float32Array(t*2);for(let s=0;s<t;s++)i[s*2]=a[s],i[s*2+1]=e[s];return i}function it(a,e,t="after"){const i=Math.min(a.length,e.length);if(i<2)return ae(a,e);const s=i*2-1,n=new Float32Array(s*2);let o=0;for(let r=0;r<i;r++)if(r===0)n[o++]=a[0],n[o++]=e[0];else{const l=a[r-1],h=e[r-1],c=a[r],d=e[r];if(t==="after")n[o++]=c,n[o++]=h,n[o++]=c,n[o++]=d;else if(t==="before")n[o++]=l,n[o++]=d,n[o++]=c,n[o++]=d;else{const u=(l+c)/2;n[o++]=u,n[o++]=h,n[o++]=u,n[o++]=d,n[o++]=c,n[o++]=d}}return n.subarray(0,o)}function st(a,e,t){const i=Math.min(a.length,e.length,t.length),s=new Float32Array(i*2*2);for(let n=0;n<i;n++){const o=n*4,r=a[n];s[o+0]=r,s[o+1]=e[n],s[o+2]=r,s[o+3]=t[n]}return s}const z={lineColor:"#666666",lineWidth:1,tickColor:"#888888",tickLength:6,labelColor:"#cccccc",labelSize:12,titleColor:"#ffffff",titleSize:14,fontFamily:"Inter, system-ui, sans-serif"},K={visible:!0,majorColor:"rgba(255, 255, 255, 0.12)",minorColor:"rgba(255, 255, 255, 0.05)",majorWidth:1,minorWidth:.5,majorDash:[4,4],minorDash:[2,4],showMinor:!0,minorDivisions:5},Q={visible:!0,position:"top-right",backgroundColor:"rgba(20, 20, 30, 0.9)",borderColor:"rgba(255, 255, 255, 0.15)",borderRadius:6,textColor:"#ffffff",fontSize:11,fontFamily:"Inter, system-ui, sans-serif",padding:5,itemGap:3,swatchSize:12},ee={lineColor:"rgba(255, 255, 255, 0.5)",lineWidth:1,lineDash:[5,5],tooltipBackground:"rgba(20, 20, 30, 0.95)",tooltipBorder:"rgba(255, 255, 255, 0.2)",tooltipColor:"#ffffff",tooltipSize:11},te={name:"dark",backgroundColor:"#0b0e14",plotBorderColor:"#444c56",grid:{...K,majorColor:"rgba(255, 255, 255, 0.12)",minorColor:"rgba(255, 255, 255, 0.04)"},xAxis:{...z,labelColor:"#adbac7",titleColor:"#cdd9e5",lineColor:"#444c56",tickColor:"#444c56"},yAxis:{...z,labelColor:"#adbac7",titleColor:"#cdd9e5",lineColor:"#444c56",tickColor:"#444c56"},legend:Q,cursor:ee},ke={name:"midnight",backgroundColor:"#05050a",plotBorderColor:"#3a3a5a",grid:{...K,majorColor:"rgba(150, 150, 255, 0.2)",minorColor:"rgba(150, 150, 255, 0.08)"},xAxis:{...z,lineColor:"#5a5a8a",labelColor:"#b0b0e0",titleColor:"#d0d0f0",tickColor:"#5a5a8a"},yAxis:{...z,lineColor:"#5a5a8a",labelColor:"#b0b0e0",titleColor:"#d0d0f0",tickColor:"#5a5a8a"},legend:{...Q,backgroundColor:"rgba(15, 15, 30, 0.95)",borderColor:"rgba(100, 100, 255, 0.4)"},cursor:{...ee,lineColor:"rgba(150, 150, 255, 0.7)"}},Ee={name:"light",backgroundColor:"#ffffff",plotBorderColor:"#cccccc",grid:{...K,majorColor:"rgba(0, 0, 0, 0.1)",minorColor:"rgba(0, 0, 0, 0.04)"},xAxis:{...z,lineColor:"#888888",tickColor:"#888888",labelColor:"#444444",titleColor:"#222222"},yAxis:{...z,lineColor:"#888888",tickColor:"#888888",labelColor:"#444444",titleColor:"#222222"},legend:{...Q,backgroundColor:"rgba(255, 255, 255, 0.95)",borderColor:"rgba(0, 0, 0, 0.15)",textColor:"#222222"},cursor:{...ee,lineColor:"rgba(0, 0, 0, 0.4)",tooltipBackground:"rgba(50, 50, 60, 0.95)"}},Pe={name:"electrochemistry",backgroundColor:"#0a1628",plotBorderColor:"#1e3a5f",grid:{...K,majorColor:"rgba(30, 136, 229, 0.15)",minorColor:"rgba(30, 136, 229, 0.06)",showMinor:!0,minorDivisions:2},xAxis:{...z,lineColor:"#1e88e5",tickColor:"#42a5f5",labelColor:"#90caf9",titleColor:"#bbdefb"},yAxis:{...z,lineColor:"#1e88e5",tickColor:"#42a5f5",labelColor:"#90caf9",titleColor:"#bbdefb"},legend:{...Q,backgroundColor:"rgba(10, 22, 40, 0.95)",borderColor:"rgba(30, 136, 229, 0.3)"},cursor:{...ee,lineColor:"rgba(100, 180, 255, 0.6)"}};function nt(a,e){return{...a,...e,grid:{...a.grid,...e.grid},xAxis:{...a.xAxis,...e.xAxis},yAxis:{...a.yAxis,...e.yAxis},legend:{...a.legend,...e.legend},cursor:{...a.cursor,...e.cursor}}}function le(a){switch(a){case"dark":return te;case"midnight":return ke;case"light":return Ee;case"electrochemistry":case"electrochem":return Pe;default:return console.warn(`[Theme] Unknown theme "${a}", using dark`),te}}const Be=te;class Ae{constructor(e,t){m(this,"ctx");m(this,"theme");this.ctx=e,this.theme=t}setTheme(e){this.theme=e}clear(e,t){this.ctx.clearRect(0,0,e,t)}drawGrid(e,t,i){if(!this.theme.grid.visible)return;const{ctx:s}=this,n=this.theme.grid,o=t.ticks(8),r=i.ticks(6);if(s.strokeStyle=n.majorColor,s.lineWidth=n.majorWidth,s.setLineDash(n.majorDash),o.forEach(l=>{const h=t.transform(l);h>=e.x&&h<=e.x+e.width&&(s.beginPath(),s.moveTo(h,e.y),s.lineTo(h,e.y+e.height),s.stroke())}),r.forEach(l=>{const h=i.transform(l);h>=e.y&&h<=e.y+e.height&&(s.beginPath(),s.moveTo(e.x,h),s.lineTo(e.x+e.width,h),s.stroke())}),n.showMinor){s.strokeStyle=n.minorColor,s.lineWidth=n.minorWidth,s.setLineDash(n.minorDash);const l=this.generateMinorTicks(o,n.minorDivisions),h=this.generateMinorTicks(r,n.minorDivisions);l.forEach(c=>{const d=t.transform(c);d>=e.x&&d<=e.x+e.width&&(s.beginPath(),s.moveTo(d,e.y),s.lineTo(d,e.y+e.height),s.stroke())}),h.forEach(c=>{const d=i.transform(c);d>=e.y&&d<=e.y+e.height&&(s.beginPath(),s.moveTo(e.x,d),s.lineTo(e.x+e.width,d),s.stroke())})}s.setLineDash([])}drawXAxis(e,t,i){const{ctx:s}=this,n=this.theme.xAxis,o=t.ticks(8),r=e.y+e.height;s.strokeStyle=n.lineColor,s.lineWidth=n.lineWidth,s.beginPath(),s.moveTo(e.x,r),s.lineTo(e.x+e.width,r),s.stroke(),s.fillStyle=n.labelColor,s.font=`${n.labelSize}px ${n.fontFamily}`,s.textAlign="center",s.textBaseline="top",o.forEach(l=>{const h=t.transform(l);h>=e.x&&h<=e.x+e.width&&(s.strokeStyle=n.tickColor,s.beginPath(),s.moveTo(h,r),s.lineTo(h,r+n.tickLength),s.stroke(),s.fillText(this.formatXTick(l),h,r+n.tickLength+3))}),i&&(s.fillStyle=n.titleColor,s.font=`${n.titleSize}px ${n.fontFamily}`,s.textAlign="center",s.textBaseline="bottom",s.fillText(i,e.x+e.width/2,e.y+e.height+45))}drawYAxis(e,t,i,s="left",n=0){const{ctx:o}=this,r=this.theme.yAxis,l=t.ticks(6),h=s==="left"?e.x-n:e.x+e.width+n,c=s==="left"?-1:1;if(o.strokeStyle=r.lineColor,o.lineWidth=r.lineWidth,o.beginPath(),o.moveTo(h,e.y),o.lineTo(h,e.y+e.height),o.stroke(),o.fillStyle=r.labelColor,o.font=`${r.labelSize}px ${r.fontFamily}`,o.textAlign=s==="left"?"right":"left",o.textBaseline="middle",l.forEach(d=>{const u=t.transform(d);if(u>=e.y&&u<=e.y+e.height){o.strokeStyle=r.tickColor,o.beginPath(),o.moveTo(h,u),o.lineTo(h+r.tickLength*c,u),o.stroke();const g=h+(r.tickLength+3)*c;o.fillText(this.formatYTick(d),g,u)}}),i){o.save(),o.fillStyle=r.titleColor,o.font=`${r.titleSize}px ${r.fontFamily}`,o.textAlign="center",o.textBaseline="top";const d=s==="left"?h-40:h+40,u=e.y+e.height/2;o.translate(d,u),o.rotate(s==="left"?-Math.PI/2:Math.PI/2),o.fillText(i,0,0),o.restore()}}drawPlotBorder(e){const{ctx:t}=this;t.strokeStyle=this.theme.plotBorderColor,t.lineWidth=1,t.strokeRect(e.x,e.y,e.width,e.height)}drawLegend(e,t){if(t.length===0)return;const{ctx:i}=this,s=this.theme.legend;i.font=`${s.fontSize}px ${s.fontFamily}`;let n=0;const o=t.map(u=>{const g=u.getId(),f=u.getStyle(),p=i.measureText(g).width;return n=Math.max(n,p),{id:u.getId(),color:f.color??"#ff0055",label:g,type:u.getType(),symbol:f.symbol,opacity:f.opacity??1}}),r=s.swatchSize+8+n+s.padding*2,l=o.length*(s.swatchSize+s.itemGap)-s.itemGap+s.padding*2;let h,c;switch(s.position){case"top-left":h=e.x+10,c=e.y+10;break;case"bottom-left":h=e.x+10,c=e.y+10;break;case"bottom-right":h=e.x+e.width-r-10,c=e.y+e.height-l-10;break;case"top-right":default:h=e.x+e.width-r-10,c=e.y+10;break}i.fillStyle=s.backgroundColor,i.strokeStyle=s.borderColor,i.lineWidth=1,i.beginPath();const d=s.borderRadius;i.moveTo(h+d,c),i.lineTo(h+r-d,c),i.arcTo(h+r,c,h+r,c+d,d),i.lineTo(h+r,c+l-d),i.arcTo(h+r,c+l,h+r-d,c+l,d),i.lineTo(h+d,c+l),i.arcTo(h,c+l,h,c+l-d,d),i.lineTo(h,c+d),i.arcTo(h,c,h+d,c,d),i.closePath(),i.fill(),i.stroke(),i.textAlign="left",i.textBaseline="middle",o.forEach((u,g)=>{const f=c+s.padding+g*(s.swatchSize+s.itemGap),p=h+s.padding,b=f+s.swatchSize/2,x=p+s.swatchSize/2;i.save(),i.globalAlpha=u.opacity,i.fillStyle=u.color,i.strokeStyle=u.color,i.lineWidth=2;const v=s.swatchSize,T=String(u.type).toLowerCase(),A=!!u.symbol&&u.symbol!=="circle",B=T==="scatter"||T==="1"||T==="line"&&A,w=T.includes("scatter")||T==="2";B?this.drawLegendSymbol(i,u.symbol??"circle",x,b,v*.9):w?(i.beginPath(),i.moveTo(p,b),i.lineTo(p+v,b),i.stroke(),this.drawLegendSymbol(i,u.symbol??"circle",x,b,v*.6)):(i.beginPath(),i.moveTo(p,b),i.lineTo(p+v,b),i.stroke()),i.restore(),i.fillStyle=s.textColor,i.fillText(u.label,h+s.padding+s.swatchSize+8,b)})}drawLegendSymbol(e,t,i,s,n){const o=n/2;switch(e.beginPath(),t){case"circle":e.arc(i,s,o,0,Math.PI*2),e.fill();break;case"square":e.rect(i-o,s-o,n,n),e.fill();break;case"diamond":e.moveTo(i,s-o),e.lineTo(i+o,s),e.lineTo(i,s+o),e.lineTo(i-o,s),e.closePath(),e.fill();break;case"triangle":e.moveTo(i,s-o),e.lineTo(i+o,s+o),e.lineTo(i-o,s+o),e.closePath(),e.fill();break;case"triangleDown":e.moveTo(i,s+o),e.lineTo(i+o,s-o),e.lineTo(i-o,s-o),e.closePath(),e.fill();break;case"cross":e.moveTo(i-o,s),e.lineTo(i+o,s),e.moveTo(i,s-o),e.lineTo(i,s+o),e.stroke();break;case"x":const r=o*.707;e.moveTo(i-r,s-r),e.lineTo(i+r,s+r),e.moveTo(i+r,s-r),e.lineTo(i-r,s+r),e.stroke();break;case"star":for(let l=0;l<5;l++)e.lineTo(i+o*Math.cos((18+l*72)/180*Math.PI),s-o*Math.sin((18+l*72)/180*Math.PI)),e.lineTo(i+o/2*Math.cos((54+l*72)/180*Math.PI),s-o/2*Math.sin((54+l*72)/180*Math.PI));e.closePath(),e.fill();break}}drawCursor(e,t){if(!t.enabled)return;const{ctx:i}=this,s=this.theme.cursor;t.x<e.x||t.x>e.x+e.width||t.y<e.y||t.y>e.y+e.height||(i.save(),i.beginPath(),i.rect(e.x,e.y,e.width,e.height),i.clip(),i.strokeStyle=s.lineColor,i.lineWidth=s.lineWidth,i.setLineDash(s.lineDash),t.crosshair?(i.beginPath(),i.moveTo(t.x,e.y),i.lineTo(t.x,e.y+e.height),i.stroke(),i.beginPath(),i.moveTo(e.x,t.y),i.lineTo(e.x+e.width,t.y),i.stroke()):(i.beginPath(),i.moveTo(t.x,e.y),i.lineTo(t.x,e.y+e.height),i.stroke()),i.restore(),t.tooltipText&&this.drawTooltip(t.x,t.y,t.tooltipText,e))}drawTooltip(e,t,i,s){const{ctx:n}=this,o=this.theme.cursor,r=i.split(`
113
+ `),l=o.tooltipSize+5,h=8;n.font=`${o.tooltipSize}px ${this.theme.xAxis.fontFamily}`;let c=0;r.forEach(b=>{c=Math.max(c,n.measureText(b).width)});const d=c+h*2,u=r.length*l+h*2-5;let g=e+15,f=t-u-10;g+d>s.x+s.width&&(g=e-d-15),f<s.y&&(f=t+15),n.fillStyle=o.tooltipBackground,n.strokeStyle=o.tooltipBorder,n.lineWidth=1,n.beginPath();const p=4;n.moveTo(g+p,f),n.lineTo(g+d-p,f),n.arcTo(g+d,f,g+d,f+p,p),n.lineTo(g+d,f+u-p),n.arcTo(g+d,f+u,g+d-p,f+u,p),n.lineTo(g+p,f+u),n.arcTo(g,f+u,g,f+u-p,p),n.lineTo(g,f+p),n.arcTo(g,f,g+p,f,p),n.closePath(),n.fill(),n.stroke(),n.fillStyle=o.tooltipColor,n.textAlign="left",n.textBaseline="top",r.forEach((b,x)=>{n.fillText(b,g+h,f+h+x*l)})}drawSelectionRect(e){const{ctx:t}=this,i=this.theme.name.toLowerCase().includes("dark")||this.theme.name.toLowerCase().includes("midnight");t.save(),t.fillStyle=i?"rgba(0, 170, 255, 0.15)":"rgba(0, 100, 255, 0.1)",t.strokeStyle="#00aaff",t.lineWidth=1,t.setLineDash([5,5]),t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fill(),t.stroke(),t.restore()}drawErrorBars(e,t,i,s){if(!t.hasErrorData())return;const{ctx:n}=this,o=t.getData(),r=t.getStyle(),l=r.errorBars??{};if(l.visible===!1)return;const h=l.color??r.color??"#ff0055",c=l.width??1,d=l.capWidth??6,u=l.showCaps!==!1,g=l.opacity??.7,f=l.direction??"both";n.save(),n.beginPath(),n.rect(e.x,e.y,e.width,e.height),n.clip(),n.strokeStyle=h,n.lineWidth=c,n.globalAlpha=g;for(let p=0;p<o.x.length;p++){const b=i.transform(o.x[p]),x=s.transform(o.y[p]);if(b<e.x||b>e.x+e.width||x<e.y||x>e.y+e.height)continue;const v=t.getYError(p);if(v){const[A,B]=v,w=o.y[p],E=s.transform(w+B),k=s.transform(w-A);n.beginPath(),(f==="both"||f==="positive")&&(n.moveTo(b,x),n.lineTo(b,E),u&&(n.moveTo(b-d/2,E),n.lineTo(b+d/2,E))),(f==="both"||f==="negative")&&(n.moveTo(b,x),n.lineTo(b,k),u&&(n.moveTo(b-d/2,k),n.lineTo(b+d/2,k))),n.stroke()}const T=t.getXError(p);if(T){const[A,B]=T,w=o.x[p],E=i.transform(w+B),k=i.transform(w-A);n.beginPath(),(f==="both"||f==="positive")&&(n.moveTo(b,x),n.lineTo(E,x),u&&(n.moveTo(E,x-d/2),n.lineTo(E,x+d/2))),(f==="both"||f==="negative")&&(n.moveTo(b,x),n.lineTo(k,x),u&&(n.moveTo(k,x-d/2),n.lineTo(k,x+d/2))),n.stroke()}}n.restore()}generateMinorTicks(e,t){if(e.length<2)return[];const i=[];for(let s=0;s<e.length-1;s++){const n=(e[s+1]-e[s])/t;for(let o=1;o<t;o++)i.push(e[s]+n*o)}return i}formatXTick(e){return Math.abs(e)<.001&&e!==0?this.toScientificUnicode(e,1):e.toFixed(3).replace(/\.?0+$/,"")}formatYTick(e){if(e===0)return"0";const t=Math.abs(e);return t<1e-4||t>=1e4?this.toScientificUnicode(e,1):e.toPrecision(3)}toScientificUnicode(e,t){const i=e.toExponential(t),[s,n]=i.split("e"),o={0:"⁰",1:"¹",2:"²",3:"³",4:"⁴",5:"⁵",6:"⁶",7:"⁷",8:"⁸",9:"⁹","-":"⁻","+":"⁺"},r=n.replace(/[0-9\-+]/g,l=>o[l]||l);return`${s} × 10${r}`}}class ot{constructor(e,t,i,s,n){m(this,"container");m(this,"callbacks");m(this,"getPlotArea");m(this,"getBounds");m(this,"getAxesLayout");m(this,"isDragging",!1);m(this,"panningAxisId");m(this,"isBoxSelecting",!1);m(this,"selectionStart",{x:0,y:0});m(this,"lastMousePos",{x:0,y:0});m(this,"isPanMode",!0);m(this,"boundWheel");m(this,"boundMouseDown");m(this,"boundMouseMove");m(this,"boundMouseUp");m(this,"boundMouseLeave");m(this,"boundTouchStart");m(this,"boundTouchMove");m(this,"boundTouchEnd");this.container=e,this.callbacks=t,this.getPlotArea=i,this.getBounds=s,this.getAxesLayout=n,this.boundWheel=this.handleWheel.bind(this),this.boundMouseDown=this.handleMouseDown.bind(this),this.boundMouseMove=this.handleMouseMove.bind(this),this.boundMouseUp=this.handleMouseUp.bind(this),this.boundMouseLeave=this.handleMouseLeave.bind(this),this.boundTouchStart=this.handleTouchStart.bind(this),this.boundTouchMove=this.handleTouchMove.bind(this),this.boundTouchEnd=this.handleTouchEnd.bind(this),this.attachListeners()}attachListeners(){this.container.addEventListener("wheel",this.boundWheel,{passive:!1}),this.container.addEventListener("mousedown",this.boundMouseDown),this.container.addEventListener("mousemove",this.boundMouseMove),this.container.addEventListener("mouseup",this.boundMouseUp),this.container.addEventListener("mouseleave",this.boundMouseLeave),this.container.addEventListener("touchstart",this.boundTouchStart),this.container.addEventListener("touchmove",this.boundTouchMove),this.container.addEventListener("touchend",this.boundTouchEnd)}detachListeners(){this.container.removeEventListener("wheel",this.boundWheel),this.container.removeEventListener("mousedown",this.boundMouseDown),this.container.removeEventListener("mousemove",this.boundMouseMove),this.container.removeEventListener("mouseup",this.boundMouseUp),this.container.removeEventListener("mouseleave",this.boundMouseLeave),this.container.removeEventListener("touchstart",this.boundTouchStart),this.container.removeEventListener("touchmove",this.boundTouchMove),this.container.removeEventListener("touchend",this.boundTouchEnd)}setPanMode(e){this.isPanMode=e}handleWheel(e){const t=this.getPlotArea();if(t.width<=1||t.height<=1)return;e.preventDefault();const i=this.container.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top,o=this.getAxesLayout();let r=!1,l=!1,h;for(const D of o){const O=D.position==="left"?t.x-D.offset:t.x+t.width+D.offset,N=65,W=D.position==="left"?O-N:O;if(s>=W&&s<=W+N&&n>=t.y&&n<=t.y+t.height){h=D.id,l=!0,r=!1;break}}if(!h)if(n>t.y+t.height&&s>=t.x&&s<=t.x+t.width)r=!0;else if(s>=t.x&&s<=t.x+t.width&&n>=t.y&&n<=t.y+t.height)r=!0,l=!0;else return;const c=this.getBounds(h),d=e.deltaY>0?1.1:.9,u=(s-t.x)/t.width,g=1-(n-t.y)/t.height,f=c.xMin+u*(c.xMax-c.xMin),p=c.yMin+g*(c.yMax-c.yMin),b=1e-12,x=1e15;let v=r?f-(f-c.xMin)*d:c.xMin,T=r?f+(c.xMax-f)*d:c.xMax,A=l?p-(p-c.yMin)*d:c.yMin,B=l?p+(c.yMax-p)*d:c.yMax;const w=T-v,E=B-A;(w<b||w>x)&&(v=c.xMin,T=c.xMax),(E<b||E>x)&&(A=c.yMin,B=c.yMax);const k={xMin:v,xMax:T,yMin:A,yMax:B};this.callbacks.onZoom(k,h)}handleMouseDown(e){const t=this.getPlotArea();if(t.width<=1||t.height<=1)return;const i=this.container.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top,o=this.getAxesLayout();for(const r of o){const l=r.position==="left"?t.x-r.offset:t.x+t.width+r.offset,h=65,c=r.position==="left"?l-h:l;if(s>=c&&s<=c+h&&n>=t.y&&n<=t.y+t.height){this.isDragging=!0,this.panningAxisId=r.id,this.lastMousePos={x:e.clientX,y:e.clientY},this.container.style.cursor="ns-resize";return}}s>=t.x&&s<=t.x+t.width&&n>=t.y&&n<=t.y+t.height&&(this.isPanMode?(this.isDragging=!0,this.panningAxisId=void 0,this.lastMousePos={x:e.clientX,y:e.clientY},this.container.style.cursor="grabbing"):(this.isBoxSelecting=!0,this.selectionStart={x:s,y:n},this.container.style.cursor="crosshair"))}handleMouseMove(e){const t=this.container.getBoundingClientRect(),i=e.clientX-t.left,s=e.clientY-t.top;if(this.callbacks.onCursorMove(i,s),this.isDragging){const n=e.clientX-this.lastMousePos.x,o=e.clientY-this.lastMousePos.y;this.callbacks.onPan(n,o,this.panningAxisId),this.lastMousePos={x:e.clientX,y:e.clientY}}else if(this.isBoxSelecting){const n=Math.min(this.selectionStart.x,i),o=Math.min(this.selectionStart.y,s),r=Math.abs(i-this.selectionStart.x),l=Math.abs(s-this.selectionStart.y);this.callbacks.onBoxZoom({x:n,y:o,width:r,height:l})}}handleMouseUp(){this.isBoxSelecting&&this.callbacks.onBoxZoom(null),this.isDragging=!1,this.panningAxisId=void 0,this.isBoxSelecting=!1,this.container.style.cursor=""}handleMouseLeave(){this.isDragging=!1,this.panningAxisId=void 0,this.container.style.cursor="",this.callbacks.onCursorLeave()}handleTouchStart(e){if(e.touches.length===1){const t=e.touches[0];this.isDragging=!0,this.panningAxisId=void 0,this.lastMousePos={x:t.clientX,y:t.clientY}}}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();const t=e.touches[0],i=t.clientX-this.lastMousePos.x,s=t.clientY-this.lastMousePos.y;this.callbacks.onPan(i,s,this.panningAxisId),this.lastMousePos={x:t.clientX,y:t.clientY}}handleTouchEnd(){this.isDragging=!1,this.panningAxisId=void 0}destroy(){this.detachListeners()}}const Y={PAN:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M18 11V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"></path><path d="M14 10V4a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"></path><path d="M10 10.5V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"></path><path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"></path></svg>',RESET:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"></polyline><polyline points="1 20 1 14 7 14"></polyline><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path></svg>',LINE:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3v18h18"></path><path d="M18.7 8l-5.1 5.2-2.8-2.7L7 14.3"></path></svg>',SCATTER:'<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><circle cx="7" cy="14" r="2"></circle><circle cx="11" cy="10" r="2"></circle><circle cx="15" cy="13" r="2"></circle><circle cx="19" cy="8" r="2"></circle><path d="M3 3v18h18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>',BOTH:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3v18h18"></path><path d="M18.7 8l-5.1 5.2-2.8-2.7L7 14.3"></path><circle cx="7" cy="14.3" r="1" fill="currentColor"></circle><circle cx="10.8" cy="10.5" r="1" fill="currentColor"></circle><circle cx="13.6" cy="13.2" r="1" fill="currentColor"></circle><circle cx="18.7" cy="8" r="1" fill="currentColor"></circle></svg>',SMOOTH:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12c.5 0 .9-.3 1.2-.7l1.6-2.6c.3-.4.7-.7 1.2-.7h2c.5 0 .9.3 1.2.7l1.6 2.6c.3.4.7.7 1.2.7h2c.5 0 .9-.3 1.2-.7l1.6-2.6c.3-.4.7-.7 1.2-.7h2"></path></svg>',AUTOSCALE:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" y1="3" x2="14" y2="10"></line><line x1="3" y1="21" x2="10" y2="14"></line></svg>',EXPORT:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>',LEGEND:'<svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6h16M4 12h16M4 18h7"></path></svg>'};class rt{constructor(e,t,i){m(this,"container");m(this,"toolbar");m(this,"callbacks");m(this,"theme");m(this,"isSmoothing",!1);m(this,"isPanMode",!0);m(this,"isLegendVisible",!0);m(this,"currentType","line");this.callbacks=i,this.theme=t,this.container=document.createElement("div"),this.container.style.cssText=`
43
114
  position: absolute;
44
115
  top: 8px;
45
116
  right: 8px;
@@ -49,7 +120,7 @@ void main() {
49
120
  flex-direction: column;
50
121
  align-items: flex-end;
51
122
  gap: 8px;
52
- `,this.toolbar=document.createElement("div"),this.toolbar.className="scichart-modebar",this.updateToolbarStyle(),this.createButtons(),this.container.appendChild(this.toolbar),e.appendChild(this.container)}isDarkTheme(){const e=this.theme.name.toLowerCase();return e.includes("dark")||e.includes("midnight")||e.includes("electro")}updateToolbarStyle(){const e=this.isDarkTheme(),t=e?"rgba(15, 23, 42, 0.85)":"rgba(255, 255, 255, 0.95)",n=e?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.15)",i=e?"0 4px 12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1)":"0 4px 12px rgba(0, 0, 0, 0.15)";this.toolbar.style.cssText=`
123
+ `,this.toolbar=document.createElement("div"),this.toolbar.className="scichart-modebar",this.updateToolbarStyle(),this.createButtons(),this.container.appendChild(this.toolbar),e.appendChild(this.container)}isDarkTheme(){const e=this.theme.name.toLowerCase();return e.includes("dark")||e.includes("midnight")||e.includes("electro")}updateToolbarStyle(){const e=this.isDarkTheme(),t=e?"rgba(15, 23, 42, 0.85)":"rgba(255, 255, 255, 0.95)",i=e?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.15)",s=e?"0 4px 12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1)":"0 4px 12px rgba(0, 0, 0, 0.15)";this.toolbar.style.cssText=`
53
124
  display: flex;
54
125
  align-items: center;
55
126
  gap: 4px;
@@ -57,11 +128,11 @@ void main() {
57
128
  background: ${t};
58
129
  backdrop-filter: blur(12px) saturate(180%);
59
130
  -webkit-backdrop-filter: blur(12px) saturate(180%);
60
- border: 1px solid ${n};
131
+ border: 1px solid ${i};
61
132
  border-radius: 8px;
62
- box-shadow: ${i};
133
+ box-shadow: ${s};
63
134
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
64
- `}createButtons(){this.createButton(L.PAN,"Pan Mode",()=>{this.isPanMode=!this.isPanMode,this.updateButtonStates(),this.callbacks.onTogglePan(this.isPanMode)},"pan"),this.createButton(L.RESET,"Reset Zoom",()=>this.callbacks.onResetZoom(),"reset"),this.createButton(L.AUTOSCALE,"Auto Scale",()=>this.callbacks.onAutoScale(),"autoscale");const e=document.createElement("div"),t=this.isDarkTheme();e.style.cssText=`width: 1px; height: 20px; background: ${t?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.2)"}; margin: 0 6px;`,this.toolbar.appendChild(e),this.createButton(L.LINE,"Toggle Line/Scatter/Both",()=>{const i=["line","scatter","line+scatter"],o=(i.indexOf(this.currentType)+1)%i.length;this.currentType=i[o],this.callbacks.onSetType(this.currentType),this.updateButtonStates()},"type"),this.createButton(L.SMOOTH,"Automated Smoothing",()=>{this.isSmoothing=!this.isSmoothing,this.updateButtonStates(),this.callbacks.onToggleSmoothing()},"smooth");const n=document.createElement("div");n.style.cssText=`width: 1px; height: 20px; background: ${t?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.2)"}; margin: 0 6px;`,this.toolbar.appendChild(n),this.createButton(L.EXPORT,"Export as PNG",()=>this.callbacks.onExport(),"export"),this.updateButtonStates()}enforceSVGVisibility(e){const t=e.querySelector(".scichart-control-icon");t&&(t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.width="100%",t.style.height="100%",t.style.pointerEvents="none");const n=e.querySelector("svg");n&&(n.setAttribute("width","14"),n.setAttribute("height","14"),n.style.display="block",n.style.overflow="visible",n.style.color="inherit",n.style.stroke="currentColor",n.getAttribute("fill")||(n.style.fill="none"))}createButton(e,t,n,i){const o=document.createElement("button");o.innerHTML=`<span class="scichart-control-icon">${e}</span>`,o.title=t,o.dataset.id=i;const s=this.isDarkTheme(),r=s?"#ffffff":"#1e293b";return o.style.cssText=`
135
+ `}createButtons(){this.createButton(Y.PAN,"Pan Mode",()=>{this.isPanMode=!this.isPanMode,this.updateButtonStates(),this.callbacks.onTogglePan(this.isPanMode)},"pan"),this.createButton(Y.RESET,"Reset Zoom",()=>this.callbacks.onResetZoom(),"reset"),this.createButton(Y.AUTOSCALE,"Auto Scale",()=>this.callbacks.onAutoScale(),"autoscale");const e=document.createElement("div"),t=this.isDarkTheme();e.style.cssText=`width: 1px; height: 20px; background: ${t?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.2)"}; margin: 0 6px;`,this.toolbar.appendChild(e),this.createButton(Y.LINE,"Toggle Line/Scatter/Both",()=>{const n=["line","scatter","line+scatter"],o=(n.indexOf(this.currentType)+1)%n.length;this.currentType=n[o],this.callbacks.onSetType(this.currentType),this.updateButtonStates()},"type"),this.createButton(Y.SMOOTH,"Automated Smoothing",()=>{this.isSmoothing=!this.isSmoothing,this.updateButtonStates(),this.callbacks.onToggleSmoothing()},"smooth");const i=document.createElement("div");i.style.cssText=`width: 1px; height: 20px; background: ${t?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.2)"}; margin: 0 6px;`,this.toolbar.appendChild(i),this.createButton(Y.EXPORT,"Export as PNG",()=>this.callbacks.onExport(),"export");const s=document.createElement("div");s.style.cssText=`width: 1px; height: 20px; background: ${this.isDarkTheme()?"rgba(255,255,255,0.25)":"rgba(0,0,0,0.2)"}; margin: 0 6px;`,this.toolbar.appendChild(s),this.createButton(Y.LEGEND,"Toggle Legend",()=>{this.isLegendVisible=!this.isLegendVisible,this.updateButtonStates(),this.callbacks.onToggleLegend(this.isLegendVisible)},"legend"),this.updateButtonStates()}enforceSVGVisibility(e){const t=e.querySelector(".scichart-control-icon");t&&(t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.width="100%",t.style.height="100%",t.style.pointerEvents="none");const i=e.querySelector("svg");i&&(i.setAttribute("width","14"),i.setAttribute("height","14"),i.style.display="block",i.style.overflow="visible",i.style.color="inherit",i.style.stroke="currentColor",i.getAttribute("fill")||(i.style.fill="none"))}createButton(e,t,i,s){const n=document.createElement("button");n.innerHTML=`<span class="scichart-control-icon">${e}</span>`,n.title=t,n.dataset.id=s;const o=this.isDarkTheme(),r=o?"#ffffff":"#1e293b";return n.style.cssText=`
65
136
  width: 24px;
66
137
  height: 24px;
67
138
  display: flex;
@@ -74,10 +145,10 @@ void main() {
74
145
  border-radius: 6px;
75
146
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
76
147
  opacity: 0.9;
77
- `,o.onmouseenter=()=>{o.style.opacity="1",o.style.background=s?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.1)",o.style.transform="translateY(-1px)",o.style.boxShadow=s?"0 2px 4px rgba(0,0,0,0.4)":"0 2px 4px rgba(0,0,0,0.1)"},o.onmouseleave=()=>{o.style.transform="none",o.style.boxShadow="none",this.updateButtonStates()},o.onclick=n,this.enforceSVGVisibility(o),this.toolbar.appendChild(o),o}updateButtonStates(){const e=this.toolbar.querySelectorAll("button"),t=this.isDarkTheme(),n="#38bdf8",i="#fb7185",o=t?"#f1f5f9":"#334155";e.forEach(s=>{const r=s.dataset.id,a=s.matches(":hover");r==="pan"?(s.style.color=this.isPanMode?n:o,s.style.opacity=a||this.isPanMode?"1":"0.8",this.isPanMode&&(s.style.background=t?"rgba(56, 189, 248, 0.15)":"rgba(56, 189, 248, 0.1)")):r==="smooth"?(s.style.color=this.isSmoothing?i:o,s.style.opacity=a||this.isSmoothing?"1":"0.8",this.isSmoothing&&(s.style.background=t?"rgba(251, 113, 133, 0.15)":"rgba(251, 113, 133, 0.1)")):r==="type"?(s.innerHTML=this.currentType==="line"?L.LINE:this.currentType==="scatter"?L.SCATTER:L.BOTH,this.enforceSVGVisibility(s),s.style.color=o,s.style.opacity=a?"1":"0.8"):(r==="reset"||r==="autoscale"||r==="export")&&(s.style.color=o,s.style.opacity=a?"1":"0.8"),!a&&!(r==="pan"&&this.isPanMode||r==="smooth"&&this.isSmoothing)&&(s.style.background="transparent")})}updateTheme(e){this.theme=e,this.updateToolbarStyle(),this.updateButtonStates()}destroy(){this.container.remove()}}class Ie{constructor(e,t,n,i){u(this,"container");u(this,"header");u(this,"content");u(this,"theme");u(this,"series",[]);u(this,"callbacks");u(this,"isDragging",!1);u(this,"startX",0);u(this,"startY",0);u(this,"initialX",0);u(this,"initialY",0);this.theme=t,this.callbacks=i,this.container=document.createElement("div"),this.container.className="scichart-legend";const o=n.x??e.clientWidth-150,s=n.y??55;this.container.style.cssText=`
148
+ `,n.onmouseenter=()=>{n.style.opacity="1",n.style.background=o?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.1)",n.style.transform="translateY(-1px)",n.style.boxShadow=o?"0 2px 4px rgba(0,0,0,0.4)":"0 2px 4px rgba(0,0,0,0.1)"},n.onmouseleave=()=>{n.style.transform="none",n.style.boxShadow="none",this.updateButtonStates()},n.onclick=i,this.enforceSVGVisibility(n),this.toolbar.appendChild(n),n}updateButtonStates(){const e=this.toolbar.querySelectorAll("button"),t=this.isDarkTheme(),i="#38bdf8",s="#fb7185",n="#4ade80",o=t?"#f1f5f9":"#334155";e.forEach(r=>{const l=r.dataset.id,h=r.matches(":hover");l==="pan"?(r.style.color=this.isPanMode?i:o,r.style.opacity=h||this.isPanMode?"1":"0.8",this.isPanMode&&(r.style.background=t?"rgba(56, 189, 248, 0.15)":"rgba(56, 189, 248, 0.1)")):l==="smooth"?(r.style.color=this.isSmoothing?s:o,r.style.opacity=h||this.isSmoothing?"1":"0.8",this.isSmoothing&&(r.style.background=t?"rgba(251, 113, 133, 0.15)":"rgba(251, 113, 133, 0.1)")):l==="legend"?(r.style.color=this.isLegendVisible?n:o,r.style.opacity=h||this.isLegendVisible?"1":"0.8",this.isLegendVisible&&(r.style.background=t?"rgba(74, 222, 128, 0.15)":"rgba(74, 222, 128, 0.1)")):l==="type"?(r.innerHTML=this.currentType==="line"?Y.LINE:this.currentType==="scatter"?Y.SCATTER:Y.BOTH,this.enforceSVGVisibility(r),r.style.color=o,r.style.opacity=h?"1":"0.8"):(l==="reset"||l==="autoscale"||l==="export")&&(r.style.color=o,r.style.opacity=h?"1":"0.8"),!h&&!(l==="pan"&&this.isPanMode||l==="smooth"&&this.isSmoothing||l==="legend"&&this.isLegendVisible)&&(r.style.background="transparent")})}updateTheme(e){this.theme=e,this.updateToolbarStyle(),this.updateButtonStates()}destroy(){this.container.remove()}}class at{constructor(e,t,i,s){m(this,"container");m(this,"header");m(this,"content");m(this,"theme");m(this,"series",[]);m(this,"callbacks");m(this,"isDragging",!1);m(this,"startX",0);m(this,"startY",0);m(this,"initialX",0);m(this,"initialY",0);this.theme=t,this.callbacks=s,this.container=document.createElement("div"),this.container.className="scichart-legend";const n=i.x??e.clientWidth-150,o=i.y??55;this.container.style.cssText=`
78
149
  position: absolute;
79
- left: ${o}px;
80
- top: ${s}px;
150
+ left: ${n}px;
151
+ top: ${o}px;
81
152
  z-index: 90;
82
153
  pointer-events: auto;
83
154
  min-width: 120px;
@@ -91,7 +162,7 @@ void main() {
91
162
  cursor: move;
92
163
  background: rgba(255,255,255,0.05);
93
164
  border-bottom: 1px solid rgba(255,255,255,0.05);
94
- `,this.content=document.createElement("div"),this.content.style.padding=`${t.legend.padding}px`,this.container.appendChild(this.header),this.container.appendChild(this.content),e.appendChild(this.container),this.initDragging()}updateStyle(){const e=this.theme.name.toLowerCase().includes("dark")||this.theme.name.toLowerCase().includes("midnight")||this.theme.name.toLowerCase().includes("electro"),t=e?"rgba(15, 23, 42, 0.85)":"rgba(255, 255, 255, 0.95)",n=e?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.1)",i=e?"0 4px 12px rgba(0, 0, 0, 0.6)":"0 4px 12px rgba(0, 0, 0, 0.15)";this.container.style.background=t,this.container.style.backdropFilter="blur(12px) saturate(180%)",this.container.style.webkitBackdropFilter="blur(12px) saturate(180%)",this.container.style.border=`1px solid ${n}`,this.container.style.boxShadow=i}initDragging(){let e=null;const t=s=>{s.button===0&&(s.stopPropagation(),s.preventDefault(),this.isDragging=!0,this.startX=s.clientX,this.startY=s.clientY,this.initialX=this.container.offsetLeft,this.initialY=this.container.offsetTop,this.container.style.transition="none",this.container.style.willChange="transform",this.container.style.boxShadow="0 8px 24px rgba(0,0,0,0.3)",this.container.style.cursor="grabbing",document.addEventListener("mousemove",i),document.addEventListener("mouseup",o))},n=(s,r)=>{const a=s-this.startX,l=r-this.startY;let h=this.initialX+a,f=this.initialY+l;const y=this.container.parentElement;y&&(h=Math.max(0,Math.min(h,y.clientWidth-this.container.clientWidth)),f=Math.max(0,Math.min(f,y.clientHeight-this.container.clientHeight)));const m=h-this.initialX,g=f-this.initialY;this.container.style.transform=`translate3d(${m}px, ${g}px, 0)`},i=s=>{this.isDragging&&(e&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>n(s.clientX,s.clientY)))},o=()=>{var s;if(this.isDragging){this.isDragging=!1,e&&cancelAnimationFrame(e);const r=this.container.getBoundingClientRect(),a=(s=this.container.parentElement)==null?void 0:s.getBoundingClientRect();if(a){const l=r.left-a.left,h=r.top-a.top;this.container.style.transform="none",this.container.style.left=`${l}px`,this.container.style.top=`${h}px`,this.callbacks.onMove(l,h)}this.container.style.willChange="auto",this.container.style.transition="box-shadow 0.2s ease",this.container.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)",this.container.style.cursor="auto"}document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",o)};this.container.addEventListener("mousedown",t),this.container.addEventListener("wheel",s=>s.stopPropagation()),this.container.addEventListener("click",s=>s.stopPropagation()),this.container.addEventListener("dblclick",s=>s.stopPropagation())}update(e){this.series=e,this.render()}render(){this.content.innerHTML="";const e=this.theme.legend;this.series.forEach(t=>{const n=document.createElement("div");n.style.cssText=`
165
+ `,this.content=document.createElement("div"),this.content.style.padding=`${t.legend.padding}px`,this.container.appendChild(this.header),this.container.appendChild(this.content),e.appendChild(this.container),this.initDragging()}updateStyle(){const e=this.theme.name.toLowerCase().includes("dark")||this.theme.name.toLowerCase().includes("midnight")||this.theme.name.toLowerCase().includes("electro"),t=e?"rgba(15, 23, 42, 0.85)":"rgba(255, 255, 255, 0.95)",i=e?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.1)",s=e?"0 4px 12px rgba(0, 0, 0, 0.6)":"0 4px 12px rgba(0, 0, 0, 0.15)";this.container.style.background=t,this.container.style.backdropFilter="blur(12px) saturate(180%)",this.container.style.webkitBackdropFilter="blur(12px) saturate(180%)",this.container.style.border=`1px solid ${i}`,this.container.style.boxShadow=s}initDragging(){let e=null;const t=o=>{o.button===0&&(o.stopPropagation(),o.preventDefault(),this.isDragging=!0,this.startX=o.clientX,this.startY=o.clientY,this.initialX=this.container.offsetLeft,this.initialY=this.container.offsetTop,this.container.style.transition="none",this.container.style.willChange="transform",this.container.style.boxShadow="0 8px 24px rgba(0,0,0,0.3)",this.container.style.cursor="grabbing",document.addEventListener("mousemove",s),document.addEventListener("mouseup",n))},i=(o,r)=>{const l=o-this.startX,h=r-this.startY;let c=this.initialX+l,d=this.initialY+h;const u=this.container.parentElement;u&&(c=Math.max(0,Math.min(c,u.clientWidth-this.container.clientWidth)),d=Math.max(0,Math.min(d,u.clientHeight-this.container.clientHeight)));const g=c-this.initialX,f=d-this.initialY;this.container.style.transform=`translate3d(${g}px, ${f}px, 0)`},s=o=>{this.isDragging&&(e&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>i(o.clientX,o.clientY)))},n=()=>{var o;if(this.isDragging){this.isDragging=!1,e&&cancelAnimationFrame(e);const r=this.container.getBoundingClientRect(),l=(o=this.container.parentElement)==null?void 0:o.getBoundingClientRect();if(l){const h=r.left-l.left,c=r.top-l.top;this.container.style.transform="none",this.container.style.left=`${h}px`,this.container.style.top=`${c}px`,this.callbacks.onMove(h,c)}this.container.style.willChange="auto",this.container.style.transition="box-shadow 0.2s ease",this.container.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)",this.container.style.cursor="auto"}document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",n)};this.container.addEventListener("mousedown",t),this.container.addEventListener("wheel",o=>o.stopPropagation()),this.container.addEventListener("click",o=>o.stopPropagation()),this.container.addEventListener("dblclick",o=>o.stopPropagation())}update(e){this.series=e,this.render()}render(){this.content.innerHTML="";const e=this.theme.legend,t=window.devicePixelRatio||1;this.series.forEach(i=>{const s=document.createElement("div");s.style.cssText=`
95
166
  display: flex;
96
167
  align-items: center;
97
168
  gap: 8px;
@@ -99,13 +170,53 @@ void main() {
99
170
  font-family: ${e.fontFamily};
100
171
  font-size: ${e.fontSize}px;
101
172
  color: ${e.textColor};
102
- `;const i=document.createElement("div");i.style.cssText=`
103
- width: ${e.swatchSize}px;
104
- height: ${e.swatchSize}px;
105
- background: ${t.getStyle().color||"#ff0055"};
106
- border-radius: 2px;
107
- `;const o=document.createElement("span");o.textContent=t.getId(),n.appendChild(i),n.appendChild(o),this.content.appendChild(n)})}draw(e,t){if(this.series.length===0)return;const n=this.theme.legend,i=n.padding*t,o=n.itemGap*t,s=n.swatchSize*t,r=8*t,a=this.container.offsetLeft*t,l=this.container.offsetTop*t,h=this.container.clientWidth*t,f=this.container.clientHeight*t;e.save();const y=this.theme.name.toLowerCase().includes("dark")||this.theme.name.toLowerCase().includes("midnight");e.fillStyle=y?n.backgroundColor:"rgba(255, 255, 255, 0.85)",e.strokeStyle=n.borderColor,e.lineWidth=1*t;const m=n.borderRadius*t;e.beginPath(),e.moveTo(a+m,l),e.lineTo(a+h-m,l),e.arcTo(a+h,l,a+h,l+m,m),e.lineTo(a+h,l+f-m),e.arcTo(a+h,l+f,a+h-m,l+f,m),e.lineTo(a+m,l+f),e.arcTo(a,l+f,a,l+f-m,m),e.lineTo(a,l+m),e.arcTo(a,l,a+m,l,m),e.closePath(),e.fill(),e.stroke(),e.textAlign="left",e.textBaseline="middle",e.font=`${n.fontSize*t}px ${n.fontFamily}`,this.series.forEach((g,x)=>{const p=l+r+i+x*(s+o)+s/2;e.fillStyle=g.getStyle().color||"#ff0055",e.fillRect(a+i,p-s/2,s,s),e.fillStyle=n.textColor,e.fillText(g.getId(),a+i+s+8*t,p)}),e.restore()}updateTheme(e){this.theme=e,this.updateStyle(),this.render()}destroy(){this.container.remove()}}const P={top:20,right:30,bottom:55,left:75};class ze{constructor(e){u(this,"container");u(this,"webglCanvas");u(this,"overlayCanvas");u(this,"overlayCtx");u(this,"series",new Map);u(this,"events",new I);u(this,"viewBounds",{xMin:-.5,xMax:.5,yMin:-1e-5,yMax:1e-5});u(this,"xAxisOptions");u(this,"yAxisOptions");u(this,"dpr");u(this,"backgroundColor");u(this,"renderer");u(this,"overlay");u(this,"interaction");u(this,"xScale");u(this,"yScale");u(this,"theme");u(this,"cursorOptions",null);u(this,"cursorPosition",null);u(this,"showLegend");u(this,"legend",null);u(this,"showControls");u(this,"controls",null);u(this,"animationFrameId",null);u(this,"needsRender",!1);u(this,"isDestroyed",!1);u(this,"selectionRect",null);const t=e.container;if(!t)throw new Error("[SciChart] Container element is required");this.container=t,this.dpr=e.devicePixelRatio??window.devicePixelRatio,this.theme=typeof e.theme=="string"?Q(e.theme):e.theme??ee;const n=V(e.background??this.theme.backgroundColor);for(this.backgroundColor=[n[0],n[1],n[2],n[3]],this.showLegend=e.showLegend??this.theme.legend.visible,this.showControls=e.showControls??!1,this.xAxisOptions={scale:"linear",auto:!0,...e.xAxis},this.yAxisOptions={scale:"linear",auto:!0,...e.yAxis},this.xScale=this.xAxisOptions.scale==="log"?new $:new H,this.yScale=this.yAxisOptions.scale==="log"?new $:new H,this.container.style.position="relative",this.container.style.overflow="hidden",this.container.style.backgroundColor=e.background??this.theme.backgroundColor,this.webglCanvas=this.createCanvas("webgl"),this.overlayCanvas=this.createCanvas("overlay");this.container.firstChild;)this.container.removeChild(this.container.firstChild);this.container.appendChild(this.webglCanvas),this.container.appendChild(this.overlayCanvas);const i=this.overlayCanvas.getContext("2d");if(!i)throw new Error("Failed to get 2D context");this.overlayCtx=i,this.renderer=new W(this.webglCanvas),this.overlay=new fe(this.overlayCtx,this.theme),this.interaction=new De(this.container,{onZoom:o=>this.zoom({x:[o.xMin,o.xMax],y:[o.yMin,o.yMax]}),onPan:(o,s)=>this.pan(o,s),onBoxZoom:o=>this.handleBoxZoom(o),onCursorMove:(o,s)=>{this.cursorPosition={x:o,y:s},this.requestRender()},onCursorLeave:()=>{this.cursorPosition=null,this.requestRender()}},()=>this.getPlotArea(),()=>this.viewBounds),new ResizeObserver(()=>!this.isDestroyed&&this.resize()).observe(this.container),this.showControls&&(this.controls=new Fe(this.container,this.theme,{onResetZoom:()=>this.resetZoom(),onSetType:o=>{this.series.forEach(s=>s.setType(o)),this.requestRender()},onToggleSmoothing:()=>{this.series.forEach(o=>{const s=o.getStyle();o.setStyle({smoothing:(s.smoothing||0)===0?.5:0})}),this.requestRender()},onTogglePan:o=>{this.interaction.setPanMode(o)},onExport:()=>{const o=this.exportImage(),s=document.createElement("a");s.download=`scichart-export-${Date.now()}.png`,s.href=o,s.click()},onAutoScale:()=>{this.autoScale(),this.requestRender(),this.events.emit("autoScale",void 0)}})),this.showLegend&&(this.legend=new Ie(this.container,this.theme,e.legendPosition||{},{onMove:(o,s)=>this.events.emit("legendMove",{x:o,y:s})}),this.legend.update(this.getAllSeries())),this.resize(),this.startRenderLoop(),setTimeout(()=>!this.isDestroyed&&this.resize(),100),console.log("[SciChart] Initialized",{dpr:this.dpr,theme:this.theme.name})}setTheme(e){if(this.isDestroyed)return;this.theme=typeof e=="string"?Q(e):e??ee;const t=V(this.theme.backgroundColor);this.backgroundColor=[t[0],t[1],t[2],t[3]],this.container.style.backgroundColor=this.theme.backgroundColor,this.overlay.setTheme(this.theme),this.controls&&this.controls.updateTheme(this.theme),this.legend&&this.legend.updateTheme(this.theme),this.resize(),this.requestRender(),setTimeout(()=>{this.isDestroyed||(this.resize(),this.render())},50)}createCanvas(e){const t=document.createElement("canvas");return t.style.cssText=e==="webgl"?`position:absolute;top:${P.top}px;left:${P.left}px;width:calc(100% - ${P.left+P.right}px);height:calc(100% - ${P.top+P.bottom}px)`:"position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none",t}getPlotArea(){const e=this.container.getBoundingClientRect(),t=Math.max(10,e.width-P.left-P.right),n=Math.max(10,e.height-P.top-P.bottom);return{x:P.left,y:P.top,width:t,height:n}}exportImage(e="png"){const t=document.createElement("canvas");t.width=this.overlayCanvas.width,t.height=this.overlayCanvas.height;const n=t.getContext("2d");if(!n)return"";const i=this.backgroundColor;n.fillStyle=`rgba(${Math.round(i[0]*255)}, ${Math.round(i[1]*255)}, ${Math.round(i[2]*255)}, ${i[3]})`,n.fillRect(0,0,t.width,t.height);const o=P.left*this.dpr,s=P.top*this.dpr;return n.drawImage(this.webglCanvas,o,s),n.drawImage(this.overlayCanvas,0,0),this.legend&&this.showLegend&&this.legend.draw(n,this.dpr),t.toDataURL(`image/${e}`)}addSeries(e){this.series.has(e.id)&&this.removeSeries(e.id);const t=new le(e);this.series.set(e.id,t),this.updateSeriesBuffer(t),(this.xAxisOptions.auto||this.yAxisOptions.auto)&&this.autoScale(),this.legend&&this.legend.update(this.getAllSeries()),this.requestRender()}removeSeries(e){const t=this.series.get(e);t&&(this.renderer.deleteBuffer(e),t.destroy(),this.series.delete(e),this.legend&&this.legend.update(this.getAllSeries()),this.requestRender())}updateSeries(e,t){const n=this.series.get(e);n&&(n.updateData(t),this.updateSeriesBuffer(n),(this.xAxisOptions.auto||this.yAxisOptions.auto)&&this.autoScale(),this.requestRender())}updateSeriesBuffer(e){const t=e.getData();!t||t.x.length===0||this.renderer.createBuffer(e.getId(),ce(t.x,t.y))}getSeries(e){return this.series.get(e)}getAllSeries(){return Array.from(this.series.values())}zoom(e){e.x&&(this.viewBounds.xMin=e.x[0],this.viewBounds.xMax=e.x[1]),e.y&&(this.viewBounds.yMin=e.y[0],this.viewBounds.yMax=e.y[1]),this.events.emit("zoom",{x:[this.viewBounds.xMin,this.viewBounds.xMax],y:[this.viewBounds.yMin,this.viewBounds.yMax]}),this.requestRender()}pan(e,t){const n=this.getPlotArea(),i=e/n.width*(this.viewBounds.xMax-this.viewBounds.xMin),o=t/n.height*(this.viewBounds.yMax-this.viewBounds.yMin);this.viewBounds.xMin-=i,this.viewBounds.xMax-=i,this.viewBounds.yMin+=o,this.viewBounds.yMax+=o,this.events.emit("pan",{deltaX:i,deltaY:o}),this.requestRender()}resetZoom(){this.autoScale(),this.events.emit("zoom",{x:[this.viewBounds.xMin,this.viewBounds.xMax],y:[this.viewBounds.yMin,this.viewBounds.yMax]}),this.requestRender()}getViewBounds(){return{...this.viewBounds}}autoScale(){if(this.series.size===0)return;let e=1/0,t=-1/0,n=1/0,i=-1/0,o=!1;if(this.series.forEach(m=>{const g=m.getBounds();g&&isFinite(g.xMin)&&isFinite(g.xMax)&&isFinite(g.yMin)&&isFinite(g.yMax)&&(e=Math.min(e,g.xMin),t=Math.max(t,g.xMax),n=Math.min(n,g.yMin),i=Math.max(i,g.yMax),o=!0)}),!o){console.warn("[SciChart] No valid data bounds found for autoScale");return}let s=t-e,r=i-n;(s<=0||!isFinite(s))&&(s=Math.abs(e)*.1||1),(r<=0||!isFinite(r))&&(r=Math.abs(n)*.1||1);const a=1e15,l=-1e15;e=Math.max(l,Math.min(a,e)),t=Math.max(l,Math.min(a,t)),n=Math.max(l,Math.min(a,n)),i=Math.max(l,Math.min(a,i));const h=Math.min(s*.05,1e10),f=Math.min(r*.05,1e10),y={xMin:Math.max(l,e-h),xMax:Math.min(a,t+h),yMin:Math.max(l,n-f),yMax:Math.min(a,i+f)};this.xAxisOptions.auto&&(this.viewBounds.xMin=y.xMin,this.viewBounds.xMax=y.xMax),this.yAxisOptions.auto&&(this.viewBounds.yMin=y.yMin,this.viewBounds.yMax=y.yMax),this.requestRender()}enableCursor(e){this.cursorOptions={enabled:!0,...e}}disableCursor(){this.cursorOptions=null,this.cursorPosition=null}resize(){const e=this.container.getBoundingClientRect();e.width===0||e.height===0||(this.overlayCanvas.width=e.width*this.dpr,this.overlayCanvas.height=e.height*this.dpr,this.overlayCtx.setTransform(1,0,0,1,0,0),this.overlayCtx.scale(this.dpr,this.dpr),this.renderer.resize(),this.events.emit("resize",{width:e.width,height:e.height}),this.requestRender())}requestRender(){this.needsRender=!0}render(){var s;if(this.isDestroyed)return;const e=performance.now();this.xScale.setDomain(this.viewBounds.xMin,this.viewBounds.xMax),this.yScale.setDomain(this.viewBounds.yMin,this.viewBounds.yMax);const t=[],n=this.getPlotArea();if(this.webglCanvas.width===0||this.webglCanvas.height===0){console.warn("[SciChart] Canvas has zero size, skipping render");return}this.xScale.setRange(n.x,n.x+n.width),this.yScale.setRange(n.y+n.height,n.y),this.series.forEach(r=>{r.needsBufferUpdate&&(this.updateSeriesBuffer(r),r.needsBufferUpdate=!1);const a=this.renderer.getBuffer(r.getId());a&&t.push({id:r.getId(),buffer:a,count:r.getPointCount(),style:r.getStyle(),visible:r.isVisible(),type:r.getType()})}),t.length===0&&this.series.size>0&&console.warn("[SciChart] No series data to render despite having series",{count:this.series.size,rendererAvailable:this.renderer.available}),this.renderer.render(t,{bounds:this.viewBounds,backgroundColor:this.backgroundColor});const i=this.container.getBoundingClientRect();if(i.width===0||i.height===0){console.warn("[SciChart] Container has zero size in render, skipping overlay");return}if(this.overlay.clear(i.width,i.height),this.overlay.drawGrid(n,this.xScale,this.yScale),this.overlay.drawXAxis(n,this.xScale,this.xAxisOptions.label),this.overlay.drawYAxis(n,this.yScale,this.yAxisOptions.label),this.overlay.drawPlotBorder(n),this.selectionRect&&this.overlay.drawSelectionRect(this.selectionRect),(s=this.cursorOptions)!=null&&s.enabled&&this.cursorPosition){const r={enabled:!0,x:this.cursorPosition.x,y:this.cursorPosition.y,crosshair:this.cursorOptions.crosshair??!1,tooltipText:this.cursorOptions.formatter?this.cursorOptions.formatter(this.pixelToDataX(this.cursorPosition.x),this.pixelToDataY(this.cursorPosition.y),""):`X: ${this.pixelToDataX(this.cursorPosition.x).toFixed(3)}
108
- Y: ${this.pixelToDataY(this.cursorPosition.y).toExponential(2)}`};this.overlay.drawCursor(n,r)}const o=performance.now()-e;this.events.emit("render",{fps:o>0?1e3/o:999,frameTime:o})}pixelToDataX(e){const t=this.getPlotArea();return this.viewBounds.xMin+(e-t.x)/t.width*(this.viewBounds.xMax-this.viewBounds.xMin)}pixelToDataY(e){const t=this.getPlotArea();return this.viewBounds.yMin+(1-(e-t.y)/t.height)*(this.viewBounds.yMax-this.viewBounds.yMin)}startRenderLoop(){const e=()=>{this.isDestroyed||(this.needsRender&&(this.render(),this.needsRender=!1),this.animationFrameId=requestAnimationFrame(e))};this.animationFrameId=requestAnimationFrame(e)}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}destroy(){for(this.isDestroyed=!0,this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),this.interaction.destroy(),this.series.forEach(e=>{this.renderer.deleteBuffer(e.getId()),e.destroy()}),this.series.clear(),this.renderer.destroy(),this.controls&&this.controls.destroy(),this.legend&&this.legend.destroy();this.container.firstChild;)this.container.removeChild(this.container.firstChild);console.log("[SciChart] Destroyed")}handleBoxZoom(e){if(e===null){if(this.selectionRect&&this.selectionRect.width>5&&this.selectionRect.height>5){const t=this.getPlotArea(),n=this.viewBounds,i=(this.selectionRect.x-t.x)/t.width,o=(this.selectionRect.x+this.selectionRect.width-t.x)/t.width,s=1-(this.selectionRect.y-t.y)/t.height,r=1-(this.selectionRect.y+this.selectionRect.height-t.y)/t.height,a=n.xMin+i*(n.xMax-n.xMin),l=n.xMin+o*(n.xMax-n.xMin),h=n.yMin+r*(n.yMax-n.yMin),f=n.yMin+s*(n.yMax-n.yMin);this.zoom({x:[a,l],y:[h,f]})}this.selectionRect=null}else this.selectionRect=e;this.requestRender()}}function ge(c){return new ze(c)}function Oe(c){return new W(c)}function Ye(c,e,t){const n=c.length;if(t>=n||t<=2)return{x:new Float32Array(c),y:new Float32Array(e),indices:new Uint32Array(Array.from({length:n},(h,f)=>f))};const i=new Float32Array(t),o=new Float32Array(t),s=new Uint32Array(t);i[0]=c[0],o[0]=e[0],s[0]=0;const r=(n-2)/(t-2);let a=0,l=1;for(let h=0;h<t-2;h++){const f=Math.floor((h+1)*r)+1,y=Math.floor((h+2)*r)+1,m=Math.min(y,n-1),g=Math.min(Math.floor((h+3)*r)+1,n);let x=0,p=0,M=0;for(let S=m;S<g;S++)x+=c[S],p+=e[S],M++;M>0&&(x/=M,p/=M);let C=-1,R=f;const A=c[a],_=e[a];for(let S=f;S<y&&S<n;S++){const z=Math.abs((A-x)*(e[S]-_)-(A-c[S])*(p-_));z>C&&(C=z,R=S)}i[l]=c[R],o[l]=e[R],s[l]=R,a=R,l++}return i[t-1]=c[n-1],o[t-1]=e[n-1],s[t-1]=n-1,{x:i,y:o,indices:s}}function Ne(c,e,t){const n=c.length;if(t>=n/2)return{x:new Float32Array(c),y:new Float32Array(e),indices:new Uint32Array(Array.from({length:n},(a,l)=>l))};const i=n/t,o=[],s=[],r=[];for(let a=0;a<t;a++){const l=Math.floor(a*i),h=Math.floor((a+1)*i);let f=1/0,y=-1/0,m=l,g=l;for(let x=l;x<h&&x<n;x++)e[x]<f&&(f=e[x],m=x),e[x]>y&&(y=e[x],g=x);m<=g?(o.push(c[m],c[g]),s.push(e[m],e[g]),r.push(m,g)):(o.push(c[g],c[m]),s.push(e[g],e[m]),r.push(g,m))}return{x:new Float32Array(o),y:new Float32Array(s),indices:new Uint32Array(r)}}function Ue(c,e,t=2){const n=e*t;return Math.min(c,n)}const me=[{symbol:"p",factor:1e-12},{symbol:"n",factor:1e-9},{symbol:"µ",factor:1e-6},{symbol:"m",factor:.001},{symbol:"",factor:1},{symbol:"k",factor:1e3},{symbol:"M",factor:1e6},{symbol:"G",factor:1e9}];function ye(c){const e=Math.abs(c);if(e===0)return{symbol:"",factor:1};for(let t=me.length-1;t>=0;t--){const n=me[t],i=e/n.factor;if(i>=1&&i<1e3)return n}return{symbol:"",factor:1}}function te(c,e,t=2){const n=ye(c);return`${(c/n.factor).toFixed(t)} ${n.symbol}${e}`}function Xe(c,e=3){return Math.abs(c)<.001||Math.abs(c)>=1e6?c.toExponential(e):c.toFixed(e)}function je(c,e=2){return c.toExponential(e)}function We(c,e=.001){const t=c instanceof Array?new Float32Array(c):c;if(t.length<3)return[];const n=[];let i=0,o=1,s=Math.sign(t[1]-t[0]),r=0;for(let a=2;a<t.length;a++){const l=Math.sign(t[a]-t[a-1]);if(l!==0&&l!==s){if(r++,r>=2){const h=t[i],f=t[a];Math.abs(f-h)<e&&(n.push({number:o,startIndex:i,endIndex:a,direction:t[i+1]>t[i]?1:-1}),o++,i=a,r=0)}s=l}}return i<t.length-1&&n.push({number:o,startIndex:i,endIndex:t.length-1,direction:t[i+1]>t[i]?1:-1}),n}function Ve(c){const e=[],t=360/Math.max(c,1);for(let n=0;n<c;n++){const i=n*t%360;e.push(`hsl(${i}, 70%, 55%)`)}return e}function He(c,e,t={}){const{minProminence:n=0,type:i="both"}=t,o=[],s=c instanceof Array?new Float32Array(c):c,r=e instanceof Array?new Float32Array(e):e;for(let a=1;a<r.length-1;a++){const l=r[a-1],h=r[a],f=r[a+1];if(h>l&&h>f){const y=Math.min(h-l,h-f);y>=n&&(i==="both"||i==="max")&&o.push({index:a,x:s[a],y:h,type:"max",prominence:y})}if(h<l&&h<f){const y=Math.min(l-h,f-h);y>=n&&(i==="both"||i==="min")&&o.push({index:a,x:s[a],y:h,type:"min",prominence:y})}}return o}function $e(c){let e=0,t=-1;const n=c instanceof Array?c:Array.from(c);for(let i=0;i<n.length;i++)isFinite(n[i])||(e++,t===-1&&(t=i));return{valid:e===0,invalidCount:e,firstInvalidIndex:t}}function Ge(c){const e=c instanceof Array?c:Array.from(c),t=e.length;if(t===0)return{min:0,max:0,mean:0,stdDev:0,count:0};let n=e[0],i=e[0],o=0;for(let l=0;l<t;l++){const h=e[l];h<n&&(n=h),h>i&&(i=h),o+=h}const s=o/t;let r=0;for(let l=0;l<t;l++){const h=e[l]-s;r+=h*h}const a=Math.sqrt(r/t);return{min:n,max:i,mean:s,stdDev:a,count:t}}function Ze(c,e){const t=c instanceof Array?new Float32Array(c):c,n=new Float32Array(t.length),i=Math.floor(e/2);for(let o=0;o<t.length;o++){let s=0,r=0;for(let a=Math.max(0,o-i);a<=Math.min(t.length-1,o+i);a++)s+=t[a],r++;n[o]=s/r}return n}function qe(c,e,t){const n=c.length;if(t>=n||t<3)return{x:new Float32Array(c),y:new Float32Array(e)};const i=new Float32Array(t),o=new Float32Array(t);i[0]=c[0],o[0]=e[0];const s=(n-2)/(t-2);let r=0,a=1;for(let l=0;l<t-2;l++){const h=Math.floor((l+1)*s)+1,f=Math.floor((l+2)*s)+1,y=Math.min(Math.floor((l+3)*s)+1,n);let m=0,g=0,x=0;for(let C=f;C<y;C++)m+=c[C],g+=e[C],x++;x>0&&(m/=x,g/=x);let p=-1,M=h;for(let C=h;C<f&&C<n;C++){const R=Math.abs((c[r]-m)*(e[C]-e[r])-(c[r]-c[C])*(g-e[r]));R>p&&(p=R,M=C)}i[a]=c[M],o[a]=e[M],a++,r=M}return i[t-1]=c[n-1],o[t-1]=e[n-1],{x:i,y:o}}var ie={exports:{}},N={};/**
173
+ `;const n=document.createElement("canvas"),o=e.swatchSize;n.width=o*t,n.height=o*t,n.style.width=`${o}px`,n.style.height=`${o}px`;const r=n.getContext("2d");if(r){r.scale(t,t);const h=i.getStyle(),c=h.color||"#ff0055",d=i.getType(),u=h.symbol||"circle";r.fillStyle=c,r.strokeStyle=c,r.lineWidth=2;const g=o/2,f=o/2,p=String(d).toLowerCase(),b=p==="scatter"||p==="1"||p==="line"&&!!h.symbol,x=p.includes("scatter")||p==="2";b?this.drawSymbol(r,u,g,f,o*.8):x?(r.beginPath(),r.moveTo(0,f),r.lineTo(o,f),r.stroke(),this.drawSymbol(r,u,g,f,o*.6)):(r.beginPath(),r.moveTo(0,f),r.lineTo(o,f),r.stroke())}const l=document.createElement("span");l.textContent=i.getId(),s.appendChild(n),s.appendChild(l),this.content.appendChild(s)})}drawSymbol(e,t,i,s,n){const o=n/2;switch(e.beginPath(),t){case"circle":e.arc(i,s,o,0,Math.PI*2),e.fill();break;case"square":e.rect(i-o,s-o,n,n),e.fill();break;case"diamond":e.moveTo(i,s-o),e.lineTo(i+o,s),e.lineTo(i,s+o),e.lineTo(i-o,s),e.closePath(),e.fill();break;case"triangle":e.moveTo(i,s-o),e.lineTo(i+o,s+o),e.lineTo(i-o,s+o),e.closePath(),e.fill();break;case"triangleDown":e.moveTo(i,s+o),e.lineTo(i+o,s-o),e.lineTo(i-o,s-o),e.closePath(),e.fill();break;case"cross":e.moveTo(i-o,s),e.lineTo(i+o,s),e.moveTo(i,s-o),e.lineTo(i,s+o),e.stroke();break;case"x":const r=o*.707;e.moveTo(i-r,s-r),e.lineTo(i+r,s+r),e.moveTo(i+r,s-r),e.lineTo(i-r,s+r),e.stroke();break;case"star":for(let l=0;l<5;l++)e.lineTo(i+o*Math.cos((18+l*72)/180*Math.PI),s-o*Math.sin((18+l*72)/180*Math.PI)),e.lineTo(i+o/2*Math.cos((54+l*72)/180*Math.PI),s-o/2*Math.sin((54+l*72)/180*Math.PI));e.closePath(),e.fill();break}}draw(e,t){if(this.series.length===0)return;const i=this.theme.legend,s=i.padding*t,n=i.itemGap*t,o=i.swatchSize*t,r=8*t,l=this.container.offsetLeft*t,h=this.container.offsetTop*t,c=this.container.clientWidth*t,d=this.container.clientHeight*t;e.save();const u=this.theme.name.toLowerCase().includes("dark")||this.theme.name.toLowerCase().includes("midnight");e.fillStyle=u?i.backgroundColor:"rgba(255, 255, 255, 0.85)",e.strokeStyle=i.borderColor,e.lineWidth=1*t;const g=i.borderRadius*t;e.beginPath(),e.moveTo(l+g,h),e.lineTo(l+c-g,h),e.arcTo(l+c,h,l+c,h+g,g),e.lineTo(l+c,h+d-g),e.arcTo(l+c,h+d,l+c-g,h+d,g),e.lineTo(l+g,h+d),e.arcTo(l,h+d,l,h+d-g,g),e.lineTo(l,h+g),e.arcTo(l,h,l+g,h,g),e.closePath(),e.fill(),e.stroke(),e.textAlign="left",e.textBaseline="middle",e.font=`${i.fontSize*t}px ${i.fontFamily}`,this.series.forEach((f,p)=>{const b=h+r+s+p*(o+n)+o/2,x=l+s+o/2,v=b,T=f.getStyle(),A=f.getType(),B=T.symbol||"circle";e.fillStyle=T.color||"#ff0055",e.strokeStyle=T.color||"#ff0055",e.lineWidth=2*t;const w=String(A).toLowerCase(),E=w==="scatter"||w==="1"||w==="line"&&!!T.symbol,k=w.includes("scatter")||w==="2";E?this.drawSymbol(e,B,x,v,o*.9):k?(e.beginPath(),e.moveTo(l+s,v),e.lineTo(l+s+o,v),e.stroke(),this.drawSymbol(e,B,x,v,o*.6)):(e.beginPath(),e.moveTo(l+s,v),e.lineTo(l+s+o,v),e.stroke()),e.fillStyle=i.textColor,e.fillText(f.getId(),l+s+o+8*t,b)}),e.restore()}updateTheme(e){this.theme=e,this.updateStyle(),this.render()}setVisible(e){this.container.style.display=e?"block":"none"}destroy(){this.container.remove()}}class lt{constructor(e,t,i){m(this,"container");m(this,"content");m(this,"theme");m(this,"series");m(this,"isExpanded",!1);this.theme=t,this.series=i,this.container=document.createElement("div"),this.container.className="scichart-stats-panel",this.updateContainerStyle();const s=document.createElement("div");s.innerHTML="📊 Statistics",s.style.cssText=`
174
+ font-weight: 600;
175
+ font-size: 11px;
176
+ text-transform: uppercase;
177
+ letter-spacing: 0.5px;
178
+ margin-bottom: 8px;
179
+ display: flex;
180
+ justify-content: space-between;
181
+ align-items: center;
182
+ cursor: pointer;
183
+ `,s.onclick=()=>this.toggle(),this.content=document.createElement("div"),this.content.style.display="none",this.container.appendChild(s),this.container.appendChild(this.content),e.appendChild(this.container)}isDarkTheme(){const e=this.theme.name.toLowerCase();return e.includes("dark")||e.includes("midnight")||e.includes("electro")}updateContainerStyle(){const e=this.isDarkTheme(),t=e?"rgba(15, 23, 42, 0.85)":"rgba(255, 255, 255, 0.95)",i=e?"#f1f5f9":"#1e293b",s=e?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.1)",n=e?"0 4px 12px rgba(0, 0, 0, 0.5)":"0 4px 12px rgba(0, 0, 0, 0.1)";this.container.style.cssText=`
184
+ position: absolute;
185
+ bottom: 8px;
186
+ right: 8px;
187
+ width: 240px;
188
+ background: ${t};
189
+ backdrop-filter: blur(8px);
190
+ -webkit-backdrop-filter: blur(8px);
191
+ border: 1px solid ${s};
192
+ border-radius: 8px;
193
+ box-shadow: ${n};
194
+ color: ${i};
195
+ font-family: system-ui, -apple-system, sans-serif;
196
+ padding: 8px 12px;
197
+ z-index: 90;
198
+ transition: all 0.3s ease;
199
+ font-size: 12px;
200
+ pointer-events: auto;
201
+ `}update(e){this.isExpanded&&(this.content.innerHTML="",this.series.forEach(t=>{if(!t.getVisible())return;const i=t.getData();if(!i)return;const s=[],n=[];for(let c=0;c<i.x.length;c++)i.x[c]>=e.xMin&&i.x[c]<=e.xMax&&(n.push(i.x[c]),s.push(i.y[c]));if(s.length===0)return;const o=re(s),r=Se(n,s),l=t.getStyle(),h=document.createElement("div");h.style.cssText=`
202
+ padding: 8px 0;
203
+ border-top: 1px solid ${this.isDarkTheme()?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"};
204
+ `,h.innerHTML=`
205
+ <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-weight: 600;">
206
+ <div style="width: 8px; height: 8px; border-radius: 2px; background: ${l.color}"></div>
207
+ ${t.getId()}
208
+ </div>
209
+ <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 4px; opacity: 0.9; font-size: 11px;">
210
+ <span>Min: ${o.min.toExponential(3)}</span>
211
+ <span>Max: ${o.max.toExponential(3)}</span>
212
+ <span>Mean: ${o.mean.toExponential(3)}</span>
213
+ <span>Count: ${o.count}</span>
214
+ <span style="grid-column: span 2;">Area: ${r.toExponential(4)}</span>
215
+ </div>
216
+ `,this.content.appendChild(h)}),this.content.innerHTML===""&&(this.content.innerHTML="<div style='opacity: 0.5; font-style: italic;'>No series visible in range</div>"))}toggle(){this.isExpanded=!this.isExpanded,this.content.style.display=this.isExpanded?"block":"none",this.isExpanded}updateTheme(e){this.theme=e,this.updateContainerStyle()}destroy(){this.container.remove()}}const P={line:{color:"rgba(255, 255, 255, 0.7)",lineWidth:1,lineDash:[]},rectangle:{fillColor:"rgba(100, 100, 255, 0.2)",strokeWidth:1},text:{fontSize:12,fontFamily:"Inter, system-ui, sans-serif",color:"#ffffff",padding:4},arrow:{color:"rgba(255, 255, 255, 0.7)",lineWidth:2,headSize:10}};class Re{constructor(){m(this,"annotations",new Map);m(this,"idCounter",0)}add(e){const t=e.id??`annotation-${++this.idCounter}`,i={...e,id:t,visible:e.visible??!0,interactive:e.interactive??!1,zIndex:e.zIndex??0};return this.annotations.set(t,i),t}remove(e){return this.annotations.delete(e)}update(e,t){const i=this.annotations.get(e);i&&this.annotations.set(e,{...i,...t})}get(e){return this.annotations.get(e)}getAll(){return Array.from(this.annotations.values())}clear(){this.annotations.clear()}get count(){return this.annotations.size}render(e,t,i){const s=this.getAll().filter(n=>n.visible!==!1).sort((n,o)=>(n.zIndex??0)-(o.zIndex??0));e.save(),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.clip();for(const n of s)this.renderAnnotation(e,n,t,i);e.restore()}renderAnnotation(e,t,i,s){switch(t.type){case"horizontal-line":this.renderHorizontalLine(e,t,i,s);break;case"vertical-line":this.renderVerticalLine(e,t,i,s);break;case"rectangle":this.renderRectangle(e,t,i,s);break;case"band":this.renderBand(e,t,i,s);break;case"text":this.renderText(e,t,i,s);break;case"arrow":this.renderArrow(e,t,i,s);break}}dataToPixelX(e,t,i){const s=(e-t.xMin)/(t.xMax-t.xMin);return i.x+s*i.width}dataToPixelY(e,t,i){const s=(e-t.yMin)/(t.yMax-t.yMin);return i.y+i.height*(1-s)}renderHorizontalLine(e,t,i,s){const n=this.dataToPixelY(t.y,s,i);if(n<i.y||n>i.y+i.height)return;const o=t.xMin!==void 0?Math.max(this.dataToPixelX(t.xMin,s,i),i.x):i.x,r=t.xMax!==void 0?Math.min(this.dataToPixelX(t.xMax,s,i),i.x+i.width):i.x+i.width;e.save(),e.strokeStyle=t.color??P.line.color,e.lineWidth=t.lineWidth??P.line.lineWidth,e.setLineDash(t.lineDash??P.line.lineDash),e.beginPath(),e.moveTo(o,n),e.lineTo(r,n),e.stroke(),t.label&&this.renderLineLabel(e,t.label,o,r,n,t.labelPosition??"right","horizontal",t.labelBackground),e.restore()}renderVerticalLine(e,t,i,s){const n=this.dataToPixelX(t.x,s,i);if(n<i.x||n>i.x+i.width)return;const o=t.yMin!==void 0?Math.min(this.dataToPixelY(t.yMin,s,i),i.y+i.height):i.y,r=t.yMax!==void 0?Math.max(this.dataToPixelY(t.yMax,s,i),i.y):i.y+i.height;e.save(),e.strokeStyle=t.color??P.line.color,e.lineWidth=t.lineWidth??P.line.lineWidth,e.setLineDash(t.lineDash??P.line.lineDash),e.beginPath(),e.moveTo(n,o),e.lineTo(n,r),e.stroke(),t.label&&this.renderLineLabel(e,t.label,o,r,n,t.labelPosition??"top","vertical",t.labelBackground),e.restore()}renderRectangle(e,t,i,s){const n=this.dataToPixelX(t.xMin,s,i),o=this.dataToPixelX(t.xMax,s,i),r=this.dataToPixelY(t.yMax,s,i),l=this.dataToPixelY(t.yMin,s,i),h=Math.min(n,o),c=Math.min(r,l),d=Math.abs(o-n),u=Math.abs(l-r);e.save(),t.fillColor&&(e.fillStyle=t.fillColor,e.fillRect(h,c,d,u)),t.strokeColor&&(e.strokeStyle=t.strokeColor,e.lineWidth=t.strokeWidth??P.rectangle.strokeWidth,e.setLineDash(t.strokeDash??[]),e.strokeRect(h,c,d,u)),t.label&&this.renderCenteredLabel(e,t.label,h+d/2,c+u/2),e.restore()}renderBand(e,t,i,s){let n,o,r,l;if(t.xMin!==void 0&&t.xMax!==void 0){const h=this.dataToPixelX(t.xMin,s,i),c=this.dataToPixelX(t.xMax,s,i);n=Math.min(h,c),r=Math.abs(c-h),o=i.y,l=i.height,t.yMin!==void 0&&(l=this.dataToPixelY(t.yMin,s,i)-o),t.yMax!==void 0&&(o=this.dataToPixelY(t.yMax,s,i),l=i.y+i.height-o)}else if(t.yMin!==void 0&&t.yMax!==void 0){const h=this.dataToPixelY(t.yMax,s,i),c=this.dataToPixelY(t.yMin,s,i);o=Math.min(h,c),l=Math.abs(c-h),n=i.x,r=i.width}else return;if(e.save(),e.fillStyle=t.fillColor??P.rectangle.fillColor,e.fillRect(n,o,r,l),t.strokeColor&&(e.strokeStyle=t.strokeColor,e.lineWidth=t.strokeWidth??1,e.strokeRect(n,o,r,l)),t.label){let h=n+r/2,c=o+l/2;switch(t.labelPosition){case"top":c=o+15;break;case"bottom":c=o+l-5;break;case"left":h=n+10;break;case"right":h=n+r-10;break}this.renderCenteredLabel(e,t.label,h,c)}e.restore()}renderText(e,t,i,s){const n=this.dataToPixelX(t.x,s,i),o=this.dataToPixelY(t.y,s,i);e.save(),t.rotation&&(e.translate(n,o),e.rotate(t.rotation*Math.PI/180),e.translate(-n,-o));const r=t.fontSize??P.text.fontSize,l=t.fontFamily??P.text.fontFamily,h=t.fontWeight??"normal";e.font=`${h} ${r}px ${l}`,e.textAlign="center",e.textBaseline="middle";const c=e.measureText(t.text),d=t.padding??P.text.padding,u=c.width+d*2,g=r+d*2;let f=n,p=o;switch(t.anchor){case"top-left":f+=u/2,p+=g/2;break;case"top-right":f-=u/2,p+=g/2;break;case"bottom-left":f+=u/2,p-=g/2;break;case"bottom-right":f-=u/2,p-=g/2;break;case"top-center":p+=g/2;break;case"bottom-center":p-=g/2;break;case"left-center":f+=u/2;break;case"right-center":f-=u/2;break}t.backgroundColor&&(e.fillStyle=t.backgroundColor,e.beginPath(),e.roundRect(f-u/2,p-g/2,u,g,4),e.fill()),e.fillStyle=t.color??P.text.color,e.fillText(t.text,f,p),e.restore()}renderArrow(e,t,i,s){const n=this.dataToPixelX(t.x1,s,i),o=this.dataToPixelY(t.y1,s,i),r=this.dataToPixelX(t.x2,s,i),l=this.dataToPixelY(t.y2,s,i);e.save(),e.strokeStyle=t.color??P.arrow.color,e.fillStyle=t.color??P.arrow.color,e.lineWidth=t.lineWidth??P.arrow.lineWidth,e.beginPath(),e.moveTo(n,o),e.lineTo(r,l),e.stroke();const h=t.headSize??P.arrow.headSize,c=Math.atan2(l-o,r-n),d=t.headStyle??"filled";if(d!=="none"&&(e.beginPath(),e.moveTo(r,l),e.lineTo(r-h*Math.cos(c-Math.PI/6),l-h*Math.sin(c-Math.PI/6)),d==="filled"?(e.lineTo(r-h*Math.cos(c+Math.PI/6),l-h*Math.sin(c+Math.PI/6)),e.closePath(),e.fill()):(e.moveTo(r,l),e.lineTo(r-h*Math.cos(c+Math.PI/6),l-h*Math.sin(c+Math.PI/6)),e.stroke())),t.showTail){const u=c+Math.PI;e.beginPath(),e.moveTo(n,o),e.lineTo(n-h*Math.cos(u-Math.PI/6),o-h*Math.sin(u-Math.PI/6)),e.lineTo(n-h*Math.cos(u+Math.PI/6),o-h*Math.sin(u+Math.PI/6)),e.closePath(),e.fill()}if(t.label){const u=(n+r)/2,g=(o+l)/2;this.renderCenteredLabel(e,t.label,u,g-10)}e.restore()}renderLineLabel(e,t,i,s,n,o,r,l){e.save(),e.font=`${P.text.fontSize}px ${P.text.fontFamily}`;const h=e.measureText(t),c=4,d=h.width+c*2,u=P.text.fontSize+c*2;let g,f;if(r==="horizontal"){switch(f=n,o){case"left":g=i+5,e.textAlign="left";break;case"right":g=s-5,e.textAlign="right";break;default:g=(i+s)/2,e.textAlign="center"}e.textBaseline="bottom",f-=4}else{switch(g=n,o){case"top":f=i+u;break;case"bottom":f=s-5;break;default:f=(i+s)/2}e.textAlign="center",e.textBaseline="middle"}if(l??!0){e.fillStyle=l??"rgba(0, 0, 0, 0.7)";const p=e.textAlign==="left"?g-c:e.textAlign==="right"?g-d+c:g-d/2;e.fillRect(p,f-u+c,d,u)}e.fillStyle=P.text.color,e.fillText(t,g,f),e.restore()}renderCenteredLabel(e,t,i,s){e.save(),e.font=`${P.text.fontSize}px ${P.text.fontFamily}`;const n=e.measureText(t),o=4,r=n.width+o*2,l=P.text.fontSize+o*2;e.fillStyle="rgba(0, 0, 0, 0.7)",e.beginPath(),e.roundRect(i-r/2,s-l/2,r,l,3),e.fill(),e.fillStyle=P.text.color,e.textAlign="center",e.textBaseline="middle",e.fillText(t,i,s),e.restore()}}function ht(a,e){const{seriesIds:t,includeHeaders:i=!0,precision:s=6,delimiter:n=","}=e??{},o=t?a.filter(h=>t.includes(h.getId())):a;if(o.length===0)return"";const r=[];if(i){const h=[];o.forEach(c=>{h.push(`${c.getId()}_x`,`${c.getId()}_y`)}),r.push(h.join(n))}const l=Math.max(...o.map(h=>h.getPointCount()));for(let h=0;h<l;h++){const c=[];o.forEach(d=>{const u=d.getData();u&&h<u.x.length?c.push(u.x[h].toFixed(s),u.y[h].toFixed(s)):c.push("","")}),r.push(c.join(n))}return r.join(`
217
+ `)}function ct(a,e,t){const{seriesIds:i,precision:s=6}=t??{},n=i?a.filter(r=>i.includes(r.getId())):a,o={};return n.forEach(r=>{const l=r.getData();o[r.getId()]={id:r.getId(),type:r.getType(),style:r.getStyle(),data:{x:l?Array.from(l.x).map(h=>parseFloat(h.toFixed(s))):[],y:l?Array.from(l.y).map(h=>parseFloat(h.toFixed(s))):[]},pointCount:r.getPointCount()}}),JSON.stringify({exportDate:new Date().toISOString(),chartBounds:e,series:o},null,2)}function dt(a,e,t,i,s,n,o="png"){const r=document.createElement("canvas");r.width=e.width,r.height=e.height;const l=r.getContext("2d");if(!l)return"";const h=t;return l.fillStyle=`rgba(${Math.round(h[0]*255)}, ${Math.round(h[1]*255)}, ${Math.round(h[2]*255)}, ${h[3]})`,l.fillRect(0,0,r.width,r.height),l.drawImage(a,0,0),l.drawImage(e,0,0),i&&s&&i.draw(l,n),r.toDataURL(`image/${o}`)}function ut(a,e){if(e.x&&(a.viewBounds.xMin=e.x[0],a.viewBounds.xMax=e.x[1]),e.y)if(e.axisId){const t=a.yScales.get(e.axisId);t&&(t.setDomain(e.y[0],e.y[1]),e.axisId===a.primaryYAxisId&&(a.viewBounds.yMin=e.y[0],a.viewBounds.yMax=e.y[1]))}else{const t=a.viewBounds.yMax-a.viewBounds.yMin,i=e.y[1]-e.y[0],s=t>0?i/t:1,n=t>0?(e.y[0]-a.viewBounds.yMin)/t:0;a.yScales.forEach((o,r)=>{if(r===a.primaryYAxisId)return;const l=o.domain[1]-o.domain[0],h=o.domain[0]+n*l,c=h+s*l;o.setDomain(h,c)}),a.viewBounds.yMin=e.y[0],a.viewBounds.yMax=e.y[1]}a.events.emit("zoom",{x:[a.viewBounds.xMin,a.viewBounds.xMax],y:[a.viewBounds.yMin,a.viewBounds.yMax]}),a.requestRender()}function ft(a,e,t,i){const s=a.getPlotArea(),n=e/s.width*(a.viewBounds.xMax-a.viewBounds.xMin);if(a.viewBounds.xMin-=n,a.viewBounds.xMax-=n,i){const r=a.yScales.get(i);if(r){const l=r.domain[1]-r.domain[0],h=t/s.height*l;r.setDomain(r.domain[0]+h,r.domain[1]+h),i===a.primaryYAxisId&&(a.viewBounds.yMin=r.domain[0],a.viewBounds.yMax=r.domain[1])}}else a.yScales.forEach((r,l)=>{const h=r.domain[1]-r.domain[0],c=t/s.height*h;r.setDomain(r.domain[0]+c,r.domain[1]+c),l===a.primaryYAxisId&&(a.viewBounds.yMin=r.domain[0],a.viewBounds.yMax=r.domain[1])});const o=t/s.height*(a.viewBounds.yMax-a.viewBounds.yMin);a.events.emit("pan",{deltaX:n,deltaY:o}),a.requestRender()}function gt(a){if(a.series.size===0)return;let e=1/0,t=-1/0;const i=new Map;a.yScales.forEach((r,l)=>{i.set(l,{min:1/0,max:-1/0})});let s=!1;if(a.series.forEach(r=>{if(!r.isVisible())return;const l=r.getBounds();if(l&&isFinite(l.xMin)&&isFinite(l.xMax)&&isFinite(l.yMin)&&isFinite(l.yMax)){e=Math.min(e,l.xMin),t=Math.max(t,l.xMax);const h=r.getYAxisId()||a.primaryYAxisId,c=i.get(h);c&&(c.min=Math.min(c.min,l.yMin),c.max=Math.max(c.max,l.yMax)),s=!0}}),!s){console.warn("[SciChart] No valid data bounds found for autoScale");return}const n=1e15,o=-1e15;if(a.xAxisOptions.auto){let r=t-e;(r<=0||!isFinite(r))&&(r=Math.abs(e)*.1||1);const l=Math.min(r*.05,1e10);a.viewBounds.xMin=Math.max(o,e-l),a.viewBounds.xMax=Math.min(n,t+l)}i.forEach((r,l)=>{if(r.min===1/0)return;const h=a.yAxisOptionsMap.get(l),c=a.yScales.get(l);if(h&&h.auto&&c){let d=r.max-r.min;(d<=0||!isFinite(d))&&(d=Math.abs(r.min)*.1||1);const u=Math.min(d*.05,1e10),g=Math.max(o,r.min-u),f=Math.min(n,r.max+u);c.setDomain(g,f),l===a.primaryYAxisId&&(a.viewBounds.yMin=g,a.viewBounds.yMax=f)}}),a.requestRender()}function mt(a,e,t,i){if(e===null){if(t&&t.width>5&&t.height>5){const s=a.getPlotArea(),n=a.viewBounds,o=(t.x-s.x)/s.width,r=(t.x+t.width-s.x)/s.width,l=1-(t.y-s.y)/s.height,h=1-(t.y+t.height-s.y)/s.height,c=n.xMin+o*(n.xMax-n.xMin),d=n.xMin+r*(n.xMax-n.xMin),u=n.yMin+h*(n.yMax-n.yMin),g=n.yMin+l*(n.yMax-n.yMin);i({x:[c,d],y:[u,g]})}return null}else return e}function yt(a,e){const t=[];return a.xScale.setRange(e.x,e.x+e.width),a.xScale.setDomain(a.viewBounds.xMin,a.viewBounds.xMax),a.yScales.forEach((i,s)=>{i.setRange(e.y+e.height,e.y),s===a.primaryYAxisId&&i.setDomain(a.viewBounds.yMin,a.viewBounds.yMax)}),a.series.forEach(i=>{i.needsBufferUpdate&&(a.updateSeriesBuffer(i),i.needsBufferUpdate=!1);const s=a.renderer.getBuffer(i.getId());if(s){const n=i.getType(),o=i.getYAxisId()||a.primaryYAxisId,r=a.yScales.get(o);let l;r&&(l={min:r.domain[0],max:r.domain[1]});const h=n==="area"?"band":n,c={id:i.getId(),buffer:s,count:i.getPointCount(),style:i.getStyle(),visible:i.isVisible(),type:h,yBounds:l};if((n==="band"||n==="area")&&(c.count=i.getPointCount()*2),n==="step"||n==="step+scatter"){const d=a.renderer.getBuffer(`${i.getId()}_step`);if(d){c.stepBuffer=d;const u=i.getStyle().stepMode??"after",g=i.getPointCount();u==="center"?c.stepCount=1+(g-1)*3:c.stepCount=g*2-1}}t.push(c)}}),t}function pt(a,e,t){var o;const i=a.container.getBoundingClientRect();if(i.width===0||i.height===0){console.warn("[SciChart] Container has zero size in render, skipping overlay");return}a.overlay.clear(i.width,i.height),a.overlay.drawGrid(e,a.xScale,t),a.overlay.drawXAxis(e,a.xScale,a.xAxisOptions.label);const s=[],n=[];if(a.yAxisOptionsMap.forEach((r,l)=>{r.position==="right"?n.push(l):s.push(l)}),s.forEach((r,l)=>{const h=a.yScales.get(r),c=a.yAxisOptionsMap.get(r);if(h&&c){const d=l*65;a.overlay.drawYAxis(e,h,c.label,"left",d)}}),n.forEach((r,l)=>{const h=a.yScales.get(r),c=a.yAxisOptionsMap.get(r);if(h&&c){const d=l*65;a.overlay.drawYAxis(e,h,c.label,"right",d)}}),a.overlay.drawPlotBorder(e),a.series.forEach(r=>{if(r.isVisible()&&r.hasErrorData()){const l=r.getYAxisId()||a.primaryYAxisId,c=a.yScales.get(l)||t;a.overlay.drawErrorBars(e,r,a.xScale,c)}}),a.selectionRect&&a.overlay.drawSelectionRect(a.selectionRect),a.annotationManager.count>0&&a.annotationManager.render(a.overlayCtx,e,a.viewBounds),(o=a.cursorOptions)!=null&&o.enabled&&a.cursorPosition){const r={enabled:!0,x:a.cursorPosition.x,y:a.cursorPosition.y,crosshair:a.cursorOptions.crosshair??!1,tooltipText:a.cursorOptions.formatter?a.cursorOptions.formatter(a.pixelToDataX(a.cursorPosition.x),a.pixelToDataY(a.cursorPosition.y),""):`X: ${a.pixelToDataX(a.cursorPosition.x).toFixed(3)}
218
+ Y: ${a.pixelToDataY(a.cursorPosition.y).toExponential(2)}`};a.overlay.drawCursor(e,r)}a.stats&&a.showStatistics&&a.stats.update(a.viewBounds)}const bt={color:"#ff0055",width:1.5,opacity:1,pointSize:4};function F(a){return a?a instanceof Float32Array||a instanceof Float64Array?a:new Float32Array(a):new Float32Array(0)}class Le{constructor(e){m(this,"id");m(this,"type");m(this,"yAxisId");m(this,"data");m(this,"style");m(this,"visible");m(this,"cycle");m(this,"maxPoints");m(this,"lastAppendCount",0);m(this,"cachedBounds",null);m(this,"boundsNeedsUpdate",!0);m(this,"_needsBufferUpdate",!0);m(this,"smoothedData",null);m(this,"smoothingNeedsUpdate",!0);var t,i,s,n,o,r,l,h,c;if(!e)throw new Error("[Series] Options are required");this.id=e.id,this.type=e.type,this.yAxisId=e.yAxisId,this.data={x:F((t=e.data)==null?void 0:t.x),y:F((i=e.data)==null?void 0:i.y),yError:(s=e.data)!=null&&s.yError?F(e.data.yError):void 0,yErrorPlus:(n=e.data)!=null&&n.yErrorPlus?F(e.data.yErrorPlus):void 0,yErrorMinus:(o=e.data)!=null&&o.yErrorMinus?F(e.data.yErrorMinus):void 0,xError:(r=e.data)!=null&&r.xError?F(e.data.xError):void 0,xErrorPlus:(l=e.data)!=null&&l.xErrorPlus?F(e.data.xErrorPlus):void 0,xErrorMinus:(h=e.data)!=null&&h.xErrorMinus?F(e.data.xErrorMinus):void 0,y2:(c=e.data)!=null&&c.y2?F(e.data.y2):void 0},this.style={...bt,...e.style},e.color&&(this.style.color=e.color),e.width&&(this.style.width=e.width),e.pointSize&&(this.style.pointSize=e.pointSize),e.symbol&&(this.style.symbol=e.symbol),this.visible=e.visible??!0,this.cycle=e.cycle,this.maxPoints=e.maxPoints,this.data.x.length!==this.data.y.length&&console.warn(`[Series "${this.id}"] X and Y arrays have different lengths:`,this.data.x.length,"vs",this.data.y.length)}getId(){return this.id}getType(){return this.type}getYAxisId(){return this.yAxisId}getVisible(){return this.visible}getData(){return this.style.smoothing&&this.style.smoothing>0?this.getSmoothedData():this.data}getSmoothedData(){return(this.smoothingNeedsUpdate||!this.smoothedData)&&(this.smoothedData=this.applySmoothing(this.data,5),this.smoothingNeedsUpdate=!1),this.smoothedData}applySmoothing(e,t){const{x:i,y:s}=e,n=i.length;if(n<t)return{...e};const o=new Float32Array(n),r=Math.floor(t/2);for(let l=0;l<n;l++){let h=0,c=0;for(let d=l-r;d<=l+r;d++)d>=0&&d<n&&(h+=s[d],c++);o[l]=h/c}return{x:i,y:o}}getStyle(){return this.style}isVisible(){return this.visible}getCycle(){return this.cycle}getPointCount(){return this.data.x.length}getLastAppendCount(){return this.lastAppendCount}resetLastAppendCount(){this.lastAppendCount=0}hasErrorData(){return!!(this.data.yError||this.data.yErrorPlus||this.data.yErrorMinus||this.data.xError||this.data.xErrorPlus||this.data.xErrorMinus)}getYError(e){var s,n;if(e<0||e>=this.data.x.length)return null;if(this.data.yError&&e<this.data.yError.length){const o=this.data.yError[e];return[o,o]}const t=((s=this.data.yErrorMinus)==null?void 0:s[e])??0,i=((n=this.data.yErrorPlus)==null?void 0:n[e])??0;return t>0||i>0?[t,i]:null}getXError(e){var s,n;if(e<0||e>=this.data.x.length)return null;if(this.data.xError&&e<this.data.xError.length){const o=this.data.xError[e];return[o,o]}const t=((s=this.data.xErrorMinus)==null?void 0:s[e])??0,i=((n=this.data.xErrorPlus)==null?void 0:n[e])??0;return t>0||i>0?[t,i]:null}getBounds(){return this.data.x.length===0?null:((this.boundsNeedsUpdate||this.cachedBounds===null)&&(this.cachedBounds=this.calculateBounds(),this.boundsNeedsUpdate=!1),this.cachedBounds)}calculateBounds(){const{x:e,y:t}=this.data;let i=1/0,s=-1/0,n=1/0,o=-1/0;for(let l=0;l<e.length;l++){const h=e[l],c=t[l];!isFinite(h)||!isFinite(c)||(h<i&&(i=h),h>s&&(s=h),c<n&&(n=c),c>o&&(o=c))}return{xMin:i,xMax:s,yMin:n,yMax:o}}updateData(e){if(e){if(e.append){const t=F(e.x),i=F(e.y);if(t.length>0&&i.length>0){if(this.data={...this.data,x:this.appendArray(this.data.x,t),y:this.appendArray(this.data.y,i)},e.y2){const s=F(e.y2);this.data.y2=this.data.y2?this.appendArray(this.data.y2,s):s}if(this.lastAppendCount+=t.length,this.maxPoints&&this.data.x.length>this.maxPoints){const s=this.data.x.length-this.maxPoints;this.data.x=this.data.x.slice(s),this.data.y=this.data.y.slice(s),this.data.y2&&(this.data.y2=this.data.y2.slice(s)),this.lastAppendCount=0}}}else e.x&&(this.data.x=F(e.x)),e.y&&(this.data.y=F(e.y)),e.y2&&(this.data.y2=F(e.y2)),this.lastAppendCount=0;this.boundsNeedsUpdate=!0,this.smoothingNeedsUpdate=!0,this._needsBufferUpdate=!0}}appendArray(e,t){const i=new e.constructor(e.length+t.length);return i.set(e,0),i.set(t,e.length),i}setData(e,t,i){this.data={x:e,y:t,y2:i},this.boundsNeedsUpdate=!0,this.smoothingNeedsUpdate=!0,this._needsBufferUpdate=!0}setStyle(e){const t=this.style.smoothing;this.style={...this.style,...e},this.style.smoothing!==t&&(this.smoothingNeedsUpdate=!0,this._needsBufferUpdate=!0)}get needsBufferUpdate(){return this._needsBufferUpdate}set needsBufferUpdate(e){this._needsBufferUpdate=e}setVisible(e){this.visible=e}setType(e){this.type=e}setMaxPoints(e){this.maxPoints=e,this.maxPoints&&this.data.x.length>this.maxPoints&&(this.data.x=this.data.x.slice(-this.maxPoints),this.data.y=this.data.y.slice(-this.maxPoints),this.data.y2&&(this.data.y2=this.data.y2.slice(-this.maxPoints)),this._needsBufferUpdate=!0)}destroy(){this.data={x:new Float32Array(0),y:new Float32Array(0)},this.cachedBounds=null}}function xt(a,e){var i;const t=new Le(e);a.series.set(t.getId(),t),$(a,t),(a.xAxisOptions.auto||Array.from(a.yAxisOptionsMap.values()).some(s=>s.auto))&&a.autoScale(),(i=a.updateLegend)==null||i.call(a),a.requestRender()}function vt(a,e){var i;const t=a.series.get(e);t&&(a.renderer.deleteBuffer(e),a.renderer.deleteBuffer(`${e}_step`),t.destroy(),a.series.delete(e),(i=a.updateLegend)==null||i.call(a),a.requestRender())}function Mt(a,e,t){const i=a.series.get(e);i&&(i.updateData(t),$(a,i),a.requestRender())}function $(a,e){const t=e.getData();if(!t||t.x.length===0)return;const i=e.getType(),s=e.getId(),n=t.x.length;if(i==="band"||i==="area"){const o=i==="area"?new Float32Array(n).fill(0):t.y2||new Float32Array(n).fill(0);a.renderer.createBuffer(s,st(t.x,t.y,o))}else a.renderer.createBuffer(s,ae(t.x,t.y));if(i==="step"||i==="step+scatter"){const o=e.getStyle().stepMode??"after",r=it(t.x,t.y,o);a.renderer.createBuffer(`${s}_step`,r)}e.resetLastAppendCount()}function wt(a,e,t,i){const s=a.series.get(e);if(!s)return;const n=s.getBounds(),o=n?n.xMax:-1/0;if(s.updateData({x:t,y:i,append:!0}),$(a,s),a.autoScrollEnabled){const r=s.getBounds();if(r){const l=a.viewBounds.xMax-a.viewBounds.xMin;(o>=a.viewBounds.xMax-l*.05||!n)&&(a.viewBounds.xMax=r.xMax,a.viewBounds.xMin=a.viewBounds.xMax-l)}}(a.xAxisOptions.auto||Array.from(a.yAxisOptionsMap.values()).some(r=>r.auto))&&a.autoScale(),a.requestRender()}function St(a,e,t){const i=a.series.get(e);i&&(i.setMaxPoints(t),$(a,i))}function Tt(a,e,t,i={}){const s=a.series.get(e);if(!s)throw new Error(`Series ${e} not found`);const n=s.getData();if(!n||n.x.length<2)return"";const o=Te(n.x,n.y,t,i),r=s.getBounds(),l=(r==null?void 0:r.xMin)??0,c=((r==null?void 0:r.xMax)??1)-l,d=200,u=new Float32Array(d),g=new Float32Array(d);for(let b=0;b<d;b++){const x=l+b/(d-1)*c;u[b]=x,g[b]=o.predict(x)}const f=`${e}-fit-${Date.now()}`,p=s.getStyle();return a.addSeries({id:f,type:"line",yAxisId:s.getYAxisId(),data:{x:u,y:g},style:{color:p.color,width:(p.width||1)*1.5,opacity:.8,lineDash:[5,5]}}),a.addAnnotation({type:"text",x:l+c*.05,y:o.predict(l+c*.05),text:`${o.equation}
219
+ (R² = ${o.rSquared.toFixed(4)})`,fontSize:12,backgroundColor:"rgba(0,0,0,0.7)",color:p.color||"#ffffff",padding:4,anchor:"bottom-left",interactive:!0}),f}class ie{constructor(){m(this,"domain",[0,1]);m(this,"range",[0,100]);m(this,"type","linear")}setDomain(e,t){if(!isFinite(e)||!isFinite(t)){this.domain=[0,1];return}if(e===t){this.domain=[e-.5,t+.5];return}this.domain=[e,t]}setRange(e,t){this.range=[e,t]}transform(e){const[t,i]=this.domain,[s,n]=this.range,o=(e-t)/(i-t);return s+o*(n-s)}invert(e){const[t,i]=this.domain,[s,n]=this.range,o=(e-s)/(n-s);return t+o*(i-t)}ticks(e=10){const[t,i]=this.domain;if(!isFinite(t)||!isFinite(i)||t===i)return[];const s=Ct(t,i,e),n=Math.ceil(t/s)*s,o=[],r=100;let l=n;for(;l<=i+s*.5&&o.length<r;)o.push(Math.round(l*1e12)/1e12),l+=s;return o}}class se{constructor(){m(this,"domain",[1,1e3]);m(this,"range",[0,100]);m(this,"type","log");m(this,"base",10)}setDomain(e,t){const i=Math.max(e,1e-12),s=Math.max(t,1e-12*10);if(i===s){this.domain=[i/10,s*10];return}this.domain=[i,s]}setRange(e,t){this.range=[e,t]}transform(e){const[t,i]=this.domain,[s,n]=this.range;if(e<=0)return s;const o=Math.log(t)/Math.log(this.base),r=Math.log(i)/Math.log(this.base),h=(Math.log(e)/Math.log(this.base)-o)/(r-o);return s+h*(n-s)}invert(e){const[t,i]=this.domain,[s,n]=this.range,o=Math.log(t)/Math.log(this.base),r=Math.log(i)/Math.log(this.base),l=(e-s)/(n-s),h=o+l*(r-o);return Math.pow(this.base,h)}ticks(e=10){const[t,i]=this.domain,s=Math.floor(Math.log10(t)),n=Math.ceil(Math.log10(i)),o=[];for(let r=s;r<=n&&o.length<e;r++){const l=Math.pow(10,r);l>=t&&l<=i&&o.push(l)}return o}}function Ct(a,e,t){const i=e-a;if(i<=0||!isFinite(i))return 1;const s=i/t,n=Math.pow(10,Math.floor(Math.log10(s))),o=s/n;let r;return o<1.5?r=1:o<3?r=2:o<7?r=5:r=10,r*n}function kt(a){return a==="log"?new se:new ie}function Et(a,e){if(!a)throw new Error("[SciChart] Container element is required");const t=e.devicePixelRatio??window.devicePixelRatio,i=typeof e.theme=="string"?le(e.theme):e.theme??Be,s=J(e.background??i.backgroundColor),n=[s[0],s[1],s[2],s[3]],o=e.showLegend??i.legend.visible,r=e.showControls??!1,l=e.autoScroll??!1,h=e.showStatistics??!1,c={scale:"linear",auto:!0,...e.xAxis},d=c.scale==="log"?new se:new ie,u=new Map,g=new Map;let f="default";(e.yAxis?Array.isArray(e.yAxis)?e.yAxis:[e.yAxis]:[{}]).forEach((T,A)=>{const B=A===0,w=B?"default":`y${A}`,E=T.id||w;B&&(f=E);const D={scale:"linear",auto:!0,position:T.position||(B?"left":"right"),...T,id:E};u.set(E,D),g.set(E,D.scale==="log"?new se:new ie)}),a.style.position="relative",a.style.overflow="hidden",a.style.backgroundColor=e.background??i.backgroundColor;const b=Ie("webgl"),x=Ie("overlay");for(;a.firstChild;)a.removeChild(a.firstChild);a.appendChild(b),a.appendChild(x);const v=x.getContext("2d");if(!v)throw new Error("Failed to get 2D context");return{theme:i,backgroundColor:n,showLegend:o,showControls:r,autoScroll:l,showStatistics:h,dpr:t,xAxisOptions:c,xScale:d,yAxisOptionsMap:u,yScales:g,primaryYAxisId:f,webglCanvas:b,overlayCanvas:x,overlayCtx:v}}function Ie(a){const e=document.createElement("canvas");return e.style.cssText="position:absolute;top:0;left:0;width:100%;height:100%;",a==="overlay"&&(e.style.pointerEvents="none"),e}function Pt(a,e){const t=a.getBoundingClientRect(),i=Array.from(e.values()).filter(r=>r.position!=="right").length,s=Array.from(e.values()).filter(r=>r.position==="right").length,n=_.left+Math.max(0,i-1)*65,o=_.right+s*65;return{x:n,y:_.top,width:Math.max(1,t.width-n-o),height:Math.max(1,t.height-_.top-_.bottom)}}function Bt(a){const e=[];let t=0,i=0;return a.forEach((s,n)=>{const o=s.position==="right"?"right":"left",r=o==="left"?t*65:i*65;o==="left"?t++:i++,e.push({id:n,position:o,offset:r})}),e}function At(a,e,t,i,s){const n=a.getBoundingClientRect();if(n.width===0||n.height===0)return!1;const o=n.width*s,r=n.height*s;return[e,t].forEach(l=>{l.width=o,l.height=r}),i.scale(s,s),!0}class Rt{constructor(e){m(this,"container");m(this,"webglCanvas");m(this,"overlayCanvas");m(this,"overlayCtx");m(this,"series",new Map);m(this,"events",new Ce);m(this,"viewBounds",{xMin:-.5,xMax:.5,yMin:-1e-5,yMax:1e-5});m(this,"xAxisOptions");m(this,"yAxisOptionsMap");m(this,"primaryYAxisId");m(this,"dpr");m(this,"backgroundColor");m(this,"renderer");m(this,"overlay");m(this,"interaction");m(this,"xScale");m(this,"yScales");m(this,"theme");m(this,"cursorOptions",null);m(this,"cursorPosition",null);m(this,"showLegend");m(this,"legend",null);m(this,"showControls");m(this,"controls",null);m(this,"animationFrameId",null);m(this,"needsRender",!1);m(this,"isDestroyed",!1);m(this,"autoScroll",!1);m(this,"showStatistics",!1);m(this,"stats",null);m(this,"selectionRect",null);m(this,"annotationManager",new Re);m(this,"analysis",Je);this.container=e.container;const t=Et(this.container,e);this.theme=t.theme,this.backgroundColor=t.backgroundColor,this.showLegend=t.showLegend,this.showControls=t.showControls,this.autoScroll=t.autoScroll,this.showStatistics=t.showStatistics,this.dpr=t.dpr,this.xAxisOptions=t.xAxisOptions,this.xScale=t.xScale,this.yAxisOptionsMap=t.yAxisOptionsMap,this.yScales=t.yScales,this.primaryYAxisId=t.primaryYAxisId,this.webglCanvas=t.webglCanvas,this.overlayCanvas=t.overlayCanvas,this.overlayCtx=t.overlayCtx,this.renderer=new Z(this.webglCanvas),this.renderer.setDPR(this.dpr),this.overlay=new Ae(this.overlayCtx,this.theme),this.interaction=new ot(this.container,{onZoom:(i,s)=>this.zoom({x:[i.xMin,i.xMax],y:[i.yMin,i.yMax],axisId:s}),onPan:(i,s,n)=>this.pan(i,s,n),onBoxZoom:i=>this.handleBoxZoom(i),onCursorMove:(i,s)=>{this.cursorPosition={x:i,y:s},this.requestRender()},onCursorLeave:()=>{this.cursorPosition=null,this.requestRender()}},()=>this.getPlotArea(),i=>this.getInteractedBounds(i),()=>Bt(this.yAxisOptionsMap)),new ResizeObserver(()=>!this.isDestroyed&&this.resize()).observe(this.container),this.initControls(),this.initLegend(e),this.showStatistics&&(this.stats=new lt(this.container,this.theme,this.series)),this.resize(),this.startRenderLoop(),setTimeout(()=>!this.isDestroyed&&this.resize(),100),console.log("[SciChart] Initialized",{dpr:this.dpr,theme:this.theme.name})}get yScale(){return this.yScales.get(this.primaryYAxisId)||this.yScales.values().next().value}initControls(){this.showControls&&(this.controls=new rt(this.container,this.theme,{onResetZoom:()=>this.resetZoom(),onSetType:e=>{this.series.forEach(t=>t.setType(e)),this.requestRender()},onToggleSmoothing:()=>{this.series.forEach(e=>{const t=e.getStyle();e.setStyle({smoothing:(t.smoothing||0)===0?.5:0})}),this.requestRender()},onTogglePan:e=>this.interaction.setPanMode(e),onExport:()=>{const e=document.createElement("a");e.download=`scichart-export-${Date.now()}.png`,e.href=this.exportImage(),e.click()},onAutoScale:()=>{this.autoScale(),this.requestRender(),this.events.emit("autoScale",void 0)},onToggleLegend:e=>{this.showLegend=e,this.legend&&this.legend.setVisible(e)}}))}initLegend(e){this.showLegend&&(this.legend=new at(this.container,this.theme,e.legendPosition||{},{onMove:(t,i)=>this.events.emit("legendMove",{x:t,y:i})}),this.legend.update(this.getAllSeries()))}setTheme(e){this.theme=typeof e=="string"?le(e):e;const t=J(this.theme.backgroundColor);this.backgroundColor=[t[0],t[1],t[2],t[3]],this.container.style.backgroundColor=this.theme.backgroundColor,this.overlay.setTheme(this.theme),this.requestRender()}getPlotArea(){return Pt(this.container,this.yAxisOptionsMap)}getInteractedBounds(e){if(e){const t=this.yScales.get(e);if(t)return{...this.viewBounds,yMin:t.domain[0],yMax:t.domain[1]}}return this.viewBounds}exportImage(e="png"){return dt(this.webglCanvas,this.overlayCanvas,this.backgroundColor,this.legend,this.showLegend,this.dpr,e)}getSeriesContext(){return{series:this.series,renderer:this.renderer,viewBounds:this.viewBounds,autoScale:()=>this.autoScale(),requestRender:()=>this.requestRender(),addAnnotation:e=>this.addAnnotation(e),xAxisOptions:this.xAxisOptions,yAxisOptionsMap:this.yAxisOptionsMap,autoScrollEnabled:this.autoScroll,addSeries:e=>this.addSeries(e),updateLegend:()=>{this.legend&&this.legend.update(this.getAllSeries())}}}addSeries(e){xt(this.getSeriesContext(),e)}removeSeries(e){vt(this.getSeriesContext(),e)}updateSeries(e,t){Mt(this.getSeriesContext(),e,t)}appendData(e,t,i){wt(this.getSeriesContext(),e,t,i)}setAutoScroll(e){this.autoScroll=e}setMaxPoints(e,t){St(this.getSeriesContext(),e,t)}addFitLine(e,t,i={}){return Tt(this.getSeriesContext(),e,t,i)}getSeries(e){return this.series.get(e)}getAllSeries(){return Array.from(this.series.values())}getNavContext(){return{viewBounds:this.viewBounds,yScales:this.yScales,yAxisOptionsMap:this.yAxisOptionsMap,xAxisOptions:this.xAxisOptions,primaryYAxisId:this.primaryYAxisId,getPlotArea:()=>this.getPlotArea(),events:this.events,requestRender:()=>this.requestRender(),series:this.series}}zoom(e){ut(this.getNavContext(),e)}pan(e,t,i){ft(this.getNavContext(),e,t,i)}resetZoom(){this.autoScale(),this.events.emit("zoom",{x:[this.viewBounds.xMin,this.viewBounds.xMax],y:[this.viewBounds.yMin,this.viewBounds.yMax]}),this.requestRender()}getViewBounds(){return{...this.viewBounds}}autoScale(){gt(this.getNavContext())}handleBoxZoom(e){this.selectionRect=mt(this.getNavContext(),e,this.selectionRect,t=>this.zoom(t)),this.requestRender()}enableCursor(e){this.cursorOptions={enabled:!0,...e}}disableCursor(){this.cursorOptions=null,this.cursorPosition=null,this.requestRender()}addAnnotation(e){const t=this.annotationManager.add(e);return this.requestRender(),t}removeAnnotation(e){const t=this.annotationManager.remove(e);return this.requestRender(),t}updateAnnotation(e,t){this.annotationManager.update(e,t),this.requestRender()}getAnnotation(e){return this.annotationManager.get(e)}getAnnotations(){return this.annotationManager.getAll()}clearAnnotations(){this.annotationManager.clear(),this.requestRender()}exportCSV(e){return ht(this.getAllSeries(),e)}exportJSON(e){return ct(this.getAllSeries(),this.viewBounds,e)}resize(){At(this.container,this.webglCanvas,this.overlayCanvas,this.overlayCtx,this.dpr)&&(this.renderer.resize(),this.requestRender())}requestRender(){this.needsRender=!0}render(){if(this.isDestroyed)return;const e=performance.now(),t=this.getPlotArea();if(this.webglCanvas.width===0||this.webglCanvas.height===0)return;const i={webglCanvas:this.webglCanvas,overlayCanvas:this.overlayCanvas,overlayCtx:this.overlayCtx,container:this.container,series:this.series,viewBounds:this.viewBounds,xScale:this.xScale,yScales:this.yScales,yAxisOptionsMap:this.yAxisOptionsMap,xAxisOptions:this.xAxisOptions,primaryYAxisId:this.primaryYAxisId,renderer:this.renderer,overlay:this.overlay,annotationManager:this.annotationManager,backgroundColor:this.backgroundColor,cursorOptions:this.cursorOptions,cursorPosition:this.cursorPosition,selectionRect:this.selectionRect,stats:this.stats,showStatistics:this.showStatistics,events:this.events,updateSeriesBuffer:n=>$(this.getSeriesContext(),n),getPlotArea:()=>t,pixelToDataX:n=>this.pixelToDataX(n),pixelToDataY:n=>this.pixelToDataY(n)},s=yt(i,t);this.renderer.render(s,{bounds:this.viewBounds,backgroundColor:this.backgroundColor,plotArea:t}),pt(i,t,this.yScale),this.events.emit("render",{fps:1e3/(performance.now()-e),frameTime:performance.now()-e})}pixelToDataX(e){const t=this.getPlotArea();return this.viewBounds.xMin+(e-t.x)/t.width*(this.viewBounds.xMax-this.viewBounds.xMin)}pixelToDataY(e){const t=this.getPlotArea();return this.viewBounds.yMin+(1-(e-t.y)/t.height)*(this.viewBounds.yMax-this.viewBounds.yMin)}startRenderLoop(){const e=()=>{this.isDestroyed||(this.needsRender&&(this.render(),this.needsRender=!1),this.animationFrameId=requestAnimationFrame(e))};this.animationFrameId=requestAnimationFrame(e)}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}destroy(){for(this.isDestroyed=!0,this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),this.interaction.destroy(),this.series.forEach(e=>{this.renderer.deleteBuffer(e.getId()),e.destroy()}),this.series.clear(),this.renderer.destroy(),this.controls&&this.controls.destroy(),this.legend&&this.legend.destroy();this.container.firstChild;)this.container.removeChild(this.container.firstChild);console.log("[SciChart] Destroyed")}}function De(a){return new Rt(a)}function Lt(a){return new Z(a)}function It(a,e,t){const i=a.length;if(t>=i||t<=2)return{x:new Float32Array(a),y:new Float32Array(e),indices:new Uint32Array(Array.from({length:i},(c,d)=>d))};const s=new Float32Array(t),n=new Float32Array(t),o=new Uint32Array(t);s[0]=a[0],n[0]=e[0],o[0]=0;const r=(i-2)/(t-2);let l=0,h=1;for(let c=0;c<t-2;c++){const d=Math.floor((c+1)*r)+1,u=Math.floor((c+2)*r)+1,g=Math.min(u,i-1),f=Math.min(Math.floor((c+3)*r)+1,i);let p=0,b=0,x=0;for(let w=g;w<f;w++)p+=a[w],b+=e[w],x++;x>0&&(p/=x,b/=x);let v=-1,T=d;const A=a[l],B=e[l];for(let w=d;w<u&&w<i;w++){const E=Math.abs((A-p)*(e[w]-B)-(A-a[w])*(b-B));E>v&&(v=E,T=w)}s[h]=a[T],n[h]=e[T],o[h]=T,l=T,h++}return s[t-1]=a[i-1],n[t-1]=e[i-1],o[t-1]=i-1,{x:s,y:n,indices:o}}function Dt(a,e,t){const i=a.length;if(t>=i/2)return{x:new Float32Array(a),y:new Float32Array(e),indices:new Uint32Array(Array.from({length:i},(l,h)=>h))};const s=i/t,n=[],o=[],r=[];for(let l=0;l<t;l++){const h=Math.floor(l*s),c=Math.floor((l+1)*s);let d=1/0,u=-1/0,g=h,f=h;for(let p=h;p<c&&p<i;p++)e[p]<d&&(d=e[p],g=p),e[p]>u&&(u=e[p],f=p);g<=f?(n.push(a[g],a[f]),o.push(e[g],e[f]),r.push(g,f)):(n.push(a[f],a[g]),o.push(e[f],e[g]),r.push(f,g))}return{x:new Float32Array(n),y:new Float32Array(o),indices:new Uint32Array(r)}}function Ft(a,e,t=2){const i=e*t;return Math.min(a,i)}var he={exports:{}},j={};/**
109
220
  * @license React
110
221
  * react-jsx-runtime.production.js
111
222
  *
@@ -113,7 +224,7 @@ Y: ${this.pixelToDataY(this.cursorPosition.y).toExponential(2)}`};this.overlay.d
113
224
  *
114
225
  * This source code is licensed under the MIT license found in the
115
226
  * LICENSE file in the root directory of this source tree.
116
- */var xe;function Je(){if(xe)return N;xe=1;var c=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,i,o){var s=null;if(o!==void 0&&(s=""+o),i.key!==void 0&&(s=""+i.key),"key"in i){o={};for(var r in i)r!=="key"&&(o[r]=i[r])}else o=i;return i=o.ref,{$$typeof:c,type:n,key:s,ref:i!==void 0?i:null,props:o}}return N.Fragment=e,N.jsx=t,N.jsxs=t,N}var U={};/**
227
+ */var Fe;function _t(){if(Fe)return j;Fe=1;var a=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,s,n){var o=null;if(n!==void 0&&(o=""+n),s.key!==void 0&&(o=""+s.key),"key"in s){n={};for(var r in s)r!=="key"&&(n[r]=s[r])}else n=s;return s=n.ref,{$$typeof:a,type:i,key:o,ref:s!==void 0?s:null,props:n}}return j.Fragment=e,j.jsx=t,j.jsxs=t,j}var V={};/**
117
228
  * @license React
118
229
  * react-jsx-runtime.development.js
119
230
  *
@@ -121,10 +232,10 @@ Y: ${this.pixelToDataY(this.cursorPosition.y).toExponential(2)}`};this.overlay.d
121
232
  *
122
233
  * This source code is licensed under the MIT license found in the
123
234
  * LICENSE file in the root directory of this source tree.
124
- */var be;function Ke(){return be||(be=1,process.env.NODE_ENV!=="production"&&function(){function c(d){if(d==null)return null;if(typeof d=="function")return d.$$typeof===ne?null:d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case p:return"Fragment";case C:return"Profiler";case M:return"StrictMode";case S:return"Suspense";case z:return"SuspenseList";case j:return"Activity"}if(typeof d=="object")switch(typeof d.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),d.$$typeof){case x:return"Portal";case A:return d.displayName||"Context";case R:return(d._context.displayName||"Context")+".Consumer";case _:var v=d.render;return d=d.displayName,d||(d=v.displayName||v.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case B:return v=d.displayName||null,v!==null?v:c(d.type)||"Memo";case D:v=d._payload,d=d._init;try{return c(d(v))}catch{}}return null}function e(d){return""+d}function t(d){try{e(d);var v=!1}catch{v=!0}if(v){v=console;var T=v.error,E=typeof Symbol=="function"&&Symbol.toStringTag&&d[Symbol.toStringTag]||d.constructor.name||"Object";return T.call(v,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",E),e(d)}}function n(d){if(d===p)return"<>";if(typeof d=="object"&&d!==null&&d.$$typeof===D)return"<...>";try{var v=c(d);return v?"<"+v+">":"<...>"}catch{return"<...>"}}function i(){var d=oe.A;return d===null?null:d.getOwner()}function o(){return Error("react-stack-top-frame")}function s(d){if(ve.call(d,"key")){var v=Object.getOwnPropertyDescriptor(d,"key").get;if(v&&v.isReactWarning)return!1}return d.key!==void 0}function r(d,v){function T(){we||(we=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",v))}T.isReactWarning=!0,Object.defineProperty(d,"key",{get:T,configurable:!0})}function a(){var d=c(this.type);return Me[d]||(Me[d]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),d=this.props.ref,d!==void 0?d:null}function l(d,v,T,E,K,re){var k=T.ref;return d={$$typeof:g,type:d,key:v,props:T,_owner:E},(k!==void 0?k:null)!==null?Object.defineProperty(d,"ref",{enumerable:!1,get:a}):Object.defineProperty(d,"ref",{enumerable:!1,value:null}),d._store={},Object.defineProperty(d._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(d,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(d,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:K}),Object.defineProperty(d,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:re}),Object.freeze&&(Object.freeze(d.props),Object.freeze(d)),d}function h(d,v,T,E,K,re){var k=v.children;if(k!==void 0)if(E)if(et(k)){for(E=0;E<k.length;E++)f(k[E]);Object.freeze&&Object.freeze(k)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(k);if(ve.call(v,"key")){k=c(d);var Y=Object.keys(v).filter(function(tt){return tt!=="key"});E=0<Y.length?"{key: someKey, "+Y.join(": ..., ")+": ...}":"{key: someKey}",Te[k+E]||(Y=0<Y.length?"{"+Y.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
235
+ */var _e;function Yt(){return _e||(_e=1,process.env.NODE_ENV!=="production"&&function(){function a(y){if(y==null)return null;if(typeof y=="function")return y.$$typeof===N?null:y.displayName||y.name||null;if(typeof y=="string")return y;switch(y){case b:return"Fragment";case v:return"Profiler";case x:return"StrictMode";case w:return"Suspense";case E:return"SuspenseList";case O:return"Activity"}if(typeof y=="object")switch(typeof y.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),y.$$typeof){case p:return"Portal";case A:return y.displayName||"Context";case T:return(y._context.displayName||"Context")+".Consumer";case B:var S=y.render;return y=y.displayName,y||(y=S.displayName||S.name||"",y=y!==""?"ForwardRef("+y+")":"ForwardRef"),y;case k:return S=y.displayName||null,S!==null?S:a(y.type)||"Memo";case D:S=y._payload,y=y._init;try{return a(y(S))}catch{}}return null}function e(y){return""+y}function t(y){try{e(y);var S=!1}catch{S=!0}if(S){S=console;var R=S.error,L=typeof Symbol=="function"&&Symbol.toStringTag&&y[Symbol.toStringTag]||y.constructor.name||"Object";return R.call(S,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",L),e(y)}}function i(y){if(y===b)return"<>";if(typeof y=="object"&&y!==null&&y.$$typeof===D)return"<...>";try{var S=a(y);return S?"<"+S+">":"<...>"}catch{return"<...>"}}function s(){var y=W.A;return y===null?null:y.getOwner()}function n(){return Error("react-stack-top-frame")}function o(y){if(ze.call(y,"key")){var S=Object.getOwnPropertyDescriptor(y,"key").get;if(S&&S.isReactWarning)return!1}return y.key!==void 0}function r(y,S){function R(){Oe||(Oe=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",S))}R.isReactWarning=!0,Object.defineProperty(y,"key",{get:R,configurable:!0})}function l(){var y=a(this.type);return Xe[y]||(Xe[y]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),y=this.props.ref,y!==void 0?y:null}function h(y,S,R,L,ne,de){var I=R.ref;return y={$$typeof:f,type:y,key:S,props:R,_owner:L},(I!==void 0?I:null)!==null?Object.defineProperty(y,"ref",{enumerable:!1,get:l}):Object.defineProperty(y,"ref",{enumerable:!1,value:null}),y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(y,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(y,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ne}),Object.defineProperty(y,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:de}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y}function c(y,S,R,L,ne,de){var I=S.children;if(I!==void 0)if(L)if(Ot(I)){for(L=0;L<I.length;L++)d(I[L]);Object.freeze&&Object.freeze(I)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else d(I);if(ze.call(S,"key")){I=a(y);var U=Object.keys(S).filter(function(Xt){return Xt!=="key"});L=0<U.length?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}",Ue[I+L]||(U=0<U.length?"{"+U.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
125
236
  let props = %s;
126
237
  <%s {...props} />
127
238
  React keys must be passed directly to JSX without using spread:
128
239
  let props = %s;
129
- <%s key={someKey} {...props} />`,E,k,Y,k),Te[k+E]=!0)}if(k=null,T!==void 0&&(t(T),k=""+T),s(v)&&(t(v.key),k=""+v.key),"key"in v){T={};for(var ae in v)ae!=="key"&&(T[ae]=v[ae])}else T=v;return k&&r(T,typeof d=="function"?d.displayName||d.name||"Unknown":d),l(d,k,T,i(),K,re)}function f(d){y(d)?d._store&&(d._store.validated=1):typeof d=="object"&&d!==null&&d.$$typeof===D&&(d._payload.status==="fulfilled"?y(d._payload.value)&&d._payload.value._store&&(d._payload.value._store.validated=1):d._store&&(d._store.validated=1))}function y(d){return typeof d=="object"&&d!==null&&d.$$typeof===g}var m=w,g=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),A=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),j=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),oe=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve=Object.prototype.hasOwnProperty,et=Array.isArray,se=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(d){return d()}};var we,Me={},Se=m.react_stack_bottom_frame.bind(m,o)(),Ce=se(n(o)),Te={};U.Fragment=p,U.jsx=function(d,v,T){var E=1e4>oe.recentlyCreatedOwnerStacks++;return h(d,v,T,!1,E?Error("react-stack-top-frame"):Se,E?se(n(d)):Ce)},U.jsxs=function(d,v,T){var E=1e4>oe.recentlyCreatedOwnerStacks++;return h(d,v,T,!0,E?Error("react-stack-top-frame"):Se,E?se(n(d)):Ce)}}()),U}process.env.NODE_ENV==="production"?ie.exports=Je():ie.exports=Ke();var X=ie.exports;function pe(c,e={}){const[t,n]=w.useState(null),[i,o]=w.useState(!1),[s,r]=w.useState(null),[a,l]=w.useState(null),h=w.useRef(e);h.current=e,w.useEffect(()=>{const p=c.current;if(p){try{const M=ge({...h.current,container:p});M.on("zoom",()=>{l(M.getViewBounds())}),n(M),o(!0),l(M.getViewBounds()),r(null),console.log("[useSciChart] Chart initialized")}catch(M){console.error("[useSciChart] Failed to initialize chart:",M),r(M instanceof Error?M:new Error(String(M))),o(!1)}return()=>{t&&(t.destroy(),n(null),o(!1))}}},[c]);const f=w.useCallback(p=>{t&&(t.addSeries(p),l(t.getViewBounds()))},[t]),y=w.useCallback((p,M)=>{t&&t.updateSeries(p,M)},[t]),m=w.useCallback(p=>{t&&t.removeSeries(p)},[t]),g=w.useCallback(p=>{t&&t.zoom(p)},[t]),x=w.useCallback(()=>{t&&(t.resetZoom(),l(t.getViewBounds()))},[t]);return{chart:t,isReady:i,error:s,bounds:a,addSeries:f,updateSeries:y,removeSeries:m,zoom:g,resetZoom:x}}const Qe=w.forwardRef(function({series:e=[],zoom:t,onZoomChange:n,cursor:i,width:o="100%",height:s=400,className:r="",style:a={},debug:l=!1,...h},f){const y=w.useRef(null),m=w.useRef(new Map),{chart:g,isReady:x,bounds:p,addSeries:M,updateSeries:C,removeSeries:R,resetZoom:A}=pe(y,h);w.useImperativeHandle(f,()=>({getChart:()=>g,resetZoom:A,getBounds:()=>p}),[g,A,p]),w.useEffect(()=>{if(!x||!g)return;const S=new Map(e.map(B=>[B.id,B])),z=m.current;z.forEach((B,D)=>{S.has(D)||R(D)}),S.forEach((B,D)=>{const j=z.get(D);if(j)(j.x!==B.x||j.y!==B.y)&&C(D,{x:B.x,y:B.y});else{const ne={id:B.id,type:"line",data:{x:B.x,y:B.y},style:{color:B.color??"#ff0055",width:B.width??1.5},visible:B.visible??!0};M(ne),S.size===1&&g.autoScale()}}),m.current=S},[e,x,g,M,C,R]),w.useEffect(()=>{!x||!g||!t||g.zoom(t)},[x,g,t]),w.useEffect(()=>{!x||!g||!n||g.on("zoom",S=>{n({xMin:S.x[0],xMax:S.x[1],yMin:S.y[0],yMax:S.y[1]})})},[x,g,n]),w.useEffect(()=>{!x||!g||(i!=null&&i.enabled?g.enableCursor(i):g.disableCursor())},[x,g,i]);const _=w.useMemo(()=>({position:"relative",width:typeof o=="number"?`${o}px`:o,height:typeof s=="number"?`${s}px`:s,...a}),[o,s,a]);return X.jsx("div",{ref:y,className:`scichart-container ${r}`,style:_,children:l&&p&&X.jsxs("div",{style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.7)",color:"#0f0",padding:"4px 8px",borderRadius:4,fontSize:11,fontFamily:"monospace"},children:[X.jsxs("div",{children:["X: [",p.xMin.toFixed(3),", ",p.xMax.toFixed(3),"]"]}),X.jsxs("div",{children:["Y: [",p.yMin.toExponential(2),", ",p.yMax.toExponential(2),"]"]}),X.jsxs("div",{children:["Series: ",e.length]})]})})});b.DARK_THEME=J,b.DEFAULT_THEME=ee,b.ELECTROCHEM_THEME=ue,b.EventEmitter=I,b.LIGHT_THEME=de,b.LinearScale=H,b.LogScale=$,b.MIDNIGHT_THEME=he,b.NativeWebGLRenderer=W,b.OverlayRenderer=fe,b.SciChart=Qe,b.Series=le,b.calculateStats=Ge,b.calculateTargetPoints=Ue,b.createChart=ge,b.createNativeRenderer=W,b.createRenderer=Oe,b.createScale=Le,b.createTheme=_e,b.detectCycles=We,b.detectPeaks=He,b.downsampleLTTB=qe,b.formatCurrent=te,b.formatPotential=te,b.formatScientific=je,b.formatValue=Xe,b.formatWithPrefix=te,b.generateCycleColors=Ve,b.getBestPrefix=ye,b.getThemeByName=Q,b.interleaveData=ce,b.lttbDownsample=Ye,b.minMaxDownsample=Ne,b.movingAverage=Ze,b.parseColor=V,b.useSciChart=pe,b.validateData=$e,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
240
+ <%s key={someKey} {...props} />`,L,I,U,I),Ue[I+L]=!0)}if(I=null,R!==void 0&&(t(R),I=""+R),o(S)&&(t(S.key),I=""+S.key),"key"in S){R={};for(var ue in S)ue!=="key"&&(R[ue]=S[ue])}else R=S;return I&&r(R,typeof y=="function"?y.displayName||y.name||"Unknown":y),h(y,I,R,s(),ne,de)}function d(y){u(y)?y._store&&(y._store.validated=1):typeof y=="object"&&y!==null&&y.$$typeof===D&&(y._payload.status==="fulfilled"?u(y._payload.value)&&y._payload.value._store&&(y._payload.value._store.validated=1):y._store&&(y._store.validated=1))}function u(y){return typeof y=="object"&&y!==null&&y.$$typeof===f}var g=C,f=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),A=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),N=Symbol.for("react.client.reference"),W=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ze=Object.prototype.hasOwnProperty,Ot=Array.isArray,ce=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(y){return y()}};var Oe,Xe={},Ne=g.react_stack_bottom_frame.bind(g,n)(),We=ce(i(n)),Ue={};V.Fragment=b,V.jsx=function(y,S,R){var L=1e4>W.recentlyCreatedOwnerStacks++;return c(y,S,R,!1,L?Error("react-stack-top-frame"):Ne,L?ce(i(y)):We)},V.jsxs=function(y,S,R){var L=1e4>W.recentlyCreatedOwnerStacks++;return c(y,S,R,!0,L?Error("react-stack-top-frame"):Ne,L?ce(i(y)):We)}}()),V}process.env.NODE_ENV==="production"?he.exports=_t():he.exports=Yt();var H=he.exports;function Ye(a,e={}){const[t,i]=C.useState(null),[s,n]=C.useState(!1),[o,r]=C.useState(null),[l,h]=C.useState(null),c=C.useRef(e);c.current=e,C.useEffect(()=>{const b=a.current;if(b){try{const x=De({...c.current,container:b});x.on("zoom",()=>{h(x.getViewBounds())}),i(x),n(!0),h(x.getViewBounds()),r(null),console.log("[useSciChart] Chart initialized")}catch(x){console.error("[useSciChart] Failed to initialize chart:",x),r(x instanceof Error?x:new Error(String(x))),n(!1)}return()=>{t&&(t.destroy(),i(null),n(!1))}}},[a]);const d=C.useCallback(b=>{t&&(t.addSeries(b),h(t.getViewBounds()))},[t]),u=C.useCallback((b,x)=>{t&&t.updateSeries(b,x)},[t]),g=C.useCallback(b=>{t&&t.removeSeries(b)},[t]),f=C.useCallback(b=>{t&&t.zoom(b)},[t]),p=C.useCallback(()=>{t&&(t.resetZoom(),h(t.getViewBounds()))},[t]);return{chart:t,isReady:s,error:o,bounds:l,addSeries:d,updateSeries:u,removeSeries:g,zoom:f,resetZoom:p}}const zt=C.forwardRef(function({series:e=[],zoom:t,onZoomChange:i,cursor:s,width:n="100%",height:o=400,className:r="",style:l={},debug:h=!1,...c},d){const u=C.useRef(null),g=C.useRef(new Map),{chart:f,isReady:p,bounds:b,addSeries:x,updateSeries:v,removeSeries:T,resetZoom:A}=Ye(u,c);C.useImperativeHandle(d,()=>({getChart:()=>f,resetZoom:A,getBounds:()=>b}),[f,A,b]),C.useEffect(()=>{if(!p||!f)return;const w=new Map(e.map(k=>[k.id,k])),E=g.current;E.forEach((k,D)=>{w.has(D)||T(D)}),w.forEach((k,D)=>{const O=E.get(D);if(O)(O.x!==k.x||O.y!==k.y)&&v(D,{x:k.x,y:k.y});else{const N={id:k.id,type:"line",data:{x:k.x,y:k.y},style:{color:k.color??"#ff0055",width:k.width??1.5},visible:k.visible??!0};x(N),w.size===1&&f.autoScale()}}),g.current=w},[e,p,f,x,v,T]),C.useEffect(()=>{!p||!f||!t||f.zoom(t)},[p,f,t]),C.useEffect(()=>{!p||!f||!i||f.on("zoom",w=>{i({xMin:w.x[0],xMax:w.x[1],yMin:w.y[0],yMax:w.y[1]})})},[p,f,i]),C.useEffect(()=>{!p||!f||(s!=null&&s.enabled?f.enableCursor(s):f.disableCursor())},[p,f,s]);const B=C.useMemo(()=>({position:"relative",width:typeof n=="number"?`${n}px`:n,height:typeof o=="number"?`${o}px`:o,...l}),[n,o,l]);return H.jsx("div",{ref:u,className:`scichart-container ${r}`,style:B,children:h&&b&&H.jsxs("div",{style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.7)",color:"#0f0",padding:"4px 8px",borderRadius:4,fontSize:11,fontFamily:"monospace"},children:[H.jsxs("div",{children:["X: [",b.xMin.toFixed(3),", ",b.xMax.toFixed(3),"]"]}),H.jsxs("div",{children:["Y: [",b.yMin.toExponential(2),", ",b.yMax.toExponential(2),"]"]}),H.jsxs("div",{children:["Series: ",e.length]})]})})});M.AnnotationManager=Re,M.DARK_THEME=te,M.DEFAULT_THEME=Be,M.ELECTROCHEM_THEME=Pe,M.EventEmitter=Ce,M.LIGHT_THEME=Ee,M.LinearScale=ie,M.LogScale=se,M.MIDNIGHT_THEME=ke,M.NativeWebGLRenderer=Z,M.OverlayRenderer=Ae,M.SciChart=zt,M.Series=Le,M.calculateStats=re,M.calculateTargetPoints=Ft,M.createChart=De,M.createNativeRenderer=Z,M.createRenderer=Lt,M.createScale=kt,M.createTheme=nt,M.detectCycles=ye,M.detectPeaks=be,M.downsampleLTTB=Me,M.formatCurrent=q,M.formatPotential=q,M.formatScientific=me,M.formatValue=ge,M.formatWithPrefix=q,M.generateCycleColors=pe,M.getBestPrefix=oe,M.getThemeByName=le,M.interleaveData=ae,M.lttbDownsample=It,M.minMaxDownsample=Dt,M.movingAverage=ve,M.parseColor=J,M.useSciChart=Ye,M.validateData=xe,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
130
241
  //# sourceMappingURL=scichart-engine.umd.js.map