@pradeepjadhav/trading-reload-chart 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { forwardRef as Rt, useEffect as rt, useImperativeHandle as Dt, useRef as N } from "react";
1
+ import { forwardRef as Rt, useEffect as st, useImperativeHandle as Dt, useRef as N } from "react";
2
2
  import { jsx as At } from "react/jsx-runtime";
3
3
  var h = {
4
4
  primary: "#7959F7",
@@ -23,7 +23,7 @@ var h = {
23
23
  gray: "#808080",
24
24
  orange: "#ff9500",
25
25
  purple: "#af52de"
26
- }, st = {
26
+ }, rt = {
27
27
  defaultWidthCandles: 10,
28
28
  defaultStopLossPercent: 0.1,
29
29
  defaultRiskRewardRatio: 1.5,
@@ -114,8 +114,8 @@ var h = {
114
114
  fillColor: y.gray,
115
115
  fillOpacity: 0
116
116
  },
117
- longPosition: { ...st },
118
- shortPosition: { ...st },
117
+ longPosition: { ...rt },
118
+ shortPosition: { ...rt },
119
119
  previousDayHighLow: {
120
120
  line: {
121
121
  color: h.red,
@@ -412,22 +412,22 @@ var h = {
412
412
  if (t.length < 2) return 900 * 1e3;
413
413
  const e = [];
414
414
  for (let i = 1; i < Math.min(t.length, 10); i++) e.push(t[i].time - t[i - 1].time);
415
- return e.sort((i, r) => i - r), e[Math.floor(e.length / 2)];
416
- }, Bt = ({ candleSpacing: t, candleTimeframeMs: e, labelWidth: i, minLabelGap: r }) => {
415
+ return e.sort((i, s) => i - s), e[Math.floor(e.length / 2)];
416
+ }, Bt = ({ candleSpacing: t, candleTimeframeMs: e, labelWidth: i, minLabelGap: s }) => {
417
417
  if (t <= 0 || e <= 0) return lt[0];
418
- const s = i + r;
419
- for (const a of lt) if (a / e * t >= s) return a;
418
+ const r = i + s;
419
+ for (const a of lt) if (a / e * t >= r) return a;
420
420
  const n = 1440 * 60 * 1e3, o = n / e * t;
421
- return n * Math.ceil(s / o);
421
+ return n * Math.ceil(r / o);
422
422
  }, Wt = (t, e) => {
423
- const i = new Date(t), r = (i.getHours() * 60 + i.getMinutes()) * 60 * 1e3 + i.getSeconds() * 1e3 + i.getMilliseconds();
424
- return e >= 1440 * 60 * 1e3 ? r === 0 : r % e === 0;
423
+ const i = new Date(t), s = (i.getHours() * 60 + i.getMinutes()) * 60 * 1e3 + i.getSeconds() * 1e3 + i.getMilliseconds();
424
+ return e >= 1440 * 60 * 1e3 ? s === 0 : s % e === 0;
425
425
  }, Ft = (t) => {
426
- const e = new Date(t), i = e.getHours(), r = e.getMinutes();
427
- return i === 0 && r === 0 ? String(e.getDate()) : `${String(i).padStart(2, "0")}:${String(r).padStart(2, "0")}`;
426
+ const e = new Date(t), i = e.getHours(), s = e.getMinutes();
427
+ return i === 0 && s === 0 ? String(e.getDate()) : `${String(i).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
428
428
  }, Yt = (t) => {
429
- const e = new Date(t), i = e.toLocaleDateString("en-US", { weekday: "short" }), r = e.toLocaleDateString("en-US", { month: "short" });
430
- return `${i} ${e.getDate()} ${r} ${e.getHours().toString().padStart(2, "0")}.${e.getMinutes().toString().padStart(2, "0")}`;
429
+ const e = new Date(t), i = e.toLocaleDateString("en-US", { weekday: "short" }), s = e.toLocaleDateString("en-US", { month: "short" });
430
+ return `${i} ${e.getDate()} ${s} ${e.getHours().toString().padStart(2, "0")}.${e.getMinutes().toString().padStart(2, "0")}`;
431
431
  }, Ot = class {
432
432
  #t;
433
433
  #e;
@@ -461,10 +461,10 @@ var h = {
461
461
  }
462
462
  drawCrosshairTimeLabel() {
463
463
  if (!this.crosshair.visible || !this.crosshair.candle) return;
464
- const t = this.#e, e = this.#t.width, i = this.#t.height, r = c.axis.axisX.crosshairLabel, s = Yt(this.crosshair.candle.time);
465
- t.save(), t.font = r.font;
466
- const n = t.measureText(s).width + r.paddingX * 2, o = r.height, a = this.getCrosshairLabelX(n, e), l = Math.max(0, (i - o) / 2);
467
- 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();
464
+ const t = this.#e, e = this.#t.width, i = this.#t.height, s = c.axis.axisX.crosshairLabel, r = Yt(this.crosshair.candle.time);
465
+ t.save(), t.font = s.font;
466
+ const n = t.measureText(r).width + s.paddingX * 2, o = s.height, a = this.getCrosshairLabelX(n, e), l = Math.max(0, (i - o) / 2);
467
+ t.fillStyle = s.backgroundColor, t.fillRect(a, l, n, o), t.strokeStyle = s.borderColor, t.lineWidth = s.borderWidth, t.strokeRect(a, l, n, o), t.fillStyle = s.textColor, t.textAlign = "center", t.textBaseline = "middle", t.fillText(r, a + n / 2, l + o / 2), t.restore();
468
468
  }
469
469
  clearCanvas() {
470
470
  this.#e.clearRect(0, 0, this.#t.width, this.#t.height);
@@ -479,16 +479,16 @@ var h = {
479
479
  }
480
480
  drawAxisLabels() {
481
481
  if (!this.viewport) return;
482
- const t = this.#e, e = c.axis.axisX, i = this.#t.width, r = It(this.candles);
482
+ const t = this.#e, e = c.axis.axisX, i = this.#t.width, s = It(this.candles);
483
483
  t.save(), t.font = e.font, t.fillStyle = e.textColor, t.textAlign = e.textAlign, t.textBaseline = "middle";
484
- const s = t.measureText("00:00").width, n = Bt({
484
+ const r = t.measureText("00:00").width, n = Bt({
485
485
  candleSpacing: this.viewport.candleSpacing,
486
- candleTimeframeMs: r,
487
- labelWidth: s,
486
+ candleTimeframeMs: s,
487
+ labelWidth: r,
488
488
  minLabelGap: e.minLabelGap
489
489
  }), { startIndex: o, endIndex: a } = this.getVisibleCandleIndexRange(i);
490
490
  for (let l = o; l <= a; l += 1) {
491
- const d = this.getSlotTime(l, r);
491
+ const d = this.getSlotTime(l, s);
492
492
  if (d === null || !Wt(d, n)) continue;
493
493
  const u = this.getCandleCenterX(l), g = Ft(d), m = t.measureText(g).width;
494
494
  this.isLabelOutsideCanvas(u, m, i) || (this.drawTick(u), this.drawLabel(g, u));
@@ -508,18 +508,18 @@ var h = {
508
508
  }
509
509
  getSlotTime(t, e) {
510
510
  if (t < this.candles.length) {
511
- const s = this.candles[t];
512
- return s ? s.time : null;
511
+ const r = this.candles[t];
512
+ return r ? r.time : null;
513
513
  }
514
514
  const i = this.candles[this.candles.length - 1];
515
515
  if (!i) return null;
516
- const r = t - (this.candles.length - 1);
517
- return i.time + r * e;
516
+ const s = t - (this.candles.length - 1);
517
+ return i.time + s * e;
518
518
  }
519
519
  getCandleCenterX(t) {
520
520
  if (!this.viewport) return 0;
521
- const { candleSpacing: e, candleWidth: i, offsetX: r } = this.viewport;
522
- return t * e + r + i / 2;
521
+ const { candleSpacing: e, candleWidth: i, offsetX: s } = this.viewport;
522
+ return t * e + s + i / 2;
523
523
  }
524
524
  isLabelOutsideCanvas(t, e, i) {
525
525
  return t + e / 2 < 0 || t - e / 2 > i;
@@ -529,25 +529,25 @@ var h = {
529
529
  e.strokeStyle = i.tickColor, e.lineWidth = i.tickWidth, e.beginPath(), e.moveTo(t, 0), e.lineTo(t, i.tickLength), e.stroke();
530
530
  }
531
531
  drawLabel(t, e) {
532
- const i = this.#e, r = c.axis.axisX;
533
- i.fillStyle = r.textColor, i.fillText(t, e, r.labelOffsetY);
532
+ const i = this.#e, s = c.axis.axisX;
533
+ i.fillStyle = s.textColor, i.fillText(t, e, s.labelOffsetY);
534
534
  }
535
535
  getCrosshairLabelX(t, e) {
536
536
  return Math.max(120, Math.min(e - t, this.crosshair.x - t / 2));
537
537
  }
538
- }, p = (t, e = 5) => Number(t.toFixed(e)), O = ({ price: t, minPrice: e, priceRange: i, chartHeight: r }) => r - (t - e) / i * r, mt = ({ y: t, minPrice: e, priceRange: i, chartHeight: r }) => e + (1 - t / r) * i, Et = ({ priceRange: t, canvasHeight: e }) => {
539
- const i = t / (e / c.axis.axisY.tickGap), r = 10 ** Math.floor(Math.log10(i));
540
- for (const s of [
538
+ }, p = (t, e = 5) => Number(t.toFixed(e)), O = ({ price: t, minPrice: e, priceRange: i, chartHeight: s }) => s - (t - e) / i * s, mt = ({ y: t, minPrice: e, priceRange: i, chartHeight: s }) => e + (1 - t / s) * i, Et = ({ priceRange: t, canvasHeight: e }) => {
539
+ const i = t / (e / c.axis.axisY.tickGap), s = 10 ** Math.floor(Math.log10(i));
540
+ for (const r of [
541
541
  1,
542
542
  2,
543
543
  5,
544
544
  10
545
545
  ]) {
546
- const n = s * r;
546
+ const n = r * s;
547
547
  if (n >= i) return n;
548
548
  }
549
- return 10 * r;
550
- }, Vt = class {
549
+ return 10 * s;
550
+ }, zt = class {
551
551
  #t;
552
552
  #e;
553
553
  viewport = null;
@@ -576,8 +576,8 @@ var h = {
576
576
  }
577
577
  drawCrosshairPriceLabel() {
578
578
  if (!this.crosshair.visible) return;
579
- 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);
580
- 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();
579
+ const t = this.#e, e = this.#t.width, i = this.#t.height, s = c.axis.axisY.crosshairLabel, r = p(this.crosshair.price).toFixed(5), n = s.height, o = this.getCrosshairLabelY(n, i);
580
+ t.save(), t.fillStyle = s.backgroundColor, t.fillRect(0, o, e, n), t.strokeStyle = s.borderColor, t.lineWidth = s.borderWidth, t.strokeRect(0, o, e, n), t.font = s.font, t.fillStyle = s.textColor, t.textAlign = "left", t.textBaseline = "middle", t.fillText(r, s.paddingX, o + n / 2), t.restore();
581
581
  }
582
582
  clearCanvas() {
583
583
  this.#e.clearRect(0, 0, this.#t.width, this.#t.height);
@@ -592,13 +592,13 @@ var h = {
592
592
  }
593
593
  drawPriceLabels() {
594
594
  if (!this.viewport) return;
595
- const t = this.#e, e = this.#t.height, i = c.axis.axisY, r = Et({
595
+ const t = this.#e, e = this.#t.height, i = c.axis.axisY, s = Et({
596
596
  priceRange: this.viewport.priceRange,
597
597
  canvasHeight: e
598
598
  });
599
599
  t.save(), t.font = i.font, t.fillStyle = i.textColor, t.textAlign = i.textAlign, t.textBaseline = "middle";
600
- const { startPrice: s, endPrice: n } = this.getVisiblePriceRange(r);
601
- for (let o = s; o <= n; o += r) {
600
+ const { startPrice: r, endPrice: n } = this.getVisiblePriceRange(s);
601
+ for (let o = r; o <= n; o += s) {
602
602
  const a = this.getPriceY(o, e);
603
603
  this.isPriceOutsideCanvas(a, e) || (this.drawTick(a), this.drawPriceLabel(o, a));
604
604
  }
@@ -629,13 +629,13 @@ var h = {
629
629
  e.strokeStyle = i.tickColor, e.lineWidth = i.tickWidth, e.beginPath(), e.moveTo(0, t), e.lineTo(i.tickLength, t), e.stroke();
630
630
  }
631
631
  drawPriceLabel(t, e) {
632
- const i = this.#e, r = c.axis.axisY;
633
- i.fillStyle = r.textColor, i.fillText(p(t).toFixed(5), r.labelOffsetX, e);
632
+ const i = this.#e, s = c.axis.axisY;
633
+ i.fillStyle = s.textColor, i.fillText(p(t).toFixed(5), s.labelOffsetX, e);
634
634
  }
635
635
  getCrosshairLabelY(t, e) {
636
636
  return Math.max(0, Math.min(e - t, this.crosshair.y - t / 2));
637
637
  }
638
- }, zt = class {
638
+ }, Vt = class {
639
639
  #t;
640
640
  #e;
641
641
  mouseX = 0;
@@ -651,8 +651,8 @@ var h = {
651
651
  this.#e = e, this.crosshairColor = t.crosshairColor ?? c.crosshair.color, this.crosshairThickness = t.crosshairThickness ?? c.crosshair.thickness, this.crosshairStyle = t.crosshairStyle ?? c.crosshair.style;
652
652
  }
653
653
  updateMousePosition(t, e, i = {}) {
654
- const r = this.getLocalCanvasPoint(t, e), s = i.snapX ?? r.x;
655
- this.mouseX = this.clampX(s), this.mouseY = this.clampY(r.y), this.visible = !0;
654
+ const s = this.getLocalCanvasPoint(t, e), r = i.snapX ?? s.x;
655
+ this.mouseX = this.clampX(r), this.mouseY = this.clampY(s.y), this.visible = !0;
656
656
  }
657
657
  hide() {
658
658
  this.visible = !1;
@@ -684,10 +684,10 @@ var h = {
684
684
  t.clearRect(0, 0, e, i), this.visible && (t.save(), this.applyCrosshairStyle(), this.drawVerticalCrosshairLine(t, i), this.drawHorizontalCrosshairLine(t, e), t.restore());
685
685
  }
686
686
  getLocalCanvasPoint(t, e) {
687
- const i = this.#t.getBoundingClientRect(), r = this.#t.width / i.width, s = this.#t.height / i.height;
687
+ const i = this.#t.getBoundingClientRect(), s = this.#t.width / i.width, r = this.#t.height / i.height;
688
688
  return {
689
- x: (t - i.left) * r,
690
- y: (e - i.top) * s
689
+ x: (t - i.left) * s,
690
+ y: (e - i.top) * r
691
691
  };
692
692
  }
693
693
  clampX(t) {
@@ -709,8 +709,8 @@ var h = {
709
709
  return [2, 6];
710
710
  }
711
711
  }
712
- drawLine({ ctx: t, fromX: e, fromY: i, toX: r, toY: s }) {
713
- t.beginPath(), t.moveTo(e, i), t.lineTo(r, s), t.stroke();
712
+ drawLine({ ctx: t, fromX: e, fromY: i, toX: s, toY: r }) {
713
+ t.beginPath(), t.moveTo(e, i), t.lineTo(s, r), t.stroke();
714
714
  }
715
715
  }, F = 60 * 1e3, Ct = 60 * F, Nt = 24 * Ct, _t = class {
716
716
  #t;
@@ -740,8 +740,8 @@ var h = {
740
740
  this.setFallbackViewport();
741
741
  return;
742
742
  }
743
- const t = this.getInitialVisibleCandles(), { minPrice: e, maxPrice: i } = this.getCandlesPriceBounds(t), r = this.getInitialPriceRange(e, i);
744
- this.priceCenter = (e + i) / 2, this.priceRange = r, this.initialPriceRange = r;
743
+ const t = this.getInitialVisibleCandles(), { minPrice: e, maxPrice: i } = this.getCandlesPriceBounds(t), s = this.getInitialPriceRange(e, i);
744
+ this.priceCenter = (e + i) / 2, this.priceRange = s, this.initialPriceRange = s;
745
745
  }
746
746
  isWithinAutoFollowThreshold() {
747
747
  return this.getRightGap() <= this.autoFollowThresholdCandles * this.candleSpacing + 5;
@@ -833,11 +833,11 @@ var h = {
833
833
  render() {
834
834
  const t = this.#e, e = this.#t.width, i = this.#t.height;
835
835
  if (this.clearCanvas(t, e, i), this.candles.length === 0) return;
836
- const { startIndex: r, endIndex: s } = this.getVisibleRange(e), n = this.candles.slice(r, s + 1);
836
+ const { startIndex: s, endIndex: r } = this.getVisibleRange(e), n = this.candles.slice(s, r + 1);
837
837
  this.drawCandles({
838
838
  ctx: t,
839
839
  candles: n,
840
- startIndex: r,
840
+ startIndex: s,
841
841
  chartHeight: i
842
842
  });
843
843
  const o = {
@@ -847,9 +847,9 @@ var h = {
847
847
  };
848
848
  this.drawAskPriceLine(o), this.drawBidPriceLine(o);
849
849
  }
850
- drawCandles({ ctx: t, candles: e, startIndex: i, chartHeight: r }) {
851
- e.forEach((s, n) => {
852
- const o = i + n, a = this.getCandleX(o), l = this.getCandleColor(s), d = this.getCandleYCoordinates(s, r);
850
+ drawCandles({ ctx: t, candles: e, startIndex: i, chartHeight: s }) {
851
+ e.forEach((r, n) => {
852
+ const o = i + n, a = this.getCandleX(o), l = this.getCandleColor(r), d = this.getCandleYCoordinates(r, s);
853
853
  this.drawSingleCandle({
854
854
  ctx: t,
855
855
  candleX: a,
@@ -858,38 +858,38 @@ var h = {
858
858
  });
859
859
  });
860
860
  }
861
- drawSingleCandle({ ctx: t, candleX: e, openY: i, closeY: r, highY: s, lowY: n, candleColor: o }) {
861
+ drawSingleCandle({ ctx: t, candleX: e, openY: i, closeY: s, highY: r, lowY: n, candleColor: o }) {
862
862
  t.strokeStyle = o, t.fillStyle = o;
863
863
  const a = e + this.candleWidth / 2;
864
- t.beginPath(), t.moveTo(a, s), t.lineTo(a, n), t.stroke();
865
- const l = Math.min(i, r), d = Math.max(Math.abs(r - i), c.candles.minBodyHeight);
864
+ t.beginPath(), t.moveTo(a, r), t.lineTo(a, n), t.stroke();
865
+ const l = Math.min(i, s), d = Math.max(Math.abs(s - i), c.candles.minBodyHeight);
866
866
  t.fillRect(e, l, this.candleWidth, d);
867
867
  }
868
- drawPriceLine({ ctx: t, chartWidth: e, chartHeight: i, price: r, color: s, opacity: n, lineWidth: o, dash: a }) {
869
- const l = this.getPriceY(p(r), i);
870
- 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();
868
+ drawPriceLine({ ctx: t, chartWidth: e, chartHeight: i, price: s, color: r, opacity: n, lineWidth: o, dash: a }) {
869
+ const l = this.getPriceY(p(s), i);
870
+ t.save(), t.globalAlpha = n, t.strokeStyle = r, t.lineWidth = o, t.setLineDash(a), t.beginPath(), t.moveTo(0, l), t.lineTo(e, l), t.stroke(), t.restore();
871
871
  }
872
872
  drawBidPriceLine({ ctx: t, chartWidth: e, chartHeight: i }) {
873
- const r = this.candles.at(-1);
874
- !r || !c.candles.liveBidPriceLine.visible || this.drawPriceLine({
873
+ const s = this.candles.at(-1);
874
+ !s || !c.candles.liveBidPriceLine.visible || this.drawPriceLine({
875
875
  ctx: t,
876
876
  chartWidth: e,
877
877
  chartHeight: i,
878
- price: r.close,
879
- color: this.getBidPriceLineColor(r),
878
+ price: s.close,
879
+ color: this.getBidPriceLineColor(s),
880
880
  opacity: c.candles.liveBidPriceLine.opacity,
881
881
  lineWidth: c.candles.liveBidPriceLine.width,
882
882
  dash: c.candles.liveBidPriceLine.dash
883
883
  });
884
884
  }
885
885
  drawAskPriceLine({ ctx: t, chartWidth: e, chartHeight: i }) {
886
- const r = this.candles.at(-1);
887
- !r || !c.candles.liveAskPriceLine.visible || r.ask == null || this.drawPriceLine({
886
+ const s = this.candles.at(-1);
887
+ !s || !c.candles.liveAskPriceLine.visible || s.ask == null || this.drawPriceLine({
888
888
  ctx: t,
889
889
  chartWidth: e,
890
890
  chartHeight: i,
891
- price: r.ask,
892
- color: this.getAskPriceLineColor(r),
891
+ price: s.ask,
892
+ color: this.getAskPriceLineColor(s),
893
893
  opacity: c.candles.liveAskPriceLine.opacity,
894
894
  lineWidth: c.candles.liveAskPriceLine.width,
895
895
  dash: c.candles.liveAskPriceLine.dash
@@ -917,15 +917,15 @@ var h = {
917
917
  }
918
918
  getCandlesPriceBounds(t) {
919
919
  let e = Number.POSITIVE_INFINITY, i = Number.NEGATIVE_INFINITY;
920
- for (const r of t)
921
- r.low < e && (e = r.low), r.high > i && (i = r.high);
920
+ for (const s of t)
921
+ s.low < e && (e = s.low), s.high > i && (i = s.high);
922
922
  return {
923
923
  minPrice: e,
924
924
  maxPrice: i
925
925
  };
926
926
  }
927
927
  getInitialPriceRange(t, e) {
928
- const i = this.getInitialFallbackPercent(), r = p(e - t), s = Math.max(Math.abs((t + e) / 2) * i, 1e-5), n = Math.max(r, s);
928
+ const i = this.getInitialFallbackPercent(), s = p(e - t), r = Math.max(Math.abs((t + e) / 2) * i, 1e-5), n = Math.max(s, r);
929
929
  return n + n * 0.2;
930
930
  }
931
931
  getInitialFallbackPercent() {
@@ -957,11 +957,11 @@ var h = {
957
957
  return (this.#t.width - this.offsetX) / this.candleSpacing;
958
958
  }
959
959
  getNextHorizontalZoom(t) {
960
- const { speed: e, min: i, max: r } = c.zoom.x, s = this.zoomX + t * e;
961
- return Math.max(i, Math.min(s, r));
960
+ const { speed: e, min: i, max: s } = c.zoom.x, r = this.zoomX + t * e;
961
+ return Math.max(i, Math.min(r, s));
962
962
  }
963
963
  getNextVerticalPriceRange(t) {
964
- 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);
964
+ const { speed: e, min: i, max: s } = c.zoom.y, r = 1 - t * e, n = this.priceRange * r, o = this.initialPriceRange * (i / 100), a = this.initialPriceRange * (s / 100);
965
965
  return Math.max(o, Math.min(n, a));
966
966
  }
967
967
  clearCanvas(t, e, i) {
@@ -996,7 +996,7 @@ var h = {
996
996
  #t;
997
997
  #e;
998
998
  #r = null;
999
- #s = null;
999
+ #i = null;
1000
1000
  constructor({ ctx: t, config: e }) {
1001
1001
  this.#t = t, this.#e = e;
1002
1002
  }
@@ -1007,32 +1007,32 @@ var h = {
1007
1007
  this.#e = t;
1008
1008
  }
1009
1009
  setPreviousDay(t) {
1010
- this.#s = t ?? null;
1010
+ this.#i = t ?? null;
1011
1011
  }
1012
1012
  render() {
1013
- if (!this.#r || !this.#s) return;
1014
- const { high: t, low: e } = this.#s;
1015
- Number.isFinite(t) && t > 0 && this.#c(t, "PDH"), Number.isFinite(e) && e > 0 && this.#c(e, "PDL");
1013
+ if (!this.#r || !this.#i) return;
1014
+ const { high: t, low: e } = this.#i;
1015
+ Number.isFinite(t) && t > 0 && this.#u(t, "PDH"), Number.isFinite(e) && e > 0 && this.#u(e, "PDL");
1016
1016
  }
1017
- #c(t, e) {
1017
+ #u(t, e) {
1018
1018
  if (!this.#r || !this.#e) return;
1019
- const i = this.#t, r = i.canvas, s = O({
1019
+ const i = this.#t, s = i.canvas, r = O({
1020
1020
  price: t,
1021
1021
  minPrice: this.#r.minPrice,
1022
1022
  priceRange: this.#r.priceRange,
1023
- chartHeight: r.height
1023
+ chartHeight: s.height
1024
1024
  });
1025
- if (s < 0 || s > r.height) return;
1026
- const { line: n, text: o } = this.#e, a = r.width;
1025
+ if (r < 0 || r > s.height) return;
1026
+ const { line: n, text: o } = this.#e, a = s.width;
1027
1027
  i.save(), i.font = o.font;
1028
1028
  const l = i.measureText(e).width, d = a / 2, u = l / 2 + o.paddingX;
1029
- 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();
1029
+ i.globalAlpha = n.opacity, i.strokeStyle = n.color, i.lineWidth = n.width, i.setLineDash(n.dash), i.beginPath(), i.moveTo(0, r), i.lineTo(d - u, r), i.stroke(), i.beginPath(), i.moveTo(d + u, r), i.lineTo(a, r), i.stroke(), i.setLineDash([]), i.globalAlpha = 1, i.fillStyle = o.color, i.textAlign = "center", i.textBaseline = "middle", i.fillText(e, d, r), i.restore();
1030
1030
  }
1031
1031
  }, vt = (t, e) => {
1032
- const i = t.getBoundingClientRect(), r = t.width / i.width, s = t.height / i.height;
1032
+ const i = t.getBoundingClientRect(), s = t.width / i.width, r = t.height / i.height;
1033
1033
  return {
1034
- x: (e.clientX - i.left) * r,
1035
- y: (e.clientY - i.top) * s
1034
+ x: (e.clientX - i.left) * s,
1035
+ y: (e.clientY - i.top) * r
1036
1036
  };
1037
1037
  };
1038
1038
  var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `shape-${Date.now()}-${Math.random().toString(16).slice(2)}`, $ = (t, e) => vt(t, e), ht = (t, e) => ({
@@ -1042,40 +1042,40 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1042
1042
  x: e.getXForTime(t.time),
1043
1043
  y: e.getYForPrice(t.price)
1044
1044
  }), Ut = (t, e) => {
1045
- const i = Math.min(t.x, e.x), r = Math.max(t.x, e.x), s = Math.min(t.y, e.y), n = Math.max(t.y, e.y);
1045
+ const i = Math.min(t.x, e.x), s = Math.max(t.x, e.x), r = Math.min(t.y, e.y), n = Math.max(t.y, e.y);
1046
1046
  return {
1047
1047
  left: i,
1048
- top: s,
1049
- right: r,
1048
+ top: r,
1049
+ right: s,
1050
1050
  bottom: n,
1051
- width: r - i,
1052
- height: n - s
1051
+ width: s - i,
1052
+ height: n - r
1053
1053
  };
1054
1054
  }, J = (t, e, i) => Ut(C(t, i), C(e, i)), K = (t, e) => {
1055
- const i = t.x - e.x, r = t.y - e.y;
1056
- return Math.sqrt(i * i + r * r);
1055
+ const i = t.x - e.x, s = t.y - e.y;
1056
+ return Math.sqrt(i * i + s * s);
1057
1057
  }, yt = (t, e, i) => {
1058
- const r = i.x - e.x, s = i.y - e.y, n = r * r + s * s;
1058
+ const s = i.x - e.x, r = i.y - e.y, n = s * s + r * r;
1059
1059
  if (n === 0) return K(t, e);
1060
- const o = Math.max(0, Math.min(1, ((t.x - e.x) * r + (t.y - e.y) * s) / n));
1060
+ const o = Math.max(0, Math.min(1, ((t.x - e.x) * s + (t.y - e.y) * r) / n));
1061
1061
  return K(t, {
1062
- x: e.x + o * r,
1063
- y: e.y + o * s
1062
+ x: e.x + o * s,
1063
+ y: e.y + o * r
1064
1064
  });
1065
1065
  }, wt = (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) => {
1066
1066
  if (!wt(t, e, i)) return !1;
1067
- 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;
1068
- return (r || s) && l || (n || o) && a;
1069
- }, x = ({ shapeId: t, type: e, point: i, radius: r = 5, cursor: s, index: n }) => ({
1067
+ const s = Math.abs(t.x - e.left) <= i, r = 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;
1068
+ return (s || r) && l || (n || o) && a;
1069
+ }, x = ({ shapeId: t, type: e, point: i, radius: s = 5, cursor: r, index: n }) => ({
1070
1070
  shapeId: t,
1071
1071
  type: e,
1072
1072
  x: i.x,
1073
1073
  y: i.y,
1074
- radius: r,
1075
- cursor: s,
1074
+ radius: s,
1075
+ cursor: r,
1076
1076
  index: n
1077
- }), j = (t, e) => K(t, e) <= e.radius + 2, z = (t, e = 1) => t === "dashed" ? [e * 6, e * 4] : t === "dotted" ? [e, e * 3] : [], Q = (t, e, i) => {
1078
- t.strokeStyle = P(e.lineColor, e.lineOpacity), t.lineWidth = i ?? e.lineWidth, t.setLineDash(z(e.lineStyle, t.lineWidth));
1077
+ }), j = (t, e) => K(t, e) <= e.radius + 2, V = (t, e = 1) => t === "dashed" ? [e * 6, e * 4] : t === "dotted" ? [e, e * 3] : [], Q = (t, e, i) => {
1078
+ t.strokeStyle = P(e.lineColor, e.lineOpacity), t.lineWidth = i ?? e.lineWidth, t.setLineDash(V(e.lineStyle, t.lineWidth));
1079
1079
  }, Pt = (t, e, i) => !e || i === void 0 || i <= 0 ? !1 : (t.fillStyle = P(e, i), !0), E = (t) => {
1080
1080
  t.setLineDash([]);
1081
1081
  }, Jt = (t, e, i = {
@@ -1084,35 +1084,35 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1084
1084
  borderThickness: 3
1085
1085
  }) => {
1086
1086
  t.save(), t.beginPath(), t.arc(e.x, e.y, e.radius, 0, Math.PI * 2), t.fillStyle = i.fillColor, t.fill(), t.lineWidth = i.borderThickness, t.strokeStyle = i.borderColor, t.stroke(), t.restore();
1087
- }, V = (t, e, i) => {
1088
- e.forEach((r) => {
1089
- Jt(t, r, i);
1087
+ }, z = (t, e, i) => {
1088
+ e.forEach((s) => {
1089
+ Jt(t, s, i);
1090
1090
  });
1091
1091
  }, P = (t, e) => {
1092
1092
  const i = jt(e, 0, 1);
1093
1093
  return t.startsWith("rgba(") ? t : t.startsWith("rgb(") ? t.replace("rgb(", "rgba(").replace(")", `, ${i})`) : t.startsWith("#") ? Kt(t, i) : t;
1094
1094
  }, Kt = (t, e) => {
1095
- const i = t.replace("#", ""), r = i.length === 3 ? i.split("").map((s) => `${s}${s}`).join("") : i;
1096
- return `rgba(${parseInt(r.slice(0, 2), 16)}, ${parseInt(r.slice(2, 4), 16)}, ${parseInt(r.slice(4, 6), 16)}, ${e})`;
1095
+ const i = t.replace("#", ""), s = i.length === 3 ? i.split("").map((r) => `${r}${r}`).join("") : i;
1096
+ return `rgba(${parseInt(s.slice(0, 2), 16)}, ${parseInt(s.slice(2, 4), 16)}, ${parseInt(s.slice(4, 6), 16)}, ${e})`;
1097
1097
  }, jt = (t, e, i) => Math.min(i, Math.max(e, t)), dt = (t, e, i) => e + (t - e) * i, Z = (t, e) => {
1098
1098
  if (t.length === 0) return -1;
1099
- let i = 0, r = Math.abs(t[0].time - e);
1100
- for (let s = 1; s < t.length; s += 1) {
1101
- const n = Math.abs(t[s].time - e);
1102
- n < r && (r = n, i = s);
1099
+ let i = 0, s = Math.abs(t[0].time - e);
1100
+ for (let r = 1; r < t.length; r += 1) {
1101
+ const n = Math.abs(t[r].time - e);
1102
+ n < s && (s = n, i = r);
1103
1103
  }
1104
1104
  return i;
1105
1105
  }, q = (t) => {
1106
1106
  if (t.length < 2) return 900 * 1e3;
1107
1107
  const e = [];
1108
1108
  for (let i = 1; i < t.length; i += 1) {
1109
- const r = t[i].time - t[i - 1].time;
1110
- r > 0 && e.push(r);
1109
+ const s = t[i].time - t[i - 1].time;
1110
+ s > 0 && e.push(s);
1111
1111
  }
1112
- return e.length === 0 ? 900 * 1e3 : e.reduce((i, r) => i + r, 0) / e.length;
1112
+ return e.length === 0 ? 900 * 1e3 : e.reduce((i, s) => i + s, 0) / e.length;
1113
1113
  }, Zt = (t, e, i) => {
1114
- const r = Z(t, e), s = r + i;
1115
- return r >= 0 && s >= 0 && s < t.length ? t[s].time : e + q(t) * i;
1114
+ const s = Z(t, e), r = s + i;
1115
+ return s >= 0 && r >= 0 && r < t.length ? t[r].time : e + q(t) * i;
1116
1116
  }, ct = (t) => t instanceof MouseEvent && t.type === "contextmenu" ? !1 : "button" in t && t.type === "pointerdown" ? t.button === 0 : !0, f = {
1117
1117
  handleColor: h.background,
1118
1118
  handleBorderColor: h.blue,
@@ -1165,20 +1165,20 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1165
1165
  fillColor: "#808080",
1166
1166
  fillOpacity: 0.04
1167
1167
  };
1168
- static draw({ ctx: e, shape: i, converter: r, config: s = I.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1169
- const [a, l] = i.vertices, d = C(a, r), u = C(l, r), g = J(a, l, r), m = Math.min(d.x, u.x), b = Math.max(d.x, u.x);
1170
- e.save(), Pt(e, s.fillColor, s.fillOpacity) && e.fillRect(g.left, g.top, g.width, g.height);
1171
- for (const v of s.levels) {
1172
- const S = dt(a.price, l.price, v.level), T = r.getYForPrice(S), k = v.lineWidth;
1173
- e.beginPath(), e.strokeStyle = P(v.color, v.opacity), e.lineWidth = k, e.setLineDash(z(v.lineStyle, k)), e.moveTo(m, T), e.lineTo(b, T), e.stroke(), v.label && (e.setLineDash([]), e.fillStyle = P(v.color, v.opacity), e.font = "11px sans-serif", e.textBaseline = "middle", e.fillText(Number(v.label).toFixed(2).toString(), b + 12, T));
1168
+ static draw({ ctx: e, shape: i, converter: s, config: r = I.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1169
+ const [a, l] = i.vertices, d = C(a, s), u = C(l, s), g = J(a, l, s), m = Math.min(d.x, u.x), b = Math.max(d.x, u.x);
1170
+ e.save(), Pt(e, r.fillColor, r.fillOpacity) && e.fillRect(g.left, g.top, g.width, g.height);
1171
+ for (const v of r.levels) {
1172
+ const S = dt(a.price, l.price, v.level), T = s.getYForPrice(S), k = v.lineWidth;
1173
+ e.beginPath(), e.strokeStyle = P(v.color, v.opacity), e.lineWidth = k, e.setLineDash(V(v.lineStyle, k)), e.moveTo(m, T), e.lineTo(b, T), e.stroke(), v.label && (e.setLineDash([]), e.fillStyle = P(v.color, v.opacity), e.font = "11px sans-serif", e.textBaseline = "middle", e.fillText(Number(v.label).toFixed(2).toString(), b + 12, T));
1174
1174
  }
1175
- E(e), (n || o) && V(e, I.getHandles(i, r), {
1175
+ E(e), (n || o) && z(e, I.getHandles(i, s), {
1176
1176
  fillColor: f.handleColor,
1177
1177
  borderColor: f.handleBorderColor,
1178
1178
  borderThickness: f.handleBorderThickness
1179
1179
  }), e.restore();
1180
1180
  }
1181
- static drawDraft({ ctx: e, vertices: i, converter: r, config: s = I.defaultConfig }) {
1181
+ static drawDraft({ ctx: e, vertices: i, converter: s, config: r = I.defaultConfig }) {
1182
1182
  I.draw({
1183
1183
  ctx: e,
1184
1184
  shape: {
@@ -1186,13 +1186,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1186
1186
  type: "fibRetracement",
1187
1187
  vertices: i
1188
1188
  },
1189
- converter: r,
1190
- config: s,
1189
+ converter: s,
1190
+ config: r,
1191
1191
  selected: !0
1192
1192
  });
1193
1193
  }
1194
1194
  static getHandles(e, i) {
1195
- const [r, s] = e.vertices, n = C(r, i), o = C(s, i);
1195
+ const [s, r] = e.vertices, n = C(s, i), o = C(r, i);
1196
1196
  return [x({
1197
1197
  shapeId: e.id,
1198
1198
  type: "start",
@@ -1207,12 +1207,12 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1207
1207
  cursor: "grab"
1208
1208
  })];
1209
1209
  }
1210
- static hitTest({ point: e, shape: i, converter: r, tolerance: s = 8, config: n = I.defaultConfig }) {
1211
- const [o, a] = i.vertices, l = C(o, r), d = C(a, r), u = Math.min(l.x, d.x), g = Math.max(l.x, d.x);
1212
- if (e.x < u - s || e.x > g + s) return !1;
1210
+ static hitTest({ point: e, shape: i, converter: s, tolerance: r = 8, config: n = I.defaultConfig }) {
1211
+ const [o, a] = i.vertices, l = C(o, s), d = C(a, s), u = Math.min(l.x, d.x), g = Math.max(l.x, d.x);
1212
+ if (e.x < u - r || e.x > g + r) return !1;
1213
1213
  for (const m of n.levels) {
1214
- const b = dt(o.price, a.price, m.level), v = r.getYForPrice(b);
1215
- if (Math.abs(e.y - v) <= s) return !0;
1214
+ const b = dt(o.price, a.price, m.level), v = s.getYForPrice(b);
1215
+ if (Math.abs(e.y - v) <= r) return !0;
1216
1216
  }
1217
1217
  return !1;
1218
1218
  }
@@ -1228,13 +1228,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1228
1228
  }]
1229
1229
  };
1230
1230
  }
1231
- static resize(e, i, r) {
1231
+ static resize(e, i, s) {
1232
1232
  return i === "start" ? {
1233
1233
  ...e,
1234
- vertices: [r, e.vertices[1]]
1234
+ vertices: [s, e.vertices[1]]
1235
1235
  } : i === "end" ? {
1236
1236
  ...e,
1237
- vertices: [e.vertices[0], r]
1237
+ vertices: [e.vertices[0], s]
1238
1238
  } : e;
1239
1239
  }
1240
1240
  }, M = class Y {
@@ -1244,15 +1244,15 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1244
1244
  lineOpacity: 1,
1245
1245
  lineStyle: "solid"
1246
1246
  };
1247
- static draw({ ctx: e, shape: i, converter: r, config: s = Y.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1248
- const [a, l] = i.vertices, d = C(a, r), u = C(l, r);
1249
- e.save(), Q(e, s), e.beginPath(), e.moveTo(d.x, d.y), e.lineTo(u.x, u.y), e.stroke(), E(e), (n || o) && V(e, Y.getHandles(i, r), {
1247
+ static draw({ ctx: e, shape: i, converter: s, config: r = Y.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1248
+ const [a, l] = i.vertices, d = C(a, s), u = C(l, s);
1249
+ e.save(), Q(e, r), e.beginPath(), e.moveTo(d.x, d.y), e.lineTo(u.x, u.y), e.stroke(), E(e), (n || o) && z(e, Y.getHandles(i, s), {
1250
1250
  fillColor: f.handleColor,
1251
1251
  borderColor: f.handleBorderColor,
1252
1252
  borderThickness: f.handleBorderThickness
1253
1253
  }), e.restore();
1254
1254
  }
1255
- static drawDraft({ ctx: e, vertices: i, converter: r, config: s = Y.defaultConfig }) {
1255
+ static drawDraft({ ctx: e, vertices: i, converter: s, config: r = Y.defaultConfig }) {
1256
1256
  Y.draw({
1257
1257
  ctx: e,
1258
1258
  shape: {
@@ -1260,13 +1260,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1260
1260
  type: "trendline",
1261
1261
  vertices: i
1262
1262
  },
1263
- converter: r,
1264
- config: s,
1263
+ converter: s,
1264
+ config: r,
1265
1265
  selected: !0
1266
1266
  });
1267
1267
  }
1268
1268
  static getHandles(e, i) {
1269
- const [r, s] = e.vertices, n = C(r, i), o = C(s, i);
1269
+ const [s, r] = e.vertices, n = C(s, i), o = C(r, i);
1270
1270
  return [x({
1271
1271
  shapeId: e.id,
1272
1272
  type: "start",
@@ -1281,9 +1281,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1281
1281
  cursor: "grab"
1282
1282
  })];
1283
1283
  }
1284
- static hitTest({ point: e, shape: i, converter: r, tolerance: s = 8 }) {
1284
+ static hitTest({ point: e, shape: i, converter: s, tolerance: r = 8 }) {
1285
1285
  const [n, o] = i.vertices;
1286
- return yt(e, C(n, r), C(o, r)) <= s;
1286
+ return yt(e, C(n, s), C(o, s)) <= r;
1287
1287
  }
1288
1288
  static move(e, i) {
1289
1289
  return {
@@ -1297,13 +1297,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1297
1297
  }]
1298
1298
  };
1299
1299
  }
1300
- static resize(e, i, r) {
1300
+ static resize(e, i, s) {
1301
1301
  return i === "start" ? {
1302
1302
  ...e,
1303
- vertices: [r, e.vertices[1]]
1303
+ vertices: [s, e.vertices[1]]
1304
1304
  } : i === "end" ? {
1305
1305
  ...e,
1306
- vertices: [e.vertices[0], r]
1306
+ vertices: [e.vertices[0], s]
1307
1307
  } : e;
1308
1308
  }
1309
1309
  }, R = class B {
@@ -1315,27 +1315,27 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1315
1315
  fillColor: "#2962ff",
1316
1316
  fillOpacity: 0
1317
1317
  };
1318
- static draw({ ctx: e, shape: i, converter: r, config: s = B.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1319
- const a = i.vertices.map((l) => C(l, r));
1318
+ static draw({ ctx: e, shape: i, converter: s, config: r = B.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1319
+ const a = i.vertices.map((l) => C(l, s));
1320
1320
  if (a.length !== 0) {
1321
- e.save(), Q(e, s), e.beginPath(), e.moveTo(a[0].x, a[0].y);
1321
+ e.save(), Q(e, r), e.beginPath(), e.moveTo(a[0].x, a[0].y);
1322
1322
  for (let l = 1; l < a.length; l += 1) e.lineTo(a[l].x, a[l].y);
1323
1323
  e.stroke(), E(e), a.length >= 2 && B.drawEndArrow({
1324
1324
  ctx: e,
1325
1325
  previousPoint: a[a.length - 2],
1326
1326
  endPoint: a[a.length - 1],
1327
- color: s.lineColor,
1328
- opacity: s.lineOpacity,
1329
- lineWidth: s.lineWidth
1330
- }), (n || o) && V(e, B.getHandles(i, r), {
1327
+ color: r.lineColor,
1328
+ opacity: r.lineOpacity,
1329
+ lineWidth: r.lineWidth
1330
+ }), (n || o) && z(e, B.getHandles(i, s), {
1331
1331
  fillColor: f.handleColor,
1332
1332
  borderColor: f.handleBorderColor,
1333
1333
  borderThickness: f.handleBorderThickness
1334
1334
  }), e.restore();
1335
1335
  }
1336
1336
  }
1337
- static drawDraft({ ctx: e, vertices: i, previewVertex: r, converter: s, config: n = B.defaultConfig }) {
1338
- const o = r ? [...i, r] : i;
1337
+ static drawDraft({ ctx: e, vertices: i, previewVertex: s, converter: r, config: n = B.defaultConfig }) {
1338
+ const o = s ? [...i, s] : i;
1339
1339
  B.draw({
1340
1340
  ctx: e,
1341
1341
  shape: {
@@ -1343,48 +1343,48 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1343
1343
  type: "path",
1344
1344
  vertices: o
1345
1345
  },
1346
- converter: s,
1346
+ converter: r,
1347
1347
  config: n,
1348
1348
  selected: !0
1349
1349
  });
1350
1350
  }
1351
1351
  static getHandles(e, i) {
1352
- return e.vertices.map((r, s) => x({
1352
+ return e.vertices.map((s, r) => x({
1353
1353
  shapeId: e.id,
1354
- type: s === 0 ? "start" : s === e.vertices.length - 1 ? "end" : "move",
1355
- point: C(r, i),
1354
+ type: r === 0 ? "start" : r === e.vertices.length - 1 ? "end" : "move",
1355
+ point: C(s, i),
1356
1356
  radius: f.handleRadius,
1357
1357
  cursor: "grab",
1358
- index: s
1358
+ index: r
1359
1359
  }));
1360
1360
  }
1361
- static hitTest({ point: e, shape: i, converter: r, tolerance: s = 8 }) {
1362
- const n = i.vertices.map((o) => C(o, r));
1361
+ static hitTest({ point: e, shape: i, converter: s, tolerance: r = 8 }) {
1362
+ const n = i.vertices.map((o) => C(o, s));
1363
1363
  if (n.length === 1) {
1364
1364
  const o = n[0], a = e.x - o.x, l = e.y - o.y;
1365
- return Math.sqrt(a * a + l * l) <= s;
1365
+ return Math.sqrt(a * a + l * l) <= r;
1366
1366
  }
1367
- for (let o = 1; o < n.length; o += 1) if (yt(e, n[o - 1], n[o]) <= s) return !0;
1367
+ for (let o = 1; o < n.length; o += 1) if (yt(e, n[o - 1], n[o]) <= r) return !0;
1368
1368
  return !1;
1369
1369
  }
1370
1370
  static move(e, i) {
1371
1371
  return {
1372
1372
  ...e,
1373
- vertices: e.vertices.map((r) => ({
1374
- time: r.time + i.time,
1375
- price: r.price + i.price
1373
+ vertices: e.vertices.map((s) => ({
1374
+ time: s.time + i.time,
1375
+ price: s.price + i.price
1376
1376
  }))
1377
1377
  };
1378
1378
  }
1379
- static resize(e, i, r) {
1379
+ static resize(e, i, s) {
1380
1380
  return i < 0 || i >= e.vertices.length ? e : {
1381
1381
  ...e,
1382
- vertices: e.vertices.map((s, n) => n === i ? r : s)
1382
+ vertices: e.vertices.map((r, n) => n === i ? s : r)
1383
1383
  };
1384
1384
  }
1385
- static drawEndArrow({ ctx: e, previousPoint: i, endPoint: r, color: s, opacity: n, lineWidth: o }) {
1386
- const a = Math.atan2(r.y - i.y, r.x - i.x), l = 12, d = Math.PI / 7;
1387
- e.save(), e.beginPath(), e.strokeStyle = P(s, n), e.fillStyle = P(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();
1385
+ static drawEndArrow({ ctx: e, previousPoint: i, endPoint: s, color: r, opacity: n, lineWidth: o }) {
1386
+ const a = Math.atan2(s.y - i.y, s.x - i.x), l = 12, d = Math.PI / 7;
1387
+ e.save(), e.beginPath(), e.strokeStyle = P(r, n), e.fillStyle = P(r, n), e.lineWidth = o, e.setLineDash([]), e.moveTo(s.x, s.y), e.lineTo(s.x - l * Math.cos(a - d), s.y - l * Math.sin(a - d)), e.lineTo(s.x - l * Math.cos(a + d), s.y - l * Math.sin(a + d)), e.closePath(), e.fill(), e.stroke(), e.restore();
1388
1388
  }
1389
1389
  }, D = class W {
1390
1390
  static defaultConfig = {
@@ -1399,15 +1399,15 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1399
1399
  textFontFamily: "Arial",
1400
1400
  textFontSize: 20
1401
1401
  };
1402
- static draw({ ctx: e, shape: i, converter: r, config: s = W.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1403
- const [a, l] = i.vertices, d = J(a, l, r);
1404
- e.save(), Pt(e, s.fillColor, s.fillOpacity) && e.fillRect(d.left, d.top, d.width, d.height), Q(e, s), e.strokeRect(d.left, d.top, d.width, d.height), E(e), W.drawText(e, d, i.text, s), (n || o) && V(e, W.getHandles(i, r), {
1402
+ static draw({ ctx: e, shape: i, converter: s, config: r = W.defaultConfig, selected: n = !1, hovered: o = !1 }) {
1403
+ const [a, l] = i.vertices, d = J(a, l, s);
1404
+ e.save(), Pt(e, r.fillColor, r.fillOpacity) && e.fillRect(d.left, d.top, d.width, d.height), Q(e, r), e.strokeRect(d.left, d.top, d.width, d.height), E(e), W.drawText(e, d, i.text, r), (n || o) && z(e, W.getHandles(i, s), {
1405
1405
  fillColor: f.handleColor,
1406
1406
  borderColor: f.handleBorderColor,
1407
1407
  borderThickness: f.handleBorderThickness
1408
1408
  }), e.restore();
1409
1409
  }
1410
- static drawDraft({ ctx: e, vertices: i, converter: r, config: s = W.defaultConfig }) {
1410
+ static drawDraft({ ctx: e, vertices: i, converter: s, config: r = W.defaultConfig }) {
1411
1411
  W.draw({
1412
1412
  ctx: e,
1413
1413
  shape: {
@@ -1415,13 +1415,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1415
1415
  type: "rectangle",
1416
1416
  vertices: i
1417
1417
  },
1418
- converter: r,
1419
- config: s,
1418
+ converter: s,
1419
+ config: r,
1420
1420
  selected: !0
1421
1421
  });
1422
1422
  }
1423
1423
  static getHandles(e, i) {
1424
- const [r, s] = e.vertices, n = C(r, i), o = C(s, i), a = n.x <= o.x, l = n.y <= o.y, d = a === l ? "nwse-resize" : "nesw-resize", u = a === l ? "nwse-resize" : "nesw-resize";
1424
+ const [s, r] = e.vertices, n = C(s, i), o = C(r, i), a = n.x <= o.x, l = n.y <= o.y, d = a === l ? "nwse-resize" : "nesw-resize", u = a === l ? "nwse-resize" : "nesw-resize";
1425
1425
  return [x({
1426
1426
  shapeId: e.id,
1427
1427
  type: "start",
@@ -1436,9 +1436,9 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1436
1436
  cursor: u
1437
1437
  })];
1438
1438
  }
1439
- static hitTest({ point: e, shape: i, converter: r, tolerance: s = 8 }) {
1439
+ static hitTest({ point: e, shape: i, converter: s, tolerance: r = 8 }) {
1440
1440
  const [n, o] = i.vertices;
1441
- return $t(e, J(n, o, r), s);
1441
+ return $t(e, J(n, o, s), r);
1442
1442
  }
1443
1443
  static move(e, i) {
1444
1444
  return {
@@ -1452,18 +1452,18 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1452
1452
  }]
1453
1453
  };
1454
1454
  }
1455
- static resize(e, i, r) {
1455
+ static resize(e, i, s) {
1456
1456
  return i === "start" ? {
1457
1457
  ...e,
1458
- vertices: [r, e.vertices[1]]
1458
+ vertices: [s, e.vertices[1]]
1459
1459
  } : i === "end" ? {
1460
1460
  ...e,
1461
- vertices: [e.vertices[0], r]
1461
+ vertices: [e.vertices[0], s]
1462
1462
  } : e;
1463
1463
  }
1464
- static drawText(e, i, r, s) {
1465
- const n = r?.trim();
1466
- 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());
1464
+ static drawText(e, i, s, r) {
1465
+ const n = s?.trim();
1466
+ n && (e.save(), e.beginPath(), e.rect(i.left, i.top, i.width, i.height), e.clip(), e.font = `${r.textFontSize}px ${r.textFontFamily}`, e.globalAlpha = r.textOpacity, e.fillStyle = r.textColor, e.textAlign = "center", e.textBaseline = "middle", e.fillText(n, i.left + i.width / 2, i.top + i.height / 2), e.restore());
1467
1467
  }
1468
1468
  }, bt = [
1469
1469
  "USDJPY",
@@ -1477,8 +1477,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1477
1477
  "USOIL",
1478
1478
  "UKOIL",
1479
1479
  "XAGUSD"
1480
- ], Tt = (t) => bt.some((e) => t.includes(e.slice(3))) ? 0.01 : xt.includes(t) ? 1 : St.includes(t) ? 0.01 : 1e-4, qt = (t, e) => bt.includes(t) ? e * 6.33806 : xt.includes(t) ? e * 1 : (St.includes(t), e * 10), ut = (t, e, i, r, s) => {
1481
- const n = s.split(".")[0], o = Tt(n), a = qt(n, r);
1480
+ ], Tt = (t) => bt.some((e) => t.includes(e.slice(3))) ? 0.01 : xt.includes(t) ? 1 : St.includes(t) ? 0.01 : 1e-4, qt = (t, e) => bt.includes(t) ? e * 6.33806 : xt.includes(t) ? e * 1 : (St.includes(t), e * 10), ut = (t, e, i, s, r) => {
1481
+ const n = r.split(".")[0], o = Tt(n), a = qt(n, s);
1482
1482
  return (t === "buy" ? i - e : e - i) / o * a;
1483
1483
  }, H = class w {
1484
1484
  static defaultLongConfig = {
@@ -1499,53 +1499,53 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1499
1499
  midLineStyle: "dashed"
1500
1500
  };
1501
1501
  static defaultShortConfig = { ...w.defaultLongConfig };
1502
- static draw({ ctx: e, activeSymbol: i, shape: r, converter: s, config: n = r.type === "longPosition" ? w.defaultLongConfig : w.defaultShortConfig, selected: o = !1, hovered: a = !1 }) {
1503
- const l = w.getGeometry(r, s);
1502
+ static draw({ ctx: e, activeSymbol: i, shape: s, converter: r, config: n = s.type === "longPosition" ? w.defaultLongConfig : w.defaultShortConfig, selected: o = !1, hovered: a = !1 }) {
1503
+ const l = w.getGeometry(s, r);
1504
1504
  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);
1505
1505
  const d = n.borderWidth;
1506
- e.strokeStyle = P(n.borderColor, n.borderOpacity), e.lineWidth = d, e.setLineDash(z(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(z(n.midLineStyle, n.midLineWidth)), e.moveTo(l.box.left, l.entryY), e.lineTo(l.box.right, l.entryY), e.stroke(), E(e), w.drawLabels({
1506
+ e.strokeStyle = P(n.borderColor, n.borderOpacity), e.lineWidth = d, e.setLineDash(V(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(V(n.midLineStyle, n.midLineWidth)), e.moveTo(l.box.left, l.entryY), e.lineTo(l.box.right, l.entryY), e.stroke(), E(e), w.drawLabels({
1507
1507
  ctx: e,
1508
1508
  activeSymbol: i,
1509
- shape: r,
1509
+ shape: s,
1510
1510
  geometry: l,
1511
1511
  config: n
1512
- }), (o || a) && V(e, w.getHandles(r, s), {
1512
+ }), (o || a) && z(e, w.getHandles(s, r), {
1513
1513
  fillColor: f.handleColor,
1514
1514
  borderColor: f.handleBorderColor,
1515
1515
  borderThickness: f.handleBorderThickness
1516
1516
  }), e.restore();
1517
1517
  }
1518
- static createFromVertex({ id: e, type: i, entry: r, converter: s, config: n = i === "longPosition" ? w.defaultLongConfig : w.defaultShortConfig }) {
1519
- const o = s.getTimeForX(s.getXForTime(r.time) + s.getCandleWidth() * n.defaultWidthCandles), a = n.defaultStopLossPercent;
1518
+ static createFromVertex({ id: e, type: i, entry: s, converter: r, config: n = i === "longPosition" ? w.defaultLongConfig : w.defaultShortConfig }) {
1519
+ const o = r.getTimeForX(r.getXForTime(s.time) + r.getCandleWidth() * n.defaultWidthCandles), a = n.defaultStopLossPercent;
1520
1520
  return {
1521
1521
  id: e,
1522
1522
  type: i,
1523
- entry: r,
1523
+ entry: s,
1524
1524
  endTime: o,
1525
1525
  stopLossPercent: a,
1526
1526
  takeProfitPercent: a * n.defaultRiskRewardRatio
1527
1527
  };
1528
1528
  }
1529
1529
  static getGeometry(e, i) {
1530
- const r = C(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), b = i.getYForPrice(g), v = Math.min(m, b, r.y), S = Math.max(m, b, r.y), T = {
1530
+ const s = C(e.entry, i), r = i.getXForTime(e.endTime), n = Math.min(s.x, r), o = Math.max(s.x, r), 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), b = i.getYForPrice(g), v = Math.min(m, b, s.y), S = Math.max(m, b, s.y), T = {
1531
1531
  left: n,
1532
1532
  top: v,
1533
1533
  right: o,
1534
- bottom: r.y,
1534
+ bottom: s.y,
1535
1535
  width: o - n,
1536
- height: Math.abs(r.y - v)
1536
+ height: Math.abs(s.y - v)
1537
1537
  }, k = {
1538
1538
  left: n,
1539
- top: r.y,
1539
+ top: s.y,
1540
1540
  right: o,
1541
1541
  bottom: S,
1542
1542
  width: o - n,
1543
- height: Math.abs(S - r.y)
1543
+ height: Math.abs(S - s.y)
1544
1544
  };
1545
1545
  return {
1546
- entryPoint: r,
1547
- endX: s,
1548
- entryY: r.y,
1546
+ entryPoint: s,
1547
+ endX: r,
1548
+ entryY: s.y,
1549
1549
  upperPrice: u,
1550
1550
  lowerPrice: g,
1551
1551
  box: {
@@ -1561,14 +1561,14 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1561
1561
  };
1562
1562
  }
1563
1563
  static getHandles(e, i) {
1564
- const r = w.getGeometry(e, i);
1564
+ const s = w.getGeometry(e, i);
1565
1565
  return [
1566
1566
  x({
1567
1567
  shapeId: e.id,
1568
1568
  type: "upperHeight",
1569
1569
  point: {
1570
- x: r.box.left,
1571
- y: r.box.top
1570
+ x: s.box.left,
1571
+ y: s.box.top
1572
1572
  },
1573
1573
  radius: f.handleRadius,
1574
1574
  cursor: "ns-resize"
@@ -1577,8 +1577,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1577
1577
  shapeId: e.id,
1578
1578
  type: "lowerHeight",
1579
1579
  point: {
1580
- x: r.box.left,
1581
- y: r.box.bottom
1580
+ x: s.box.left,
1581
+ y: s.box.bottom
1582
1582
  },
1583
1583
  radius: f.handleRadius,
1584
1584
  cursor: "ns-resize"
@@ -1587,8 +1587,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1587
1587
  shapeId: e.id,
1588
1588
  type: "start",
1589
1589
  point: {
1590
- x: r.entryPoint.x,
1591
- y: r.entryY
1590
+ x: s.entryPoint.x,
1591
+ y: s.entryY
1592
1592
  },
1593
1593
  radius: f.handleRadius,
1594
1594
  cursor: "ns-resize"
@@ -1597,16 +1597,16 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1597
1597
  shapeId: e.id,
1598
1598
  type: "end",
1599
1599
  point: {
1600
- x: r.endX,
1601
- y: r.entryY
1600
+ x: s.endX,
1601
+ y: s.entryY
1602
1602
  },
1603
1603
  radius: f.handleRadius,
1604
1604
  cursor: "ew-resize"
1605
1605
  })
1606
1606
  ];
1607
1607
  }
1608
- static hitTest({ point: e, shape: i, converter: r }) {
1609
- return w.getHandles(i, r).some((s) => j(e, s)) ? !0 : wt(e, w.getGeometry(i, r).box);
1608
+ static hitTest({ point: e, shape: i, converter: s }) {
1609
+ return w.getHandles(i, s).some((r) => j(e, r)) ? !0 : wt(e, w.getGeometry(i, s).box);
1610
1610
  }
1611
1611
  static move(e, i) {
1612
1612
  return {
@@ -1618,48 +1618,48 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1618
1618
  endTime: e.endTime + i.time
1619
1619
  };
1620
1620
  }
1621
- static resize({ shape: e, handleType: i, vertex: r, converter: s }) {
1621
+ static resize({ shape: e, handleType: i, vertex: s, converter: r }) {
1622
1622
  return i === "start" ? {
1623
1623
  ...e,
1624
1624
  entry: {
1625
1625
  time: e.entry.time,
1626
- price: r.price
1626
+ price: s.price
1627
1627
  }
1628
1628
  } : i === "end" ? {
1629
1629
  ...e,
1630
- endTime: r.time
1631
- } : i === "upperHeight" ? w.resizeUpperHeight(e, r.price) : i === "lowerHeight" ? w.resizeLowerHeight(e, r.price) : {
1630
+ endTime: s.time
1631
+ } : i === "upperHeight" ? w.resizeUpperHeight(e, s.price) : i === "lowerHeight" ? w.resizeLowerHeight(e, s.price) : {
1632
1632
  ...e,
1633
- endTime: s.getTimeForX(s.getXForTime(e.endTime))
1633
+ endTime: r.getTimeForX(r.getXForTime(e.endTime))
1634
1634
  };
1635
1635
  }
1636
1636
  static resizeUpperHeight(e, i) {
1637
- const r = Math.max(0, (i - e.entry.price) / e.entry.price * 100);
1637
+ const s = Math.max(0, (i - e.entry.price) / e.entry.price * 100);
1638
1638
  return e.type === "longPosition" ? {
1639
1639
  ...e,
1640
- takeProfitPercent: r
1640
+ takeProfitPercent: s
1641
1641
  } : {
1642
1642
  ...e,
1643
- stopLossPercent: r
1643
+ stopLossPercent: s
1644
1644
  };
1645
1645
  }
1646
1646
  static resizeLowerHeight(e, i) {
1647
- const r = Math.max(0, (e.entry.price - i) / e.entry.price * 100);
1647
+ const s = Math.max(0, (e.entry.price - i) / e.entry.price * 100);
1648
1648
  return e.type === "longPosition" ? {
1649
1649
  ...e,
1650
- stopLossPercent: r
1650
+ stopLossPercent: s
1651
1651
  } : {
1652
1652
  ...e,
1653
- takeProfitPercent: r
1653
+ takeProfitPercent: s
1654
1654
  };
1655
1655
  }
1656
- static drawLabels({ ctx: e, activeSymbol: i, shape: r, geometry: s, config: n }) {
1656
+ static drawLabels({ ctx: e, activeSymbol: i, shape: s, geometry: r, config: n }) {
1657
1657
  e.save(), e.font = "11px sans-serif", e.textBaseline = "middle";
1658
- 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;
1658
+ const o = s.type, a = Tt(i), l = s.entry.price * (s.takeProfitPercent / 100) / a, d = s.entry.price * (s.stopLossPercent / 100) / a, u = r.box.left + 6, g = l / d;
1659
1659
  e.fillStyle = P(n.profitFillColor, 0.95);
1660
- const m = o === "longPosition" ? s.profitBox.top + s.profitBox.height / 10 : s.profitBox.bottom - s.profitBox.height / 10;
1660
+ const m = o === "longPosition" ? r.profitBox.top + r.profitBox.height / 10 : r.profitBox.bottom - r.profitBox.height / 10;
1661
1661
  e.fillText(`${l.toFixed(2)} (${g.toFixed(2)})`, u, m), e.fillStyle = P(n.lossFillColor, 0.95);
1662
- const b = o === "shortPosition" ? s.lossBox.top + s.lossBox.height / 10 : s.lossBox.bottom - s.lossBox.height / 10;
1662
+ const b = o === "shortPosition" ? r.lossBox.top + r.lossBox.height / 10 : r.lossBox.bottom - r.lossBox.height / 10;
1663
1663
  e.fillText(d.toFixed(1), u, b);
1664
1664
  }
1665
1665
  }, Qt = class {
@@ -1731,8 +1731,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1731
1731
  if (this.selectedShapeId && !this.draft && !this.activeTool && (t.key === "ArrowLeft" || t.key === "ArrowRight" || t.key === "ArrowUp" || t.key === "ArrowDown")) {
1732
1732
  const e = this.shapes.find((i) => i.id === this.selectedShapeId);
1733
1733
  if (e) {
1734
- const i = this.getArrowKeyDelta(t.key), r = this.moveShape(e, i);
1735
- return this.emitShapeModified(r), !0;
1734
+ const i = this.getArrowKeyDelta(t.key), s = this.moveShape(e, i);
1735
+ return this.emitShapeModified(s), !0;
1736
1736
  }
1737
1737
  }
1738
1738
  return !1;
@@ -1764,42 +1764,42 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1764
1764
  vertex: i
1765
1765
  }), !0;
1766
1766
  if (!ct(t)) return !1;
1767
- const r = this.findHandleAtPoint(e);
1768
- if (r) {
1769
- const n = this.shapes.find((o) => o.id === r.shapeId);
1767
+ const s = this.findHandleAtPoint(e);
1768
+ if (s) {
1769
+ const n = this.shapes.find((o) => o.id === s.shapeId);
1770
1770
  return n ? (this.setSelectedShapeId(n.id), this.checkTouchDoubleTap(n, t), this.dragState = {
1771
1771
  edit: {
1772
1772
  mode: "resize",
1773
1773
  shape: n,
1774
- handleType: r.type,
1775
- handleIndex: r.index,
1774
+ handleType: s.type,
1775
+ handleIndex: s.index,
1776
1776
  startPoint: e,
1777
1777
  startVertex: i
1778
1778
  },
1779
1779
  lastModifiedShape: n
1780
- }, this.canvas.style.cursor = r.cursor ?? "grab", !0) : !1;
1780
+ }, this.canvas.style.cursor = s.cursor ?? "grab", !0) : !1;
1781
1781
  }
1782
- const s = this.findShapeAtPoint(e);
1783
- if (s) {
1784
- const n = this.findHandleAtPointForShape(s, e);
1785
- return n ? (this.setSelectedShapeId(s.id), this.checkTouchDoubleTap(s, t), this.dragState = {
1782
+ const r = this.findShapeAtPoint(e);
1783
+ if (r) {
1784
+ const n = this.findHandleAtPointForShape(r, e);
1785
+ return n ? (this.setSelectedShapeId(r.id), this.checkTouchDoubleTap(r, t), this.dragState = {
1786
1786
  edit: {
1787
1787
  mode: "resize",
1788
- shape: s,
1788
+ shape: r,
1789
1789
  handleType: n.type,
1790
1790
  handleIndex: n.index,
1791
1791
  startPoint: e,
1792
1792
  startVertex: i
1793
1793
  },
1794
- lastModifiedShape: s
1795
- }, this.canvas.style.cursor = n.cursor ?? "grab", !0) : (this.setSelectedShapeId(s.id), this.checkTouchDoubleTap(s, t), this.hoveredShapeId = s.id, this.dragState = {
1794
+ lastModifiedShape: r
1795
+ }, this.canvas.style.cursor = n.cursor ?? "grab", !0) : (this.setSelectedShapeId(r.id), this.checkTouchDoubleTap(r, t), this.hoveredShapeId = r.id, this.dragState = {
1796
1796
  edit: {
1797
1797
  mode: "move",
1798
- shape: s,
1798
+ shape: r,
1799
1799
  startPoint: e,
1800
1800
  startVertex: i
1801
1801
  },
1802
- lastModifiedShape: s
1802
+ lastModifiedShape: r
1803
1803
  }, this.canvas.style.cursor = "move", !0);
1804
1804
  }
1805
1805
  return this.setSelectedShapeId(null), this.hoveredShapeId = null, this.canvas.style.cursor = "crosshair", !1;
@@ -1814,11 +1814,11 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1814
1814
  }
1815
1815
  if (this.activeTool)
1816
1816
  return this.canvas.style.cursor = "crosshair", !0;
1817
- const r = this.findHandleAtPoint(e);
1818
- if (r)
1819
- return this.canvas.style.cursor = "pointer", this.hoveredShapeId = r.shapeId, !0;
1820
- const s = this.findShapeAtPoint(e);
1821
- return s ? (this.hoveredShapeId = s.id, this.canvas.style.cursor = "pointer", !0) : this.hoveredShapeId !== null ? (this.hoveredShapeId = null, this.canvas.style.cursor = "crosshair", !0) : !1;
1817
+ const s = this.findHandleAtPoint(e);
1818
+ if (s)
1819
+ return this.canvas.style.cursor = "pointer", this.hoveredShapeId = s.shapeId, !0;
1820
+ const r = this.findShapeAtPoint(e);
1821
+ return r ? (this.hoveredShapeId = r.id, this.canvas.style.cursor = "pointer", !0) : this.hoveredShapeId !== null ? (this.hoveredShapeId = null, this.canvas.style.cursor = "crosshair", !0) : !1;
1822
1822
  }
1823
1823
  handlePointerUp() {
1824
1824
  if (!this.dragState) return !1;
@@ -1899,14 +1899,14 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1899
1899
  }), this.draft = null, this.setActiveToolAndEmit(null));
1900
1900
  }
1901
1901
  addPositionShape(t, e) {
1902
- const i = this.getConverter(), r = t === "longPosition" ? this.config.longPosition : this.config.shortPosition, s = H.createFromVertex({
1902
+ const i = this.getConverter(), s = t === "longPosition" ? this.config.longPosition : this.config.shortPosition, r = H.createFromVertex({
1903
1903
  id: U(),
1904
1904
  type: t,
1905
1905
  entry: e,
1906
1906
  converter: i,
1907
- config: r
1907
+ config: s
1908
1908
  });
1909
- this.addShape(s), this.setActiveToolAndEmit(null);
1909
+ this.addShape(r), this.setActiveToolAndEmit(null);
1910
1910
  }
1911
1911
  updateDraftPreview(t) {
1912
1912
  if (this.draft) {
@@ -1952,15 +1952,15 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1952
1952
  moveShape(t, e) {
1953
1953
  return t.type === "trendline" ? M.move(t, e) : t.type === "rectangle" ? D.move(t, e) : t.type === "path" ? R.move(t, e) : t.type === "fibRetracement" ? L.move(t, e) : H.move(t, e);
1954
1954
  }
1955
- resizeShape(t, e, i, r) {
1956
- return t.type === "trendline" ? M.resize(t, e, i) : t.type === "rectangle" ? D.resize(t, e, i) : t.type === "fibRetracement" ? L.resize(t, e, i) : t.type === "path" ? R.resize(t, r ?? -1, i) : H.resize({
1955
+ resizeShape(t, e, i, s) {
1956
+ return t.type === "trendline" ? M.resize(t, e, i) : t.type === "rectangle" ? D.resize(t, e, i) : t.type === "fibRetracement" ? L.resize(t, e, i) : t.type === "path" ? R.resize(t, s ?? -1, i) : H.resize({
1957
1957
  shape: t,
1958
1958
  handleType: e,
1959
1959
  vertex: i,
1960
1960
  converter: this.getConverter()
1961
1961
  });
1962
1962
  }
1963
- drawShape({ shape: t, converter: e, selected: i, hovered: r }) {
1963
+ drawShape({ shape: t, converter: e, selected: i, hovered: s }) {
1964
1964
  if (t.type === "trendline") {
1965
1965
  const n = this.getTrendlineConfig(t);
1966
1966
  M.draw({
@@ -1969,7 +1969,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1969
1969
  converter: e,
1970
1970
  config: n,
1971
1971
  selected: i,
1972
- hovered: r
1972
+ hovered: s
1973
1973
  });
1974
1974
  return;
1975
1975
  }
@@ -1981,7 +1981,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1981
1981
  converter: e,
1982
1982
  config: n,
1983
1983
  selected: i,
1984
- hovered: r
1984
+ hovered: s
1985
1985
  });
1986
1986
  return;
1987
1987
  }
@@ -1993,7 +1993,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1993
1993
  converter: e,
1994
1994
  config: n,
1995
1995
  selected: i,
1996
- hovered: r
1996
+ hovered: s
1997
1997
  });
1998
1998
  return;
1999
1999
  }
@@ -2005,19 +2005,19 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2005
2005
  converter: e,
2006
2006
  config: n,
2007
2007
  selected: i,
2008
- hovered: r
2008
+ hovered: s
2009
2009
  });
2010
2010
  return;
2011
2011
  }
2012
- const s = this.getPositionConfig(t);
2012
+ const r = this.getPositionConfig(t);
2013
2013
  H.draw({
2014
2014
  ctx: this.ctx,
2015
2015
  activeSymbol: this.activeSymbol,
2016
2016
  shape: t,
2017
2017
  converter: e,
2018
- config: s,
2018
+ config: r,
2019
2019
  selected: i,
2020
- hovered: r
2020
+ hovered: s
2021
2021
  });
2022
2022
  }
2023
2023
  drawDraft(t) {
@@ -2063,8 +2063,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2063
2063
  this.handleHitboxes = [];
2064
2064
  return;
2065
2065
  }
2066
- const t = this.getConverter(), e = [], i = this.shapes.find((s) => s.id === this.selectedShapeId), r = this.hoveredShapeId && this.hoveredShapeId !== this.selectedShapeId ? this.shapes.find((s) => s.id === this.hoveredShapeId) ?? null : null;
2067
- i && e.push(i), r && e.push(r), this.handleHitboxes = e.flatMap((s) => this.getShapeHandles(s, t));
2066
+ const t = this.getConverter(), e = [], i = this.shapes.find((r) => r.id === this.selectedShapeId), s = this.hoveredShapeId && this.hoveredShapeId !== this.selectedShapeId ? this.shapes.find((r) => r.id === this.hoveredShapeId) ?? null : null;
2067
+ i && e.push(i), s && e.push(s), this.handleHitboxes = e.flatMap((r) => this.getShapeHandles(r, t));
2068
2068
  }
2069
2069
  getShapeHandles(t, e) {
2070
2070
  return t.type === "trendline" ? M.getHandles(t, e) : t.type === "rectangle" ? D.getHandles(t, e) : t.type === "path" ? R.getHandles(t, e) : t.type === "fibRetracement" ? L.getHandles(t, e) : H.getHandles(t, e);
@@ -2077,15 +2077,15 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2077
2077
  return null;
2078
2078
  }
2079
2079
  findHandleAtPointForShape(t, e) {
2080
- const i = this.getConverter(), r = this.getShapeHandles(t, i);
2081
- for (const s of r) if (j(e, s)) return s;
2080
+ const i = this.getConverter(), s = this.getShapeHandles(t, i);
2081
+ for (const r of s) if (j(e, r)) return r;
2082
2082
  return null;
2083
2083
  }
2084
2084
  findShapeAtPoint(t) {
2085
2085
  const e = this.getConverter();
2086
2086
  for (let i = this.shapes.length - 1; i >= 0; i -= 1) {
2087
- const r = this.shapes[i];
2088
- if (this.isShapeHit(r, t, e)) return r;
2087
+ const s = this.shapes[i];
2088
+ if (this.isShapeHit(s, t, e)) return s;
2089
2089
  }
2090
2090
  return null;
2091
2091
  }
@@ -2195,8 +2195,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2195
2195
  getNearestCandleTimeForX: (e) => {
2196
2196
  const i = this.getTimeForX(e);
2197
2197
  if (this.candles.length > 0 && i > this.candles[this.candles.length - 1].time) return i;
2198
- const r = Z(this.candles, i);
2199
- return r >= 0 ? this.candles[r].time : i;
2198
+ const s = Z(this.candles, i);
2199
+ return s >= 0 ? this.candles[s].time : i;
2200
2200
  },
2201
2201
  getCandleWidth: () => t ? this.getCandleStepWidth(t) : 12
2202
2202
  };
@@ -2312,51 +2312,51 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2312
2312
  for (const t of this.trades) this.drawTrade({ trade: t });
2313
2313
  this.drawTemporaryProtectionDrag();
2314
2314
  }
2315
- createHitBox = ({ price: t, trade: e, type: i, x: r, y: s, width: n, height: o, viewport: a }) => {
2316
- const { showCloseSection: l, widthClose: d } = this.getHandleStyleConfig(i).handle, u = l ? d : 0, g = n - u, m = r + n - u;
2315
+ createHitBox = ({ price: t, trade: e, type: i, x: s, y: r, width: n, height: o, viewport: a }) => {
2316
+ const { showCloseSection: l, widthClose: d } = this.getHandleStyleConfig(i).handle, u = l ? d : 0, g = n - u, m = s + n - u;
2317
2317
  return {
2318
2318
  kind: "existingHandle",
2319
2319
  price: p(t),
2320
2320
  trade: e,
2321
2321
  type: i,
2322
- x: r,
2323
- y: s,
2322
+ x: s,
2323
+ y: r,
2324
2324
  width: n,
2325
2325
  height: o,
2326
2326
  viewport: a,
2327
2327
  labelArea: {
2328
- x: r,
2329
- y: s,
2328
+ x: s,
2329
+ y: r,
2330
2330
  width: g,
2331
2331
  height: o
2332
2332
  },
2333
2333
  closeButtonArea: {
2334
2334
  x: m,
2335
- y: s,
2335
+ y: r,
2336
2336
  width: u,
2337
2337
  height: o
2338
2338
  }
2339
2339
  };
2340
2340
  };
2341
- createMissingProtectionHitBox = ({ price: t, trade: e, type: i, x: r, y: s, width: n, height: o, viewport: a }) => ({
2341
+ createMissingProtectionHitBox = ({ price: t, trade: e, type: i, x: s, y: r, width: n, height: o, viewport: a }) => ({
2342
2342
  kind: "missingProtectionHandle",
2343
2343
  price: p(t),
2344
2344
  trade: e,
2345
2345
  type: i,
2346
- x: r,
2347
- y: s,
2346
+ x: s,
2347
+ y: r,
2348
2348
  width: n,
2349
2349
  height: o,
2350
2350
  viewport: a,
2351
2351
  labelArea: {
2352
- x: r,
2353
- y: s,
2352
+ x: s,
2353
+ y: r,
2354
2354
  width: n,
2355
2355
  height: o
2356
2356
  },
2357
2357
  closeButtonArea: {
2358
- x: r + n,
2359
- y: s,
2358
+ x: s + n,
2359
+ y: r,
2360
2360
  width: 0,
2361
2361
  height: o
2362
2362
  }
@@ -2384,21 +2384,21 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2384
2384
  type: "takeProfit",
2385
2385
  trade: t
2386
2386
  });
2387
- for (const r of i)
2388
- this.addMissingProtectionHitbox(r), this.drawMissingProtectionHandleRect({
2389
- x: r.handleX,
2390
- y: r.handleY,
2391
- width: r.handleWidth,
2392
- config: r.config
2393
- }), this.drawMissingProtectionHandleLabel(r);
2387
+ for (const s of i)
2388
+ this.addMissingProtectionHitbox(s), this.drawMissingProtectionHandleRect({
2389
+ x: s.handleX,
2390
+ y: s.handleY,
2391
+ width: s.handleWidth,
2392
+ config: s.config
2393
+ }), this.drawMissingProtectionHandleLabel(s);
2394
2394
  }
2395
2395
  drawTradeHandle({ price: t, type: e, trade: i }) {
2396
- const r = this.getTradeHandleRenderState({
2396
+ const s = this.getTradeHandleRenderState({
2397
2397
  price: t,
2398
2398
  type: e,
2399
2399
  trade: i
2400
2400
  });
2401
- return r ? (this.drawTradeHandleFromRenderState({ renderState: r }), r) : null;
2401
+ return s ? (this.drawTradeHandleFromRenderState({ renderState: s }), s) : null;
2402
2402
  }
2403
2403
  drawTradeHandleFromRenderState({ renderState: t, blockedRanges: e = [] }) {
2404
2404
  this.addHandleHitbox(t), this.drawHandleHorizontalLines({
@@ -2420,26 +2420,26 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2420
2420
  y: t.y
2421
2421
  });
2422
2422
  }
2423
- drawHandleLine({ x1: t, x2: e, y: i, config: r }) {
2423
+ drawHandleLine({ x1: t, x2: e, y: i, config: s }) {
2424
2424
  if (e <= t) return;
2425
- const s = this.#e;
2426
- s.save(), s.globalAlpha = r.opacity, s.strokeStyle = r.color, s.lineWidth = r.width, s.setLineDash(this.getHandleLineDash(r)), s.beginPath(), s.moveTo(t, i), s.lineTo(e, i), s.stroke(), s.restore();
2425
+ const r = this.#e;
2426
+ r.save(), r.globalAlpha = s.opacity, r.strokeStyle = s.color, r.lineWidth = s.width, r.setLineDash(this.getHandleLineDash(s)), r.beginPath(), r.moveTo(t, i), r.lineTo(e, i), r.stroke(), r.restore();
2427
2427
  }
2428
- drawConnectorLine({ x1: t, y1: e, x2: i, y2: r, config: s }) {
2428
+ drawConnectorLine({ x1: t, y1: e, x2: i, y2: s, config: r }) {
2429
2429
  const n = this.#e;
2430
- n.save(), n.globalAlpha = s.opacity, n.strokeStyle = s.color, n.lineWidth = s.width, n.setLineDash(this.getHandleLineDash(s)), n.beginPath(), n.moveTo(t, e), n.lineTo(i, r), n.stroke(), n.restore();
2430
+ n.save(), n.globalAlpha = r.opacity, n.strokeStyle = r.color, n.lineWidth = r.width, n.setLineDash(this.getHandleLineDash(r)), n.beginPath(), n.moveTo(t, e), n.lineTo(i, s), n.stroke(), n.restore();
2431
2431
  }
2432
- drawHandleRect({ x: t, y: e, width: i, config: r }) {
2433
- const s = this.#e;
2432
+ drawHandleRect({ x: t, y: e, width: i, config: s }) {
2433
+ const r = this.#e;
2434
2434
  this.clearRectArea({
2435
2435
  x: t,
2436
2436
  y: e,
2437
2437
  width: i,
2438
- height: r.height,
2439
- padding: Math.max(1, r.borderWidth)
2440
- }), 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();
2438
+ height: s.height,
2439
+ padding: Math.max(1, s.borderWidth)
2440
+ }), r.save(), r.globalAlpha = s.backgroundOpacity, r.fillStyle = s.backgroundColor, r.fillRect(t, e, i, s.height), r.globalAlpha = s.borderOpacity, r.strokeStyle = s.borderColor, r.lineWidth = s.borderWidth, r.strokeRect(t, e, i, s.height), r.restore();
2441
2441
  }
2442
- drawHandleSections({ handleType: t, handleX: e, handleY: i, handleWidth: r, handleHeight: s, handleConfig: n, trade: o, y: a }) {
2442
+ drawHandleSections({ handleType: t, handleX: e, handleY: i, handleWidth: s, handleHeight: r, handleConfig: n, trade: o, y: a }) {
2443
2443
  const l = this.#e, d = c.tradeHandles, u = this.getHandleSections({
2444
2444
  handleType: t,
2445
2445
  handleConfig: n,
@@ -2452,10 +2452,10 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2452
2452
  section: m,
2453
2453
  currentX: g,
2454
2454
  y: a
2455
- }), g += m.width, g < e + r && this.drawHandleSectionDivider({
2455
+ }), g += m.width, g < e + s && this.drawHandleSectionDivider({
2456
2456
  x: g,
2457
2457
  y1: i + 4,
2458
- y2: i + s - 4,
2458
+ y2: i + r - 4,
2459
2459
  config: n
2460
2460
  }));
2461
2461
  l.restore();
@@ -2464,8 +2464,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2464
2464
  if (t === "startPrice") return this.formatPnlLabel(e.pnl);
2465
2465
  const i = t === "stopLoss" ? e.sl : e.tp;
2466
2466
  if (!i) return "N/A";
2467
- const r = ut(e.type, e.openPrice, i, e.volume, e.symbol);
2468
- return this.formatPnlLabel(r);
2467
+ const s = ut(e.type, e.openPrice, i, e.volume, e.symbol);
2468
+ return this.formatPnlLabel(s);
2469
2469
  }
2470
2470
  getHandleWidth(t) {
2471
2471
  let e = 0;
@@ -2494,8 +2494,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2494
2494
  }
2495
2495
  }
2496
2496
  getProtectionDirection({ trade: t, type: e }) {
2497
- const i = this.isBuyTrade(t), r = e === "takeProfit" ? 1 : -1;
2498
- return i ? r : -r;
2497
+ const i = this.isBuyTrade(t), s = e === "takeProfit" ? 1 : -1;
2498
+ return i ? s : -s;
2499
2499
  }
2500
2500
  constrainProtectionPrice({ price: t, trade: e, type: i }) {
2501
2501
  return this.getProtectionDirection({
@@ -2520,18 +2520,18 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2520
2520
  if (!this.viewport) return null;
2521
2521
  const e = this.getTimeX(t.openTime), i = this.getTimeX(t.closeTime);
2522
2522
  if (e === null || i === null) return null;
2523
- 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;
2523
+ const s = this.getPriceY(t.openPrice, this.viewport), r = this.getPriceY(t.closePrice, this.viewport), n = c.closedTradeIndicators.arrow, o = n.width, a = n.height;
2524
2524
  return {
2525
2525
  trade: t,
2526
2526
  start: {
2527
2527
  x: e,
2528
- y: r,
2528
+ y: s,
2529
2529
  time: t.openTime,
2530
2530
  price: t.openPrice
2531
2531
  },
2532
2532
  close: {
2533
2533
  x: i,
2534
- y: s,
2534
+ y: r,
2535
2535
  time: t.closeTime,
2536
2536
  price: t.closePrice
2537
2537
  },
@@ -2549,7 +2549,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2549
2549
  config: i
2550
2550
  });
2551
2551
  }
2552
- drawClosedTradeArrows({ trade: t, start: e, close: i, arrowWidth: r, arrowHeight: s }) {
2552
+ drawClosedTradeArrows({ trade: t, start: e, close: i, arrowWidth: s, arrowHeight: r }) {
2553
2553
  const n = c.closedTradeIndicators.arrow;
2554
2554
  if (!n.visible) return;
2555
2555
  const o = t.type === "buy" ? "sell" : "buy";
@@ -2557,39 +2557,39 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2557
2557
  x: e.x,
2558
2558
  y: e.y,
2559
2559
  type: t.type,
2560
- width: r,
2561
- height: s,
2560
+ width: s,
2561
+ height: r,
2562
2562
  config: n
2563
2563
  }), this.drawClosedTradeArrow({
2564
2564
  x: i.x,
2565
2565
  y: i.y,
2566
2566
  type: o,
2567
- width: r,
2568
- height: s,
2567
+ width: s,
2568
+ height: r,
2569
2569
  config: n
2570
2570
  });
2571
2571
  }
2572
- drawClosedTradeArrow({ x: t, y: e, type: i, width: r, height: s, config: n }) {
2573
- if (r <= 0 || s <= 0) return;
2574
- 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, b = t, v = e + u * s, S = s / 2, T = S / Math.SQRT2, k = S / Math.SQRT2, Ht = g - T, kt = g + T, tt = m + u * k, et = Math.max(1, n.shaftWidthRatio), Mt = et + n.borderWidth * 2, it = () => {
2572
+ drawClosedTradeArrow({ x: t, y: e, type: i, width: s, height: r, config: n }) {
2573
+ if (s <= 0 || r <= 0) return;
2574
+ 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, b = t, v = e + u * r, S = r / 2, T = S / Math.SQRT2, k = S / Math.SQRT2, Ht = g - T, kt = g + T, tt = m + u * k, et = Math.max(1, n.shaftWidthRatio), Mt = et + n.borderWidth * 2, it = () => {
2575
2575
  o.beginPath(), o.moveTo(b, v), o.lineTo(g, m), o.moveTo(g, m), o.lineTo(Ht, tt), o.moveTo(g, m), o.lineTo(kt, tt), o.stroke();
2576
2576
  };
2577
2577
  o.save(), o.globalAlpha = n.opacity, o.lineCap = "round", o.lineJoin = "round", o.strokeStyle = d, o.lineWidth = Mt, it(), o.strokeStyle = l, o.lineWidth = et, it(), o.restore();
2578
2578
  }
2579
2579
  getTimeX(t) {
2580
2580
  if (!this.viewport || this.candles.length === 0 || !Number.isFinite(t)) return null;
2581
- const e = this.normalizeTimestamp(t), i = this.candles[0], r = this.candles[this.candles.length - 1];
2582
- if (!i || !r) return null;
2581
+ const e = this.normalizeTimestamp(t), i = this.candles[0], s = this.candles[this.candles.length - 1];
2582
+ if (!i || !s) return null;
2583
2583
  if (this.candles.length === 1) return this.getCandleCenterX(0);
2584
2584
  if (e <= i.time) {
2585
2585
  const d = this.getCandleTimeInterval(0), u = (i.time - e) / d;
2586
2586
  return this.getCandleCenterX(0) - u * this.viewport.candleSpacing;
2587
2587
  }
2588
- if (e >= r.time) {
2589
- const d = this.candles.length - 1, u = this.getCandleTimeInterval(d), g = (e - r.time) / u;
2588
+ if (e >= s.time) {
2589
+ const d = this.candles.length - 1, u = this.getCandleTimeInterval(d), g = (e - s.time) / u;
2590
2590
  return this.getCandleCenterX(d) + g * this.viewport.candleSpacing;
2591
2591
  }
2592
- const s = this.getFirstCandleIndexAtOrAfterTime(e), n = Math.max(0, s - 1), o = this.candles[n], a = this.candles[s];
2592
+ const r = this.getFirstCandleIndexAtOrAfterTime(e), n = Math.max(0, r - 1), o = this.candles[n], a = this.candles[r];
2593
2593
  if (!o || !a || a.time === o.time) return this.getCandleCenterX(n);
2594
2594
  const l = (e - o.time) / (a.time - o.time);
2595
2595
  return this.getCandleCenterX(n) + l * this.viewport.candleSpacing;
@@ -2600,8 +2600,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2600
2600
  getFirstCandleIndexAtOrAfterTime(t) {
2601
2601
  let e = 0, i = this.candles.length - 1;
2602
2602
  for (; e < i; ) {
2603
- const r = Math.floor((e + i) / 2);
2604
- this.candles[r].time < t ? e = r + 1 : i = r;
2603
+ const s = Math.floor((e + i) / 2);
2604
+ this.candles[s].time < t ? e = s + 1 : i = s;
2605
2605
  }
2606
2606
  return e;
2607
2607
  }
@@ -2609,18 +2609,18 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2609
2609
  return this.viewport ? t * this.viewport.candleSpacing + this.viewport.offsetX + this.viewport.candleWidth / 2 : 0;
2610
2610
  }
2611
2611
  getCandleTimeInterval(t) {
2612
- const e = this.candles[t], i = this.candles[t - 1], r = this.candles[t + 1];
2613
- return e && r && r.time > e.time ? r.time - e.time : e && i && e.time > i.time ? e.time - i.time : 60 * 1e3;
2612
+ const e = this.candles[t], i = this.candles[t - 1], s = this.candles[t + 1];
2613
+ return e && s && s.time > e.time ? s.time - e.time : e && i && e.time > i.time ? e.time - i.time : 60 * 1e3;
2614
2614
  }
2615
2615
  getTradeHandleRenderState({ price: t, type: e, trade: i }) {
2616
2616
  if (!this.viewport) return null;
2617
- 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;
2617
+ const s = this.viewport, r = this.getPriceY(t, s), n = this.getHandleStyleConfig(e), o = n.handle, a = n.handleLine, l = this.getHandleWidth(o), d = o.height;
2618
2618
  return {
2619
2619
  price: t,
2620
2620
  type: e,
2621
2621
  trade: i,
2622
- viewport: r,
2623
- y: s,
2622
+ viewport: s,
2623
+ y: r,
2624
2624
  handleStyleConfig: n,
2625
2625
  handleConfig: o,
2626
2626
  lineConfig: a,
@@ -2628,7 +2628,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2628
2628
  handleWidth: l,
2629
2629
  config: o
2630
2630
  }),
2631
- handleY: s - d / 2,
2631
+ handleY: r - d / 2,
2632
2632
  handleWidth: l,
2633
2633
  handleHeight: d
2634
2634
  };
@@ -2665,20 +2665,20 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2665
2665
  viewport: t.viewport
2666
2666
  }));
2667
2667
  }
2668
- drawHandleHorizontalLines({ handleX: t, handleWidth: e, y: i, lineConfig: r, blockedRanges: s = [] }) {
2668
+ drawHandleHorizontalLines({ handleX: t, handleWidth: e, y: i, lineConfig: s, blockedRanges: r = [] }) {
2669
2669
  this.drawHorizontalLineAroundBlockedRanges({
2670
2670
  y: i,
2671
- config: r,
2671
+ config: s,
2672
2672
  blockedRanges: [{
2673
2673
  x1: t,
2674
2674
  x2: t + e
2675
- }, ...s]
2675
+ }, ...r]
2676
2676
  });
2677
2677
  }
2678
- drawTemporaryProtectionHorizontalLines({ handleX: t, handleWidth: e, y: i, lineConfig: r }) {
2678
+ drawTemporaryProtectionHorizontalLines({ handleX: t, handleWidth: e, y: i, lineConfig: s }) {
2679
2679
  this.drawHorizontalLineAroundBlockedRanges({
2680
2680
  y: i,
2681
- config: r,
2681
+ config: s,
2682
2682
  blockedRanges: [{
2683
2683
  x1: t,
2684
2684
  x2: t + e
@@ -2686,34 +2686,34 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2686
2686
  });
2687
2687
  }
2688
2688
  drawHorizontalLineAroundBlockedRanges({ y: t, config: e, blockedRanges: i }) {
2689
- const r = this.getMergedBlockedRanges(i);
2690
- let s = 0;
2691
- for (const n of r)
2692
- n.x1 > s && this.drawHandleLine({
2693
- x1: s,
2689
+ const s = this.getMergedBlockedRanges(i);
2690
+ let r = 0;
2691
+ for (const n of s)
2692
+ n.x1 > r && this.drawHandleLine({
2693
+ x1: r,
2694
2694
  x2: n.x1,
2695
2695
  y: t,
2696
2696
  config: e
2697
- }), s = Math.max(s, n.x2);
2698
- s < this.#t.width && this.drawHandleLine({
2699
- x1: s,
2697
+ }), r = Math.max(r, n.x2);
2698
+ r < this.#t.width && this.drawHandleLine({
2699
+ x1: r,
2700
2700
  x2: this.#t.width,
2701
2701
  y: t,
2702
2702
  config: e
2703
2703
  });
2704
2704
  }
2705
2705
  getMergedBlockedRanges(t) {
2706
- const e = t.map((r) => ({
2707
- x1: Math.max(0, Math.min(r.x1, this.#t.width)),
2708
- x2: Math.max(0, Math.min(r.x2, this.#t.width))
2709
- })).filter((r) => r.x2 > r.x1).sort((r, s) => r.x1 - s.x1), i = [];
2710
- for (const r of e) {
2711
- const s = i.at(-1);
2712
- if (!s || r.x1 > s.x2) {
2713
- i.push({ ...r });
2706
+ const e = t.map((s) => ({
2707
+ x1: Math.max(0, Math.min(s.x1, this.#t.width)),
2708
+ x2: Math.max(0, Math.min(s.x2, this.#t.width))
2709
+ })).filter((s) => s.x2 > s.x1).sort((s, r) => s.x1 - r.x1), i = [];
2710
+ for (const s of e) {
2711
+ const r = i.at(-1);
2712
+ if (!r || s.x1 > r.x2) {
2713
+ i.push({ ...s });
2714
2714
  continue;
2715
2715
  }
2716
- s.x2 = Math.max(s.x2, r.x2);
2716
+ r.x2 = Math.max(r.x2, s.x2);
2717
2717
  }
2718
2718
  return i;
2719
2719
  }
@@ -2728,7 +2728,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2728
2728
  }
2729
2729
  }
2730
2730
  getHandleSections({ handleType: t, handleConfig: e, trade: i }) {
2731
- const r = this.getHandlePnLLabel({
2731
+ const s = this.getHandlePnLLabel({
2732
2732
  handleType: t,
2733
2733
  trade: i
2734
2734
  });
@@ -2739,7 +2739,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2739
2739
  visible: e.showVolumeSection
2740
2740
  },
2741
2741
  {
2742
- label: r,
2742
+ label: s,
2743
2743
  width: e.widthPNL,
2744
2744
  visible: e.showPnlSection,
2745
2745
  color: this.getHandlePnlTextColor({
@@ -2756,18 +2756,18 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2756
2756
  ];
2757
2757
  }
2758
2758
  drawHandleSectionLabel({ section: t, currentX: e, y: i }) {
2759
- const r = this.#e, s = c.tradeHandles, n = e + t.width / 2;
2760
- r.fillStyle = t.color ?? s.textColor, r.fillText(t.label, n - r.measureText(t.label).width / 2, i);
2759
+ const s = this.#e, r = c.tradeHandles, n = e + t.width / 2;
2760
+ s.fillStyle = t.color ?? r.textColor, s.fillText(t.label, n - s.measureText(t.label).width / 2, i);
2761
2761
  }
2762
- drawHandleSectionDivider({ x: t, y1: e, y2: i, config: r }) {
2763
- const s = this.#e;
2764
- s.strokeStyle = r.sectionDividerColor, s.lineWidth = 1, s.beginPath(), s.moveTo(t, e), s.lineTo(t, i), s.stroke();
2762
+ drawHandleSectionDivider({ x: t, y1: e, y2: i, config: s }) {
2763
+ const r = this.#e;
2764
+ r.strokeStyle = s.sectionDividerColor, r.lineWidth = 1, r.beginPath(), r.moveTo(t, e), r.lineTo(t, i), r.stroke();
2765
2765
  }
2766
2766
  getMissingProtectionRenderStates({ trade: t, startPriceRenderState: e }) {
2767
2767
  if (!c.tradeHandles.missingProtectionHandles.visible) return [];
2768
2768
  const i = this.getMissingProtectionHandleTypes(t);
2769
- return i.map((r) => this.getMissingProtectionHandleRenderState({
2770
- type: r,
2769
+ return i.map((s) => this.getMissingProtectionHandleRenderState({
2770
+ type: s,
2771
2771
  trade: t,
2772
2772
  startPriceRenderState: e,
2773
2773
  visibleTypes: i
@@ -2777,12 +2777,12 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2777
2777
  const e = [];
2778
2778
  return t.sl || e.push("stopLoss"), t.tp || e.push("takeProfit"), e;
2779
2779
  }
2780
- getMissingProtectionHandleRenderState({ type: t, trade: e, startPriceRenderState: i, visibleTypes: r }) {
2781
- const s = this.getMissingProtectionHandleConfig(t), n = s.width, o = s.height, a = this.getMissingProtectionHandleX({
2780
+ getMissingProtectionHandleRenderState({ type: t, trade: e, startPriceRenderState: i, visibleTypes: s }) {
2781
+ const r = this.getMissingProtectionHandleConfig(t), n = r.width, o = r.height, a = this.getMissingProtectionHandleX({
2782
2782
  type: t,
2783
- config: s,
2783
+ config: r,
2784
2784
  startPriceRenderState: i,
2785
- visibleTypes: r
2785
+ visibleTypes: s
2786
2786
  }), l = i.y - o / 2;
2787
2787
  return {
2788
2788
  price: e.openPrice,
@@ -2790,15 +2790,15 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2790
2790
  trade: e,
2791
2791
  viewport: i.viewport,
2792
2792
  y: i.y,
2793
- config: s,
2793
+ config: r,
2794
2794
  handleX: a,
2795
2795
  handleY: l,
2796
2796
  handleWidth: n,
2797
2797
  handleHeight: o
2798
2798
  };
2799
2799
  }
2800
- getMissingProtectionHandleX({ type: t, config: e, startPriceRenderState: i, visibleTypes: r }) {
2801
- const s = r.indexOf(t), n = e.gapFromStartPriceHandle + s * (e.width + e.gapBetweenHandles);
2800
+ getMissingProtectionHandleX({ type: t, config: e, startPriceRenderState: i, visibleTypes: s }) {
2801
+ const r = s.indexOf(t), n = e.gapFromStartPriceHandle + r * (e.width + e.gapBetweenHandles);
2802
2802
  return e.placement === "left" ? i.handleX - n - e.width : i.handleX + i.handleWidth + n;
2803
2803
  }
2804
2804
  getLineBlockedRangesFromMissingProtectionHandles(t) {
@@ -2811,19 +2811,19 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2811
2811
  const e = c.tradeHandles.missingProtectionHandles;
2812
2812
  return t === "stopLoss" ? e.slHandle : e.tpHandle;
2813
2813
  }
2814
- drawMissingProtectionHandleRect({ x: t, y: e, width: i, config: r }) {
2815
- const s = this.#e;
2814
+ drawMissingProtectionHandleRect({ x: t, y: e, width: i, config: s }) {
2815
+ const r = this.#e;
2816
2816
  this.clearRectArea({
2817
2817
  x: t,
2818
2818
  y: e,
2819
2819
  width: i,
2820
- height: r.height,
2821
- padding: Math.max(1, r.borderWidth)
2822
- }), 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();
2820
+ height: s.height,
2821
+ padding: Math.max(1, s.borderWidth)
2822
+ }), r.save(), r.globalAlpha = s.backgroundOpacity, r.fillStyle = s.backgroundColor, r.fillRect(t, e, i, s.height), r.globalAlpha = s.borderOpacity, r.strokeStyle = s.borderColor, r.lineWidth = s.borderWidth, r.strokeRect(t, e, i, s.height), r.restore();
2823
2823
  }
2824
- drawMissingProtectionHandleLabel({ type: t, handleX: e, y: i, handleWidth: r, config: s }) {
2825
- const n = this.#e, o = t === "stopLoss" ? "SL" : "TP", a = e + r / 2;
2826
- 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();
2824
+ drawMissingProtectionHandleLabel({ type: t, handleX: e, y: i, handleWidth: s, config: r }) {
2825
+ const n = this.#e, o = t === "stopLoss" ? "SL" : "TP", a = e + s / 2;
2826
+ n.save(), n.font = r.font, n.textBaseline = "middle", n.globalAlpha = r.textOpacity, n.fillStyle = r.textColor, n.fillText(o, a - n.measureText(o).width / 2, i), n.restore();
2827
2827
  }
2828
2828
  drawTemporaryProtectionDrag() {
2829
2829
  const t = this.getTemporaryProtectionRenderState();
@@ -2836,20 +2836,20 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2836
2836
  }
2837
2837
  getTemporaryProtectionRenderState() {
2838
2838
  if (!this.temporaryProtectionDrag) return null;
2839
- 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;
2839
+ const { trade: t, type: e, viewport: i } = this.temporaryProtectionDrag, s = p(this.temporaryProtectionDrag.price), r = this.getPriceY(s, i), n = this.getTemporaryProtectionHandleConfig(e), o = this.getTemporaryProtectionLineConfig(e), a = n.widthPNL, l = n.height;
2840
2840
  return {
2841
- price: r,
2841
+ price: s,
2842
2842
  type: e,
2843
2843
  trade: t,
2844
2844
  viewport: i,
2845
- y: s,
2845
+ y: r,
2846
2846
  handleConfig: n,
2847
2847
  lineConfig: o,
2848
2848
  handleX: this.getTemporaryProtectionHandleX({
2849
2849
  handleWidth: a,
2850
2850
  config: n
2851
2851
  }),
2852
- handleY: s - l / 2,
2852
+ handleY: r - l / 2,
2853
2853
  handleWidth: a,
2854
2854
  handleHeight: l
2855
2855
  };
@@ -2862,22 +2862,22 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2862
2862
  const e = c.tradeHandles.missingProtectionHandles;
2863
2863
  return t === "stopLoss" ? e.temporarySlLine : e.temporaryTpLine;
2864
2864
  }
2865
- drawTemporaryProtectionHandleRect({ x: t, y: e, width: i, config: r }) {
2866
- const s = this.#e;
2865
+ drawTemporaryProtectionHandleRect({ x: t, y: e, width: i, config: s }) {
2866
+ const r = this.#e;
2867
2867
  this.clearRectArea({
2868
2868
  x: t,
2869
2869
  y: e,
2870
2870
  width: i,
2871
- height: r.height,
2872
- padding: Math.max(1, r.borderWidth)
2873
- }), 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();
2871
+ height: s.height,
2872
+ padding: Math.max(1, s.borderWidth)
2873
+ }), r.save(), r.globalAlpha = s.backgroundOpacity, r.fillStyle = s.backgroundColor, r.fillRect(t, e, i, s.height), r.globalAlpha = s.borderOpacity, r.strokeStyle = s.borderColor, r.lineWidth = s.borderWidth, r.strokeRect(t, e, i, s.height), r.restore();
2874
2874
  }
2875
- drawTemporaryProtectionPnLLabel({ trade: t, type: e, price: i, handleX: r, y: s, handleWidth: n, handleConfig: o }) {
2876
- const a = this.#e, l = ut(t.type, t.openPrice, i, t.volume, t.symbol), d = this.formatPnlLabel(l), u = r + n / 2;
2877
- 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();
2875
+ drawTemporaryProtectionPnLLabel({ trade: t, type: e, price: i, handleX: s, y: r, handleWidth: n, handleConfig: o }) {
2876
+ const a = this.#e, l = ut(t.type, t.openPrice, i, t.volume, t.symbol), d = this.formatPnlLabel(l), u = s + n / 2;
2877
+ 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, r), a.restore();
2878
2878
  }
2879
- clearRectArea({ x: t, y: e, width: i, height: r, padding: s = 0 }) {
2880
- this.#e.clearRect(t - s, e - s, i + s * 2, r + s * 2);
2879
+ clearRectArea({ x: t, y: e, width: i, height: s, padding: r = 0 }) {
2880
+ this.#e.clearRect(t - r, e - r, i + r * 2, s + r * 2);
2881
2881
  }
2882
2882
  getPositionedHandleX({ handleWidth: t, position: e }) {
2883
2883
  const i = this.#t.width;
@@ -2910,22 +2910,22 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2910
2910
  #t;
2911
2911
  #e;
2912
2912
  #r;
2913
- #s;
2914
- #c;
2915
2913
  #i;
2916
- #l;
2917
2914
  #u;
2915
+ #s;
2916
+ #l;
2917
+ #g;
2918
2918
  #n;
2919
2919
  #a = null;
2920
2920
  #o = null;
2921
2921
  #d = !1;
2922
2922
  #h = 0;
2923
- #f = 0;
2923
+ #m = 0;
2924
2924
  constructor(t) {
2925
- 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;
2925
+ this.#t = t.canvas, this.#e = t.getHandleHitboxes, this.#r = t.getCurrentPrice, this.#i = t.onDrag, this.#u = t.onMissingProtectionDrag, this.#s = t.onMissingProtectionDragEnd, this.#l = t.onMissingProtectionDragCancel, this.#g = t.onTradeModified, this.#n = t.onTradeCloseClicked;
2926
2926
  }
2927
2927
  cancelActiveInteraction() {
2928
- this.#o && this.#l?.(), this.#a = null, this.#o = null, this.#d = !1, this.#h = 0, this.#f = 0;
2928
+ this.#o && this.#l?.(), this.#a = null, this.#o = null, this.#d = !1, this.#h = 0, this.#m = 0;
2929
2929
  }
2930
2930
  handlePointerEvent(t) {
2931
2931
  if (!this.isSupportedEventType(t.type)) return !1;
@@ -2941,16 +2941,16 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2941
2941
  return ee.includes(t);
2942
2942
  }
2943
2943
  getCanvasMousePoint(t) {
2944
- const e = this.#t.getBoundingClientRect(), i = this.#t.width / e.width, r = this.#t.height / e.height;
2944
+ const e = this.#t.getBoundingClientRect(), i = this.#t.width / e.width, s = this.#t.height / e.height;
2945
2945
  return {
2946
2946
  x: (t.clientX - e.left) * i,
2947
- y: (t.clientY - e.top) * r
2947
+ y: (t.clientY - e.top) * s
2948
2948
  };
2949
2949
  }
2950
2950
  handleActiveDrag(t, e) {
2951
2951
  if (!this.#a) return !1;
2952
2952
  const i = this.getNextDragPrice(e.y);
2953
- return this.#a.price = i, this.#s?.({
2953
+ return this.#a.price = i, this.#i?.({
2954
2954
  trade: this.#a.trade,
2955
2955
  type: this.#a.type,
2956
2956
  price: i
@@ -2958,25 +2958,25 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2958
2958
  }
2959
2959
  handleActiveMissingProtectionDrag(t, e) {
2960
2960
  if (!this.#o || !this.isProtectionHandleType(this.#o.type)) return !1;
2961
- const i = e.y - this.#h, r = c.tradeHandles.missingProtectionHandles.dragActivationThresholdPx;
2962
- if (!this.#d && Math.abs(i) < r)
2961
+ const i = e.y - this.#h, s = c.tradeHandles.missingProtectionHandles.dragActivationThresholdPx;
2962
+ if (!this.#d && Math.abs(i) < s)
2963
2963
  return this.consumeEvent(t), !0;
2964
2964
  this.#d = !0;
2965
- const s = this.getNextMissingProtectionPrice(e.y);
2966
- return this.#o.price = s, this.#c?.({
2965
+ const r = this.getNextMissingProtectionPrice(e.y);
2966
+ return this.#o.price = r, this.#u?.({
2967
2967
  trade: this.#o.trade,
2968
2968
  type: this.#o.type,
2969
- price: s
2969
+ price: r
2970
2970
  }), this.consumeEvent(t), !0;
2971
2971
  }
2972
2972
  getNextDragPrice(t) {
2973
2973
  if (!this.#a) return 0;
2974
- const e = t - this.#h, i = this.#a.viewport.priceRange / this.#t.height, r = p(this.#f - e * i);
2974
+ const e = t - this.#h, i = this.#a.viewport.priceRange / this.#t.height, s = p(this.#m - e * i);
2975
2975
  return this.isProtectionHandleType(this.#a.type) ? this.constrainExistingProtectionPrice({
2976
- price: r,
2976
+ price: s,
2977
2977
  hitbox: this.#a,
2978
2978
  type: this.#a.type
2979
- }) : r;
2979
+ }) : s;
2980
2980
  }
2981
2981
  getNextMissingProtectionPrice(t) {
2982
2982
  if (!this.#o || !this.isProtectionHandleType(this.#o.type)) return 0;
@@ -2991,7 +2991,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2991
2991
  return this.#a && this.modifyActiveDragTrade(), this.#a = null, !1;
2992
2992
  }
2993
2993
  handleMissingProtectionDragEnd() {
2994
- return this.#o && this.#d && this.isProtectionHandleType(this.#o.type) ? this.#i?.({
2994
+ return this.#o && this.#d && this.isProtectionHandleType(this.#o.type) ? this.#s?.({
2995
2995
  trade: this.#o.trade,
2996
2996
  type: this.#o.type,
2997
2997
  price: p(this.#o.price)
@@ -3001,13 +3001,13 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3001
3001
  if (!this.#a) return;
3002
3002
  const t = p(this.#a.price);
3003
3003
  if (this.#a.type === "stopLoss") {
3004
- this.#u?.({
3004
+ this.#g?.({
3005
3005
  ticket: this.#a.trade.ticket,
3006
3006
  sl: t
3007
3007
  });
3008
3008
  return;
3009
3009
  }
3010
- this.#u?.({
3010
+ this.#g?.({
3011
3011
  ticket: this.#a.trade.ticket,
3012
3012
  tp: t
3013
3013
  });
@@ -3017,21 +3017,21 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3017
3017
  }
3018
3018
  handleHoveredHitbox(t, e, i) {
3019
3019
  if (e.kind === "missingProtectionHandle") return this.handleMissingProtectionHandleHover(t, e, i);
3020
- const r = this.isPointInsideArea(i, e.closeButtonArea), s = this.isPointInsideArea(i, e.labelArea);
3021
- return r ? this.handleCloseButtonHover(t, e) : (this.updateHandleCursor(e), s && t.type === "pointerdown" && e.type !== "startPrice" && this.startDrag(e, i.y), e.type !== "startPrice" ? (this.consumeEvent(t), !0) : !1);
3020
+ const s = this.isPointInsideArea(i, e.closeButtonArea), r = this.isPointInsideArea(i, e.labelArea);
3021
+ return s ? this.handleCloseButtonHover(t, e) : (this.updateHandleCursor(e), r && t.type === "pointerdown" && e.type !== "startPrice" && this.startDrag(e, i.y), e.type !== "startPrice" ? (this.consumeEvent(t), !0) : !1);
3022
3022
  }
3023
3023
  handleMissingProtectionHandleHover(t, e, i) {
3024
3024
  return document.body.style.cursor = "ns-resize", t.type === "pointerdown" ? (this.startMissingProtectionDrag(e, i.y), this.consumeEvent(t), !0) : (this.consumeEvent(t), !0);
3025
3025
  }
3026
3026
  handleCloseButtonHover(t, e) {
3027
- return document.body.style.cursor = "pointer", t.type !== "pointerdown" ? e.type !== "startPrice" : (this.handleCloseButtonClick(e), this.consumeEvent(t), !0);
3027
+ return document.body.style.cursor = "pointer", this.consumeEvent(t), t.type === "pointerdown" && this.handleCloseButtonClick(e), !0;
3028
3028
  }
3029
3029
  handleCloseButtonClick(t) {
3030
3030
  if (t.type === "startPrice") {
3031
3031
  this.#n?.({ ticket: t.trade.ticket });
3032
3032
  return;
3033
3033
  }
3034
- this.#u?.({
3034
+ this.#g?.({
3035
3035
  ticket: t.trade.ticket,
3036
3036
  ...t.type === "stopLoss" ? { sl: null } : {},
3037
3037
  ...t.type === "takeProfit" ? { tp: null } : {}
@@ -3041,7 +3041,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3041
3041
  document.body.style.cursor = t.type === "startPrice" ? "crosshair" : "ns-resize";
3042
3042
  }
3043
3043
  startDrag(t, e) {
3044
- this.#a = t, this.#h = e, this.#f = t.price;
3044
+ this.#a = t, this.#h = e, this.#m = t.price;
3045
3045
  }
3046
3046
  startMissingProtectionDrag(t, e) {
3047
3047
  this.#o = t, this.#h = e, this.#d = !1;
@@ -3050,19 +3050,19 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3050
3050
  !this.#a && !this.#o && (document.body.style.cursor = "crosshair");
3051
3051
  }
3052
3052
  isPointInsideArea(t, e) {
3053
- const i = t.x >= e.x && t.x <= e.x + e.width, r = t.y >= e.y && t.y <= e.y + e.height;
3054
- return i && r;
3053
+ const i = t.x >= e.x && t.x <= e.x + e.width, s = t.y >= e.y && t.y <= e.y + e.height;
3054
+ return i && s;
3055
3055
  }
3056
3056
  isProtectionHandleType(t) {
3057
3057
  return t === "stopLoss" || t === "takeProfit";
3058
3058
  }
3059
3059
  constrainExistingProtectionPrice({ price: t, hitbox: e, type: i }) {
3060
- const r = this.isBuyTrade(e), s = e.trade.openPrice, n = this.#r?.() ?? 0;
3061
- return p(i === "takeProfit" ? r ? Math.max(t, s, n) : Math.min(t, s, n) : r ? Math.min(t, n) : Math.max(t, n));
3060
+ const s = this.isBuyTrade(e), r = e.trade.openPrice, n = this.#r?.() ?? 0;
3061
+ return p(i === "takeProfit" ? s ? Math.max(t, r, n) : Math.min(t, r, n) : s ? Math.min(t, n) : Math.max(t, n));
3062
3062
  }
3063
3063
  constrainProtectionPrice({ price: t, hitbox: e, type: i }) {
3064
- const r = this.isBuyTrade(e), s = e.trade.openPrice, n = this.#r?.() ?? 0;
3065
- return p(i === "takeProfit" ? r ? Math.max(t, s, n) : Math.min(t, s, n) : r ? Math.min(t, n) : Math.max(t, n));
3064
+ const s = this.isBuyTrade(e), r = e.trade.openPrice, n = this.#r?.() ?? 0;
3065
+ return p(i === "takeProfit" ? s ? Math.max(t, r, n) : Math.min(t, r, n) : s ? Math.min(t, n) : Math.max(t, n));
3066
3066
  }
3067
3067
  isBuyTrade(t) {
3068
3068
  return String(t.trade.type).toLowerCase().includes("buy");
@@ -3070,7 +3070,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3070
3070
  consumeEvent(t) {
3071
3071
  t.stopPropagation(), t.preventDefault();
3072
3072
  }
3073
- }, re = class {
3073
+ }, se = class {
3074
3074
  #t;
3075
3075
  #e;
3076
3076
  candles;
@@ -3097,34 +3097,34 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3097
3097
  }
3098
3098
  render() {
3099
3099
  if (this.clearCanvas(), !c.volume.visible || !this.viewport || this.candles.length === 0) return;
3100
- const t = this.#e, e = this.#t.width, i = this.#t.height, { startIndex: r, endIndex: s } = this.getVisibleRange(e);
3101
- if (s < r) return;
3102
- const n = this.candles.slice(r, s + 1), o = this.getMaxVolume(n);
3100
+ const t = this.#e, e = this.#t.width, i = this.#t.height, { startIndex: s, endIndex: r } = this.getVisibleRange(e);
3101
+ if (r < s) return;
3102
+ const n = this.candles.slice(s, r + 1), o = this.getMaxVolume(n);
3103
3103
  o <= 0 || this.drawVolumeBars({
3104
3104
  ctx: t,
3105
3105
  candles: n,
3106
- startIndex: r,
3106
+ startIndex: s,
3107
3107
  maxVolume: o,
3108
3108
  chartHeight: i
3109
3109
  });
3110
3110
  }
3111
- drawVolumeBars({ ctx: t, candles: e, startIndex: i, maxVolume: r, chartHeight: s }) {
3111
+ drawVolumeBars({ ctx: t, candles: e, startIndex: i, maxVolume: s, chartHeight: r }) {
3112
3112
  t.save(), t.globalAlpha = this.opacity, e.forEach((n, o) => {
3113
3113
  const a = i + o, l = this.getCandleX(a);
3114
3114
  this.drawSingleVolumeBar({
3115
3115
  ctx: t,
3116
3116
  candle: n,
3117
3117
  candleX: l,
3118
- maxVolume: r,
3119
- chartHeight: s
3118
+ maxVolume: s,
3119
+ chartHeight: r
3120
3120
  });
3121
3121
  }), t.restore();
3122
3122
  }
3123
- drawSingleVolumeBar({ ctx: t, candle: e, candleX: i, maxVolume: r, chartHeight: s }) {
3123
+ drawSingleVolumeBar({ ctx: t, candle: e, candleX: i, maxVolume: s, chartHeight: r }) {
3124
3124
  if (!this.viewport || e.volume <= 0) return;
3125
- const n = this.getVolumeAreaHeight(s);
3125
+ const n = this.getVolumeAreaHeight(r);
3126
3126
  if (n <= 0) return;
3127
- 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);
3127
+ const o = n * (e.volume / s), a = Math.min(n, Math.max(o, this.minBarHeight)), l = r - this.bottomOffset - a, d = Math.max(1, this.viewport.candleWidth);
3128
3128
  t.fillStyle = this.getVolumeBarColor(e), t.fillRect(i, l, d, a);
3129
3129
  }
3130
3130
  getVisibleRange(t) {
@@ -3159,20 +3159,20 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3159
3159
  }, A = (t) => {
3160
3160
  const e = document.createElement("canvas");
3161
3161
  return e.className = t, e;
3162
- }, se = (t, e) => {
3162
+ }, re = (t, e) => {
3163
3163
  const i = document.createElement("div");
3164
3164
  i.className = "trading-reload-chart", i.style.backgroundColor = e, i.tabIndex = 0;
3165
- const r = document.createElement("div");
3166
- r.className = "trading-reload-chart__layout";
3167
3165
  const s = document.createElement("div");
3168
- s.className = "trading-reload-chart__stack";
3166
+ s.className = "trading-reload-chart__layout";
3167
+ const r = document.createElement("div");
3168
+ r.className = "trading-reload-chart__stack";
3169
3169
  const n = A("trading-reload-chart__volume"), o = A("trading-reload-chart__plot"), a = A("trading-reload-chart__shapes"), l = A("trading-reload-chart__trades"), d = A("trading-reload-chart__overlay"), u = A("trading-reload-chart__axis-x");
3170
- s.append(n, o, a, l, d, u);
3170
+ r.append(n, o, a, l, d, u);
3171
3171
  const g = A("trading-reload-chart__axis-y");
3172
- return r.append(s, g), i.append(r), t.append(i), {
3172
+ return s.append(r, g), i.append(s), t.append(i), {
3173
3173
  root: i,
3174
- layout: r,
3175
- stack: s,
3174
+ layout: s,
3175
+ stack: r,
3176
3176
  volumeCanvas: n,
3177
3177
  candleCanvas: o,
3178
3178
  shapesCanvas: a,
@@ -3180,69 +3180,70 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3180
3180
  overlayCanvas: d,
3181
3181
  axisXCanvas: u,
3182
3182
  axisYCanvas: g,
3183
- interactionTarget: r
3183
+ interactionTarget: s
3184
3184
  };
3185
3185
  }, gt = (t) => typeof t == "object" && t !== null && !Array.isArray(t), Lt = (t, e) => {
3186
3186
  const i = { ...t };
3187
- for (const r of Object.keys(e)) {
3188
- const s = e[r], n = t[r];
3189
- if (s !== void 0) {
3190
- if (gt(s) && gt(n)) {
3191
- i[r] = Lt(n, s);
3187
+ for (const s of Object.keys(e)) {
3188
+ const r = e[s], n = t[s];
3189
+ if (r !== void 0) {
3190
+ if (gt(r) && gt(n)) {
3191
+ i[s] = Lt(n, r);
3192
3192
  continue;
3193
3193
  }
3194
- i[r] = s;
3194
+ i[s] = r;
3195
3195
  }
3196
3196
  }
3197
3197
  return i;
3198
3198
  }, ft = (t) => Lt(c, t ?? {}), pt = (t, e) => e === void 0 || t.time >= 1e12 ? t : {
3199
3199
  ...t,
3200
3200
  time: t.time * 1e3 - e
3201
- }, ne = class {
3201
+ }, ne = 12, oe = class {
3202
3202
  #t;
3203
3203
  #e;
3204
3204
  #r;
3205
- #s = null;
3206
- #c = null;
3207
3205
  #i = null;
3208
- #l = null;
3209
3206
  #u = null;
3207
+ #s = null;
3208
+ #l = null;
3209
+ #g = null;
3210
3210
  #n = null;
3211
3211
  #a = null;
3212
3212
  #o = null;
3213
3213
  #d = null;
3214
3214
  #h = null;
3215
- #f = !1;
3216
- #v = 0;
3217
- #y = !1;
3218
- #x = 0;
3219
- #S = 0;
3220
- #p = null;
3221
- #w = null;
3215
+ #m = !1;
3216
+ #y = 0;
3217
+ #w = !1;
3218
+ #T = 0;
3219
+ #L = 0;
3220
+ #f = null;
3221
+ #C = null;
3222
3222
  #P = null;
3223
+ #b = null;
3223
3224
  constructor(t, e) {
3224
- this.#t = t, this.#e = e, this.#r = ft(e.config), this.#s = se(t, this.#r.colors.background), this.#h = new zt({
3225
- canvas: this.#s.overlayCanvas,
3225
+ this.#t = t, this.#e = e, this.#r = ft(e.config), this.#i = re(t, this.#r.colors.background), this.#h = new Vt({
3226
+ canvas: this.#i.overlayCanvas,
3226
3227
  crosshairColor: this.#r.crosshair.color,
3227
3228
  crosshairThickness: this.#r.crosshair.thickness,
3228
3229
  crosshairStyle: this.#r.crosshair.style
3229
- }), this.#R(), this.#D(), this.#H(), this.updateProps(e);
3230
+ }), this.#B(), this.#W(), this.#M(), this.updateProps(e);
3230
3231
  }
3231
3232
  updateProps(t) {
3232
3233
  const e = this.#e.activeShapeTool;
3233
- this.#e = t, this.#r = ft(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.#X(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.#B(), this.#g());
3234
+ this.#e = t, this.#r = ft(t.config), this.#i && (this.#i.root.style.backgroundColor = this.#r.colors.background, this.#i.layout.style.setProperty("--axis-x-height", `${this.#r.axis.axisX.height}px`)), !this.#m && t.candles.length > 0 && this.#I(t.candles), this.#s && (t.activeShapeTool !== e && this.#Y(t.activeShapeTool), this.#l?.setConfig(this.#r.shapes), this.#l?.setShapes(t.shapes), this.#l?.setActiveTool(t.activeShapeTool), this.#g?.setConfig(this.#r.shapes.previousDayHighLow ?? null), this.#g?.setPreviousDay(t.previousDay), this.#n?.setClosedTrades(t.closedTrades ?? []), this.#x(), this.#E(), this.#c());
3234
3235
  }
3235
3236
  resetChartView() {
3236
- this.#i?.resetView(), this.#g();
3237
+ this.#s?.resetView(), this.#c();
3237
3238
  }
3238
3239
  destroy() {
3239
- 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;
3240
+ this.#b?.abort(), this.#b = null, this.#P?.disconnect(), this.#P = null, this.#i?.root.remove(), this.#i = null, this.#u = null, this.#s = null, this.#l = null, this.#g = null, this.#n = null, this.#a = null, this.#o = null, this.#d = null, this.#h = null, this.#f = null, this.#m = !1;
3240
3241
  }
3241
- #M(t) {
3242
- if (!this.#s || this.#f) return;
3243
- const e = t.map((r) => pt(r, this.#e.brokerTimezoneOffsetMs));
3244
- this.#c = new re({
3245
- canvas: this.#s.volumeCanvas,
3242
+ #I(t) {
3243
+ if (!this.#i || this.#m) return;
3244
+ const e = t.map((s) => pt(s, this.#e.brokerTimezoneOffsetMs));
3245
+ this.#u = new se({
3246
+ canvas: this.#i.volumeCanvas,
3246
3247
  candles: e,
3247
3248
  bullishColor: this.#r.volume.bullishColor,
3248
3249
  bearishColor: this.#r.volume.bearishColor,
@@ -3250,8 +3251,8 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3250
3251
  height: this.#r.volume.height,
3251
3252
  bottomOffset: this.#r.volume.bottomOffset,
3252
3253
  minBarHeight: this.#r.volume.minBarHeight
3253
- }), this.#i = new _t({
3254
- canvas: this.#s.candleCanvas,
3254
+ }), this.#s = new _t({
3255
+ canvas: this.#i.candleCanvas,
3255
3256
  candles: e,
3256
3257
  baseCandleWidth: this.#r.candles.defaultWidth,
3257
3258
  baseCandleGap: this.#r.candles.defaultGap,
@@ -3261,122 +3262,122 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3261
3262
  autoFollowThresholdCandles: this.#r.candles.autoFollowThresholdCandles,
3262
3263
  rightOffsetCandles: this.#r.candles.rightOffsetCandles
3263
3264
  }), this.#l = new Qt({
3264
- canvas: this.#s.shapesCanvas,
3265
+ canvas: this.#i.shapesCanvas,
3265
3266
  activeSymbol: this.#e.activeSymbol,
3266
3267
  candles: e,
3267
3268
  shapes: this.#e.shapes,
3268
3269
  activeTool: this.#e.activeShapeTool,
3269
3270
  config: this.#r.shapes,
3270
- onShapeAdded: (r) => {
3271
- this.#e.onShapeAdded?.(r);
3271
+ onShapeAdded: (s) => {
3272
+ this.#e.onShapeAdded?.(s);
3272
3273
  },
3273
- onShapeModified: (r) => {
3274
- this.#e.onShapeModified?.(r);
3274
+ onShapeModified: (s) => {
3275
+ this.#e.onShapeModified?.(s);
3275
3276
  },
3276
- onShapeSelected: (r) => {
3277
- this.#e.onShapeSelected?.(r);
3277
+ onShapeSelected: (s) => {
3278
+ this.#e.onShapeSelected?.(s);
3278
3279
  },
3279
- onShapeDoubleClicked: (r) => {
3280
- this.#e.onShapeDoubleClicked?.(r);
3280
+ onShapeDoubleClicked: (s) => {
3281
+ this.#e.onShapeDoubleClicked?.(s);
3281
3282
  },
3282
- onToolChange: (r) => {
3283
- this.#e.onActiveShapeToolChange?.(r);
3283
+ onToolChange: (s) => {
3284
+ this.#e.onActiveShapeToolChange?.(s);
3284
3285
  }
3285
3286
  });
3286
- const i = this.#s.shapesCanvas.getContext("2d");
3287
- i && (this.#u = new Gt({
3287
+ const i = this.#i.shapesCanvas.getContext("2d");
3288
+ i && (this.#g = new Gt({
3288
3289
  ctx: i,
3289
3290
  config: this.#r.shapes.previousDayHighLow ?? null
3290
- }), this.#u.setPreviousDay(this.#e.previousDay)), this.#n = new te({ canvas: this.#s.tradesCanvas }), this.#n.setCandles(e), this.#n.setClosedTrades(this.#e.closedTrades ?? []), this.#b(), this.#o = new Ot({
3291
- canvas: this.#s.axisXCanvas,
3291
+ }), this.#g.setPreviousDay(this.#e.previousDay)), this.#n = new te({ canvas: this.#i.tradesCanvas }), this.#n.setCandles(e), this.#n.setClosedTrades(this.#e.closedTrades ?? []), this.#x(), this.#o = new Ot({
3292
+ canvas: this.#i.axisXCanvas,
3292
3293
  candles: e
3293
- }), this.#d = new Vt({ canvas: this.#s.axisYCanvas }), this.#a = new ie({
3294
- canvas: this.#s.tradesCanvas,
3295
- getHandleHitboxes: () => this.#m() ? [] : this.#n?.handleHitboxes ?? [],
3296
- getCurrentPrice: () => this.#i?.liveCandle?.close ?? 0,
3297
- onDrag: (r) => this.#W(r),
3298
- onMissingProtectionDrag: (r) => this.#F(r),
3299
- onMissingProtectionDragEnd: (r) => this.#Y(r),
3300
- onMissingProtectionDragCancel: () => this.#O(),
3301
- onTradeModified: (r) => this.#k(r),
3302
- onTradeCloseClicked: (r) => this.#e.onTradeClose?.(r)
3303
- }), this.#f = !0, this.#g();
3304
- }
3305
- #R() {
3306
- if (!this.#s) return;
3307
- this.#P = new AbortController();
3308
- const { signal: t } = this.#P, e = this.#s.interactionTarget;
3309
- e.addEventListener("pointerdown", (i) => this.#N(i), { signal: t }), e.addEventListener("pointerup", (i) => this.#G(i), { signal: t }), e.addEventListener("pointermove", (i) => this.#_(i), { signal: t }), e.addEventListener("pointerenter", (i) => this.#U(i), { signal: t }), e.addEventListener("pointerleave", () => this.#$(), { signal: t }), e.addEventListener("contextmenu", (i) => this.#J(i), { signal: t }), e.addEventListener("dblclick", (i) => this.#K(i), { signal: t }), e.addEventListener("wheel", (i) => this.#V(i), {
3294
+ }), this.#d = new zt({ canvas: this.#i.axisYCanvas }), this.#a = new ie({
3295
+ canvas: this.#i.tradesCanvas,
3296
+ getHandleHitboxes: () => this.#p() ? [] : this.#n?.handleHitboxes ?? [],
3297
+ getCurrentPrice: () => this.#s?.liveCandle?.close ?? 0,
3298
+ onDrag: (s) => this.#z(s),
3299
+ onMissingProtectionDrag: (s) => this.#V(s),
3300
+ onMissingProtectionDragEnd: (s) => this.#N(s),
3301
+ onMissingProtectionDragCancel: () => this.#_(),
3302
+ onTradeModified: (s) => this.#R(s),
3303
+ onTradeCloseClicked: (s) => this.#e.onTradeClose?.(s)
3304
+ }), this.#m = !0, this.#c();
3305
+ }
3306
+ #B() {
3307
+ if (!this.#i) return;
3308
+ this.#b = new AbortController();
3309
+ const { signal: t } = this.#b, e = this.#i.interactionTarget;
3310
+ e.addEventListener("pointerdown", (i) => this.#J(i), { signal: t }), e.addEventListener("pointerup", (i) => this.#j(i), { signal: t }), e.addEventListener("pointermove", (i) => this.#K(i), { signal: t }), e.addEventListener("pointerenter", (i) => this.#Z(i), { signal: t }), e.addEventListener("pointerleave", () => this.#q(), { signal: t }), e.addEventListener("contextmenu", (i) => this.#Q(i), { signal: t }), e.addEventListener("dblclick", (i) => this.#tt(i), { signal: t }), e.addEventListener("wheel", (i) => this.#U(i), {
3310
3311
  passive: !1,
3311
3312
  signal: t
3312
- }), this.#s.axisYCanvas.addEventListener("wheel", (i) => this.#z(i), {
3313
+ }), this.#i.axisXCanvas.addEventListener("pointerenter", (i) => this.#D(i), { signal: t }), this.#i.axisXCanvas.addEventListener("pointerdown", (i) => this.#A(i, "x"), { signal: t }), this.#i.axisXCanvas.addEventListener("pointermove", (i) => this.#X(i), { signal: t }), this.#i.axisXCanvas.addEventListener("pointerup", (i) => this.#S(i), { signal: t }), this.#i.axisXCanvas.addEventListener("pointercancel", (i) => this.#S(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointerenter", (i) => this.#D(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointerdown", (i) => this.#A(i, "y"), { signal: t }), this.#i.axisYCanvas.addEventListener("pointermove", (i) => this.#X(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointerup", (i) => this.#S(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointercancel", (i) => this.#S(i), { signal: t }), this.#i.axisYCanvas.addEventListener("wheel", (i) => this.#$(i), {
3313
3314
  passive: !1,
3314
3315
  signal: t
3315
- }), document.addEventListener("keydown", (i) => this.#j(i), { signal: t });
3316
+ }), document.addEventListener("keydown", (i) => this.#et(i), { signal: t });
3316
3317
  }
3317
- #D() {
3318
- this.#w = new ResizeObserver(() => {
3319
- this.#H(), this.#g();
3320
- }), this.#w.observe(this.#t);
3318
+ #W() {
3319
+ this.#P = new ResizeObserver(() => {
3320
+ this.#M(), this.#c();
3321
+ }), this.#P.observe(this.#t);
3321
3322
  }
3322
- #A() {
3323
- const t = this.#r.axis.axisY.width, e = this.#r.axis.axisX.height, i = this.#t.clientWidth, r = this.#t.clientHeight;
3323
+ #F() {
3324
+ const t = this.#r.axis.axisY.width, e = this.#r.axis.axisX.height, i = this.#t.clientWidth, s = this.#t.clientHeight;
3324
3325
  return {
3325
3326
  axisYWidth: t,
3326
3327
  axisXHeight: e,
3327
3328
  plotWidth: Math.max(0, i - t),
3328
- plotHeight: Math.max(0, r - e)
3329
+ plotHeight: Math.max(0, s - e)
3329
3330
  };
3330
3331
  }
3331
- #C(t, e, i) {
3332
+ #v(t, e, i) {
3332
3333
  t.width = e, t.height = i;
3333
3334
  }
3334
- #H() {
3335
- if (!this.#s) return;
3336
- const { plotWidth: t, plotHeight: e, axisYWidth: i, axisXHeight: r } = this.#A();
3337
- if (this.#i && this.#v > 0 && t !== this.#v) {
3338
- const s = t - this.#v;
3339
- this.#i.panHorizontally(s);
3335
+ #M() {
3336
+ if (!this.#i) return;
3337
+ const { plotWidth: t, plotHeight: e, axisYWidth: i, axisXHeight: s } = this.#F();
3338
+ if (this.#s && this.#y > 0 && t !== this.#y) {
3339
+ const r = t - this.#y;
3340
+ this.#s.panHorizontally(r);
3340
3341
  }
3341
- 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);
3342
+ this.#y = t, this.#v(this.#i.volumeCanvas, t, e), this.#v(this.#i.candleCanvas, t, e), this.#v(this.#i.shapesCanvas, t, e), this.#v(this.#i.overlayCanvas, t, e), this.#v(this.#i.tradesCanvas, t, e), this.#v(this.#i.axisXCanvas, t, s), this.#v(this.#i.axisYCanvas, i, e);
3342
3343
  }
3343
- #T() {
3344
- 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());
3344
+ #H() {
3345
+ this.#s && (this.#o?.setCandles(this.#s.candles), this.#o?.setViewport(this.#s.viewport), this.#o?.render(), this.#d?.setViewport(this.#s.viewport), this.#d?.render());
3345
3346
  }
3346
- #g() {
3347
- 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.#T(), this.#h?.render());
3347
+ #c() {
3348
+ this.#s && (this.#u?.setCandles(this.#s.candles), this.#u?.setLiveCandle(this.#s.liveCandle), this.#u?.setViewport(this.#s.viewport), this.#u?.render(), this.#s.render(), this.#l?.setCandles(this.#s.candles), this.#l?.setViewport(this.#s.viewport), this.#l?.render(), this.#g?.setViewport(this.#s.viewport), this.#g?.render(), this.#n?.setCandles(this.#s.candles), this.#n?.setViewport(this.#s.viewport), this.#n?.isDragging ? this.#n.renderLiveFeed() : this.#n?.render(), this.#H(), this.#h?.render());
3348
3349
  }
3349
- #m() {
3350
+ #p() {
3350
3351
  return this.#e.activeShapeTool !== null;
3351
3352
  }
3352
- #X(t) {
3353
- t !== null && (this.#y = !1, this.#n?.setIsDragging(!1), this.#a?.cancelActiveInteraction()), this.#l?.setActiveTool(t);
3353
+ #Y(t) {
3354
+ t !== null && (this.#w = !1, this.#n?.setIsDragging(!1), this.#a?.cancelActiveInteraction()), this.#l?.setActiveTool(t);
3354
3355
  }
3355
- #I() {
3356
+ #O() {
3356
3357
  const t = this.#e.openTrades ?? [];
3357
- return this.#p ? t.map((e) => e.ticket !== this.#p?.ticket ? e : {
3358
+ return this.#C ? t.map((e) => e.ticket !== this.#C?.ticket ? e : {
3358
3359
  ...e,
3359
- ...this.#p.sl !== void 0 ? { sl: this.#p.sl } : {},
3360
- ...this.#p.tp !== void 0 ? { tp: this.#p.tp } : {}
3360
+ ...this.#C.sl !== void 0 ? { sl: this.#C.sl } : {},
3361
+ ...this.#C.tp !== void 0 ? { tp: this.#C.tp } : {}
3361
3362
  }) : t;
3362
3363
  }
3363
- #b() {
3364
- this.#n?.setTrades(this.#I());
3364
+ #x() {
3365
+ this.#n?.setTrades(this.#O());
3365
3366
  }
3366
- #B() {
3367
+ #E() {
3367
3368
  const t = this.#e.liveCandle;
3368
- if (!t || !this.#i) return;
3369
+ if (!t || !this.#s) return;
3369
3370
  const e = pt(t, this.#e.brokerTimezoneOffsetMs);
3370
- this.#i.updateLiveCandle(e), this.#n?.setLiveCandle(this.#i.liveCandle), this.#n?.setCandles(this.#i.candles);
3371
+ this.#s.updateLiveCandle(e), this.#n?.setLiveCandle(this.#s.liveCandle), this.#n?.setCandles(this.#s.candles);
3371
3372
  }
3372
- #W({ trade: t, type: e, price: i }) {
3373
- this.#n && (this.#n.setIsDragging(!0), this.#p = {
3373
+ #z({ trade: t, type: e, price: i }) {
3374
+ this.#n && (this.#n.setIsDragging(!0), this.#C = {
3374
3375
  ticket: t.ticket,
3375
3376
  ...e === "stopLoss" ? { sl: i } : {},
3376
3377
  ...e === "takeProfit" ? { tp: i } : {}
3377
- }, this.#b(), this.#n.render());
3378
+ }, this.#x(), this.#n.render());
3378
3379
  }
3379
- #F({ trade: t, type: e, price: i }) {
3380
+ #V({ trade: t, type: e, price: i }) {
3380
3381
  this.#n?.viewport && (this.#n.setIsDragging(!0), this.#n.setTemporaryProtectionDrag({
3381
3382
  visible: !0,
3382
3383
  trade: t,
@@ -3385,28 +3386,28 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3385
3386
  viewport: this.#n.viewport
3386
3387
  }), this.#n.render());
3387
3388
  }
3388
- #Y({ trade: t, type: e, price: i }) {
3389
- this.#n?.setIsDragging(!1), this.#k({
3389
+ #N({ trade: t, type: e, price: i }) {
3390
+ this.#n?.setIsDragging(!1), this.#R({
3390
3391
  ticket: t.ticket,
3391
3392
  ...e === "stopLoss" ? { sl: i } : {},
3392
3393
  ...e === "takeProfit" ? { tp: i } : {}
3393
3394
  });
3394
3395
  }
3395
- #O() {
3396
+ #_() {
3396
3397
  this.#n?.setIsDragging(!1), this.#n?.clearTemporaryProtectionDrag(), this.#n?.render();
3397
3398
  }
3398
- #k(t) {
3399
- this.#n?.setIsDragging(!1), this.#p = null, this.#n?.clearTemporaryProtectionDrag(), this.#e.onTradeModify?.(t), this.#b(), this.#n?.render();
3399
+ #R(t) {
3400
+ this.#n?.setIsDragging(!1), this.#C = null, this.#n?.clearTemporaryProtectionDrag(), this.#e.onTradeModify?.(t), this.#x(), this.#n?.render();
3400
3401
  }
3401
- #L(t) {
3402
- if (!this.#h || !this.#s) return;
3403
- if (!this.#i) {
3402
+ #k(t) {
3403
+ if (!this.#h || !this.#i) return;
3404
+ if (!this.#s) {
3404
3405
  this.#h.updateMousePosition(t.clientX, t.clientY), this.#h.render();
3405
3406
  return;
3406
3407
  }
3407
- const e = vt(this.#s.overlayCanvas, t), i = this.#i.getNearestCandleIndexByX(e.x), r = i === null ? null : this.#i.candles[i] ?? null, s = i === null ? e.x : this.#i.getRawCandleSnapX(e.x);
3408
- this.#h.updateMousePosition(t.clientX, t.clientY, { snapX: s });
3409
- const n = this.#i.getPriceAtY(this.#h.mouseY);
3408
+ const e = vt(this.#i.overlayCanvas, t), i = this.#s.getNearestCandleIndexByX(e.x), s = i === null ? null : this.#s.candles[i] ?? null, r = i === null ? e.x : this.#s.getRawCandleSnapX(e.x);
3409
+ this.#h.updateMousePosition(t.clientX, t.clientY, { snapX: r });
3410
+ const n = this.#s.getPriceAtY(this.#h.mouseY);
3410
3411
  this.#d?.setCrosshair({
3411
3412
  visible: !0,
3412
3413
  y: this.#h.mouseY,
@@ -3414,78 +3415,105 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3414
3415
  }), this.#o?.setCrosshair({
3415
3416
  visible: !0,
3416
3417
  x: this.#h.mouseX,
3417
- candle: r
3418
- }), this.#T(), this.#h.render();
3418
+ candle: s
3419
+ }), this.#H(), this.#h.render();
3419
3420
  }
3420
- #E() {
3421
- this.#h?.hide(), this.#o?.hideCrosshair(), this.#d?.hideCrosshair(), this.#T(), this.#h?.render();
3421
+ #G() {
3422
+ this.#h?.hide(), this.#o?.hideCrosshair(), this.#d?.hideCrosshair(), this.#H(), this.#h?.render();
3422
3423
  }
3423
- #V(t) {
3424
- if (!this.#i || !this.#n) return;
3425
- this.#m() || this.#a?.handlePointerEvent(t), t.preventDefault();
3424
+ #U(t) {
3425
+ if (!this.#s || !this.#n) return;
3426
+ this.#p() || this.#a?.handlePointerEvent(t), t.preventDefault();
3426
3427
  const e = t.deltaY < 0 ? 1 : -1;
3427
- t.ctrlKey || t.metaKey ? this.#i.zoomVertically(e) : this.#i.zoomHorizontally(e), this.#g();
3428
+ t.ctrlKey || t.metaKey ? this.#s.zoomVertically(e) : this.#s.zoomHorizontally(e), this.#c();
3428
3429
  }
3429
- #z(t) {
3430
- if (!this.#i) return;
3430
+ #$(t) {
3431
+ if (!this.#s) return;
3431
3432
  t.preventDefault(), t.stopPropagation();
3432
3433
  const e = t.deltaY < 0 ? 1 : -1;
3433
- this.#i.zoomVertically(e), this.#g();
3434
+ this.#s.zoomVertically(e), this.#c();
3434
3435
  }
3435
- #N(t) {
3436
- if (this.#l?.handlePointerEvent(t) ?? !1) {
3437
- this.#g();
3438
- return;
3436
+ #D(t) {
3437
+ const e = t.currentTarget;
3438
+ e.style.cursor = e === this.#i?.axisXCanvas ? "ew-resize" : "ns-resize";
3439
+ }
3440
+ #A(t, e) {
3441
+ t.stopPropagation(), t.button === 0 && (t.currentTarget.setPointerCapture(t.pointerId), this.#f = {
3442
+ axis: e,
3443
+ lastClientPosition: e === "x" ? t.clientX : t.clientY,
3444
+ pointerId: t.pointerId
3445
+ }, t.preventDefault());
3446
+ }
3447
+ #X(t) {
3448
+ t.stopPropagation();
3449
+ const e = t.currentTarget, i = e === this.#i?.axisXCanvas ? "x" : "y";
3450
+ if (e.style.cursor = i === "x" ? "ew-resize" : "ns-resize", !this.#f || this.#f.pointerId !== t.pointerId || this.#f.axis !== i) return;
3451
+ const s = i === "x" ? t.clientX : t.clientY, r = s - this.#f.lastClientPosition;
3452
+ if (this.#f.lastClientPosition = s, !this.#s || r === 0) return;
3453
+ const n = (i === "x" ? r : -r) / ne;
3454
+ i === "x" ? this.#s.zoomHorizontally(n) : this.#s.zoomVertically(n), t.preventDefault(), this.#c();
3455
+ }
3456
+ #S(t) {
3457
+ if (t.stopPropagation(), this.#f?.pointerId !== t.pointerId) return;
3458
+ const e = t.currentTarget;
3459
+ e.hasPointerCapture(t.pointerId) && e.releasePointerCapture(t.pointerId), this.#f = null, t.preventDefault();
3460
+ }
3461
+ #J(t) {
3462
+ if (!(!this.#p() && this.#a?.handlePointerEvent(t))) {
3463
+ if (this.#l?.handlePointerEvent(t) ?? !1) {
3464
+ this.#c();
3465
+ return;
3466
+ }
3467
+ this.#p() || (this.#w = !0, this.#T = t.clientX, this.#L = t.clientY);
3439
3468
  }
3440
- this.#m() || this.#a?.handlePointerEvent(t) || (this.#y = !0, this.#x = t.clientX, this.#S = t.clientY);
3441
3469
  }
3442
- #_(t) {
3470
+ #K(t) {
3443
3471
  const e = this.#l?.handlePointerEvent(t) ?? !1;
3444
- if (this.#m() || this.#a?.handlePointerEvent(t), this.#L(t), e) {
3445
- this.#g(), this.#L(t);
3472
+ if (this.#p() || this.#a?.handlePointerEvent(t), this.#k(t), e) {
3473
+ this.#c(), this.#k(t);
3446
3474
  return;
3447
3475
  }
3448
- if (!this.#y || !this.#i || this.#m()) return;
3449
- const i = t.clientX - this.#x, r = t.clientY - this.#S;
3450
- this.#x = t.clientX, this.#S = t.clientY, this.#i.panHorizontally(i), this.#i.panVertically(r), this.#g(), this.#L(t);
3476
+ if (!this.#w || !this.#s || this.#p()) return;
3477
+ const i = t.clientX - this.#T, s = t.clientY - this.#L;
3478
+ this.#T = t.clientX, this.#L = t.clientY, this.#s.panHorizontally(i), this.#s.panVertically(s), this.#c(), this.#k(t);
3451
3479
  }
3452
- #G(t) {
3453
- if (this.#y = !1, this.#l?.handlePointerEvent(t) ?? !1) {
3454
- this.#g();
3480
+ #j(t) {
3481
+ if (this.#w = !1, this.#l?.handlePointerEvent(t) ?? !1) {
3482
+ this.#c();
3455
3483
  return;
3456
3484
  }
3457
- this.#m() || this.#a?.handlePointerEvent(t);
3485
+ this.#p() || this.#a?.handlePointerEvent(t);
3458
3486
  }
3459
- #U(t) {
3460
- document.body.style.cursor = "crosshair", this.#l?.handlePointerEvent(t), this.#m() || this.#a?.handlePointerEvent(t);
3487
+ #Z(t) {
3488
+ document.body.style.cursor = "crosshair", this.#l?.handlePointerEvent(t), this.#p() || this.#a?.handlePointerEvent(t);
3461
3489
  }
3462
- #$() {
3463
- this.#l?.clearHoverState(), document.body.style.cursor = "", this.#E();
3490
+ #q() {
3491
+ this.#l?.clearHoverState(), document.body.style.cursor = "", this.#G();
3464
3492
  }
3465
- #J(t) {
3466
- ((this.#l?.handlePointerEvent(t) ?? !1) || this.#m()) && (t.preventDefault(), t.stopPropagation(), this.#g());
3493
+ #Q(t) {
3494
+ ((this.#l?.handlePointerEvent(t) ?? !1) || this.#p()) && (t.preventDefault(), t.stopPropagation(), this.#c());
3467
3495
  }
3468
- #K(t) {
3496
+ #tt(t) {
3469
3497
  this.#l?.handlePointerEvent(t);
3470
3498
  }
3471
- #j(t) {
3472
- (this.#l?.handleKeyboardEvent(t) ?? !1) && (t.preventDefault(), this.#g());
3499
+ #et(t) {
3500
+ (this.#l?.handleKeyboardEvent(t) ?? !1) && (t.preventDefault(), this.#c());
3473
3501
  }
3474
- }, le = Rt(({ className: t, style: e, ...i }, r) => {
3475
- const s = N(null), n = N(null), o = N(i);
3476
- return o.current = i, Dt(r, () => ({ resetChartView() {
3502
+ }, he = Rt(({ className: t, style: e, ...i }, s) => {
3503
+ const r = N(null), n = N(null), o = N(i);
3504
+ return o.current = i, Dt(s, () => ({ resetChartView() {
3477
3505
  n.current?.resetChartView();
3478
- } })), rt(() => {
3479
- const a = s.current;
3506
+ } })), st(() => {
3507
+ const a = r.current;
3480
3508
  if (!a) return;
3481
- const l = new ne(a, o.current);
3509
+ const l = new oe(a, o.current);
3482
3510
  return n.current = l, () => {
3483
3511
  l.destroy(), n.current = null;
3484
3512
  };
3485
- }, []), rt(() => {
3513
+ }, []), st(() => {
3486
3514
  n.current?.updateProps(o.current);
3487
3515
  }, [i]), /* @__PURE__ */ At("div", {
3488
- ref: s,
3516
+ ref: r,
3489
3517
  className: t,
3490
3518
  style: {
3491
3519
  width: "100%",
@@ -3496,5 +3524,5 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3496
3524
  });
3497
3525
  export {
3498
3526
  c as CHART_CONFIG,
3499
- le as TradingReload
3527
+ he as TradingReload
3500
3528
  };