@gearbox-protocol/ui-kit 2.1.0-next.1 → 3.0.0

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 (69) hide show
  1. package/README.md +7 -87
  2. package/dist/cjs/components/assets-list-cell/assets-list-cell.cjs +1 -1
  3. package/dist/cjs/components/auth/connect-required.cjs +1 -1
  4. package/dist/cjs/components/auth/index.cjs +1 -1
  5. package/dist/cjs/components/auth/signin-required.cjs +1 -1
  6. package/dist/cjs/components/block-sync/block-sync.cjs +1 -1
  7. package/dist/cjs/components/checkbox/checkbox-labeled.cjs +1 -1
  8. package/dist/cjs/components/client-adapters/styled-rounded-image/styled-rounded-image.cjs +1 -1
  9. package/dist/cjs/components/complex-input/complex-input.cjs +1 -1
  10. package/dist/cjs/components/compound-apy/compound-apy.cjs +1 -1
  11. package/dist/cjs/components/detailed-page-title/detailed-page-title.cjs +1 -1
  12. package/dist/cjs/components/graph/graph.cjs +1 -1
  13. package/dist/cjs/components/index.cjs +1 -1
  14. package/dist/cjs/components/markdown-viewer/markdown-viewer.cjs +1 -1
  15. package/dist/cjs/components/next/index.cjs +1 -1
  16. package/dist/cjs/components/next/siwe-provider.cjs +1 -0
  17. package/dist/cjs/components/table/editable-grid-table.cjs +1 -1
  18. package/dist/cjs/components/table/editable-table.cjs +1 -1
  19. package/dist/cjs/components/time-to-liquidation/time-to-liquidation.cjs +1 -1
  20. package/dist/cjs/components/tokens-list-cell/tokens-list-cell.cjs +1 -1
  21. package/dist/cjs/components/with-copy/with-copy.cjs +1 -1
  22. package/dist/cjs/index.cjs +1 -1
  23. package/dist/esm/components/assets-list-cell/assets-list-cell.js +4 -3
  24. package/dist/esm/components/auth/connect-required.js +11 -18
  25. package/dist/esm/components/auth/index.js +4 -5
  26. package/dist/esm/components/auth/signin-required.js +23 -30
  27. package/dist/esm/components/block-sync/block-sync.js +4 -3
  28. package/dist/esm/components/checkbox/checkbox-labeled.js +2 -1
  29. package/dist/esm/components/client-adapters/styled-rounded-image/styled-rounded-image.js +2 -1
  30. package/dist/esm/components/complex-input/complex-input.js +4 -3
  31. package/dist/esm/components/compound-apy/compound-apy.js +4 -3
  32. package/dist/esm/components/detailed-page-title/detailed-page-title.js +2 -1
  33. package/dist/esm/components/graph/graph.js +164 -167
  34. package/dist/esm/components/index.js +607 -608
  35. package/dist/esm/components/markdown-viewer/markdown-viewer.js +4 -3
  36. package/dist/esm/components/next/index.js +8 -6
  37. package/dist/esm/components/next/{connectkit/siwe-provider.js → siwe-provider.js} +1 -1
  38. package/dist/esm/components/table/editable-grid-table.js +37 -36
  39. package/dist/esm/components/table/editable-table.js +18 -17
  40. package/dist/esm/components/time-to-liquidation/time-to-liquidation.js +2 -1
  41. package/dist/esm/components/tokens-list-cell/tokens-list-cell.js +4 -3
  42. package/dist/esm/components/with-copy/with-copy.js +4 -3
  43. package/dist/esm/index.js +767 -768
  44. package/dist/types/components/auth/connect-required.d.ts +11 -10
  45. package/dist/types/components/auth/index.d.ts +1 -1
  46. package/dist/types/components/auth/signin-required.d.ts +5 -7
  47. package/dist/types/components/auth/siwe-provider.d.ts +31 -0
  48. package/dist/types/components/filter/filter-modal.d.ts +1 -1
  49. package/dist/types/components/next/index.d.ts +1 -0
  50. package/dist/types/components/next/siwe-provider.d.ts +7 -0
  51. package/dist/types/components/simple-accordion/simple-accordion.d.ts +1 -1
  52. package/package.json +16 -22
  53. package/dist/cjs/components/auth/wallet-ui-context.cjs +0 -1
  54. package/dist/cjs/components/connectkit/connect-kit-wallet-adapter.cjs +0 -1
  55. package/dist/cjs/components/connectkit/index.cjs +0 -1
  56. package/dist/cjs/components/next/connectkit/index.cjs +0 -1
  57. package/dist/cjs/components/next/connectkit/siwe-provider.cjs +0 -1
  58. package/dist/esm/components/auth/wallet-ui-context.js +0 -13
  59. package/dist/esm/components/connectkit/connect-kit-wallet-adapter.js +0 -32
  60. package/dist/esm/components/connectkit/index.js +0 -6
  61. package/dist/esm/components/next/connectkit/index.js +0 -4
  62. package/dist/types/components/auth/wallet-ui-context.d.ts +0 -36
  63. package/dist/types/components/connectkit/connect-kit-wallet-adapter.d.ts +0 -12
  64. package/dist/types/components/connectkit/index.d.ts +0 -2
  65. package/dist/types/components/connectkit/siwe-provider.d.ts +0 -30
  66. package/dist/types/components/next/connectkit/index.d.ts +0 -1
  67. package/dist/types/components/next/connectkit/siwe-provider.d.ts +0 -8
  68. /package/dist/cjs/components/{connectkit → auth}/siwe-provider.cjs +0 -0
  69. /package/dist/esm/components/{connectkit → auth}/siwe-provider.js +0 -0
@@ -1,24 +1,24 @@
1
1
  import { jsxs as j, jsx as h } from "react/jsx-runtime";
2
- import { createChart as It, CrosshairMode as zt, AreaSeries as $t } from "lightweight-charts";
3
- import * as lt from "react";
4
- import { useRef as M, useState as it, useEffect as D } from "react";
5
- import { useIsMobile as Dt } from "../../hooks/use-media-query.js";
6
- import { cn as ut } from "../../utils/cn.js";
7
- import { resolveCSSColor as wt, generateColorsFromBase as q, hslToHex as Et } from "../../utils/colors.js";
8
- import { getDefaultOptions as Rt, getDefaultSeries as Gt, getDefaultVerticalLine as Ot } from "./default-config.js";
9
- import { getXFormatters as yt, createAdaptiveYAxisFormatter as Bt, formatExactValue as st } from "./formatters.js";
10
- import { GraphCurrentValue as Yt } from "./graph-current-value.js";
11
- import { GraphTooltip as Ht } from "./graph-tooltip.js";
12
- import { VertLine as jt } from "./plugins/vertical-line.js";
13
- function Wt(e, v, m) {
14
- const A = e.labelText ?? "", f = e.value, S = f === void 0 ? "" : typeof f == "number" ? v === "$" ? `$${st(f, void 0, m)}` : v === "%" ? `${st(f, void 0, m)}%` : st(
2
+ import { createChart as At, CrosshairMode as It, AreaSeries as zt } from "lightweight-charts";
3
+ import * as at from "react";
4
+ import { useRef as z, useState as lt, useEffect as D } from "react";
5
+ import { useIsMobile as $t } from "../../hooks/use-media-query.js";
6
+ import { cn as ct } from "../../utils/cn.js";
7
+ import { resolveCSSColor as St, generateColorsFromBase as X, hslToHex as Dt } from "../../utils/colors.js";
8
+ import { getDefaultOptions as wt, getDefaultSeries as Et, getDefaultVerticalLine as Gt } from "./default-config.js";
9
+ import { getXFormatters as Rt, createAdaptiveYAxisFormatter as Bt, formatExactValue as it } from "./formatters.js";
10
+ import { GraphCurrentValue as Ot } from "./graph-current-value.js";
11
+ import { GraphTooltip as Yt } from "./graph-tooltip.js";
12
+ import { VertLine as Ht } from "./plugins/vertical-line.js";
13
+ function jt(e, v, m) {
14
+ const M = e.labelText ?? "", f = e.value, S = f === void 0 ? "" : typeof f == "number" ? v === "$" ? `$${it(f, void 0, m)}` : v === "%" ? `${it(f, void 0, m)}%` : it(
15
15
  f,
16
16
  v !== "none" && v !== "%" && v !== "$" ? v : void 0,
17
17
  m
18
18
  ) : String(f);
19
- return { labelText: A, valueStr: S };
19
+ return { labelText: M, valueStr: S };
20
20
  }
21
- const ct = [
21
+ const st = [
22
22
  // 0 green (emerald)
23
23
  {
24
24
  line: "#02c39a",
@@ -133,95 +133,92 @@ const ct = [
133
133
  top: "rgba(71, 85, 105, 0.56)",
134
134
  bottom: "rgba(71, 85, 105, 0.04)"
135
135
  }
136
- ], _t = 137.5;
136
+ ], Wt = 137.5;
137
137
  function Vt(e) {
138
- if (e < ct.length)
139
- return ct[e];
140
- const m = (e - ct.length) * _t % 360, A = Et(m, 70, 50), { topColor: f, bottomColor: S } = q(A);
141
- return { line: A, top: f, bottom: S };
138
+ if (e < st.length)
139
+ return st[e];
140
+ const m = (e - st.length) * Wt % 360, M = Dt(m, 70, 50), { topColor: f, bottomColor: S } = X(M);
141
+ return { line: M, top: f, bottom: S };
142
142
  }
143
- function se({
143
+ function ie({
144
144
  series: e,
145
145
  className: v,
146
146
  showLegend: m = !1,
147
- onUnselectSeries: A,
147
+ onUnselectSeries: M,
148
148
  xMeasureUnit: f = "time",
149
149
  yMeasureUnit: S = "token",
150
150
  optionsOverrides: Y,
151
151
  verticalLineOptions: C,
152
- currentValueDecimals: Z,
153
- useSharedPriceScale: V = !1,
154
- showCurrentValue: kt = !0,
155
- graphTitle: K,
156
- yScaleMin: ft,
157
- yScaleMinMultiple: dt
152
+ currentValueDecimals: q,
153
+ useSharedPriceScale: y = !1,
154
+ showCurrentValue: yt = !0,
155
+ graphTitle: Z,
156
+ yScaleMin: ut,
157
+ yScaleMinMultiple: ft
158
158
  }) {
159
- const k = M(null), w = M(/* @__PURE__ */ new Map()), J = M(!1), gt = M(!0), Q = M(
159
+ const k = z(null), w = z(/* @__PURE__ */ new Map()), K = z(!1), gt = z(!0), J = z(
160
160
  null
161
- ), Nt = M(null), $ = M(null), U = M(null), W = M(null), y = Dt(), I = lt.useMemo(() => e.flatMap((t) => t.data), [e]), Pt = lt.useMemo(() => {
161
+ ), kt = z(null), $ = z(null), Q = z(null), V = $t(), A = at.useMemo(() => e.flatMap((t) => t.data), [e]), Nt = at.useMemo(() => {
162
162
  if (e.length > 0) {
163
163
  const t = e[e.length - 1];
164
164
  if (t.data.length > 0)
165
165
  return t.data[t.data.length - 1];
166
166
  }
167
- }, [e]), [mt, tt] = it(() => {
168
- if (!Pt) return;
167
+ }, [e]), [dt, U] = lt(() => {
168
+ if (!Nt) return;
169
169
  const t = /* @__PURE__ */ new Map();
170
170
  for (const a of e)
171
171
  a.data.length > 0 && t.set(a.label, a.data[a.data.length - 1]);
172
172
  return t;
173
- }), [bt, z] = it(null), [ht, pt] = it([]);
173
+ }), [mt, I] = lt(null), [bt, ht] = lt([]);
174
174
  D(() => {
175
175
  const t = () => {
176
- try {
177
- if (k.current && $.current) {
178
- const l = $.current.clientWidth, s = $.current.clientHeight;
179
- k.current.resize(l, s);
180
- }
181
- } catch {
176
+ if (k.current && $.current) {
177
+ const l = $.current.clientWidth, s = $.current.clientHeight;
178
+ k.current.resize(l, s);
182
179
  }
183
180
  }, a = $.current, r = a ? new ResizeObserver(t) : null;
184
- return W.current = r, a && r?.observe(a), () => {
185
- a && r?.unobserve(a), r?.disconnect(), W.current = null;
181
+ return a && r?.observe(a), () => {
182
+ a && r?.unobserve(a);
186
183
  };
187
184
  }, []), D(() => {
188
- if (!U.current || J.current) return;
189
- const t = Rt(), a = wt(
185
+ if (!Q.current || K.current) return;
186
+ const t = wt(), a = St(
190
187
  "hsl(var(--foreground))",
191
188
  "rgb(0, 0, 0)"
192
- ), r = It(U.current, {
189
+ ), r = At(Q.current, {
193
190
  ...t,
194
191
  rightPriceScale: {
195
192
  ...t.rightPriceScale || {},
196
- visible: !y,
193
+ visible: !V,
197
194
  textColor: a
198
195
  },
199
- ...y && {
196
+ ...V && {
200
197
  crosshair: {
201
198
  ...t.crosshair,
202
- mode: zt.Magnet
199
+ mode: It.Magnet
203
200
  }
204
201
  },
205
202
  ...Y
206
203
  });
207
- return k.current = r, J.current = !0, () => {
208
- W.current?.disconnect(), W.current = null, r.remove(), k.current = null, J.current = !1, w.current.clear();
204
+ return k.current = r, K.current = !0, () => {
205
+ r.remove(), k.current = null, K.current = !1, w.current.clear();
209
206
  };
210
- }, [y, Y]), D(() => {
207
+ }, [V, Y]), D(() => {
211
208
  const t = k.current;
212
209
  if (!t || e.length === 0) return;
213
- const r = e.filter((o) => o.data.length > 0).length <= 1 ? ft : dt, l = f === "time" ? yt(f, I) : yt(f), s = I.map((o) => o.value), {
210
+ const r = e.filter((o) => o.data.length > 0).length <= 1 ? ut : ft, l = f === "time" ? Rt(f, A) : Rt(f), s = A.map((o) => o.value), {
214
211
  formatter: c,
215
212
  tickmarksFormatter: u,
216
213
  updateVisibleRange: N,
217
- updateLastValues: d
214
+ updateLastValues: g
218
215
  } = Bt(s, S, {
219
216
  yScaleMin: r
220
217
  });
221
- Q.current = N, Nt.current = d;
218
+ J.current = N, kt.current = g;
222
219
  const P = e.filter((o) => o.data.length > 0).map((o) => o.data[o.data.length - 1].value);
223
- d(P);
224
- const L = Rt();
220
+ g(P);
221
+ const L = wt();
225
222
  t.applyOptions({
226
223
  localization: {
227
224
  ...L.localization || {},
@@ -238,7 +235,7 @@ function se({
238
235
  minBarSpacing: 0
239
236
  }
240
237
  });
241
- const g = (I.length > 0 ? Math.min(...I.map((o) => o.value)) : 0) < 0, x = I.some((o) => o.value === 0), b = !g && x, p = e.length > 1 && !V, T = e.length > 1 && !V || y, F = wt(
238
+ const d = (A.length > 0 ? Math.min(...A.map((o) => o.value)) : 0) < 0, x = A.some((o) => o.value === 0), b = !d && x, p = e.length > 1 && !y, T = e.length > 1 && !y || V, F = St(
242
239
  "hsl(var(--foreground))",
243
240
  "rgb(0, 0, 0)"
244
241
  );
@@ -255,83 +252,83 @@ function se({
255
252
  }
256
253
  }
257
254
  });
258
- const et = new Set(w.current.keys()), ot = new Set(e.map((o) => o.label));
259
- for (const o of et)
260
- if (!ot.has(o)) {
255
+ const tt = new Set(w.current.keys()), et = new Set(e.map((o) => o.label));
256
+ for (const o of tt)
257
+ if (!et.has(o)) {
261
258
  const n = w.current.get(o);
262
259
  n && (t.removeSeries(n), w.current.delete(o));
263
260
  }
264
- const Lt = Gt(), rt = [];
265
- let X = 0;
261
+ const Pt = Et(), ot = [];
262
+ let _ = 0;
266
263
  for (let o = 0; o < e.length; o++) {
267
264
  const n = e[o], H = Vt(o), E = n.lineColor ?? n.color ?? H.line;
268
- let G, O;
265
+ let G, B;
269
266
  if (n.lineColor ?? n.color)
270
267
  if (n.topColor && n.bottomColor)
271
- G = n.topColor, O = n.bottomColor;
268
+ G = n.topColor, B = n.bottomColor;
272
269
  else if (n.topColor) {
273
- const i = q(E);
274
- G = n.topColor, O = i.bottomColor;
270
+ const i = X(E);
271
+ G = n.topColor, B = i.bottomColor;
275
272
  } else if (n.bottomColor)
276
- G = q(E).topColor, O = n.bottomColor;
273
+ G = X(E).topColor, B = n.bottomColor;
277
274
  else {
278
- const i = q(E);
279
- G = i.topColor, O = i.bottomColor;
275
+ const i = X(E);
276
+ G = i.topColor, B = i.bottomColor;
280
277
  }
281
278
  else
282
- G = n.topColor || H.top, O = n.bottomColor || H.bottom;
279
+ G = n.topColor || H.top, B = n.bottomColor || H.bottom;
283
280
  if (n.data.length === 0) {
284
281
  const i = w.current.get(n.label);
285
282
  i && (t.removeSeries(i), w.current.delete(n.label));
286
283
  continue;
287
284
  }
288
- const Tt = (n.data.length > 0 ? Math.min(...n.data.map((i) => i.value)) : 0) < 0, Ft = n.data.some((i) => i.value === 0), Mt = !Tt && Ft, Ct = V || !p || X === 0 ? "right" : `scale-${X}`;
289
- p && rt.push({
290
- priceScaleId: Ct || "right",
291
- shouldPreventNegativeAxis: Mt,
292
- seriesIndex: X
285
+ const Lt = (n.data.length > 0 ? Math.min(...n.data.map((i) => i.value)) : 0) < 0, Tt = n.data.some((i) => i.value === 0), Ft = !Lt && Tt, vt = y || !p || _ === 0 ? "right" : `scale-${_}`;
286
+ p && ot.push({
287
+ priceScaleId: vt || "right",
288
+ shouldPreventNegativeAxis: Ft,
289
+ seriesIndex: _
293
290
  });
294
- const xt = (V || !p) && r !== void 0 && typeof r == "number", St = {
291
+ const Ct = (y || !p) && r !== void 0 && typeof r == "number", xt = {
295
292
  lineColor: E,
296
293
  topColor: G,
297
- bottomColor: O,
298
- priceScaleId: Ct,
294
+ bottomColor: B,
295
+ priceScaleId: vt,
299
296
  priceFormat: {
300
297
  type: "custom",
301
298
  minMove: 0.01,
302
- formatter: xt && typeof r == "number" ? (i) => c(
299
+ formatter: Ct && typeof r == "number" ? (i) => c(
303
300
  i < r ? r : i
304
301
  ) : c,
305
302
  tickmarksFormatter: u
306
303
  },
307
304
  autoscaleInfoProvider: (i) => {
308
- if (!xt) return i();
309
- const at = i();
310
- if (at?.priceRange) {
311
- const At = r;
312
- at.priceRange.minValue = At;
305
+ if (!Ct) return i();
306
+ const nt = i();
307
+ if (nt?.priceRange) {
308
+ const Mt = r;
309
+ nt.priceRange.minValue = Mt;
313
310
  }
314
- return at;
311
+ return nt;
315
312
  }
316
313
  };
317
- let B = w.current.get(n.label);
318
- B ? (B.applyOptions(St), B.setData(
314
+ let O = w.current.get(n.label);
315
+ O ? (O.applyOptions(xt), O.setData(
319
316
  n.data.map((i) => ({
320
317
  ...i,
321
318
  time: i.time
322
319
  }))
323
- )) : (B = t.addSeries($t, {
324
- ...Lt,
325
- ...St
326
- }), B.setData(
320
+ )) : (O = t.addSeries(zt, {
321
+ ...Pt,
322
+ ...xt
323
+ }), O.setData(
327
324
  n.data.map((i) => ({
328
325
  ...i,
329
326
  time: i.time
330
327
  }))
331
- ), w.current.set(n.label, B)), X++;
328
+ ), w.current.set(n.label, O)), _++;
332
329
  }
333
- if (p && rt.length > 0)
334
- for (const o of rt)
330
+ if (p && ot.length > 0)
331
+ for (const o of ot)
335
332
  try {
336
333
  const n = t.priceScale(o.priceScaleId);
337
334
  n && n.applyOptions({
@@ -361,7 +358,7 @@ function se({
361
358
  try {
362
359
  const o = t.priceScale("right");
363
360
  o && o.applyOptions({
364
- visible: !y,
361
+ visible: !V,
365
362
  autoScale: !0,
366
363
  scaleMargins: {
367
364
  top: 0.1,
@@ -379,28 +376,28 @@ function se({
379
376
  });
380
377
  } catch {
381
378
  }
382
- if (r !== void 0 && !y && (V || !p) && t.applyOptions({
379
+ if (r !== void 0 && !V && (y || !p) && t.applyOptions({
383
380
  handleScroll: {
384
381
  vertTouchDrag: !1
385
382
  }
386
- }), I.length > 0) {
387
- const o = I.map((E) => Number(E.time)), n = Math.min(...o), H = Math.max(...o);
383
+ }), A.length > 0) {
384
+ const o = A.map((E) => Number(E.time)), n = Math.min(...o), H = Math.max(...o);
388
385
  t.timeScale().setVisibleRange({ from: n, to: H });
389
386
  }
390
387
  gt.current && (gt.current = !1);
391
- const nt = /* @__PURE__ */ new Map();
388
+ const rt = /* @__PURE__ */ new Map();
392
389
  for (const o of e)
393
- o.data.length > 0 && nt.set(o.label, o.data[o.data.length - 1]);
394
- tt(nt.size > 0 ? nt : void 0);
390
+ o.data.length > 0 && rt.set(o.label, o.data[o.data.length - 1]);
391
+ U(rt.size > 0 ? rt : void 0);
395
392
  }, [
396
393
  e,
397
- I,
394
+ A,
398
395
  f,
399
396
  S,
400
- y,
401
397
  V,
402
- ft,
403
- dt
398
+ y,
399
+ ut,
400
+ ft
404
401
  ]), D(() => {
405
402
  const t = k.current;
406
403
  if (!t || e.length === 0) return;
@@ -413,18 +410,18 @@ function se({
413
410
  }
414
411
  if (!r) return;
415
412
  const l = (s) => {
416
- const { time: c = r, seriesData: u, point: N } = s || {}, d = Array.from(w.current.values());
413
+ const { time: c = r, seriesData: u, point: N } = s || {}, g = Array.from(w.current.values());
417
414
  if (!N || !c) {
418
415
  const R = /* @__PURE__ */ new Map();
419
- for (const g of e)
420
- g.data.length > 0 && R.set(g.label, g.data[g.data.length - 1]);
421
- if (tt(R.size > 0 ? R : void 0), a || V)
422
- z(null);
423
- else if (d[0] && r) {
416
+ for (const d of e)
417
+ d.data.length > 0 && R.set(d.label, d.data[d.data.length - 1]);
418
+ if (U(R.size > 0 ? R : void 0), a || y)
419
+ I(null);
420
+ else if (g[0] && r) {
424
421
  const x = t.timeScale().timeToCoordinate(r), b = e[0];
425
422
  if (b.data.length > 0) {
426
- const p = b.data[b.data.length - 1].value, T = d[0].priceToCoordinate(p);
427
- x !== null && T !== null && z({ x, y: T });
423
+ const p = b.data[b.data.length - 1].value, T = g[0].priceToCoordinate(p);
424
+ x !== null && T !== null && I({ x, y: T });
428
425
  }
429
426
  }
430
427
  return;
@@ -432,54 +429,54 @@ function se({
432
429
  const P = /* @__PURE__ */ new Map();
433
430
  let L;
434
431
  for (let R = 0; R < e.length; R++) {
435
- const g = e[R], x = d[R];
432
+ const d = e[R], x = g[R];
436
433
  if (!x) continue;
437
- const b = u?.get(x), p = b && "value" in b ? b.value : void 0, T = g.data[g.data.length - 1], F = p !== void 0 ? p : T?.value ?? 0;
438
- R === 0 && (L = F), P.set(g.label, { value: F, time: c });
434
+ const b = u?.get(x), p = b && "value" in b ? b.value : void 0, T = d.data[d.data.length - 1], F = p !== void 0 ? p : T?.value ?? 0;
435
+ R === 0 && (L = F), P.set(d.label, { value: F, time: c });
439
436
  }
440
- if (tt(P), L !== void 0 && d[0]) {
441
- const g = t.timeScale().timeToCoordinate(c), x = d[0].priceToCoordinate(L);
442
- if (g !== null && x !== null) {
437
+ if (U(P), L !== void 0 && g[0]) {
438
+ const d = t.timeScale().timeToCoordinate(c), x = g[0].priceToCoordinate(L);
439
+ if (d !== null && x !== null) {
443
440
  const b = $.current;
444
441
  if (b) {
445
442
  const p = b.querySelector(
446
443
  ".LightweightChart"
447
444
  );
448
445
  if (p) {
449
- const T = p.getBoundingClientRect(), F = b.getBoundingClientRect(), et = g + (T.left - F.left), ot = x + (T.top - F.top);
450
- z({ x: et, y: ot });
446
+ const T = p.getBoundingClientRect(), F = b.getBoundingClientRect(), tt = d + (T.left - F.left), et = x + (T.top - F.top);
447
+ I({ x: tt, y: et });
451
448
  } else
452
- z({ x: g, y: x });
449
+ I({ x: d, y: x });
453
450
  } else
454
- z({ x: g, y: x });
451
+ I({ x: d, y: x });
455
452
  } else
456
- z(null);
453
+ I(null);
457
454
  } else
458
- z(null);
455
+ I(null);
459
456
  };
460
- return t.subscribeCrosshairMove(l), y && t.subscribeClick(l), !a && !V && requestAnimationFrame(() => {
457
+ return t.subscribeCrosshairMove(l), V && t.subscribeClick(l), !a && !y && requestAnimationFrame(() => {
461
458
  const s = Array.from(w.current.values());
462
459
  if (s[0] && r && e[0]?.data.length > 0) {
463
- const u = t.timeScale().timeToCoordinate(r), N = e[0].data[e[0].data.length - 1].value, d = s[0].priceToCoordinate(N);
464
- u !== null && d !== null && z({ x: u, y: d });
460
+ const u = t.timeScale().timeToCoordinate(r), N = e[0].data[e[0].data.length - 1].value, g = s[0].priceToCoordinate(N);
461
+ u !== null && g !== null && I({ x: u, y: g });
465
462
  }
466
463
  }), () => {
467
- t.unsubscribeCrosshairMove(l), y && t.unsubscribeClick(l);
464
+ t.unsubscribeCrosshairMove(l), V && t.unsubscribeClick(l);
468
465
  };
469
- }, [e, V, y]), D(() => {
466
+ }, [e, y, V]), D(() => {
470
467
  const t = k.current;
471
468
  if (!t || e.length === 0) return;
472
469
  const a = t.timeScale(), r = () => {
473
- if (!Q.current) return;
470
+ if (!J.current) return;
474
471
  const l = a.getVisibleRange();
475
472
  if (!l) return;
476
473
  const s = Number(l.from), c = Number(l.to), u = [];
477
474
  for (const N of e)
478
- for (const d of N.data) {
479
- const P = Number(d.time);
480
- P >= s && P <= c && u.push(d.value);
475
+ for (const g of N.data) {
476
+ const P = Number(g.time);
477
+ P >= s && P <= c && u.push(g.value);
481
478
  }
482
- u.length > 0 && Q.current(u);
479
+ u.length > 0 && J.current(u);
483
480
  };
484
481
  return a.subscribeVisibleLogicalRangeChange(r), () => {
485
482
  a.unsubscribeVisibleLogicalRangeChange(
@@ -489,9 +486,9 @@ function se({
489
486
  }, [e]), D(() => {
490
487
  const t = k.current, a = Array.from(w.current.values()), r = [];
491
488
  if (t && a.length > 0 && C) {
492
- const l = Ot(), s = a[0];
489
+ const l = Gt(), s = a[0];
493
490
  for (const c of C) {
494
- const u = new jt(t, s, c.xCoordinate, {
491
+ const u = new Ht(t, s, c.xCoordinate, {
495
492
  ...l,
496
493
  ...c.options || {}
497
494
  });
@@ -508,12 +505,12 @@ function se({
508
505
  }, [C]), D(() => {
509
506
  const t = k.current;
510
507
  if (!t || !C?.length) {
511
- pt([]);
508
+ ht([]);
512
509
  return;
513
510
  }
514
511
  const a = () => {
515
512
  const s = t.timeScale(), c = C.map((u) => s.timeToCoordinate(u.xCoordinate) ?? null);
516
- pt(c);
513
+ ht(c);
517
514
  };
518
515
  a();
519
516
  const r = t.timeScale(), l = () => {
@@ -523,59 +520,59 @@ function se({
523
520
  r.unsubscribeVisibleLogicalRangeChange(l);
524
521
  };
525
522
  }, [C]);
526
- const _ = e.length === 1, vt = lt.useMemo(() => {
527
- if (_ && e.length > 0) {
523
+ const W = e.length === 1, pt = at.useMemo(() => {
524
+ if (W && e.length > 0) {
528
525
  const t = e[0];
529
526
  if (t.data.length > 0)
530
527
  return t.data[t.data.length - 1];
531
528
  }
532
- }, [_, e]);
529
+ }, [W, e]);
533
530
  return /* @__PURE__ */ j(
534
531
  "div",
535
532
  {
536
533
  ref: $,
537
- className: ut(
534
+ className: ct(
538
535
  "relative z-[1] w-full h-full overflow-hidden p-0",
539
536
  v
540
537
  ),
541
538
  children: [
542
- K != null && K !== !1 && _ ? /* @__PURE__ */ h("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ h("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: K }) }) : kt && _ && vt && /* @__PURE__ */ h(
543
- Yt,
539
+ Z != null && Z !== !1 && W ? /* @__PURE__ */ h("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ h("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: Z }) }) : yt && W && pt && /* @__PURE__ */ h(
540
+ Ot,
544
541
  {
545
- point: vt,
542
+ point: pt,
546
543
  xMeasureUnit: f,
547
544
  yMeasureUnit: S,
548
- decimals: Z
545
+ decimals: q
549
546
  }
550
547
  ),
551
- mt && bt && /* @__PURE__ */ h(
552
- Ht,
548
+ dt && mt && /* @__PURE__ */ h(
549
+ Yt,
553
550
  {
554
- points: mt,
551
+ points: dt,
555
552
  xMeasureUnit: f,
556
553
  yMeasureUnit: S,
557
554
  series: e,
558
- position: bt,
555
+ position: mt,
559
556
  containerRef: $,
560
- decimals: Z
557
+ decimals: q
561
558
  }
562
559
  ),
563
- m && /* @__PURE__ */ h(Xt, { series: e, onUnselect: A }),
564
- C && C.length > 0 && ht.length === C.length && /* @__PURE__ */ h(
560
+ m && /* @__PURE__ */ h(_t, { series: e, onUnselect: M }),
561
+ C && C.length > 0 && bt.length === C.length && /* @__PURE__ */ h(
565
562
  "div",
566
563
  {
567
564
  className: "absolute inset-0 z-[5] pointer-events-none",
568
565
  "aria-hidden": !0,
569
566
  children: C.map((t, a) => {
570
- const r = ht[a], l = t.options ?? {}, s = l.showLabel !== !1;
567
+ const r = bt[a], l = t.options ?? {}, s = l.showLabel !== !1;
571
568
  if (r === null || !s) return null;
572
- const { labelText: c, valueStr: u } = Wt(
569
+ const { labelText: c, valueStr: u } = jt(
573
570
  l,
574
571
  S,
575
- Z
572
+ q
576
573
  );
577
574
  if (!(c || u)) return null;
578
- const d = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", P = l.labelTextColor ?? "hsl(var(--foreground))", L = `${String(t.xCoordinate)}-${c}`;
575
+ const g = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", P = l.labelTextColor ?? "hsl(var(--foreground))", L = `${String(t.xCoordinate)}-${c}`;
579
576
  return /* @__PURE__ */ j(
580
577
  "div",
581
578
  {
@@ -583,12 +580,12 @@ function se({
583
580
  style: {
584
581
  left: r,
585
582
  transform: "translateX(-50%)",
586
- backgroundColor: d,
583
+ backgroundColor: g,
587
584
  color: P
588
585
  },
589
586
  children: [
590
587
  c && /* @__PURE__ */ h("span", { className: "block", children: c }),
591
- u && /* @__PURE__ */ h("span", { className: ut("block", c && "mt-0.5"), children: u })
588
+ u && /* @__PURE__ */ h("span", { className: ct("block", c && "mt-0.5"), children: u })
592
589
  ]
593
590
  },
594
591
  L
@@ -599,7 +596,7 @@ function se({
599
596
  /* @__PURE__ */ h(
600
597
  "div",
601
598
  {
602
- ref: U,
599
+ ref: Q,
603
600
  className: "LightweightChart w-full h-full overflow-hidden"
604
601
  }
605
602
  )
@@ -607,16 +604,16 @@ function se({
607
604
  }
608
605
  );
609
606
  }
610
- function Xt({
607
+ function _t({
611
608
  series: e,
612
609
  onUnselect: v
613
610
  }) {
614
- return /* @__PURE__ */ h("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((m, A) => {
615
- const f = Vt(A), S = (m.lineColor ?? m.color) || f.line, Y = m.data.length === 0;
611
+ return /* @__PURE__ */ h("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((m, M) => {
612
+ const f = Vt(M), S = (m.lineColor ?? m.color) || f.line, Y = m.data.length === 0;
616
613
  return /* @__PURE__ */ j(
617
614
  "div",
618
615
  {
619
- className: ut(
616
+ className: ct(
620
617
  "flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
621
618
  Y && "opacity-50"
622
619
  ),
@@ -671,8 +668,8 @@ function Xt({
671
668
  }) });
672
669
  }
673
670
  export {
674
- ct as DEFAULT_SERIES_COLORS,
675
- se as Graph,
671
+ st as DEFAULT_SERIES_COLORS,
672
+ ie as Graph,
676
673
  Vt as getSeriesColorPalette,
677
- Wt as getVerticalLineTooltipContent
674
+ jt as getVerticalLineTooltipContent
678
675
  };