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