@gearbox-protocol/ui-kit 3.14.0-next.38 → 3.14.0-next.39
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.
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/graph/index.cjs +1 -1
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/components/graph/graph.js +323 -315
- package/dist/esm/components/graph/index.js +25 -24
- package/dist/esm/components/index.js +462 -461
- package/dist/esm/index.js +626 -625
- package/dist/types/components/graph/graph.d.ts +8 -0
- package/dist/types/components/graph/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,99 +1,99 @@
|
|
|
1
1
|
import { jsxs as ne, jsx as w } from "react/jsx-runtime";
|
|
2
|
-
import { createChart as
|
|
3
|
-
import * as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { useIsMobile as
|
|
2
|
+
import { createChart as ot, CrosshairMode as rt, LineStyle as ee, LineSeries as nt, AreaSeries as lt } from "lightweight-charts";
|
|
3
|
+
import * as ye from "react";
|
|
4
|
+
import { useRef as Z, useState as ce, useEffect as $ } from "react";
|
|
5
|
+
import { useIsMobile as it } from "../../hooks/use-media-query.js";
|
|
6
6
|
import { cn as le } from "../../utils/cn.js";
|
|
7
|
-
import { resolveCSSColor as U, generateColorsFromBase as
|
|
8
|
-
import { getDefaultOptions as je, getDefaultSeries as
|
|
9
|
-
import { getXFormatters as He, formatExactValue as xe, createAdaptiveYAxisFormatter as
|
|
10
|
-
import { GraphCurrentValue as
|
|
11
|
-
import { GraphTooltip as
|
|
12
|
-
import { VertLine as
|
|
13
|
-
class
|
|
7
|
+
import { resolveCSSColor as U, generateColorsFromBase as ue, hslToHex as at } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as je, getDefaultSeries as st, getDefaultVerticalLine as ct } from "./default-config.js";
|
|
9
|
+
import { getXFormatters as He, formatExactValue as xe, createAdaptiveYAxisFormatter as ut } from "./formatters.js";
|
|
10
|
+
import { GraphCurrentValue as ft } from "./graph-current-value.js";
|
|
11
|
+
import { GraphTooltip as ht } from "./graph-tooltip.js";
|
|
12
|
+
import { VertLine as dt } from "./plugins/vertical-line.js";
|
|
13
|
+
class pt {
|
|
14
14
|
_yTop;
|
|
15
15
|
_yBottom;
|
|
16
16
|
_color;
|
|
17
|
-
constructor(
|
|
18
|
-
this._yTop =
|
|
17
|
+
constructor(n, f, c) {
|
|
18
|
+
this._yTop = n, this._yBottom = f, this._color = c;
|
|
19
19
|
}
|
|
20
|
-
draw(
|
|
21
|
-
|
|
22
|
-
const c = f.context, d = f.verticalPixelRatio, v = this._yTop === null ? 0 : this._yTop * d,
|
|
20
|
+
draw(n) {
|
|
21
|
+
n.useBitmapCoordinateSpace((f) => {
|
|
22
|
+
const c = f.context, d = f.verticalPixelRatio, v = this._yTop === null ? 0 : this._yTop * d, z = this._yBottom === null ? f.bitmapSize.height : this._yBottom * d, x = Math.min(v, z), M = Math.max(v, z);
|
|
23
23
|
c.fillStyle = this._color, c.fillRect(0, x, f.bitmapSize.width, M - x);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
class
|
|
27
|
+
class mt {
|
|
28
28
|
_source;
|
|
29
29
|
_yTop = null;
|
|
30
30
|
_yBottom = null;
|
|
31
|
-
constructor(
|
|
32
|
-
this._source =
|
|
31
|
+
constructor(n) {
|
|
32
|
+
this._source = n;
|
|
33
33
|
}
|
|
34
34
|
update() {
|
|
35
|
-
const
|
|
36
|
-
this._yTop = this._source.priceTop === void 0 ? null :
|
|
35
|
+
const n = this._source.series;
|
|
36
|
+
this._yTop = this._source.priceTop === void 0 ? null : n.priceToCoordinate(this._source.priceTop), this._yBottom = this._source.priceBottom === void 0 ? null : n.priceToCoordinate(this._source.priceBottom);
|
|
37
37
|
}
|
|
38
38
|
/** Draw beneath the series line/area so the data stays readable. */
|
|
39
39
|
zOrder() {
|
|
40
40
|
return "bottom";
|
|
41
41
|
}
|
|
42
42
|
renderer() {
|
|
43
|
-
return new
|
|
43
|
+
return new pt(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(
|
|
53
|
-
this.series =
|
|
52
|
+
constructor(n, f, c, d) {
|
|
53
|
+
this.series = n, this.priceTop = f, this.priceBottom = c, this.color = d, this._paneViews = [new mt(this)];
|
|
54
54
|
}
|
|
55
55
|
updateAllViews() {
|
|
56
|
-
for (const
|
|
56
|
+
for (const n of this._paneViews) n.update();
|
|
57
57
|
}
|
|
58
58
|
paneViews() {
|
|
59
59
|
return this._paneViews;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
switch (
|
|
62
|
+
function bt(e, n) {
|
|
63
|
+
switch (e) {
|
|
64
64
|
case ee.Dotted:
|
|
65
|
-
return [
|
|
65
|
+
return [n, n];
|
|
66
66
|
case ee.Dashed:
|
|
67
|
-
return [2 *
|
|
67
|
+
return [2 * n, 2 * n];
|
|
68
68
|
case ee.LargeDashed:
|
|
69
|
-
return [6 *
|
|
69
|
+
return [6 * n, 6 * n];
|
|
70
70
|
case ee.SparseDotted:
|
|
71
|
-
return [
|
|
71
|
+
return [n, 4 * n];
|
|
72
72
|
default:
|
|
73
73
|
return [];
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
class
|
|
76
|
+
class vt {
|
|
77
77
|
_y;
|
|
78
78
|
_color;
|
|
79
79
|
_lineWidth;
|
|
80
80
|
_lineStyle;
|
|
81
|
-
constructor(
|
|
82
|
-
this._y =
|
|
81
|
+
constructor(n, f, c, d) {
|
|
82
|
+
this._y = n, this._color = f, this._lineWidth = c, this._lineStyle = d;
|
|
83
83
|
}
|
|
84
|
-
draw(
|
|
85
|
-
|
|
84
|
+
draw(n) {
|
|
85
|
+
n.useBitmapCoordinateSpace((f) => {
|
|
86
86
|
if (this._y === null) return;
|
|
87
|
-
const c = f.context, d = f.verticalPixelRatio, v = Math.max(1, Math.round(this._lineWidth * d)),
|
|
88
|
-
c.save(), c.strokeStyle = this._color, c.lineWidth = v, c.setLineDash(
|
|
87
|
+
const c = f.context, d = f.verticalPixelRatio, v = Math.max(1, Math.round(this._lineWidth * d)), z = Math.round(this._y * d);
|
|
88
|
+
c.save(), c.strokeStyle = this._color, c.lineWidth = v, c.setLineDash(bt(this._lineStyle, v)), c.beginPath(), c.moveTo(0, z), c.lineTo(f.bitmapSize.width, z), c.stroke(), c.restore();
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
class
|
|
92
|
+
class St {
|
|
93
93
|
_source;
|
|
94
94
|
_y = null;
|
|
95
|
-
constructor(
|
|
96
|
-
this._source =
|
|
95
|
+
constructor(n) {
|
|
96
|
+
this._source = n;
|
|
97
97
|
}
|
|
98
98
|
update() {
|
|
99
99
|
this._y = this._source.series.priceToCoordinate(this._source.price);
|
|
@@ -108,7 +108,7 @@ class gt {
|
|
|
108
108
|
return "top";
|
|
109
109
|
}
|
|
110
110
|
renderer() {
|
|
111
|
-
return new
|
|
111
|
+
return new vt(
|
|
112
112
|
this._y,
|
|
113
113
|
this._source.color,
|
|
114
114
|
this._source.lineWidth,
|
|
@@ -116,35 +116,39 @@ class gt {
|
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
class
|
|
119
|
+
class Ct {
|
|
120
120
|
series;
|
|
121
121
|
price;
|
|
122
122
|
color;
|
|
123
123
|
lineWidth;
|
|
124
124
|
lineStyle;
|
|
125
125
|
_paneViews;
|
|
126
|
-
constructor(
|
|
127
|
-
this.series =
|
|
126
|
+
constructor(n, f, c, d, v) {
|
|
127
|
+
this.series = n, this.price = f, this.color = c, this.lineWidth = d, this.lineStyle = v, this._paneViews = [new St(this)];
|
|
128
128
|
}
|
|
129
129
|
updateAllViews() {
|
|
130
|
-
for (const
|
|
130
|
+
for (const n of this._paneViews) n.update();
|
|
131
131
|
}
|
|
132
132
|
paneViews() {
|
|
133
133
|
return this._paneViews;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
const c =
|
|
136
|
+
function yt(e, n, f) {
|
|
137
|
+
const c = e.labelText ?? "", d = e.value, v = d === void 0 ? "" : typeof d == "number" ? n === "$" ? `$${xe(d, void 0, f)}` : n === "%" ? `${xe(d, void 0, f)}%` : xe(
|
|
138
138
|
d,
|
|
139
|
-
|
|
139
|
+
n !== "none" && n !== "%" && n !== "$" ? n : void 0,
|
|
140
140
|
f
|
|
141
141
|
) : String(d);
|
|
142
142
|
return { labelText: c, valueStr: v };
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
const Oe = 40;
|
|
145
|
+
function xt(e, n) {
|
|
146
|
+
return n <= 0 ? { left: e, transform: "translateX(-50%)" } : e <= Oe ? { left: e, transform: "translateX(4px)" } : e >= n - Oe ? { left: e, transform: "translateX(calc(-100% - 4px))" } : { left: e, transform: "translateX(-50%)" };
|
|
147
|
+
}
|
|
148
|
+
function wt(e, n) {
|
|
149
|
+
for (let f = e.length - 1; f >= 0; f--)
|
|
150
|
+
if (Number(e[f].time) <= n)
|
|
151
|
+
return e[f].value;
|
|
148
152
|
return 0;
|
|
149
153
|
}
|
|
150
154
|
const we = [
|
|
@@ -262,70 +266,70 @@ const we = [
|
|
|
262
266
|
top: "rgba(71, 85, 105, 0.56)",
|
|
263
267
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
264
268
|
}
|
|
265
|
-
],
|
|
266
|
-
function
|
|
267
|
-
if (
|
|
268
|
-
return we[
|
|
269
|
-
const f = (
|
|
269
|
+
], _t = 137.5;
|
|
270
|
+
function qe(e) {
|
|
271
|
+
if (e < we.length)
|
|
272
|
+
return we[e];
|
|
273
|
+
const f = (e - we.length) * _t % 360, c = at(f, 70, 50), { topColor: d, bottomColor: v } = ue(c);
|
|
270
274
|
return { line: c, top: d, bottom: v };
|
|
271
275
|
}
|
|
272
|
-
function
|
|
273
|
-
series:
|
|
274
|
-
className:
|
|
276
|
+
function Wt({
|
|
277
|
+
series: e,
|
|
278
|
+
className: n,
|
|
275
279
|
showLegend: f = !1,
|
|
276
280
|
onUnselectSeries: c,
|
|
277
281
|
xMeasureUnit: d = "time",
|
|
278
282
|
yMeasureUnit: v = "token",
|
|
279
|
-
optionsOverrides:
|
|
283
|
+
optionsOverrides: z,
|
|
280
284
|
verticalLineOptions: x,
|
|
281
285
|
priceLineOptions: M,
|
|
282
286
|
zoneOptions: j,
|
|
283
|
-
currentValueDecimals:
|
|
284
|
-
useSharedPriceScale:
|
|
287
|
+
currentValueDecimals: fe,
|
|
288
|
+
useSharedPriceScale: G = !1,
|
|
285
289
|
dualYAxis: D = !1,
|
|
286
290
|
defaultVisiblePriceScaleId: _e = "right",
|
|
287
291
|
leftPriceScaleTitle: Ne,
|
|
288
|
-
rightPriceScaleTitle:
|
|
289
|
-
showCurrentValue:
|
|
290
|
-
graphTitle:
|
|
292
|
+
rightPriceScaleTitle: Tt,
|
|
293
|
+
showCurrentValue: Ze = !0,
|
|
294
|
+
graphTitle: he,
|
|
291
295
|
yScaleMin: Te,
|
|
292
296
|
yScaleMinMultiple: Ve,
|
|
293
|
-
visibleTimeFrom:
|
|
297
|
+
visibleTimeFrom: K,
|
|
294
298
|
disableZoom: ie = !1,
|
|
295
|
-
hideDefaultTooltip:
|
|
299
|
+
hideDefaultTooltip: de = !1
|
|
296
300
|
}) {
|
|
297
|
-
const
|
|
298
|
-
if (
|
|
299
|
-
const o =
|
|
301
|
+
const E = Z(null), C = Z(/* @__PURE__ */ new Map()), pe = Z(!1), Pe = Z(!0), Le = Z([]), I = Z(null), me = Z(null), ae = Z(null), V = it(), H = ye.useMemo(() => e.flatMap((o) => o.data), [e]), Ke = ye.useMemo(() => {
|
|
302
|
+
if (e.length > 0) {
|
|
303
|
+
const o = e[e.length - 1];
|
|
300
304
|
if (o.data.length > 0)
|
|
301
305
|
return o.data[o.data.length - 1];
|
|
302
306
|
}
|
|
303
|
-
}, [
|
|
304
|
-
if (!
|
|
307
|
+
}, [e]), [Re, ge] = ce(() => {
|
|
308
|
+
if (!Ke) return;
|
|
305
309
|
const o = /* @__PURE__ */ new Map();
|
|
306
|
-
for (const s of
|
|
310
|
+
for (const s of e)
|
|
307
311
|
s.data.length > 0 && o.set(s.label, s.data[s.data.length - 1]);
|
|
308
312
|
return o;
|
|
309
|
-
}), [Me, O] =
|
|
310
|
-
|
|
313
|
+
}), [Me, O] = ce(null), [ke, De] = ce([]), [Je, Ie] = ce(0);
|
|
314
|
+
$(() => {
|
|
311
315
|
const o = () => {
|
|
312
316
|
try {
|
|
313
|
-
if (
|
|
314
|
-
const a =
|
|
315
|
-
|
|
317
|
+
if (I.current && Ie(I.current.clientWidth), E.current && I.current) {
|
|
318
|
+
const a = I.current.clientWidth, i = I.current.clientHeight;
|
|
319
|
+
E.current.resize(a, i);
|
|
316
320
|
}
|
|
317
321
|
} catch {
|
|
318
322
|
}
|
|
319
|
-
}, s =
|
|
320
|
-
return ae.current =
|
|
321
|
-
s &&
|
|
323
|
+
}, s = I.current, l = s ? new ResizeObserver(o) : null;
|
|
324
|
+
return ae.current = l, s && l?.observe(s), () => {
|
|
325
|
+
s && l?.unobserve(s), l?.disconnect(), ae.current = null;
|
|
322
326
|
};
|
|
323
|
-
}, []),
|
|
324
|
-
if (!
|
|
327
|
+
}, []), $(() => {
|
|
328
|
+
if (!me.current || pe.current) return;
|
|
325
329
|
const o = je(), s = U(
|
|
326
330
|
"hsl(var(--foreground))",
|
|
327
331
|
"rgb(0, 0, 0)"
|
|
328
|
-
),
|
|
332
|
+
), l = ie ? {
|
|
329
333
|
handleScale: {
|
|
330
334
|
mouseWheel: !1,
|
|
331
335
|
pinch: !1,
|
|
@@ -338,7 +342,7 @@ function Bt({
|
|
|
338
342
|
horzTouchDrag: !1,
|
|
339
343
|
vertTouchDrag: !1
|
|
340
344
|
}
|
|
341
|
-
} : {}, a =
|
|
345
|
+
} : {}, a = ot(me.current, {
|
|
342
346
|
...o,
|
|
343
347
|
leftPriceScale: {
|
|
344
348
|
...o.leftPriceScale || {},
|
|
@@ -353,17 +357,17 @@ function Bt({
|
|
|
353
357
|
...V && {
|
|
354
358
|
crosshair: {
|
|
355
359
|
...o.crosshair,
|
|
356
|
-
mode:
|
|
360
|
+
mode: rt.Magnet
|
|
357
361
|
}
|
|
358
362
|
},
|
|
359
|
-
...
|
|
360
|
-
...
|
|
363
|
+
...l,
|
|
364
|
+
...z
|
|
361
365
|
});
|
|
362
|
-
return
|
|
363
|
-
ae.current?.disconnect(), ae.current = null, a.remove(),
|
|
366
|
+
return E.current = a, pe.current = !0, () => {
|
|
367
|
+
ae.current?.disconnect(), ae.current = null, a.remove(), E.current = null, pe.current = !1, C.current.clear();
|
|
364
368
|
};
|
|
365
|
-
}, [V,
|
|
366
|
-
const o =
|
|
369
|
+
}, [V, z, ie]), $(() => {
|
|
370
|
+
const o = E.current;
|
|
367
371
|
o && o.applyOptions(
|
|
368
372
|
ie ? {
|
|
369
373
|
handleScale: {
|
|
@@ -393,51 +397,51 @@ function Bt({
|
|
|
393
397
|
}
|
|
394
398
|
}
|
|
395
399
|
);
|
|
396
|
-
}, [ie]),
|
|
397
|
-
const o =
|
|
398
|
-
if (!o ||
|
|
399
|
-
const
|
|
400
|
+
}, [ie]), $(() => {
|
|
401
|
+
const o = E.current;
|
|
402
|
+
if (!o || e.length === 0) return;
|
|
403
|
+
const l = e.filter((r) => r.data.length > 0).length <= 1 ? Te : Ve, a = d === "time" ? He(d, H) : He(d), i = /* @__PURE__ */ new Map();
|
|
400
404
|
{
|
|
401
405
|
let r = 0;
|
|
402
|
-
for (const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
+
for (const t of e)
|
|
407
|
+
t.data.length !== 0 && (i.set(
|
|
408
|
+
t.label,
|
|
409
|
+
t.priceScaleId ?? (r === 0 ? "left" : "right")
|
|
406
410
|
), r++);
|
|
407
411
|
}
|
|
408
|
-
const u = (r,
|
|
412
|
+
const u = (r, t, p) => {
|
|
409
413
|
const {
|
|
410
414
|
formatter: k,
|
|
411
415
|
tickmarksFormatter: T,
|
|
412
|
-
updateVisibleRange:
|
|
413
|
-
updateLastValues:
|
|
414
|
-
} =
|
|
415
|
-
yScaleMin:
|
|
416
|
-
}),
|
|
417
|
-
return
|
|
416
|
+
updateVisibleRange: A,
|
|
417
|
+
updateLastValues: ze
|
|
418
|
+
} = ut(r, t, {
|
|
419
|
+
yScaleMin: l
|
|
420
|
+
}), ve = e.filter((J) => J.data.length > 0 && p.has(J.label)).map((J) => J.data[J.data.length - 1].value);
|
|
421
|
+
return ze(ve), { formatter: k, tickmarksFormatter: T, updateVisibleRange: A, labels: p };
|
|
418
422
|
}, h = [];
|
|
419
423
|
if (D)
|
|
420
424
|
for (const r of ["left", "right"]) {
|
|
421
|
-
const
|
|
425
|
+
const t = /* @__PURE__ */ new Set(), p = [];
|
|
422
426
|
let k = v;
|
|
423
|
-
for (const T of
|
|
427
|
+
for (const T of e)
|
|
424
428
|
if (T.data.length !== 0 && i.get(T.label) === r) {
|
|
425
|
-
|
|
426
|
-
for (const
|
|
429
|
+
t.size === 0 && T.yMeasureUnit && (k = T.yMeasureUnit), t.add(T.label);
|
|
430
|
+
for (const A of T.data) p.push(A.value);
|
|
427
431
|
}
|
|
428
|
-
|
|
432
|
+
t.size > 0 && h.push(u(p, k, t));
|
|
429
433
|
}
|
|
430
434
|
else {
|
|
431
|
-
const r = H.map((p) => p.value),
|
|
432
|
-
|
|
435
|
+
const r = H.map((p) => p.value), t = new Set(
|
|
436
|
+
e.filter((p) => p.data.length > 0).map((p) => p.label)
|
|
433
437
|
);
|
|
434
|
-
h.push(u(r, v,
|
|
438
|
+
h.push(u(r, v, t));
|
|
435
439
|
}
|
|
436
|
-
|
|
440
|
+
Le.current = h;
|
|
437
441
|
const b = /* @__PURE__ */ new Map();
|
|
438
442
|
for (const r of h)
|
|
439
|
-
for (const
|
|
440
|
-
b.set(
|
|
443
|
+
for (const t of r.labels)
|
|
444
|
+
b.set(t, r);
|
|
441
445
|
const S = je();
|
|
442
446
|
o.applyOptions({
|
|
443
447
|
localization: {
|
|
@@ -455,7 +459,7 @@ function Bt({
|
|
|
455
459
|
minBarSpacing: 0
|
|
456
460
|
}
|
|
457
461
|
});
|
|
458
|
-
const P = (H.length > 0 ? Math.min(...H.map((r) => r.value)) : 0) < 0, _ = H.some((r) => r.value === 0), m = !P && _, y = !D &&
|
|
462
|
+
const P = (H.length > 0 ? Math.min(...H.map((r) => r.value)) : 0) < 0, _ = H.some((r) => r.value === 0), m = !P && _, y = !D && e.length > 1 && !G, L = D ? V : e.length > 1 && !G || V, R = U(
|
|
459
463
|
"hsl(var(--foreground))",
|
|
460
464
|
"rgb(0, 0, 0)"
|
|
461
465
|
);
|
|
@@ -466,15 +470,15 @@ function Bt({
|
|
|
466
470
|
leftPriceScale: {
|
|
467
471
|
...S.leftPriceScale || {},
|
|
468
472
|
visible: D && !V,
|
|
469
|
-
textColor:
|
|
473
|
+
textColor: R,
|
|
470
474
|
...D && Ne && {
|
|
471
475
|
// lightweight-charts uses scale margins; title shown via localization if needed
|
|
472
476
|
}
|
|
473
477
|
},
|
|
474
478
|
rightPriceScale: {
|
|
475
479
|
...S.rightPriceScale || {},
|
|
476
|
-
visible: D ? !V : !
|
|
477
|
-
textColor:
|
|
480
|
+
visible: D ? !V : !L,
|
|
481
|
+
textColor: R,
|
|
478
482
|
...m && !D && {
|
|
479
483
|
scaleMargins: {
|
|
480
484
|
top: 0.3,
|
|
@@ -483,106 +487,106 @@ function Bt({
|
|
|
483
487
|
}
|
|
484
488
|
}
|
|
485
489
|
});
|
|
486
|
-
const N = new Set(C.current.keys()),
|
|
490
|
+
const N = new Set(C.current.keys()), q = new Set(e.map((r) => r.label));
|
|
487
491
|
for (const r of N)
|
|
488
|
-
if (!
|
|
489
|
-
const
|
|
490
|
-
|
|
492
|
+
if (!q.has(r)) {
|
|
493
|
+
const t = C.current.get(r);
|
|
494
|
+
t && (o.removeSeries(t), C.current.delete(r));
|
|
491
495
|
}
|
|
492
|
-
const Q =
|
|
496
|
+
const Q = st(), te = [];
|
|
493
497
|
let oe = 0;
|
|
494
|
-
const
|
|
498
|
+
const Fe = e.find((r) => r.data.length > 0), re = /* @__PURE__ */ new Map();
|
|
495
499
|
if (M && M.length > 0)
|
|
496
500
|
for (const r of M) {
|
|
497
501
|
if (!Number.isFinite(r.price)) continue;
|
|
498
|
-
const
|
|
499
|
-
if (!
|
|
500
|
-
const p = re.get(
|
|
501
|
-
p.push(r.price), re.set(
|
|
502
|
+
const t = r.seriesLabel ?? Fe?.label;
|
|
503
|
+
if (!t) continue;
|
|
504
|
+
const p = re.get(t) ?? [];
|
|
505
|
+
p.push(r.price), re.set(t, p);
|
|
502
506
|
}
|
|
503
507
|
if (j && j.length > 0)
|
|
504
508
|
for (const r of j) {
|
|
505
|
-
const
|
|
506
|
-
if (!
|
|
507
|
-
const p = re.get(
|
|
508
|
-
Number.isFinite(r.priceTop) && p.push(r.priceTop), Number.isFinite(r.priceBottom) && p.push(r.priceBottom), re.set(
|
|
509
|
+
const t = r.seriesLabel ?? Fe?.label;
|
|
510
|
+
if (!t) continue;
|
|
511
|
+
const p = re.get(t) ?? [];
|
|
512
|
+
Number.isFinite(r.priceTop) && p.push(r.priceTop), Number.isFinite(r.priceBottom) && p.push(r.priceBottom), re.set(t, p);
|
|
509
513
|
}
|
|
510
|
-
for (let r = 0; r <
|
|
511
|
-
const
|
|
512
|
-
let T,
|
|
513
|
-
if (
|
|
514
|
-
if (
|
|
515
|
-
T =
|
|
516
|
-
else if (
|
|
517
|
-
const g =
|
|
518
|
-
T =
|
|
519
|
-
} else if (
|
|
520
|
-
T =
|
|
514
|
+
for (let r = 0; r < e.length; r++) {
|
|
515
|
+
const t = e[r], p = qe(r), k = t.lineColor ?? t.color ?? p.line;
|
|
516
|
+
let T, A;
|
|
517
|
+
if (t.lineColor ?? t.color)
|
|
518
|
+
if (t.topColor && t.bottomColor)
|
|
519
|
+
T = t.topColor, A = t.bottomColor;
|
|
520
|
+
else if (t.topColor) {
|
|
521
|
+
const g = ue(k);
|
|
522
|
+
T = t.topColor, A = g.bottomColor;
|
|
523
|
+
} else if (t.bottomColor)
|
|
524
|
+
T = ue(k).topColor, A = t.bottomColor;
|
|
521
525
|
else {
|
|
522
|
-
const g =
|
|
523
|
-
T = g.topColor,
|
|
526
|
+
const g = ue(k);
|
|
527
|
+
T = g.topColor, A = g.bottomColor;
|
|
524
528
|
}
|
|
525
529
|
else
|
|
526
|
-
T =
|
|
527
|
-
if (
|
|
528
|
-
const g = C.current.get(
|
|
529
|
-
g && (o.removeSeries(g), C.current.delete(
|
|
530
|
+
T = t.topColor || p.top, A = t.bottomColor || p.bottom;
|
|
531
|
+
if (t.data.length === 0) {
|
|
532
|
+
const g = C.current.get(t.label);
|
|
533
|
+
g && (o.removeSeries(g), C.current.delete(t.label));
|
|
530
534
|
continue;
|
|
531
535
|
}
|
|
532
|
-
const
|
|
536
|
+
const ve = (t.data.length > 0 ? Math.min(...t.data.map((g) => g.value)) : 0) < 0, J = t.data.some((g) => g.value === 0), Qe = !ve && J, Ee = D ? t.priceScaleId ?? (oe === 0 ? "left" : "right") : G || !y || oe === 0 ? "right" : `scale-${oe}`;
|
|
533
537
|
y && te.push({
|
|
534
|
-
priceScaleId:
|
|
535
|
-
shouldPreventNegativeAxis:
|
|
538
|
+
priceScaleId: Ee || "right",
|
|
539
|
+
shouldPreventNegativeAxis: Qe,
|
|
536
540
|
seriesIndex: oe
|
|
537
541
|
});
|
|
538
|
-
const We = (
|
|
539
|
-
const
|
|
540
|
-
if (
|
|
541
|
-
We && (
|
|
542
|
-
for (const
|
|
543
|
-
|
|
542
|
+
const We = (G || !y) && l !== void 0 && typeof l == "number", Ye = re.get(t.label) ?? [], Ue = (g) => {
|
|
543
|
+
const F = g();
|
|
544
|
+
if (F?.priceRange) {
|
|
545
|
+
We && (F.priceRange.minValue = l);
|
|
546
|
+
for (const X of Ye)
|
|
547
|
+
X < F.priceRange.minValue && (F.priceRange.minValue = X), X > F.priceRange.maxValue && (F.priceRange.maxValue = X);
|
|
544
548
|
}
|
|
545
|
-
return
|
|
546
|
-
},
|
|
549
|
+
return F;
|
|
550
|
+
}, Ae = b.get(t.label) ?? h[0], $e = Ae.formatter, et = Ae.tickmarksFormatter, Se = {
|
|
547
551
|
lineColor: k,
|
|
548
552
|
topColor: T,
|
|
549
|
-
bottomColor:
|
|
550
|
-
priceScaleId:
|
|
551
|
-
...
|
|
552
|
-
lineStyle:
|
|
553
|
+
bottomColor: A,
|
|
554
|
+
priceScaleId: Ee,
|
|
555
|
+
...t.seriesType === "line" && {
|
|
556
|
+
lineStyle: t.lineStyle ?? ee.Solid
|
|
553
557
|
},
|
|
554
558
|
priceFormat: {
|
|
555
559
|
type: "custom",
|
|
556
560
|
minMove: 0.01,
|
|
557
|
-
formatter: We && typeof
|
|
558
|
-
g <
|
|
559
|
-
) :
|
|
560
|
-
tickmarksFormatter:
|
|
561
|
+
formatter: We && typeof l == "number" ? (g) => $e(
|
|
562
|
+
g < l ? l : g
|
|
563
|
+
) : $e,
|
|
564
|
+
tickmarksFormatter: et
|
|
561
565
|
},
|
|
562
|
-
autoscaleInfoProvider:
|
|
563
|
-
},
|
|
564
|
-
let
|
|
565
|
-
const Y =
|
|
566
|
+
autoscaleInfoProvider: Ue
|
|
567
|
+
}, Ge = t.seriesType === "line";
|
|
568
|
+
let B = C.current.get(t.label);
|
|
569
|
+
const Y = t.data.map((g) => ({
|
|
566
570
|
...g,
|
|
567
571
|
time: g.time
|
|
568
572
|
}));
|
|
569
|
-
if (
|
|
570
|
-
const g = Number(Y[0].time),
|
|
571
|
-
for (let
|
|
572
|
-
|
|
573
|
-
Y.unshift(...
|
|
573
|
+
if (K !== void 0 && Y.length > 0 && Number(Y[0].time) > K) {
|
|
574
|
+
const g = Number(Y[0].time), F = g - K, X = 86400, tt = F > 180 * X ? 7 * X : F > 30 * X ? X : 6 * 3600, Xe = [];
|
|
575
|
+
for (let Ce = K; Ce < g; Ce += tt)
|
|
576
|
+
Xe.push({ time: Ce });
|
|
577
|
+
Y.unshift(...Xe);
|
|
574
578
|
}
|
|
575
|
-
|
|
579
|
+
B && B.seriesType() !== (Ge ? "Line" : "Area") && (o.removeSeries(B), C.current.delete(t.label), B = void 0), B ? (B.applyOptions(Se), B.setData(Y)) : (Ge ? B = o.addSeries(nt, {
|
|
576
580
|
...Q,
|
|
577
|
-
...
|
|
578
|
-
}) :
|
|
581
|
+
...Se
|
|
582
|
+
}) : B = o.addSeries(lt, {
|
|
579
583
|
...Q,
|
|
580
|
-
...
|
|
581
|
-
}),
|
|
584
|
+
...Se
|
|
585
|
+
}), B.setData(Y), C.current.set(t.label, B)), oe++;
|
|
582
586
|
}
|
|
583
587
|
if (D)
|
|
584
588
|
try {
|
|
585
|
-
const r = o.priceScale("left"),
|
|
589
|
+
const r = o.priceScale("left"), t = o.priceScale("right"), p = {
|
|
586
590
|
visible: !V,
|
|
587
591
|
autoScale: !0,
|
|
588
592
|
scaleMargins: { top: 0.1, bottom: 0.1 },
|
|
@@ -590,16 +594,16 @@ function Bt({
|
|
|
590
594
|
borderVisible: !0,
|
|
591
595
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
592
596
|
entireTextOnly: !1,
|
|
593
|
-
textColor:
|
|
597
|
+
textColor: R
|
|
594
598
|
};
|
|
595
|
-
r?.applyOptions(p),
|
|
599
|
+
r?.applyOptions(p), t?.applyOptions(p);
|
|
596
600
|
} catch {
|
|
597
601
|
}
|
|
598
602
|
else if (y && te.length > 0)
|
|
599
603
|
for (const r of te)
|
|
600
604
|
try {
|
|
601
|
-
const
|
|
602
|
-
|
|
605
|
+
const t = o.priceScale(r.priceScaleId);
|
|
606
|
+
t && t.applyOptions({
|
|
603
607
|
visible: !1,
|
|
604
608
|
autoScale: !0,
|
|
605
609
|
scaleMargins: {
|
|
@@ -614,12 +618,12 @@ function Bt({
|
|
|
614
618
|
borderVisible: !0,
|
|
615
619
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
616
620
|
entireTextOnly: !1,
|
|
617
|
-
textColor:
|
|
621
|
+
textColor: R
|
|
618
622
|
});
|
|
619
|
-
} catch (
|
|
623
|
+
} catch (t) {
|
|
620
624
|
console.warn(
|
|
621
625
|
`Failed to configure price scale ${r.priceScaleId} for series ${r.seriesIndex}:`,
|
|
622
|
-
|
|
626
|
+
t
|
|
623
627
|
);
|
|
624
628
|
}
|
|
625
629
|
else if (!y)
|
|
@@ -631,7 +635,7 @@ function Bt({
|
|
|
631
635
|
scaleMargins: {
|
|
632
636
|
top: 0.1,
|
|
633
637
|
// No bottom margin when yScaleMin is set so the scale doesn't extend below the minimum (avoids negative labels like -10M)
|
|
634
|
-
bottom:
|
|
638
|
+
bottom: l !== void 0 || m ? 0 : 0.1,
|
|
635
639
|
...m && {
|
|
636
640
|
top: 0.3
|
|
637
641
|
}
|
|
@@ -640,18 +644,18 @@ function Bt({
|
|
|
640
644
|
borderVisible: !0,
|
|
641
645
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
642
646
|
entireTextOnly: !1,
|
|
643
|
-
textColor:
|
|
647
|
+
textColor: R
|
|
644
648
|
});
|
|
645
649
|
} catch {
|
|
646
650
|
}
|
|
647
|
-
if (
|
|
651
|
+
if (l !== void 0 && !V && (G || !y) && o.applyOptions({
|
|
648
652
|
handleScroll: {
|
|
649
653
|
vertTouchDrag: !1
|
|
650
654
|
}
|
|
651
655
|
}), H.length > 0) {
|
|
652
|
-
const r = H.map((
|
|
656
|
+
const r = H.map((t) => Number(t.time)).filter((t) => Number.isFinite(t));
|
|
653
657
|
if (r.length > 0) {
|
|
654
|
-
const
|
|
658
|
+
const t = Math.min(...r), p = K !== void 0 ? Math.min(K, t) : t, k = Math.max(...r);
|
|
655
659
|
if (Number(p) <= Number(k))
|
|
656
660
|
try {
|
|
657
661
|
o.timeScale().setVisibleRange({ from: p, to: k });
|
|
@@ -664,48 +668,48 @@ function Bt({
|
|
|
664
668
|
}
|
|
665
669
|
}
|
|
666
670
|
Pe.current && (Pe.current = !1);
|
|
667
|
-
const
|
|
668
|
-
for (const r of
|
|
669
|
-
r.data.length > 0 &&
|
|
670
|
-
|
|
671
|
+
const be = /* @__PURE__ */ new Map();
|
|
672
|
+
for (const r of e)
|
|
673
|
+
r.data.length > 0 && be.set(r.label, r.data[r.data.length - 1]);
|
|
674
|
+
ge(be.size > 0 ? be : void 0);
|
|
671
675
|
}, [
|
|
672
|
-
|
|
676
|
+
e,
|
|
673
677
|
H,
|
|
674
678
|
d,
|
|
675
679
|
v,
|
|
676
680
|
V,
|
|
677
|
-
|
|
681
|
+
G,
|
|
678
682
|
D,
|
|
679
683
|
_e,
|
|
680
684
|
Ne,
|
|
681
685
|
Te,
|
|
682
686
|
Ve,
|
|
683
|
-
|
|
687
|
+
K,
|
|
684
688
|
M,
|
|
685
689
|
j
|
|
686
|
-
]),
|
|
687
|
-
const o =
|
|
688
|
-
if (!o ||
|
|
689
|
-
const s =
|
|
690
|
-
let
|
|
691
|
-
for (const i of
|
|
690
|
+
]), $(() => {
|
|
691
|
+
const o = E.current;
|
|
692
|
+
if (!o || e.length === 0) return;
|
|
693
|
+
const s = e.length === 1;
|
|
694
|
+
let l;
|
|
695
|
+
for (const i of e)
|
|
692
696
|
if (i.data.length > 0) {
|
|
693
|
-
|
|
697
|
+
l = i.data[i.data.length - 1].time;
|
|
694
698
|
break;
|
|
695
699
|
}
|
|
696
|
-
if (!
|
|
700
|
+
if (!l) return;
|
|
697
701
|
const a = (i) => {
|
|
698
|
-
const { time: u =
|
|
702
|
+
const { time: u = l, seriesData: h, point: b } = i || {}, S = Array.from(C.current.values());
|
|
699
703
|
if (!b || !u) {
|
|
700
704
|
const _ = /* @__PURE__ */ new Map();
|
|
701
|
-
for (const m of
|
|
705
|
+
for (const m of e)
|
|
702
706
|
m.data.length > 0 && _.set(m.label, m.data[m.data.length - 1]);
|
|
703
|
-
if (
|
|
707
|
+
if (ge(_.size > 0 ? _ : void 0), s || G || de)
|
|
704
708
|
O(null);
|
|
705
|
-
else if (S[0] &&
|
|
706
|
-
const y = o.timeScale().timeToCoordinate(
|
|
707
|
-
if (
|
|
708
|
-
const
|
|
709
|
+
else if (S[0] && l) {
|
|
710
|
+
const y = o.timeScale().timeToCoordinate(l), L = e[0];
|
|
711
|
+
if (L.data.length > 0) {
|
|
712
|
+
const R = L.data[L.data.length - 1].value, N = S[0].priceToCoordinate(R);
|
|
709
713
|
y !== null && N !== null && O({ x: y, y: N });
|
|
710
714
|
}
|
|
711
715
|
}
|
|
@@ -713,33 +717,33 @@ function Bt({
|
|
|
713
717
|
}
|
|
714
718
|
const W = /* @__PURE__ */ new Map();
|
|
715
719
|
let P;
|
|
716
|
-
for (let _ = 0; _ <
|
|
717
|
-
const m =
|
|
720
|
+
for (let _ = 0; _ < e.length; _++) {
|
|
721
|
+
const m = e[_], y = C.current.get(m.label);
|
|
718
722
|
if (!y) continue;
|
|
719
|
-
const
|
|
723
|
+
const L = h?.get(y), R = L && "value" in L ? L.value : void 0;
|
|
720
724
|
let N;
|
|
721
|
-
if (
|
|
722
|
-
N =
|
|
725
|
+
if (R !== void 0)
|
|
726
|
+
N = R;
|
|
723
727
|
else if (s) {
|
|
724
|
-
const
|
|
725
|
-
|
|
728
|
+
const q = Number(u), Q = m.data.length > 0 ? Number(m.data[0].time) : Number.POSITIVE_INFINITY;
|
|
729
|
+
q < Q ? N = Number.NaN : N = m.data[m.data.length - 1]?.value ?? 0;
|
|
726
730
|
} else {
|
|
727
|
-
const
|
|
728
|
-
if (Number(u) <
|
|
729
|
-
N =
|
|
731
|
+
const q = m.data.length > 0 ? Number(m.data[0].time) : Number.POSITIVE_INFINITY;
|
|
732
|
+
if (Number(u) < q) continue;
|
|
733
|
+
N = wt(m.data, Number(u));
|
|
730
734
|
}
|
|
731
735
|
Number.isNaN(N) || (P === void 0 && (P = N), W.set(m.label, { value: N, time: u }));
|
|
732
736
|
}
|
|
733
|
-
if (
|
|
737
|
+
if (ge(W), P !== void 0 && S[0]) {
|
|
734
738
|
const m = o.timeScale().timeToCoordinate(u), y = S[0].priceToCoordinate(P);
|
|
735
739
|
if (m !== null && y !== null) {
|
|
736
|
-
const
|
|
737
|
-
if (
|
|
738
|
-
const
|
|
740
|
+
const L = I.current;
|
|
741
|
+
if (L) {
|
|
742
|
+
const R = L.querySelector(
|
|
739
743
|
".LightweightChart"
|
|
740
744
|
);
|
|
741
|
-
if (
|
|
742
|
-
const N =
|
|
745
|
+
if (R) {
|
|
746
|
+
const N = R.getBoundingClientRect(), q = L.getBoundingClientRect(), Q = m + (N.left - q.left), te = y + (N.top - q.top);
|
|
743
747
|
O({ x: Q, y: te });
|
|
744
748
|
} else
|
|
745
749
|
O({ x: m, y });
|
|
@@ -750,27 +754,27 @@ function Bt({
|
|
|
750
754
|
} else
|
|
751
755
|
O(null);
|
|
752
756
|
};
|
|
753
|
-
return o.subscribeCrosshairMove(a), V && o.subscribeClick(a), !s && !
|
|
757
|
+
return o.subscribeCrosshairMove(a), V && o.subscribeClick(a), !s && !G && !de && requestAnimationFrame(() => {
|
|
754
758
|
const i = Array.from(C.current.values());
|
|
755
|
-
if (i[0] &&
|
|
756
|
-
const h = o.timeScale().timeToCoordinate(
|
|
759
|
+
if (i[0] && l && e[0]?.data.length > 0) {
|
|
760
|
+
const h = o.timeScale().timeToCoordinate(l), b = e[0].data[e[0].data.length - 1].value, S = i[0].priceToCoordinate(b);
|
|
757
761
|
h !== null && S !== null && O({ x: h, y: S });
|
|
758
762
|
}
|
|
759
763
|
}), () => {
|
|
760
764
|
o.unsubscribeCrosshairMove(a), V && o.unsubscribeClick(a);
|
|
761
765
|
};
|
|
762
|
-
}, [
|
|
763
|
-
const o =
|
|
764
|
-
if (!o ||
|
|
765
|
-
const s = o.timeScale(),
|
|
766
|
-
const a =
|
|
766
|
+
}, [e, G, V, de]), $(() => {
|
|
767
|
+
const o = E.current;
|
|
768
|
+
if (!o || e.length === 0) return;
|
|
769
|
+
const s = o.timeScale(), l = () => {
|
|
770
|
+
const a = Le.current;
|
|
767
771
|
if (a.length === 0) return;
|
|
768
772
|
const i = s.getVisibleRange();
|
|
769
773
|
if (!i) return;
|
|
770
774
|
const u = Number(i.from), h = Number(i.to);
|
|
771
775
|
for (const b of a) {
|
|
772
776
|
const S = [];
|
|
773
|
-
for (const W of
|
|
777
|
+
for (const W of e)
|
|
774
778
|
if (b.labels.has(W.label))
|
|
775
779
|
for (const P of W.data) {
|
|
776
780
|
const _ = Number(P.time);
|
|
@@ -779,42 +783,42 @@ function Bt({
|
|
|
779
783
|
S.length > 0 && b.updateVisibleRange(S);
|
|
780
784
|
}
|
|
781
785
|
};
|
|
782
|
-
return s.subscribeVisibleLogicalRangeChange(
|
|
786
|
+
return s.subscribeVisibleLogicalRangeChange(l), () => {
|
|
783
787
|
s.unsubscribeVisibleLogicalRangeChange(
|
|
784
|
-
|
|
788
|
+
l
|
|
785
789
|
);
|
|
786
790
|
};
|
|
787
|
-
}, [
|
|
788
|
-
const o =
|
|
791
|
+
}, [e]), $(() => {
|
|
792
|
+
const o = E.current, s = Array.from(C.current.values()), l = [];
|
|
789
793
|
if (o && s.length > 0 && x) {
|
|
790
|
-
const a =
|
|
794
|
+
const a = ct(), i = s[0];
|
|
791
795
|
for (const u of x) {
|
|
792
796
|
const h = {
|
|
793
797
|
...a,
|
|
794
798
|
...u.options || {}
|
|
795
799
|
};
|
|
796
800
|
h.color && (h.color = U(h.color, h.color));
|
|
797
|
-
const b = new
|
|
798
|
-
i.attachPrimitive(b),
|
|
801
|
+
const b = new dt(o, i, u.xCoordinate, h);
|
|
802
|
+
i.attachPrimitive(b), l.push(b);
|
|
799
803
|
}
|
|
800
804
|
}
|
|
801
805
|
return () => {
|
|
802
806
|
if (s.length > 0) {
|
|
803
807
|
const a = s[0];
|
|
804
|
-
for (const i of
|
|
808
|
+
for (const i of l)
|
|
805
809
|
a.detachPrimitive(i);
|
|
806
810
|
}
|
|
807
811
|
};
|
|
808
|
-
}, [x,
|
|
812
|
+
}, [x, e]), $(() => {
|
|
809
813
|
const o = [], s = [];
|
|
810
814
|
if (M && M.length > 0) {
|
|
811
|
-
const
|
|
815
|
+
const l = Array.from(C.current.values())[0], a = U(
|
|
812
816
|
"hsl(var(--destructive))",
|
|
813
817
|
"rgb(239, 68, 68)"
|
|
814
818
|
);
|
|
815
819
|
for (const i of M) {
|
|
816
820
|
if (!Number.isFinite(i.price)) continue;
|
|
817
|
-
const u = i.seriesLabel ? C.current.get(i.seriesLabel) :
|
|
821
|
+
const u = i.seriesLabel ? C.current.get(i.seriesLabel) : l;
|
|
818
822
|
if (!u) continue;
|
|
819
823
|
const h = i.color ? U(i.color, i.color) : a, b = i.lineWidth ?? 1, S = i.lineStyle ?? ee.Dashed, W = u.createPriceLine({
|
|
820
824
|
price: i.price,
|
|
@@ -825,7 +829,7 @@ function Bt({
|
|
|
825
829
|
title: i.title ?? ""
|
|
826
830
|
});
|
|
827
831
|
o.push({ series: u, line: W });
|
|
828
|
-
const P = new
|
|
832
|
+
const P = new Ct(
|
|
829
833
|
u,
|
|
830
834
|
i.price,
|
|
831
835
|
h,
|
|
@@ -836,25 +840,25 @@ function Bt({
|
|
|
836
840
|
}
|
|
837
841
|
}
|
|
838
842
|
return () => {
|
|
839
|
-
for (const { series:
|
|
843
|
+
for (const { series: l, primitive: a } of s)
|
|
840
844
|
try {
|
|
841
|
-
|
|
845
|
+
l.detachPrimitive(a);
|
|
842
846
|
} catch {
|
|
843
847
|
}
|
|
844
|
-
for (const { series:
|
|
848
|
+
for (const { series: l, line: a } of o)
|
|
845
849
|
try {
|
|
846
|
-
|
|
850
|
+
l.removePriceLine(a);
|
|
847
851
|
} catch {
|
|
848
852
|
}
|
|
849
853
|
};
|
|
850
|
-
}, [M,
|
|
854
|
+
}, [M, e]), $(() => {
|
|
851
855
|
const o = [];
|
|
852
856
|
if (j && j.length > 0) {
|
|
853
|
-
const s = Array.from(C.current.values())[0],
|
|
857
|
+
const s = Array.from(C.current.values())[0], l = "rgba(239, 68, 68, 0.12)";
|
|
854
858
|
for (const a of j) {
|
|
855
859
|
const i = a.seriesLabel ? C.current.get(a.seriesLabel) : s;
|
|
856
860
|
if (!i) continue;
|
|
857
|
-
const u = a.color ? U(a.color,
|
|
861
|
+
const u = a.color ? U(a.color, l) : l, h = new gt(
|
|
858
862
|
i,
|
|
859
863
|
a.priceTop,
|
|
860
864
|
a.priceBottom,
|
|
@@ -864,83 +868,86 @@ function Bt({
|
|
|
864
868
|
}
|
|
865
869
|
}
|
|
866
870
|
return () => {
|
|
867
|
-
for (const { series: s, zone:
|
|
871
|
+
for (const { series: s, zone: l } of o)
|
|
868
872
|
try {
|
|
869
|
-
s.detachPrimitive(
|
|
873
|
+
s.detachPrimitive(l);
|
|
870
874
|
} catch {
|
|
871
875
|
}
|
|
872
876
|
};
|
|
873
|
-
}, [j,
|
|
874
|
-
const o =
|
|
877
|
+
}, [j, e]), $(() => {
|
|
878
|
+
const o = E.current;
|
|
875
879
|
if (!o || !x?.length) {
|
|
876
880
|
De([]);
|
|
877
881
|
return;
|
|
878
882
|
}
|
|
879
883
|
const s = () => {
|
|
880
884
|
const i = o.timeScale(), u = x.map((h) => i.timeToCoordinate(h.xCoordinate) ?? null);
|
|
881
|
-
De(u);
|
|
885
|
+
De(u), I.current && Ie(I.current.clientWidth);
|
|
882
886
|
};
|
|
883
887
|
s();
|
|
884
|
-
const
|
|
888
|
+
const l = o.timeScale(), a = () => {
|
|
885
889
|
s();
|
|
886
890
|
};
|
|
887
|
-
return
|
|
888
|
-
|
|
891
|
+
return l.subscribeVisibleLogicalRangeChange(a), () => {
|
|
892
|
+
l.unsubscribeVisibleLogicalRangeChange(a);
|
|
889
893
|
};
|
|
890
|
-
}, [x,
|
|
891
|
-
const se =
|
|
892
|
-
if (se &&
|
|
893
|
-
const o =
|
|
894
|
+
}, [x, e]);
|
|
895
|
+
const se = e.length === 1, Be = ye.useMemo(() => {
|
|
896
|
+
if (se && e.length > 0) {
|
|
897
|
+
const o = e[0];
|
|
894
898
|
if (o.data.length > 0)
|
|
895
899
|
return o.data[o.data.length - 1];
|
|
896
900
|
}
|
|
897
|
-
}, [se,
|
|
901
|
+
}, [se, e]);
|
|
898
902
|
return /* @__PURE__ */ ne(
|
|
899
903
|
"div",
|
|
900
904
|
{
|
|
901
|
-
ref:
|
|
905
|
+
ref: I,
|
|
902
906
|
className: le(
|
|
903
907
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
904
|
-
|
|
908
|
+
n
|
|
905
909
|
),
|
|
906
910
|
children: [
|
|
907
|
-
|
|
908
|
-
|
|
911
|
+
he != null && he !== !1 && se ? /* @__PURE__ */ w("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ w("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: he }) }) : Ze && se && Be && /* @__PURE__ */ w(
|
|
912
|
+
ft,
|
|
909
913
|
{
|
|
910
|
-
point:
|
|
914
|
+
point: Be,
|
|
911
915
|
xMeasureUnit: d,
|
|
912
916
|
yMeasureUnit: v,
|
|
913
|
-
decimals:
|
|
917
|
+
decimals: fe
|
|
914
918
|
}
|
|
915
919
|
),
|
|
916
|
-
|
|
917
|
-
|
|
920
|
+
Re && Me && /* @__PURE__ */ w(
|
|
921
|
+
ht,
|
|
918
922
|
{
|
|
919
|
-
points:
|
|
923
|
+
points: Re,
|
|
920
924
|
xMeasureUnit: d,
|
|
921
925
|
yMeasureUnit: v,
|
|
922
|
-
series:
|
|
926
|
+
series: e,
|
|
923
927
|
position: Me,
|
|
924
|
-
containerRef:
|
|
925
|
-
decimals:
|
|
928
|
+
containerRef: I,
|
|
929
|
+
decimals: fe
|
|
926
930
|
}
|
|
927
931
|
),
|
|
928
|
-
f && /* @__PURE__ */ w(
|
|
932
|
+
f && /* @__PURE__ */ w(Nt, { series: e, onUnselect: c }),
|
|
929
933
|
x && x.length > 0 && ke.length === x.length && /* @__PURE__ */ w(
|
|
930
934
|
"div",
|
|
931
935
|
{
|
|
932
936
|
className: "absolute inset-0 z-[5] pointer-events-none",
|
|
933
937
|
"aria-hidden": !0,
|
|
934
938
|
children: x.map((o, s) => {
|
|
935
|
-
const
|
|
936
|
-
if (
|
|
937
|
-
const { labelText: u, valueStr: h } =
|
|
939
|
+
const l = ke[s], a = o.options ?? {}, i = a.showLabel !== !1;
|
|
940
|
+
if (l === null || !i) return null;
|
|
941
|
+
const { labelText: u, valueStr: h } = yt(
|
|
938
942
|
a,
|
|
939
943
|
v,
|
|
940
|
-
|
|
944
|
+
fe
|
|
941
945
|
), b = a.tooltipText ?? "";
|
|
942
946
|
if (!(u || h || b)) return null;
|
|
943
|
-
const W = a.labelBackgroundColor ?? a.color ?? "hsl(var(--background))", P = a.labelTextColor ?? "hsl(var(--foreground))", _ = `${String(o.xCoordinate)}-${u}-${b}
|
|
947
|
+
const W = a.labelBackgroundColor ?? a.color ?? "hsl(var(--background))", P = a.labelTextColor ?? "hsl(var(--foreground))", _ = `${String(o.xCoordinate)}-${u}-${b}`, m = xt(
|
|
948
|
+
l,
|
|
949
|
+
Je
|
|
950
|
+
);
|
|
944
951
|
return /* @__PURE__ */ ne(
|
|
945
952
|
"div",
|
|
946
953
|
{
|
|
@@ -949,8 +956,7 @@ function Bt({
|
|
|
949
956
|
b && "pointer-events-auto cursor-default"
|
|
950
957
|
),
|
|
951
958
|
style: {
|
|
952
|
-
|
|
953
|
-
transform: "translateX(-50%)",
|
|
959
|
+
...m,
|
|
954
960
|
backgroundColor: W,
|
|
955
961
|
color: P
|
|
956
962
|
},
|
|
@@ -975,7 +981,7 @@ function Bt({
|
|
|
975
981
|
/* @__PURE__ */ w(
|
|
976
982
|
"div",
|
|
977
983
|
{
|
|
978
|
-
ref:
|
|
984
|
+
ref: me,
|
|
979
985
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
980
986
|
}
|
|
981
987
|
)
|
|
@@ -983,9 +989,9 @@ function Bt({
|
|
|
983
989
|
}
|
|
984
990
|
);
|
|
985
991
|
}
|
|
986
|
-
function
|
|
987
|
-
series:
|
|
988
|
-
onUnselect:
|
|
992
|
+
function Nt({
|
|
993
|
+
series: e,
|
|
994
|
+
onUnselect: n,
|
|
989
995
|
inline: f = !1
|
|
990
996
|
}) {
|
|
991
997
|
return /* @__PURE__ */ w(
|
|
@@ -995,8 +1001,8 @@ function yt({
|
|
|
995
1001
|
"flex flex-wrap gap-2",
|
|
996
1002
|
f ? "items-center" : "absolute top-0 left-2 z-[10]"
|
|
997
1003
|
),
|
|
998
|
-
children:
|
|
999
|
-
const v =
|
|
1004
|
+
children: e.map((c, d) => {
|
|
1005
|
+
const v = qe(d), z = (c.lineColor ?? c.color) || v.line, x = c.data.length === 0;
|
|
1000
1006
|
return /* @__PURE__ */ ne(
|
|
1001
1007
|
"div",
|
|
1002
1008
|
{
|
|
@@ -1009,19 +1015,19 @@ function yt({
|
|
|
1009
1015
|
"div",
|
|
1010
1016
|
{
|
|
1011
1017
|
className: "w-3 h-3 rounded-sm",
|
|
1012
|
-
style: { backgroundColor:
|
|
1018
|
+
style: { backgroundColor: z }
|
|
1013
1019
|
}
|
|
1014
1020
|
),
|
|
1015
1021
|
/* @__PURE__ */ ne("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
1016
1022
|
c.label,
|
|
1017
1023
|
x && " (no data)"
|
|
1018
1024
|
] }),
|
|
1019
|
-
|
|
1025
|
+
n && /* @__PURE__ */ w(
|
|
1020
1026
|
"button",
|
|
1021
1027
|
{
|
|
1022
1028
|
type: "button",
|
|
1023
1029
|
onClick: (M) => {
|
|
1024
|
-
M.stopPropagation(),
|
|
1030
|
+
M.stopPropagation(), n(c.label);
|
|
1025
1031
|
},
|
|
1026
1032
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
1027
1033
|
"aria-label": `Remove ${c.label}`,
|
|
@@ -1058,9 +1064,11 @@ function yt({
|
|
|
1058
1064
|
}
|
|
1059
1065
|
export {
|
|
1060
1066
|
we as DEFAULT_SERIES_COLORS,
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
Oe as
|
|
1064
|
-
|
|
1065
|
-
|
|
1067
|
+
Wt as Graph,
|
|
1068
|
+
Nt as GraphLegend,
|
|
1069
|
+
Oe as VERTICAL_LINE_LABEL_EDGE_PADDING,
|
|
1070
|
+
qe as getSeriesColorPalette,
|
|
1071
|
+
wt as getStepForwardValue,
|
|
1072
|
+
xt as getVerticalLineLabelStyle,
|
|
1073
|
+
yt as getVerticalLineTooltipContent
|
|
1066
1074
|
};
|