@gearbox-protocol/ui-kit 3.14.0-next.35 → 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.
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createChart as
|
|
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
3
|
import * as Ce from "react";
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { useIsMobile as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { resolveCSSColor as
|
|
8
|
-
import { getDefaultOptions as
|
|
9
|
-
import { getXFormatters as
|
|
10
|
-
import { GraphCurrentValue as
|
|
11
|
-
import { GraphTooltip as
|
|
12
|
-
import { VertLine as
|
|
13
|
-
class
|
|
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(s,
|
|
18
|
-
this._yTop = s, this._yBottom =
|
|
17
|
+
constructor(s, g, m) {
|
|
18
|
+
this._yTop = s, this._yBottom = g, this._color = m;
|
|
19
19
|
}
|
|
20
20
|
draw(s) {
|
|
21
|
-
s.useBitmapCoordinateSpace((
|
|
22
|
-
const m =
|
|
23
|
-
m.fillStyle = this._color, m.fillRect(0,
|
|
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
|
|
27
|
+
class ht {
|
|
28
28
|
_source;
|
|
29
29
|
_yTop = null;
|
|
30
30
|
_yBottom = null;
|
|
@@ -40,17 +40,17 @@ class ft {
|
|
|
40
40
|
return "bottom";
|
|
41
41
|
}
|
|
42
42
|
renderer() {
|
|
43
|
-
return new
|
|
43
|
+
return new ft(this._yTop, this._yBottom, this._source.color);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
class
|
|
46
|
+
class gt {
|
|
47
47
|
series;
|
|
48
48
|
priceTop;
|
|
49
49
|
priceBottom;
|
|
50
50
|
color;
|
|
51
51
|
_paneViews;
|
|
52
|
-
constructor(s,
|
|
53
|
-
this.series = s, this.priceTop =
|
|
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
56
|
for (const s of this._paneViews) s.update();
|
|
@@ -59,18 +59,18 @@ class ht {
|
|
|
59
59
|
return this._paneViews;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const m =
|
|
64
|
-
|
|
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
65
|
s !== "none" && s !== "%" && s !== "$" ? s : void 0,
|
|
66
|
-
|
|
67
|
-
) : String(
|
|
68
|
-
return { labelText: m, valueStr:
|
|
66
|
+
g
|
|
67
|
+
) : String(d);
|
|
68
|
+
return { labelText: m, valueStr: N };
|
|
69
69
|
}
|
|
70
|
-
function mt(
|
|
71
|
-
for (let
|
|
72
|
-
if (Number(
|
|
73
|
-
return
|
|
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
76
|
const ye = [
|
|
@@ -188,72 +188,70 @@ const ye = [
|
|
|
188
188
|
top: "rgba(71, 85, 105, 0.56)",
|
|
189
189
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
190
190
|
}
|
|
191
|
-
],
|
|
192
|
-
function
|
|
193
|
-
if (
|
|
194
|
-
return ye[
|
|
195
|
-
const
|
|
196
|
-
return { line: m, top:
|
|
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
198
|
function Lt({
|
|
199
|
-
series:
|
|
199
|
+
series: o,
|
|
200
200
|
className: s,
|
|
201
|
-
showLegend:
|
|
201
|
+
showLegend: g = !1,
|
|
202
202
|
onUnselectSeries: m,
|
|
203
|
-
xMeasureUnit:
|
|
204
|
-
yMeasureUnit:
|
|
205
|
-
optionsOverrides:
|
|
206
|
-
verticalLineOptions:
|
|
207
|
-
priceLineOptions:
|
|
208
|
-
zoneOptions:
|
|
209
|
-
currentValueDecimals:
|
|
210
|
-
useSharedPriceScale:
|
|
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
211
|
dualYAxis: L = !1,
|
|
212
212
|
defaultVisiblePriceScaleId: we = "right",
|
|
213
213
|
leftPriceScaleTitle: Te,
|
|
214
|
-
rightPriceScaleTitle:
|
|
215
|
-
showCurrentValue:
|
|
216
|
-
graphTitle:
|
|
214
|
+
rightPriceScaleTitle: vt,
|
|
215
|
+
showCurrentValue: qe = !0,
|
|
216
|
+
graphTitle: ue,
|
|
217
217
|
yScaleMin: Ne,
|
|
218
218
|
yScaleMinMultiple: Ve,
|
|
219
|
-
visibleTimeFrom:
|
|
220
|
-
disableZoom:
|
|
221
|
-
hideDefaultTooltip:
|
|
219
|
+
visibleTimeFrom: Z,
|
|
220
|
+
disableZoom: le = !1,
|
|
221
|
+
hideDefaultTooltip: fe = !1
|
|
222
222
|
}) {
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (e.data.length > 0)
|
|
229
|
-
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];
|
|
230
228
|
}
|
|
231
|
-
}, [
|
|
232
|
-
if (!
|
|
233
|
-
const
|
|
234
|
-
for (const a of
|
|
235
|
-
a.data.length > 0 &&
|
|
236
|
-
return
|
|
237
|
-
}), [
|
|
238
|
-
|
|
239
|
-
const
|
|
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 = () => {
|
|
240
238
|
try {
|
|
241
|
-
if (
|
|
242
|
-
const n =
|
|
243
|
-
|
|
239
|
+
if (I.current && K.current) {
|
|
240
|
+
const n = K.current.clientWidth, i = K.current.clientHeight;
|
|
241
|
+
I.current.resize(n, i);
|
|
244
242
|
}
|
|
245
243
|
} catch {
|
|
246
244
|
}
|
|
247
|
-
}, a =
|
|
248
|
-
return
|
|
249
|
-
a && l?.unobserve(a), l?.disconnect(),
|
|
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;
|
|
250
248
|
};
|
|
251
|
-
}, []),
|
|
252
|
-
if (!
|
|
253
|
-
const
|
|
249
|
+
}, []), W(() => {
|
|
250
|
+
if (!ge.current || he.current) return;
|
|
251
|
+
const t = je(), a = U(
|
|
254
252
|
"hsl(var(--foreground))",
|
|
255
253
|
"rgb(0, 0, 0)"
|
|
256
|
-
), l =
|
|
254
|
+
), l = le ? {
|
|
257
255
|
handleScale: {
|
|
258
256
|
mouseWheel: !1,
|
|
259
257
|
pinch: !1,
|
|
@@ -266,34 +264,34 @@ function Lt({
|
|
|
266
264
|
horzTouchDrag: !1,
|
|
267
265
|
vertTouchDrag: !1
|
|
268
266
|
}
|
|
269
|
-
} : {}, n =
|
|
270
|
-
...
|
|
267
|
+
} : {}, n = Ue(ge.current, {
|
|
268
|
+
...t,
|
|
271
269
|
leftPriceScale: {
|
|
272
|
-
...
|
|
270
|
+
...t.leftPriceScale || {},
|
|
273
271
|
visible: !1,
|
|
274
272
|
textColor: a
|
|
275
273
|
},
|
|
276
274
|
rightPriceScale: {
|
|
277
|
-
...
|
|
278
|
-
visible: !
|
|
275
|
+
...t.rightPriceScale || {},
|
|
276
|
+
visible: !R,
|
|
279
277
|
textColor: a
|
|
280
278
|
},
|
|
281
|
-
...
|
|
279
|
+
...R && {
|
|
282
280
|
crosshair: {
|
|
283
|
-
...
|
|
284
|
-
mode:
|
|
281
|
+
...t.crosshair,
|
|
282
|
+
mode: et.Magnet
|
|
285
283
|
}
|
|
286
284
|
},
|
|
287
285
|
...l,
|
|
288
|
-
...
|
|
286
|
+
...q
|
|
289
287
|
});
|
|
290
|
-
return
|
|
291
|
-
|
|
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();
|
|
292
290
|
};
|
|
293
|
-
}, [
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
291
|
+
}, [R, q, le]), W(() => {
|
|
292
|
+
const t = I.current;
|
|
293
|
+
t && t.applyOptions(
|
|
294
|
+
le ? {
|
|
297
295
|
handleScale: {
|
|
298
296
|
mouseWheel: !1,
|
|
299
297
|
pinch: !1,
|
|
@@ -321,58 +319,89 @@ function Lt({
|
|
|
321
319
|
}
|
|
322
320
|
}
|
|
323
321
|
);
|
|
324
|
-
}, [
|
|
325
|
-
const
|
|
326
|
-
if (!
|
|
327
|
-
const l =
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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({
|
|
340
369
|
localization: {
|
|
341
|
-
...
|
|
370
|
+
...v.localization || {},
|
|
342
371
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
343
|
-
timeFormatter: (
|
|
372
|
+
timeFormatter: (r) => (
|
|
344
373
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
345
|
-
n.timeFormatter(parseFloat(
|
|
374
|
+
n.timeFormatter(parseFloat(r), void 0)
|
|
346
375
|
)
|
|
347
376
|
},
|
|
348
377
|
timeScale: {
|
|
349
|
-
...
|
|
378
|
+
...v.timeScale || {},
|
|
350
379
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
351
380
|
tickMarkFormatter: n.tickMarkFormatter,
|
|
352
381
|
minBarSpacing: 0
|
|
353
382
|
}
|
|
354
383
|
});
|
|
355
|
-
const
|
|
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(
|
|
356
385
|
"hsl(var(--foreground))",
|
|
357
386
|
"rgb(0, 0, 0)"
|
|
358
387
|
);
|
|
359
|
-
|
|
388
|
+
t.applyOptions({
|
|
360
389
|
...L && {
|
|
361
390
|
defaultVisiblePriceScaleId: we
|
|
362
391
|
},
|
|
363
392
|
leftPriceScale: {
|
|
364
|
-
...
|
|
365
|
-
visible: L && !
|
|
366
|
-
textColor:
|
|
393
|
+
...v.leftPriceScale || {},
|
|
394
|
+
visible: L && !R,
|
|
395
|
+
textColor: M,
|
|
367
396
|
...L && Te && {
|
|
368
397
|
// lightweight-charts uses scale margins; title shown via localization if needed
|
|
369
398
|
}
|
|
370
399
|
},
|
|
371
400
|
rightPriceScale: {
|
|
372
|
-
...
|
|
373
|
-
visible: L ? !
|
|
374
|
-
textColor:
|
|
375
|
-
...
|
|
401
|
+
...v.rightPriceScale || {},
|
|
402
|
+
visible: L ? !R : !P,
|
|
403
|
+
textColor: M,
|
|
404
|
+
...p && !L && {
|
|
376
405
|
scaleMargins: {
|
|
377
406
|
top: 0.3,
|
|
378
407
|
bottom: 0
|
|
@@ -380,129 +409,129 @@ function Lt({
|
|
|
380
409
|
}
|
|
381
410
|
}
|
|
382
411
|
});
|
|
383
|
-
const
|
|
384
|
-
for (const
|
|
385
|
-
if (!
|
|
386
|
-
const
|
|
387
|
-
|
|
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));
|
|
388
417
|
}
|
|
389
|
-
const
|
|
390
|
-
let
|
|
391
|
-
const De =
|
|
392
|
-
if (
|
|
393
|
-
for (const
|
|
394
|
-
if (!Number.isFinite(
|
|
395
|
-
const
|
|
396
|
-
if (!
|
|
397
|
-
const
|
|
398
|
-
|
|
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);
|
|
399
428
|
}
|
|
400
|
-
if (
|
|
401
|
-
for (const
|
|
402
|
-
const
|
|
403
|
-
if (!
|
|
404
|
-
const
|
|
405
|
-
Number.isFinite(
|
|
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);
|
|
406
435
|
}
|
|
407
|
-
for (let
|
|
408
|
-
const
|
|
409
|
-
let
|
|
410
|
-
if (
|
|
411
|
-
if (
|
|
412
|
-
|
|
413
|
-
else if (
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
} else if (
|
|
417
|
-
|
|
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;
|
|
418
447
|
else {
|
|
419
|
-
const
|
|
420
|
-
|
|
448
|
+
const h = se(B);
|
|
449
|
+
S = h.topColor, z = h.bottomColor;
|
|
421
450
|
}
|
|
422
451
|
else
|
|
423
|
-
|
|
424
|
-
if (
|
|
425
|
-
const
|
|
426
|
-
|
|
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));
|
|
427
456
|
continue;
|
|
428
457
|
}
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
priceScaleId:
|
|
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",
|
|
432
461
|
shouldPreventNegativeAxis: Ke,
|
|
433
|
-
seriesIndex:
|
|
462
|
+
seriesIndex: te
|
|
434
463
|
});
|
|
435
|
-
const
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
|
|
439
|
-
for (const
|
|
440
|
-
|
|
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);
|
|
441
470
|
}
|
|
442
|
-
return
|
|
443
|
-
},
|
|
444
|
-
lineColor:
|
|
445
|
-
topColor:
|
|
446
|
-
bottomColor:
|
|
447
|
-
priceScaleId:
|
|
448
|
-
...
|
|
449
|
-
lineStyle:
|
|
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
|
|
450
479
|
},
|
|
451
480
|
priceFormat: {
|
|
452
481
|
type: "custom",
|
|
453
482
|
minMove: 0.01,
|
|
454
|
-
formatter:
|
|
455
|
-
|
|
456
|
-
) :
|
|
457
|
-
tickmarksFormatter:
|
|
483
|
+
formatter: ze && typeof l == "number" ? (h) => $e(
|
|
484
|
+
h < l ? l : h
|
|
485
|
+
) : $e,
|
|
486
|
+
tickmarksFormatter: Qe
|
|
458
487
|
},
|
|
459
488
|
autoscaleInfoProvider: Je
|
|
460
|
-
},
|
|
461
|
-
let
|
|
462
|
-
const
|
|
463
|
-
...
|
|
464
|
-
time:
|
|
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
|
|
465
494
|
}));
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
468
|
-
for (let ve =
|
|
469
|
-
|
|
470
|
-
|
|
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);
|
|
471
500
|
}
|
|
472
|
-
|
|
473
|
-
...
|
|
474
|
-
...
|
|
475
|
-
}) :
|
|
476
|
-
...
|
|
477
|
-
...
|
|
478
|
-
}),
|
|
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++;
|
|
479
508
|
}
|
|
480
509
|
if (L)
|
|
481
510
|
try {
|
|
482
|
-
const
|
|
483
|
-
visible: !
|
|
511
|
+
const r = t.priceScale("left"), e = t.priceScale("right"), u = {
|
|
512
|
+
visible: !R,
|
|
484
513
|
autoScale: !0,
|
|
485
514
|
scaleMargins: { top: 0.1, bottom: 0.1 },
|
|
486
515
|
alignLabels: !0,
|
|
487
516
|
borderVisible: !0,
|
|
488
517
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
489
518
|
entireTextOnly: !1,
|
|
490
|
-
textColor:
|
|
519
|
+
textColor: M
|
|
491
520
|
};
|
|
492
|
-
|
|
521
|
+
r?.applyOptions(u), e?.applyOptions(u);
|
|
493
522
|
} catch {
|
|
494
523
|
}
|
|
495
|
-
else if (
|
|
496
|
-
for (const
|
|
524
|
+
else if (C && ee.length > 0)
|
|
525
|
+
for (const r of ee)
|
|
497
526
|
try {
|
|
498
|
-
const
|
|
499
|
-
|
|
527
|
+
const e = t.priceScale(r.priceScaleId);
|
|
528
|
+
e && e.applyOptions({
|
|
500
529
|
visible: !1,
|
|
501
530
|
autoScale: !0,
|
|
502
531
|
scaleMargins: {
|
|
503
532
|
top: 0.1,
|
|
504
533
|
bottom: 0.1,
|
|
505
|
-
...
|
|
534
|
+
...r.shouldPreventNegativeAxis && {
|
|
506
535
|
top: 0.3,
|
|
507
536
|
bottom: 0
|
|
508
537
|
}
|
|
@@ -511,25 +540,25 @@ function Lt({
|
|
|
511
540
|
borderVisible: !0,
|
|
512
541
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
513
542
|
entireTextOnly: !1,
|
|
514
|
-
textColor:
|
|
543
|
+
textColor: M
|
|
515
544
|
});
|
|
516
|
-
} catch (
|
|
545
|
+
} catch (e) {
|
|
517
546
|
console.warn(
|
|
518
|
-
`Failed to configure price scale ${
|
|
519
|
-
|
|
547
|
+
`Failed to configure price scale ${r.priceScaleId} for series ${r.seriesIndex}:`,
|
|
548
|
+
e
|
|
520
549
|
);
|
|
521
550
|
}
|
|
522
|
-
else if (!
|
|
551
|
+
else if (!C)
|
|
523
552
|
try {
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
visible: !
|
|
553
|
+
const r = t.priceScale("right");
|
|
554
|
+
r && r.applyOptions({
|
|
555
|
+
visible: !R,
|
|
527
556
|
autoScale: !0,
|
|
528
557
|
scaleMargins: {
|
|
529
558
|
top: 0.1,
|
|
530
559
|
// No bottom margin when yScaleMin is set so the scale doesn't extend below the minimum (avoids negative labels like -10M)
|
|
531
|
-
bottom: l !== void 0 ||
|
|
532
|
-
...
|
|
560
|
+
bottom: l !== void 0 || p ? 0 : 0.1,
|
|
561
|
+
...p && {
|
|
533
562
|
top: 0.3
|
|
534
563
|
}
|
|
535
564
|
},
|
|
@@ -537,141 +566,148 @@ function Lt({
|
|
|
537
566
|
borderVisible: !0,
|
|
538
567
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
539
568
|
entireTextOnly: !1,
|
|
540
|
-
textColor:
|
|
569
|
+
textColor: M
|
|
541
570
|
});
|
|
542
571
|
} catch {
|
|
543
572
|
}
|
|
544
|
-
if (l !== void 0 && !
|
|
573
|
+
if (l !== void 0 && !R && ($ || !C) && t.applyOptions({
|
|
545
574
|
handleScroll: {
|
|
546
575
|
vertTouchDrag: !1
|
|
547
576
|
}
|
|
548
577
|
}), G.length > 0) {
|
|
549
|
-
const
|
|
550
|
-
|
|
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 });
|
|
551
580
|
}
|
|
552
581
|
Re.current && (Re.current = !1);
|
|
553
|
-
const
|
|
554
|
-
for (const
|
|
555
|
-
|
|
556
|
-
|
|
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);
|
|
557
586
|
}, [
|
|
558
|
-
|
|
587
|
+
o,
|
|
559
588
|
G,
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
589
|
+
d,
|
|
590
|
+
N,
|
|
591
|
+
R,
|
|
592
|
+
$,
|
|
564
593
|
L,
|
|
565
594
|
we,
|
|
566
595
|
Te,
|
|
567
596
|
Ne,
|
|
568
597
|
Ve,
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
]),
|
|
573
|
-
const
|
|
574
|
-
if (!
|
|
575
|
-
const a =
|
|
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;
|
|
576
605
|
let l;
|
|
577
|
-
for (const i of
|
|
606
|
+
for (const i of o)
|
|
578
607
|
if (i.data.length > 0) {
|
|
579
608
|
l = i.data[i.data.length - 1].time;
|
|
580
609
|
break;
|
|
581
610
|
}
|
|
582
611
|
if (!l) return;
|
|
583
612
|
const n = (i) => {
|
|
584
|
-
const { time:
|
|
585
|
-
if (!
|
|
586
|
-
const
|
|
587
|
-
for (const
|
|
588
|
-
|
|
589
|
-
if (
|
|
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)
|
|
590
619
|
j(null);
|
|
591
620
|
else if (v[0] && l) {
|
|
592
|
-
const
|
|
593
|
-
if (
|
|
594
|
-
const
|
|
595
|
-
|
|
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 });
|
|
596
625
|
}
|
|
597
626
|
}
|
|
598
627
|
return;
|
|
599
628
|
}
|
|
600
|
-
const
|
|
601
|
-
let
|
|
602
|
-
for (let
|
|
603
|
-
const
|
|
604
|
-
if (!
|
|
605
|
-
const
|
|
606
|
-
let
|
|
607
|
-
if (
|
|
608
|
-
|
|
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;
|
|
609
638
|
else if (a) {
|
|
610
|
-
const
|
|
611
|
-
|
|
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;
|
|
612
641
|
} else
|
|
613
|
-
|
|
614
|
-
Number.isNaN(
|
|
642
|
+
V = mt(p.data, Number(f));
|
|
643
|
+
Number.isNaN(V) || (_ === void 0 && (_ = V), H.set(p.label, { value: V, time: f }));
|
|
615
644
|
}
|
|
616
|
-
if (
|
|
617
|
-
const
|
|
618
|
-
if (
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
-
const
|
|
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(
|
|
622
651
|
".LightweightChart"
|
|
623
652
|
);
|
|
624
|
-
if (
|
|
625
|
-
const
|
|
626
|
-
j({ x: Q, y:
|
|
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 });
|
|
627
656
|
} else
|
|
628
|
-
j({ x:
|
|
657
|
+
j({ x: p, y: C });
|
|
629
658
|
} else
|
|
630
|
-
j({ x:
|
|
659
|
+
j({ x: p, y: C });
|
|
631
660
|
} else
|
|
632
661
|
j(null);
|
|
633
662
|
} else
|
|
634
663
|
j(null);
|
|
635
664
|
};
|
|
636
|
-
return
|
|
637
|
-
const i = Array.from(
|
|
638
|
-
if (i[0] && l &&
|
|
639
|
-
const
|
|
640
|
-
|
|
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 });
|
|
641
670
|
}
|
|
642
671
|
}), () => {
|
|
643
|
-
|
|
672
|
+
t.unsubscribeCrosshairMove(n), R && t.unsubscribeClick(n);
|
|
644
673
|
};
|
|
645
|
-
}, [
|
|
646
|
-
const
|
|
647
|
-
if (!
|
|
648
|
-
const a =
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
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
|
+
}
|
|
659
693
|
};
|
|
660
694
|
return a.subscribeVisibleLogicalRangeChange(l), () => {
|
|
661
695
|
a.unsubscribeVisibleLogicalRangeChange(
|
|
662
696
|
l
|
|
663
697
|
);
|
|
664
698
|
};
|
|
665
|
-
}, [
|
|
666
|
-
const
|
|
667
|
-
if (
|
|
668
|
-
const n =
|
|
669
|
-
for (const
|
|
670
|
-
const
|
|
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 = {
|
|
671
705
|
...n,
|
|
672
|
-
...
|
|
673
|
-
}
|
|
674
|
-
|
|
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);
|
|
675
711
|
}
|
|
676
712
|
}
|
|
677
713
|
return () => {
|
|
@@ -681,153 +717,164 @@ function Lt({
|
|
|
681
717
|
n.detachPrimitive(i);
|
|
682
718
|
}
|
|
683
719
|
};
|
|
684
|
-
}, [
|
|
685
|
-
const
|
|
686
|
-
if (
|
|
687
|
-
const a = Array.from(
|
|
720
|
+
}, [x, o]), W(() => {
|
|
721
|
+
const t = [];
|
|
722
|
+
if (k && k.length > 0) {
|
|
723
|
+
const a = Array.from(y.current.values())[0], l = U(
|
|
688
724
|
"hsl(var(--destructive))",
|
|
689
725
|
"rgb(239, 68, 68)"
|
|
690
726
|
);
|
|
691
|
-
for (const n of
|
|
727
|
+
for (const n of k) {
|
|
692
728
|
if (!Number.isFinite(n.price)) continue;
|
|
693
|
-
const i = n.seriesLabel ?
|
|
729
|
+
const i = n.seriesLabel ? y.current.get(n.seriesLabel) : a;
|
|
694
730
|
if (!i) continue;
|
|
695
|
-
const
|
|
731
|
+
const f = i.createPriceLine({
|
|
696
732
|
price: n.price,
|
|
697
|
-
color: n.color ?
|
|
733
|
+
color: n.color ? U(n.color, n.color) : l,
|
|
698
734
|
lineWidth: n.lineWidth ?? 1,
|
|
699
|
-
lineStyle: n.lineStyle ??
|
|
735
|
+
lineStyle: n.lineStyle ?? Ge.Dashed,
|
|
700
736
|
axisLabelVisible: n.axisLabelVisible ?? !0,
|
|
701
737
|
title: n.title ?? ""
|
|
702
738
|
});
|
|
703
|
-
|
|
739
|
+
t.push({ series: i, line: f });
|
|
704
740
|
}
|
|
705
741
|
}
|
|
706
742
|
return () => {
|
|
707
|
-
for (const { series: a, line: l } of
|
|
743
|
+
for (const { series: a, line: l } of t)
|
|
708
744
|
try {
|
|
709
745
|
a.removePriceLine(l);
|
|
710
746
|
} catch {
|
|
711
747
|
}
|
|
712
748
|
};
|
|
713
|
-
}, [
|
|
714
|
-
const
|
|
715
|
-
if (
|
|
716
|
-
const a = Array.from(
|
|
717
|
-
for (const n of
|
|
718
|
-
const i = n.seriesLabel ?
|
|
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;
|
|
719
755
|
if (!i) continue;
|
|
720
|
-
const
|
|
756
|
+
const f = n.color ? U(n.color, l) : l, c = new gt(
|
|
721
757
|
i,
|
|
722
758
|
n.priceTop,
|
|
723
759
|
n.priceBottom,
|
|
724
|
-
|
|
760
|
+
f
|
|
725
761
|
);
|
|
726
|
-
i.attachPrimitive(
|
|
762
|
+
i.attachPrimitive(c), t.push({ series: i, zone: c });
|
|
727
763
|
}
|
|
728
764
|
}
|
|
729
765
|
return () => {
|
|
730
|
-
for (const { series: a, zone: l } of
|
|
766
|
+
for (const { series: a, zone: l } of t)
|
|
731
767
|
try {
|
|
732
768
|
a.detachPrimitive(l);
|
|
733
769
|
} catch {
|
|
734
770
|
}
|
|
735
771
|
};
|
|
736
|
-
}, [
|
|
737
|
-
const
|
|
738
|
-
if (!
|
|
739
|
-
|
|
772
|
+
}, [A, o]), W(() => {
|
|
773
|
+
const t = I.current;
|
|
774
|
+
if (!t || !x?.length) {
|
|
775
|
+
_e([]);
|
|
740
776
|
return;
|
|
741
777
|
}
|
|
742
778
|
const a = () => {
|
|
743
|
-
const i =
|
|
744
|
-
|
|
779
|
+
const i = t.timeScale(), f = x.map((c) => i.timeToCoordinate(c.xCoordinate) ?? null);
|
|
780
|
+
_e(f);
|
|
745
781
|
};
|
|
746
782
|
a();
|
|
747
|
-
const l =
|
|
783
|
+
const l = t.timeScale(), n = () => {
|
|
748
784
|
a();
|
|
749
785
|
};
|
|
750
786
|
return l.subscribeVisibleLogicalRangeChange(n), () => {
|
|
751
787
|
l.unsubscribeVisibleLogicalRangeChange(n);
|
|
752
788
|
};
|
|
753
|
-
}, [
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
758
|
-
return
|
|
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];
|
|
759
795
|
}
|
|
760
|
-
}, [
|
|
761
|
-
return /* @__PURE__ */
|
|
796
|
+
}, [ie, o]);
|
|
797
|
+
return /* @__PURE__ */ re(
|
|
762
798
|
"div",
|
|
763
799
|
{
|
|
764
|
-
ref:
|
|
765
|
-
className:
|
|
800
|
+
ref: K,
|
|
801
|
+
className: ne(
|
|
766
802
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
767
803
|
s
|
|
768
804
|
),
|
|
769
805
|
children: [
|
|
770
|
-
|
|
771
|
-
|
|
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,
|
|
772
808
|
{
|
|
773
|
-
point:
|
|
774
|
-
xMeasureUnit:
|
|
775
|
-
yMeasureUnit:
|
|
776
|
-
decimals:
|
|
809
|
+
point: Be,
|
|
810
|
+
xMeasureUnit: d,
|
|
811
|
+
yMeasureUnit: N,
|
|
812
|
+
decimals: ce
|
|
777
813
|
}
|
|
778
814
|
),
|
|
779
|
-
|
|
780
|
-
|
|
815
|
+
Me && ke && /* @__PURE__ */ T(
|
|
816
|
+
ct,
|
|
781
817
|
{
|
|
782
|
-
points:
|
|
783
|
-
xMeasureUnit:
|
|
784
|
-
yMeasureUnit:
|
|
785
|
-
series:
|
|
786
|
-
position:
|
|
787
|
-
containerRef:
|
|
788
|
-
decimals:
|
|
818
|
+
points: Me,
|
|
819
|
+
xMeasureUnit: d,
|
|
820
|
+
yMeasureUnit: N,
|
|
821
|
+
series: o,
|
|
822
|
+
position: ke,
|
|
823
|
+
containerRef: K,
|
|
824
|
+
decimals: ce
|
|
789
825
|
}
|
|
790
826
|
),
|
|
791
|
-
|
|
792
|
-
|
|
827
|
+
g && /* @__PURE__ */ T(bt, { series: o, onUnselect: m }),
|
|
828
|
+
x && x.length > 0 && Le.length === x.length && /* @__PURE__ */ T(
|
|
793
829
|
"div",
|
|
794
830
|
{
|
|
795
831
|
className: "absolute inset-0 z-[5] pointer-events-none",
|
|
796
832
|
"aria-hidden": !0,
|
|
797
|
-
children:
|
|
798
|
-
const l =
|
|
833
|
+
children: x.map((t, a) => {
|
|
834
|
+
const l = Le[a], n = t.options ?? {}, i = n.showLabel !== !1;
|
|
799
835
|
if (l === null || !i) return null;
|
|
800
|
-
const { labelText:
|
|
836
|
+
const { labelText: f, valueStr: c } = dt(
|
|
801
837
|
n,
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
);
|
|
805
|
-
if (!(c ||
|
|
806
|
-
const
|
|
807
|
-
return /* @__PURE__ */
|
|
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(
|
|
808
844
|
"div",
|
|
809
845
|
{
|
|
810
|
-
className:
|
|
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
|
+
),
|
|
811
850
|
style: {
|
|
812
851
|
left: l,
|
|
813
852
|
transform: "translateX(-50%)",
|
|
814
|
-
backgroundColor:
|
|
815
|
-
color:
|
|
853
|
+
backgroundColor: H,
|
|
854
|
+
color: _
|
|
816
855
|
},
|
|
817
856
|
children: [
|
|
818
|
-
|
|
819
|
-
|
|
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
|
+
)
|
|
820
867
|
]
|
|
821
868
|
},
|
|
822
|
-
|
|
869
|
+
w
|
|
823
870
|
);
|
|
824
871
|
})
|
|
825
872
|
}
|
|
826
873
|
),
|
|
827
|
-
/* @__PURE__ */
|
|
874
|
+
/* @__PURE__ */ T(
|
|
828
875
|
"div",
|
|
829
876
|
{
|
|
830
|
-
ref:
|
|
877
|
+
ref: ge,
|
|
831
878
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
832
879
|
}
|
|
833
880
|
)
|
|
@@ -836,48 +883,48 @@ function Lt({
|
|
|
836
883
|
);
|
|
837
884
|
}
|
|
838
885
|
function bt({
|
|
839
|
-
series:
|
|
886
|
+
series: o,
|
|
840
887
|
onUnselect: s,
|
|
841
|
-
inline:
|
|
888
|
+
inline: g = !1
|
|
842
889
|
}) {
|
|
843
|
-
return /* @__PURE__ */
|
|
890
|
+
return /* @__PURE__ */ T(
|
|
844
891
|
"div",
|
|
845
892
|
{
|
|
846
|
-
className:
|
|
893
|
+
className: ne(
|
|
847
894
|
"flex flex-wrap gap-2",
|
|
848
|
-
|
|
895
|
+
g ? "items-center" : "absolute top-0 left-2 z-[10]"
|
|
849
896
|
),
|
|
850
|
-
children:
|
|
851
|
-
const
|
|
852
|
-
return /* @__PURE__ */
|
|
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(
|
|
853
900
|
"div",
|
|
854
901
|
{
|
|
855
|
-
className:
|
|
902
|
+
className: ne(
|
|
856
903
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
857
|
-
|
|
904
|
+
x && "opacity-50"
|
|
858
905
|
),
|
|
859
906
|
children: [
|
|
860
|
-
/* @__PURE__ */
|
|
907
|
+
/* @__PURE__ */ T(
|
|
861
908
|
"div",
|
|
862
909
|
{
|
|
863
910
|
className: "w-3 h-3 rounded-sm",
|
|
864
|
-
style: { backgroundColor:
|
|
911
|
+
style: { backgroundColor: q }
|
|
865
912
|
}
|
|
866
913
|
),
|
|
867
|
-
/* @__PURE__ */
|
|
914
|
+
/* @__PURE__ */ re("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
868
915
|
m.label,
|
|
869
|
-
|
|
916
|
+
x && " (no data)"
|
|
870
917
|
] }),
|
|
871
|
-
s && /* @__PURE__ */
|
|
918
|
+
s && /* @__PURE__ */ T(
|
|
872
919
|
"button",
|
|
873
920
|
{
|
|
874
921
|
type: "button",
|
|
875
|
-
onClick: (
|
|
876
|
-
|
|
922
|
+
onClick: (k) => {
|
|
923
|
+
k.stopPropagation(), s(m.label);
|
|
877
924
|
},
|
|
878
925
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
879
926
|
"aria-label": `Remove ${m.label}`,
|
|
880
|
-
children: /* @__PURE__ */
|
|
927
|
+
children: /* @__PURE__ */ re(
|
|
881
928
|
"svg",
|
|
882
929
|
{
|
|
883
930
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -892,9 +939,9 @@ function bt({
|
|
|
892
939
|
className: "text-muted-foreground hover:text-foreground",
|
|
893
940
|
"aria-hidden": "true",
|
|
894
941
|
children: [
|
|
895
|
-
/* @__PURE__ */
|
|
896
|
-
/* @__PURE__ */
|
|
897
|
-
/* @__PURE__ */
|
|
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" })
|
|
898
945
|
]
|
|
899
946
|
}
|
|
900
947
|
)
|
|
@@ -912,7 +959,7 @@ export {
|
|
|
912
959
|
ye as DEFAULT_SERIES_COLORS,
|
|
913
960
|
Lt as Graph,
|
|
914
961
|
bt as GraphLegend,
|
|
915
|
-
|
|
962
|
+
Xe as getSeriesColorPalette,
|
|
916
963
|
mt as getStepForwardValue,
|
|
917
|
-
|
|
964
|
+
dt as getVerticalLineTooltipContent
|
|
918
965
|
};
|