@tradecanvas/core 1.11.0 → 1.12.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.
Files changed (65) hide show
  1. package/README.md +2 -4
  2. package/dist/{WebGLSeriesRenderer-DVJBHdfm.js → WebGLSeriesRenderer-CLVnGxIS.js} +174 -134
  3. package/dist/{WebGLSeriesRenderer-DVJBHdfm.js.map → WebGLSeriesRenderer-CLVnGxIS.js.map} +1 -1
  4. package/dist/{WebGLSeriesRenderer-DjkYvHPQ.cjs → WebGLSeriesRenderer-rB3-CqXS.cjs} +12 -12
  5. package/dist/{WebGLSeriesRenderer-DjkYvHPQ.cjs.map → WebGLSeriesRenderer-rB3-CqXS.cjs.map} +1 -1
  6. package/dist/charts/BaselineRenderer.d.ts.map +1 -1
  7. package/dist/charts/KagiRenderer.d.ts.map +1 -1
  8. package/dist/charts/PointAndFigureRenderer.d.ts.map +1 -1
  9. package/dist/engine/RenderEngine.d.ts +5 -0
  10. package/dist/engine/RenderEngine.d.ts.map +1 -1
  11. package/dist/engine/gpu.d.ts +3 -1
  12. package/dist/engine/gpu.d.ts.map +1 -1
  13. package/dist/engine/gpuContexts.d.ts +23 -0
  14. package/dist/engine/gpuContexts.d.ts.map +1 -0
  15. package/dist/engine/index.d.ts +3 -1
  16. package/dist/engine/index.d.ts.map +1 -1
  17. package/dist/engine/loadWebGL.d.ts +15 -2
  18. package/dist/engine/loadWebGL.d.ts.map +1 -1
  19. package/dist/{gridLines-CBmfrSCE.cjs → gridLines-CVQJ3gzb.cjs} +2 -2
  20. package/dist/gridLines-CVQJ3gzb.cjs.map +1 -0
  21. package/dist/{gridLines-BJLaM2d7.js → gridLines-ovHZBvAe.js} +38 -5
  22. package/dist/gridLines-ovHZBvAe.js.map +1 -0
  23. package/dist/index.cjs +6 -6
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.js +3242 -2484
  26. package/dist/index.js.map +1 -1
  27. package/dist/indicators/index.d.ts +13 -1
  28. package/dist/indicators/index.d.ts.map +1 -1
  29. package/dist/indicators/math.d.ts +2 -0
  30. package/dist/indicators/math.d.ts.map +1 -1
  31. package/dist/indicators/overlay/HammingMA.d.ts +19 -0
  32. package/dist/indicators/overlay/HammingMA.d.ts.map +1 -0
  33. package/dist/indicators/overlay/MAChannel.d.ts +13 -0
  34. package/dist/indicators/overlay/MAChannel.d.ts.map +1 -0
  35. package/dist/indicators/overlay/MACross.d.ts.map +1 -1
  36. package/dist/indicators/overlay/MovingAverageSets.d.ts +20 -0
  37. package/dist/indicators/overlay/MovingAverageSets.d.ts.map +1 -0
  38. package/dist/indicators/overlay/PivotPoints.d.ts +5 -0
  39. package/dist/indicators/overlay/PivotPoints.d.ts.map +1 -1
  40. package/dist/indicators/overlay/PriceAverages.d.ts +25 -0
  41. package/dist/indicators/overlay/PriceAverages.d.ts.map +1 -0
  42. package/dist/indicators/overlay/VolatilityIndex.d.ts +13 -0
  43. package/dist/indicators/overlay/VolatilityIndex.d.ts.map +1 -0
  44. package/dist/indicators/panel/AccumulativeSwingIndex.d.ts +13 -0
  45. package/dist/indicators/panel/AccumulativeSwingIndex.d.ts.map +1 -0
  46. package/dist/indicators/panel/AdvanceDecline.d.ts +18 -0
  47. package/dist/indicators/panel/AdvanceDecline.d.ts.map +1 -0
  48. package/dist/indicators/panel/ChopZone.d.ts +17 -0
  49. package/dist/indicators/panel/ChopZone.d.ts.map +1 -0
  50. package/dist/indicators/panel/MajorityRule.d.ts +15 -0
  51. package/dist/indicators/panel/MajorityRule.d.ts.map +1 -0
  52. package/dist/indicators/panel/PriceOscillator.d.ts +8 -0
  53. package/dist/indicators/panel/PriceOscillator.d.ts.map +1 -0
  54. package/dist/indicators/panel/SMIErgodic.d.ts +12 -0
  55. package/dist/indicators/panel/SMIErgodic.d.ts.map +1 -0
  56. package/dist/indicators/panel/VolatilityEstimators.d.ts +29 -0
  57. package/dist/indicators/panel/VolatilityEstimators.d.ts.map +1 -0
  58. package/dist/indicators/registry.d.ts.map +1 -1
  59. package/dist/indicators/symbols/symbolIndicators.d.ts +27 -0
  60. package/dist/indicators/symbols/symbolIndicators.d.ts.map +1 -1
  61. package/dist/webgl/WebGLSeriesRenderer.d.ts +30 -12
  62. package/dist/webgl/WebGLSeriesRenderer.d.ts.map +1 -1
  63. package/package.json +2 -2
  64. package/dist/gridLines-BJLaM2d7.js.map +0 -1
  65. package/dist/gridLines-CBmfrSCE.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
- import { i as e, o as t, r as n, s as r, t as i } from "./gridLines-BJLaM2d7.js";
2
- import { resolveVolumeColors as a } from "@tradecanvas/commons";
3
- var o = (e, t) => e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume, s = class {
1
+ import { c as e, d as t, f as n, l as r, r as i, t as a } from "./gridLines-ovHZBvAe.js";
2
+ import { resolveVolumeColors as o } from "@tradecanvas/commons";
3
+ var s = (e, t) => e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume, c = class {
4
4
  buffer = new Float32Array();
5
5
  count = 0;
6
6
  basePrice = 0;
@@ -24,12 +24,12 @@ var o = (e, t) => e.time === t.time && e.open === t.open && e.high === t.high &&
24
24
  to: 0
25
25
  };
26
26
  let n = this.count;
27
- if (!(e === this.source && n > 0 && t >= n && this.samples.every(({ index: t, bar: n }) => o(e[t], n)))) return this.basePrice = e[t - 1].close, this.ensure(t), this.write(e, 0, t), this.remember(e), {
27
+ if (!(e === this.source && n > 0 && t >= n && this.samples.every(({ index: t, bar: n }) => s(e[t], n)))) return this.basePrice = e[t - 1].close, this.ensure(t), this.write(e, 0, t), this.remember(e), {
28
28
  full: !0,
29
29
  from: 0,
30
30
  to: t
31
31
  };
32
- let r = this.last !== null && o(e[n - 1], this.last) ? n : n - 1;
32
+ let r = this.last !== null && s(e[n - 1], this.last) ? n : n - 1;
33
33
  return t > this.buffer.length / 6 ? (this.ensure(t), this.write(e, 0, t), this.remember(e), {
34
34
  full: !0,
35
35
  from: 0,
@@ -62,11 +62,11 @@ var o = (e, t) => e.time === t.time && e.open === t.open && e.high === t.high &&
62
62
  bar: { ...e[t] }
63
63
  })), this.last = { ...e[t - 1] }, this.source = e;
64
64
  }
65
- }, c = /* @__PURE__ */ new Map(), l;
66
- function u(e, t) {
65
+ }, l = /* @__PURE__ */ new Map(), u;
66
+ function d(e, t) {
67
67
  return e.endsWith("%") ? parseFloat(e) / 100 : parseFloat(e) / t;
68
68
  }
69
- function d(e) {
69
+ function f(e) {
70
70
  let t = e.trim();
71
71
  if (t.toLowerCase() === "transparent") return [
72
72
  0,
@@ -88,28 +88,28 @@ function d(e) {
88
88
  }
89
89
  let r = /^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i.exec(t);
90
90
  return r ? [
91
- u(r[1], 255),
92
- u(r[2], 255),
93
- u(r[3], 255),
94
- r[4] === void 0 ? 1 : u(r[4], 1)
91
+ d(r[1], 255),
92
+ d(r[2], 255),
93
+ d(r[3], 255),
94
+ r[4] === void 0 ? 1 : d(r[4], 1)
95
95
  ] : null;
96
96
  }
97
- function f() {
98
- if (l !== void 0) return l;
97
+ function p() {
98
+ if (u !== void 0) return u;
99
99
  try {
100
- l = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1).getContext("2d") : typeof document < "u" ? document.createElement("canvas").getContext("2d") : null;
100
+ u = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1).getContext("2d") : typeof document < "u" ? document.createElement("canvas").getContext("2d") : null;
101
101
  } catch {
102
- l = null;
102
+ u = null;
103
103
  }
104
- return l;
104
+ return u;
105
105
  }
106
- function p(e) {
107
- let t = f();
106
+ function m(e) {
107
+ let t = p();
108
108
  if (!t) return null;
109
109
  t.fillStyle = "#000", t.fillStyle = e;
110
110
  let n = String(t.fillStyle);
111
111
  if (t.fillStyle = "#fff", t.fillStyle = e, String(t.fillStyle) !== n) return null;
112
- let r = d(n);
112
+ let r = f(n);
113
113
  if (r) return r;
114
114
  t.clearRect(0, 0, 1, 1), t.fillRect(0, 0, 1, 1);
115
115
  let i = t.getImageData(0, 0, 1, 1).data;
@@ -120,23 +120,23 @@ function p(e) {
120
120
  i[3] / 255
121
121
  ];
122
122
  }
123
- var m = /* @__PURE__ */ new Set();
124
- function h(e) {
125
- let t = c.get(e);
123
+ var h = /* @__PURE__ */ new Set();
124
+ function g(e) {
125
+ let t = l.get(e);
126
126
  if (t) return t;
127
- if (m.has(e)) return null;
128
- let n = d(e) ?? p(e);
129
- return c.size > 256 && c.clear(), m.size > 256 && m.clear(), n ? c.set(e, n) : m.add(e), n;
127
+ if (h.has(e)) return null;
128
+ let n = f(e) ?? m(e);
129
+ return l.size > 256 && l.clear(), h.size > 256 && h.clear(), n ? l.set(e, n) : h.add(e), n;
130
130
  }
131
- function g(e) {
132
- return h(e) ?? [
131
+ function _(e) {
132
+ return g(e) ?? [
133
133
  0,
134
134
  0,
135
135
  0,
136
136
  0
137
137
  ];
138
138
  }
139
- function _([e, t, n, r]) {
139
+ function v([e, t, n, r]) {
140
140
  return [
141
141
  e * r,
142
142
  t * r,
@@ -146,7 +146,7 @@ function _([e, t, n, r]) {
146
146
  }
147
147
  //#endregion
148
148
  //#region src/webgl/yMapping.ts
149
- function v(e, t) {
149
+ function ee(e, t) {
150
150
  let { min: n, max: r } = e.priceRange, { y: i, height: a } = e.chartRect, o = +(e.invertScale === !0), s = {
151
151
  log: 0,
152
152
  invert: o,
@@ -185,7 +185,7 @@ function v(e, t) {
185
185
  }
186
186
  //#endregion
187
187
  //#region src/webgl/glKit.ts
188
- var ee = class {
188
+ var te = class {
189
189
  constructor(e) {
190
190
  this.gl = e;
191
191
  }
@@ -253,14 +253,14 @@ var ee = class {
253
253
  };
254
254
  //#endregion
255
255
  //#region src/webgl/polygonSpans.ts
256
- function te(e) {
256
+ function ne(e) {
257
257
  let t = e.length / 2;
258
258
  if (t < 3) return [];
259
259
  let n = 0, r = 0;
260
260
  for (let i = 1; i < t; i++) e[2 * i] < e[2 * n] && (n = i), e[2 * i] > e[2 * r] && (r = i);
261
261
  if (e[2 * n] === e[2 * r]) return [];
262
262
  let i = b(e, n, r, 1, t), a = b(e, n, r, -1, t);
263
- return !i || !a ? null : ne(i, a);
263
+ return !i || !a ? null : re(i, a);
264
264
  }
265
265
  function y(e) {
266
266
  let t = 0, n = e.length / 2;
@@ -290,7 +290,7 @@ var x = class {
290
290
  return [s(e), s(t)];
291
291
  }
292
292
  };
293
- function ne(e, t) {
293
+ function re(e, t) {
294
294
  let n = /* @__PURE__ */ new Set();
295
295
  for (let t = 0; t < e.length; t += 2) n.add(e[t]);
296
296
  for (let e = 0; e < t.length; e += 2) n.add(t[e]);
@@ -303,7 +303,7 @@ function ne(e, t) {
303
303
  }
304
304
  //#endregion
305
305
  //#region src/webgl/recordedShaders.ts
306
- var S = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform vec4 u_clip;\n\nvec4 toClip(vec2 dev) {\n return vec4(dev.x / u_canvas.x * 2.0 - 1.0, 1.0 - dev.y / u_canvas.y * 2.0, 0.0, 1.0);\n}\n", C = "\nvec2 corner(int k) {\n if (k == 0) return vec2(0.0, 0.0);\n if (k == 1 || k == 4) return vec2(1.0, 0.0);\n if (k == 2 || k == 3) return vec2(0.0, 1.0);\n return vec2(1.0, 1.0);\n}\nconst vec4 NOWHERE = vec4(-2.0, -2.0, 0.0, 1.0);\n", w = "\n// This fragment's pixel centre in device pixels, y down.\nvec2 pixelCentre() { return vec2(gl_FragCoord.x, u_canvas.y - gl_FragCoord.y); }\n\n// The share of the pixel centred at p inside the clip.\nfloat clipCoverage(vec2 p) {\n vec2 lo = p - 0.5;\n vec2 c = clamp(min(lo + 1.0, u_clip.zw) - max(lo, u_clip.xy), 0.0, 1.0);\n return c.x * c.y;\n}\n", re = `${S}${C}
306
+ var S = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform vec4 u_clip;\n\nvec4 toClip(vec2 dev) {\n return vec4(dev.x / u_canvas.x * 2.0 - 1.0, 1.0 - dev.y / u_canvas.y * 2.0, 0.0, 1.0);\n}\n", C = "\nvec2 corner(int k) {\n if (k == 0) return vec2(0.0, 0.0);\n if (k == 1 || k == 4) return vec2(1.0, 0.0);\n if (k == 2 || k == 3) return vec2(0.0, 1.0);\n return vec2(1.0, 1.0);\n}\nconst vec4 NOWHERE = vec4(-2.0, -2.0, 0.0, 1.0);\n", w = "\n// This fragment's pixel centre in device pixels, y down.\nvec2 pixelCentre() { return vec2(gl_FragCoord.x, u_canvas.y - gl_FragCoord.y); }\n\n// The share of the pixel centred at p inside the clip.\nfloat clipCoverage(vec2 p) {\n vec2 lo = p - 0.5;\n vec2 c = clamp(min(lo + 1.0, u_clip.zw) - max(lo, u_clip.xy), 0.0, 1.0);\n return c.x * c.y;\n}\n", ie = `${S}${C}
307
307
  uniform float u_hw;
308
308
  in vec4 a_p0;
309
309
  in vec4 a_p1;
@@ -332,7 +332,7 @@ void main() {
332
332
  vec2 pos = mix(a - dir * m, b + dir * m, cr.x) + n * mix(-m, m, cr.y);
333
333
  gl_Position = toClip(pos);
334
334
  }
335
- `, ie = `${S}${w}
335
+ `, ae = `${S}${w}
336
336
  uniform vec4 u_color;
337
337
  uniform float u_hw;
338
338
  uniform int u_cap;
@@ -411,7 +411,7 @@ void main() {
411
411
  if (cov <= 0.0) discard;
412
412
  outColor = u_color * (cov * clipCov);
413
413
  }
414
- `, ae = `${S}${C}
414
+ `, oe = `${S}${C}
415
415
  in vec2 a_x;
416
416
  in vec4 a_ab;
417
417
  in vec2 a_ends;
@@ -428,7 +428,7 @@ void main() {
428
428
  vec2 cr = corner(gl_VertexID % 6);
429
429
  gl_Position = toClip(mix(vec2(floor(a_x.x), floor(lo) - 1.0), vec2(ceil(a_x.y), ceil(hi) + 1.0), cr));
430
430
  }
431
- `, oe = `${S}${w}
431
+ `, se = `${S}${w}
432
432
  uniform int u_kind;
433
433
  uniform vec4 u_color;
434
434
  uniform vec4 u_line;
@@ -486,7 +486,7 @@ void main() {
486
486
  vec4 color = u_kind == 1 ? gradient(p) : u_color;
487
487
  outColor = color * cov;
488
488
  }
489
- `, se = `${S}${C}
489
+ `, ce = `${S}${C}
490
490
  in vec3 a_disc;
491
491
  in vec4 a_color;
492
492
  flat out vec3 v_disc;
@@ -497,7 +497,7 @@ void main() {
497
497
  float m = a_disc.z + 1.0;
498
498
  gl_Position = toClip(mix(a_disc.xy - m, a_disc.xy + m, corner(gl_VertexID % 6)));
499
499
  }
500
- `, ce = `${S}${w}
500
+ `, le = `${S}${w}
501
501
  flat in vec3 v_disc;
502
502
  flat in vec4 v_color;
503
503
  out vec4 outColor;
@@ -507,24 +507,24 @@ void main() {
507
507
  if (cov <= 0.0) discard;
508
508
  outColor = v_color * cov;
509
509
  }
510
- `, T = 4, E = T * 4, D = 32, O = 7, k = O * 4, le = class {
510
+ `, T = 4, E = T * 4, D = 32, O = 7, k = O * 4, ue = class {
511
511
  stroke;
512
512
  span;
513
513
  disc;
514
514
  buffer;
515
515
  constructor(e) {
516
- this.kit = e, this.stroke = e.program(re, ie, [
516
+ this.kit = e, this.stroke = e.program(ie, ae, [
517
517
  "a_p0",
518
518
  "a_p1",
519
519
  "a_p2",
520
520
  "a_p3",
521
521
  "a_p4",
522
522
  "a_p5"
523
- ]), this.span = e.program(ae, oe, [
523
+ ]), this.span = e.program(oe, se, [
524
524
  "a_x",
525
525
  "a_ab",
526
526
  "a_ends"
527
- ]), this.disc = e.program(se, ce, ["a_disc", "a_color"]), this.buffer = e.buffer();
527
+ ]), this.disc = e.program(ce, le, ["a_disc", "a_color"]), this.buffer = e.buffer();
528
528
  }
529
529
  draw(e, t, n, r) {
530
530
  let i = this.kit.gl;
@@ -731,7 +731,7 @@ var P = class {
731
731
  !(t instanceof e) || n !== void 0 ? this.unsupported = !0 : (this.calls.push(...t.calls), this.unsupported ||= t.unsupported), F.prototype.addPath?.call(this, t, n);
732
732
  }
733
733
  };
734
- function ue(e) {
734
+ function de(e) {
735
735
  let t = globalThis, n = Object.prototype.hasOwnProperty.call(t, "Path2D"), r = t.Path2D;
736
736
  t.Path2D = I;
737
737
  try {
@@ -742,24 +742,24 @@ function ue(e) {
742
742
  }
743
743
  //#endregion
744
744
  //#region src/webgl/strokeGeometry.ts
745
- var de = .25;
746
- function fe(e, t, n, r) {
745
+ var fe = .25;
746
+ function pe(e, t, n, r) {
747
747
  if (n === "round") return !1;
748
748
  let i = e.points, a = i.length / 2, o = +!e.closed, s = e.closed ? a : a - 1;
749
749
  for (let e = o; e < s; e++) {
750
750
  let o = (e - 1 + a) % a, s = (e + 1) % a, c = i[2 * e] - i[2 * o], l = i[2 * e + 1] - i[2 * o + 1], u = i[2 * s] - i[2 * e], d = i[2 * s + 1] - i[2 * e + 1], f = Math.hypot(c, l), p = Math.hypot(u, d);
751
751
  if (f === 0 || p === 0) continue;
752
752
  let m = Math.max(-1, Math.min(1, (c * u + l * d) / (f * p))), h = Math.sqrt((1 + m) / 2);
753
- if ((n === "miter" && h > 0 && 1 / h <= r ? t * (1 / h - 1) : t * (1 - h)) > de) return !0;
753
+ if ((n === "miter" && h > 0 && 1 / h <= r ? t * (1 / h - 1) : t * (1 - h)) > fe) return !0;
754
754
  }
755
755
  return !1;
756
756
  }
757
- function pe(e, t) {
757
+ function me(e, t) {
758
758
  let n = e.points;
759
759
  for (let e = 2; e < n.length; e += 2) if (Math.hypot(n[e] - n[e - 2], n[e + 1] - n[e - 1]) < t) return !0;
760
760
  return !1;
761
761
  }
762
- function me(e) {
762
+ function he(e) {
763
763
  let t = [], n = () => t.push(0, 0, -1, 0);
764
764
  n(), n();
765
765
  for (let { points: r, closed: i } of e) {
@@ -774,11 +774,11 @@ function me(e) {
774
774
  //#endregion
775
775
  //#region src/webgl/recorder.ts
776
776
  var L = Math.PI * 2;
777
- function R(e, t) {
777
+ function ge(e, t) {
778
778
  let n = 2 * Math.sqrt(Math.max(.2 / Math.max(e, .1), 1e-6));
779
779
  return Math.min(512, Math.max(4, Math.ceil(Math.abs(t) / Math.min(n, Math.PI / 4))));
780
780
  }
781
- var z = new Set([
781
+ var R = new Set([
782
782
  "fillStyle",
783
783
  "strokeStyle",
784
784
  "lineWidth",
@@ -797,14 +797,14 @@ var z = new Set([
797
797
  "shadowOffsetX",
798
798
  "shadowOffsetY",
799
799
  "filter"
800
- ]), B = new Set([
800
+ ]), z = new Set([
801
801
  "fontKerning",
802
802
  "fontStretch",
803
803
  "fontVariantCaps",
804
804
  "letterSpacing",
805
805
  "wordSpacing",
806
806
  "textRendering"
807
- ]), V = new Set(["imageSmoothingEnabled", "imageSmoothingQuality"]), H = (e) => !!(e.rect || e.circle) || e.points.length >= 6, he = class {
807
+ ]), B = new Set(["imageSmoothingEnabled", "imageSmoothingQuality"]), V = (e) => !!(e.rect || e.circle) || e.points.length >= 6, _e = class {
808
808
  commands = [];
809
809
  ctx;
810
810
  texts = [];
@@ -839,13 +839,13 @@ var z = new Set([
839
839
  };
840
840
  this.stepStart = t.commands, this.ok = !0;
841
841
  try {
842
- ue(() => e(this.ctx));
842
+ de(() => e(this.ctx));
843
843
  } catch {
844
844
  this.ok = !1;
845
845
  }
846
846
  return this.ok ? !0 : (this.commands.length = t.commands, i.length = t.texts, !1);
847
847
  },
848
- drawText: (e) => ge(e, i)
848
+ drawText: (e) => ve(e, i)
849
849
  };
850
850
  }
851
851
  reset(e) {
@@ -980,7 +980,7 @@ var z = new Set([
980
980
  if (n < 0) throw new DOMException("negative radius", "IndexSizeError");
981
981
  let o = i - r;
982
982
  o = !a && o >= L ? L : a && -o >= L ? -L : a ? -(((r - i) % L + L) % L) : (o % L + L) % L;
983
- let s = this.current(), c = this.state.transform, l = e + n * Math.cos(r), u = t + n * Math.sin(r), d = !s || s.closed || s.points.length === 2 && Math.abs(s.points[0] - (c[0] * l + c[2] * u + c[4])) < 1e-6 && Math.abs(s.points[1] - (c[1] * l + c[3] * u + c[5])) < 1e-6, f = R(n * Math.abs(c[0]), o);
983
+ let s = this.current(), c = this.state.transform, l = e + n * Math.cos(r), u = t + n * Math.sin(r), d = !s || s.closed || s.points.length === 2 && Math.abs(s.points[0] - (c[0] * l + c[2] * u + c[4])) < 1e-6 && Math.abs(s.points[1] - (c[1] * l + c[3] * u + c[5])) < 1e-6, f = ge(n * Math.abs(c[0]), o);
984
984
  for (let i = 0; i <= f; i++) {
985
985
  let a = r + o * i / f;
986
986
  this.lineTo(e + n * Math.cos(a), t + n * Math.sin(a));
@@ -1038,7 +1038,7 @@ var z = new Set([
1038
1038
  baseColor(e) {
1039
1039
  let t = this.solid;
1040
1040
  if (t && t.style === e) return t.color;
1041
- let n = _(g(e));
1041
+ let n = v(_(e));
1042
1042
  return this.solid = {
1043
1043
  style: e,
1044
1044
  color: n
@@ -1076,7 +1076,7 @@ var z = new Set([
1076
1076
  let n = this.state.transform, r = e.x0 === e.x1 || e.y0 === e.y1;
1077
1077
  if (!this.axisAligned() || !this.uniform() && !r) return null;
1078
1078
  let i = [...e.stops].sort((e, t) => e.offset - t.offset).map((e) => {
1079
- let n = g(e.color);
1079
+ let n = _(e.color);
1080
1080
  return {
1081
1081
  offset: e.offset,
1082
1082
  color: [
@@ -1098,13 +1098,13 @@ var z = new Set([
1098
1098
  }
1099
1099
  plain() {
1100
1100
  let e = this.state;
1101
- return e.globalCompositeOperation !== "source-over" || e.filter !== "none" ? !1 : e.shadowBlur === 0 && e.shadowOffsetX === 0 && e.shadowOffsetY === 0 ? !0 : !(g(e.shadowColor)[3] > 0);
1101
+ return e.globalCompositeOperation !== "source-over" || e.filter !== "none" ? !1 : e.shadowBlur === 0 && e.shadowOffsetX === 0 && e.shadowOffsetY === 0 ? !0 : !(_(e.shadowColor)[3] > 0);
1102
1102
  }
1103
1103
  fill(e = "nonzero") {
1104
1104
  if (!this.plain()) return this.unsupported();
1105
1105
  let t = this.paint(this.state.fillStyle);
1106
1106
  if (!t) return this.unsupported();
1107
- let n = this.path.filter(H);
1107
+ let n = this.path.filter(V);
1108
1108
  if (n.length === 0 || t.kind === "solid" && t.color[3] === 0) return;
1109
1109
  if (n.length > 1 && N(n.map((e) => M(e.points)))) {
1110
1110
  let r = t.kind === "solid" && t.color[3] >= 1, i = Math.sign(y(n[0].points));
@@ -1123,7 +1123,7 @@ var z = new Set([
1123
1123
  }
1124
1124
  let r = [];
1125
1125
  for (let e of n) {
1126
- let t = te(e.points);
1126
+ let t = ne(e.points);
1127
1127
  if (!t) return this.unsupported();
1128
1128
  for (let e of t) r.push(e);
1129
1129
  }
@@ -1188,7 +1188,7 @@ var z = new Set([
1188
1188
  let o = t.lineCap === "round" ? 1 : t.lineCap === "square" ? 2 : 0;
1189
1189
  this.commands.push({
1190
1190
  type: "stroke",
1191
- points: me(i),
1191
+ points: he(i),
1192
1192
  color: e.color,
1193
1193
  width: r,
1194
1194
  cap: o,
@@ -1206,12 +1206,12 @@ var z = new Set([
1206
1206
  }
1207
1207
  drawsAlike(e, t, n) {
1208
1208
  let r = this.state, i = t / 2;
1209
- if (t > 1 && e.some((e) => fe(e, i, r.lineJoin, r.miterLimit))) return !1;
1209
+ if (t > 1 && e.some((e) => pe(e, i, r.lineJoin, r.miterLimit))) return !1;
1210
1210
  let a = i + (r.lineCap === "butt" ? 0 : i);
1211
- return !(e.length > 1 && N(e.map((e) => M(e.points, a))) || n < 1 && e.some((e) => pe(e, t)));
1211
+ return !(e.length > 1 && N(e.map((e) => M(e.points, a))) || n < 1 && e.some((e) => me(e, t)));
1212
1212
  }
1213
1213
  clip() {
1214
- let e = this.path.filter(H);
1214
+ let e = this.path.filter(V);
1215
1215
  if (e.length !== 1 || !e[0].rect) return this.unsupported();
1216
1216
  this.state.clip = A(this.state.clip, e[0].rect);
1217
1217
  }
@@ -1320,10 +1320,10 @@ var z = new Set([
1320
1320
  get: (t, n) => {
1321
1321
  if (typeof n == "string") {
1322
1322
  if (n in e) return e[n];
1323
- if (z.has(n)) return this.state[n];
1324
- if (B.has(n)) return this.state.textExtras[n];
1323
+ if (R.has(n)) return this.state[n];
1324
+ if (z.has(n)) return this.state.textExtras[n];
1325
1325
  if (n === "canvas") return this.measure?.canvas;
1326
- if (!V.has(n)) return this.unsupported(), () => void 0;
1326
+ if (!B.has(n)) return this.unsupported(), () => void 0;
1327
1327
  }
1328
1328
  },
1329
1329
  set: (e, t, n) => (typeof t == "string" && this.setProp(t, n), !0)
@@ -1331,10 +1331,10 @@ var z = new Set([
1331
1331
  }
1332
1332
  setProp(e, t) {
1333
1333
  let n = this.state;
1334
- e === "lineWidth" || e === "miterLimit" ? typeof t == "number" && Number.isFinite(t) && t > 0 && (n[e] = t) : e === "globalAlpha" ? typeof t == "number" && Number.isFinite(t) && t >= 0 && t <= 1 && (n.globalAlpha = t) : e === "fillStyle" || e === "strokeStyle" ? t instanceof P ? n[e] = t : typeof t == "string" ? h(t) && (n[e] = t) : this.unsupported() : z.has(e) ? n[e] = t : B.has(e) ? this.state.textExtras[e] = t : V.has(e) || this.unsupported();
1334
+ e === "lineWidth" || e === "miterLimit" ? typeof t == "number" && Number.isFinite(t) && t > 0 && (n[e] = t) : e === "globalAlpha" ? typeof t == "number" && Number.isFinite(t) && t >= 0 && t <= 1 && (n.globalAlpha = t) : e === "fillStyle" || e === "strokeStyle" ? t instanceof P ? n[e] = t : typeof t == "string" ? g(t) && (n[e] = t) : this.unsupported() : R.has(e) ? n[e] = t : z.has(e) ? this.state.textExtras[e] = t : B.has(e) || this.unsupported();
1335
1335
  }
1336
1336
  };
1337
- function ge(e, t) {
1337
+ function ve(e, t) {
1338
1338
  for (let n of t) {
1339
1339
  let t = n.state;
1340
1340
  if (j(t.clip)) continue;
@@ -1343,12 +1343,12 @@ function ge(e, t) {
1343
1343
  e.setTransform(r, i, a, o, s, c), e.font = t.font, e.textAlign = t.textAlign, e.textBaseline = t.textBaseline, e.direction = t.direction, e.globalAlpha = t.globalAlpha, Object.assign(e, t.textExtras), n.stroke ? (e.strokeStyle = t.strokeStyle, e.lineWidth = t.lineWidth, e.strokeText(n.text, n.x, n.y, n.maxWidth)) : (e.fillStyle = t.fillStyle, e.fillText(n.text, n.x, n.y, n.maxWidth)), e.restore();
1344
1344
  }
1345
1345
  }
1346
- function _e(e, t) {
1347
- return new he(e, t);
1346
+ function ye(e, t) {
1347
+ return new _e(e, t);
1348
1348
  }
1349
1349
  //#endregion
1350
1350
  //#region src/webgl/shaders.ts
1351
- var U = `#version 300 es
1351
+ var H = `#version 300 es
1352
1352
  precision highp float;
1353
1353
  uniform vec2 u_canvas;
1354
1354
  uniform float u_dpr;
@@ -1390,7 +1390,7 @@ vec2 corner(int k) {
1390
1390
 
1391
1391
  // Nothing to draw: every vertex at one point off the canvas.
1392
1392
  const vec4 NOWHERE = vec4(-2.0, -2.0, 0.0, 1.0);
1393
- `, ve = `${U}
1393
+ `, be = `${H}
1394
1394
  in vec4 a_ohlc;
1395
1395
  in vec2 a_vd;
1396
1396
  uniform float u_x0;
@@ -1431,7 +1431,7 @@ void main() {
1431
1431
  }
1432
1432
  gl_Position = toClip(vec2(left + cr.x * width, top + cr.y * height));
1433
1433
  }
1434
- `, ye = `${U}
1434
+ `, xe = `${H}
1435
1435
  in vec4 a_ohlc;
1436
1436
  in vec2 a_vd;
1437
1437
  uniform float u_x0;
@@ -1453,7 +1453,7 @@ void main() {
1453
1453
  v_color = a_vd.y > 0.5 ? u_volUp : u_volDown;
1454
1454
  gl_Position = toClip(vec2(left + cr.x * u_body, top + cr.y * (bottom - top)));
1455
1455
  }
1456
- `, be = `${U}
1456
+ `, Se = `${H}
1457
1457
  in vec4 a_col;
1458
1458
  in float a_up;
1459
1459
  uniform vec4 u_upBody;
@@ -1468,7 +1468,7 @@ void main() {
1468
1468
  v_color = a_up > 0.5 ? u_upBody : u_downBody;
1469
1469
  gl_Position = toClip(vec2(left + cr.x * width, min(t, b) + cr.y * max(abs(b - t), 1.0)));
1470
1470
  }
1471
- `, xe = `${U}
1471
+ `, Ce = `${H}
1472
1472
  in vec4 a_col;
1473
1473
  in float a_up;
1474
1474
  uniform float u_volBottom;
@@ -1486,7 +1486,7 @@ void main() {
1486
1486
  v_color = a_up > 0.5 ? u_volUp : u_volDown;
1487
1487
  gl_Position = toClip(vec2(left + cr.x * width, top + cr.y * (bottom - top)));
1488
1488
  }
1489
- `, Se = `${U}
1489
+ `, we = `${H}
1490
1490
  in vec4 a_rect;
1491
1491
  in vec4 a_color;
1492
1492
  in vec2 a_dash;
@@ -1500,7 +1500,7 @@ void main() {
1500
1500
  v_color = a_color;
1501
1501
  gl_Position = toClip(mix(floor(v_rect.xy), ceil(v_rect.zw), cr));
1502
1502
  }
1503
- `, Ce = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform int u_union;\nin vec4 v_color;\nflat in vec4 v_rect;\nflat in vec2 v_dash;\nout vec4 outColor;\n\n// The share of rows [y, y + 1] inside the rectangle and, dashed, on a dash.\nfloat rows(float y) {\n float lo = max(y, v_rect.y);\n float hi = min(y + 1.0, v_rect.w);\n if (hi <= lo) return 0.0;\n if (v_dash.x <= 0.0) return hi - lo;\n // A dash period is longer than a device pixel, so the row meets the dash\n // of the period it starts in and the next (a third to spare).\n float period = v_dash.x + v_dash.y;\n float first = v_rect.y + floor((lo - v_rect.y) / period) * period;\n float on = 0.0;\n for (int i = 0; i < 3; i++) {\n float start = first + float(i) * period;\n on += max(0.0, min(hi, start + v_dash.x) - max(lo, start));\n }\n return on;\n}\n\nvoid main() {\n // This pixel's top-left corner in device pixels, y down.\n vec2 p = vec2(floor(gl_FragCoord.x), u_canvas.y - floor(gl_FragCoord.y) - 1.0);\n float coverage = clamp(min(p.x + 1.0, v_rect.z) - max(p.x, v_rect.x), 0.0, 1.0) * rows(p.y);\n outColor = u_union == 1 ? vec4(v_color.rgb * coverage, coverage) : v_color * coverage;\n}\n", W = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform vec4 u_clip;\nin vec4 v_color;\nout vec4 outColor;\n\nvoid main() {\n vec2 p = vec2(floor(gl_FragCoord.x), u_canvas.y - floor(gl_FragCoord.y) - 1.0);\n vec2 c = clamp(min(p + 1.0, u_clip.zw) - max(p, u_clip.xy), 0.0, 1.0);\n outColor = v_color * (c.x * c.y);\n}\n", G = 24, K = 5, q = K * 4, J = 10, Y = J * 4, X = [
1503
+ `, Te = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform int u_union;\nin vec4 v_color;\nflat in vec4 v_rect;\nflat in vec2 v_dash;\nout vec4 outColor;\n\n// The share of rows [y, y + 1] inside the rectangle and, dashed, on a dash.\nfloat rows(float y) {\n float lo = max(y, v_rect.y);\n float hi = min(y + 1.0, v_rect.w);\n if (hi <= lo) return 0.0;\n if (v_dash.x <= 0.0) return hi - lo;\n // A dash period is longer than a device pixel, so the row meets the dash\n // of the period it starts in and the next (a third to spare).\n float period = v_dash.x + v_dash.y;\n float first = v_rect.y + floor((lo - v_rect.y) / period) * period;\n float on = 0.0;\n for (int i = 0; i < 3; i++) {\n float start = first + float(i) * period;\n on += max(0.0, min(hi, start + v_dash.x) - max(lo, start));\n }\n return on;\n}\n\nvoid main() {\n // This pixel's top-left corner in device pixels, y down.\n vec2 p = vec2(floor(gl_FragCoord.x), u_canvas.y - floor(gl_FragCoord.y) - 1.0);\n float coverage = clamp(min(p.x + 1.0, v_rect.z) - max(p.x, v_rect.x), 0.0, 1.0) * rows(p.y);\n outColor = u_union == 1 ? vec4(v_color.rgb * coverage, coverage) : v_color * coverage;\n}\n", U = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform vec4 u_clip;\nin vec4 v_color;\nout vec4 outColor;\n\nvoid main() {\n vec2 p = vec2(floor(gl_FragCoord.x), u_canvas.y - floor(gl_FragCoord.y) - 1.0);\n vec2 c = clamp(min(p + 1.0, u_clip.zw) - max(p, u_clip.xy), 0.0, 1.0);\n outColor = v_color * (c.x * c.y);\n}\n", W = 24, G = 5, K = G * 4, q = 10, J = q * 4, Y = () => {}, X = [
1504
1504
  "a_ohlc",
1505
1505
  "a_vd",
1506
1506
  "a_col",
@@ -1508,7 +1508,7 @@ void main() {
1508
1508
  "a_rect",
1509
1509
  "a_color",
1510
1510
  "a_dash"
1511
- ], we = class t {
1511
+ ], Ee = class t {
1512
1512
  label;
1513
1513
  gl;
1514
1514
  kit;
@@ -1521,10 +1521,10 @@ void main() {
1521
1521
  seriesBuffer;
1522
1522
  columnBuffer;
1523
1523
  rectBuffer;
1524
- uploads = new s();
1524
+ uploads = new c();
1525
1525
  gpuFloats = 0;
1526
- columns = new Float32Array(4096 * K);
1527
- rectValues = new Float32Array(64 * J);
1526
+ columns = new Float32Array(4096 * G);
1527
+ rectValues = new Float32Array(64 * q);
1528
1528
  clip = [
1529
1529
  0,
1530
1530
  0,
@@ -1533,6 +1533,8 @@ void main() {
1533
1533
  ];
1534
1534
  lost = !1;
1535
1535
  lostCallback = null;
1536
+ restoredCallback = null;
1537
+ release = Y;
1536
1538
  static create(e = {}) {
1537
1539
  if (typeof document > "u") return null;
1538
1540
  let n = document.createElement("canvas"), r = null;
@@ -1551,17 +1553,33 @@ void main() {
1551
1553
  }
1552
1554
  if (!r) return null;
1553
1555
  try {
1554
- return new t(n, r);
1556
+ let i = new t(n, r);
1557
+ return i.release = e.release ?? Y, i;
1555
1558
  } catch (e) {
1556
1559
  return $(e), Q(r), null;
1557
1560
  }
1558
1561
  }
1559
1562
  constructor(e, t) {
1560
- this.canvas = e, this.gl = t, this.kit = new ee(t);
1561
- let n = t.getExtension("WEBGL_debug_renderer_info");
1562
- this.label = String(n ? t.getParameter(n.UNMASKED_RENDERER_WEBGL) : t.getParameter(t.RENDERER));
1563
- let r = this.kit;
1564
- this.candleBars = r.program(ve, W, X), this.volumeBars = r.program(ye, W, X), this.candleColumns = r.program(be, W, X), this.volumeColumns = r.program(xe, W, X), this.rects = r.program(Se, Ce, X), this.seriesBuffer = r.buffer(), this.columnBuffer = r.buffer(), this.rectBuffer = r.buffer(), this.drawer = new le(r), e.addEventListener("webglcontextlost", this.handleLost);
1563
+ this.canvas = e, this.gl = t, this.kit = new te(t), this.label = De(t), this.build(), e.addEventListener("webglcontextlost", this.handleLost), e.addEventListener("webglcontextrestored", this.handleRestored);
1564
+ }
1565
+ build() {
1566
+ let e = this.kit;
1567
+ Object.assign(this, {
1568
+ candleBars: e.program(be, U, X),
1569
+ volumeBars: e.program(xe, U, X),
1570
+ candleColumns: e.program(Se, U, X),
1571
+ volumeColumns: e.program(Ce, U, X),
1572
+ rects: e.program(we, Te, X),
1573
+ seriesBuffer: e.buffer(),
1574
+ columnBuffer: e.buffer(),
1575
+ rectBuffer: e.buffer(),
1576
+ drawer: new ue(e),
1577
+ uploads: new c(),
1578
+ gpuFloats: 0
1579
+ });
1580
+ }
1581
+ onRestored(e) {
1582
+ this.restoredCallback = e;
1565
1583
  }
1566
1584
  onLost(e) {
1567
1585
  this.lostCallback = e, (this.lost || this.gl.isContextLost()) && (this.lost = !0, queueMicrotask(() => {
@@ -1569,7 +1587,7 @@ void main() {
1569
1587
  }));
1570
1588
  }
1571
1589
  recorder(e, t) {
1572
- return _e(e, t);
1590
+ return ye(e, t);
1573
1591
  }
1574
1592
  render(e) {
1575
1593
  let t = this.gl;
@@ -1589,11 +1607,11 @@ void main() {
1589
1607
  };
1590
1608
  return t.viewport(0, 0, this.canvas.width, this.canvas.height), t.disable(t.SCISSOR_TEST), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.enable(t.BLEND), e.background && this.drawBackground(e, e.background), r && this.drawRecorded(e, r), this.drawSeries(e), n && this.drawRecorded(e, n), i;
1591
1609
  }
1592
- drawSeries(t) {
1593
- let n = this.gl, { data: r, viewport: i, dpr: a } = t;
1594
- if (r.length === 0 || !t.candles && !t.volume) return;
1595
- this.syncSeries(t);
1596
- let o = Math.max(0, i.visibleRange.from), s = Math.min(i.visibleRange.to, r.length - 1);
1610
+ drawSeries(e) {
1611
+ let t = this.gl, { data: n, viewport: i, dpr: a } = e;
1612
+ if (n.length === 0 || !e.candles && !e.volume) return;
1613
+ this.syncSeries(e);
1614
+ let o = Math.max(0, i.visibleRange.from), s = Math.min(i.visibleRange.to, n.length - 1);
1597
1615
  if (s < o) return;
1598
1616
  let { chartRect: c } = i;
1599
1617
  this.clip = [
@@ -1603,11 +1621,11 @@ void main() {
1603
1621
  (c.y + c.height) * a
1604
1622
  ];
1605
1623
  let l = Math.floor(this.clip[0]), u = Math.floor(this.clip[1]), d = Math.ceil(this.clip[2]) - l, f = Math.ceil(this.clip[3]) - u;
1606
- n.enable(n.SCISSOR_TEST), n.scissor(l, this.canvas.height - u - f, Math.max(0, d), Math.max(0, f)), n.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA);
1607
- let p = e(i), m = p ? this.buildColumns(t, o, s) : 0;
1608
- t.volume && this.drawVolume(t, o, s, p, m);
1624
+ t.enable(t.SCISSOR_TEST), t.scissor(l, this.canvas.height - u - f, Math.max(0, d), Math.max(0, f)), t.blendFunc(t.ONE, t.ONE_MINUS_SRC_ALPHA);
1625
+ let p = r(i), m = p ? this.buildColumns(e, o, s) : 0;
1626
+ e.volume && this.drawVolume(e, o, s, p, m);
1609
1627
  let { min: h, max: g } = i.priceRange;
1610
- t.candles && g - h !== 0 && this.drawCandles(t, o, s, p, m), n.disable(n.SCISSOR_TEST);
1628
+ e.candles && g - h !== 0 && this.drawCandles(e, o, s, p, m), t.disable(t.SCISSOR_TEST);
1611
1629
  }
1612
1630
  drawRecorded(e, t) {
1613
1631
  t.commands.length !== 0 && this.drawer.draw(t.commands, this.canvas.width, this.canvas.height, (t, n) => this.drawRecordedRects(e, t, n));
@@ -1617,9 +1635,10 @@ void main() {
1617
1635
  this.kit.float(i, "u_dpr", 1), this.kit.int(i, "u_union", 0), r.bindBuffer(r.ARRAY_BUFFER, this.rectBuffer), r.bufferData(r.ARRAY_BUFFER, t, r.STREAM_DRAW), this.bindRects(i, 0), r.drawArraysInstanced(r.TRIANGLES, 0, 6, n);
1618
1636
  }
1619
1637
  destroy() {
1620
- this.canvas.removeEventListener("webglcontextlost", this.handleLost), this.lostCallback = null;
1638
+ this.canvas.removeEventListener("webglcontextlost", this.handleLost), this.canvas.removeEventListener("webglcontextrestored", this.handleRestored), this.lostCallback = null, this.restoredCallback = null, this.release(), this.release = Y;
1621
1639
  let e = this.gl;
1622
- if (!e.isContextLost()) {
1640
+ if (e.isContextLost()) this.canvas.addEventListener("webglcontextrestored", () => Q(e), { once: !0 });
1641
+ else {
1623
1642
  for (let e of [
1624
1643
  this.candleBars,
1625
1644
  this.volumeBars,
@@ -1632,85 +1651,100 @@ void main() {
1632
1651
  this.canvas.remove();
1633
1652
  }
1634
1653
  handleLost = (e) => {
1635
- e.preventDefault(), !this.lost && (this.lost = !0, this.lostCallback?.());
1654
+ e.preventDefault(), !this.lost && (this.lost = !0, this.release(), this.release = Y, this.lostCallback?.());
1655
+ };
1656
+ handleRestored = () => {
1657
+ if (!this.lost || this.gl.isContextLost()) return;
1658
+ let e = i();
1659
+ if (!e) {
1660
+ Q(this.gl);
1661
+ return;
1662
+ }
1663
+ try {
1664
+ this.build();
1665
+ } catch (t) {
1666
+ e(), $(t), Q(this.gl);
1667
+ return;
1668
+ }
1669
+ this.release = e, this.lost = !1, this.restoredCallback?.();
1636
1670
  };
1637
1671
  syncSeries(e) {
1638
1672
  let t = this.gl, n = this.uploads.sync(e.data), r = this.uploads.values;
1639
- t.bindBuffer(t.ARRAY_BUFFER, this.seriesBuffer), n.full || r.length !== this.gpuFloats ? (t.bufferData(t.ARRAY_BUFFER, r, t.DYNAMIC_DRAW), this.gpuFloats = r.length) : n.to > n.from && t.bufferSubData(t.ARRAY_BUFFER, n.from * G, r, n.from * 6, (n.to - n.from) * 6);
1673
+ t.bindBuffer(t.ARRAY_BUFFER, this.seriesBuffer), n.full || r.length !== this.gpuFloats ? (t.bufferData(t.ARRAY_BUFFER, r, t.DYNAMIC_DRAW), this.gpuFloats = r.length) : n.to > n.from && t.bufferSubData(t.ARRAY_BUFFER, n.from * W, r, n.from * 6, (n.to - n.from) * 6);
1640
1674
  }
1641
- buildColumns(e, t, r) {
1642
- let { viewport: i, data: a } = e, o = i.barWidth + i.barSpacing, s = -i.offset + i.chartRect.x + i.barWidth / 2, c = this.uploads.base, l = 0;
1643
- n(a, t, r, (e) => e * o + s, (e) => {
1644
- if ((l + 1) * K > this.columns.length) {
1675
+ buildColumns(t, n, r) {
1676
+ let { viewport: i, data: a } = t, o = i.barWidth + i.barSpacing, s = -i.offset + i.chartRect.x + i.barWidth / 2, c = this.uploads.base, l = 0;
1677
+ e(a, n, r, (e) => e * o + s, (e) => {
1678
+ if ((l + 1) * G > this.columns.length) {
1645
1679
  let e = new Float32Array(this.columns.length * 2);
1646
1680
  e.set(this.columns), this.columns = e;
1647
1681
  }
1648
- let t = l * K;
1682
+ let t = l * G;
1649
1683
  this.columns[t] = e.x, this.columns[t + 1] = e.high - c, this.columns[t + 2] = e.low - c, this.columns[t + 3] = e.volume, this.columns[t + 4] = +(e.close >= e.open), l++;
1650
1684
  });
1651
1685
  let u = this.gl;
1652
- return u.bindBuffer(u.ARRAY_BUFFER, this.columnBuffer), u.bufferData(u.ARRAY_BUFFER, this.columns.subarray(0, l * K), u.STREAM_DRAW), l;
1686
+ return u.bindBuffer(u.ARRAY_BUFFER, this.columnBuffer), u.bufferData(u.ARRAY_BUFFER, this.columns.subarray(0, l * G), u.STREAM_DRAW), l;
1653
1687
  }
1654
1688
  drawBackground(e, t) {
1655
- let { viewport: n, theme: r } = e, a = t.grid ? i(n) : {
1689
+ let { viewport: n, theme: r } = e, i = t.grid ? a(n) : {
1656
1690
  horizontal: [],
1657
1691
  vertical: []
1658
- }, o = a.horizontal.length + a.vertical.length, s = o + t.rects.length;
1692
+ }, o = i.horizontal.length + i.vertical.length, s = o + t.rects.length;
1659
1693
  if (s === 0) return;
1660
- this.rectValues.length < s * J && (this.rectValues = new Float32Array(s * J * 2));
1694
+ this.rectValues.length < s * q && (this.rectValues = new Float32Array(s * q * 2));
1661
1695
  let c = this.rectValues, l = 0, u = (e, t, n, r, i, a, o) => {
1662
1696
  c[l++] = e, c[l++] = t, c[l++] = n, c[l++] = r;
1663
1697
  for (let e = 0; e < 4; e++) c[l++] = i[e] * a;
1664
1698
  c[l++] = o ? o[0] : 0, c[l++] = o ? o[1] : 0;
1665
- }, d = _(g(r.grid)), { chartRect: f } = n;
1666
- for (let e of a.horizontal) u(f.x, e - .5, f.x + f.width, e + .5, d, 1);
1667
- for (let e of a.vertical) u(e - .5, f.y, e + .5, f.y + f.height, d, 1);
1699
+ }, d = v(_(r.grid)), { chartRect: f } = n;
1700
+ for (let e of i.horizontal) u(f.x, e - .5, f.x + f.width, e + .5, d, 1);
1701
+ for (let e of i.vertical) u(e - .5, f.y, e + .5, f.y + f.height, d, 1);
1668
1702
  let p = "", m = d;
1669
- for (let e of t.rects) e.color !== p && (p = e.color, m = _(g(e.color))), u(e.x, e.y, e.x + e.width, e.y + e.height, m, e.alpha, e.dash);
1670
- let h = this.gl, v = this.use(this.rects, e);
1671
- h.bindBuffer(h.ARRAY_BUFFER, this.rectBuffer), h.bufferData(h.ARRAY_BUFFER, c.subarray(0, l), h.STREAM_DRAW), o > 0 && (h.uniform1i(this.loc(v, "u_union"), 1), h.blendColor(0, 0, 0, d[3]), h.blendFuncSeparate(h.ONE, h.ONE_MINUS_SRC_ALPHA, h.CONSTANT_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.bindRects(v, 0), h.drawArraysInstanced(h.TRIANGLES, 0, 6, o)), t.rects.length > 0 && (h.uniform1i(this.loc(v, "u_union"), 0), h.blendFunc(h.ONE, h.ONE_MINUS_SRC_ALPHA), this.bindRects(v, o), h.drawArraysInstanced(h.TRIANGLES, 0, 6, t.rects.length));
1703
+ for (let e of t.rects) e.color !== p && (p = e.color, m = v(_(e.color))), u(e.x, e.y, e.x + e.width, e.y + e.height, m, e.alpha, e.dash);
1704
+ let h = this.gl, g = this.use(this.rects, e);
1705
+ h.bindBuffer(h.ARRAY_BUFFER, this.rectBuffer), h.bufferData(h.ARRAY_BUFFER, c.subarray(0, l), h.STREAM_DRAW), o > 0 && (h.uniform1i(this.loc(g, "u_union"), 1), h.blendColor(0, 0, 0, d[3]), h.blendFuncSeparate(h.ONE, h.ONE_MINUS_SRC_ALPHA, h.CONSTANT_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.bindRects(g, 0), h.drawArraysInstanced(h.TRIANGLES, 0, 6, o)), t.rects.length > 0 && (h.uniform1i(this.loc(g, "u_union"), 0), h.blendFunc(h.ONE, h.ONE_MINUS_SRC_ALPHA), this.bindRects(g, o), h.drawArraysInstanced(h.TRIANGLES, 0, 6, t.rects.length));
1672
1706
  }
1673
1707
  drawCandles(e, t, n, r, i) {
1674
- let { theme: a, viewport: o, dpr: s } = e, c = _(g(a.candleUp)), l = _(g(a.candleDown));
1708
+ let { theme: a, viewport: o, dpr: s } = e, c = v(_(a.candleUp)), l = v(_(a.candleDown));
1675
1709
  if (r) {
1676
1710
  let t = this.use(this.candleColumns, e);
1677
1711
  this.vec4(t, "u_upBody", c), this.vec4(t, "u_downBody", l), this.bindColumns(t), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6, i);
1678
1712
  return;
1679
1713
  }
1680
1714
  let u = this.use(this.candleBars, e);
1681
- this.barUniforms(u, o, t, s), this.vec4(u, "u_upBody", c), this.vec4(u, "u_downBody", l), this.vec4(u, "u_upWick", _(g(a.candleUpWick))), this.vec4(u, "u_downWick", _(g(a.candleDownWick))), this.bindBars(u, t), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 12, n - t + 1);
1715
+ this.barUniforms(u, o, t, s), this.vec4(u, "u_upBody", c), this.vec4(u, "u_downBody", l), this.vec4(u, "u_upWick", v(_(a.candleUpWick))), this.vec4(u, "u_downWick", v(_(a.candleDownWick))), this.bindBars(u, t), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 12, n - t + 1);
1682
1716
  }
1683
1717
  drawVolume(e, t, n, r, i) {
1684
- let { data: o, viewport: s, theme: c, dpr: l } = e, u = 0;
1685
- for (let e = t; e <= n; e++) o[e].volume > u && (u = o[e].volume);
1718
+ let { data: a, viewport: s, theme: c, dpr: l } = e, u = 0;
1719
+ for (let e = t; e <= n; e++) a[e].volume > u && (u = a[e].volume);
1686
1720
  if (u === 0) return;
1687
- let { chartRect: d } = s, f = a(c), p = this.use(r ? this.volumeColumns : this.volumeBars, e);
1688
- if (this.float(p, "u_volBottom", d.y + d.height), this.float(p, "u_volScale", d.height * (e.volume?.heightRatio ?? .15) / u), this.vec4(p, "u_volUp", _(g(f.up))), this.vec4(p, "u_volDown", _(g(f.down))), r) {
1721
+ let { chartRect: d } = s, f = o(c), p = this.use(r ? this.volumeColumns : this.volumeBars, e);
1722
+ if (this.float(p, "u_volBottom", d.y + d.height), this.float(p, "u_volScale", d.height * (e.volume?.heightRatio ?? .15) / u), this.vec4(p, "u_volUp", v(_(f.up))), this.vec4(p, "u_volDown", v(_(f.down))), r) {
1689
1723
  this.bindColumns(p), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6, i);
1690
1724
  return;
1691
1725
  }
1692
1726
  this.barUniforms(p, s, t, l), this.bindBars(p, t), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6, n - t + 1);
1693
1727
  }
1694
- barUniforms(e, t, n, i) {
1695
- let a = t.barWidth + t.barSpacing, o = -t.offset + t.chartRect.x + t.barWidth / 2, { body: s, wick: c } = r(t.barWidth, i);
1696
- this.float(e, "u_x0", n * a + o), this.float(e, "u_unit", a), this.float(e, "u_wick", c), this.float(e, "u_body", s);
1728
+ barUniforms(e, t, r, i) {
1729
+ let a = t.barWidth + t.barSpacing, o = -t.offset + t.chartRect.x + t.barWidth / 2, { body: s, wick: c } = n(t.barWidth, i);
1730
+ this.float(e, "u_x0", r * a + o), this.float(e, "u_unit", a), this.float(e, "u_wick", c), this.float(e, "u_body", s);
1697
1731
  }
1698
1732
  use(e, t) {
1699
1733
  let n = this.gl;
1700
1734
  this.kit.use(e), n.uniform2f(this.loc(e, "u_canvas"), this.canvas.width, this.canvas.height), this.vec4(e, "u_clip", this.clip), this.float(e, "u_dpr", t.dpr);
1701
- let r = v(t.viewport, this.uploads.base);
1735
+ let r = ee(t.viewport, this.uploads.base);
1702
1736
  return n.uniform1i(this.loc(e, "u_log"), r.log), n.uniform1i(this.loc(e, "u_invert"), r.invert), this.float(e, "u_yA", r.yA), this.float(e, "u_yB", r.yB), this.float(e, "u_logOffset", r.logOffset), this.float(e, "u_min", r.min), this.float(e, "u_logFloor", r.logFloor), this.float(e, "u_logK", r.logK), this.float(e, "u_top", r.top), this.float(e, "u_bottom", r.bottom), e;
1703
1737
  }
1704
1738
  bindBars(e, t) {
1705
1739
  let n = this.gl;
1706
- n.bindBuffer(n.ARRAY_BUFFER, this.seriesBuffer), this.attrib(e, "a_ohlc", 4, G, t * G), this.attrib(e, "a_vd", 2, G, t * G + 16);
1740
+ n.bindBuffer(n.ARRAY_BUFFER, this.seriesBuffer), this.attrib(e, "a_ohlc", 4, W, t * W), this.attrib(e, "a_vd", 2, W, t * W + 16);
1707
1741
  }
1708
1742
  bindRects(e, t) {
1709
- this.attrib(e, "a_rect", 4, Y, t * Y), this.attrib(e, "a_color", 4, Y, t * Y + 16), this.attrib(e, "a_dash", 2, Y, t * Y + 32);
1743
+ this.attrib(e, "a_rect", 4, J, t * J), this.attrib(e, "a_color", 4, J, t * J + 16), this.attrib(e, "a_dash", 2, J, t * J + 32);
1710
1744
  }
1711
1745
  bindColumns(e) {
1712
1746
  let t = this.gl;
1713
- t.bindBuffer(t.ARRAY_BUFFER, this.columnBuffer), this.attrib(e, "a_col", 4, q, 0), this.attrib(e, "a_up", 1, q, 16);
1747
+ t.bindBuffer(t.ARRAY_BUFFER, this.columnBuffer), this.attrib(e, "a_col", 4, K, 0), this.attrib(e, "a_up", 1, K, 16);
1714
1748
  }
1715
1749
  attrib(e, t, n, r, i) {
1716
1750
  this.kit.attrib(e, t, n, r, i);
@@ -1728,6 +1762,12 @@ void main() {
1728
1762
  function Z(e) {
1729
1763
  return typeof e == "object" && !!e && Array.isArray(e.commands);
1730
1764
  }
1765
+ function De(e) {
1766
+ let t = String(e.getParameter(e.RENDERER));
1767
+ if (t && t !== "WebKit WebGL") return t;
1768
+ let n = e.getExtension("WEBGL_debug_renderer_info");
1769
+ return n ? String(e.getParameter(n.UNMASKED_RENDERER_WEBGL)) : t;
1770
+ }
1731
1771
  function Q(e) {
1732
1772
  e.getExtension("WEBGL_lose_context")?.loseContext();
1733
1773
  }
@@ -1735,6 +1775,6 @@ function $(e) {
1735
1775
  console.warn("TradeCanvas: WebGL renderer unavailable, drawing with Canvas 2D.", e);
1736
1776
  }
1737
1777
  //#endregion
1738
- export { we as WebGLSeriesRenderer };
1778
+ export { Ee as WebGLSeriesRenderer };
1739
1779
 
1740
- //# sourceMappingURL=WebGLSeriesRenderer-DVJBHdfm.js.map
1780
+ //# sourceMappingURL=WebGLSeriesRenderer-CLVnGxIS.js.map