@pradeepjadhav/trading-reload-chart 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -399,7 +399,7 @@ var h = {
399
399
  }
400
400
  }
401
401
  },
402
- pastTradeIndicators: {
402
+ closedTradeIndicators: {
403
403
  visible: !0,
404
404
  arrow: {
405
405
  visible: !0,
@@ -444,9 +444,9 @@ var h = {
444
444
  }, Xt = ({ candleSpacing: t, candleTimeframeMs: e, labelWidth: i, minLabelGap: r }) => {
445
445
  if (t <= 0 || e <= 0) return nt[0];
446
446
  const s = i + r;
447
- for (const o of nt) if (o / e * t >= s) return o;
448
- const n = 1440 * 60 * 1e3, a = n / e * t;
449
- return n * Math.ceil(s / a);
447
+ for (const a of nt) if (a / e * t >= s) return a;
448
+ const n = 1440 * 60 * 1e3, o = n / e * t;
449
+ return n * Math.ceil(s / o);
450
450
  }, At = (t, e) => {
451
451
  const i = new Date(t), r = (i.getHours() * 60 + i.getMinutes()) * 60 * 1e3 + i.getSeconds() * 1e3 + i.getMilliseconds();
452
452
  return e >= 1440 * 60 * 1e3 ? r === 0 : r % e === 0;
@@ -491,8 +491,8 @@ var h = {
491
491
  if (!this.crosshair.visible || !this.crosshair.candle) return;
492
492
  const t = this.#e, e = this.#t.width, i = this.#t.height, r = c.axis.axisX.crosshairLabel, s = Ft(this.crosshair.candle.time);
493
493
  t.save(), t.font = r.font;
494
- const n = t.measureText(s).width + r.paddingX * 2, a = r.height, o = this.getCrosshairLabelX(n, e), l = Math.max(0, (i - a) / 2);
495
- t.fillStyle = r.backgroundColor, t.fillRect(o, l, n, a), t.strokeStyle = r.borderColor, t.lineWidth = r.borderWidth, t.strokeRect(o, l, n, a), t.fillStyle = r.textColor, t.textAlign = "center", t.textBaseline = "middle", t.fillText(s, o + n / 2, l + a / 2), t.restore();
494
+ const n = t.measureText(s).width + r.paddingX * 2, o = r.height, a = this.getCrosshairLabelX(n, e), l = Math.max(0, (i - o) / 2);
495
+ t.fillStyle = r.backgroundColor, t.fillRect(a, l, n, o), t.strokeStyle = r.borderColor, t.lineWidth = r.borderWidth, t.strokeRect(a, l, n, o), t.fillStyle = r.textColor, t.textAlign = "center", t.textBaseline = "middle", t.fillText(s, a + n / 2, l + o / 2), t.restore();
496
496
  }
497
497
  clearCanvas() {
498
498
  this.#e.clearRect(0, 0, this.#t.width, this.#t.height);
@@ -514,8 +514,8 @@ var h = {
514
514
  candleTimeframeMs: r,
515
515
  labelWidth: s,
516
516
  minLabelGap: e.minLabelGap
517
- }), { startIndex: a, endIndex: o } = this.getVisibleCandleIndexRange(i);
518
- for (let l = a; l <= o; l += 1) {
517
+ }), { startIndex: o, endIndex: a } = this.getVisibleCandleIndexRange(i);
518
+ for (let l = o; l <= a; l += 1) {
519
519
  const d = this.getSlotTime(l, r);
520
520
  if (d === null || !At(d, n)) continue;
521
521
  const u = this.getCandleCenterX(l), g = It(d), m = t.measureText(g).width;
@@ -604,8 +604,8 @@ var h = {
604
604
  }
605
605
  drawCrosshairPriceLabel() {
606
606
  if (!this.crosshair.visible) return;
607
- const t = this.#e, e = this.#t.width, i = this.#t.height, r = c.axis.axisY.crosshairLabel, s = p(this.crosshair.price).toFixed(5), n = r.height, a = this.getCrosshairLabelY(n, i);
608
- t.save(), t.fillStyle = r.backgroundColor, t.fillRect(0, a, e, n), t.strokeStyle = r.borderColor, t.lineWidth = r.borderWidth, t.strokeRect(0, a, e, n), t.font = r.font, t.fillStyle = r.textColor, t.textAlign = "left", t.textBaseline = "middle", t.fillText(s, r.paddingX, a + n / 2), t.restore();
607
+ const t = this.#e, e = this.#t.width, i = this.#t.height, r = c.axis.axisY.crosshairLabel, s = p(this.crosshair.price).toFixed(5), n = r.height, o = this.getCrosshairLabelY(n, i);
608
+ t.save(), t.fillStyle = r.backgroundColor, t.fillRect(0, o, e, n), t.strokeStyle = r.borderColor, t.lineWidth = r.borderWidth, t.strokeRect(0, o, e, n), t.font = r.font, t.fillStyle = r.textColor, t.textAlign = "left", t.textBaseline = "middle", t.fillText(s, r.paddingX, o + n / 2), t.restore();
609
609
  }
610
610
  clearCanvas() {
611
611
  this.#e.clearRect(0, 0, this.#t.width, this.#t.height);
@@ -626,9 +626,9 @@ var h = {
626
626
  });
627
627
  t.save(), t.font = i.font, t.fillStyle = i.textColor, t.textAlign = i.textAlign, t.textBaseline = "middle";
628
628
  const { startPrice: s, endPrice: n } = this.getVisiblePriceRange(r);
629
- for (let a = s; a <= n; a += r) {
630
- const o = this.getPriceY(a, e);
631
- this.isPriceOutsideCanvas(o, e) || (this.drawTick(o), this.drawPriceLabel(a, o));
629
+ for (let o = s; o <= n; o += r) {
630
+ const a = this.getPriceY(o, e);
631
+ this.isPriceOutsideCanvas(a, e) || (this.drawTick(a), this.drawPriceLabel(o, a));
632
632
  }
633
633
  t.restore();
634
634
  }
@@ -868,34 +868,34 @@ var h = {
868
868
  startIndex: r,
869
869
  chartHeight: i
870
870
  });
871
- const a = {
871
+ const o = {
872
872
  ctx: t,
873
873
  chartWidth: e,
874
874
  chartHeight: i
875
875
  };
876
- this.drawAskPriceLine(a), this.drawBidPriceLine(a);
876
+ this.drawAskPriceLine(o), this.drawBidPriceLine(o);
877
877
  }
878
878
  drawCandles({ ctx: t, candles: e, startIndex: i, chartHeight: r }) {
879
879
  e.forEach((s, n) => {
880
- const a = i + n, o = this.getCandleX(a), l = this.getCandleColor(s), d = this.getCandleYCoordinates(s, r);
880
+ const o = i + n, a = this.getCandleX(o), l = this.getCandleColor(s), d = this.getCandleYCoordinates(s, r);
881
881
  this.drawSingleCandle({
882
882
  ctx: t,
883
- candleX: o,
883
+ candleX: a,
884
884
  candleColor: l,
885
885
  ...d
886
886
  });
887
887
  });
888
888
  }
889
- drawSingleCandle({ ctx: t, candleX: e, openY: i, closeY: r, highY: s, lowY: n, candleColor: a }) {
890
- t.strokeStyle = a, t.fillStyle = a;
891
- const o = e + this.candleWidth / 2;
892
- t.beginPath(), t.moveTo(o, s), t.lineTo(o, n), t.stroke();
889
+ drawSingleCandle({ ctx: t, candleX: e, openY: i, closeY: r, highY: s, lowY: n, candleColor: o }) {
890
+ t.strokeStyle = o, t.fillStyle = o;
891
+ const a = e + this.candleWidth / 2;
892
+ t.beginPath(), t.moveTo(a, s), t.lineTo(a, n), t.stroke();
893
893
  const l = Math.min(i, r), d = Math.max(Math.abs(r - i), c.candles.minBodyHeight);
894
894
  t.fillRect(e, l, this.candleWidth, d);
895
895
  }
896
- drawPriceLine({ ctx: t, chartWidth: e, chartHeight: i, price: r, color: s, opacity: n, lineWidth: a, dash: o }) {
896
+ drawPriceLine({ ctx: t, chartWidth: e, chartHeight: i, price: r, color: s, opacity: n, lineWidth: o, dash: a }) {
897
897
  const l = this.getPriceY(p(r), i);
898
- t.save(), t.globalAlpha = n, t.strokeStyle = s, t.lineWidth = a, t.setLineDash(o), t.beginPath(), t.moveTo(0, l), t.lineTo(e, l), t.stroke(), t.restore();
898
+ t.save(), t.globalAlpha = n, t.strokeStyle = s, t.lineWidth = o, t.setLineDash(a), t.beginPath(), t.moveTo(0, l), t.lineTo(e, l), t.stroke(), t.restore();
899
899
  }
900
900
  drawBidPriceLine({ ctx: t, chartWidth: e, chartHeight: i }) {
901
901
  const r = this.candles.at(-1);
@@ -989,8 +989,8 @@ var h = {
989
989
  return Math.max(i, Math.min(s, r));
990
990
  }
991
991
  getNextVerticalPriceRange(t) {
992
- const { speed: e, min: i, max: r } = c.zoom.y, s = 1 - t * e, n = this.priceRange * s, a = this.initialPriceRange * (i / 100), o = this.initialPriceRange * (r / 100);
993
- return Math.max(a, Math.min(n, o));
992
+ const { speed: e, min: i, max: r } = c.zoom.y, s = 1 - t * e, n = this.priceRange * s, o = this.initialPriceRange * (i / 100), a = this.initialPriceRange * (r / 100);
993
+ return Math.max(o, Math.min(n, a));
994
994
  }
995
995
  clearCanvas(t, e, i) {
996
996
  t.clearRect(0, 0, e, i);
@@ -1051,10 +1051,10 @@ var h = {
1051
1051
  chartHeight: r.height
1052
1052
  });
1053
1053
  if (s < 0 || s > r.height) return;
1054
- const { line: n, text: a } = this.#e, o = r.width;
1055
- i.save(), i.font = a.font;
1056
- const l = i.measureText(e).width, d = o / 2, u = l / 2 + a.paddingX;
1057
- i.globalAlpha = n.opacity, i.strokeStyle = n.color, i.lineWidth = n.width, i.setLineDash(n.dash), i.beginPath(), i.moveTo(0, s), i.lineTo(d - u, s), i.stroke(), i.beginPath(), i.moveTo(d + u, s), i.lineTo(o, s), i.stroke(), i.setLineDash([]), i.globalAlpha = 1, i.fillStyle = a.color, i.textAlign = "center", i.textBaseline = "middle", i.fillText(e, d, s), i.restore();
1054
+ const { line: n, text: o } = this.#e, a = r.width;
1055
+ i.save(), i.font = o.font;
1056
+ const l = i.measureText(e).width, d = a / 2, u = l / 2 + o.paddingX;
1057
+ i.globalAlpha = n.opacity, i.strokeStyle = n.color, i.lineWidth = n.width, i.setLineDash(n.dash), i.beginPath(), i.moveTo(0, s), i.lineTo(d - u, s), i.stroke(), i.beginPath(), i.moveTo(d + u, s), i.lineTo(a, s), i.stroke(), i.setLineDash([]), i.globalAlpha = 1, i.fillStyle = o.color, i.textAlign = "center", i.textBaseline = "middle", i.fillText(e, d, s), i.restore();
1058
1058
  }
1059
1059
  }, mt = (t, e) => {
1060
1060
  const i = t.getBoundingClientRect(), r = t.width / i.width, s = t.height / i.height;
@@ -1063,7 +1063,7 @@ var h = {
1063
1063
  y: (e.clientY - i.top) * s
1064
1064
  };
1065
1065
  };
1066
- var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `shape-${Date.now()}-${Math.random().toString(16).slice(2)}`, at = (t, e) => mt(t, e), ot = (t, e) => ({
1066
+ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `shape-${Date.now()}-${Math.random().toString(16).slice(2)}`, ot = (t, e) => mt(t, e), at = (t, e) => ({
1067
1067
  time: e.getNearestCandleTimeForX(t.x),
1068
1068
  price: e.getPriceForY(t.y)
1069
1069
  }), v = (t, e) => ({
@@ -1085,15 +1085,15 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1085
1085
  }, Ct = (t, e, i) => {
1086
1086
  const r = i.x - e.x, s = i.y - e.y, n = r * r + s * s;
1087
1087
  if (n === 0) return $(t, e);
1088
- const a = Math.max(0, Math.min(1, ((t.x - e.x) * r + (t.y - e.y) * s) / n));
1088
+ const o = Math.max(0, Math.min(1, ((t.x - e.x) * r + (t.y - e.y) * s) / n));
1089
1089
  return $(t, {
1090
- x: e.x + a * r,
1091
- y: e.y + a * s
1090
+ x: e.x + o * r,
1091
+ y: e.y + o * s
1092
1092
  });
1093
1093
  }, vt = (t, e, i = 0) => t.x >= e.left - i && t.x <= e.right + i && t.y >= e.top - i && t.y <= e.bottom + i, _t = (t, e, i = 8) => {
1094
1094
  if (!vt(t, e, i)) return !1;
1095
- const r = Math.abs(t.x - e.left) <= i, s = Math.abs(t.x - e.right) <= i, n = Math.abs(t.y - e.top) <= i, a = Math.abs(t.y - e.bottom) <= i, o = t.x >= e.left - i && t.x <= e.right + i, l = t.y >= e.top - i && t.y <= e.bottom + i;
1096
- return (r || s) && l || (n || a) && o;
1095
+ const r = Math.abs(t.x - e.left) <= i, s = Math.abs(t.x - e.right) <= i, n = Math.abs(t.y - e.top) <= i, o = Math.abs(t.y - e.bottom) <= i, a = t.x >= e.left - i && t.x <= e.right + i, l = t.y >= e.top - i && t.y <= e.bottom + i;
1096
+ return (r || s) && l || (n || o) && a;
1097
1097
  }, b = ({ shapeId: t, type: e, point: i, radius: r = 5, cursor: s, index: n }) => ({
1098
1098
  shapeId: t,
1099
1099
  type: e,
@@ -1103,8 +1103,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1103
1103
  cursor: s,
1104
1104
  index: n
1105
1105
  }), J = (t, e) => $(t, e) <= e.radius + 2, E = (t, e = 1) => t === "dashed" ? [e * 6, e * 4] : t === "dotted" ? [e, e * 3] : [], K = (t, e, i) => {
1106
- t.strokeStyle = P(e.lineColor, e.lineOpacity), t.lineWidth = i ?? e.lineWidth, t.setLineDash(E(e.lineStyle, t.lineWidth));
1107
- }, yt = (t, e, i) => !e || i === void 0 || i <= 0 ? !1 : (t.fillStyle = P(e, i), !0), O = (t) => {
1106
+ t.strokeStyle = w(e.lineColor, e.lineOpacity), t.lineWidth = i ?? e.lineWidth, t.setLineDash(E(e.lineStyle, t.lineWidth));
1107
+ }, yt = (t, e, i) => !e || i === void 0 || i <= 0 ? !1 : (t.fillStyle = w(e, i), !0), O = (t) => {
1108
1108
  t.setLineDash([]);
1109
1109
  }, $t = (t, e, i = {
1110
1110
  fillColor: "#ffffff",
@@ -1116,7 +1116,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1116
1116
  e.forEach((r) => {
1117
1117
  $t(t, r, i);
1118
1118
  });
1119
- }, P = (t, e) => {
1119
+ }, w = (t, e) => {
1120
1120
  const i = jt(e, 0, 1);
1121
1121
  return t.startsWith("rgba(") ? t : t.startsWith("rgb(") ? t.replace("rgb(", "rgba(").replace(")", `, ${i})`) : t.startsWith("#") ? Jt(t, i) : t;
1122
1122
  }, Jt = (t, e) => {
@@ -1130,7 +1130,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1130
1130
  n < r && (r = n, i = s);
1131
1131
  }
1132
1132
  return i;
1133
- }, Pt = (t) => {
1133
+ }, wt = (t) => {
1134
1134
  if (t.length < 2) return 900 * 1e3;
1135
1135
  const e = [];
1136
1136
  for (let i = 1; i < t.length; i += 1) {
@@ -1140,7 +1140,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1140
1140
  return e.length === 0 ? 900 * 1e3 : e.reduce((i, r) => i + r, 0) / e.length;
1141
1141
  }, Kt = (t, e, i) => {
1142
1142
  const r = j(t, e), s = r + i;
1143
- return r >= 0 && s >= 0 && s < t.length ? t[s].time : e + Pt(t) * i;
1143
+ return r >= 0 && s >= 0 && s < t.length ? t[s].time : e + wt(t) * i;
1144
1144
  }, ht = (t) => t instanceof MouseEvent && t.type === "contextmenu" ? !1 : "button" in t && t.type === "pointerdown" ? t.button === 0 : !0, S = class D {
1145
1145
  static defaultConfig = {
1146
1146
  levels: [
@@ -1194,14 +1194,14 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1194
1194
  hoverLineWidth: 2,
1195
1195
  selectedLineWidth: 2
1196
1196
  };
1197
- static draw({ ctx: e, shape: i, converter: r, config: s = D.defaultConfig, selected: n = !1, hovered: a = !1 }) {
1198
- const [o, l] = i.vertices, d = v(o, r), u = v(l, r), g = _(o, l, r), m = Math.min(d.x, u.x), w = Math.max(d.x, u.x);
1197
+ static draw({ ctx: e, shape: i, converter: r, config: s = D.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1198
+ const [a, l] = i.vertices, d = v(a, r), u = v(l, r), g = _(a, l, r), m = Math.min(d.x, u.x), P = Math.max(d.x, u.x);
1199
1199
  e.save(), yt(e, s.fillColor, s.fillOpacity) && e.fillRect(g.left, g.top, g.width, g.height);
1200
1200
  for (const C of s.levels) {
1201
- const x = lt(o.price, l.price, C.level), T = r.getYForPrice(x), H = n ? Math.max(C.lineWidth, s.selectedLineWidth) : a ? Math.max(C.lineWidth, s.hoverLineWidth) : C.lineWidth;
1202
- e.beginPath(), e.strokeStyle = P(C.color, C.opacity), e.lineWidth = H, e.setLineDash(E(C.lineStyle, H)), e.moveTo(m, T), e.lineTo(w, T), e.stroke(), C.label && (e.setLineDash([]), e.fillStyle = P(C.color, C.opacity), e.font = "11px sans-serif", e.textBaseline = "middle", e.fillText(Number(C.label).toFixed(2).toString(), w + 12, T));
1201
+ const x = lt(a.price, l.price, C.level), T = r.getYForPrice(x), H = n ? Math.max(C.lineWidth, s.selectedLineWidth) : o ? Math.max(C.lineWidth, s.hoverLineWidth) : C.lineWidth;
1202
+ e.beginPath(), e.strokeStyle = w(C.color, C.opacity), e.lineWidth = H, e.setLineDash(E(C.lineStyle, H)), e.moveTo(m, T), e.lineTo(P, T), e.stroke(), C.label && (e.setLineDash([]), e.fillStyle = w(C.color, C.opacity), e.font = "11px sans-serif", e.textBaseline = "middle", e.fillText(Number(C.label).toFixed(2).toString(), P + 12, T));
1203
1203
  }
1204
- O(e), (n || a) && V(e, D.getHandles(i, r, s), {
1204
+ O(e), (n || o) && V(e, D.getHandles(i, r, s), {
1205
1205
  fillColor: s.handleColor,
1206
1206
  borderColor: s.handleBorderColor,
1207
1207
  borderThickness: s.handleBorderThickness
@@ -1221,26 +1221,26 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1221
1221
  });
1222
1222
  }
1223
1223
  static getHandles(e, i, r = D.defaultConfig) {
1224
- const [s, n] = e.vertices, a = v(s, i), o = v(n, i);
1224
+ const [s, n] = e.vertices, o = v(s, i), a = v(n, i);
1225
1225
  return [b({
1226
1226
  shapeId: e.id,
1227
1227
  type: "start",
1228
- point: a,
1228
+ point: o,
1229
1229
  radius: r.handleRadius,
1230
1230
  cursor: "grab"
1231
1231
  }), b({
1232
1232
  shapeId: e.id,
1233
1233
  type: "end",
1234
- point: o,
1234
+ point: a,
1235
1235
  radius: r.handleRadius,
1236
1236
  cursor: "grab"
1237
1237
  })];
1238
1238
  }
1239
1239
  static hitTest({ point: e, shape: i, converter: r, tolerance: s = 8, config: n = D.defaultConfig }) {
1240
- const [a, o] = i.vertices, l = v(a, r), d = v(o, r), u = Math.min(l.x, d.x), g = Math.max(l.x, d.x);
1240
+ const [o, a] = i.vertices, l = v(o, r), d = v(a, r), u = Math.min(l.x, d.x), g = Math.max(l.x, d.x);
1241
1241
  if (e.x < u - s || e.x > g + s) return !1;
1242
1242
  for (const m of n.levels) {
1243
- const w = lt(a.price, o.price, m.level), C = r.getYForPrice(w);
1243
+ const P = lt(o.price, a.price, m.level), C = r.getYForPrice(P);
1244
1244
  if (Math.abs(e.y - C) <= s) return !0;
1245
1245
  }
1246
1246
  return !1;
@@ -1279,9 +1279,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1279
1279
  hoverLineWidth: 3,
1280
1280
  selectedLineWidth: 3
1281
1281
  };
1282
- static draw({ ctx: e, shape: i, converter: r, config: s = I.defaultConfig, selected: n = !1, hovered: a = !1 }) {
1283
- const [o, l] = i.vertices, d = v(o, r), u = v(l, r);
1284
- e.save(), K(e, s, n ? s.selectedLineWidth : a ? s.hoverLineWidth : void 0), e.beginPath(), e.moveTo(d.x, d.y), e.lineTo(u.x, u.y), e.stroke(), O(e), (n || a) && V(e, I.getHandles(i, r, s), {
1282
+ static draw({ ctx: e, shape: i, converter: r, config: s = I.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1283
+ const [a, l] = i.vertices, d = v(a, r), u = v(l, r);
1284
+ e.save(), K(e, s, n ? s.selectedLineWidth : o ? s.hoverLineWidth : void 0), e.beginPath(), e.moveTo(d.x, d.y), e.lineTo(u.x, u.y), e.stroke(), O(e), (n || o) && V(e, I.getHandles(i, r, s), {
1285
1285
  fillColor: s.handleColor,
1286
1286
  borderColor: s.handleBorderColor,
1287
1287
  borderThickness: s.handleBorderThickness
@@ -1301,24 +1301,24 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1301
1301
  });
1302
1302
  }
1303
1303
  static getHandles(e, i, r = I.defaultConfig) {
1304
- const [s, n] = e.vertices, a = v(s, i), o = v(n, i);
1304
+ const [s, n] = e.vertices, o = v(s, i), a = v(n, i);
1305
1305
  return [b({
1306
1306
  shapeId: e.id,
1307
1307
  type: "start",
1308
- point: a,
1308
+ point: o,
1309
1309
  radius: r.handleRadius,
1310
1310
  cursor: "grab"
1311
1311
  }), b({
1312
1312
  shapeId: e.id,
1313
1313
  type: "end",
1314
- point: o,
1314
+ point: a,
1315
1315
  radius: r.handleRadius,
1316
1316
  cursor: "grab"
1317
1317
  })];
1318
1318
  }
1319
1319
  static hitTest({ point: e, shape: i, converter: r, tolerance: s = 8 }) {
1320
- const [n, a] = i.vertices;
1321
- return Ct(e, v(n, r), v(a, r)) <= s;
1320
+ const [n, o] = i.vertices;
1321
+ return Ct(e, v(n, r), v(o, r)) <= s;
1322
1322
  }
1323
1323
  static move(e, i) {
1324
1324
  return {
@@ -1356,19 +1356,19 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1356
1356
  hoverLineWidth: 3,
1357
1357
  selectedLineWidth: 3
1358
1358
  };
1359
- static draw({ ctx: e, shape: i, converter: r, config: s = B.defaultConfig, selected: n = !1, hovered: a = !1 }) {
1360
- const o = i.vertices.map((l) => v(l, r));
1361
- if (o.length !== 0) {
1362
- e.save(), K(e, s, n ? s.selectedLineWidth : a ? s.hoverLineWidth : void 0), e.beginPath(), e.moveTo(o[0].x, o[0].y);
1363
- for (let l = 1; l < o.length; l += 1) e.lineTo(o[l].x, o[l].y);
1364
- e.stroke(), O(e), o.length >= 2 && B.drawEndArrow({
1359
+ static draw({ ctx: e, shape: i, converter: r, config: s = B.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1360
+ const a = i.vertices.map((l) => v(l, r));
1361
+ if (a.length !== 0) {
1362
+ e.save(), K(e, s, n ? s.selectedLineWidth : o ? s.hoverLineWidth : void 0), e.beginPath(), e.moveTo(a[0].x, a[0].y);
1363
+ for (let l = 1; l < a.length; l += 1) e.lineTo(a[l].x, a[l].y);
1364
+ e.stroke(), O(e), a.length >= 2 && B.drawEndArrow({
1365
1365
  ctx: e,
1366
- previousPoint: o[o.length - 2],
1367
- endPoint: o[o.length - 1],
1366
+ previousPoint: a[a.length - 2],
1367
+ endPoint: a[a.length - 1],
1368
1368
  color: s.lineColor,
1369
1369
  opacity: s.lineOpacity,
1370
- lineWidth: n ? s.selectedLineWidth ?? s.lineWidth : a ? s.hoverLineWidth ?? s.lineWidth : s.lineWidth
1371
- }), (n || a) && V(e, B.getHandles(i, r, s), {
1370
+ lineWidth: n ? s.selectedLineWidth ?? s.lineWidth : o ? s.hoverLineWidth ?? s.lineWidth : s.lineWidth
1371
+ }), (n || o) && V(e, B.getHandles(i, r, s), {
1372
1372
  fillColor: s.handleColor,
1373
1373
  borderColor: s.handleBorderColor,
1374
1374
  borderThickness: s.handleBorderThickness
@@ -1376,13 +1376,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1376
1376
  }
1377
1377
  }
1378
1378
  static drawDraft({ ctx: e, vertices: i, previewVertex: r, converter: s, config: n = B.defaultConfig }) {
1379
- const a = r ? [...i, r] : i;
1379
+ const o = r ? [...i, r] : i;
1380
1380
  B.draw({
1381
1381
  ctx: e,
1382
1382
  shape: {
1383
1383
  id: "__draft_path__",
1384
1384
  type: "path",
1385
- vertices: a
1385
+ vertices: o
1386
1386
  },
1387
1387
  converter: s,
1388
1388
  config: n,
@@ -1400,12 +1400,12 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1400
1400
  }));
1401
1401
  }
1402
1402
  static hitTest({ point: e, shape: i, converter: r, tolerance: s = 8 }) {
1403
- const n = i.vertices.map((a) => v(a, r));
1403
+ const n = i.vertices.map((o) => v(o, r));
1404
1404
  if (n.length === 1) {
1405
- const a = n[0], o = e.x - a.x, l = e.y - a.y;
1406
- return Math.sqrt(o * o + l * l) <= s;
1405
+ const o = n[0], a = e.x - o.x, l = e.y - o.y;
1406
+ return Math.sqrt(a * a + l * l) <= s;
1407
1407
  }
1408
- for (let a = 1; a < n.length; a += 1) if (Ct(e, n[a - 1], n[a]) <= s) return !0;
1408
+ for (let o = 1; o < n.length; o += 1) if (Ct(e, n[o - 1], n[o]) <= s) return !0;
1409
1409
  return !1;
1410
1410
  }
1411
1411
  static move(e, i) {
@@ -1423,9 +1423,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1423
1423
  vertices: e.vertices.map((s, n) => n === i ? r : s)
1424
1424
  };
1425
1425
  }
1426
- static drawEndArrow({ ctx: e, previousPoint: i, endPoint: r, color: s, opacity: n, lineWidth: a }) {
1427
- const o = Math.atan2(r.y - i.y, r.x - i.x), l = 12, d = Math.PI / 7;
1428
- e.save(), e.beginPath(), e.strokeStyle = P(s, n), e.fillStyle = P(s, n), e.lineWidth = a, e.setLineDash([]), e.moveTo(r.x, r.y), e.lineTo(r.x - l * Math.cos(o - d), r.y - l * Math.sin(o - d)), e.lineTo(r.x - l * Math.cos(o + d), r.y - l * Math.sin(o + d)), e.closePath(), e.fill(), e.stroke(), e.restore();
1426
+ static drawEndArrow({ ctx: e, previousPoint: i, endPoint: r, color: s, opacity: n, lineWidth: o }) {
1427
+ const a = Math.atan2(r.y - i.y, r.x - i.x), l = 12, d = Math.PI / 7;
1428
+ e.save(), e.beginPath(), e.strokeStyle = w(s, n), e.fillStyle = w(s, n), e.lineWidth = o, e.setLineDash([]), e.moveTo(r.x, r.y), e.lineTo(r.x - l * Math.cos(a - d), r.y - l * Math.sin(a - d)), e.lineTo(r.x - l * Math.cos(a + d), r.y - l * Math.sin(a + d)), e.closePath(), e.fill(), e.stroke(), e.restore();
1429
1429
  }
1430
1430
  }, R = class X {
1431
1431
  static defaultConfig = {
@@ -1446,9 +1446,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1446
1446
  textFontFamily: "Arial",
1447
1447
  textFontSize: 20
1448
1448
  };
1449
- static draw({ ctx: e, shape: i, converter: r, config: s = X.defaultConfig, selected: n = !1, hovered: a = !1 }) {
1450
- const [o, l] = i.vertices, d = _(o, l, r);
1451
- e.save(), yt(e, s.fillColor, s.fillOpacity) && e.fillRect(d.left, d.top, d.width, d.height), K(e, s, n ? s.selectedLineWidth : a ? s.hoverLineWidth : void 0), e.strokeRect(d.left, d.top, d.width, d.height), O(e), X.drawText(e, d, i.text, s), (n || a) && V(e, X.getHandles(i, r, s), {
1449
+ static draw({ ctx: e, shape: i, converter: r, config: s = X.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1450
+ const [a, l] = i.vertices, d = _(a, l, r);
1451
+ e.save(), yt(e, s.fillColor, s.fillOpacity) && e.fillRect(d.left, d.top, d.width, d.height), K(e, s, n ? s.selectedLineWidth : o ? s.hoverLineWidth : void 0), e.strokeRect(d.left, d.top, d.width, d.height), O(e), X.drawText(e, d, i.text, s), (n || o) && V(e, X.getHandles(i, r, s), {
1452
1452
  fillColor: s.handleColor,
1453
1453
  borderColor: s.handleBorderColor,
1454
1454
  borderThickness: s.handleBorderThickness
@@ -1468,24 +1468,24 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1468
1468
  });
1469
1469
  }
1470
1470
  static getHandles(e, i, r = X.defaultConfig) {
1471
- const [s, n] = e.vertices, a = v(s, i), o = v(n, i), l = a.x <= o.x, d = a.y <= o.y, u = l === d ? "nwse-resize" : "nesw-resize", g = l === d ? "nwse-resize" : "nesw-resize";
1471
+ const [s, n] = e.vertices, o = v(s, i), a = v(n, i), l = o.x <= a.x, d = o.y <= a.y, u = l === d ? "nwse-resize" : "nesw-resize", g = l === d ? "nwse-resize" : "nesw-resize";
1472
1472
  return [b({
1473
1473
  shapeId: e.id,
1474
1474
  type: "start",
1475
- point: a,
1475
+ point: o,
1476
1476
  radius: r.handleRadius,
1477
1477
  cursor: u
1478
1478
  }), b({
1479
1479
  shapeId: e.id,
1480
1480
  type: "end",
1481
- point: o,
1481
+ point: a,
1482
1482
  radius: r.handleRadius,
1483
1483
  cursor: g
1484
1484
  })];
1485
1485
  }
1486
1486
  static hitTest({ point: e, shape: i, converter: r, tolerance: s = 8 }) {
1487
- const [n, a] = i.vertices;
1488
- return _t(e, _(n, a, r), s);
1487
+ const [n, o] = i.vertices;
1488
+ return _t(e, _(n, o, r), s);
1489
1489
  }
1490
1490
  static move(e, i) {
1491
1491
  return {
@@ -1512,7 +1512,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1512
1512
  const n = r?.trim();
1513
1513
  n && (e.save(), e.beginPath(), e.rect(i.left, i.top, i.width, i.height), e.clip(), e.font = `${s.textFontSize}px ${s.textFontFamily}`, e.globalAlpha = s.textOpacity, e.fillStyle = s.textColor, e.textAlign = "center", e.textBaseline = "middle", e.fillText(n, i.left + i.width / 2, i.top + i.height / 2), e.restore());
1514
1514
  }
1515
- }, wt = [
1515
+ }, Pt = [
1516
1516
  "USDJPY",
1517
1517
  "GBPJPY",
1518
1518
  "AUDJPY",
@@ -1524,9 +1524,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1524
1524
  "USOIL",
1525
1525
  "UKOIL",
1526
1526
  "XAGUSD"
1527
- ], Tt = (t) => wt.some((e) => t.includes(e.slice(3))) ? 0.01 : bt.includes(t) ? 1 : xt.includes(t) ? 0.01 : 1e-4, Zt = (t, e) => wt.includes(t) ? e * 6.33806 : bt.includes(t) ? e * 1 : (xt.includes(t), e * 10), dt = (t, e, i, r, s) => {
1528
- const n = s.split(".")[0], a = Tt(n), o = Zt(n, r);
1529
- return (t === "buy" ? i - e : e - i) / a * o;
1527
+ ], Tt = (t) => Pt.some((e) => t.includes(e.slice(3))) ? 0.01 : bt.includes(t) ? 1 : xt.includes(t) ? 0.01 : 1e-4, Zt = (t, e) => Pt.includes(t) ? e * 6.33806 : bt.includes(t) ? e * 1 : (xt.includes(t), e * 10), dt = (t, e, i, r, s) => {
1528
+ const n = s.split(".")[0], o = Tt(n), a = Zt(n, r);
1529
+ return (t === "buy" ? i - e : e - i) / o * a;
1530
1530
  }, L = class y {
1531
1531
  static defaultLongConfig = {
1532
1532
  defaultWidthCandles: 10,
@@ -1552,47 +1552,47 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1552
1552
  selectedLineWidth: 2
1553
1553
  };
1554
1554
  static defaultShortConfig = { ...y.defaultLongConfig };
1555
- static draw({ ctx: e, activeSymbol: i, shape: r, converter: s, config: n = r.type === "longPosition" ? y.defaultLongConfig : y.defaultShortConfig, selected: a = !1, hovered: o = !1 }) {
1555
+ static draw({ ctx: e, activeSymbol: i, shape: r, converter: s, config: n = r.type === "longPosition" ? y.defaultLongConfig : y.defaultShortConfig, selected: o = !1, hovered: a = !1 }) {
1556
1556
  const l = y.getGeometry(r, s);
1557
- e.save(), e.fillStyle = P(n.profitFillColor, n.profitFillOpacity), e.fillRect(l.profitBox.left, l.profitBox.top, l.profitBox.width, l.profitBox.height), e.fillStyle = P(n.lossFillColor, n.lossFillOpacity), e.fillRect(l.lossBox.left, l.lossBox.top, l.lossBox.width, l.lossBox.height);
1558
- const d = a ? Math.max(n.borderWidth, n.selectedLineWidth) : o ? Math.max(n.borderWidth, n.hoverLineWidth) : n.borderWidth;
1559
- e.strokeStyle = P(n.borderColor, n.borderOpacity), e.lineWidth = d, e.setLineDash(E(n.borderStyle, d)), e.strokeRect(l.box.left, l.box.top, l.box.width, l.box.height), e.beginPath(), e.strokeStyle = P(n.midLineColor, n.midLineOpacity), e.lineWidth = n.midLineWidth, e.setLineDash(E(n.midLineStyle, n.midLineWidth)), e.moveTo(l.box.left, l.entryY), e.lineTo(l.box.right, l.entryY), e.stroke(), O(e), y.drawLabels({
1557
+ e.save(), e.fillStyle = w(n.profitFillColor, n.profitFillOpacity), e.fillRect(l.profitBox.left, l.profitBox.top, l.profitBox.width, l.profitBox.height), e.fillStyle = w(n.lossFillColor, n.lossFillOpacity), e.fillRect(l.lossBox.left, l.lossBox.top, l.lossBox.width, l.lossBox.height);
1558
+ const d = o ? Math.max(n.borderWidth, n.selectedLineWidth) : a ? Math.max(n.borderWidth, n.hoverLineWidth) : n.borderWidth;
1559
+ e.strokeStyle = w(n.borderColor, n.borderOpacity), e.lineWidth = d, e.setLineDash(E(n.borderStyle, d)), e.strokeRect(l.box.left, l.box.top, l.box.width, l.box.height), e.beginPath(), e.strokeStyle = w(n.midLineColor, n.midLineOpacity), e.lineWidth = n.midLineWidth, e.setLineDash(E(n.midLineStyle, n.midLineWidth)), e.moveTo(l.box.left, l.entryY), e.lineTo(l.box.right, l.entryY), e.stroke(), O(e), y.drawLabels({
1560
1560
  ctx: e,
1561
1561
  activeSymbol: i,
1562
1562
  shape: r,
1563
1563
  geometry: l,
1564
1564
  config: n
1565
- }), (a || o) && V(e, y.getHandles(r, s, n), {
1565
+ }), (o || a) && V(e, y.getHandles(r, s, n), {
1566
1566
  fillColor: n.handleColor,
1567
1567
  borderColor: n.handleBorderColor,
1568
1568
  borderThickness: n.handleBorderThickness
1569
1569
  }), e.restore();
1570
1570
  }
1571
1571
  static createFromVertex({ id: e, type: i, entry: r, converter: s, config: n = i === "longPosition" ? y.defaultLongConfig : y.defaultShortConfig }) {
1572
- const a = s.getTimeForX(s.getXForTime(r.time) + s.getCandleWidth() * n.defaultWidthCandles), o = n.defaultStopLossPercent;
1572
+ const o = s.getTimeForX(s.getXForTime(r.time) + s.getCandleWidth() * n.defaultWidthCandles), a = n.defaultStopLossPercent;
1573
1573
  return {
1574
1574
  id: e,
1575
1575
  type: i,
1576
1576
  entry: r,
1577
- endTime: a,
1578
- stopLossPercent: o,
1579
- takeProfitPercent: o * n.defaultRiskRewardRatio
1577
+ endTime: o,
1578
+ stopLossPercent: a,
1579
+ takeProfitPercent: a * n.defaultRiskRewardRatio
1580
1580
  };
1581
1581
  }
1582
1582
  static getGeometry(e, i) {
1583
- const r = v(e.entry, i), s = i.getXForTime(e.endTime), n = Math.min(r.x, s), a = Math.max(r.x, s), o = e.type === "longPosition", l = o ? e.takeProfitPercent : e.stopLossPercent, d = o ? e.stopLossPercent : e.takeProfitPercent, u = e.entry.price * (1 + l / 100), g = e.entry.price * (1 - d / 100), m = i.getYForPrice(u), w = i.getYForPrice(g), C = Math.min(m, w, r.y), x = Math.max(m, w, r.y), T = {
1583
+ const r = v(e.entry, i), s = i.getXForTime(e.endTime), n = Math.min(r.x, s), o = Math.max(r.x, s), a = e.type === "longPosition", l = a ? e.takeProfitPercent : e.stopLossPercent, d = a ? e.stopLossPercent : e.takeProfitPercent, u = e.entry.price * (1 + l / 100), g = e.entry.price * (1 - d / 100), m = i.getYForPrice(u), P = i.getYForPrice(g), C = Math.min(m, P, r.y), x = Math.max(m, P, r.y), T = {
1584
1584
  left: n,
1585
1585
  top: C,
1586
- right: a,
1586
+ right: o,
1587
1587
  bottom: r.y,
1588
- width: a - n,
1588
+ width: o - n,
1589
1589
  height: Math.abs(r.y - C)
1590
1590
  }, H = {
1591
1591
  left: n,
1592
1592
  top: r.y,
1593
- right: a,
1593
+ right: o,
1594
1594
  bottom: x,
1595
- width: a - n,
1595
+ width: o - n,
1596
1596
  height: Math.abs(x - r.y)
1597
1597
  };
1598
1598
  return {
@@ -1604,13 +1604,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1604
1604
  box: {
1605
1605
  left: n,
1606
1606
  top: C,
1607
- right: a,
1607
+ right: o,
1608
1608
  bottom: x,
1609
- width: a - n,
1609
+ width: o - n,
1610
1610
  height: x - C
1611
1611
  },
1612
- profitBox: o ? T : H,
1613
- lossBox: o ? H : T
1612
+ profitBox: a ? T : H,
1613
+ lossBox: a ? H : T
1614
1614
  };
1615
1615
  }
1616
1616
  static getHandles(e, i, r) {
@@ -1708,12 +1708,12 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1708
1708
  }
1709
1709
  static drawLabels({ ctx: e, activeSymbol: i, shape: r, geometry: s, config: n }) {
1710
1710
  e.save(), e.font = "11px sans-serif", e.textBaseline = "middle";
1711
- const a = r.type, o = Tt(i), l = r.entry.price * (r.takeProfitPercent / 100) / o, d = r.entry.price * (r.stopLossPercent / 100) / o, u = s.box.left + 6, g = l / d;
1712
- e.fillStyle = P(n.profitFillColor, 0.95);
1713
- const m = a === "longPosition" ? s.profitBox.top + s.profitBox.height / 10 : s.profitBox.bottom - s.profitBox.height / 10;
1714
- e.fillText(`${l.toFixed(2)} (${g.toFixed(2)})`, u, m), e.fillStyle = P(n.lossFillColor, 0.95);
1715
- const w = a === "shortPosition" ? s.lossBox.top + s.lossBox.height / 10 : s.lossBox.bottom - s.lossBox.height / 10;
1716
- e.fillText(d.toFixed(1), u, w);
1711
+ const o = r.type, a = Tt(i), l = r.entry.price * (r.takeProfitPercent / 100) / a, d = r.entry.price * (r.stopLossPercent / 100) / a, u = s.box.left + 6, g = l / d;
1712
+ e.fillStyle = w(n.profitFillColor, 0.95);
1713
+ const m = o === "longPosition" ? s.profitBox.top + s.profitBox.height / 10 : s.profitBox.bottom - s.profitBox.height / 10;
1714
+ e.fillText(`${l.toFixed(2)} (${g.toFixed(2)})`, u, m), e.fillStyle = w(n.lossFillColor, 0.95);
1715
+ const P = o === "shortPosition" ? s.lossBox.top + s.lossBox.height / 10 : s.lossBox.bottom - s.lossBox.height / 10;
1716
+ e.fillText(d.toFixed(1), u, P);
1717
1717
  }
1718
1718
  }, qt = class {
1719
1719
  canvas;
@@ -1775,7 +1775,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1775
1775
  return t.key === "Escape" && this.draft?.type === "path" ? (this.completePathDraft(), !0) : t.key === "Escape" && this.draft ? (this.draft = null, this.setActiveToolAndEmit(null), !0) : t.key === "Escape" && this.selectedShapeId ? (this.setSelectedShapeId(null), !0) : !1;
1776
1776
  }
1777
1777
  handlePointerDown(t) {
1778
- const e = at(this.canvas, t), i = ot(e, this.getConverter());
1778
+ const e = ot(this.canvas, t), i = at(e, this.getConverter());
1779
1779
  if (this.activeTool)
1780
1780
  return ht(t) && this.handleToolPointerDown({
1781
1781
  point: e,
@@ -1784,7 +1784,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1784
1784
  if (!ht(t)) return !1;
1785
1785
  const r = this.findHandleAtPoint(e);
1786
1786
  if (r) {
1787
- const n = this.shapes.find((a) => a.id === r.shapeId);
1787
+ const n = this.shapes.find((o) => o.id === r.shapeId);
1788
1788
  return n ? (this.setSelectedShapeId(n.id), this.dragState = {
1789
1789
  edit: {
1790
1790
  mode: "resize",
@@ -1823,7 +1823,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1823
1823
  return this.setSelectedShapeId(null), this.hoveredShapeId = null, this.canvas.style.cursor = "crosshair", !1;
1824
1824
  }
1825
1825
  handlePointerMove(t) {
1826
- const e = at(this.canvas, t), i = ot(e, this.getConverter());
1826
+ const e = ot(this.canvas, t), i = at(e, this.getConverter());
1827
1827
  if (this.draft)
1828
1828
  return this.updateDraftPreview(i), !0;
1829
1829
  if (this.dragState) {
@@ -2213,7 +2213,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2213
2213
  getXForTime(t) {
2214
2214
  if (!this.viewport || this.candles.length === 0) return 0;
2215
2215
  if (t > this.candles[this.candles.length - 1].time) {
2216
- const i = Pt(this.candles);
2216
+ const i = wt(this.candles);
2217
2217
  return (t - this.candles[0].time) / i * this.viewport.candleSpacing + this.viewport.offsetX + this.viewport.candleWidth / 2;
2218
2218
  }
2219
2219
  const e = j(this.candles, t);
@@ -2277,7 +2277,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2277
2277
  #e;
2278
2278
  isDragging;
2279
2279
  trades = [];
2280
- pastTrades = [];
2280
+ closedTrades = [];
2281
2281
  candles = [];
2282
2282
  viewport = null;
2283
2283
  liveCandle = null;
@@ -2292,8 +2292,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2292
2292
  setTrades(t) {
2293
2293
  this.trades = t;
2294
2294
  }
2295
- setPastTrades(t) {
2296
- this.pastTrades = t;
2295
+ setClosedTrades(t) {
2296
+ this.closedTrades = t;
2297
2297
  }
2298
2298
  setCandles(t) {
2299
2299
  this.candles = t;
@@ -2317,11 +2317,11 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2317
2317
  this.isDragging || this.render();
2318
2318
  }
2319
2319
  render() {
2320
- this.clearCanvas(), this.resetHitboxes(), this.drawPastTradeIndicators();
2320
+ this.clearCanvas(), this.resetHitboxes(), this.drawClosedTradeIndicators();
2321
2321
  for (const t of this.trades) this.drawTrade({ trade: t });
2322
2322
  this.drawTemporaryProtectionDrag();
2323
2323
  }
2324
- createHitBox = ({ price: t, trade: e, type: i, x: r, y: s, width: n, height: a, viewport: o }) => {
2324
+ createHitBox = ({ price: t, trade: e, type: i, x: r, y: s, width: n, height: o, viewport: a }) => {
2325
2325
  const { showCloseSection: l, widthClose: d } = this.getHandleStyleConfig(i).handle, u = l ? d : 0, g = n - u, m = r + n - u;
2326
2326
  return {
2327
2327
  kind: "existingHandle",
@@ -2331,23 +2331,23 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2331
2331
  x: r,
2332
2332
  y: s,
2333
2333
  width: n,
2334
- height: a,
2335
- viewport: o,
2334
+ height: o,
2335
+ viewport: a,
2336
2336
  labelArea: {
2337
2337
  x: r,
2338
2338
  y: s,
2339
2339
  width: g,
2340
- height: a
2340
+ height: o
2341
2341
  },
2342
2342
  closeButtonArea: {
2343
2343
  x: m,
2344
2344
  y: s,
2345
2345
  width: u,
2346
- height: a
2346
+ height: o
2347
2347
  }
2348
2348
  };
2349
2349
  };
2350
- createMissingProtectionHitBox = ({ price: t, trade: e, type: i, x: r, y: s, width: n, height: a, viewport: o }) => ({
2350
+ createMissingProtectionHitBox = ({ price: t, trade: e, type: i, x: r, y: s, width: n, height: o, viewport: a }) => ({
2351
2351
  kind: "missingProtectionHandle",
2352
2352
  price: p(t),
2353
2353
  trade: e,
@@ -2355,19 +2355,19 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2355
2355
  x: r,
2356
2356
  y: s,
2357
2357
  width: n,
2358
- height: a,
2359
- viewport: o,
2358
+ height: o,
2359
+ viewport: a,
2360
2360
  labelArea: {
2361
2361
  x: r,
2362
2362
  y: s,
2363
2363
  width: n,
2364
- height: a
2364
+ height: o
2365
2365
  },
2366
2366
  closeButtonArea: {
2367
2367
  x: r + n,
2368
2368
  y: s,
2369
2369
  width: 0,
2370
- height: a
2370
+ height: o
2371
2371
  }
2372
2372
  });
2373
2373
  drawTrade({ trade: t }) {
@@ -2448,11 +2448,11 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2448
2448
  padding: Math.max(1, r.borderWidth)
2449
2449
  }), s.save(), s.globalAlpha = r.backgroundOpacity, s.fillStyle = r.backgroundColor, s.fillRect(t, e, i, r.height), s.globalAlpha = r.borderOpacity, s.strokeStyle = r.borderColor, s.lineWidth = r.borderWidth, s.strokeRect(t, e, i, r.height), s.restore();
2450
2450
  }
2451
- drawHandleSections({ handleType: t, handleX: e, handleY: i, handleWidth: r, handleHeight: s, handleConfig: n, trade: a, y: o }) {
2451
+ drawHandleSections({ handleType: t, handleX: e, handleY: i, handleWidth: r, handleHeight: s, handleConfig: n, trade: o, y: a }) {
2452
2452
  const l = this.#e, d = c.tradeHandles, u = this.getHandleSections({
2453
2453
  handleType: t,
2454
2454
  handleConfig: n,
2455
- trade: a
2455
+ trade: o
2456
2456
  });
2457
2457
  let g = e;
2458
2458
  l.save(), l.font = d.font, l.textBaseline = "middle", l.globalAlpha = d.textOpacity;
@@ -2460,7 +2460,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2460
2460
  m.visible && (this.drawHandleSectionLabel({
2461
2461
  section: m,
2462
2462
  currentX: g,
2463
- y: o
2463
+ y: a
2464
2464
  }), g += m.width, g < e + r && this.drawHandleSectionDivider({
2465
2465
  x: g,
2466
2466
  y1: i + 4,
@@ -2518,18 +2518,18 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2518
2518
  resetHitboxes() {
2519
2519
  this.handleHitboxes = [];
2520
2520
  }
2521
- drawPastTradeIndicators() {
2522
- if (!(!c.pastTradeIndicators.visible || !this.viewport || this.candles.length === 0))
2523
- for (const t of this.pastTrades) {
2524
- const e = this.getPastTradeIndicatorRenderState(t);
2525
- e && (this.drawPastTradeConnector(e), this.drawPastTradeArrows(e));
2521
+ drawClosedTradeIndicators() {
2522
+ if (!(!c.closedTradeIndicators.visible || !this.viewport || this.candles.length === 0))
2523
+ for (const t of this.closedTrades) {
2524
+ const e = this.getClosedTradeIndicatorRenderState(t);
2525
+ e && (this.drawClosedTradeConnector(e), this.drawClosedTradeArrows(e));
2526
2526
  }
2527
2527
  }
2528
- getPastTradeIndicatorRenderState(t) {
2528
+ getClosedTradeIndicatorRenderState(t) {
2529
2529
  if (!this.viewport) return null;
2530
2530
  const e = this.getTimeX(t.openTime), i = this.getTimeX(t.closeTime);
2531
2531
  if (e === null || i === null) return null;
2532
- const r = this.getPriceY(t.openPrice, this.viewport), s = this.getPriceY(t.closePrice, this.viewport), n = c.pastTradeIndicators.arrow, a = n.width, o = n.height;
2532
+ const r = this.getPriceY(t.openPrice, this.viewport), s = this.getPriceY(t.closePrice, this.viewport), n = c.closedTradeIndicators.arrow, o = n.width, a = n.height;
2533
2533
  return {
2534
2534
  trade: t,
2535
2535
  start: {
@@ -2544,12 +2544,12 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2544
2544
  time: t.closeTime,
2545
2545
  price: t.closePrice
2546
2546
  },
2547
- arrowWidth: a,
2548
- arrowHeight: o
2547
+ arrowWidth: o,
2548
+ arrowHeight: a
2549
2549
  };
2550
2550
  }
2551
- drawPastTradeConnector({ start: t, close: e }) {
2552
- const i = c.pastTradeIndicators.connectorLine;
2551
+ drawClosedTradeConnector({ start: t, close: e }) {
2552
+ const i = c.closedTradeIndicators.connectorLine;
2553
2553
  this.drawConnectorLine({
2554
2554
  x1: t.x,
2555
2555
  y1: t.y,
@@ -2558,32 +2558,32 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2558
2558
  config: i
2559
2559
  });
2560
2560
  }
2561
- drawPastTradeArrows({ trade: t, start: e, close: i, arrowWidth: r, arrowHeight: s }) {
2562
- const n = c.pastTradeIndicators.arrow;
2561
+ drawClosedTradeArrows({ trade: t, start: e, close: i, arrowWidth: r, arrowHeight: s }) {
2562
+ const n = c.closedTradeIndicators.arrow;
2563
2563
  if (!n.visible) return;
2564
- const a = t.type === "buy" ? "sell" : "buy";
2565
- this.drawPastTradeArrow({
2564
+ const o = t.type === "buy" ? "sell" : "buy";
2565
+ this.drawClosedTradeArrow({
2566
2566
  x: e.x,
2567
2567
  y: e.y,
2568
2568
  type: t.type,
2569
2569
  width: r,
2570
2570
  height: s,
2571
2571
  config: n
2572
- }), this.drawPastTradeArrow({
2572
+ }), this.drawClosedTradeArrow({
2573
2573
  x: i.x,
2574
2574
  y: i.y,
2575
- type: a,
2575
+ type: o,
2576
2576
  width: r,
2577
2577
  height: s,
2578
2578
  config: n
2579
2579
  });
2580
2580
  }
2581
- drawPastTradeArrow({ x: t, y: e, type: i, width: r, height: s, config: n }) {
2581
+ drawClosedTradeArrow({ x: t, y: e, type: i, width: r, height: s, config: n }) {
2582
2582
  if (r <= 0 || s <= 0) return;
2583
- const a = this.#e, o = i === "buy", l = o ? n.buyColor : n.sellColor, d = o ? n.buyBorderColor : n.sellBorderColor, u = o ? 1 : -1, g = t, m = e, w = t, C = e + u * s, x = s / 2, T = x / Math.SQRT2, H = x / Math.SQRT2, Lt = g - T, Ht = g + T, Z = m + u * H, q = Math.max(1, n.shaftWidthRatio), kt = q + n.borderWidth * 2, Q = () => {
2584
- a.beginPath(), a.moveTo(w, C), a.lineTo(g, m), a.moveTo(g, m), a.lineTo(Lt, Z), a.moveTo(g, m), a.lineTo(Ht, Z), a.stroke();
2583
+ const o = this.#e, a = i === "buy", l = a ? n.buyColor : n.sellColor, d = a ? n.buyBorderColor : n.sellBorderColor, u = a ? 1 : -1, g = t, m = e, P = t, C = e + u * s, x = s / 2, T = x / Math.SQRT2, H = x / Math.SQRT2, Lt = g - T, Ht = g + T, Z = m + u * H, q = Math.max(1, n.shaftWidthRatio), kt = q + n.borderWidth * 2, Q = () => {
2584
+ o.beginPath(), o.moveTo(P, C), o.lineTo(g, m), o.moveTo(g, m), o.lineTo(Lt, Z), o.moveTo(g, m), o.lineTo(Ht, Z), o.stroke();
2585
2585
  };
2586
- a.save(), a.globalAlpha = n.opacity, a.lineCap = "round", a.lineJoin = "round", a.strokeStyle = d, a.lineWidth = kt, Q(), a.strokeStyle = l, a.lineWidth = q, Q(), a.restore();
2586
+ o.save(), o.globalAlpha = n.opacity, o.lineCap = "round", o.lineJoin = "round", o.strokeStyle = d, o.lineWidth = kt, Q(), o.strokeStyle = l, o.lineWidth = q, Q(), o.restore();
2587
2587
  }
2588
2588
  getTimeX(t) {
2589
2589
  if (!this.viewport || this.candles.length === 0 || !Number.isFinite(t)) return null;
@@ -2598,9 +2598,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2598
2598
  const d = this.candles.length - 1, u = this.getCandleTimeInterval(d), g = (e - r.time) / u;
2599
2599
  return this.getCandleCenterX(d) + g * this.viewport.candleSpacing;
2600
2600
  }
2601
- const s = this.getFirstCandleIndexAtOrAfterTime(e), n = Math.max(0, s - 1), a = this.candles[n], o = this.candles[s];
2602
- if (!a || !o || o.time === a.time) return this.getCandleCenterX(n);
2603
- const l = (e - a.time) / (o.time - a.time);
2601
+ const s = this.getFirstCandleIndexAtOrAfterTime(e), n = Math.max(0, s - 1), o = this.candles[n], a = this.candles[s];
2602
+ if (!o || !a || a.time === o.time) return this.getCandleCenterX(n);
2603
+ const l = (e - o.time) / (a.time - o.time);
2604
2604
  return this.getCandleCenterX(n) + l * this.viewport.candleSpacing;
2605
2605
  }
2606
2606
  normalizeTimestamp(t) {
@@ -2623,7 +2623,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2623
2623
  }
2624
2624
  getTradeHandleRenderState({ price: t, type: e, trade: i }) {
2625
2625
  if (!this.viewport) return null;
2626
- const r = this.viewport, s = this.getPriceY(t, r), n = this.getHandleStyleConfig(e), a = n.handle, o = n.handleLine, l = this.getHandleWidth(a), d = a.height;
2626
+ const r = this.viewport, s = this.getPriceY(t, r), n = this.getHandleStyleConfig(e), o = n.handle, a = n.handleLine, l = this.getHandleWidth(o), d = o.height;
2627
2627
  return {
2628
2628
  price: t,
2629
2629
  type: e,
@@ -2631,11 +2631,11 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2631
2631
  viewport: r,
2632
2632
  y: s,
2633
2633
  handleStyleConfig: n,
2634
- handleConfig: a,
2635
- lineConfig: o,
2634
+ handleConfig: o,
2635
+ lineConfig: a,
2636
2636
  handleX: this.getHandleX({
2637
2637
  handleWidth: l,
2638
- config: a
2638
+ config: o
2639
2639
  }),
2640
2640
  handleY: s - d / 2,
2641
2641
  handleWidth: l,
@@ -2787,12 +2787,12 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2787
2787
  return t.sl || e.push("stopLoss"), t.tp || e.push("takeProfit"), e;
2788
2788
  }
2789
2789
  getMissingProtectionHandleRenderState({ type: t, trade: e, startPriceRenderState: i, visibleTypes: r }) {
2790
- const s = this.getMissingProtectionHandleConfig(t), n = s.width, a = s.height, o = this.getMissingProtectionHandleX({
2790
+ const s = this.getMissingProtectionHandleConfig(t), n = s.width, o = s.height, a = this.getMissingProtectionHandleX({
2791
2791
  type: t,
2792
2792
  config: s,
2793
2793
  startPriceRenderState: i,
2794
2794
  visibleTypes: r
2795
- }), l = i.y - a / 2;
2795
+ }), l = i.y - o / 2;
2796
2796
  return {
2797
2797
  price: e.openPrice,
2798
2798
  type: t,
@@ -2800,10 +2800,10 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2800
2800
  viewport: i.viewport,
2801
2801
  y: i.y,
2802
2802
  config: s,
2803
- handleX: o,
2803
+ handleX: a,
2804
2804
  handleY: l,
2805
2805
  handleWidth: n,
2806
- handleHeight: a
2806
+ handleHeight: o
2807
2807
  };
2808
2808
  }
2809
2809
  getMissingProtectionHandleX({ type: t, config: e, startPriceRenderState: i, visibleTypes: r }) {
@@ -2831,8 +2831,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2831
2831
  }), s.save(), s.globalAlpha = r.backgroundOpacity, s.fillStyle = r.backgroundColor, s.fillRect(t, e, i, r.height), s.globalAlpha = r.borderOpacity, s.strokeStyle = r.borderColor, s.lineWidth = r.borderWidth, s.strokeRect(t, e, i, r.height), s.restore();
2832
2832
  }
2833
2833
  drawMissingProtectionHandleLabel({ type: t, handleX: e, y: i, handleWidth: r, config: s }) {
2834
- const n = this.#e, a = t === "stopLoss" ? "SL" : "TP", o = e + r / 2;
2835
- n.save(), n.font = s.font, n.textBaseline = "middle", n.globalAlpha = s.textOpacity, n.fillStyle = s.textColor, n.fillText(a, o - n.measureText(a).width / 2, i), n.restore();
2834
+ const n = this.#e, o = t === "stopLoss" ? "SL" : "TP", a = e + r / 2;
2835
+ n.save(), n.font = s.font, n.textBaseline = "middle", n.globalAlpha = s.textOpacity, n.fillStyle = s.textColor, n.fillText(o, a - n.measureText(o).width / 2, i), n.restore();
2836
2836
  }
2837
2837
  drawTemporaryProtectionDrag() {
2838
2838
  const t = this.getTemporaryProtectionRenderState();
@@ -2845,7 +2845,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2845
2845
  }
2846
2846
  getTemporaryProtectionRenderState() {
2847
2847
  if (!this.temporaryProtectionDrag) return null;
2848
- const { trade: t, type: e, viewport: i } = this.temporaryProtectionDrag, r = p(this.temporaryProtectionDrag.price), s = this.getPriceY(r, i), n = this.getTemporaryProtectionHandleConfig(e), a = this.getTemporaryProtectionLineConfig(e), o = n.widthPNL, l = n.height;
2848
+ const { trade: t, type: e, viewport: i } = this.temporaryProtectionDrag, r = p(this.temporaryProtectionDrag.price), s = this.getPriceY(r, i), n = this.getTemporaryProtectionHandleConfig(e), o = this.getTemporaryProtectionLineConfig(e), a = n.widthPNL, l = n.height;
2849
2849
  return {
2850
2850
  price: r,
2851
2851
  type: e,
@@ -2853,13 +2853,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2853
2853
  viewport: i,
2854
2854
  y: s,
2855
2855
  handleConfig: n,
2856
- lineConfig: a,
2856
+ lineConfig: o,
2857
2857
  handleX: this.getTemporaryProtectionHandleX({
2858
- handleWidth: o,
2858
+ handleWidth: a,
2859
2859
  config: n
2860
2860
  }),
2861
2861
  handleY: s - l / 2,
2862
- handleWidth: o,
2862
+ handleWidth: a,
2863
2863
  handleHeight: l
2864
2864
  };
2865
2865
  }
@@ -2881,9 +2881,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2881
2881
  padding: Math.max(1, r.borderWidth)
2882
2882
  }), s.save(), s.globalAlpha = r.backgroundOpacity, s.fillStyle = r.backgroundColor, s.fillRect(t, e, i, r.height), s.globalAlpha = r.borderOpacity, s.strokeStyle = r.borderColor, s.lineWidth = r.borderWidth, s.strokeRect(t, e, i, r.height), s.restore();
2883
2883
  }
2884
- drawTemporaryProtectionPnLLabel({ trade: t, type: e, price: i, handleX: r, y: s, handleWidth: n, handleConfig: a }) {
2885
- const o = this.#e, l = dt(t.type, t.openPrice, i, t.volume, t.symbol), d = this.formatPnlLabel(l), u = r + n / 2;
2886
- o.save(), o.font = a.font, o.textBaseline = "middle", o.globalAlpha = a.textOpacity, o.fillStyle = this.getProtectionPnlTextColor(e), o.fillText(d, u - o.measureText(d).width / 2, s), o.restore();
2884
+ drawTemporaryProtectionPnLLabel({ trade: t, type: e, price: i, handleX: r, y: s, handleWidth: n, handleConfig: o }) {
2885
+ const a = this.#e, l = dt(t.type, t.openPrice, i, t.volume, t.symbol), d = this.formatPnlLabel(l), u = r + n / 2;
2886
+ a.save(), a.font = o.font, a.textBaseline = "middle", a.globalAlpha = o.textOpacity, a.fillStyle = this.getProtectionPnlTextColor(e), a.fillText(d, u - a.measureText(d).width / 2, s), a.restore();
2887
2887
  }
2888
2888
  clearRectArea({ x: t, y: e, width: i, height: r, padding: s = 0 }) {
2889
2889
  this.#e.clearRect(t - s, e - s, i + s * 2, r + s * 2);
@@ -2925,8 +2925,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2925
2925
  #l;
2926
2926
  #u;
2927
2927
  #n;
2928
- #o = null;
2929
2928
  #a = null;
2929
+ #o = null;
2930
2930
  #d = !1;
2931
2931
  #h = 0;
2932
2932
  #f = 0;
@@ -2934,15 +2934,15 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2934
2934
  this.#t = t.canvas, this.#e = t.getHandleHitboxes, this.#r = t.getCurrentPrice, this.#s = t.onDrag, this.#c = t.onMissingProtectionDrag, this.#i = t.onMissingProtectionDragEnd, this.#l = t.onMissingProtectionDragCancel, this.#u = t.onTradeModified, this.#n = t.onTradeCloseClicked;
2935
2935
  }
2936
2936
  cancelActiveInteraction() {
2937
- this.#a && this.#l?.(), this.#o = null, this.#a = null, this.#d = !1, this.#h = 0, this.#f = 0;
2937
+ this.#o && this.#l?.(), this.#a = null, this.#o = null, this.#d = !1, this.#h = 0, this.#f = 0;
2938
2938
  }
2939
2939
  handlePointerEvent(t) {
2940
2940
  if (!this.isSupportedEventType(t.type)) return !1;
2941
2941
  const e = this.getCanvasMousePoint(t);
2942
- if (t.type === "pointermove" && this.#a) return this.handleActiveMissingProtectionDrag(t, e);
2943
- if (t.type === "pointermove" && this.#o) return this.handleActiveDrag(t, e);
2942
+ if (t.type === "pointermove" && this.#o) return this.handleActiveMissingProtectionDrag(t, e);
2943
+ if (t.type === "pointermove" && this.#a) return this.handleActiveDrag(t, e);
2944
2944
  if (t.type === "pointerup")
2945
- return this.#a ? this.handleMissingProtectionDragEnd() : this.handleDragEnd();
2945
+ return this.#o ? this.handleMissingProtectionDragEnd() : this.handleDragEnd();
2946
2946
  const i = this.getHoveredHitbox(e);
2947
2947
  return i ? this.handleHoveredHitbox(t, i, e) : (this.resetCursorIfIdle(), !1);
2948
2948
  }
@@ -2957,67 +2957,67 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2957
2957
  };
2958
2958
  }
2959
2959
  handleActiveDrag(t, e) {
2960
- if (!this.#o) return !1;
2960
+ if (!this.#a) return !1;
2961
2961
  const i = this.getNextDragPrice(e.y);
2962
- return this.#o.price = i, this.#s?.({
2963
- trade: this.#o.trade,
2964
- type: this.#o.type,
2962
+ return this.#a.price = i, this.#s?.({
2963
+ trade: this.#a.trade,
2964
+ type: this.#a.type,
2965
2965
  price: i
2966
2966
  }), this.consumeEvent(t), !0;
2967
2967
  }
2968
2968
  handleActiveMissingProtectionDrag(t, e) {
2969
- if (!this.#a || !this.isProtectionHandleType(this.#a.type)) return !1;
2969
+ if (!this.#o || !this.isProtectionHandleType(this.#o.type)) return !1;
2970
2970
  const i = e.y - this.#h, r = c.tradeHandles.missingProtectionHandles.dragActivationThresholdPx;
2971
2971
  if (!this.#d && Math.abs(i) < r)
2972
2972
  return this.consumeEvent(t), !0;
2973
2973
  this.#d = !0;
2974
2974
  const s = this.getNextMissingProtectionPrice(e.y);
2975
- return this.#a.price = s, this.#c?.({
2976
- trade: this.#a.trade,
2977
- type: this.#a.type,
2975
+ return this.#o.price = s, this.#c?.({
2976
+ trade: this.#o.trade,
2977
+ type: this.#o.type,
2978
2978
  price: s
2979
2979
  }), this.consumeEvent(t), !0;
2980
2980
  }
2981
2981
  getNextDragPrice(t) {
2982
- if (!this.#o) return 0;
2983
- const e = t - this.#h, i = this.#o.viewport.priceRange / this.#t.height, r = p(this.#f - e * i);
2984
- return this.isProtectionHandleType(this.#o.type) ? this.constrainExistingProtectionPrice({
2982
+ if (!this.#a) return 0;
2983
+ const e = t - this.#h, i = this.#a.viewport.priceRange / this.#t.height, r = p(this.#f - e * i);
2984
+ return this.isProtectionHandleType(this.#a.type) ? this.constrainExistingProtectionPrice({
2985
2985
  price: r,
2986
- hitbox: this.#o,
2987
- type: this.#o.type
2986
+ hitbox: this.#a,
2987
+ type: this.#a.type
2988
2988
  }) : r;
2989
2989
  }
2990
2990
  getNextMissingProtectionPrice(t) {
2991
- if (!this.#a || !this.isProtectionHandleType(this.#a.type)) return 0;
2992
- const e = p(this.#a.viewport.minPrice + (this.#t.height - t) / this.#t.height * this.#a.viewport.priceRange);
2991
+ if (!this.#o || !this.isProtectionHandleType(this.#o.type)) return 0;
2992
+ const e = p(this.#o.viewport.minPrice + (this.#t.height - t) / this.#t.height * this.#o.viewport.priceRange);
2993
2993
  return this.constrainProtectionPrice({
2994
2994
  price: e,
2995
- hitbox: this.#a,
2996
- type: this.#a.type
2995
+ hitbox: this.#o,
2996
+ type: this.#o.type
2997
2997
  });
2998
2998
  }
2999
2999
  handleDragEnd() {
3000
- return this.#o && this.modifyActiveDragTrade(), this.#o = null, !1;
3000
+ return this.#a && this.modifyActiveDragTrade(), this.#a = null, !1;
3001
3001
  }
3002
3002
  handleMissingProtectionDragEnd() {
3003
- return this.#a && this.#d && this.isProtectionHandleType(this.#a.type) ? this.#i?.({
3004
- trade: this.#a.trade,
3005
- type: this.#a.type,
3006
- price: p(this.#a.price)
3007
- }) : this.#l?.(), this.#a = null, this.#d = !1, !1;
3003
+ return this.#o && this.#d && this.isProtectionHandleType(this.#o.type) ? this.#i?.({
3004
+ trade: this.#o.trade,
3005
+ type: this.#o.type,
3006
+ price: p(this.#o.price)
3007
+ }) : this.#l?.(), this.#o = null, this.#d = !1, !1;
3008
3008
  }
3009
3009
  modifyActiveDragTrade() {
3010
- if (!this.#o) return;
3011
- const t = p(this.#o.price);
3012
- if (this.#o.type === "stopLoss") {
3010
+ if (!this.#a) return;
3011
+ const t = p(this.#a.price);
3012
+ if (this.#a.type === "stopLoss") {
3013
3013
  this.#u?.({
3014
- ticket: this.#o.trade.ticket,
3014
+ ticket: this.#a.trade.ticket,
3015
3015
  sl: t
3016
3016
  });
3017
3017
  return;
3018
3018
  }
3019
3019
  this.#u?.({
3020
- ticket: this.#o.trade.ticket,
3020
+ ticket: this.#a.trade.ticket,
3021
3021
  tp: t
3022
3022
  });
3023
3023
  }
@@ -3050,13 +3050,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3050
3050
  document.body.style.cursor = t.type === "startPrice" ? "crosshair" : "ns-resize";
3051
3051
  }
3052
3052
  startDrag(t, e) {
3053
- this.#o = t, this.#h = e, this.#f = t.price;
3053
+ this.#a = t, this.#h = e, this.#f = t.price;
3054
3054
  }
3055
3055
  startMissingProtectionDrag(t, e) {
3056
- this.#a = t, this.#h = e, this.#d = !1;
3056
+ this.#o = t, this.#h = e, this.#d = !1;
3057
3057
  }
3058
3058
  resetCursorIfIdle() {
3059
- !this.#o && !this.#a && (document.body.style.cursor = "crosshair");
3059
+ !this.#a && !this.#o && (document.body.style.cursor = "crosshair");
3060
3060
  }
3061
3061
  isPointInsideArea(t, e) {
3062
3062
  const i = t.x >= e.x && t.x <= e.x + e.width, r = t.y >= e.y && t.y <= e.y + e.height;
@@ -3108,18 +3108,18 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3108
3108
  if (this.clearCanvas(), !c.volume.visible || !this.viewport || this.candles.length === 0) return;
3109
3109
  const t = this.#e, e = this.#t.width, i = this.#t.height, { startIndex: r, endIndex: s } = this.getVisibleRange(e);
3110
3110
  if (s < r) return;
3111
- const n = this.candles.slice(r, s + 1), a = this.getMaxVolume(n);
3112
- a <= 0 || this.drawVolumeBars({
3111
+ const n = this.candles.slice(r, s + 1), o = this.getMaxVolume(n);
3112
+ o <= 0 || this.drawVolumeBars({
3113
3113
  ctx: t,
3114
3114
  candles: n,
3115
3115
  startIndex: r,
3116
- maxVolume: a,
3116
+ maxVolume: o,
3117
3117
  chartHeight: i
3118
3118
  });
3119
3119
  }
3120
3120
  drawVolumeBars({ ctx: t, candles: e, startIndex: i, maxVolume: r, chartHeight: s }) {
3121
- t.save(), t.globalAlpha = this.opacity, e.forEach((n, a) => {
3122
- const o = i + a, l = this.getCandleX(o);
3121
+ t.save(), t.globalAlpha = this.opacity, e.forEach((n, o) => {
3122
+ const a = i + o, l = this.getCandleX(a);
3123
3123
  this.drawSingleVolumeBar({
3124
3124
  ctx: t,
3125
3125
  candle: n,
@@ -3133,8 +3133,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3133
3133
  if (!this.viewport || e.volume <= 0) return;
3134
3134
  const n = this.getVolumeAreaHeight(s);
3135
3135
  if (n <= 0) return;
3136
- const a = n * (e.volume / r), o = Math.min(n, Math.max(a, this.minBarHeight)), l = s - this.bottomOffset - o, d = Math.max(1, this.viewport.candleWidth);
3137
- t.fillStyle = this.getVolumeBarColor(e), t.fillRect(i, l, d, o);
3136
+ const o = n * (e.volume / r), a = Math.min(n, Math.max(o, this.minBarHeight)), l = s - this.bottomOffset - a, d = Math.max(1, this.viewport.candleWidth);
3137
+ t.fillStyle = this.getVolumeBarColor(e), t.fillRect(i, l, d, a);
3138
3138
  }
3139
3139
  getVisibleRange(t) {
3140
3140
  if (!this.viewport) return {
@@ -3175,16 +3175,16 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3175
3175
  r.className = "trading-reload-chart__layout";
3176
3176
  const s = document.createElement("div");
3177
3177
  s.className = "trading-reload-chart__stack";
3178
- const n = W("trading-reload-chart__volume"), a = W("trading-reload-chart__plot"), o = W("trading-reload-chart__shapes"), l = W("trading-reload-chart__trades"), d = W("trading-reload-chart__overlay"), u = W("trading-reload-chart__axis-x");
3179
- s.append(n, a, o, l, d, u);
3178
+ const n = W("trading-reload-chart__volume"), o = W("trading-reload-chart__plot"), a = W("trading-reload-chart__shapes"), l = W("trading-reload-chart__trades"), d = W("trading-reload-chart__overlay"), u = W("trading-reload-chart__axis-x");
3179
+ s.append(n, o, a, l, d, u);
3180
3180
  const g = W("trading-reload-chart__axis-y");
3181
3181
  return r.append(s, g), i.append(r), t.append(i), {
3182
3182
  root: i,
3183
3183
  layout: r,
3184
3184
  stack: s,
3185
3185
  volumeCanvas: n,
3186
- candleCanvas: a,
3187
- shapesCanvas: o,
3186
+ candleCanvas: o,
3187
+ shapesCanvas: a,
3188
3188
  tradesCanvas: l,
3189
3189
  overlayCanvas: d,
3190
3190
  axisXCanvas: u,
@@ -3217,8 +3217,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3217
3217
  #l = null;
3218
3218
  #u = null;
3219
3219
  #n = null;
3220
- #o = null;
3221
3220
  #a = null;
3221
+ #o = null;
3222
3222
  #d = null;
3223
3223
  #h = null;
3224
3224
  #f = !1;
@@ -3227,8 +3227,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3227
3227
  #x = 0;
3228
3228
  #T = 0;
3229
3229
  #p = null;
3230
- #P = null;
3231
3230
  #w = null;
3231
+ #P = null;
3232
3232
  constructor(t, e) {
3233
3233
  this.#t = t, this.#e = e, this.#r = ut(e.config), this.#s = re(t, this.#r.colors.background), this.#h = new Et({
3234
3234
  canvas: this.#s.overlayCanvas,
@@ -3239,13 +3239,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3239
3239
  }
3240
3240
  updateProps(t) {
3241
3241
  const e = this.#e.activeShapeTool;
3242
- this.#e = t, this.#r = ut(t.config), this.#s && (this.#s.root.style.backgroundColor = this.#r.colors.background, this.#s.layout.style.setProperty("--axis-x-height", `${this.#r.axis.axisX.height}px`)), !this.#f && t.candles.length > 0 && this.#M(t.candles), this.#i && (t.activeShapeTool !== e && this.#B(t.activeShapeTool), this.#l?.setConfig(this.#r.shapes), this.#l?.setShapes(t.shapes), this.#l?.setActiveTool(t.activeShapeTool), this.#u?.setConfig(this.#r.shapes.previousDayHighLow ?? null), this.#u?.setPreviousDay(t.previousDay), this.#n?.setPastTrades(t.pastTrades ?? []), this.#b(), this.#A(), this.#g());
3242
+ this.#e = t, this.#r = ut(t.config), this.#s && (this.#s.root.style.backgroundColor = this.#r.colors.background, this.#s.layout.style.setProperty("--axis-x-height", `${this.#r.axis.axisX.height}px`)), !this.#f && t.candles.length > 0 && this.#M(t.candles), this.#i && (t.activeShapeTool !== e && this.#B(t.activeShapeTool), this.#l?.setConfig(this.#r.shapes), this.#l?.setShapes(t.shapes), this.#l?.setActiveTool(t.activeShapeTool), this.#u?.setConfig(this.#r.shapes.previousDayHighLow ?? null), this.#u?.setPreviousDay(t.previousDay), this.#n?.setClosedTrades(t.closedTrades ?? []), this.#b(), this.#A(), this.#g());
3243
3243
  }
3244
3244
  resetChartView() {
3245
3245
  this.#i?.resetView(), this.#g();
3246
3246
  }
3247
3247
  destroy() {
3248
- this.#w?.abort(), this.#w = null, this.#P?.disconnect(), this.#P = null, this.#s?.root.remove(), this.#s = null, this.#c = null, this.#i = null, this.#l = null, this.#u = null, this.#n = null, this.#o = null, this.#a = null, this.#d = null, this.#h = null, this.#f = !1;
3248
+ this.#P?.abort(), this.#P = null, this.#w?.disconnect(), this.#w = null, this.#s?.root.remove(), this.#s = null, this.#c = null, this.#i = null, this.#l = null, this.#u = null, this.#n = null, this.#a = null, this.#o = null, this.#d = null, this.#h = null, this.#f = !1;
3249
3249
  }
3250
3250
  #M(t) {
3251
3251
  if (!this.#s || this.#f) return;
@@ -3293,10 +3293,10 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3293
3293
  i && (this.#u = new Gt({
3294
3294
  ctx: i,
3295
3295
  config: this.#r.shapes.previousDayHighLow ?? null
3296
- }), this.#u.setPreviousDay(this.#e.previousDay)), this.#n = new Qt({ canvas: this.#s.tradesCanvas }), this.#n.setCandles(e), this.#n.setPastTrades(this.#e.pastTrades ?? []), this.#b(), this.#a = new Yt({
3296
+ }), this.#u.setPreviousDay(this.#e.previousDay)), this.#n = new Qt({ canvas: this.#s.tradesCanvas }), this.#n.setCandles(e), this.#n.setClosedTrades(this.#e.closedTrades ?? []), this.#b(), this.#o = new Yt({
3297
3297
  canvas: this.#s.axisXCanvas,
3298
3298
  candles: e
3299
- }), this.#d = new Vt({ canvas: this.#s.axisYCanvas }), this.#o = new ee({
3299
+ }), this.#d = new Vt({ canvas: this.#s.axisYCanvas }), this.#a = new ee({
3300
3300
  canvas: this.#s.tradesCanvas,
3301
3301
  getHandleHitboxes: () => this.#m() ? [] : this.#n?.handleHitboxes ?? [],
3302
3302
  getCurrentPrice: () => this.#i?.liveCandle?.close ?? 0,
@@ -3310,8 +3310,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3310
3310
  }
3311
3311
  #R() {
3312
3312
  if (!this.#s) return;
3313
- this.#w = new AbortController();
3314
- const { signal: t } = this.#w, e = this.#s.interactionTarget;
3313
+ this.#P = new AbortController();
3314
+ const { signal: t } = this.#P, e = this.#s.interactionTarget;
3315
3315
  e.addEventListener("pointerdown", (i) => this.#N(i), { signal: t }), e.addEventListener("pointerup", (i) => this.#U(i), { signal: t }), e.addEventListener("pointermove", (i) => this.#G(i), { signal: t }), e.addEventListener("pointerenter", (i) => this.#_(i), { signal: t }), e.addEventListener("pointerleave", () => this.#$(), { signal: t }), e.addEventListener("contextmenu", (i) => this.#J(i), { signal: t }), e.addEventListener("wheel", (i) => this.#E(i), {
3316
3316
  passive: !1,
3317
3317
  signal: t
@@ -3321,9 +3321,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3321
3321
  }), document.addEventListener("keydown", (i) => this.#j(i), { signal: t });
3322
3322
  }
3323
3323
  #W() {
3324
- this.#P = new ResizeObserver(() => {
3324
+ this.#w = new ResizeObserver(() => {
3325
3325
  this.#H(), this.#g();
3326
- }), this.#P.observe(this.#t);
3326
+ }), this.#w.observe(this.#t);
3327
3327
  }
3328
3328
  #D() {
3329
3329
  const t = this.#r.axis.axisY.width, e = this.#r.axis.axisX.height, i = this.#t.clientWidth, r = this.#t.clientHeight;
@@ -3347,7 +3347,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3347
3347
  this.#v = t, this.#C(this.#s.volumeCanvas, t, e), this.#C(this.#s.candleCanvas, t, e), this.#C(this.#s.shapesCanvas, t, e), this.#C(this.#s.overlayCanvas, t, e), this.#C(this.#s.tradesCanvas, t, e), this.#C(this.#s.axisXCanvas, t, r), this.#C(this.#s.axisYCanvas, i, e);
3348
3348
  }
3349
3349
  #S() {
3350
- this.#i && (this.#a?.setCandles(this.#i.candles), this.#a?.setViewport(this.#i.viewport), this.#a?.render(), this.#d?.setViewport(this.#i.viewport), this.#d?.render());
3350
+ this.#i && (this.#o?.setCandles(this.#i.candles), this.#o?.setViewport(this.#i.viewport), this.#o?.render(), this.#d?.setViewport(this.#i.viewport), this.#d?.render());
3351
3351
  }
3352
3352
  #g() {
3353
3353
  this.#i && (this.#c?.setCandles(this.#i.candles), this.#c?.setLiveCandle(this.#i.liveCandle), this.#c?.setViewport(this.#i.viewport), this.#c?.render(), this.#i.render(), this.#l?.setCandles(this.#i.candles), this.#l?.setViewport(this.#i.viewport), this.#l?.render(), this.#u?.setViewport(this.#i.viewport), this.#u?.render(), this.#n?.setCandles(this.#i.candles), this.#n?.setViewport(this.#i.viewport), this.#n?.isDragging ? this.#n.renderLiveFeed() : this.#n?.render(), this.#S(), this.#h?.render());
@@ -3356,7 +3356,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3356
3356
  return this.#e.activeShapeTool !== null;
3357
3357
  }
3358
3358
  #B(t) {
3359
- t !== null && (this.#y = !1, this.#n?.setIsDragging(!1), this.#o?.cancelActiveInteraction()), this.#l?.setActiveTool(t);
3359
+ t !== null && (this.#y = !1, this.#n?.setIsDragging(!1), this.#a?.cancelActiveInteraction()), this.#l?.setActiveTool(t);
3360
3360
  }
3361
3361
  #X() {
3362
3362
  const t = this.#e.openTrades ?? [];
@@ -3417,18 +3417,18 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3417
3417
  visible: !0,
3418
3418
  y: this.#h.mouseY,
3419
3419
  price: n
3420
- }), this.#a?.setCrosshair({
3420
+ }), this.#o?.setCrosshair({
3421
3421
  visible: !0,
3422
3422
  x: this.#h.mouseX,
3423
3423
  candle: r
3424
3424
  }), this.#S(), this.#h.render();
3425
3425
  }
3426
3426
  #V() {
3427
- this.#h?.hide(), this.#a?.hideCrosshair(), this.#d?.hideCrosshair(), this.#S(), this.#h?.render();
3427
+ this.#h?.hide(), this.#o?.hideCrosshair(), this.#d?.hideCrosshair(), this.#S(), this.#h?.render();
3428
3428
  }
3429
3429
  #E(t) {
3430
3430
  if (!this.#i || !this.#n) return;
3431
- this.#m() || this.#o?.handlePointerEvent(t), t.preventDefault();
3431
+ this.#m() || this.#a?.handlePointerEvent(t), t.preventDefault();
3432
3432
  const e = t.deltaY < 0 ? 1 : -1;
3433
3433
  t.ctrlKey || t.metaKey ? this.#i.zoomVertically(e) : this.#i.zoomHorizontally(e), this.#g();
3434
3434
  }
@@ -3443,11 +3443,11 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3443
3443
  this.#g();
3444
3444
  return;
3445
3445
  }
3446
- this.#m() || this.#o?.handlePointerEvent(t) || (this.#y = !0, this.#x = t.clientX, this.#T = t.clientY);
3446
+ this.#m() || this.#a?.handlePointerEvent(t) || (this.#y = !0, this.#x = t.clientX, this.#T = t.clientY);
3447
3447
  }
3448
3448
  #G(t) {
3449
3449
  const e = this.#l?.handlePointerEvent(t) ?? !1;
3450
- if (this.#m() || this.#o?.handlePointerEvent(t), this.#L(t), e) {
3450
+ if (this.#m() || this.#a?.handlePointerEvent(t), this.#L(t), e) {
3451
3451
  this.#g(), this.#L(t);
3452
3452
  return;
3453
3453
  }
@@ -3460,10 +3460,10 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3460
3460
  this.#g();
3461
3461
  return;
3462
3462
  }
3463
- this.#m() || this.#o?.handlePointerEvent(t);
3463
+ this.#m() || this.#a?.handlePointerEvent(t);
3464
3464
  }
3465
3465
  #_(t) {
3466
- document.body.style.cursor = "crosshair", this.#l?.handlePointerEvent(t), this.#m() || this.#o?.handlePointerEvent(t);
3466
+ document.body.style.cursor = "crosshair", this.#l?.handlePointerEvent(t), this.#m() || this.#a?.handlePointerEvent(t);
3467
3467
  }
3468
3468
  #$() {
3469
3469
  this.#l?.clearHoverState(), document.body.style.cursor = "", this.#V();
@@ -3474,19 +3474,19 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3474
3474
  #j(t) {
3475
3475
  (this.#l?.handleKeyboardEvent(t) ?? !1) && (t.preventDefault(), this.#g());
3476
3476
  }
3477
- }, oe = Mt(({ className: t, style: e, ...i }, r) => {
3478
- const s = z(null), n = z(null), a = z(i);
3479
- return a.current = i, Rt(r, () => ({ resetChartView() {
3477
+ }, ae = Mt(({ className: t, style: e, ...i }, r) => {
3478
+ const s = z(null), n = z(null), o = z(i);
3479
+ return o.current = i, Rt(r, () => ({ resetChartView() {
3480
3480
  n.current?.resetChartView();
3481
3481
  } })), tt(() => {
3482
- const o = s.current;
3483
- if (!o) return;
3484
- const l = new se(o, a.current);
3482
+ const a = s.current;
3483
+ if (!a) return;
3484
+ const l = new se(a, o.current);
3485
3485
  return n.current = l, () => {
3486
3486
  l.destroy(), n.current = null;
3487
3487
  };
3488
3488
  }, []), tt(() => {
3489
- n.current?.updateProps(a.current);
3489
+ n.current?.updateProps(o.current);
3490
3490
  }, [i]), /* @__PURE__ */ Wt("div", {
3491
3491
  ref: s,
3492
3492
  className: t,
@@ -3499,5 +3499,5 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3499
3499
  });
3500
3500
  export {
3501
3501
  c as CHART_CONFIG,
3502
- oe as TradingReload
3502
+ ae as TradingReload
3503
3503
  };