@tradecanvas/core 0.5.0 → 0.6.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 (68) hide show
  1. package/README.md +22 -6
  2. package/dist/charts/transforms/index.d.ts +2 -0
  3. package/dist/charts/transforms/index.d.ts.map +1 -1
  4. package/dist/charts/transforms/rangeBars.d.ts +18 -0
  5. package/dist/charts/transforms/rangeBars.d.ts.map +1 -0
  6. package/dist/drawings/tools/TextAnnotation.d.ts +5 -0
  7. package/dist/drawings/tools/TextAnnotation.d.ts.map +1 -1
  8. package/dist/features/ChartState.d.ts +6 -1
  9. package/dist/features/ChartState.d.ts.map +1 -1
  10. package/dist/index.cjs +3 -3
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.js +1067 -327
  13. package/dist/index.js.map +1 -1
  14. package/dist/indicators/index.d.ts +12 -0
  15. package/dist/indicators/index.d.ts.map +1 -1
  16. package/dist/indicators/overlay/AnchoredVWAP.d.ts +20 -0
  17. package/dist/indicators/overlay/AnchoredVWAP.d.ts.map +1 -0
  18. package/dist/indicators/overlay/BollingerBands.d.ts.map +1 -1
  19. package/dist/indicators/overlay/DonchianChannel.d.ts.map +1 -1
  20. package/dist/indicators/overlay/EMA.d.ts.map +1 -1
  21. package/dist/indicators/overlay/HullMA.d.ts +19 -0
  22. package/dist/indicators/overlay/HullMA.d.ts.map +1 -0
  23. package/dist/indicators/overlay/Ichimoku.d.ts.map +1 -1
  24. package/dist/indicators/overlay/KeltnerChannel.d.ts.map +1 -1
  25. package/dist/indicators/overlay/LinearRegressionChannel.d.ts +20 -0
  26. package/dist/indicators/overlay/LinearRegressionChannel.d.ts.map +1 -0
  27. package/dist/indicators/overlay/ParabolicSAR.d.ts.map +1 -1
  28. package/dist/indicators/overlay/PivotPoints.d.ts +15 -0
  29. package/dist/indicators/overlay/PivotPoints.d.ts.map +1 -0
  30. package/dist/indicators/overlay/SMA.d.ts.map +1 -1
  31. package/dist/indicators/overlay/Supertrend.d.ts.map +1 -1
  32. package/dist/indicators/overlay/ZigZag.d.ts +20 -0
  33. package/dist/indicators/overlay/ZigZag.d.ts.map +1 -0
  34. package/dist/indicators/panel/ADX.d.ts.map +1 -1
  35. package/dist/indicators/panel/ATR.d.ts.map +1 -1
  36. package/dist/indicators/panel/Aroon.d.ts.map +1 -1
  37. package/dist/indicators/panel/AwesomeOscillator.d.ts +16 -0
  38. package/dist/indicators/panel/AwesomeOscillator.d.ts.map +1 -0
  39. package/dist/indicators/panel/CCI.d.ts.map +1 -1
  40. package/dist/indicators/panel/CMF.d.ts.map +1 -1
  41. package/dist/indicators/panel/ChaikinOscillator.d.ts +21 -0
  42. package/dist/indicators/panel/ChaikinOscillator.d.ts.map +1 -0
  43. package/dist/indicators/panel/MACD.d.ts.map +1 -1
  44. package/dist/indicators/panel/MFI.d.ts.map +1 -1
  45. package/dist/indicators/panel/ROC.d.ts.map +1 -1
  46. package/dist/indicators/panel/RSI.d.ts.map +1 -1
  47. package/dist/indicators/panel/StdDev.d.ts.map +1 -1
  48. package/dist/indicators/panel/Stochastic.d.ts.map +1 -1
  49. package/dist/indicators/panel/TSI.d.ts.map +1 -1
  50. package/dist/indicators/panel/VROC.d.ts.map +1 -1
  51. package/dist/indicators/panel/VolumeProfile.d.ts.map +1 -1
  52. package/dist/indicators/panel/WilliamsR.d.ts.map +1 -1
  53. package/dist/indicators/params.d.ts +10 -0
  54. package/dist/indicators/params.d.ts.map +1 -0
  55. package/dist/indicators/registry.d.ts.map +1 -1
  56. package/dist/indicators/worker/IndicatorWorkerHost.d.ts +49 -0
  57. package/dist/indicators/worker/IndicatorWorkerHost.d.ts.map +1 -0
  58. package/dist/indicators/worker/indicator.worker.d.ts +2 -0
  59. package/dist/indicators/worker/indicator.worker.d.ts.map +1 -0
  60. package/dist/indicators/worker/messages.d.ts +27 -0
  61. package/dist/indicators/worker/messages.d.ts.map +1 -0
  62. package/dist/realtime/adapters/BinanceAdapter.d.ts.map +1 -1
  63. package/dist/realtime/adapters/binanceTypes.d.ts +58 -0
  64. package/dist/realtime/adapters/binanceTypes.d.ts.map +1 -0
  65. package/dist/trading/PositionRenderer.d.ts.map +1 -1
  66. package/dist/trading/positionFormat.d.ts +15 -0
  67. package/dist/trading/positionFormat.d.ts.map +1 -0
  68. package/package.json +8 -3
package/dist/index.js CHANGED
@@ -317,7 +317,9 @@ var D = class {
317
317
  maxBarWidth;
318
318
  rightMarginBars;
319
319
  constructor(e, r, i = 2, a = 30, o = 5) {
320
- this.minBarWidth = i, this.maxBarWidth = a, this.rightMarginBars = o, this.state = {
320
+ this.minBarWidth = i, this.maxBarWidth = a, this.rightMarginBars = o;
321
+ let s = this.computeChartRect(e, r);
322
+ this.state = {
321
323
  visibleRange: {
322
324
  from: 0,
323
325
  to: 0
@@ -329,7 +331,7 @@ var D = class {
329
331
  barWidth: n,
330
332
  barSpacing: t,
331
333
  offset: 0,
332
- chartRect: this.computeChartRect(e, r)
334
+ chartRect: s
333
335
  };
334
336
  }
335
337
  getState() {
@@ -817,6 +819,37 @@ function he(e, t, n = 3) {
817
819
  }), r;
818
820
  }
819
821
  //#endregion
822
+ //#region src/charts/transforms/rangeBars.ts
823
+ function ge(e, t) {
824
+ if (e.length === 0 || t.rangeSize <= 0) return [];
825
+ let n = [], r = e[0].time, i = e[0].open, a = i, o = i, s = 0, c = (e, c) => {
826
+ for (e > a && (a = e), e < o && (o = e), s += c; a - o >= t.rangeSize;) {
827
+ let c = e >= i, l = c ? i + t.rangeSize : i - t.rangeSize;
828
+ n.push({
829
+ time: r++,
830
+ open: i,
831
+ high: c ? l : i,
832
+ low: c ? i : l,
833
+ close: l,
834
+ volume: s
835
+ }), i = l, a = l, o = l, s = 0;
836
+ }
837
+ };
838
+ for (let t of e) {
839
+ let e = t.close >= t.open ? [
840
+ t.low,
841
+ t.high,
842
+ t.close
843
+ ] : [
844
+ t.high,
845
+ t.low,
846
+ t.close
847
+ ], n = t.volume / e.length;
848
+ for (let t of e) c(t, n);
849
+ }
850
+ return n;
851
+ }
852
+ //#endregion
820
853
  //#region src/indicators/IndicatorBase.ts
821
854
  var j = class {
822
855
  drawLine(e, t, n, r) {
@@ -853,7 +886,7 @@ var j = class {
853
886
  }
854
887
  return i;
855
888
  }
856
- }, ge = 1, _e = class {
889
+ }, _e = 1, ve = class {
857
890
  registry = /* @__PURE__ */ new Map();
858
891
  instances = /* @__PURE__ */ new Map();
859
892
  register(e) {
@@ -865,7 +898,7 @@ var j = class {
865
898
  addIndicator(e, t = {}, n) {
866
899
  let r = this.registry.get(e);
867
900
  if (!r) throw Error(`Unknown indicator: ${e}`);
868
- let i = `tc_${e}_${ge++}`, a = {
901
+ let i = `tc_${e}_${_e++}`, a = {
869
902
  id: e,
870
903
  instanceId: i,
871
904
  params: {
@@ -957,7 +990,25 @@ var j = class {
957
990
  });
958
991
  return e;
959
992
  }
960
- }, ve = class extends j {
993
+ };
994
+ //#endregion
995
+ //#region src/indicators/params.ts
996
+ function M(e, t, n) {
997
+ let r = e.params[t];
998
+ if (typeof r == "number" && Number.isFinite(r)) return r;
999
+ if (typeof r == "string") {
1000
+ let e = Number(r);
1001
+ if (Number.isFinite(e)) return e;
1002
+ }
1003
+ return n;
1004
+ }
1005
+ function N(e, t, n, r = 1) {
1006
+ let i = M(e, t, n);
1007
+ return Math.max(r, Math.floor(i));
1008
+ }
1009
+ //#endregion
1010
+ //#region src/indicators/overlay/SMA.ts
1011
+ var ye = class extends j {
961
1012
  descriptor = {
962
1013
  id: "sma",
963
1014
  name: "Simple Moving Average",
@@ -965,7 +1016,7 @@ var j = class {
965
1016
  defaultConfig: { period: 20 }
966
1017
  };
967
1018
  calculate(e, t) {
968
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null), a = 0;
1019
+ let n = N(t, "period", 20, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null), a = 0;
969
1020
  for (let t = 0; t < e.length; t++) if (a += e[t].close, t >= n && (a -= e[t - n].close), t >= n - 1) {
970
1021
  let o = { value: a / n };
971
1022
  r.set(e[t].time, o), i[t] = o;
@@ -989,7 +1040,7 @@ var j = class {
989
1040
  }
990
1041
  e.stroke();
991
1042
  }
992
- }, ye = class extends j {
1043
+ }, P = class extends j {
993
1044
  descriptor = {
994
1045
  id: "ema",
995
1046
  name: "Exponential Moving Average",
@@ -997,7 +1048,7 @@ var j = class {
997
1048
  defaultConfig: { period: 20 }
998
1049
  };
999
1050
  calculate(e, t) {
1000
- let n = t.params.period, r = 2 / (n + 1), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null), o = 0;
1051
+ let n = N(t, "period", 20, 1), r = 2 / (n + 1), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null), o = 0;
1001
1052
  for (let t = 0; t < e.length; t++) {
1002
1053
  if (t < n - 1) {
1003
1054
  o += e[t].close;
@@ -1026,7 +1077,7 @@ var j = class {
1026
1077
  }
1027
1078
  e.stroke();
1028
1079
  }
1029
- }, be = class extends j {
1080
+ }, F = class extends j {
1030
1081
  descriptor = {
1031
1082
  id: "bb",
1032
1083
  name: "Bollinger Bands",
@@ -1037,7 +1088,7 @@ var j = class {
1037
1088
  }
1038
1089
  };
1039
1090
  calculate(e, t) {
1040
- let n = t.params.period, r = t.params.stdDev, i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null), o = 0, s = 0;
1091
+ let n = N(t, "period", 20, 1), r = M(t, "stdDev", 2), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null), o = 0, s = 0;
1041
1092
  for (let t = 0; t < e.length; t++) {
1042
1093
  let c = e[t].close;
1043
1094
  if (o += c, s += c * c, t >= n) {
@@ -1081,7 +1132,7 @@ var j = class {
1081
1132
  e.stroke();
1082
1133
  }
1083
1134
  }
1084
- }, xe = class extends j {
1135
+ }, be = class extends j {
1085
1136
  descriptor = {
1086
1137
  id: "vwap",
1087
1138
  name: "Volume Weighted Average Price",
@@ -1116,7 +1167,7 @@ var j = class {
1116
1167
  }
1117
1168
  e.stroke();
1118
1169
  }
1119
- }, Se = class extends j {
1170
+ }, xe = class extends j {
1120
1171
  descriptor = {
1121
1172
  id: "ichimoku",
1122
1173
  name: "Ichimoku Cloud",
@@ -1129,7 +1180,7 @@ var j = class {
1129
1180
  }
1130
1181
  };
1131
1182
  calculate(e, t) {
1132
- let n = t.params.tenkan, r = t.params.kijun, i = t.params.senkou, a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null), s = (t) => {
1183
+ let n = N(t, "tenkan", 9, 1), r = N(t, "kijun", 26, 1), i = N(t, "senkou", 52, 1), a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null), s = (t) => {
1133
1184
  let n = new Float64Array(e.length), r = new Float64Array(e.length);
1134
1185
  for (let i = 0; i < e.length; i++) {
1135
1186
  let a = -Infinity, o = Infinity, s = Math.max(0, i - t + 1);
@@ -1176,7 +1227,7 @@ var j = class {
1176
1227
  };
1177
1228
  x(c, l, u, r.colors[0], r.lineWidths[0]), x(d, f, p, r.colors[1] ?? "#FF9800", r.lineWidths[0]), x(m, h, g, r.colors[2] ?? "#26A69A", 1), x(v, y, b, r.colors[3] ?? "#EF5350", 1);
1178
1229
  }
1179
- }, Ce = class extends j {
1230
+ }, Se = class extends j {
1180
1231
  descriptor = {
1181
1232
  id: "psar",
1182
1233
  name: "Parabolic SAR",
@@ -1187,7 +1238,7 @@ var j = class {
1187
1238
  }
1188
1239
  };
1189
1240
  calculate(e, t) {
1190
- let n = t.params.step, r = t.params.max, i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
1241
+ let n = M(t, "step", .02), r = M(t, "max", .2), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
1191
1242
  if (e.length < 2) return {
1192
1243
  values: i,
1193
1244
  series: a
@@ -1222,7 +1273,7 @@ var j = class {
1222
1273
  e.beginPath(), e.arc(o, c, s, 0, Math.PI * 2), e.fillStyle = a.trend === 1 ? r.colors[0] : r.colors[1] ?? "#EF5350", e.fill();
1223
1274
  }
1224
1275
  }
1225
- }, we = class extends j {
1276
+ }, Ce = class extends j {
1226
1277
  descriptor = {
1227
1278
  id: "supertrend",
1228
1279
  name: "Supertrend",
@@ -1233,7 +1284,7 @@ var j = class {
1233
1284
  }
1234
1285
  };
1235
1286
  calculate(e, t) {
1236
- let n = t.params.period, r = t.params.multiplier, i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
1287
+ let n = N(t, "period", 10, 1), r = M(t, "multiplier", 3), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
1237
1288
  if (e.length < n) return {
1238
1289
  values: i,
1239
1290
  series: a
@@ -1270,7 +1321,7 @@ var j = class {
1270
1321
  d !== 0 && (e.beginPath(), e.strokeStyle = p === 1 ? s : c, e.lineWidth = r.lineWidths[0] + .5, e.moveTo(l, u), e.lineTo(o, f), e.stroke()), l = o, u = f, d = p;
1271
1322
  }
1272
1323
  }
1273
- }, Te = class extends j {
1324
+ }, we = class extends j {
1274
1325
  descriptor = {
1275
1326
  id: "keltner",
1276
1327
  name: "Keltner Channel",
@@ -1282,7 +1333,7 @@ var j = class {
1282
1333
  }
1283
1334
  };
1284
1335
  calculate(e, t) {
1285
- let n = t.params.emaPeriod, r = t.params.atrPeriod, i = t.params.multiplier, a = /* @__PURE__ */ new Map();
1336
+ let n = N(t, "emaPeriod", 20, 1), r = N(t, "atrPeriod", 10, 1), i = M(t, "multiplier", 1.5), a = /* @__PURE__ */ new Map();
1286
1337
  if (e.length < Math.max(n, r)) return { values: a };
1287
1338
  let o = 2 / (n + 1), s = e[0].close, c = [s];
1288
1339
  for (let t = 1; t < e.length; t++) s = (e[t].close - s) * o + s, c.push(s);
@@ -1327,7 +1378,7 @@ var j = class {
1327
1378
  }
1328
1379
  this.drawBand(e, s, l, _(r.colors[0], .08)), this.drawLine(e, s, r.colors[0], r.lineWidths[0]), this.drawLine(e, c, r.colors[1] ?? r.colors[0], r.lineWidths[0]), this.drawLine(e, l, r.colors[0], r.lineWidths[0]);
1329
1380
  }
1330
- }, Ee = class extends j {
1381
+ }, Te = class extends j {
1331
1382
  descriptor = {
1332
1383
  id: "donchian",
1333
1384
  name: "Donchian Channel",
@@ -1335,7 +1386,7 @@ var j = class {
1335
1386
  defaultConfig: { period: 20 }
1336
1387
  };
1337
1388
  calculate(e, t) {
1338
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1389
+ let n = N(t, "period", 20, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1339
1390
  for (let t = n - 1; t < e.length; t++) {
1340
1391
  let a = -Infinity, o = Infinity;
1341
1392
  for (let r = t - n + 1; r <= t; r++) e[r].high > a && (a = e[r].high), e[r].low < o && (o = e[r].low);
@@ -1372,7 +1423,396 @@ var j = class {
1372
1423
  }
1373
1424
  this.drawBand(e, s, l, _(r.colors[0], .08)), this.drawLine(e, s, r.colors[0], r.lineWidths[0]), this.drawLine(e, c, r.colors[1] ?? "#787B86", 1), this.drawLine(e, l, r.colors[0], r.lineWidths[0]);
1374
1425
  }
1375
- }, De = class extends j {
1426
+ }, Ee = [
1427
+ "s3",
1428
+ "s2",
1429
+ "s1",
1430
+ "pp",
1431
+ "r1",
1432
+ "r2",
1433
+ "r3"
1434
+ ], De = class extends j {
1435
+ descriptor = {
1436
+ id: "pivots",
1437
+ name: "Pivot Points (Classic)",
1438
+ placement: "overlay",
1439
+ defaultConfig: { lookback: 24 }
1440
+ };
1441
+ calculate(e, t) {
1442
+ let n = N(t, "lookback", 24, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1443
+ if (e.length <= n) return {
1444
+ values: r,
1445
+ series: i
1446
+ };
1447
+ for (let t = n; t < e.length; t++) {
1448
+ let a = -Infinity, o = Infinity;
1449
+ for (let r = t - n; r < t; r++) e[r].high > a && (a = e[r].high), e[r].low < o && (o = e[r].low);
1450
+ let s = e[t - 1].close, c = (a + o + s) / 3, l = a - o, u = {
1451
+ pp: c,
1452
+ r1: 2 * c - o,
1453
+ s1: 2 * c - a,
1454
+ r2: c + l,
1455
+ s2: c - l,
1456
+ r3: a + 2 * (c - o),
1457
+ s3: o - 2 * (a - c)
1458
+ };
1459
+ r.set(e[t].time, u), i[t] = u;
1460
+ }
1461
+ return {
1462
+ values: r,
1463
+ series: i
1464
+ };
1465
+ }
1466
+ render(e, t, n, r) {
1467
+ let i = t.series;
1468
+ if (!i) return;
1469
+ let { from: a, to: o } = n.visibleRange, s = r.colors[0], c = r.colors[1] ?? "#EF5350", l = r.colors[2] ?? "#26A69A", u = r.lineWidths[0], d = (e) => e === "pp" ? s : e.startsWith("r") ? c : l;
1470
+ for (let t of Ee) {
1471
+ e.beginPath(), e.strokeStyle = d(t), e.lineWidth = t === "pp" ? u : Math.max(1, u - 1), t !== "pp" && e.setLineDash([4, 3]);
1472
+ let r = !1;
1473
+ for (let s = a; s <= o && s < i.length; s++) {
1474
+ let a = i[s]?.[t];
1475
+ if (a === void 0) continue;
1476
+ let o = S(s, n), c = C(a, n);
1477
+ r ? e.lineTo(o, c) : (e.moveTo(o, c), r = !0);
1478
+ }
1479
+ e.stroke(), e.setLineDash([]);
1480
+ }
1481
+ }
1482
+ }, Oe = class extends j {
1483
+ descriptor = {
1484
+ id: "avwap",
1485
+ name: "Anchored VWAP",
1486
+ placement: "overlay",
1487
+ defaultConfig: { anchorTime: 0 }
1488
+ };
1489
+ calculate(e, t) {
1490
+ let n = M(t, "anchorTime", 0), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null), a = 0;
1491
+ if (n > 0 && (a = e.findIndex((e) => e.time >= n), a < 0)) return {
1492
+ values: r,
1493
+ series: i
1494
+ };
1495
+ let o = 0, s = 0;
1496
+ for (let t = a; t < e.length; t++) {
1497
+ let n = (e[t].high + e[t].low + e[t].close) / 3;
1498
+ if (o += e[t].volume, s += n * e[t].volume, o > 0) {
1499
+ let n = { value: s / o };
1500
+ r.set(e[t].time, n), i[t] = n;
1501
+ }
1502
+ }
1503
+ return {
1504
+ values: r,
1505
+ series: i
1506
+ };
1507
+ }
1508
+ render(e, t, n, r) {
1509
+ let i = t.series;
1510
+ if (!i) return;
1511
+ let { from: a, to: o } = n.visibleRange;
1512
+ e.beginPath(), e.strokeStyle = r.colors[0], e.lineWidth = r.lineWidths[0], e.lineJoin = "round";
1513
+ let s = !1;
1514
+ for (let t = a; t <= o && t < i.length; t++) {
1515
+ let r = i[t];
1516
+ if (!r || r.value === void 0) continue;
1517
+ let a = S(t, n), o = C(r.value, n);
1518
+ s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
1519
+ }
1520
+ e.stroke();
1521
+ }
1522
+ }, ke = class extends j {
1523
+ descriptor = {
1524
+ id: "zigzag",
1525
+ name: "ZigZag",
1526
+ placement: "overlay",
1527
+ defaultConfig: { deviation: 5 }
1528
+ };
1529
+ calculate(e, t) {
1530
+ let n = Math.max(.01, M(t, "deviation", 5)) / 100, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1531
+ if (e.length < 2) return {
1532
+ values: r,
1533
+ series: i,
1534
+ meta: { pivots: [] }
1535
+ };
1536
+ let a = [], o = null, s = 0, c = e[0].close;
1537
+ for (let t = 1; t < e.length; t++) {
1538
+ let r = e[t].high, i = e[t].low;
1539
+ if (o === null) {
1540
+ r >= c * (1 + n) ? (a.push({
1541
+ idx: s,
1542
+ price: c,
1543
+ type: "low"
1544
+ }), o = "up", s = t, c = r) : i <= c * (1 - n) && (a.push({
1545
+ idx: s,
1546
+ price: c,
1547
+ type: "high"
1548
+ }), o = "down", s = t, c = i);
1549
+ continue;
1550
+ }
1551
+ o === "up" ? r > c ? (s = t, c = r) : i <= c * (1 - n) && (a.push({
1552
+ idx: s,
1553
+ price: c,
1554
+ type: "high"
1555
+ }), o = "down", s = t, c = i) : i < c ? (s = t, c = i) : r >= c * (1 + n) && (a.push({
1556
+ idx: s,
1557
+ price: c,
1558
+ type: "low"
1559
+ }), o = "up", s = t, c = r);
1560
+ }
1561
+ a.push({
1562
+ idx: s,
1563
+ price: c,
1564
+ type: o === "up" ? "high" : "low"
1565
+ });
1566
+ for (let t of a) {
1567
+ let n = { pivot: t.price };
1568
+ r.set(e[t.idx].time, n), i[t.idx] = n;
1569
+ }
1570
+ return {
1571
+ values: r,
1572
+ series: i,
1573
+ meta: { pivots: a }
1574
+ };
1575
+ }
1576
+ render(e, t, n, r) {
1577
+ let i = t.meta?.pivots;
1578
+ if (!(!i || i.length < 2)) {
1579
+ e.beginPath(), e.strokeStyle = r.colors[0], e.lineWidth = r.lineWidths[0], e.lineJoin = "round";
1580
+ for (let t = 0; t < i.length; t++) {
1581
+ let r = i[t], a = S(r.idx, n), o = C(r.price, n);
1582
+ t === 0 ? e.moveTo(a, o) : e.lineTo(a, o);
1583
+ }
1584
+ e.stroke();
1585
+ }
1586
+ }
1587
+ }, Ae = class extends j {
1588
+ descriptor = {
1589
+ id: "lrc",
1590
+ name: "Linear Regression Channel",
1591
+ placement: "overlay",
1592
+ defaultConfig: {
1593
+ period: 100,
1594
+ stdDev: 2
1595
+ }
1596
+ };
1597
+ calculate(e, t) {
1598
+ let n = N(t, "period", 100, 2), r = M(t, "stdDev", 2), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
1599
+ if (e.length < n) return {
1600
+ values: i,
1601
+ series: a
1602
+ };
1603
+ for (let t = n - 1; t < e.length; t++) {
1604
+ let o = t - n + 1, s = 0, c = 0, l = 0, u = 0;
1605
+ for (let t = 0; t < n; t++) {
1606
+ let n = t, r = e[o + t].close;
1607
+ s += n, c += r, l += n * r, u += n * n;
1608
+ }
1609
+ let d = n * u - s * s;
1610
+ if (d === 0) continue;
1611
+ let f = (n * l - s * c) / d, p = (c - f * s) / n, m = 0;
1612
+ for (let t = 0; t < n; t++) {
1613
+ let n = f * t + p, r = e[o + t].close - n;
1614
+ m += r * r;
1615
+ }
1616
+ let h = Math.sqrt(m / n), g = f * (n - 1) + p, _ = {
1617
+ middle: g,
1618
+ upper: g + r * h,
1619
+ lower: g - r * h,
1620
+ slope: f
1621
+ };
1622
+ i.set(e[t].time, _), a[t] = _;
1623
+ }
1624
+ return {
1625
+ values: i,
1626
+ series: a
1627
+ };
1628
+ }
1629
+ render(e, t, n, r) {
1630
+ let i = t.series;
1631
+ if (!i) return;
1632
+ let { from: a, to: o } = n.visibleRange, s = [], c = [], l = [];
1633
+ for (let e = a; e <= o && e < i.length; e++) {
1634
+ let t = i[e];
1635
+ if (!t) continue;
1636
+ let r = S(e, n);
1637
+ t.middle !== void 0 && c.push({
1638
+ x: r,
1639
+ y: C(t.middle, n)
1640
+ }), t.upper !== void 0 && s.push({
1641
+ x: r,
1642
+ y: C(t.upper, n)
1643
+ }), t.lower !== void 0 && l.push({
1644
+ x: r,
1645
+ y: C(t.lower, n)
1646
+ });
1647
+ }
1648
+ this.drawBand(e, s, l, _(r.colors[0], .08)), this.drawLine(e, s, r.colors[0], r.lineWidths[0]), this.drawLine(e, c, r.colors[1] ?? r.colors[0], r.lineWidths[0]), this.drawLine(e, l, r.colors[0], r.lineWidths[0]);
1649
+ }
1650
+ }, je = class extends j {
1651
+ descriptor = {
1652
+ id: "hma",
1653
+ name: "Hull Moving Average",
1654
+ placement: "overlay",
1655
+ defaultConfig: { period: 21 }
1656
+ };
1657
+ calculate(e, t) {
1658
+ let n = N(t, "period", 21, 2), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1659
+ if (e.length < n) return {
1660
+ values: r,
1661
+ series: i
1662
+ };
1663
+ let a = e.map((e) => e.close), o = Math.max(2, Math.floor(n / 2)), s = Math.max(2, Math.floor(Math.sqrt(n))), c = Me(a, n), l = Me(a, o), u = Ne(a.map((e, t) => c[t] === null || l[t] === null ? null : 2 * l[t] - c[t]), s);
1664
+ for (let t = 0; t < e.length; t++) {
1665
+ if (u[t] === null) continue;
1666
+ let n = { value: u[t] };
1667
+ r.set(e[t].time, n), i[t] = n;
1668
+ }
1669
+ return {
1670
+ values: r,
1671
+ series: i
1672
+ };
1673
+ }
1674
+ render(e, t, n, r) {
1675
+ let i = t.series;
1676
+ if (!i) return;
1677
+ let { from: a, to: o } = n.visibleRange;
1678
+ e.beginPath(), e.strokeStyle = r.colors[0], e.lineWidth = r.lineWidths[0], e.lineJoin = "round";
1679
+ let s = !1;
1680
+ for (let t = a; t <= o && t < i.length; t++) {
1681
+ let r = i[t];
1682
+ if (!r || r.value === void 0) continue;
1683
+ let a = S(t, n), o = C(r.value, n);
1684
+ s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
1685
+ }
1686
+ e.stroke();
1687
+ }
1688
+ };
1689
+ function Me(e, t) {
1690
+ let n = Array(e.length).fill(null);
1691
+ if (e.length < t) return n;
1692
+ let r = t * (t + 1) / 2;
1693
+ for (let i = t - 1; i < e.length; i++) {
1694
+ let a = 0;
1695
+ for (let n = 0; n < t; n++) a += e[i - n] * (t - n);
1696
+ n[i] = a / r;
1697
+ }
1698
+ return n;
1699
+ }
1700
+ function Ne(e, t) {
1701
+ let n = Array(e.length).fill(null), r = t * (t + 1) / 2;
1702
+ for (let i = t - 1; i < e.length; i++) {
1703
+ let a = 0, o = !0;
1704
+ for (let n = 0; n < t; n++) {
1705
+ let r = e[i - n];
1706
+ if (r === null) {
1707
+ o = !1;
1708
+ break;
1709
+ }
1710
+ a += r * (t - n);
1711
+ }
1712
+ o && (n[i] = a / r);
1713
+ }
1714
+ return n;
1715
+ }
1716
+ //#endregion
1717
+ //#region src/indicators/panel/AwesomeOscillator.ts
1718
+ var Pe = class extends j {
1719
+ descriptor = {
1720
+ id: "ao",
1721
+ name: "Awesome Oscillator",
1722
+ placement: "panel",
1723
+ defaultConfig: {
1724
+ fast: 5,
1725
+ slow: 34
1726
+ }
1727
+ };
1728
+ calculate(e, t) {
1729
+ let n = N(t, "fast", 5, 1), r = N(t, "slow", 34, 1), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
1730
+ if (e.length < r) return {
1731
+ values: i,
1732
+ series: a
1733
+ };
1734
+ let o = Array(e.length);
1735
+ for (let t = 0; t < e.length; t++) o[t] = (e[t].high + e[t].low) / 2;
1736
+ let s = 0, c = 0, l;
1737
+ for (let t = 0; t < e.length; t++) if (c += o[t], t >= r && (c -= o[t - r]), s += o[t], t >= n && (s -= o[t - n]), t >= r - 1) {
1738
+ let o = s / n - c / r, u = {
1739
+ value: o,
1740
+ up: +(l === void 0 || o >= l)
1741
+ };
1742
+ i.set(e[t].time, u), a[t] = u, l = o;
1743
+ }
1744
+ return {
1745
+ values: i,
1746
+ series: a
1747
+ };
1748
+ }
1749
+ render(e, t, n, r) {
1750
+ let i = t.series;
1751
+ if (!i) return;
1752
+ let { chartRect: a } = n, { from: o, to: s } = n.visibleRange, c = Infinity, l = -Infinity;
1753
+ for (let e = o; e <= s && e < i.length; e++) {
1754
+ let t = i[e]?.value;
1755
+ t !== void 0 && (t < c && (c = t), t > l && (l = t));
1756
+ }
1757
+ if (c === Infinity) return;
1758
+ let u = Math.max(Math.abs(c), Math.abs(l)) || 1, d = (e) => a.y + a.height * (1 - (e + u) / (2 * u)), f = d(0), p = n.barWidth / 2, m = r.colors[0] ?? "#26A69A", h = r.colors[1] ?? "#EF5350";
1759
+ for (let t = o; t <= s && t < i.length; t++) {
1760
+ let r = i[t];
1761
+ if (!r || r.value === void 0) continue;
1762
+ let a = S(t, n), o = d(r.value), s = Math.min(o, f), c = Math.max(Math.abs(o - f), 1);
1763
+ e.fillStyle = r.up ? m : h, e.fillRect(a - p, s, n.barWidth, c);
1764
+ }
1765
+ }
1766
+ }, Fe = class extends j {
1767
+ descriptor = {
1768
+ id: "chaikinOsc",
1769
+ name: "Chaikin Oscillator",
1770
+ placement: "panel",
1771
+ defaultConfig: {
1772
+ fast: 3,
1773
+ slow: 10
1774
+ }
1775
+ };
1776
+ calculate(e, t) {
1777
+ let n = N(t, "fast", 3, 1), r = N(t, "slow", 10, 1), i = /* @__PURE__ */ new Map(), a = Array(e.length).fill(null);
1778
+ if (e.length < r) return {
1779
+ values: i,
1780
+ series: a
1781
+ };
1782
+ let o = 2 / (n + 1), s = 2 / (r + 1), c = 0, l = 0, u = 0;
1783
+ for (let t = 0; t < e.length; t++) {
1784
+ let { high: n, low: d, close: f, volume: p } = e[t], m = n - d, h = m === 0 ? 0 : (f - d - (n - f)) / m;
1785
+ if (c += h * p, t === 0 ? (l = c, u = c) : (l = (c - l) * o + l, u = (c - u) * s + u), t >= r - 1) {
1786
+ let n = {
1787
+ value: l - u,
1788
+ adl: c
1789
+ };
1790
+ i.set(e[t].time, n), a[t] = n;
1791
+ }
1792
+ }
1793
+ return {
1794
+ values: i,
1795
+ series: a
1796
+ };
1797
+ }
1798
+ render(e, t, n, r) {
1799
+ let i = t.series;
1800
+ if (!i) return;
1801
+ let { chartRect: a } = n, { from: o, to: s } = n.visibleRange, c = Infinity, l = -Infinity;
1802
+ for (let e = o; e <= s && e < i.length; e++) {
1803
+ let t = i[e]?.value;
1804
+ t !== void 0 && (t < c && (c = t), t > l && (l = t));
1805
+ }
1806
+ if (c === Infinity) return;
1807
+ let u = Math.max(Math.abs(c), Math.abs(l)) || 1, d = (e) => a.y + a.height * (1 - (e + u) / (2 * u)), f = d(0), p = n.barWidth / 2, m = r.colors[0] ?? "#26A69A", h = r.colors[1] ?? "#EF5350";
1808
+ for (let t = o; t <= s && t < i.length; t++) {
1809
+ let r = i[t];
1810
+ if (!r || r.value === void 0) continue;
1811
+ let a = S(t, n), o = d(r.value), s = Math.min(o, f), c = Math.max(Math.abs(o - f), 1);
1812
+ e.fillStyle = r.value >= 0 ? m : h, e.fillRect(a - p, s, n.barWidth, c);
1813
+ }
1814
+ }
1815
+ }, Ie = class extends j {
1376
1816
  descriptor = {
1377
1817
  id: "rsi",
1378
1818
  name: "Relative Strength Index",
@@ -1380,7 +1820,7 @@ var j = class {
1380
1820
  defaultConfig: { period: 14 }
1381
1821
  };
1382
1822
  calculate(e, t) {
1383
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1823
+ let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1384
1824
  if (e.length < n + 1) return {
1385
1825
  values: r,
1386
1826
  series: i
@@ -1423,7 +1863,7 @@ var j = class {
1423
1863
  }
1424
1864
  e.stroke();
1425
1865
  }
1426
- }, Oe = class extends j {
1866
+ }, Le = class extends j {
1427
1867
  descriptor = {
1428
1868
  id: "macd",
1429
1869
  name: "MACD",
@@ -1435,7 +1875,7 @@ var j = class {
1435
1875
  }
1436
1876
  };
1437
1877
  calculate(e, t) {
1438
- let n = t.params.fast, r = t.params.slow, i = t.params.signal, a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null);
1878
+ let n = N(t, "fast", 12, 1), r = N(t, "slow", 26, 1), i = N(t, "signal", 9, 1), a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null);
1439
1879
  if (e.length < r) return {
1440
1880
  values: a,
1441
1881
  series: o
@@ -1490,7 +1930,7 @@ var j = class {
1490
1930
  }
1491
1931
  e.fillStyle = m, e.fill(v), e.fillStyle = h, e.fill(y), e.strokeStyle = g, e.lineWidth = r.lineWidths[0], e.lineJoin = "round", e.stroke(C), e.strokeStyle = _, e.stroke(w);
1492
1932
  }
1493
- }, ke = class extends j {
1933
+ }, Re = class extends j {
1494
1934
  descriptor = {
1495
1935
  id: "stochastic",
1496
1936
  name: "Stochastic Oscillator",
@@ -1502,7 +1942,7 @@ var j = class {
1502
1942
  }
1503
1943
  };
1504
1944
  calculate(e, t) {
1505
- let n = t.params.kPeriod, r = t.params.dPeriod, i = t.params.smooth, a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null);
1945
+ let n = N(t, "kPeriod", 14, 1), r = N(t, "dPeriod", 3, 1), i = N(t, "smooth", 3, 1), a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null);
1506
1946
  if (e.length < n) return {
1507
1947
  values: a,
1508
1948
  series: o
@@ -1565,7 +2005,7 @@ var j = class {
1565
2005
  };
1566
2006
  l("k", r.colors[0]), l("d", r.colors[1] ?? "#FF9800");
1567
2007
  }
1568
- }, Ae = class extends j {
2008
+ }, ze = class extends j {
1569
2009
  descriptor = {
1570
2010
  id: "atr",
1571
2011
  name: "Average True Range",
@@ -1573,7 +2013,7 @@ var j = class {
1573
2013
  defaultConfig: { period: 14 }
1574
2014
  };
1575
2015
  calculate(e, t) {
1576
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2016
+ let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1577
2017
  if (e.length < 2) return {
1578
2018
  values: r,
1579
2019
  series: i
@@ -1619,7 +2059,7 @@ var j = class {
1619
2059
  }
1620
2060
  e.stroke();
1621
2061
  }
1622
- }, je = class extends j {
2062
+ }, Be = class extends j {
1623
2063
  descriptor = {
1624
2064
  id: "adx",
1625
2065
  name: "Average Directional Index",
@@ -1627,7 +2067,7 @@ var j = class {
1627
2067
  defaultConfig: { period: 14 }
1628
2068
  };
1629
2069
  calculate(e, t) {
1630
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2070
+ let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1631
2071
  if (e.length < n * 2) return {
1632
2072
  values: r,
1633
2073
  series: i
@@ -1692,7 +2132,7 @@ var j = class {
1692
2132
  };
1693
2133
  l("adx", r.colors[0]), l("plusDI", r.colors[1] ?? "#26A69A"), l("minusDI", r.colors[2] ?? "#EF5350");
1694
2134
  }
1695
- }, Me = class extends j {
2135
+ }, Ve = class extends j {
1696
2136
  descriptor = {
1697
2137
  id: "obv",
1698
2138
  name: "On Balance Volume",
@@ -1738,7 +2178,7 @@ var j = class {
1738
2178
  }
1739
2179
  e.stroke();
1740
2180
  }
1741
- }, Ne = class extends j {
2181
+ }, He = class extends j {
1742
2182
  descriptor = {
1743
2183
  id: "williamsR",
1744
2184
  name: "Williams %R",
@@ -1746,7 +2186,7 @@ var j = class {
1746
2186
  defaultConfig: { period: 14 }
1747
2187
  };
1748
2188
  calculate(e, t) {
1749
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2189
+ let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1750
2190
  for (let t = n - 1; t < e.length; t++) {
1751
2191
  let a = -Infinity, o = Infinity;
1752
2192
  for (let r = t - n + 1; r <= t; r++) e[r].high > a && (a = e[r].high), e[r].low < o && (o = e[r].low);
@@ -1778,7 +2218,7 @@ var j = class {
1778
2218
  }
1779
2219
  e.stroke();
1780
2220
  }
1781
- }, M = class extends j {
2221
+ }, Ue = class extends j {
1782
2222
  descriptor = {
1783
2223
  id: "cci",
1784
2224
  name: "Commodity Channel Index",
@@ -1786,7 +2226,7 @@ var j = class {
1786
2226
  defaultConfig: { period: 20 }
1787
2227
  };
1788
2228
  calculate(e, t) {
1789
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2229
+ let n = N(t, "period", 20, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1790
2230
  for (let t = n - 1; t < e.length; t++) {
1791
2231
  let a = 0;
1792
2232
  for (let r = t - n + 1; r <= t; r++) a += (e[r].high + e[r].low + e[r].close) / 3;
@@ -1833,7 +2273,7 @@ var j = class {
1833
2273
  }
1834
2274
  e.stroke();
1835
2275
  }
1836
- }, N = class extends j {
2276
+ }, We = class extends j {
1837
2277
  descriptor = {
1838
2278
  id: "mfi",
1839
2279
  name: "Money Flow Index",
@@ -1841,7 +2281,7 @@ var j = class {
1841
2281
  defaultConfig: { period: 14 }
1842
2282
  };
1843
2283
  calculate(e, t) {
1844
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2284
+ let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1845
2285
  if (e.length < n + 1) return {
1846
2286
  values: r,
1847
2287
  series: i
@@ -1878,7 +2318,7 @@ var j = class {
1878
2318
  }
1879
2319
  e.stroke();
1880
2320
  }
1881
- }, P = class extends j {
2321
+ }, Ge = class extends j {
1882
2322
  descriptor = {
1883
2323
  id: "aroon",
1884
2324
  name: "Aroon",
@@ -1886,7 +2326,7 @@ var j = class {
1886
2326
  defaultConfig: { period: 25 }
1887
2327
  };
1888
2328
  calculate(e, t) {
1889
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2329
+ let n = N(t, "period", 25, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1890
2330
  for (let t = n; t < e.length; t++) {
1891
2331
  let a = 0, o = 0, s = -Infinity, c = Infinity;
1892
2332
  for (let r = 0; r <= n; r++) {
@@ -1920,7 +2360,7 @@ var j = class {
1920
2360
  };
1921
2361
  l("up", r.colors[0]), l("down", r.colors[1] ?? "#EF5350");
1922
2362
  }
1923
- }, F = class extends j {
2363
+ }, Ke = class extends j {
1924
2364
  descriptor = {
1925
2365
  id: "roc",
1926
2366
  name: "Rate of Change",
@@ -1928,7 +2368,7 @@ var j = class {
1928
2368
  defaultConfig: { period: 12 }
1929
2369
  };
1930
2370
  calculate(e, t) {
1931
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2371
+ let n = N(t, "period", 12, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
1932
2372
  for (let t = n; t < e.length; t++) {
1933
2373
  let a = e[t - n].close, o = { value: a === 0 ? 0 : (e[t].close - a) / a * 100 };
1934
2374
  r.set(e[t].time, o), i[t] = o;
@@ -1964,7 +2404,7 @@ var j = class {
1964
2404
  }
1965
2405
  e.stroke();
1966
2406
  }
1967
- }, I = class extends j {
2407
+ }, qe = class extends j {
1968
2408
  descriptor = {
1969
2409
  id: "tsi",
1970
2410
  name: "True Strength Index",
@@ -1981,7 +2421,7 @@ var j = class {
1981
2421
  return r;
1982
2422
  }
1983
2423
  calculate(e, t) {
1984
- let n = t.params.longPeriod, r = t.params.shortPeriod, i = t.params.signalPeriod, a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null);
2424
+ let n = N(t, "longPeriod", 25, 1), r = N(t, "shortPeriod", 13, 1), i = N(t, "signalPeriod", 7, 1), a = /* @__PURE__ */ new Map(), o = Array(e.length).fill(null);
1985
2425
  if (e.length < 2) return {
1986
2426
  values: a,
1987
2427
  series: o
@@ -2033,7 +2473,7 @@ var j = class {
2033
2473
  };
2034
2474
  h("tsi", r.colors[0]), h("signal", r.colors[1] ?? "#FF9800");
2035
2475
  }
2036
- }, L = class extends j {
2476
+ }, Je = class extends j {
2037
2477
  descriptor = {
2038
2478
  id: "cmf",
2039
2479
  name: "Chaikin Money Flow",
@@ -2041,7 +2481,7 @@ var j = class {
2041
2481
  defaultConfig: { period: 20 }
2042
2482
  };
2043
2483
  calculate(e, t) {
2044
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2484
+ let n = N(t, "period", 20, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2045
2485
  for (let t = n - 1; t < e.length; t++) {
2046
2486
  let a = 0, o = 0;
2047
2487
  for (let r = t - n + 1; r <= t; r++) {
@@ -2078,7 +2518,7 @@ var j = class {
2078
2518
  }
2079
2519
  }
2080
2520
  }
2081
- }, R = class extends j {
2521
+ }, Ye = class extends j {
2082
2522
  descriptor = {
2083
2523
  id: "stddev",
2084
2524
  name: "Standard Deviation",
@@ -2086,7 +2526,7 @@ var j = class {
2086
2526
  defaultConfig: { period: 20 }
2087
2527
  };
2088
2528
  calculate(e, t) {
2089
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2529
+ let n = N(t, "period", 20, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2090
2530
  for (let t = n - 1; t < e.length; t++) {
2091
2531
  let a = 0;
2092
2532
  for (let r = t - n + 1; r <= t; r++) a += e[r].close;
@@ -2124,7 +2564,7 @@ var j = class {
2124
2564
  }
2125
2565
  e.stroke();
2126
2566
  }
2127
- }, z = class extends j {
2567
+ }, Xe = class extends j {
2128
2568
  descriptor = {
2129
2569
  id: "volumeProfile",
2130
2570
  name: "Volume Profile",
@@ -2132,7 +2572,7 @@ var j = class {
2132
2572
  defaultConfig: { rows: 24 }
2133
2573
  };
2134
2574
  calculate(e, t) {
2135
- let n = t.params.rows, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2575
+ let n = N(t, "rows", 24, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2136
2576
  if (e.length === 0) return {
2137
2577
  values: r,
2138
2578
  series: i
@@ -2174,7 +2614,7 @@ var j = class {
2174
2614
  e.fillStyle = l[t] > u * .7 ? r.colors[1] ?? "rgba(255, 152, 0, 0.5)" : r.colors[0] ?? "rgba(33, 150, 243, 0.3)", e.fillRect(i.x, s - d / 2, p, Math.max(d - 1, 1));
2175
2615
  }
2176
2616
  }
2177
- }, Pe = class extends j {
2617
+ }, Ze = class extends j {
2178
2618
  descriptor = {
2179
2619
  id: "ad",
2180
2620
  name: "Accumulation/Distribution",
@@ -2220,7 +2660,7 @@ var j = class {
2220
2660
  }
2221
2661
  e.stroke();
2222
2662
  }
2223
- }, Fe = class extends j {
2663
+ }, Qe = class extends j {
2224
2664
  descriptor = {
2225
2665
  id: "vroc",
2226
2666
  name: "Volume Rate of Change",
@@ -2228,7 +2668,7 @@ var j = class {
2228
2668
  defaultConfig: { period: 14 }
2229
2669
  };
2230
2670
  calculate(e, t) {
2231
- let n = t.params.period, r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2671
+ let n = N(t, "period", 14, 1), r = /* @__PURE__ */ new Map(), i = Array(e.length).fill(null);
2232
2672
  for (let t = n; t < e.length; t++) {
2233
2673
  let a = e[t - n].volume, o = { value: a === 0 ? 0 : (e[t].volume - a) / a * 100 };
2234
2674
  r.set(e[t].time, o), i[t] = o;
@@ -2262,12 +2702,105 @@ var j = class {
2262
2702
  };
2263
2703
  //#endregion
2264
2704
  //#region src/indicators/registry.ts
2265
- function Ie(e) {
2266
- e.register(new ve()), e.register(new ye()), e.register(new be()), e.register(new xe()), e.register(new Se()), e.register(new Ce()), e.register(new we()), e.register(new Te()), e.register(new Ee()), e.register(new De()), e.register(new Oe()), e.register(new ke()), e.register(new Ae()), e.register(new je()), e.register(new Me()), e.register(new Ne()), e.register(new M()), e.register(new N()), e.register(new P()), e.register(new F()), e.register(new I()), e.register(new L()), e.register(new R()), e.register(new z()), e.register(new Pe()), e.register(new Fe());
2705
+ function $e(e) {
2706
+ e.register(new ye()), e.register(new P()), e.register(new F()), e.register(new be()), e.register(new xe()), e.register(new Se()), e.register(new Ce()), e.register(new we()), e.register(new Te()), e.register(new De()), e.register(new Oe()), e.register(new ke()), e.register(new Ae()), e.register(new je()), e.register(new Ie()), e.register(new Le()), e.register(new Re()), e.register(new ze()), e.register(new Be()), e.register(new Ve()), e.register(new He()), e.register(new Ue()), e.register(new We()), e.register(new Ge()), e.register(new Ke()), e.register(new qe()), e.register(new Je()), e.register(new Ye()), e.register(new Xe()), e.register(new Ze()), e.register(new Qe()), e.register(new Pe()), e.register(new Fe());
2707
+ }
2708
+ //#endregion
2709
+ //#region src/indicators/worker/messages.ts
2710
+ function et(e) {
2711
+ if (typeof e != "object" || !e) return !1;
2712
+ let t = e;
2713
+ return typeof t.requestId == "number" ? t.type === "result" || t.type === "pong" || t.type === "error" : !1;
2267
2714
  }
2268
2715
  //#endregion
2269
- //#region src/axis/GridRenderer.ts
2270
- var Le = class {
2716
+ //#region src/indicators/worker/IndicatorWorkerHost.ts
2717
+ var tt = class {
2718
+ worker;
2719
+ fallbackPlugins;
2720
+ timeoutMs;
2721
+ nextRequestId = 1;
2722
+ pending = /* @__PURE__ */ new Map();
2723
+ messageHandler;
2724
+ constructor(e, t = {}) {
2725
+ this.worker = e, this.fallbackPlugins = t.fallbackPlugins ?? /* @__PURE__ */ new Map(), this.timeoutMs = t.timeoutMs ?? 3e4, this.messageHandler = (e) => this.handleMessage(e), this.worker && (this.worker.addEventListener("message", this.messageHandler), this.worker.addEventListener("error", this.messageHandler));
2726
+ }
2727
+ hasWorker() {
2728
+ return this.worker !== null;
2729
+ }
2730
+ registerFallbackPlugin(e) {
2731
+ this.fallbackPlugins.set(e.descriptor.id, e);
2732
+ }
2733
+ async calculate(e, t, n) {
2734
+ if (!this.worker) {
2735
+ let r = this.fallbackPlugins.get(e);
2736
+ if (!r) throw Error(`Unknown indicator: ${e}`);
2737
+ return r.calculate(n, t);
2738
+ }
2739
+ let r = this.nextRequestId++, i = {
2740
+ type: "calculate",
2741
+ requestId: r,
2742
+ indicatorId: e,
2743
+ config: t,
2744
+ data: n
2745
+ };
2746
+ return new Promise((t, n) => {
2747
+ let a = {
2748
+ resolve: t,
2749
+ reject: n,
2750
+ timer: null
2751
+ };
2752
+ this.timeoutMs > 0 && (a.timer = setTimeout(() => {
2753
+ this.pending.delete(r), n(/* @__PURE__ */ Error(`Indicator worker timeout (${this.timeoutMs}ms): ${e}`));
2754
+ }, this.timeoutMs)), this.pending.set(r, a), this.worker.postMessage(i);
2755
+ });
2756
+ }
2757
+ ping() {
2758
+ if (!this.worker) return Promise.resolve();
2759
+ let e = this.nextRequestId++;
2760
+ return new Promise((t, n) => {
2761
+ let r = {
2762
+ resolve: () => t(),
2763
+ reject: n,
2764
+ timer: this.timeoutMs > 0 ? setTimeout(() => {
2765
+ this.pending.delete(e), n(/* @__PURE__ */ Error("Indicator worker ping timeout"));
2766
+ }, this.timeoutMs) : null
2767
+ };
2768
+ this.pending.set(e, r), this.worker.postMessage({
2769
+ type: "ping",
2770
+ requestId: e
2771
+ });
2772
+ });
2773
+ }
2774
+ terminate() {
2775
+ this.worker &&= (this.worker.removeEventListener("message", this.messageHandler), this.worker.removeEventListener("error", this.messageHandler), this.worker.terminate(), null);
2776
+ for (let e of this.pending.values()) e.timer && clearTimeout(e.timer), e.reject(/* @__PURE__ */ Error("Indicator worker terminated"));
2777
+ this.pending.clear();
2778
+ }
2779
+ handleMessage(e) {
2780
+ let t = e.data;
2781
+ if (t !== void 0) {
2782
+ if (!et(t)) return;
2783
+ this.dispatchResponse(t);
2784
+ return;
2785
+ }
2786
+ let n = e.message ?? "Indicator worker error";
2787
+ for (let [e, t] of this.pending) t.timer && clearTimeout(t.timer), t.reject(Error(n)), this.pending.delete(e);
2788
+ }
2789
+ dispatchResponse(e) {
2790
+ let t = this.pending.get(e.requestId);
2791
+ if (t) {
2792
+ if (this.pending.delete(e.requestId), t.timer && clearTimeout(t.timer), e.type === "error") {
2793
+ t.reject(Error(e.message));
2794
+ return;
2795
+ }
2796
+ if (e.type === "pong") {
2797
+ t.resolve(void 0);
2798
+ return;
2799
+ }
2800
+ t.resolve(e.output);
2801
+ }
2802
+ }
2803
+ }, nt = class {
2271
2804
  visible = !0;
2272
2805
  setVisible(e) {
2273
2806
  this.visible = e;
@@ -2296,7 +2829,7 @@ var Le = class {
2296
2829
  }
2297
2830
  e.stroke();
2298
2831
  }
2299
- }, Re = class {
2832
+ }, rt = class {
2300
2833
  locale = "en-US";
2301
2834
  setLocale(e) {
2302
2835
  this.locale = e;
@@ -2319,7 +2852,7 @@ var Le = class {
2319
2852
  e.fillStyle = n.axisLabel;
2320
2853
  for (let { y: t, text: n } of h) e.fillText(n, a + 5, t);
2321
2854
  }
2322
- }, B = /* @__PURE__ */ new Date(), ze = (e) => e < 10 ? "0" + e : "" + e, Be = -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, Ve = `UTC${Be >= 0 ? "+" : ""}${Be}`, He = class {
2855
+ }, I = /* @__PURE__ */ new Date(), it = (e) => e < 10 ? "0" + e : "" + e, at = -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, ot = `UTC${at >= 0 ? "+" : ""}${at}`, st = class {
2323
2856
  render(e, t, n, r, i) {
2324
2857
  let { chartRect: a } = t, o = i ?? a.y + a.height;
2325
2858
  e.strokeStyle = n.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(a.x, o + .5), e.lineTo(a.x + a.width, o + .5), e.stroke();
@@ -2329,14 +2862,14 @@ var Le = class {
2329
2862
  for (let t = l; t <= u && t < r.length; t++) {
2330
2863
  if (t % c !== 0) continue;
2331
2864
  let n = t * s + d, i = r[t].time, a = i > 0xe8d4a51000 ? i : i * 1e3;
2332
- B.setTime(a);
2333
- let l = B.getDate(), u = B.getMonth() + 1, p = B.getHours(), m = B.getMinutes(), h;
2334
- l === f ? h = `${ze(p)}:${ze(m)}` : (h = `${u}/${l}`, f = l), e.fillText(h, n, o + 5);
2865
+ I.setTime(a);
2866
+ let l = I.getDate(), u = I.getMonth() + 1, p = I.getHours(), m = I.getMinutes(), h;
2867
+ l === f ? h = `${it(p)}:${it(m)}` : (h = `${u}/${l}`, f = l), e.fillText(h, n, o + 5);
2335
2868
  }
2336
2869
  let p = a.x + a.width - 4, m = o + 4;
2337
- e.font = `${n.font.sizeSmall - 1}px ${n.font.family}`, e.textAlign = "right", e.textBaseline = "top", e.fillStyle = n.textSecondary, e.fillText(Ve, p, m);
2870
+ e.font = `${n.font.sizeSmall - 1}px ${n.font.family}`, e.textAlign = "right", e.textBaseline = "top", e.fillStyle = n.textSecondary, e.fillText(ot, p, m);
2338
2871
  }
2339
- }, Ue = class {
2872
+ }, ct = class {
2340
2873
  panHandler = null;
2341
2874
  zoomHandler = null;
2342
2875
  crosshairHandler = null;
@@ -2464,7 +2997,7 @@ var Le = class {
2464
2997
  y: (e.clientY + t.clientY) / 2 - n.top
2465
2998
  };
2466
2999
  }
2467
- }, We = class {
3000
+ }, lt = class {
2468
3001
  dragging = !1;
2469
3002
  lastX = 0;
2470
3003
  lastTime = 0;
@@ -2500,7 +3033,7 @@ var Le = class {
2500
3033
  stopMomentum() {
2501
3034
  this.momentumId &&= (cancelAnimationFrame(this.momentumId), 0);
2502
3035
  }
2503
- }, Ge = class {
3036
+ }, ut = class {
2504
3037
  callback;
2505
3038
  sensitivity;
2506
3039
  pendingDelta = 0;
@@ -2519,7 +3052,7 @@ var Le = class {
2519
3052
  dispose() {
2520
3053
  this.rafId &&= (cancelAnimationFrame(this.rafId), 0);
2521
3054
  }
2522
- }, Ke = class {
3055
+ }, dt = class {
2523
3056
  position = null;
2524
3057
  callback = null;
2525
3058
  data = [];
@@ -2581,7 +3114,7 @@ var Le = class {
2581
3114
  flushCallback(e, t) {
2582
3115
  this.callback?.(e, t);
2583
3116
  }
2584
- }, qe = class {
3117
+ }, ft = class {
2585
3118
  callbacks;
2586
3119
  enabled = !0;
2587
3120
  constructor(e) {
@@ -2607,7 +3140,7 @@ var Le = class {
2607
3140
  default: return !1;
2608
3141
  }
2609
3142
  }
2610
- }, Je = class {
3143
+ }, pt = class {
2611
3144
  el = null;
2612
3145
  visible = !1;
2613
3146
  timeEl;
@@ -2646,8 +3179,8 @@ var Le = class {
2646
3179
  this.changeEl.textContent = `${l}${a(s)} (${l}${c.toFixed(2)}%)`, this.changeEl.style.color = i;
2647
3180
  let u = t.volume;
2648
3181
  this.volEl.textContent = `Vol ${u >= 1e6 ? (u / 1e6).toFixed(1) + "M" : u >= 1e3 ? (u / 1e3).toFixed(1) + "K" : u.toFixed(0)}`, this.volEl.style.color = n.textSecondary;
2649
- let d = Ye(n.background);
2650
- this.el.style.background = d ? Xe(n.background, .95) : Xe(n.background, .97), this.el.style.border = `1px solid ${n.axisLine}`, this.el.style.boxShadow = d ? "0 4px 12px rgba(0,0,0,0.5)" : "0 4px 12px rgba(0,0,0,0.15)", this.el.style.color = n.text, this.el.style.backdropFilter = "blur(8px)", !this.measured && this.visible && (this.measuredWidth = this.el.offsetWidth, this.measuredHeight = this.el.offsetHeight, this.measured = !0);
3182
+ let d = mt(n.background);
3183
+ this.el.style.background = d ? ht(n.background, .95) : ht(n.background, .97), this.el.style.border = `1px solid ${n.axisLine}`, this.el.style.boxShadow = d ? "0 4px 12px rgba(0,0,0,0.5)" : "0 4px 12px rgba(0,0,0,0.15)", this.el.style.color = n.text, this.el.style.backdropFilter = "blur(8px)", !this.measured && this.visible && (this.measuredWidth = this.el.offsetWidth, this.measuredHeight = this.el.offsetHeight, this.measured = !0);
2651
3184
  let f = e.x + 16, p = e.y - 40;
2652
3185
  f + this.measuredWidth > r.width - 80 && (f = e.x - this.measuredWidth - 16), p < 4 && (p = 4), p + this.measuredHeight > r.height && (p = r.height - this.measuredHeight - 4), this.el.style.transform = `translate(${Math.round(f)}px, ${Math.round(p)}px)`, this.el.style.left = "0", this.el.style.top = "0", this.visible ||= (this.el.style.display = "block", !0);
2653
3186
  }
@@ -2672,7 +3205,7 @@ var Le = class {
2672
3205
  return document.createElement("span");
2673
3206
  }
2674
3207
  };
2675
- function Ye(e) {
3208
+ function mt(e) {
2676
3209
  if (e.startsWith("#")) {
2677
3210
  let t = e.slice(1), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t.slice(0, 6), r = parseInt(n.slice(0, 2), 16), i = parseInt(n.slice(2, 4), 16), a = parseInt(n.slice(4, 6), 16);
2678
3211
  return (.299 * r + .587 * i + .114 * a) / 255 < .5;
@@ -2684,7 +3217,7 @@ function Ye(e) {
2684
3217
  }
2685
3218
  return !0;
2686
3219
  }
2687
- function Xe(e, t) {
3220
+ function ht(e, t) {
2688
3221
  if (e.startsWith("#")) {
2689
3222
  let n = e.slice(1), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n.slice(0, 6);
2690
3223
  return `rgba(${parseInt(r.slice(0, 2), 16)}, ${parseInt(r.slice(2, 4), 16)}, ${parseInt(r.slice(4, 6), 16)}, ${t})`;
@@ -2693,7 +3226,7 @@ function Xe(e, t) {
2693
3226
  }
2694
3227
  //#endregion
2695
3228
  //#region src/events/EventBus.ts
2696
- var Ze = class {
3229
+ var gt = class {
2697
3230
  listeners = /* @__PURE__ */ new Map();
2698
3231
  tauriBridge = null;
2699
3232
  on(e, t) {
@@ -2724,7 +3257,7 @@ var Ze = class {
2724
3257
  destroy() {
2725
3258
  this.listeners.clear(), this.tauriBridge = null;
2726
3259
  }
2727
- }, V = class {
3260
+ }, L = class {
2728
3261
  hitTestAnchor(e, t, n, r) {
2729
3262
  for (let i = 0; i < t.anchors.length; i++) {
2730
3263
  let a = this.anchorToPixel(t.anchors[i], n);
@@ -2779,8 +3312,8 @@ var Ze = class {
2779
3312
  let r = n.x - t.x, i = n.y - t.y, a = Math.hypot(r, i);
2780
3313
  return a === 0 ? Math.hypot(e.x - t.x, e.y - t.y) : Math.abs(r * (t.y - e.y) - i * (t.x - e.x)) / a;
2781
3314
  }
2782
- }, Qe = 1;
2783
- function H(e) {
3315
+ }, _t = 1;
3316
+ function R(e) {
2784
3317
  return {
2785
3318
  ...e,
2786
3319
  anchors: e.anchors.map((e) => ({ ...e })),
@@ -2788,7 +3321,7 @@ function H(e) {
2788
3321
  meta: e.meta ? { ...e.meta } : void 0
2789
3322
  };
2790
3323
  }
2791
- var $e = class {
3324
+ var vt = class {
2792
3325
  registry = /* @__PURE__ */ new Map();
2793
3326
  drawings = [];
2794
3327
  state = "idle";
@@ -2960,7 +3493,7 @@ var $e = class {
2960
3493
  e && this.undoRedo?.push({
2961
3494
  type: "drawingModify",
2962
3495
  before: this.dragBeforeState,
2963
- after: H(e)
3496
+ after: R(e)
2964
3497
  });
2965
3498
  }
2966
3499
  return this.state = "selected", this.dragStartPoint = null, this.dragStartAnchors = [], this.dragAnchorIndex = -1, this.dragBeforeState = null, !0;
@@ -2993,7 +3526,7 @@ var $e = class {
2993
3526
  let t = this.drawings.find((t) => t.id === e);
2994
3527
  if (!t) return null;
2995
3528
  let n = structuredClone(t);
2996
- return n.id = `tc_drawing_${Qe++}`, n.anchors = n.anchors.map((e) => ({
3529
+ return n.id = `tc_drawing_${_t++}`, n.anchors = n.anchors.map((e) => ({
2997
3530
  ...e,
2998
3531
  time: e.time + 3
2999
3532
  })), n.locked = !1, this.drawings.push(n), this.undoRedo?.push({
@@ -3035,7 +3568,7 @@ var $e = class {
3035
3568
  if (!n) return !1;
3036
3569
  let r = w(e.x, t), i = T(e.y, t), a = this.snapToOHLC(r, i, t);
3037
3570
  return this.creatingDrawing ? (this.creatingDrawing.anchors.push(a), this.committedAnchors++, this.previewAnchor = null, this.committedAnchors >= n.descriptor.requiredAnchors && this.finalizeCreation(), this.requestRender?.(), !0) : (this.creatingDrawing = {
3038
- id: `tc_drawing_${Qe++}`,
3571
+ id: `tc_drawing_${_t++}`,
3039
3572
  type: this.activeTool,
3040
3573
  anchors: [a],
3041
3574
  style: { ...this.activeStyle },
@@ -3057,8 +3590,8 @@ var $e = class {
3057
3590
  let r = this.registry.get(n.type);
3058
3591
  if (r) {
3059
3592
  let i = r.hitTestAnchor(e, n, t, 8);
3060
- if (i >= 0) return this.state = "resizing", this.dragAnchorIndex = i, this.dragStartPoint = e, this.dragBeforeState = H(n), !0;
3061
- if (r.hitTest(e, n, t, 8)) return this.state = "moving", this.dragStartPoint = e, this.dragStartAnchors = n.anchors.map((e) => ({ ...e })), this.dragBeforeState = H(n), !0;
3593
+ if (i >= 0) return this.state = "resizing", this.dragAnchorIndex = i, this.dragStartPoint = e, this.dragBeforeState = R(n), !0;
3594
+ if (r.hitTest(e, n, t, 8)) return this.state = "moving", this.dragStartPoint = e, this.dragStartAnchors = n.anchors.map((e) => ({ ...e })), this.dragBeforeState = R(n), !0;
3062
3595
  }
3063
3596
  }
3064
3597
  }
@@ -3086,14 +3619,14 @@ var $e = class {
3086
3619
  price: T(e.y, t)
3087
3620
  }, this.requestRender?.(), !0);
3088
3621
  }
3089
- }, et = class {
3622
+ }, yt = class {
3090
3623
  constructor(e) {
3091
3624
  this.manager = e;
3092
3625
  }
3093
3626
  render(e, t) {
3094
3627
  this.manager.render(e, t);
3095
3628
  }
3096
- }, tt = class extends V {
3629
+ }, bt = class extends L {
3097
3630
  descriptor = {
3098
3631
  type: "trendLine",
3099
3632
  name: "Trend Line",
@@ -3109,7 +3642,7 @@ var $e = class {
3109
3642
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3110
3643
  return this.distanceToLine(e, i, a) <= r;
3111
3644
  }
3112
- }, nt = class extends V {
3645
+ }, xt = class extends L {
3113
3646
  descriptor = {
3114
3647
  type: "horizontalLine",
3115
3648
  name: "Horizontal Line",
@@ -3125,7 +3658,7 @@ var $e = class {
3125
3658
  let i = C(t.anchors[0].price, n);
3126
3659
  return Math.abs(e.y - i) <= r && e.x >= n.chartRect.x && e.x <= n.chartRect.x + n.chartRect.width;
3127
3660
  }
3128
- }, rt = class extends V {
3661
+ }, St = class extends L {
3129
3662
  descriptor = {
3130
3663
  type: "verticalLine",
3131
3664
  name: "Vertical Line",
@@ -3141,7 +3674,7 @@ var $e = class {
3141
3674
  let i = this.anchorToPixel(t.anchors[0], n), { chartRect: a } = n;
3142
3675
  return Math.abs(e.x - i.x) <= r && e.y >= a.y && e.y <= a.y + a.height;
3143
3676
  }
3144
- }, it = class extends V {
3677
+ }, Ct = class extends L {
3145
3678
  descriptor = {
3146
3679
  type: "ray",
3147
3680
  name: "Ray",
@@ -3159,7 +3692,7 @@ var $e = class {
3159
3692
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = a.x - i.x, s = a.y - i.y;
3160
3693
  return ((e.x - i.x) * o + (e.y - i.y) * s) / (o * o + s * s) < 0 ? !1 : this.distanceToInfiniteLine(e, i, a) <= r;
3161
3694
  }
3162
- }, at = class extends V {
3695
+ }, wt = class extends L {
3163
3696
  descriptor = {
3164
3697
  type: "extendedLine",
3165
3698
  name: "Extended Line",
@@ -3177,7 +3710,7 @@ var $e = class {
3177
3710
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3178
3711
  return this.distanceToInfiniteLine(e, i, a) <= r;
3179
3712
  }
3180
- }, ot = class extends V {
3713
+ }, Tt = class extends L {
3181
3714
  descriptor = {
3182
3715
  type: "parallelChannel",
3183
3716
  name: "Parallel Channel",
@@ -3214,7 +3747,7 @@ var $e = class {
3214
3747
  }
3215
3748
  return !1;
3216
3749
  }
3217
- }, st = class extends V {
3750
+ }, Et = class extends L {
3218
3751
  descriptor = {
3219
3752
  type: "regressionChannel",
3220
3753
  name: "Regression Channel",
@@ -3237,7 +3770,7 @@ var $e = class {
3237
3770
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = Math.hypot(a.x - i.x, a.y - i.y), s = Math.max(10, Math.min(o * .2, 100));
3238
3771
  return this.distanceToLine(e, i, a) <= r + s;
3239
3772
  }
3240
- }, U = [
3773
+ }, z = [
3241
3774
  0,
3242
3775
  .236,
3243
3776
  .382,
@@ -3245,7 +3778,7 @@ var $e = class {
3245
3778
  .618,
3246
3779
  .786,
3247
3780
  1
3248
- ], ct = class extends V {
3781
+ ], Dt = class extends L {
3249
3782
  descriptor = {
3250
3783
  type: "fibRetracement",
3251
3784
  name: "Fibonacci Retracement",
@@ -3255,13 +3788,13 @@ var $e = class {
3255
3788
  if (t.anchors.length < 2) return;
3256
3789
  let { chartRect: i } = n, a = t.anchors[0].price, o = t.anchors[1].price, s = a - o;
3257
3790
  e.font = "11px sans-serif", e.textBaseline = "middle";
3258
- for (let r of U) {
3791
+ for (let r of z) {
3259
3792
  let a = o + s * (1 - r), c = C(a, n);
3260
3793
  this.applyLineStyle(e, t.style), e.globalAlpha = r === 0 || r === 1 ? 1 : .7, e.beginPath(), e.moveTo(i.x, c), e.lineTo(i.x + i.width, c), e.stroke(), e.fillStyle = t.style.color, e.textAlign = "left", e.fillText(`${(r * 100).toFixed(1)}% (${a.toFixed(2)})`, i.x + 4, c - 2);
3261
3794
  }
3262
3795
  if (e.globalAlpha = 1, t.style.fillColor) {
3263
- for (let r = 0; r < U.length - 1; r++) {
3264
- let a = o + s * (1 - U[r]), c = o + s * (1 - U[r + 1]), l = C(a, n), u = C(c, n);
3796
+ for (let r = 0; r < z.length - 1; r++) {
3797
+ let a = o + s * (1 - z[r]), c = o + s * (1 - z[r + 1]), l = C(a, n), u = C(c, n);
3265
3798
  e.fillStyle = t.style.fillColor, e.globalAlpha = .05 + r * .02, e.fillRect(i.x, Math.min(l, u), i.width, Math.abs(u - l));
3266
3799
  }
3267
3800
  e.globalAlpha = 1;
@@ -3273,13 +3806,13 @@ var $e = class {
3273
3806
  let { chartRect: i } = n;
3274
3807
  if (e.x < i.x - r || e.x > i.x + i.width + r) return !1;
3275
3808
  let a = t.anchors[0].price, o = t.anchors[1].price, s = a - o;
3276
- for (let t of U) {
3809
+ for (let t of z) {
3277
3810
  let i = C(o + s * (1 - t), n);
3278
3811
  if (Math.abs(e.y - i) <= r) return !0;
3279
3812
  }
3280
3813
  return !1;
3281
3814
  }
3282
- }, lt = [
3815
+ }, Ot = [
3283
3816
  0,
3284
3817
  .618,
3285
3818
  1,
@@ -3288,7 +3821,7 @@ var $e = class {
3288
3821
  2.618,
3289
3822
  3.618,
3290
3823
  4.236
3291
- ], ut = class extends V {
3824
+ ], kt = class extends L {
3292
3825
  descriptor = {
3293
3826
  type: "fibExtension",
3294
3827
  name: "Fibonacci Extension",
@@ -3304,7 +3837,7 @@ var $e = class {
3304
3837
  }
3305
3838
  let { chartRect: i } = n, a = t.anchors[0].price, o = t.anchors[1].price, s = t.anchors[2].price, c = a - o;
3306
3839
  e.font = "11px sans-serif", e.textBaseline = "middle", e.textAlign = "left";
3307
- for (let r of lt) {
3840
+ for (let r of Ot) {
3308
3841
  let a = C(s + c * r, n);
3309
3842
  this.applyLineStyle(e, t.style), e.globalAlpha = r === 0 || r === 1 ? 1 : .6, e.beginPath(), e.moveTo(i.x, a), e.lineTo(i.x + i.width, a), e.stroke(), e.fillStyle = t.style.color, e.fillText(`${(r * 100).toFixed(1)}%`, i.x + 4, a - 2);
3310
3843
  }
@@ -3315,13 +3848,13 @@ var $e = class {
3315
3848
  let { chartRect: i } = n;
3316
3849
  if (e.x < i.x - r || e.x > i.x + i.width + r) return !1;
3317
3850
  let a = t.anchors[0].price - t.anchors[1].price;
3318
- for (let i of lt) {
3851
+ for (let i of Ot) {
3319
3852
  let o = C(t.anchors[2].price + a * i, n);
3320
3853
  if (Math.abs(e.y - o) <= r) return !0;
3321
3854
  }
3322
3855
  return !1;
3323
3856
  }
3324
- }, dt = class extends V {
3857
+ }, At = class extends L {
3325
3858
  descriptor = {
3326
3859
  type: "rectangle",
3327
3860
  name: "Rectangle",
@@ -3339,7 +3872,7 @@ var $e = class {
3339
3872
  let u = Math.min(i.x, a.x) + r, d = Math.min(i.y, a.y) + r, f = Math.max(i.x, a.x) - r, p = Math.max(i.y, a.y) - r;
3340
3873
  return !(e.x > u && e.x < f && e.y > d && e.y < p) || !!t.style.fillColor;
3341
3874
  }
3342
- }, ft = class extends V {
3875
+ }, jt = class extends L {
3343
3876
  descriptor = {
3344
3877
  type: "ellipse",
3345
3878
  name: "Ellipse",
@@ -3355,7 +3888,7 @@ var $e = class {
3355
3888
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = (i.x + a.x) / 2, s = (i.y + a.y) / 2, c = Math.max(Math.abs(a.x - i.x) / 2, 1), l = Math.max(Math.abs(a.y - i.y) / 2, 1), u = (e.x - o) / c, d = (e.y - s) / l, f = Math.sqrt(u * u + d * d), p = r / Math.max(Math.min(c, l), 4);
3356
3889
  return t.style.fillColor ? f <= 1 + p : Math.abs(f - 1) <= p;
3357
3890
  }
3358
- }, pt = class extends V {
3891
+ }, Mt = class extends L {
3359
3892
  descriptor = {
3360
3893
  type: "triangle",
3361
3894
  name: "Triangle",
@@ -3381,7 +3914,7 @@ var $e = class {
3381
3914
  }
3382
3915
  return !1;
3383
3916
  }
3384
- }, mt = class extends V {
3917
+ }, Nt = class extends L {
3385
3918
  descriptor = {
3386
3919
  type: "pitchfork",
3387
3920
  name: "Andrews' Pitchfork",
@@ -3417,7 +3950,7 @@ var $e = class {
3417
3950
  };
3418
3951
  return this.distanceToInfiniteLine(e, a, u) <= r || this.distanceToInfiniteLine(e, o, d) <= r;
3419
3952
  }
3420
- }, ht = [
3953
+ }, Pt = [
3421
3954
  "1",
3422
3955
  "2",
3423
3956
  "3",
@@ -3426,7 +3959,7 @@ var $e = class {
3426
3959
  "A",
3427
3960
  "B",
3428
3961
  "C"
3429
- ], gt = class extends V {
3962
+ ], Ft = class extends L {
3430
3963
  descriptor = {
3431
3964
  type: "elliottWave",
3432
3965
  name: "Elliott Wave",
@@ -3438,9 +3971,9 @@ var $e = class {
3438
3971
  this.applyLineStyle(e, t.style), e.beginPath(), e.moveTo(i[0].x, i[0].y);
3439
3972
  for (let t = 1; t < i.length; t++) e.lineTo(i[t].x, i[t].y);
3440
3973
  e.stroke(), this.resetLineStyle(e), e.font = "bold 12px sans-serif", e.fillStyle = t.style.color, e.textAlign = "center";
3441
- for (let t = 0; t < i.length && t < ht.length; t++) {
3974
+ for (let t = 0; t < i.length && t < Pt.length; t++) {
3442
3975
  let n = t % 2 == 0 ? -12 : 12;
3443
- e.textBaseline = n < 0 ? "bottom" : "top", e.fillText(ht[t], i[t].x, i[t].y + n);
3976
+ e.textBaseline = n < 0 ? "bottom" : "top", e.fillText(Pt[t], i[t].x, i[t].y + n);
3444
3977
  }
3445
3978
  r && this.renderAnchorHandles(e, t, n);
3446
3979
  }
@@ -3450,7 +3983,7 @@ var $e = class {
3450
3983
  for (let t = 0; t < i.length - 1; t++) if (this.distanceToLine(e, i[t], i[t + 1]) <= r) return !0;
3451
3984
  return !1;
3452
3985
  }
3453
- }, _t = class extends V {
3986
+ }, It = class extends L {
3454
3987
  descriptor = {
3455
3988
  type: "priceRange",
3456
3989
  name: "Price Range",
@@ -3468,7 +4001,7 @@ var $e = class {
3468
4001
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = Math.min(i.x, a.x), s = Math.max(i.x, a.x), c = Math.min(i.y, a.y), l = Math.max(i.y, a.y);
3469
4002
  return e.x >= o - r && e.x <= s + r && e.y >= c - r && e.y <= l + r;
3470
4003
  }
3471
- }, vt = class extends V {
4004
+ }, Lt = class extends L {
3472
4005
  descriptor = {
3473
4006
  type: "dateRange",
3474
4007
  name: "Date Range",
@@ -3486,7 +4019,7 @@ var $e = class {
3486
4019
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), { chartRect: o } = n, s = Math.min(i.x, a.x), c = Math.max(i.x, a.x);
3487
4020
  return e.x >= s - r && e.x <= c + r && e.y >= o.y && e.y <= o.y + o.height;
3488
4021
  }
3489
- }, yt = class extends V {
4022
+ }, Rt = class extends L {
3490
4023
  descriptor = {
3491
4024
  type: "measure",
3492
4025
  name: "Measure",
@@ -3508,7 +4041,15 @@ var $e = class {
3508
4041
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3509
4042
  return this.distanceToLine(e, i, a) <= r;
3510
4043
  }
3511
- }, bt = class extends V {
4044
+ };
4045
+ //#endregion
4046
+ //#region src/drawings/tools/TextAnnotation.ts
4047
+ function zt(e, t = "Text") {
4048
+ if (typeof e.style.text == "string" && e.style.text.length > 0) return e.style.text;
4049
+ let n = e.meta?.text;
4050
+ return typeof n == "string" && n.length > 0 ? n : t;
4051
+ }
4052
+ var Bt = class extends L {
3512
4053
  descriptor = {
3513
4054
  type: "text",
3514
4055
  name: "Text",
@@ -3516,7 +4057,7 @@ var $e = class {
3516
4057
  };
3517
4058
  render(e, t, n, r) {
3518
4059
  if (t.anchors.length < 1) return;
3519
- let i = this.anchorToPixel(t.anchors[0], n), a = t.style.text || t.meta?.text || "Text", o = t.style.fontSize || 14;
4060
+ let i = this.anchorToPixel(t.anchors[0], n), a = zt(t), o = t.style.fontSize || 14;
3520
4061
  if (e.font = `${o}px sans-serif`, e.fillStyle = t.style.color, e.textAlign = "left", e.textBaseline = "top", r) {
3521
4062
  let n = e.measureText(a);
3522
4063
  e.strokeStyle = t.style.color, e.lineWidth = 1, e.setLineDash([3, 3]), e.strokeRect(i.x - 2, i.y - 2, n.width + 4, o + 4), e.setLineDash([]);
@@ -3528,7 +4069,7 @@ var $e = class {
3528
4069
  let i = this.anchorToPixel(t.anchors[0], n), a = t.style.fontSize || 14;
3529
4070
  return e.x >= i.x - r && e.x <= i.x + 80 + r && e.y >= i.y - r && e.y <= i.y + a + r;
3530
4071
  }
3531
- }, xt = class extends V {
4072
+ }, Vt = class extends L {
3532
4073
  descriptor = {
3533
4074
  type: "arrow",
3534
4075
  name: "Arrow",
@@ -3546,7 +4087,7 @@ var $e = class {
3546
4087
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3547
4088
  return this.distanceToLine(e, i, a) <= r;
3548
4089
  }
3549
- }, St = [
4090
+ }, Ht = [
3550
4091
  {
3551
4092
  label: "8x1",
3552
4093
  ratio: 8
@@ -3583,7 +4124,7 @@ var $e = class {
3583
4124
  label: "1x8",
3584
4125
  ratio: .125
3585
4126
  }
3586
- ], Ct = class extends V {
4127
+ ], Ut = class extends L {
3587
4128
  descriptor = {
3588
4129
  type: "gannFan",
3589
4130
  name: "Gann Fan",
@@ -3595,7 +4136,7 @@ var $e = class {
3595
4136
  if (Math.abs(o) < 1) return;
3596
4137
  let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
3597
4138
  this.applyLineStyle(e, t.style);
3598
- for (let { label: n, ratio: r } of St) {
4139
+ for (let { label: n, ratio: r } of Ht) {
3599
4140
  let a = c * r, o = d, s = i.y + a * (o - i.x);
3600
4141
  e.globalAlpha = r === 1 ? 1 : .5, e.lineWidth = r === 1 ? t.style.lineWidth : Math.max(.5, t.style.lineWidth * .7), e.beginPath(), e.moveTo(i.x, i.y), e.lineTo(o, s), e.stroke();
3601
4142
  let f = o - l * 4, p = s;
@@ -3608,7 +4149,7 @@ var $e = class {
3608
4149
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = a.x - i.x, s = a.y - i.y;
3609
4150
  if (Math.abs(o) < 1) return !1;
3610
4151
  let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
3611
- for (let { ratio: t } of St) {
4152
+ for (let { ratio: t } of Ht) {
3612
4153
  let n = c * t, a = d, o = i.y + n * (a - i.x);
3613
4154
  if (this.distanceToLine(e, i, {
3614
4155
  x: a,
@@ -3617,7 +4158,7 @@ var $e = class {
3617
4158
  }
3618
4159
  return !1;
3619
4160
  }
3620
- }, W = [
4161
+ }, B = [
3621
4162
  0,
3622
4163
  .25,
3623
4164
  .333,
@@ -3625,7 +4166,7 @@ var $e = class {
3625
4166
  .667,
3626
4167
  .75,
3627
4168
  1
3628
- ], wt = class extends V {
4169
+ ], Wt = class extends L {
3629
4170
  descriptor = {
3630
4171
  type: "gannBox",
3631
4172
  name: "Gann Box",
@@ -3636,18 +4177,18 @@ var $e = class {
3636
4177
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = Math.min(i.x, a.x), s = Math.max(i.x, a.x), c = Math.min(i.y, a.y), l = Math.max(i.y, a.y), u = s - o, d = l - c;
3637
4178
  if (!(u < 2 || d < 2)) {
3638
4179
  this.applyLineStyle(e, t.style), e.strokeRect(o, c, u, d), e.save(), e.globalAlpha = .35;
3639
- for (let t of W) {
4180
+ for (let t of B) {
3640
4181
  if (t === 0 || t === 1) continue;
3641
4182
  let n = c + d * t;
3642
4183
  e.beginPath(), e.moveTo(o, n), e.lineTo(s, n), e.stroke();
3643
4184
  }
3644
- for (let t of W) {
4185
+ for (let t of B) {
3645
4186
  if (t === 0 || t === 1) continue;
3646
4187
  let n = o + u * t;
3647
4188
  e.beginPath(), e.moveTo(n, c), e.lineTo(n, l), e.stroke();
3648
4189
  }
3649
4190
  e.globalAlpha = .5, e.setLineDash([4, 3]), e.beginPath(), e.moveTo(o, c), e.lineTo(s, l), e.stroke(), e.beginPath(), e.moveTo(s, c), e.lineTo(o, l), e.stroke(), e.restore(), this.resetLineStyle(e), e.fillStyle = t.style.color, e.font = "8px sans-serif", e.globalAlpha = .6, e.textBaseline = "bottom", e.textAlign = "right";
3650
- for (let t of W) {
4191
+ for (let t of B) {
3651
4192
  if (t === 0 || t === 1) continue;
3652
4193
  let n = c + d * t;
3653
4194
  e.fillText(`${(t * 100).toFixed(0)}%`, o - 3, n);
@@ -3672,7 +4213,7 @@ var $e = class {
3672
4213
  y: l
3673
4214
  }) <= r;
3674
4215
  }
3675
- }, Tt = class extends V {
4216
+ }, Gt = class extends L {
3676
4217
  descriptor = {
3677
4218
  type: "anchoredVWAP",
3678
4219
  name: "Anchored VWAP",
@@ -3744,7 +4285,7 @@ var $e = class {
3744
4285
  }
3745
4286
  return !1;
3746
4287
  }
3747
- }, Et = class extends V {
4288
+ }, Kt = class extends L {
3748
4289
  descriptor = {
3749
4290
  type: "volumeProfileRange",
3750
4291
  name: "Volume Profile (Range)",
@@ -3789,12 +4330,12 @@ var $e = class {
3789
4330
  };
3790
4331
  //#endregion
3791
4332
  //#region src/drawings/tools/index.ts
3792
- function Dt(e) {
3793
- e.register(new tt()), e.register(new nt()), e.register(new rt()), e.register(new it()), e.register(new at()), e.register(new ot()), e.register(new st()), e.register(new ct()), e.register(new ut()), e.register(new dt()), e.register(new ft()), e.register(new pt()), e.register(new mt()), e.register(new gt()), e.register(new _t()), e.register(new vt()), e.register(new yt()), e.register(new bt()), e.register(new xt()), e.register(new Ct()), e.register(new wt()), e.register(new Tt()), e.register(new Et());
4333
+ function qt(e) {
4334
+ e.register(new bt()), e.register(new xt()), e.register(new St()), e.register(new Ct()), e.register(new wt()), e.register(new Tt()), e.register(new Et()), e.register(new Dt()), e.register(new kt()), e.register(new At()), e.register(new jt()), e.register(new Mt()), e.register(new Nt()), e.register(new Ft()), e.register(new It()), e.register(new Lt()), e.register(new Rt()), e.register(new Bt()), e.register(new Vt()), e.register(new Ut()), e.register(new Wt()), e.register(new Gt()), e.register(new Kt());
3794
4335
  }
3795
4336
  //#endregion
3796
4337
  //#region src/trading/OrderRenderer.ts
3797
- var Ot = class {
4338
+ var Jt = class {
3798
4339
  render(e, t, n, r, i, a) {
3799
4340
  let o = i.orderColors?.buy ?? "#26A69A", s = i.orderColors?.sell ?? "#EF5350", { chartRect: c } = n;
3800
4341
  for (let i of t) {
@@ -3832,27 +4373,76 @@ var Ot = class {
3832
4373
  }
3833
4374
  return null;
3834
4375
  }
3835
- }, kt = class {
4376
+ };
4377
+ //#endregion
4378
+ //#region src/trading/positionFormat.ts
4379
+ function Yt(e, t, n) {
4380
+ let r = Math.min(Math.max(e.closedQuantity ?? 0, 0), e.quantity), i = e.quantity - r, a = e.side === "buy" ? 1 : -1, o = (t - e.entryPrice) * i * a, s = e.entryPrice === 0 ? 0 : (t - e.entryPrice) / e.entryPrice * 100 * a;
4381
+ return {
4382
+ side: e.side,
4383
+ quantity: e.quantity,
4384
+ closedQuantity: r,
4385
+ openQuantity: i,
4386
+ entryPrice: e.entryPrice,
4387
+ currentPrice: t,
4388
+ pnl: o,
4389
+ pnlPct: s,
4390
+ precision: n
4391
+ };
4392
+ }
4393
+ var Xt = /\{(side|qty|closedQty|openQty|entry|price|pnl|pnlPct|pnlSign)\}/g;
4394
+ function Zt(e, t) {
4395
+ return e.replace(Xt, (e, n) => {
4396
+ switch (n) {
4397
+ case "side": return t.side.toUpperCase();
4398
+ case "qty": return String(t.quantity);
4399
+ case "closedQty": return String(t.closedQuantity);
4400
+ case "openQty": return String(t.openQuantity);
4401
+ case "entry": return t.entryPrice.toFixed(t.precision);
4402
+ case "price": return t.currentPrice.toFixed(t.precision);
4403
+ case "pnl": return t.pnl.toFixed(t.precision);
4404
+ case "pnlPct": return `${t.pnlPct.toFixed(2)}%`;
4405
+ case "pnlSign": return t.pnl >= 0 ? "+" : "";
4406
+ default: return "";
4407
+ }
4408
+ });
4409
+ }
4410
+ function Qt(e, t) {
4411
+ return typeof e == "function" ? e(t) : Zt(e ?? "{side} {qty} | P&L: {pnlSign}{pnl}", t);
4412
+ }
4413
+ function $t(e, t, n) {
4414
+ if (!t || t.length === 0) return n;
4415
+ let r = [...t].sort((e, t) => e.pnl - t.pnl), i;
4416
+ for (let t of r) if (e >= t.pnl) i = t.color;
4417
+ else break;
4418
+ return i ?? n;
4419
+ }
4420
+ //#endregion
4421
+ //#region src/trading/PositionRenderer.ts
4422
+ var en = class {
3836
4423
  render(e, t, n, r, i, a) {
3837
4424
  let { chartRect: o } = r, s = a.positionColors?.profit ?? "#26A69A", c = a.positionColors?.loss ?? "#EF5350", l = a.positionColors?.entry ?? "#2196F3", u = a.pricePrecision ?? 2;
3838
- for (let a of t) {
3839
- let t = C(a.entryPrice, r);
4425
+ for (let d of t) {
4426
+ let t = C(d.entryPrice, r);
3840
4427
  if (e.strokeStyle = l, e.lineWidth = 1.5, e.setLineDash([]), e.beginPath(), e.moveTo(o.x, Math.round(t) + .5), e.lineTo(o.x + o.width, Math.round(t) + .5), e.stroke(), n !== null) {
3841
- let l = C(n, r), d = (n - a.entryPrice) * a.quantity * (a.side === "buy" ? 1 : -1), f = d >= 0;
3842
- e.fillStyle = f ? s : c, e.globalAlpha = .08;
3843
- let p = Math.min(t, l), m = Math.abs(l - t);
3844
- e.fillRect(o.x, p, o.width, m), e.globalAlpha = 1;
3845
- let h = `${a.side.toUpperCase()} ${a.quantity} | P&L: ${d >= 0 ? "+" : ""}${d.toFixed(u)}`;
4428
+ let f = C(n, r), p = Yt(d, n, u), m = p.pnl, h = m >= 0 ? s : c, g = $t(m, a.pnlThresholds, h);
4429
+ e.fillStyle = g, e.globalAlpha = .08;
4430
+ let _ = Math.min(t, f), v = Math.abs(f - t);
4431
+ if (e.fillRect(o.x, _, o.width, v), e.globalAlpha = 1, p.closedQuantity > 0 && d.quantity > 0) {
4432
+ let t = p.closedQuantity / d.quantity;
4433
+ e.fillStyle = l, e.globalAlpha = .25, e.fillRect(o.x, _, Math.max(2, o.width * t * .04) + 2, v), e.globalAlpha = 1;
4434
+ }
4435
+ let y = Qt(a.positionLabel, p);
3846
4436
  e.font = `bold 11px ${i.font.family}`;
3847
- let g = e.measureText(h).width + 12, _ = o.x + 8;
3848
- e.fillStyle = f ? s : c, e.globalAlpha = .9, e.fillRect(_, t - 10, g, 20), e.globalAlpha = 1, e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(h, _ + 6, t);
4437
+ let b = e.measureText(y).width + 12, x = o.x + 8;
4438
+ e.fillStyle = g, e.globalAlpha = .9, e.fillRect(x, t - 10, b, 20), e.globalAlpha = 1, e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(y, x + 6, t);
3849
4439
  }
3850
- if (a.stopLoss !== void 0) {
3851
- let t = C(a.stopLoss, r);
4440
+ if (d.stopLoss !== void 0) {
4441
+ let t = C(d.stopLoss, r);
3852
4442
  e.setLineDash([4, 4]), e.strokeStyle = c, e.lineWidth = 1, e.beginPath(), e.moveTo(o.x, Math.round(t) + .5), e.lineTo(o.x + o.width, Math.round(t) + .5), e.stroke(), e.font = `bold 10px ${i.font.family}`, e.fillStyle = c, e.fillRect(o.x + 4, t - 8, 24, 16), e.fillStyle = "#FFFFFF", e.textAlign = "left", e.textBaseline = "middle", e.fillText("SL", o.x + 8, t);
3853
4443
  }
3854
- if (a.takeProfit !== void 0) {
3855
- let t = C(a.takeProfit, r);
4444
+ if (d.takeProfit !== void 0) {
4445
+ let t = C(d.takeProfit, r);
3856
4446
  e.setLineDash([4, 4]), e.strokeStyle = s, e.lineWidth = 1, e.beginPath(), e.moveTo(o.x, Math.round(t) + .5), e.lineTo(o.x + o.width, Math.round(t) + .5), e.stroke(), e.font = `bold 10px ${i.font.family}`, e.fillStyle = s, e.fillRect(o.x + 4, t - 8, 24, 16), e.fillStyle = "#FFFFFF", e.textAlign = "left", e.textBaseline = "middle", e.fillText("TP", o.x + 8, t);
3857
4447
  }
3858
4448
  e.setLineDash([]);
@@ -3865,7 +4455,7 @@ var Ot = class {
3865
4455
  e.fillStyle = o, e.fillRect(l, t - 9, c - 2, 18), e.fillStyle = "#FFFFFF", e.font = `11px ${r.font.family}`, e.textAlign = "left", e.textBaseline = "middle", e.fillText(i.entryPrice.toFixed(s), l + 5, t);
3866
4456
  }
3867
4457
  }
3868
- }, At = class {
4458
+ }, tn = class {
3869
4459
  render(e, t, n, r) {
3870
4460
  if (!r.depthOverlay?.enabled) return;
3871
4461
  let { chartRect: i } = n, a = r.depthOverlay.bidColor ?? "rgba(38,166,154,0.15)", o = r.depthOverlay.askColor ?? "rgba(239,83,80,0.15)", s = r.depthOverlay.maxWidth ?? 100, c = 0, l = [], u = 0;
@@ -3896,7 +4486,7 @@ var Ot = class {
3896
4486
  e.fillRect(p - o, a - f / 2, o, f);
3897
4487
  }
3898
4488
  }
3899
- }, jt = class {
4489
+ }, nn = class {
3900
4490
  dragState = null;
3901
4491
  startY = 0;
3902
4492
  dragging = !1;
@@ -3960,7 +4550,7 @@ var Ot = class {
3960
4550
  isActive() {
3961
4551
  return this.dragState !== null;
3962
4552
  }
3963
- }, Mt = class {
4553
+ }, V = class {
3964
4554
  menuElement = null;
3965
4555
  removeHandler = null;
3966
4556
  onItemSelect = null;
@@ -4044,17 +4634,17 @@ var Ot = class {
4044
4634
  destroy() {
4045
4635
  this.hide(), this.onItemSelect = null;
4046
4636
  }
4047
- }, Nt = class {
4637
+ }, rn = class {
4048
4638
  orders = [];
4049
4639
  positions = [];
4050
4640
  depthData = null;
4051
4641
  currentPrice = null;
4052
4642
  config;
4053
- orderRenderer = new Ot();
4054
- positionRenderer = new kt();
4055
- depthOverlay = new At();
4643
+ orderRenderer = new Jt();
4644
+ positionRenderer = new en();
4645
+ depthOverlay = new tn();
4056
4646
  dragHandler;
4057
- contextMenu = new Mt();
4647
+ contextMenu = new V();
4058
4648
  requestRender = null;
4059
4649
  eventCallback = null;
4060
4650
  container = null;
@@ -4062,7 +4652,7 @@ var Ot = class {
4062
4652
  this.config = {
4063
4653
  ...a,
4064
4654
  ...e
4065
- }, this.dragHandler = new jt(this.config.dragThreshold), this.contextMenu.onItemSelect = (e) => {
4655
+ }, this.dragHandler = new nn(this.config.dragThreshold), this.contextMenu.onItemSelect = (e) => {
4066
4656
  this.eventCallback?.("orderPlace", e);
4067
4657
  };
4068
4658
  }
@@ -4123,7 +4713,7 @@ var Ot = class {
4123
4713
  destroy() {
4124
4714
  this.contextMenu.destroy();
4125
4715
  }
4126
- }, Pt = class {
4716
+ }, an = class {
4127
4717
  constructor(e) {
4128
4718
  this.manager = e;
4129
4719
  }
@@ -4133,7 +4723,7 @@ var Ot = class {
4133
4723
  renderAxisBadges(e, t, n) {
4134
4724
  this.manager.renderAxisBadges(e, t, n);
4135
4725
  }
4136
- }, G = class {
4726
+ }, H = class {
4137
4727
  listeners = /* @__PURE__ */ new Map();
4138
4728
  on(e, t) {
4139
4729
  let n = this.listeners.get(e);
@@ -4155,7 +4745,7 @@ var Ot = class {
4155
4745
  removeAllListeners() {
4156
4746
  this.listeners.clear();
4157
4747
  }
4158
- }, Ft = class extends G {
4748
+ }, on = class extends H {
4159
4749
  currentBar = null;
4160
4750
  timeframeMs;
4161
4751
  tickRing;
@@ -4217,7 +4807,7 @@ var Ot = class {
4217
4807
  alignToTimeframe(e) {
4218
4808
  return Math.floor(e / this.timeframeMs) * this.timeframeMs;
4219
4809
  }
4220
- }, K = class extends G {
4810
+ }, U = class extends H {
4221
4811
  config;
4222
4812
  attempt = 0;
4223
4813
  timer = null;
@@ -4264,7 +4854,7 @@ var Ot = class {
4264
4854
  let e = this.config.baseDelay, t = this.config.backoffMultiplier ** (this.attempt - 1), n = Math.min(e * t, this.config.maxDelay), r = n * .25 * (Math.random() * 2 - 1);
4265
4855
  return Math.max(0, Math.round(n + r));
4266
4856
  }
4267
- }, It = class {
4857
+ }, sn = class {
4268
4858
  price = null;
4269
4859
  previousClose = null;
4270
4860
  visible = !0;
@@ -4295,12 +4885,12 @@ var Ot = class {
4295
4885
  let f = s - 5;
4296
4886
  e.beginPath(), e.moveTo(f, r), e.lineTo(f + 5, r - 5), e.lineTo(f + 5, r + 5), e.closePath(), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(l, s + 5, r);
4297
4887
  }
4298
- }, Lt = class extends G {
4888
+ }, cn = class extends H {
4299
4889
  config = null;
4300
4890
  adapter = null;
4301
4891
  aggregator = null;
4302
4892
  reconnector;
4303
- priceLine = new It();
4893
+ priceLine = new sn();
4304
4894
  state = "disconnected";
4305
4895
  lastPrice = null;
4306
4896
  previousClose = null;
@@ -4308,13 +4898,13 @@ var Ot = class {
4308
4898
  heartbeatTimer = null;
4309
4899
  lastMessageTime = 0;
4310
4900
  constructor() {
4311
- super(), this.reconnector = new K(), this.wireReconnector();
4901
+ super(), this.reconnector = new U(), this.wireReconnector();
4312
4902
  }
4313
4903
  async connect(e) {
4314
4904
  this.disconnect(), this.config = {
4315
4905
  ...i,
4316
4906
  ...e
4317
- }, this.adapter = e.adapter, this.aggregator = new Ft(e.timeframe), this.reconnector.removeAllListeners(), this.reconnector.stop(), this.reconnector = new K(e.reconnect ?? r), this.wireReconnector(), this.aggregator.on("bar", (e) => {
4907
+ }, this.adapter = e.adapter, this.aggregator = new on(e.timeframe), this.reconnector.removeAllListeners(), this.reconnector.stop(), this.reconnector = new U(e.reconnect ?? r), this.wireReconnector(), this.aggregator.on("bar", (e) => {
4318
4908
  this.emit("barUpdate", e), this.updatePrice(e.close);
4319
4909
  }), this.aggregator.on("barClose", (e) => {
4320
4910
  this.previousClose = e.close, this.emit("barClose", e);
@@ -4424,7 +5014,56 @@ var Ot = class {
4424
5014
  dispose() {
4425
5015
  this.disconnect(), this.removeAllListeners();
4426
5016
  }
4427
- }, Rt = {
5017
+ };
5018
+ //#endregion
5019
+ //#region src/realtime/adapters/binanceTypes.ts
5020
+ function ln(e) {
5021
+ if (!Array.isArray(e) || e.length < 6) return null;
5022
+ let t = e[0];
5023
+ if (typeof t != "number" || !Number.isFinite(t)) return null;
5024
+ let n = W(e[1]), r = W(e[2]), i = W(e[3]), a = W(e[4]), o = W(e[5]);
5025
+ return n === null || r === null || i === null || a === null || o === null ? null : {
5026
+ time: t,
5027
+ open: n,
5028
+ high: r,
5029
+ low: i,
5030
+ close: a,
5031
+ volume: o
5032
+ };
5033
+ }
5034
+ function un(e) {
5035
+ if (!dn(e)) return null;
5036
+ let t = e.t;
5037
+ if (typeof t != "number" || !Number.isFinite(t)) return null;
5038
+ let n = W(e.o), r = W(e.h), i = W(e.l), a = W(e.c), o = W(e.v);
5039
+ if (n === null || r === null || i === null || a === null || o === null) return null;
5040
+ let s = typeof e.x == "boolean" ? e.x : !1;
5041
+ return {
5042
+ bar: {
5043
+ time: t,
5044
+ open: n,
5045
+ high: r,
5046
+ low: i,
5047
+ close: a,
5048
+ volume: o
5049
+ },
5050
+ closed: s
5051
+ };
5052
+ }
5053
+ function W(e) {
5054
+ if (typeof e == "number") return Number.isFinite(e) ? e : null;
5055
+ if (typeof e == "string") {
5056
+ let t = parseFloat(e);
5057
+ return Number.isFinite(t) ? t : null;
5058
+ }
5059
+ return null;
5060
+ }
5061
+ function dn(e) {
5062
+ return typeof e == "object" && !!e;
5063
+ }
5064
+ //#endregion
5065
+ //#region src/realtime/adapters/BinanceAdapter.ts
5066
+ var fn = {
4428
5067
  "1s": "1s",
4429
5068
  "1m": "1m",
4430
5069
  "3m": "3m",
@@ -4441,7 +5080,7 @@ var Ot = class {
4441
5080
  "3d": "3d",
4442
5081
  "1w": "1w",
4443
5082
  "1M": "1M"
4444
- }, zt = class {
5083
+ }, pn = class {
4445
5084
  name = "binance";
4446
5085
  ws = null;
4447
5086
  state = "disconnected";
@@ -4462,16 +5101,16 @@ var Ot = class {
4462
5101
  return this.state;
4463
5102
  }
4464
5103
  async fetchHistory(e, t, n = 500) {
4465
- let r = Rt[t] ?? "15m", i = `${this.restBase}/klines?symbol=${e}&interval=${r}&limit=${n}`, a = await fetch(i);
5104
+ let r = fn[t] ?? "15m", i = `${this.restBase}/klines?symbol=${e}&interval=${r}&limit=${n}`, a = await fetch(i);
4466
5105
  if (!a.ok) throw Error(`Binance REST error: ${a.status}`);
4467
- return (await a.json()).map((e) => ({
4468
- time: e[0],
4469
- open: parseFloat(e[1]),
4470
- high: parseFloat(e[2]),
4471
- low: parseFloat(e[3]),
4472
- close: parseFloat(e[4]),
4473
- volume: parseFloat(e[5])
4474
- }));
5106
+ let o = await a.json();
5107
+ if (!Array.isArray(o)) return [];
5108
+ let s = [];
5109
+ for (let e of o) {
5110
+ let t = ln(e);
5111
+ t && s.push(t);
5112
+ }
5113
+ return s;
4475
5114
  }
4476
5115
  on(e, t) {
4477
5116
  let n = this.listeners.get(e);
@@ -4485,7 +5124,7 @@ var Ot = class {
4485
5124
  }
4486
5125
  connectWs() {
4487
5126
  if (!this.config) return;
4488
- let e = `${this.config.symbol.toLowerCase()}@kline_${Rt[this.config.timeframe] ?? "15m"}`, t = `${this.wsBase}/${e}`;
5127
+ let e = `${this.config.symbol.toLowerCase()}@kline_${fn[this.config.timeframe] ?? "15m"}`, t = `${this.wsBase}/${e}`;
4489
5128
  this.setState("connecting");
4490
5129
  try {
4491
5130
  this.ws = new WebSocket(t);
@@ -4496,10 +5135,13 @@ var Ot = class {
4496
5135
  this.ws.onopen = () => {
4497
5136
  this.setState("connected"), this.emitEvent("connectionChange", "connected");
4498
5137
  }, this.ws.onmessage = (e) => {
5138
+ let t;
4499
5139
  try {
4500
- let t = JSON.parse(e.data);
4501
- t.e === "kline" && this.handleKline(t.k);
4502
- } catch {}
5140
+ t = JSON.parse(typeof e.data == "string" ? e.data : "");
5141
+ } catch {
5142
+ return;
5143
+ }
5144
+ typeof t == "object" && t && t.e === "kline" && this.handleKline(t.k);
4503
5145
  }, this.ws.onerror = () => {
4504
5146
  this.setState("error"), this.emitEvent("error", { message: "WebSocket error" });
4505
5147
  }, this.ws.onclose = () => {
@@ -4507,21 +5149,16 @@ var Ot = class {
4507
5149
  };
4508
5150
  }
4509
5151
  handleKline(e) {
4510
- let t = {
4511
- time: e.t,
4512
- open: parseFloat(e.o),
4513
- high: parseFloat(e.h),
4514
- low: parseFloat(e.l),
4515
- close: parseFloat(e.c),
4516
- volume: parseFloat(e.v)
4517
- }, n = e.x;
5152
+ let t = un(e);
5153
+ if (!t) return;
5154
+ let { bar: n, closed: r } = t;
4518
5155
  this.emitEvent("bar", {
4519
- bar: t,
4520
- closed: n
5156
+ bar: n,
5157
+ closed: r
4521
5158
  }), this.emitEvent("tick", {
4522
5159
  time: Date.now(),
4523
- price: t.close,
4524
- volume: t.volume
5160
+ price: n.close,
5161
+ volume: n.volume
4525
5162
  });
4526
5163
  }
4527
5164
  setState(e) {
@@ -4538,7 +5175,7 @@ var Ot = class {
4538
5175
  for (let e of n) e(r);
4539
5176
  }
4540
5177
  }
4541
- }, Bt = class {
5178
+ }, mn = class {
4542
5179
  name = "mock";
4543
5180
  state = "disconnected";
4544
5181
  listeners = /* @__PURE__ */ new Map();
@@ -4633,7 +5270,7 @@ var Ot = class {
4633
5270
  for (let e of n) e(r);
4634
5271
  }
4635
5272
  }
4636
- }, Vt = {
5273
+ }, hn = {
4637
5274
  visible: !0,
4638
5275
  showSymbol: !0,
4639
5276
  showOHLC: !0,
@@ -4641,8 +5278,8 @@ var Ot = class {
4641
5278
  showVolume: !0,
4642
5279
  position: "top-left",
4643
5280
  fontSize: 12
4644
- }, Ht = class {
4645
- config = { ...Vt };
5281
+ }, gn = class {
5282
+ config = { ...hn };
4646
5283
  symbol = "";
4647
5284
  timeframe = "";
4648
5285
  hoverBar = null;
@@ -4733,7 +5370,7 @@ var Ot = class {
4733
5370
  }
4734
5371
  }
4735
5372
  }
4736
- }, Ut = class {
5373
+ }, _n = class {
4737
5374
  static toDataURL(e, t) {
4738
5375
  let n = e.querySelectorAll("canvas");
4739
5376
  if (n.length === 0) return "";
@@ -4755,7 +5392,7 @@ var Ot = class {
4755
5392
  let i = document.createElement("a");
4756
5393
  i.href = r, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
4757
5394
  }
4758
- }, Wt = class {
5395
+ }, vn = class {
4759
5396
  config = null;
4760
5397
  setConfig(e) {
4761
5398
  this.config = e;
@@ -4765,7 +5402,7 @@ var Ot = class {
4765
5402
  let { chartRect: r } = t, i = this.config.fontSize ?? 48, a = this.config.color ?? n.textSecondary;
4766
5403
  e.save(), e.globalAlpha = .07, e.font = `bold ${i}px ${n.font.family}`, e.fillStyle = a, e.textAlign = "center", e.textBaseline = "middle", e.fillText(this.config.text, r.x + r.width / 2, r.y + r.height / 2), e.restore();
4767
5404
  }
4768
- }, Gt = class {
5405
+ }, yn = class {
4769
5406
  visible = !0;
4770
5407
  timeframeMs = 0;
4771
5408
  setVisible(e) {
@@ -4788,7 +5425,7 @@ var Ot = class {
4788
5425
  let t = Math.ceil(e / 1e3), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), i = t % 60;
4789
5426
  return n > 0 ? `${n}:${String(r).padStart(2, "0")}:${String(i).padStart(2, "0")}` : `${r}:${String(i).padStart(2, "0")}`;
4790
5427
  }
4791
- }, Kt = class {
5428
+ }, bn = class {
4792
5429
  config = { visible: !1 };
4793
5430
  cachedBreaks = [];
4794
5431
  lastDataLength = 0;
@@ -4832,7 +5469,7 @@ var Ot = class {
4832
5469
  invalidateCache() {
4833
5470
  this.lastDataLength = 0, this.cachedBreaks = [];
4834
5471
  }
4835
- }, qt = 1, Jt = class extends G {
5472
+ }, xn = 1, Sn = class extends H {
4836
5473
  alerts = [];
4837
5474
  lastPrice = null;
4838
5475
  requestRender = null;
@@ -4844,7 +5481,7 @@ var Ot = class {
4844
5481
  this.pricePrecision = e;
4845
5482
  }
4846
5483
  addAlert(e, t = "crossing", n, r = !1) {
4847
- let i = `tc_alert_${qt++}`, a = {
5484
+ let i = `tc_alert_${xn++}`, a = {
4848
5485
  id: i,
4849
5486
  price: e,
4850
5487
  condition: t,
@@ -4924,7 +5561,7 @@ var Ot = class {
4924
5561
  e.fillText(s, r.x + r.width - 4, a - 2);
4925
5562
  }
4926
5563
  }
4927
- }, Yt = class extends G {
5564
+ }, Cn = class extends H {
4928
5565
  data = [];
4929
5566
  currentIndex = 0;
4930
5567
  timer = null;
@@ -4978,10 +5615,114 @@ var Ot = class {
4978
5615
  dispose() {
4979
5616
  this.stop(), this.removeAllListeners(), this.data = [];
4980
5617
  }
4981
- }, q = 1, Xt = class {
5618
+ }, G = 1;
5619
+ function K(e) {
5620
+ return typeof e == "object" && !!e && !Array.isArray(e);
5621
+ }
5622
+ function q(e) {
5623
+ return Array.isArray(e) ? e : [];
5624
+ }
5625
+ function wn(e, t) {
5626
+ return typeof e == "string" ? e : t;
5627
+ }
5628
+ function J(e, t) {
5629
+ return typeof e == "number" && Number.isFinite(e) ? e : t;
5630
+ }
5631
+ function Tn(e) {
5632
+ if (!K(e) || typeof e.id != "string" || typeof e.type != "string" || !Array.isArray(e.anchors) || e.anchors.length === 0 || !K(e.style)) return null;
5633
+ let t = [];
5634
+ for (let n of e.anchors) {
5635
+ if (!K(n) || typeof n.time != "number" || typeof n.price != "number" || !Number.isFinite(n.time) || !Number.isFinite(n.price)) return null;
5636
+ t.push({
5637
+ time: n.time,
5638
+ price: n.price
5639
+ });
5640
+ }
5641
+ let n = e.style;
5642
+ return typeof n.color != "string" || typeof n.lineWidth != "number" ? null : {
5643
+ id: e.id,
5644
+ type: e.type,
5645
+ anchors: t,
5646
+ style: n,
5647
+ visible: typeof e.visible == "boolean" ? e.visible : !0,
5648
+ locked: typeof e.locked == "boolean" ? e.locked : !1,
5649
+ meta: K(e.meta) ? e.meta : void 0
5650
+ };
5651
+ }
5652
+ function En(e) {
5653
+ return !K(e) || typeof e.id != "string" || typeof e.side != "string" || typeof e.type != "string" || typeof e.price != "number" || typeof e.quantity != "number" ? null : e;
5654
+ }
5655
+ function Dn(e) {
5656
+ return !K(e) || typeof e.id != "string" || typeof e.side != "string" || typeof e.entryPrice != "number" || typeof e.quantity != "number" ? null : e;
5657
+ }
5658
+ function On(e) {
5659
+ if (!K(e)) return kn();
5660
+ typeof e.version == "number" && e.version !== G && console.warn(`Chart state version mismatch: ${e.version} vs ${G}`);
5661
+ let t = K(e.viewport) ? e.viewport : {}, n = [];
5662
+ for (let t of q(e.indicators)) K(t) && (typeof t.id != "string" || typeof t.instanceId != "string" || K(t.params) && n.push({
5663
+ id: t.id,
5664
+ instanceId: t.instanceId,
5665
+ params: t.params,
5666
+ position: typeof t.position == "string" ? t.position : void 0
5667
+ }));
5668
+ let r = [];
5669
+ for (let t of q(e.drawings)) {
5670
+ let e = Tn(t);
5671
+ e && r.push(e);
5672
+ }
5673
+ let i = [];
5674
+ for (let t of q(e.orders)) {
5675
+ let e = En(t);
5676
+ e && i.push(e);
5677
+ }
5678
+ let a = [];
5679
+ for (let t of q(e.positions)) {
5680
+ let e = Dn(t);
5681
+ e && a.push(e);
5682
+ }
5683
+ let o = [];
5684
+ for (let t of q(e.alerts)) K(t) && typeof t.id == "string" && o.push(t);
5685
+ return {
5686
+ version: typeof e.version == "number" ? e.version : G,
5687
+ timestamp: J(e.timestamp, Date.now()),
5688
+ symbol: typeof e.symbol == "string" ? e.symbol : void 0,
5689
+ timeframe: typeof e.timeframe == "string" ? e.timeframe : void 0,
5690
+ chartType: wn(e.chartType, "candlestick"),
5691
+ viewport: {
5692
+ barWidth: J(t.barWidth, 8),
5693
+ barSpacing: J(t.barSpacing, 2),
5694
+ offset: J(t.offset, 0)
5695
+ },
5696
+ theme: typeof e.theme == "string" ? e.theme : void 0,
5697
+ locale: typeof e.locale == "string" ? e.locale : void 0,
5698
+ indicators: n,
5699
+ drawings: r,
5700
+ orders: i,
5701
+ positions: a,
5702
+ alerts: o
5703
+ };
5704
+ }
5705
+ function kn() {
5706
+ return {
5707
+ version: G,
5708
+ timestamp: Date.now(),
5709
+ chartType: "candlestick",
5710
+ viewport: {
5711
+ barWidth: 8,
5712
+ barSpacing: 2,
5713
+ offset: 0
5714
+ },
5715
+ indicators: [],
5716
+ drawings: [],
5717
+ orders: [],
5718
+ positions: [],
5719
+ alerts: []
5720
+ };
5721
+ }
5722
+ var An = class {
4982
5723
  static capture(e, t) {
4983
5724
  return {
4984
- version: q,
5725
+ version: G,
4985
5726
  timestamp: Date.now(),
4986
5727
  chartType: t?.chartType ?? "candlestick",
4987
5728
  symbol: t?.symbol,
@@ -5003,8 +5744,7 @@ var Ot = class {
5003
5744
  return JSON.stringify(e);
5004
5745
  }
5005
5746
  static deserialize(e) {
5006
- let t = JSON.parse(e);
5007
- return t.version !== q && console.warn(`Chart state version mismatch: ${t.version} vs ${q}`), t;
5747
+ return On(JSON.parse(e));
5008
5748
  }
5009
5749
  static saveToStorage(e, t) {
5010
5750
  localStorage.setItem(e, this.serialize(t));
@@ -5031,7 +5771,7 @@ var Ot = class {
5031
5771
  }, n.click();
5032
5772
  });
5033
5773
  }
5034
- }, Zt = class {
5774
+ }, jn = class {
5035
5775
  undoStack = [];
5036
5776
  redoStack = [];
5037
5777
  maxHistory = 50;
@@ -5067,7 +5807,7 @@ var Ot = class {
5067
5807
  redoCount: this.redoStack.length
5068
5808
  };
5069
5809
  }
5070
- }, Qt = class {
5810
+ }, Mn = class {
5071
5811
  static toCSV(e) {
5072
5812
  return ["Time,Open,High,Low,Close,Volume", ...e.map((e) => `${new Date(e.time).toISOString()},${e.open},${e.high},${e.low},${e.close},${e.volume}`)].join("\n");
5073
5813
  }
@@ -5085,7 +5825,7 @@ var Ot = class {
5085
5825
  let r = new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
5086
5826
  a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
5087
5827
  }
5088
- }, $t = {
5828
+ }, Nn = {
5089
5829
  linear: (e) => e,
5090
5830
  easeOutCubic: (e) => 1 - (1 - e) ** 3,
5091
5831
  easeOutQuart: (e) => 1 - (1 - e) ** 4,
@@ -5093,7 +5833,7 @@ var Ot = class {
5093
5833
  easeOutExpo: (e) => e === 1 ? 1 : 1 - 2 ** (-10 * e),
5094
5834
  easeOutElastic: (e) => e === 0 || e === 1 ? e : 2 ** (-10 * e) * Math.sin((e * 10 - .75) * (2 * Math.PI / 3)) + 1,
5095
5835
  spring: (e) => 1 - Math.E ** (-6 * e) * Math.cos(8 * e)
5096
- }, en = class {
5836
+ }, Pn = class {
5097
5837
  animations = /* @__PURE__ */ new Map();
5098
5838
  frameId = 0;
5099
5839
  running = !1;
@@ -5101,7 +5841,7 @@ var Ot = class {
5101
5841
  this.animations.set(e, {
5102
5842
  startTime: -1,
5103
5843
  duration: t.duration,
5104
- easing: t.easing ?? $t.easeOutCubic,
5844
+ easing: t.easing ?? Nn.easeOutCubic,
5105
5845
  onUpdate: t.onUpdate,
5106
5846
  onComplete: t.onComplete
5107
5847
  }), this.running || (this.running = !0, this.tick());
@@ -5136,10 +5876,10 @@ var Ot = class {
5136
5876
  };
5137
5877
  //#endregion
5138
5878
  //#region src/finance/BaseFinanceChart.ts
5139
- function tn(t) {
5879
+ function Fn(t) {
5140
5880
  return !t || t === "dark" ? e : t === "light" ? o : t;
5141
5881
  }
5142
- var nn = class {
5882
+ var In = class {
5143
5883
  canvas;
5144
5884
  ctx;
5145
5885
  container;
@@ -5150,7 +5890,7 @@ var nn = class {
5150
5890
  frameId = null;
5151
5891
  resizeObserver;
5152
5892
  constructor(e, t) {
5153
- this.container = e, this.theme = tn(t), this.canvas = document.createElement("canvas"), this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.display = "block", e.appendChild(this.canvas), this.ctx = this.canvas.getContext("2d"), this.dpr = window.devicePixelRatio || 1, this.updateSize(), this.resizeObserver = new ResizeObserver(() => {
5893
+ this.container = e, this.theme = Fn(t), this.canvas = document.createElement("canvas"), this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.display = "block", e.appendChild(this.canvas), this.ctx = this.canvas.getContext("2d"), this.dpr = window.devicePixelRatio || 1, this.updateSize(), this.resizeObserver = new ResizeObserver(() => {
5154
5894
  this.updateSize(), this.requestRender();
5155
5895
  }), this.resizeObserver.observe(e);
5156
5896
  }
@@ -5165,12 +5905,12 @@ var nn = class {
5165
5905
  }));
5166
5906
  }
5167
5907
  setTheme(e) {
5168
- this.theme = tn(e), this.requestRender();
5908
+ this.theme = Fn(e), this.requestRender();
5169
5909
  }
5170
5910
  destroy() {
5171
5911
  this.frameId !== null && cancelAnimationFrame(this.frameId), this.resizeObserver.disconnect(), this.canvas.remove();
5172
5912
  }
5173
- }, rn = class {
5913
+ }, Ln = class {
5174
5914
  pos = null;
5175
5915
  canvas;
5176
5916
  onUpdate;
@@ -5202,7 +5942,7 @@ var nn = class {
5202
5942
  };
5203
5943
  //#endregion
5204
5944
  //#region src/finance/SparklineRenderer.ts
5205
- function an(e, t, n, r, i) {
5945
+ function Rn(e, t, n, r, i) {
5206
5946
  let { data: a, mode: o = "area", lineWidth: s = 1.5, showLastPoint: c = !1, showMinMax: l = !1 } = r;
5207
5947
  if (a.length < 2 || t <= 0 || n <= 0) return;
5208
5948
  let u = r.color ?? i.lineColor, d = r.fillColor ?? u, f = t - 4, p = n - 4, m = Infinity, h = -Infinity, g = 0, _ = 0;
@@ -5227,8 +5967,8 @@ function an(e, t, n, r, i) {
5227
5967
  }
5228
5968
  //#endregion
5229
5969
  //#region src/finance/DepthChartRenderer.ts
5230
- var on = 50, sn = 60, J = 20, cn = .2;
5231
- function ln(e) {
5970
+ var zn = 50, Bn = 60, Y = 20, Vn = .2;
5971
+ function Hn(e) {
5232
5972
  let t = [...e].sort((e, t) => t.price - e.price), n = [], r = 0;
5233
5973
  for (let e of t) r += e.volume, n.push({
5234
5974
  price: e.price,
@@ -5236,7 +5976,7 @@ function ln(e) {
5236
5976
  });
5237
5977
  return n;
5238
5978
  }
5239
- function un(e) {
5979
+ function Un(e) {
5240
5980
  let t = [...e].sort((e, t) => e.price - t.price), n = [], r = 0;
5241
5981
  for (let e of t) r += e.volume, n.push({
5242
5982
  price: e.price,
@@ -5244,20 +5984,20 @@ function un(e) {
5244
5984
  });
5245
5985
  return n;
5246
5986
  }
5247
- function dn(e, t) {
5987
+ function Wn(e, t) {
5248
5988
  return {
5249
- left: on,
5250
- right: e - sn,
5251
- top: J,
5252
- bottom: t - J,
5253
- plotWidth: e - on - sn,
5254
- plotHeight: t - J * 2
5989
+ left: zn,
5990
+ right: e - Bn,
5991
+ top: Y,
5992
+ bottom: t - Y,
5993
+ plotWidth: e - zn - Bn,
5994
+ plotHeight: t - Y * 2
5255
5995
  };
5256
5996
  }
5257
- function fn(e, t, n, r) {
5997
+ function Gn(e, t, n, r) {
5258
5998
  e.fillStyle = r, e.fillRect(0, 0, t, n);
5259
5999
  }
5260
- function pn(e, t, n, r, i, a, o, s) {
6000
+ function Kn(e, t, n, r, i, a, o, s) {
5261
6001
  let { left: c, right: l, top: u, bottom: d, plotWidth: p, plotHeight: m } = t;
5262
6002
  e.save(), e.strokeStyle = a.grid, e.lineWidth = .5, e.fillStyle = a.axisLabel, e.font = `${a.font.sizeSmall}px ${a.font.family}`;
5263
6003
  let h = f(0, i, 5);
@@ -5272,7 +6012,7 @@ function pn(e, t, n, r, i, a, o, s) {
5272
6012
  }
5273
6013
  e.restore();
5274
6014
  }
5275
- function mn(e, t, n, r, i, a, o, s, c) {
6015
+ function qn(e, t, n, r, i, a, o, s, c) {
5276
6016
  if (t.length === 0) return;
5277
6017
  let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - e / a * f;
5278
6018
  if (e.beginPath(), c === "bid") {
@@ -5305,14 +6045,14 @@ function mn(e, t, n, r, i, a, o, s, c) {
5305
6045
  }
5306
6046
  e.strokeStyle = s, e.lineWidth = 1.5, e.stroke();
5307
6047
  }
5308
- function hn(e, t, n, r, i, a, o, s, c) {
6048
+ function Jn(e, t, n, r, i, a, o, s, c) {
5309
6049
  let { left: l, top: u, bottom: d, plotWidth: f } = r, p = l + (t - i) / a * f;
5310
6050
  if (e.save(), e.strokeStyle = o.textSecondary, e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(p, u), e.lineTo(p, d), e.stroke(), e.restore(), s) {
5311
6051
  let t = `Spread: ${c(n)}`;
5312
6052
  e.save(), e.font = `${o.font.sizeSmall}px ${o.font.family}`, e.fillStyle = o.textSecondary, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(t, p, u - 2), e.restore();
5313
6053
  }
5314
6054
  }
5315
- function gn(e, t, n, r, i, a, o, s, c, l, u) {
6055
+ function Yn(e, t, n, r, i, a, o, s, c, l, u) {
5316
6056
  let { left: d, top: f, bottom: p, plotWidth: m, plotHeight: h } = i, g = t.x;
5317
6057
  if (g < d || g > i.right) return;
5318
6058
  let _ = a + (g - d) / m * o, v = 0, y = "";
@@ -5338,47 +6078,47 @@ function gn(e, t, n, r, i, a, o, s, c, l, u) {
5338
6078
  for (let t = 0; t < b.length; t++) e.fillText(b[t], C + 8, w + 6 + t * (c.font.sizeSmall + 4));
5339
6079
  e.restore();
5340
6080
  }
5341
- function _n(e) {
6081
+ function Xn(e) {
5342
6082
  return e.toFixed(2);
5343
6083
  }
5344
- function vn(e) {
6084
+ function Zn(e) {
5345
6085
  return e >= 1e6 ? (e / 1e6).toFixed(2) + "M" : e >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(0);
5346
6086
  }
5347
- function yn(e, t, n, r, i, a) {
6087
+ function Qn(e, t, n, r, i, a) {
5348
6088
  let { data: o } = r;
5349
6089
  if (o.bids.length === 0 && o.asks.length === 0 || t <= 0 || n <= 0) return;
5350
- let s = r.bidColor ?? i.candleUp, c = r.askColor ?? i.candleDown, l = r.bidFillColor ?? s + "40", u = r.askFillColor ?? c + "40", d = r.midPriceLine !== !1, f = r.spreadLabel !== !1, p = r.priceFormat ?? _n, m = r.volumeFormat ?? vn, h = ln(o.bids), g = un(o.asks), _ = h.length > 0 ? h[0].price : 0, v = g.length > 0 ? g[0].price : 0, y = h.length > 0 && g.length > 0 ? (_ + v) / 2 : _ || v, b = g.length > 0 && h.length > 0 ? v - _ : 0, x = h.length > 0 ? h[h.length - 1].price : y, S = g.length > 0 ? g[g.length - 1].price : y, C = Math.max(y - x, S - y) * (1 + cn), w = y - C, T = y + C, E = T - w, D = h.length > 0 ? h[h.length - 1].cumulativeVolume : 0, O = g.length > 0 ? g[g.length - 1].cumulativeVolume : 0, k = Math.max(D, O) || 1, A = dn(t, n);
5351
- fn(e, t, n, i.background), pn(e, A, w, T, k, i, p, m), mn(e, h, A, w, E, k, l, s, "bid"), mn(e, g, A, w, E, k, u, c, "ask"), d && hn(e, y, b, A, w, E, i, f, p), a && gn(e, a, h, g, A, w, E, k, i, p, m);
6090
+ let s = r.bidColor ?? i.candleUp, c = r.askColor ?? i.candleDown, l = r.bidFillColor ?? s + "40", u = r.askFillColor ?? c + "40", d = r.midPriceLine !== !1, f = r.spreadLabel !== !1, p = r.priceFormat ?? Xn, m = r.volumeFormat ?? Zn, h = Hn(o.bids), g = Un(o.asks), _ = h.length > 0 ? h[0].price : 0, v = g.length > 0 ? g[0].price : 0, y = h.length > 0 && g.length > 0 ? (_ + v) / 2 : _ || v, b = g.length > 0 && h.length > 0 ? v - _ : 0, x = h.length > 0 ? h[h.length - 1].price : y, S = g.length > 0 ? g[g.length - 1].price : y, C = Math.max(y - x, S - y) * (1 + Vn), w = y - C, T = y + C, E = T - w, D = h.length > 0 ? h[h.length - 1].cumulativeVolume : 0, O = g.length > 0 ? g[g.length - 1].cumulativeVolume : 0, k = Math.max(D, O) || 1, A = Wn(t, n);
6091
+ Gn(e, t, n, i.background), Kn(e, A, w, T, k, i, p, m), qn(e, h, A, w, E, k, l, s, "bid"), qn(e, g, A, w, E, k, u, c, "ask"), d && Jn(e, y, b, A, w, E, i, f, p), a && Yn(e, a, h, g, A, w, E, k, i, p, m);
5352
6092
  }
5353
6093
  //#endregion
5354
6094
  //#region src/finance/EquityCurveRenderer.ts
5355
- var bn = 70, xn = 30, Sn = 20, Cn = 20, wn = .05;
5356
- function Tn(e, t) {
6095
+ var $n = 70, er = 30, tr = 20, nr = 20, rr = .05;
6096
+ function ir(e, t) {
5357
6097
  return {
5358
- left: bn,
5359
- right: e - Sn,
5360
- top: Cn,
5361
- bottom: t - xn,
5362
- plotWidth: e - bn - Sn,
5363
- plotHeight: t - Cn - xn
6098
+ left: $n,
6099
+ right: e - tr,
6100
+ top: nr,
6101
+ bottom: t - er,
6102
+ plotWidth: e - $n - tr,
6103
+ plotHeight: t - nr - er
5364
6104
  };
5365
6105
  }
5366
- function En(e, t) {
6106
+ function ar(e, t) {
5367
6107
  let n = Infinity, r = -Infinity;
5368
6108
  for (let t of e) t.value < n && (n = t.value), t.value > r && (r = t.value);
5369
6109
  if (t) for (let e of t) e.value < n && (n = e.value), e.value > r && (r = e.value);
5370
- let i = (r - n) * wn;
6110
+ let i = (r - n) * rr;
5371
6111
  return {
5372
6112
  valMin: n - i,
5373
6113
  valMax: r + i
5374
6114
  };
5375
6115
  }
5376
- function Dn(e) {
6116
+ function or(e) {
5377
6117
  let t = [], n = -Infinity;
5378
6118
  for (let r of e) r.value > n && (n = r.value), t.push(n);
5379
6119
  return t;
5380
6120
  }
5381
- function On(e) {
6121
+ function sr(e) {
5382
6122
  let t = 864e5;
5383
6123
  if (365.25 * t, e < 7 * t) {
5384
6124
  let e = new Intl.DateTimeFormat(void 0, {
@@ -5400,13 +6140,13 @@ function On(e) {
5400
6140
  });
5401
6141
  return (e) => n.format(new Date(e));
5402
6142
  }
5403
- function kn(e) {
6143
+ function cr(e) {
5404
6144
  return Math.abs(e) >= 1e6 ? (e / 1e6).toFixed(2) + "M" : Math.abs(e) >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
5405
6145
  }
5406
- function An(e, t, n, r) {
6146
+ function lr(e, t, n, r) {
5407
6147
  e.fillStyle = r, e.fillRect(0, 0, t, n);
5408
6148
  }
5409
- function jn(e, t, n, r, i, a, o, s, c) {
6149
+ function ur(e, t, n, r, i, a, o, s, c) {
5410
6150
  let { left: l, right: u, top: d, bottom: p, plotWidth: m, plotHeight: h } = t;
5411
6151
  e.save(), e.strokeStyle = o.grid, e.lineWidth = .5, e.fillStyle = o.axisLabel, e.font = `${o.font.sizeSmall}px ${o.font.family}`;
5412
6152
  let g = f(n, r, 6), _ = Math.ceil(n / g) * g;
@@ -5421,21 +6161,21 @@ function jn(e, t, n, r, i, a, o, s, c) {
5421
6161
  }
5422
6162
  e.restore();
5423
6163
  }
5424
- function Mn(e, t, n, r, i, a, o, s, c) {
6164
+ function dr(e, t, n, r, i, a, o, s, c) {
5425
6165
  if (t.length < 2) return;
5426
6166
  let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - (e - a) / o * f;
5427
6167
  e.save(), e.beginPath(), e.moveTo(p(t[0].time), m(t[0].value));
5428
6168
  for (let n = 1; n < t.length; n++) e.lineTo(p(t[n].time), m(t[n].value));
5429
6169
  e.strokeStyle = s, e.lineWidth = c, e.lineJoin = "round", e.stroke(), e.restore();
5430
6170
  }
5431
- function Nn(e, t, n, r, i, a, o, s) {
6171
+ function fr(e, t, n, r, i, a, o, s) {
5432
6172
  if (t.length < 2) return;
5433
6173
  let { left: c, bottom: l, plotWidth: u, plotHeight: d } = n, f = (e) => c + (e - r) / i * u, p = (e) => l - (e - a) / o * d, m = e.createLinearGradient(0, n.top, 0, l);
5434
6174
  m.addColorStop(0, s + "40"), m.addColorStop(1, "transparent"), e.save(), e.beginPath(), e.moveTo(f(t[0].time), p(t[0].value));
5435
6175
  for (let n = 1; n < t.length; n++) e.lineTo(f(t[n].time), p(t[n].value));
5436
6176
  e.lineTo(f(t[t.length - 1].time), l), e.lineTo(f(t[0].time), l), e.closePath(), e.fillStyle = m, e.fill(), e.restore();
5437
6177
  }
5438
- function Pn(e, t, n, r, i, a, o, s, c) {
6178
+ function pr(e, t, n, r, i, a, o, s, c) {
5439
6179
  if (t.length < 2) return;
5440
6180
  let { left: l, bottom: u, plotWidth: d, plotHeight: f } = r, p = (e) => l + (e - i) / a * d, m = (e) => u - (e - o) / s * f;
5441
6181
  e.save(), e.fillStyle = c, e.beginPath(), e.moveTo(p(t[0].time), m(n[0]));
@@ -5443,12 +6183,12 @@ function Pn(e, t, n, r, i, a, o, s, c) {
5443
6183
  for (let n = t.length - 1; n >= 0; n--) e.lineTo(p(t[n].time), m(t[n].value));
5444
6184
  e.closePath(), e.fill(), e.restore();
5445
6185
  }
5446
- function Fn(e, t, n, r, i, a, o, s, c, l) {
6186
+ function mr(e, t, n, r, i, a, o, s, c, l) {
5447
6187
  if (t.length === 0) return;
5448
6188
  let { left: u, bottom: d, plotWidth: f, plotHeight: p } = n, m = t[t.length - 1], h = u + (m.time - r) / i * f, g = d - (m.value - a) / o * p;
5449
6189
  e.save(), e.font = `${l.font.sizeSmall}px ${l.font.family}`, e.fillStyle = c, e.textAlign = "left", e.textBaseline = "middle", e.fillText(s, h + 4, g), e.restore();
5450
6190
  }
5451
- function In(e, t, n, r, i, a, o, s, c, l, u, d) {
6191
+ function hr(e, t, n, r, i, a, o, s, c, l, u, d) {
5452
6192
  let { left: f, top: p, bottom: m, plotWidth: h, plotHeight: g } = i, _ = t.x;
5453
6193
  if (_ < f || _ > i.right) return;
5454
6194
  e.save(), e.strokeStyle = l.crosshair, e.lineWidth = .5, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(_, p), e.lineTo(_, m), e.stroke(), e.restore();
@@ -5466,15 +6206,15 @@ function In(e, t, n, r, i, a, o, s, c, l, u, d) {
5466
6206
  for (let t = 0; t < S.length; t++) e.fillText(S[t], D + 8, O + 6 + t * (l.font.sizeSmall + 4));
5467
6207
  e.restore();
5468
6208
  }
5469
- function Ln(e, t, n, r, i, a) {
6209
+ function gr(e, t, n, r, i, a) {
5470
6210
  let { data: o } = r;
5471
6211
  if (o.length < 2 || t <= 0 || n <= 0) return;
5472
- let s = r.lineColor ?? i.lineColor, c = r.lineWidth ?? 1.5, l = r.drawdown === !0, u = r.drawdownColor ?? i.candleDown + "30", d = r.fillArea === !0, f = r.benchmark, p = r.benchmarkColor ?? i.textSecondary, m = r.benchmarkLabel ?? "Benchmark", h = r.valueFormat ?? kn, { valMin: g, valMax: _ } = En(o, f), v = _ - g || 1, y = o[0].time, b = o[o.length - 1].time, x = b - y || 1, S = r.timeFormat ?? On(x), C = Tn(t, n);
5473
- An(e, t, n, i.background), jn(e, C, g, _, y, b, i, h, S), l && Pn(e, o, Dn(o), C, y, x, g, v, u), d && Nn(e, o, C, y, x, g, v, s), Mn(e, o, C, y, x, g, v, s, c), f && f.length >= 2 && (Mn(e, f, C, y, x, g, v, p, 1), Fn(e, f, C, y, x, g, v, m, p, i)), a && In(e, a, o, f, C, y, x, g, v, i, S, h);
6212
+ let s = r.lineColor ?? i.lineColor, c = r.lineWidth ?? 1.5, l = r.drawdown === !0, u = r.drawdownColor ?? i.candleDown + "30", d = r.fillArea === !0, f = r.benchmark, p = r.benchmarkColor ?? i.textSecondary, m = r.benchmarkLabel ?? "Benchmark", h = r.valueFormat ?? cr, { valMin: g, valMax: _ } = ar(o, f), v = _ - g || 1, y = o[0].time, b = o[o.length - 1].time, x = b - y || 1, S = r.timeFormat ?? sr(x), C = ir(t, n);
6213
+ lr(e, t, n, i.background), ur(e, C, g, _, y, b, i, h, S), l && pr(e, o, or(o), C, y, x, g, v, u), d && fr(e, o, C, y, x, g, v, s), dr(e, o, C, y, x, g, v, s, c), f && f.length >= 2 && (dr(e, f, C, y, x, g, v, p, 1), mr(e, f, C, y, x, g, v, m, p, i)), a && hr(e, a, o, f, C, y, x, g, v, i, S, h);
5474
6214
  }
5475
6215
  //#endregion
5476
6216
  //#region src/finance/HeatmapLayout.ts
5477
- function Rn(e, t, n) {
6217
+ function _r(e, t, n) {
5478
6218
  if (e.length === 0) return [];
5479
6219
  let r = e.length, i = Math.ceil(Math.sqrt(r)), a = Math.ceil(r / i), o = t.width / i, s = t.height / a, c = [];
5480
6220
  for (let a = 0; a < r; a++) {
@@ -5491,7 +6231,7 @@ function Rn(e, t, n) {
5491
6231
  }
5492
6232
  return c;
5493
6233
  }
5494
- function zn(e, t) {
6234
+ function vr(e, t) {
5495
6235
  let n = e.reduce((e, t) => e + t, 0);
5496
6236
  if (n === 0 || t === 0) return Infinity;
5497
6237
  let r = 0;
@@ -5501,7 +6241,7 @@ function zn(e, t) {
5501
6241
  }
5502
6242
  return r;
5503
6243
  }
5504
- function Y(e, t, n, r, i, a) {
6244
+ function X(e, t, n, r, i, a) {
5505
6245
  let o = r ? n.height : n.width, s = e.reduce((e, t) => e + t, 0), c = o > 0 ? s / o : 0, l = 0;
5506
6246
  for (let o = 0; o < e.length; o++) {
5507
6247
  let s = c > 0 ? e[o] / c : 0, u;
@@ -5521,19 +6261,19 @@ function Y(e, t, n, r, i, a) {
5521
6261
  }), l += s;
5522
6262
  }
5523
6263
  }
5524
- function Bn(e, t, n, r, i) {
6264
+ function yr(e, t, n, r, i) {
5525
6265
  if (e.length === 0) return;
5526
6266
  let a = n.width >= n.height, o = a ? n.height : n.width;
5527
6267
  if (e.length === 1) {
5528
- Y(e, t, n, a, r, i);
6268
+ X(e, t, n, a, r, i);
5529
6269
  return;
5530
6270
  }
5531
6271
  let s = [], c = [], l = 0;
5532
6272
  for (; l < e.length;) {
5533
6273
  let u = [...s, e[l]];
5534
- if (s.length === 0 || zn(u, o) <= zn(s, o)) s.push(e[l]), c.push(t[l]), l++;
6274
+ if (s.length === 0 || vr(u, o) <= vr(s, o)) s.push(e[l]), c.push(t[l]), l++;
5535
6275
  else {
5536
- Y(s, c, n, a, r, i);
6276
+ X(s, c, n, a, r, i);
5537
6277
  let u = s.reduce((e, t) => e + t, 0), d = o > 0 ? u / o : 0;
5538
6278
  n = a ? {
5539
6279
  x: n.x + d,
@@ -5545,28 +6285,28 @@ function Bn(e, t, n, r, i) {
5545
6285
  y: n.y + d,
5546
6286
  width: n.width,
5547
6287
  height: n.height - d
5548
- }, Bn(e.slice(l), t.slice(l), n, r, i);
6288
+ }, yr(e.slice(l), t.slice(l), n, r, i);
5549
6289
  return;
5550
6290
  }
5551
6291
  }
5552
- s.length > 0 && Y(s, c, n, a, r, i);
6292
+ s.length > 0 && X(s, c, n, a, r, i);
5553
6293
  }
5554
- function Vn(e, t, n) {
6294
+ function br(e, t, n) {
5555
6295
  if (e.length === 0) return [];
5556
6296
  let r = [...e].sort((e, t) => t.weight - e.weight), i = r.reduce((e, t) => e + Math.max(0, t.weight), 0);
5557
6297
  if (i === 0) return [];
5558
6298
  let a = t.width * t.height, o = r.map((e) => Math.max(0, e.weight) / i * a), s = r.map((e) => e.id), c = [];
5559
- return Bn(o, s, { ...t }, n, c), c;
6299
+ return yr(o, s, { ...t }, n, c), c;
5560
6300
  }
5561
6301
  //#endregion
5562
6302
  //#region src/finance/HeatmapRenderer.ts
5563
- function Hn(e) {
6303
+ function xr(e) {
5564
6304
  return (e >= 0 ? "+" : "") + e.toFixed(2) + "%";
5565
6305
  }
5566
- function Un(e) {
6306
+ function Sr(e) {
5567
6307
  return e.label;
5568
6308
  }
5569
- function Wn(e, t) {
6309
+ function Cr(e, t) {
5570
6310
  let n = t.min ?? -5, r = t.max ?? 5;
5571
6311
  if (e <= n) return t.negative;
5572
6312
  if (e >= r) return t.positive;
@@ -5577,11 +6317,11 @@ function Wn(e, t) {
5577
6317
  let i = e / r;
5578
6318
  return m(t.zero, t.positive, i);
5579
6319
  }
5580
- function X(e, t, n, r, i, a) {
6320
+ function Z(e, t, n, r, i, a) {
5581
6321
  let o = Math.min(a, r / 2, i / 2);
5582
6322
  e.beginPath(), e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.arcTo(t + r, n, t + r, n + o, o), e.lineTo(t + r, n + i - o), e.arcTo(t + r, n + i, t + r - o, n + i, o), e.lineTo(t + o, n + i), e.arcTo(t, n + i, t, n + i - o, o), e.lineTo(t, n + o), e.arcTo(t, n, t + o, n, o), e.closePath();
5583
6323
  }
5584
- function Gn(e, t, n, r, i, a, o, s, c, l, u) {
6324
+ function wr(e, t, n, r, i, a, o, s, c, l, u) {
5585
6325
  if (i < 40 || a < 30) return;
5586
6326
  let d = n + i / 2, f = r + a / 2;
5587
6327
  if (e.save(), e.shadowColor = "rgba(0,0,0,0.6)", e.shadowBlur = 2, e.fillStyle = "#FFFFFF", e.textAlign = "center", s) {
@@ -5594,22 +6334,22 @@ function Gn(e, t, n, r, i, a, o, s, c, l, u) {
5594
6334
  }
5595
6335
  e.restore();
5596
6336
  }
5597
- function Kn(e, t, n, r, i, a, o, s) {
6337
+ function Tr(e, t, n, r, i, a, o, s) {
5598
6338
  let c = [o(t), s(t.value)];
5599
6339
  if (t.meta) for (let [e, n] of Object.entries(t.meta)) c.push(e + ": " + String(n));
5600
6340
  e.save(), e.font = a.font.sizeSmall + "px " + a.font.family;
5601
6341
  let l = Math.max(...c.map((t) => e.measureText(t).width)) + 16, u = a.font.sizeSmall + 4, d = c.length * u + 12, f = n.x + 14, p = n.y - d / 2;
5602
- f + l > r && (f = n.x - l - 14), p < 0 && (p = 0), p + d > i && (p = i - d), e.fillStyle = a.axisLabelBackground, e.globalAlpha = .92, X(e, f, p, l, d, 4), e.fill(), e.globalAlpha = 1, e.fillStyle = a.text, e.textBaseline = "top", e.textAlign = "left";
6342
+ f + l > r && (f = n.x - l - 14), p < 0 && (p = 0), p + d > i && (p = i - d), e.fillStyle = a.axisLabelBackground, e.globalAlpha = .92, Z(e, f, p, l, d, 4), e.fill(), e.globalAlpha = 1, e.fillStyle = a.text, e.textBaseline = "top", e.textAlign = "left";
5603
6343
  for (let t = 0; t < c.length; t++) e.fillText(c[t], f + 8, p + 6 + t * u);
5604
6344
  e.restore();
5605
6345
  }
5606
- function qn(e, t, n, r, i, a, o, s) {
6346
+ function Er(e, t, n, r, i, a, o, s) {
5607
6347
  if (r.length === 0 || i.length === 0 || t <= 0 || n <= 0) return null;
5608
6348
  let c = a.colorScale ?? {
5609
6349
  negative: "#EF5350",
5610
6350
  zero: "#424242",
5611
6351
  positive: "#26A69A"
5612
- }, l = a.cellRadius ?? 4, u = a.showLabels !== !1, d = a.showValues !== !1, f = a.valueFormat ?? Hn, p = a.labelFormat ?? Un, m = /* @__PURE__ */ new Map();
6352
+ }, l = a.cellRadius ?? 4, u = a.showLabels !== !1, d = a.showValues !== !1, f = a.valueFormat ?? xr, p = a.labelFormat ?? Sr, m = /* @__PURE__ */ new Map();
5613
6353
  for (let e of r) m.set(e.id, e);
5614
6354
  let h = null, g = null;
5615
6355
  if (s) for (let e of i) {
@@ -5630,37 +6370,37 @@ function qn(e, t, n, r, i, a, o, s) {
5630
6370
  if (!n) continue;
5631
6371
  let { x: r, y: i, width: a, height: s } = t.rect;
5632
6372
  if (a <= 0 || s <= 0) continue;
5633
- let g = Wn(n.value, c);
5634
- X(e, r, i, a, s, l), e.fillStyle = g, e.fill(), Gn(e, n, r, i, a, s, o, u, d, p, f), t.id === h && (X(e, r, i, a, s, l), e.strokeStyle = "#FFFFFF", e.lineWidth = 1.5, e.stroke());
6373
+ let g = Cr(n.value, c);
6374
+ Z(e, r, i, a, s, l), e.fillStyle = g, e.fill(), wr(e, n, r, i, a, s, o, u, d, p, f), t.id === h && (Z(e, r, i, a, s, l), e.strokeStyle = "#FFFFFF", e.lineWidth = 1.5, e.stroke());
5635
6375
  }
5636
- return g && s && Kn(e, g.cell, s, t, n, o, p, f), g;
6376
+ return g && s && Tr(e, g.cell, s, t, n, o, p, f), g;
5637
6377
  }
5638
6378
  //#endregion
5639
6379
  //#region src/finance/WaterfallRenderer.ts
5640
- var Jn = 60, Z = 12, Yn = 24, Xn = 40, Zn = .7, Qn = 1;
5641
- function $n(e) {
6380
+ var Dr = 60, Or = 12, kr = 24, Ar = 40, jr = .7, Mr = 1;
6381
+ function Nr(e) {
5642
6382
  return e.type ? e.type : e.value > 0 ? "positive" : e.value < 0 ? "negative" : "subtotal";
5643
6383
  }
5644
- function er(e) {
6384
+ function Pr(e) {
5645
6385
  let t = Math.abs(e);
5646
6386
  return t >= 1e6 ? (e / 1e6).toFixed(2) + "M" : t >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
5647
6387
  }
5648
- function tr(e, t) {
6388
+ function Fr(e, t) {
5649
6389
  return {
5650
- left: Jn,
5651
- right: e - Z,
5652
- top: Yn,
5653
- bottom: t - Xn,
5654
- plotWidth: e - Jn - Z,
5655
- plotHeight: t - Yn - Xn
6390
+ left: Dr,
6391
+ right: e - Or,
6392
+ top: kr,
6393
+ bottom: t - Ar,
6394
+ plotWidth: e - Dr - Or,
6395
+ plotHeight: t - kr - Ar
5656
6396
  };
5657
6397
  }
5658
- function nr(e, t, n, r, i) {
6398
+ function Ir(e, t, n, r, i) {
5659
6399
  let a = Array(e.length), o = Array(e.length), s = t.plotWidth / e.length, c = s * n, l = (s - c) / 2, { left: u, bottom: d, plotHeight: f } = t, p = 0;
5660
6400
  for (let t = 0; t < e.length; t++) {
5661
- let n = e[t], m = $n(n), h, g;
6401
+ let n = e[t], m = Nr(n), h, g;
5662
6402
  m === "total" || m === "subtotal" ? (h = 0, g = n.value, p = n.value) : (h = p, g = p + n.value, p = g);
5663
- let _ = Math.min(h, g), v = Math.max(h, g), y = d - (_ - r) / i * f, b = d - (v - r) / i * f, x = Math.min(y, b), S = Math.max(Math.abs(b - y), Qn), C = u + t * s, w = C + l;
6403
+ let _ = Math.min(h, g), v = Math.max(h, g), y = d - (_ - r) / i * f, b = d - (v - r) / i * f, x = Math.min(y, b), S = Math.max(Math.abs(b - y), Mr), C = u + t * s, w = C + l;
5664
6404
  a[t] = {
5665
6405
  label: n.label,
5666
6406
  value: n.value,
@@ -5680,14 +6420,14 @@ function nr(e, t, n, r, i) {
5680
6420
  cumulatives: o
5681
6421
  };
5682
6422
  }
5683
- function rr(e) {
6423
+ function Lr(e) {
5684
6424
  if (e.length === 0) return {
5685
6425
  valMin: 0,
5686
6426
  valMax: 1
5687
6427
  };
5688
6428
  let t = 0, n = 0, r = 0;
5689
6429
  for (let i = 0; i < e.length; i++) {
5690
- let a = e[i], o = $n(a), s, c;
6430
+ let a = e[i], o = Nr(a), s, c;
5691
6431
  o === "total" || o === "subtotal" ? (s = 0, c = a.value, r = a.value) : (s = r, c = r + a.value, r = c), s < t && (t = s), c < t && (t = c), s > n && (n = s), c > n && (n = c);
5692
6432
  }
5693
6433
  let i = (n - t || 1) * .1;
@@ -5696,10 +6436,10 @@ function rr(e) {
5696
6436
  valMax: n + i
5697
6437
  };
5698
6438
  }
5699
- function ir(e, t, n, r) {
6439
+ function Rr(e, t, n, r) {
5700
6440
  e.fillStyle = r, e.fillRect(0, 0, t, n);
5701
6441
  }
5702
- function ar(e, t, n, r, i, a) {
6442
+ function zr(e, t, n, r, i, a) {
5703
6443
  let { left: o, right: s, top: c, bottom: l, plotHeight: u } = t, d = r - n || 1;
5704
6444
  e.strokeStyle = i.grid, e.lineWidth = .5, e.fillStyle = i.axisLabel, e.font = `${i.font.sizeSmall}px ${i.font.family}`, e.textAlign = "right", e.textBaseline = "middle";
5705
6445
  let p = f(n, r, 5), m = Math.ceil(n / p) * p;
@@ -5718,7 +6458,7 @@ function ar(e, t, n, r, i, a) {
5718
6458
  e.strokeStyle = i.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(o, t), e.lineTo(s, t), e.stroke();
5719
6459
  }
5720
6460
  }
5721
- function or(e, t, n) {
6461
+ function Br(e, t, n) {
5722
6462
  let r = [
5723
6463
  "positive",
5724
6464
  "negative",
@@ -5737,7 +6477,7 @@ function or(e, t, n) {
5737
6477
  s && (e.fillStyle = o, e.fill());
5738
6478
  }
5739
6479
  }
5740
- function sr(e, t, n, r, i, a, o) {
6480
+ function Vr(e, t, n, r, i, a, o) {
5741
6481
  if (o === "none" || t.length < 2) return;
5742
6482
  let { bottom: s, plotHeight: c } = n;
5743
6483
  e.strokeStyle = a, e.lineWidth = 1, o === "dashed" ? e.setLineDash([4, 4]) : e.setLineDash([]), e.beginPath();
@@ -5747,7 +6487,7 @@ function sr(e, t, n, r, i, a, o) {
5747
6487
  }
5748
6488
  e.stroke(), e.setLineDash([]);
5749
6489
  }
5750
- function cr(e, t, n, r, i, a) {
6490
+ function Hr(e, t, n, r, i, a) {
5751
6491
  e.fillStyle = r.text, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center";
5752
6492
  for (let r = 0; r < t.length; r++) {
5753
6493
  let o = t[r], s;
@@ -5756,7 +6496,7 @@ function cr(e, t, n, r, i, a) {
5756
6496
  o.end < o.start ? (e.textBaseline = "top", e.fillText(s, c, o.rectY + o.rectH + 4)) : (e.textBaseline = "bottom", e.fillText(s, c, o.rectY - 4));
5757
6497
  }
5758
6498
  }
5759
- function lr(e, t, n, r, i) {
6499
+ function Ur(e, t, n, r, i) {
5760
6500
  e.fillStyle = r.axisLabel, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center", e.textBaseline = "top";
5761
6501
  let a = n.bottom + 6, o = t.length > 0 ? t[0].slotW - 4 : 0, s = !1;
5762
6502
  for (let n = 0; n < t.length; n++) if (e.measureText(i(t[n].label)).width > o) {
@@ -5777,7 +6517,7 @@ function lr(e, t, n, r, i) {
5777
6517
  }
5778
6518
  e.setTransform(1, 0, 0, 1, 0, 0), e.restore();
5779
6519
  }
5780
- function ur(e, t, n) {
6520
+ function Wr(e, t, n) {
5781
6521
  if (t < n.left || t > n.right) return null;
5782
6522
  for (let n = 0; n < e.length; n++) {
5783
6523
  let r = e[n];
@@ -5785,7 +6525,7 @@ function ur(e, t, n) {
5785
6525
  }
5786
6526
  return null;
5787
6527
  }
5788
- function dr(e, t, n, r, i, a, o, s) {
6528
+ function Gr(e, t, n, r, i, a, o, s) {
5789
6529
  let c = t[r], l = n[r], u = Math.round(c.slotX + c.slotW / 2) + .5;
5790
6530
  e.strokeStyle = o.crosshair, e.lineWidth = .5, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(u, a.top), e.lineTo(u, a.bottom), e.stroke(), e.setLineDash([]);
5791
6531
  let d = [
@@ -5804,31 +6544,31 @@ function dr(e, t, n, r, i, a, o, s) {
5804
6544
  let _ = o.font.sizeSmall + 4;
5805
6545
  for (let t = 0; t < d.length; t++) e.fillText(d[t], h + 8, g + 6 + t * _);
5806
6546
  }
5807
- function fr(e, t, n, r, i, a) {
6547
+ function Kr(e, t, n, r, i, a) {
5808
6548
  let { data: o } = r;
5809
6549
  if (!o || o.length === 0 || t <= 0 || n <= 0) return { hitBar: null };
5810
- let s = r.positiveColor ?? i.candleUp, c = r.negativeColor ?? i.candleDown, l = r.totalColor ?? i.lineColor, u = r.subtotalColor ?? i.textSecondary, d = r.connectorColor ?? i.textSecondary, f = r.connectorStyle ?? "dashed", p = r.barWidth ?? Zn, m = r.showValues !== !1, h = r.showDelta !== !1, g = r.valueFormat ?? er, _ = r.labelFormat ?? ((e) => e), { valMin: v, valMax: y } = rr(o), b = y - v || 1, x = tr(t, n), { bars: S, cumulatives: C } = nr(o, x, p, v, b);
5811
- ir(e, t, n, i.background), ar(e, x, v, y, i, g), sr(e, S, x, v, b, d, f), or(e, S, {
6550
+ let s = r.positiveColor ?? i.candleUp, c = r.negativeColor ?? i.candleDown, l = r.totalColor ?? i.lineColor, u = r.subtotalColor ?? i.textSecondary, d = r.connectorColor ?? i.textSecondary, f = r.connectorStyle ?? "dashed", p = r.barWidth ?? jr, m = r.showValues !== !1, h = r.showDelta !== !1, g = r.valueFormat ?? Pr, _ = r.labelFormat ?? ((e) => e), { valMin: v, valMax: y } = Lr(o), b = y - v || 1, x = Fr(t, n), { bars: S, cumulatives: C } = Ir(o, x, p, v, b);
6551
+ Rr(e, t, n, i.background), zr(e, x, v, y, i, g), Vr(e, S, x, v, b, d, f), Br(e, S, {
5812
6552
  positive: s,
5813
6553
  negative: c,
5814
6554
  total: l,
5815
6555
  subtotal: u
5816
- }), m && cr(e, S, C, i, g, h), lr(e, S, x, i, _);
5817
- let w = a ? ur(S, a.x, x) : null;
5818
- return a && w !== null && dr(e, S, C, w, a, x, i, g), { hitBar: w };
6556
+ }), m && Hr(e, S, C, i, g, h), Ur(e, S, x, i, _);
6557
+ let w = a ? Wr(S, a.x, x) : null;
6558
+ return a && w !== null && Gr(e, S, C, w, a, x, i, g), { hitBar: w };
5819
6559
  }
5820
6560
  //#endregion
5821
6561
  //#region src/finance/GaugeRenderer.ts
5822
- var pr = Math.PI / 180, mr = 135, hr = 405, gr = .25;
5823
- function _r(e) {
6562
+ var qr = Math.PI / 180, Jr = 135, Yr = 405, Xr = .25;
6563
+ function Zr(e) {
5824
6564
  let t = Math.abs(e);
5825
6565
  return t >= 1e6 ? (e / 1e6).toFixed(2) + "M" : t >= 1e3 ? (e / 1e3).toFixed(1) + "K" : Number.isInteger(e) ? e.toFixed(0) : e.toFixed(1);
5826
6566
  }
5827
6567
  function Q(e, t, n) {
5828
6568
  return e < t ? t : e > n ? n : e;
5829
6569
  }
5830
- function vr(e, t, n) {
5831
- let r = n.min ?? 0, i = n.max ?? 100, a = i - r || 1, o = (n.startAngle ?? mr) * pr, s = (n.endAngle ?? hr) * pr, c = n.thickness ?? gr, l = e / 2, u = t / 2 + t * .05, d = Math.max(10, Math.min(e, t) / 2 - 24);
6570
+ function Qr(e, t, n) {
6571
+ let r = n.min ?? 0, i = n.max ?? 100, a = i - r || 1, o = (n.startAngle ?? Jr) * qr, s = (n.endAngle ?? Yr) * qr, c = n.thickness ?? Xr, l = e / 2, u = t / 2 + t * .05, d = Math.max(10, Math.min(e, t) / 2 - 24);
5832
6572
  return {
5833
6573
  cx: l,
5834
6574
  cy: u,
@@ -5846,38 +6586,38 @@ function $(e, t) {
5846
6586
  let n = Q((e - t.min) / t.range, 0, 1);
5847
6587
  return t.startAngle + t.angleRange * n;
5848
6588
  }
5849
- function yr(e, t, n, r) {
6589
+ function $r(e, t, n, r) {
5850
6590
  e.fillStyle = r, e.fillRect(0, 0, t, n);
5851
6591
  }
5852
- function br(e, t, n) {
6592
+ function ei(e, t, n) {
5853
6593
  e.beginPath(), e.arc(t.cx, t.cy, t.radius, t.startAngle, t.endAngle, !1), e.arc(t.cx, t.cy, t.innerRadius, t.endAngle, t.startAngle, !0), e.closePath(), e.fillStyle = n, e.fill();
5854
6594
  }
5855
- function xr(e, t, n) {
6595
+ function ti(e, t, n) {
5856
6596
  let r = Q(n.from, t.min, t.max), i = Q(n.to, t.min, t.max);
5857
6597
  if (i <= r) return;
5858
6598
  let a = $(r, t), o = $(i, t);
5859
6599
  e.beginPath(), e.arc(t.cx, t.cy, t.radius, a, o, !1), e.arc(t.cx, t.cy, t.innerRadius, o, a, !0), e.closePath(), e.fillStyle = n.color, e.fill();
5860
6600
  }
5861
- function Sr(e, t, n, r, i) {
6601
+ function ni(e, t, n, r, i) {
5862
6602
  let a = $(n, t);
5863
6603
  a <= t.startAngle || (e.globalAlpha = i, e.beginPath(), e.arc(t.cx, t.cy, t.radius, t.startAngle, a, !1), e.arc(t.cx, t.cy, t.innerRadius, a, t.startAngle, !0), e.closePath(), e.fillStyle = r, e.fill(), e.globalAlpha = 1);
5864
6604
  }
5865
- function Cr(e, t, n, r) {
6605
+ function ri(e, t, n, r) {
5866
6606
  let i = $(n, t), a = Math.cos(i), o = Math.sin(i), s = t.radius - 2, c = t.innerRadius * .25, l = -o, u = a, d = t.cx + a * s, f = t.cy + o * s, p = t.cx + l * 4 - a * c, m = t.cy + u * 4 - o * c, h = t.cx - l * 4 - a * c, g = t.cy - u * 4 - o * c;
5867
6607
  e.beginPath(), e.moveTo(d, f), e.lineTo(p, m), e.lineTo(h, g), e.closePath(), e.fillStyle = r, e.fill(), e.beginPath(), e.arc(t.cx, t.cy, Math.max(4, t.innerRadius * .12), 0, Math.PI * 2), e.fill();
5868
6608
  }
5869
- function wr(e, t, n, r, i) {
6609
+ function ii(e, t, n, r, i) {
5870
6610
  let a = Math.round(t.innerRadius * .55), o = Math.round(i.font.sizeMedium);
5871
6611
  e.fillStyle = i.text, e.textAlign = "center", e.textBaseline = "middle", e.font = `600 ${a}px ${i.font.family}`;
5872
6612
  let s = !!r, c = s ? t.cy - o * .6 : t.cy - a * .1;
5873
6613
  e.fillText(n, t.cx, c), s && (e.fillStyle = i.textSecondary, e.font = `${o}px ${i.font.family}`, e.fillText(r, t.cx, t.cy + a * .55));
5874
6614
  }
5875
- function Tr(e, t, n, r) {
6615
+ function ai(e, t, n, r) {
5876
6616
  e.fillStyle = r.textSecondary, e.font = `${r.font.sizeSmall}px ${r.font.family}`;
5877
6617
  let i = t.radius + 10, a = Math.cos(t.startAngle), o = Math.sin(t.startAngle), s = Math.cos(t.endAngle), c = Math.sin(t.endAngle), l = t.cx + a * i, u = t.cy + o * i, d = t.cx + s * i, f = t.cy + c * i;
5878
6618
  e.textBaseline = "middle", e.textAlign = a < -.2 ? "right" : a > .2 ? "left" : "center", e.fillText(n(t.min), l, u), e.textAlign = s < -.2 ? "right" : s > .2 ? "left" : "center", e.fillText(n(t.max), d, f);
5879
6619
  }
5880
- function Er(e, t, n, r) {
6620
+ function oi(e, t, n, r) {
5881
6621
  e.fillStyle = r.textSecondary, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center", e.textBaseline = "middle";
5882
6622
  let i = (t.radius + t.innerRadius) / 2;
5883
6623
  for (let r = 0; r < n.length; r++) {
@@ -5887,15 +6627,15 @@ function Er(e, t, n, r) {
5887
6627
  e.fillText(a.label, s, c);
5888
6628
  }
5889
6629
  }
5890
- function Dr(e, t, n, r, i, a) {
6630
+ function si(e, t, n, r, i, a) {
5891
6631
  if (t <= 0 || n <= 0) return;
5892
- let o = vr(t, n, r), s = r.trackColor ?? i.grid, c = r.needleColor ?? i.text, l = r.showValue !== !1, u = r.showZoneLabels === !0, d = r.valueFormat ?? _r, f = Q(a, o.min, o.max);
5893
- yr(e, t, n, i.background), br(e, o, s);
6632
+ let o = Qr(t, n, r), s = r.trackColor ?? i.grid, c = r.needleColor ?? i.text, l = r.showValue !== !1, u = r.showZoneLabels === !0, d = r.valueFormat ?? Zr, f = Q(a, o.min, o.max);
6633
+ $r(e, t, n, i.background), ei(e, o, s);
5894
6634
  let p = r.zones;
5895
- if (p && p.length > 0) for (let t = 0; t < p.length; t++) xr(e, o, p[t]);
5896
- Sr(e, o, f, c, .12), Cr(e, o, f, c), l && wr(e, o, d(f), r.label, i), Tr(e, o, d, i), u && p && p.length > 0 && Er(e, o, p, i);
6635
+ if (p && p.length > 0) for (let t = 0; t < p.length; t++) ti(e, o, p[t]);
6636
+ ni(e, o, f, c, .12), ri(e, o, f, c), l && ii(e, o, d(f), r.label, i), ai(e, o, d, i), u && p && p.length > 0 && oi(e, o, p, i);
5897
6637
  }
5898
6638
  //#endregion
5899
- export { je as ADXIndicator, Ae as ATRIndicator, Pe as AccumulationDistributionIndicator, Jt as AlertManager, Tt as AnchoredVWAPTool, en as Animator, te as AreaRenderer, P as AroonIndicator, xt as ArrowTool, Gt as BarCountdown, ne as BarRenderer, nn as BaseFinanceChart, ie as BaselineRenderer, zt as BinanceAdapter, be as BollingerBandsIndicator, M as CCIIndicator, L as CMFIndicator, A as CandlestickRenderer, v as CanvasLayer, Ht as ChartLegend, Xt as ChartStateManager, le as CompareRenderer, Ke as CrosshairHandler, Je as CrosshairTooltip, It as CurrentPriceLine, Vt as DEFAULT_LEGEND_CONFIG, x as DPRManager, Qt as DataExporter, vt as DateRangeTool, At as DepthOverlay, Ee as DonchianChannelIndicator, V as DrawingBase, $e as DrawingManager, et as DrawingRenderer, ye as EMAIndicator, $t as Easing, gt as ElliottWaveTool, ft as EllipseTool, G as Emitter, Ze as EventBus, at as ExtendedLineTool, ut as FibExtensionTool, ct as FibRetracementTool, rn as FinanceCrosshair, wt as GannBoxTool, Ct as GannFanTool, Le as GridRenderer, re as HollowCandleRenderer, nt as HorizontalLineTool, Se as IchimokuIndicator, j as IndicatorBase, _e as IndicatorEngine, Ue as InteractionManager, oe as KagiRenderer, Te as KeltnerChannelIndicator, qe as KeyboardHandler, y as LayerManager, ee as LineRenderer, Oe as MACDIndicator, N as MFIIndicator, yt as MeasureTool, Bt as MockAdapter, Me as OBVIndicator, Ot as OrderRenderer, We as PanHandler, Ce as ParabolicSARIndicator, ot as ParallelChannelTool, mt as PitchforkTool, se as PointAndFigureRenderer, kt as PositionRenderer, Re as PriceAxis, _t as PriceRangeTool, F as ROCIndicator, De as RSIIndicator, it as RayTool, K as ReconnectManager, dt as RectangleTool, st as RegressionChannelTool, D as RenderEngine, b as RenderLoop, ae as RenkoRenderer, Yt as ReplayManager, ve as SMAIndicator, Ut as Screenshot, Kt as SessionBreaks, R as StdDevIndicator, ke as StochasticIndicator, Lt as StreamManager, we as SupertrendIndicator, I as TSIIndicator, bt as TextAnnotationTool, Ft as TickAggregator, He as TimeAxis, Mt as TradingContextMenu, jt as TradingDragHandler, Nt as TradingManager, Pt as TradingRenderer, tt as TrendLineTool, pt as TriangleTool, Zt as UndoRedoManager, Fe as VROCIndicator, xe as VWAPIndicator, rt as VerticalLineTool, O as Viewport, z as VolumeProfileIndicator, Et as VolumeProfileRangeTool, ce as VolumeRenderer, Wt as Watermark, Ne as WilliamsRIndicator, Ge as ZoomHandler, S as barIndexToX, k as getVisibleData, Vn as layoutSquarifiedTreemap, Rn as layoutUniformGrid, C as priceToY, Dt as registerBuiltInDrawingTools, Ie as registerBuiltInIndicators, yn as renderDepthChart, Ln as renderEquityCurve, Dr as renderGauge, qn as renderHeatmap, an as renderSparkline, fr as renderWaterfall, E as timestampToBarIndex, ue as toHeikinAshi, me as toKagi, pe as toLineBreak, he as toPointAndFigure, de as toRenko, w as xToBarIndex, T as yToPrice };
6639
+ export { Be as ADXIndicator, ze as ATRIndicator, Ze as AccumulationDistributionIndicator, Sn as AlertManager, Oe as AnchoredVWAPIndicator, Gt as AnchoredVWAPTool, Pn as Animator, te as AreaRenderer, Ge as AroonIndicator, Vt as ArrowTool, Pe as AwesomeOscillatorIndicator, yn as BarCountdown, ne as BarRenderer, In as BaseFinanceChart, ie as BaselineRenderer, pn as BinanceAdapter, F as BollingerBandsIndicator, Ue as CCIIndicator, Je as CMFIndicator, A as CandlestickRenderer, v as CanvasLayer, Fe as ChaikinOscillatorIndicator, gn as ChartLegend, An as ChartStateManager, le as CompareRenderer, dt as CrosshairHandler, pt as CrosshairTooltip, sn as CurrentPriceLine, hn as DEFAULT_LEGEND_CONFIG, x as DPRManager, Mn as DataExporter, Lt as DateRangeTool, tn as DepthOverlay, Te as DonchianChannelIndicator, L as DrawingBase, vt as DrawingManager, yt as DrawingRenderer, P as EMAIndicator, Nn as Easing, Ft as ElliottWaveTool, jt as EllipseTool, H as Emitter, gt as EventBus, wt as ExtendedLineTool, kt as FibExtensionTool, Dt as FibRetracementTool, Ln as FinanceCrosshair, Wt as GannBoxTool, Ut as GannFanTool, nt as GridRenderer, re as HollowCandleRenderer, xt as HorizontalLineTool, je as HullMAIndicator, xe as IchimokuIndicator, j as IndicatorBase, ve as IndicatorEngine, tt as IndicatorWorkerHost, ct as InteractionManager, oe as KagiRenderer, we as KeltnerChannelIndicator, ft as KeyboardHandler, y as LayerManager, ee as LineRenderer, Ae as LinearRegressionChannelIndicator, Le as MACDIndicator, We as MFIIndicator, Rt as MeasureTool, mn as MockAdapter, Ve as OBVIndicator, Jt as OrderRenderer, lt as PanHandler, Se as ParabolicSARIndicator, Tt as ParallelChannelTool, Nt as PitchforkTool, De as PivotPointsIndicator, se as PointAndFigureRenderer, en as PositionRenderer, rt as PriceAxis, It as PriceRangeTool, Ke as ROCIndicator, Ie as RSIIndicator, Ct as RayTool, U as ReconnectManager, At as RectangleTool, Et as RegressionChannelTool, D as RenderEngine, b as RenderLoop, ae as RenkoRenderer, Cn as ReplayManager, ye as SMAIndicator, _n as Screenshot, bn as SessionBreaks, Ye as StdDevIndicator, Re as StochasticIndicator, cn as StreamManager, Ce as SupertrendIndicator, qe as TSIIndicator, Bt as TextAnnotationTool, on as TickAggregator, st as TimeAxis, V as TradingContextMenu, nn as TradingDragHandler, rn as TradingManager, an as TradingRenderer, bt as TrendLineTool, Mt as TriangleTool, jn as UndoRedoManager, Qe as VROCIndicator, be as VWAPIndicator, St as VerticalLineTool, O as Viewport, Xe as VolumeProfileIndicator, Kt as VolumeProfileRangeTool, ce as VolumeRenderer, vn as Watermark, He as WilliamsRIndicator, ke as ZigZagIndicator, ut as ZoomHandler, S as barIndexToX, N as getIntParam, M as getNumberParam, k as getVisibleData, et as isWorkerResponse, br as layoutSquarifiedTreemap, _r as layoutUniformGrid, C as priceToY, qt as registerBuiltInDrawingTools, $e as registerBuiltInIndicators, Qn as renderDepthChart, gr as renderEquityCurve, si as renderGauge, Er as renderHeatmap, Rn as renderSparkline, Kr as renderWaterfall, E as timestampToBarIndex, ue as toHeikinAshi, me as toKagi, pe as toLineBreak, he as toPointAndFigure, ge as toRangeBars, de as toRenko, w as xToBarIndex, T as yToPrice };
5900
6640
 
5901
6641
  //# sourceMappingURL=index.js.map