@overdoser/react-toolkit 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,32 @@
1
1
  import { jsxs as et, jsx as x } from "react/jsx-runtime";
2
- import { useRef as U, useState as St, useCallback as X, useMemo as qt, useLayoutEffect as Qt, useEffect as te } from "react";
3
- import ee from "clsx";
4
- import { niceTicks as Ht } from "./scales.js";
5
- import { rsi as ne, sma as oe, ema as re, bollinger as ie } from "./trading/indicators.js";
6
- import { periodToSeconds as le } from "./trading/period.js";
7
- import mt from "./Chart.module.scss.js";
8
- import { Popover as se } from "../Popover/Popover.js";
9
- import { Button as ae } from "../Button/Button.js";
10
- import { Dropdown as ce } from "../Dropdown/Dropdown.js";
11
- const fe = 420, Tt = 64, vt = 28, he = 40, ue = 4, At = { rsi: 0.18, volume: 0.14 }, pe = 1, de = 40, kt = 0.1, me = 500, ge = [];
12
- function Ze({
2
+ import { useRef as U, useState as kt, useCallback as X, useMemo as Qt, useLayoutEffect as te, useEffect as ee } from "react";
3
+ import ne from "clsx";
4
+ import { niceTicks as Dt } from "./scales.js";
5
+ import { rsi as oe, sma as re, ema as ie, bollinger as le } from "./trading/indicators.js";
6
+ import { periodToSeconds as se } from "./trading/period.js";
7
+ import gt from "./Chart.module.scss.js";
8
+ import { Popover as ae } from "../Popover/Popover.js";
9
+ import { Button as ce } from "../Button/Button.js";
10
+ import { Dropdown as fe } from "../Dropdown/Dropdown.js";
11
+ const he = 420, vt = 64, wt = 28, ue = 40, pe = 4, Ct = { rsi: 0.18, volume: 0.14 }, de = 1, me = 40, Lt = 0.1, ge = 500, Me = [];
12
+ function Ge({
13
13
  datafeed: t,
14
14
  symbol: n,
15
15
  resolution: e,
16
16
  period: o,
17
17
  seriesType: r = "candle",
18
- indicators: l = ge,
18
+ indicators: l = Me,
19
19
  precision: i = 2,
20
- initialLookback: s = me,
21
- height: c = fe,
20
+ initialLookback: s = ge,
21
+ height: c = he,
22
22
  upColor: g = "var(--crk-color-success)",
23
- downColor: h = "var(--crk-color-danger)",
23
+ downColor: u = "var(--crk-color-danger)",
24
24
  lineColor: f = "var(--crk-chart-1)",
25
25
  timezone: d,
26
26
  defaultTimezone: M = "local",
27
27
  onTimezoneChange: k,
28
- showConfigPanel: C = !0,
29
- priceBadgeColorByDirection: L = !1,
28
+ showConfigPanel: L = !0,
29
+ priceBadgeColorByDirection: W = !1,
30
30
  priceBadgeShowTime: P = !1,
31
31
  priceBadgeTimeFormat: j,
32
32
  onCrosshair: N,
@@ -34,241 +34,242 @@ function Ze({
34
34
  className: _,
35
35
  style: J
36
36
  }) {
37
- const z = U(null), Z = U(null), I = U([]), y = U({ from: 0, to: 0 }), F = U(null), V = U(null), G = U(!1), K = U(null), ht = U(null), wt = U(1), ut = U({ width: 0, height: 0 }), pt = U(() => {
38
- }), yt = U(N), lt = U(Y);
39
- yt.current = N, lt.current = Y;
40
- const [st, Ot] = St(null), [Et, Ut] = St(M), dt = d ?? Et, _t = X(
37
+ const Z = U(null), G = U(null), I = U([]), y = U({ from: 0, to: 0 }), F = U(null), V = U(null), z = U(!1), K = U(0), ht = U(null), ut = U(null), yt = U(1), pt = U({ width: 0, height: 0 }), dt = U(() => {
38
+ }), bt = U(N), lt = U(Y);
39
+ bt.current = N, lt.current = Y;
40
+ const [st, Ut] = kt(null), [_t, xt] = kt(M), mt = d ?? _t, Ft = X(
41
41
  (p) => {
42
- d === void 0 && Ut(p), k?.(p);
42
+ d === void 0 && xt(p), k?.(p);
43
43
  },
44
44
  [d, k]
45
- ), bt = qt(
46
- () => ({ up: g, down: h, line: f }),
47
- [g, h, f]
48
- ), q = l, nt = q.some((p) => p.type === "rsi"), ot = q.some((p) => p.type === "volume"), xt = X(() => {
49
- const p = Z.current;
45
+ ), Rt = Qt(
46
+ () => ({ up: g, down: u, line: f }),
47
+ [g, u, f]
48
+ ), q = l, nt = q.some((p) => p.type === "rsi"), ot = q.some((p) => p.type === "volume"), Nt = X(() => {
49
+ const p = G.current;
50
50
  if (!p) return;
51
51
  const a = p.getContext("2d");
52
52
  if (!a) return;
53
- const { width: A, height: b } = ut.current;
54
- if (A === 0 || b === 0) return;
55
- const R = wt.current;
53
+ const { width: S, height: b } = pt.current;
54
+ if (S === 0 || b === 0) return;
55
+ const R = yt.current;
56
56
  a.save(), a.setTransform(1, 0, 0, 1, 0, 0), a.clearRect(0, 0, p.width, p.height), a.scale(R, R);
57
- const m = Re(z.current, bt), H = Dt(z.current), S = I.current;
58
- if (S.length === 0) {
59
- Se(a, A, b, m), a.restore();
57
+ const m = Se(Z.current, Rt), $ = It(Z.current), A = I.current;
58
+ if (A.length === 0) {
59
+ Ae(a, S, b, m), a.restore();
60
60
  return;
61
61
  }
62
- const u = gt(A, b, nt, ot), { from: T, to: w } = we(y.current, S.length);
63
- y.current = { from: T, to: w };
64
- const W = S.slice(Math.max(0, Math.floor(T)), Math.min(S.length, Math.ceil(w) + 1)), $ = (v) => {
65
- const it = w - T + 1, tt = u.plotWidth / it;
66
- return u.plotLeft + (v - T + 0.5) * tt;
67
- }, rt = u.plotWidth / (w - T + 1), Q = q.map((v) => ye(v, S)).filter((v) => v !== null).map((v) => ({ ...v, color: H(v.color) })), E = Bt(u.main, W, Q, T, w);
68
- Mt(a, u.plotLeft, u.plotRight, E, m), Ae(a, u, E, i, m), a.save(), a.beginPath(), a.rect(u.plotLeft, E.paneTop, u.plotWidth, E.paneHeight), a.clip();
69
- for (let v = 0; v < q.length; v++) {
70
- const it = q[v], tt = Q[v];
71
- tt && We(a, tt, it, S, T, w, $, E);
62
+ const h = Mt(S, b, nt, ot), { from: T, to: v } = ye(y.current, A.length);
63
+ y.current = { from: T, to: v };
64
+ const C = A.slice(Math.max(0, Math.floor(T)), Math.min(A.length, Math.ceil(v) + 1)), H = (w) => {
65
+ const it = v - T + 1, tt = h.plotWidth / it;
66
+ return h.plotLeft + (w - T + 0.5) * tt;
67
+ }, rt = h.plotWidth / (v - T + 1), Q = q.map((w) => be(w, A)).filter((w) => w !== null).map((w) => ({ ...w, color: $(w.color) })), E = Pt(h.main, C, Q, T, v);
68
+ Tt(a, h.plotLeft, h.plotRight, E, m), ke(a, h, E, i, m), a.save(), a.beginPath(), a.rect(h.plotLeft, E.paneTop, h.plotWidth, E.paneHeight), a.clip();
69
+ for (let w = 0; w < q.length; w++) {
70
+ const it = q[w], tt = Q[w];
71
+ tt && $e(a, tt, it, A, T, v, H, E);
72
72
  }
73
- if (r === "candle" ? ke(a, S, T, w, $, rt, E, { up: m.up, down: m.down }) : r === "bar" ? Ce(a, S, T, w, $, rt, E, { up: m.up, down: m.down }) : Le(a, S, T, w, $, E, m.line, r === "area"), a.restore(), u.volume) {
74
- const v = be(u.volume, S, T, w);
75
- Mt(a, u.plotLeft, u.plotRight, v, m, !0), Ct(a, u, u.volume, "Volume", m), a.save(), a.beginPath(), a.rect(u.plotLeft, v.paneTop, u.plotWidth, v.paneHeight), a.clip(), $e(a, S, T, w, $, rt, v, { up: m.up, down: m.down }), a.restore();
73
+ if (r === "candle" ? Ce(a, A, T, v, H, rt, E, { up: m.up, down: m.down }) : r === "bar" ? Le(a, A, T, v, H, rt, E, { up: m.up, down: m.down }) : We(a, A, T, v, H, E, m.line, r === "area"), a.restore(), h.volume) {
74
+ const w = Re(h.volume, A, T, v);
75
+ Tt(a, h.plotLeft, h.plotRight, w, m, !0), Wt(a, h, h.volume, "Volume", m), a.save(), a.beginPath(), a.rect(h.plotLeft, w.paneTop, h.plotWidth, w.paneHeight), a.clip(), He(a, A, T, v, H, rt, w, { up: m.up, down: m.down }), a.restore();
76
76
  }
77
- if (u.rsi) {
78
- const v = q.find((Jt) => Jt.type === "rsi"), it = v && v.type === "rsi" ? v.period ?? 14 : 14, tt = v && v.type === "rsi" ? v.overbought ?? 70 : 70, Rt = v && v.type === "rsi" ? v.oversold ?? 30 : 30, Gt = (v && v.type === "rsi" ? v.color : void 0) ?? "var(--crk-chart-5)", Kt = H(Gt), jt = ne(S, it), ct = {
79
- paneTop: u.rsi.top,
80
- paneBottom: u.rsi.bottom,
81
- paneHeight: u.rsi.height,
77
+ if (h.rsi) {
78
+ const w = q.find((qt) => qt.type === "rsi"), it = w && w.type === "rsi" ? w.period ?? 14 : 14, tt = w && w.type === "rsi" ? w.overbought ?? 70 : 70, At = w && w.type === "rsi" ? w.oversold ?? 30 : 30, Kt = (w && w.type === "rsi" ? w.color : void 0) ?? "var(--crk-chart-5)", jt = $(Kt), Jt = oe(A, it), ct = {
79
+ paneTop: h.rsi.top,
80
+ paneBottom: h.rsi.bottom,
81
+ paneHeight: h.rsi.height,
82
82
  priceMin: 0,
83
83
  priceMax: 100,
84
- ticks: [Rt, 50, tt]
84
+ ticks: [At, 50, tt]
85
85
  };
86
- Mt(a, u.plotLeft, u.plotRight, ct, m, !0), Ct(a, u, u.rsi, `RSI ${it}`, m), a.save(), a.beginPath(), a.rect(u.plotLeft, ct.paneTop, u.plotWidth, ct.paneHeight), a.clip(), ft(a, jt, T, w, $, ct, Kt), a.restore(), He(a, u, ct, tt, Rt, m);
86
+ Tt(a, h.plotLeft, h.plotRight, ct, m, !0), Wt(a, h, h.rsi, `RSI ${it}`, m), a.save(), a.beginPath(), a.rect(h.plotLeft, ct.paneTop, h.plotWidth, ct.paneHeight), a.clip(), ft(a, Jt, T, v, H, ct, jt), a.restore(), Be(a, h, ct, tt, At, m);
87
87
  }
88
- Be(a, u, S, T, w, e, m), F.current && De(
88
+ De(a, h, A, T, v, e, m), F.current && Pe(
89
89
  a,
90
- u,
90
+ h,
91
91
  F.current,
92
- S,
92
+ A,
93
93
  T,
94
- w,
95
- $,
94
+ v,
95
+ H,
96
96
  i,
97
97
  E,
98
- dt,
98
+ mt,
99
99
  m,
100
100
  e,
101
- L,
101
+ W,
102
102
  P,
103
103
  j
104
104
  ), a.restore();
105
- }, [r, q, nt, ot, i, bt, e, dt, L, P, j]);
106
- pt.current = xt;
105
+ }, [r, q, nt, ot, i, Rt, e, mt, W, P, j]);
106
+ dt.current = Nt;
107
107
  const O = X(() => {
108
- if (ht.current === null) {
108
+ if (ut.current === null) {
109
109
  if (typeof requestAnimationFrame > "u") {
110
- pt.current();
110
+ dt.current();
111
111
  return;
112
112
  }
113
- ht.current = requestAnimationFrame(() => {
114
- ht.current = null, pt.current();
113
+ ut.current = requestAnimationFrame(() => {
114
+ ut.current = null, dt.current();
115
115
  });
116
116
  }
117
117
  }, []);
118
- Qt(() => {
119
- const p = z.current;
118
+ te(() => {
119
+ const p = Z.current;
120
120
  if (!p) return;
121
121
  const a = () => {
122
122
  const b = p.getBoundingClientRect(), R = typeof window < "u" && window.devicePixelRatio || 1;
123
- wt.current = R, ut.current = { width: b.width, height: b.height };
124
- const m = Z.current;
123
+ yt.current = R, pt.current = { width: b.width, height: b.height };
124
+ const m = G.current;
125
125
  m && (m.width = Math.round(b.width * R), m.height = Math.round(b.height * R), m.style.width = `${b.width}px`, m.style.height = `${b.height}px`), O();
126
126
  };
127
127
  if (a(), typeof ResizeObserver > "u") return;
128
- const A = new ResizeObserver(a);
129
- return A.observe(p), () => A.disconnect();
130
- }, [O]), te(() => {
128
+ const S = new ResizeObserver(a);
129
+ return S.observe(p), () => S.disconnect();
130
+ }, [O]), ee(() => {
131
131
  let p = !1;
132
- const a = Math.floor(Date.now() / 1e3), A = $t(e), b = o === "MAX", R = o !== void 0 ? le(o) : A * s, m = o !== void 0 ? Math.max(10, Math.ceil(R / A)) : s, H = b ? 0 : a - R;
133
- I.current = [], y.current = { from: 0, to: 0 }, O(), t.getBars({ symbol: n, resolution: e, from: H, to: a, countBack: m }).then((u) => {
132
+ const a = Math.floor(Date.now() / 1e3), S = Bt(e), b = o === "MAX", R = o !== void 0 ? se(o) : S * s, m = o !== void 0 ? Math.max(10, Math.ceil(R / S)) : s, $ = b ? 0 : a - R;
133
+ I.current = [], y.current = { from: 0, to: 0 }, K.current += 1, z.current = !1, O(), t.getBars({ symbol: n, resolution: e, from: $, to: a, countBack: m }).then((h) => {
134
134
  if (p) return;
135
- const T = [...u].sort((W, $) => W.time - $.time);
135
+ const T = [...h].sort((C, H) => C.time - H.time);
136
136
  I.current = T;
137
- const w = T.length - 1;
137
+ const v = T.length - 1;
138
138
  if (o !== void 0)
139
- y.current = { from: 0, to: w };
139
+ y.current = { from: 0, to: v };
140
140
  else {
141
- const W = Math.min(T.length, Math.min(200, s));
141
+ const C = Math.min(T.length, Math.min(200, s));
142
142
  y.current = {
143
- from: Math.max(0, w - W + 1),
144
- to: w
143
+ from: Math.max(0, v - C + 1),
144
+ to: v
145
145
  };
146
146
  }
147
147
  lt.current?.(y.current, T), O();
148
148
  }).catch(() => {
149
149
  });
150
- const S = t.subscribeBars({
150
+ const A = t.subscribeBars({
151
151
  symbol: n,
152
152
  resolution: e,
153
- onTick: (u) => {
153
+ onTick: (h) => {
154
154
  if (p) return;
155
- const T = I.current, w = T[T.length - 1];
156
- if (w && w.time === u.time)
157
- T[T.length - 1] = u;
158
- else if (!w || u.time > w.time) {
159
- T.push(u);
160
- const W = y.current;
161
- W.to >= T.length - 2 && (y.current = { from: W.from + 1, to: W.to + 1 });
155
+ const T = I.current, v = T[T.length - 1];
156
+ if (v && v.time === h.time)
157
+ T[T.length - 1] = h;
158
+ else if (!v || h.time > v.time) {
159
+ T.push(h);
160
+ const C = y.current;
161
+ C.to >= T.length - 2 && (y.current = { from: C.from + 1, to: C.to + 1 });
162
162
  }
163
163
  O();
164
164
  }
165
165
  });
166
- return K.current = S, () => {
167
- p = !0, K.current !== null && (t.unsubscribeBars(K.current), K.current = null);
166
+ return ht.current = A, () => {
167
+ p = !0, ht.current !== null && (t.unsubscribeBars(ht.current), ht.current = null);
168
168
  };
169
169
  }, [t, n, e, o, s]);
170
170
  const at = X((p) => {
171
- Ot(p), yt.current?.(p);
172
- }, []), Ft = X((p) => {
171
+ Ut(p), bt.current?.(p);
172
+ }, []), Xt = X((p) => {
173
173
  p.currentTarget.setPointerCapture(p.pointerId);
174
174
  const a = y.current;
175
175
  V.current = { startX: p.clientX, from: a.from, to: a.to };
176
- }, []), Nt = X(
176
+ }, []), St = X(() => {
177
+ if (z.current) return;
178
+ const p = I.current;
179
+ if (p.length === 0) return;
180
+ z.current = !0;
181
+ const a = K.current, S = Bt(e), b = p[0].time, R = b - S * s, m = b - S;
182
+ t.getBars({ symbol: n, resolution: e, from: R, to: m, countBack: s }).then(($) => {
183
+ if (a !== K.current) return;
184
+ if ($.length === 0) {
185
+ z.current = !1;
186
+ return;
187
+ }
188
+ const h = [...$].sort((v, C) => v.time - C.time).filter((v) => v.time < b), T = y.current;
189
+ I.current = [...h, ...I.current], y.current = { from: T.from + h.length, to: T.to + h.length }, z.current = !1, O();
190
+ }).catch(() => {
191
+ a === K.current && (z.current = !1);
192
+ });
193
+ }, [t, n, e, s, O]), Yt = X(
177
194
  (p) => {
178
- const a = p.currentTarget.getBoundingClientRect(), A = p.clientX - a.left, b = p.clientY - a.top;
179
- if (F.current = { x: A, y: b }, V.current) {
180
- const { startX: H, from: S, to: u } = V.current, { width: T } = ut.current, w = Math.max(1, T - Tt), W = u - S + 1, $ = w / W, rt = -(p.clientX - H) / $;
181
- let Q = S + rt, E = u + rt;
182
- const v = I.current.length;
183
- Q < 0 && (Zt(), Q = 0, E = W - 1), E > v - 1 && (E = v - 1, Q = E - W + 1), y.current = { from: Q, to: E }, lt.current?.(y.current, I.current);
195
+ const a = p.currentTarget.getBoundingClientRect(), S = p.clientX - a.left, b = p.clientY - a.top;
196
+ if (F.current = { x: S, y: b }, V.current) {
197
+ const { startX: $, from: A, to: h } = V.current, { width: T } = pt.current, v = Math.max(1, T - vt), C = h - A + 1, H = v / C, rt = -(p.clientX - $) / H;
198
+ let Q = A + rt, E = h + rt;
199
+ const w = I.current.length;
200
+ Q < 0 && (St(), Q = 0, E = C - 1), E > w - 1 && (E = w - 1, Q = E - C + 1), y.current = { from: Q, to: E }, lt.current?.(y.current, I.current);
184
201
  }
185
- const R = gt(a.width, a.height, nt, ot), m = y.current;
186
- if (A >= R.plotLeft && A <= R.plotRight) {
187
- const H = m.to - m.from + 1, S = R.plotWidth / H, u = Math.round(m.from + (A - R.plotLeft) / S - 0.5), T = I.current, w = Math.max(0, Math.min(T.length - 1, u)), W = T[w] ?? null, $ = Pe(b, R, T, m.from, m.to);
188
- at({ barIndex: w, bar: W, priceAtCursor: $ });
202
+ const R = Mt(a.width, a.height, nt, ot), m = y.current;
203
+ if (S >= R.plotLeft && S <= R.plotRight) {
204
+ const $ = m.to - m.from + 1, A = R.plotWidth / $, h = Math.round(m.from + (S - R.plotLeft) / A - 0.5), T = I.current, v = Math.max(0, Math.min(T.length - 1, h)), C = T[v] ?? null, H = Ie(b, R, T, m.from, m.to);
205
+ at({ barIndex: v, bar: C, priceAtCursor: H });
189
206
  } else
190
207
  at(null);
191
208
  O();
192
209
  },
193
- [nt, ot, O, at]
194
- ), Xt = X((p) => {
210
+ [nt, ot, St, O, at]
211
+ ), Vt = X((p) => {
195
212
  p.currentTarget.releasePointerCapture(p.pointerId), V.current = null;
196
- }, []), Yt = X(() => {
213
+ }, []), zt = X(() => {
197
214
  F.current = null, V.current = null, at(null), O();
198
- }, [O, at]), Vt = X(
215
+ }, [O, at]), Zt = X(
199
216
  (p) => {
200
217
  p.preventDefault();
201
- const a = p.currentTarget.getBoundingClientRect(), A = p.clientX - a.left, b = gt(a.width, a.height, nt, ot), R = y.current, m = I.current;
218
+ const a = p.currentTarget.getBoundingClientRect(), S = p.clientX - a.left, b = Mt(a.width, a.height, nt, ot), R = y.current, m = I.current;
202
219
  if (m.length === 0) return;
203
- const H = R.to - R.from + 1, S = p.deltaY > 0 ? 1 + kt : 1 / (1 + kt), u = Math.max(
204
- b.plotWidth / de,
205
- Math.min(m.length, b.plotWidth / pe, H * S)
206
- ), T = R.from + (A - b.plotLeft) / (b.plotWidth / H), w = (T - R.from) / H;
207
- let W = T - w * u, $ = W + u - 1;
208
- W < 0 && (W = 0, $ = u - 1), $ > m.length - 1 && ($ = m.length - 1, W = $ - u + 1), y.current = { from: W, to: $ }, lt.current?.(y.current, m), O();
220
+ const $ = R.to - R.from + 1, A = p.deltaY > 0 ? 1 + Lt : 1 / (1 + Lt), h = Math.max(
221
+ b.plotWidth / me,
222
+ Math.min(m.length, b.plotWidth / de, $ * A)
223
+ ), T = R.from + (S - b.plotLeft) / (b.plotWidth / $), v = (T - R.from) / $;
224
+ let C = T - v * h, H = C + h - 1;
225
+ C < 0 && (C = 0, H = h - 1), H > m.length - 1 && (H = m.length - 1, C = H - h + 1), y.current = { from: C, to: H }, lt.current?.(y.current, m), O();
209
226
  },
210
227
  [nt, ot, O]
211
- ), zt = X(
228
+ ), Gt = X(
212
229
  (p) => {
213
- const a = y.current, A = a.to - a.from + 1, b = I.current;
230
+ const a = y.current, S = a.to - a.from + 1, b = I.current;
214
231
  if (b.length === 0) return;
215
232
  let R = 0;
216
- if (p.key === "ArrowLeft") R = -Math.max(1, Math.floor(A * 0.1));
217
- else if (p.key === "ArrowRight") R = Math.max(1, Math.floor(A * 0.1));
233
+ if (p.key === "ArrowLeft") R = -Math.max(1, Math.floor(S * 0.1));
234
+ else if (p.key === "ArrowRight") R = Math.max(1, Math.floor(S * 0.1));
218
235
  else return;
219
236
  p.preventDefault();
220
- let m = a.from + R, H = a.to + R;
221
- m < 0 && (m = 0, H = A - 1), H > b.length - 1 && (H = b.length - 1, m = H - A + 1), y.current = { from: m, to: H }, lt.current?.(y.current, b), O();
237
+ let m = a.from + R, $ = a.to + R;
238
+ m < 0 && (m = 0, $ = S - 1), $ > b.length - 1 && ($ = b.length - 1, m = $ - S + 1), y.current = { from: m, to: $ }, lt.current?.(y.current, b), O();
222
239
  },
223
240
  [O]
224
- ), Zt = X(() => {
225
- if (G.current) return;
226
- const p = I.current;
227
- if (p.length === 0) return;
228
- G.current = !0;
229
- const a = $t(e), A = p[0].time, b = A - a * s, R = A - a;
230
- t.getBars({ symbol: n, resolution: e, from: b, to: R, countBack: s }).then((m) => {
231
- if (m.length === 0) {
232
- G.current = !1;
233
- return;
234
- }
235
- const S = [...m].sort((T, w) => T.time - w.time).filter((T) => T.time < A), u = y.current;
236
- I.current = [...S, ...p], y.current = { from: u.from + S.length, to: u.to + S.length }, G.current = !1, O();
237
- }).catch(() => {
238
- G.current = !1;
239
- });
240
- }, [t, n, e, s, O]);
241
+ );
241
242
  return /* @__PURE__ */ et(
242
243
  "div",
243
244
  {
244
- ref: z,
245
- className: ee(mt.root, _),
245
+ ref: Z,
246
+ className: ne(gt.root, _),
246
247
  style: { ...J, height: c, position: "relative" },
247
248
  tabIndex: 0,
248
249
  role: "figure",
249
250
  "aria-label": `${n} ${e} chart`,
250
- onKeyDown: zt,
251
+ onKeyDown: Gt,
251
252
  children: [
252
253
  /* @__PURE__ */ x(
253
254
  "canvas",
254
255
  {
255
- ref: Z,
256
- className: mt.svg,
257
- onPointerDown: Ft,
258
- onPointerMove: Nt,
259
- onPointerUp: Xt,
260
- onPointerLeave: Yt,
261
- onWheel: Vt,
256
+ ref: G,
257
+ className: gt.svg,
258
+ onPointerDown: Xt,
259
+ onPointerMove: Yt,
260
+ onPointerUp: Vt,
261
+ onPointerLeave: zt,
262
+ onWheel: Zt,
262
263
  style: { cursor: V.current ? "grabbing" : "crosshair", touchAction: "none" }
263
264
  }
264
265
  ),
265
266
  /* @__PURE__ */ et(
266
267
  "div",
267
268
  {
268
- className: mt.tradingHeader,
269
+ className: gt.tradingHeader,
269
270
  style: {
270
271
  position: "absolute",
271
- top: ue,
272
+ top: pe,
272
273
  left: 8,
273
274
  right: 8,
274
275
  pointerEvents: "none",
@@ -293,26 +294,26 @@ function Ze({
293
294
  st.bar.close.toFixed(i)
294
295
  ] })
295
296
  ] }),
296
- C && /* @__PURE__ */ x("div", { style: { pointerEvents: "auto" }, children: /* @__PURE__ */ x(
297
- se,
297
+ L && /* @__PURE__ */ x("div", { style: { pointerEvents: "auto" }, children: /* @__PURE__ */ x(
298
+ ae,
298
299
  {
299
300
  position: "bottom",
300
301
  asChild: !0,
301
302
  trigger: /* @__PURE__ */ x(
302
- ae,
303
+ ce,
303
304
  {
304
305
  variant: "ghost",
305
306
  size: "sm",
306
307
  iconOnly: !0,
307
308
  "aria-label": "Chart settings",
308
- children: /* @__PURE__ */ x(ve, {})
309
+ children: /* @__PURE__ */ x(we, {})
309
310
  }
310
311
  ),
311
312
  content: /* @__PURE__ */ x(
312
- Te,
313
+ ve,
313
314
  {
314
- timezone: dt,
315
- onTimezoneChange: _t
315
+ timezone: mt,
316
+ onTimezoneChange: Ft
316
317
  }
317
318
  )
318
319
  }
@@ -324,7 +325,7 @@ function Ze({
324
325
  }
325
326
  );
326
327
  }
327
- const Me = [
328
+ const Te = [
328
329
  { value: "local", label: "Local time" },
329
330
  { value: "utc", label: "UTC" },
330
331
  { value: "America/New_York", label: "America / New York" },
@@ -334,7 +335,7 @@ const Me = [
334
335
  { value: "Asia/Tokyo", label: "Asia / Tokyo" },
335
336
  { value: "Asia/Singapore", label: "Asia / Singapore" }
336
337
  ];
337
- function Te({
338
+ function ve({
338
339
  timezone: t,
339
340
  onTimezoneChange: n
340
341
  }) {
@@ -353,9 +354,9 @@ function Te({
353
354
  /* @__PURE__ */ et("label", { style: { display: "flex", flexDirection: "column", gap: 4, padding: "4px" }, children: [
354
355
  /* @__PURE__ */ x("span", { style: { fontSize: "var(--crk-font-size-xs)", color: "var(--crk-color-text-muted)" }, children: "Timezone" }),
355
356
  /* @__PURE__ */ x(
356
- ce,
357
+ fe,
357
358
  {
358
- options: Me.map((e) => ({ value: e.value, label: e.label })),
359
+ options: Te.map((e) => ({ value: e.value, label: e.label })),
359
360
  value: t,
360
361
  onChange: (e) => n(e)
361
362
  }
@@ -363,7 +364,7 @@ function Te({
363
364
  ] })
364
365
  ] });
365
366
  }
366
- function ve() {
367
+ function we() {
367
368
  return /* @__PURE__ */ et(
368
369
  "svg",
369
370
  {
@@ -381,15 +382,15 @@ function ve() {
381
382
  }
382
383
  );
383
384
  }
384
- function gt(t, n, e, o) {
385
- const l = Math.max(0, t - Tt), i = he, s = Math.max(i, n - vt), c = Math.max(0, l - 0), g = Math.max(0, s - i);
386
- let h = g, f = i;
385
+ function Mt(t, n, e, o) {
386
+ const l = Math.max(0, t - vt), i = ue, s = Math.max(i, n - wt), c = Math.max(0, l - 0), g = Math.max(0, s - i);
387
+ let u = g, f = i;
387
388
  const d = { top: i, bottom: s, height: g };
388
389
  let M = null, k = null;
389
- const C = e ? At.rsi : 0, L = o ? At.volume : 0;
390
- return h = g * (1 - C - L), d.top = f, d.height = h, d.bottom = d.top + h, f = d.bottom, e && (M = { top: f, height: g * C, bottom: f + g * C }, f = M.bottom), o && (k = { top: f, height: g * L, bottom: f + g * L }), { width: t, height: n, plotLeft: 0, plotRight: l, plotTop: i, plotBottom: s, plotWidth: c, plotHeight: g, main: d, rsi: M, volume: k };
390
+ const L = e ? Ct.rsi : 0, W = o ? Ct.volume : 0;
391
+ return u = g * (1 - L - W), d.top = f, d.height = u, d.bottom = d.top + u, f = d.bottom, e && (M = { top: f, height: g * L, bottom: f + g * L }, f = M.bottom), o && (k = { top: f, height: g * W, bottom: f + g * W }), { width: t, height: n, plotLeft: 0, plotRight: l, plotTop: i, plotBottom: s, plotWidth: c, plotHeight: g, main: d, rsi: M, volume: k };
391
392
  }
392
- function we(t, n) {
393
+ function ye(t, n) {
393
394
  if (n === 0) return { from: 0, to: 0 };
394
395
  let { from: e, to: o } = t;
395
396
  if (o >= n) {
@@ -398,13 +399,13 @@ function we(t, n) {
398
399
  }
399
400
  return e < 0 && (e = 0), o < e && (o = e), { from: e, to: o };
400
401
  }
401
- function ye(t, n) {
402
+ function be(t, n) {
402
403
  if (t.type === "sma")
403
- return { kind: "line", values: oe(n, t.period), color: t.color ?? "var(--crk-chart-2)" };
404
+ return { kind: "line", values: re(n, t.period), color: t.color ?? "var(--crk-chart-2)" };
404
405
  if (t.type === "ema")
405
- return { kind: "line", values: re(n, t.period), color: t.color ?? "var(--crk-chart-3)" };
406
+ return { kind: "line", values: ie(n, t.period), color: t.color ?? "var(--crk-chart-3)" };
406
407
  if (t.type === "bollinger") {
407
- const e = ie(n, t.period, t.stdDev ?? 2);
408
+ const e = le(n, t.period, t.stdDev ?? 2);
408
409
  return {
409
410
  kind: "bollinger",
410
411
  middle: e.middle,
@@ -416,39 +417,39 @@ function ye(t, n) {
416
417
  }
417
418
  return null;
418
419
  }
419
- function Bt(t, n, e, o, r) {
420
+ function Pt(t, n, e, o, r) {
420
421
  let l = 1 / 0, i = -1 / 0;
421
422
  for (const f of n)
422
423
  f.low < l && (l = f.low), f.high > i && (i = f.high);
423
424
  for (const f of e) {
424
425
  const d = f.kind === "line" ? [f.values] : [f.upper, f.lower];
425
426
  for (const M of d) {
426
- const k = Math.max(0, Math.floor(o)), C = Math.min(M.length - 1, Math.ceil(r));
427
- for (let L = k; L <= C; L++) {
428
- const P = M[L];
427
+ const k = Math.max(0, Math.floor(o)), L = Math.min(M.length - 1, Math.ceil(r));
428
+ for (let W = k; W <= L; W++) {
429
+ const P = M[W];
429
430
  P != null && (P < l && (l = P), P > i && (i = P));
430
431
  }
431
432
  }
432
433
  }
433
434
  (!isFinite(l) || !isFinite(i)) && (l = 0, i = 1);
434
- const s = (i - l) * 0.08 || 1, c = Ht(l - s, i + s, 5), g = Math.min(c[0], l), h = Math.max(c[c.length - 1], i);
435
- return { paneTop: t.top, paneBottom: t.bottom, paneHeight: t.height, priceMin: g, priceMax: h, ticks: c };
435
+ const s = (i - l) * 0.08 || 1, c = Dt(l - s, i + s, 5), g = Math.min(c[0], l), u = Math.max(c[c.length - 1], i);
436
+ return { paneTop: t.top, paneBottom: t.bottom, paneHeight: t.height, priceMin: g, priceMax: u, ticks: c };
436
437
  }
437
- function be(t, n, e, o) {
438
+ function Re(t, n, e, o) {
438
439
  let r = 0;
439
440
  const l = Math.max(0, Math.floor(e)), i = Math.min(n.length - 1, Math.ceil(o));
440
441
  for (let g = l; g <= i; g++) {
441
- const h = n[g].volume ?? 0;
442
- h > r && (r = h);
442
+ const u = n[g].volume ?? 0;
443
+ u > r && (r = u);
443
444
  }
444
- const s = Ht(0, r || 1, 3), c = Math.max(s[s.length - 1], r);
445
+ const s = Dt(0, r || 1, 3), c = Math.max(s[s.length - 1], r);
445
446
  return { paneTop: t.top, paneBottom: t.bottom, paneHeight: t.height, priceMin: 0, priceMax: c, ticks: s };
446
447
  }
447
448
  function B(t, n) {
448
449
  const e = (t - n.priceMin) / (n.priceMax - n.priceMin || 1);
449
450
  return n.paneBottom - e * n.paneHeight;
450
451
  }
451
- function Dt(t) {
452
+ function It(t) {
452
453
  if (!t || typeof getComputedStyle > "u") return (r) => r;
453
454
  const n = getComputedStyle(t), e = /* @__PURE__ */ new Map(), o = (r) => {
454
455
  if (!r || !r.includes("var(")) return r;
@@ -465,8 +466,8 @@ function Dt(t) {
465
466
  };
466
467
  return o;
467
468
  }
468
- function Re(t, n) {
469
- const e = Dt(t);
469
+ function Se(t, n) {
470
+ const e = It(t);
470
471
  return {
471
472
  up: e(n.up),
472
473
  down: e(n.down),
@@ -478,10 +479,10 @@ function Re(t, n) {
478
479
  bg: e("var(--crk-color-bg)") || "#ffffff"
479
480
  };
480
481
  }
481
- function Se(t, n, e, o) {
482
+ function Ae(t, n, e, o) {
482
483
  t.fillStyle = o.textMuted, t.font = "13px system-ui, sans-serif", t.textAlign = "center", t.textBaseline = "middle", t.fillText("Loading…", n / 2, e / 2);
483
484
  }
484
- function Mt(t, n, e, o, r, l = !1) {
485
+ function Tt(t, n, e, o, r, l = !1) {
485
486
  t.strokeStyle = r.grid, t.lineWidth = 1, t.beginPath();
486
487
  for (const i of o.ticks) {
487
488
  const s = Math.round(B(i, o)) + 0.5;
@@ -489,54 +490,54 @@ function Mt(t, n, e, o, r, l = !1) {
489
490
  }
490
491
  t.stroke();
491
492
  }
492
- function Ae(t, n, e, o, r) {
493
+ function ke(t, n, e, o, r) {
493
494
  t.fillStyle = r.axis, t.font = "11px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "middle";
494
495
  for (const l of e.ticks) {
495
496
  const i = B(l, e);
496
497
  t.fillText(l.toFixed(o), n.plotRight + 6, i);
497
498
  }
498
499
  }
499
- function ke(t, n, e, o, r, l, i, s) {
500
- const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), h = Math.max(1, l * 0.7);
500
+ function Ce(t, n, e, o, r, l, i, s) {
501
+ const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), u = Math.max(1, l * 0.7);
501
502
  for (let f = c; f <= g; f++) {
502
- const d = n[f], M = r(f), k = B(d.open, i), C = B(d.close, i), L = B(d.high, i), P = B(d.low, i), N = d.close >= d.open ? s.up : s.down;
503
+ const d = n[f], M = r(f), k = B(d.open, i), L = B(d.close, i), W = B(d.high, i), P = B(d.low, i), N = d.close >= d.open ? s.up : s.down;
503
504
  t.strokeStyle = N, t.fillStyle = N, t.beginPath();
504
505
  const Y = Math.round(M) + 0.5;
505
- t.moveTo(Y, L), t.lineTo(Y, P), t.stroke();
506
- const _ = Math.min(k, C), J = Math.max(1, Math.abs(C - k));
507
- t.fillRect(Math.round(M - h / 2), Math.round(_), Math.round(h), Math.round(J));
506
+ t.moveTo(Y, W), t.lineTo(Y, P), t.stroke();
507
+ const _ = Math.min(k, L), J = Math.max(1, Math.abs(L - k));
508
+ t.fillRect(Math.round(M - u / 2), Math.round(_), Math.round(u), Math.round(J));
508
509
  }
509
510
  }
510
- function Ce(t, n, e, o, r, l, i, s) {
511
- const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), h = Math.max(2, Math.min(l * 0.4, 8));
511
+ function Le(t, n, e, o, r, l, i, s) {
512
+ const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), u = Math.max(2, Math.min(l * 0.4, 8));
512
513
  t.lineWidth = Math.max(1, Math.min(2, l * 0.18)), t.lineCap = "butt";
513
514
  for (let f = c; f <= g; f++) {
514
- const d = n[f], M = Math.round(r(f)) + 0.5, k = B(d.high, i), C = B(d.low, i), L = B(d.open, i), P = B(d.close, i), j = d.close >= d.open;
515
- t.strokeStyle = j ? s.up : s.down, t.beginPath(), t.moveTo(M, k), t.lineTo(M, C), t.moveTo(M - h, L), t.lineTo(M, L), t.moveTo(M, P), t.lineTo(M + h, P), t.stroke();
515
+ const d = n[f], M = Math.round(r(f)) + 0.5, k = B(d.high, i), L = B(d.low, i), W = B(d.open, i), P = B(d.close, i), j = d.close >= d.open;
516
+ t.strokeStyle = j ? s.up : s.down, t.beginPath(), t.moveTo(M, k), t.lineTo(M, L), t.moveTo(M - u, W), t.lineTo(M, W), t.moveTo(M, P), t.lineTo(M + u, P), t.stroke();
516
517
  }
517
518
  }
518
- function Le(t, n, e, o, r, l, i, s) {
519
+ function We(t, n, e, o, r, l, i, s) {
519
520
  const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o));
520
521
  if (!(g <= c)) {
521
522
  t.strokeStyle = i, t.lineWidth = 1.5, t.beginPath(), t.moveTo(r(c), B(n[c].close, l));
522
- for (let h = c + 1; h <= g; h++)
523
- t.lineTo(r(h), B(n[h].close, l));
523
+ for (let u = c + 1; u <= g; u++)
524
+ t.lineTo(r(u), B(n[u].close, l));
524
525
  t.stroke(), s && (t.globalAlpha = 0.18, t.fillStyle = i, t.lineTo(r(g), l.paneBottom), t.lineTo(r(c), l.paneBottom), t.closePath(), t.fill(), t.globalAlpha = 1);
525
526
  }
526
527
  }
527
- function We(t, n, e, o, r, l, i, s) {
528
+ function $e(t, n, e, o, r, l, i, s) {
528
529
  if (n.kind === "line") {
529
530
  ft(t, n.values, r, l, i, s, n.color);
530
531
  return;
531
532
  }
532
533
  const c = Math.max(0, Math.floor(r)), g = Math.min(o.length - 1, Math.ceil(l));
533
534
  t.globalAlpha = n.fillOpacity, t.fillStyle = n.color, t.beginPath();
534
- let h = !1;
535
+ let u = !1;
535
536
  for (let f = c; f <= g; f++) {
536
537
  const d = n.upper[f];
537
538
  if (d == null) continue;
538
539
  const M = i(f), k = B(d, s);
539
- h ? t.lineTo(M, k) : (t.moveTo(M, k), h = !0);
540
+ u ? t.lineTo(M, k) : (t.moveTo(M, k), u = !0);
540
541
  }
541
542
  for (let f = g; f >= c; f--) {
542
543
  const d = n.lower[f];
@@ -548,30 +549,30 @@ function ft(t, n, e, o, r, l, i) {
548
549
  t.strokeStyle = i, t.lineWidth = 1.25, t.beginPath();
549
550
  let s = !1;
550
551
  const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o));
551
- for (let h = c; h <= g; h++) {
552
- const f = n[h];
552
+ for (let u = c; u <= g; u++) {
553
+ const f = n[u];
553
554
  if (f == null) {
554
555
  s = !1;
555
556
  continue;
556
557
  }
557
- const d = r(h), M = B(f, l);
558
+ const d = r(u), M = B(f, l);
558
559
  s ? t.lineTo(d, M) : (t.moveTo(d, M), s = !0);
559
560
  }
560
561
  t.stroke();
561
562
  }
562
- function $e(t, n, e, o, r, l, i, s) {
563
- const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), h = Math.max(1, l * 0.7);
563
+ function He(t, n, e, o, r, l, i, s) {
564
+ const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), u = Math.max(1, l * 0.7);
564
565
  for (let f = c; f <= g; f++) {
565
566
  const d = n[f], M = d.volume ?? 0;
566
567
  if (M === 0) continue;
567
568
  const k = d.close >= d.open;
568
569
  t.fillStyle = k ? s.up : s.down, t.globalAlpha = 0.55;
569
- const C = B(M, i), L = i.paneBottom - C;
570
- t.fillRect(Math.round(r(f) - h / 2), Math.round(C), Math.round(h), Math.round(L));
570
+ const L = B(M, i), W = i.paneBottom - L;
571
+ t.fillRect(Math.round(r(f) - u / 2), Math.round(L), Math.round(u), Math.round(W));
571
572
  }
572
573
  t.globalAlpha = 1;
573
574
  }
574
- function He(t, n, e, o, r, l) {
575
+ function Be(t, n, e, o, r, l) {
575
576
  t.strokeStyle = l.grid, t.setLineDash([3, 3]), t.beginPath();
576
577
  for (const i of [o, r]) {
577
578
  const s = Math.round(B(i, e)) + 0.5;
@@ -579,64 +580,64 @@ function He(t, n, e, o, r, l) {
579
580
  }
580
581
  t.stroke(), t.setLineDash([]), t.fillStyle = l.axis, t.font = "10px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "middle", t.fillText(String(o), n.plotRight + 6, B(o, e)), t.fillText(String(r), n.plotRight + 6, B(r, e));
581
582
  }
582
- function Ct(t, n, e, o, r) {
583
+ function Wt(t, n, e, o, r) {
583
584
  t.fillStyle = r.textMuted, t.font = "11px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "top", t.fillText(o, n.plotLeft + 6, e.top + 4);
584
585
  }
585
- function Be(t, n, e, o, r, l, i) {
586
+ function De(t, n, e, o, r, l, i) {
586
587
  const s = r - o + 1, c = n.plotWidth / s, g = Math.max(1, Math.round(80 / c));
587
588
  t.fillStyle = i.axis, t.font = "11px system-ui, sans-serif", t.textAlign = "center", t.textBaseline = "middle";
588
- const h = Math.max(0, Math.floor(o)), f = Math.min(e.length - 1, Math.ceil(r)), d = n.plotBottom + vt / 2;
589
- for (let M = h; M <= f; M += g) {
590
- const k = e[M], C = n.plotLeft + (M - o + 0.5) * c;
591
- t.fillText(Ie(k.time, l), C, d);
589
+ const u = Math.max(0, Math.floor(o)), f = Math.min(e.length - 1, Math.ceil(r)), d = n.plotBottom + wt / 2;
590
+ for (let M = u; M <= f; M += g) {
591
+ const k = e[M], L = n.plotLeft + (M - o + 0.5) * c;
592
+ t.fillText(Oe(k.time, l), L, d);
592
593
  }
593
594
  }
594
- function De(t, n, e, o, r, l, i, s, c, g, h, f, d, M, k) {
595
+ function Pe(t, n, e, o, r, l, i, s, c, g, u, f, d, M, k) {
595
596
  if (e.x < n.plotLeft || e.x > n.plotRight) return;
596
- const C = l - r + 1, L = n.plotWidth / C, P = r + (e.x - n.plotLeft) / L - 0.5, j = Math.round(P), N = Math.max(0, Math.min(o.length - 1, j)), Y = i(N);
597
- if (t.save(), t.strokeStyle = h.textMuted, t.setLineDash([3, 3]), t.lineWidth = 1, t.beginPath(), t.moveTo(Y + 0.5, n.plotTop), t.lineTo(Y + 0.5, n.plotBottom), t.moveTo(n.plotLeft, e.y + 0.5), t.lineTo(n.plotRight, e.y + 0.5), t.stroke(), t.setLineDash([]), e.y >= c.paneTop && e.y <= c.paneBottom) {
597
+ const L = l - r + 1, W = n.plotWidth / L, P = r + (e.x - n.plotLeft) / W - 0.5, j = Math.round(P), N = Math.max(0, Math.min(o.length - 1, j)), Y = i(N);
598
+ if (t.save(), t.strokeStyle = u.textMuted, t.setLineDash([3, 3]), t.lineWidth = 1, t.beginPath(), t.moveTo(Y + 0.5, n.plotTop), t.lineTo(Y + 0.5, n.plotBottom), t.moveTo(n.plotLeft, e.y + 0.5), t.lineTo(n.plotRight, e.y + 0.5), t.stroke(), t.setLineDash([]), e.y >= c.paneTop && e.y <= c.paneBottom) {
598
599
  const _ = c.priceMax - (e.y - c.paneTop) / c.paneHeight * (c.priceMax - c.priceMin);
599
- t.fillStyle = h.text, t.fillRect(n.plotRight, e.y - 9, Tt, 18), t.fillStyle = h.bg, t.font = "11px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "middle", t.fillText(_.toFixed(s), n.plotRight + 6, e.y);
600
+ t.fillStyle = u.text, t.fillRect(n.plotRight, e.y - 9, vt, 18), t.fillStyle = u.bg, t.font = "11px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "middle", t.fillText(_.toFixed(s), n.plotRight + 6, e.y);
600
601
  }
601
602
  if (o[N]) {
602
- const _ = It(o[N].time, g);
603
+ const _ = Et(o[N].time, g);
603
604
  t.font = "11px system-ui, sans-serif", t.textBaseline = "middle";
604
- const Z = t.measureText(_).width + 8 * 2, I = vt, y = Math.max(
605
+ const G = t.measureText(_).width + 8 * 2, I = wt, y = Math.max(
605
606
  n.plotLeft,
606
- Math.min(n.plotRight - Z, Y - Z / 2)
607
+ Math.min(n.plotRight - G, Y - G / 2)
607
608
  ), F = n.plotBottom;
608
- t.fillStyle = h.text, t.fillRect(y, F, Z, I), t.fillStyle = h.bg, t.textAlign = "center", t.fillText(_, y + Z / 2, F + I / 2);
609
+ t.fillStyle = u.text, t.fillRect(y, F, G, I), t.fillStyle = u.bg, t.textAlign = "center", t.fillText(_, y + G / 2, F + I / 2);
609
610
  }
610
611
  if (o[N]) {
611
612
  const _ = o[N], J = _.close.toFixed(s);
612
- let z = J;
613
+ let Z = J;
613
614
  if (M) {
614
- const K = (k ?? Pt)(_.time, f, g);
615
- K && (z = `${J} · ${K}`);
615
+ const K = (k ?? Ot)(_.time, f, g);
616
+ K && (Z = `${J} · ${K}`);
616
617
  }
617
618
  t.font = "11px system-ui, sans-serif", t.textBaseline = "middle";
618
- const y = t.measureText(z).width + 8 * 2, F = 18, V = Math.max(
619
+ const y = t.measureText(Z).width + 8 * 2, F = 18, V = Math.max(
619
620
  n.plotLeft,
620
621
  Math.min(n.plotRight - y, Y - y / 2)
621
- ), G = Math.max(0, n.plotTop - F - 2);
622
+ ), z = Math.max(0, n.plotTop - F - 2);
622
623
  if (d) {
623
624
  const K = _.close >= _.open;
624
- t.fillStyle = K ? h.up : h.down, t.fillRect(V, G, y, F), t.fillStyle = "#ffffff";
625
+ t.fillStyle = K ? u.up : u.down, t.fillRect(V, z, y, F), t.fillStyle = "#ffffff";
625
626
  } else
626
- t.fillStyle = h.text, t.fillRect(V, G, y, F), t.fillStyle = h.bg;
627
- t.textAlign = "center", t.fillText(z, V + y / 2, G + F / 2);
627
+ t.fillStyle = u.text, t.fillRect(V, z, y, F), t.fillStyle = u.bg;
628
+ t.textAlign = "center", t.fillText(Z, V + y / 2, z + F / 2);
628
629
  }
629
630
  t.restore();
630
631
  }
631
- function Pe(t, n, e, o, r, l, i) {
632
- const s = e.slice(Math.max(0, Math.floor(o)), Math.min(e.length, Math.ceil(r) + 1)), c = Bt(n.main, s, [], o, r);
632
+ function Ie(t, n, e, o, r, l, i) {
633
+ const s = e.slice(Math.max(0, Math.floor(o)), Math.min(e.length, Math.ceil(r) + 1)), c = Pt(n.main, s, [], o, r);
633
634
  return t < c.paneTop || t > c.paneBottom ? null : c.priceMax - (t - c.paneTop) / c.paneHeight * (c.priceMax - c.priceMin);
634
635
  }
635
- function Ie(t, n) {
636
+ function Oe(t, n) {
636
637
  const e = new Date(t * 1e3);
637
638
  return n === "D" || n === "W" || n === "M" ? `${e.getUTCFullYear()}-${D(e.getUTCMonth() + 1)}-${D(e.getUTCDate())}` : `${D(e.getUTCHours())}:${D(e.getUTCMinutes())}`;
638
639
  }
639
- const Lt = [
640
+ const $t = [
640
641
  "Jan",
641
642
  "Feb",
642
643
  "Mar",
@@ -649,14 +650,14 @@ const Lt = [
649
650
  "Oct",
650
651
  "Nov",
651
652
  "Dec"
652
- ], Wt = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
653
- function Pt(t, n, e) {
653
+ ], Ht = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
654
+ function Ot(t, n, e) {
654
655
  const o = new Date(t * 1e3), r = n === "D" || n === "W" || n === "M";
655
- let l, i, s, c, g, h;
656
+ let l, i, s, c, g, u;
656
657
  if (e === "local")
657
- l = o.getDate(), i = o.getMonth(), s = o.getFullYear(), c = o.getHours(), g = o.getMinutes(), h = o.getDay();
658
+ l = o.getDate(), i = o.getMonth(), s = o.getFullYear(), c = o.getHours(), g = o.getMinutes(), u = o.getDay();
658
659
  else if (e === "utc")
659
- l = o.getUTCDate(), i = o.getUTCMonth(), s = o.getUTCFullYear(), c = o.getUTCHours(), g = o.getUTCMinutes(), h = o.getUTCDay();
660
+ l = o.getUTCDate(), i = o.getUTCMonth(), s = o.getUTCFullYear(), c = o.getUTCHours(), g = o.getUTCMinutes(), u = o.getUTCDay();
660
661
  else
661
662
  try {
662
663
  const d = new Intl.DateTimeFormat("en-US", {
@@ -669,19 +670,19 @@ function Pt(t, n, e) {
669
670
  weekday: "short",
670
671
  hour12: !1,
671
672
  hourCycle: "h23"
672
- }).formatToParts(o), M = (L) => d.find((P) => P.type === L)?.value ?? "";
673
+ }).formatToParts(o), M = (W) => d.find((P) => P.type === W)?.value ?? "";
673
674
  l = Number(M("day")), i = Number(M("month")) - 1, s = Number(M("year")), c = Number(M("hour")), g = Number(M("minute"));
674
- const k = M("weekday"), C = Wt.indexOf(k);
675
- h = C >= 0 ? C : 0;
675
+ const k = M("weekday"), L = Ht.indexOf(k);
676
+ u = L >= 0 ? L : 0;
676
677
  } catch {
677
- return Pt(t, n, "utc");
678
+ return Ot(t, n, "utc");
678
679
  }
679
- return r ? `${l} ${Lt[i]} ${s}` : `${Wt[h]} ${l} ${Lt[i]} ${D(c)}:${D(g)}`;
680
+ return r ? `${l} ${$t[i]} ${s}` : `${Ht[u]} ${l} ${$t[i]} ${D(c)}:${D(g)}`;
680
681
  }
681
- function It(t, n) {
682
+ function Et(t, n) {
682
683
  const e = new Date(t * 1e3);
683
684
  if (n === "local")
684
- return `${e.getFullYear()}-${D(e.getMonth() + 1)}-${D(e.getDate())} ${D(e.getHours())}:${D(e.getMinutes())}:${D(e.getSeconds())} ${Oe(e)}`;
685
+ return `${e.getFullYear()}-${D(e.getMonth() + 1)}-${D(e.getDate())} ${D(e.getHours())}:${D(e.getMinutes())}:${D(e.getSeconds())} ${Ee(e)}`;
685
686
  if (n === "utc")
686
687
  return `${e.getUTCFullYear()}-${D(e.getUTCMonth() + 1)}-${D(e.getUTCDate())} ${D(e.getUTCHours())}:${D(e.getUTCMinutes())}:${D(e.getUTCSeconds())} UTC`;
687
688
  try {
@@ -699,17 +700,17 @@ function It(t, n) {
699
700
  }).formatToParts(e), l = (s) => r.find((c) => c.type === s)?.value ?? "", i = l("timeZoneName") || n;
700
701
  return `${l("year")}-${l("month")}-${l("day")} ${l("hour")}:${l("minute")}:${l("second")} ${i}`;
701
702
  } catch {
702
- return It(t, "utc");
703
+ return Et(t, "utc");
703
704
  }
704
705
  }
705
- function Oe(t) {
706
+ function Ee(t) {
706
707
  const n = -t.getTimezoneOffset(), e = n >= 0 ? "+" : "-", o = Math.abs(n);
707
708
  return `${e}${D(Math.floor(o / 60))}:${D(o % 60)}`;
708
709
  }
709
710
  function D(t) {
710
711
  return t < 10 ? `0${t}` : String(t);
711
712
  }
712
- function $t(t) {
713
+ function Bt(t) {
713
714
  if (t === "D") return 86400;
714
715
  if (t === "W") return 86400 * 7;
715
716
  if (t === "M") return 86400 * 30;
@@ -726,7 +727,7 @@ function $t(t) {
726
727
  return 60;
727
728
  }
728
729
  export {
729
- Ze as TradingChart,
730
- $t as approxIntervalSeconds,
731
- It as formatCrosshairTime
730
+ Ge as TradingChart,
731
+ Bt as approxIntervalSeconds,
732
+ Et as formatCrosshairTime
732
733
  };