charts-core 1.1.1 → 1.1.2

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,149 +1,149 @@
1
- var Mn = Object.defineProperty;
2
- var Cn = (i, e, t) => e in i ? Mn(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var m = (i, e, t) => Cn(i, typeof e != "symbol" ? e + "" : e, t);
1
+ var ws = Object.defineProperty;
2
+ var Ms = (i, e, t) => e in i ? ws(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var g = (i, e, t) => Ms(i, typeof e != "symbol" ? e + "" : e, t);
4
4
  import * as k from "d3";
5
- const Tn = (i) => {
6
- const { svg: e, config: t, y: n, width: r } = i, { margin: s, yAxis: o } = t, { customTicks: l, tickFormat: c, tickValues: d, ticks: u, isShow: _ } = o;
5
+ const Ts = (i) => {
6
+ const { svg: e, config: t, y: s, width: r } = i, { margin: n, yAxis: o } = t, { customTicks: l, tickFormat: h, tickValues: d, ticks: u, isShow: _ } = o;
7
7
  if (!_) return null;
8
- e.append("g").attr("transform", `translate(${r - s.right},0)`).call((g) => {
9
- let p = k.axisRight(n);
10
- l && c ? p = p.tickFormat(c) : p = p.tickFormat((v) => {
11
- const y = Number(v), b = (w) => w.toString().replace(/\.0+$/, "");
8
+ e.append("g").attr("transform", `translate(${r - n.right},0)`).call((m) => {
9
+ let p = k.axisRight(s);
10
+ l && h ? p = p.tickFormat(h) : p = p.tickFormat((v) => {
11
+ const y = Number(v), b = (x) => x.toString().replace(/\.0+$/, "");
12
12
  return Math.abs(y) >= 1e12 ? b(y / 1e12) + "T" : Math.abs(y) >= 1e9 ? b(y / 1e9) + "B" : Math.abs(y) >= 1e6 ? b(y / 1e6) + "M" : Math.abs(y) >= 1e3 ? b(y / 1e3) + "K" : b(y);
13
- }), l && u && (p = Array.isArray(u) ? p.ticks(...u) : p.ticks(u)), l && d && (p = p.tickValues(d)), g.call(p);
14
- }).call((g) => {
13
+ }), l && u && (p = Array.isArray(u) ? p.ticks(...u) : p.ticks(u)), l && d && (p = p.tickValues(d)), m.call(p);
14
+ }).call((m) => {
15
15
  let p = [];
16
- g.selectAll(".tick").each((v) => p.push(v)), i.yTicks = p;
17
- }).call((g) => g.select(".domain").remove()).call((g) => g.selectAll(".tick line").remove()).call((g) => {
18
- const p = g.selectAll(".tick text");
16
+ m.selectAll(".tick").each((v) => p.push(v)), i.yTicks = p;
17
+ }).call((m) => m.select(".domain").remove()).call((m) => m.selectAll(".tick line").remove()).call((m) => {
18
+ const p = m.selectAll(".tick text");
19
19
  p.classed("sc-charts__y-axis-tick", !0).attr("text-anchor", "start");
20
20
  const v = p.nodes().map((b) => b.getBBox().width), y = Math.max(...v);
21
- g.selectAll(".tick").each(function(b, w) {
22
- var X;
23
- const T = k.select(this), C = T.select("text"), N = v[w], W = y - N, B = T.append("g").attr("transform", "translate(10, 0)");
24
- C.attr("x", W), C.remove(), (X = B.node()) == null || X.appendChild(C.node());
21
+ m.selectAll(".tick").each(function(b, x) {
22
+ var W;
23
+ const C = k.select(this), M = C.select("text"), E = v[x], $ = y - E, F = C.append("g").attr("transform", "translate(10, 0)");
24
+ M.attr("x", $), M.remove(), (W = F.node()) == null || W.appendChild(M.node());
25
25
  });
26
26
  }).attr("font-family", "inherit");
27
- }, An = (i) => {
28
- const { svg: e, config: t, x: n, height: r } = i, { margin: s, xAxis: o } = t, { isShow: l, tickValues: c, tickFormat: d, customTicks: u, ticks: _ } = o;
27
+ }, Cs = (i) => {
28
+ const { svg: e, config: t, x: s, height: r } = i, { margin: n, xAxis: o } = t, { isShow: l, tickValues: h, tickFormat: d, customTicks: u, ticks: _ } = o;
29
29
  if (!l) return null;
30
- e.append("g").attr("transform", `translate(0,${r - s.bottom})`).call((g) => {
31
- let p = k.axisBottom(n);
32
- u ? (d && (p = p.tickFormat(d)), _ && (p = Array.isArray(_) ? p.ticks(..._) : p.ticks(_)), c && (p = p.tickValues(c))) : p.ticks(5), g.call(p);
33
- }).call((g) => g.select(".domain").remove()).call((g) => {
30
+ e.append("g").attr("transform", `translate(0,${r - n.bottom})`).call((m) => {
31
+ let p = k.axisBottom(s);
32
+ u ? (d && (p = p.tickFormat(d)), _ && (p = Array.isArray(_) ? p.ticks(..._) : p.ticks(_)), h && (p = p.tickValues(h))) : p.ticks(5), m.call(p);
33
+ }).call((m) => m.select(".domain").remove()).call((m) => {
34
34
  let p = [];
35
- g.selectAll(".tick").each((v) => p.push(v)), i.xTicks = p;
36
- }).call((g) => g.selectAll(".tick line").remove()).call((g) => g.selectAll(".tick text").classed("sc-charts__x-axis-tick", !0)).attr("font-family", "inherit");
37
- }, Sn = (i) => {
38
- const { svg: e, config: t, y: n, width: r } = i, {
39
- margin: s,
35
+ m.selectAll(".tick").each((v) => p.push(v)), i.xTicks = p;
36
+ }).call((m) => m.selectAll(".tick line").remove()).call((m) => m.selectAll(".tick text").classed("sc-charts__x-axis-tick", !0)).attr("font-family", "inherit");
37
+ }, As = (i) => {
38
+ const { svg: e, config: t, y: s, width: r } = i, {
39
+ margin: n,
40
40
  grid: { horizontalStyle: o }
41
41
  } = t;
42
42
  if (o !== "none") {
43
43
  if (o.startsWith("zero-line")) {
44
- const l = e.append("line").attr("x1", 0 + s.left).attr("x2", r - s.right).attr("y1", n(0)).attr("y2", n(0)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
44
+ const l = e.append("line").attr("x1", 0 + n.left).attr("x2", r - n.right).attr("y1", s(0)).attr("y2", s(0)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
45
45
  o === "zero-line-dashed" && l.attr("stroke-dasharray", "4 4");
46
46
  }
47
- o.startsWith("every-line") && (i.yTicks || n.ticks()).forEach((c) => {
48
- const d = e.append("line").attr("x1", 0 + s.left).attr("x2", r - s.right).attr("y1", n(c)).attr("y2", n(c)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
47
+ o.startsWith("every-line") && (i.yTicks || s.ticks()).forEach((h) => {
48
+ const d = e.append("line").attr("x1", 0 + n.left).attr("x2", r - n.right).attr("y1", s(h)).attr("y2", s(h)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
49
49
  o === "every-line-dashed" && d.attr("stroke-dasharray", "4 4");
50
50
  });
51
51
  }
52
- }, kn = (i) => {
52
+ }, Ss = (i) => {
53
53
  const e = Array.from(i.childNodes);
54
54
  for (let t = 0; t < e.length; t++)
55
55
  i.removeChild(e[t]);
56
- }, En = (i) => {
56
+ }, ks = (i) => {
57
57
  const e = "http://www.w3.org/2000/svg", t = document.createElement("div");
58
58
  t.className = "sc-charts__hovered-circles-tooltip-container", t.style.display = "none";
59
- const n = document.createElement("div");
60
- n.className = "sc-charts__hovered-circles-tooltip";
59
+ const s = document.createElement("div");
60
+ s.className = "sc-charts__hovered-circles-tooltip";
61
61
  const r = document.createElement("div");
62
62
  r.className = "sc-charts__hovered-circles-tooltip-arrow";
63
- const s = document.createElementNS(e, "svg");
64
- s.setAttribute("width", "12"), s.setAttribute("height", "4"), s.setAttribute("viewBox", "0 0 12 4"), s.setAttribute("fill", "none"), s.setAttribute("xmlns", e);
63
+ const n = document.createElementNS(e, "svg");
64
+ n.setAttribute("width", "12"), n.setAttribute("height", "4"), n.setAttribute("viewBox", "0 0 12 4"), n.setAttribute("fill", "none"), n.setAttribute("xmlns", e);
65
65
  const o = document.createElementNS(e, "path");
66
- return o.setAttribute("d", "M6 4L0 0H12L6 4Z"), s.appendChild(o), r.appendChild(s), t.append(r), t.append(n), i.append(t), {
66
+ return o.setAttribute("d", "M6 4L0 0H12L6 4Z"), n.appendChild(o), r.appendChild(n), t.append(r), t.append(s), i.append(t), {
67
67
  tooltipContainer: t,
68
- tooltip: n,
68
+ tooltip: s,
69
69
  tooltipArrow: r
70
70
  };
71
- }, Dn = (i, e, {
71
+ }, Es = (i, e, {
72
72
  x: t,
73
- y: n,
73
+ y: s,
74
74
  r = 3.5,
75
- hr: s = 0
75
+ hr: n = 0
76
76
  }) => {
77
77
  if (e)
78
- return i.append("image").attr("x", t - 6).attr("y", n - 6).attr("width", 12).attr("height", 12).attr(
78
+ return i.append("image").attr("x", t - 6).attr("y", s - 6).attr("width", 12).attr("height", 12).attr(
79
79
  "href",
80
80
  "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTMiIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgMCAxMyAxMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzE0NTJfNTAwOSkiPgo8cGF0aCBkPSJNNi41MzY0NiAxMS41Njg4QzkuMjA1ODYgMTEuNTY4OCAxMS4zNjk4IDkuNDA0ODMgMTEuMzY5OCA2LjczNTQzQzExLjM2OTggNC4wNjYwNiA5LjIwNTg2IDEuOTAyMSA2LjUzNjQ2IDEuOTAyMUMzLjg2NzA4IDEuOTAyMSAxLjcwMzEyIDQuMDY2MDYgMS43MDMxMiA2LjczNTQzQzEuNzAzMTIgOS40MDQ4MyAzLjg2NzA4IDExLjU2ODggNi41MzY0NiAxMS41Njg4WiIgZmlsbD0iI0ZDRUJFOSIvPgo8cGF0aCBkPSJNMy4xMTcxOSAxMC4xNTM1TDkuOTQ3MTkgMy4zMjM0OSIgc3Ryb2tlPSIjRjE4MTY5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPHBhdGggZD0iTTYuNTM2NDYgMTEuNTY4OEM5LjIwNTg2IDExLjU2ODggMTEuMzY5OCA5LjQwNDgzIDExLjM2OTggNi43MzU0M0MxMS4zNjk4IDQuMDY2MDYgOS4yMDU4NiAxLjkwMjEgNi41MzY0NiAxLjkwMjFDMy44NjcwOSAxLjkwMjEgMS43MDMxMiA0LjA2NjA2IDEuNzAzMTIgNi43MzU0M0MxLjcwMzEyIDkuNDA0ODMgMy44NjcwOSAxMS41Njg4IDYuNTM2NDYgMTEuNTY4OFoiIHN0cm9rZT0iI0YxODE2OSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+CjwvZz4KPGRlZnM+CjxjbGlwUGF0aCBpZD0iY2xpcDBfMTQ1Ml81MDA5Ij4KPHJlY3Qgd2lkdGg9IjEyIiBoZWlnaHQ9IjEyIiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMC41MzUxNTYgMC43MzUzNTIpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg=="
81
81
  );
82
82
  {
83
83
  const o = i.append("g");
84
- return o.append("circle").attr("cx", t).attr("cy", n).attr("r", r).classed("sc-charts__hovered-circles", !0), o.append("circle").attr("cx", t).attr("cy", n).attr("r", r + s).classed("sc-charts__hovered-circles_add", !0), o;
84
+ return o.append("circle").attr("cx", t).attr("cy", s).attr("r", r).classed("sc-charts__hovered-circles", !0), o.append("circle").attr("cx", t).attr("cy", s).attr("r", r + n).classed("sc-charts__hovered-circles_add", !0), o;
85
85
  }
86
86
  };
87
- function Nn(i, e, t, n) {
87
+ function Ds(i, e, t, s) {
88
88
  if (!i) return null;
89
- const r = i.width / 2, s = e - r, o = e + r;
90
- return s < t ? t : o > n ? n - i.width : e - r;
89
+ const r = i.width / 2, n = e - r, o = e + r;
90
+ return n < t ? t : o > s ? s - i.width : e - r;
91
91
  }
92
- const bt = (i, { x1: e, x2: t, y1: n, y2: r }) => i.append("line").attr("x1", e).attr("x2", t).attr("y1", n).attr("y2", r).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1), Ln = (i) => {
93
- const { svg: e, config: t, x: n, y: r, height: s, data: o, wrapperNode: l } = i, {
94
- margin: c,
95
- grid: { verticalStyle: d, tooltipNode: u, hoverCirclesRadius: _, hoverCirclesAdditionalArea: g }
92
+ const yt = (i, { x1: e, x2: t, y1: s, y2: r }) => i.append("line").attr("x1", e).attr("x2", t).attr("y1", s).attr("y2", r).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1), Ls = (i) => {
93
+ const { svg: e, config: t, x: s, y: r, height: n, data: o, wrapperNode: l } = i, {
94
+ margin: h,
95
+ grid: { verticalStyle: d, tooltipNode: u, hoverCirclesRadius: _, hoverCirclesAdditionalArea: m }
96
96
  } = t;
97
- if (d !== "none" && (d.startsWith("every-line") && (i.xTicks || n.ticks()).forEach((v) => {
98
- const y = e.append("line").attr("x1", n(v)).attr("x2", n(v)).attr("y1", c.top).attr("y2", s - c.bottom).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
97
+ if (d !== "none" && (d.startsWith("every-line") && (i.xTicks || s.ticks()).forEach((v) => {
98
+ const y = e.append("line").attr("x1", s(v)).attr("x2", s(v)).attr("y1", h.top).attr("y2", n - h.bottom).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-width", 1);
99
99
  d === "every-line-dashed" && y.attr("stroke-dasharray", "4 4");
100
100
  }), d === "hovered-circles")) {
101
- const p = r.range()[0], v = n(o[0].date), y = n(o[o.length - 1].date);
102
- bt(e, { x1: v, x2: y, y1: p, y2: p });
103
- const { tooltipContainer: b, tooltip: w, tooltipArrow: T } = En(l);
104
- o.forEach((C, N) => {
105
- const W = n(C.date), B = r(C.value), X = o[N - 1], U = N > 0 && X && C.value === X.value;
106
- U || bt(e, { x1: W, x2: W, y1: B, y2: p });
107
- const Ee = Dn(e, U, {
108
- x: W,
101
+ const p = r.range()[0], v = s(o[0].date), y = s(o[o.length - 1].date);
102
+ yt(e, { x1: v, x2: y, y1: p, y2: p });
103
+ const { tooltipContainer: b, tooltip: x, tooltipArrow: C } = ks(l);
104
+ o.forEach((M, E) => {
105
+ const $ = s(M.date), F = r(M.value), W = o[E - 1], Z = E > 0 && W && M.value === W.value;
106
+ Z || yt(e, { x1: $, x2: $, y1: F, y2: p });
107
+ const ke = Es(e, Z, {
108
+ x: $,
109
109
  y: p,
110
110
  r: _,
111
- hr: g
111
+ hr: m
112
112
  });
113
- u && Ee.on("mouseover", function() {
114
- kn(w), b.style.display = "block", w.append(u({ date: C.date, value: U ? null : C.value }));
115
- const De = w.getBoundingClientRect(), Ne = Nn(
116
- De,
117
- n(C.date),
113
+ u && ke.on("mouseover", function() {
114
+ Ss(x), b.style.display = "block", x.append(u({ date: M.date, value: Z ? null : M.value }));
115
+ const Ee = x.getBoundingClientRect(), De = Ds(
116
+ Ee,
117
+ s(M.date),
118
118
  i.config.margin.left - i.config.grid.tooltipArrowSize,
119
119
  i.width - i.config.margin.right + i.config.grid.tooltipArrowSize
120
120
  );
121
- w.style.left = Ne + "px", T.style.left = n(C.date) + "px";
121
+ x.style.left = De + "px", C.style.left = s(M.date) + "px";
122
122
  }).on("mouseout", function() {
123
123
  b.style.display = "none";
124
124
  });
125
125
  });
126
126
  }
127
- }, In = (i) => {
128
- Sn(i), Ln(i);
129
- }, Fn = (i) => {
130
- const { svg: e, config: t, width: n, height: r } = i, { margin: s, logo: o } = t;
131
- An(i), Tn(i), o && e.append("image").attr("xlink:href", t.theme === "dark" ? o.picDarkTheme : o.picLightTheme).attr("width", o.width).attr("height", o.height).attr("x", o.x ?? (n - s.left - s.right) / 2 - o.width / 2 + s.left).attr("y", o.y ?? (r - s.top - s.bottom) / 2 - o.height / 2 + s.top), In(i);
127
+ }, Ns = (i) => {
128
+ As(i), Ls(i);
129
+ }, Hs = (i) => {
130
+ const { svg: e, config: t, width: s, height: r } = i, { margin: n, logo: o } = t;
131
+ Cs(i), Ts(i), o && e.append("image").attr("xlink:href", t.theme === "dark" ? o.picDarkTheme : o.picLightTheme).attr("width", o.width).attr("height", o.height).attr("x", o.x ?? (s - n.left - n.right) / 2 - o.width / 2 + n.left).attr("y", o.y ?? (r - n.top - n.bottom) / 2 - o.height / 2 + n.top), Ns(i);
132
132
  }, de = (i, e, t) => {
133
- let n = i.select(`#${e}`);
134
- return n.empty() && (n = i.append("linearGradient").attr("gradientUnits", "userSpaceOnUse").attr("id", e)), n.attr("x1", t.x1).attr("y1", t.x2).attr("x2", t.y1).attr("y2", t.y2), t.stops.forEach(({ offset: r, stopColor: s }) => {
135
- n.append("stop").attr("offset", r).attr("stop-color", s);
136
- }), n;
133
+ let s = i.select(`#${e}`);
134
+ return s.empty() && (s = i.append("linearGradient").attr("gradientUnits", "userSpaceOnUse").attr("id", e)), s.attr("x1", t.x1).attr("y1", t.x2).attr("x2", t.y1).attr("y2", t.y2), t.stops.forEach(({ offset: r, stopColor: n }) => {
135
+ s.append("stop").attr("offset", r).attr("stop-color", n);
136
+ }), s;
137
137
  }, ie = (i) => {
138
138
  const e = k.select(i).select("defs");
139
139
  return e.empty() ? k.select(i).append("defs") : e;
140
- }, Ht = (i) => {
140
+ }, Pt = (i) => {
141
141
  const {
142
142
  y: e,
143
143
  config: { margin: t }
144
- } = i, n = e.range()[0] - e(0), r = e.range()[0] - n >= 0 ? e.range()[0] - n : 0, s = n + t.bottom >= 0 ? n + t.bottom : 0;
145
- return { x: 0, y: r, width: "100%", height: s };
146
- }, xt = (i, e) => ({
144
+ } = i, s = e.range()[0] - e(0), r = e.range()[0] - s >= 0 ? e.range()[0] - s : 0, n = s + t.bottom >= 0 ? s + t.bottom : 0;
145
+ return { x: 0, y: r, width: "100%", height: n };
146
+ }, bt = (i, e) => ({
147
147
  ...i,
148
148
  ...e,
149
149
  margin: {
@@ -178,151 +178,151 @@ const bt = (i, { x1: e, x2: t, y1: n, y2: r }) => i.append("line").attr("x1", e)
178
178
  ...i.selection,
179
179
  ...e == null ? void 0 : e.selection
180
180
  }
181
- }), wt = (i, e = {}) => {
182
- const t = i.node(), n = ie(t), r = (l, c) => de(n, l, {
181
+ }), xt = (i, e = {}) => {
182
+ const t = i.node(), s = ie(t), r = (l, h) => de(s, l, {
183
183
  x1: "0%",
184
184
  y1: "0%",
185
185
  x2: "0%",
186
186
  y2: "100%",
187
187
  stops: [
188
188
  { offset: "0%", stopColor: "rgba(255, 255, 255, 0)" },
189
- { offset: "20%", stopColor: c },
190
- { offset: "60%", stopColor: c },
189
+ { offset: "20%", stopColor: h },
190
+ { offset: "60%", stopColor: h },
191
191
  { offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
192
192
  ]
193
193
  });
194
194
  r("gradient-range-borders-up", "var(--sc-color-selection-up)"), r("gradient-range-borders-down", "var(--sc-color-selection-down)");
195
- const s = "sc-charts__border-range-line", o = i.append("line").classed(s, !0).style("display", e.hidden ? "none" : "block");
195
+ const n = "sc-charts__border-range-line", o = i.append("line").classed(n, !0).style("display", e.hidden ? "none" : "block");
196
196
  return {
197
- className(l, c) {
198
- l === "remove" ? o.classed(`${s}${c}`, !1) : o.classed(`${s}${c}`, !0);
197
+ className(l, h) {
198
+ l === "remove" ? o.classed(`${n}${h}`, !1) : o.classed(`${n}${h}`, !0);
199
199
  },
200
- update({ x1: l, x2: c, y1: d, y2: u, hidden: _ }) {
201
- l !== void 0 && o.attr("x1", l), c !== void 0 && o.attr("x2", c), d !== void 0 && o.attr("y1", d), u !== void 0 && o.attr("y2", u), _ !== void 0 && o.style("display", _ ? "none" : "block");
200
+ update({ x1: l, x2: h, y1: d, y2: u, hidden: _ }) {
201
+ l !== void 0 && o.attr("x1", l), h !== void 0 && o.attr("x2", h), d !== void 0 && o.attr("y1", d), u !== void 0 && o.attr("y2", u), _ !== void 0 && o.style("display", _ ? "none" : "block");
202
202
  },
203
203
  destroy() {
204
204
  o.remove();
205
205
  }
206
206
  };
207
- }, We = (i, e = {}) => {
208
- const t = i.append("circle").attr("r", e.radius || 4).style("display", e.hidden ? "none" : "block"), n = e.className || "";
209
- return n && t.classed(n, !0), {
210
- className(r, s) {
211
- r === "remove" ? t.classed(`${n}${s}`, !1) : t.classed(`${n}${s}`, !0);
207
+ }, je = (i, e = {}) => {
208
+ const t = i.append("circle").attr("r", e.radius || 4).style("display", e.hidden ? "none" : "block"), s = e.className || "";
209
+ return s && t.classed(s, !0), {
210
+ className(r, n) {
211
+ r === "remove" ? t.classed(`${s}${n}`, !1) : t.classed(`${s}${n}`, !0);
212
212
  },
213
- update({ cx: r, cy: s, hidden: o, fill: l }) {
214
- r !== void 0 && t.attr("cx", r), s !== void 0 && t.attr("cy", s), l !== void 0 && t.attr("fill", l), o !== void 0 && t.style("display", o ? "none" : "block");
213
+ update({ cx: r, cy: n, hidden: o, fill: l }) {
214
+ r !== void 0 && t.attr("cx", r), n !== void 0 && t.attr("cy", n), l !== void 0 && t.attr("fill", l), o !== void 0 && t.style("display", o ? "none" : "block");
215
215
  },
216
216
  destroy() {
217
217
  t.remove();
218
218
  }
219
219
  };
220
- }, Rn = (i, e = {}) => {
221
- const t = "sc-charts__hover-line", n = i.append("line").style("display", e.hidden ? "none" : "block").classed(t, !0), r = i.node(), s = ie(r);
222
- return ((l, c) => de(s, l, {
220
+ }, Is = (i, e = {}) => {
221
+ const t = "sc-charts__hover-line", s = i.append("line").style("display", e.hidden ? "none" : "block").classed(t, !0), r = i.node(), n = ie(r);
222
+ return ((l, h) => de(n, l, {
223
223
  x1: "0%",
224
224
  y1: "0%",
225
225
  x2: "0%",
226
226
  y2: "100%",
227
227
  stops: [
228
228
  { offset: "0%", stopColor: "rgba(255, 255, 255, 0)" },
229
- { offset: "15%", stopColor: c },
230
- { offset: "75%", stopColor: c },
229
+ { offset: "15%", stopColor: h },
230
+ { offset: "75%", stopColor: h },
231
231
  { offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
232
232
  ]
233
233
  }))("hover-line-gradient", "var(--sc-color-hover-line)"), {
234
- className(l, c) {
235
- l === "remove" ? n.classed(`${t}${c}`, !1) : n.classed(`${t}${c}`, !0);
234
+ className(l, h) {
235
+ l === "remove" ? s.classed(`${t}${h}`, !1) : s.classed(`${t}${h}`, !0);
236
236
  },
237
- update({ x1: l, x2: c, y1: d, y2: u, hidden: _ }) {
238
- l !== void 0 && n.attr("x1", l), c !== void 0 && n.attr("x2", c), d !== void 0 && n.attr("y1", d), u !== void 0 && n.attr("y2", u), _ !== void 0 && n.style("display", _ ? "none" : "block");
237
+ update({ x1: l, x2: h, y1: d, y2: u, hidden: _ }) {
238
+ l !== void 0 && s.attr("x1", l), h !== void 0 && s.attr("x2", h), d !== void 0 && s.attr("y1", d), u !== void 0 && s.attr("y2", u), _ !== void 0 && s.style("display", _ ? "none" : "block");
239
239
  },
240
240
  destroy() {
241
- n.remove();
241
+ s.remove();
242
242
  }
243
243
  };
244
- }, K = "sc-charts__range-tooltip", Mt = k.timeFormat("%b %e, %I:%M %p"), zn = (i) => {
244
+ }, K = "sc-charts__range-tooltip", wt = k.timeFormat("%b %e, %I:%M %p"), Rs = (i) => {
245
245
  const e = k.format(",.2f");
246
246
  return `${i < 0 ? "-" : ""}$${e(Math.abs(i))}`;
247
247
  };
248
- function $n(i) {
248
+ function Fs(i) {
249
249
  const e = "http://www.w3.org/2000/svg", t = document.createElement("div");
250
250
  t.className = K, t.style.position = "absolute", t.style.top = "0", t.style.pointerEvents = "none", t.style.display = "none", i.append(t);
251
- const n = document.createElement("div");
252
- n.className = `${K}-container`, t.append(n);
253
- const r = document.createElement("div");
254
- r.className = `${K}-sum`, n.append(r);
255
251
  const s = document.createElement("div");
256
- s.className = `${K}-sum-icon`;
252
+ s.className = `${K}-container`, t.append(s);
253
+ const r = document.createElement("div");
254
+ r.className = `${K}-sum`, s.append(r);
255
+ const n = document.createElement("div");
256
+ n.className = `${K}-sum-icon`;
257
257
  const o = document.createElementNS(e, "svg");
258
258
  o.setAttribute("width", "14"), o.setAttribute("height", "14"), o.setAttribute("viewBox", "0 0 14 14"), o.setAttribute("fill", "none"), o.setAttribute("xmlns", e);
259
259
  const l = document.createElementNS(e, "path");
260
260
  l.setAttribute(
261
261
  "d",
262
262
  "M7 0.5C5.71442 0.5 4.45772 0.881218 3.3888 1.59545C2.31988 2.30968 1.48676 3.32484 0.994786 4.51256C0.502816 5.70028 0.374095 7.00721 0.624899 8.26809C0.875703 9.52896 1.49477 10.6872 2.40381 11.5962C3.31285 12.5052 4.47104 13.1243 5.73192 13.3751C6.99279 13.6259 8.29973 13.4972 9.48744 13.0052C10.6752 12.5132 11.6903 11.6801 12.4046 10.6112C13.1188 9.54229 13.5 8.28558 13.5 7C13.4982 5.27665 12.8128 3.62441 11.5942 2.40582C10.3756 1.18722 8.72335 0.50182 7 0.5ZM9.35375 6.85375C9.30732 6.90024 9.25217 6.93712 9.19147 6.96228C9.13077 6.98744 9.06571 7.00039 9 7.00039C8.93429 7.00039 8.86923 6.98744 8.80853 6.96228C8.74783 6.93712 8.69269 6.90024 8.64625 6.85375L7.5 5.70687V9.5C7.5 9.63261 7.44732 9.75979 7.35356 9.85355C7.25979 9.94732 7.13261 10 7 10C6.86739 10 6.74022 9.94732 6.64645 9.85355C6.55268 9.75979 6.5 9.63261 6.5 9.5V5.70687L5.35375 6.85375C5.25993 6.94757 5.13268 7.00028 5 7.00028C4.86732 7.00028 4.74007 6.94757 4.64625 6.85375C4.55243 6.75993 4.49972 6.63268 4.49972 6.5C4.49972 6.36732 4.55243 6.24007 4.64625 6.14625L6.64625 4.14625C6.69269 4.09976 6.74783 4.06288 6.80853 4.03772C6.86923 4.01256 6.9343 3.99961 7 3.99961C7.06571 3.99961 7.13077 4.01256 7.19147 4.03772C7.25217 4.06288 7.30732 4.09976 7.35375 4.14625L9.35375 6.14625C9.40024 6.19269 9.43712 6.24783 9.46228 6.30853C9.48744 6.36923 9.5004 6.43429 9.5004 6.5C9.5004 6.56571 9.48744 6.63077 9.46228 6.69147C9.43712 6.75217 9.40024 6.80731 9.35375 6.85375Z"
263
- ), l.setAttribute("fill", "currentColor"), o.appendChild(l), s.appendChild(o), r.append(s);
264
- const c = document.createElement("div");
265
- r.append(c);
263
+ ), l.setAttribute("fill", "currentColor"), o.appendChild(l), n.appendChild(o), r.append(n);
264
+ const h = document.createElement("div");
265
+ r.append(h);
266
266
  const d = document.createElement("div");
267
- return d.className = `${K}-time`, n.append(d), { wrapper: t, sumNode: c, timeNode: d };
267
+ return d.className = `${K}-time`, s.append(d), { wrapper: t, sumNode: h, timeNode: d };
268
268
  }
269
- const Bn = (i) => {
270
- const { wrapper: e, sumNode: t, timeNode: n } = $n(i.wrapperNode);
269
+ const zs = (i) => {
270
+ const { wrapper: e, sumNode: t, timeNode: s } = Fs(i.wrapperNode);
271
271
  return {
272
- className(r, s) {
273
- r === "remove" ? e.classList.remove(`${K}${s}`) : e.classList.add(`${K}${s}`);
272
+ className(r, n) {
273
+ r === "remove" ? e.classList.remove(`${K}${n}`) : e.classList.add(`${K}${n}`);
274
274
  },
275
- update({ leftPoint: r, rightPoint: s, x: o, y: l, hidden: c, closest: d }) {
276
- if (r && s && d && o !== void 0) {
277
- const u = s.value - r.value, { sumFormatter: _, timeFormatter: g } = i.config.selection, p = (i.x(s.date) + i.x(r.date)) / 2, v = i.x(d.date) < p ? "left" : "right";
275
+ update({ leftPoint: r, rightPoint: n, x: o, y: l, hidden: h, closest: d }) {
276
+ if (r && n && d && o !== void 0) {
277
+ const u = n.value - r.value, { sumFormatter: _, timeFormatter: m } = i.config.selection, p = (i.x(n.date) + i.x(r.date)) / 2, v = i.x(d.date) < p ? "left" : "right";
278
278
  let y = "", b = "";
279
279
  if (_)
280
- y = _({ left: r.value, right: s.value, direction: v });
280
+ y = _({ left: r.value, right: n.value, direction: v });
281
281
  else {
282
- const w = (u / Math.abs(r.value) * 100).toFixed(2);
283
- y = `${zn(u)} (${w}%)`;
282
+ const x = (u / Math.abs(r.value) * 100).toFixed(2);
283
+ y = `${Rs(u)} (${x}%)`;
284
284
  }
285
- g ? b = g({ left: r.date, right: s.date, direction: v }) : b = `${Mt(r.date)} to ${Mt(s.date)}`, t.textContent = y, n.textContent = b, requestAnimationFrame(() => {
286
- const w = e.getBoundingClientRect(), T = i.wrapperNode.getBoundingClientRect(), C = i.x(r.date), N = i.x(s.date);
287
- let B = (C + N) / 2 - w.width / 2;
288
- const X = 0, U = T.width - w.width;
289
- B < X && (B = X), B > U && (B = U), e.style.left = `${B}px`, e.style.top = `${l}px`;
285
+ m ? b = m({ left: r.date, right: n.date, direction: v }) : b = `${wt(r.date)} to ${wt(n.date)}`, t.textContent = y, s.textContent = b, requestAnimationFrame(() => {
286
+ const x = e.getBoundingClientRect(), C = i.wrapperNode.getBoundingClientRect(), M = i.x(r.date), E = i.x(n.date);
287
+ let F = (M + E) / 2 - x.width / 2;
288
+ const W = 0, Z = C.width - x.width;
289
+ F < W && (F = W), F > Z && (F = Z), e.style.left = `${F}px`, e.style.top = `${l}px`;
290
290
  });
291
291
  }
292
- c !== void 0 && (e.style.display = c ? "none" : "block");
292
+ h !== void 0 && (e.style.display = h ? "none" : "block");
293
293
  },
294
294
  destroy() {
295
295
  e.remove();
296
296
  }
297
297
  };
298
- }, he = "sc-charts__hover-tooltip", Xe = 16, On = k.timeFormat("%a, %b %d, %-I:%M %p"), Pn = (i) => {
298
+ }, he = "sc-charts__hover-tooltip", Xe = 16, Bs = k.timeFormat("%a, %b %d, %-I:%M %p"), $s = (i) => {
299
299
  const e = k.format(",.2f");
300
300
  return `${i < 0 ? "-" : ""}$${e(Math.abs(i))}`;
301
301
  };
302
- function Hn(i) {
302
+ function Ps(i) {
303
303
  const e = document.createElement("div");
304
304
  e.className = `${he}-container`, e.style.position = "absolute", e.style.top = "0", e.style.pointerEvents = "none", e.style.display = "none", i.appendChild(e);
305
305
  const t = document.createElement("div");
306
306
  t.className = `${he}-sum`, e.appendChild(t);
307
- const n = document.createElement("div");
308
- return n.className = `${he}-time`, e.appendChild(n), { wrapper: e, sumNode: t, timeNode: n };
307
+ const s = document.createElement("div");
308
+ return s.className = `${he}-time`, e.appendChild(s), { wrapper: e, sumNode: t, timeNode: s };
309
309
  }
310
- function jn(i, e, t) {
310
+ function Os(i, e, t) {
311
311
  return i ? e + Xe + i.width < t ? e + Xe : e - Xe - i.width : null;
312
312
  }
313
- const Yn = (i) => {
314
- const { wrapper: e, sumNode: t, timeNode: n } = Hn(i.wrapperNode);
313
+ const Ys = (i) => {
314
+ const { wrapper: e, sumNode: t, timeNode: s } = Ps(i.wrapperNode);
315
315
  return {
316
- className(r, s) {
317
- r === "remove" ? e.classList.remove(`${he}${s}`) : e.classList.add(`${he}${s}`);
316
+ className(r, n) {
317
+ r === "remove" ? e.classList.remove(`${he}${n}`) : e.classList.add(`${he}${n}`);
318
318
  },
319
- update({ hidden: r, dataItem: s }) {
320
- if (s) {
319
+ update({ hidden: r, dataItem: n }) {
320
+ if (n) {
321
321
  const { sumFormatter: o, timeFormatter: l } = i.config.hover;
322
- t.textContent = o ? o(s.value) : Pn(s.value), n.textContent = l ? l(s.date) : On(s.date), requestAnimationFrame(() => {
323
- const c = e.getBoundingClientRect(), d = jn(
324
- c,
325
- i.x(s.date),
322
+ t.textContent = o ? o(n.value) : $s(n.value), s.textContent = l ? l(n.date) : Bs(n.date), requestAnimationFrame(() => {
323
+ const h = e.getBoundingClientRect(), d = Os(
324
+ h,
325
+ i.x(n.date),
326
326
  i.width - i.config.margin.right
327
327
  );
328
328
  d && (e.style.left = d + "px");
@@ -334,7 +334,7 @@ const Yn = (i) => {
334
334
  e.remove();
335
335
  }
336
336
  };
337
- }, Wn = {
337
+ }, js = {
338
338
  margin: { top: 10, right: 30, bottom: 20, left: 10 },
339
339
  theme: "light",
340
340
  logo: {
@@ -385,8 +385,8 @@ const Yn = (i) => {
385
385
  },
386
386
  enableBelowZeroLine: !1,
387
387
  curveTension: 1
388
- }, Se = (i) => k.curveCardinal.tension(i.config.curveTension), Xn = (i) => {
389
- const { svg: e, data: t, x: n, y: r, config: s } = i, o = e.node(), l = ie(o);
388
+ }, Ae = (i) => k.curveCardinal.tension(i.config.curveTension), Xs = (i) => {
389
+ const { svg: e, data: t, x: s, y: r, config: n } = i, o = e.node(), l = ie(o);
390
390
  de(l, "main-line-area-gradient", {
391
391
  x1: "0%",
392
392
  y1: "0%",
@@ -397,14 +397,14 @@ const Yn = (i) => {
397
397
  { offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
398
398
  ]
399
399
  });
400
- const d = k.area().x((g) => n(g.date)).y0(r.range()[0]).y1((g) => r(g.value)).curve(Se(i)), u = "sc-charts__main-line-area", _ = e.append("path").datum(t).attr("d", d).attr("class", u).classed(`${u}_hidden`, !s.hasMainLineArea);
400
+ const d = k.area().x((m) => s(m.date)).y0(r.range()[0]).y1((m) => r(m.value)).curve(Ae(i)), u = "sc-charts__main-line-area", _ = e.append("path").datum(t).attr("d", d).attr("class", u).classed(`${u}_hidden`, !n.hasMainLineArea);
401
401
  return {
402
- className(g, p) {
403
- g === "remove" ? _.classed(`${u}${p}`, !1) : _.classed(`${u}${p}`, !0);
402
+ className(m, p) {
403
+ m === "remove" ? _.classed(`${u}${p}`, !1) : _.classed(`${u}${p}`, !0);
404
404
  },
405
- update({ data: g, hidden: p }) {
406
- if (g !== void 0 && _.datum(g).attr("d", d), p !== void 0) {
407
- if (!s.hasMainLineArea) return null;
405
+ update({ data: m, hidden: p }) {
406
+ if (m !== void 0 && _.datum(m).attr("d", d), p !== void 0) {
407
+ if (!n.hasMainLineArea) return null;
408
408
  _.classed(`${u}_hidden`, p);
409
409
  }
410
410
  },
@@ -412,9 +412,9 @@ const Yn = (i) => {
412
412
  _.remove();
413
413
  }
414
414
  };
415
- }, Gn = (i, e = {}) => {
416
- const t = "sc-charts__range-line-area", { svg: n, x: r, y: s, config: o, data: l, chartId: c } = i, { clip: d } = e, u = n.node(), _ = ie(u), g = "range-line-area-gradient";
417
- de(_, g + "_up", {
415
+ }, Ws = (i, e = {}) => {
416
+ const t = "sc-charts__range-line-area", { svg: s, x: r, y: n, config: o, data: l, chartId: h } = i, { clip: d } = e, u = s.node(), _ = ie(u), m = "range-line-area-gradient";
417
+ de(_, m + "_up", {
418
418
  x1: "0%",
419
419
  y1: "0%",
420
420
  x2: "0%",
@@ -423,7 +423,7 @@ const Yn = (i) => {
423
423
  { offset: "0%", stopColor: "var(--sc-color-selection-up)" },
424
424
  { offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
425
425
  ]
426
- }), de(_, g + "_down", {
426
+ }), de(_, m + "_down", {
427
427
  x1: "0%",
428
428
  y1: "0%",
429
429
  x2: "0%",
@@ -433,59 +433,59 @@ const Yn = (i) => {
433
433
  { offset: "100%", stopColor: "rgba(255, 255, 255, 0)" }
434
434
  ]
435
435
  });
436
- const p = k.area().x((T) => r(T.date)).y0(s.range()[0]).y1((T) => s(T.value)).curve(Se(i)), v = `${c}-clip-${t}`, b = _.append("clipPath").attr("id", v).append("rect").attr("x", (d == null ? void 0 : d.x) || 0).attr("y", (d == null ? void 0 : d.y) || 0).attr("width", (d == null ? void 0 : d.width) || "100%").attr("height", (d == null ? void 0 : d.height) || "100%"), w = n.append("path").datum(l).attr("d", p).attr("class", t).classed(`${t}_hidden`, !o.hasMainLineArea).attr("clip-path", `url(#${v})`);
436
+ const p = k.area().x((C) => r(C.date)).y0(n.range()[0]).y1((C) => n(C.value)).curve(Ae(i)), v = `${h}-clip-${t}`, b = _.append("clipPath").attr("id", v).append("rect").attr("x", (d == null ? void 0 : d.x) || 0).attr("y", (d == null ? void 0 : d.y) || 0).attr("width", (d == null ? void 0 : d.width) || "100%").attr("height", (d == null ? void 0 : d.height) || "100%"), x = s.append("path").datum(l).attr("d", p).attr("class", t).classed(`${t}_hidden`, !o.hasMainLineArea).attr("clip-path", `url(#${v})`);
437
437
  return {
438
- className(T, C) {
439
- T === "remove" ? w.classed(`${t}${C}`, !1) : w.classed(`${t}${C}`, !0);
438
+ className(C, M) {
439
+ C === "remove" ? x.classed(`${t}${M}`, !1) : x.classed(`${t}${M}`, !0);
440
440
  },
441
- update({ data: T, hidden: C, clip: N }) {
442
- T !== void 0 && w.datum(T).attr("d", p), C !== void 0 && w.classed(`${t}_hidden`, C), N !== void 0 && b.attr("x", N.x).attr("y", N.y).attr("width", N.width).attr("height", N.height);
441
+ update({ data: C, hidden: M, clip: E }) {
442
+ C !== void 0 && x.datum(C).attr("d", p), M !== void 0 && x.classed(`${t}_hidden`, M), E !== void 0 && b.attr("x", E.x).attr("y", E.y).attr("width", E.width).attr("height", E.height);
443
443
  },
444
444
  destroy() {
445
- w.remove();
445
+ x.remove();
446
446
  }
447
447
  };
448
- }, Ge = (i, e) => {
449
- const { svg: t, data: n, x: r, y: s, chartId: o } = i, { baseClassName: l, id: c, clip: d } = e, u = t.node(), _ = ie(u), g = k.line().x((w) => r(w.date)).y((w) => s(w.value)).curve(Se(i)), p = `${o}-clip-${l}`, y = _.append("clipPath").attr("id", p).append("rect").attr("x", (d == null ? void 0 : d.x) || 0).attr("y", (d == null ? void 0 : d.y) || 0).attr("width", (d == null ? void 0 : d.width) || "100%").attr("height", (d == null ? void 0 : d.height) || "100%"), b = t.append("path").classed(l, !0).datum(n).attr("d", g).attr("id", c).attr("clip-path", `url(#${p})`);
448
+ }, We = (i, e) => {
449
+ const { svg: t, data: s, x: r, y: n, chartId: o } = i, { baseClassName: l, id: h, clip: d } = e, u = t.node(), _ = ie(u), m = k.line().x((x) => r(x.date)).y((x) => n(x.value)).curve(Ae(i)), p = `${o}-clip-${l}`, y = _.append("clipPath").attr("id", p).append("rect").attr("x", (d == null ? void 0 : d.x) || 0).attr("y", (d == null ? void 0 : d.y) || 0).attr("width", (d == null ? void 0 : d.width) || "100%").attr("height", (d == null ? void 0 : d.height) || "100%"), b = t.append("path").classed(l, !0).datum(s).attr("d", m).attr("id", h).attr("clip-path", `url(#${p})`);
450
450
  return {
451
- className(w, T) {
452
- w === "remove" ? b.classed(`${l}${T}`, !1) : b.classed(`${l}${T}`, !0);
451
+ className(x, C) {
452
+ x === "remove" ? b.classed(`${l}${C}`, !1) : b.classed(`${l}${C}`, !0);
453
453
  },
454
- update({ data: w, clip: T, hidden: C }) {
455
- w !== void 0 && b.datum(w).attr("d", g), C !== void 0 && b.classed(`${l}_hidden`, C), T !== void 0 && y.attr("x", T.x).attr("y", T.y).attr("width", T.width).attr("height", T.height);
454
+ update({ data: x, clip: C, hidden: M }) {
455
+ x !== void 0 && b.datum(x).attr("d", m), M !== void 0 && b.classed(`${l}_hidden`, M), C !== void 0 && y.attr("x", C.x).attr("y", C.y).attr("width", C.width).attr("height", C.height);
456
456
  },
457
457
  destroy() {
458
458
  b.remove();
459
459
  }
460
460
  };
461
- }, Zn = (i, e) => {
462
- const { svg: t, data: n, x: r, y: s, chartId: o, config: l } = i, { baseClassName: c, id: d, clip: u } = e, _ = t.node(), g = ie(_), p = k.line().x((T) => r(T.date)).y((T) => s(T.value)).curve(Se(i)), v = `${o}-clip-${c}`, b = g.append("clipPath").attr("id", v).append("rect").attr("x", (u == null ? void 0 : u.x) || 0).attr("y", (u == null ? void 0 : u.y) || 0).attr("width", (u == null ? void 0 : u.width) || "100%").attr("height", (u == null ? void 0 : u.height) || "100%"), w = t.append("path").classed(c, !0).datum(n).attr("d", p).attr("id", d).attr("clip-path", `url(#${v})`);
461
+ }, Gs = (i, e) => {
462
+ const { svg: t, data: s, x: r, y: n, chartId: o, config: l } = i, { baseClassName: h, id: d, clip: u } = e, _ = t.node(), m = ie(_), p = k.line().x((C) => r(C.date)).y((C) => n(C.value)).curve(Ae(i)), v = `${o}-clip-${h}`, b = m.append("clipPath").attr("id", v).append("rect").attr("x", (u == null ? void 0 : u.x) || 0).attr("y", (u == null ? void 0 : u.y) || 0).attr("width", (u == null ? void 0 : u.width) || "100%").attr("height", (u == null ? void 0 : u.height) || "100%"), x = t.append("path").classed(h, !0).datum(s).attr("d", p).attr("id", d).attr("clip-path", `url(#${v})`);
463
463
  return {
464
- className(T, C) {
465
- T === "remove" ? w.classed(`${c}${C}`, !1) : w.classed(`${c}${C}`, !0);
464
+ className(C, M) {
465
+ C === "remove" ? x.classed(`${h}${M}`, !1) : x.classed(`${h}${M}`, !0);
466
466
  },
467
- update({ data: T, clip: C, hidden: N }) {
468
- T !== void 0 && w.datum(T).attr("d", p), N !== void 0 && w.classed(`${c}_hidden`, N), C !== void 0 && (l.hover.transitionName === "default" ? b.transition().duration(l.hover.transitionDuration).attr("x", C.x).attr("y", C.y).attr("width", C.width).attr("height", C.height).ease(k.easeLinear) : b.attr("x", C.x).attr("y", C.y).attr("width", C.width).attr("height", C.height));
467
+ update({ data: C, clip: M, hidden: E }) {
468
+ C !== void 0 && x.datum(C).attr("d", p), E !== void 0 && x.classed(`${h}_hidden`, E), M !== void 0 && (l.hover.transitionName === "default" ? b.transition().duration(l.hover.transitionDuration).attr("x", M.x).attr("y", M.y).attr("width", M.width).attr("height", M.height).ease(k.easeLinear) : b.attr("x", M.x).attr("y", M.y).attr("width", M.width).attr("height", M.height));
469
469
  },
470
470
  destroy() {
471
- w.remove();
471
+ x.remove();
472
472
  }
473
473
  };
474
- }, Un = (i) => {
474
+ }, Us = (i) => {
475
475
  const e = Math.abs(i);
476
476
  let t;
477
477
  return e >= 1e9 ? t = (i / 1e9).toFixed(1) + "B" : e >= 1e6 ? t = (i / 1e6).toFixed(1) + "M" : e >= 1e3 ? t = (i / 1e3).toFixed(1) + "K" : t = i.toFixed(1), t;
478
- }, Vn = (i, e) => {
479
- const { svg: t, data: n, x: r, y: s } = i, { baseClassName: o } = e, l = t.append("g").classed(o, !0), c = l.append("circle").attr("r", 5).classed(`${o}-circle`, !0), d = l.append("text").attr("text-anchor", "middle").attr("dy", "-9px").classed(`${o}-label`, !0);
478
+ }, Zs = (i, e) => {
479
+ const { svg: t, data: s, x: r, y: n } = i, { baseClassName: o } = e, l = t.append("g").classed(o, !0), h = l.append("circle").attr("r", 5).classed(`${o}-circle`, !0), d = l.append("text").attr("text-anchor", "middle").attr("dy", "-9px").classed(`${o}-label`, !0);
480
480
  return ((_) => {
481
481
  if (!_ || _.length === 0) return;
482
- const g = _[_.length - 1], p = r(g.date), v = s(g.value);
483
- c.attr("cx", p).attr("cy", v);
484
- const y = i.config.extremePointFormatter || Un;
485
- d.attr("x", p).attr("y", v).text(y(g.value));
486
- })(n), {
487
- className(_, g) {
488
- _ === "remove" ? l.classed(`${o}${g}`, !1) : l.classed(`${o}${g}`, !0);
482
+ const m = _[_.length - 1], p = r(m.date), v = n(m.value);
483
+ h.attr("cx", p).attr("cy", v);
484
+ const y = i.config.extremePointFormatter || Us;
485
+ d.attr("x", p).attr("y", v).text(y(m.value));
486
+ })(s), {
487
+ className(_, m) {
488
+ _ === "remove" ? l.classed(`${o}${m}`, !1) : l.classed(`${o}${m}`, !0);
489
489
  },
490
490
  update({ hidden: _ }) {
491
491
  _ !== void 0 && l.classed(`${o}_hidden`, _);
@@ -494,71 +494,71 @@ const Yn = (i) => {
494
494
  l.remove();
495
495
  }
496
496
  };
497
- }, Jn = (i) => {
498
- const e = Ge(i, {
497
+ }, Vs = (i) => {
498
+ const e = We(i, {
499
499
  baseClassName: "sc-charts__main-line",
500
500
  id: `${i.chartId}-sc-charts__main-line`
501
- }), t = Xn(i);
502
- let n = null;
503
- i.config.hasExtremePoint && (n = Vn(i, {
501
+ }), t = Xs(i);
502
+ let s = null;
503
+ i.config.hasExtremePoint && (s = Zs(i, {
504
504
  baseClassName: "sc-charts__extreme-point"
505
505
  }));
506
- const r = Rn(i.svg), s = Zn(i, {
506
+ const r = Is(i.svg), n = Gs(i, {
507
507
  baseClassName: "sc-charts__highlight-line",
508
508
  id: `${i.chartId}-sc-charts__highlight-line`,
509
509
  clip: { x: 0, y: 0, width: "0", height: "0" }
510
510
  });
511
511
  let o = null;
512
- i.config.enableBelowZeroLine && (o = Ge(i, {
512
+ i.config.enableBelowZeroLine && (o = We(i, {
513
513
  baseClassName: "sc-charts__below-zero-line",
514
514
  id: `${i.chartId}-sc-charts__below-zero-line`,
515
- clip: Ht(i)
515
+ clip: Pt(i)
516
516
  }));
517
- const l = We(i.svg, {
517
+ const l = je(i.svg, {
518
518
  className: "sc-charts__hover-circle",
519
519
  hidden: !0
520
- }), c = wt(i.svg), d = wt(i.svg), u = Ge(i, {
520
+ }), h = xt(i.svg), d = xt(i.svg), u = We(i, {
521
521
  baseClassName: "sc-charts__range-line",
522
522
  id: `${i.chartId}-sc-charts__range-line`,
523
523
  clip: { x: 0, y: 0, width: "0", height: "0" }
524
- }), _ = We(i.svg, {
524
+ }), _ = je(i.svg, {
525
525
  className: "sc-charts__range-circle-left",
526
526
  hidden: !0
527
- }), g = We(i.svg, {
527
+ }), m = je(i.svg, {
528
528
  className: "sc-charts__range-circle-right",
529
529
  hidden: !0
530
- }), p = Bn(i), v = Yn(i), y = Gn(i);
530
+ }), p = zs(i), v = Ys(i), y = Ws(i);
531
531
  return {
532
532
  hoverLine: r,
533
533
  hoverCircle: l,
534
- rangeBorderLeft: c,
534
+ rangeBorderLeft: h,
535
535
  rangeBorderRight: d,
536
536
  rangeLine: u,
537
537
  rangeLineArea: y,
538
538
  rangeCircleLeft: _,
539
- rangeCircleRight: g,
539
+ rangeCircleRight: m,
540
540
  mainLine: e,
541
541
  rangeTooltip: p,
542
- highlightLine: s,
542
+ highlightLine: n,
543
543
  hoverTooltip: v,
544
544
  mainLineArea: t,
545
545
  belowZeroLine: o,
546
- extremePoint: n
546
+ extremePoint: s
547
547
  };
548
- }, Qn = (i, e, t) => {
549
- const n = i.match(/^(\d+)([dMhmw])$/);
550
- if (!n)
548
+ }, Js = (i, e, t) => {
549
+ const s = i.match(/^(\d+)([dMhmw])$/);
550
+ if (!s)
551
551
  return console.warn("Invalid hoverRange:", i), {
552
552
  x: 0,
553
553
  y: 0,
554
554
  width: "100%",
555
555
  height: "100%"
556
556
  };
557
- const [, r, s] = n, o = parseInt(r, 10), [l, c] = t.domain();
557
+ const [, r, n] = s, o = parseInt(r, 10), [l, h] = t.domain();
558
558
  let d = new Date(l);
559
- for (; d < c; ) {
559
+ for (; d < h; ) {
560
560
  let u = new Date(d);
561
- switch (s) {
561
+ switch (n) {
562
562
  case "M":
563
563
  u.setMinutes(u.getMinutes() + o);
564
564
  break;
@@ -583,19 +583,19 @@ const Yn = (i) => {
583
583
  };
584
584
  }
585
585
  if (e >= d && e < u) {
586
- const _ = t(d), g = t(u);
586
+ const _ = t(d), m = t(u);
587
587
  return {
588
588
  x: _,
589
589
  y: 0,
590
- width: g - _,
590
+ width: m - _,
591
591
  height: "100%"
592
592
  };
593
593
  }
594
594
  d = new Date(u);
595
595
  }
596
- if (e.getTime() === c.getTime()) {
597
- let u = new Date(c);
598
- switch (s) {
596
+ if (e.getTime() === h.getTime()) {
597
+ let u = new Date(h);
598
+ switch (n) {
599
599
  case "M":
600
600
  u.setMinutes(u.getMinutes() - o);
601
601
  break;
@@ -609,14 +609,14 @@ const Yn = (i) => {
609
609
  u.setDate(u.getDate() - o * 7);
610
610
  break;
611
611
  case "m":
612
- u = new Date(c.getFullYear(), c.getMonth() - o, 1);
612
+ u = new Date(h.getFullYear(), h.getMonth() - o, 1);
613
613
  break;
614
614
  }
615
- const _ = t(u), g = t(c);
615
+ const _ = t(u), m = t(h);
616
616
  return {
617
617
  x: _,
618
618
  y: 0,
619
- width: g - _,
619
+ width: m - _,
620
620
  height: "100%"
621
621
  };
622
622
  }
@@ -626,49 +626,49 @@ const Yn = (i) => {
626
626
  width: "100%",
627
627
  height: "100%"
628
628
  };
629
- }, Ct = (i, e) => {
629
+ }, Mt = (i, e) => {
630
630
  var d;
631
631
  const {
632
632
  x: t,
633
- y: n,
633
+ y: s,
634
634
  elements: r,
635
- config: { margin: s },
635
+ config: { margin: n },
636
636
  height: o
637
637
  } = i;
638
638
  r.hoverLine.update({
639
639
  x1: t(e.date),
640
640
  x2: t(e.date),
641
- y1: s.top,
642
- y2: o - s.bottom,
641
+ y1: n.top,
642
+ y2: o - n.bottom,
643
643
  hidden: !1
644
644
  }), r.hoverCircle.update({
645
645
  cx: t(e.date),
646
- cy: n(e.value),
646
+ cy: s(e.value),
647
647
  hidden: !1
648
648
  }), r.hoverTooltip.update({
649
649
  dataItem: e,
650
650
  hidden: !1
651
651
  });
652
- const l = Qn(i.config.hover.range, e.date, t);
652
+ const l = Js(i.config.hover.range, e.date, t);
653
653
  r.highlightLine.update({
654
654
  clip: l,
655
655
  hidden: !1
656
656
  });
657
- const c = n.range()[0] - n(0) + s.bottom;
658
- c >= 0 && ((d = r.belowZeroLine) == null || d.update({
657
+ const h = s.range()[0] - s(0) + n.bottom;
658
+ h >= 0 && ((d = r.belowZeroLine) == null || d.update({
659
659
  clip: {
660
660
  ...l,
661
- y: n(0),
662
- height: c
661
+ y: s(0),
662
+ height: h
663
663
  }
664
664
  })), r.mainLine.className("add", "_muted");
665
665
  }, Tt = (i) => {
666
666
  var t;
667
667
  const { elements: e } = i;
668
668
  e.hoverLine.update({ hidden: !0 }), e.hoverCircle.update({ hidden: !0 }), e.highlightLine.update({ hidden: !0 }), e.mainLine.className("remove", "_muted"), e.hoverTooltip.update({ hidden: !0 }), i.action !== "selection" && ((t = e.belowZeroLine) == null || t.update({
669
- clip: Ht(i)
669
+ clip: Pt(i)
670
670
  }));
671
- }, qn = (i, e) => {
671
+ }, Qs = (i, e) => {
672
672
  [
673
673
  "rangeBorderLeft",
674
674
  "rangeBorderRight",
@@ -677,36 +677,36 @@ const Yn = (i) => {
677
677
  "rangeLine",
678
678
  "rangeLineArea",
679
679
  "rangeTooltip"
680
- ].forEach((n) => {
681
- e ? (i[n].className("remove", "_down"), i[n].className("add", "_up")) : (i[n].className("remove", "_up"), i[n].className("add", "_down"));
680
+ ].forEach((s) => {
681
+ e ? (i[s].className("remove", "_down"), i[s].className("add", "_up")) : (i[s].className("remove", "_up"), i[s].className("add", "_down"));
682
682
  });
683
- }, Kn = (i, e, t) => {
683
+ }, qs = (i, e, t) => {
684
684
  var v;
685
685
  const {
686
- x: n,
686
+ x: s,
687
687
  y: r,
688
- config: { margin: s },
688
+ config: { margin: n },
689
689
  height: o,
690
690
  elements: l
691
- } = i, c = n(e.date) < n(t.date) ? e : t, d = n(e.date) >= n(t.date) ? e : t, u = d.value - c.value >= 0, _ = n(c.date), g = n(d.date), p = g - _;
691
+ } = i, h = s(e.date) < s(t.date) ? e : t, d = s(e.date) >= s(t.date) ? e : t, u = d.value - h.value >= 0, _ = s(h.date), m = s(d.date), p = m - _;
692
692
  l.rangeBorderLeft.update({
693
693
  x1: _,
694
694
  x2: _,
695
- y1: s.top,
696
- y2: o - s.bottom,
695
+ y1: n.top,
696
+ y2: o - n.bottom,
697
697
  hidden: !1
698
698
  }), l.rangeBorderRight.update({
699
- x1: g,
700
- x2: g,
701
- y1: s.top,
702
- y2: o - s.bottom,
699
+ x1: m,
700
+ x2: m,
701
+ y1: n.top,
702
+ y2: o - n.bottom,
703
703
  hidden: !1
704
704
  }), l.rangeCircleLeft.update({
705
705
  cx: _,
706
- cy: r(c.value),
706
+ cy: r(h.value),
707
707
  hidden: !1
708
708
  }), l.rangeCircleRight.update({
709
- cx: g,
709
+ cx: m,
710
710
  cy: r(d.value),
711
711
  hidden: !1
712
712
  }), l.rangeLine.update({
@@ -727,498 +727,498 @@ const Yn = (i) => {
727
727
  hidden: !1
728
728
  }), l.rangeTooltip.update({
729
729
  rightPoint: d,
730
- leftPoint: c,
730
+ leftPoint: h,
731
731
  closest: t,
732
732
  x: _ + p / 2,
733
733
  y: 0,
734
734
  hidden: !1
735
735
  }), (v = l.belowZeroLine) == null || v.update({
736
736
  hidden: !0
737
- }), l.mainLineArea.update({ hidden: !0 }), qn(l, u), l.mainLine.className("add", "_selected-muted");
738
- }, At = (i) => {
737
+ }), l.mainLineArea.update({ hidden: !0 }), Qs(l, u), l.mainLine.className("add", "_selected-muted");
738
+ }, Ct = (i) => {
739
739
  var t;
740
740
  const { elements: e } = i;
741
741
  e.rangeLine.update({ hidden: !0 }), e.rangeLineArea.update({ hidden: !0 }), e.rangeBorderLeft.update({ hidden: !0 }), e.rangeBorderRight.update({ hidden: !0 }), e.rangeCircleLeft.update({ hidden: !0 }), e.rangeCircleRight.update({ hidden: !0 }), e.rangeTooltip.update({ hidden: !0 }), e.mainLine.className("remove", "_selected-muted"), e.mainLineArea.update({ hidden: !1 }), (t = e.belowZeroLine) == null || t.update({ hidden: !1 });
742
- }, es = (i) => {
743
- const { svg: e, data: t, x: n, config: r, width: s, height: o } = i, { margin: l, hover: c, selection: d } = r;
742
+ }, Ks = (i) => {
743
+ const { svg: e, data: t, x: s, config: r, width: n, height: o } = i, { margin: l, hover: h, selection: d } = r;
744
744
  let u = null, _ = !1;
745
- const g = (v) => t.reduce(
746
- (y, b) => Math.abs(n(y.date) - v) < Math.abs(n(b.date) - v) ? y : b
745
+ const m = (v) => t.reduce(
746
+ (y, b) => Math.abs(s(y.date) - v) < Math.abs(s(b.date) - v) ? y : b
747
747
  );
748
- e.append("rect").attr("width", s - l.left - l.right).attr("height", o - l.top - l.bottom).attr("x", l.left).attr("y", l.top).attr("fill", "transparent").on("mousemove", function(v) {
749
- const [y] = k.pointer(v, this), b = g(y);
750
- !_ && c.enable ? (i.action = "hover", Ct(i, b)) : (i.action = _ ? "selection" : "none", Tt(i)), u && d.enable && (i.action = "selection", Kn(i, u, b));
748
+ e.append("rect").attr("width", n - l.left - l.right).attr("height", o - l.top - l.bottom).attr("x", l.left).attr("y", l.top).attr("fill", "transparent").on("mousemove", function(v) {
749
+ const [y] = k.pointer(v, this), b = m(y);
750
+ !_ && h.enable ? (i.action = "hover", Mt(i, b)) : (i.action = _ ? "selection" : "none", Tt(i)), u && d.enable && (i.action = "selection", qs(i, u, b));
751
751
  }).on("mouseleave", () => {
752
- i.action = "none", _ = !1, u = null, Tt(i), At(i);
752
+ i.action = "none", _ = !1, u = null, Tt(i), Ct(i);
753
753
  }).on("mousedown", function(v) {
754
754
  if (d.enable) {
755
755
  _ = !0, i.action = "selection";
756
756
  const [y] = k.pointer(v, this);
757
- u = g(y);
757
+ u = m(y);
758
758
  }
759
759
  }).on("mouseup", function(v) {
760
- const [y] = k.pointer(v, this), b = g(y);
761
- _ = !1, u = null, i.action = "hover", d.enable && At(i), c.enable && Ct(i, b);
760
+ const [y] = k.pointer(v, this), b = m(y);
761
+ _ = !1, u = null, i.action = "hover", d.enable && Ct(i), h.enable && Mt(i, b);
762
762
  });
763
- }, ts = (i, e, t) => {
764
- const { margin: n } = e, r = k.scaleTime(), s = k.extent(i, (o) => new Date(o.date));
765
- return s[0] == null || s[1] == null ? r : r.domain([s[0], s[1]]).range([n.left, t - n.right]);
766
- }, is = (i, e, t) => {
767
- const { margin: n } = e, r = k.max(i, (o) => o.value) ?? 0, s = k.min(i, (o) => o.value) ?? 0;
768
- return k.scaleLinear().domain([s, r]).range([t - n.bottom, n.top]);
769
- }, mr = (i, e) => {
763
+ }, en = (i, e, t) => {
764
+ const { margin: s } = e, r = k.scaleTime(), n = k.extent(i, (o) => new Date(o.date));
765
+ return n[0] == null || n[1] == null ? r : r.domain([n[0], n[1]]).range([s.left, t - s.right]);
766
+ }, tn = (i, e, t) => {
767
+ const { margin: s } = e, r = k.max(i, (o) => o.value) ?? 0, n = k.min(i, (o) => o.value) ?? 0;
768
+ return k.scaleLinear().domain([n, r]).range([t - s.bottom, s.top]);
769
+ }, Er = (i, e) => {
770
770
  const t = k.select(i);
771
771
  if (t.empty())
772
772
  return console.error(`Element with selector ${i} not found!`), null;
773
773
  if (!e.chartId || !/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e.chartId))
774
774
  return console.error(`chartId is required and must be a valid id
775
775
  (only letters, numbers or underscores. The first character must be a letter)`), null;
776
- const n = t.append("div"), r = n.append("svg"), s = t.node();
777
- let o = s.getBoundingClientRect(), l = o.width, c = o.height, d = xt({ ...Wn }, e.config), u = e.data;
776
+ const s = t.append("div"), r = s.append("svg"), n = t.node();
777
+ let o = n.getBoundingClientRect(), l = o.width, h = o.height, d = bt({ ...js }, e.config), u = e.data;
778
778
  const _ = () => {
779
- o = s.getBoundingClientRect(), l = o.width, c = o.height, g({ data: u, config: d });
779
+ o = n.getBoundingClientRect(), l = o.width, h = o.height, m({ data: u, config: d });
780
780
  };
781
781
  window.addEventListener("resize", _);
782
- const g = (p, v = !1) => {
783
- v && p.config && (d = xt(d, p.config)), v && p.data && (u = p.data);
784
- const y = u.map((N) => ({ date: new Date(N.date), value: N.value })).sort((N, W) => N.date.getTime() - W.date.getTime()), b = ts(y, d, l), w = is(y, d, c);
785
- n.attr("class", `sc-charts sc-charts__${d.theme}`), r.attr("preserveAspectRatio", "xMinYMin meet").attr("viewBox", `0 0 ${l} ${c}`).style("width", "100%").style("height", "100%").selectAll("*").remove();
786
- const T = {
782
+ const m = (p, v = !1) => {
783
+ v && p.config && (d = bt(d, p.config)), v && p.data && (u = p.data);
784
+ const y = u.map((E) => ({ date: new Date(E.date), value: E.value })).sort((E, $) => E.date.getTime() - $.date.getTime()), b = en(y, d, l), x = tn(y, d, h);
785
+ s.attr("class", `sc-charts sc-charts__${d.theme}`), r.attr("preserveAspectRatio", "xMinYMin meet").attr("viewBox", `0 0 ${l} ${h}`).style("width", "100%").style("height", "100%").selectAll("*").remove();
786
+ const C = {
787
787
  chartId: e.chartId,
788
788
  svg: r,
789
- wrapperNode: n.node(),
789
+ wrapperNode: s.node(),
790
790
  data: y,
791
791
  x: b,
792
- y: w,
792
+ y: x,
793
793
  config: d,
794
794
  action: "none",
795
795
  width: l,
796
- height: c
796
+ height: h
797
797
  };
798
- Fn(T);
799
- const C = {
800
- ...T,
801
- elements: Jn(T)
798
+ Hs(C);
799
+ const M = {
800
+ ...C,
801
+ elements: Vs(C)
802
802
  };
803
- es(C);
803
+ Ks(M);
804
804
  };
805
- return g(e), {
806
- update: (p) => g(p, !0),
805
+ return m(e), {
806
+ update: (p) => m(p, !0),
807
807
  destroy: () => {
808
808
  window.removeEventListener("resize", _), r.remove();
809
809
  }
810
810
  };
811
811
  };
812
812
  var be = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
813
- function ns(i) {
813
+ function sn(i) {
814
814
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
815
815
  }
816
816
  var le = { exports: {} };
817
817
  le.exports;
818
- var St;
819
- function ss() {
820
- return St || (St = 1, function(i, e) {
821
- var t = 200, n = "__lodash_hash_undefined__", r = 800, s = 16, o = 9007199254740991, l = "[object Arguments]", c = "[object Array]", d = "[object AsyncFunction]", u = "[object Boolean]", _ = "[object Date]", g = "[object Error]", p = "[object Function]", v = "[object GeneratorFunction]", y = "[object Map]", b = "[object Number]", w = "[object Null]", T = "[object Object]", C = "[object Proxy]", N = "[object RegExp]", W = "[object Set]", B = "[object String]", X = "[object Undefined]", U = "[object WeakMap]", Ee = "[object ArrayBuffer]", De = "[object DataView]", Ne = "[object Float32Array]", Qt = "[object Float64Array]", qt = "[object Int8Array]", Kt = "[object Int16Array]", ei = "[object Int32Array]", ti = "[object Uint8Array]", ii = "[object Uint8ClampedArray]", ni = "[object Uint16Array]", si = "[object Uint32Array]", ri = /[\\^$.*+?()[\]{}|]/g, ai = /^\[object .+?Constructor\]$/, oi = /^(?:0|[1-9]\d*)$/, D = {};
822
- D[Ne] = D[Qt] = D[qt] = D[Kt] = D[ei] = D[ti] = D[ii] = D[ni] = D[si] = !0, D[l] = D[c] = D[Ee] = D[u] = D[De] = D[_] = D[g] = D[p] = D[y] = D[b] = D[T] = D[N] = D[W] = D[B] = D[U] = !1;
823
- var Qe = typeof be == "object" && be && be.Object === Object && be, li = typeof self == "object" && self && self.Object === Object && self, ne = Qe || li || Function("return this")(), qe = e && !e.nodeType && e, se = qe && !0 && i && !i.nodeType && i, Ke = se && se.exports === qe, Le = Ke && Qe.process, et = function() {
818
+ var At;
819
+ function nn() {
820
+ return At || (At = 1, function(i, e) {
821
+ var t = 200, s = "__lodash_hash_undefined__", r = 800, n = 16, o = 9007199254740991, l = "[object Arguments]", h = "[object Array]", d = "[object AsyncFunction]", u = "[object Boolean]", _ = "[object Date]", m = "[object Error]", p = "[object Function]", v = "[object GeneratorFunction]", y = "[object Map]", b = "[object Number]", x = "[object Null]", C = "[object Object]", M = "[object Proxy]", E = "[object RegExp]", $ = "[object Set]", F = "[object String]", W = "[object Undefined]", Z = "[object WeakMap]", ke = "[object ArrayBuffer]", Ee = "[object DataView]", De = "[object Float32Array]", Qt = "[object Float64Array]", qt = "[object Int8Array]", Kt = "[object Int16Array]", ei = "[object Int32Array]", ti = "[object Uint8Array]", ii = "[object Uint8ClampedArray]", si = "[object Uint16Array]", ni = "[object Uint32Array]", ri = /[\\^$.*+?()[\]{}|]/g, ai = /^\[object .+?Constructor\]$/, oi = /^(?:0|[1-9]\d*)$/, L = {};
822
+ L[De] = L[Qt] = L[qt] = L[Kt] = L[ei] = L[ti] = L[ii] = L[si] = L[ni] = !0, L[l] = L[h] = L[ke] = L[u] = L[Ee] = L[_] = L[m] = L[p] = L[y] = L[b] = L[C] = L[E] = L[$] = L[F] = L[Z] = !1;
823
+ var Je = typeof be == "object" && be && be.Object === Object && be, li = typeof self == "object" && self && self.Object === Object && self, se = Je || li || Function("return this")(), Qe = e && !e.nodeType && e, ne = Qe && !0 && i && !i.nodeType && i, qe = ne && ne.exports === Qe, Le = qe && Je.process, Ke = function() {
824
824
  try {
825
- var a = se && se.require && se.require("util").types;
825
+ var a = ne && ne.require && ne.require("util").types;
826
826
  return a || Le && Le.binding && Le.binding("util");
827
827
  } catch {
828
828
  }
829
- }(), tt = et && et.isTypedArray;
830
- function ci(a, h, f) {
829
+ }(), et = Ke && Ke.isTypedArray;
830
+ function ci(a, c, f) {
831
831
  switch (f.length) {
832
832
  case 0:
833
- return a.call(h);
833
+ return a.call(c);
834
834
  case 1:
835
- return a.call(h, f[0]);
835
+ return a.call(c, f[0]);
836
836
  case 2:
837
- return a.call(h, f[0], f[1]);
837
+ return a.call(c, f[0], f[1]);
838
838
  case 3:
839
- return a.call(h, f[0], f[1], f[2]);
839
+ return a.call(c, f[0], f[1], f[2]);
840
840
  }
841
- return a.apply(h, f);
841
+ return a.apply(c, f);
842
842
  }
843
- function hi(a, h) {
844
- for (var f = -1, x = Array(a); ++f < a; )
845
- x[f] = h(f);
846
- return x;
843
+ function hi(a, c) {
844
+ for (var f = -1, w = Array(a); ++f < a; )
845
+ w[f] = c(f);
846
+ return w;
847
847
  }
848
848
  function di(a) {
849
- return function(h) {
850
- return a(h);
849
+ return function(c) {
850
+ return a(c);
851
851
  };
852
852
  }
853
- function ui(a, h) {
854
- return a == null ? void 0 : a[h];
853
+ function ui(a, c) {
854
+ return a == null ? void 0 : a[c];
855
855
  }
856
- function fi(a, h) {
856
+ function gi(a, c) {
857
857
  return function(f) {
858
- return a(h(f));
858
+ return a(c(f));
859
859
  };
860
860
  }
861
- var gi = Array.prototype, _i = Function.prototype, ue = Object.prototype, Ie = ne["__core-js_shared__"], fe = _i.toString, V = ue.hasOwnProperty, it = function() {
862
- var a = /[^.]+$/.exec(Ie && Ie.keys && Ie.keys.IE_PROTO || "");
861
+ var fi = Array.prototype, _i = Function.prototype, ue = Object.prototype, Ne = se["__core-js_shared__"], ge = _i.toString, V = ue.hasOwnProperty, tt = function() {
862
+ var a = /[^.]+$/.exec(Ne && Ne.keys && Ne.keys.IE_PROTO || "");
863
863
  return a ? "Symbol(src)_1." + a : "";
864
- }(), nt = ue.toString, mi = fe.call(Object), pi = RegExp(
865
- "^" + fe.call(V).replace(ri, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
866
- ), ge = Ke ? ne.Buffer : void 0, st = ne.Symbol, rt = ne.Uint8Array;
867
- ge && ge.allocUnsafe;
868
- var at = fi(Object.getPrototypeOf, Object), ot = Object.create, vi = ue.propertyIsEnumerable, yi = gi.splice, J = st ? st.toStringTag : void 0, _e = function() {
864
+ }(), it = ue.toString, mi = ge.call(Object), pi = RegExp(
865
+ "^" + ge.call(V).replace(ri, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
866
+ ), fe = qe ? se.Buffer : void 0, st = se.Symbol, nt = se.Uint8Array;
867
+ fe && fe.allocUnsafe;
868
+ var rt = gi(Object.getPrototypeOf, Object), at = Object.create, vi = ue.propertyIsEnumerable, yi = fi.splice, J = st ? st.toStringTag : void 0, _e = function() {
869
869
  try {
870
- var a = ze(Object, "defineProperty");
870
+ var a = Re(Object, "defineProperty");
871
871
  return a({}, "", {}), a;
872
872
  } catch {
873
873
  }
874
- }(), bi = ge ? ge.isBuffer : void 0, lt = Math.max, xi = Date.now, ct = ze(ne, "Map"), re = ze(Object, "create"), wi = /* @__PURE__ */ function() {
874
+ }(), bi = fe ? fe.isBuffer : void 0, ot = Math.max, xi = Date.now, lt = Re(se, "Map"), re = Re(Object, "create"), wi = /* @__PURE__ */ function() {
875
875
  function a() {
876
876
  }
877
- return function(h) {
878
- if (!q(h))
877
+ return function(c) {
878
+ if (!q(c))
879
879
  return {};
880
- if (ot)
881
- return ot(h);
882
- a.prototype = h;
880
+ if (at)
881
+ return at(c);
882
+ a.prototype = c;
883
883
  var f = new a();
884
884
  return a.prototype = void 0, f;
885
885
  };
886
886
  }();
887
887
  function Q(a) {
888
- var h = -1, f = a == null ? 0 : a.length;
889
- for (this.clear(); ++h < f; ) {
890
- var x = a[h];
891
- this.set(x[0], x[1]);
888
+ var c = -1, f = a == null ? 0 : a.length;
889
+ for (this.clear(); ++c < f; ) {
890
+ var w = a[c];
891
+ this.set(w[0], w[1]);
892
892
  }
893
893
  }
894
894
  function Mi() {
895
895
  this.__data__ = re ? re(null) : {}, this.size = 0;
896
896
  }
897
- function Ci(a) {
898
- var h = this.has(a) && delete this.__data__[a];
899
- return this.size -= h ? 1 : 0, h;
900
- }
901
897
  function Ti(a) {
902
- var h = this.__data__;
898
+ var c = this.has(a) && delete this.__data__[a];
899
+ return this.size -= c ? 1 : 0, c;
900
+ }
901
+ function Ci(a) {
902
+ var c = this.__data__;
903
903
  if (re) {
904
- var f = h[a];
905
- return f === n ? void 0 : f;
904
+ var f = c[a];
905
+ return f === s ? void 0 : f;
906
906
  }
907
- return V.call(h, a) ? h[a] : void 0;
907
+ return V.call(c, a) ? c[a] : void 0;
908
908
  }
909
909
  function Ai(a) {
910
- var h = this.__data__;
911
- return re ? h[a] !== void 0 : V.call(h, a);
910
+ var c = this.__data__;
911
+ return re ? c[a] !== void 0 : V.call(c, a);
912
912
  }
913
- function Si(a, h) {
913
+ function Si(a, c) {
914
914
  var f = this.__data__;
915
- return this.size += this.has(a) ? 0 : 1, f[a] = re && h === void 0 ? n : h, this;
915
+ return this.size += this.has(a) ? 0 : 1, f[a] = re && c === void 0 ? s : c, this;
916
916
  }
917
- Q.prototype.clear = Mi, Q.prototype.delete = Ci, Q.prototype.get = Ti, Q.prototype.has = Ai, Q.prototype.set = Si;
917
+ Q.prototype.clear = Mi, Q.prototype.delete = Ti, Q.prototype.get = Ci, Q.prototype.has = Ai, Q.prototype.set = Si;
918
918
  function G(a) {
919
- var h = -1, f = a == null ? 0 : a.length;
920
- for (this.clear(); ++h < f; ) {
921
- var x = a[h];
922
- this.set(x[0], x[1]);
919
+ var c = -1, f = a == null ? 0 : a.length;
920
+ for (this.clear(); ++c < f; ) {
921
+ var w = a[c];
922
+ this.set(w[0], w[1]);
923
923
  }
924
924
  }
925
925
  function ki() {
926
926
  this.__data__ = [], this.size = 0;
927
927
  }
928
928
  function Ei(a) {
929
- var h = this.__data__, f = me(h, a);
929
+ var c = this.__data__, f = me(c, a);
930
930
  if (f < 0)
931
931
  return !1;
932
- var x = h.length - 1;
933
- return f == x ? h.pop() : yi.call(h, f, 1), --this.size, !0;
932
+ var w = c.length - 1;
933
+ return f == w ? c.pop() : yi.call(c, f, 1), --this.size, !0;
934
934
  }
935
935
  function Di(a) {
936
- var h = this.__data__, f = me(h, a);
937
- return f < 0 ? void 0 : h[f][1];
936
+ var c = this.__data__, f = me(c, a);
937
+ return f < 0 ? void 0 : c[f][1];
938
938
  }
939
- function Ni(a) {
939
+ function Li(a) {
940
940
  return me(this.__data__, a) > -1;
941
941
  }
942
- function Li(a, h) {
943
- var f = this.__data__, x = me(f, a);
944
- return x < 0 ? (++this.size, f.push([a, h])) : f[x][1] = h, this;
942
+ function Ni(a, c) {
943
+ var f = this.__data__, w = me(f, a);
944
+ return w < 0 ? (++this.size, f.push([a, c])) : f[w][1] = c, this;
945
945
  }
946
- G.prototype.clear = ki, G.prototype.delete = Ei, G.prototype.get = Di, G.prototype.has = Ni, G.prototype.set = Li;
946
+ G.prototype.clear = ki, G.prototype.delete = Ei, G.prototype.get = Di, G.prototype.has = Li, G.prototype.set = Ni;
947
947
  function ee(a) {
948
- var h = -1, f = a == null ? 0 : a.length;
949
- for (this.clear(); ++h < f; ) {
950
- var x = a[h];
951
- this.set(x[0], x[1]);
948
+ var c = -1, f = a == null ? 0 : a.length;
949
+ for (this.clear(); ++c < f; ) {
950
+ var w = a[c];
951
+ this.set(w[0], w[1]);
952
952
  }
953
953
  }
954
- function Ii() {
954
+ function Hi() {
955
955
  this.size = 0, this.__data__ = {
956
956
  hash: new Q(),
957
- map: new (ct || G)(),
957
+ map: new (lt || G)(),
958
958
  string: new Q()
959
959
  };
960
960
  }
961
- function Fi(a) {
962
- var h = ve(this, a).delete(a);
963
- return this.size -= h ? 1 : 0, h;
961
+ function Ii(a) {
962
+ var c = ve(this, a).delete(a);
963
+ return this.size -= c ? 1 : 0, c;
964
964
  }
965
965
  function Ri(a) {
966
966
  return ve(this, a).get(a);
967
967
  }
968
- function zi(a) {
968
+ function Fi(a) {
969
969
  return ve(this, a).has(a);
970
970
  }
971
- function $i(a, h) {
972
- var f = ve(this, a), x = f.size;
973
- return f.set(a, h), this.size += f.size == x ? 0 : 1, this;
971
+ function zi(a, c) {
972
+ var f = ve(this, a), w = f.size;
973
+ return f.set(a, c), this.size += f.size == w ? 0 : 1, this;
974
974
  }
975
- ee.prototype.clear = Ii, ee.prototype.delete = Fi, ee.prototype.get = Ri, ee.prototype.has = zi, ee.prototype.set = $i;
975
+ ee.prototype.clear = Hi, ee.prototype.delete = Ii, ee.prototype.get = Ri, ee.prototype.has = Fi, ee.prototype.set = zi;
976
976
  function te(a) {
977
- var h = this.__data__ = new G(a);
978
- this.size = h.size;
977
+ var c = this.__data__ = new G(a);
978
+ this.size = c.size;
979
979
  }
980
980
  function Bi() {
981
981
  this.__data__ = new G(), this.size = 0;
982
982
  }
983
- function Oi(a) {
984
- var h = this.__data__, f = h.delete(a);
985
- return this.size = h.size, f;
983
+ function $i(a) {
984
+ var c = this.__data__, f = c.delete(a);
985
+ return this.size = c.size, f;
986
986
  }
987
987
  function Pi(a) {
988
988
  return this.__data__.get(a);
989
989
  }
990
- function Hi(a) {
990
+ function Oi(a) {
991
991
  return this.__data__.has(a);
992
992
  }
993
- function ji(a, h) {
993
+ function Yi(a, c) {
994
994
  var f = this.__data__;
995
995
  if (f instanceof G) {
996
- var x = f.__data__;
997
- if (!ct || x.length < t - 1)
998
- return x.push([a, h]), this.size = ++f.size, this;
999
- f = this.__data__ = new ee(x);
996
+ var w = f.__data__;
997
+ if (!lt || w.length < t - 1)
998
+ return w.push([a, c]), this.size = ++f.size, this;
999
+ f = this.__data__ = new ee(w);
1000
1000
  }
1001
- return f.set(a, h), this.size = f.size, this;
1002
- }
1003
- te.prototype.clear = Bi, te.prototype.delete = Oi, te.prototype.get = Pi, te.prototype.has = Hi, te.prototype.set = ji;
1004
- function Yi(a, h) {
1005
- var f = Oe(a), x = !f && Be(a), A = !f && !x && gt(a), E = !f && !x && !A && mt(a), L = f || x || A || E, S = L ? hi(a.length, String) : [], I = S.length;
1006
- for (var O in a)
1007
- L && // Safari 9 has enumerable `arguments.length` in strict mode.
1008
- (O == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
1009
- A && (O == "offset" || O == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
1010
- E && (O == "buffer" || O == "byteLength" || O == "byteOffset") || // Skip index properties.
1011
- ut(O, I)) || S.push(O);
1001
+ return f.set(a, c), this.size = f.size, this;
1002
+ }
1003
+ te.prototype.clear = Bi, te.prototype.delete = $i, te.prototype.get = Pi, te.prototype.has = Oi, te.prototype.set = Yi;
1004
+ function ji(a, c) {
1005
+ var f = Be(a), w = !f && ze(a), A = !f && !w && gt(a), D = !f && !w && !A && _t(a), N = f || w || A || D, S = N ? hi(a.length, String) : [], H = S.length;
1006
+ for (var P in a)
1007
+ N && // Safari 9 has enumerable `arguments.length` in strict mode.
1008
+ (P == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
1009
+ A && (P == "offset" || P == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
1010
+ D && (P == "buffer" || P == "byteLength" || P == "byteOffset") || // Skip index properties.
1011
+ dt(P, H)) || S.push(P);
1012
1012
  return S;
1013
1013
  }
1014
- function Fe(a, h, f) {
1015
- (f !== void 0 && !ye(a[h], f) || f === void 0 && !(h in a)) && Re(a, h, f);
1014
+ function He(a, c, f) {
1015
+ (f !== void 0 && !ye(a[c], f) || f === void 0 && !(c in a)) && Ie(a, c, f);
1016
1016
  }
1017
- function Wi(a, h, f) {
1018
- var x = a[h];
1019
- (!(V.call(a, h) && ye(x, f)) || f === void 0 && !(h in a)) && Re(a, h, f);
1017
+ function Xi(a, c, f) {
1018
+ var w = a[c];
1019
+ (!(V.call(a, c) && ye(w, f)) || f === void 0 && !(c in a)) && Ie(a, c, f);
1020
1020
  }
1021
- function me(a, h) {
1021
+ function me(a, c) {
1022
1022
  for (var f = a.length; f--; )
1023
- if (ye(a[f][0], h))
1023
+ if (ye(a[f][0], c))
1024
1024
  return f;
1025
1025
  return -1;
1026
1026
  }
1027
- function Re(a, h, f) {
1028
- h == "__proto__" && _e ? _e(a, h, {
1027
+ function Ie(a, c, f) {
1028
+ c == "__proto__" && _e ? _e(a, c, {
1029
1029
  configurable: !0,
1030
1030
  enumerable: !0,
1031
1031
  value: f,
1032
1032
  writable: !0
1033
- }) : a[h] = f;
1033
+ }) : a[c] = f;
1034
1034
  }
1035
- var Xi = rn();
1035
+ var Wi = ns();
1036
1036
  function pe(a) {
1037
- return a == null ? a === void 0 ? X : w : J && J in Object(a) ? an(a) : un(a);
1037
+ return a == null ? a === void 0 ? W : x : J && J in Object(a) ? rs(a) : ds(a);
1038
1038
  }
1039
- function ht(a) {
1039
+ function ct(a) {
1040
1040
  return ae(a) && pe(a) == l;
1041
1041
  }
1042
1042
  function Gi(a) {
1043
- if (!q(a) || hn(a))
1043
+ if (!q(a) || cs(a))
1044
1044
  return !1;
1045
- var h = He(a) ? pi : ai;
1046
- return h.test(mn(a));
1047
- }
1048
- function Zi(a) {
1049
- return ae(a) && _t(a.length) && !!D[pe(a)];
1045
+ var c = Pe(a) ? pi : ai;
1046
+ return c.test(_s(a));
1050
1047
  }
1051
1048
  function Ui(a) {
1049
+ return ae(a) && ft(a.length) && !!L[pe(a)];
1050
+ }
1051
+ function Zi(a) {
1052
1052
  if (!q(a))
1053
- return dn(a);
1054
- var h = ft(a), f = [];
1055
- for (var x in a)
1056
- x == "constructor" && (h || !V.call(a, x)) || f.push(x);
1053
+ return hs(a);
1054
+ var c = ut(a), f = [];
1055
+ for (var w in a)
1056
+ w == "constructor" && (c || !V.call(a, w)) || f.push(w);
1057
1057
  return f;
1058
1058
  }
1059
- function dt(a, h, f, x, A) {
1060
- a !== h && Xi(h, function(E, L) {
1061
- if (A || (A = new te()), q(E))
1062
- Vi(a, h, L, f, dt, x, A);
1059
+ function ht(a, c, f, w, A) {
1060
+ a !== c && Wi(c, function(D, N) {
1061
+ if (A || (A = new te()), q(D))
1062
+ Vi(a, c, N, f, ht, w, A);
1063
1063
  else {
1064
- var S = x ? x($e(a, L), E, L + "", a, h, A) : void 0;
1065
- S === void 0 && (S = E), Fe(a, L, S);
1064
+ var S = w ? w(Fe(a, N), D, N + "", a, c, A) : void 0;
1065
+ S === void 0 && (S = D), He(a, N, S);
1066
1066
  }
1067
- }, pt);
1067
+ }, mt);
1068
1068
  }
1069
- function Vi(a, h, f, x, A, E, L) {
1070
- var S = $e(a, f), I = $e(h, f), O = L.get(I);
1071
- if (O) {
1072
- Fe(a, f, O);
1069
+ function Vi(a, c, f, w, A, D, N) {
1070
+ var S = Fe(a, f), H = Fe(c, f), P = N.get(H);
1071
+ if (P) {
1072
+ He(a, f, P);
1073
1073
  return;
1074
1074
  }
1075
- var z = E ? E(S, I, f + "", a, h, L) : void 0, oe = z === void 0;
1075
+ var z = D ? D(S, H, f + "", a, c, N) : void 0, oe = z === void 0;
1076
1076
  if (oe) {
1077
- var je = Oe(I), Ye = !je && gt(I), yt = !je && !Ye && mt(I);
1078
- z = I, je || Ye || yt ? Oe(S) ? z = S : pn(S) ? z = tn(S) : Ye ? (oe = !1, z = qi(I)) : yt ? (oe = !1, z = en(I)) : z = [] : vn(I) || Be(I) ? (z = S, Be(S) ? z = yn(S) : (!q(S) || He(S)) && (z = on(I))) : oe = !1;
1077
+ var Oe = Be(H), Ye = !Oe && gt(H), vt = !Oe && !Ye && _t(H);
1078
+ z = H, Oe || Ye || vt ? Be(S) ? z = S : ms(S) ? z = ts(S) : Ye ? (oe = !1, z = qi(H)) : vt ? (oe = !1, z = es(H)) : z = [] : ps(H) || ze(H) ? (z = S, ze(S) ? z = vs(S) : (!q(S) || Pe(S)) && (z = as(H))) : oe = !1;
1079
1079
  }
1080
- oe && (L.set(I, z), A(z, I, x, E, L), L.delete(I)), Fe(a, f, z);
1080
+ oe && (N.set(H, z), A(z, H, w, D, N), N.delete(H)), He(a, f, z);
1081
1081
  }
1082
- function Ji(a, h) {
1083
- return gn(fn(a, h, vt), a + "");
1082
+ function Ji(a, c) {
1083
+ return gs(us(a, c, pt), a + "");
1084
1084
  }
1085
- var Qi = _e ? function(a, h) {
1085
+ var Qi = _e ? function(a, c) {
1086
1086
  return _e(a, "toString", {
1087
1087
  configurable: !0,
1088
1088
  enumerable: !1,
1089
- value: xn(h),
1089
+ value: bs(c),
1090
1090
  writable: !0
1091
1091
  });
1092
- } : vt;
1093
- function qi(a, h) {
1092
+ } : pt;
1093
+ function qi(a, c) {
1094
1094
  return a.slice();
1095
1095
  }
1096
1096
  function Ki(a) {
1097
- var h = new a.constructor(a.byteLength);
1098
- return new rt(h).set(new rt(a)), h;
1097
+ var c = new a.constructor(a.byteLength);
1098
+ return new nt(c).set(new nt(a)), c;
1099
1099
  }
1100
- function en(a, h) {
1100
+ function es(a, c) {
1101
1101
  var f = Ki(a.buffer);
1102
1102
  return new a.constructor(f, a.byteOffset, a.length);
1103
1103
  }
1104
- function tn(a, h) {
1105
- var f = -1, x = a.length;
1106
- for (h || (h = Array(x)); ++f < x; )
1107
- h[f] = a[f];
1108
- return h;
1104
+ function ts(a, c) {
1105
+ var f = -1, w = a.length;
1106
+ for (c || (c = Array(w)); ++f < w; )
1107
+ c[f] = a[f];
1108
+ return c;
1109
1109
  }
1110
- function nn(a, h, f, x) {
1110
+ function is(a, c, f, w) {
1111
1111
  var A = !f;
1112
1112
  f || (f = {});
1113
- for (var E = -1, L = h.length; ++E < L; ) {
1114
- var S = h[E], I = void 0;
1115
- I === void 0 && (I = a[S]), A ? Re(f, S, I) : Wi(f, S, I);
1113
+ for (var D = -1, N = c.length; ++D < N; ) {
1114
+ var S = c[D], H = void 0;
1115
+ H === void 0 && (H = a[S]), A ? Ie(f, S, H) : Xi(f, S, H);
1116
1116
  }
1117
1117
  return f;
1118
1118
  }
1119
- function sn(a) {
1120
- return Ji(function(h, f) {
1121
- var x = -1, A = f.length, E = A > 1 ? f[A - 1] : void 0, L = A > 2 ? f[2] : void 0;
1122
- for (E = a.length > 3 && typeof E == "function" ? (A--, E) : void 0, L && ln(f[0], f[1], L) && (E = A < 3 ? void 0 : E, A = 1), h = Object(h); ++x < A; ) {
1123
- var S = f[x];
1124
- S && a(h, S, x, E);
1119
+ function ss(a) {
1120
+ return Ji(function(c, f) {
1121
+ var w = -1, A = f.length, D = A > 1 ? f[A - 1] : void 0, N = A > 2 ? f[2] : void 0;
1122
+ for (D = a.length > 3 && typeof D == "function" ? (A--, D) : void 0, N && os(f[0], f[1], N) && (D = A < 3 ? void 0 : D, A = 1), c = Object(c); ++w < A; ) {
1123
+ var S = f[w];
1124
+ S && a(c, S, w, D);
1125
1125
  }
1126
- return h;
1126
+ return c;
1127
1127
  });
1128
1128
  }
1129
- function rn(a) {
1130
- return function(h, f, x) {
1131
- for (var A = -1, E = Object(h), L = x(h), S = L.length; S--; ) {
1132
- var I = L[++A];
1133
- if (f(E[I], I, E) === !1)
1129
+ function ns(a) {
1130
+ return function(c, f, w) {
1131
+ for (var A = -1, D = Object(c), N = w(c), S = N.length; S--; ) {
1132
+ var H = N[++A];
1133
+ if (f(D[H], H, D) === !1)
1134
1134
  break;
1135
1135
  }
1136
- return h;
1136
+ return c;
1137
1137
  };
1138
1138
  }
1139
- function ve(a, h) {
1139
+ function ve(a, c) {
1140
1140
  var f = a.__data__;
1141
- return cn(h) ? f[typeof h == "string" ? "string" : "hash"] : f.map;
1141
+ return ls(c) ? f[typeof c == "string" ? "string" : "hash"] : f.map;
1142
1142
  }
1143
- function ze(a, h) {
1144
- var f = ui(a, h);
1143
+ function Re(a, c) {
1144
+ var f = ui(a, c);
1145
1145
  return Gi(f) ? f : void 0;
1146
1146
  }
1147
- function an(a) {
1148
- var h = V.call(a, J), f = a[J];
1147
+ function rs(a) {
1148
+ var c = V.call(a, J), f = a[J];
1149
1149
  try {
1150
1150
  a[J] = void 0;
1151
- var x = !0;
1151
+ var w = !0;
1152
1152
  } catch {
1153
1153
  }
1154
- var A = nt.call(a);
1155
- return x && (h ? a[J] = f : delete a[J]), A;
1154
+ var A = it.call(a);
1155
+ return w && (c ? a[J] = f : delete a[J]), A;
1156
1156
  }
1157
- function on(a) {
1158
- return typeof a.constructor == "function" && !ft(a) ? wi(at(a)) : {};
1157
+ function as(a) {
1158
+ return typeof a.constructor == "function" && !ut(a) ? wi(rt(a)) : {};
1159
1159
  }
1160
- function ut(a, h) {
1160
+ function dt(a, c) {
1161
1161
  var f = typeof a;
1162
- return h = h ?? o, !!h && (f == "number" || f != "symbol" && oi.test(a)) && a > -1 && a % 1 == 0 && a < h;
1162
+ return c = c ?? o, !!c && (f == "number" || f != "symbol" && oi.test(a)) && a > -1 && a % 1 == 0 && a < c;
1163
1163
  }
1164
- function ln(a, h, f) {
1164
+ function os(a, c, f) {
1165
1165
  if (!q(f))
1166
1166
  return !1;
1167
- var x = typeof h;
1168
- return (x == "number" ? Pe(f) && ut(h, f.length) : x == "string" && h in f) ? ye(f[h], a) : !1;
1167
+ var w = typeof c;
1168
+ return (w == "number" ? $e(f) && dt(c, f.length) : w == "string" && c in f) ? ye(f[c], a) : !1;
1169
1169
  }
1170
- function cn(a) {
1171
- var h = typeof a;
1172
- return h == "string" || h == "number" || h == "symbol" || h == "boolean" ? a !== "__proto__" : a === null;
1170
+ function ls(a) {
1171
+ var c = typeof a;
1172
+ return c == "string" || c == "number" || c == "symbol" || c == "boolean" ? a !== "__proto__" : a === null;
1173
1173
  }
1174
- function hn(a) {
1175
- return !!it && it in a;
1174
+ function cs(a) {
1175
+ return !!tt && tt in a;
1176
1176
  }
1177
- function ft(a) {
1178
- var h = a && a.constructor, f = typeof h == "function" && h.prototype || ue;
1177
+ function ut(a) {
1178
+ var c = a && a.constructor, f = typeof c == "function" && c.prototype || ue;
1179
1179
  return a === f;
1180
1180
  }
1181
- function dn(a) {
1182
- var h = [];
1181
+ function hs(a) {
1182
+ var c = [];
1183
1183
  if (a != null)
1184
1184
  for (var f in Object(a))
1185
- h.push(f);
1186
- return h;
1185
+ c.push(f);
1186
+ return c;
1187
1187
  }
1188
- function un(a) {
1189
- return nt.call(a);
1188
+ function ds(a) {
1189
+ return it.call(a);
1190
1190
  }
1191
- function fn(a, h, f) {
1192
- return h = lt(h === void 0 ? a.length - 1 : h, 0), function() {
1193
- for (var x = arguments, A = -1, E = lt(x.length - h, 0), L = Array(E); ++A < E; )
1194
- L[A] = x[h + A];
1191
+ function us(a, c, f) {
1192
+ return c = ot(c === void 0 ? a.length - 1 : c, 0), function() {
1193
+ for (var w = arguments, A = -1, D = ot(w.length - c, 0), N = Array(D); ++A < D; )
1194
+ N[A] = w[c + A];
1195
1195
  A = -1;
1196
- for (var S = Array(h + 1); ++A < h; )
1197
- S[A] = x[A];
1198
- return S[h] = f(L), ci(a, this, S);
1196
+ for (var S = Array(c + 1); ++A < c; )
1197
+ S[A] = w[A];
1198
+ return S[c] = f(N), ci(a, this, S);
1199
1199
  };
1200
1200
  }
1201
- function $e(a, h) {
1202
- if (!(h === "constructor" && typeof a[h] == "function") && h != "__proto__")
1203
- return a[h];
1201
+ function Fe(a, c) {
1202
+ if (!(c === "constructor" && typeof a[c] == "function") && c != "__proto__")
1203
+ return a[c];
1204
1204
  }
1205
- var gn = _n(Qi);
1206
- function _n(a) {
1207
- var h = 0, f = 0;
1205
+ var gs = fs(Qi);
1206
+ function fs(a) {
1207
+ var c = 0, f = 0;
1208
1208
  return function() {
1209
- var x = xi(), A = s - (x - f);
1210
- if (f = x, A > 0) {
1211
- if (++h >= r)
1209
+ var w = xi(), A = n - (w - f);
1210
+ if (f = w, A > 0) {
1211
+ if (++c >= r)
1212
1212
  return arguments[0];
1213
1213
  } else
1214
- h = 0;
1214
+ c = 0;
1215
1215
  return a.apply(void 0, arguments);
1216
1216
  };
1217
1217
  }
1218
- function mn(a) {
1218
+ function _s(a) {
1219
1219
  if (a != null) {
1220
1220
  try {
1221
- return fe.call(a);
1221
+ return ge.call(a);
1222
1222
  } catch {
1223
1223
  }
1224
1224
  try {
@@ -1228,78 +1228,78 @@ function ss() {
1228
1228
  }
1229
1229
  return "";
1230
1230
  }
1231
- function ye(a, h) {
1232
- return a === h || a !== a && h !== h;
1231
+ function ye(a, c) {
1232
+ return a === c || a !== a && c !== c;
1233
1233
  }
1234
- var Be = ht(/* @__PURE__ */ function() {
1234
+ var ze = ct(/* @__PURE__ */ function() {
1235
1235
  return arguments;
1236
- }()) ? ht : function(a) {
1236
+ }()) ? ct : function(a) {
1237
1237
  return ae(a) && V.call(a, "callee") && !vi.call(a, "callee");
1238
- }, Oe = Array.isArray;
1239
- function Pe(a) {
1240
- return a != null && _t(a.length) && !He(a);
1238
+ }, Be = Array.isArray;
1239
+ function $e(a) {
1240
+ return a != null && ft(a.length) && !Pe(a);
1241
1241
  }
1242
- function pn(a) {
1243
- return ae(a) && Pe(a);
1242
+ function ms(a) {
1243
+ return ae(a) && $e(a);
1244
1244
  }
1245
- var gt = bi || wn;
1246
- function He(a) {
1245
+ var gt = bi || xs;
1246
+ function Pe(a) {
1247
1247
  if (!q(a))
1248
1248
  return !1;
1249
- var h = pe(a);
1250
- return h == p || h == v || h == d || h == C;
1249
+ var c = pe(a);
1250
+ return c == p || c == v || c == d || c == M;
1251
1251
  }
1252
- function _t(a) {
1252
+ function ft(a) {
1253
1253
  return typeof a == "number" && a > -1 && a % 1 == 0 && a <= o;
1254
1254
  }
1255
1255
  function q(a) {
1256
- var h = typeof a;
1257
- return a != null && (h == "object" || h == "function");
1256
+ var c = typeof a;
1257
+ return a != null && (c == "object" || c == "function");
1258
1258
  }
1259
1259
  function ae(a) {
1260
1260
  return a != null && typeof a == "object";
1261
1261
  }
1262
- function vn(a) {
1263
- if (!ae(a) || pe(a) != T)
1262
+ function ps(a) {
1263
+ if (!ae(a) || pe(a) != C)
1264
1264
  return !1;
1265
- var h = at(a);
1266
- if (h === null)
1265
+ var c = rt(a);
1266
+ if (c === null)
1267
1267
  return !0;
1268
- var f = V.call(h, "constructor") && h.constructor;
1269
- return typeof f == "function" && f instanceof f && fe.call(f) == mi;
1268
+ var f = V.call(c, "constructor") && c.constructor;
1269
+ return typeof f == "function" && f instanceof f && ge.call(f) == mi;
1270
1270
  }
1271
- var mt = tt ? di(tt) : Zi;
1272
- function yn(a) {
1273
- return nn(a, pt(a));
1271
+ var _t = et ? di(et) : Ui;
1272
+ function vs(a) {
1273
+ return is(a, mt(a));
1274
1274
  }
1275
- function pt(a) {
1276
- return Pe(a) ? Yi(a) : Ui(a);
1275
+ function mt(a) {
1276
+ return $e(a) ? ji(a) : Zi(a);
1277
1277
  }
1278
- var bn = sn(function(a, h, f) {
1279
- dt(a, h, f);
1278
+ var ys = ss(function(a, c, f) {
1279
+ ht(a, c, f);
1280
1280
  });
1281
- function xn(a) {
1281
+ function bs(a) {
1282
1282
  return function() {
1283
1283
  return a;
1284
1284
  };
1285
1285
  }
1286
- function vt(a) {
1286
+ function pt(a) {
1287
1287
  return a;
1288
1288
  }
1289
- function wn() {
1289
+ function xs() {
1290
1290
  return !1;
1291
1291
  }
1292
- i.exports = bn;
1292
+ i.exports = ys;
1293
1293
  }(le, le.exports)), le.exports;
1294
1294
  }
1295
- var rs = ss();
1296
- const Ce = /* @__PURE__ */ ns(rs), kt = 12, as = {
1295
+ var rn = nn();
1296
+ const we = /* @__PURE__ */ sn(rn), St = 12, an = {
1297
1297
  candles: {
1298
1298
  direction: "right",
1299
- offset: `${Math.round(kt / 2)}px`,
1299
+ offset: `${Math.round(St / 2)}px`,
1300
1300
  style: "filled",
1301
1301
  strokeWidth: 1,
1302
- baseWidth: kt,
1302
+ baseWidth: St,
1303
1303
  bodyRatio: 0.7,
1304
1304
  zoomOnWheel: "both"
1305
1305
  },
@@ -1329,17 +1329,17 @@ const Ce = /* @__PURE__ */ ns(rs), kt = 12, as = {
1329
1329
  },
1330
1330
  markers: []
1331
1331
  };
1332
- class os {
1332
+ class on {
1333
1333
  constructor(e) {
1334
- m(this, "_candles");
1335
- m(this, "_xAxis");
1336
- m(this, "_yAxis");
1337
- m(this, "_guides");
1338
- const t = Ce({}, as, e);
1334
+ g(this, "_candles");
1335
+ g(this, "_xAxis");
1336
+ g(this, "_yAxis");
1337
+ g(this, "_guides");
1338
+ const t = we({}, an, e);
1339
1339
  this._candles = t.candles, this._xAxis = t.xAxis, this._yAxis = t.yAxis, this._guides = t.guides;
1340
1340
  }
1341
1341
  update(e) {
1342
- const t = Ce(
1342
+ const t = we(
1343
1343
  {},
1344
1344
  {
1345
1345
  candles: this._candles,
@@ -1367,18 +1367,18 @@ class os {
1367
1367
  return this._guides;
1368
1368
  }
1369
1369
  }
1370
- class P {
1370
+ class O {
1371
1371
  constructor(e) {
1372
- m(this, "_x");
1373
- m(this, "_y");
1374
- m(this, "_width");
1375
- m(this, "_height");
1372
+ g(this, "_x");
1373
+ g(this, "_y");
1374
+ g(this, "_width");
1375
+ g(this, "_height");
1376
1376
  let t;
1377
1377
  if (!e)
1378
1378
  t = { x: 0, y: 0, width: 0, height: 0 };
1379
1379
  else if (e instanceof HTMLElement || e instanceof Element) {
1380
- const { x: n, y: r, width: s, height: o } = e.getBoundingClientRect();
1381
- t = { x: n, y: r, width: s, height: o };
1380
+ const { x: s, y: r, width: n, height: o } = e.getBoundingClientRect();
1381
+ t = { x: s, y: r, width: n, height: o };
1382
1382
  } else
1383
1383
  t = e;
1384
1384
  this._x = t.x, this._y = t.y, this._width = t.width, this._height = t.height;
@@ -1408,47 +1408,47 @@ class P {
1408
1408
  return this._y + this._height;
1409
1409
  }
1410
1410
  }
1411
- class ls {
1411
+ class ln {
1412
1412
  constructor(e, t) {
1413
- m(this, "_chart", new P());
1414
- m(this, "_area", new P());
1415
- m(this, "_xAxis", new P());
1416
- m(this, "_yAxis", new P());
1417
- m(this, "_axisIntersection", new P());
1418
- const { xAxis: n, yAxis: r } = t;
1419
- this._chart = new P(e), this._calc(n, r);
1413
+ g(this, "_chart", new O());
1414
+ g(this, "_area", new O());
1415
+ g(this, "_xAxis", new O());
1416
+ g(this, "_yAxis", new O());
1417
+ g(this, "_axisIntersection", new O());
1418
+ const { xAxis: s, yAxis: r } = t;
1419
+ this._chart = new O(e), this._calc(s, r);
1420
1420
  }
1421
1421
  _calc(e, t) {
1422
- const n = e.isShow ? e.height : 0, r = t.isShow ? t.width : 0, s = this._chart.height - n, o = this._chart.width - r;
1423
- this._area = new P({
1422
+ const s = e.isShow ? e.height : 0, r = t.isShow ? t.width : 0, n = this._chart.height - s, o = this._chart.width - r;
1423
+ this._area = new O({
1424
1424
  x: t.position === "left" ? r : 0,
1425
- y: e.position === "top" ? n : 0,
1425
+ y: e.position === "top" ? s : 0,
1426
1426
  width: o,
1427
- height: s
1428
- }), this._xAxis = new P({
1429
- y: e.position === "top" ? 0 : s,
1427
+ height: n
1428
+ }), this._xAxis = new O({
1429
+ y: e.position === "top" ? 0 : n,
1430
1430
  x: t.position === "left" ? r : 0,
1431
- height: n,
1431
+ height: s,
1432
1432
  width: o
1433
- }), this._yAxis = new P({
1434
- y: e.position === "top" ? n : 0,
1433
+ }), this._yAxis = new O({
1434
+ y: e.position === "top" ? s : 0,
1435
1435
  x: t.position === "left" ? 0 : o,
1436
1436
  width: r,
1437
- height: s
1438
- }), this._axisIntersection = new P({
1439
- y: e.position === "top" ? 0 : s,
1437
+ height: n
1438
+ }), this._axisIntersection = new O({
1439
+ y: e.position === "top" ? 0 : n,
1440
1440
  x: t.position === "left" ? 0 : o,
1441
1441
  width: r,
1442
- height: n
1442
+ height: s
1443
1443
  });
1444
1444
  }
1445
1445
  updateConfig(e) {
1446
- const { xAxis: t, yAxis: n } = e;
1447
- this._calc(t, n);
1446
+ const { xAxis: t, yAxis: s } = e;
1447
+ this._calc(t, s);
1448
1448
  }
1449
1449
  update(e) {
1450
- const { xAxis: t, yAxis: n } = e.config;
1451
- this._chart = new P(e.container), this._calc(t, n);
1450
+ const { xAxis: t, yAxis: s } = e.config;
1451
+ this._chart = new O(e.container), this._calc(t, s);
1452
1452
  }
1453
1453
  get area() {
1454
1454
  return this._area;
@@ -1466,57 +1466,73 @@ class ls {
1466
1466
  return this._chart;
1467
1467
  }
1468
1468
  }
1469
- const jt = (i) => i ? new Date(i.close_time).getTime() - new Date(i.open_time).getTime() : 0;
1470
- function cs(i, e) {
1469
+ const Ot = (i) => i ? new Date(i.close_time).getTime() - new Date(i.open_time).getTime() : 0;
1470
+ function cn(i, e) {
1471
1471
  if (i.length < 2) return [];
1472
1472
  const t = [];
1473
- for (let n = 0; n < i.length - 1; n++) {
1474
- const r = i[n].close_time.getTime(), s = i[n].open_time.getTime(), l = new Date(i[n + 1].open_time).getTime() - r;
1473
+ for (let s = 0; s < i.length - 1; s++) {
1474
+ const r = i[s].close_time.getTime(), n = i[s].open_time.getTime(), l = new Date(i[s + 1].open_time).getTime() - r;
1475
1475
  if (l >= e) {
1476
- const c = Math.floor(l / e), d = [];
1477
- for (let u = 1; u <= c; u++)
1478
- d.push(s + u * e);
1476
+ const h = Math.floor(l / e), d = [];
1477
+ for (let u = 1; u <= h; u++)
1478
+ d.push(n + u * e);
1479
1479
  d.length > 0 && t.push(d);
1480
1480
  }
1481
1481
  }
1482
1482
  return t;
1483
1483
  }
1484
- function hs(i) {
1485
- const e = jt(i[0]), t = cs(i, e), n = [];
1486
- return t.forEach((r) => {
1487
- if (r.length === 0) return;
1488
- const s = i.find((u) => u.close_time.getTime() === r[0]), o = i.find(
1489
- (u) => u.open_time.getTime() === r[r.length - 1] + e
1484
+ function kt(i, e) {
1485
+ const t = Ot(i[0]), s = cn(i, t), r = [];
1486
+ return s.forEach((n) => {
1487
+ if (n.length === 0) return;
1488
+ const o = i.find((_) => _.close_time.getTime() === n[0]), l = i.find(
1489
+ (_) => _.open_time.getTime() === n[n.length - 1] + t
1490
1490
  );
1491
- if (!s || !o)
1491
+ if (!o || !l)
1492
1492
  throw new Error("[CS_Data] error while creating missing data");
1493
- const l = s.close, d = (o.open - l) / r.length;
1494
- r.forEach((u, _) => {
1495
- const g = l + d * _, p = g + d, v = Math.abs(g - p), y = Math.max(g, p) + v / 2, b = Math.min(g, p) - v / 2, w = {
1496
- open_time: new Date(u),
1497
- close_time: new Date(u + e),
1498
- open: g,
1499
- close: p,
1500
- high: y,
1501
- low: b
1493
+ const h = o.close, d = l.open;
1494
+ let u = h;
1495
+ n.forEach((_, m) => {
1496
+ const p = (d - u) / n.length;
1497
+ let v = u + p * m, y = v + p;
1498
+ const b = Math.abs(v - y);
1499
+ let x = Math.max(v, y) + b / 2, C = Math.min(v, y) - b / 2;
1500
+ if (e.trade) {
1501
+ const E = [...e.trade.entries, ...e.trade.exits].find(($) => {
1502
+ const F = $.time.getTime();
1503
+ return F >= _ && F < _ + t;
1504
+ });
1505
+ E && (E.type === "buy" ? (C = E.price, y = Math.max(C, y), v = y + b, x = Math.max(v, y) + b / 2, u = v) : E.type === "sell" && (x = E.price, y = Math.min(x, y), v = y - b, C = Math.min(v, y) - b / 2, u = v));
1506
+ }
1507
+ const M = {
1508
+ open_time: new Date(_),
1509
+ close_time: new Date(_ + t),
1510
+ open: v,
1511
+ close: y,
1512
+ high: x,
1513
+ low: C
1502
1514
  };
1503
- n.push(w);
1515
+ r.push(M);
1504
1516
  });
1505
- }), n;
1517
+ }), r;
1506
1518
  }
1507
- class ds {
1508
- constructor(e) {
1509
- m(this, "_initialData", []);
1510
- m(this, "_preparedData", []);
1511
- m(this, "_missingData", []);
1512
- m(this, "_count", 0);
1513
- this.update(e);
1519
+ class hn {
1520
+ constructor(e, t) {
1521
+ g(this, "_initialData", []);
1522
+ g(this, "_preparedData", []);
1523
+ g(this, "_missingData", []);
1524
+ g(this, "_count", 0);
1525
+ g(this, "_model");
1526
+ this._model = t, this.update(e);
1514
1527
  }
1515
1528
  _prepare(e) {
1516
- return e.map((t) => ({ ...t, open_time: new Date(t.open_time), close_time: new Date(t.close_time) })).sort((t, n) => t.open_time.getTime() - n.open_time.getTime());
1529
+ return e.map((t) => ({ ...t, open_time: new Date(t.open_time), close_time: new Date(t.close_time) })).sort((t, s) => t.open_time.getTime() - s.open_time.getTime());
1517
1530
  }
1518
1531
  update(e) {
1519
- this._initialData = e, this._preparedData = this._prepare(e), this._missingData = hs(this._preparedData), this._count = this._preparedData.length + this._missingData.length;
1532
+ this._initialData = e, this._preparedData = this._prepare(e), this._missingData = kt(this._preparedData, this._model), this._count = this._preparedData.length + this._missingData.length;
1533
+ }
1534
+ updateMissingCandles() {
1535
+ this._missingData = kt(this._preparedData, this._model);
1520
1536
  }
1521
1537
  get initialData() {
1522
1538
  return this._initialData;
@@ -1534,29 +1550,29 @@ class ds {
1534
1550
  return this._count;
1535
1551
  }
1536
1552
  }
1537
- class us {
1553
+ class dn {
1538
1554
  constructor() {
1539
- m(this, "listeners", {});
1555
+ g(this, "listeners", {});
1540
1556
  }
1541
1557
  subscribe(e, t) {
1542
1558
  return this.listeners[e] || (this.listeners[e] = []), this.listeners[e].push(t), () => this.unsubscribe(e, t);
1543
1559
  }
1544
1560
  unsubscribe(e, t) {
1545
- var n;
1546
- this.listeners[e] = ((n = this.listeners[e]) == null ? void 0 : n.filter((r) => r !== t)) || [];
1561
+ var s;
1562
+ this.listeners[e] = ((s = this.listeners[e]) == null ? void 0 : s.filter((r) => r !== t)) || [];
1547
1563
  }
1548
1564
  emit(e, ...t) {
1549
1565
  var r;
1550
- const n = t[0];
1551
- (r = this.listeners[e]) == null || r.forEach((s) => {
1552
- s(n);
1566
+ const s = t[0];
1567
+ (r = this.listeners[e]) == null || r.forEach((n) => {
1568
+ n(s);
1553
1569
  });
1554
1570
  }
1555
1571
  }
1556
- class Ve {
1572
+ class Ze {
1557
1573
  constructor(e, t) {
1558
- m(this, "_scale");
1559
- m(this, "_onChange");
1574
+ g(this, "_scale");
1575
+ g(this, "_onChange");
1560
1576
  this._scale = e, this._onChange = t;
1561
1577
  }
1562
1578
  reConstruct(e) {
@@ -1586,7 +1602,7 @@ class Ve {
1586
1602
  return this._scale.tickFormat(e, t);
1587
1603
  }
1588
1604
  copy() {
1589
- return new Ve(this._scale.copy(), this._onChange);
1605
+ return new Ze(this._scale.copy(), this._onChange);
1590
1606
  }
1591
1607
  raw() {
1592
1608
  return this._scale;
@@ -1595,10 +1611,10 @@ class Ve {
1595
1611
  return this._scale(e);
1596
1612
  }
1597
1613
  }
1598
- class Je {
1614
+ class Ve {
1599
1615
  constructor(e, t) {
1600
- m(this, "_scale");
1601
- m(this, "_onChange");
1616
+ g(this, "_scale");
1617
+ g(this, "_onChange");
1602
1618
  this._scale = e, this._onChange = t;
1603
1619
  }
1604
1620
  reConstruct(e) {
@@ -1630,7 +1646,7 @@ class Je {
1630
1646
  return this._scale.tickFormat(e, t);
1631
1647
  }
1632
1648
  copy() {
1633
- return new Je(this._scale.copy(), this._onChange);
1649
+ return new Ve(this._scale.copy(), this._onChange);
1634
1650
  }
1635
1651
  raw() {
1636
1652
  return this._scale;
@@ -1639,12 +1655,12 @@ class Je {
1639
1655
  return this._scale(e);
1640
1656
  }
1641
1657
  }
1642
- const fs = (i) => {
1658
+ const un = (i) => {
1643
1659
  const e = i.match(/^(\d+)([a-zA-Z]+)$/);
1644
1660
  if (!e)
1645
1661
  throw new Error(`Invalid offset format: "${i}"`);
1646
1662
  return [parseInt(e[1]), e[2]];
1647
- }, gs = {
1663
+ }, gn = {
1648
1664
  s: 1e3,
1649
1665
  M: 1e3 * 60,
1650
1666
  h: 1e3 * 60 * 60,
@@ -1653,41 +1669,41 @@ const fs = (i) => {
1653
1669
  }, Et = (i) => {
1654
1670
  const {
1655
1671
  candles: { preparedData: e, count: t },
1656
- layout: { area: n, xAxis: r },
1672
+ layout: { area: s, xAxis: r },
1657
1673
  config: {
1658
- candles: { offset: s, direction: o, baseWidth: l, bodyRatio: c }
1674
+ candles: { offset: n, direction: o, baseWidth: l, bodyRatio: h }
1659
1675
  }
1660
- } = i, d = k.extent(e, (N) => new Date(N.open_time));
1676
+ } = i, d = k.extent(e, (E) => new Date(E.open_time));
1661
1677
  if (!d[0] || !d[1])
1662
1678
  throw new Error("Cannot create scales: data is empty or invalid");
1663
- const u = d[0].getTime(), _ = d[1].getTime(), g = _ - u, p = l / c * t, v = g * (n.width / p), y = o === "left" ? [d[0], new Date(u + v)] : [new Date(_ - v), d[1]];
1679
+ const u = d[0].getTime(), _ = d[1].getTime(), m = _ - u, p = l / h * t, v = m * (s.width / p), y = o === "left" ? [d[0], new Date(u + v)] : [new Date(_ - v), d[1]];
1664
1680
  let b = k.scaleTime().domain(y).range([r.x, r.width]);
1665
- const [w, T] = fs(s);
1666
- let C = 0;
1667
- return T === "px" ? C = b.invert(r.x + w).getTime() - b.invert(r.x).getTime() : C = gs[T] * w, C *= o === "left" ? -1 : 1, b.domain([
1668
- new Date(y[0].getTime() + C),
1669
- new Date(y[1].getTime() + C)
1681
+ const [x, C] = un(n);
1682
+ let M = 0;
1683
+ return C === "px" ? M = b.invert(r.x + x).getTime() - b.invert(r.x).getTime() : M = gn[C] * x, M *= o === "left" ? -1 : 1, b.domain([
1684
+ new Date(y[0].getTime() + M),
1685
+ new Date(y[1].getTime() + M)
1670
1686
  ]), b;
1671
1687
  }, Dt = (i) => {
1672
1688
  const {
1673
1689
  candles: { preparedData: e },
1674
1690
  layout: { yAxis: t }
1675
- } = i, n = k.min(e, (s) => s.low), r = k.max(e, (s) => s.high);
1676
- if (n === void 0 || r === void 0)
1691
+ } = i, s = k.min(e, (n) => n.low), r = k.max(e, (n) => n.high);
1692
+ if (s === void 0 || r === void 0)
1677
1693
  throw new Error("Cannot create scales: data is empty or invalid");
1678
- return k.scaleLinear().domain([n, r]).range([t.y + t.height, t.y]);
1694
+ return k.scaleLinear().domain([s, r]).range([t.y + t.height, t.y]);
1679
1695
  };
1680
- class _s {
1696
+ class fn {
1681
1697
  constructor(e) {
1682
- m(this, "_scaleX");
1683
- m(this, "_scaleY");
1684
- m(this, "_scaleFactorX", 1);
1685
- m(this, "_scaleFactorY", 1);
1686
- m(this, "_model");
1687
- this._model = e, this._scaleX = new Ve(
1698
+ g(this, "_scaleX");
1699
+ g(this, "_scaleY");
1700
+ g(this, "_scaleFactorX", 1);
1701
+ g(this, "_scaleFactorY", 1);
1702
+ g(this, "_model");
1703
+ this._model = e, this._scaleX = new Ze(
1688
1704
  Et(this._model),
1689
1705
  () => e.eventBus.emit("scale_event")
1690
- ), this._scaleY = new Je(
1706
+ ), this._scaleY = new Ve(
1691
1707
  Dt(this._model),
1692
1708
  () => e.eventBus.emit("scale_event")
1693
1709
  );
@@ -1714,12 +1730,107 @@ class _s {
1714
1730
  this._scaleFactorY = e;
1715
1731
  }
1716
1732
  }
1717
- class Yt {
1733
+ class Lt {
1734
+ static parseTrades({ entry: e, exit: t }) {
1735
+ const s = e.map((n) => ({
1736
+ ...n,
1737
+ kind: "entry",
1738
+ time: new Date(n.time)
1739
+ })), r = t.map((n) => ({
1740
+ ...n,
1741
+ kind: "exit",
1742
+ time: new Date(n.time)
1743
+ }));
1744
+ return [...s, ...r];
1745
+ }
1746
+ static mapTradesToCandles(e, t) {
1747
+ return t.map((s) => {
1748
+ const r = e.filter(
1749
+ (n) => n.time >= s.open_time && n.time < s.close_time
1750
+ );
1751
+ return { candle: s, trades: r };
1752
+ }).filter((s) => s.trades.length > 0);
1753
+ }
1754
+ static createMarker(e, t, s) {
1755
+ return {
1756
+ type: "horizontal",
1757
+ value: s[e === "entry" ? "low" : "high"],
1758
+ formatter: (r) => `${e === "entry" ? "Entry" : "Exit"} | ${r}`,
1759
+ mainColor: t.main,
1760
+ lineColor: t.line,
1761
+ textColor: t.text
1762
+ };
1763
+ }
1764
+ }
1765
+ class _n {
1766
+ constructor(e, { entry: t = [], exit: s = [] }) {
1767
+ g(this, "_model");
1768
+ g(this, "_rawEntry");
1769
+ g(this, "_rawExit");
1770
+ g(this, "_mapped", []);
1771
+ g(this, "_entry", []);
1772
+ g(this, "_exit", []);
1773
+ g(this, "_timeRange", []);
1774
+ g(this, "_activeTradeTime", null);
1775
+ g(this, "_hoveredTradeTime", null);
1776
+ this._rawEntry = t, this._rawExit = s, this._model = e, this.recalculate();
1777
+ }
1778
+ _calcTimeRange() {
1779
+ const { allData: e } = this._model.candles, t = e.map((h) => h.open_time.getTime()), s = Ot(e[0]), r = Math.min(...this._entry.map((h) => h.time.getTime())), n = Math.max(...this._exit.map((h) => h.time.getTime())), o = t.findIndex((h) => h <= r && h + s >= r), l = t.findIndex((h) => h <= n && h + s >= n);
1780
+ return t.slice(o === -1 ? 0 : o, (l === -1 ? t.length - 1 : l) + 1);
1781
+ }
1782
+ recalculate() {
1783
+ const e = Lt.parseTrades({
1784
+ entry: this._rawEntry,
1785
+ exit: this._rawExit
1786
+ });
1787
+ this._mapped = Lt.mapTradesToCandles(e, this._model.candles.allData);
1788
+ const t = this._mapped.flatMap((s) => s.trades);
1789
+ this._entry = t.filter((s) => s.kind === "entry"), this._exit = t.filter((s) => s.kind === "exit"), this._timeRange = this._calcTimeRange();
1790
+ }
1791
+ updateTrade({ entry: e, exit: t }) {
1792
+ this._rawEntry = e, this._rawExit = t, this.recalculate();
1793
+ }
1794
+ setActiveTrade(e) {
1795
+ this._activeTradeTime = e, this._mapped = this._mapped.map((t) => ({
1796
+ ...t,
1797
+ isActive: t.candle.open_time.getTime() === e
1798
+ }));
1799
+ }
1800
+ setHoveredTrade(e) {
1801
+ this._hoveredTradeTime = e, this._mapped = this._mapped.map((t) => ({
1802
+ ...t,
1803
+ isHovered: t.candle.open_time.getTime() === e
1804
+ }));
1805
+ }
1806
+ get hasActiveTrade() {
1807
+ return this._activeTradeTime !== null;
1808
+ }
1809
+ get hasHoveredTrade() {
1810
+ return this._hoveredTradeTime !== null;
1811
+ }
1812
+ get tradedCandles() {
1813
+ return this._mapped;
1814
+ }
1815
+ get entries() {
1816
+ return this._entry;
1817
+ }
1818
+ get exits() {
1819
+ return this._exit;
1820
+ }
1821
+ get timeRange() {
1822
+ return this._timeRange;
1823
+ }
1824
+ get hasTrade() {
1825
+ return !!(this._rawEntry.length && this._rawExit.length);
1826
+ }
1827
+ }
1828
+ class mn {
1718
1829
  constructor(e, t) {
1719
- m(this, "_rawMarkers");
1720
- m(this, "_markers", []);
1721
- m(this, "_model");
1722
- m(this, "_defaults", {
1830
+ g(this, "_rawMarkers");
1831
+ g(this, "_markers", []);
1832
+ g(this, "_model");
1833
+ g(this, "_defaults", {
1723
1834
  mainColor: "#000000",
1724
1835
  textColor: "#ffffff",
1725
1836
  lineColor: "#000000",
@@ -1733,33 +1844,33 @@ class Yt {
1733
1844
  rebuild() {
1734
1845
  const {
1735
1846
  layout: { area: e, chart: t },
1736
- config: n,
1737
- scales: { x: r, y: s },
1847
+ config: s,
1848
+ scales: { x: r, y: n },
1738
1849
  colorScheme: {
1739
1850
  userMarkers: { default: o }
1740
1851
  }
1741
1852
  } = this._model;
1742
1853
  this._markers = this._rawMarkers.map((l) => {
1743
1854
  var u, _;
1744
- const c = {
1855
+ const h = {
1745
1856
  mainColor: l.mainColor ?? o.main,
1746
1857
  textColor: l.textColor ?? o.text,
1747
1858
  lineColor: l.lineColor ?? o.line
1748
1859
  };
1749
1860
  if ((l.type ?? "horizontal") === "horizontal") {
1750
- const g = l, p = s.map(g.value), y = (g.formatter ?? ((u = this._defaults.formatter) == null ? void 0 : u.horizontal) ?? ((b) => b.toString()))(g.value);
1861
+ const m = l, p = n.map(m.value), y = (m.formatter ?? ((u = this._defaults.formatter) == null ? void 0 : u.horizontal) ?? ((b) => b.toString()))(m.value);
1751
1862
  return {
1752
- value: g.value,
1863
+ value: m.value,
1753
1864
  type: "horizontal",
1754
1865
  text: y,
1755
1866
  x: e.x,
1756
1867
  y: p,
1757
1868
  lineLength: t.width,
1758
- position: n.yAxis.position,
1759
- ...c
1869
+ position: s.yAxis.position,
1870
+ ...h
1760
1871
  };
1761
1872
  } else {
1762
- const g = l, p = g.value instanceof Date ? g.value : new Date(g.value), v = r.map(p), b = (g.formatter ?? ((_ = this._defaults.formatter) == null ? void 0 : _.vertical) ?? ((w) => w.toLocaleString()))(p);
1873
+ const m = l, p = m.value instanceof Date ? m.value : new Date(m.value), v = r.map(p), b = (m.formatter ?? ((_ = this._defaults.formatter) == null ? void 0 : _.vertical) ?? ((x) => x.toLocaleString()))(p);
1763
1874
  return {
1764
1875
  value: p,
1765
1876
  type: "vertical",
@@ -1767,8 +1878,8 @@ class Yt {
1767
1878
  x: v,
1768
1879
  y: e.y,
1769
1880
  lineLength: t.height,
1770
- position: n.xAxis.position,
1771
- ...c
1881
+ position: s.xAxis.position,
1882
+ ...h
1772
1883
  };
1773
1884
  }
1774
1885
  });
@@ -1780,176 +1891,89 @@ class Yt {
1780
1891
  return this._markers;
1781
1892
  }
1782
1893
  }
1783
- class xe {
1784
- static parseTrades({ entry: e, exit: t }) {
1785
- const n = e.map((s) => ({
1786
- ...s,
1787
- kind: "entry",
1788
- time: new Date(s.time)
1789
- })), r = t.map((s) => ({
1790
- ...s,
1791
- kind: "exit",
1792
- time: new Date(s.time)
1793
- }));
1794
- return [...n, ...r];
1795
- }
1796
- static mapTradesToCandles(e, t) {
1797
- return t.map((n) => {
1798
- const r = e.filter(
1799
- (s) => s.time >= n.open_time && s.time < n.close_time
1800
- );
1801
- return { candle: n, trades: r };
1802
- }).filter((n) => n.trades.length > 0);
1803
- }
1804
- static createMarker(e, t, n) {
1805
- return {
1806
- type: "horizontal",
1807
- value: n[e === "entry" ? "low" : "high"],
1808
- formatter: (r) => `${e === "entry" ? "Entry" : "Exit"} | ${r}`,
1809
- mainColor: t.main,
1810
- lineColor: t.line,
1811
- textColor: t.text
1812
- };
1813
- }
1814
- }
1815
- class ms {
1816
- constructor(e, { entry: t = [], exit: n = [] }) {
1817
- m(this, "_model");
1818
- m(this, "_rawEntry");
1819
- m(this, "_rawExit");
1820
- m(this, "_mapped", []);
1821
- m(this, "_entry", []);
1822
- m(this, "_exit", []);
1823
- m(this, "_markers");
1824
- m(this, "_timeRange", []);
1825
- m(this, "_activeTradeTime", null);
1826
- this._rawEntry = t, this._rawExit = n, this._model = e, this._markers = new Yt(e, []), this.recalculate();
1827
- }
1828
- _createMarkers() {
1829
- const { trade: e } = this._model.colorScheme;
1830
- return this._mapped.flatMap(({ candle: t, trades: n }) => {
1831
- const r = [];
1832
- return n.some((s) => s.kind === "entry") && r.push(xe.createMarker("entry", e.entryMarker, t)), n.some((s) => s.kind === "exit") && r.push(xe.createMarker("exit", e.exitMarker, t)), r;
1894
+ class pn {
1895
+ constructor() {
1896
+ g(this, "bg", "#FFFFFF");
1897
+ g(this, "axisIntersection", "#FFFFFF");
1898
+ g(this, "xAxis", {
1899
+ bg: "#FFFFFF",
1900
+ text: "#7F7F83"
1833
1901
  });
1834
- }
1835
- _calcTimeRange() {
1836
- const { allData: e } = this._model.candles, t = e.map((c) => c.open_time.getTime()), n = jt(e[0]), r = Math.min(...this._entry.map((c) => c.time.getTime())), s = Math.max(...this._exit.map((c) => c.time.getTime())), o = t.findIndex((c) => c <= r && c + n >= r), l = t.findIndex((c) => c <= s && c + n >= s);
1837
- return t.slice(o === -1 ? 0 : o, (l === -1 ? t.length - 1 : l) + 1);
1838
- }
1839
- recalculate() {
1840
- const e = xe.parseTrades({
1841
- entry: this._rawEntry,
1842
- exit: this._rawExit
1902
+ g(this, "yAxis", {
1903
+ bg: "#FFFFFF",
1904
+ text: "#7F7F83"
1843
1905
  });
1844
- this._mapped = xe.mapTradesToCandles(e, this._model.candles.allData);
1845
- const t = this._mapped.flatMap((n) => n.trades);
1846
- this._entry = t.filter((n) => n.kind === "entry"), this._exit = t.filter((n) => n.kind === "exit"), this._markers.updateMarkers(this._createMarkers()), this._timeRange = this._calcTimeRange();
1847
- }
1848
- updateTrade({ entry: e, exit: t }) {
1849
- this._rawEntry = e, this._rawExit = t, this.recalculate();
1850
- }
1851
- setActiveTrade(e) {
1852
- this._activeTradeTime = e, this._mapped = this._mapped.map((t) => ({
1853
- ...t,
1854
- isActive: t.candle.open_time.getTime() === e
1855
- }));
1856
- }
1857
- get hasActiveTrade() {
1858
- return this._activeTradeTime !== null;
1859
- }
1860
- get tradedCandles() {
1861
- return this._mapped;
1862
- }
1863
- get entries() {
1864
- return this._entry;
1865
- }
1866
- get exits() {
1867
- return this._exit;
1868
- }
1869
- get markers() {
1870
- return this._markers;
1906
+ g(this, "candles", {
1907
+ risingFill: "#56B683",
1908
+ risingStroke: "#000000",
1909
+ fallingFill: "#F18169",
1910
+ fallingStroke: "#000000",
1911
+ noDataFill: ["#d9d9da", "#ededed"],
1912
+ noDataStroke: "#000000"
1913
+ });
1914
+ g(this, "guides", {
1915
+ horizontalMarker: {
1916
+ main: "#1C2026",
1917
+ text: "#ffffff",
1918
+ line: "#1C2026"
1919
+ },
1920
+ verticalMarker: {
1921
+ main: "#1C2026",
1922
+ text: "#ffffff",
1923
+ line: "#1C2026"
1924
+ }
1925
+ });
1926
+ g(this, "trade");
1927
+ g(this, "userMarkers");
1928
+ this.trade = {
1929
+ buyLabel: {
1930
+ main: this.candles.risingFill,
1931
+ text: "#ffffff"
1932
+ },
1933
+ sellLabel: {
1934
+ main: this.candles.fallingFill,
1935
+ text: "#ffffff"
1936
+ },
1937
+ connectionLine: "#D9D9DA",
1938
+ tradeBorders: "#EDEDED",
1939
+ activeLabel: "#007AFF"
1940
+ }, this.userMarkers = {
1941
+ default: {
1942
+ main: "#EDEDED",
1943
+ text: "#000000",
1944
+ line: "#EDEDED"
1945
+ }
1946
+ };
1871
1947
  }
1872
- get timeRange() {
1873
- return this._timeRange;
1948
+ toObject() {
1949
+ return {
1950
+ bg: this.bg,
1951
+ axisIntersection: this.axisIntersection,
1952
+ xAxis: this.xAxis,
1953
+ yAxis: this.yAxis,
1954
+ candles: this.candles,
1955
+ guides: this.guides,
1956
+ trade: this.trade,
1957
+ userMarkers: this.userMarkers
1958
+ };
1874
1959
  }
1875
1960
  }
1876
- const ps = {
1877
- bg: "#FFFFFF",
1878
- axisIntersection: "#FFFFFF",
1879
- xAxis: {
1880
- bg: "#FFFFFF",
1881
- text: "#7F7F83"
1882
- },
1883
- yAxis: {
1884
- bg: "#FFFFFF",
1885
- text: "#7F7F83"
1886
- },
1887
- candles: {
1888
- risingFill: "#56B683",
1889
- risingStroke: "#000000",
1890
- fallingFill: "#F18169",
1891
- fallingStroke: "#000000",
1892
- noDataFill: ["#d9d9da", "#ededed"],
1893
- noDataStroke: "#000000"
1894
- },
1895
- guides: {
1896
- horizontalMarker: {
1897
- main: "#1C2026",
1898
- text: "#ffffff",
1899
- line: "#1C2026"
1900
- },
1901
- verticalMarker: {
1902
- main: "#1C2026",
1903
- text: "#ffffff",
1904
- line: "#1C2026"
1905
- }
1906
- },
1907
- trade: {
1908
- entryMarker: {
1909
- main: "#56B683",
1910
- text: "#ffffff",
1911
- line: "#56B683"
1912
- },
1913
- exitMarker: {
1914
- main: "#F18169",
1915
- text: "#ffffff",
1916
- line: "#F18169"
1917
- },
1918
- entryLabel: {
1919
- main: "#56B683",
1920
- text: "#ffffff"
1921
- },
1922
- exitLabel: {
1923
- main: "#F18169",
1924
- text: "#ffffff"
1925
- },
1926
- connectionLine: "#D9D9DA",
1927
- tradeBorders: "#EDEDED",
1928
- activeLabel: "#007AFF"
1929
- },
1930
- userMarkers: {
1931
- default: {
1932
- main: "#EDEDED",
1933
- text: "#000000",
1934
- line: "#EDEDED"
1935
- }
1936
- }
1937
- };
1938
- class vs {
1961
+ const vn = new pn().toObject();
1962
+ class yn {
1939
1963
  constructor(e) {
1940
- m(this, "_bg");
1941
- m(this, "_candles");
1942
- m(this, "_xAxis");
1943
- m(this, "_yAxis");
1944
- m(this, "_guides");
1945
- m(this, "_axisIntersection");
1946
- m(this, "_trade");
1947
- m(this, "_userMarkers");
1948
- const t = Ce({}, ps, e);
1964
+ g(this, "_bg");
1965
+ g(this, "_candles");
1966
+ g(this, "_xAxis");
1967
+ g(this, "_yAxis");
1968
+ g(this, "_guides");
1969
+ g(this, "_axisIntersection");
1970
+ g(this, "_trade");
1971
+ g(this, "_userMarkers");
1972
+ const t = we({}, vn, e);
1949
1973
  this._candles = t.candles, this._bg = t.bg, this._xAxis = t.xAxis, this._yAxis = t.yAxis, this._guides = t.guides, this._axisIntersection = t.axisIntersection, this._trade = t.trade, this._userMarkers = t.userMarkers;
1950
1974
  }
1951
1975
  update(e) {
1952
- const t = Ce(
1976
+ const t = we(
1953
1977
  {},
1954
1978
  {
1955
1979
  bg: this._bg,
@@ -1990,27 +2014,27 @@ class vs {
1990
2014
  return this._userMarkers;
1991
2015
  }
1992
2016
  }
1993
- class ys {
2017
+ class bn {
1994
2018
  constructor({
1995
2019
  chartId: e,
1996
2020
  container: t,
1997
- candles: n,
2021
+ candles: s,
1998
2022
  config: r,
1999
- trade: s = { entry: [], exit: [] },
2023
+ trade: n = { entry: [], exit: [] },
2000
2024
  userMarkers: o = [],
2001
2025
  colorScheme: l
2002
2026
  }) {
2003
- m(this, "_chartId");
2004
- m(this, "_container");
2005
- m(this, "_eventBus", new us());
2006
- m(this, "_candles");
2007
- m(this, "_config");
2008
- m(this, "_colorScheme");
2009
- m(this, "_layout");
2010
- m(this, "_scaleManager");
2011
- m(this, "_trade");
2012
- m(this, "_userMarkers");
2013
- this._chartId = e, this._container = t, this._candles = new ds(n), this._config = new os(r), this._colorScheme = new vs(l), this._layout = new ls(t, this._config), this._scaleManager = new _s(this), this._trade = new ms(this, s), this._userMarkers = new Yt(this, o);
2027
+ g(this, "_chartId");
2028
+ g(this, "_container");
2029
+ g(this, "_eventBus", new dn());
2030
+ g(this, "_candles");
2031
+ g(this, "_config");
2032
+ g(this, "_colorScheme");
2033
+ g(this, "_layout");
2034
+ g(this, "_scaleManager");
2035
+ g(this, "_trade");
2036
+ g(this, "_userMarkers");
2037
+ this._chartId = e, this._container = t, this._candles = new hn(s, this), this._config = new on(r), this._colorScheme = new yn(l), this._layout = new ln(t, this._config), this._scaleManager = new fn(this), this._trade = new _n(this, n), this._candles.updateMissingCandles(), this._trade.recalculate(), this._userMarkers = new mn(this, o);
2014
2038
  }
2015
2039
  init() {
2016
2040
  this._eventBus.emit("init_model");
@@ -2067,18 +2091,18 @@ class ys {
2067
2091
  return this._colorScheme;
2068
2092
  }
2069
2093
  }
2070
- const we = window.devicePixelRatio || 2;
2094
+ const xe = window.devicePixelRatio || 2;
2071
2095
  class R {
2072
- constructor({ tag: e, className: t, id: n, textContent: r }) {
2073
- m(this, "_tag");
2074
- m(this, "_className");
2075
- m(this, "_id");
2076
- m(this, "_textContent");
2077
- m(this, "_node");
2078
- m(this, "_absolutePosition", new DOMRect());
2079
- this._tag = e || "div", this._className = t || "", this._id = n || "", this._textContent = r || "";
2080
- const s = document.createElement(this._tag);
2081
- this._className && (s.className = this._className), this._id && (s.id = this._id), this._textContent && (s.textContent = this._textContent), this._node = s;
2096
+ constructor({ tag: e, className: t, id: s, textContent: r }) {
2097
+ g(this, "_tag");
2098
+ g(this, "_className");
2099
+ g(this, "_id");
2100
+ g(this, "_textContent");
2101
+ g(this, "_node");
2102
+ g(this, "_absolutePosition", new DOMRect());
2103
+ this._tag = e || "div", this._className = t || "", this._id = s || "", this._textContent = r || "";
2104
+ const n = document.createElement(this._tag);
2105
+ this._className && (n.className = this._className), this._id && (n.id = this._id), this._textContent && (n.textContent = this._textContent), this._node = n;
2082
2106
  }
2083
2107
  get node() {
2084
2108
  return this._node;
@@ -2099,24 +2123,24 @@ class R {
2099
2123
  this._absolutePosition = this._node.getBoundingClientRect();
2100
2124
  }
2101
2125
  }
2102
- class Te extends R {
2103
- constructor({ className: t, id: n, width: r, height: s, isMain: o }) {
2126
+ class Me extends R {
2127
+ constructor({ className: t, id: s, width: r, height: n, isMain: o }) {
2104
2128
  super({
2105
2129
  tag: "canvas",
2106
2130
  className: `${t} sc-charts-cs__canvas ${o ? "" : "sc-charts-cs__canvas-additional"}`,
2107
- id: n
2131
+ id: s
2108
2132
  });
2109
- m(this, "_ctx");
2110
- m(this, "_width");
2111
- m(this, "_height");
2112
- m(this, "background", null);
2113
- this._width = r, this._height = s, this.updateSize({ width: r, height: s });
2133
+ g(this, "_ctx");
2134
+ g(this, "_width");
2135
+ g(this, "_height");
2136
+ g(this, "background", null);
2137
+ this._width = r, this._height = n, this.updateSize({ width: r, height: n });
2114
2138
  const l = this._node.getContext("2d");
2115
2139
  if (!l) throw new Error("Failed to get 2D context");
2116
- l.scale(we, we), this._ctx = l;
2140
+ l.scale(xe, xe), this._ctx = l;
2117
2141
  }
2118
- updateSize({ width: t, height: n }) {
2119
- t && (this._node.width = t * we, this._node.style.width = `${t}px`, this._width = t), n && (this._node.height = n * we, this._node.style.height = `${n}px`, this._height = n);
2142
+ updateSize({ width: t, height: s }) {
2143
+ t && (this._node.width = t * xe, this._node.style.width = `${t}px`, this._width = t), s && (this._node.height = s * xe, this._node.style.height = `${s}px`, this._height = s);
2120
2144
  }
2121
2145
  clear() {
2122
2146
  this.background ? (this._ctx.save(), this._ctx.fillStyle = this.background, this._ctx.fillRect(0, 0, this._width, this._height), this._ctx.restore()) : this._ctx.clearRect(0, 0, this._width, this._height);
@@ -2131,24 +2155,24 @@ class Te extends R {
2131
2155
  return this._height;
2132
2156
  }
2133
2157
  }
2134
- function Ae(i) {
2158
+ function Te(i) {
2135
2159
  "@babel/helpers - typeof";
2136
- return Ae = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
2160
+ return Te = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
2137
2161
  return typeof e;
2138
2162
  } : function(e) {
2139
2163
  return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
2140
- }, Ae(i);
2164
+ }, Te(i);
2141
2165
  }
2142
- var bs = /^\s+/, xs = /\s+$/;
2143
- function M(i, e) {
2144
- if (i = i || "", e = e || {}, i instanceof M)
2166
+ var xn = /^\s+/, wn = /\s+$/;
2167
+ function T(i, e) {
2168
+ if (i = i || "", e = e || {}, i instanceof T)
2145
2169
  return i;
2146
- if (!(this instanceof M))
2147
- return new M(i, e);
2148
- var t = ws(i);
2170
+ if (!(this instanceof T))
2171
+ return new T(i, e);
2172
+ var t = Mn(i);
2149
2173
  this._originalInput = i, this._r = t.r, this._g = t.g, this._b = t.b, this._a = t.a, this._roundA = Math.round(100 * this._a) / 100, this._format = e.format || t.format, this._gradientType = e.gradientType, this._r < 1 && (this._r = Math.round(this._r)), this._g < 1 && (this._g = Math.round(this._g)), this._b < 1 && (this._b = Math.round(this._b)), this._ok = t.ok;
2150
2174
  }
2151
- M.prototype = {
2175
+ T.prototype = {
2152
2176
  isDark: function() {
2153
2177
  return this.getBrightness() < 128;
2154
2178
  },
@@ -2172,14 +2196,14 @@ M.prototype = {
2172
2196
  return (e.r * 299 + e.g * 587 + e.b * 114) / 1e3;
2173
2197
  },
2174
2198
  getLuminance: function() {
2175
- var e = this.toRgb(), t, n, r, s, o, l;
2176
- return t = e.r / 255, n = e.g / 255, r = e.b / 255, t <= 0.03928 ? s = t / 12.92 : s = Math.pow((t + 0.055) / 1.055, 2.4), n <= 0.03928 ? o = n / 12.92 : o = Math.pow((n + 0.055) / 1.055, 2.4), r <= 0.03928 ? l = r / 12.92 : l = Math.pow((r + 0.055) / 1.055, 2.4), 0.2126 * s + 0.7152 * o + 0.0722 * l;
2199
+ var e = this.toRgb(), t, s, r, n, o, l;
2200
+ return t = e.r / 255, s = e.g / 255, r = e.b / 255, t <= 0.03928 ? n = t / 12.92 : n = Math.pow((t + 0.055) / 1.055, 2.4), s <= 0.03928 ? o = s / 12.92 : o = Math.pow((s + 0.055) / 1.055, 2.4), r <= 0.03928 ? l = r / 12.92 : l = Math.pow((r + 0.055) / 1.055, 2.4), 0.2126 * n + 0.7152 * o + 0.0722 * l;
2177
2201
  },
2178
2202
  setAlpha: function(e) {
2179
- return this._a = Wt(e), this._roundA = Math.round(100 * this._a) / 100, this;
2203
+ return this._a = Yt(e), this._roundA = Math.round(100 * this._a) / 100, this;
2180
2204
  },
2181
2205
  toHsv: function() {
2182
- var e = Lt(this._r, this._g, this._b);
2206
+ var e = Ht(this._r, this._g, this._b);
2183
2207
  return {
2184
2208
  h: e.h * 360,
2185
2209
  s: e.s,
@@ -2188,8 +2212,8 @@ M.prototype = {
2188
2212
  };
2189
2213
  },
2190
2214
  toHsvString: function() {
2191
- var e = Lt(this._r, this._g, this._b), t = Math.round(e.h * 360), n = Math.round(e.s * 100), r = Math.round(e.v * 100);
2192
- return this._a == 1 ? "hsv(" + t + ", " + n + "%, " + r + "%)" : "hsva(" + t + ", " + n + "%, " + r + "%, " + this._roundA + ")";
2215
+ var e = Ht(this._r, this._g, this._b), t = Math.round(e.h * 360), s = Math.round(e.s * 100), r = Math.round(e.v * 100);
2216
+ return this._a == 1 ? "hsv(" + t + ", " + s + "%, " + r + "%)" : "hsva(" + t + ", " + s + "%, " + r + "%, " + this._roundA + ")";
2193
2217
  },
2194
2218
  toHsl: function() {
2195
2219
  var e = Nt(this._r, this._g, this._b);
@@ -2201,8 +2225,8 @@ M.prototype = {
2201
2225
  };
2202
2226
  },
2203
2227
  toHslString: function() {
2204
- var e = Nt(this._r, this._g, this._b), t = Math.round(e.h * 360), n = Math.round(e.s * 100), r = Math.round(e.l * 100);
2205
- return this._a == 1 ? "hsl(" + t + ", " + n + "%, " + r + "%)" : "hsla(" + t + ", " + n + "%, " + r + "%, " + this._roundA + ")";
2228
+ var e = Nt(this._r, this._g, this._b), t = Math.round(e.h * 360), s = Math.round(e.s * 100), r = Math.round(e.l * 100);
2229
+ return this._a == 1 ? "hsl(" + t + ", " + s + "%, " + r + "%)" : "hsla(" + t + ", " + s + "%, " + r + "%, " + this._roundA + ")";
2206
2230
  },
2207
2231
  toHex: function(e) {
2208
2232
  return It(this._r, this._g, this._b, e);
@@ -2211,7 +2235,7 @@ M.prototype = {
2211
2235
  return "#" + this.toHex(e);
2212
2236
  },
2213
2237
  toHex8: function(e) {
2214
- return As(this._r, this._g, this._b, this._a, e);
2238
+ return Sn(this._r, this._g, this._b, this._a, e);
2215
2239
  },
2216
2240
  toHex8String: function(e) {
2217
2241
  return "#" + this.toHex8(e);
@@ -2229,102 +2253,102 @@ M.prototype = {
2229
2253
  },
2230
2254
  toPercentageRgb: function() {
2231
2255
  return {
2232
- r: Math.round(F(this._r, 255) * 100) + "%",
2233
- g: Math.round(F(this._g, 255) * 100) + "%",
2234
- b: Math.round(F(this._b, 255) * 100) + "%",
2256
+ r: Math.round(I(this._r, 255) * 100) + "%",
2257
+ g: Math.round(I(this._g, 255) * 100) + "%",
2258
+ b: Math.round(I(this._b, 255) * 100) + "%",
2235
2259
  a: this._a
2236
2260
  };
2237
2261
  },
2238
2262
  toPercentageRgbString: function() {
2239
- return this._a == 1 ? "rgb(" + Math.round(F(this._r, 255) * 100) + "%, " + Math.round(F(this._g, 255) * 100) + "%, " + Math.round(F(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(F(this._r, 255) * 100) + "%, " + Math.round(F(this._g, 255) * 100) + "%, " + Math.round(F(this._b, 255) * 100) + "%, " + this._roundA + ")";
2263
+ return this._a == 1 ? "rgb(" + Math.round(I(this._r, 255) * 100) + "%, " + Math.round(I(this._g, 255) * 100) + "%, " + Math.round(I(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(I(this._r, 255) * 100) + "%, " + Math.round(I(this._g, 255) * 100) + "%, " + Math.round(I(this._b, 255) * 100) + "%, " + this._roundA + ")";
2240
2264
  },
2241
2265
  toName: function() {
2242
- return this._a === 0 ? "transparent" : this._a < 1 ? !1 : Bs[It(this._r, this._g, this._b, !0)] || !1;
2266
+ return this._a === 0 ? "transparent" : this._a < 1 ? !1 : $n[It(this._r, this._g, this._b, !0)] || !1;
2243
2267
  },
2244
2268
  toFilter: function(e) {
2245
- var t = "#" + Ft(this._r, this._g, this._b, this._a), n = t, r = this._gradientType ? "GradientType = 1, " : "";
2269
+ var t = "#" + Rt(this._r, this._g, this._b, this._a), s = t, r = this._gradientType ? "GradientType = 1, " : "";
2246
2270
  if (e) {
2247
- var s = M(e);
2248
- n = "#" + Ft(s._r, s._g, s._b, s._a);
2271
+ var n = T(e);
2272
+ s = "#" + Rt(n._r, n._g, n._b, n._a);
2249
2273
  }
2250
- return "progid:DXImageTransform.Microsoft.gradient(" + r + "startColorstr=" + t + ",endColorstr=" + n + ")";
2274
+ return "progid:DXImageTransform.Microsoft.gradient(" + r + "startColorstr=" + t + ",endColorstr=" + s + ")";
2251
2275
  },
2252
2276
  toString: function(e) {
2253
2277
  var t = !!e;
2254
2278
  e = e || this._format;
2255
- var n = !1, r = this._a < 1 && this._a >= 0, s = !t && r && (e === "hex" || e === "hex6" || e === "hex3" || e === "hex4" || e === "hex8" || e === "name");
2256
- return s ? e === "name" && this._a === 0 ? this.toName() : this.toRgbString() : (e === "rgb" && (n = this.toRgbString()), e === "prgb" && (n = this.toPercentageRgbString()), (e === "hex" || e === "hex6") && (n = this.toHexString()), e === "hex3" && (n = this.toHexString(!0)), e === "hex4" && (n = this.toHex8String(!0)), e === "hex8" && (n = this.toHex8String()), e === "name" && (n = this.toName()), e === "hsl" && (n = this.toHslString()), e === "hsv" && (n = this.toHsvString()), n || this.toHexString());
2279
+ var s = !1, r = this._a < 1 && this._a >= 0, n = !t && r && (e === "hex" || e === "hex6" || e === "hex3" || e === "hex4" || e === "hex8" || e === "name");
2280
+ return n ? e === "name" && this._a === 0 ? this.toName() : this.toRgbString() : (e === "rgb" && (s = this.toRgbString()), e === "prgb" && (s = this.toPercentageRgbString()), (e === "hex" || e === "hex6") && (s = this.toHexString()), e === "hex3" && (s = this.toHexString(!0)), e === "hex4" && (s = this.toHex8String(!0)), e === "hex8" && (s = this.toHex8String()), e === "name" && (s = this.toName()), e === "hsl" && (s = this.toHslString()), e === "hsv" && (s = this.toHsvString()), s || this.toHexString());
2257
2281
  },
2258
2282
  clone: function() {
2259
- return M(this.toString());
2283
+ return T(this.toString());
2260
2284
  },
2261
2285
  _applyModification: function(e, t) {
2262
- var n = e.apply(null, [this].concat([].slice.call(t)));
2263
- return this._r = n._r, this._g = n._g, this._b = n._b, this.setAlpha(n._a), this;
2286
+ var s = e.apply(null, [this].concat([].slice.call(t)));
2287
+ return this._r = s._r, this._g = s._g, this._b = s._b, this.setAlpha(s._a), this;
2264
2288
  },
2265
2289
  lighten: function() {
2266
- return this._applyModification(Ds, arguments);
2290
+ return this._applyModification(Ln, arguments);
2267
2291
  },
2268
2292
  brighten: function() {
2269
- return this._applyModification(Ns, arguments);
2293
+ return this._applyModification(Nn, arguments);
2270
2294
  },
2271
2295
  darken: function() {
2272
- return this._applyModification(Ls, arguments);
2296
+ return this._applyModification(Hn, arguments);
2273
2297
  },
2274
2298
  desaturate: function() {
2275
- return this._applyModification(Ss, arguments);
2299
+ return this._applyModification(kn, arguments);
2276
2300
  },
2277
2301
  saturate: function() {
2278
- return this._applyModification(ks, arguments);
2302
+ return this._applyModification(En, arguments);
2279
2303
  },
2280
2304
  greyscale: function() {
2281
- return this._applyModification(Es, arguments);
2305
+ return this._applyModification(Dn, arguments);
2282
2306
  },
2283
2307
  spin: function() {
2284
- return this._applyModification(Is, arguments);
2308
+ return this._applyModification(In, arguments);
2285
2309
  },
2286
2310
  _applyCombination: function(e, t) {
2287
2311
  return e.apply(null, [this].concat([].slice.call(t)));
2288
2312
  },
2289
2313
  analogous: function() {
2290
- return this._applyCombination(zs, arguments);
2314
+ return this._applyCombination(zn, arguments);
2291
2315
  },
2292
2316
  complement: function() {
2293
- return this._applyCombination(Fs, arguments);
2317
+ return this._applyCombination(Rn, arguments);
2294
2318
  },
2295
2319
  monochromatic: function() {
2296
- return this._applyCombination($s, arguments);
2320
+ return this._applyCombination(Bn, arguments);
2297
2321
  },
2298
2322
  splitcomplement: function() {
2299
- return this._applyCombination(Rs, arguments);
2323
+ return this._applyCombination(Fn, arguments);
2300
2324
  },
2301
2325
  // Disabled until https://github.com/bgrins/TinyColor/issues/254
2302
2326
  // polyad: function (number) {
2303
2327
  // return this._applyCombination(polyad, [number]);
2304
2328
  // },
2305
2329
  triad: function() {
2306
- return this._applyCombination(Rt, [3]);
2330
+ return this._applyCombination(Ft, [3]);
2307
2331
  },
2308
2332
  tetrad: function() {
2309
- return this._applyCombination(Rt, [4]);
2333
+ return this._applyCombination(Ft, [4]);
2310
2334
  }
2311
2335
  };
2312
- M.fromRatio = function(i, e) {
2313
- if (Ae(i) == "object") {
2336
+ T.fromRatio = function(i, e) {
2337
+ if (Te(i) == "object") {
2314
2338
  var t = {};
2315
- for (var n in i)
2316
- i.hasOwnProperty(n) && (n === "a" ? t[n] = i[n] : t[n] = ce(i[n]));
2339
+ for (var s in i)
2340
+ i.hasOwnProperty(s) && (s === "a" ? t[s] = i[s] : t[s] = ce(i[s]));
2317
2341
  i = t;
2318
2342
  }
2319
- return M(i, e);
2343
+ return T(i, e);
2320
2344
  };
2321
- function ws(i) {
2345
+ function Mn(i) {
2322
2346
  var e = {
2323
2347
  r: 0,
2324
2348
  g: 0,
2325
2349
  b: 0
2326
- }, t = 1, n = null, r = null, s = null, o = !1, l = !1;
2327
- return typeof i == "string" && (i = js(i)), Ae(i) == "object" && (Z(i.r) && Z(i.g) && Z(i.b) ? (e = Ms(i.r, i.g, i.b), o = !0, l = String(i.r).substr(-1) === "%" ? "prgb" : "rgb") : Z(i.h) && Z(i.s) && Z(i.v) ? (n = ce(i.s), r = ce(i.v), e = Ts(i.h, n, r), o = !0, l = "hsv") : Z(i.h) && Z(i.s) && Z(i.l) && (n = ce(i.s), s = ce(i.l), e = Cs(i.h, n, s), o = !0, l = "hsl"), i.hasOwnProperty("a") && (t = i.a)), t = Wt(t), {
2350
+ }, t = 1, s = null, r = null, n = null, o = !1, l = !1;
2351
+ return typeof i == "string" && (i = jn(i)), Te(i) == "object" && (U(i.r) && U(i.g) && U(i.b) ? (e = Tn(i.r, i.g, i.b), o = !0, l = String(i.r).substr(-1) === "%" ? "prgb" : "rgb") : U(i.h) && U(i.s) && U(i.v) ? (s = ce(i.s), r = ce(i.v), e = An(i.h, s, r), o = !0, l = "hsv") : U(i.h) && U(i.s) && U(i.l) && (s = ce(i.s), n = ce(i.l), e = Cn(i.h, s, n), o = !0, l = "hsl"), i.hasOwnProperty("a") && (t = i.a)), t = Yt(t), {
2328
2352
  ok: o,
2329
2353
  format: i.format || l,
2330
2354
  r: Math.min(255, Math.max(e.r, 0)),
@@ -2333,230 +2357,230 @@ function ws(i) {
2333
2357
  a: t
2334
2358
  };
2335
2359
  }
2336
- function Ms(i, e, t) {
2360
+ function Tn(i, e, t) {
2337
2361
  return {
2338
- r: F(i, 255) * 255,
2339
- g: F(e, 255) * 255,
2340
- b: F(t, 255) * 255
2362
+ r: I(i, 255) * 255,
2363
+ g: I(e, 255) * 255,
2364
+ b: I(t, 255) * 255
2341
2365
  };
2342
2366
  }
2343
2367
  function Nt(i, e, t) {
2344
- i = F(i, 255), e = F(e, 255), t = F(t, 255);
2345
- var n = Math.max(i, e, t), r = Math.min(i, e, t), s, o, l = (n + r) / 2;
2346
- if (n == r)
2347
- s = o = 0;
2368
+ i = I(i, 255), e = I(e, 255), t = I(t, 255);
2369
+ var s = Math.max(i, e, t), r = Math.min(i, e, t), n, o, l = (s + r) / 2;
2370
+ if (s == r)
2371
+ n = o = 0;
2348
2372
  else {
2349
- var c = n - r;
2350
- switch (o = l > 0.5 ? c / (2 - n - r) : c / (n + r), n) {
2373
+ var h = s - r;
2374
+ switch (o = l > 0.5 ? h / (2 - s - r) : h / (s + r), s) {
2351
2375
  case i:
2352
- s = (e - t) / c + (e < t ? 6 : 0);
2376
+ n = (e - t) / h + (e < t ? 6 : 0);
2353
2377
  break;
2354
2378
  case e:
2355
- s = (t - i) / c + 2;
2379
+ n = (t - i) / h + 2;
2356
2380
  break;
2357
2381
  case t:
2358
- s = (i - e) / c + 4;
2382
+ n = (i - e) / h + 4;
2359
2383
  break;
2360
2384
  }
2361
- s /= 6;
2385
+ n /= 6;
2362
2386
  }
2363
2387
  return {
2364
- h: s,
2388
+ h: n,
2365
2389
  s: o,
2366
2390
  l
2367
2391
  };
2368
2392
  }
2369
- function Cs(i, e, t) {
2370
- var n, r, s;
2371
- i = F(i, 360), e = F(e, 100), t = F(t, 100);
2393
+ function Cn(i, e, t) {
2394
+ var s, r, n;
2395
+ i = I(i, 360), e = I(e, 100), t = I(t, 100);
2372
2396
  function o(d, u, _) {
2373
2397
  return _ < 0 && (_ += 1), _ > 1 && (_ -= 1), _ < 1 / 6 ? d + (u - d) * 6 * _ : _ < 1 / 2 ? u : _ < 2 / 3 ? d + (u - d) * (2 / 3 - _) * 6 : d;
2374
2398
  }
2375
2399
  if (e === 0)
2376
- n = r = s = t;
2400
+ s = r = n = t;
2377
2401
  else {
2378
- var l = t < 0.5 ? t * (1 + e) : t + e - t * e, c = 2 * t - l;
2379
- n = o(c, l, i + 1 / 3), r = o(c, l, i), s = o(c, l, i - 1 / 3);
2402
+ var l = t < 0.5 ? t * (1 + e) : t + e - t * e, h = 2 * t - l;
2403
+ s = o(h, l, i + 1 / 3), r = o(h, l, i), n = o(h, l, i - 1 / 3);
2380
2404
  }
2381
2405
  return {
2382
- r: n * 255,
2406
+ r: s * 255,
2383
2407
  g: r * 255,
2384
- b: s * 255
2408
+ b: n * 255
2385
2409
  };
2386
2410
  }
2387
- function Lt(i, e, t) {
2388
- i = F(i, 255), e = F(e, 255), t = F(t, 255);
2389
- var n = Math.max(i, e, t), r = Math.min(i, e, t), s, o, l = n, c = n - r;
2390
- if (o = n === 0 ? 0 : c / n, n == r)
2391
- s = 0;
2411
+ function Ht(i, e, t) {
2412
+ i = I(i, 255), e = I(e, 255), t = I(t, 255);
2413
+ var s = Math.max(i, e, t), r = Math.min(i, e, t), n, o, l = s, h = s - r;
2414
+ if (o = s === 0 ? 0 : h / s, s == r)
2415
+ n = 0;
2392
2416
  else {
2393
- switch (n) {
2417
+ switch (s) {
2394
2418
  case i:
2395
- s = (e - t) / c + (e < t ? 6 : 0);
2419
+ n = (e - t) / h + (e < t ? 6 : 0);
2396
2420
  break;
2397
2421
  case e:
2398
- s = (t - i) / c + 2;
2422
+ n = (t - i) / h + 2;
2399
2423
  break;
2400
2424
  case t:
2401
- s = (i - e) / c + 4;
2425
+ n = (i - e) / h + 4;
2402
2426
  break;
2403
2427
  }
2404
- s /= 6;
2428
+ n /= 6;
2405
2429
  }
2406
2430
  return {
2407
- h: s,
2431
+ h: n,
2408
2432
  s: o,
2409
2433
  v: l
2410
2434
  };
2411
2435
  }
2412
- function Ts(i, e, t) {
2413
- i = F(i, 360) * 6, e = F(e, 100), t = F(t, 100);
2414
- var n = Math.floor(i), r = i - n, s = t * (1 - e), o = t * (1 - r * e), l = t * (1 - (1 - r) * e), c = n % 6, d = [t, o, s, s, l, t][c], u = [l, t, t, o, s, s][c], _ = [s, s, l, t, t, o][c];
2436
+ function An(i, e, t) {
2437
+ i = I(i, 360) * 6, e = I(e, 100), t = I(t, 100);
2438
+ var s = Math.floor(i), r = i - s, n = t * (1 - e), o = t * (1 - r * e), l = t * (1 - (1 - r) * e), h = s % 6, d = [t, o, n, n, l, t][h], u = [l, t, t, o, n, n][h], _ = [n, n, l, t, t, o][h];
2415
2439
  return {
2416
2440
  r: d * 255,
2417
2441
  g: u * 255,
2418
2442
  b: _ * 255
2419
2443
  };
2420
2444
  }
2421
- function It(i, e, t, n) {
2422
- var r = [Y(Math.round(i).toString(16)), Y(Math.round(e).toString(16)), Y(Math.round(t).toString(16))];
2423
- return n && r[0].charAt(0) == r[0].charAt(1) && r[1].charAt(0) == r[1].charAt(1) && r[2].charAt(0) == r[2].charAt(1) ? r[0].charAt(0) + r[1].charAt(0) + r[2].charAt(0) : r.join("");
2445
+ function It(i, e, t, s) {
2446
+ var r = [X(Math.round(i).toString(16)), X(Math.round(e).toString(16)), X(Math.round(t).toString(16))];
2447
+ return s && r[0].charAt(0) == r[0].charAt(1) && r[1].charAt(0) == r[1].charAt(1) && r[2].charAt(0) == r[2].charAt(1) ? r[0].charAt(0) + r[1].charAt(0) + r[2].charAt(0) : r.join("");
2424
2448
  }
2425
- function As(i, e, t, n, r) {
2426
- var s = [Y(Math.round(i).toString(16)), Y(Math.round(e).toString(16)), Y(Math.round(t).toString(16)), Y(Xt(n))];
2427
- return r && s[0].charAt(0) == s[0].charAt(1) && s[1].charAt(0) == s[1].charAt(1) && s[2].charAt(0) == s[2].charAt(1) && s[3].charAt(0) == s[3].charAt(1) ? s[0].charAt(0) + s[1].charAt(0) + s[2].charAt(0) + s[3].charAt(0) : s.join("");
2449
+ function Sn(i, e, t, s, r) {
2450
+ var n = [X(Math.round(i).toString(16)), X(Math.round(e).toString(16)), X(Math.round(t).toString(16)), X(jt(s))];
2451
+ return r && n[0].charAt(0) == n[0].charAt(1) && n[1].charAt(0) == n[1].charAt(1) && n[2].charAt(0) == n[2].charAt(1) && n[3].charAt(0) == n[3].charAt(1) ? n[0].charAt(0) + n[1].charAt(0) + n[2].charAt(0) + n[3].charAt(0) : n.join("");
2428
2452
  }
2429
- function Ft(i, e, t, n) {
2430
- var r = [Y(Xt(n)), Y(Math.round(i).toString(16)), Y(Math.round(e).toString(16)), Y(Math.round(t).toString(16))];
2453
+ function Rt(i, e, t, s) {
2454
+ var r = [X(jt(s)), X(Math.round(i).toString(16)), X(Math.round(e).toString(16)), X(Math.round(t).toString(16))];
2431
2455
  return r.join("");
2432
2456
  }
2433
- M.equals = function(i, e) {
2434
- return !i || !e ? !1 : M(i).toRgbString() == M(e).toRgbString();
2457
+ T.equals = function(i, e) {
2458
+ return !i || !e ? !1 : T(i).toRgbString() == T(e).toRgbString();
2435
2459
  };
2436
- M.random = function() {
2437
- return M.fromRatio({
2460
+ T.random = function() {
2461
+ return T.fromRatio({
2438
2462
  r: Math.random(),
2439
2463
  g: Math.random(),
2440
2464
  b: Math.random()
2441
2465
  });
2442
2466
  };
2443
- function Ss(i, e) {
2467
+ function kn(i, e) {
2444
2468
  e = e === 0 ? 0 : e || 10;
2445
- var t = M(i).toHsl();
2446
- return t.s -= e / 100, t.s = ke(t.s), M(t);
2469
+ var t = T(i).toHsl();
2470
+ return t.s -= e / 100, t.s = Se(t.s), T(t);
2447
2471
  }
2448
- function ks(i, e) {
2472
+ function En(i, e) {
2449
2473
  e = e === 0 ? 0 : e || 10;
2450
- var t = M(i).toHsl();
2451
- return t.s += e / 100, t.s = ke(t.s), M(t);
2474
+ var t = T(i).toHsl();
2475
+ return t.s += e / 100, t.s = Se(t.s), T(t);
2452
2476
  }
2453
- function Es(i) {
2454
- return M(i).desaturate(100);
2477
+ function Dn(i) {
2478
+ return T(i).desaturate(100);
2455
2479
  }
2456
- function Ds(i, e) {
2480
+ function Ln(i, e) {
2457
2481
  e = e === 0 ? 0 : e || 10;
2458
- var t = M(i).toHsl();
2459
- return t.l += e / 100, t.l = ke(t.l), M(t);
2482
+ var t = T(i).toHsl();
2483
+ return t.l += e / 100, t.l = Se(t.l), T(t);
2460
2484
  }
2461
- function Ns(i, e) {
2485
+ function Nn(i, e) {
2462
2486
  e = e === 0 ? 0 : e || 10;
2463
- var t = M(i).toRgb();
2464
- return t.r = Math.max(0, Math.min(255, t.r - Math.round(255 * -(e / 100)))), t.g = Math.max(0, Math.min(255, t.g - Math.round(255 * -(e / 100)))), t.b = Math.max(0, Math.min(255, t.b - Math.round(255 * -(e / 100)))), M(t);
2487
+ var t = T(i).toRgb();
2488
+ return t.r = Math.max(0, Math.min(255, t.r - Math.round(255 * -(e / 100)))), t.g = Math.max(0, Math.min(255, t.g - Math.round(255 * -(e / 100)))), t.b = Math.max(0, Math.min(255, t.b - Math.round(255 * -(e / 100)))), T(t);
2465
2489
  }
2466
- function Ls(i, e) {
2490
+ function Hn(i, e) {
2467
2491
  e = e === 0 ? 0 : e || 10;
2468
- var t = M(i).toHsl();
2469
- return t.l -= e / 100, t.l = ke(t.l), M(t);
2492
+ var t = T(i).toHsl();
2493
+ return t.l -= e / 100, t.l = Se(t.l), T(t);
2470
2494
  }
2471
- function Is(i, e) {
2472
- var t = M(i).toHsl(), n = (t.h + e) % 360;
2473
- return t.h = n < 0 ? 360 + n : n, M(t);
2495
+ function In(i, e) {
2496
+ var t = T(i).toHsl(), s = (t.h + e) % 360;
2497
+ return t.h = s < 0 ? 360 + s : s, T(t);
2474
2498
  }
2475
- function Fs(i) {
2476
- var e = M(i).toHsl();
2477
- return e.h = (e.h + 180) % 360, M(e);
2499
+ function Rn(i) {
2500
+ var e = T(i).toHsl();
2501
+ return e.h = (e.h + 180) % 360, T(e);
2478
2502
  }
2479
- function Rt(i, e) {
2503
+ function Ft(i, e) {
2480
2504
  if (isNaN(e) || e <= 0)
2481
2505
  throw new Error("Argument to polyad must be a positive number");
2482
- for (var t = M(i).toHsl(), n = [M(i)], r = 360 / e, s = 1; s < e; s++)
2483
- n.push(M({
2484
- h: (t.h + s * r) % 360,
2506
+ for (var t = T(i).toHsl(), s = [T(i)], r = 360 / e, n = 1; n < e; n++)
2507
+ s.push(T({
2508
+ h: (t.h + n * r) % 360,
2485
2509
  s: t.s,
2486
2510
  l: t.l
2487
2511
  }));
2488
- return n;
2512
+ return s;
2489
2513
  }
2490
- function Rs(i) {
2491
- var e = M(i).toHsl(), t = e.h;
2492
- return [M(i), M({
2514
+ function Fn(i) {
2515
+ var e = T(i).toHsl(), t = e.h;
2516
+ return [T(i), T({
2493
2517
  h: (t + 72) % 360,
2494
2518
  s: e.s,
2495
2519
  l: e.l
2496
- }), M({
2520
+ }), T({
2497
2521
  h: (t + 216) % 360,
2498
2522
  s: e.s,
2499
2523
  l: e.l
2500
2524
  })];
2501
2525
  }
2502
- function zs(i, e, t) {
2526
+ function zn(i, e, t) {
2503
2527
  e = e || 6, t = t || 30;
2504
- var n = M(i).toHsl(), r = 360 / t, s = [M(i)];
2505
- for (n.h = (n.h - (r * e >> 1) + 720) % 360; --e; )
2506
- n.h = (n.h + r) % 360, s.push(M(n));
2507
- return s;
2528
+ var s = T(i).toHsl(), r = 360 / t, n = [T(i)];
2529
+ for (s.h = (s.h - (r * e >> 1) + 720) % 360; --e; )
2530
+ s.h = (s.h + r) % 360, n.push(T(s));
2531
+ return n;
2508
2532
  }
2509
- function $s(i, e) {
2533
+ function Bn(i, e) {
2510
2534
  e = e || 6;
2511
- for (var t = M(i).toHsv(), n = t.h, r = t.s, s = t.v, o = [], l = 1 / e; e--; )
2512
- o.push(M({
2513
- h: n,
2535
+ for (var t = T(i).toHsv(), s = t.h, r = t.s, n = t.v, o = [], l = 1 / e; e--; )
2536
+ o.push(T({
2537
+ h: s,
2514
2538
  s: r,
2515
- v: s
2516
- })), s = (s + l) % 1;
2539
+ v: n
2540
+ })), n = (n + l) % 1;
2517
2541
  return o;
2518
2542
  }
2519
- M.mix = function(i, e, t) {
2543
+ T.mix = function(i, e, t) {
2520
2544
  t = t === 0 ? 0 : t || 50;
2521
- var n = M(i).toRgb(), r = M(e).toRgb(), s = t / 100, o = {
2522
- r: (r.r - n.r) * s + n.r,
2523
- g: (r.g - n.g) * s + n.g,
2524
- b: (r.b - n.b) * s + n.b,
2525
- a: (r.a - n.a) * s + n.a
2545
+ var s = T(i).toRgb(), r = T(e).toRgb(), n = t / 100, o = {
2546
+ r: (r.r - s.r) * n + s.r,
2547
+ g: (r.g - s.g) * n + s.g,
2548
+ b: (r.b - s.b) * n + s.b,
2549
+ a: (r.a - s.a) * n + s.a
2526
2550
  };
2527
- return M(o);
2551
+ return T(o);
2528
2552
  };
2529
- M.readability = function(i, e) {
2530
- var t = M(i), n = M(e);
2531
- return (Math.max(t.getLuminance(), n.getLuminance()) + 0.05) / (Math.min(t.getLuminance(), n.getLuminance()) + 0.05);
2553
+ T.readability = function(i, e) {
2554
+ var t = T(i), s = T(e);
2555
+ return (Math.max(t.getLuminance(), s.getLuminance()) + 0.05) / (Math.min(t.getLuminance(), s.getLuminance()) + 0.05);
2532
2556
  };
2533
- M.isReadable = function(i, e, t) {
2534
- var n = M.readability(i, e), r, s;
2535
- switch (s = !1, r = Ys(t), r.level + r.size) {
2557
+ T.isReadable = function(i, e, t) {
2558
+ var s = T.readability(i, e), r, n;
2559
+ switch (n = !1, r = Xn(t), r.level + r.size) {
2536
2560
  case "AAsmall":
2537
2561
  case "AAAlarge":
2538
- s = n >= 4.5;
2562
+ n = s >= 4.5;
2539
2563
  break;
2540
2564
  case "AAlarge":
2541
- s = n >= 3;
2565
+ n = s >= 3;
2542
2566
  break;
2543
2567
  case "AAAsmall":
2544
- s = n >= 7;
2568
+ n = s >= 7;
2545
2569
  break;
2546
2570
  }
2547
- return s;
2571
+ return n;
2548
2572
  };
2549
- M.mostReadable = function(i, e, t) {
2550
- var n = null, r = 0, s, o, l, c;
2551
- t = t || {}, o = t.includeFallbackColors, l = t.level, c = t.size;
2573
+ T.mostReadable = function(i, e, t) {
2574
+ var s = null, r = 0, n, o, l, h;
2575
+ t = t || {}, o = t.includeFallbackColors, l = t.level, h = t.size;
2552
2576
  for (var d = 0; d < e.length; d++)
2553
- s = M.readability(i, e[d]), s > r && (r = s, n = M(e[d]));
2554
- return M.isReadable(i, n, {
2577
+ n = T.readability(i, e[d]), n > r && (r = n, s = T(e[d]));
2578
+ return T.isReadable(i, s, {
2555
2579
  level: l,
2556
- size: c
2557
- }) || !o ? n : (t.includeFallbackColors = !1, M.mostReadable(i, ["#fff", "#000"], t));
2580
+ size: h
2581
+ }) || !o ? s : (t.includeFallbackColors = !1, T.mostReadable(i, ["#fff", "#000"], t));
2558
2582
  };
2559
- var Ue = M.names = {
2583
+ var Ue = T.names = {
2560
2584
  aliceblue: "f0f8ff",
2561
2585
  antiquewhite: "faebd7",
2562
2586
  aqua: "0ff",
@@ -2706,54 +2730,54 @@ var Ue = M.names = {
2706
2730
  whitesmoke: "f5f5f5",
2707
2731
  yellow: "ff0",
2708
2732
  yellowgreen: "9acd32"
2709
- }, Bs = M.hexNames = Os(Ue);
2710
- function Os(i) {
2733
+ }, $n = T.hexNames = Pn(Ue);
2734
+ function Pn(i) {
2711
2735
  var e = {};
2712
2736
  for (var t in i)
2713
2737
  i.hasOwnProperty(t) && (e[i[t]] = t);
2714
2738
  return e;
2715
2739
  }
2716
- function Wt(i) {
2740
+ function Yt(i) {
2717
2741
  return i = parseFloat(i), (isNaN(i) || i < 0 || i > 1) && (i = 1), i;
2718
2742
  }
2719
- function F(i, e) {
2720
- Ps(i) && (i = "100%");
2721
- var t = Hs(i);
2743
+ function I(i, e) {
2744
+ On(i) && (i = "100%");
2745
+ var t = Yn(i);
2722
2746
  return i = Math.min(e, Math.max(0, parseFloat(i))), t && (i = parseInt(i * e, 10) / 100), Math.abs(i - e) < 1e-6 ? 1 : i % e / parseFloat(e);
2723
2747
  }
2724
- function ke(i) {
2748
+ function Se(i) {
2725
2749
  return Math.min(1, Math.max(0, i));
2726
2750
  }
2727
- function $(i) {
2751
+ function B(i) {
2728
2752
  return parseInt(i, 16);
2729
2753
  }
2730
- function Ps(i) {
2754
+ function On(i) {
2731
2755
  return typeof i == "string" && i.indexOf(".") != -1 && parseFloat(i) === 1;
2732
2756
  }
2733
- function Hs(i) {
2757
+ function Yn(i) {
2734
2758
  return typeof i == "string" && i.indexOf("%") != -1;
2735
2759
  }
2736
- function Y(i) {
2760
+ function X(i) {
2737
2761
  return i.length == 1 ? "0" + i : "" + i;
2738
2762
  }
2739
2763
  function ce(i) {
2740
2764
  return i <= 1 && (i = i * 100 + "%"), i;
2741
2765
  }
2742
- function Xt(i) {
2766
+ function jt(i) {
2743
2767
  return Math.round(parseFloat(i) * 255).toString(16);
2744
2768
  }
2745
2769
  function zt(i) {
2746
- return $(i) / 255;
2770
+ return B(i) / 255;
2747
2771
  }
2748
- var H = function() {
2749
- var i = "[-\\+]?\\d+%?", e = "[-\\+]?\\d*\\.\\d+%?", t = "(?:" + e + ")|(?:" + i + ")", n = "[\\s|\\(]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")\\s*\\)?", r = "[\\s|\\(]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")\\s*\\)?";
2772
+ var Y = function() {
2773
+ var i = "[-\\+]?\\d+%?", e = "[-\\+]?\\d*\\.\\d+%?", t = "(?:" + e + ")|(?:" + i + ")", s = "[\\s|\\(]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")\\s*\\)?", r = "[\\s|\\(]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")\\s*\\)?";
2750
2774
  return {
2751
2775
  CSS_UNIT: new RegExp(t),
2752
- rgb: new RegExp("rgb" + n),
2776
+ rgb: new RegExp("rgb" + s),
2753
2777
  rgba: new RegExp("rgba" + r),
2754
- hsl: new RegExp("hsl" + n),
2778
+ hsl: new RegExp("hsl" + s),
2755
2779
  hsla: new RegExp("hsla" + r),
2756
- hsv: new RegExp("hsv" + n),
2780
+ hsv: new RegExp("hsv" + s),
2757
2781
  hsva: new RegExp("hsva" + r),
2758
2782
  hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
2759
2783
  hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
@@ -2761,11 +2785,11 @@ var H = function() {
2761
2785
  hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
2762
2786
  };
2763
2787
  }();
2764
- function Z(i) {
2765
- return !!H.CSS_UNIT.exec(i);
2788
+ function U(i) {
2789
+ return !!Y.CSS_UNIT.exec(i);
2766
2790
  }
2767
- function js(i) {
2768
- i = i.replace(bs, "").replace(xs, "").toLowerCase();
2791
+ function jn(i) {
2792
+ i = i.replace(xn, "").replace(wn, "").toLowerCase();
2769
2793
  var e = !1;
2770
2794
  if (Ue[i])
2771
2795
  i = Ue[i], e = !0;
@@ -2778,58 +2802,58 @@ function js(i) {
2778
2802
  format: "name"
2779
2803
  };
2780
2804
  var t;
2781
- return (t = H.rgb.exec(i)) ? {
2805
+ return (t = Y.rgb.exec(i)) ? {
2782
2806
  r: t[1],
2783
2807
  g: t[2],
2784
2808
  b: t[3]
2785
- } : (t = H.rgba.exec(i)) ? {
2809
+ } : (t = Y.rgba.exec(i)) ? {
2786
2810
  r: t[1],
2787
2811
  g: t[2],
2788
2812
  b: t[3],
2789
2813
  a: t[4]
2790
- } : (t = H.hsl.exec(i)) ? {
2814
+ } : (t = Y.hsl.exec(i)) ? {
2791
2815
  h: t[1],
2792
2816
  s: t[2],
2793
2817
  l: t[3]
2794
- } : (t = H.hsla.exec(i)) ? {
2818
+ } : (t = Y.hsla.exec(i)) ? {
2795
2819
  h: t[1],
2796
2820
  s: t[2],
2797
2821
  l: t[3],
2798
2822
  a: t[4]
2799
- } : (t = H.hsv.exec(i)) ? {
2823
+ } : (t = Y.hsv.exec(i)) ? {
2800
2824
  h: t[1],
2801
2825
  s: t[2],
2802
2826
  v: t[3]
2803
- } : (t = H.hsva.exec(i)) ? {
2827
+ } : (t = Y.hsva.exec(i)) ? {
2804
2828
  h: t[1],
2805
2829
  s: t[2],
2806
2830
  v: t[3],
2807
2831
  a: t[4]
2808
- } : (t = H.hex8.exec(i)) ? {
2809
- r: $(t[1]),
2810
- g: $(t[2]),
2811
- b: $(t[3]),
2832
+ } : (t = Y.hex8.exec(i)) ? {
2833
+ r: B(t[1]),
2834
+ g: B(t[2]),
2835
+ b: B(t[3]),
2812
2836
  a: zt(t[4]),
2813
2837
  format: e ? "name" : "hex8"
2814
- } : (t = H.hex6.exec(i)) ? {
2815
- r: $(t[1]),
2816
- g: $(t[2]),
2817
- b: $(t[3]),
2838
+ } : (t = Y.hex6.exec(i)) ? {
2839
+ r: B(t[1]),
2840
+ g: B(t[2]),
2841
+ b: B(t[3]),
2818
2842
  format: e ? "name" : "hex"
2819
- } : (t = H.hex4.exec(i)) ? {
2820
- r: $(t[1] + "" + t[1]),
2821
- g: $(t[2] + "" + t[2]),
2822
- b: $(t[3] + "" + t[3]),
2843
+ } : (t = Y.hex4.exec(i)) ? {
2844
+ r: B(t[1] + "" + t[1]),
2845
+ g: B(t[2] + "" + t[2]),
2846
+ b: B(t[3] + "" + t[3]),
2823
2847
  a: zt(t[4] + "" + t[4]),
2824
2848
  format: e ? "name" : "hex8"
2825
- } : (t = H.hex3.exec(i)) ? {
2826
- r: $(t[1] + "" + t[1]),
2827
- g: $(t[2] + "" + t[2]),
2828
- b: $(t[3] + "" + t[3]),
2849
+ } : (t = Y.hex3.exec(i)) ? {
2850
+ r: B(t[1] + "" + t[1]),
2851
+ g: B(t[2] + "" + t[2]),
2852
+ b: B(t[3] + "" + t[3]),
2829
2853
  format: e ? "name" : "hex"
2830
2854
  } : !1;
2831
2855
  }
2832
- function Ys(i) {
2856
+ function Xn(i) {
2833
2857
  var e, t;
2834
2858
  return i = i || {
2835
2859
  level: "AA",
@@ -2839,17 +2863,17 @@ function Ys(i) {
2839
2863
  size: t
2840
2864
  };
2841
2865
  }
2842
- function Gt(i, e, t, { fillColor: n, strokeColor: r, candleWidth: s, strokeWidth: o }, l) {
2843
- const c = (C) => t.scales.x.map(C), d = (C) => t.scales.y.map(C), u = c(e.open_time), _ = d(e.open), g = d(e.close), p = t.trade.timeRange.includes(e.open_time.getTime()), v = t.trade.timeRange.length && !p, y = (C) => v ? M.mix(C, l).toString() : C;
2844
- i.fillStyle = y(n), i.strokeStyle = y(r), i.lineWidth = o, i.beginPath(), i.moveTo(u, d(e.high)), i.lineTo(u, d(e.low)), i.stroke();
2845
- const b = Math.min(_, g), w = Math.abs(g - _), T = u - s / 2;
2846
- i.fillRect(T, b, s, w), i.strokeRect(T, b, s, w);
2847
- }
2848
- function Ws(i, e) {
2849
- const { strokeWidth: t, style: n } = e.config.candles, { candles: r, bg: s } = e.colorScheme, o = e.config.candles.baseWidth * e.scales.factorX;
2850
- e.candles.missingData.forEach((l, c) => {
2851
- const d = r.noDataFill[c % r.noDataFill.length], u = n === "filled" ? d : r.noDataStroke;
2852
- Gt(
2866
+ function Xt(i, e, t, { fillColor: s, strokeColor: r, candleWidth: n, strokeWidth: o }, l) {
2867
+ const h = (M) => t.scales.x.map(M), d = (M) => t.scales.y.map(M), u = h(e.open_time), _ = d(e.open), m = d(e.close), p = t.trade.timeRange.includes(e.open_time.getTime()), v = t.trade.timeRange.length && !p, y = (M) => v ? T.mix(M, l).toString() : M;
2868
+ i.fillStyle = y(s), i.strokeStyle = y(r), i.lineWidth = o, i.beginPath(), i.moveTo(u, d(e.high)), i.lineTo(u, d(e.low)), i.stroke();
2869
+ const b = Math.min(_, m), x = Math.abs(m - _), C = u - n / 2;
2870
+ i.fillRect(C, b, n, x), i.strokeRect(C, b, n, x);
2871
+ }
2872
+ function Wn(i, e) {
2873
+ const { strokeWidth: t, style: s } = e.config.candles, { candles: r, bg: n } = e.colorScheme, o = e.config.candles.baseWidth * e.scales.factorX;
2874
+ e.candles.missingData.forEach((l, h) => {
2875
+ const d = r.noDataFill[h % r.noDataFill.length], u = s === "filled" ? d : r.noDataStroke;
2876
+ Xt(
2853
2877
  i,
2854
2878
  l,
2855
2879
  e,
@@ -2859,21 +2883,21 @@ function Ws(i, e) {
2859
2883
  candleWidth: o,
2860
2884
  strokeWidth: t
2861
2885
  },
2862
- s
2886
+ n
2863
2887
  );
2864
2888
  });
2865
2889
  }
2866
- function Xs(i, e) {
2867
- const { strokeWidth: t, style: n } = e.config.candles, r = e.config.candles.baseWidth * e.scales.factorX, { candles: s, bg: o } = e.colorScheme;
2890
+ function Gn(i, e) {
2891
+ const { strokeWidth: t, style: s } = e.config.candles, r = e.config.candles.baseWidth * e.scales.factorX, { candles: n, bg: o } = e.colorScheme;
2868
2892
  e.candles.preparedData.forEach((l) => {
2869
- const c = l.close >= l.open ? "up" : "down", d = c === "up" ? s.risingFill : s.fallingFill, u = c === "up" ? s.risingStroke : s.fallingStroke;
2870
- Gt(
2893
+ const h = l.close >= l.open ? "up" : "down", d = h === "up" ? n.risingFill : n.fallingFill, u = h === "up" ? n.risingStroke : n.fallingStroke;
2894
+ Xt(
2871
2895
  i,
2872
2896
  l,
2873
2897
  e,
2874
2898
  {
2875
2899
  fillColor: d,
2876
- strokeColor: n === "filled" ? d : u,
2900
+ strokeColor: s === "filled" ? d : u,
2877
2901
  candleWidth: r,
2878
2902
  strokeWidth: t
2879
2903
  },
@@ -2881,65 +2905,65 @@ function Xs(i, e) {
2881
2905
  );
2882
2906
  });
2883
2907
  }
2884
- class Gs {
2908
+ class Un {
2885
2909
  static renderAll(e, t) {
2886
- Ws(e, t), Xs(e, t);
2910
+ Wn(e, t), Gn(e, t);
2887
2911
  }
2888
2912
  }
2889
- const $t = 10;
2890
- function Zs(i, e) {
2913
+ const Bt = 10;
2914
+ function Zn(i, e) {
2891
2915
  const {
2892
2916
  layout: { xAxis: t },
2893
- colorScheme: { xAxis: n },
2917
+ colorScheme: { xAxis: s },
2894
2918
  config: { xAxis: r },
2895
- scales: s
2896
- } = e, o = s.x.ticks($t), l = (c) => {
2897
- const d = s.x.tickFormat($t)(c);
2898
- return /AM|PM/.test(d) ? k.timeFormat("%H:%M")(c) : d;
2919
+ scales: n
2920
+ } = e, o = n.x.ticks(Bt), l = (h) => {
2921
+ const d = n.x.tickFormat(Bt)(h);
2922
+ return /AM|PM/.test(d) ? k.timeFormat("%H:%M")(h) : d;
2899
2923
  };
2900
- i.save(), i.fillStyle = n.bg, i.fillRect(t.x, t.y, t.width, t.height), i.restore(), i.fillStyle = n.text, i.font = `${r.text.fontSize} ${r.text.font}`, i.textAlign = "center", i.textBaseline = "middle", o.forEach((c) => {
2901
- const d = s.x.map(c), u = l(c);
2924
+ i.save(), i.fillStyle = s.bg, i.fillRect(t.x, t.y, t.width, t.height), i.restore(), i.fillStyle = s.text, i.font = `${r.text.fontSize} ${r.text.font}`, i.textAlign = "center", i.textBaseline = "middle", o.forEach((h) => {
2925
+ const d = n.x.map(h), u = l(h);
2902
2926
  i.fillText(u, d, t.y + t.height / 2);
2903
2927
  });
2904
2928
  }
2905
- function Us(i, e) {
2929
+ function Vn(i, e) {
2906
2930
  const {
2907
2931
  layout: { yAxis: t },
2908
- colorScheme: { yAxis: n },
2932
+ colorScheme: { yAxis: s },
2909
2933
  config: { yAxis: r },
2910
- scales: s
2911
- } = e, o = s.y.ticks(6), l = s.y.tickFormat(6);
2912
- i.save(), i.fillStyle = n.bg, i.fillRect(t.x, t.y, t.width, t.height), i.restore(), i.fillStyle = n.text, i.font = `${r.text.fontSize} ${r.text.font}`, i.textAlign = "center", i.textBaseline = "middle", o.forEach((c) => {
2913
- const d = s.y.map(c), u = l(c);
2934
+ scales: n
2935
+ } = e, o = n.y.ticks(6), l = n.y.tickFormat(6);
2936
+ i.save(), i.fillStyle = s.bg, i.fillRect(t.x, t.y, t.width, t.height), i.restore(), i.fillStyle = s.text, i.font = `${r.text.fontSize} ${r.text.font}`, i.textAlign = "center", i.textBaseline = "middle", o.forEach((h) => {
2937
+ const d = n.y.map(h), u = l(h);
2914
2938
  i.fillText(u, t.x + t.width / 2, d);
2915
2939
  });
2916
2940
  }
2917
- const Vs = (i, e) => {
2941
+ const Jn = (i, e) => {
2918
2942
  const {
2919
2943
  layout: { axisIntersection: t },
2920
- colorScheme: n
2944
+ colorScheme: s
2921
2945
  } = e;
2922
- i.save(), i.fillStyle = n.axisIntersection, i.fillRect(
2946
+ i.save(), i.fillStyle = s.axisIntersection, i.fillRect(
2923
2947
  t.x,
2924
2948
  t.y,
2925
2949
  t.width,
2926
2950
  t.height
2927
2951
  ), i.restore();
2928
2952
  };
2929
- class Ze {
2953
+ class Ge {
2930
2954
  static xAxis(e, t) {
2931
- Zs(e, t);
2955
+ Zn(e, t);
2932
2956
  }
2933
2957
  static yAxis(e, t) {
2934
- Us(e, t);
2958
+ Vn(e, t);
2935
2959
  }
2936
2960
  static intersection(e, t) {
2937
- Vs(e, t);
2961
+ Jn(e, t);
2938
2962
  }
2939
2963
  }
2940
- class Js {
2964
+ class Qn {
2941
2965
  constructor(e) {
2942
- m(this, "_target");
2966
+ g(this, "_target");
2943
2967
  this._target = e;
2944
2968
  }
2945
2969
  mousemove(e) {
@@ -2957,95 +2981,98 @@ class Js {
2957
2981
  wheel(e) {
2958
2982
  this._target.addEventListener("wheel", e);
2959
2983
  }
2984
+ dblclick(e) {
2985
+ this._target.addEventListener("dblclick", e);
2986
+ }
2960
2987
  }
2961
2988
  class j {
2962
- static line(e, { lineColor: t, type: n, x: r, y: s, lineLength: o }) {
2963
- e.save(), e.strokeStyle = t || "#777777", e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(r, s), e.lineTo(r + (n === "h" ? o : 0), s + (n === "v" ? o : 0)), e.stroke(), e.restore();
2989
+ static line(e, { lineColor: t, type: s, x: r, y: n, lineLength: o }) {
2990
+ e.save(), e.strokeStyle = t || "#777777", e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(r, n), e.lineTo(r + (s === "h" ? o : 0), n + (s === "v" ? o : 0)), e.stroke(), e.restore();
2964
2991
  }
2965
2992
  static _basicLabel(e, {
2966
2993
  text: t,
2967
- mainColor: n,
2994
+ mainColor: s,
2968
2995
  textColor: r,
2969
- position: s
2996
+ position: n
2970
2997
  }) {
2971
- e.textContent = t, e.style.backgroundColor = n ?? "#777777", e.style.color = r ?? "#ffffff", e.style[s] = "0px";
2998
+ e.textContent = t, e.style.backgroundColor = s ?? "#777777", e.style.color = r ?? "#ffffff", e.style[n] = "0px";
2972
2999
  }
2973
- static label_h(e, { text: t, y: n, mainColor: r, textColor: s, position: o }) {
2974
- j._basicLabel(e, { text: t, mainColor: r, textColor: s, position: o }), e.style.top = n + "px", e.style.transform = "translateY(-50%)";
3000
+ static label_h(e, { text: t, y: s, mainColor: r, textColor: n, position: o }) {
3001
+ j._basicLabel(e, { text: t, mainColor: r, textColor: n, position: o }), e.style.top = s + "px", e.style.transform = "translateY(-50%)";
2975
3002
  }
2976
- static label_v(e, { text: t, x: n, mainColor: r, textColor: s, position: o }) {
2977
- j._basicLabel(e, { text: t, mainColor: r, textColor: s, position: o }), e.style.left = n + "px", e.style.transform = "translateX(-50%)";
3003
+ static label_v(e, { text: t, x: s, mainColor: r, textColor: n, position: o }) {
3004
+ j._basicLabel(e, { text: t, mainColor: r, textColor: n, position: o }), e.style.left = s + "px", e.style.transform = "translateX(-50%)";
2978
3005
  }
2979
3006
  static horizontalMarker({
2980
3007
  node: e,
2981
3008
  ctx: t,
2982
- x: n,
3009
+ x: s,
2983
3010
  y: r,
2984
- lineLength: s,
3011
+ lineLength: n,
2985
3012
  text: o,
2986
3013
  textColor: l,
2987
- mainColor: c,
3014
+ mainColor: h,
2988
3015
  lineColor: d,
2989
3016
  position: u
2990
3017
  }) {
2991
3018
  j.line(t, {
2992
3019
  type: "h",
2993
- x: n,
3020
+ x: s,
2994
3021
  y: r,
2995
- lineLength: s,
3022
+ lineLength: n,
2996
3023
  lineColor: d
2997
3024
  }), j.label_h(e, {
2998
3025
  text: o,
2999
3026
  y: r,
3000
3027
  textColor: l,
3001
- mainColor: c,
3028
+ mainColor: h,
3002
3029
  position: u
3003
3030
  });
3004
3031
  }
3005
3032
  static verticalMarker({
3006
3033
  node: e,
3007
3034
  ctx: t,
3008
- x: n,
3035
+ x: s,
3009
3036
  y: r,
3010
- lineLength: s,
3037
+ lineLength: n,
3011
3038
  text: o,
3012
3039
  textColor: l,
3013
- mainColor: c,
3040
+ mainColor: h,
3014
3041
  lineColor: d,
3015
3042
  position: u
3016
3043
  }) {
3017
3044
  j.line(t, {
3018
3045
  type: "v",
3019
- x: n,
3046
+ x: s,
3020
3047
  y: r,
3021
- lineLength: s,
3048
+ lineLength: n,
3022
3049
  lineColor: d
3023
3050
  }), j.label_v(e, {
3024
3051
  text: o,
3025
- x: n,
3052
+ x: s,
3026
3053
  textColor: l,
3027
- mainColor: c,
3054
+ mainColor: h,
3028
3055
  position: u
3029
3056
  });
3030
3057
  }
3031
3058
  }
3032
- class Qs {
3059
+ class qn {
3033
3060
  constructor(e, t) {
3034
- m(this, "_canvas");
3035
- m(this, "_parent");
3036
- m(this, "_horizontalMarker");
3037
- m(this, "_verticalMarker");
3061
+ g(this, "_canvas");
3062
+ g(this, "_parent");
3063
+ g(this, "_horizontalMarker");
3064
+ g(this, "_verticalMarker");
3038
3065
  this._canvas = t;
3039
- const n = new R({ tag: "div", className: "sc-charts-cs__guide-markers" });
3040
- this._parent = n;
3066
+ const s = new R({ tag: "div", className: "sc-charts-cs__guide-markers" });
3067
+ this._parent = s;
3041
3068
  const r = new R({
3042
3069
  tag: "div",
3043
3070
  className: "sc-charts-cs__guide-marker sc-charts-cs__guide-marker-h"
3044
- }), s = new R({
3071
+ }), n = new R({
3045
3072
  tag: "div",
3046
3073
  className: "sc-charts-cs__guide-marker sc-charts-cs__guide-marker-v"
3047
3074
  });
3048
- this._horizontalMarker = r, this._verticalMarker = s, n.append(r.node), n.append(s.node), e.append(n.node), this.hide();
3075
+ this._horizontalMarker = r, this._verticalMarker = n, s.append(r.node), s.append(n.node), e.append(s.node), this.hide();
3049
3076
  }
3050
3077
  update(e) {
3051
3078
  this._verticalMarker.node.style.display = e.isShowX ? "flex" : "none", this._horizontalMarker.node.style.display = e.isShowY ? "flex" : "none";
@@ -3056,11 +3083,11 @@ class Qs {
3056
3083
  show() {
3057
3084
  this._verticalMarker.node.style.display = "flex", this._horizontalMarker.node.style.display = "flex";
3058
3085
  }
3059
- render(e, { x: t, y: n }) {
3086
+ render(e, { x: t, y: s }) {
3060
3087
  this._canvas.clear();
3061
3088
  const {
3062
- layout: { area: r, chart: s },
3063
- config: { guides: o, yAxis: l, xAxis: c },
3089
+ layout: { area: r, chart: n },
3090
+ config: { guides: o, yAxis: l, xAxis: h },
3064
3091
  colorScheme: {
3065
3092
  guides: { horizontalMarker: d, verticalMarker: u }
3066
3093
  }
@@ -3069,9 +3096,9 @@ class Qs {
3069
3096
  ctx: this._canvas.ctx,
3070
3097
  node: this._horizontalMarker.node,
3071
3098
  x: r.left,
3072
- y: n,
3073
- lineLength: s.width,
3074
- text: e.scales.y.invert(n).toFixed(2),
3099
+ y: s,
3100
+ lineLength: n.width,
3101
+ text: e.scales.y.invert(s).toFixed(2),
3075
3102
  position: l.position,
3076
3103
  mainColor: d.main,
3077
3104
  lineColor: d.line,
@@ -3080,10 +3107,10 @@ class Qs {
3080
3107
  ctx: this._canvas.ctx,
3081
3108
  node: this._verticalMarker.node,
3082
3109
  text: k.timeFormat("%a %d, %b %y %H:%M")(e.scales.x.invert(t)),
3083
- position: c.position,
3110
+ position: h.position,
3084
3111
  x: t,
3085
3112
  y: r.top,
3086
- lineLength: s.height,
3113
+ lineLength: n.height,
3087
3114
  mainColor: u.main,
3088
3115
  lineColor: u.line,
3089
3116
  textColor: u.text
@@ -3093,148 +3120,124 @@ class Qs {
3093
3120
  this._canvas.clear(), this._parent.remove();
3094
3121
  }
3095
3122
  }
3096
- function Me(i) {
3123
+ function Ce(i) {
3097
3124
  return i * 0.1875;
3098
3125
  }
3099
- const qs = (i, { mainColor: e, textColor: t, symbol: n, x: r, y: s, size: o, fontSize: l }) => {
3100
- const _ = o / 16, g = 16 * _, p = r - g / 2, v = s;
3126
+ const Kn = (i, { mainColor: e, textColor: t, symbol: s, x: r, y: n, size: o, fontSize: l }) => {
3127
+ const _ = o / 16, m = 16 * _, p = r - m / 2, v = n;
3101
3128
  i.save(), i.translate(p, v), i.scale(_, _), i.beginPath(), i.moveTo(7.85696, 0.288512), i.lineTo(4.53377, 3.11938), i.bezierCurveTo(4.17982, 3.42089, 4.39305, 4, 4.85801, 4), i.lineTo(11.2275, 4), i.bezierCurveTo(11.6818, 4, 11.9006, 3.44302, 11.5678, 3.13374), i.lineTo(8.52156, 0.302869), i.bezierCurveTo(8.33575, 0.130189, 8.05007, 0.124018, 7.85696, 0.288512), i.closePath(), i.fillStyle = e, i.fill(), i.beginPath(), i.moveTo(0, 7), i.bezierCurveTo(0, 4.79086, 1.79086, 3, 4, 3), i.lineTo(12, 3), i.bezierCurveTo(14.2091, 3, 16, 4.79086, 16, 7), i.lineTo(16, 15), i.bezierCurveTo(16, 17.2091, 14.2091, 19, 12, 19), i.lineTo(4, 19), i.bezierCurveTo(1.79086, 19, 0, 17.2091, 0, 15), i.lineTo(0, 7), i.closePath(), i.fillStyle = e, i.fill(), i.restore(), i.save(), i.font = `bold ${l}px sans-serif`, i.textAlign = "center", i.textBaseline = "top", i.textAlign = "center", i.textBaseline = "middle";
3102
- const y = s + _ * 3 + 0.5, b = _ * 16, w = y + b / 2;
3103
- i.fillStyle = t, i.fillText(n, r, w), i.restore();
3104
- }, Ks = (i, { mainColor: e, textColor: t, symbol: n, x: r, y: s, size: o, fontSize: l }) => {
3105
- const _ = o / 16, g = 16 * _, p = r - g / 2, v = s;
3129
+ const y = n + _ * 3 + 0.5, b = _ * 16, x = y + b / 2;
3130
+ i.fillStyle = t, i.fillText(s, r, x), i.restore();
3131
+ }, er = (i, { mainColor: e, textColor: t, symbol: s, x: r, y: n, size: o, fontSize: l }) => {
3132
+ const _ = o / 16, m = 16 * _, p = r - m / 2, v = n;
3106
3133
  i.save(), i.translate(p, v), i.scale(_, -_), i.beginPath(), i.moveTo(7.85696, 0.288512), i.lineTo(4.53377, 3.11938), i.bezierCurveTo(4.17982, 3.42089, 4.39305, 4, 4.85801, 4), i.lineTo(11.2275, 4), i.bezierCurveTo(11.6818, 4, 11.9006, 3.44302, 11.5678, 3.13374), i.lineTo(8.52156, 0.302869), i.bezierCurveTo(8.33575, 0.130189, 8.05007, 0.124018, 7.85696, 0.288512), i.closePath(), i.fillStyle = e, i.fill(), i.beginPath(), i.moveTo(0, 7), i.bezierCurveTo(0, 4.79086, 1.79086, 3, 4, 3), i.lineTo(12, 3), i.bezierCurveTo(14.2091, 3, 16, 4.79086, 16, 7), i.lineTo(16, 15), i.bezierCurveTo(16, 17.2091, 14.2091, 19, 12, 19), i.lineTo(4, 19), i.bezierCurveTo(1.79086, 19, 0, 17.2091, 0, 15), i.lineTo(0, 7), i.closePath(), i.fillStyle = e, i.fill(), i.restore(), i.save(), i.font = `bold ${l}px sans-serif`, i.textAlign = "center", i.textBaseline = "middle";
3107
- const y = _ * 16, b = s - _ * 19 + y / 2;
3108
- i.fillStyle = t, i.fillText(n, r, b), i.restore();
3134
+ const y = _ * 16, b = n - _ * 19 + y / 2;
3135
+ i.fillStyle = t, i.fillText(s, r, b), i.restore();
3109
3136
  };
3110
- function er(i, e) {
3137
+ function tr(i, e) {
3111
3138
  const {
3112
3139
  trade: { tradedCandles: t },
3113
- scales: { x: n, y: r },
3114
- colorScheme: { trade: s }
3115
- } = e, o = 4;
3116
- t.forEach(({ isActive: l, candle: c, trades: d }) => {
3117
- const u = n.map(c.open_time);
3118
- d.forEach((_) => {
3119
- const g = _.kind === "entry", p = g ? s.entryLabel.main : s.exitLabel.main, v = g ? s.entryLabel.text : s.exitLabel.text, y = _.type === "buy" ? "B" : "S", b = g ? r.map(c.low) + o : r.map(c.high) - o;
3120
- (_.type === "buy" ? qs : Ks)(i, {
3121
- x: u,
3122
- y: b,
3123
- symbol: y,
3124
- mainColor: l ? s.activeLabel : p,
3125
- textColor: v,
3140
+ scales: { x: s, y: r },
3141
+ colorScheme: n
3142
+ } = e, { trade: o } = n, l = 4;
3143
+ t.forEach(({ isHovered: h, isActive: d, candle: u, trades: _ }) => {
3144
+ const m = s.map(u.open_time);
3145
+ _.forEach((p) => {
3146
+ const v = p.type === "buy", y = v ? o.buyLabel.text : o.sellLabel.text, b = v ? "B" : "S", x = v ? r.map(u.low) + l : r.map(u.high) - l, C = v ? Kn : er;
3147
+ let M = v ? o.buyLabel.main : o.sellLabel.main;
3148
+ h && (M = T.mix(M, n.bg, 20).toString()), d && (M = o.activeLabel), C(i, {
3149
+ x: m,
3150
+ y: x,
3151
+ symbol: b,
3152
+ mainColor: M,
3153
+ textColor: y,
3126
3154
  size: 16,
3127
3155
  fontSize: 12
3128
3156
  });
3129
3157
  });
3130
3158
  });
3131
3159
  }
3132
- function tr(i, e) {
3160
+ function ir(i, e) {
3133
3161
  const {
3134
- scales: { x: t, factorX: n },
3162
+ scales: { x: t, factorX: s },
3135
3163
  layout: { area: r },
3136
- trade: { tradedCandles: s, exits: o, entries: l },
3137
- config: { candles: c },
3164
+ trade: { tradedCandles: n, exits: o, entries: l },
3165
+ config: { candles: h },
3138
3166
  colorScheme: { trade: d }
3139
3167
  } = e;
3140
- if (s.length === 0) return;
3141
- const u = s.map((g) => g.candle).sort((g, p) => g.open_time.getTime() - p.open_time.getTime()), _ = c.baseWidth / 2 * n + c.strokeWidth / 2;
3168
+ if (n.length === 0) return;
3169
+ const u = n.map((m) => m.candle).sort((m, p) => m.open_time.getTime() - p.open_time.getTime()), _ = h.baseWidth / 2 * s + h.strokeWidth / 2;
3142
3170
  if (i.save(), i.lineWidth = 1, i.strokeStyle = d.tradeBorders, l.length) {
3143
- const g = t.map(u[0].open_time) - _;
3144
- i.beginPath(), i.moveTo(g, r.y), i.lineTo(g, r.y + r.height), i.stroke();
3171
+ const m = t.map(u[0].open_time) - _;
3172
+ i.beginPath(), i.moveTo(m, r.y), i.lineTo(m, r.y + r.height), i.stroke();
3145
3173
  }
3146
3174
  if (o.length) {
3147
- const g = t.map(u[u.length - 1].open_time) + _;
3148
- i.beginPath(), i.moveTo(g, r.y), i.lineTo(g, r.y + r.height), i.stroke();
3175
+ const m = t.map(u[u.length - 1].open_time) + _;
3176
+ i.beginPath(), i.moveTo(m, r.y), i.lineTo(m, r.y + r.height), i.stroke();
3149
3177
  }
3150
3178
  i.restore();
3151
3179
  }
3152
- const ir = (i, e) => {
3180
+ const sr = (i, e) => {
3153
3181
  const {
3154
- scales: { x: t, y: n },
3155
- trade: { tradedCandles: r, entries: s, exits: o },
3182
+ scales: { x: t, y: s },
3183
+ trade: { tradedCandles: r, entries: n, exits: o },
3156
3184
  colorScheme: { trade: l }
3157
3185
  } = e;
3158
3186
  i.save();
3159
- const c = (u) => {
3187
+ const h = (u) => {
3160
3188
  var _;
3161
3189
  return (_ = r.find(
3162
- (g) => u.getTime() >= g.candle.open_time.getTime() && u.getTime() < g.candle.close_time.getTime()
3190
+ (m) => u.getTime() >= m.candle.open_time.getTime() && u.getTime() < m.candle.close_time.getTime()
3163
3191
  )) == null ? void 0 : _.candle;
3164
3192
  }, d = (u, _) => {
3165
- const g = c(u), p = c(_);
3166
- if (!g || !p) return;
3167
- const v = t.map(g.open_time), y = n.map(g.low), b = t.map(p.open_time), w = n.map(p.high);
3168
- i.beginPath(), i.setLineDash([4, 4]), i.strokeStyle = l.connectionLine, i.moveTo(v, y), i.lineTo(b, w), i.stroke(), i.setLineDash([]);
3193
+ const m = h(u.time), p = h(_.time);
3194
+ if (!m || !p) return;
3195
+ const v = t.map(m.open_time), y = t.map(p.open_time);
3196
+ let b, x;
3197
+ u.type === "buy" ? (b = s.map(m.low), x = s.map(p.high)) : (b = s.map(m.high), x = s.map(p.low)), i.beginPath(), i.setLineDash([4, 4]), i.strokeStyle = l.connectionLine, i.moveTo(v, b), i.lineTo(y, x), i.stroke(), i.setLineDash([]);
3169
3198
  };
3170
- if (s.length === 1 && o.length > 1)
3171
- o.forEach((u) => d(s[0].time, u.time));
3172
- else if (o.length === 1 && s.length > 1)
3173
- s.forEach((u) => d(u.time, o[0].time));
3174
- else if (s.length === 1 && o.length === 1)
3175
- d(s[0].time, o[0].time);
3176
- else if (s.length > 0 && o.length > 0) {
3177
- const u = s.reduce((g, p) => g.time.getTime() < p.time.getTime() ? g : p), _ = o.reduce((g, p) => g.time.getTime() > p.time.getTime() ? g : p);
3178
- d(u.time, _.time);
3199
+ if (n.length === 1 && o.length > 1)
3200
+ o.forEach((u) => d(n[0], u));
3201
+ else if (o.length === 1 && n.length > 1)
3202
+ n.forEach((u) => d(u, o[0]));
3203
+ else if (n.length === 1 && o.length === 1)
3204
+ d(n[0], o[0]);
3205
+ else if (n.length > 0 && o.length > 0) {
3206
+ const u = n.reduce((m, p) => m.time < p.time ? m : p), _ = o.reduce((m, p) => m.time > p.time ? m : p);
3207
+ d(u, _);
3179
3208
  }
3180
3209
  i.restore();
3181
3210
  };
3182
- class Zt {
3183
- constructor(e, t) {
3184
- m(this, "canvas");
3185
- m(this, "parent");
3186
- m(this, "items", {});
3187
- m(this, "className");
3188
- this.className = t, this.canvas = new Te({
3189
- width: e.width,
3190
- height: e.height,
3191
- className: `${t}-canvas`
3192
- }), e.canvasesContainer.append(this.canvas.node), this.parent = new R({ tag: "div", className: t }), e.domElements.append(this.parent.node);
3193
- }
3194
- render(e) {
3195
- const t = new Set(e.map(this.getIdFromMarker));
3196
- this.canvas.clear(), this.removeObsoleteItems(t);
3197
- for (const n of e) {
3198
- const r = this.getIdFromMarker(n), s = this.items[r] ?? this.createMarkerElement(r);
3199
- this.renderMarker(n, s.node);
3211
+ class Wt extends R {
3212
+ constructor({ className: t, isAdaptPosition: s } = {}) {
3213
+ super({ tag: "div", className: t });
3214
+ g(this, "_isAdaptPosition");
3215
+ this._isAdaptPosition = !!s;
3216
+ }
3217
+ show({ x: t, y: s, parent: r, offset: n = 8 }) {
3218
+ let o = t + n, l = s + n;
3219
+ if (this._isAdaptPosition) {
3220
+ this.updateAbsolutePosition();
3221
+ const h = this.absolutePosition, d = {
3222
+ top: 0,
3223
+ left: 0,
3224
+ bottom: r.bottom - r.top,
3225
+ right: r.right - r.left
3226
+ };
3227
+ o + h.width > d.right && (o = t - h.width - n, o < d.left + n && (o = d.left + n)), l + h.height > d.bottom && (l = s - h.height - n, l < d.top + n && (l = d.top + n));
3200
3228
  }
3229
+ this.node.style.opacity = "1", this.node.style.visibility = "visible", this.node.style.left = `${o}px`, this.node.style.top = `${l}px`;
3201
3230
  }
3202
- clear() {
3203
- this.canvas.clear(), this.parent.remove();
3204
- }
3205
- getIdFromMarker(e) {
3206
- const t = e.type === "horizontal" ? "h" : "v", n = e.value instanceof Date ? e.value.getTime().toString() : e.value.toString().replace(".", "d");
3207
- return `${t}_${n}`;
3208
- }
3209
- removeObsoleteItems(e) {
3210
- for (const t in this.items)
3211
- e.has(t) || (this.items[t].remove(), delete this.items[t]);
3212
- }
3213
- createMarkerElement(e) {
3214
- const t = new R({
3215
- tag: "div",
3216
- className: `${this.className}-item`
3217
- });
3218
- return this.parent.append(t.node), this.items[e] = t, t;
3219
- }
3220
- renderMarker(e, t) {
3221
- e.type === "horizontal" ? j.horizontalMarker({
3222
- ctx: this.canvas.ctx,
3223
- node: t,
3224
- ...e
3225
- }) : j.verticalMarker({
3226
- ctx: this.canvas.ctx,
3227
- node: t,
3228
- ...e
3229
- });
3231
+ hide() {
3232
+ this.node.style.opacity = "0", this.node.style.visibility = "hidden";
3230
3233
  }
3231
3234
  }
3232
- class nr extends R {
3235
+ class nr extends Wt {
3233
3236
  constructor() {
3234
- super({ tag: "div", className: "sc-charts-cs__trade-label-tooltip" });
3235
- m(this, "_title");
3236
- m(this, "_manyBox");
3237
- m(this, "_oneBox");
3237
+ super({ className: "sc-charts-cs__trade-label-tooltip", isAdaptPosition: !0 });
3238
+ g(this, "_title");
3239
+ g(this, "_manyBox");
3240
+ g(this, "_oneBox");
3238
3241
  this._title = new R({
3239
3242
  tag: "div",
3240
3243
  className: "sc-charts-cs__trade-label-tooltip-title"
@@ -3244,85 +3247,68 @@ class nr extends R {
3244
3247
  }), this._oneBox = new R({
3245
3248
  tag: "div",
3246
3249
  className: "sc-charts-cs__trade-label-tooltip-box_one"
3247
- });
3250
+ }), this.node.append(this._title.node, this._oneBox.node, this._manyBox.node);
3248
3251
  }
3249
- _createLineNodes(t, n) {
3252
+ _createLineNodes(t, s) {
3250
3253
  const r = [];
3251
- for (const s of Object.keys(n))
3252
- if (s in t) {
3254
+ for (const n of Object.keys(s))
3255
+ if (n in t) {
3253
3256
  const o = new R({
3254
3257
  tag: "div",
3255
3258
  className: `sc-charts-cs__trade-label-tooltip-line
3256
- sc-charts-cs__trade-label-tooltip-line-key-${s}`
3259
+ sc-charts-cs__trade-label-tooltip-line-key-${n}`
3257
3260
  });
3258
- let l = t[s].toString();
3259
- s === "kind" && (l = this._formatDate(t.time));
3260
- const c = new R({ tag: "strong", textContent: n[s] }), d = new R({ tag: "span", textContent: l });
3261
- o.append(c.node, d.node), r.push(o.node);
3261
+ let l = t[n].toString();
3262
+ n === "kind" && (l = this._formatDate(t.time));
3263
+ const h = new R({ tag: "strong", textContent: s[n] }), d = new R({ tag: "span", textContent: l });
3264
+ o.append(h.node, d.node), r.push(o.node);
3262
3265
  }
3263
3266
  return r;
3264
3267
  }
3265
3268
  _formatDate(t) {
3266
- const n = new Intl.DateTimeFormat("en-US", {
3269
+ const s = new Intl.DateTimeFormat("en-US", {
3267
3270
  hour: "2-digit",
3268
3271
  minute: "2-digit",
3269
3272
  day: "2-digit",
3270
3273
  month: "short",
3271
3274
  year: "numeric",
3272
3275
  hour12: !1
3273
- }).format(t), [r, s, o] = n.split(", ");
3274
- return `${r}, ${s} ${o}`;
3276
+ }).format(t), [r, n, o] = s.split(", ");
3277
+ return `${r}, ${n} ${o}`;
3275
3278
  }
3276
3279
  _clearTooltip() {
3277
3280
  this._title.node.style.display = "none", this._oneBox.node.style.display = "none", this._oneBox.node.replaceChildren(), this._manyBox.node.style.display = "none", this._manyBox.node.replaceChildren();
3278
3281
  }
3279
- show({
3280
- x: t,
3281
- y: n,
3282
- trade: { trades: r },
3283
- layout: s
3284
- }) {
3285
- if (!r.length) return;
3286
- if (this.node.style.opacity = "1", this.node.style.visibility = "visible", this._clearTooltip(), r.length === 1) {
3287
- this._title.node.style.display = "flex", this._oneBox.node.style.display = "flex", this._title.node.textContent = this._formatDate(r[0].time);
3288
- const _ = this._createLineNodes(r[0], {
3289
- price: "Price:",
3290
- profit: "Realized P&L:",
3291
- volume: "Volume:",
3292
- percentage: "% of position:"
3293
- });
3294
- this._oneBox.append(..._), this.node.append(this._title.node, this._oneBox.node);
3295
- } else if (r.length > 1) {
3296
- this._manyBox.node.style.display = "flex";
3297
- const _ = r.map((g) => {
3298
- const p = new R({ tag: "div" }), v = this._createLineNodes(g, {
3299
- kind: g.kind === "entry" ? "Entry:" : "Exit:",
3300
- price: "Price:"
3282
+ updateContent(t) {
3283
+ if (t.length) {
3284
+ if (this._clearTooltip(), t.length === 1) {
3285
+ this._title.node.style.display = "flex", this._oneBox.node.style.display = "flex", this._title.node.textContent = this._formatDate(t[0].time);
3286
+ const s = this._createLineNodes(t[0], {
3287
+ price: "Price:",
3288
+ profit: "Realized P&L:",
3289
+ volume: "Volume:",
3290
+ percentage: "% of position:"
3301
3291
  });
3302
- return p.append(...v), p.node;
3303
- });
3304
- this._manyBox.append(..._), this.node.append(this._manyBox.node);
3305
- }
3306
- this.updateAbsolutePosition();
3307
- const o = this.absolutePosition, l = {
3308
- top: 0,
3309
- left: 0,
3310
- bottom: s.chart.bottom - s.chart.top,
3311
- right: s.chart.right - s.chart.left
3312
- }, c = 8;
3313
- let d = t + c, u = n + c;
3314
- d + o.width > l.right && (d = t - o.width - c, d < l.left + c && (d = l.left + c)), u + o.height > l.bottom && (u = n - o.height - c, u < l.top + c && (u = l.top + c)), this.node.style.left = `${d}px`, this.node.style.top = `${u}px`;
3315
- }
3316
- hide() {
3317
- this.node.style.opacity = "0", this.node.style.visibility = "hidden";
3292
+ this._oneBox.append(...s), this.node.append(this._title.node, this._oneBox.node);
3293
+ } else if (t.length > 1) {
3294
+ this._manyBox.node.style.display = "flex";
3295
+ const s = t.map((r) => {
3296
+ const n = new R({ tag: "div" }), o = this._createLineNodes(r, {
3297
+ kind: r.kind === "entry" ? "Entry:" : "Exit:",
3298
+ price: "Price:"
3299
+ });
3300
+ return n.append(...o), n.node;
3301
+ });
3302
+ this._manyBox.append(...s), this.node.append(this._manyBox.node);
3303
+ }
3304
+ }
3318
3305
  }
3319
3306
  }
3320
- class sr {
3321
- constructor(e, { domParent: t, canvasParent: n, width: r, height: s }) {
3322
- m(this, "_canvas");
3323
- m(this, "_markerManager");
3324
- m(this, "_labelTooltip");
3325
- this._canvas = new Te({ className: "sc-charts-cs__canvas-trade", width: r, height: s }), this._labelTooltip = new nr(), n.append(this._canvas.node), t.append(this._labelTooltip.node), this._markerManager = new Zt(e, "sc-charts-cs__canvas-trade-markers");
3307
+ class rr {
3308
+ constructor({ domParent: e, canvasParent: t, width: s, height: r }) {
3309
+ g(this, "_canvas");
3310
+ g(this, "_labelTooltip");
3311
+ this._canvas = new Me({ className: "sc-charts-cs__canvas-trade", width: s, height: r }), this._labelTooltip = new nr(), t.append(this._canvas.node), e.append(this._labelTooltip.node);
3326
3312
  }
3327
3313
  get canvas() {
3328
3314
  return this._canvas;
@@ -3331,58 +3317,94 @@ class sr {
3331
3317
  return this._labelTooltip;
3332
3318
  }
3333
3319
  renderAll(e) {
3334
- this._canvas.clear(), tr(this._canvas.ctx, e), er(this._canvas.ctx, e), ir(this._canvas.ctx, e), this._markerManager.render(e.trade.markers.data);
3320
+ this._canvas.clear(), ir(this._canvas.ctx, e), tr(this._canvas.ctx, e), sr(this._canvas.ctx, e);
3335
3321
  }
3336
3322
  }
3337
- class rr extends R {
3323
+ class ar {
3324
+ constructor(e, t) {
3325
+ g(this, "canvas");
3326
+ g(this, "parent");
3327
+ g(this, "items", {});
3328
+ g(this, "className");
3329
+ this.className = t, this.canvas = new Me({
3330
+ width: e.width,
3331
+ height: e.height,
3332
+ className: `${t}-canvas`
3333
+ }), e.canvasesContainer.append(this.canvas.node), this.parent = new R({ tag: "div", className: t }), e.domElements.append(this.parent.node);
3334
+ }
3335
+ render(e) {
3336
+ const t = new Set(e.map(this.getIdFromMarker));
3337
+ this.canvas.clear(), this.removeObsoleteItems(t);
3338
+ for (const s of e) {
3339
+ const r = this.getIdFromMarker(s), n = this.items[r] ?? this.createMarkerElement(r);
3340
+ this.renderMarker(s, n.node);
3341
+ }
3342
+ }
3343
+ clear() {
3344
+ this.canvas.clear(), this.parent.remove();
3345
+ }
3346
+ getIdFromMarker(e) {
3347
+ const t = e.type === "horizontal" ? "h" : "v", s = e.value instanceof Date ? e.value.getTime().toString() : e.value.toString().replace(".", "d");
3348
+ return `${t}_${s}`;
3349
+ }
3350
+ removeObsoleteItems(e) {
3351
+ for (const t in this.items)
3352
+ e.has(t) || (this.items[t].remove(), delete this.items[t]);
3353
+ }
3354
+ createMarkerElement(e) {
3355
+ const t = new R({
3356
+ tag: "div",
3357
+ className: `${this.className}-item`
3358
+ });
3359
+ return this.parent.append(t.node), this.items[e] = t, t;
3360
+ }
3361
+ renderMarker(e, t) {
3362
+ e.type === "horizontal" ? j.horizontalMarker({
3363
+ ctx: this.canvas.ctx,
3364
+ node: t,
3365
+ ...e
3366
+ }) : j.verticalMarker({
3367
+ ctx: this.canvas.ctx,
3368
+ node: t,
3369
+ ...e
3370
+ });
3371
+ }
3372
+ }
3373
+ class or extends Wt {
3338
3374
  constructor() {
3339
- super({ className: "sc-charts-cs__candle-tooltip_nodata" });
3375
+ super({ className: "sc-charts-cs__candle-tooltip_nodata", isAdaptPosition: !0 });
3340
3376
  const e = new R({ tag: "p" });
3341
3377
  e.node.textContent = "No data from broker", this.append(e.node);
3342
3378
  }
3343
- show({ x: e, y: t, layout: n }) {
3344
- this.node.style.opacity = "1", this.node.style.visibility = "visible", this.updateAbsolutePosition();
3345
- const r = this.absolutePosition, s = {
3346
- top: 0,
3347
- left: 0,
3348
- bottom: n.chart.bottom - n.chart.top,
3349
- right: n.chart.right - n.chart.left
3350
- }, o = 8;
3351
- let l = e + o, c = t + o;
3352
- l + r.width > s.right && (l = e - r.width - o, l < s.left + o && (l = s.left + o)), c + r.height > s.bottom && (c = t - r.height - o, c < s.top + o && (c = s.top + o)), this.node.style.left = `${l}px`, this.node.style.top = `${c}px`;
3353
- }
3354
- hide() {
3355
- this.node.style.opacity = "0", this.node.style.visibility = "hidden";
3356
- }
3357
3379
  }
3358
- class ar {
3380
+ class lr {
3359
3381
  constructor(e) {
3360
- m(this, "_container");
3361
- m(this, "_width");
3362
- m(this, "_height");
3363
- m(this, "_wrapper");
3364
- m(this, "_domElements");
3365
- m(this, "_canvasesContainer");
3366
- m(this, "_mainCanvas");
3367
- m(this, "_guidesCanvas");
3368
- m(this, "_bindingManager");
3369
- m(this, "_userMarkers");
3370
- m(this, "_guideMarkers");
3371
- m(this, "_trade");
3372
- m(this, "_noDataTooltip");
3382
+ g(this, "_container");
3383
+ g(this, "_width");
3384
+ g(this, "_height");
3385
+ g(this, "_wrapper");
3386
+ g(this, "_domElements");
3387
+ g(this, "_canvasesContainer");
3388
+ g(this, "_mainCanvas");
3389
+ g(this, "_guidesCanvas");
3390
+ g(this, "_bindingManager");
3391
+ g(this, "_userMarkers");
3392
+ g(this, "_guideMarkers");
3393
+ g(this, "_trade");
3394
+ g(this, "_noDataTooltip");
3373
3395
  this._container = e, this._wrapper = new R({ tag: "div", className: "sc-charts-cs" }), e.append(this._wrapper.node);
3374
- const { width: t, height: n } = e.getBoundingClientRect();
3375
- this._width = t, this._height = n, this._mainCanvas = new Te({
3396
+ const { width: t, height: s } = e.getBoundingClientRect();
3397
+ this._width = t, this._height = s, this._mainCanvas = new Me({
3376
3398
  className: "sc-charts-cs__canvas-main",
3377
3399
  width: t,
3378
- height: n,
3400
+ height: s,
3379
3401
  isMain: !0
3380
- }), this._guidesCanvas = new Te({ className: "sc-charts-cs__canvas-guides", width: t, height: n }), this._domElements = new R({ tag: "div", className: "sc-charts-cs__dom-elements" }), this._canvasesContainer = new R({ tag: "div", className: "sc-charts-cs__canvases" }), this._noDataTooltip = new rr(), this._canvasesContainer.append(this._mainCanvas.node), this._wrapper.append(this._canvasesContainer.node, this._domElements.node), this._mainCanvas.updateAbsolutePosition(), this._bindingManager = new Js(this._mainCanvas.node), this._userMarkers = new Zt(this, "sc-charts-cs__user-markers"), this._trade = new sr(this, {
3402
+ }), this._guidesCanvas = new Me({ className: "sc-charts-cs__canvas-guides", width: t, height: s }), this._domElements = new R({ tag: "div", className: "sc-charts-cs__dom-elements" }), this._canvasesContainer = new R({ tag: "div", className: "sc-charts-cs__canvases" }), this._noDataTooltip = new or(), this._canvasesContainer.append(this._mainCanvas.node), this._wrapper.append(this._canvasesContainer.node, this._domElements.node), this._mainCanvas.updateAbsolutePosition(), this._bindingManager = new Qn(this._mainCanvas.node), this._userMarkers = new ar(this, "sc-charts-cs__user-markers"), this._trade = new rr({
3381
3403
  width: t,
3382
- height: n,
3404
+ height: s,
3383
3405
  canvasParent: this._canvasesContainer,
3384
3406
  domParent: this._domElements
3385
- }), this._guideMarkers = new Qs(this._domElements, this._guidesCanvas), this._domElements.append(this._noDataTooltip.node), this._canvasesContainer.append(this._guidesCanvas.node);
3407
+ }), this._guideMarkers = new qn(this._domElements, this._guidesCanvas), this._domElements.append(this._noDataTooltip.node), this._canvasesContainer.append(this._guidesCanvas.node);
3386
3408
  }
3387
3409
  get container() {
3388
3410
  return this._container;
@@ -3424,66 +3446,12 @@ class ar {
3424
3446
  return this._noDataTooltip;
3425
3447
  }
3426
3448
  renderAll(e) {
3427
- this._mainCanvas.clear(), Gs.renderAll(this._mainCanvas.ctx, e), Ze.xAxis(this._mainCanvas.ctx, e), Ze.yAxis(this._mainCanvas.ctx, e), Ze.intersection(this._mainCanvas.ctx, e), this._trade.renderAll(e), this._userMarkers.render(e.userMarkers.data);
3428
- }
3429
- setCursor(e, t = !1) {
3430
- const n = {
3431
- x_axis: t ? "grabbing" : "ew-resize",
3432
- y_axis: t ? "grabbing" : "ns-resize",
3433
- area: t ? "grabbing" : "crosshair",
3434
- default: "default"
3435
- };
3436
- this._mainCanvas.node.style.cursor = n[e];
3437
- }
3438
- }
3439
- const or = (i, e) => {
3440
- e.scales.x.setRange([0, e.layout.area.width]);
3441
- const t = e.scales.x.domain(), n = e.scales.x.range(), r = e.scales.x.invert(n[0] - i).getTime() - t[0].getTime();
3442
- e.scales.x.setDomain([
3443
- new Date(t[0].getTime() + r),
3444
- new Date(t[1].getTime() + r)
3445
- ]);
3446
- }, lr = (i, e) => {
3447
- e.scales.y.setRange([e.layout.area.height, 0]);
3448
- const t = e.scales.y.domain(), n = e.scales.y.range(), r = e.scales.y.invert(n[0] - i) - t[0];
3449
- e.scales.y.setDomain([t[0] + r, t[1] + r]);
3450
- }, cr = 2e-3, Ut = { x: 0.2, y: 0.2 }, hr = 1e-3, Vt = (i, e, t) => Math.max(i, t + e * cr), Jt = (i, e) => Math.abs(i - e) > hr, Bt = (i, e) => {
3451
- const t = e.scales.factorX, n = Vt(Ut.x, i, t);
3452
- if (Jt(n, t)) {
3453
- e.scales.factorX = n;
3454
- const r = t / n, [s, o] = e.scales.x.domain(), l = s.getTime(), c = o.getTime(), d = new Date(l + (c - l) * r);
3455
- e.scales.x.setDomain([s, d]);
3456
- }
3457
- }, Ot = (i, e) => {
3458
- const t = e.scales.factorX, n = Vt(Ut.y, -i, t);
3459
- if (Jt(n, t)) {
3460
- e.scales.factorY = n;
3461
- const r = t / n, [s, o] = e.scales.y.domain(), l = s + (o - s) * r;
3462
- e.scales.y.setDomain([s, l]);
3449
+ this._mainCanvas.clear(), Un.renderAll(this._mainCanvas.ctx, e), Ge.xAxis(this._mainCanvas.ctx, e), Ge.yAxis(this._mainCanvas.ctx, e), Ge.intersection(this._mainCanvas.ctx, e), this._trade.renderAll(e), this._userMarkers.render(e.userMarkers.data);
3463
3450
  }
3464
- };
3465
- function Pt(i, e, t) {
3466
- const { xAxis: n, yAxis: r, area: s } = t, o = i >= n.x && i <= n.x + n.width && e >= n.y && e <= n.y + n.height, l = i >= r.x && i <= r.x + r.width && e >= r.y && e <= r.y + r.height, c = i >= s.x && i <= s.x + s.width && e >= s.y && e <= s.y + s.height;
3467
- return o ? "x_axis" : l ? "y_axis" : c ? "area" : null;
3468
- }
3469
- function dr(i, e, t) {
3470
- const {
3471
- candles: { missingData: n },
3472
- scales: { x: r, y: s },
3473
- config: {
3474
- candles: { baseWidth: o }
3475
- }
3476
- } = t;
3477
- for (const l of n) {
3478
- const c = r.map(l.open_time), d = s.map(l.high), u = s.map(l.low);
3479
- if (i >= c - o / 2 && i <= c + o / 2 && e >= Math.min(d, u) && e <= Math.max(d, u))
3480
- return l;
3481
- }
3482
- return null;
3483
3451
  }
3484
- class ur {
3452
+ class cr {
3485
3453
  constructor(e) {
3486
- m(this, "logColors", {
3454
+ g(this, "logColors", {
3487
3455
  init_model: "color: green",
3488
3456
  scale_event: "color: orange",
3489
3457
  update_config: "color: blue",
@@ -3492,34 +3460,34 @@ class ur {
3492
3460
  update_user_markers: "color: brown",
3493
3461
  update_color_scheme: "color: teal"
3494
3462
  });
3495
- m(this, "ignoredLogEvents", []);
3463
+ g(this, "ignoredLogEvents", []);
3496
3464
  e && (this.ignoredLogEvents = e);
3497
3465
  }
3498
3466
  log(e, t) {
3499
3467
  if (this.ignoredLogEvents.includes(e)) return;
3500
- const n = this.logColors[e] || "color: gray";
3468
+ const s = this.logColors[e] || "color: gray";
3501
3469
  let r;
3502
3470
  try {
3503
3471
  r = JSON.parse(JSON.stringify(t));
3504
3472
  } catch {
3505
3473
  r = t;
3506
3474
  }
3507
- console.log(`%c[SUBSCRIBE] ${e}`, n, r);
3475
+ console.log(`%c[SUBSCRIBE] ${e}`, s, r);
3508
3476
  }
3509
3477
  }
3510
- class fr {
3478
+ class hr {
3511
3479
  constructor(e, t) {
3512
- m(this, "_model");
3513
- m(this, "_view");
3514
- m(this, "_enableLogging");
3515
- m(this, "_logger");
3516
- this._model = e, this._view = t, this._enableLogging = !1, this._logger = new ur(["scale_event"]);
3480
+ g(this, "_model");
3481
+ g(this, "_view");
3482
+ g(this, "_enableLogging");
3483
+ g(this, "_logger");
3484
+ this._model = e, this._view = t, this._enableLogging = !1, this._logger = new cr(["scale_event"]);
3517
3485
  }
3518
3486
  subscribeWithLogging(e, t) {
3519
- const n = (r) => {
3487
+ const s = (r) => {
3520
3488
  this._enableLogging && this._logger.log(e, r), t(r);
3521
3489
  };
3522
- this._model.subscribe(e, n);
3490
+ this._model.subscribe(e, s);
3523
3491
  }
3524
3492
  // [TODO]: optimize renderers, call only the necessary ones. Get rid of this._view.renderAll
3525
3493
  init() {
@@ -3528,7 +3496,7 @@ class fr {
3528
3496
  }), this.subscribeWithLogging("scale_event", () => {
3529
3497
  this._model.userMarkers.rebuild(), this._model.trade.recalculate(), this._view.renderAll(this._model);
3530
3498
  }), this.subscribeWithLogging("update_config", (e) => {
3531
- this._model.config.update(e), this._model.layout.updateConfig(this._model.config), this._model.scales.recalculate(), this._model.userMarkers.rebuild(), this._model.trade.markers.rebuild(), this._view.renderAll(this._model);
3499
+ this._model.config.update(e), this._model.layout.updateConfig(this._model.config), this._model.scales.recalculate(), this._model.userMarkers.rebuild(), this._view.renderAll(this._model);
3532
3500
  }), this.subscribeWithLogging("update_candles", (e) => {
3533
3501
  this._model.candles.update(e), this._model.trade.recalculate(), this._model.scales.recalculate(), this._view.renderAll(this._model);
3534
3502
  }), this.subscribeWithLogging("update_trade", (e) => {
@@ -3537,45 +3505,447 @@ class fr {
3537
3505
  this._model.userMarkers.updateMarkers(e), this._view.userMarkers.render(this._model.userMarkers.data);
3538
3506
  }), this.subscribeWithLogging("update_color_scheme", (e) => {
3539
3507
  this._model.colorScheme.update(e), this._view.renderAll(this._model);
3540
- }), this.subscribeWithLogging("open_trade_label_tooltip", ({ trade: e, x: t, y: n }) => {
3541
- this._model.trade.setActiveTrade(e.candle.open_time.getTime()), this._view.trade.renderAll(this._model), this._view.trade.labelTooltip.show({ trade: e, x: t, y: n, layout: this._model.layout });
3508
+ }), this.subscribeWithLogging("open_trade_label_tooltip", ({ trade: e, x: t, y: s }) => {
3509
+ this._model.trade.setActiveTrade(e.candle.open_time.getTime()), this._view.trade.renderAll(this._model), this._view.trade.labelTooltip.updateContent(e.trades), this._view.trade.labelTooltip.show({ x: t, y: s, parent: this._model.layout.chart });
3542
3510
  }), this.subscribeWithLogging("close_trade_label_tooltip", () => {
3543
3511
  this._model.trade.setActiveTrade(null), this._view.trade.renderAll(this._model), this._view.trade.labelTooltip.hide();
3544
3512
  }), this.subscribeWithLogging("hover_nodata_candle", ({ x: e, y: t }) => {
3545
- this._view.noDataTooltip.show({ x: e, y: t, layout: this._model.layout });
3513
+ this._view.noDataTooltip.show({ x: e, y: t, parent: this._model.layout.area });
3546
3514
  }), this.subscribeWithLogging("leave_nodata_candle", () => {
3547
3515
  this._view.noDataTooltip.hide();
3516
+ }), this.subscribeWithLogging("mouseover_trade_label_tooltip", (e) => {
3517
+ this._model.trade.setHoveredTrade(e.candle.open_time.getTime()), this._view.trade.renderAll(this._model);
3518
+ }), this.subscribeWithLogging("mouseleave_trade_label_tooltip", () => {
3519
+ this._model.trade.setHoveredTrade(null), this._view.trade.renderAll(this._model);
3548
3520
  });
3549
3521
  }
3550
3522
  }
3523
+ class $t {
3524
+ constructor() {
3525
+ g(this, "_map", /* @__PURE__ */ new Map());
3526
+ }
3527
+ add(e, t, s) {
3528
+ let r = this._map.get(e);
3529
+ r || (r = {}, this._map.set(e, r)), r[t] || (r[t] = /* @__PURE__ */ new Set()), r[t].add(s);
3530
+ }
3531
+ remove(e, t, s) {
3532
+ var n;
3533
+ const r = this._map.get(e);
3534
+ (n = r == null ? void 0 : r[t]) == null || n.delete(s);
3535
+ }
3536
+ removeAll(e) {
3537
+ this._map.delete(e);
3538
+ }
3539
+ emit(e, t) {
3540
+ const s = this._map.get(e), r = s == null ? void 0 : s[t.type];
3541
+ if (!r) return !1;
3542
+ let n = !1;
3543
+ const o = {
3544
+ ...t,
3545
+ stopPropagation: () => {
3546
+ n = !0;
3547
+ }
3548
+ };
3549
+ for (const l of r)
3550
+ if (l(o), n) break;
3551
+ return n;
3552
+ }
3553
+ }
3554
+ class dr {
3555
+ constructor() {
3556
+ g(this, "_elements", []);
3557
+ g(this, "_listeners", new $t());
3558
+ g(this, "_lastHovered", /* @__PURE__ */ new Set());
3559
+ g(this, "_dragContext", null);
3560
+ }
3561
+ get isDragging() {
3562
+ return this._dragContext !== null;
3563
+ }
3564
+ register(...e) {
3565
+ this._elements.push(...e);
3566
+ }
3567
+ unregister(e) {
3568
+ this._elements = this._elements.filter((t) => t !== e), this._listeners.removeAll(e), this._lastHovered.delete(e);
3569
+ }
3570
+ clear() {
3571
+ this._elements = [], this._listeners = new $t(), this._lastHovered.clear();
3572
+ }
3573
+ on(e, t, s) {
3574
+ this._listeners.add(e, t, s);
3575
+ }
3576
+ off(e, t, s) {
3577
+ this._listeners.remove(e, t, s);
3578
+ }
3579
+ dispatchMouseMove(e, t) {
3580
+ if (this._dragContext) {
3581
+ this._emitSingle(this._dragContext.target, {
3582
+ type: "drag",
3583
+ target: this._dragContext.target,
3584
+ x: e,
3585
+ y: t,
3586
+ prevX: this._dragContext.lastX,
3587
+ prevY: this._dragContext.lastY
3588
+ }), this._dragContext.lastX = e, this._dragContext.lastY = t;
3589
+ return;
3590
+ }
3591
+ const s = this._getHitsAt(e, t), r = new Set(s.map((n) => n.target));
3592
+ for (const n of s)
3593
+ if (!this._lastHovered.has(n.target) && this._emitSingle(n.target, {
3594
+ type: "mouseover",
3595
+ target: n.target,
3596
+ x: n.x,
3597
+ y: n.y
3598
+ }) || this._emitSingle(n.target, {
3599
+ type: "mousemove",
3600
+ target: n.target,
3601
+ x: n.x,
3602
+ y: n.y
3603
+ })) break;
3604
+ for (const n of this._lastHovered)
3605
+ r.has(n) || this._emitSingle(n, {
3606
+ type: "mouseleave",
3607
+ target: n,
3608
+ x: e,
3609
+ y: t
3610
+ });
3611
+ this._lastHovered = r;
3612
+ }
3613
+ dispatchMouseDown(e, t) {
3614
+ const s = this._getHitsAt(e, t);
3615
+ if (s.length === 0) {
3616
+ this._dragContext = null;
3617
+ return;
3618
+ }
3619
+ this._dragContext = null;
3620
+ for (const r of s)
3621
+ if (this._emitSingle(r.target, {
3622
+ type: "mousedown",
3623
+ target: r.target,
3624
+ x: r.x,
3625
+ y: r.y
3626
+ })) {
3627
+ this._dragContext = { target: r.target, lastX: e, lastY: t };
3628
+ break;
3629
+ }
3630
+ !this._dragContext && s.length > 0 && (this._dragContext = { target: s[s.length - 1].target, lastX: e, lastY: t });
3631
+ }
3632
+ dispatchMouseUp(e, t) {
3633
+ this._dragContext && this._emitSingle(this._dragContext.target, {
3634
+ type: "mouseup",
3635
+ target: this._dragContext.target,
3636
+ x: e,
3637
+ y: t
3638
+ }), this._dragContext = null;
3639
+ }
3640
+ dispatchClick(e, t) {
3641
+ const s = this._getHitsAt(e, t);
3642
+ for (const r of s)
3643
+ if (this._emitSingle(r.target, {
3644
+ type: "click",
3645
+ target: r.target,
3646
+ x: r.x,
3647
+ y: r.y
3648
+ })) break;
3649
+ }
3650
+ dispatchDblClick(e, t) {
3651
+ const s = this._getHitsAt(e, t);
3652
+ for (const r of s)
3653
+ if (this._emitSingle(r.target, {
3654
+ type: "dblclick",
3655
+ target: r.target,
3656
+ x: r.x,
3657
+ y: r.y
3658
+ })) break;
3659
+ }
3660
+ dispatchWheel(e, t, s, r, n) {
3661
+ const o = this._getHitsAt(e, t);
3662
+ for (const l of o)
3663
+ if (this._emitSingle(l.target, {
3664
+ type: "wheel",
3665
+ target: l.target,
3666
+ x: l.x,
3667
+ y: l.y,
3668
+ deltaX: s,
3669
+ deltaY: r,
3670
+ deltaZ: n
3671
+ })) break;
3672
+ }
3673
+ hitTestAll(e, t) {
3674
+ return this._getHitsAt(e, t);
3675
+ }
3676
+ _getHitsAt(e, t) {
3677
+ return this._elements.map((s) => s.hitTest(e, t)).filter((s) => s !== null);
3678
+ }
3679
+ _emitSingle(e, t) {
3680
+ let s = !1;
3681
+ const r = {
3682
+ ...t,
3683
+ stopPropagation() {
3684
+ s = !0;
3685
+ }
3686
+ };
3687
+ return this._listeners.emit(e, r), s;
3688
+ }
3689
+ }
3690
+ class ur {
3691
+ constructor(e) {
3692
+ this.model = e;
3693
+ }
3694
+ hitTest(e, t) {
3695
+ const {
3696
+ candles: { missingData: s },
3697
+ scales: { x: r, y: n },
3698
+ config: {
3699
+ candles: { baseWidth: o }
3700
+ }
3701
+ } = this.model;
3702
+ for (const l of s) {
3703
+ const h = r.map(l.open_time), d = n.map(l.high), u = n.map(l.low), _ = h - o / 2, m = h + o / 2, p = Math.min(d, u), v = Math.max(d, u);
3704
+ if (e >= _ && e <= m && t >= p && t <= v)
3705
+ return {
3706
+ target: this,
3707
+ x: e,
3708
+ y: t,
3709
+ type: "candle",
3710
+ candle: l
3711
+ };
3712
+ }
3713
+ return null;
3714
+ }
3715
+ }
3551
3716
  class gr {
3552
3717
  constructor(e, t) {
3553
- m(this, "_model");
3554
- m(this, "_view");
3555
- m(this, "_activeZone", null);
3556
- m(this, "_lastMouseX", 0);
3557
- m(this, "_lastMouseY", 0);
3558
- m(this, "_isDragging", !1);
3559
- m(this, "_hoveredCandle", null);
3560
- m(this, "_subscriptionsManager");
3561
- m(this, "_boundMouseMove", this.onDocumentMouseMove.bind(this));
3562
- m(this, "_boundMouseUp", this.onDocumentMouseUp.bind(this));
3563
- this._model = e, this._view = t, this._subscriptionsManager = new fr(e, t);
3718
+ g(this, "_model");
3719
+ g(this, "_hitManager");
3720
+ g(this, "_hit");
3721
+ this._model = e, this._hitManager = t, this._hit = new ur(e), this._hitManager.register(this._hit);
3722
+ }
3723
+ register() {
3724
+ this._hitManager.on(this._hit, "mouseover", (e) => {
3725
+ const t = this._hit.hitTest(e.x, e.y);
3726
+ if (!t) return;
3727
+ const s = this._model.scales.x.map(t.candle.open_time), r = this._model.scales.y.map(t.candle.high) - 4;
3728
+ this._model.eventBus.emit("hover_nodata_candle", { x: s, y: r });
3729
+ }), this._hitManager.on(this._hit, "mouseleave", () => {
3730
+ this._model.eventBus.emit("leave_nodata_candle");
3731
+ });
3732
+ }
3733
+ }
3734
+ class fr {
3735
+ constructor(e) {
3736
+ this.model = e;
3737
+ }
3738
+ hitTest(e, t) {
3739
+ const { tradedCandles: s } = this.model.trade, { x: r, y: n } = this.model.scales, o = 16, l = 4;
3740
+ for (const { candle: h, trades: d } of s) {
3741
+ const u = r.map(h.open_time), _ = o, m = o, p = d[0].type === "buy", v = u + this.model.config.candles.baseWidth / 2, y = p ? n.map(h.low) + l + Ce(o) : n.map(h.high) - l - o - Ce(o), b = e >= v - _ / 2 && e <= v + _ / 2, x = t >= y && t <= y + m;
3742
+ if (b && x)
3743
+ return {
3744
+ target: this,
3745
+ type: "trade-label",
3746
+ x: e,
3747
+ y: t,
3748
+ candle: h,
3749
+ trades: d
3750
+ };
3751
+ }
3752
+ return null;
3753
+ }
3754
+ }
3755
+ class _r {
3756
+ constructor(e, t) {
3757
+ g(this, "_model");
3758
+ g(this, "_hitManager");
3759
+ g(this, "_tradeLabelHit");
3760
+ this._model = e, this._hitManager = t, this._tradeLabelHit = new fr(e), this._hitManager.register(this._tradeLabelHit);
3761
+ }
3762
+ register() {
3763
+ this._hitManager.on(this._tradeLabelHit, "click", (e) => {
3764
+ const t = this._tradeLabelHit.hitTest(e.x, e.y);
3765
+ if (!t) return;
3766
+ const s = this._model.scales.x.map(t.candle.open_time), r = this._model.scales.y.map(
3767
+ t.trades[0].type === "buy" ? t.candle.low : t.candle.high
3768
+ ), n = t.trades[0].type === "buy" ? r + 4 + Ce(16) + 8 : r - 4 - 16 - Ce(16) + 8;
3769
+ this._model.eventBus.emit("open_trade_label_tooltip", {
3770
+ trade: { candle: t.candle, trades: t.trades },
3771
+ x: s,
3772
+ y: n
3773
+ });
3774
+ }), this._hitManager.on(this._tradeLabelHit, "mouseover", (e) => {
3775
+ const t = this._tradeLabelHit.hitTest(e.x, e.y);
3776
+ t && this._model.eventBus.emit("mouseover_trade_label_tooltip", {
3777
+ candle: t.candle,
3778
+ trades: t.trades
3779
+ });
3780
+ }), this._hitManager.on(this._tradeLabelHit, "mouseleave", () => {
3781
+ this._model.eventBus.emit("mouseleave_trade_label_tooltip");
3782
+ });
3783
+ }
3784
+ }
3785
+ class mr {
3786
+ constructor(e) {
3787
+ this.model = e;
3788
+ }
3789
+ hitTest(e, t) {
3790
+ const { xAxis: s } = this.model.layout;
3791
+ return e >= s.x && e <= s.x + s.width && t >= s.y && t <= s.y + s.height ? {
3792
+ target: this,
3793
+ x: e,
3794
+ y: t,
3795
+ type: "x-axis"
3796
+ } : null;
3797
+ }
3798
+ }
3799
+ const pr = (i, e) => {
3800
+ e.scales.x.setRange([0, e.layout.area.width]);
3801
+ const t = e.scales.x.domain(), s = e.scales.x.range(), r = e.scales.x.invert(s[0] - i).getTime() - t[0].getTime();
3802
+ e.scales.x.setDomain([
3803
+ new Date(t[0].getTime() + r),
3804
+ new Date(t[1].getTime() + r)
3805
+ ]);
3806
+ }, vr = (i, e) => {
3807
+ e.scales.y.setRange([e.layout.area.height, 0]);
3808
+ const t = e.scales.y.domain(), s = e.scales.y.range(), r = e.scales.y.invert(s[0] - i) - t[0];
3809
+ e.scales.y.setDomain([t[0] + r, t[1] + r]);
3810
+ }, yr = 2e-3, Gt = { x: 0.2, y: 0.2 }, br = 1e-3, Ut = (i, e, t) => Math.max(i, t + e * yr), Zt = (i, e) => Math.abs(i - e) > br, Vt = (i, e) => {
3811
+ const t = e.scales.factorX, s = Ut(Gt.x, i, t);
3812
+ if (Zt(s, t)) {
3813
+ e.scales.factorX = s;
3814
+ const r = t / s, [n, o] = e.scales.x.domain(), l = n.getTime(), h = o.getTime(), d = new Date(l + (h - l) * r);
3815
+ e.scales.x.setDomain([n, d]);
3816
+ }
3817
+ }, Jt = (i, e) => {
3818
+ const t = e.scales.factorX, s = Ut(Gt.y, -i, t);
3819
+ if (Zt(s, t)) {
3820
+ e.scales.factorY = s;
3821
+ const r = t / s, [n, o] = e.scales.y.domain(), l = n + (o - n) * r;
3822
+ e.scales.y.setDomain([n, l]);
3823
+ }
3824
+ };
3825
+ class xr {
3826
+ constructor(e) {
3827
+ this.model = e;
3828
+ }
3829
+ hitTest(e, t) {
3830
+ const { area: s } = this.model.layout;
3831
+ return e >= s.x && e <= s.x + s.width && t >= s.y && t <= s.y + s.height ? {
3832
+ target: this,
3833
+ x: e,
3834
+ y: t,
3835
+ type: "area"
3836
+ } : null;
3837
+ }
3838
+ }
3839
+ class wr {
3840
+ constructor(e) {
3841
+ this.model = e;
3842
+ }
3843
+ hitTest(e, t) {
3844
+ const { yAxis: s } = this.model.layout;
3845
+ return e >= s.x && e <= s.x + s.width && t >= s.y && t <= s.y + s.height ? {
3846
+ target: this,
3847
+ x: e,
3848
+ y: t,
3849
+ type: "y-axis"
3850
+ } : null;
3851
+ }
3852
+ }
3853
+ class Mr {
3854
+ constructor(e, t) {
3855
+ g(this, "_model");
3856
+ g(this, "_hitManager");
3857
+ g(this, "_hit");
3858
+ this._model = e, this._hitManager = t, this._hit = new mr(e), this._hitManager.register(this._hit);
3859
+ }
3860
+ register() {
3861
+ this._hitManager.on(this._hit, "drag", (e) => {
3862
+ const t = e.x - (e.prevX ?? e.x);
3863
+ Vt(t, this._model);
3864
+ }), this._hitManager.on(this._hit, "dblclick", () => {
3865
+ this._model.eventBus.emit("update_config", {});
3866
+ });
3867
+ }
3868
+ }
3869
+ class Tr {
3870
+ constructor(e, t) {
3871
+ g(this, "_model");
3872
+ g(this, "_hitManager");
3873
+ g(this, "_hit");
3874
+ this._model = e, this._hitManager = t, this._hit = new wr(e), this._hitManager.register(this._hit);
3875
+ }
3876
+ register() {
3877
+ this._hitManager.on(this._hit, "drag", (e) => {
3878
+ const t = e.y - (e.prevY ?? e.y);
3879
+ Jt(t, this._model);
3880
+ }), this._hitManager.on(this._hit, "dblclick", () => {
3881
+ this._model.eventBus.emit("update_config", {});
3882
+ });
3883
+ }
3884
+ }
3885
+ class Cr {
3886
+ constructor(e, t, s) {
3887
+ g(this, "_model");
3888
+ g(this, "_view");
3889
+ g(this, "_hitManager");
3890
+ g(this, "_hit");
3891
+ this._model = e, this._view = t, this._hitManager = s, this._hit = new xr(e), this._hitManager.register(this._hit);
3892
+ }
3893
+ register() {
3894
+ this._hitManager.on(this._hit, "mousemove", (e) => {
3895
+ this._view.guideMarkers.show(), this._view.guideMarkers.render(this._model, { x: e.x, y: e.y });
3896
+ }), this._hitManager.on(this._hit, "mouseleave", () => {
3897
+ this._view.guideMarkers.hide();
3898
+ }), this._hitManager.on(this._hit, "drag", (e) => {
3899
+ const t = e.x - (e.prevX ?? e.x), s = e.y - (e.prevY ?? e.y);
3900
+ pr(t, this._model), vr(s, this._model), this._view.guideMarkers.render(this._model, { x: e.x, y: e.y });
3901
+ }), this._hitManager.on(this._hit, "wheel", (e) => {
3902
+ var r, n;
3903
+ if (!e.deltaY) return;
3904
+ const t = -e.deltaY, s = (n = (r = this._model.config) == null ? void 0 : r.candles) == null ? void 0 : n.zoomOnWheel;
3905
+ ["x", "both"].includes(s) && Vt(t, this._model), ["y", "both"].includes(s) && Jt(t, this._model);
3906
+ });
3907
+ }
3908
+ }
3909
+ class Ar {
3910
+ constructor(e, t, s) {
3911
+ g(this, "_hitManager");
3912
+ g(this, "_candlesHandler");
3913
+ g(this, "_tradeLabelsHandler");
3914
+ g(this, "_xAxisHandler");
3915
+ g(this, "_yAxisHandler");
3916
+ g(this, "_areaHandler");
3917
+ this._hitManager = s, this._candlesHandler = new gr(e, this._hitManager), this._tradeLabelsHandler = new _r(e, this._hitManager), this._xAxisHandler = new Mr(e, this._hitManager), this._yAxisHandler = new Tr(e, this._hitManager), this._areaHandler = new Cr(e, t, this._hitManager);
3918
+ }
3919
+ register() {
3920
+ this._candlesHandler.register(), this._tradeLabelsHandler.register(), this._xAxisHandler.register(), this._yAxisHandler.register(), this._areaHandler.register();
3921
+ }
3922
+ }
3923
+ class Sr {
3924
+ constructor(e, t) {
3925
+ g(this, "_model");
3926
+ g(this, "_view");
3927
+ g(this, "_subscriptionsManager");
3928
+ g(this, "_hitManager", new dr());
3929
+ g(this, "_boundMouseMove", this.onDocumentMouseMove.bind(this));
3930
+ g(this, "_boundMouseUp", this.onDocumentMouseUp.bind(this));
3931
+ this._model = e, this._view = t, this._subscriptionsManager = new hr(e, t);
3564
3932
  }
3565
3933
  init() {
3566
- this._subscriptionsManager.init(), this._model.init(), this._view.binding.mousemove(this.onMouseMove.bind(this)), this._view.binding.mouseleave(this.onMouseLeave.bind(this)), this._view.binding.mousedown(this.onMouseDown.bind(this)), this._view.binding.mouseup(this.onMouseUp.bind(this)), this._view.binding.wheel(this.onWheel.bind(this)), document.addEventListener("click", this.onDocumentClick.bind(this));
3934
+ this._subscriptionsManager.init(), this._model.init(), this._view.binding.mousemove(this.onMouseMove.bind(this)), this._view.binding.mousedown(this.onMouseDown.bind(this)), this._view.binding.mouseup(this.onMouseUp.bind(this)), this._view.binding.wheel(this.onWheel.bind(this)), this._view.binding.mouseleave(this.onMouseLeave.bind(this)), this._view.binding.dblclick(this.onDoubleClick.bind(this)), window.addEventListener("scroll", this.onWindowScroll.bind(this), { passive: !0 }), document.addEventListener("click", this.onDocumentClick.bind(this)), new Ar(this._model, this._view, this._hitManager).register();
3935
+ }
3936
+ onWindowScroll() {
3937
+ this._view.mainCanvas.updateAbsolutePosition();
3938
+ }
3939
+ onMouseLeave() {
3940
+ this._hitManager.isDragging || (this._hitManager.dispatchMouseMove(-1 / 0, -1 / 0), document.removeEventListener("mousemove", this._boundMouseMove), document.removeEventListener("mouseup", this._boundMouseUp));
3941
+ }
3942
+ onDoubleClick(e) {
3943
+ const { x: t, y: s } = this.getMouseRelative(e);
3944
+ this._hitManager.dispatchDblClick(t, s);
3567
3945
  }
3568
3946
  onDocumentClick(e) {
3569
- const t = this.getMouseRelative(e), { tradedCandles: n } = this._model.trade, { x: r, y: s } = this._model.scales, o = 16, l = 4;
3570
- for (const { candle: c, trades: d } of n) {
3571
- const u = r.map(c.open_time), _ = o, g = o;
3572
- for (const p of d) {
3573
- const v = p.type === "buy", y = u + this._model.config.candles.baseWidth / 2, b = v ? s.map(c.low) + l + Me(o) : s.map(c.high) - l - o - Me(o), w = t.x >= y - _ / 2 && t.x <= y + _ / 2, T = t.y >= b && t.y <= b + g;
3574
- if (w && T)
3575
- return;
3576
- }
3577
- }
3578
- this._model.trade.hasActiveTrade && this._model.eventBus.emit("close_trade_label_tooltip");
3947
+ const t = this.getMouseRelative(e);
3948
+ this._hitManager.dispatchClick(t.x, t.y), !this._hitManager.hitTestAll(t.x, t.y).find((r) => r.type === "trade-label") && this._model.trade.hasActiveTrade && this._model.eventBus.emit("close_trade_label_tooltip");
3579
3949
  }
3580
3950
  getMouseRelative(e) {
3581
3951
  return {
@@ -3583,85 +3953,55 @@ class gr {
3583
3953
  y: e.clientY - this._view.mainCanvas.absolutePosition.top
3584
3954
  };
3585
3955
  }
3956
+ onDocumentMouseMove(e) {
3957
+ const { x: t, y: s } = this.getMouseRelative(e);
3958
+ this._hitManager.dispatchMouseMove(t, s);
3959
+ }
3586
3960
  onMouseDown(e) {
3587
- this._isDragging = !0;
3588
- const { x: t, y: n } = this.getMouseRelative(e);
3589
- this._lastMouseX = t, this._lastMouseY = n, this._activeZone = Pt(t, n, this._model.layout), e.preventDefault(), document.addEventListener("mousemove", this._boundMouseMove), document.addEventListener("mouseup", this._boundMouseUp);
3961
+ const { x: t, y: s } = this.getMouseRelative(e);
3962
+ this._hitManager.dispatchMouseDown(t, s), e.preventDefault(), document.addEventListener("mouseup", this._boundMouseUp), this._hitManager.isDragging && document.addEventListener("mousemove", this._boundMouseMove);
3590
3963
  }
3591
3964
  onMouseUp(e) {
3592
- this._isDragging = !1, this._activeZone = null;
3593
- const { tradedCandles: t } = this._model.trade, { x: n, y: r } = this._model.scales, s = 16, o = 4;
3594
- for (const { candle: l, trades: c } of t) {
3595
- const d = n.map(l.open_time), u = s, _ = s;
3596
- for (const g of c) {
3597
- const p = g.type === "buy", v = d + this._model.config.candles.baseWidth / 2, y = p ? r.map(l.low) + o + Me(s) : r.map(l.high) - o - s - Me(s), b = this.getMouseRelative(e), w = b.x >= v - u / 2 && b.x <= v + u / 2, T = b.y >= y && b.y <= y + _;
3598
- if (w && T) {
3599
- this._model.eventBus.emit("open_trade_label_tooltip", {
3600
- trade: { candle: l, trades: c },
3601
- x: d,
3602
- y: y + _ / 2
3603
- });
3604
- return;
3605
- }
3606
- }
3607
- }
3608
- document.removeEventListener("mousemove", this._boundMouseMove), document.removeEventListener("mouseup", this._boundMouseUp);
3609
- }
3610
- onDocumentMouseMove(e) {
3611
- if (!this._isDragging || !this._activeZone) return;
3612
- const { x: t, y: n } = this.getMouseRelative(e), r = t - this._lastMouseX, s = n - this._lastMouseY;
3613
- this._activeZone === "x_axis" && Bt(r, this._model), this._activeZone === "y_axis" && Ot(s, this._model), this._activeZone === "area" && (or(r, this._model), lr(s, this._model), this._lastMouseX = t, this._lastMouseY = n), this._lastMouseX = t, this._lastMouseY = n, this._activeZone === "area" && (this._view.guideMarkers.show(), this._view.guideMarkers.render(this._model, { x: t, y: n }), this._view.setCursor(this._activeZone ?? "default", !0));
3965
+ const t = this.getMouseRelative(e);
3966
+ this._hitManager.dispatchMouseUp(t.x, t.y), document.removeEventListener("mouseup", this._boundMouseUp);
3614
3967
  }
3615
- onDocumentMouseUp() {
3616
- this._isDragging = !1, this._activeZone = null, document.removeEventListener("mousemove", this._boundMouseMove), document.removeEventListener("mouseup", this._boundMouseUp);
3968
+ onDocumentMouseUp(e) {
3969
+ const { x: t, y: s } = this.getMouseRelative(e);
3970
+ this._hitManager.dispatchMouseUp(t, s), document.removeEventListener("mouseup", this._boundMouseUp), document.removeEventListener("mousemove", this._boundMouseMove);
3617
3971
  }
3618
3972
  onMouseMove(e) {
3619
- if (this._isDragging) return;
3620
- const { x: t, y: n } = this.getMouseRelative(e), {
3621
- layout: r,
3622
- scales: { x: s, y: o }
3623
- } = this._model;
3624
- if (this._activeZone = Pt(t, n, r), this._view.setCursor(this._activeZone ?? "default", this._isDragging), this._activeZone === "area") {
3625
- this._view.guideMarkers.show(), this._view.guideMarkers.render(this._model, { x: t, y: n });
3626
- const l = dr(t, n, this._model);
3627
- if (l && (!this._hoveredCandle || this._hoveredCandle.candle !== l)) {
3628
- const c = s.map(l.open_time), d = o.map(l.high) - 4;
3629
- this._hoveredCandle = { candle: l, x: c, y: d }, this._model.eventBus.emit("hover_nodata_candle", { x: c, y: d });
3630
- }
3631
- !l && this._hoveredCandle && (this._hoveredCandle = null, this._model.eventBus.emit("leave_nodata_candle"));
3632
- } else
3633
- this._hoveredCandle = null, this._view.guideMarkers.hide(), this._model.eventBus.emit("leave_nodata_candle");
3634
- }
3635
- onMouseLeave() {
3636
- this._activeZone = null, this._hoveredCandle = null, this._view.guideMarkers.hide(), this._model.eventBus.emit("leave_nodata_candle");
3973
+ var n;
3974
+ if (!this._hitManager.isDragging) {
3975
+ const { x: o, y: l } = this.getMouseRelative(e);
3976
+ this._hitManager.dispatchMouseMove(o, l);
3977
+ }
3978
+ const { x: t, y: s } = this.getMouseRelative(e), r = this._hitManager.hitTestAll(t, s);
3979
+ (n = r[0]) != null && n.type && (r[0].type === "area" ? this._view.mainCanvas.node.style.cursor = "crosshair" : r[0].type === "trade-label" ? this._view.mainCanvas.node.style.cursor = "pointer" : r[0].type === "x-axis" ? this._view.mainCanvas.node.style.cursor = "ew-resize" : r[0].type === "y-axis" ? this._view.mainCanvas.node.style.cursor = "ns-resize" : this._view.mainCanvas.node.style.cursor = "default");
3637
3980
  }
3638
3981
  onWheel(e) {
3639
- var r, s;
3640
- e.preventDefault();
3641
- const t = -e.deltaY, n = (s = (r = this._model.config) == null ? void 0 : r.candles) == null ? void 0 : s.zoomOnWheel;
3642
- ["x", "both"].includes(n) && Bt(t, this._model), ["y", "both"].includes(n) && Ot(t, this._model);
3643
- }
3644
- }
3645
- class pr {
3646
- constructor(e, { chartId: t, candles: n, config: r, trade: s, userMarkers: o, colorScheme: l }) {
3647
- m(this, "_model");
3648
- m(this, "_view");
3649
- m(this, "_controller");
3650
- const c = document.querySelector(e);
3651
- if (!c) throw new Error(`Element with selector "${e}" not found!`);
3982
+ e.preventDefault(), this._hitManager.dispatchWheel(e.offsetX, e.offsetY, e.deltaX, e.deltaY, e.deltaZ);
3983
+ }
3984
+ }
3985
+ class Dr {
3986
+ constructor(e, { chartId: t, candles: s, config: r, trade: n, userMarkers: o, colorScheme: l }) {
3987
+ g(this, "_model");
3988
+ g(this, "_view");
3989
+ g(this, "_controller");
3990
+ const h = document.querySelector(e);
3991
+ if (!h) throw new Error(`Element with selector "${e}" not found!`);
3652
3992
  if (!t || !/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(t))
3653
3993
  throw new Error(
3654
3994
  "chartId is required and must be a valid id (only letters, numbers or underscores. The first character must be a letter)"
3655
3995
  );
3656
- this._model = new ys({
3996
+ this._model = new bn({
3657
3997
  chartId: t,
3658
- candles: n,
3998
+ candles: s,
3659
3999
  config: r,
3660
- container: c,
3661
- trade: s,
4000
+ container: h,
4001
+ trade: n,
3662
4002
  userMarkers: o,
3663
4003
  colorScheme: l
3664
- }), this._view = new ar(c), this._controller = new gr(this._model, this._view), this._controller.init();
4004
+ }), this._view = new lr(h), this._controller = new Sr(this._model, this._view), this._controller.init();
3665
4005
  }
3666
4006
  updateConfig(e) {
3667
4007
  this._model.updateConfig(e);
@@ -3680,7 +4020,7 @@ class pr {
3680
4020
  }
3681
4021
  }
3682
4022
  export {
3683
- pr as CandlestickChart,
3684
- mr as createLineChart
4023
+ Dr as CandlestickChart,
4024
+ Er as createLineChart
3685
4025
  };
3686
4026
  //# sourceMappingURL=charts-core.js.map