@gearbox-protocol/ui-kit 4.0.0-next.31 → 4.0.0-next.33

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,15 +1,15 @@
1
- import { jsxs as ge, jsx as N } from "react/jsx-runtime";
1
+ import { jsxs as ge, jsx as V } from "react/jsx-runtime";
2
2
  import { createChart as ht, CrosshairMode as gt, LineStyle as ae, LineSeries as mt, AreaSeries as pt } from "lightweight-charts";
3
3
  import * as Ve from "react";
4
4
  import { useRef as K, useState as re, useEffect as A, useLayoutEffect as dt } from "react";
5
5
  import { useIsMobile as bt } from "../../hooks/use-media-query.js";
6
6
  import { cn as ee } from "../../utils/cn.js";
7
7
  import { resolveCSSColor as ne, generateColorsFromBase as ve, hslToHex as St } from "../../utils/colors.js";
8
- import { getDefaultOptions as Oe, getDefaultSeries as vt, AXIS_TICK_MARK_DENSITY as Se, getDefaultVerticalLine as Ct, AXIS_FONT_SIZE as yt, AXIS_EDGE_LABEL_PADDING_PX as Qe, AXIS_TOP_LABEL_PADDING_PX as Ye, AXIS_TIME_EDGE_PADDING_PX as xt } from "./default-config.js";
8
+ import { getDefaultOptions as Je, getDefaultSeries as vt, AXIS_TICK_MARK_DENSITY as Se, getDefaultVerticalLine as Ct, AXIS_FONT_SIZE as yt, AXIS_EDGE_LABEL_PADDING_PX as Qe, AXIS_TOP_LABEL_PADDING_PX as Ye, AXIS_TIME_EDGE_PADDING_PX as xt } from "./default-config.js";
9
9
  import { getXFormatters as Ue, formatExactValue as Le, isRatioUnit as _t, createAdaptiveYAxisFormatter as wt } from "./formatters.js";
10
10
  import { GraphCurrentValue as Pt } from "./graph-current-value.js";
11
- import { GraphTooltip as Tt } from "./graph-tooltip.js";
12
- import { VertLine as Rt } from "./plugins/vertical-line.js";
11
+ import { GraphTooltip as Rt } from "./graph-tooltip.js";
12
+ import { VertLine as Tt } from "./plugins/vertical-line.js";
13
13
  import { pickMinMove as Nt, niceAxisRange as Vt } from "./y-axis-scale.js";
14
14
  function ie(e) {
15
15
  return e.id ?? e.label;
@@ -19,8 +19,8 @@ function et(e, i, u) {
19
19
  return e.values().next().value;
20
20
  const f = e.get(u);
21
21
  if (f) return f;
22
- const c = i.find((d) => d.id === u || d.label === u);
23
- return c ? e.get(ie(c)) : void 0;
22
+ const s = i.find((d) => d.id === u || d.label === u);
23
+ return s ? e.get(ie(s)) : void 0;
24
24
  }
25
25
  class Lt {
26
26
  _yTop;
@@ -31,7 +31,7 @@ class Lt {
31
31
  }
32
32
  draw(i) {
33
33
  i.useBitmapCoordinateSpace((u) => {
34
- const f = u.context, c = u.verticalPixelRatio, d = this._yTop === null ? 0 : this._yTop * c, S = this._yBottom === null ? u.bitmapSize.height : this._yBottom * c, w = Math.min(d, S), k = Math.max(d, S);
34
+ const f = u.context, s = u.verticalPixelRatio, d = this._yTop === null ? 0 : this._yTop * s, S = this._yBottom === null ? u.bitmapSize.height : this._yBottom * s, w = Math.min(d, S), k = Math.max(d, S);
35
35
  f.fillStyle = this._color, f.fillRect(0, w, u.bitmapSize.width, k - w);
36
36
  });
37
37
  }
@@ -61,8 +61,8 @@ class kt {
61
61
  priceBottom;
62
62
  color;
63
63
  _paneViews;
64
- constructor(i, u, f, c) {
65
- this.series = i, this.priceTop = u, this.priceBottom = f, this.color = c, this._paneViews = [new Mt(this)];
64
+ constructor(i, u, f, s) {
65
+ this.series = i, this.priceTop = u, this.priceBottom = f, this.color = s, this._paneViews = [new Mt(this)];
66
66
  }
67
67
  updateAllViews() {
68
68
  for (const i of this._paneViews) i.update();
@@ -90,13 +90,13 @@ class Dt {
90
90
  _color;
91
91
  _lineWidth;
92
92
  _lineStyle;
93
- constructor(i, u, f, c) {
94
- this._y = i, this._color = u, this._lineWidth = f, this._lineStyle = c;
93
+ constructor(i, u, f, s) {
94
+ this._y = i, this._color = u, this._lineWidth = f, this._lineStyle = s;
95
95
  }
96
96
  draw(i) {
97
97
  i.useBitmapCoordinateSpace((u) => {
98
98
  if (this._y === null) return;
99
- const f = u.context, c = u.verticalPixelRatio, d = Math.max(1, Math.round(this._lineWidth * c)), S = Math.round(this._y * c);
99
+ const f = u.context, s = u.verticalPixelRatio, d = Math.max(1, Math.round(this._lineWidth * s)), S = Math.round(this._y * s);
100
100
  f.save(), f.strokeStyle = this._color, f.lineWidth = d, f.setLineDash(It(this._lineStyle, d)), f.beginPath(), f.moveTo(0, S), f.lineTo(u.bitmapSize.width, S), f.stroke(), f.restore();
101
101
  });
102
102
  }
@@ -135,8 +135,8 @@ class Bt {
135
135
  lineWidth;
136
136
  lineStyle;
137
137
  _paneViews;
138
- constructor(i, u, f, c, d) {
139
- this.series = i, this.price = u, this.color = f, this.lineWidth = c, this.lineStyle = d, this._paneViews = [new Et(this)];
138
+ constructor(i, u, f, s, d) {
139
+ this.series = i, this.price = u, this.color = f, this.lineWidth = s, this.lineStyle = d, this._paneViews = [new Et(this)];
140
140
  }
141
141
  updateAllViews() {
142
142
  for (const i of this._paneViews) i.update();
@@ -146,11 +146,11 @@ class Bt {
146
146
  }
147
147
  }
148
148
  function Ft(e, i, u) {
149
- const f = e.labelText ?? "", c = e.value, d = c === void 0 ? "" : typeof c == "number" ? i === "$" ? `$${Le(c, void 0, u)}` : i === "%" ? `${Le(c, void 0, u)}%` : Le(
150
- c,
149
+ const f = e.labelText ?? "", s = e.value, d = s === void 0 ? "" : typeof s == "number" ? i === "$" ? `$${Le(s, void 0, u)}` : i === "%" ? `${Le(s, void 0, u)}%` : Le(
150
+ s,
151
151
  i !== "none" && i !== "%" && i !== "$" && !_t(i) ? i : void 0,
152
152
  u
153
- ) : String(c);
153
+ ) : String(s);
154
154
  return { labelText: f, valueStr: d };
155
155
  }
156
156
  const tt = 4;
@@ -158,7 +158,7 @@ function zt(e, i, u) {
158
158
  const f = { left: e, transform: "translateX(-50%)" };
159
159
  if (i <= 0 || !u || u <= 0)
160
160
  return f;
161
- const c = u / 2, d = tt + c, S = i - tt - c;
161
+ const s = u / 2, d = tt + s, S = i - tt - s;
162
162
  return S < d ? { left: i / 2, transform: "translateX(-50%)" } : { left: Math.min(Math.max(e, d), S), transform: "translateX(-50%)" };
163
163
  }
164
164
  function At(e, i) {
@@ -286,15 +286,15 @@ const Me = [
286
286
  function ot(e) {
287
287
  if (e < Me.length)
288
288
  return Me[e];
289
- const u = (e - Me.length) * Gt % 360, f = St(u, 70, 50), { topColor: c, bottomColor: d } = ve(f);
290
- return { line: f, top: c, bottom: d };
289
+ const u = (e - Me.length) * Gt % 360, f = St(u, 70, 50), { topColor: s, bottomColor: d } = ve(f);
290
+ return { line: f, top: s, bottom: d };
291
291
  }
292
292
  function oo({
293
293
  series: e,
294
294
  className: i,
295
295
  showLegend: u = !1,
296
296
  onUnselectSeries: f,
297
- xMeasureUnit: c = "time",
297
+ xMeasureUnit: s = "time",
298
298
  yMeasureUnit: d = "token",
299
299
  optionsOverrides: S,
300
300
  verticalLineOptions: w,
@@ -314,7 +314,7 @@ function oo({
314
314
  disableZoom: Be = !1,
315
315
  hideDefaultTooltip: xe = !1
316
316
  }) {
317
- const E = K(null), V = K(/* @__PURE__ */ new Map()), _e = K(!1), Fe = K(!0), ze = K([]), le = K(0), B = K(null), we = K(null), Ae = K(null), P = bt(), se = Ve.useMemo(() => e.flatMap((t) => t.data), [e]), nt = Ve.useMemo(() => {
317
+ const E = K(null), L = K(/* @__PURE__ */ new Map()), _e = K(!1), Fe = K(!0), ze = K([]), le = K(0), B = K(null), we = K(null), Ae = K(null), P = bt(), se = Ve.useMemo(() => e.flatMap((t) => t.data), [e]), nt = Ve.useMemo(() => {
318
318
  if (e.length > 0) {
319
319
  const t = e[e.length - 1];
320
320
  if (t.data.length > 0)
@@ -326,13 +326,13 @@ function oo({
326
326
  for (const l of e)
327
327
  l.data.length > 0 && t.set(l.label, l.data[l.data.length - 1]);
328
328
  return t;
329
- }), [We, J] = re(null), [Xe, $e] = re([]), [it, He] = re(0), je = K(/* @__PURE__ */ new Map()), [at, lt] = re({}), [Y, st] = re(0);
329
+ }), [We, O] = re(null), [Xe, $e] = re([]), [it, He] = re(0), je = K(/* @__PURE__ */ new Map()), [at, lt] = re({}), [Y, st] = re(0);
330
330
  A(() => {
331
331
  const t = () => {
332
332
  try {
333
333
  if (B.current && He(B.current.clientWidth), E.current && B.current) {
334
- const a = B.current.clientWidth, s = B.current.clientHeight;
335
- E.current.resize(a, s);
334
+ const a = B.current.clientWidth, c = B.current.clientHeight;
335
+ E.current.resize(a, c);
336
336
  try {
337
337
  le.current = E.current.paneSize().height;
338
338
  } catch {
@@ -346,7 +346,7 @@ function oo({
346
346
  };
347
347
  }, []), A(() => {
348
348
  if (!we.current || _e.current) return;
349
- const t = Oe(), l = ne(
349
+ const t = Je(), l = ne(
350
350
  "hsl(var(--muted-foreground))",
351
351
  "rgb(163, 163, 163)"
352
352
  ), n = ht(we.current, {
@@ -375,7 +375,7 @@ function oo({
375
375
  le.current = 0;
376
376
  }
377
377
  return st((a) => a + 1), () => {
378
- n.remove(), E.current = null, _e.current = !1, V.current.clear();
378
+ n.remove(), E.current = null, _e.current = !1, L.current.clear();
379
379
  };
380
380
  }, [P]), A(() => {
381
381
  const t = E.current;
@@ -414,29 +414,29 @@ function oo({
414
414
  }, [Y, S]), A(() => {
415
415
  const t = E.current;
416
416
  if (!t || e.length === 0) return;
417
- const n = e.filter((r) => r.data.length > 0).length <= 1 ? De : Ee, a = c === "time" ? Ue(c, se) : Ue(c), s = /* @__PURE__ */ new Map();
417
+ const n = e.filter((r) => r.data.length > 0).length <= 1 ? De : Ee, a = s === "time" ? Ue(s, se) : Ue(s), c = /* @__PURE__ */ new Map();
418
418
  {
419
419
  let r = 0;
420
420
  for (const o of e)
421
- o.data.length !== 0 && (s.set(
421
+ o.data.length !== 0 && (c.set(
422
422
  o.label,
423
423
  o.priceScaleId ?? (r === 0 ? "left" : "right")
424
424
  ), r++);
425
425
  }
426
426
  const h = (r, o, g) => {
427
- const { formatter: F, tickmarksFormatter: R, updateVisibleRange: M } = wt(r, o, {
427
+ const { formatter: F, tickmarksFormatter: T, updateVisibleRange: N } = wt(r, o, {
428
428
  yScaleMin: n
429
429
  });
430
- return { formatter: F, tickmarksFormatter: R, updateVisibleRange: M, labels: g };
430
+ return { formatter: F, tickmarksFormatter: T, updateVisibleRange: N, labels: g };
431
431
  }, m = [];
432
432
  if (D)
433
433
  for (const r of ["left", "right"]) {
434
434
  const o = /* @__PURE__ */ new Set(), g = [];
435
435
  let F = d;
436
- for (const R of e)
437
- if (R.data.length !== 0 && s.get(R.label) === r) {
438
- o.size === 0 && R.yMeasureUnit && (F = R.yMeasureUnit), o.add(R.label);
439
- for (const M of R.data) g.push(M.value);
436
+ for (const T of e)
437
+ if (T.data.length !== 0 && c.get(T.label) === r) {
438
+ o.size === 0 && T.yMeasureUnit && (F = T.yMeasureUnit), o.add(T.label);
439
+ for (const N of T.data) g.push(N.value);
440
440
  }
441
441
  o.size > 0 && m.push(h(g, F, o));
442
442
  }
@@ -451,7 +451,7 @@ function oo({
451
451
  for (const r of m)
452
452
  for (const o of r.labels)
453
453
  y.set(o, r);
454
- const x = Oe();
454
+ const x = Je();
455
455
  t.applyOptions({
456
456
  localization: {
457
457
  ...x.localization || {},
@@ -469,7 +469,7 @@ function oo({
469
469
  minBarSpacing: 0
470
470
  }
471
471
  });
472
- const v = !D && e.length > 1 && !Z, W = D ? P : e.length > 1 && !Z || P, L = ne(
472
+ const v = !D && e.length > 1 && !Z, W = D ? P : e.length > 1 && !Z || P, M = ne(
473
473
  "hsl(var(--muted-foreground))",
474
474
  "rgb(163, 163, 163)"
475
475
  );
@@ -481,7 +481,7 @@ function oo({
481
481
  ...x.leftPriceScale || {},
482
482
  ...S?.leftPriceScale,
483
483
  visible: D && !P,
484
- textColor: L,
484
+ textColor: M,
485
485
  ...D && Ie && {
486
486
  // lightweight-charts uses scale margins; title shown via localization if needed
487
487
  }
@@ -490,17 +490,17 @@ function oo({
490
490
  ...x.rightPriceScale || {},
491
491
  ...S?.rightPriceScale,
492
492
  visible: D ? !P : !W,
493
- textColor: L
493
+ textColor: M
494
494
  }
495
495
  });
496
- const U = new Set(V.current.keys()), X = new Set(e.map(ie));
496
+ const U = new Set(L.current.keys()), X = new Set(e.map(ie));
497
497
  for (const r of U)
498
498
  if (!X.has(r)) {
499
- const o = V.current.get(r);
500
- o && (t.removeSeries(o), V.current.delete(r));
499
+ const o = L.current.get(r);
500
+ o && (t.removeSeries(o), L.current.delete(r));
501
501
  }
502
502
  const p = vt(), I = [];
503
- let T = 0;
503
+ let R = 0;
504
504
  const $ = e.find((r) => r.data.length > 0), C = /* @__PURE__ */ new Map();
505
505
  if (k && k.length > 0)
506
506
  for (const r of k) {
@@ -518,39 +518,39 @@ function oo({
518
518
  Number.isFinite(r.priceTop) && g.push(r.priceTop), Number.isFinite(r.priceBottom) && g.push(r.priceBottom), C.set(o, g);
519
519
  }
520
520
  for (let r = 0; r < e.length; r++) {
521
- const o = e[r], g = ie(o), F = ot(r), R = o.lineColor ?? o.color ?? F.line;
522
- let M, O;
521
+ const o = e[r], g = ie(o), F = ot(r), T = o.lineColor ?? o.color ?? F.line;
522
+ let N, J;
523
523
  if (o.lineColor ?? o.color)
524
524
  if (o.topColor && o.bottomColor)
525
- M = o.topColor, O = o.bottomColor;
525
+ N = o.topColor, J = o.bottomColor;
526
526
  else if (o.topColor) {
527
- const b = ve(R);
528
- M = o.topColor, O = b.bottomColor;
527
+ const b = ve(T);
528
+ N = o.topColor, J = b.bottomColor;
529
529
  } else if (o.bottomColor)
530
- M = ve(R).topColor, O = o.bottomColor;
530
+ N = ve(T).topColor, J = o.bottomColor;
531
531
  else {
532
- const b = ve(R);
533
- M = b.topColor, O = b.bottomColor;
532
+ const b = ve(T);
533
+ N = b.topColor, J = b.bottomColor;
534
534
  }
535
535
  else
536
- M = o.topColor || F.top, O = o.bottomColor || F.bottom;
536
+ N = o.topColor || F.top, J = o.bottomColor || F.bottom;
537
537
  if (o.data.length === 0) {
538
- const b = V.current.get(g);
539
- b && (t.removeSeries(b), V.current.delete(g));
538
+ const b = L.current.get(g);
539
+ b && (t.removeSeries(b), L.current.delete(g));
540
540
  continue;
541
541
  }
542
- const pe = o.data.length > 0 ? Math.min(...o.data.map((b) => b.value)) : 0, ce = o.data.length > 0 ? Math.max(...o.data.map((b) => b.value)) : 0, ue = pe < 0, q = o.data.some((b) => b.value === 0), de = !ue && q, fe = Nt(ce - pe), he = D ? o.priceScaleId ?? (T === 0 ? "left" : "right") : Z || !v || T === 0 ? "right" : `scale-${T}`;
542
+ const pe = o.data.length > 0 ? Math.min(...o.data.map((b) => b.value)) : 0, ce = o.data.length > 0 ? Math.max(...o.data.map((b) => b.value)) : 0, ue = pe < 0, q = o.data.some((b) => b.value === 0), de = !ue && q, fe = Nt(ce - pe), he = D ? o.priceScaleId ?? (R === 0 ? "left" : "right") : Z || !v || R === 0 ? "right" : `scale-${R}`;
543
543
  v && I.push({
544
544
  priceScaleId: he || "right",
545
- seriesIndex: T
545
+ seriesIndex: R
546
546
  });
547
- const Te = (Z || !v) && n !== void 0 && typeof n == "number", ct = C.get(o.label) ?? [], ut = (b) => {
547
+ const Re = (Z || !v) && n !== void 0 && typeof n == "number", ct = C.get(o.label) ?? [], ut = (b) => {
548
548
  const _ = b();
549
549
  if (_?.priceRange) {
550
- Te && (_.priceRange.minValue = n);
550
+ Re && (_.priceRange.minValue = n);
551
551
  for (const j of ct)
552
552
  j < _.priceRange.minValue && (_.priceRange.minValue = j), j > _.priceRange.maxValue && (_.priceRange.maxValue = j);
553
- const oe = Te ? n : de && _.priceRange.minValue >= 0 ? 0 : void 0, be = le.current > 0 ? le.current : B.current?.clientHeight ?? 0;
553
+ const oe = Re ? n : de && _.priceRange.minValue >= 0 ? 0 : void 0, be = le.current > 0 ? le.current : B.current?.clientHeight ?? 0;
554
554
  if (be > 0) {
555
555
  const j = Vt({
556
556
  min: _.priceRange.minValue,
@@ -571,10 +571,10 @@ function oo({
571
571
  };
572
572
  }
573
573
  return _;
574
- }, Ze = y.get(o.label) ?? m[0], qe = Ze.formatter, ft = Ze.tickmarksFormatter, Re = {
575
- lineColor: R,
576
- topColor: M,
577
- bottomColor: O,
574
+ }, Ze = y.get(o.label) ?? m[0], qe = Ze.formatter, ft = Ze.tickmarksFormatter, Te = {
575
+ lineColor: T,
576
+ topColor: N,
577
+ bottomColor: J,
578
578
  priceScaleId: he,
579
579
  ...o.seriesType === "line" && {
580
580
  lineStyle: o.lineStyle ?? ae.Solid
@@ -582,14 +582,14 @@ function oo({
582
582
  priceFormat: {
583
583
  type: "custom",
584
584
  minMove: fe,
585
- formatter: Te && typeof n == "number" ? (b) => qe(
585
+ formatter: Re && typeof n == "number" ? (b) => qe(
586
586
  b < n ? n : b
587
587
  ) : qe,
588
588
  tickmarksFormatter: ft
589
589
  },
590
590
  autoscaleInfoProvider: ut
591
- }, Je = o.seriesType === "line";
592
- let z = V.current.get(g);
591
+ }, Oe = o.seriesType === "line";
592
+ let z = L.current.get(g);
593
593
  const te = o.data.map((b) => ({
594
594
  ...b,
595
595
  time: b.time
@@ -600,13 +600,13 @@ function oo({
600
600
  j.push({ time: Ne });
601
601
  te.unshift(...j);
602
602
  }
603
- z && z.seriesType() !== (Je ? "Line" : "Area") && (t.removeSeries(z), V.current.delete(g), z = void 0), z ? (z.applyOptions(Re), z.setData(te)) : (Je ? z = t.addSeries(mt, {
603
+ z && z.seriesType() !== (Oe ? "Line" : "Area") && (t.removeSeries(z), L.current.delete(g), z = void 0), z ? (z.applyOptions(Te), z.setData(te)) : (Oe ? z = t.addSeries(mt, {
604
604
  ...p,
605
- ...Re
605
+ ...Te
606
606
  }) : z = t.addSeries(pt, {
607
607
  ...p,
608
- ...Re
609
- }), z.setData(te), V.current.set(g, z)), T++;
608
+ ...Te
609
+ }), z.setData(te), L.current.set(g, z)), R++;
610
610
  }
611
611
  if (D)
612
612
  try {
@@ -617,7 +617,7 @@ function oo({
617
617
  alignLabels: !0,
618
618
  entireTextOnly: !1,
619
619
  tickMarkDensity: Se,
620
- textColor: L,
620
+ textColor: M,
621
621
  ...S?.rightPriceScale
622
622
  };
623
623
  r?.applyOptions(g), o?.applyOptions(g);
@@ -637,7 +637,7 @@ function oo({
637
637
  alignLabels: !0,
638
638
  entireTextOnly: !1,
639
639
  tickMarkDensity: Se,
640
- textColor: L
640
+ textColor: M
641
641
  });
642
642
  } catch (o) {
643
643
  console.warn(
@@ -658,7 +658,7 @@ function oo({
658
658
  alignLabels: !0,
659
659
  entireTextOnly: !1,
660
660
  tickMarkDensity: Se,
661
- textColor: L,
661
+ textColor: M,
662
662
  ...S?.rightPriceScale
663
663
  });
664
664
  } catch {
@@ -672,27 +672,35 @@ function oo({
672
672
  if (r.length > 0) {
673
673
  const o = Math.min(...r), g = Q !== void 0 ? Math.min(Q, o) : o, F = Math.max(...r);
674
674
  if (Number(g) <= Number(F)) {
675
- const R = () => {
676
- const M = t.timeScale(), O = D && !P, pe = D ? !P : !W, ce = !O, ue = !pe;
677
- if (M.applyOptions({
675
+ const T = () => {
676
+ const N = t.timeScale();
677
+ if (s !== "time") {
678
+ N.applyOptions({
679
+ fixLeftEdge: !0,
680
+ fixRightEdge: !0
681
+ });
682
+ return;
683
+ }
684
+ const J = D && !P, pe = D ? !P : !W, ce = !J, ue = !pe;
685
+ if (N.applyOptions({
678
686
  fixLeftEdge: !ce,
679
687
  fixRightEdge: !ue
680
688
  }), !ce && !ue) return;
681
- const q = M.getVisibleLogicalRange(), de = M.width();
689
+ const q = N.getVisibleLogicalRange(), de = N.width();
682
690
  if (!q || !(de > 0)) return;
683
691
  const fe = q.to - q.from;
684
692
  if (!(fe > 0)) return;
685
693
  const he = xt * fe / de;
686
- M.setVisibleLogicalRange({
694
+ N.setVisibleLogicalRange({
687
695
  from: ce ? q.from - he : q.from,
688
696
  to: ue ? q.to + he : q.to
689
697
  });
690
698
  };
691
699
  try {
692
- t.timeScale().setVisibleRange({ from: g, to: F }), R();
700
+ t.timeScale().setVisibleRange({ from: g, to: F }), T();
693
701
  } catch {
694
702
  try {
695
- t.timeScale().fitContent(), R();
703
+ t.timeScale().fitContent(), T();
696
704
  } catch {
697
705
  }
698
706
  }
@@ -708,7 +716,7 @@ function oo({
708
716
  Y,
709
717
  e,
710
718
  se,
711
- c,
719
+ s,
712
720
  d,
713
721
  P,
714
722
  Z,
@@ -726,35 +734,35 @@ function oo({
726
734
  if (!t || e.length === 0) return;
727
735
  const l = e.length === 1;
728
736
  let n;
729
- for (const s of e)
730
- if (s.data.length > 0) {
731
- n = s.data[s.data.length - 1].time;
737
+ for (const c of e)
738
+ if (c.data.length > 0) {
739
+ n = c.data[c.data.length - 1].time;
732
740
  break;
733
741
  }
734
742
  if (!n) return;
735
- const a = (s) => {
736
- const { time: h = n, seriesData: m, point: y } = s || {}, x = e[0], v = x ? V.current.get(ie(x)) : void 0;
743
+ const a = (c) => {
744
+ const { time: h = n, seriesData: m, point: y } = c || {}, x = e[0], v = x ? L.current.get(ie(x)) : void 0;
737
745
  if (!y || !h) {
738
746
  const X = /* @__PURE__ */ new Map();
739
747
  for (const p of e)
740
748
  p.data.length > 0 && X.set(p.label, p.data[p.data.length - 1]);
741
749
  if (Pe(X.size > 0 ? X : void 0), l || Z || xe)
742
- J(null);
750
+ O(null);
743
751
  else if (v && n) {
744
752
  const p = e[0];
745
753
  if (p && p.data.length > 0) {
746
- const T = t.timeScale().timeToCoordinate(n), $ = p.data[p.data.length - 1].value, C = v.priceToCoordinate($);
747
- T !== null && C !== null && J({ x: T, y: C });
754
+ const R = t.timeScale().timeToCoordinate(n), $ = p.data[p.data.length - 1].value, C = v.priceToCoordinate($);
755
+ R !== null && C !== null && O({ x: R, y: C });
748
756
  }
749
757
  }
750
758
  return;
751
759
  }
752
760
  const W = /* @__PURE__ */ new Map();
753
- let L, U = v;
761
+ let M, U = v;
754
762
  for (let X = 0; X < e.length; X++) {
755
- const p = e[X], I = V.current.get(ie(p));
763
+ const p = e[X], I = L.current.get(ie(p));
756
764
  if (!I) continue;
757
- const T = m?.get(I), $ = T && "value" in T ? T.value : void 0;
765
+ const R = m?.get(I), $ = R && "value" in R ? R.value : void 0;
758
766
  let C;
759
767
  if ($ !== void 0)
760
768
  C = $;
@@ -766,33 +774,33 @@ function oo({
766
774
  if (Number(h) < H) continue;
767
775
  C = At(p.data, Number(h));
768
776
  }
769
- Number.isNaN(C) || (L === void 0 && (L = C, U = I), W.set(p.label, { value: C, time: h }));
777
+ Number.isNaN(C) || (M === void 0 && (M = C, U = I), W.set(p.label, { value: C, time: h }));
770
778
  }
771
- if (Pe(W), L !== void 0 && U) {
772
- const p = t.timeScale().timeToCoordinate(h), I = U.priceToCoordinate(L);
779
+ if (Pe(W), M !== void 0 && U) {
780
+ const p = t.timeScale().timeToCoordinate(h), I = U.priceToCoordinate(M);
773
781
  if (p !== null && I !== null) {
774
- const T = B.current;
775
- if (T) {
776
- const $ = T.querySelector(
782
+ const R = B.current;
783
+ if (R) {
784
+ const $ = R.querySelector(
777
785
  ".LightweightChart"
778
786
  );
779
787
  if ($) {
780
- const C = $.getBoundingClientRect(), H = T.getBoundingClientRect(), r = p + (C.left - H.left), o = I + (C.top - H.top);
781
- J({ x: r, y: o });
788
+ const C = $.getBoundingClientRect(), H = R.getBoundingClientRect(), r = p + (C.left - H.left), o = I + (C.top - H.top);
789
+ O({ x: r, y: o });
782
790
  } else
783
- J({ x: p, y: I });
791
+ O({ x: p, y: I });
784
792
  } else
785
- J({ x: p, y: I });
793
+ O({ x: p, y: I });
786
794
  } else
787
- J(null);
795
+ O(null);
788
796
  } else
789
- J(null);
797
+ O(null);
790
798
  };
791
799
  return t.subscribeCrosshairMove(a), P && t.subscribeClick(a), !l && !Z && !xe && requestAnimationFrame(() => {
792
- const s = e[0], h = s ? V.current.get(ie(s)) : void 0;
793
- if (h && n && s.data.length > 0) {
794
- const y = t.timeScale().timeToCoordinate(n), x = s.data[s.data.length - 1].value, v = h.priceToCoordinate(x);
795
- y !== null && v !== null && J({ x: y, y: v });
800
+ const c = e[0], h = c ? L.current.get(ie(c)) : void 0;
801
+ if (h && n && c.data.length > 0) {
802
+ const y = t.timeScale().timeToCoordinate(n), x = c.data[c.data.length - 1].value, v = h.priceToCoordinate(x);
803
+ y !== null && v !== null && O({ x: y, y: v });
796
804
  }
797
805
  }), () => {
798
806
  t.unsubscribeCrosshairMove(a), P && t.unsubscribeClick(a);
@@ -803,16 +811,16 @@ function oo({
803
811
  const l = t.timeScale(), n = () => {
804
812
  const a = ze.current;
805
813
  if (a.length === 0) return;
806
- const s = l.getVisibleRange();
807
- if (!s) return;
808
- const h = Number(s.from), m = Number(s.to);
814
+ const c = l.getVisibleRange();
815
+ if (!c) return;
816
+ const h = Number(c.from), m = Number(c.to);
809
817
  for (const y of a) {
810
818
  const x = [];
811
819
  for (const v of e)
812
820
  if (y.labels.has(v.label))
813
821
  for (const W of v.data) {
814
- const L = Number(W.time);
815
- L >= h && L <= m && x.push(W.value);
822
+ const M = Number(W.time);
823
+ M >= h && M <= m && x.push(W.value);
816
824
  }
817
825
  x.length > 0 && y.updateVisibleRange(x);
818
826
  }
@@ -823,25 +831,25 @@ function oo({
823
831
  );
824
832
  };
825
833
  }, [e]), A(() => {
826
- const t = E.current, l = Array.from(V.current.values()), n = [];
834
+ const t = E.current, l = Array.from(L.current.values()), n = [];
827
835
  if (t && l.length > 0 && w) {
828
- const a = Ct(), s = l[0];
836
+ const a = Ct(), c = l[0];
829
837
  for (const h of w) {
830
838
  const m = {
831
839
  ...a,
832
840
  ...h.options || {}
833
841
  };
834
842
  m.color && (m.color = ne(m.color, m.color));
835
- const y = new Rt(t, s, h.xCoordinate, m);
836
- s.attachPrimitive(y), n.push(y);
843
+ const y = new Tt(t, c, h.xCoordinate, m);
844
+ c.attachPrimitive(y), n.push(y);
837
845
  }
838
846
  }
839
847
  return () => {
840
848
  if (l.length > 0) {
841
849
  const a = l[0];
842
- for (const s of n)
850
+ for (const c of n)
843
851
  try {
844
- a.detachPrimitive(s);
852
+ a.detachPrimitive(c);
845
853
  } catch {
846
854
  }
847
855
  }
@@ -855,13 +863,13 @@ function oo({
855
863
  );
856
864
  for (const a of k) {
857
865
  if (!Number.isFinite(a.price)) continue;
858
- const s = et(
859
- V.current,
866
+ const c = et(
867
+ L.current,
860
868
  e,
861
869
  a.seriesLabel
862
870
  );
863
- if (!s) continue;
864
- const h = a.color ? ne(a.color, a.color) : n, m = a.lineWidth ?? 1, y = a.lineStyle ?? ae.Dashed, x = s.createPriceLine({
871
+ if (!c) continue;
872
+ const h = a.color ? ne(a.color, a.color) : n, m = a.lineWidth ?? 1, y = a.lineStyle ?? ae.Dashed, x = c.createPriceLine({
865
873
  price: a.price,
866
874
  color: h,
867
875
  lineWidth: m,
@@ -869,15 +877,15 @@ function oo({
869
877
  axisLabelVisible: a.axisLabelVisible ?? !0,
870
878
  title: a.title ?? ""
871
879
  });
872
- t.push({ series: s, line: x });
880
+ t.push({ series: c, line: x });
873
881
  const v = new Bt(
874
- s,
882
+ c,
875
883
  a.price,
876
884
  h,
877
885
  m,
878
886
  y
879
887
  );
880
- s.attachPrimitive(v), l.push({ series: s, primitive: v });
888
+ c.attachPrimitive(v), l.push({ series: c, primitive: v });
881
889
  }
882
890
  }
883
891
  return () => {
@@ -898,16 +906,16 @@ function oo({
898
906
  const l = "rgba(239, 68, 68, 0.12)";
899
907
  for (const n of G) {
900
908
  const a = et(
901
- V.current,
909
+ L.current,
902
910
  e,
903
911
  n.seriesLabel
904
912
  );
905
913
  if (!a) continue;
906
- const s = n.color ? ne(n.color, l) : l, h = new kt(
914
+ const c = n.color ? ne(n.color, l) : l, h = new kt(
907
915
  a,
908
916
  n.priceTop,
909
917
  n.priceBottom,
910
- s
918
+ c
911
919
  );
912
920
  a.attachPrimitive(h), t.push({ series: a, zone: h });
913
921
  }
@@ -926,7 +934,7 @@ function oo({
926
934
  return;
927
935
  }
928
936
  const l = () => {
929
- const s = t.timeScale(), h = w.map((m) => s.timeToCoordinate(m.xCoordinate) ?? null);
937
+ const c = t.timeScale(), h = w.map((m) => c.timeToCoordinate(m.xCoordinate) ?? null);
930
938
  $e(h), B.current && He(B.current.clientWidth);
931
939
  };
932
940
  l();
@@ -940,9 +948,9 @@ function oo({
940
948
  lt((t) => {
941
949
  const l = {};
942
950
  let n = !1;
943
- for (const [a, s] of je.current) {
944
- if (!s) continue;
945
- const h = s.offsetWidth;
951
+ for (const [a, c] of je.current) {
952
+ if (!c) continue;
953
+ const h = c.offsetWidth;
946
954
  l[a] = h, t[a] !== h && (n = !0);
947
955
  }
948
956
  return Object.keys(t).length !== Object.keys(l).length && (n = !0), n ? l : t;
@@ -964,20 +972,20 @@ function oo({
964
972
  i
965
973
  ),
966
974
  children: [
967
- ye != null && ye !== !1 && me ? /* @__PURE__ */ N("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ N("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: ye }) }) : rt && me && Ke && /* @__PURE__ */ N(
975
+ ye != null && ye !== !1 && me ? /* @__PURE__ */ V("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ V("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: ye }) }) : rt && me && Ke && /* @__PURE__ */ V(
968
976
  Pt,
969
977
  {
970
978
  point: Ke,
971
- xMeasureUnit: c,
979
+ xMeasureUnit: s,
972
980
  yMeasureUnit: d,
973
981
  decimals: Ce
974
982
  }
975
983
  ),
976
- Ge && We && /* @__PURE__ */ N(
977
- Tt,
984
+ Ge && We && /* @__PURE__ */ V(
985
+ Rt,
978
986
  {
979
987
  points: Ge,
980
- xMeasureUnit: c,
988
+ xMeasureUnit: s,
981
989
  yMeasureUnit: d,
982
990
  series: e,
983
991
  position: We,
@@ -985,8 +993,8 @@ function oo({
985
993
  decimals: Ce
986
994
  }
987
995
  ),
988
- u && /* @__PURE__ */ N(Wt, { series: e, onUnselect: f }),
989
- w && w.length > 0 && Xe.length === w.length && /* @__PURE__ */ N(
996
+ u && /* @__PURE__ */ V(Wt, { series: e, onUnselect: f }),
997
+ w && w.length > 0 && Xe.length === w.length && /* @__PURE__ */ V(
990
998
  "div",
991
999
  {
992
1000
  className: "absolute inset-0 z-[5] pointer-events-none",
@@ -994,13 +1002,13 @@ function oo({
994
1002
  children: w.map((t, l) => {
995
1003
  const n = Xe[l], a = t.options ?? {};
996
1004
  if (n === null) return null;
997
- const { labelText: s, valueStr: h } = Ft(
1005
+ const { labelText: c, valueStr: h } = Ft(
998
1006
  a,
999
1007
  d,
1000
1008
  Ce
1001
1009
  ), m = a.tooltipText ?? "";
1002
- if (!(s || h || m)) return null;
1003
- const x = a.labelBackgroundColor ?? a.color ?? "hsl(var(--background))", v = a.labelTextColor ?? "hsl(var(--foreground))", W = `${String(t.xCoordinate)}-${s}-${m}`, L = zt(
1010
+ if (!(c || h || m)) return null;
1011
+ const x = a.labelBackgroundColor ?? a.color ?? "hsl(var(--background))", v = a.labelTextColor ?? "hsl(var(--foreground))", W = `${String(t.xCoordinate)}-${c}-${m}`, M = zt(
1004
1012
  n,
1005
1013
  it,
1006
1014
  at[l]
@@ -1016,14 +1024,14 @@ function oo({
1016
1024
  m && "pointer-events-auto cursor-default"
1017
1025
  ),
1018
1026
  style: {
1019
- ...L,
1027
+ ...M,
1020
1028
  backgroundColor: x,
1021
1029
  color: v
1022
1030
  },
1023
1031
  children: [
1024
- s && /* @__PURE__ */ N("span", { className: "block", children: s }),
1025
- h && /* @__PURE__ */ N("span", { className: ee("block", s && "mt-0.5"), children: h }),
1026
- m && /* @__PURE__ */ N(
1032
+ c && /* @__PURE__ */ V("span", { className: "block", children: c }),
1033
+ h && /* @__PURE__ */ V("span", { className: ee("block", c && "mt-0.5"), children: h }),
1034
+ m && /* @__PURE__ */ V(
1027
1035
  "span",
1028
1036
  {
1029
1037
  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",
@@ -1038,7 +1046,7 @@ function oo({
1038
1046
  })
1039
1047
  }
1040
1048
  ),
1041
- /* @__PURE__ */ N(
1049
+ /* @__PURE__ */ V(
1042
1050
  "div",
1043
1051
  {
1044
1052
  ref: we,
@@ -1054,16 +1062,16 @@ function Wt({
1054
1062
  onUnselect: i,
1055
1063
  inline: u = !1
1056
1064
  }) {
1057
- const f = e.every((c) => c.data.length === 0);
1058
- return /* @__PURE__ */ N(
1065
+ const f = e.every((s) => s.data.length === 0);
1066
+ return /* @__PURE__ */ V(
1059
1067
  "div",
1060
1068
  {
1061
1069
  className: ee(
1062
1070
  "flex flex-wrap",
1063
1071
  u ? "items-center justify-center gap-6" : "absolute top-0 left-2 z-[10] gap-2"
1064
1072
  ),
1065
- children: e.map((c, d) => {
1066
- const S = ot(d), w = (c.lineColor ?? c.color) || S.line, k = !f && c.data.length === 0;
1073
+ children: e.map((s, d) => {
1074
+ const S = ot(d), w = (s.lineColor ?? s.color) || S.line, k = !f && s.data.length === 0;
1067
1075
  return /* @__PURE__ */ ge(
1068
1076
  "div",
1069
1077
  {
@@ -1073,7 +1081,7 @@ function Wt({
1073
1081
  k && "opacity-50"
1074
1082
  ),
1075
1083
  children: [
1076
- /* @__PURE__ */ N(
1084
+ /* @__PURE__ */ V(
1077
1085
  "div",
1078
1086
  {
1079
1087
  className: ee(
@@ -1090,20 +1098,20 @@ function Wt({
1090
1098
  u ? "text-sm" : "text-[10px] sm:text-xs"
1091
1099
  ),
1092
1100
  children: [
1093
- c.label,
1101
+ s.label,
1094
1102
  k && " (no data)"
1095
1103
  ]
1096
1104
  }
1097
1105
  ),
1098
- i && /* @__PURE__ */ N(
1106
+ i && /* @__PURE__ */ V(
1099
1107
  "button",
1100
1108
  {
1101
1109
  type: "button",
1102
1110
  onClick: (G) => {
1103
- G.stopPropagation(), i(c.label);
1111
+ G.stopPropagation(), i(s.label);
1104
1112
  },
1105
1113
  className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
1106
- "aria-label": `Remove ${c.label}`,
1114
+ "aria-label": `Remove ${s.label}`,
1107
1115
  children: /* @__PURE__ */ ge(
1108
1116
  "svg",
1109
1117
  {
@@ -1119,9 +1127,9 @@ function Wt({
1119
1127
  className: "text-muted-foreground hover:text-foreground",
1120
1128
  "aria-hidden": "true",
1121
1129
  children: [
1122
- /* @__PURE__ */ N("title", { children: "Close" }),
1123
- /* @__PURE__ */ N("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1124
- /* @__PURE__ */ N("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1130
+ /* @__PURE__ */ V("title", { children: "Close" }),
1131
+ /* @__PURE__ */ V("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1132
+ /* @__PURE__ */ V("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1125
1133
  ]
1126
1134
  }
1127
1135
  )
@@ -1129,7 +1137,7 @@ function Wt({
1129
1137
  )
1130
1138
  ]
1131
1139
  },
1132
- c.id ?? c.label
1140
+ s.id ?? s.label
1133
1141
  );
1134
1142
  })
1135
1143
  }