@gearbox-protocol/ui-kit 4.0.0-next.36 → 4.0.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.
- package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/tab-control/tab-control.cjs +1 -1
- package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
- package/dist/cjs/locale/en.json.cjs +1 -1
- package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +56 -56
- package/dist/esm/components/graph/graph.js +407 -375
- package/dist/esm/components/tab-control/tab-control.js +29 -23
- package/dist/esm/components/trading-view/trading-view.js +87 -85
- package/dist/esm/locale/en.json.js +23 -23
- package/dist/globals.css +1 -1
- package/dist/types/components/graph/graph.d.ts +14 -1
- package/dist/types/components/graph/index.d.ts +1 -1
- package/dist/types/components/trading-view/trading-view.d.ts +8 -1
- package/dist/types/locale/en.json.d.ts +23 -23
- package/package.json +1 -1
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createChart as ht, CrosshairMode as
|
|
1
|
+
import { jsxs as te, jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import { createChart as ht, CrosshairMode as dt, LineStyle as le, LineSeries as mt, AreaSeries as gt } from "lightweight-charts";
|
|
3
3
|
import * as Ve from "react";
|
|
4
|
-
import { useRef as K, useState as
|
|
4
|
+
import { useRef as K, useState as ne, useEffect as G, useLayoutEffect as pt } from "react";
|
|
5
5
|
import { useIsMobile as bt } from "../../hooks/use-media-query.js";
|
|
6
|
-
import { cn as
|
|
7
|
-
import { resolveCSSColor as
|
|
8
|
-
import { getDefaultOptions as Je, getDefaultSeries as vt, AXIS_TICK_MARK_DENSITY as
|
|
6
|
+
import { cn as Z } from "../../utils/cn.js";
|
|
7
|
+
import { resolveCSSColor as ie, generateColorsFromBase as Ce, hslToHex as St } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as Je, getDefaultSeries as vt, AXIS_TICK_MARK_DENSITY as ve, getDefaultVerticalLine as Ct, AXIS_FONT_SIZE as xt, AXIS_EDGE_LABEL_PADDING_PX as Qe, AXIS_TOP_LABEL_PADDING_PX as Ye, AXIS_TIME_EDGE_PADDING_PX as yt } from "./default-config.js";
|
|
9
9
|
import { getXFormatters as Ue, formatExactValue as Le, isRatioUnit as _t, createAdaptiveYAxisFormatter as wt } from "./formatters.js";
|
|
10
10
|
import { GraphCurrentValue as Pt } from "./graph-current-value.js";
|
|
11
|
-
import { GraphTooltip as
|
|
12
|
-
import { VertLine as
|
|
13
|
-
import { pickMinMove as
|
|
14
|
-
function
|
|
11
|
+
import { GraphTooltip as Nt } from "./graph-tooltip.js";
|
|
12
|
+
import { VertLine as Rt } from "./plugins/vertical-line.js";
|
|
13
|
+
import { pickMinMove as Tt, niceAxisRange as Vt } from "./y-axis-scale.js";
|
|
14
|
+
function ae(e) {
|
|
15
15
|
return e.id ?? e.label;
|
|
16
16
|
}
|
|
17
|
-
function et(e, i,
|
|
18
|
-
if (!
|
|
17
|
+
function et(e, i, c) {
|
|
18
|
+
if (!c)
|
|
19
19
|
return e.values().next().value;
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
return
|
|
20
|
+
const u = e.get(c);
|
|
21
|
+
if (u) return u;
|
|
22
|
+
const h = i.find((f) => f.id === c || f.label === c);
|
|
23
|
+
return h ? e.get(ae(h)) : void 0;
|
|
24
24
|
}
|
|
25
25
|
class Lt {
|
|
26
26
|
_yTop;
|
|
27
27
|
_yBottom;
|
|
28
28
|
_color;
|
|
29
|
-
constructor(i,
|
|
30
|
-
this._yTop = i, this._yBottom =
|
|
29
|
+
constructor(i, c, u) {
|
|
30
|
+
this._yTop = i, this._yBottom = c, this._color = u;
|
|
31
31
|
}
|
|
32
32
|
draw(i) {
|
|
33
|
-
i.useBitmapCoordinateSpace((
|
|
34
|
-
const
|
|
35
|
-
|
|
33
|
+
i.useBitmapCoordinateSpace((c) => {
|
|
34
|
+
const u = c.context, h = c.verticalPixelRatio, f = this._yTop === null ? 0 : this._yTop * h, S = this._yBottom === null ? c.bitmapSize.height : this._yBottom * h, P = Math.min(f, S), I = Math.max(f, S);
|
|
35
|
+
u.fillStyle = this._color, u.fillRect(0, P, c.bitmapSize.width, I - P);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -61,8 +61,8 @@ class kt {
|
|
|
61
61
|
priceBottom;
|
|
62
62
|
color;
|
|
63
63
|
_paneViews;
|
|
64
|
-
constructor(i,
|
|
65
|
-
this.series = i, this.priceTop =
|
|
64
|
+
constructor(i, c, u, h) {
|
|
65
|
+
this.series = i, this.priceTop = c, this.priceBottom = u, this.color = h, this._paneViews = [new Mt(this)];
|
|
66
66
|
}
|
|
67
67
|
updateAllViews() {
|
|
68
68
|
for (const i of this._paneViews) i.update();
|
|
@@ -73,13 +73,13 @@ class kt {
|
|
|
73
73
|
}
|
|
74
74
|
function It(e, i) {
|
|
75
75
|
switch (e) {
|
|
76
|
-
case
|
|
76
|
+
case le.Dotted:
|
|
77
77
|
return [i, i];
|
|
78
|
-
case
|
|
78
|
+
case le.Dashed:
|
|
79
79
|
return [2 * i, 2 * i];
|
|
80
|
-
case
|
|
80
|
+
case le.LargeDashed:
|
|
81
81
|
return [6 * i, 6 * i];
|
|
82
|
-
case
|
|
82
|
+
case le.SparseDotted:
|
|
83
83
|
return [i, 4 * i];
|
|
84
84
|
default:
|
|
85
85
|
return [];
|
|
@@ -90,14 +90,14 @@ class Dt {
|
|
|
90
90
|
_color;
|
|
91
91
|
_lineWidth;
|
|
92
92
|
_lineStyle;
|
|
93
|
-
constructor(i,
|
|
94
|
-
this._y = i, this._color =
|
|
93
|
+
constructor(i, c, u, h) {
|
|
94
|
+
this._y = i, this._color = c, this._lineWidth = u, this._lineStyle = h;
|
|
95
95
|
}
|
|
96
96
|
draw(i) {
|
|
97
|
-
i.useBitmapCoordinateSpace((
|
|
97
|
+
i.useBitmapCoordinateSpace((c) => {
|
|
98
98
|
if (this._y === null) return;
|
|
99
|
-
const
|
|
100
|
-
|
|
99
|
+
const u = c.context, h = c.verticalPixelRatio, f = Math.max(1, Math.round(this._lineWidth * h)), S = Math.round(this._y * h);
|
|
100
|
+
u.save(), u.strokeStyle = this._color, u.lineWidth = f, u.setLineDash(It(this._lineStyle, f)), u.beginPath(), u.moveTo(0, S), u.lineTo(c.bitmapSize.width, S), u.stroke(), u.restore();
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -135,8 +135,8 @@ class Bt {
|
|
|
135
135
|
lineWidth;
|
|
136
136
|
lineStyle;
|
|
137
137
|
_paneViews;
|
|
138
|
-
constructor(i,
|
|
139
|
-
this.series = i, this.price =
|
|
138
|
+
constructor(i, c, u, h, f) {
|
|
139
|
+
this.series = i, this.price = c, this.color = u, this.lineWidth = h, this.lineStyle = f, this._paneViews = [new Et(this)];
|
|
140
140
|
}
|
|
141
141
|
updateAllViews() {
|
|
142
142
|
for (const i of this._paneViews) i.update();
|
|
@@ -145,26 +145,26 @@ class Bt {
|
|
|
145
145
|
return this._paneViews;
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
function Ft(e, i,
|
|
149
|
-
const
|
|
150
|
-
|
|
148
|
+
function Ft(e, i, c) {
|
|
149
|
+
const u = e.labelText ?? "", h = e.value, f = h === void 0 ? "" : typeof h == "number" ? i === "$" ? `$${Le(h, void 0, c)}` : i === "%" ? `${Le(h, void 0, c)}%` : Le(
|
|
150
|
+
h,
|
|
151
151
|
i !== "none" && i !== "%" && i !== "$" && !_t(i) ? i : void 0,
|
|
152
|
-
|
|
153
|
-
) : String(
|
|
154
|
-
return { labelText:
|
|
152
|
+
c
|
|
153
|
+
) : String(h);
|
|
154
|
+
return { labelText: u, valueStr: f };
|
|
155
155
|
}
|
|
156
156
|
const tt = 4;
|
|
157
|
-
function zt(e, i,
|
|
158
|
-
const
|
|
159
|
-
if (i <= 0 || !
|
|
160
|
-
return
|
|
161
|
-
const
|
|
162
|
-
return S <
|
|
157
|
+
function zt(e, i, c) {
|
|
158
|
+
const u = { left: e, transform: "translateX(-50%)" };
|
|
159
|
+
if (i <= 0 || !c || c <= 0)
|
|
160
|
+
return u;
|
|
161
|
+
const h = c / 2, f = tt + h, S = i - tt - h;
|
|
162
|
+
return S < f ? { left: i / 2, transform: "translateX(-50%)" } : { left: Math.min(Math.max(e, f), S), transform: "translateX(-50%)" };
|
|
163
163
|
}
|
|
164
164
|
function At(e, i) {
|
|
165
|
-
for (let
|
|
166
|
-
if (Number(e[
|
|
167
|
-
return e[
|
|
165
|
+
for (let c = e.length - 1; c >= 0; c--)
|
|
166
|
+
if (Number(e[c].time) <= i)
|
|
167
|
+
return e[c].value;
|
|
168
168
|
return 0;
|
|
169
169
|
}
|
|
170
170
|
const Me = [
|
|
@@ -286,55 +286,55 @@ const Me = [
|
|
|
286
286
|
function ot(e) {
|
|
287
287
|
if (e < Me.length)
|
|
288
288
|
return Me[e];
|
|
289
|
-
const
|
|
290
|
-
return { line:
|
|
289
|
+
const c = (e - Me.length) * Gt % 360, u = St(c, 70, 50), { topColor: h, bottomColor: f } = Ce(u);
|
|
290
|
+
return { line: u, top: h, bottom: f };
|
|
291
291
|
}
|
|
292
292
|
function oo({
|
|
293
293
|
series: e,
|
|
294
294
|
className: i,
|
|
295
|
-
showLegend:
|
|
296
|
-
onUnselectSeries:
|
|
297
|
-
xMeasureUnit:
|
|
298
|
-
yMeasureUnit:
|
|
295
|
+
showLegend: c = !1,
|
|
296
|
+
onUnselectSeries: u,
|
|
297
|
+
xMeasureUnit: h = "time",
|
|
298
|
+
yMeasureUnit: f = "token",
|
|
299
299
|
optionsOverrides: S,
|
|
300
|
-
verticalLineOptions:
|
|
301
|
-
priceLineOptions:
|
|
302
|
-
zoneOptions:
|
|
303
|
-
currentValueDecimals:
|
|
304
|
-
useSharedPriceScale:
|
|
300
|
+
verticalLineOptions: P,
|
|
301
|
+
priceLineOptions: I,
|
|
302
|
+
zoneOptions: F,
|
|
303
|
+
currentValueDecimals: se,
|
|
304
|
+
useSharedPriceScale: q = !1,
|
|
305
305
|
dualYAxis: D = !1,
|
|
306
306
|
defaultVisiblePriceScaleId: ke = "right",
|
|
307
307
|
leftPriceScaleTitle: Ie,
|
|
308
308
|
rightPriceScaleTitle: Xt,
|
|
309
309
|
showCurrentValue: rt = !0,
|
|
310
|
-
graphTitle:
|
|
310
|
+
graphTitle: xe,
|
|
311
311
|
yScaleMin: De,
|
|
312
312
|
yScaleMinMultiple: Ee,
|
|
313
|
-
visibleTimeFrom:
|
|
313
|
+
visibleTimeFrom: Y,
|
|
314
314
|
disableZoom: Be = !1,
|
|
315
|
-
hideDefaultTooltip:
|
|
315
|
+
hideDefaultTooltip: ye = !1
|
|
316
316
|
}) {
|
|
317
|
-
const E = K(null), L = K(/* @__PURE__ */ new Map()), _e = K(!1), Fe = K(!0), ze = K([]),
|
|
317
|
+
const E = K(null), L = K(/* @__PURE__ */ new Map()), _e = K(!1), Fe = K(!0), ze = K([]), ce = K(0), B = K(null), we = K(null), Ae = K(null), N = bt(), ue = Ve.useMemo(() => e.flatMap((t) => t.data), [e]), nt = Ve.useMemo(() => {
|
|
318
318
|
if (e.length > 0) {
|
|
319
319
|
const t = e[e.length - 1];
|
|
320
320
|
if (t.data.length > 0)
|
|
321
321
|
return t.data[t.data.length - 1];
|
|
322
322
|
}
|
|
323
|
-
}, [e]), [Ge, Pe] =
|
|
323
|
+
}, [e]), [Ge, Pe] = ne(() => {
|
|
324
324
|
if (!nt) return;
|
|
325
325
|
const t = /* @__PURE__ */ new Map();
|
|
326
326
|
for (const l of e)
|
|
327
327
|
l.data.length > 0 && t.set(l.label, l.data[l.data.length - 1]);
|
|
328
328
|
return t;
|
|
329
|
-
}), [We,
|
|
330
|
-
|
|
329
|
+
}), [We, J] = ne(null), [Xe, $e] = ne([]), [it, He] = ne(0), je = K(/* @__PURE__ */ new Map()), [at, lt] = ne({}), [U, st] = ne(0);
|
|
330
|
+
G(() => {
|
|
331
331
|
const t = () => {
|
|
332
332
|
try {
|
|
333
333
|
if (B.current && He(B.current.clientWidth), E.current && B.current) {
|
|
334
|
-
const a = B.current.clientWidth,
|
|
335
|
-
E.current.resize(a,
|
|
334
|
+
const a = B.current.clientWidth, s = B.current.clientHeight;
|
|
335
|
+
E.current.resize(a, s);
|
|
336
336
|
try {
|
|
337
|
-
|
|
337
|
+
ce.current = E.current.paneSize().height;
|
|
338
338
|
} catch {
|
|
339
339
|
}
|
|
340
340
|
}
|
|
@@ -344,9 +344,9 @@ function oo({
|
|
|
344
344
|
return Ae.current = n, l && n?.observe(l), () => {
|
|
345
345
|
l && n?.unobserve(l), n?.disconnect(), Ae.current = null;
|
|
346
346
|
};
|
|
347
|
-
}, []),
|
|
347
|
+
}, []), G(() => {
|
|
348
348
|
if (!we.current || _e.current) return;
|
|
349
|
-
const t = Je(), l =
|
|
349
|
+
const t = Je(), l = ie(
|
|
350
350
|
"hsl(var(--muted-foreground))",
|
|
351
351
|
"rgb(163, 163, 163)"
|
|
352
352
|
), n = ht(we.current, {
|
|
@@ -358,26 +358,26 @@ function oo({
|
|
|
358
358
|
},
|
|
359
359
|
rightPriceScale: {
|
|
360
360
|
...t.rightPriceScale || {},
|
|
361
|
-
visible: !
|
|
361
|
+
visible: !N,
|
|
362
362
|
textColor: l
|
|
363
363
|
},
|
|
364
|
-
...
|
|
364
|
+
...N && {
|
|
365
365
|
crosshair: {
|
|
366
366
|
...t.crosshair,
|
|
367
|
-
mode:
|
|
367
|
+
mode: dt.Magnet
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
});
|
|
371
371
|
E.current = n, _e.current = !0;
|
|
372
372
|
try {
|
|
373
|
-
|
|
373
|
+
ce.current = n.paneSize().height;
|
|
374
374
|
} catch {
|
|
375
|
-
|
|
375
|
+
ce.current = 0;
|
|
376
376
|
}
|
|
377
377
|
return st((a) => a + 1), () => {
|
|
378
378
|
n.remove(), E.current = null, _e.current = !1, L.current.clear();
|
|
379
379
|
};
|
|
380
|
-
}, [
|
|
380
|
+
}, [N]), G(() => {
|
|
381
381
|
const t = E.current;
|
|
382
382
|
t && t.applyOptions(
|
|
383
383
|
Be ? {
|
|
@@ -408,53 +408,53 @@ function oo({
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
);
|
|
411
|
-
}, [
|
|
411
|
+
}, [U, Be]), G(() => {
|
|
412
412
|
const t = E.current;
|
|
413
413
|
!t || !S || t.applyOptions(S);
|
|
414
|
-
}, [
|
|
414
|
+
}, [U, S]), G(() => {
|
|
415
415
|
const t = E.current;
|
|
416
416
|
if (!t || e.length === 0) return;
|
|
417
|
-
const n = e.filter((r) => r.data.length > 0).length <= 1 ? De : Ee, a =
|
|
417
|
+
const n = e.filter((r) => r.data.length > 0).length <= 1 ? De : Ee, a = h === "time" ? Ue(h, ue) : Ue(h), s = /* @__PURE__ */ new Map();
|
|
418
418
|
{
|
|
419
419
|
let r = 0;
|
|
420
420
|
for (const o of e)
|
|
421
|
-
o.data.length !== 0 && (
|
|
421
|
+
o.data.length !== 0 && (s.set(
|
|
422
422
|
o.label,
|
|
423
423
|
o.priceScaleId ?? (r === 0 ? "left" : "right")
|
|
424
424
|
), r++);
|
|
425
425
|
}
|
|
426
|
-
const
|
|
427
|
-
const { formatter:
|
|
426
|
+
const d = (r, o, m) => {
|
|
427
|
+
const { formatter: z, tickmarksFormatter: T, updateVisibleRange: V } = wt(r, o, {
|
|
428
428
|
yScaleMin: n
|
|
429
429
|
});
|
|
430
|
-
return { formatter:
|
|
431
|
-
},
|
|
430
|
+
return { formatter: z, tickmarksFormatter: T, updateVisibleRange: V, labels: m };
|
|
431
|
+
}, g = [];
|
|
432
432
|
if (D)
|
|
433
433
|
for (const r of ["left", "right"]) {
|
|
434
|
-
const o = /* @__PURE__ */ new Set(),
|
|
435
|
-
let
|
|
434
|
+
const o = /* @__PURE__ */ new Set(), m = [];
|
|
435
|
+
let z = f;
|
|
436
436
|
for (const T of e)
|
|
437
|
-
if (T.data.length !== 0 &&
|
|
438
|
-
o.size === 0 && T.yMeasureUnit && (
|
|
439
|
-
for (const
|
|
437
|
+
if (T.data.length !== 0 && s.get(T.label) === r) {
|
|
438
|
+
o.size === 0 && T.yMeasureUnit && (z = T.yMeasureUnit), o.add(T.label);
|
|
439
|
+
for (const V of T.data) m.push(V.value);
|
|
440
440
|
}
|
|
441
|
-
o.size > 0 &&
|
|
441
|
+
o.size > 0 && g.push(d(m, z, o));
|
|
442
442
|
}
|
|
443
443
|
else {
|
|
444
|
-
const r =
|
|
445
|
-
e.filter((
|
|
444
|
+
const r = ue.map((m) => m.value), o = new Set(
|
|
445
|
+
e.filter((m) => m.data.length > 0).map((m) => m.label)
|
|
446
446
|
);
|
|
447
|
-
|
|
447
|
+
g.push(d(r, f, o));
|
|
448
448
|
}
|
|
449
|
-
ze.current =
|
|
450
|
-
const
|
|
451
|
-
for (const r of
|
|
449
|
+
ze.current = g;
|
|
450
|
+
const x = /* @__PURE__ */ new Map();
|
|
451
|
+
for (const r of g)
|
|
452
452
|
for (const o of r.labels)
|
|
453
|
-
|
|
454
|
-
const
|
|
453
|
+
x.set(o, r);
|
|
454
|
+
const y = Je();
|
|
455
455
|
t.applyOptions({
|
|
456
456
|
localization: {
|
|
457
|
-
...
|
|
457
|
+
...y.localization || {},
|
|
458
458
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
459
459
|
timeFormatter: (r) => (
|
|
460
460
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
@@ -462,14 +462,14 @@ function oo({
|
|
|
462
462
|
)
|
|
463
463
|
},
|
|
464
464
|
timeScale: {
|
|
465
|
-
...
|
|
465
|
+
...y.timeScale || {},
|
|
466
466
|
...S?.timeScale,
|
|
467
467
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
468
468
|
tickMarkFormatter: a.tickMarkFormatter,
|
|
469
469
|
minBarSpacing: 0
|
|
470
470
|
}
|
|
471
471
|
});
|
|
472
|
-
const v = !D && e.length > 1 && !
|
|
472
|
+
const v = !D && e.length > 1 && !q, W = D ? N : e.length > 1 && !q || N, M = ie(
|
|
473
473
|
"hsl(var(--muted-foreground))",
|
|
474
474
|
"rgb(163, 163, 163)"
|
|
475
475
|
);
|
|
@@ -478,88 +478,88 @@ function oo({
|
|
|
478
478
|
defaultVisiblePriceScaleId: ke
|
|
479
479
|
},
|
|
480
480
|
leftPriceScale: {
|
|
481
|
-
...
|
|
481
|
+
...y.leftPriceScale || {},
|
|
482
482
|
...S?.leftPriceScale,
|
|
483
|
-
visible: D && !
|
|
483
|
+
visible: D && !N,
|
|
484
484
|
textColor: M,
|
|
485
485
|
...D && Ie && {
|
|
486
486
|
// lightweight-charts uses scale margins; title shown via localization if needed
|
|
487
487
|
}
|
|
488
488
|
},
|
|
489
489
|
rightPriceScale: {
|
|
490
|
-
...
|
|
490
|
+
...y.rightPriceScale || {},
|
|
491
491
|
...S?.rightPriceScale,
|
|
492
|
-
visible: D ? !
|
|
492
|
+
visible: D ? !N : !W,
|
|
493
493
|
textColor: M
|
|
494
494
|
}
|
|
495
495
|
});
|
|
496
|
-
const
|
|
497
|
-
for (const r of
|
|
496
|
+
const ee = new Set(L.current.keys()), X = new Set(e.map(ae));
|
|
497
|
+
for (const r of ee)
|
|
498
498
|
if (!X.has(r)) {
|
|
499
499
|
const o = L.current.get(r);
|
|
500
500
|
o && (t.removeSeries(o), L.current.delete(r));
|
|
501
501
|
}
|
|
502
|
-
const p = vt(),
|
|
502
|
+
const p = vt(), k = [];
|
|
503
503
|
let R = 0;
|
|
504
504
|
const $ = e.find((r) => r.data.length > 0), C = /* @__PURE__ */ new Map();
|
|
505
|
-
if (
|
|
506
|
-
for (const r of
|
|
505
|
+
if (I && I.length > 0)
|
|
506
|
+
for (const r of I) {
|
|
507
507
|
if (!Number.isFinite(r.price)) continue;
|
|
508
508
|
const o = r.seriesLabel ?? $?.label;
|
|
509
509
|
if (!o) continue;
|
|
510
|
-
const
|
|
511
|
-
|
|
510
|
+
const m = C.get(o) ?? [];
|
|
511
|
+
m.push(r.price), C.set(o, m);
|
|
512
512
|
}
|
|
513
|
-
if (
|
|
514
|
-
for (const r of
|
|
513
|
+
if (F && F.length > 0)
|
|
514
|
+
for (const r of F) {
|
|
515
515
|
const o = r.seriesLabel ?? $?.label;
|
|
516
516
|
if (!o) continue;
|
|
517
|
-
const
|
|
518
|
-
Number.isFinite(r.priceTop) &&
|
|
517
|
+
const m = C.get(o) ?? [];
|
|
518
|
+
Number.isFinite(r.priceTop) && m.push(r.priceTop), Number.isFinite(r.priceBottom) && m.push(r.priceBottom), C.set(o, m);
|
|
519
519
|
}
|
|
520
520
|
for (let r = 0; r < e.length; r++) {
|
|
521
|
-
const o = e[r],
|
|
522
|
-
let
|
|
521
|
+
const o = e[r], m = ae(o), z = ot(r), T = o.lineColor ?? o.color ?? z.line;
|
|
522
|
+
let V, Q;
|
|
523
523
|
if (o.lineColor ?? o.color)
|
|
524
524
|
if (o.topColor && o.bottomColor)
|
|
525
|
-
|
|
525
|
+
V = o.topColor, Q = o.bottomColor;
|
|
526
526
|
else if (o.topColor) {
|
|
527
|
-
const b =
|
|
528
|
-
|
|
527
|
+
const b = Ce(T);
|
|
528
|
+
V = o.topColor, Q = b.bottomColor;
|
|
529
529
|
} else if (o.bottomColor)
|
|
530
|
-
|
|
530
|
+
V = Ce(T).topColor, Q = o.bottomColor;
|
|
531
531
|
else {
|
|
532
|
-
const b =
|
|
533
|
-
|
|
532
|
+
const b = Ce(T);
|
|
533
|
+
V = b.topColor, Q = b.bottomColor;
|
|
534
534
|
}
|
|
535
535
|
else
|
|
536
|
-
|
|
536
|
+
V = o.topColor || z.top, Q = o.bottomColor || z.bottom;
|
|
537
537
|
if (o.data.length === 0) {
|
|
538
|
-
const b = L.current.get(
|
|
539
|
-
b && (t.removeSeries(b), L.current.delete(
|
|
538
|
+
const b = L.current.get(m);
|
|
539
|
+
b && (t.removeSeries(b), L.current.delete(m));
|
|
540
540
|
continue;
|
|
541
541
|
}
|
|
542
|
-
const pe = o.data.length > 0 ? Math.min(...o.data.map((b) => b.value)) : 0,
|
|
543
|
-
v &&
|
|
544
|
-
priceScaleId:
|
|
542
|
+
const pe = o.data.length > 0 ? Math.min(...o.data.map((b) => b.value)) : 0, fe = o.data.length > 0 ? Math.max(...o.data.map((b) => b.value)) : 0, he = pe < 0, O = o.data.some((b) => b.value === 0), be = !he && O, de = Tt(fe - pe), me = D ? o.priceScaleId ?? (R === 0 ? "left" : "right") : q || !v || R === 0 ? "right" : `scale-${R}`;
|
|
543
|
+
v && k.push({
|
|
544
|
+
priceScaleId: me || "right",
|
|
545
545
|
seriesIndex: R
|
|
546
546
|
});
|
|
547
|
-
const
|
|
547
|
+
const Ne = (q || !v) && n !== void 0 && typeof n == "number", ct = C.get(o.label) ?? [], ut = (b) => {
|
|
548
548
|
const _ = b();
|
|
549
549
|
if (_?.priceRange) {
|
|
550
|
-
|
|
550
|
+
Ne && (_.priceRange.minValue = n);
|
|
551
551
|
for (const j of ct)
|
|
552
552
|
j < _.priceRange.minValue && (_.priceRange.minValue = j), j > _.priceRange.maxValue && (_.priceRange.maxValue = j);
|
|
553
|
-
const
|
|
554
|
-
if (
|
|
553
|
+
const re = Ne ? n : be && _.priceRange.minValue >= 0 ? 0 : void 0, Se = ce.current > 0 ? ce.current : B.current?.clientHeight ?? 0;
|
|
554
|
+
if (Se > 0) {
|
|
555
555
|
const j = Vt({
|
|
556
556
|
min: _.priceRange.minValue,
|
|
557
557
|
max: _.priceRange.maxValue,
|
|
558
|
-
floor:
|
|
559
|
-
scaleHeightPx:
|
|
560
|
-
fontSizePx:
|
|
561
|
-
tickMarkDensity:
|
|
562
|
-
minMove:
|
|
558
|
+
floor: re,
|
|
559
|
+
scaleHeightPx: Se,
|
|
560
|
+
fontSizePx: xt,
|
|
561
|
+
tickMarkDensity: ve,
|
|
562
|
+
minMove: de,
|
|
563
563
|
edgePaddingPx: Qe,
|
|
564
564
|
edgePaddingTopPx: Ye
|
|
565
565
|
});
|
|
@@ -571,60 +571,60 @@ function oo({
|
|
|
571
571
|
};
|
|
572
572
|
}
|
|
573
573
|
return _;
|
|
574
|
-
}, Ze =
|
|
574
|
+
}, Ze = x.get(o.label) ?? g[0], qe = Ze.formatter, ft = Ze.tickmarksFormatter, Re = {
|
|
575
575
|
lineColor: T,
|
|
576
|
-
topColor:
|
|
577
|
-
bottomColor:
|
|
578
|
-
priceScaleId:
|
|
576
|
+
topColor: V,
|
|
577
|
+
bottomColor: Q,
|
|
578
|
+
priceScaleId: me,
|
|
579
579
|
...o.seriesType === "line" && {
|
|
580
|
-
lineStyle: o.lineStyle ??
|
|
580
|
+
lineStyle: o.lineStyle ?? le.Solid
|
|
581
581
|
},
|
|
582
582
|
priceFormat: {
|
|
583
583
|
type: "custom",
|
|
584
|
-
minMove:
|
|
585
|
-
formatter:
|
|
584
|
+
minMove: de,
|
|
585
|
+
formatter: Ne && typeof n == "number" ? (b) => qe(
|
|
586
586
|
b < n ? n : b
|
|
587
587
|
) : qe,
|
|
588
588
|
tickmarksFormatter: ft
|
|
589
589
|
},
|
|
590
590
|
autoscaleInfoProvider: ut
|
|
591
591
|
}, Oe = o.seriesType === "line";
|
|
592
|
-
let
|
|
593
|
-
const
|
|
592
|
+
let A = L.current.get(m);
|
|
593
|
+
const oe = o.data.map((b) => ({
|
|
594
594
|
...b,
|
|
595
595
|
time: b.time
|
|
596
596
|
}));
|
|
597
|
-
if (
|
|
598
|
-
const b = Number(
|
|
599
|
-
for (let
|
|
600
|
-
j.push({ time:
|
|
601
|
-
|
|
597
|
+
if (Y !== void 0 && oe.length > 0 && Number(oe[0].time) > Y) {
|
|
598
|
+
const b = Number(oe[0].time), _ = b - Y, re = 86400, Se = _ > 180 * re ? 7 * re : _ > 30 * re ? re : 6 * 3600, j = [];
|
|
599
|
+
for (let Te = Y; Te < b; Te += Se)
|
|
600
|
+
j.push({ time: Te });
|
|
601
|
+
oe.unshift(...j);
|
|
602
602
|
}
|
|
603
|
-
|
|
603
|
+
A && A.seriesType() !== (Oe ? "Line" : "Area") && (t.removeSeries(A), L.current.delete(m), A = void 0), A ? (A.applyOptions(Re), A.setData(oe)) : (Oe ? A = t.addSeries(mt, {
|
|
604
604
|
...p,
|
|
605
|
-
...
|
|
606
|
-
}) :
|
|
605
|
+
...Re
|
|
606
|
+
}) : A = t.addSeries(gt, {
|
|
607
607
|
...p,
|
|
608
|
-
...
|
|
609
|
-
}),
|
|
608
|
+
...Re
|
|
609
|
+
}), A.setData(oe), L.current.set(m, A)), R++;
|
|
610
610
|
}
|
|
611
611
|
if (D)
|
|
612
612
|
try {
|
|
613
|
-
const r = t.priceScale("left"), o = t.priceScale("right"),
|
|
614
|
-
visible: !
|
|
613
|
+
const r = t.priceScale("left"), o = t.priceScale("right"), m = {
|
|
614
|
+
visible: !N,
|
|
615
615
|
autoScale: !0,
|
|
616
616
|
scaleMargins: { top: 0, bottom: 0 },
|
|
617
617
|
alignLabels: !0,
|
|
618
618
|
entireTextOnly: !1,
|
|
619
|
-
tickMarkDensity:
|
|
619
|
+
tickMarkDensity: ve,
|
|
620
620
|
textColor: M,
|
|
621
621
|
...S?.rightPriceScale
|
|
622
622
|
};
|
|
623
|
-
r?.applyOptions(
|
|
623
|
+
r?.applyOptions(m), o?.applyOptions(m);
|
|
624
624
|
} catch {
|
|
625
625
|
}
|
|
626
|
-
else if (v &&
|
|
627
|
-
for (const r of
|
|
626
|
+
else if (v && k.length > 0)
|
|
627
|
+
for (const r of k)
|
|
628
628
|
try {
|
|
629
629
|
const o = t.priceScale(r.priceScaleId);
|
|
630
630
|
o && o.applyOptions({
|
|
@@ -636,7 +636,7 @@ function oo({
|
|
|
636
636
|
},
|
|
637
637
|
alignLabels: !0,
|
|
638
638
|
entireTextOnly: !1,
|
|
639
|
-
tickMarkDensity:
|
|
639
|
+
tickMarkDensity: ve,
|
|
640
640
|
textColor: M
|
|
641
641
|
});
|
|
642
642
|
} catch (o) {
|
|
@@ -649,7 +649,7 @@ function oo({
|
|
|
649
649
|
try {
|
|
650
650
|
const r = t.priceScale("right");
|
|
651
651
|
r && r.applyOptions({
|
|
652
|
-
visible: !
|
|
652
|
+
visible: !N,
|
|
653
653
|
autoScale: !0,
|
|
654
654
|
scaleMargins: {
|
|
655
655
|
top: 0,
|
|
@@ -657,47 +657,47 @@ function oo({
|
|
|
657
657
|
},
|
|
658
658
|
alignLabels: !0,
|
|
659
659
|
entireTextOnly: !1,
|
|
660
|
-
tickMarkDensity:
|
|
660
|
+
tickMarkDensity: ve,
|
|
661
661
|
textColor: M,
|
|
662
662
|
...S?.rightPriceScale
|
|
663
663
|
});
|
|
664
664
|
} catch {
|
|
665
665
|
}
|
|
666
|
-
if (n !== void 0 && !
|
|
666
|
+
if (n !== void 0 && !N && (q || !v) && t.applyOptions({
|
|
667
667
|
handleScroll: {
|
|
668
668
|
vertTouchDrag: !1
|
|
669
669
|
}
|
|
670
|
-
}),
|
|
671
|
-
const r =
|
|
670
|
+
}), ue.length > 0) {
|
|
671
|
+
const r = ue.map((o) => Number(o.time)).filter((o) => Number.isFinite(o));
|
|
672
672
|
if (r.length > 0) {
|
|
673
|
-
const o = Math.min(...r),
|
|
674
|
-
if (Number(
|
|
673
|
+
const o = Math.min(...r), m = Y !== void 0 ? Math.min(Y, o) : o, z = Math.max(...r);
|
|
674
|
+
if (Number(m) <= Number(z)) {
|
|
675
675
|
const T = () => {
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
678
|
-
|
|
676
|
+
const V = t.timeScale();
|
|
677
|
+
if (h !== "time") {
|
|
678
|
+
V.applyOptions({
|
|
679
679
|
fixLeftEdge: !0,
|
|
680
680
|
fixRightEdge: !0
|
|
681
681
|
});
|
|
682
682
|
return;
|
|
683
683
|
}
|
|
684
|
-
const
|
|
685
|
-
if (
|
|
686
|
-
fixLeftEdge: !
|
|
687
|
-
fixRightEdge: !
|
|
688
|
-
}), !
|
|
689
|
-
const
|
|
690
|
-
if (!
|
|
691
|
-
const
|
|
692
|
-
if (!(
|
|
693
|
-
const
|
|
694
|
-
|
|
695
|
-
from:
|
|
696
|
-
to:
|
|
684
|
+
const Q = D && !N, pe = D ? !N : !W, fe = !Q, he = !pe;
|
|
685
|
+
if (V.applyOptions({
|
|
686
|
+
fixLeftEdge: !fe,
|
|
687
|
+
fixRightEdge: !he
|
|
688
|
+
}), !fe && !he) return;
|
|
689
|
+
const O = V.getVisibleLogicalRange(), be = V.width();
|
|
690
|
+
if (!O || !(be > 0)) return;
|
|
691
|
+
const de = O.to - O.from;
|
|
692
|
+
if (!(de > 0)) return;
|
|
693
|
+
const me = yt * de / be;
|
|
694
|
+
V.setVisibleLogicalRange({
|
|
695
|
+
from: fe ? O.from - me : O.from,
|
|
696
|
+
to: he ? O.to + me : O.to
|
|
697
697
|
});
|
|
698
698
|
};
|
|
699
699
|
try {
|
|
700
|
-
t.timeScale().setVisibleRange({ from:
|
|
700
|
+
t.timeScale().setVisibleRange({ from: m, to: z }), T();
|
|
701
701
|
} catch {
|
|
702
702
|
try {
|
|
703
703
|
t.timeScale().fitContent(), T();
|
|
@@ -713,116 +713,116 @@ function oo({
|
|
|
713
713
|
r.data.length > 0 && H.set(r.label, r.data[r.data.length - 1]);
|
|
714
714
|
Pe(H.size > 0 ? H : void 0);
|
|
715
715
|
}, [
|
|
716
|
-
|
|
716
|
+
U,
|
|
717
717
|
e,
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
718
|
+
ue,
|
|
719
|
+
h,
|
|
720
|
+
f,
|
|
721
|
+
N,
|
|
722
|
+
q,
|
|
723
723
|
D,
|
|
724
724
|
ke,
|
|
725
725
|
Ie,
|
|
726
726
|
De,
|
|
727
727
|
Ee,
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
728
|
+
Y,
|
|
729
|
+
I,
|
|
730
|
+
F,
|
|
731
731
|
S
|
|
732
|
-
]),
|
|
732
|
+
]), G(() => {
|
|
733
733
|
const t = E.current;
|
|
734
734
|
if (!t || e.length === 0) return;
|
|
735
735
|
const l = e.length === 1;
|
|
736
736
|
let n;
|
|
737
|
-
for (const
|
|
738
|
-
if (
|
|
739
|
-
n =
|
|
737
|
+
for (const s of e)
|
|
738
|
+
if (s.data.length > 0) {
|
|
739
|
+
n = s.data[s.data.length - 1].time;
|
|
740
740
|
break;
|
|
741
741
|
}
|
|
742
742
|
if (!n) return;
|
|
743
|
-
const a = (
|
|
744
|
-
const { time:
|
|
745
|
-
if (!
|
|
743
|
+
const a = (s) => {
|
|
744
|
+
const { time: d = n, seriesData: g, point: x } = s || {}, y = e[0], v = y ? L.current.get(ae(y)) : void 0;
|
|
745
|
+
if (!x || !d) {
|
|
746
746
|
const X = /* @__PURE__ */ new Map();
|
|
747
747
|
for (const p of e)
|
|
748
748
|
p.data.length > 0 && X.set(p.label, p.data[p.data.length - 1]);
|
|
749
|
-
if (Pe(X.size > 0 ? X : void 0), l ||
|
|
750
|
-
|
|
749
|
+
if (Pe(X.size > 0 ? X : void 0), l || q || ye)
|
|
750
|
+
J(null);
|
|
751
751
|
else if (v && n) {
|
|
752
752
|
const p = e[0];
|
|
753
753
|
if (p && p.data.length > 0) {
|
|
754
754
|
const R = t.timeScale().timeToCoordinate(n), $ = p.data[p.data.length - 1].value, C = v.priceToCoordinate($);
|
|
755
|
-
R !== null && C !== null &&
|
|
755
|
+
R !== null && C !== null && J({ x: R, y: C });
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
758
|
return;
|
|
759
759
|
}
|
|
760
760
|
const W = /* @__PURE__ */ new Map();
|
|
761
|
-
let M,
|
|
761
|
+
let M, ee = v;
|
|
762
762
|
for (let X = 0; X < e.length; X++) {
|
|
763
|
-
const p = e[X],
|
|
764
|
-
if (!
|
|
765
|
-
const R =
|
|
763
|
+
const p = e[X], k = L.current.get(ae(p));
|
|
764
|
+
if (!k) continue;
|
|
765
|
+
const R = g?.get(k), $ = R && "value" in R ? R.value : void 0;
|
|
766
766
|
let C;
|
|
767
767
|
if ($ !== void 0)
|
|
768
768
|
C = $;
|
|
769
769
|
else if (l) {
|
|
770
|
-
const H = Number(
|
|
770
|
+
const H = Number(d), r = p.data.length > 0 ? Number(p.data[0].time) : Number.POSITIVE_INFINITY;
|
|
771
771
|
H < r ? C = Number.NaN : C = p.data[p.data.length - 1]?.value ?? 0;
|
|
772
772
|
} else {
|
|
773
773
|
const H = p.data.length > 0 ? Number(p.data[0].time) : Number.POSITIVE_INFINITY;
|
|
774
|
-
if (Number(
|
|
775
|
-
C = At(p.data, Number(
|
|
774
|
+
if (Number(d) < H) continue;
|
|
775
|
+
C = At(p.data, Number(d));
|
|
776
776
|
}
|
|
777
|
-
Number.isNaN(C) || (M === void 0 && (M = C,
|
|
777
|
+
Number.isNaN(C) || (M === void 0 && (M = C, ee = k), W.set(p.label, { value: C, time: d }));
|
|
778
778
|
}
|
|
779
|
-
if (Pe(W), M !== void 0 &&
|
|
780
|
-
const p = t.timeScale().timeToCoordinate(
|
|
781
|
-
if (p !== null &&
|
|
779
|
+
if (Pe(W), M !== void 0 && ee) {
|
|
780
|
+
const p = t.timeScale().timeToCoordinate(d), k = ee.priceToCoordinate(M);
|
|
781
|
+
if (p !== null && k !== null) {
|
|
782
782
|
const R = B.current;
|
|
783
783
|
if (R) {
|
|
784
784
|
const $ = R.querySelector(
|
|
785
785
|
".LightweightChart"
|
|
786
786
|
);
|
|
787
787
|
if ($) {
|
|
788
|
-
const C = $.getBoundingClientRect(), H = R.getBoundingClientRect(), r = p + (C.left - H.left), o =
|
|
789
|
-
|
|
788
|
+
const C = $.getBoundingClientRect(), H = R.getBoundingClientRect(), r = p + (C.left - H.left), o = k + (C.top - H.top);
|
|
789
|
+
J({ x: r, y: o });
|
|
790
790
|
} else
|
|
791
|
-
|
|
791
|
+
J({ x: p, y: k });
|
|
792
792
|
} else
|
|
793
|
-
|
|
793
|
+
J({ x: p, y: k });
|
|
794
794
|
} else
|
|
795
|
-
|
|
795
|
+
J(null);
|
|
796
796
|
} else
|
|
797
|
-
|
|
797
|
+
J(null);
|
|
798
798
|
};
|
|
799
|
-
return t.subscribeCrosshairMove(a),
|
|
800
|
-
const
|
|
801
|
-
if (
|
|
802
|
-
const
|
|
803
|
-
|
|
799
|
+
return t.subscribeCrosshairMove(a), N && t.subscribeClick(a), !l && !q && !ye && requestAnimationFrame(() => {
|
|
800
|
+
const s = e[0], d = s ? L.current.get(ae(s)) : void 0;
|
|
801
|
+
if (d && n && s.data.length > 0) {
|
|
802
|
+
const x = t.timeScale().timeToCoordinate(n), y = s.data[s.data.length - 1].value, v = d.priceToCoordinate(y);
|
|
803
|
+
x !== null && v !== null && J({ x, y: v });
|
|
804
804
|
}
|
|
805
805
|
}), () => {
|
|
806
|
-
t.unsubscribeCrosshairMove(a),
|
|
806
|
+
t.unsubscribeCrosshairMove(a), N && t.unsubscribeClick(a);
|
|
807
807
|
};
|
|
808
|
-
}, [e,
|
|
808
|
+
}, [e, q, N, ye]), G(() => {
|
|
809
809
|
const t = E.current;
|
|
810
810
|
if (!t || e.length === 0) return;
|
|
811
811
|
const l = t.timeScale(), n = () => {
|
|
812
812
|
const a = ze.current;
|
|
813
813
|
if (a.length === 0) return;
|
|
814
|
-
const
|
|
815
|
-
if (!
|
|
816
|
-
const
|
|
817
|
-
for (const
|
|
818
|
-
const
|
|
814
|
+
const s = l.getVisibleRange();
|
|
815
|
+
if (!s) return;
|
|
816
|
+
const d = Number(s.from), g = Number(s.to);
|
|
817
|
+
for (const x of a) {
|
|
818
|
+
const y = [];
|
|
819
819
|
for (const v of e)
|
|
820
|
-
if (
|
|
820
|
+
if (x.labels.has(v.label))
|
|
821
821
|
for (const W of v.data) {
|
|
822
822
|
const M = Number(W.time);
|
|
823
|
-
M >=
|
|
823
|
+
M >= d && M <= g && y.push(W.value);
|
|
824
824
|
}
|
|
825
|
-
|
|
825
|
+
y.length > 0 && x.updateVisibleRange(y);
|
|
826
826
|
}
|
|
827
827
|
};
|
|
828
828
|
return l.subscribeVisibleLogicalRangeChange(n), () => {
|
|
@@ -830,62 +830,62 @@ function oo({
|
|
|
830
830
|
n
|
|
831
831
|
);
|
|
832
832
|
};
|
|
833
|
-
}, [e]),
|
|
833
|
+
}, [e]), G(() => {
|
|
834
834
|
const t = E.current, l = Array.from(L.current.values()), n = [];
|
|
835
|
-
if (t && l.length > 0 &&
|
|
836
|
-
const a = Ct(),
|
|
837
|
-
for (const
|
|
838
|
-
const
|
|
835
|
+
if (t && l.length > 0 && P) {
|
|
836
|
+
const a = Ct(), s = l[0];
|
|
837
|
+
for (const d of P) {
|
|
838
|
+
const g = {
|
|
839
839
|
...a,
|
|
840
|
-
...
|
|
840
|
+
...d.options || {}
|
|
841
841
|
};
|
|
842
|
-
|
|
843
|
-
const
|
|
844
|
-
|
|
842
|
+
g.color && (g.color = ie(g.color, g.color));
|
|
843
|
+
const x = new Rt(t, s, d.xCoordinate, g);
|
|
844
|
+
s.attachPrimitive(x), n.push(x);
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
847
|
return () => {
|
|
848
848
|
if (l.length > 0) {
|
|
849
849
|
const a = l[0];
|
|
850
|
-
for (const
|
|
850
|
+
for (const s of n)
|
|
851
851
|
try {
|
|
852
|
-
a.detachPrimitive(
|
|
852
|
+
a.detachPrimitive(s);
|
|
853
853
|
} catch {
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
856
|
};
|
|
857
|
-
}, [
|
|
857
|
+
}, [P, e, U]), G(() => {
|
|
858
858
|
const t = [], l = [];
|
|
859
|
-
if (
|
|
860
|
-
const n =
|
|
859
|
+
if (I && I.length > 0) {
|
|
860
|
+
const n = ie(
|
|
861
861
|
"hsl(var(--destructive))",
|
|
862
862
|
"rgb(239, 68, 68)"
|
|
863
863
|
);
|
|
864
|
-
for (const a of
|
|
864
|
+
for (const a of I) {
|
|
865
865
|
if (!Number.isFinite(a.price)) continue;
|
|
866
|
-
const
|
|
866
|
+
const s = et(
|
|
867
867
|
L.current,
|
|
868
868
|
e,
|
|
869
869
|
a.seriesLabel
|
|
870
870
|
);
|
|
871
|
-
if (!
|
|
872
|
-
const
|
|
871
|
+
if (!s) continue;
|
|
872
|
+
const d = a.color ? ie(a.color, a.color) : n, g = a.lineWidth ?? 1, x = a.lineStyle ?? le.Dashed, y = s.createPriceLine({
|
|
873
873
|
price: a.price,
|
|
874
|
-
color:
|
|
875
|
-
lineWidth:
|
|
876
|
-
lineStyle:
|
|
874
|
+
color: d,
|
|
875
|
+
lineWidth: g,
|
|
876
|
+
lineStyle: x,
|
|
877
877
|
axisLabelVisible: a.axisLabelVisible ?? !0,
|
|
878
878
|
title: a.title ?? ""
|
|
879
879
|
});
|
|
880
|
-
t.push({ series:
|
|
880
|
+
t.push({ series: s, line: y });
|
|
881
881
|
const v = new Bt(
|
|
882
|
-
|
|
882
|
+
s,
|
|
883
883
|
a.price,
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
884
|
+
d,
|
|
885
|
+
g,
|
|
886
|
+
x
|
|
887
887
|
);
|
|
888
|
-
|
|
888
|
+
s.attachPrimitive(v), l.push({ series: s, primitive: v });
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
891
|
return () => {
|
|
@@ -900,24 +900,24 @@ function oo({
|
|
|
900
900
|
} catch {
|
|
901
901
|
}
|
|
902
902
|
};
|
|
903
|
-
}, [
|
|
903
|
+
}, [I, e, U]), G(() => {
|
|
904
904
|
const t = [];
|
|
905
|
-
if (
|
|
905
|
+
if (F && F.length > 0) {
|
|
906
906
|
const l = "rgba(239, 68, 68, 0.12)";
|
|
907
|
-
for (const n of
|
|
907
|
+
for (const n of F) {
|
|
908
908
|
const a = et(
|
|
909
909
|
L.current,
|
|
910
910
|
e,
|
|
911
911
|
n.seriesLabel
|
|
912
912
|
);
|
|
913
913
|
if (!a) continue;
|
|
914
|
-
const
|
|
914
|
+
const s = n.color ? ie(n.color, l) : l, d = new kt(
|
|
915
915
|
a,
|
|
916
916
|
n.priceTop,
|
|
917
917
|
n.priceBottom,
|
|
918
|
-
|
|
918
|
+
s
|
|
919
919
|
);
|
|
920
|
-
a.attachPrimitive(
|
|
920
|
+
a.attachPrimitive(d), t.push({ series: a, zone: d });
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
923
|
return () => {
|
|
@@ -927,15 +927,15 @@ function oo({
|
|
|
927
927
|
} catch {
|
|
928
928
|
}
|
|
929
929
|
};
|
|
930
|
-
}, [
|
|
930
|
+
}, [F, e, U]), G(() => {
|
|
931
931
|
const t = E.current;
|
|
932
|
-
if (!t || !
|
|
932
|
+
if (!t || !P?.length) {
|
|
933
933
|
$e([]);
|
|
934
934
|
return;
|
|
935
935
|
}
|
|
936
936
|
const l = () => {
|
|
937
|
-
const
|
|
938
|
-
$e(
|
|
937
|
+
const s = t.timeScale(), d = P.map((g) => s.timeToCoordinate(g.xCoordinate) ?? null);
|
|
938
|
+
$e(d), B.current && He(B.current.clientWidth);
|
|
939
939
|
};
|
|
940
940
|
l();
|
|
941
941
|
const n = t.timeScale(), a = () => {
|
|
@@ -944,99 +944,99 @@ function oo({
|
|
|
944
944
|
return n.subscribeVisibleLogicalRangeChange(a), () => {
|
|
945
945
|
n.unsubscribeVisibleLogicalRangeChange(a);
|
|
946
946
|
};
|
|
947
|
-
}, [
|
|
947
|
+
}, [P, e, U]), pt(() => {
|
|
948
948
|
lt((t) => {
|
|
949
949
|
const l = {};
|
|
950
950
|
let n = !1;
|
|
951
|
-
for (const [a,
|
|
952
|
-
if (!
|
|
953
|
-
const
|
|
954
|
-
l[a] =
|
|
951
|
+
for (const [a, s] of je.current) {
|
|
952
|
+
if (!s) continue;
|
|
953
|
+
const d = s.offsetWidth;
|
|
954
|
+
l[a] = d, t[a] !== d && (n = !0);
|
|
955
955
|
}
|
|
956
956
|
return Object.keys(t).length !== Object.keys(l).length && (n = !0), n ? l : t;
|
|
957
957
|
});
|
|
958
958
|
});
|
|
959
|
-
const
|
|
960
|
-
if (
|
|
959
|
+
const ge = e.length === 1, Ke = Ve.useMemo(() => {
|
|
960
|
+
if (ge && e.length > 0) {
|
|
961
961
|
const t = e[0];
|
|
962
962
|
if (t.data.length > 0)
|
|
963
963
|
return t.data[t.data.length - 1];
|
|
964
964
|
}
|
|
965
|
-
}, [
|
|
966
|
-
return /* @__PURE__ */
|
|
965
|
+
}, [ge, e]);
|
|
966
|
+
return /* @__PURE__ */ te(
|
|
967
967
|
"div",
|
|
968
968
|
{
|
|
969
969
|
ref: B,
|
|
970
|
-
className:
|
|
970
|
+
className: Z(
|
|
971
971
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
972
972
|
i
|
|
973
973
|
),
|
|
974
974
|
children: [
|
|
975
|
-
|
|
975
|
+
xe != null && xe !== !1 && ge ? /* @__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: xe }) }) : rt && ge && Ke && /* @__PURE__ */ w(
|
|
976
976
|
Pt,
|
|
977
977
|
{
|
|
978
978
|
point: Ke,
|
|
979
|
-
xMeasureUnit:
|
|
980
|
-
yMeasureUnit:
|
|
981
|
-
decimals:
|
|
979
|
+
xMeasureUnit: h,
|
|
980
|
+
yMeasureUnit: f,
|
|
981
|
+
decimals: se
|
|
982
982
|
}
|
|
983
983
|
),
|
|
984
|
-
Ge && We && /* @__PURE__ */
|
|
985
|
-
|
|
984
|
+
Ge && We && /* @__PURE__ */ w(
|
|
985
|
+
Nt,
|
|
986
986
|
{
|
|
987
987
|
points: Ge,
|
|
988
|
-
xMeasureUnit:
|
|
989
|
-
yMeasureUnit:
|
|
988
|
+
xMeasureUnit: h,
|
|
989
|
+
yMeasureUnit: f,
|
|
990
990
|
series: e,
|
|
991
991
|
position: We,
|
|
992
992
|
containerRef: B,
|
|
993
|
-
decimals:
|
|
993
|
+
decimals: se
|
|
994
994
|
}
|
|
995
995
|
),
|
|
996
|
-
|
|
997
|
-
|
|
996
|
+
c && /* @__PURE__ */ w(Wt, { series: e, onUnselect: u }),
|
|
997
|
+
P && P.length > 0 && Xe.length === P.length && /* @__PURE__ */ w(
|
|
998
998
|
"div",
|
|
999
999
|
{
|
|
1000
1000
|
className: "absolute inset-0 z-[5] pointer-events-none",
|
|
1001
1001
|
"aria-hidden": !0,
|
|
1002
|
-
children:
|
|
1002
|
+
children: P.map((t, l) => {
|
|
1003
1003
|
const n = Xe[l], a = t.options ?? {};
|
|
1004
1004
|
if (n === null) return null;
|
|
1005
|
-
const { labelText:
|
|
1005
|
+
const { labelText: s, valueStr: d } = Ft(
|
|
1006
1006
|
a,
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
),
|
|
1010
|
-
if (!(
|
|
1011
|
-
const
|
|
1007
|
+
f,
|
|
1008
|
+
se
|
|
1009
|
+
), g = a.tooltipText ?? "";
|
|
1010
|
+
if (!(s || d || g)) return null;
|
|
1011
|
+
const y = a.labelBackgroundColor ?? a.color ?? "hsl(var(--background))", v = a.labelTextColor ?? "hsl(var(--foreground))", W = `${String(t.xCoordinate)}-${s}-${g}`, M = zt(
|
|
1012
1012
|
n,
|
|
1013
1013
|
it,
|
|
1014
1014
|
at[l]
|
|
1015
1015
|
);
|
|
1016
|
-
return /* @__PURE__ */
|
|
1016
|
+
return /* @__PURE__ */ te(
|
|
1017
1017
|
"div",
|
|
1018
1018
|
{
|
|
1019
|
-
ref: (
|
|
1020
|
-
je.current.set(l,
|
|
1019
|
+
ref: (ee) => {
|
|
1020
|
+
je.current.set(l, ee);
|
|
1021
1021
|
},
|
|
1022
|
-
className:
|
|
1022
|
+
className: Z(
|
|
1023
1023
|
"group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
|
|
1024
|
-
|
|
1024
|
+
g && "pointer-events-auto cursor-default"
|
|
1025
1025
|
),
|
|
1026
1026
|
style: {
|
|
1027
1027
|
...M,
|
|
1028
|
-
backgroundColor:
|
|
1028
|
+
backgroundColor: y,
|
|
1029
1029
|
color: v
|
|
1030
1030
|
},
|
|
1031
1031
|
children: [
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1032
|
+
s && /* @__PURE__ */ w("span", { className: "block", children: s }),
|
|
1033
|
+
d && /* @__PURE__ */ w("span", { className: Z("block", s && "mt-0.5"), children: d }),
|
|
1034
|
+
g && /* @__PURE__ */ w(
|
|
1035
1035
|
"span",
|
|
1036
1036
|
{
|
|
1037
1037
|
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",
|
|
1038
1038
|
role: "tooltip",
|
|
1039
|
-
children:
|
|
1039
|
+
children: g
|
|
1040
1040
|
}
|
|
1041
1041
|
)
|
|
1042
1042
|
]
|
|
@@ -1046,7 +1046,7 @@ function oo({
|
|
|
1046
1046
|
})
|
|
1047
1047
|
}
|
|
1048
1048
|
),
|
|
1049
|
-
/* @__PURE__ */
|
|
1049
|
+
/* @__PURE__ */ w(
|
|
1050
1050
|
"div",
|
|
1051
1051
|
{
|
|
1052
1052
|
ref: we,
|
|
@@ -1059,87 +1059,119 @@ function oo({
|
|
|
1059
1059
|
}
|
|
1060
1060
|
function Wt({
|
|
1061
1061
|
series: e,
|
|
1062
|
-
|
|
1062
|
+
markers: i,
|
|
1063
|
+
onUnselect: c,
|
|
1063
1064
|
inline: u = !1
|
|
1064
1065
|
}) {
|
|
1065
|
-
const
|
|
1066
|
-
return /* @__PURE__ */
|
|
1066
|
+
const h = e.every((f) => f.data.length === 0);
|
|
1067
|
+
return /* @__PURE__ */ te(
|
|
1067
1068
|
"div",
|
|
1068
1069
|
{
|
|
1069
|
-
className:
|
|
1070
|
+
className: Z(
|
|
1070
1071
|
"flex flex-wrap",
|
|
1071
1072
|
u ? "items-center justify-center gap-6" : "absolute top-0 left-2 z-[10] gap-2"
|
|
1072
1073
|
),
|
|
1073
|
-
children:
|
|
1074
|
-
|
|
1075
|
-
|
|
1074
|
+
children: [
|
|
1075
|
+
e.map((f, S) => {
|
|
1076
|
+
const P = ot(S), I = (f.lineColor ?? f.color) || P.line, F = !h && f.data.length === 0;
|
|
1077
|
+
return /* @__PURE__ */ te(
|
|
1078
|
+
"div",
|
|
1079
|
+
{
|
|
1080
|
+
className: Z(
|
|
1081
|
+
"flex items-center gap-1.5",
|
|
1082
|
+
!u && "px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
1083
|
+
F && "opacity-50"
|
|
1084
|
+
),
|
|
1085
|
+
children: [
|
|
1086
|
+
/* @__PURE__ */ w(
|
|
1087
|
+
"div",
|
|
1088
|
+
{
|
|
1089
|
+
className: Z(
|
|
1090
|
+
u ? "size-2 rounded-full" : "h-3 w-3 rounded-sm"
|
|
1091
|
+
),
|
|
1092
|
+
style: { backgroundColor: I }
|
|
1093
|
+
}
|
|
1094
|
+
),
|
|
1095
|
+
/* @__PURE__ */ te(
|
|
1096
|
+
"span",
|
|
1097
|
+
{
|
|
1098
|
+
className: Z(
|
|
1099
|
+
"font-medium text-foreground",
|
|
1100
|
+
u ? "text-sm" : "text-[10px] sm:text-xs"
|
|
1101
|
+
),
|
|
1102
|
+
children: [
|
|
1103
|
+
f.label,
|
|
1104
|
+
F && " (no data)"
|
|
1105
|
+
]
|
|
1106
|
+
}
|
|
1107
|
+
),
|
|
1108
|
+
c && /* @__PURE__ */ w(
|
|
1109
|
+
"button",
|
|
1110
|
+
{
|
|
1111
|
+
type: "button",
|
|
1112
|
+
onClick: (se) => {
|
|
1113
|
+
se.stopPropagation(), c(f.label);
|
|
1114
|
+
},
|
|
1115
|
+
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
1116
|
+
"aria-label": `Remove ${f.label}`,
|
|
1117
|
+
children: /* @__PURE__ */ te(
|
|
1118
|
+
"svg",
|
|
1119
|
+
{
|
|
1120
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1121
|
+
width: "12",
|
|
1122
|
+
height: "12",
|
|
1123
|
+
viewBox: "0 0 24 24",
|
|
1124
|
+
fill: "none",
|
|
1125
|
+
stroke: "currentColor",
|
|
1126
|
+
strokeWidth: "2",
|
|
1127
|
+
strokeLinecap: "round",
|
|
1128
|
+
strokeLinejoin: "round",
|
|
1129
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
1130
|
+
"aria-hidden": "true",
|
|
1131
|
+
children: [
|
|
1132
|
+
/* @__PURE__ */ w("title", { children: "Close" }),
|
|
1133
|
+
/* @__PURE__ */ w("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1134
|
+
/* @__PURE__ */ w("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1135
|
+
]
|
|
1136
|
+
}
|
|
1137
|
+
)
|
|
1138
|
+
}
|
|
1139
|
+
)
|
|
1140
|
+
]
|
|
1141
|
+
},
|
|
1142
|
+
f.id ?? f.label
|
|
1143
|
+
);
|
|
1144
|
+
}),
|
|
1145
|
+
i?.map((f) => /* @__PURE__ */ te(
|
|
1076
1146
|
"div",
|
|
1077
1147
|
{
|
|
1078
|
-
className:
|
|
1148
|
+
className: Z(
|
|
1079
1149
|
"flex items-center gap-1.5",
|
|
1080
|
-
!u && "px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border"
|
|
1081
|
-
k && "opacity-50"
|
|
1150
|
+
!u && "px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border"
|
|
1082
1151
|
),
|
|
1083
1152
|
children: [
|
|
1084
|
-
/* @__PURE__ */
|
|
1153
|
+
/* @__PURE__ */ w(
|
|
1085
1154
|
"div",
|
|
1086
1155
|
{
|
|
1087
|
-
className:
|
|
1088
|
-
|
|
1089
|
-
),
|
|
1090
|
-
style: { backgroundColor: w }
|
|
1156
|
+
className: Z("w-0.5", "h-3"),
|
|
1157
|
+
style: { backgroundColor: f.color }
|
|
1091
1158
|
}
|
|
1092
1159
|
),
|
|
1093
|
-
/* @__PURE__ */
|
|
1160
|
+
/* @__PURE__ */ w(
|
|
1094
1161
|
"span",
|
|
1095
1162
|
{
|
|
1096
|
-
className:
|
|
1163
|
+
className: Z(
|
|
1097
1164
|
"font-medium text-foreground",
|
|
1098
1165
|
u ? "text-sm" : "text-[10px] sm:text-xs"
|
|
1099
1166
|
),
|
|
1100
|
-
children:
|
|
1101
|
-
s.label,
|
|
1102
|
-
k && " (no data)"
|
|
1103
|
-
]
|
|
1104
|
-
}
|
|
1105
|
-
),
|
|
1106
|
-
i && /* @__PURE__ */ V(
|
|
1107
|
-
"button",
|
|
1108
|
-
{
|
|
1109
|
-
type: "button",
|
|
1110
|
-
onClick: (G) => {
|
|
1111
|
-
G.stopPropagation(), i(s.label);
|
|
1112
|
-
},
|
|
1113
|
-
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
1114
|
-
"aria-label": `Remove ${s.label}`,
|
|
1115
|
-
children: /* @__PURE__ */ ge(
|
|
1116
|
-
"svg",
|
|
1117
|
-
{
|
|
1118
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1119
|
-
width: "12",
|
|
1120
|
-
height: "12",
|
|
1121
|
-
viewBox: "0 0 24 24",
|
|
1122
|
-
fill: "none",
|
|
1123
|
-
stroke: "currentColor",
|
|
1124
|
-
strokeWidth: "2",
|
|
1125
|
-
strokeLinecap: "round",
|
|
1126
|
-
strokeLinejoin: "round",
|
|
1127
|
-
className: "text-muted-foreground hover:text-foreground",
|
|
1128
|
-
"aria-hidden": "true",
|
|
1129
|
-
children: [
|
|
1130
|
-
/* @__PURE__ */ V("title", { children: "Close" }),
|
|
1131
|
-
/* @__PURE__ */ V("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1132
|
-
/* @__PURE__ */ V("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1133
|
-
]
|
|
1134
|
-
}
|
|
1135
|
-
)
|
|
1167
|
+
children: f.label
|
|
1136
1168
|
}
|
|
1137
1169
|
)
|
|
1138
1170
|
]
|
|
1139
1171
|
},
|
|
1140
|
-
|
|
1141
|
-
)
|
|
1142
|
-
|
|
1172
|
+
f.id
|
|
1173
|
+
))
|
|
1174
|
+
]
|
|
1143
1175
|
}
|
|
1144
1176
|
);
|
|
1145
1177
|
}
|
|
@@ -1152,5 +1184,5 @@ export {
|
|
|
1152
1184
|
At as getStepForwardValue,
|
|
1153
1185
|
zt as getVerticalLineLabelStyle,
|
|
1154
1186
|
Ft as getVerticalLineTooltipContent,
|
|
1155
|
-
|
|
1187
|
+
ae as seriesIdentity
|
|
1156
1188
|
};
|