@gearbox-protocol/ui-kit 3.0.0 → 3.1.0-next.2

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