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