@gearbox-protocol/ui-kit 3.14.0-next.37 → 3.14.0-next.38

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