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

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