@gearbox-protocol/ui-kit 3.14.0-next.34 → 3.14.0-next.36

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