@gearbox-protocol/ui-kit 4.5.0 → 4.5.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,127 +1,127 @@
1
- import { jsxs as U, jsx as _ } from "react/jsx-runtime";
2
- import { createChart as ut, CrosshairMode as ft, LineStyle as ie, LineSeries as ht, AreaSeries as dt } from "lightweight-charts";
3
- import * as we from "react";
4
- import { useRef as K, useState as oe, useEffect as W, useLayoutEffect as pt } from "react";
5
- import { resolveCSSColor as re, generateColorsFromBase as _e } from "./colors.js";
6
- import { useIsMobile as mt } from "../../hooks/use-media-query.js";
1
+ import { jsxs as ee, jsx as _ } from "react/jsx-runtime";
2
+ import { createChart as ft, CrosshairMode as ht, LineStyle as le, LineSeries as dt, AreaSeries as mt } from "lightweight-charts";
3
+ import * as _e from "react";
4
+ import { useRef as H, useState as re, useEffect as W, useLayoutEffect as pt } from "react";
5
+ import { resolveCSSColor as ne, generateColorsFromBase as Pe } from "./colors.js";
6
+ import { useIsMobile as gt } from "../../hooks/use-media-query.js";
7
7
  import { cn as J } from "../../utils/cn.js";
8
- import { AXIS_TIME_EDGE_PADDING_PX as gt, getDefaultOptions as He, getDefaultSeries as bt, AXIS_TICK_MARK_DENSITY as pe, getDefaultVerticalLine as St, AXIS_FONT_SIZE as vt, AXIS_EDGE_LABEL_PADDING_PX as Ke, AXIS_TOP_LABEL_PADDING_PX as Ze } from "./default-config.js";
9
- import { formatExactValue as Pe, isRatioUnit as Ct, getXFormatters as qe, createAdaptiveYAxisFormatter as yt } from "./formatters.js";
10
- import { GraphCurrentValue as xt } from "./graph-current-value.js";
11
- import { GraphTooltip as wt } from "./graph-tooltip.js";
12
- import { VertLine as _t } from "./plugins/vertical-line.js";
13
- import { resolvePriceScaleSides as Pt } from "./series-config.js";
14
- import { getSeriesColorPalette as Ye } from "./series-palette.js";
15
- import { pickMinMove as Rt, niceAxisRange as Tt } from "./y-axis-scale.js";
16
- function ne(e) {
8
+ import { AXIS_TIME_EDGE_PADDING_PX as bt, getDefaultOptions as Ke, getDefaultSeries as St, AXIS_TICK_MARK_DENSITY as pe, getDefaultVerticalLine as vt, AXIS_FONT_SIZE as Ct, AXIS_EDGE_LABEL_PADDING_PX as Ze, AXIS_TOP_LABEL_PADDING_PX as qe } from "./default-config.js";
9
+ import { formatExactValue as Re, isRatioUnit as yt, getXFormatters as Je, createAdaptiveYAxisFormatter as xt } from "./formatters.js";
10
+ import { GraphCurrentValue as wt } from "./graph-current-value.js";
11
+ import { GraphTooltip as _t } from "./graph-tooltip.js";
12
+ import { VertLine as Pt } from "./plugins/vertical-line.js";
13
+ import { resolvePriceScaleSides as Rt } from "./series-config.js";
14
+ import { getSeriesColorPalette as Oe } from "./series-palette.js";
15
+ import { pickMinMove as Tt, niceAxisRange as Nt } from "./y-axis-scale.js";
16
+ function ie(e) {
17
17
  return e.id ?? e.label;
18
18
  }
19
- function Nt({
19
+ function Vt({
20
20
  lastIndex: e,
21
- width: i,
21
+ width: n,
22
22
  padLeft: c,
23
23
  padRight: f,
24
- paddingPx: h = gt
24
+ paddingPx: h = bt
25
25
  }) {
26
26
  if (e < 0) return null;
27
- const u = (c || f) && i > 0 ? h * Math.max(e, 1) / i : 0;
27
+ const u = (c || f) && n > 0 ? h * Math.max(e, 1) / n : 0;
28
28
  return {
29
29
  from: c && u !== 0 ? -u : 0,
30
30
  to: f ? e + u : e
31
31
  };
32
32
  }
33
- function Je(e, i, c) {
33
+ function Qe(e, n, c) {
34
34
  if (!c)
35
35
  return e.values().next().value;
36
36
  const f = e.get(c);
37
37
  if (f) return f;
38
- const h = i.find((u) => u.id === c || u.label === c);
39
- return h ? e.get(ne(h)) : void 0;
38
+ const h = n.find((u) => u.id === c || u.label === c);
39
+ return h ? e.get(ie(h)) : void 0;
40
40
  }
41
- class Vt {
41
+ class kt {
42
42
  _yTop;
43
43
  _yBottom;
44
44
  _color;
45
- constructor(i, c, f) {
46
- this._yTop = i, this._yBottom = c, this._color = f;
45
+ constructor(n, c, f) {
46
+ this._yTop = n, this._yBottom = c, this._color = f;
47
47
  }
48
- draw(i) {
49
- i.useBitmapCoordinateSpace((c) => {
48
+ draw(n) {
49
+ n.useBitmapCoordinateSpace((c) => {
50
50
  const f = c.context, h = c.verticalPixelRatio, u = this._yTop === null ? 0 : this._yTop * h, S = this._yBottom === null ? c.bitmapSize.height : this._yBottom * h, P = Math.min(u, S), D = Math.max(u, S);
51
51
  f.fillStyle = this._color, f.fillRect(0, P, c.bitmapSize.width, D - P);
52
52
  });
53
53
  }
54
54
  }
55
- class kt {
55
+ class Lt {
56
56
  _source;
57
57
  _yTop = null;
58
58
  _yBottom = null;
59
- constructor(i) {
60
- this._source = i;
59
+ constructor(n) {
60
+ this._source = n;
61
61
  }
62
62
  update() {
63
- const i = this._source.series;
64
- this._yTop = this._source.priceTop === void 0 ? null : i.priceToCoordinate(this._source.priceTop), this._yBottom = this._source.priceBottom === void 0 ? null : i.priceToCoordinate(this._source.priceBottom);
63
+ const n = this._source.series;
64
+ this._yTop = this._source.priceTop === void 0 ? null : n.priceToCoordinate(this._source.priceTop), this._yBottom = this._source.priceBottom === void 0 ? null : n.priceToCoordinate(this._source.priceBottom);
65
65
  }
66
66
  /** Draw beneath the series line/area so the data stays readable. */
67
67
  zOrder() {
68
68
  return "bottom";
69
69
  }
70
70
  renderer() {
71
- return new Vt(this._yTop, this._yBottom, this._source.color);
71
+ return new kt(this._yTop, this._yBottom, this._source.color);
72
72
  }
73
73
  }
74
- class Lt {
74
+ class Mt {
75
75
  series;
76
76
  priceTop;
77
77
  priceBottom;
78
78
  color;
79
79
  _paneViews;
80
- constructor(i, c, f, h) {
81
- this.series = i, this.priceTop = c, this.priceBottom = f, this.color = h, this._paneViews = [new kt(this)];
80
+ constructor(n, c, f, h) {
81
+ this.series = n, this.priceTop = c, this.priceBottom = f, this.color = h, this._paneViews = [new Lt(this)];
82
82
  }
83
83
  updateAllViews() {
84
- for (const i of this._paneViews) i.update();
84
+ for (const n of this._paneViews) n.update();
85
85
  }
86
86
  paneViews() {
87
87
  return this._paneViews;
88
88
  }
89
89
  }
90
- function Mt(e, i) {
90
+ function Dt(e, n) {
91
91
  switch (e) {
92
- case ie.Dotted:
93
- return [i, i];
94
- case ie.Dashed:
95
- return [2 * i, 2 * i];
96
- case ie.LargeDashed:
97
- return [6 * i, 6 * i];
98
- case ie.SparseDotted:
99
- return [i, 4 * i];
92
+ case le.Dotted:
93
+ return [n, n];
94
+ case le.Dashed:
95
+ return [2 * n, 2 * n];
96
+ case le.LargeDashed:
97
+ return [6 * n, 6 * n];
98
+ case le.SparseDotted:
99
+ return [n, 4 * n];
100
100
  default:
101
101
  return [];
102
102
  }
103
103
  }
104
- class Dt {
104
+ class It {
105
105
  _y;
106
106
  _color;
107
107
  _lineWidth;
108
108
  _lineStyle;
109
- constructor(i, c, f, h) {
110
- this._y = i, this._color = c, this._lineWidth = f, this._lineStyle = h;
109
+ constructor(n, c, f, h) {
110
+ this._y = n, this._color = c, this._lineWidth = f, this._lineStyle = h;
111
111
  }
112
- draw(i) {
113
- i.useBitmapCoordinateSpace((c) => {
112
+ draw(n) {
113
+ n.useBitmapCoordinateSpace((c) => {
114
114
  if (this._y === null) return;
115
115
  const f = c.context, h = c.verticalPixelRatio, u = Math.max(1, Math.round(this._lineWidth * h)), S = Math.round(this._y * h);
116
- f.save(), f.strokeStyle = this._color, f.lineWidth = u, f.setLineDash(Mt(this._lineStyle, u)), f.beginPath(), f.moveTo(0, S), f.lineTo(c.bitmapSize.width, S), f.stroke(), f.restore();
116
+ f.save(), f.strokeStyle = this._color, f.lineWidth = u, f.setLineDash(Dt(this._lineStyle, u)), f.beginPath(), f.moveTo(0, S), f.lineTo(c.bitmapSize.width, S), f.stroke(), f.restore();
117
117
  });
118
118
  }
119
119
  }
120
- class It {
120
+ class Bt {
121
121
  _source;
122
122
  _y = null;
123
- constructor(i) {
124
- this._source = i;
123
+ constructor(n) {
124
+ this._source = n;
125
125
  }
126
126
  update() {
127
127
  this._y = this._source.series.priceToCoordinate(this._source.price);
@@ -136,7 +136,7 @@ class It {
136
136
  return "top";
137
137
  }
138
138
  renderer() {
139
- return new Dt(
139
+ return new It(
140
140
  this._y,
141
141
  this._source.color,
142
142
  this._source.lineWidth,
@@ -144,48 +144,48 @@ class It {
144
144
  );
145
145
  }
146
146
  }
147
- class Bt {
147
+ class Et {
148
148
  series;
149
149
  price;
150
150
  color;
151
151
  lineWidth;
152
152
  lineStyle;
153
153
  _paneViews;
154
- constructor(i, c, f, h, u) {
155
- this.series = i, this.price = c, this.color = f, this.lineWidth = h, this.lineStyle = u, this._paneViews = [new It(this)];
154
+ constructor(n, c, f, h, u) {
155
+ this.series = n, this.price = c, this.color = f, this.lineWidth = h, this.lineStyle = u, this._paneViews = [new Bt(this)];
156
156
  }
157
157
  updateAllViews() {
158
- for (const i of this._paneViews) i.update();
158
+ for (const n of this._paneViews) n.update();
159
159
  }
160
160
  paneViews() {
161
161
  return this._paneViews;
162
162
  }
163
163
  }
164
- function Et(e, i, c) {
165
- const f = e.labelText ?? "", h = e.value, u = h === void 0 ? "" : typeof h == "number" ? i === "$" ? `$${Pe(h, void 0, c)}` : i === "%" ? `${Pe(h, void 0, c)}%` : Pe(
164
+ function Ft(e, n, c) {
165
+ const f = e.labelText ?? "", h = e.value, u = h === void 0 ? "" : typeof h == "number" ? n === "$" ? `$${Re(h, void 0, c)}` : n === "%" ? `${Re(h, void 0, c)}%` : Re(
166
166
  h,
167
- i !== "none" && i !== "%" && i !== "$" && !Ct(i) ? i : void 0,
167
+ n !== "none" && n !== "%" && n !== "$" && !yt(n) ? n : void 0,
168
168
  c
169
169
  ) : String(h);
170
170
  return { labelText: f, valueStr: u };
171
171
  }
172
- const Qe = 4;
173
- function Ft(e, i, c) {
172
+ const Ye = 4;
173
+ function zt(e, n, c) {
174
174
  const f = { left: e, transform: "translateX(-50%)" };
175
- if (i <= 0 || !c || c <= 0)
175
+ if (n <= 0 || !c || c <= 0)
176
176
  return f;
177
- const h = c / 2, u = Qe + h, S = i - Qe - h;
178
- return S < u ? { left: i / 2, transform: "translateX(-50%)" } : { left: Math.min(Math.max(e, u), S), transform: "translateX(-50%)" };
177
+ const h = c / 2, u = Ye + h, S = n - Ye - h;
178
+ return S < u ? { left: n / 2, transform: "translateX(-50%)" } : { left: Math.min(Math.max(e, u), S), transform: "translateX(-50%)" };
179
179
  }
180
- function zt(e, i) {
180
+ function At(e, n) {
181
181
  for (let c = e.length - 1; c >= 0; c--)
182
- if (Number(e[c].time) <= i)
182
+ if (Number(e[c].time) <= n)
183
183
  return e[c].value;
184
184
  return 0;
185
185
  }
186
- function to({
186
+ function oo({
187
187
  series: e,
188
- className: i,
188
+ className: n,
189
189
  showLegend: c = !1,
190
190
  onUnselectSeries: f,
191
191
  xMeasureUnit: h = "time",
@@ -195,84 +195,84 @@ function to({
195
195
  priceLineOptions: D,
196
196
  zoneOptions: F,
197
197
  currentValueDecimals: se,
198
- useSharedPriceScale: Z = !1,
198
+ useSharedPriceScale: K = !1,
199
199
  dualYAxis: z = !1,
200
- defaultVisiblePriceScaleId: Re = "right",
201
- showCurrentValue: Oe = !0,
202
- graphTitle: me,
203
- yScaleMin: Te,
204
- yScaleMinMultiple: Ne,
205
- visibleTimeFrom: le,
206
- disableZoom: Ve = !1,
207
- hideDefaultTooltip: ge = !1
200
+ defaultVisiblePriceScaleId: Te = "right",
201
+ showCurrentValue: Ue = !0,
202
+ graphTitle: ge,
203
+ yScaleMin: Ne,
204
+ yScaleMinMultiple: Ve,
205
+ visibleTimeFrom: ae,
206
+ disableZoom: ke = !1,
207
+ hideDefaultTooltip: be = !1
208
208
  }) {
209
- const I = K(null), N = K(/* @__PURE__ */ new Map()), be = K(!1), ke = K(!0), Le = K([]), ae = K(0), B = K(null), Se = K(null), Me = K(null), R = mt(), ce = we.useMemo(() => e.flatMap((t) => t.data), [e]), Ue = we.useMemo(() => {
209
+ const I = H(null), V = H(/* @__PURE__ */ new Map()), Se = H(!1), Le = H(!0), Me = H([]), ce = H(0), B = H(null), ve = H(null), De = H(null), R = gt(), ue = _e.useMemo(() => e.flatMap((t) => t.data), [e]), et = _e.useMemo(() => {
210
210
  if (e.length > 0) {
211
211
  const t = e[e.length - 1];
212
212
  if (t.data.length > 0)
213
213
  return t.data[t.data.length - 1];
214
214
  }
215
- }, [e]), [De, ve] = oe(() => {
216
- if (!Ue) return;
215
+ }, [e]), [Ie, Ce] = re(() => {
216
+ if (!et) return;
217
217
  const t = /* @__PURE__ */ new Map();
218
- for (const l of e)
219
- l.data.length > 0 && t.set(l.label, l.data[l.data.length - 1]);
218
+ for (const s of e)
219
+ s.data.length > 0 && t.set(s.label, s.data[s.data.length - 1]);
220
220
  return t;
221
- }), [Ie, Q] = oe(null), [Be, Ee] = oe([]), [et, Fe] = oe(0), ze = K(/* @__PURE__ */ new Map()), [tt, ot] = oe({}), [Y, rt] = oe(0);
221
+ }), [Be, Q] = re(null), [Ee, Fe] = re([]), [tt, ze] = re(0), Ae = H(/* @__PURE__ */ new Map()), [ot, rt] = re({}), [Y, nt] = re(0);
222
222
  W(() => {
223
223
  const t = () => {
224
224
  try {
225
- if (B.current && Fe(B.current.clientWidth), I.current && B.current) {
226
- const s = B.current.clientWidth, a = B.current.clientHeight;
227
- I.current.resize(s, a);
225
+ if (B.current && ze(B.current.clientWidth), I.current && B.current) {
226
+ const l = B.current.clientWidth, a = B.current.clientHeight;
227
+ I.current.resize(l, a);
228
228
  try {
229
- ae.current = I.current.paneSize().height;
229
+ ce.current = I.current.paneSize().height;
230
230
  } catch {
231
231
  }
232
232
  }
233
233
  } catch {
234
234
  }
235
- }, l = B.current, r = l ? new ResizeObserver(t) : null;
236
- return Me.current = r, l && r?.observe(l), () => {
237
- l && r?.unobserve(l), r?.disconnect(), Me.current = null;
235
+ }, s = B.current, r = s ? new ResizeObserver(t) : null;
236
+ return De.current = r, s && r?.observe(s), () => {
237
+ s && r?.unobserve(s), r?.disconnect(), De.current = null;
238
238
  };
239
239
  }, []), W(() => {
240
- if (!Se.current || be.current) return;
241
- const t = He(), l = re(
240
+ if (!ve.current || Se.current) return;
241
+ const t = Ke(), s = ne(
242
242
  "hsl(var(--muted-foreground))",
243
243
  "rgb(163, 163, 163)"
244
- ), r = ut(Se.current, {
244
+ ), r = ft(ve.current, {
245
245
  ...t,
246
246
  leftPriceScale: {
247
247
  ...t.leftPriceScale || {},
248
248
  visible: !1,
249
- textColor: l
249
+ textColor: s
250
250
  },
251
251
  rightPriceScale: {
252
252
  ...t.rightPriceScale || {},
253
253
  visible: !R,
254
- textColor: l
254
+ textColor: s
255
255
  },
256
256
  ...R && {
257
257
  crosshair: {
258
258
  ...t.crosshair,
259
- mode: ft.Magnet
259
+ mode: ht.Magnet
260
260
  }
261
261
  }
262
262
  });
263
- I.current = r, be.current = !0;
263
+ I.current = r, Se.current = !0;
264
264
  try {
265
- ae.current = r.paneSize().height;
265
+ ce.current = r.paneSize().height;
266
266
  } catch {
267
- ae.current = 0;
267
+ ce.current = 0;
268
268
  }
269
- return rt((s) => s + 1), () => {
270
- r.remove(), I.current = null, be.current = !1, N.current.clear();
269
+ return nt((l) => l + 1), () => {
270
+ r.remove(), I.current = null, Se.current = !1, V.current.clear();
271
271
  };
272
272
  }, [R]), W(() => {
273
273
  const t = I.current;
274
274
  t && t.applyOptions(
275
- Ve ? {
275
+ ke ? {
276
276
  handleScale: {
277
277
  mouseWheel: !1,
278
278
  pinch: !1,
@@ -300,218 +300,219 @@ function to({
300
300
  }
301
301
  }
302
302
  );
303
- }, [Y, Ve]), W(() => {
303
+ }, [Y, ke]), W(() => {
304
304
  const t = I.current;
305
305
  !t || !S || t.applyOptions(S);
306
306
  }, [Y, S]), W(() => {
307
307
  const t = I.current;
308
308
  if (!t || e.length === 0) return;
309
- const r = e.filter((n) => n.data.length > 0).length <= 1 ? Te : Ne, s = h === "time" ? qe(h, ce) : qe(h), a = new Map(
310
- Pt(e).map(({ series: n, side: o }) => [
311
- n.label,
309
+ const r = e.filter((i) => i.data.length > 0).length <= 1 ? Ne : Ve, l = h === "time" ? Je(h, ue) : Je(h), a = new Map(
310
+ Rt(e).map(({ series: i, side: o }) => [
311
+ i.label,
312
312
  o
313
313
  ])
314
- ), p = (n, o, d) => {
315
- const { formatter: L, tickmarksFormatter: k, updateVisibleRange: E } = yt(n, o, {
314
+ ), m = (i, o, d) => {
315
+ const { formatter: L, tickmarksFormatter: N, updateVisibleRange: E } = xt(i, o, {
316
316
  yScaleMin: r
317
317
  });
318
- return { formatter: L, tickmarksFormatter: k, updateVisibleRange: E, labels: d };
319
- }, m = [];
318
+ return { formatter: L, tickmarksFormatter: N, updateVisibleRange: E, labels: d };
319
+ }, p = [];
320
320
  if (z)
321
- for (const n of ["left", "right"]) {
321
+ for (const i of ["left", "right"]) {
322
322
  const o = /* @__PURE__ */ new Set(), d = [];
323
323
  let L = u;
324
- for (const k of e)
325
- if (k.data.length !== 0 && a.get(k.label) === n) {
326
- o.size === 0 && k.yMeasureUnit && (L = k.yMeasureUnit), o.add(k.label);
327
- for (const E of k.data) d.push(E.value);
324
+ for (const N of e)
325
+ if (N.data.length !== 0 && a.get(N.label) === i) {
326
+ o.size === 0 && N.yMeasureUnit && (L = N.yMeasureUnit), o.add(N.label);
327
+ for (const E of N.data) d.push(E.value);
328
328
  }
329
- o.size > 0 && m.push(p(d, L, o));
329
+ o.size > 0 && p.push(m(d, L, o));
330
330
  }
331
331
  else {
332
- const n = ce.map((d) => d.value), o = new Set(
332
+ const i = ue.map((d) => d.value), o = new Set(
333
333
  e.filter((d) => d.data.length > 0).map((d) => d.label)
334
334
  );
335
- m.push(p(n, u, o));
335
+ p.push(m(i, u, o));
336
336
  }
337
- Le.current = m;
337
+ Me.current = p;
338
338
  const y = /* @__PURE__ */ new Map();
339
- for (const n of m)
340
- for (const o of n.labels)
341
- y.set(o, n);
342
- const x = He();
339
+ for (const i of p)
340
+ for (const o of i.labels)
341
+ y.set(o, i);
342
+ const x = Ke();
343
343
  t.applyOptions({
344
344
  localization: {
345
345
  ...x.localization || {},
346
346
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
347
- timeFormatter: (n) => (
347
+ timeFormatter: (i) => (
348
348
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
349
- s.timeFormatter(parseFloat(n), void 0)
349
+ l.timeFormatter(parseFloat(i), void 0)
350
350
  )
351
351
  },
352
352
  timeScale: {
353
353
  ...x.timeScale || {},
354
354
  ...S?.timeScale,
355
355
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
356
- tickMarkFormatter: s.tickMarkFormatter,
356
+ tickMarkFormatter: l.tickMarkFormatter,
357
357
  minBarSpacing: 0
358
358
  }
359
359
  });
360
- const v = !z && e.length > 1 && !Z, X = z ? R : e.length > 1 && !Z || R, V = re(
360
+ const v = !z && e.length > 1 && !K, X = z ? R : e.length > 1 && !K || R, k = ne(
361
361
  "hsl(var(--muted-foreground))",
362
362
  "rgb(163, 163, 163)"
363
363
  );
364
364
  t.applyOptions({
365
365
  ...z && {
366
- defaultVisiblePriceScaleId: Re
366
+ defaultVisiblePriceScaleId: Te
367
367
  },
368
368
  leftPriceScale: {
369
369
  ...x.leftPriceScale || {},
370
370
  ...S?.leftPriceScale,
371
371
  visible: z && !R,
372
- textColor: V
372
+ textColor: k
373
373
  },
374
374
  rightPriceScale: {
375
375
  ...x.rightPriceScale || {},
376
376
  ...S?.rightPriceScale,
377
377
  visible: z ? !R : !X,
378
- textColor: V
378
+ textColor: k
379
379
  }
380
380
  });
381
- const O = new Set(N.current.keys()), $ = new Set(e.map(ne));
382
- for (const n of O)
383
- if (!$.has(n)) {
384
- const o = N.current.get(n);
385
- o && (t.removeSeries(o), N.current.delete(n));
381
+ const O = new Set(V.current.keys()), $ = new Set(e.map(ie));
382
+ for (const i of O)
383
+ if (!$.has(i)) {
384
+ const o = V.current.get(i);
385
+ o && (t.removeSeries(o), V.current.delete(i));
386
386
  }
387
- const g = bt(), M = [];
387
+ const g = St(), M = [];
388
388
  let T = 0;
389
- const G = e.find((n) => n.data.length > 0), C = /* @__PURE__ */ new Map();
389
+ const G = e.find((i) => i.data.length > 0), C = /* @__PURE__ */ new Map();
390
390
  if (D && D.length > 0)
391
- for (const n of D) {
392
- if (!Number.isFinite(n.price)) continue;
393
- const o = n.seriesLabel ?? G?.label;
391
+ for (const i of D) {
392
+ if (!Number.isFinite(i.price)) continue;
393
+ const o = i.seriesLabel ?? G?.label;
394
394
  if (!o) continue;
395
395
  const d = C.get(o) ?? [];
396
- d.push(n.price), C.set(o, d);
396
+ d.push(i.price), C.set(o, d);
397
397
  }
398
398
  if (F && F.length > 0)
399
- for (const n of F) {
400
- const o = n.seriesLabel ?? G?.label;
399
+ for (const i of F) {
400
+ const o = i.seriesLabel ?? G?.label;
401
401
  if (!o) continue;
402
402
  const d = C.get(o) ?? [];
403
- Number.isFinite(n.priceTop) && d.push(n.priceTop), Number.isFinite(n.priceBottom) && d.push(n.priceBottom), C.set(o, d);
403
+ Number.isFinite(i.priceTop) && d.push(i.priceTop), Number.isFinite(i.priceBottom) && d.push(i.priceBottom), C.set(o, d);
404
404
  }
405
- for (let n = 0; n < e.length; n++) {
406
- const o = e[n], d = ne(o), L = Ye(n), k = o.lineColor ?? o.color ?? L.line;
405
+ for (let i = 0; i < e.length; i++) {
406
+ const o = e[i], d = ie(o), L = Oe(i), N = o.lineColor ?? o.color ?? L.line;
407
407
  let E, q;
408
408
  if (o.lineColor ?? o.color)
409
409
  if (o.topColor && o.bottomColor)
410
410
  E = o.topColor, q = o.bottomColor;
411
411
  else if (o.topColor) {
412
- const b = _e(k);
412
+ const b = Pe(N);
413
413
  E = o.topColor, q = b.bottomColor;
414
414
  } else if (o.bottomColor)
415
- E = _e(k).topColor, q = o.bottomColor;
415
+ E = Pe(N).topColor, q = o.bottomColor;
416
416
  else {
417
- const b = _e(k);
417
+ const b = Pe(N);
418
418
  E = b.topColor, q = b.bottomColor;
419
419
  }
420
420
  else
421
421
  E = o.topColor || L.top, q = o.bottomColor || L.bottom;
422
422
  if (o.data.length === 0) {
423
- const b = N.current.get(d);
424
- b && (t.removeSeries(b), N.current.delete(d));
423
+ const b = V.current.get(d);
424
+ b && (t.removeSeries(b), V.current.delete(d));
425
425
  continue;
426
426
  }
427
- const ue = o.data.length > 0 ? Math.min(...o.data.map((b) => b.value)) : 0, he = o.data.length > 0 ? Math.max(...o.data.map((b) => b.value)) : 0, nt = ue < 0, it = o.data.some((b) => b.value === 0), st = !nt && it, We = Rt(he - ue), Xe = z ? o.priceScaleId ?? (T === 0 ? "left" : "right") : Z || !v || T === 0 ? "right" : `scale-${T}`;
427
+ const fe = o.data.length > 0 ? Math.min(...o.data.map((b) => b.value)) : 0, de = o.data.length > 0 ? Math.max(...o.data.map((b) => b.value)) : 0, it = fe < 0, lt = o.data.some((b) => b.value === 0), st = !it && lt, Xe = Tt(de - fe), $e = z ? o.priceScaleId ?? (T === 0 ? "left" : "right") : K || !v || T === 0 ? "right" : `scale-${T}`;
428
428
  v && M.push({
429
- priceScaleId: Xe || "right",
429
+ priceScaleId: $e || "right",
430
430
  seriesIndex: T
431
431
  });
432
- const Ce = (Z || !v) && r !== void 0 && typeof r == "number", lt = C.get(o.label) ?? [], at = (b) => {
432
+ const ye = (K || !v) && r !== void 0 && typeof r == "number", at = C.get(o.label) ?? [], ct = (b) => {
433
433
  const w = b();
434
434
  if (w?.priceRange) {
435
- Ce && (w.priceRange.minValue = r);
436
- for (const H of lt)
437
- H < w.priceRange.minValue && (w.priceRange.minValue = H), H > w.priceRange.maxValue && (w.priceRange.maxValue = H);
438
- const te = Ce ? r : st && w.priceRange.minValue >= 0 ? 0 : void 0, de = ae.current > 0 ? ae.current : B.current?.clientHeight ?? 0;
439
- if (de > 0) {
440
- const H = Tt({
435
+ ye && (w.priceRange.minValue = r);
436
+ for (const j of at)
437
+ j < w.priceRange.minValue && (w.priceRange.minValue = j), j > w.priceRange.maxValue && (w.priceRange.maxValue = j);
438
+ const oe = ye ? r : st && w.priceRange.minValue >= 0 ? 0 : void 0, me = ce.current > 0 ? ce.current : B.current?.clientHeight ?? 0;
439
+ if (me > 0) {
440
+ const j = Nt({
441
441
  min: w.priceRange.minValue,
442
442
  max: w.priceRange.maxValue,
443
- floor: te,
444
- scaleHeightPx: de,
445
- fontSizePx: vt,
443
+ floor: oe,
444
+ scaleHeightPx: me,
445
+ fontSizePx: Ct,
446
446
  tickMarkDensity: pe,
447
- minMove: We,
448
- edgePaddingPx: Ke,
449
- edgePaddingTopPx: Ze
447
+ minMove: Xe,
448
+ edgePaddingPx: Ze,
449
+ edgePaddingTopPx: qe
450
450
  });
451
- w.priceRange.minValue = H.min, w.priceRange.maxValue = H.max;
451
+ w.priceRange.minValue = j.min, w.priceRange.maxValue = j.max;
452
452
  }
453
453
  w.margins = {
454
- above: Ze,
455
- below: Ke
454
+ above: qe,
455
+ below: Ze
456
456
  };
457
457
  }
458
458
  return w;
459
- }, $e = y.get(o.label) ?? m[0], Ge = $e.formatter, ct = $e.tickmarksFormatter, ye = {
460
- lineColor: k,
459
+ }, Ge = y.get(o.label) ?? p[0], je = Ge.formatter, ut = Ge.tickmarksFormatter, xe = {
460
+ lineColor: N,
461
461
  topColor: E,
462
462
  bottomColor: q,
463
- priceScaleId: Xe,
463
+ priceScaleId: $e,
464
464
  ...o.seriesType === "line" && {
465
- lineStyle: o.lineStyle ?? ie.Solid
465
+ color: N,
466
+ lineStyle: o.lineStyle ?? le.Solid
466
467
  },
467
468
  priceFormat: {
468
469
  type: "custom",
469
- minMove: We,
470
- formatter: Ce && typeof r == "number" ? (b) => Ge(
470
+ minMove: Xe,
471
+ formatter: ye && typeof r == "number" ? (b) => je(
471
472
  b < r ? r : b
472
- ) : Ge,
473
- tickmarksFormatter: ct
473
+ ) : je,
474
+ tickmarksFormatter: ut
474
475
  },
475
- autoscaleInfoProvider: at
476
- }, je = o.seriesType === "line";
477
- let A = N.current.get(d);
478
- const ee = o.data.map((b) => ({
476
+ autoscaleInfoProvider: ct
477
+ }, He = o.seriesType === "line";
478
+ let A = V.current.get(d);
479
+ const te = o.data.map((b) => ({
479
480
  ...b,
480
481
  time: b.time
481
482
  }));
482
- if (le !== void 0 && ee.length > 0 && Number(ee[0].time) > le) {
483
- const b = Number(ee[0].time), w = b - le, te = 86400, de = w > 180 * te ? 7 * te : w > 30 * te ? te : 6 * 3600, H = [];
484
- for (let xe = le; xe < b; xe += de)
485
- H.push({ time: xe });
486
- ee.unshift(...H);
483
+ if (ae !== void 0 && te.length > 0 && Number(te[0].time) > ae) {
484
+ const b = Number(te[0].time), w = b - ae, oe = 86400, me = w > 180 * oe ? 7 * oe : w > 30 * oe ? oe : 6 * 3600, j = [];
485
+ for (let we = ae; we < b; we += me)
486
+ j.push({ time: we });
487
+ te.unshift(...j);
487
488
  }
488
- A && A.seriesType() !== (je ? "Line" : "Area") && (t.removeSeries(A), N.current.delete(d), A = void 0), A ? (A.applyOptions(ye), A.setData(ee)) : (je ? A = t.addSeries(ht, {
489
+ A && A.seriesType() !== (He ? "Line" : "Area") && (t.removeSeries(A), V.current.delete(d), A = void 0), A ? (A.applyOptions(xe), A.setData(te)) : (He ? A = t.addSeries(dt, {
489
490
  ...g,
490
- ...ye
491
- }) : A = t.addSeries(dt, {
491
+ ...xe
492
+ }) : A = t.addSeries(mt, {
492
493
  ...g,
493
- ...ye
494
- }), A.setData(ee), N.current.set(d, A)), T++;
494
+ ...xe
495
+ }), A.setData(te), V.current.set(d, A)), T++;
495
496
  }
496
497
  if (z)
497
498
  try {
498
- const n = t.priceScale("left"), o = t.priceScale("right"), d = {
499
+ const i = t.priceScale("left"), o = t.priceScale("right"), d = {
499
500
  visible: !R,
500
501
  autoScale: !0,
501
502
  scaleMargins: { top: 0, bottom: 0 },
502
503
  alignLabels: !0,
503
504
  entireTextOnly: !1,
504
505
  tickMarkDensity: pe,
505
- textColor: V,
506
+ textColor: k,
506
507
  ...S?.rightPriceScale
507
508
  };
508
- n?.applyOptions(d), o?.applyOptions(d);
509
+ i?.applyOptions(d), o?.applyOptions(d);
509
510
  } catch {
510
511
  }
511
512
  else if (v && M.length > 0)
512
- for (const n of M)
513
+ for (const i of M)
513
514
  try {
514
- const o = t.priceScale(n.priceScaleId);
515
+ const o = t.priceScale(i.priceScaleId);
515
516
  o && o.applyOptions({
516
517
  visible: !1,
517
518
  autoScale: !0,
@@ -522,18 +523,18 @@ function to({
522
523
  alignLabels: !0,
523
524
  entireTextOnly: !1,
524
525
  tickMarkDensity: pe,
525
- textColor: V
526
+ textColor: k
526
527
  });
527
528
  } catch (o) {
528
529
  console.warn(
529
- `Failed to configure price scale ${n.priceScaleId} for series ${n.seriesIndex}:`,
530
+ `Failed to configure price scale ${i.priceScaleId} for series ${i.seriesIndex}:`,
530
531
  o
531
532
  );
532
533
  }
533
534
  else if (!v)
534
535
  try {
535
- const n = t.priceScale("right");
536
- n && n.applyOptions({
536
+ const i = t.priceScale("right");
537
+ i && i.applyOptions({
537
538
  visible: !R,
538
539
  autoScale: !0,
539
540
  scaleMargins: {
@@ -543,17 +544,19 @@ function to({
543
544
  alignLabels: !0,
544
545
  entireTextOnly: !1,
545
546
  tickMarkDensity: pe,
546
- textColor: V,
547
+ textColor: k,
547
548
  ...S?.rightPriceScale
548
549
  });
549
550
  } catch {
550
551
  }
551
- if (r !== void 0 && !R && (Z || !v) && t.applyOptions({
552
+ r !== void 0 && !R && (K || !v) && t.applyOptions({
552
553
  handleScroll: {
553
554
  vertTouchDrag: !1
554
555
  }
555
- }), ce.length > 0) {
556
- const n = ce.map((d) => Number(d.time)).filter((d) => Number.isFinite(d)), o = new Set(n).size - 1;
556
+ });
557
+ let Z = 0;
558
+ if (ue.length > 0) {
559
+ const i = ue.map((d) => Number(d.time)).filter((d) => Number.isFinite(d)), o = new Set(i).size - 1;
557
560
  if (o >= 0) {
558
561
  const d = () => {
559
562
  const L = t.timeScale();
@@ -564,18 +567,23 @@ function to({
564
567
  }), L.setVisibleLogicalRange({ from: 0, to: o });
565
568
  return;
566
569
  }
567
- const k = z && !R, E = z ? !R : !X, q = !k, ue = !E;
570
+ const N = z && !R, E = z ? !R : !X, q = !N, fe = !E;
568
571
  L.applyOptions({
569
572
  fixLeftEdge: !q,
570
- fixRightEdge: !ue
571
- });
572
- const he = Nt({
573
- lastIndex: o,
574
- width: L.width(),
575
- padLeft: q,
576
- padRight: ue
573
+ fixRightEdge: !fe
574
+ }), Z = requestAnimationFrame(() => {
575
+ const de = Vt({
576
+ lastIndex: o,
577
+ width: L.width(),
578
+ padLeft: q,
579
+ padRight: fe
580
+ });
581
+ try {
582
+ de && L.setVisibleLogicalRange(de);
583
+ } catch {
584
+ L.fitContent();
585
+ }
577
586
  });
578
- he && L.setVisibleLogicalRange(he);
579
587
  };
580
588
  try {
581
589
  d();
@@ -587,31 +595,31 @@ function to({
587
595
  }
588
596
  }
589
597
  }
590
- ke.current && (ke.current = !1), S && t.applyOptions(S);
591
- const j = /* @__PURE__ */ new Map();
592
- for (const n of e)
593
- n.data.length > 0 && j.set(n.label, n.data[n.data.length - 1]);
594
- ve(j.size > 0 ? j : void 0);
598
+ Le.current && (Le.current = !1), S && t.applyOptions(S);
599
+ const U = /* @__PURE__ */ new Map();
600
+ for (const i of e)
601
+ i.data.length > 0 && U.set(i.label, i.data[i.data.length - 1]);
602
+ return Ce(U.size > 0 ? U : void 0), () => cancelAnimationFrame(Z);
595
603
  }, [
596
604
  Y,
597
605
  e,
598
- ce,
606
+ ue,
599
607
  h,
600
608
  u,
601
609
  R,
602
- Z,
610
+ K,
603
611
  z,
604
- Re,
605
612
  Te,
606
613
  Ne,
607
- le,
614
+ Ve,
615
+ ae,
608
616
  D,
609
617
  F,
610
618
  S
611
619
  ]), W(() => {
612
620
  const t = I.current;
613
621
  if (!t || e.length === 0) return;
614
- const l = e.length === 1;
622
+ const s = e.length === 1;
615
623
  let r;
616
624
  for (const a of e)
617
625
  if (a.data.length > 0) {
@@ -619,13 +627,13 @@ function to({
619
627
  break;
620
628
  }
621
629
  if (!r) return;
622
- const s = (a) => {
623
- const { time: p = r, seriesData: m, point: y } = a || {}, x = e[0], v = x ? N.current.get(ne(x)) : void 0;
624
- if (!y || !p) {
630
+ const l = (a) => {
631
+ const { time: m = r, seriesData: p, point: y } = a || {}, x = e[0], v = x ? V.current.get(ie(x)) : void 0;
632
+ if (!y || !m) {
625
633
  const $ = /* @__PURE__ */ new Map();
626
634
  for (const g of e)
627
635
  g.data.length > 0 && $.set(g.label, g.data[g.data.length - 1]);
628
- if (ve($.size > 0 ? $ : void 0), l || Z || ge)
636
+ if (Ce($.size > 0 ? $ : void 0), s || K || be)
629
637
  Q(null);
630
638
  else if (v && r) {
631
639
  const g = e[0];
@@ -637,26 +645,26 @@ function to({
637
645
  return;
638
646
  }
639
647
  const X = /* @__PURE__ */ new Map();
640
- let V, O = v;
648
+ let k, O = v;
641
649
  for (let $ = 0; $ < e.length; $++) {
642
- const g = e[$], M = N.current.get(ne(g));
650
+ const g = e[$], M = V.current.get(ie(g));
643
651
  if (!M) continue;
644
- const T = m?.get(M), G = T && "value" in T ? T.value : void 0;
652
+ const T = p?.get(M), G = T && "value" in T ? T.value : void 0;
645
653
  let C;
646
654
  if (G !== void 0)
647
655
  C = G;
648
- else if (l) {
649
- const j = Number(p), n = g.data.length > 0 ? Number(g.data[0].time) : Number.POSITIVE_INFINITY;
650
- j < n ? C = Number.NaN : C = g.data[g.data.length - 1]?.value ?? 0;
656
+ else if (s) {
657
+ const Z = Number(m), U = g.data.length > 0 ? Number(g.data[0].time) : Number.POSITIVE_INFINITY;
658
+ Z < U ? C = Number.NaN : C = g.data[g.data.length - 1]?.value ?? 0;
651
659
  } else {
652
- const j = g.data.length > 0 ? Number(g.data[0].time) : Number.POSITIVE_INFINITY;
653
- if (Number(p) < j) continue;
654
- C = zt(g.data, Number(p));
660
+ const Z = g.data.length > 0 ? Number(g.data[0].time) : Number.POSITIVE_INFINITY;
661
+ if (Number(m) < Z) continue;
662
+ C = At(g.data, Number(m));
655
663
  }
656
- Number.isNaN(C) || (V === void 0 && (V = C, O = M), X.set(g.label, { value: C, time: p }));
664
+ Number.isNaN(C) || (k === void 0 && (k = C, O = M), X.set(g.label, { value: C, time: m }));
657
665
  }
658
- if (ve(X), V !== void 0 && O) {
659
- const g = t.timeScale().timeToCoordinate(p), M = O.priceToCoordinate(V);
666
+ if (Ce(X), k !== void 0 && O) {
667
+ const g = t.timeScale().timeToCoordinate(m), M = O.priceToCoordinate(k);
660
668
  if (g !== null && M !== null) {
661
669
  const T = B.current;
662
670
  if (T) {
@@ -664,8 +672,8 @@ function to({
664
672
  ".LightweightChart"
665
673
  );
666
674
  if (G) {
667
- const C = G.getBoundingClientRect(), j = T.getBoundingClientRect(), n = g + (C.left - j.left), o = M + (C.top - j.top);
668
- Q({ x: n, y: o });
675
+ const C = G.getBoundingClientRect(), Z = T.getBoundingClientRect(), U = g + (C.left - Z.left), i = M + (C.top - Z.top);
676
+ Q({ x: U, y: i });
669
677
  } else
670
678
  Q({ x: g, y: M });
671
679
  } else
@@ -675,252 +683,252 @@ function to({
675
683
  } else
676
684
  Q(null);
677
685
  };
678
- return t.subscribeCrosshairMove(s), R && t.subscribeClick(s), !l && !Z && !ge && requestAnimationFrame(() => {
679
- const a = e[0], p = a ? N.current.get(ne(a)) : void 0;
680
- if (p && r && a.data.length > 0) {
681
- const y = t.timeScale().timeToCoordinate(r), x = a.data[a.data.length - 1].value, v = p.priceToCoordinate(x);
686
+ return t.subscribeCrosshairMove(l), R && t.subscribeClick(l), !s && !K && !be && requestAnimationFrame(() => {
687
+ const a = e[0], m = a ? V.current.get(ie(a)) : void 0;
688
+ if (m && r && a.data.length > 0) {
689
+ const y = t.timeScale().timeToCoordinate(r), x = a.data[a.data.length - 1].value, v = m.priceToCoordinate(x);
682
690
  y !== null && v !== null && Q({ x: y, y: v });
683
691
  }
684
692
  }), () => {
685
- t.unsubscribeCrosshairMove(s), R && t.unsubscribeClick(s);
693
+ t.unsubscribeCrosshairMove(l), R && t.unsubscribeClick(l);
686
694
  };
687
- }, [e, Z, R, ge]), W(() => {
695
+ }, [e, K, R, be]), W(() => {
688
696
  const t = I.current;
689
697
  if (!t || e.length === 0) return;
690
- const l = t.timeScale(), r = () => {
691
- const s = Le.current;
692
- if (s.length === 0) return;
693
- const a = l.getVisibleRange();
698
+ const s = t.timeScale(), r = () => {
699
+ const l = Me.current;
700
+ if (l.length === 0) return;
701
+ const a = s.getVisibleRange();
694
702
  if (!a) return;
695
- const p = Number(a.from), m = Number(a.to);
696
- for (const y of s) {
703
+ const m = Number(a.from), p = Number(a.to);
704
+ for (const y of l) {
697
705
  const x = [];
698
706
  for (const v of e)
699
707
  if (y.labels.has(v.label))
700
708
  for (const X of v.data) {
701
- const V = Number(X.time);
702
- V >= p && V <= m && x.push(X.value);
709
+ const k = Number(X.time);
710
+ k >= m && k <= p && x.push(X.value);
703
711
  }
704
712
  x.length > 0 && y.updateVisibleRange(x);
705
713
  }
706
714
  };
707
- return l.subscribeVisibleLogicalRangeChange(r), () => {
708
- l.unsubscribeVisibleLogicalRangeChange(
715
+ return s.subscribeVisibleLogicalRangeChange(r), () => {
716
+ s.unsubscribeVisibleLogicalRangeChange(
709
717
  r
710
718
  );
711
719
  };
712
720
  }, [e]), W(() => {
713
- const t = I.current, l = Array.from(N.current.values()), r = [];
714
- if (t && l.length > 0 && P) {
715
- const s = St(), a = l[0];
716
- for (const p of P) {
717
- const m = {
718
- ...s,
719
- ...p.options || {}
721
+ const t = I.current, s = Array.from(V.current.values()), r = [];
722
+ if (t && s.length > 0 && P) {
723
+ const l = vt(), a = s[0];
724
+ for (const m of P) {
725
+ const p = {
726
+ ...l,
727
+ ...m.options || {}
720
728
  };
721
- m.color && (m.color = re(m.color, m.color));
722
- const y = new _t(
729
+ p.color && (p.color = ne(p.color, p.color));
730
+ const y = new Pt(
723
731
  t,
724
732
  a,
725
- p.xCoordinate,
726
- m
733
+ m.xCoordinate,
734
+ p
727
735
  );
728
736
  a.attachPrimitive(y), r.push(y);
729
737
  }
730
738
  }
731
739
  return () => {
732
- if (l.length > 0) {
733
- const s = l[0];
740
+ if (s.length > 0) {
741
+ const l = s[0];
734
742
  for (const a of r)
735
743
  try {
736
- s.detachPrimitive(a);
744
+ l.detachPrimitive(a);
737
745
  } catch {
738
746
  }
739
747
  }
740
748
  };
741
749
  }, [P, e, Y]), W(() => {
742
- const t = [], l = [];
750
+ const t = [], s = [];
743
751
  if (D && D.length > 0) {
744
- const r = re(
752
+ const r = ne(
745
753
  "hsl(var(--destructive))",
746
754
  "rgb(239, 68, 68)"
747
755
  );
748
- for (const s of D) {
749
- if (!Number.isFinite(s.price)) continue;
750
- const a = Je(
751
- N.current,
756
+ for (const l of D) {
757
+ if (!Number.isFinite(l.price)) continue;
758
+ const a = Qe(
759
+ V.current,
752
760
  e,
753
- s.seriesLabel
761
+ l.seriesLabel
754
762
  );
755
763
  if (!a) continue;
756
- const p = s.color ? re(s.color, s.color) : r, m = s.lineWidth ?? 1, y = s.lineStyle ?? ie.Dashed, x = a.createPriceLine({
757
- price: s.price,
758
- color: p,
759
- lineWidth: m,
764
+ const m = l.color ? ne(l.color, l.color) : r, p = l.lineWidth ?? 1, y = l.lineStyle ?? le.Dashed, x = a.createPriceLine({
765
+ price: l.price,
766
+ color: m,
767
+ lineWidth: p,
760
768
  lineStyle: y,
761
- axisLabelVisible: s.axisLabelVisible ?? !0,
762
- title: s.title ?? ""
769
+ axisLabelVisible: l.axisLabelVisible ?? !0,
770
+ title: l.title ?? ""
763
771
  });
764
772
  t.push({ series: a, line: x });
765
- const v = new Bt(
773
+ const v = new Et(
766
774
  a,
767
- s.price,
768
- p,
775
+ l.price,
769
776
  m,
777
+ p,
770
778
  y
771
779
  );
772
- a.attachPrimitive(v), l.push({ series: a, primitive: v });
780
+ a.attachPrimitive(v), s.push({ series: a, primitive: v });
773
781
  }
774
782
  }
775
783
  return () => {
776
- for (const { series: r, primitive: s } of l)
784
+ for (const { series: r, primitive: l } of s)
777
785
  try {
778
- r.detachPrimitive(s);
786
+ r.detachPrimitive(l);
779
787
  } catch {
780
788
  }
781
- for (const { series: r, line: s } of t)
789
+ for (const { series: r, line: l } of t)
782
790
  try {
783
- r.removePriceLine(s);
791
+ r.removePriceLine(l);
784
792
  } catch {
785
793
  }
786
794
  };
787
795
  }, [D, e, Y]), W(() => {
788
796
  const t = [];
789
797
  if (F && F.length > 0) {
790
- const l = "rgba(239, 68, 68, 0.12)";
798
+ const s = "rgba(239, 68, 68, 0.12)";
791
799
  for (const r of F) {
792
- const s = Je(
793
- N.current,
800
+ const l = Qe(
801
+ V.current,
794
802
  e,
795
803
  r.seriesLabel
796
804
  );
797
- if (!s) continue;
798
- const a = r.color ? re(r.color, l) : l, p = new Lt(
799
- s,
805
+ if (!l) continue;
806
+ const a = r.color ? ne(r.color, s) : s, m = new Mt(
807
+ l,
800
808
  r.priceTop,
801
809
  r.priceBottom,
802
810
  a
803
811
  );
804
- s.attachPrimitive(p), t.push({ series: s, zone: p });
812
+ l.attachPrimitive(m), t.push({ series: l, zone: m });
805
813
  }
806
814
  }
807
815
  return () => {
808
- for (const { series: l, zone: r } of t)
816
+ for (const { series: s, zone: r } of t)
809
817
  try {
810
- l.detachPrimitive(r);
818
+ s.detachPrimitive(r);
811
819
  } catch {
812
820
  }
813
821
  };
814
822
  }, [F, e, Y]), W(() => {
815
823
  const t = I.current;
816
824
  if (!t || !P?.length) {
817
- Ee([]);
825
+ Fe([]);
818
826
  return;
819
827
  }
820
- const l = () => {
821
- const a = t.timeScale(), p = P.map((m) => a.timeToCoordinate(m.xCoordinate) ?? null);
822
- Ee(p), B.current && Fe(B.current.clientWidth);
828
+ const s = () => {
829
+ const a = t.timeScale(), m = P.map((p) => a.timeToCoordinate(p.xCoordinate) ?? null);
830
+ Fe(m), B.current && ze(B.current.clientWidth);
823
831
  };
824
- l();
825
- const r = t.timeScale(), s = () => {
826
- l();
832
+ s();
833
+ const r = t.timeScale(), l = () => {
834
+ s();
827
835
  };
828
- return r.subscribeVisibleLogicalRangeChange(s), () => {
829
- r.unsubscribeVisibleLogicalRangeChange(s);
836
+ return r.subscribeVisibleLogicalRangeChange(l), () => {
837
+ r.unsubscribeVisibleLogicalRangeChange(l);
830
838
  };
831
839
  }, [P, e, Y]), pt(() => {
832
- ot((t) => {
833
- const l = {};
840
+ rt((t) => {
841
+ const s = {};
834
842
  let r = !1;
835
- for (const [s, a] of ze.current) {
843
+ for (const [l, a] of Ae.current) {
836
844
  if (!a) continue;
837
- const p = a.offsetWidth;
838
- l[s] = p, t[s] !== p && (r = !0);
845
+ const m = a.offsetWidth;
846
+ s[l] = m, t[l] !== m && (r = !0);
839
847
  }
840
- return Object.keys(t).length !== Object.keys(l).length && (r = !0), r ? l : t;
848
+ return Object.keys(t).length !== Object.keys(s).length && (r = !0), r ? s : t;
841
849
  });
842
850
  });
843
- const fe = e.length === 1, Ae = we.useMemo(() => {
844
- if (fe && e.length > 0) {
851
+ const he = e.length === 1, We = _e.useMemo(() => {
852
+ if (he && e.length > 0) {
845
853
  const t = e[0];
846
854
  if (t.data.length > 0)
847
855
  return t.data[t.data.length - 1];
848
856
  }
849
- }, [fe, e]);
850
- return /* @__PURE__ */ U(
857
+ }, [he, e]);
858
+ return /* @__PURE__ */ ee(
851
859
  "div",
852
860
  {
853
861
  ref: B,
854
862
  className: J(
855
863
  "relative z-[1] w-full h-full overflow-hidden p-0",
856
- i
864
+ n
857
865
  ),
858
866
  children: [
859
- me != null && me !== !1 && fe ? /* @__PURE__ */ _("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ _("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: me }) }) : Oe && fe && Ae && /* @__PURE__ */ _(
860
- xt,
867
+ ge != null && ge !== !1 && he ? /* @__PURE__ */ _("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ _("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: ge }) }) : Ue && he && We && /* @__PURE__ */ _(
868
+ wt,
861
869
  {
862
- point: Ae,
870
+ point: We,
863
871
  xMeasureUnit: h,
864
872
  yMeasureUnit: u,
865
873
  decimals: se
866
874
  }
867
875
  ),
868
- De && Ie && /* @__PURE__ */ _(
869
- wt,
876
+ Ie && Be && /* @__PURE__ */ _(
877
+ _t,
870
878
  {
871
- points: De,
879
+ points: Ie,
872
880
  xMeasureUnit: h,
873
881
  yMeasureUnit: u,
874
882
  series: e,
875
- position: Ie,
883
+ position: Be,
876
884
  containerRef: B,
877
885
  decimals: se
878
886
  }
879
887
  ),
880
- c && /* @__PURE__ */ _(At, { series: e, onUnselect: f }),
881
- P && P.length > 0 && Be.length === P.length && /* @__PURE__ */ _(
888
+ c && /* @__PURE__ */ _(Wt, { series: e, onUnselect: f }),
889
+ P && P.length > 0 && Ee.length === P.length && /* @__PURE__ */ _(
882
890
  "div",
883
891
  {
884
892
  className: "absolute inset-0 z-[5] pointer-events-none",
885
893
  "aria-hidden": !0,
886
- children: P.map((t, l) => {
887
- const r = Be[l], s = t.options ?? {};
894
+ children: P.map((t, s) => {
895
+ const r = Ee[s], l = t.options ?? {};
888
896
  if (r === null) return null;
889
- const { labelText: a, valueStr: p } = Et(
890
- s,
897
+ const { labelText: a, valueStr: m } = Ft(
898
+ l,
891
899
  u,
892
900
  se
893
- ), m = s.tooltipText ?? "";
894
- if (!(a || p || m)) return null;
895
- const x = s.labelBackgroundColor ?? s.color ?? "hsl(var(--background))", v = s.labelTextColor ?? "hsl(var(--foreground))", X = `${String(t.xCoordinate)}-${a}-${m}`, V = Ft(
901
+ ), p = l.tooltipText ?? "";
902
+ if (!(a || m || p)) return null;
903
+ const x = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", v = l.labelTextColor ?? "hsl(var(--foreground))", X = `${String(t.xCoordinate)}-${a}-${p}`, k = zt(
896
904
  r,
897
- et,
898
- tt[l]
905
+ tt,
906
+ ot[s]
899
907
  );
900
- return /* @__PURE__ */ U(
908
+ return /* @__PURE__ */ ee(
901
909
  "div",
902
910
  {
903
911
  ref: (O) => {
904
- ze.current.set(l, O);
912
+ Ae.current.set(s, O);
905
913
  },
906
914
  className: J(
907
915
  "group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
908
- m && "pointer-events-auto cursor-default"
916
+ p && "pointer-events-auto cursor-default"
909
917
  ),
910
918
  style: {
911
- ...V,
919
+ ...k,
912
920
  backgroundColor: x,
913
921
  color: v
914
922
  },
915
923
  children: [
916
924
  a && /* @__PURE__ */ _("span", { className: "block", children: a }),
917
- p && /* @__PURE__ */ _("span", { className: J("block", a && "mt-0.5"), children: p }),
918
- m && /* @__PURE__ */ _(
925
+ m && /* @__PURE__ */ _("span", { className: J("block", a && "mt-0.5"), children: m }),
926
+ p && /* @__PURE__ */ _(
919
927
  "span",
920
928
  {
921
929
  className: "pointer-events-none absolute right-0 top-full z-10 mt-1 hidden w-[280px] whitespace-normal rounded border border-border bg-popover px-2.5 py-1.5 text-left leading-snug text-popover-foreground shadow-md group-hover:block",
922
930
  role: "tooltip",
923
- children: m
931
+ children: p
924
932
  }
925
933
  )
926
934
  ]
@@ -933,7 +941,7 @@ function to({
933
941
  /* @__PURE__ */ _(
934
942
  "div",
935
943
  {
936
- ref: Se,
944
+ ref: ve,
937
945
  className: "LightweightChart w-full h-full overflow-hidden"
938
946
  }
939
947
  )
@@ -941,14 +949,14 @@ function to({
941
949
  }
942
950
  );
943
951
  }
944
- function At({
952
+ function Wt({
945
953
  series: e,
946
- markers: i,
954
+ markers: n,
947
955
  onUnselect: c,
948
956
  inline: f = !1
949
957
  }) {
950
958
  const h = e.every((u) => u.data.length === 0);
951
- return /* @__PURE__ */ U(
959
+ return /* @__PURE__ */ ee(
952
960
  "div",
953
961
  {
954
962
  className: J(
@@ -957,8 +965,8 @@ function At({
957
965
  ),
958
966
  children: [
959
967
  e.map((u, S) => {
960
- const P = Ye(S), D = (u.lineColor ?? u.color) || P.line, F = !h && u.data.length === 0;
961
- return /* @__PURE__ */ U(
968
+ const P = Oe(S), D = (u.lineColor ?? u.color) || P.line, F = !h && u.data.length === 0;
969
+ return /* @__PURE__ */ ee(
962
970
  "div",
963
971
  {
964
972
  className: J(
@@ -977,7 +985,7 @@ function At({
977
985
  style: { backgroundColor: D }
978
986
  }
979
987
  ),
980
- /* @__PURE__ */ U(
988
+ /* @__PURE__ */ ee(
981
989
  "span",
982
990
  {
983
991
  className: J(
@@ -999,7 +1007,7 @@ function At({
999
1007
  },
1000
1008
  className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
1001
1009
  "aria-label": `Remove ${u.label}`,
1002
- children: /* @__PURE__ */ U(
1010
+ children: /* @__PURE__ */ ee(
1003
1011
  "svg",
1004
1012
  {
1005
1013
  xmlns: "http://www.w3.org/2000/svg",
@@ -1027,7 +1035,7 @@ function At({
1027
1035
  u.id ?? u.label
1028
1036
  );
1029
1037
  }),
1030
- i?.map((u) => /* @__PURE__ */ U(
1038
+ n?.map((u) => /* @__PURE__ */ ee(
1031
1039
  "div",
1032
1040
  {
1033
1041
  className: J(
@@ -1061,12 +1069,12 @@ function At({
1061
1069
  );
1062
1070
  }
1063
1071
  export {
1064
- to as Graph,
1065
- At as GraphLegend,
1066
- Qe as VERTICAL_LINE_LABEL_EDGE_PADDING,
1067
- zt as getStepForwardValue,
1068
- Ft as getVerticalLineLabelStyle,
1069
- Et as getVerticalLineTooltipContent,
1070
- ne as seriesIdentity,
1071
- Nt as visibleLogicalRangeFor
1072
+ oo as Graph,
1073
+ Wt as GraphLegend,
1074
+ Ye as VERTICAL_LINE_LABEL_EDGE_PADDING,
1075
+ At as getStepForwardValue,
1076
+ zt as getVerticalLineLabelStyle,
1077
+ Ft as getVerticalLineTooltipContent,
1078
+ ie as seriesIdentity,
1079
+ Vt as visibleLogicalRangeFor
1072
1080
  };