@gearbox-protocol/ui-kit 4.0.0-next.57 → 4.0.0-next.59

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