@tradecanvas/chart 1.50.0 → 1.51.0
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/README.md +1 -1
- package/dist/Chart.d.ts +20 -5
- package/dist/Chart.d.ts.map +1 -1
- package/dist/LayoutSession-DuV9kpdQ.cjs +2 -0
- package/dist/LayoutSession-DuV9kpdQ.cjs.map +1 -0
- package/dist/{LayoutSession-Dcvn5KMK.js → LayoutSession-Qkx1huV-.js} +304 -275
- package/dist/LayoutSession-Qkx1huV-.js.map +1 -0
- package/dist/finance/performanceData.d.ts +17 -2
- package/dist/finance/performanceData.d.ts.map +1 -1
- package/dist/i18n-Bg_UJSNs.cjs +2 -0
- package/dist/i18n-Bg_UJSNs.cjs.map +1 -0
- package/dist/{i18n-DjzoHpMJ.js → i18n-DFTQ73Cz.js} +15 -1
- package/dist/i18n-DFTQ73Cz.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +116 -115
- package/dist/index.js.map +1 -1
- package/dist/layout/labelWidths.d.ts +16 -0
- package/dist/layout/labelWidths.d.ts.map +1 -0
- package/dist/widget/ChartWidget.d.ts +40 -6
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/WatchlistStore.d.ts.map +1 -1
- package/dist/widget/WidgetContextMenu.d.ts +25 -3
- package/dist/widget/WidgetContextMenu.d.ts.map +1 -1
- package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
- package/dist/widget/WidgetIndicatorLegend.d.ts +2 -0
- package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -1
- package/dist/widget/WidgetLayoutsUI.d.ts.map +1 -1
- package/dist/widget/WidgetStatusBar.d.ts +110 -3
- package/dist/widget/WidgetStatusBar.d.ts.map +1 -1
- package/dist/widget/WidgetSymbolSearch.d.ts +73 -20
- package/dist/widget/WidgetSymbolSearch.d.ts.map +1 -1
- package/dist/widget/WidgetToolbar.d.ts +65 -6
- package/dist/widget/WidgetToolbar.d.ts.map +1 -1
- package/dist/widget/WidgetTradeMenu.d.ts.map +1 -1
- package/dist/widget/hostButtons.d.ts +5 -2
- package/dist/widget/hostButtons.d.ts.map +1 -1
- package/dist/widget/index.cjs +459 -119
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +2302 -1737
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/locales/ar.d.ts.map +1 -1
- package/dist/widget/locales/cs.d.ts.map +1 -1
- package/dist/widget/locales/da.d.ts.map +1 -1
- package/dist/widget/locales/de.d.ts.map +1 -1
- package/dist/widget/locales/el.d.ts.map +1 -1
- package/dist/widget/locales/en.d.ts +7 -0
- package/dist/widget/locales/en.d.ts.map +1 -1
- package/dist/widget/locales/es.d.ts.map +1 -1
- package/dist/widget/locales/et.d.ts.map +1 -1
- package/dist/widget/locales/fa.d.ts.map +1 -1
- package/dist/widget/locales/fr.d.ts.map +1 -1
- package/dist/widget/locales/he.d.ts.map +1 -1
- package/dist/widget/locales/hu.d.ts.map +1 -1
- package/dist/widget/locales/id.d.ts.map +1 -1
- package/dist/widget/locales/index.cjs +1 -1
- package/dist/widget/locales/index.cjs.map +1 -1
- package/dist/widget/locales/index.js +197 -1
- package/dist/widget/locales/index.js.map +1 -1
- package/dist/widget/locales/it.d.ts.map +1 -1
- package/dist/widget/locales/ja.d.ts.map +1 -1
- package/dist/widget/locales/ko.d.ts.map +1 -1
- package/dist/widget/locales/ms.d.ts.map +1 -1
- package/dist/widget/locales/nb.d.ts.map +1 -1
- package/dist/widget/locales/nl.d.ts.map +1 -1
- package/dist/widget/locales/pl.d.ts.map +1 -1
- package/dist/widget/locales/pt.d.ts.map +1 -1
- package/dist/widget/locales/ro.d.ts.map +1 -1
- package/dist/widget/locales/ru.d.ts.map +1 -1
- package/dist/widget/locales/sk.d.ts.map +1 -1
- package/dist/widget/locales/sv.d.ts.map +1 -1
- package/dist/widget/locales/th.d.ts.map +1 -1
- package/dist/widget/locales/tr.d.ts.map +1 -1
- package/dist/widget/locales/vi.d.ts.map +1 -1
- package/dist/widget/locales/zh.d.ts.map +1 -1
- package/dist/widget/locales/zhHant.d.ts.map +1 -1
- package/dist/widget/selectMenu.d.ts.map +1 -1
- package/dist/widget/symbolBadge.d.ts +26 -0
- package/dist/widget/symbolBadge.d.ts.map +1 -0
- package/dist/widget/symbolCatalog.d.ts +62 -0
- package/dist/widget/symbolCatalog.d.ts.map +1 -0
- package/dist/widget/symbolCell.d.ts +8 -0
- package/dist/widget/symbolCell.d.ts.map +1 -0
- package/dist/widget/symbolInfoView.d.ts +3 -0
- package/dist/widget/symbolInfoView.d.ts.map +1 -1
- package/dist/widget/symbolMatch.d.ts +38 -0
- package/dist/widget/symbolMatch.d.ts.map +1 -0
- package/dist/widget/symbolSearchFilters.d.ts +52 -0
- package/dist/widget/symbolSearchFilters.d.ts.map +1 -0
- package/dist/widget/types.d.ts +28 -4
- package/dist/widget/types.d.ts.map +1 -1
- package/dist/widget/widgetUI.d.ts +2 -1
- package/dist/widget/widgetUI.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-BBw0ke8V.cjs +0 -2
- package/dist/LayoutSession-BBw0ke8V.cjs.map +0 -1
- package/dist/LayoutSession-Dcvn5KMK.js.map +0 -1
- package/dist/i18n-DVeWlg64.cjs +0 -2
- package/dist/i18n-DVeWlg64.cjs.map +0 -1
- package/dist/i18n-DjzoHpMJ.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barTimeUnit as l, chartStyleValue as u, computePriceLimits as d, computePriceRange as f, formatPrice as p, fractionTick as m, indicatorSource as h, isValidTimeZone as g, mergeBar as _, normalizeBarTime as v, parseIndicatorSource as y, priceFormatterFor as ee, priceStepAt as te, readChartStyleOverrides as
|
|
2
|
-
import { AlertDragHandler as
|
|
1
|
+
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barTimeUnit as l, chartStyleValue as u, computePriceLimits as d, computePriceRange as f, formatPrice as p, fractionTick as m, indicatorSource as h, isValidTimeZone as g, mergeBar as _, normalizeBarTime as v, parseIndicatorSource as y, priceFormatterFor as ee, priceStepAt as te, readChartStyleOverrides as b, readChartTypeOptions as x, readIndicatorPlotStyles as ne, readPaneStyle as re, resolveChartTheme as ie, sessionMinute as S, setLocale as ae, stepDecimals as oe, symbolTimeZone as C, tickBarCount as se, timeframeToMs as ce, zonedDateFormatter as le } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as ue, AlertManager as de, Animator as fe, AreaRenderer as pe, AxisDragHandler as me, BarCountdown as he, BarRenderer as ge, BaselineRenderer as _e, CandlestickRenderer as ve, ChartLegend as ye, ChartStateManager as w, CompareRenderer as be, CompareSymbolIndicator as xe, CorrelationCoefficientIndicator as Se, CorrelationLogIndicator as Ce, CrosshairHandler as we, CrosshairTooltip as Te, CurrentPriceLine as Ee, DEFAULT_SESSION_HOURS as De, DataExporter as T, DepthHeatmapRenderer as Oe, DrawingManager as ke, DrawingRenderer as Ae, EquivolumeRenderer as je, EventBus as Me, GridRenderer as Ne, HLCAreaRenderer as Pe, HiLoRenderer as Fe, HollowCandleRenderer as Ie, IndicatorEngine as Le, InteractionManager as Re, KagiRenderer as ze, KeyboardHandler as Be, LineRenderer as Ve, LineWithMarkersRenderer as He, MarketProfileRenderer as Ue, MeasureOverlay as We, PRICE_SCALE_MARGIN as E, PanHandler as Ge, PaneResizeHandler as Ke, PeriodLevelsRenderer as qe, PinnedTooltip as Je, PivotMarkersRenderer as Ye, PointAndFigureRenderer as D, PriceAxis as Xe, PriceAxisAddButton as Ze, PriceLines as Qe, RenderEngine as $e, RenkoRenderer as et, ReplayManager as tt, SYMBOL_INDICATOR_IDS as O, Screenshot as k, SelectionBoxOverlay as nt, SessionBreaks as rt, SessionShading as it, SignalMarkerManager as at, SpreadIndicator as ot, StepLineRenderer as st, StreamManager as ct, SymbolSeriesStore as lt, TimeAxis as ut, TradeZoneManager as dt, TradingManager as ft, TradingRenderer as pt, UndoRedoManager as mt, Viewport as ht, VolumeCandleRenderer as gt, VolumeProfileRenderer as _t, VolumeRenderer as vt, Watermark as yt, ZoomHandler as bt, barTimeStepMs as xt, findDominantSwing as St, gpuContextsLeft as Ct, isRegularSession as wt, loadWebGL as Tt, mergeSessionHours as Et, priceToY as Dt, rangePresetStart as Ot, readAlertOptions as kt, registerBuiltInDrawingTools as At, registerBuiltInIndicators as jt, servesTimeframe as Mt, sourceParam as A, timeToX as Nt, timestampToBarIndex as j, toHeikinAshi as Pt, toKagi as Ft, toLineBreak as It, toPointAndFigure as Lt, toRangeBars as Rt, toRenko as zt, whenGpuContextFree as Bt, withResampling as Vt, xToBarIndex as Ht, xToTime as M, yToPrice as N } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
let n =
|
|
4
|
+
var Ut = 864e5, Wt = 10;
|
|
5
|
+
function Gt(e, t) {
|
|
6
|
+
let n = C(e);
|
|
7
7
|
if (!n || !g(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
9
|
-
let t =
|
|
9
|
+
let t = S(e.start), n = S(e.end);
|
|
10
10
|
return t === null || n === null ? [] : [{
|
|
11
11
|
startMinute: t,
|
|
12
12
|
endMinute: n
|
|
@@ -14,34 +14,34 @@ function Ht(e, t) {
|
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
16
|
let i = l(t), a = Infinity;
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
17
|
+
for (let e = Math.max(1, t.length - Wt); e < t.length; e++) {
|
|
18
18
|
let n = (t[e].time - t[e - 1].time) * i;
|
|
19
19
|
n > 0 && n < a && (a = n);
|
|
20
20
|
}
|
|
21
|
-
if (!(a <
|
|
21
|
+
if (!(a < Ut)) return null;
|
|
22
22
|
let o = {
|
|
23
23
|
timeZone: n,
|
|
24
24
|
windows: r,
|
|
25
25
|
startMinute: r[0].startMinute,
|
|
26
26
|
endMinute: r[r.length - 1].endMinute
|
|
27
27
|
};
|
|
28
|
-
return (e) =>
|
|
28
|
+
return (e) => wt(e * i, o);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var P = {
|
|
33
33
|
role: "chart",
|
|
34
34
|
summary: "{what}. Last price {close}.",
|
|
35
35
|
empty: "Chart, no data.",
|
|
36
36
|
view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
|
|
37
37
|
bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
|
|
38
38
|
keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
|
|
39
|
-
},
|
|
39
|
+
}, F = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Kt = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], qt = 400, Jt = 1e3, Yt = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var Ut = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
...
|
|
58
|
+
...P,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of Kt) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = I("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = I("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
|
|
63
63
|
}
|
|
64
64
|
setLabels(e) {
|
|
65
65
|
this.labels = {
|
|
66
|
-
...
|
|
66
|
+
...P,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = Jt - (Date.now() - this.summaryAt);
|
|
72
72
|
if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
|
|
73
73
|
this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
|
|
74
74
|
return;
|
|
@@ -80,7 +80,7 @@ var Ut = {
|
|
|
80
80
|
viewMoved() {
|
|
81
81
|
this.cursor = null, this.viewTimer && clearTimeout(this.viewTimer), this.viewTimer = setTimeout(() => {
|
|
82
82
|
this.viewTimer = null, this.say(this.viewText());
|
|
83
|
-
},
|
|
83
|
+
}, qt);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -93,13 +93,13 @@ var Ut = {
|
|
|
93
93
|
let i = t[this.cursor];
|
|
94
94
|
this.source.showBar(i.time);
|
|
95
95
|
let a = this.source.formatPrice;
|
|
96
|
-
this.say(
|
|
96
|
+
this.say(F(this.labels.bar, {
|
|
97
97
|
time: this.source.formatTime(i.time),
|
|
98
98
|
open: a(i.open),
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: Xt(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -118,7 +118,7 @@ var Ut = {
|
|
|
118
118
|
this.labels.typeName ? this.labels.typeName(t) : t,
|
|
119
119
|
this.source.timeframe()
|
|
120
120
|
].filter(Boolean).join(", ");
|
|
121
|
-
return
|
|
121
|
+
return F(this.labels.summary, {
|
|
122
122
|
what: n,
|
|
123
123
|
close: this.source.formatPrice(e[e.length - 1].close)
|
|
124
124
|
});
|
|
@@ -128,7 +128,7 @@ var Ut = {
|
|
|
128
128
|
if (e.length === 0) return this.labels.empty;
|
|
129
129
|
let t = this.source.visibleRange(), n = Math.max(0, Math.min(e.length - 1, Math.ceil(t.from))), r = Math.max(n, Math.min(e.length - 1, Math.floor(t.to))), i = -Infinity, a = Infinity;
|
|
130
130
|
for (let t = n; t <= r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
|
|
131
|
-
return
|
|
131
|
+
return F(this.labels.view, {
|
|
132
132
|
count: r - n + 1,
|
|
133
133
|
from: this.source.formatTime(e[n].time),
|
|
134
134
|
to: this.source.formatTime(e[r].time),
|
|
@@ -140,7 +140,7 @@ var Ut = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function I(e, t) {
|
|
144
144
|
let n = document.createElement(e);
|
|
145
145
|
return n.className = t, Object.assign(n.style, {
|
|
146
146
|
position: "absolute",
|
|
@@ -154,12 +154,12 @@ function Jt(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Xt(e) {
|
|
158
158
|
return Number.isInteger(e) ? String(e) : e.toFixed(2);
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/indicatorLabel.ts
|
|
162
|
-
function
|
|
162
|
+
function L(e, t, n, r) {
|
|
163
163
|
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, 3).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
|
|
164
164
|
return [
|
|
165
165
|
e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
|
|
@@ -174,42 +174,42 @@ function Zt(e) {
|
|
|
174
174
|
case "candlestick":
|
|
175
175
|
case "heikinAshi":
|
|
176
176
|
case "lineBreak":
|
|
177
|
-
case "rangeBars": return new
|
|
178
|
-
case "line": return new
|
|
179
|
-
case "area": return new
|
|
180
|
-
case "bar": return new
|
|
181
|
-
case "hollowCandle": return new
|
|
182
|
-
case "baseline": return new
|
|
183
|
-
case "renko": return new
|
|
184
|
-
case "kagi": return new
|
|
185
|
-
case "pointAndFigure": return new
|
|
186
|
-
case "volumeCandles": return new
|
|
187
|
-
case "equivolume": return new
|
|
188
|
-
case "hlcArea": return new
|
|
189
|
-
case "stepLine": return new
|
|
190
|
-
case "lineWithMarkers": return new
|
|
191
|
-
case "hiLo": return new
|
|
192
|
-
default: return new
|
|
177
|
+
case "rangeBars": return new ve();
|
|
178
|
+
case "line": return new Ve();
|
|
179
|
+
case "area": return new pe();
|
|
180
|
+
case "bar": return new ge();
|
|
181
|
+
case "hollowCandle": return new Ie();
|
|
182
|
+
case "baseline": return new _e();
|
|
183
|
+
case "renko": return new et();
|
|
184
|
+
case "kagi": return new ze();
|
|
185
|
+
case "pointAndFigure": return new D();
|
|
186
|
+
case "volumeCandles": return new gt();
|
|
187
|
+
case "equivolume": return new je();
|
|
188
|
+
case "hlcArea": return new Pe();
|
|
189
|
+
case "stepLine": return new st();
|
|
190
|
+
case "lineWithMarkers": return new He();
|
|
191
|
+
case "hiLo": return new Fe();
|
|
192
|
+
default: return new ve();
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
function Qt(e, t, n = {}) {
|
|
196
196
|
if (t.length === 0) return t;
|
|
197
197
|
switch (e) {
|
|
198
|
-
case "heikinAshi": return
|
|
198
|
+
case "heikinAshi": return Pt(t);
|
|
199
199
|
case "renko": {
|
|
200
200
|
let e = n.renko?.boxSize;
|
|
201
|
-
return typeof e == "number" ?
|
|
201
|
+
return typeof e == "number" ? zt(t, { brickSize: e }) : zt(t, {
|
|
202
202
|
brickSize: 0,
|
|
203
203
|
useATR: !0,
|
|
204
204
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
-
case "lineBreak": return
|
|
208
|
-
case "kagi": return
|
|
209
|
-
case "pointAndFigure": return
|
|
207
|
+
case "lineBreak": return It(t, n.lineBreak?.lines ?? 3);
|
|
208
|
+
case "kagi": return Ft(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
|
|
209
|
+
case "pointAndFigure": return Lt(t, en(t, n), n.pointAndFigure?.reversal ?? 3);
|
|
210
210
|
case "rangeBars": {
|
|
211
211
|
let e = n.rangeBars?.range;
|
|
212
|
-
return
|
|
212
|
+
return Rt(t, { rangeSize: typeof e == "number" ? e : tn(t) * .005 });
|
|
213
213
|
}
|
|
214
214
|
default: return t;
|
|
215
215
|
}
|
|
@@ -644,7 +644,7 @@ var gn = class t {
|
|
|
644
644
|
return i;
|
|
645
645
|
}
|
|
646
646
|
getTheme() {
|
|
647
|
-
return this.effective ??=
|
|
647
|
+
return this.effective ??= ie(this.base, this.chartType, this.merged()), this.effective;
|
|
648
648
|
}
|
|
649
649
|
getBaseTheme() {
|
|
650
650
|
return this.base;
|
|
@@ -974,7 +974,25 @@ function En(e) {
|
|
|
974
974
|
function Dn(e, t) {
|
|
975
975
|
return t > e || t <= e - 12 ? t : e;
|
|
976
976
|
}
|
|
977
|
-
|
|
977
|
+
//#endregion
|
|
978
|
+
//#region src/layout/labelWidths.ts
|
|
979
|
+
var On = 512, kn = class {
|
|
980
|
+
widths = /* @__PURE__ */ new Map();
|
|
981
|
+
fonts;
|
|
982
|
+
forget = () => this.widths.clear();
|
|
983
|
+
constructor() {
|
|
984
|
+
this.fonts = typeof document < "u" ? document.fonts ?? null : null, this.fonts?.addEventListener("loadingdone", this.forget);
|
|
985
|
+
}
|
|
986
|
+
get(e, t, n) {
|
|
987
|
+
let r = `${t}\n${e}`, i = this.widths.get(r);
|
|
988
|
+
if (i !== void 0) return i;
|
|
989
|
+
let a = n();
|
|
990
|
+
return this.widths.size >= On && this.widths.clear(), this.widths.set(r, a), a;
|
|
991
|
+
}
|
|
992
|
+
destroy() {
|
|
993
|
+
this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
|
|
994
|
+
}
|
|
995
|
+
}, An = class {
|
|
978
996
|
netY = 0;
|
|
979
997
|
travelX = 0;
|
|
980
998
|
engaged = !1;
|
|
@@ -990,11 +1008,11 @@ var On = class {
|
|
|
990
1008
|
}
|
|
991
1009
|
return this.engaged;
|
|
992
1010
|
}
|
|
993
|
-
},
|
|
994
|
-
function
|
|
1011
|
+
}, jn = 1;
|
|
1012
|
+
function W(e, t) {
|
|
995
1013
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
996
1014
|
}
|
|
997
|
-
function
|
|
1015
|
+
function G(e) {
|
|
998
1016
|
switch (e.kind) {
|
|
999
1017
|
case "indicator": return `indicator:${e.plugin.descriptor.id}`;
|
|
1000
1018
|
case "drawing": return `drawing:${e.plugin.descriptor.type}`;
|
|
@@ -1004,25 +1022,25 @@ function W(e) {
|
|
|
1004
1022
|
}
|
|
1005
1023
|
//#endregion
|
|
1006
1024
|
//#region src/plugins/registry.ts
|
|
1007
|
-
var
|
|
1008
|
-
function jn(e) {
|
|
1009
|
-
G.set(W(e), e);
|
|
1010
|
-
}
|
|
1025
|
+
var K = /* @__PURE__ */ new Map();
|
|
1011
1026
|
function Mn(e) {
|
|
1012
|
-
|
|
1027
|
+
K.set(G(e), e);
|
|
1013
1028
|
}
|
|
1014
|
-
function Nn() {
|
|
1015
|
-
return
|
|
1029
|
+
function Nn(e) {
|
|
1030
|
+
return K.delete(e);
|
|
1016
1031
|
}
|
|
1017
1032
|
function Pn() {
|
|
1018
|
-
|
|
1033
|
+
return [...K.values()];
|
|
1034
|
+
}
|
|
1035
|
+
function Fn() {
|
|
1036
|
+
K.clear();
|
|
1019
1037
|
}
|
|
1020
1038
|
//#endregion
|
|
1021
1039
|
//#region src/plugins/PluginManager.ts
|
|
1022
|
-
var
|
|
1040
|
+
var In = class {
|
|
1023
1041
|
plugins = /* @__PURE__ */ new Map();
|
|
1024
1042
|
constructor(e, t = {}) {
|
|
1025
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
1043
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of Pn()) this.add(e);
|
|
1026
1044
|
for (let e of t.plugins ?? []) this.add(e);
|
|
1027
1045
|
}
|
|
1028
1046
|
register(e) {
|
|
@@ -1050,17 +1068,17 @@ var Fn = class {
|
|
|
1050
1068
|
return e;
|
|
1051
1069
|
}
|
|
1052
1070
|
add(e) {
|
|
1053
|
-
this.plugins.set(
|
|
1071
|
+
this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
1054
1072
|
}
|
|
1055
|
-
},
|
|
1073
|
+
}, Ln = {
|
|
1056
1074
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
1057
1075
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
1058
1076
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
1059
1077
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
1060
1078
|
positionClose: (e, t) => e.closePosition(t),
|
|
1061
|
-
positionReverse: (e, t, n) =>
|
|
1079
|
+
positionReverse: (e, t, n) => Rn(e, t, n)
|
|
1062
1080
|
};
|
|
1063
|
-
async function
|
|
1081
|
+
async function Rn(e, t, n) {
|
|
1064
1082
|
let { reversing: r } = n;
|
|
1065
1083
|
if (!r.has(t.positionId)) {
|
|
1066
1084
|
r.add(t.positionId);
|
|
@@ -1089,7 +1107,7 @@ async function Ln(e, t, n) {
|
|
|
1089
1107
|
}
|
|
1090
1108
|
}
|
|
1091
1109
|
}
|
|
1092
|
-
function
|
|
1110
|
+
function zn(e, t) {
|
|
1093
1111
|
let n = [], r = null, i = {
|
|
1094
1112
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
1095
1113
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -1099,8 +1117,8 @@ function Rn(e, t) {
|
|
|
1099
1117
|
e.data && t.onFill?.(e.data);
|
|
1100
1118
|
};
|
|
1101
1119
|
e.on("orders", a), e.on("positions", o), e.on("error", s), e.on("fill", c), n.push(() => e.off("orders", a), () => e.off("positions", o), () => e.off("error", s), () => e.off("fill", c));
|
|
1102
|
-
for (let r of Object.keys(
|
|
1103
|
-
let a =
|
|
1120
|
+
for (let r of Object.keys(Ln)) {
|
|
1121
|
+
let a = Ln[r], o = t.onIntent(r, (n) => {
|
|
1104
1122
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
1105
1123
|
message: `Execution command failed: ${r}`,
|
|
1106
1124
|
cause: e
|
|
@@ -1114,24 +1132,24 @@ function Rn(e, t) {
|
|
|
1114
1132
|
}
|
|
1115
1133
|
//#endregion
|
|
1116
1134
|
//#region src/Chart.ts
|
|
1117
|
-
var
|
|
1135
|
+
var Bn = {
|
|
1118
1136
|
min: 0,
|
|
1119
1137
|
max: 100
|
|
1120
|
-
},
|
|
1121
|
-
function
|
|
1138
|
+
}, Vn = "exchange", Hn = Vn;
|
|
1139
|
+
function Un(e) {
|
|
1122
1140
|
if (typeof e == "string" && e !== "exchange" && !g(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
1123
1141
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
1124
1142
|
}
|
|
1125
|
-
function
|
|
1126
|
-
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r :
|
|
1143
|
+
function Wn(e, t) {
|
|
1144
|
+
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
|
|
1127
1145
|
return i === void 0 ? e : {
|
|
1128
1146
|
...e,
|
|
1129
1147
|
timeZone: i,
|
|
1130
1148
|
timezone: i
|
|
1131
1149
|
};
|
|
1132
1150
|
}
|
|
1133
|
-
var
|
|
1134
|
-
static version = "1.
|
|
1151
|
+
var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontalLine", "crossLine"]), Zn = new Set(["verticalLine", "crossLine"]), Qn = class {
|
|
1152
|
+
static version = "1.51.0";
|
|
1135
1153
|
engine;
|
|
1136
1154
|
viewport;
|
|
1137
1155
|
series = new un((e) => this.sessionKeep(e));
|
|
@@ -1158,6 +1176,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1158
1176
|
renderDeferred = !1;
|
|
1159
1177
|
priceAxisWidth = o;
|
|
1160
1178
|
measureCtx;
|
|
1179
|
+
labelWidths = new kn();
|
|
1161
1180
|
containerSizeCache = null;
|
|
1162
1181
|
containerSizeCacheTime = 0;
|
|
1163
1182
|
lastEmittedRange = null;
|
|
@@ -1171,14 +1190,14 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1171
1190
|
indicatorEdit = null;
|
|
1172
1191
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
1173
1192
|
zoomAreaMode = !1;
|
|
1174
|
-
priceAxisAddButton = new
|
|
1193
|
+
priceAxisAddButton = new Ze();
|
|
1175
1194
|
displayTz = null;
|
|
1176
1195
|
timeZoneSetting = null;
|
|
1177
1196
|
symbolInfo = null;
|
|
1178
1197
|
symbolInfoSeq = 0;
|
|
1179
1198
|
sessionBreaks;
|
|
1180
1199
|
sessionShading;
|
|
1181
|
-
hostSessionHours = { ...
|
|
1200
|
+
hostSessionHours = { ...De };
|
|
1182
1201
|
compareRenderer;
|
|
1183
1202
|
countdownInterval = null;
|
|
1184
1203
|
pausedFor = {
|
|
@@ -1197,7 +1216,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1197
1216
|
signalMarkerManager;
|
|
1198
1217
|
tradeZoneManager;
|
|
1199
1218
|
measureOverlay;
|
|
1200
|
-
selectionBoxOverlay = new
|
|
1219
|
+
selectionBoxOverlay = new nt();
|
|
1201
1220
|
replayManager;
|
|
1202
1221
|
replayBarUnsub = null;
|
|
1203
1222
|
replaySeeking = !1;
|
|
@@ -1219,14 +1238,14 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1219
1238
|
disposed = !1;
|
|
1220
1239
|
chartTypeOptions = {};
|
|
1221
1240
|
mainSeriesVisible = !0;
|
|
1222
|
-
priceLines = new
|
|
1223
|
-
symbolSeries = new
|
|
1241
|
+
priceLines = new Qe();
|
|
1242
|
+
symbolSeries = new lt();
|
|
1224
1243
|
extendedHours = !0;
|
|
1225
1244
|
replayRestarting = !1;
|
|
1226
1245
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
1227
1246
|
gridRenderer;
|
|
1228
1247
|
priceAxis;
|
|
1229
|
-
leftPriceAxis = new
|
|
1248
|
+
leftPriceAxis = new Xe();
|
|
1230
1249
|
leftScaleRequested = !1;
|
|
1231
1250
|
leftAxisWidth = o;
|
|
1232
1251
|
leftViewport = null;
|
|
@@ -1257,7 +1276,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1257
1276
|
snapshotKey = null;
|
|
1258
1277
|
historyCheckQueued = !1;
|
|
1259
1278
|
constructor(e, t) {
|
|
1260
|
-
t.timeZone != null &&
|
|
1279
|
+
t.timeZone != null && Un(t.timeZone), this.container = e, this.options = {
|
|
1261
1280
|
...t,
|
|
1262
1281
|
chartType: t.chartType ?? "candlestick"
|
|
1263
1282
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1299,11 +1318,11 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1299
1318
|
oldestTime: () => this.series.bars()[0]?.time ?? null,
|
|
1300
1319
|
prepend: (e) => this.prependBars(e),
|
|
1301
1320
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1302
|
-
}), this.themeManager = new gn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(vn(t), "host", !1), this.layoutManager = new xn(), this.indicatorEngine = new
|
|
1321
|
+
}), this.themeManager = new gn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(vn(t), "host", !1), this.layoutManager = new xn(), this.indicatorEngine = new Le(), this.pluginManager = new In(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Me(), jt(this.indicatorEngine), this.indicatorEngine.register(new xe(this.symbolSeries)), this.indicatorEngine.register(new ot(this.symbolSeries)), this.indicatorEngine.register(new Se(this.symbolSeries)), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.drawingManager = new ke(), At(this.drawingManager), this.drawingRenderer = new Ae(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
1303
1322
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1304
1323
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1305
1324
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1306
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1325
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new mt();
|
|
1307
1326
|
let i = "";
|
|
1308
1327
|
this.undoRedoManager.setOnChange(() => {
|
|
1309
1328
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1316,21 +1335,21 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1316
1335
|
primary: e[0] ?? null
|
|
1317
1336
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1318
1337
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1319
|
-
}), this.drawingManager.setDataGetter(() => this.series.bars()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new
|
|
1338
|
+
}), this.drawingManager.setDataGetter(() => this.series.bars()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new ft({
|
|
1320
1339
|
enabled: this.features.trading,
|
|
1321
1340
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1322
|
-
}), this.tradingRenderer = new
|
|
1341
|
+
}), this.tradingRenderer = new pt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1323
1342
|
this.eventBus.emit(e, t);
|
|
1324
|
-
}), this.engine = new
|
|
1343
|
+
}), this.engine = new $e(e, t.maxPixelRatio);
|
|
1325
1344
|
let a = this.engine.dprManager.getContainerSize();
|
|
1326
|
-
if (this.viewport = new
|
|
1345
|
+
if (this.viewport = new ht(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
|
|
1327
1346
|
freePan: t.freePan ?? !0,
|
|
1328
1347
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1329
1348
|
}), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1330
1349
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1331
1350
|
let t = this.viewport.isAtEnd();
|
|
1332
1351
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
1333
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new
|
|
1352
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Ne(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Xe(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new ut(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new we(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setDataSource(() => this.crosshairSeries()), this.crosshairHandler.setCallback((e, t) => {
|
|
1334
1353
|
if (e !== null && t) {
|
|
1335
1354
|
let n = this.crosshairSeries(), r = e >= 0 && e < n.length ? n[e] : void 0;
|
|
1336
1355
|
this.chartLegend.setHoverBar(r ?? null, e > 0 ? n[e - 1] ?? null : null);
|
|
@@ -1339,7 +1358,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1339
1358
|
prevClose: e > 0 ? n[e - 1]?.close : void 0,
|
|
1340
1359
|
priceRange: i.priceRange,
|
|
1341
1360
|
plot: i.chartRect,
|
|
1342
|
-
barStepMs:
|
|
1361
|
+
barStepMs: xt(n),
|
|
1343
1362
|
timeUnit: l(n)
|
|
1344
1363
|
}) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
1345
1364
|
point: t,
|
|
@@ -1347,12 +1366,12 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1347
1366
|
barIndex: e
|
|
1348
1367
|
});
|
|
1349
1368
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
|
|
1350
|
-
}), this.chartLegend = new
|
|
1369
|
+
}), this.chartLegend = new ye(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new yt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new vt(), this.volumeProfile = new _t(), this.marketProfile = new Ue(), this.depthHeatmap = new Oe(), this.periodLevels = new qe(), this.pivotMarkers = new Ye(), this.barCountdown = new he(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new rt(), this.sessionShading = new it(), this.compareRenderer = new be(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1351
1370
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1352
1371
|
color: t.sessionBreaks.color,
|
|
1353
1372
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1354
1373
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1355
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
1374
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new fe(), this.crosshairTooltip = new Te(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Je(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = x(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(ir(t.shapes)), t.font && this.themeManager.setFont(rr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Be({
|
|
1356
1375
|
scrollBars: (e) => {
|
|
1357
1376
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1358
1377
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1369,14 +1388,14 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1369
1388
|
},
|
|
1370
1389
|
fitContent: () => this.fitContent()
|
|
1371
1390
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1372
|
-
this.a11y = new
|
|
1391
|
+
this.a11y = new Yt(e, {
|
|
1373
1392
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1374
1393
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1375
1394
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
1376
1395
|
bars: () => this.getDisplayData(),
|
|
1377
1396
|
visibleRange: () => this.viewport.getState().visibleRange,
|
|
1378
1397
|
formatPrice: (e) => this.formatPrice(e),
|
|
1379
|
-
formatTime: (e) =>
|
|
1398
|
+
formatTime: (e) => le(this.numberLocale || "en-US", {
|
|
1380
1399
|
dateStyle: "medium",
|
|
1381
1400
|
timeStyle: "short"
|
|
1382
1401
|
}, this.displayTz)(e * l(this.getDisplayData())),
|
|
@@ -1399,8 +1418,8 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1399
1418
|
}
|
|
1400
1419
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1401
1420
|
}
|
|
1402
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
1403
|
-
this.eventBus.emit("alertTriggered",
|
|
1421
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ee(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new de(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
1422
|
+
this.eventBus.emit("alertTriggered", q(e)), this.eventBus.emit("dataUpdate", {
|
|
1404
1423
|
kind: "alert",
|
|
1405
1424
|
alert: "triggered",
|
|
1406
1425
|
alertId: e.id,
|
|
@@ -1408,14 +1427,14 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1408
1427
|
message: e.message
|
|
1409
1428
|
});
|
|
1410
1429
|
}), this.alertManager.on("added", (e) => {
|
|
1411
|
-
this.eventBus.emit("alertAdd",
|
|
1430
|
+
this.eventBus.emit("alertAdd", q(e));
|
|
1412
1431
|
}), this.alertManager.on("removed", (e) => {
|
|
1413
1432
|
this.eventBus.emit("alertRemove", { id: e });
|
|
1414
1433
|
}), this.alertManager.on("expired", (e) => {
|
|
1415
|
-
this.eventBus.emit("alertExpired",
|
|
1434
|
+
this.eventBus.emit("alertExpired", q(e));
|
|
1416
1435
|
}), this.alertManager.on("updated", (e) => {
|
|
1417
|
-
this.eventBus.emit("alertUpdate",
|
|
1418
|
-
}), this.signalMarkerManager = new
|
|
1436
|
+
this.eventBus.emit("alertUpdate", q(e));
|
|
1437
|
+
}), this.signalMarkerManager = new at(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
|
|
1419
1438
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1420
1439
|
id: e.id,
|
|
1421
1440
|
source: e.source,
|
|
@@ -1423,14 +1442,14 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1423
1442
|
});
|
|
1424
1443
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1425
1444
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1426
|
-
}), this.tradeZoneManager = new
|
|
1445
|
+
}), this.tradeZoneManager = new dt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
|
|
1427
1446
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1428
1447
|
id: e.id,
|
|
1429
1448
|
direction: e.direction
|
|
1430
1449
|
});
|
|
1431
1450
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1432
1451
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1433
|
-
}), this.replayManager = new
|
|
1452
|
+
}), this.replayManager = new tt(), this.replayManager.on("complete", () => {
|
|
1434
1453
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1435
1454
|
t && this.eventBus.emit("replayComplete", {
|
|
1436
1455
|
barIndex: e,
|
|
@@ -1438,9 +1457,9 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1438
1457
|
});
|
|
1439
1458
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1440
1459
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1441
|
-
}), this.measureOverlay = new
|
|
1442
|
-
let e = new
|
|
1443
|
-
this.interactionManager.setPanHandler(new
|
|
1460
|
+
}), this.measureOverlay = new We(), this.interactionManager = new Re(e), this.features.panning) {
|
|
1461
|
+
let e = new An();
|
|
1462
|
+
this.interactionManager.setPanHandler(new Ge((t, n) => {
|
|
1444
1463
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1445
1464
|
}, () => e.reset()));
|
|
1446
1465
|
}
|
|
@@ -1452,10 +1471,10 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1452
1471
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1453
1472
|
}
|
|
1454
1473
|
})), this.features.zooming) {
|
|
1455
|
-
this.interactionManager.setZoomHandler(new
|
|
1474
|
+
this.interactionManager.setZoomHandler(new bt((e, t) => {
|
|
1456
1475
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1457
1476
|
}));
|
|
1458
|
-
let e = new
|
|
1477
|
+
let e = new me((e) => {
|
|
1459
1478
|
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1460
1479
|
}, (e) => {
|
|
1461
1480
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -1475,7 +1494,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1475
1494
|
y: t.y
|
|
1476
1495
|
});
|
|
1477
1496
|
})), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.priceAxisAddButton.setEnabled(this.features.priceAxisAddButton && this.features.crosshair), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
|
|
1478
|
-
let t =
|
|
1497
|
+
let t = N(e.y, this.viewport.getState());
|
|
1479
1498
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1480
1499
|
price: t,
|
|
1481
1500
|
x: e.x,
|
|
@@ -1485,10 +1504,10 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1485
1504
|
...this.viewport.getState(),
|
|
1486
1505
|
data: this.getDisplayData()
|
|
1487
1506
|
})), this.features.alerts) {
|
|
1488
|
-
let e = new
|
|
1507
|
+
let e = new ue(this.alertManager, () => this.viewport.getState());
|
|
1489
1508
|
this.interactionManager.setAlertDragHandler(e);
|
|
1490
1509
|
}
|
|
1491
|
-
let o = new
|
|
1510
|
+
let o = new Ke();
|
|
1492
1511
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
1493
1512
|
let t = this.getDisplayData();
|
|
1494
1513
|
if (t.length === 0) return;
|
|
@@ -1512,7 +1531,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1512
1531
|
x: e.x,
|
|
1513
1532
|
y: e.y
|
|
1514
1533
|
}), t.length === 0) return;
|
|
1515
|
-
let r =
|
|
1534
|
+
let r = Ht(e.x, this.viewport.getState());
|
|
1516
1535
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1517
1536
|
bar: t[r],
|
|
1518
1537
|
barIndex: r,
|
|
@@ -1555,7 +1574,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1555
1574
|
end: () => {
|
|
1556
1575
|
let e = this.selectionBoxOverlay.end();
|
|
1557
1576
|
if (e && this.zoomAreaMode) {
|
|
1558
|
-
if (e.x1 - e.x0 <
|
|
1577
|
+
if (e.x1 - e.x0 < Yn) return;
|
|
1559
1578
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1560
1579
|
return;
|
|
1561
1580
|
}
|
|
@@ -1596,7 +1615,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1596
1615
|
if (i === 0) return a;
|
|
1597
1616
|
let o = this.series.bars();
|
|
1598
1617
|
if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), r !== void 0) {
|
|
1599
|
-
let e = Math.round(
|
|
1618
|
+
let e = Math.round(j(r, this.getDisplayData()));
|
|
1600
1619
|
this.viewport.prependBars(e - n);
|
|
1601
1620
|
}
|
|
1602
1621
|
return this.updateViewportAndRender(), a;
|
|
@@ -1628,13 +1647,13 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1628
1647
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
1629
1648
|
if (t.width <= 0) return;
|
|
1630
1649
|
let { from: n, to: r } = e;
|
|
1631
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
1650
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Jn, r - n));
|
|
1632
1651
|
}));
|
|
1633
1652
|
}
|
|
1634
1653
|
useStreamHistory(e, t) {
|
|
1635
1654
|
if (this.hostHistoryLoader) return;
|
|
1636
|
-
let n =
|
|
1637
|
-
if (!r || i === null ||
|
|
1655
|
+
let n = Vt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
|
|
1656
|
+
if (!r || i === null || se(i) !== null) {
|
|
1638
1657
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
1639
1658
|
return;
|
|
1640
1659
|
}
|
|
@@ -1702,11 +1721,11 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1702
1721
|
setChartTypeOptions(e) {
|
|
1703
1722
|
this.chartTypeOptions = {
|
|
1704
1723
|
...this.chartTypeOptions,
|
|
1705
|
-
...
|
|
1724
|
+
...x(e)
|
|
1706
1725
|
}, this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged();
|
|
1707
1726
|
}
|
|
1708
1727
|
getChartTypeOptions() {
|
|
1709
|
-
return
|
|
1728
|
+
return x(this.chartTypeOptions);
|
|
1710
1729
|
}
|
|
1711
1730
|
setExtendedHours(e) {
|
|
1712
1731
|
e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
|
|
@@ -1715,7 +1734,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1715
1734
|
return this.extendedHours;
|
|
1716
1735
|
}
|
|
1717
1736
|
sessionKeep(e) {
|
|
1718
|
-
return this.extendedHours ? null :
|
|
1737
|
+
return this.extendedHours ? null : Gt(this.symbolInfo, e);
|
|
1719
1738
|
}
|
|
1720
1739
|
reapplyExtendedHours() {
|
|
1721
1740
|
if (!this.series.refilter()) return;
|
|
@@ -1726,7 +1745,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1726
1745
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
1727
1746
|
}
|
|
1728
1747
|
setShapes(e) {
|
|
1729
|
-
let t =
|
|
1748
|
+
let t = ir(e);
|
|
1730
1749
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
1731
1750
|
...this.themeManager.getTheme().shape,
|
|
1732
1751
|
...t
|
|
@@ -1738,7 +1757,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1738
1757
|
setFont(e) {
|
|
1739
1758
|
if (e === null) this.themeManager.setFont(null);
|
|
1740
1759
|
else {
|
|
1741
|
-
let t =
|
|
1760
|
+
let t = rr(e);
|
|
1742
1761
|
if (Object.keys(t).length === 0) return;
|
|
1743
1762
|
this.themeManager.setFont(t);
|
|
1744
1763
|
}
|
|
@@ -1789,7 +1808,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1789
1808
|
setSymbolSeries(e, t) {
|
|
1790
1809
|
e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
|
|
1791
1810
|
let n = this.series.bars(), r = !1;
|
|
1792
|
-
for (let t of this.indicatorEngine.getActiveIndicators()) !
|
|
1811
|
+
for (let t of this.indicatorEngine.getActiveIndicators()) !O.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
|
|
1793
1812
|
r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
|
|
1794
1813
|
}
|
|
1795
1814
|
forgetUnreadSymbols() {
|
|
@@ -1803,20 +1822,20 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1803
1822
|
let e = /* @__PURE__ */ new Set();
|
|
1804
1823
|
for (let t of this.indicatorEngine.getActiveIndicators()) {
|
|
1805
1824
|
let n = t.params.symbol;
|
|
1806
|
-
|
|
1825
|
+
O.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
|
|
1807
1826
|
}
|
|
1808
1827
|
return [...e];
|
|
1809
1828
|
}
|
|
1810
1829
|
requestMissingSymbols(e) {
|
|
1811
1830
|
this.forgetUnreadSymbols();
|
|
1812
|
-
let t = this.indicatorEngine.getIndicatorConfig(e), n = t &&
|
|
1831
|
+
let t = this.indicatorEngine.getIndicatorConfig(e), n = t && O.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
|
|
1813
1832
|
!n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
|
|
1814
1833
|
}
|
|
1815
1834
|
updateIndicator(e, t) {
|
|
1816
1835
|
this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
|
|
1817
1836
|
}
|
|
1818
1837
|
updateIndicatorNow(e, t) {
|
|
1819
|
-
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ?
|
|
1838
|
+
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? A(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
|
|
1820
1839
|
this.indicatorEngine.updateIndicator(e, t, this.series.bars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
1821
1840
|
instanceId: e,
|
|
1822
1841
|
change: "params"
|
|
@@ -1834,7 +1853,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1834
1853
|
paneFor(e, t, n, r) {
|
|
1835
1854
|
if (n) return this.paneHostOf(n, r);
|
|
1836
1855
|
if (e.placement !== "overlay") return null;
|
|
1837
|
-
let i =
|
|
1856
|
+
let i = A(e), a = i ? y(t[i]) : null;
|
|
1838
1857
|
return a ? this.paneHostOf(a.instanceId, r) : null;
|
|
1839
1858
|
}
|
|
1840
1859
|
paneHostOf(e, t) {
|
|
@@ -1877,8 +1896,8 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1877
1896
|
return {
|
|
1878
1897
|
...e,
|
|
1879
1898
|
priceRange: {
|
|
1880
|
-
min: t.min - n *
|
|
1881
|
-
max: t.max + n *
|
|
1899
|
+
min: t.min - n * Gn,
|
|
1900
|
+
max: t.max + n * Gn
|
|
1882
1901
|
},
|
|
1883
1902
|
logScale: !1,
|
|
1884
1903
|
scaleMode: "regular",
|
|
@@ -1930,7 +1949,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1930
1949
|
this.indicatorEngine.setStyleDefaults(e, null);
|
|
1931
1950
|
return;
|
|
1932
1951
|
}
|
|
1933
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
1952
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ne(n);
|
|
1934
1953
|
this.indicatorEngine.setStyleDefaults(e, {
|
|
1935
1954
|
...r,
|
|
1936
1955
|
...i ? { plots: i } : {}
|
|
@@ -1938,7 +1957,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1938
1957
|
}
|
|
1939
1958
|
setPaneStyle(e, t) {
|
|
1940
1959
|
let n = this.paneOf(e);
|
|
1941
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ?
|
|
1960
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? re(t) : null));
|
|
1942
1961
|
}
|
|
1943
1962
|
setPaneStyleNow(e, t) {
|
|
1944
1963
|
JSON.stringify(t) !== JSON.stringify(this.paneStyles.get(e) ?? null) && (t ? this.paneStyles.set(e, t) : this.paneStyles.delete(e), this.panelInfoCache = null, this.syncRenderContext(), this.engine.requestRender(), this.markStateChanged());
|
|
@@ -1957,8 +1976,8 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1957
1976
|
return this.pluginManager;
|
|
1958
1977
|
}
|
|
1959
1978
|
static indicators() {
|
|
1960
|
-
let e = new
|
|
1961
|
-
return
|
|
1979
|
+
let e = new Le();
|
|
1980
|
+
return jt(e), e.getAvailableIndicators();
|
|
1962
1981
|
}
|
|
1963
1982
|
setPanelPosition(e, t) {
|
|
1964
1983
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -1981,7 +2000,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
1981
2000
|
paneMoveHost(e, t) {
|
|
1982
2001
|
let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
|
|
1983
2002
|
if (!n || !r) return;
|
|
1984
|
-
let i =
|
|
2003
|
+
let i = A(r);
|
|
1985
2004
|
if (r.placement === "overlay" && i && y(n.params[i])) return;
|
|
1986
2005
|
if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
|
|
1987
2006
|
if (t === "new") {
|
|
@@ -2093,7 +2112,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2093
2112
|
roundPrice(e) {
|
|
2094
2113
|
if (!Number.isFinite(e)) return e;
|
|
2095
2114
|
let t = this.stepAt(e);
|
|
2096
|
-
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(
|
|
2115
|
+
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(oe(t)));
|
|
2097
2116
|
let { min: n, max: r } = this.viewport.getState().priceRange;
|
|
2098
2117
|
return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
|
|
2099
2118
|
}
|
|
@@ -2177,7 +2196,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2177
2196
|
}
|
|
2178
2197
|
autoFib() {
|
|
2179
2198
|
if (!this.features.drawings) return null;
|
|
2180
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
2199
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = St(e, t.visibleRange.from, t.visibleRange.to);
|
|
2181
2200
|
return n ? this.addDrawing({
|
|
2182
2201
|
type: "fibRetracement",
|
|
2183
2202
|
anchors: [n[0], n[1]]
|
|
@@ -2255,7 +2274,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2255
2274
|
recordUndo(e) {
|
|
2256
2275
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2257
2276
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2258
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2277
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < qn) {
|
|
2259
2278
|
this.undoRedoManager.replaceLast({
|
|
2260
2279
|
...n,
|
|
2261
2280
|
custom: {
|
|
@@ -2302,7 +2321,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2302
2321
|
x: t.x,
|
|
2303
2322
|
y: t.y
|
|
2304
2323
|
};
|
|
2305
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
2324
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = N(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = M(t.x, n)), e === "pane") {
|
|
2306
2325
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2307
2326
|
e && (r.pane = e.instanceId);
|
|
2308
2327
|
}
|
|
@@ -2328,7 +2347,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2328
2347
|
...this.viewport.getState(),
|
|
2329
2348
|
data: this.getDisplayData()
|
|
2330
2349
|
};
|
|
2331
|
-
this.setVisibleRange(
|
|
2350
|
+
this.setVisibleRange(M(e.x0, t), M(e.x1, t));
|
|
2332
2351
|
}
|
|
2333
2352
|
lockAllDrawings() {
|
|
2334
2353
|
this.drawingManager.lockAllDrawings();
|
|
@@ -2373,7 +2392,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2373
2392
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2374
2393
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2375
2394
|
if (!t) continue;
|
|
2376
|
-
let r =
|
|
2395
|
+
let r = L(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2377
2396
|
key: e,
|
|
2378
2397
|
title: e
|
|
2379
2398
|
}));
|
|
@@ -2397,11 +2416,11 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2397
2416
|
}
|
|
2398
2417
|
getExportText(e = "csv", t = {}) {
|
|
2399
2418
|
let { bars: n, columns: r } = this.getExportData(t);
|
|
2400
|
-
return e === "json" ?
|
|
2419
|
+
return e === "json" ? T.toJSON(n, r) : T.toCSV(n, r);
|
|
2401
2420
|
}
|
|
2402
2421
|
download(e, t, n) {
|
|
2403
2422
|
let r = this.getExportText(e, n);
|
|
2404
|
-
e === "json" ?
|
|
2423
|
+
e === "json" ? T.download(r, t ?? "chart-data.json", "application/json") : T.download(r, t ?? "chart-data.csv", "text/csv");
|
|
2405
2424
|
}
|
|
2406
2425
|
setAutoSave(e, t = 5e3) {
|
|
2407
2426
|
this.autoSaveScheduler.enable(e, t);
|
|
@@ -2463,7 +2482,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2463
2482
|
this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
|
|
2464
2483
|
}
|
|
2465
2484
|
updateIndicatorStyleNow(e, t) {
|
|
2466
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2485
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ne(n);
|
|
2467
2486
|
this.indicatorEngine.updateIndicatorStyle(e, {
|
|
2468
2487
|
...r,
|
|
2469
2488
|
...i ? { plots: i } : {}
|
|
@@ -2582,8 +2601,8 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2582
2601
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
2583
2602
|
}
|
|
2584
2603
|
async connect(e) {
|
|
2585
|
-
if (!
|
|
2586
|
-
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new
|
|
2604
|
+
if (!Mt(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
2605
|
+
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new ct(), this.streamManager.on("snapshot", (t) => {
|
|
2587
2606
|
let n = `${this.currentSymbol}|${this.streamTimeframe}`;
|
|
2588
2607
|
this.replaySession ? this.series.loadAside(t) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(t) : this.setData(t), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
|
|
2589
2608
|
}), this.streamManager.on("barClose", (e) => {
|
|
@@ -2634,14 +2653,14 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2634
2653
|
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
|
|
2635
2654
|
let t = this.streamManager;
|
|
2636
2655
|
if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
|
|
2637
|
-
let n =
|
|
2656
|
+
let n = ce(e.timeframe);
|
|
2638
2657
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
2639
2658
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
2640
2659
|
}, 1e3);
|
|
2641
2660
|
}
|
|
2642
2661
|
setStreamTarget(e, t) {
|
|
2643
2662
|
let n = this.announcedSymbol;
|
|
2644
|
-
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream =
|
|
2663
|
+
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = se(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
2645
2664
|
symbol: e,
|
|
2646
2665
|
previous: n
|
|
2647
2666
|
})), this.useTimeframe(t);
|
|
@@ -2659,8 +2678,8 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2659
2678
|
async switchStream(e, t) {
|
|
2660
2679
|
if (!this.streamManager) return;
|
|
2661
2680
|
let n = this.streamAdapter;
|
|
2662
|
-
if (n && !
|
|
2663
|
-
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(
|
|
2681
|
+
if (n && !Mt(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
2682
|
+
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(ce(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
|
|
2664
2683
|
}
|
|
2665
2684
|
isIndicatorAllowed(e) {
|
|
2666
2685
|
let t = this.features.indicatorIds;
|
|
@@ -2679,7 +2698,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2679
2698
|
}
|
|
2680
2699
|
connectExecution(e, t = {}) {
|
|
2681
2700
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
2682
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
2701
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = zn(e, {
|
|
2683
2702
|
onIntent: (e, t) => {
|
|
2684
2703
|
let n = (e) => t(e.payload);
|
|
2685
2704
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -2770,18 +2789,18 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2770
2789
|
goToTime(e) {
|
|
2771
2790
|
let t = this.getDisplayData();
|
|
2772
2791
|
if (t.length === 0 || !Number.isFinite(e)) return -1;
|
|
2773
|
-
let n = Math.max(0, Math.min(t.length - 1, Math.floor(
|
|
2792
|
+
let n = Math.max(0, Math.min(t.length - 1, Math.floor(j(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
|
|
2774
2793
|
return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
|
|
2775
2794
|
}
|
|
2776
2795
|
setVisibleRangePreset(e) {
|
|
2777
2796
|
let t = this.getDisplayData();
|
|
2778
2797
|
if (t.length === 0) return;
|
|
2779
|
-
let n = t.length - 1, r = l(t), i =
|
|
2798
|
+
let n = t.length - 1, r = l(t), i = Ot(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
2780
2799
|
if (a === null || a < t[0].time) {
|
|
2781
2800
|
this.fitContent();
|
|
2782
2801
|
return;
|
|
2783
2802
|
}
|
|
2784
|
-
let o =
|
|
2803
|
+
let o = j(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
|
|
2785
2804
|
this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
|
|
2786
2805
|
}
|
|
2787
2806
|
scrollToEnd() {
|
|
@@ -2806,7 +2825,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2806
2825
|
setVisibleRange(e, t) {
|
|
2807
2826
|
let n = this.getDisplayData();
|
|
2808
2827
|
if (n.length === 0) return;
|
|
2809
|
-
let r =
|
|
2828
|
+
let r = j(Math.min(e, t), n), i = j(Math.max(e, t), n);
|
|
2810
2829
|
this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
|
|
2811
2830
|
}
|
|
2812
2831
|
suspend() {
|
|
@@ -2912,7 +2931,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2912
2931
|
this.applyStyle(e, t.layer ?? "host", !0);
|
|
2913
2932
|
}
|
|
2914
2933
|
setOverrides(e, t = {}) {
|
|
2915
|
-
let n = t.layer ?? "host", { overrides: r, rejected: i } =
|
|
2934
|
+
let n = t.layer ?? "host", { overrides: r, rejected: i } = b(e);
|
|
2916
2935
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
|
|
2917
2936
|
let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
|
|
2918
2937
|
this.themeManager.setOverrides(a, n) && this.styleChanged(n);
|
|
@@ -2931,7 +2950,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2931
2950
|
return this.themeManager.getStyleValue(e);
|
|
2932
2951
|
}
|
|
2933
2952
|
applyStyle(e, t, n) {
|
|
2934
|
-
let { overrides: r, rejected: i } =
|
|
2953
|
+
let { overrides: r, rejected: i } = b(e);
|
|
2935
2954
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
|
|
2936
2955
|
}
|
|
2937
2956
|
styleChanged(e) {
|
|
@@ -2961,7 +2980,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
2961
2980
|
e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
|
|
2962
2981
|
}
|
|
2963
2982
|
setCrosshairTime(e) {
|
|
2964
|
-
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(
|
|
2983
|
+
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(j(e, t));
|
|
2965
2984
|
n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
|
|
2966
2985
|
}
|
|
2967
2986
|
getData() {
|
|
@@ -3023,7 +3042,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3023
3042
|
this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
|
|
3024
3043
|
}
|
|
3025
3044
|
setTimeZone(e) {
|
|
3026
|
-
|
|
3045
|
+
Un(e), this.timeZoneSetting = e, this.applyTimeZone();
|
|
3027
3046
|
}
|
|
3028
3047
|
getTimeZone() {
|
|
3029
3048
|
return this.timeZoneSetting;
|
|
@@ -3032,7 +3051,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3032
3051
|
return this.displayTz;
|
|
3033
3052
|
}
|
|
3034
3053
|
getExchangeTimeZone() {
|
|
3035
|
-
return [
|
|
3054
|
+
return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && g(e)) ?? null;
|
|
3036
3055
|
}
|
|
3037
3056
|
setTimezone(e) {
|
|
3038
3057
|
this.setTimeZone(e);
|
|
@@ -3054,18 +3073,18 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3054
3073
|
this.displayTz = e, this.timeAxis.setTimezoneOffset(e), this.crosshairHandler.setTimezoneOffset(e), this.crosshairTooltip.setTimezoneOffset(e), this.pinnedTooltip.setTimezone(e), this.sessionBreaks.setTimezone(e), this.engine.requestRender();
|
|
3055
3074
|
}
|
|
3056
3075
|
setSymbolInfo(e) {
|
|
3057
|
-
let t = e && this.symbolInfo?.symbol === e.symbol ?
|
|
3058
|
-
this.symbolInfo = e ?
|
|
3076
|
+
let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
|
|
3077
|
+
this.symbolInfo = e ? Wn({
|
|
3059
3078
|
...e,
|
|
3060
3079
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
3061
3080
|
}, t) : null, this.chartLegend.setExchange(this.symbolInfo?.exchange ?? ""), this.engine.requestRender(r.Hover), this.priceAxis.setPriceTick(this.symbolInfo?.minTick ?? null), this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
|
|
3062
3081
|
let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
|
|
3063
|
-
let t =
|
|
3082
|
+
let t = S(e.start), n = S(e.end);
|
|
3064
3083
|
return t === null || n === null ? [] : [{
|
|
3065
3084
|
startMinute: t,
|
|
3066
3085
|
endMinute: n
|
|
3067
3086
|
}];
|
|
3068
|
-
}), i =
|
|
3087
|
+
}), i = C(this.symbolInfo);
|
|
3069
3088
|
this.sessionShading.replaceConfig(n.length > 0 && i && g(i) ? {
|
|
3070
3089
|
timeZone: i,
|
|
3071
3090
|
windows: n,
|
|
@@ -3080,11 +3099,11 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3080
3099
|
if (!e || typeof e != "object") return;
|
|
3081
3100
|
let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
|
|
3082
3101
|
if (!n(e.symbol)) return;
|
|
3083
|
-
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i =
|
|
3102
|
+
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Wn({
|
|
3084
3103
|
...r,
|
|
3085
3104
|
...e,
|
|
3086
3105
|
symbol: e.symbol || r?.symbol || t
|
|
3087
|
-
},
|
|
3106
|
+
}, C(r));
|
|
3088
3107
|
r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
|
|
3089
3108
|
}
|
|
3090
3109
|
resolveStreamSymbol(e, t) {
|
|
@@ -3114,7 +3133,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3114
3133
|
return this.sessionShading.isVisible();
|
|
3115
3134
|
}
|
|
3116
3135
|
setSessionShadingConfig(e) {
|
|
3117
|
-
this.hostSessionHours =
|
|
3136
|
+
this.hostSessionHours = Et(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
|
|
3118
3137
|
}
|
|
3119
3138
|
setTooltipVisible(e) {
|
|
3120
3139
|
e || this.crosshairTooltip.hide();
|
|
@@ -3133,11 +3152,11 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3133
3152
|
return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
|
|
3134
3153
|
}
|
|
3135
3154
|
async takeGpu(e, t, n) {
|
|
3136
|
-
let { gpu: r, reason: i } = await
|
|
3137
|
-
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ?
|
|
3155
|
+
let { gpu: r, reason: i } = await Tt(e);
|
|
3156
|
+
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? Ct() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
|
|
3138
3157
|
}
|
|
3139
3158
|
waitForGpu(e) {
|
|
3140
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
3159
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Bt(e) : null;
|
|
3141
3160
|
}
|
|
3142
3161
|
getRenderer() {
|
|
3143
3162
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -3159,23 +3178,23 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3159
3178
|
this.engine.getGpu() && this.engine.renderNow();
|
|
3160
3179
|
}
|
|
3161
3180
|
screenshot(e) {
|
|
3162
|
-
this.features.screenshot && (this.freshFrame(),
|
|
3181
|
+
this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
|
|
3163
3182
|
}
|
|
3164
3183
|
async copyScreenshot() {
|
|
3165
3184
|
if (!this.features.screenshot) return !1;
|
|
3166
3185
|
try {
|
|
3167
3186
|
this.freshFrame();
|
|
3168
|
-
let e = await
|
|
3187
|
+
let e = await k.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
|
|
3169
3188
|
return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
|
|
3170
3189
|
} catch {
|
|
3171
3190
|
return !1;
|
|
3172
3191
|
}
|
|
3173
3192
|
}
|
|
3174
3193
|
screenshotDataURL() {
|
|
3175
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3194
|
+
return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
3176
3195
|
}
|
|
3177
3196
|
async screenshotBlob() {
|
|
3178
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3197
|
+
return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
3179
3198
|
}
|
|
3180
3199
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
3181
3200
|
if (!this.features.alerts) return null;
|
|
@@ -3309,23 +3328,23 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3309
3328
|
};
|
|
3310
3329
|
}
|
|
3311
3330
|
let { steps: n, startTime: r, hideHistory: i, revealMarks: a, ...o } = e ?? {}, s = this.series.inHoursShown(this.series.liveBars()), c = t > 0 && r === void 0 && i !== !1, l = o.startIndex;
|
|
3312
|
-
r !== void 0 && l === void 0 ? l =
|
|
3331
|
+
r !== void 0 && l === void 0 ? l = cr(s, r) : c && l !== void 0 && (l += t);
|
|
3313
3332
|
let u = c ? t : i && l !== void 0 && l > 0 ? Math.min(Math.floor(l), s.length - 1) : 0, d = u > 0 ? s.slice(u) : s;
|
|
3314
3333
|
l !== void 0 && (o.startIndex = l - u), this.replayOffset = u, this.replayRevealMarks = a !== !1;
|
|
3315
|
-
let f = n ?
|
|
3334
|
+
let f = n ? fr(n, d) : null;
|
|
3316
3335
|
this.replayStepsSeries = f, this.replayCoarse = d, this.options.autoScale = !0, this.replayRestarting = !0;
|
|
3317
3336
|
try {
|
|
3318
3337
|
this.replayManager.load(f ?? d);
|
|
3319
3338
|
} finally {
|
|
3320
3339
|
this.replayRestarting = !1;
|
|
3321
3340
|
}
|
|
3322
|
-
f && o.startIndex !== void 0 && (o.startIndex =
|
|
3341
|
+
f && o.startIndex !== void 0 && (o.startIndex = mr(f, d, o.startIndex)), this.replayBarUnsub?.();
|
|
3323
3342
|
let p = -1, m = -1, h = null, g = f ?? d;
|
|
3324
3343
|
this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
|
|
3325
3344
|
let t = e, n = d[e];
|
|
3326
3345
|
if (f) {
|
|
3327
3346
|
let r = f[e];
|
|
3328
|
-
t =
|
|
3347
|
+
t = pr(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? gr(h, r) : hr(d[t], f, e), n = h;
|
|
3329
3348
|
}
|
|
3330
3349
|
m = e;
|
|
3331
3350
|
let r = t + 1, i = p > 0 && r >= p && this.series.length() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
@@ -3377,20 +3396,20 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3377
3396
|
return;
|
|
3378
3397
|
}
|
|
3379
3398
|
if (i.time <= n.fedTime) return;
|
|
3380
|
-
let a = e.slice(
|
|
3399
|
+
let a = e.slice(lr(e, n.fedTime), t + 1);
|
|
3381
3400
|
n.fedTime = i.time;
|
|
3382
|
-
let o = Math.ceil(a.length /
|
|
3383
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
3401
|
+
let o = Math.ceil(a.length / sr);
|
|
3402
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of ur(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
3384
3403
|
this.tradingManager.setCurrentPrice(i.close);
|
|
3385
3404
|
}
|
|
3386
3405
|
getReplayBarIndex() {
|
|
3387
3406
|
if (!this.replaySession) return -1;
|
|
3388
3407
|
let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
|
|
3389
|
-
return t && this.replayCoarse ?
|
|
3408
|
+
return t && this.replayCoarse ? pr(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
|
|
3390
3409
|
}
|
|
3391
3410
|
replaySeekToBar(e) {
|
|
3392
3411
|
let t = this.replayStepsSeries;
|
|
3393
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
3412
|
+
this.replaySeek(t && this.replayCoarse ? mr(t, this.replayCoarse, e) : e);
|
|
3394
3413
|
}
|
|
3395
3414
|
replayPause() {
|
|
3396
3415
|
this.replayManager.pause();
|
|
@@ -3422,10 +3441,10 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3422
3441
|
data: this.getDisplayData()
|
|
3423
3442
|
}, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
3424
3443
|
for (let e of t.anchors) {
|
|
3425
|
-
let t =
|
|
3444
|
+
let t = Nt(e.time, n), r = Dt(e.price, n);
|
|
3426
3445
|
i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
|
|
3427
3446
|
}
|
|
3428
|
-
return
|
|
3447
|
+
return Xn.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Zn.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
|
|
3429
3448
|
x: i,
|
|
3430
3449
|
y: o,
|
|
3431
3450
|
width: a - i,
|
|
@@ -3456,7 +3475,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3456
3475
|
return this.replayManager.getProgress();
|
|
3457
3476
|
}
|
|
3458
3477
|
captureSnapshot() {
|
|
3459
|
-
return
|
|
3478
|
+
return w.capture({
|
|
3460
3479
|
getDrawings: () => this.getDrawings(),
|
|
3461
3480
|
getTheme: () => this.themeManager.getBaseTheme(),
|
|
3462
3481
|
getAlerts: () => this.getAlerts(),
|
|
@@ -3469,14 +3488,14 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3469
3488
|
});
|
|
3470
3489
|
}
|
|
3471
3490
|
restoreIndicators(e, t) {
|
|
3472
|
-
let n =
|
|
3491
|
+
let n = $n(e), r = /* @__PURE__ */ new Map();
|
|
3473
3492
|
this.unrestoredIndicators = [];
|
|
3474
3493
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
3475
3494
|
if (t) {
|
|
3476
3495
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
3477
3496
|
for (let n of t) {
|
|
3478
3497
|
let t = e.get(n.instanceId);
|
|
3479
|
-
t &&
|
|
3498
|
+
t && er(n, t) && o.add(n.instanceId);
|
|
3480
3499
|
}
|
|
3481
3500
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
3482
3501
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -3538,7 +3557,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3538
3557
|
let s = t.levels ?? null;
|
|
3539
3558
|
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
|
|
3540
3559
|
let c = t.intervals ?? null;
|
|
3541
|
-
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ?
|
|
3560
|
+
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? re(t.paneStyle) : null);
|
|
3542
3561
|
}
|
|
3543
3562
|
restorePanes(e) {
|
|
3544
3563
|
for (let [t, n] of e) t.paneSize !== void 0 && this.layoutManager.setPanelSize(n, t.paneSize), (t.paneSize !== void 0 || t.paneCollapsed) && this.layoutManager.setPanelCollapsed(n, !!t.paneCollapsed), t.paneSize !== void 0 && this.layoutManager.setPanelScale(n, {
|
|
@@ -3643,7 +3662,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3643
3662
|
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
3644
3663
|
let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
|
|
3645
3664
|
if (JSON.stringify(n) === JSON.stringify(i)) return r;
|
|
3646
|
-
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) <
|
|
3665
|
+
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < qn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
|
|
3647
3666
|
type: "indicators",
|
|
3648
3667
|
before: null,
|
|
3649
3668
|
after: null
|
|
@@ -3671,12 +3690,12 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3671
3690
|
}
|
|
3672
3691
|
saveState(e) {
|
|
3673
3692
|
if (!this.features.saveLoad) return null;
|
|
3674
|
-
let t = this.captureSnapshot(), n =
|
|
3675
|
-
return e &&
|
|
3693
|
+
let t = this.captureSnapshot(), n = w.serialize(t);
|
|
3694
|
+
return e && w.saveToStorage(e, t), n;
|
|
3676
3695
|
}
|
|
3677
3696
|
loadState(e) {
|
|
3678
3697
|
if (!this.features.saveLoad) return;
|
|
3679
|
-
let t =
|
|
3698
|
+
let t = w.deserialize(e);
|
|
3680
3699
|
this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), (t.theme === "dark" || t.theme === "light") && this.setTheme(t.theme), t.version >= 3 && this.themeManager.setUserOverrides(t.overrides ?? {}) && this.styleChanged("user");
|
|
3681
3700
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
3682
3701
|
if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
|
|
@@ -3687,7 +3706,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3687
3706
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
3688
3707
|
return r ? r + e.slice(t) : e;
|
|
3689
3708
|
}, r = t(e.channel), i = {
|
|
3690
|
-
...
|
|
3709
|
+
...kt(e),
|
|
3691
3710
|
...e.target ? { target: t(e.target) } : {}
|
|
3692
3711
|
};
|
|
3693
3712
|
if (!e.expired) {
|
|
@@ -3707,22 +3726,22 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3707
3726
|
}
|
|
3708
3727
|
loadStateFromStorage(e) {
|
|
3709
3728
|
if (!this.features.saveLoad) return !1;
|
|
3710
|
-
let t =
|
|
3711
|
-
return t ? (this.loadState(
|
|
3729
|
+
let t = w.loadFromStorage(e);
|
|
3730
|
+
return t ? (this.loadState(w.serialize(t)), !0) : !1;
|
|
3712
3731
|
}
|
|
3713
3732
|
downloadState(e) {
|
|
3714
|
-
this.features.saveLoad &&
|
|
3733
|
+
this.features.saveLoad && w.downloadFile(this.captureSnapshot(), e);
|
|
3715
3734
|
}
|
|
3716
3735
|
async loadStateFromFile() {
|
|
3717
3736
|
if (!this.features.saveLoad) return;
|
|
3718
|
-
let e = await
|
|
3719
|
-
this.loadState(
|
|
3737
|
+
let e = await w.loadFromFile();
|
|
3738
|
+
this.loadState(w.serialize(e));
|
|
3720
3739
|
}
|
|
3721
3740
|
setLocale(e) {
|
|
3722
|
-
|
|
3741
|
+
ae(e), this.engine.requestRender();
|
|
3723
3742
|
}
|
|
3724
3743
|
setNumberLocale(e) {
|
|
3725
|
-
this.numberLocale = e, this.viewport.setNumberLocale(e), this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.timeAxis.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.
|
|
3744
|
+
this.numberLocale = e, this.viewport.setNumberLocale(e), this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.timeAxis.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
|
|
3726
3745
|
}
|
|
3727
3746
|
getNumberLocale() {
|
|
3728
3747
|
return this.numberLocale;
|
|
@@ -3775,11 +3794,11 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3775
3794
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(n), this.eventBus.emit("resize", e);
|
|
3776
3795
|
}
|
|
3777
3796
|
destroy() {
|
|
3778
|
-
this.disposed = !0, this.stopWatchingVisibility?.(), this.stopWatchingVisibility = null, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
3797
|
+
this.disposed = !0, this.stopWatchingVisibility?.(), this.stopWatchingVisibility = null, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.labelWidths.destroy(), this.container.innerHTML = "";
|
|
3779
3798
|
}
|
|
3780
3799
|
createChartRenderer(e) {
|
|
3781
3800
|
let t = nn(e, (e) => this.pluginManager.getChartType(e));
|
|
3782
|
-
return t instanceof
|
|
3801
|
+
return t instanceof Fe && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
3783
3802
|
}
|
|
3784
3803
|
crosshairSeries() {
|
|
3785
3804
|
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
@@ -3789,7 +3808,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3789
3808
|
let e = this.series.bars();
|
|
3790
3809
|
if (e.length === 0) return e;
|
|
3791
3810
|
let t = rn(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
|
|
3792
|
-
return this.chartRenderer instanceof
|
|
3811
|
+
return this.chartRenderer instanceof D && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(en(e, this.chartTypeOptions)), this.displayDataCache = t, t;
|
|
3793
3812
|
}
|
|
3794
3813
|
recalcIndicatorsFrom(e, t) {
|
|
3795
3814
|
this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
|
|
@@ -3842,12 +3861,12 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3842
3861
|
}
|
|
3843
3862
|
fitPriceScale(e, t) {
|
|
3844
3863
|
if (e.length === 0) return;
|
|
3845
|
-
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i =
|
|
3864
|
+
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = or(or(f(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && ar(e, n, r) ? this.volumeRenderer.getHeightRatio() + Kn : E;
|
|
3846
3865
|
this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
|
|
3847
3866
|
top: a,
|
|
3848
|
-
bottom:
|
|
3867
|
+
bottom: E
|
|
3849
3868
|
} : {
|
|
3850
|
-
top:
|
|
3869
|
+
top: E,
|
|
3851
3870
|
bottom: a
|
|
3852
3871
|
}), this.viewport.fitToPrices(i.min, i.max);
|
|
3853
3872
|
}
|
|
@@ -3893,9 +3912,13 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3893
3912
|
return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
3894
3913
|
}
|
|
3895
3914
|
measureText(e, t) {
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3915
|
+
let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
|
|
3916
|
+
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => tr(n, e, t));
|
|
3917
|
+
let i = n ?? this.detachedMeasureContext();
|
|
3918
|
+
return i ? tr(i, e, t) : e.length * 7;
|
|
3919
|
+
}
|
|
3920
|
+
detachedMeasureContext() {
|
|
3921
|
+
return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
|
|
3899
3922
|
}
|
|
3900
3923
|
emitViewportEvents() {
|
|
3901
3924
|
let e = this.viewport.getState(), t = Math.max(0, Math.floor(e.visibleRange.from)), n = Math.max(t, Math.ceil(e.visibleRange.to));
|
|
@@ -3933,7 +3956,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
3933
3956
|
buildPanelRenderInfos() {
|
|
3934
3957
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
3935
3958
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
3936
|
-
let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...
|
|
3959
|
+
let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...Bn }, o = {
|
|
3937
3960
|
x: e.rect.x,
|
|
3938
3961
|
y: e.rect.y + 20,
|
|
3939
3962
|
width: e.rect.width,
|
|
@@ -4015,7 +4038,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
4015
4038
|
});
|
|
4016
4039
|
}
|
|
4017
4040
|
drawOverlayPlugins(e, t) {
|
|
4018
|
-
let n =
|
|
4041
|
+
let n = W(this.pluginManager.getOverlays(), t);
|
|
4019
4042
|
if (n.length === 0) return;
|
|
4020
4043
|
let r = {
|
|
4021
4044
|
viewport: this.viewport.getState(),
|
|
@@ -4036,7 +4059,7 @@ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontal
|
|
|
4036
4059
|
};
|
|
4037
4060
|
}
|
|
4038
4061
|
};
|
|
4039
|
-
function
|
|
4062
|
+
function $n(e) {
|
|
4040
4063
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
4041
4064
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
4042
4065
|
i.add(e.instanceId);
|
|
@@ -4050,13 +4073,19 @@ function Qn(e) {
|
|
|
4050
4073
|
for (let t of e) a(t);
|
|
4051
4074
|
return n;
|
|
4052
4075
|
}
|
|
4053
|
-
function
|
|
4076
|
+
function er(e, t) {
|
|
4054
4077
|
return e.id === t.id && (e.pane ?? null) === (t.pane ?? null) && (e.scale ?? null) === (t.scale ?? null) && e.position === void 0 == (t.position === void 0);
|
|
4055
4078
|
}
|
|
4056
|
-
|
|
4057
|
-
|
|
4079
|
+
function tr(e, t, n) {
|
|
4080
|
+
let r = e.font;
|
|
4081
|
+
e.font = n;
|
|
4082
|
+
let i = e.measureText(t).width;
|
|
4083
|
+
return e.font = r, i;
|
|
4084
|
+
}
|
|
4085
|
+
var nr = 300;
|
|
4086
|
+
function rr(e) {
|
|
4058
4087
|
let t = {}, n = e.family;
|
|
4059
|
-
typeof n == "string" && n.trim() !== "" && n.length <=
|
|
4088
|
+
typeof n == "string" && n.trim() !== "" && n.length <= nr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
|
|
4060
4089
|
for (let n of [
|
|
4061
4090
|
"sizeSmall",
|
|
4062
4091
|
"sizeMedium",
|
|
@@ -4067,21 +4096,21 @@ function tr(e) {
|
|
|
4067
4096
|
}
|
|
4068
4097
|
return t;
|
|
4069
4098
|
}
|
|
4070
|
-
function
|
|
4099
|
+
function ir(e) {
|
|
4071
4100
|
let t = e.tagRadius;
|
|
4072
4101
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
4073
4102
|
}
|
|
4074
|
-
function
|
|
4103
|
+
function ar(e, t, n) {
|
|
4075
4104
|
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
4076
4105
|
return !1;
|
|
4077
4106
|
}
|
|
4078
|
-
function
|
|
4107
|
+
function or(e, t) {
|
|
4079
4108
|
return e ? t ? {
|
|
4080
4109
|
min: Math.min(e.min, t.min),
|
|
4081
4110
|
max: Math.max(e.max, t.max)
|
|
4082
4111
|
} : e : t;
|
|
4083
4112
|
}
|
|
4084
|
-
function
|
|
4113
|
+
function q(e) {
|
|
4085
4114
|
return {
|
|
4086
4115
|
id: e.id,
|
|
4087
4116
|
price: e.price,
|
|
@@ -4096,8 +4125,8 @@ function K(e) {
|
|
|
4096
4125
|
bars: e.bars
|
|
4097
4126
|
};
|
|
4098
4127
|
}
|
|
4099
|
-
var
|
|
4100
|
-
function
|
|
4128
|
+
var sr = 500;
|
|
4129
|
+
function cr(e, t) {
|
|
4101
4130
|
let n = 0, r = e.length;
|
|
4102
4131
|
for (; n < r;) {
|
|
4103
4132
|
let i = n + r >> 1;
|
|
@@ -4105,7 +4134,7 @@ function or(e, t) {
|
|
|
4105
4134
|
}
|
|
4106
4135
|
return n;
|
|
4107
4136
|
}
|
|
4108
|
-
function
|
|
4137
|
+
function lr(e, t) {
|
|
4109
4138
|
let n = 0, r = e.length;
|
|
4110
4139
|
for (; n < r;) {
|
|
4111
4140
|
let i = n + r >> 1;
|
|
@@ -4113,20 +4142,20 @@ function sr(e, t) {
|
|
|
4113
4142
|
}
|
|
4114
4143
|
return n;
|
|
4115
4144
|
}
|
|
4116
|
-
function
|
|
4145
|
+
function ur(e) {
|
|
4117
4146
|
let t = 0, n = 0;
|
|
4118
4147
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
4119
4148
|
let r = [e[t].low, e[t].time], i = [e[n].high, e[n].time], a = t === n ? e[t].close >= e[t].open : t < n, o = e[e.length - 1];
|
|
4120
4149
|
return [...a ? [r, i] : [i, r], [o.close, o.time]];
|
|
4121
4150
|
}
|
|
4122
|
-
function
|
|
4151
|
+
function dr(e) {
|
|
4123
4152
|
let t = 0;
|
|
4124
4153
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
4125
4154
|
return t > 0 ? t : Infinity;
|
|
4126
4155
|
}
|
|
4127
|
-
function
|
|
4156
|
+
function fr(e, t) {
|
|
4128
4157
|
if (t.length === 0) return null;
|
|
4129
|
-
let n = t[t.length - 1].time +
|
|
4158
|
+
let n = t[t.length - 1].time + dr(t), r = e.filter((e) => ln(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
4130
4159
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
4131
4160
|
if (i.length === 0) return null;
|
|
4132
4161
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -4134,7 +4163,7 @@ function ur(e, t) {
|
|
|
4134
4163
|
let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
|
|
4135
4164
|
return [...o, ...s];
|
|
4136
4165
|
}
|
|
4137
|
-
function
|
|
4166
|
+
function pr(e, t) {
|
|
4138
4167
|
let n = 0, r = e.length - 1;
|
|
4139
4168
|
for (; n < r;) {
|
|
4140
4169
|
let i = n + r + 1 >> 1;
|
|
@@ -4142,22 +4171,22 @@ function dr(e, t) {
|
|
|
4142
4171
|
}
|
|
4143
4172
|
return n;
|
|
4144
4173
|
}
|
|
4145
|
-
function
|
|
4174
|
+
function mr(e, t, n) {
|
|
4146
4175
|
let r = Math.max(0, Math.min(Math.floor(Number.isFinite(n) ? n : 0), t.length - 1)), i = r + 1 < t.length ? t[r + 1].time : Infinity, a = -1;
|
|
4147
4176
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
4148
4177
|
return Math.max(0, a);
|
|
4149
4178
|
}
|
|
4150
|
-
function
|
|
4179
|
+
function hr(e, t, n) {
|
|
4151
4180
|
let r = n;
|
|
4152
4181
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
4153
4182
|
let i = {
|
|
4154
4183
|
...t[r],
|
|
4155
4184
|
time: e.time
|
|
4156
4185
|
};
|
|
4157
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
4186
|
+
for (let e = r + 1; e <= n; e++) i = gr(i, t[e]);
|
|
4158
4187
|
return i;
|
|
4159
4188
|
}
|
|
4160
|
-
function
|
|
4189
|
+
function gr(e, t) {
|
|
4161
4190
|
return {
|
|
4162
4191
|
time: e.time,
|
|
4163
4192
|
open: e.open,
|
|
@@ -4169,26 +4198,26 @@ function mr(e, t) {
|
|
|
4169
4198
|
}
|
|
4170
4199
|
//#endregion
|
|
4171
4200
|
//#region src/io/parseOHLCV.ts
|
|
4172
|
-
var
|
|
4201
|
+
var _r = [
|
|
4173
4202
|
"time",
|
|
4174
4203
|
"timestamp",
|
|
4175
4204
|
"date",
|
|
4176
4205
|
"datetime",
|
|
4177
4206
|
"t"
|
|
4178
|
-
],
|
|
4207
|
+
], vr = ["open", "o"], yr = ["high", "h"], br = ["low", "l"], xr = ["close", "c"], Sr = [
|
|
4179
4208
|
"volume",
|
|
4180
4209
|
"vol",
|
|
4181
4210
|
"v"
|
|
4182
4211
|
];
|
|
4183
|
-
function
|
|
4212
|
+
function Cr(e) {
|
|
4184
4213
|
let t = e.trim();
|
|
4185
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
4214
|
+
return t ? t[0] === "[" || t[0] === "{" ? wr(t) : Tr(t) : {
|
|
4186
4215
|
data: [],
|
|
4187
4216
|
rowCount: 0,
|
|
4188
4217
|
skipped: 0
|
|
4189
4218
|
};
|
|
4190
4219
|
}
|
|
4191
|
-
function
|
|
4220
|
+
function wr(e) {
|
|
4192
4221
|
let t;
|
|
4193
4222
|
try {
|
|
4194
4223
|
t = JSON.parse(e);
|
|
@@ -4198,19 +4227,19 @@ function xr(e) {
|
|
|
4198
4227
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
4199
4228
|
let n = [], r = 0;
|
|
4200
4229
|
for (let e of t) {
|
|
4201
|
-
let t = Array.isArray(e) ?
|
|
4230
|
+
let t = Array.isArray(e) ? Ar(e) : kr(e);
|
|
4202
4231
|
t ? n.push(t) : r++;
|
|
4203
4232
|
}
|
|
4204
|
-
return
|
|
4233
|
+
return jr(n, t.length, r);
|
|
4205
4234
|
}
|
|
4206
|
-
function
|
|
4235
|
+
function Tr(e) {
|
|
4207
4236
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
4208
4237
|
if (t.length === 0) return {
|
|
4209
4238
|
data: [],
|
|
4210
4239
|
rowCount: 0,
|
|
4211
4240
|
skipped: 0
|
|
4212
4241
|
};
|
|
4213
|
-
let n =
|
|
4242
|
+
let n = Er(t[0]), r = Dr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Or(r) : {
|
|
4214
4243
|
time: 0,
|
|
4215
4244
|
open: 1,
|
|
4216
4245
|
high: 2,
|
|
@@ -4221,7 +4250,7 @@ function Sr(e) {
|
|
|
4221
4250
|
if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
|
|
4222
4251
|
let o = [], s = 0;
|
|
4223
4252
|
for (let e = +!!i; e < t.length; e++) {
|
|
4224
|
-
let r =
|
|
4253
|
+
let r = Dr(t[e], n), i = Y(r[a.time]), c = J(r[a.open]), l = J(r[a.high]), u = J(r[a.low]), d = J(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
4225
4254
|
if (i === null || ![
|
|
4226
4255
|
c,
|
|
4227
4256
|
l,
|
|
@@ -4240,9 +4269,9 @@ function Sr(e) {
|
|
|
4240
4269
|
volume: Number.isFinite(f) ? f : 0
|
|
4241
4270
|
});
|
|
4242
4271
|
}
|
|
4243
|
-
return
|
|
4272
|
+
return jr(o, t.length - +!!i, s);
|
|
4244
4273
|
}
|
|
4245
|
-
function
|
|
4274
|
+
function Er(e) {
|
|
4246
4275
|
let t = {
|
|
4247
4276
|
",": 0,
|
|
4248
4277
|
";": 0,
|
|
@@ -4254,7 +4283,7 @@ function Cr(e) {
|
|
|
4254
4283
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
4255
4284
|
return n;
|
|
4256
4285
|
}
|
|
4257
|
-
function
|
|
4286
|
+
function Dr(e, t) {
|
|
4258
4287
|
let n = [], r = "", i = !1;
|
|
4259
4288
|
for (let a = 0; a < e.length; a++) {
|
|
4260
4289
|
let o = e[a];
|
|
@@ -4262,25 +4291,25 @@ function wr(e, t) {
|
|
|
4262
4291
|
}
|
|
4263
4292
|
return n.push(r), n;
|
|
4264
4293
|
}
|
|
4265
|
-
function
|
|
4294
|
+
function Or(e) {
|
|
4266
4295
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
4267
4296
|
return {
|
|
4268
|
-
time: t(
|
|
4269
|
-
open: t(
|
|
4270
|
-
high: t(
|
|
4271
|
-
low: t(
|
|
4272
|
-
close: t(
|
|
4273
|
-
volume: t(
|
|
4297
|
+
time: t(_r),
|
|
4298
|
+
open: t(vr),
|
|
4299
|
+
high: t(yr),
|
|
4300
|
+
low: t(br),
|
|
4301
|
+
close: t(xr),
|
|
4302
|
+
volume: t(Sr)
|
|
4274
4303
|
};
|
|
4275
4304
|
}
|
|
4276
|
-
function
|
|
4305
|
+
function kr(e) {
|
|
4277
4306
|
let t = (t) => {
|
|
4278
4307
|
for (let n of t) {
|
|
4279
4308
|
if (e[n] !== void 0) return e[n];
|
|
4280
4309
|
let t = n.toUpperCase();
|
|
4281
4310
|
if (e[t] !== void 0) return e[t];
|
|
4282
4311
|
}
|
|
4283
|
-
}, n = Y(String(t(
|
|
4312
|
+
}, n = Y(String(t(_r) ?? "")), r = Number(t(vr)), i = Number(t(yr)), a = Number(t(br)), o = Number(t(xr)), s = Number(t(Sr) ?? 0);
|
|
4284
4313
|
return n === null || ![
|
|
4285
4314
|
r,
|
|
4286
4315
|
i,
|
|
@@ -4295,7 +4324,7 @@ function Er(e) {
|
|
|
4295
4324
|
volume: Number.isFinite(s) ? s : 0
|
|
4296
4325
|
};
|
|
4297
4326
|
}
|
|
4298
|
-
function
|
|
4327
|
+
function Ar(e) {
|
|
4299
4328
|
if (e.length < 5) return null;
|
|
4300
4329
|
let t = Y(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
|
|
4301
4330
|
return t === null || ![
|
|
@@ -4323,7 +4352,7 @@ function Y(e) {
|
|
|
4323
4352
|
let r = Date.parse(t);
|
|
4324
4353
|
return Number.isFinite(r) ? r : null;
|
|
4325
4354
|
}
|
|
4326
|
-
function
|
|
4355
|
+
function jr(e, t, n) {
|
|
4327
4356
|
e.sort((e, t) => e.time - t.time);
|
|
4328
4357
|
let r = [];
|
|
4329
4358
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -4335,7 +4364,7 @@ function Or(e, t, n) {
|
|
|
4335
4364
|
}
|
|
4336
4365
|
//#endregion
|
|
4337
4366
|
//#region src/io/DragDropImporter.ts
|
|
4338
|
-
var
|
|
4367
|
+
var Mr = class {
|
|
4339
4368
|
host;
|
|
4340
4369
|
overlay = null;
|
|
4341
4370
|
callbacks;
|
|
@@ -4368,7 +4397,7 @@ var kr = class {
|
|
|
4368
4397
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
4369
4398
|
let t = e.dataTransfer?.files?.[0];
|
|
4370
4399
|
if (t) try {
|
|
4371
|
-
let e =
|
|
4400
|
+
let e = Cr(await t.text());
|
|
4372
4401
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
4373
4402
|
this.callbacks.onData(e.data, e, t);
|
|
4374
4403
|
} catch (e) {
|
|
@@ -4412,7 +4441,7 @@ function Z(e) {
|
|
|
4412
4441
|
};
|
|
4413
4442
|
return e.symbol !== void 0 && (t.symbol = e.symbol), e.timeframe !== void 0 && (t.timeframe = e.timeframe), e.kind !== void 0 && (t.kind = e.kind), t;
|
|
4414
4443
|
}
|
|
4415
|
-
var
|
|
4444
|
+
var Nr = (e, t) => t.updatedAt - e.updatedAt;
|
|
4416
4445
|
function Q(e) {
|
|
4417
4446
|
if (typeof e != "object" || !e) return null;
|
|
4418
4447
|
let t = e;
|
|
@@ -4425,17 +4454,17 @@ function Q(e) {
|
|
|
4425
4454
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
4426
4455
|
});
|
|
4427
4456
|
}
|
|
4428
|
-
function
|
|
4457
|
+
function Pr(e) {
|
|
4429
4458
|
let t = Q(e), n = t ? e.content : void 0;
|
|
4430
4459
|
return t && typeof n == "string" ? {
|
|
4431
4460
|
...t,
|
|
4432
4461
|
content: n
|
|
4433
4462
|
} : null;
|
|
4434
4463
|
}
|
|
4435
|
-
function
|
|
4464
|
+
function Fr(e = []) {
|
|
4436
4465
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
4437
4466
|
return {
|
|
4438
|
-
list: () => [...t.values()].map(Z).sort(
|
|
4467
|
+
list: () => [...t.values()].map(Z).sort(Nr),
|
|
4439
4468
|
load: (e) => {
|
|
4440
4469
|
let n = t.get(e);
|
|
4441
4470
|
return n ? { ...n } : null;
|
|
@@ -4448,7 +4477,7 @@ function Mr(e = []) {
|
|
|
4448
4477
|
}
|
|
4449
4478
|
};
|
|
4450
4479
|
}
|
|
4451
|
-
function
|
|
4480
|
+
function Ir(e = "tcw:layouts:") {
|
|
4452
4481
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
4453
4482
|
let e;
|
|
4454
4483
|
try {
|
|
@@ -4459,7 +4488,7 @@ function Nr(e = "tcw:layouts:") {
|
|
|
4459
4488
|
return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
|
|
4460
4489
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
4461
4490
|
return {
|
|
4462
|
-
list: () => r().sort(
|
|
4491
|
+
list: () => r().sort(Nr),
|
|
4463
4492
|
load: (e) => {
|
|
4464
4493
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
4465
4494
|
return t && i !== null ? {
|
|
@@ -4477,14 +4506,14 @@ function Nr(e = "tcw:layouts:") {
|
|
|
4477
4506
|
}
|
|
4478
4507
|
//#endregion
|
|
4479
4508
|
//#region src/state/LayoutSession.ts
|
|
4480
|
-
var
|
|
4509
|
+
var Lr = 80;
|
|
4481
4510
|
function $(e) {
|
|
4482
4511
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
4483
4512
|
}
|
|
4484
|
-
function
|
|
4513
|
+
function Rr() {
|
|
4485
4514
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
4486
4515
|
}
|
|
4487
|
-
function
|
|
4516
|
+
function zr(e) {
|
|
4488
4517
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
4489
4518
|
return {
|
|
4490
4519
|
id: t,
|
|
@@ -4495,7 +4524,7 @@ function Ir(e) {
|
|
|
4495
4524
|
...o === void 0 ? {} : { kind: o }
|
|
4496
4525
|
};
|
|
4497
4526
|
}
|
|
4498
|
-
var
|
|
4527
|
+
var Br = class {
|
|
4499
4528
|
currentLayout = null;
|
|
4500
4529
|
savedContent = null;
|
|
4501
4530
|
dirty = !1;
|
|
@@ -4511,7 +4540,7 @@ var Lr = class {
|
|
|
4511
4540
|
now;
|
|
4512
4541
|
newId;
|
|
4513
4542
|
constructor(e, t, n = {}) {
|
|
4514
|
-
this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ??
|
|
4543
|
+
this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? Rr;
|
|
4515
4544
|
}
|
|
4516
4545
|
current() {
|
|
4517
4546
|
return this.currentLayout;
|
|
@@ -4541,7 +4570,7 @@ var Lr = class {
|
|
|
4541
4570
|
}
|
|
4542
4571
|
open(e) {
|
|
4543
4572
|
return this.queue(async () => {
|
|
4544
|
-
let t =
|
|
4573
|
+
let t = Pr(await this.storage.load(e));
|
|
4545
4574
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
4546
4575
|
this.cancelTimer(), this.applying++;
|
|
4547
4576
|
try {
|
|
@@ -4551,13 +4580,13 @@ var Lr = class {
|
|
|
4551
4580
|
} finally {
|
|
4552
4581
|
this.applying--;
|
|
4553
4582
|
}
|
|
4554
|
-
return this.cancelTimer(), this.currentLayout =
|
|
4583
|
+
return this.cancelTimer(), this.currentLayout = zr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
4555
4584
|
});
|
|
4556
4585
|
}
|
|
4557
4586
|
rename(e, t) {
|
|
4558
4587
|
let n = $(t);
|
|
4559
4588
|
return n ? this.queue(async () => {
|
|
4560
|
-
let t =
|
|
4589
|
+
let t = Pr(await this.storage.load(e));
|
|
4561
4590
|
!t || t.id !== e || (await this.storage.save({
|
|
4562
4591
|
...t,
|
|
4563
4592
|
name: n
|
|
@@ -4635,7 +4664,7 @@ var Lr = class {
|
|
|
4635
4664
|
content: n.content
|
|
4636
4665
|
};
|
|
4637
4666
|
await this.storage.save(r);
|
|
4638
|
-
let i =
|
|
4667
|
+
let i = zr(r);
|
|
4639
4668
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
4640
4669
|
}
|
|
4641
4670
|
forget() {
|
|
@@ -4656,6 +4685,6 @@ var Lr = class {
|
|
|
4656
4685
|
}
|
|
4657
4686
|
};
|
|
4658
4687
|
//#endregion
|
|
4659
|
-
export { V as C, dn as S,
|
|
4688
|
+
export { V as C, dn as S, L as T, W as _, Fr as a, gn as b, Qn as c, In as d, Fn as f, jn as g, Nn as h, Ir as i, Hn as l, Mn as m, Lr as n, Mr as o, Pn as p, $ as r, Cr as s, Br as t, Vn as u, G as v, z as w, pn as x, xn as y };
|
|
4660
4689
|
|
|
4661
|
-
//# sourceMappingURL=LayoutSession-
|
|
4690
|
+
//# sourceMappingURL=LayoutSession-Qkx1huV-.js.map
|