@gearbox-protocol/ui-kit 4.4.1 → 4.5.1

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), N = 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, N.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,70 +300,70 @@ 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: k, tickmarksFormatter: L, 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: k, tickmarksFormatter: L, 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
- 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);
323
+ let k = u;
324
+ for (const L of e)
325
+ if (L.data.length !== 0 && a.get(L.label) === i) {
326
+ o.size === 0 && L.yMeasureUnit && (k = L.yMeasureUnit), o.add(L.label);
327
+ for (const E of L.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, k, 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, V = 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 || {},
@@ -378,124 +378,124 @@ function to({
378
378
  textColor: V
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(N.current.keys()), $ = new Set(e.map(ie));
382
+ for (const i of O)
383
+ if (!$.has(i)) {
384
+ const o = N.current.get(i);
385
+ o && (t.removeSeries(o), N.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), k = Oe(i), L = o.lineColor ?? o.color ?? k.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(L);
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(L).topColor, q = o.bottomColor;
416
416
  else {
417
- const b = _e(k);
417
+ const b = Pe(L);
418
418
  E = b.topColor, q = b.bottomColor;
419
419
  }
420
420
  else
421
- E = o.topColor || L.top, q = o.bottomColor || L.bottom;
421
+ E = o.topColor || k.top, q = o.bottomColor || k.bottom;
422
422
  if (o.data.length === 0) {
423
423
  const b = N.current.get(d);
424
424
  b && (t.removeSeries(b), N.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: L,
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
+ lineStyle: o.lineStyle ?? le.Solid
466
466
  },
467
467
  priceFormat: {
468
468
  type: "custom",
469
- minMove: We,
470
- formatter: Ce && typeof r == "number" ? (b) => Ge(
469
+ minMove: Xe,
470
+ formatter: ye && typeof r == "number" ? (b) => je(
471
471
  b < r ? r : b
472
- ) : Ge,
473
- tickmarksFormatter: ct
472
+ ) : je,
473
+ tickmarksFormatter: ut
474
474
  },
475
- autoscaleInfoProvider: at
476
- }, je = o.seriesType === "line";
475
+ autoscaleInfoProvider: ct
476
+ }, He = o.seriesType === "line";
477
477
  let A = N.current.get(d);
478
- const ee = o.data.map((b) => ({
478
+ const te = o.data.map((b) => ({
479
479
  ...b,
480
480
  time: b.time
481
481
  }));
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);
482
+ if (ae !== void 0 && te.length > 0 && Number(te[0].time) > ae) {
483
+ const b = Number(te[0].time), w = b - ae, oe = 86400, me = w > 180 * oe ? 7 * oe : w > 30 * oe ? oe : 6 * 3600, j = [];
484
+ for (let we = ae; we < b; we += me)
485
+ j.push({ time: we });
486
+ te.unshift(...j);
487
487
  }
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, {
488
+ A && A.seriesType() !== (He ? "Line" : "Area") && (t.removeSeries(A), N.current.delete(d), A = void 0), A ? (A.applyOptions(xe), A.setData(te)) : (He ? A = t.addSeries(dt, {
489
489
  ...g,
490
- ...ye
491
- }) : A = t.addSeries(dt, {
490
+ ...xe
491
+ }) : A = t.addSeries(mt, {
492
492
  ...g,
493
- ...ye
494
- }), A.setData(ee), N.current.set(d, A)), T++;
493
+ ...xe
494
+ }), A.setData(te), N.current.set(d, A)), T++;
495
495
  }
496
496
  if (z)
497
497
  try {
498
- const n = t.priceScale("left"), o = t.priceScale("right"), d = {
498
+ const i = t.priceScale("left"), o = t.priceScale("right"), d = {
499
499
  visible: !R,
500
500
  autoScale: !0,
501
501
  scaleMargins: { top: 0, bottom: 0 },
@@ -505,13 +505,13 @@ function to({
505
505
  textColor: V,
506
506
  ...S?.rightPriceScale
507
507
  };
508
- n?.applyOptions(d), o?.applyOptions(d);
508
+ i?.applyOptions(d), o?.applyOptions(d);
509
509
  } catch {
510
510
  }
511
511
  else if (v && M.length > 0)
512
- for (const n of M)
512
+ for (const i of M)
513
513
  try {
514
- const o = t.priceScale(n.priceScaleId);
514
+ const o = t.priceScale(i.priceScaleId);
515
515
  o && o.applyOptions({
516
516
  visible: !1,
517
517
  autoScale: !0,
@@ -526,14 +526,14 @@ function to({
526
526
  });
527
527
  } catch (o) {
528
528
  console.warn(
529
- `Failed to configure price scale ${n.priceScaleId} for series ${n.seriesIndex}:`,
529
+ `Failed to configure price scale ${i.priceScaleId} for series ${i.seriesIndex}:`,
530
530
  o
531
531
  );
532
532
  }
533
533
  else if (!v)
534
534
  try {
535
- const n = t.priceScale("right");
536
- n && n.applyOptions({
535
+ const i = t.priceScale("right");
536
+ i && i.applyOptions({
537
537
  visible: !R,
538
538
  autoScale: !0,
539
539
  scaleMargins: {
@@ -548,34 +548,41 @@ function to({
548
548
  });
549
549
  } catch {
550
550
  }
551
- if (r !== void 0 && !R && (Z || !v) && t.applyOptions({
551
+ r !== void 0 && !R && (K || !v) && t.applyOptions({
552
552
  handleScroll: {
553
553
  vertTouchDrag: !1
554
554
  }
555
- }), ce.length > 0) {
556
- const n = ce.map((d) => Number(d.time)).filter((d) => Number.isFinite(d)), o = new Set(n).size - 1;
555
+ });
556
+ let Z = 0;
557
+ if (ue.length > 0) {
558
+ const i = ue.map((d) => Number(d.time)).filter((d) => Number.isFinite(d)), o = new Set(i).size - 1;
557
559
  if (o >= 0) {
558
560
  const d = () => {
559
- const L = t.timeScale();
561
+ const k = t.timeScale();
560
562
  if (h !== "time") {
561
- L.applyOptions({
563
+ k.applyOptions({
562
564
  fixLeftEdge: !0,
563
565
  fixRightEdge: !0
564
- }), L.setVisibleLogicalRange({ from: 0, to: o });
566
+ }), k.setVisibleLogicalRange({ from: 0, to: o });
565
567
  return;
566
568
  }
567
- const k = z && !R, E = z ? !R : !X, q = !k, ue = !E;
568
- L.applyOptions({
569
+ const L = z && !R, E = z ? !R : !X, q = !L, fe = !E;
570
+ k.applyOptions({
569
571
  fixLeftEdge: !q,
570
- fixRightEdge: !ue
571
- });
572
- const he = Nt({
573
- lastIndex: o,
574
- width: L.width(),
575
- padLeft: q,
576
- padRight: ue
572
+ fixRightEdge: !fe
573
+ }), Z = requestAnimationFrame(() => {
574
+ const de = Vt({
575
+ lastIndex: o,
576
+ width: k.width(),
577
+ padLeft: q,
578
+ padRight: fe
579
+ });
580
+ try {
581
+ de && k.setVisibleLogicalRange(de);
582
+ } catch {
583
+ k.fitContent();
584
+ }
577
585
  });
578
- he && L.setVisibleLogicalRange(he);
579
586
  };
580
587
  try {
581
588
  d();
@@ -587,31 +594,31 @@ function to({
587
594
  }
588
595
  }
589
596
  }
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);
597
+ Le.current && (Le.current = !1), S && t.applyOptions(S);
598
+ const U = /* @__PURE__ */ new Map();
599
+ for (const i of e)
600
+ i.data.length > 0 && U.set(i.label, i.data[i.data.length - 1]);
601
+ return Ce(U.size > 0 ? U : void 0), () => cancelAnimationFrame(Z);
595
602
  }, [
596
603
  Y,
597
604
  e,
598
- ce,
605
+ ue,
599
606
  h,
600
607
  u,
601
608
  R,
602
- Z,
609
+ K,
603
610
  z,
604
- Re,
605
611
  Te,
606
612
  Ne,
607
- le,
613
+ Ve,
614
+ ae,
608
615
  D,
609
616
  F,
610
617
  S
611
618
  ]), W(() => {
612
619
  const t = I.current;
613
620
  if (!t || e.length === 0) return;
614
- const l = e.length === 1;
621
+ const s = e.length === 1;
615
622
  let r;
616
623
  for (const a of e)
617
624
  if (a.data.length > 0) {
@@ -619,13 +626,13 @@ function to({
619
626
  break;
620
627
  }
621
628
  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) {
629
+ const l = (a) => {
630
+ const { time: m = r, seriesData: p, point: y } = a || {}, x = e[0], v = x ? N.current.get(ie(x)) : void 0;
631
+ if (!y || !m) {
625
632
  const $ = /* @__PURE__ */ new Map();
626
633
  for (const g of e)
627
634
  g.data.length > 0 && $.set(g.label, g.data[g.data.length - 1]);
628
- if (ve($.size > 0 ? $ : void 0), l || Z || ge)
635
+ if (Ce($.size > 0 ? $ : void 0), s || K || be)
629
636
  Q(null);
630
637
  else if (v && r) {
631
638
  const g = e[0];
@@ -639,24 +646,24 @@ function to({
639
646
  const X = /* @__PURE__ */ new Map();
640
647
  let V, O = v;
641
648
  for (let $ = 0; $ < e.length; $++) {
642
- const g = e[$], M = N.current.get(ne(g));
649
+ const g = e[$], M = N.current.get(ie(g));
643
650
  if (!M) continue;
644
- const T = m?.get(M), G = T && "value" in T ? T.value : void 0;
651
+ const T = p?.get(M), G = T && "value" in T ? T.value : void 0;
645
652
  let C;
646
653
  if (G !== void 0)
647
654
  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;
655
+ else if (s) {
656
+ const Z = Number(m), U = g.data.length > 0 ? Number(g.data[0].time) : Number.POSITIVE_INFINITY;
657
+ Z < U ? C = Number.NaN : C = g.data[g.data.length - 1]?.value ?? 0;
651
658
  } 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));
659
+ const Z = g.data.length > 0 ? Number(g.data[0].time) : Number.POSITIVE_INFINITY;
660
+ if (Number(m) < Z) continue;
661
+ C = At(g.data, Number(m));
655
662
  }
656
- Number.isNaN(C) || (V === void 0 && (V = C, O = M), X.set(g.label, { value: C, time: p }));
663
+ Number.isNaN(C) || (V === void 0 && (V = C, O = M), X.set(g.label, { value: C, time: m }));
657
664
  }
658
- if (ve(X), V !== void 0 && O) {
659
- const g = t.timeScale().timeToCoordinate(p), M = O.priceToCoordinate(V);
665
+ if (Ce(X), V !== void 0 && O) {
666
+ const g = t.timeScale().timeToCoordinate(m), M = O.priceToCoordinate(V);
660
667
  if (g !== null && M !== null) {
661
668
  const T = B.current;
662
669
  if (T) {
@@ -664,8 +671,8 @@ function to({
664
671
  ".LightweightChart"
665
672
  );
666
673
  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 });
674
+ const C = G.getBoundingClientRect(), Z = T.getBoundingClientRect(), U = g + (C.left - Z.left), i = M + (C.top - Z.top);
675
+ Q({ x: U, y: i });
669
676
  } else
670
677
  Q({ x: g, y: M });
671
678
  } else
@@ -675,237 +682,237 @@ function to({
675
682
  } else
676
683
  Q(null);
677
684
  };
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);
685
+ return t.subscribeCrosshairMove(l), R && t.subscribeClick(l), !s && !K && !be && requestAnimationFrame(() => {
686
+ const a = e[0], m = a ? N.current.get(ie(a)) : void 0;
687
+ if (m && r && a.data.length > 0) {
688
+ const y = t.timeScale().timeToCoordinate(r), x = a.data[a.data.length - 1].value, v = m.priceToCoordinate(x);
682
689
  y !== null && v !== null && Q({ x: y, y: v });
683
690
  }
684
691
  }), () => {
685
- t.unsubscribeCrosshairMove(s), R && t.unsubscribeClick(s);
692
+ t.unsubscribeCrosshairMove(l), R && t.unsubscribeClick(l);
686
693
  };
687
- }, [e, Z, R, ge]), W(() => {
694
+ }, [e, K, R, be]), W(() => {
688
695
  const t = I.current;
689
696
  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();
697
+ const s = t.timeScale(), r = () => {
698
+ const l = Me.current;
699
+ if (l.length === 0) return;
700
+ const a = s.getVisibleRange();
694
701
  if (!a) return;
695
- const p = Number(a.from), m = Number(a.to);
696
- for (const y of s) {
702
+ const m = Number(a.from), p = Number(a.to);
703
+ for (const y of l) {
697
704
  const x = [];
698
705
  for (const v of e)
699
706
  if (y.labels.has(v.label))
700
707
  for (const X of v.data) {
701
708
  const V = Number(X.time);
702
- V >= p && V <= m && x.push(X.value);
709
+ V >= m && V <= p && x.push(X.value);
703
710
  }
704
711
  x.length > 0 && y.updateVisibleRange(x);
705
712
  }
706
713
  };
707
- return l.subscribeVisibleLogicalRangeChange(r), () => {
708
- l.unsubscribeVisibleLogicalRangeChange(
714
+ return s.subscribeVisibleLogicalRangeChange(r), () => {
715
+ s.unsubscribeVisibleLogicalRangeChange(
709
716
  r
710
717
  );
711
718
  };
712
719
  }, [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 || {}
720
+ const t = I.current, s = Array.from(N.current.values()), r = [];
721
+ if (t && s.length > 0 && P) {
722
+ const l = vt(), a = s[0];
723
+ for (const m of P) {
724
+ const p = {
725
+ ...l,
726
+ ...m.options || {}
720
727
  };
721
- m.color && (m.color = re(m.color, m.color));
722
- const y = new _t(
728
+ p.color && (p.color = ne(p.color, p.color));
729
+ const y = new Pt(
723
730
  t,
724
731
  a,
725
- p.xCoordinate,
726
- m
732
+ m.xCoordinate,
733
+ p
727
734
  );
728
735
  a.attachPrimitive(y), r.push(y);
729
736
  }
730
737
  }
731
738
  return () => {
732
- if (l.length > 0) {
733
- const s = l[0];
739
+ if (s.length > 0) {
740
+ const l = s[0];
734
741
  for (const a of r)
735
742
  try {
736
- s.detachPrimitive(a);
743
+ l.detachPrimitive(a);
737
744
  } catch {
738
745
  }
739
746
  }
740
747
  };
741
748
  }, [P, e, Y]), W(() => {
742
- const t = [], l = [];
749
+ const t = [], s = [];
743
750
  if (D && D.length > 0) {
744
- const r = re(
751
+ const r = ne(
745
752
  "hsl(var(--destructive))",
746
753
  "rgb(239, 68, 68)"
747
754
  );
748
- for (const s of D) {
749
- if (!Number.isFinite(s.price)) continue;
750
- const a = Je(
755
+ for (const l of D) {
756
+ if (!Number.isFinite(l.price)) continue;
757
+ const a = Qe(
751
758
  N.current,
752
759
  e,
753
- s.seriesLabel
760
+ l.seriesLabel
754
761
  );
755
762
  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,
763
+ const m = l.color ? ne(l.color, l.color) : r, p = l.lineWidth ?? 1, y = l.lineStyle ?? le.Dashed, x = a.createPriceLine({
764
+ price: l.price,
765
+ color: m,
766
+ lineWidth: p,
760
767
  lineStyle: y,
761
- axisLabelVisible: s.axisLabelVisible ?? !0,
762
- title: s.title ?? ""
768
+ axisLabelVisible: l.axisLabelVisible ?? !0,
769
+ title: l.title ?? ""
763
770
  });
764
771
  t.push({ series: a, line: x });
765
- const v = new Bt(
772
+ const v = new Et(
766
773
  a,
767
- s.price,
768
- p,
774
+ l.price,
769
775
  m,
776
+ p,
770
777
  y
771
778
  );
772
- a.attachPrimitive(v), l.push({ series: a, primitive: v });
779
+ a.attachPrimitive(v), s.push({ series: a, primitive: v });
773
780
  }
774
781
  }
775
782
  return () => {
776
- for (const { series: r, primitive: s } of l)
783
+ for (const { series: r, primitive: l } of s)
777
784
  try {
778
- r.detachPrimitive(s);
785
+ r.detachPrimitive(l);
779
786
  } catch {
780
787
  }
781
- for (const { series: r, line: s } of t)
788
+ for (const { series: r, line: l } of t)
782
789
  try {
783
- r.removePriceLine(s);
790
+ r.removePriceLine(l);
784
791
  } catch {
785
792
  }
786
793
  };
787
794
  }, [D, e, Y]), W(() => {
788
795
  const t = [];
789
796
  if (F && F.length > 0) {
790
- const l = "rgba(239, 68, 68, 0.12)";
797
+ const s = "rgba(239, 68, 68, 0.12)";
791
798
  for (const r of F) {
792
- const s = Je(
799
+ const l = Qe(
793
800
  N.current,
794
801
  e,
795
802
  r.seriesLabel
796
803
  );
797
- if (!s) continue;
798
- const a = r.color ? re(r.color, l) : l, p = new Lt(
799
- s,
804
+ if (!l) continue;
805
+ const a = r.color ? ne(r.color, s) : s, m = new Mt(
806
+ l,
800
807
  r.priceTop,
801
808
  r.priceBottom,
802
809
  a
803
810
  );
804
- s.attachPrimitive(p), t.push({ series: s, zone: p });
811
+ l.attachPrimitive(m), t.push({ series: l, zone: m });
805
812
  }
806
813
  }
807
814
  return () => {
808
- for (const { series: l, zone: r } of t)
815
+ for (const { series: s, zone: r } of t)
809
816
  try {
810
- l.detachPrimitive(r);
817
+ s.detachPrimitive(r);
811
818
  } catch {
812
819
  }
813
820
  };
814
821
  }, [F, e, Y]), W(() => {
815
822
  const t = I.current;
816
823
  if (!t || !P?.length) {
817
- Ee([]);
824
+ Fe([]);
818
825
  return;
819
826
  }
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);
827
+ const s = () => {
828
+ const a = t.timeScale(), m = P.map((p) => a.timeToCoordinate(p.xCoordinate) ?? null);
829
+ Fe(m), B.current && ze(B.current.clientWidth);
823
830
  };
824
- l();
825
- const r = t.timeScale(), s = () => {
826
- l();
831
+ s();
832
+ const r = t.timeScale(), l = () => {
833
+ s();
827
834
  };
828
- return r.subscribeVisibleLogicalRangeChange(s), () => {
829
- r.unsubscribeVisibleLogicalRangeChange(s);
835
+ return r.subscribeVisibleLogicalRangeChange(l), () => {
836
+ r.unsubscribeVisibleLogicalRangeChange(l);
830
837
  };
831
838
  }, [P, e, Y]), pt(() => {
832
- ot((t) => {
833
- const l = {};
839
+ rt((t) => {
840
+ const s = {};
834
841
  let r = !1;
835
- for (const [s, a] of ze.current) {
842
+ for (const [l, a] of Ae.current) {
836
843
  if (!a) continue;
837
- const p = a.offsetWidth;
838
- l[s] = p, t[s] !== p && (r = !0);
844
+ const m = a.offsetWidth;
845
+ s[l] = m, t[l] !== m && (r = !0);
839
846
  }
840
- return Object.keys(t).length !== Object.keys(l).length && (r = !0), r ? l : t;
847
+ return Object.keys(t).length !== Object.keys(s).length && (r = !0), r ? s : t;
841
848
  });
842
849
  });
843
- const fe = e.length === 1, Ae = we.useMemo(() => {
844
- if (fe && e.length > 0) {
850
+ const he = e.length === 1, We = _e.useMemo(() => {
851
+ if (he && e.length > 0) {
845
852
  const t = e[0];
846
853
  if (t.data.length > 0)
847
854
  return t.data[t.data.length - 1];
848
855
  }
849
- }, [fe, e]);
850
- return /* @__PURE__ */ U(
856
+ }, [he, e]);
857
+ return /* @__PURE__ */ ee(
851
858
  "div",
852
859
  {
853
860
  ref: B,
854
861
  className: J(
855
862
  "relative z-[1] w-full h-full overflow-hidden p-0",
856
- i
863
+ n
857
864
  ),
858
865
  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,
866
+ 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__ */ _(
867
+ wt,
861
868
  {
862
- point: Ae,
869
+ point: We,
863
870
  xMeasureUnit: h,
864
871
  yMeasureUnit: u,
865
872
  decimals: se
866
873
  }
867
874
  ),
868
- De && Ie && /* @__PURE__ */ _(
869
- wt,
875
+ Ie && Be && /* @__PURE__ */ _(
876
+ _t,
870
877
  {
871
- points: De,
878
+ points: Ie,
872
879
  xMeasureUnit: h,
873
880
  yMeasureUnit: u,
874
881
  series: e,
875
- position: Ie,
882
+ position: Be,
876
883
  containerRef: B,
877
884
  decimals: se
878
885
  }
879
886
  ),
880
- c && /* @__PURE__ */ _(At, { series: e, onUnselect: f }),
881
- P && P.length > 0 && Be.length === P.length && /* @__PURE__ */ _(
887
+ c && /* @__PURE__ */ _(Wt, { series: e, onUnselect: f }),
888
+ P && P.length > 0 && Ee.length === P.length && /* @__PURE__ */ _(
882
889
  "div",
883
890
  {
884
891
  className: "absolute inset-0 z-[5] pointer-events-none",
885
892
  "aria-hidden": !0,
886
- children: P.map((t, l) => {
887
- const r = Be[l], s = t.options ?? {};
893
+ children: P.map((t, s) => {
894
+ const r = Ee[s], l = t.options ?? {};
888
895
  if (r === null) return null;
889
- const { labelText: a, valueStr: p } = Et(
890
- s,
896
+ const { labelText: a, valueStr: m } = Ft(
897
+ l,
891
898
  u,
892
899
  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(
900
+ ), p = l.tooltipText ?? "";
901
+ if (!(a || m || p)) return null;
902
+ const x = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", v = l.labelTextColor ?? "hsl(var(--foreground))", X = `${String(t.xCoordinate)}-${a}-${p}`, V = zt(
896
903
  r,
897
- et,
898
- tt[l]
904
+ tt,
905
+ ot[s]
899
906
  );
900
- return /* @__PURE__ */ U(
907
+ return /* @__PURE__ */ ee(
901
908
  "div",
902
909
  {
903
910
  ref: (O) => {
904
- ze.current.set(l, O);
911
+ Ae.current.set(s, O);
905
912
  },
906
913
  className: J(
907
914
  "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"
915
+ p && "pointer-events-auto cursor-default"
909
916
  ),
910
917
  style: {
911
918
  ...V,
@@ -914,13 +921,13 @@ function to({
914
921
  },
915
922
  children: [
916
923
  a && /* @__PURE__ */ _("span", { className: "block", children: a }),
917
- p && /* @__PURE__ */ _("span", { className: J("block", a && "mt-0.5"), children: p }),
918
- m && /* @__PURE__ */ _(
924
+ m && /* @__PURE__ */ _("span", { className: J("block", a && "mt-0.5"), children: m }),
925
+ p && /* @__PURE__ */ _(
919
926
  "span",
920
927
  {
921
928
  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
929
  role: "tooltip",
923
- children: m
930
+ children: p
924
931
  }
925
932
  )
926
933
  ]
@@ -933,7 +940,7 @@ function to({
933
940
  /* @__PURE__ */ _(
934
941
  "div",
935
942
  {
936
- ref: Se,
943
+ ref: ve,
937
944
  className: "LightweightChart w-full h-full overflow-hidden"
938
945
  }
939
946
  )
@@ -941,14 +948,14 @@ function to({
941
948
  }
942
949
  );
943
950
  }
944
- function At({
951
+ function Wt({
945
952
  series: e,
946
- markers: i,
953
+ markers: n,
947
954
  onUnselect: c,
948
955
  inline: f = !1
949
956
  }) {
950
957
  const h = e.every((u) => u.data.length === 0);
951
- return /* @__PURE__ */ U(
958
+ return /* @__PURE__ */ ee(
952
959
  "div",
953
960
  {
954
961
  className: J(
@@ -957,8 +964,8 @@ function At({
957
964
  ),
958
965
  children: [
959
966
  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(
967
+ const P = Oe(S), D = (u.lineColor ?? u.color) || P.line, F = !h && u.data.length === 0;
968
+ return /* @__PURE__ */ ee(
962
969
  "div",
963
970
  {
964
971
  className: J(
@@ -977,7 +984,7 @@ function At({
977
984
  style: { backgroundColor: D }
978
985
  }
979
986
  ),
980
- /* @__PURE__ */ U(
987
+ /* @__PURE__ */ ee(
981
988
  "span",
982
989
  {
983
990
  className: J(
@@ -999,7 +1006,7 @@ function At({
999
1006
  },
1000
1007
  className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
1001
1008
  "aria-label": `Remove ${u.label}`,
1002
- children: /* @__PURE__ */ U(
1009
+ children: /* @__PURE__ */ ee(
1003
1010
  "svg",
1004
1011
  {
1005
1012
  xmlns: "http://www.w3.org/2000/svg",
@@ -1027,7 +1034,7 @@ function At({
1027
1034
  u.id ?? u.label
1028
1035
  );
1029
1036
  }),
1030
- i?.map((u) => /* @__PURE__ */ U(
1037
+ n?.map((u) => /* @__PURE__ */ ee(
1031
1038
  "div",
1032
1039
  {
1033
1040
  className: J(
@@ -1061,12 +1068,12 @@ function At({
1061
1068
  );
1062
1069
  }
1063
1070
  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
1071
+ oo as Graph,
1072
+ Wt as GraphLegend,
1073
+ Ye as VERTICAL_LINE_LABEL_EDGE_PADDING,
1074
+ At as getStepForwardValue,
1075
+ zt as getVerticalLineLabelStyle,
1076
+ Ft as getVerticalLineTooltipContent,
1077
+ ie as seriesIdentity,
1078
+ Vt as visibleLogicalRangeFor
1072
1079
  };