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