@tradecanvas/chart 1.51.0 → 1.53.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/dist/Chart.d.ts +275 -10
- package/dist/Chart.d.ts.map +1 -1
- package/dist/DataManager.d.ts +24 -0
- package/dist/DataManager.d.ts.map +1 -1
- package/dist/HistoryPager.d.ts +12 -2
- package/dist/HistoryPager.d.ts.map +1 -1
- package/dist/{LayoutSession-Qkx1huV-.js → LayoutSession-D7uQq3jX.js} +1225 -474
- package/dist/LayoutSession-D7uQq3jX.js.map +1 -0
- package/dist/LayoutSession-nlhT-EH7.cjs +2 -0
- package/dist/LayoutSession-nlhT-EH7.cjs.map +1 -0
- package/dist/SeriesStore.d.ts +58 -4
- package/dist/SeriesStore.d.ts.map +1 -1
- package/dist/charts/ChartTypeStrategy.d.ts +32 -5
- package/dist/charts/ChartTypeStrategy.d.ts.map +1 -1
- package/dist/frameworks/feedBars.d.ts +22 -6
- package/dist/frameworks/feedBars.d.ts.map +1 -1
- package/dist/{i18n-DFTQ73Cz.js → i18n-CwCzRLKW.js} +39 -1
- package/dist/i18n-CwCzRLKW.js.map +1 -0
- package/dist/i18n-D7B7uFrN.cjs +2 -0
- package/dist/i18n-D7B7uFrN.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +124 -101
- package/dist/index.js.map +1 -1
- package/dist/io/resampleOHLCV.d.ts +10 -4
- package/dist/io/resampleOHLCV.d.ts.map +1 -1
- package/dist/replay/ReplayStepLoader.d.ts +52 -0
- package/dist/replay/ReplayStepLoader.d.ts.map +1 -0
- package/dist/replay/intrabarPath.d.ts +44 -0
- package/dist/replay/intrabarPath.d.ts.map +1 -0
- package/dist/replay/replayStep.d.ts +18 -0
- package/dist/replay/replayStep.d.ts.map +1 -0
- package/dist/widget/ChartWidget.d.ts +329 -13
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/ChartWidgetGrid.d.ts.map +1 -1
- package/dist/widget/WidgetDataWindow.d.ts +7 -0
- package/dist/widget/WidgetDataWindow.d.ts.map +1 -1
- package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
- package/dist/widget/WidgetIndicatorLegend.d.ts +21 -3
- package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -1
- package/dist/widget/WidgetIndicatorSettings.d.ts.map +1 -1
- package/dist/widget/WidgetObjectTree.d.ts +7 -1
- package/dist/widget/WidgetObjectTree.d.ts.map +1 -1
- package/dist/widget/WidgetReplayBar.d.ts +101 -23
- package/dist/widget/WidgetReplayBar.d.ts.map +1 -1
- package/dist/widget/WidgetSettings.d.ts +11 -3
- package/dist/widget/WidgetSettings.d.ts.map +1 -1
- package/dist/widget/chartSettingsStore.d.ts +76 -0
- package/dist/widget/chartSettingsStore.d.ts.map +1 -0
- package/dist/widget/chartTemplates.d.ts.map +1 -1
- package/dist/widget/compareLegend.d.ts +20 -0
- package/dist/widget/compareLegend.d.ts.map +1 -0
- package/dist/widget/index.cjs +382 -166
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.d.ts +1 -1
- package/dist/widget/index.d.ts.map +1 -1
- package/dist/widget/index.js +2947 -2041
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/indicatorInputWords.d.ts +19 -0
- package/dist/widget/indicatorInputWords.d.ts.map +1 -0
- 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 +20 -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 +533 -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/settingsRows.d.ts +12 -3
- package/dist/widget/settingsRows.d.ts.map +1 -1
- package/dist/widget/symbolInfoView.d.ts.map +1 -1
- package/dist/widget/types.d.ts +75 -7
- package/dist/widget/types.d.ts.map +1 -1
- package/dist/widget/widgetCompare.d.ts +18 -0
- package/dist/widget/widgetCompare.d.ts.map +1 -1
- package/dist/widget/widgetLayout.d.ts +13 -1
- package/dist/widget/widgetLayout.d.ts.map +1 -1
- package/dist/widget/widgetSettingsLook.d.ts +3 -1
- package/dist/widget/widgetSettingsLook.d.ts.map +1 -1
- package/dist/widget/widgetShareState.d.ts +8 -0
- package/dist/widget/widgetShareState.d.ts.map +1 -1
- package/dist/widget/widgetTimezones.d.ts +4 -1
- package/dist/widget/widgetTimezones.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-DuV9kpdQ.cjs +0 -2
- package/dist/LayoutSession-DuV9kpdQ.cjs.map +0 -1
- package/dist/LayoutSession-Qkx1huV-.js.map +0 -1
- package/dist/i18n-Bg_UJSNs.cjs +0 -2
- package/dist/i18n-Bg_UJSNs.cjs.map +0 -1
- package/dist/i18n-DFTQ73Cz.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
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,
|
|
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, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, formatPrice as h, fractionTick as g, indicatorSource as _, isValidTimeZone as v, mergeBar as ee, niceNumber as te, normalizeBarTime as y, parseIndicatorSource as b, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as x, readIndicatorPlotStyles as ae, readPaneStyle as oe, resolveChartTheme as se, sessionMinute as S, setLocale as ce, stepDecimals as le, symbolTimeZone as C, tickBarCount as ue, timeframeToMs as w, zonedDateFormatter as de } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as fe, AlertManager as pe, Animator as me, AreaRenderer as he, AxisDragHandler as ge, BarCountdown as _e, BarRenderer as ve, BaselineRenderer as ye, CandlestickRenderer as be, ChartLegend as xe, ChartStateManager as T, CompareRenderer as Se, CompareSymbolIndicator as Ce, CorrelationCoefficientIndicator as we, CorrelationLogIndicator as Te, CrosshairHandler as Ee, CrosshairTooltip as De, CurrentPriceLine as Oe, DEFAULT_SESSION_HOURS as ke, DataExporter as E, DepthHeatmapRenderer as Ae, DrawingManager as je, DrawingRenderer as Me, EquivolumeRenderer as Ne, EventBus as Pe, GridRenderer as Fe, HLCAreaRenderer as Ie, HiLoRenderer as Le, HollowCandleRenderer as Re, IndicatorEngine as ze, InteractionManager as Be, KagiRenderer as Ve, KeyboardHandler as He, LineRenderer as Ue, LineWithMarkersRenderer as We, MarketProfileRenderer as Ge, MeasureOverlay as Ke, PRICE_SCALE_MARGIN as D, PanHandler as qe, PaneResizeHandler as Je, PeriodLevelsRenderer as Ye, PinnedTooltip as Xe, PivotMarkersRenderer as Ze, PointAndFigureRenderer as Qe, PriceAxis as $e, PriceAxisAddButton as et, PriceLines as tt, RenderEngine as nt, RenkoRenderer as rt, ReplayManager as it, ResamplingAdapter as at, ReshapeMemo as ot, SYMBOL_INDICATOR_IDS as O, SYMBOL_ZONE_WAIT_MS as st, Screenshot as k, SelectionBoxOverlay as ct, SessionBreaks as lt, SessionShading as ut, SignalMarkerManager as dt, SpreadIndicator as ft, StepLineRenderer as pt, StreamManager as mt, SymbolSeriesStore as ht, TimeAxis as gt, TradeZoneManager as _t, TradingManager as vt, TradingRenderer as yt, UndoRedoManager as bt, Viewport as xt, VolumeCandleRenderer as St, VolumeProfileRenderer as Ct, VolumeRenderer as wt, Watermark as Tt, ZoomHandler as Et, barTimeStepMs as Dt, findDominantSwing as Ot, gpuContextsLeft as kt, isPriceLevelAlert as At, isRegularSession as jt, loadWebGL as Mt, mergeSessionHours as Nt, pointAndFigureColumns as Pt, priceToY as Ft, rangePresetStart as It, readAlertOptions as Lt, registerBuiltInDrawingTools as Rt, registerBuiltInIndicators as zt, servesTimeframe as A, sourceParam as j, timeToX as Bt, timestampToBarIndex as M, toHeikinAshi as Vt, toKagi as Ht, toLineBreak as Ut, toRangeBars as Wt, toRenko as Gt, whenGpuContextFree as Kt, withResampling as N, xToBarIndex as qt, xToTime as P, yToPrice as Jt } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var Yt = 864e5, Xt = 10;
|
|
5
|
+
function Zt(e, t) {
|
|
6
6
|
let n = C(e);
|
|
7
|
-
if (!n || !
|
|
7
|
+
if (!n || !v(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
9
9
|
let t = S(e.start), n = S(e.end);
|
|
10
10
|
return t === null || n === null ? [] : [{
|
|
@@ -13,35 +13,35 @@ function Gt(e, t) {
|
|
|
13
13
|
}];
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
|
-
let i =
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
16
|
+
let i = u(t), a = Infinity;
|
|
17
|
+
for (let e = Math.max(1, t.length - Xt); 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 < Yt)) 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) => jt(e * i, o);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var Qt = {
|
|
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
|
-
}, F = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e),
|
|
39
|
+
}, F = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), $t = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], en = 400, tn = 1e3, nn = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var P = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
...
|
|
58
|
+
...Qt,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of $t) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = rn("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 = rn("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
|
+
...Qt,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = tn - (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 P = {
|
|
|
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
|
+
}, en);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -99,7 +99,7 @@ var P = {
|
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: an(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -140,7 +140,7 @@ var P = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function rn(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 I(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function an(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 on(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(),
|
|
@@ -169,52 +169,52 @@ function L(e, t, n, r) {
|
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/charts/ChartTypeStrategy.ts
|
|
172
|
-
function
|
|
172
|
+
function sn(e) {
|
|
173
173
|
switch (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 be();
|
|
178
|
+
case "line": return new Ue();
|
|
179
|
+
case "area": return new he();
|
|
180
|
+
case "bar": return new ve();
|
|
181
|
+
case "hollowCandle": return new Re();
|
|
182
|
+
case "baseline": return new ye();
|
|
183
|
+
case "renko": return new rt();
|
|
184
|
+
case "kagi": return new Ve();
|
|
185
|
+
case "pointAndFigure": return new Qe();
|
|
186
|
+
case "volumeCandles": return new St();
|
|
187
|
+
case "equivolume": return new Ne();
|
|
188
|
+
case "hlcArea": return new Ie();
|
|
189
|
+
case "stepLine": return new pt();
|
|
190
|
+
case "lineWithMarkers": return new We();
|
|
191
|
+
case "hiLo": return new Le();
|
|
192
|
+
default: return new be();
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function cn(e, t, n = {}, r, i) {
|
|
196
196
|
if (t.length === 0) return t;
|
|
197
197
|
switch (e) {
|
|
198
|
-
case "heikinAshi": return
|
|
198
|
+
case "heikinAshi": return Vt(t);
|
|
199
199
|
case "renko": {
|
|
200
200
|
let e = n.renko?.boxSize;
|
|
201
|
-
return typeof e == "number" ?
|
|
201
|
+
return typeof e == "number" ? Gt(t, { brickSize: e }, i) : Gt(t, {
|
|
202
202
|
brickSize: 0,
|
|
203
203
|
useATR: !0,
|
|
204
204
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
205
|
-
});
|
|
206
|
-
}
|
|
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
|
-
case "rangeBars": {
|
|
211
|
-
let e = n.rangeBars?.range;
|
|
212
|
-
return Rt(t, { rangeSize: typeof e == "number" ? e : tn(t) * .005 });
|
|
205
|
+
}, i);
|
|
213
206
|
}
|
|
207
|
+
case "lineBreak": return Ut(t, n.lineBreak?.lines ?? 3);
|
|
208
|
+
case "kagi": return Ht(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
|
|
209
|
+
case "pointAndFigure": return un(t, n, i).columns;
|
|
210
|
+
case "rangeBars": return Wt(t, {
|
|
211
|
+
rangeSize: _n(t, n, r),
|
|
212
|
+
includeForming: !0
|
|
213
|
+
}, i);
|
|
214
214
|
default: return t;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function ln(e) {
|
|
218
218
|
switch (e) {
|
|
219
219
|
case "heikinAshi":
|
|
220
220
|
case "renko":
|
|
@@ -225,30 +225,65 @@ function $t(e) {
|
|
|
225
225
|
default: return !1;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
return e !== "heikinAshi" &&
|
|
228
|
+
function I(e) {
|
|
229
|
+
return e !== "heikinAshi" && ln(e);
|
|
230
230
|
}
|
|
231
|
-
function
|
|
232
|
-
let
|
|
233
|
-
return typeof
|
|
231
|
+
function un(e, t = {}, n) {
|
|
232
|
+
let r = t.pointAndFigure?.boxSize;
|
|
233
|
+
return Pt(e, typeof r == "number" ? r : dn(e) * .01, t.pointAndFigure?.reversal ?? 3, n);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function dn(e) {
|
|
236
236
|
let t = 0;
|
|
237
237
|
for (let n of e) t += n.close;
|
|
238
238
|
return t / e.length;
|
|
239
239
|
}
|
|
240
|
-
|
|
240
|
+
var fn = 100, pn = 3, mn = .01, hn = 15, gn = (e) => Number(e.toPrecision(hn));
|
|
241
|
+
function _n(e, t = {}, n) {
|
|
242
|
+
let r = t.rangeBars?.range;
|
|
243
|
+
if (typeof r == "number") return r;
|
|
244
|
+
let i = e.length >= pn ? yn(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
|
|
245
|
+
return Sn(gn(te(i > 0 ? i : a * mn || 1, !0)), n);
|
|
246
|
+
}
|
|
247
|
+
function vn(e) {
|
|
248
|
+
let t = e.length - 1;
|
|
249
|
+
return {
|
|
250
|
+
from: Math.max(0, t - fn),
|
|
251
|
+
end: t
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function yn(e) {
|
|
255
|
+
let { from: t, end: n } = vn(e), r = 0;
|
|
256
|
+
for (let i = t; i < n; i++) {
|
|
257
|
+
let { high: t, low: n } = e[i], a = i > 0 ? e[i - 1].close : n;
|
|
258
|
+
r += Math.max(t - n, Math.abs(t - a), Math.abs(n - a));
|
|
259
|
+
}
|
|
260
|
+
return n > t ? r / (n - t) : 0;
|
|
261
|
+
}
|
|
262
|
+
function bn(e, t) {
|
|
263
|
+
let { from: n, end: r } = vn(e);
|
|
264
|
+
if (r <= n) return t(e[e.length - 1]?.close ?? 0);
|
|
265
|
+
let i = -Infinity, a = Infinity;
|
|
266
|
+
for (let t = n; t < r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
|
|
267
|
+
return xn(t(i), t(a));
|
|
268
|
+
}
|
|
269
|
+
function xn(e, t) {
|
|
270
|
+
return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
|
|
271
|
+
}
|
|
272
|
+
function Sn(e, t) {
|
|
273
|
+
return t === void 0 || !(t > 0) ? e : gn(Math.max(1, Math.round(e / t)) * t);
|
|
274
|
+
}
|
|
275
|
+
function Cn(e, t) {
|
|
241
276
|
let n = t?.(e);
|
|
242
|
-
return n ? n.createRenderer() :
|
|
277
|
+
return n ? n.createRenderer() : sn(e);
|
|
243
278
|
}
|
|
244
|
-
function
|
|
279
|
+
function wn(e, t, n, r, i, a) {
|
|
245
280
|
if (t.length === 0) return t;
|
|
246
|
-
let
|
|
247
|
-
return
|
|
281
|
+
let o = n?.(e);
|
|
282
|
+
return o?.transform ? o.transform(t) : cn(e, t, r, i, a);
|
|
248
283
|
}
|
|
249
284
|
//#endregion
|
|
250
285
|
//#region src/state/AutoSaveScheduler.ts
|
|
251
|
-
var
|
|
286
|
+
var Tn = class {
|
|
252
287
|
timer = null;
|
|
253
288
|
delayMs = 0;
|
|
254
289
|
key = null;
|
|
@@ -278,15 +313,15 @@ var an = class {
|
|
|
278
313
|
};
|
|
279
314
|
//#endregion
|
|
280
315
|
//#region src/DataManager.ts
|
|
281
|
-
function
|
|
316
|
+
function L(e) {
|
|
282
317
|
if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
|
|
283
318
|
let { open: t, high: n, low: r, close: i } = e;
|
|
284
319
|
return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
|
|
285
320
|
}
|
|
286
|
-
function
|
|
321
|
+
function En(e) {
|
|
287
322
|
return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
|
|
288
323
|
}
|
|
289
|
-
function
|
|
324
|
+
function R(e) {
|
|
290
325
|
return {
|
|
291
326
|
...e,
|
|
292
327
|
high: Math.max(e.open, e.high, e.low, e.close),
|
|
@@ -294,22 +329,36 @@ function B(e) {
|
|
|
294
329
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
295
330
|
};
|
|
296
331
|
}
|
|
297
|
-
function
|
|
332
|
+
function z(e, t) {
|
|
333
|
+
return e === t || e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume;
|
|
334
|
+
}
|
|
335
|
+
function Dn(e, t) {
|
|
336
|
+
for (let n = e.length - 1; n >= 0; n--) {
|
|
337
|
+
if (e[n].time === t) return n;
|
|
338
|
+
if (e[n].time < t) return -1;
|
|
339
|
+
}
|
|
340
|
+
return -1;
|
|
341
|
+
}
|
|
342
|
+
var On = {
|
|
343
|
+
index: -1,
|
|
344
|
+
changed: !1
|
|
345
|
+
};
|
|
346
|
+
function kn(e, t) {
|
|
298
347
|
if (e.length === 0) return t;
|
|
299
|
-
let n =
|
|
300
|
-
return
|
|
348
|
+
let n = y(t);
|
|
349
|
+
return u(e) === 1 ? n : n / 1e3;
|
|
301
350
|
}
|
|
302
|
-
function
|
|
303
|
-
let n =
|
|
351
|
+
function An(e, t) {
|
|
352
|
+
let n = kn(e, t.time);
|
|
304
353
|
return n === t.time ? t : {
|
|
305
354
|
...t,
|
|
306
355
|
time: n
|
|
307
356
|
};
|
|
308
357
|
}
|
|
309
|
-
var
|
|
358
|
+
var B = class {
|
|
310
359
|
data = [];
|
|
311
360
|
withSeriesTime(e) {
|
|
312
|
-
return
|
|
361
|
+
return An(this.data, e);
|
|
313
362
|
}
|
|
314
363
|
getData() {
|
|
315
364
|
return this.data;
|
|
@@ -318,16 +367,16 @@ var V = class {
|
|
|
318
367
|
let t = [];
|
|
319
368
|
for (let n = 0; n < e.length; n++) {
|
|
320
369
|
let r = e[n];
|
|
321
|
-
|
|
370
|
+
L(r) && t.push(En(r) ? r : R(r));
|
|
322
371
|
}
|
|
323
372
|
this.data = t;
|
|
324
373
|
}
|
|
325
374
|
prependBars(e) {
|
|
326
375
|
let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
|
|
327
376
|
for (let r = 0; r < e.length; r++) {
|
|
328
|
-
if (!
|
|
377
|
+
if (!L(e[r])) continue;
|
|
329
378
|
let i = this.withSeriesTime(e[r]);
|
|
330
|
-
i.time >= t || n.push(
|
|
379
|
+
i.time >= t || n.push(En(i) ? i : R(i));
|
|
331
380
|
}
|
|
332
381
|
if (n.length === 0) return 0;
|
|
333
382
|
n.sort((e, t) => e.time - t.time);
|
|
@@ -336,19 +385,32 @@ var V = class {
|
|
|
336
385
|
return n.length = r, this.data = n.concat(this.data), r;
|
|
337
386
|
}
|
|
338
387
|
appendBar(e) {
|
|
339
|
-
|
|
388
|
+
L(e) && this.data.push(R(this.withSeriesTime(e)));
|
|
340
389
|
}
|
|
341
390
|
updateLastBar(e) {
|
|
342
|
-
if (!
|
|
343
|
-
let t =
|
|
391
|
+
if (!L(e)) return;
|
|
392
|
+
let t = R(this.withSeriesTime(e));
|
|
344
393
|
if (this.data.length === 0) {
|
|
345
394
|
this.data.push(t);
|
|
346
395
|
return;
|
|
347
396
|
}
|
|
348
397
|
this.data[this.data.length - 1] = t;
|
|
349
398
|
}
|
|
399
|
+
replaceBar(e) {
|
|
400
|
+
if (!L(e)) return On;
|
|
401
|
+
let t = this.withSeriesTime(e), n = Dn(this.data, t.time);
|
|
402
|
+
if (n < 0) return On;
|
|
403
|
+
let r = R(t);
|
|
404
|
+
return z(this.data[n], r) ? {
|
|
405
|
+
index: n,
|
|
406
|
+
changed: !1
|
|
407
|
+
} : (this.data[n] = r, {
|
|
408
|
+
index: n,
|
|
409
|
+
changed: !0
|
|
410
|
+
});
|
|
411
|
+
}
|
|
350
412
|
updateLastBarFromTick(e) {
|
|
351
|
-
this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] =
|
|
413
|
+
this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = ee(this.data[this.data.length - 1], this.withSeriesTime(e))));
|
|
352
414
|
}
|
|
353
415
|
getLength() {
|
|
354
416
|
return this.data.length;
|
|
@@ -356,16 +418,18 @@ var V = class {
|
|
|
356
418
|
clear() {
|
|
357
419
|
this.data = [];
|
|
358
420
|
}
|
|
421
|
+
}, V = {
|
|
422
|
+
to: "none",
|
|
423
|
+
index: -1,
|
|
424
|
+
changed: !1
|
|
359
425
|
};
|
|
360
|
-
//#endregion
|
|
361
|
-
//#region src/SeriesStore.ts
|
|
362
426
|
function H(e, t) {
|
|
363
427
|
let n = e[e.length - 1];
|
|
364
428
|
if (!n) return "append";
|
|
365
|
-
let r =
|
|
429
|
+
let r = y(t.time), i = y(n.time);
|
|
366
430
|
return r > i ? "append" : r === i ? "update" : "stale";
|
|
367
431
|
}
|
|
368
|
-
function
|
|
432
|
+
function jn(e) {
|
|
369
433
|
return [
|
|
370
434
|
e.time,
|
|
371
435
|
e.open,
|
|
@@ -374,12 +438,13 @@ function ln(e) {
|
|
|
374
438
|
e.close
|
|
375
439
|
].every(Number.isFinite);
|
|
376
440
|
}
|
|
377
|
-
var
|
|
378
|
-
shown = new
|
|
441
|
+
var Mn = class {
|
|
442
|
+
shown = new B();
|
|
379
443
|
whole = null;
|
|
380
444
|
aside = null;
|
|
381
|
-
|
|
382
|
-
|
|
445
|
+
shownRevision = 0;
|
|
446
|
+
constructor(e, t = () => {}) {
|
|
447
|
+
this.hoursFilter = e, this.onLiveChange = t;
|
|
383
448
|
}
|
|
384
449
|
bars() {
|
|
385
450
|
return this.shown.getData();
|
|
@@ -387,16 +452,33 @@ var un = class {
|
|
|
387
452
|
length() {
|
|
388
453
|
return this.shown.getLength();
|
|
389
454
|
}
|
|
455
|
+
revision() {
|
|
456
|
+
return this.shownRevision;
|
|
457
|
+
}
|
|
390
458
|
liveBars() {
|
|
391
459
|
return this.aside?.getData() ?? this.whole ?? this.shown.getData();
|
|
392
460
|
}
|
|
393
461
|
load(e) {
|
|
462
|
+
if (this.aside) {
|
|
463
|
+
this.aside.setData(e), this.onLiveChange({ kind: "series" });
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
394
466
|
this.shown.setData(this.regularOnly(e));
|
|
395
467
|
}
|
|
396
468
|
prepend(e) {
|
|
469
|
+
if (this.aside) {
|
|
470
|
+
let t = this.aside.prependBars(e);
|
|
471
|
+
return t > 0 && this.onLiveChange({
|
|
472
|
+
kind: "older",
|
|
473
|
+
taken: t
|
|
474
|
+
}), {
|
|
475
|
+
added: 0,
|
|
476
|
+
taken: t
|
|
477
|
+
};
|
|
478
|
+
}
|
|
397
479
|
let t = null, n = e;
|
|
398
480
|
if (this.whole) {
|
|
399
|
-
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(
|
|
481
|
+
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(jn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
|
|
400
482
|
this.whole = [...a, ...this.whole];
|
|
401
483
|
let o = this.hoursFilter(this.whole);
|
|
402
484
|
t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
|
|
@@ -408,12 +490,12 @@ var un = class {
|
|
|
408
490
|
};
|
|
409
491
|
}
|
|
410
492
|
mergeSnapshot(e) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
return
|
|
493
|
+
if (this.aside) return this.aside.setData(Nn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
|
|
494
|
+
let t = Nn(this.whole ?? this.shown.getData(), e);
|
|
495
|
+
return t ? (this.shown.setData(this.regularOnly(t)), !0) : !1;
|
|
414
496
|
}
|
|
415
497
|
refilter() {
|
|
416
|
-
if (this.aside) return !1;
|
|
498
|
+
if (this.aside) return this.onLiveChange({ kind: "hours" }), !1;
|
|
417
499
|
let e = this.whole ?? this.shown.getData().slice();
|
|
418
500
|
return !this.whole && !this.hoursFilter(e) ? !1 : (this.shown.setData(this.regularOnly(e)), !0);
|
|
419
501
|
}
|
|
@@ -466,7 +548,7 @@ var un = class {
|
|
|
466
548
|
mergeTick(e) {
|
|
467
549
|
if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
|
|
468
550
|
let t = this.whole ? this.hoursFilter(this.whole) : null;
|
|
469
|
-
if (t && this.whole && !t(
|
|
551
|
+
if (t && this.whole && !t(kn(this.whole, e.time))) return this.wrote("hidden", !1);
|
|
470
552
|
let n = this.shown.getLength();
|
|
471
553
|
this.shown.updateLastBarFromTick(e);
|
|
472
554
|
let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
|
|
@@ -496,11 +578,34 @@ var un = class {
|
|
|
496
578
|
refiltered: r
|
|
497
579
|
});
|
|
498
580
|
}
|
|
499
|
-
|
|
500
|
-
this.aside
|
|
581
|
+
replace(e) {
|
|
582
|
+
if (this.aside) {
|
|
583
|
+
let { index: t, changed: n } = this.aside.replaceBar(e);
|
|
584
|
+
return t < 0 ? V : (n && this.onLiveChange({
|
|
585
|
+
kind: "bar",
|
|
586
|
+
time: this.aside.getData()[t].time
|
|
587
|
+
}), {
|
|
588
|
+
to: "aside",
|
|
589
|
+
index: -1,
|
|
590
|
+
changed: n
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
if (!L(e)) return V;
|
|
594
|
+
let t = this.inSeriesUnit(e), n = this.whole, r = n ? Dn(n, t.time) : -1;
|
|
595
|
+
if (n) {
|
|
596
|
+
if (r < 0 || !L(n[r])) return V;
|
|
597
|
+
let e = this.hoursFilter(n);
|
|
598
|
+
if (e && !e(t.time)) return this.replaceHidden(n, r, t);
|
|
599
|
+
}
|
|
600
|
+
let { index: i, changed: a } = this.shown.replaceBar(t);
|
|
601
|
+
return i < 0 ? V : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
|
|
602
|
+
to: "shown",
|
|
603
|
+
index: i,
|
|
604
|
+
changed: a
|
|
605
|
+
});
|
|
501
606
|
}
|
|
502
607
|
beginReplay() {
|
|
503
|
-
this.aside || (this.aside = new
|
|
608
|
+
this.aside || (this.aside = new B(), this.aside.setData(this.whole ?? this.shown.getData()));
|
|
504
609
|
}
|
|
505
610
|
endReplay() {
|
|
506
611
|
let e = this.aside;
|
|
@@ -520,7 +625,15 @@ var un = class {
|
|
|
520
625
|
this.shown.updateLastBar(e);
|
|
521
626
|
}
|
|
522
627
|
inSeriesUnit(e) {
|
|
523
|
-
return
|
|
628
|
+
return An(this.whole ?? this.shown.getData(), e);
|
|
629
|
+
}
|
|
630
|
+
replaceHidden(e, t, n) {
|
|
631
|
+
let r = R(n), i = !z(e[t], r);
|
|
632
|
+
return i && (e[t] = r), {
|
|
633
|
+
to: "hidden",
|
|
634
|
+
index: -1,
|
|
635
|
+
changed: i
|
|
636
|
+
};
|
|
524
637
|
}
|
|
525
638
|
wrote(e, t) {
|
|
526
639
|
return {
|
|
@@ -548,7 +661,15 @@ var un = class {
|
|
|
548
661
|
let r = this.hoursFilter(n);
|
|
549
662
|
return !r || r(e.time);
|
|
550
663
|
}
|
|
551
|
-
}
|
|
664
|
+
};
|
|
665
|
+
function Nn(e, t) {
|
|
666
|
+
let n = t[0]?.time, r = 0;
|
|
667
|
+
for (; n !== void 0 && r < e.length && e[r].time < n;) r++;
|
|
668
|
+
return r === 0 || r === e.length ? null : e.slice(0, r).concat(t);
|
|
669
|
+
}
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/HistoryPager.ts
|
|
672
|
+
var Pn = 5e3, Fn = 6e4, In = 500, Ln = class {
|
|
552
673
|
loader = null;
|
|
553
674
|
pageSize = 500;
|
|
554
675
|
loading = !1;
|
|
@@ -556,6 +677,7 @@ var un = class {
|
|
|
556
677
|
failures = 0;
|
|
557
678
|
retryAt = 0;
|
|
558
679
|
seq = 0;
|
|
680
|
+
inFlight = null;
|
|
559
681
|
constructor(e) {
|
|
560
682
|
this.host = e;
|
|
561
683
|
}
|
|
@@ -566,7 +688,12 @@ var un = class {
|
|
|
566
688
|
return this.loader !== null;
|
|
567
689
|
}
|
|
568
690
|
reset() {
|
|
569
|
-
this.seq
|
|
691
|
+
this.seq++;
|
|
692
|
+
let e = this.loading;
|
|
693
|
+
this.loading = !1, this.exhausted = !1, this.failures = 0, this.retryAt = 0, e && this.emit({
|
|
694
|
+
state: "loaded",
|
|
695
|
+
count: 0
|
|
696
|
+
});
|
|
570
697
|
}
|
|
571
698
|
isLoading() {
|
|
572
699
|
return this.loading;
|
|
@@ -577,7 +704,12 @@ var un = class {
|
|
|
577
704
|
maybeLoad(e, t) {
|
|
578
705
|
e >= t || !this.canLoad() || this.failures >= 5 || this.now() < this.retryAt || this.loadMore();
|
|
579
706
|
}
|
|
580
|
-
|
|
707
|
+
loadMore() {
|
|
708
|
+
if (this.loading && this.inFlight) return this.inFlight;
|
|
709
|
+
let e = this.loadPage();
|
|
710
|
+
return this.inFlight = e, e;
|
|
711
|
+
}
|
|
712
|
+
async loadPage() {
|
|
581
713
|
let e = this.loader, t = this.host.oldestTime();
|
|
582
714
|
if (!e || !this.canLoad() || t === null) return 0;
|
|
583
715
|
let n = this.seq;
|
|
@@ -589,7 +721,7 @@ var un = class {
|
|
|
589
721
|
try {
|
|
590
722
|
r = await e(t, this.pageSize);
|
|
591
723
|
} catch (e) {
|
|
592
|
-
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(
|
|
724
|
+
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Fn, Pn * 2 ** (this.failures - 1)), this.emit({
|
|
593
725
|
state: "error",
|
|
594
726
|
count: 0,
|
|
595
727
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -622,10 +754,10 @@ var un = class {
|
|
|
622
754
|
};
|
|
623
755
|
//#endregion
|
|
624
756
|
//#region src/ThemeManager.ts
|
|
625
|
-
function
|
|
757
|
+
function Rn(e, t) {
|
|
626
758
|
return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
|
|
627
759
|
}
|
|
628
|
-
var
|
|
760
|
+
var zn = class t {
|
|
629
761
|
base;
|
|
630
762
|
shape = null;
|
|
631
763
|
font = null;
|
|
@@ -644,13 +776,13 @@ var gn = class t {
|
|
|
644
776
|
return i;
|
|
645
777
|
}
|
|
646
778
|
getTheme() {
|
|
647
|
-
return this.effective ??=
|
|
779
|
+
return this.effective ??= se(this.base, this.chartType, this.merged()), this.effective;
|
|
648
780
|
}
|
|
649
781
|
getBaseTheme() {
|
|
650
782
|
return this.base;
|
|
651
783
|
}
|
|
652
784
|
setTheme(e) {
|
|
653
|
-
let n = t.read(e), r = this.font !== null &&
|
|
785
|
+
let n = t.read(e), r = this.font !== null && Rn(n.font, this.base.font);
|
|
654
786
|
this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
|
|
655
787
|
...this.base,
|
|
656
788
|
shape: {
|
|
@@ -715,7 +847,7 @@ var gn = class t {
|
|
|
715
847
|
return JSON.stringify(e) === JSON.stringify(this.getUserOverrides()) ? !1 : (this.user = new Map(Object.entries(e).map(([e, t]) => [e, { ...t }])), this.effective = null, !0);
|
|
716
848
|
}
|
|
717
849
|
getStyleValue(e) {
|
|
718
|
-
return
|
|
850
|
+
return f(this.base, this.merged(), e, this.chartType);
|
|
719
851
|
}
|
|
720
852
|
layer(e) {
|
|
721
853
|
return e === "host" ? this.host : this.user.get(this.base.name) ?? {};
|
|
@@ -732,7 +864,7 @@ var gn = class t {
|
|
|
732
864
|
};
|
|
733
865
|
//#endregion
|
|
734
866
|
//#region src/style/styleOptions.ts
|
|
735
|
-
function
|
|
867
|
+
function Bn(e, t) {
|
|
736
868
|
return t ? {
|
|
737
869
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
738
870
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -740,22 +872,22 @@ function _n(e, t) {
|
|
|
740
872
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
741
873
|
} : {};
|
|
742
874
|
}
|
|
743
|
-
function
|
|
875
|
+
function Vn(e) {
|
|
744
876
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
745
877
|
return {
|
|
746
878
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
747
879
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
748
880
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
749
881
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
750
|
-
...
|
|
751
|
-
...
|
|
882
|
+
...Bn("horizontal", n?.hLine),
|
|
883
|
+
...Bn("vertical", n?.vLine),
|
|
752
884
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
753
885
|
...e.overrides
|
|
754
886
|
};
|
|
755
887
|
}
|
|
756
888
|
//#endregion
|
|
757
889
|
//#region src/layout/LayoutManager.ts
|
|
758
|
-
var
|
|
890
|
+
var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom", Wn = class {
|
|
759
891
|
panels = [];
|
|
760
892
|
containerWidth = 0;
|
|
761
893
|
containerHeight = 0;
|
|
@@ -771,8 +903,8 @@ var yn = 200, bn = 80, U = (e) => e.position === "top" || e.position === "bottom
|
|
|
771
903
|
this.panels.push({
|
|
772
904
|
id: e,
|
|
773
905
|
position: n,
|
|
774
|
-
size: r ?? (a ?
|
|
775
|
-
minSize: a ?
|
|
906
|
+
size: r ?? (a ? Hn : t),
|
|
907
|
+
minSize: a ? Un : i,
|
|
776
908
|
content: {
|
|
777
909
|
type: "indicator",
|
|
778
910
|
indicatorInstanceId: e
|
|
@@ -841,7 +973,7 @@ var yn = 200, bn = 80, U = (e) => e.position === "top" || e.position === "bottom
|
|
|
841
973
|
let r = this.panels.find((t) => t.id === e);
|
|
842
974
|
if (r) {
|
|
843
975
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
844
|
-
r.position = n, a !== o && (r.size = o ?
|
|
976
|
+
r.position = n, a !== o && (r.size = o ? Hn : t, r.minSize = o ? Un : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
845
977
|
}
|
|
846
978
|
}
|
|
847
979
|
setPanelSize(e, t) {
|
|
@@ -957,26 +1089,26 @@ var yn = 200, bn = 80, U = (e) => e.position === "top" || e.position === "bottom
|
|
|
957
1089
|
getMainChartRect() {
|
|
958
1090
|
return this.resolve().mainChartRect;
|
|
959
1091
|
}
|
|
960
|
-
},
|
|
961
|
-
function
|
|
1092
|
+
}, Gn = 14, Kn = 14, qn = 22, Jn = 4;
|
|
1093
|
+
function Yn(e) {
|
|
962
1094
|
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: a, fontSizeSmall: s, measure: l } = e, u = e.tagPrecision ?? c(t, n), d = u, f = r === null ? [t, n] : [
|
|
963
1095
|
t,
|
|
964
1096
|
n,
|
|
965
1097
|
r
|
|
966
|
-
],
|
|
1098
|
+
], p = o;
|
|
967
1099
|
for (let t of f) {
|
|
968
1100
|
if (!Number.isFinite(t)) continue;
|
|
969
|
-
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) :
|
|
970
|
-
|
|
1101
|
+
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : h(t, u, i), r = e.format ? n : h(t, d, i);
|
|
1102
|
+
p = Math.max(p, l(n, `500 ${s}px ${a}`) + Gn, l(r, `bold 11px ${a}`) + Kn, l(r, `600 ${s}px ${a}`) + qn);
|
|
971
1103
|
}
|
|
972
|
-
return
|
|
1104
|
+
return p <= o ? o : Math.ceil(p / Jn) * Jn;
|
|
973
1105
|
}
|
|
974
|
-
function
|
|
1106
|
+
function Xn(e, t) {
|
|
975
1107
|
return t > e || t <= e - 12 ? t : e;
|
|
976
1108
|
}
|
|
977
1109
|
//#endregion
|
|
978
1110
|
//#region src/layout/labelWidths.ts
|
|
979
|
-
var
|
|
1111
|
+
var Zn = 512, Qn = class {
|
|
980
1112
|
widths = /* @__PURE__ */ new Map();
|
|
981
1113
|
fonts;
|
|
982
1114
|
forget = () => this.widths.clear();
|
|
@@ -987,12 +1119,12 @@ var On = 512, kn = class {
|
|
|
987
1119
|
let r = `${t}\n${e}`, i = this.widths.get(r);
|
|
988
1120
|
if (i !== void 0) return i;
|
|
989
1121
|
let a = n();
|
|
990
|
-
return this.widths.size >=
|
|
1122
|
+
return this.widths.size >= Zn && this.widths.clear(), this.widths.set(r, a), a;
|
|
991
1123
|
}
|
|
992
1124
|
destroy() {
|
|
993
1125
|
this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
|
|
994
1126
|
}
|
|
995
|
-
},
|
|
1127
|
+
}, $n = class {
|
|
996
1128
|
netY = 0;
|
|
997
1129
|
travelX = 0;
|
|
998
1130
|
engaged = !1;
|
|
@@ -1008,11 +1140,11 @@ var On = 512, kn = class {
|
|
|
1008
1140
|
}
|
|
1009
1141
|
return this.engaged;
|
|
1010
1142
|
}
|
|
1011
|
-
},
|
|
1012
|
-
function
|
|
1143
|
+
}, er = 1;
|
|
1144
|
+
function tr(e, t) {
|
|
1013
1145
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
1014
1146
|
}
|
|
1015
|
-
function
|
|
1147
|
+
function W(e) {
|
|
1016
1148
|
switch (e.kind) {
|
|
1017
1149
|
case "indicator": return `indicator:${e.plugin.descriptor.id}`;
|
|
1018
1150
|
case "drawing": return `drawing:${e.plugin.descriptor.type}`;
|
|
@@ -1022,25 +1154,25 @@ function G(e) {
|
|
|
1022
1154
|
}
|
|
1023
1155
|
//#endregion
|
|
1024
1156
|
//#region src/plugins/registry.ts
|
|
1025
|
-
var
|
|
1026
|
-
function
|
|
1027
|
-
|
|
1157
|
+
var G = /* @__PURE__ */ new Map();
|
|
1158
|
+
function nr(e) {
|
|
1159
|
+
G.set(W(e), e);
|
|
1028
1160
|
}
|
|
1029
|
-
function
|
|
1030
|
-
return
|
|
1161
|
+
function rr(e) {
|
|
1162
|
+
return G.delete(e);
|
|
1031
1163
|
}
|
|
1032
|
-
function
|
|
1033
|
-
return [...
|
|
1164
|
+
function ir() {
|
|
1165
|
+
return [...G.values()];
|
|
1034
1166
|
}
|
|
1035
|
-
function
|
|
1036
|
-
|
|
1167
|
+
function ar() {
|
|
1168
|
+
G.clear();
|
|
1037
1169
|
}
|
|
1038
1170
|
//#endregion
|
|
1039
1171
|
//#region src/plugins/PluginManager.ts
|
|
1040
|
-
var
|
|
1172
|
+
var or = class {
|
|
1041
1173
|
plugins = /* @__PURE__ */ new Map();
|
|
1042
1174
|
constructor(e, t = {}) {
|
|
1043
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
1175
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of ir()) this.add(e);
|
|
1044
1176
|
for (let e of t.plugins ?? []) this.add(e);
|
|
1045
1177
|
}
|
|
1046
1178
|
register(e) {
|
|
@@ -1068,17 +1200,17 @@ var In = class {
|
|
|
1068
1200
|
return e;
|
|
1069
1201
|
}
|
|
1070
1202
|
add(e) {
|
|
1071
|
-
this.plugins.set(
|
|
1203
|
+
this.plugins.set(W(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
1072
1204
|
}
|
|
1073
|
-
},
|
|
1205
|
+
}, sr = {
|
|
1074
1206
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
1075
1207
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
1076
1208
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
1077
1209
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
1078
1210
|
positionClose: (e, t) => e.closePosition(t),
|
|
1079
|
-
positionReverse: (e, t, n) =>
|
|
1211
|
+
positionReverse: (e, t, n) => cr(e, t, n)
|
|
1080
1212
|
};
|
|
1081
|
-
async function
|
|
1213
|
+
async function cr(e, t, n) {
|
|
1082
1214
|
let { reversing: r } = n;
|
|
1083
1215
|
if (!r.has(t.positionId)) {
|
|
1084
1216
|
r.add(t.positionId);
|
|
@@ -1107,7 +1239,7 @@ async function Rn(e, t, n) {
|
|
|
1107
1239
|
}
|
|
1108
1240
|
}
|
|
1109
1241
|
}
|
|
1110
|
-
function
|
|
1242
|
+
function lr(e, t) {
|
|
1111
1243
|
let n = [], r = null, i = {
|
|
1112
1244
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
1113
1245
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -1117,8 +1249,8 @@ function zn(e, t) {
|
|
|
1117
1249
|
e.data && t.onFill?.(e.data);
|
|
1118
1250
|
};
|
|
1119
1251
|
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));
|
|
1120
|
-
for (let r of Object.keys(
|
|
1121
|
-
let a =
|
|
1252
|
+
for (let r of Object.keys(sr)) {
|
|
1253
|
+
let a = sr[r], o = t.onIntent(r, (n) => {
|
|
1122
1254
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
1123
1255
|
message: `Execution command failed: ${r}`,
|
|
1124
1256
|
cause: e
|
|
@@ -1131,16 +1263,231 @@ function zn(e, t) {
|
|
|
1131
1263
|
};
|
|
1132
1264
|
}
|
|
1133
1265
|
//#endregion
|
|
1266
|
+
//#region src/replay/ReplayStepLoader.ts
|
|
1267
|
+
var ur = 1e3, dr = class {
|
|
1268
|
+
pieces = /* @__PURE__ */ new Map();
|
|
1269
|
+
asked = /* @__PURE__ */ new Set();
|
|
1270
|
+
inFlight = !1;
|
|
1271
|
+
lastAsk = -Infinity;
|
|
1272
|
+
done = !1;
|
|
1273
|
+
now;
|
|
1274
|
+
constructor(e) {
|
|
1275
|
+
this.options = e, this.now = e.now ?? (() => Date.now());
|
|
1276
|
+
}
|
|
1277
|
+
piecesOf(e) {
|
|
1278
|
+
return this.pieces.get(e);
|
|
1279
|
+
}
|
|
1280
|
+
ensure(e, t, n) {
|
|
1281
|
+
if (this.done || this.inFlight) return;
|
|
1282
|
+
if (!this.options.source) {
|
|
1283
|
+
this.finish("end", 0);
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
let r = Math.min(e.length, t + Math.max(1, n)), i = t;
|
|
1287
|
+
for (; i < r && this.asked.has(e[i].time);) i++;
|
|
1288
|
+
if (i >= r) return;
|
|
1289
|
+
let a = this.now();
|
|
1290
|
+
a - this.lastAsk < 500 || (this.lastAsk = a, this.ask(e, i));
|
|
1291
|
+
}
|
|
1292
|
+
evictBefore(e) {
|
|
1293
|
+
for (let t of this.pieces.keys()) t < e && this.pieces.delete(t);
|
|
1294
|
+
for (let t of this.asked) t < e && this.asked.delete(t);
|
|
1295
|
+
}
|
|
1296
|
+
dispose() {
|
|
1297
|
+
this.done = !0;
|
|
1298
|
+
}
|
|
1299
|
+
ask(e, t) {
|
|
1300
|
+
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(ur / n)), s = Math.min(e.length, t + o), c = s < e.length ? e[s].time : e[e.length - 1].time + r, l = e.slice(t, s);
|
|
1301
|
+
for (let e of l) this.asked.add(e.time);
|
|
1302
|
+
this.inFlight = !0, a({
|
|
1303
|
+
state: "loading",
|
|
1304
|
+
step: i,
|
|
1305
|
+
count: 0
|
|
1306
|
+
}), this.options.source(c, l.length * n).then((e) => this.take(l, c, e), (e) => {
|
|
1307
|
+
this.done || (this.inFlight = !1, this.finish("error", 0, e instanceof Error ? e.message : String(e)));
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
take(e, t, n) {
|
|
1311
|
+
if (this.done) return;
|
|
1312
|
+
if (this.inFlight = !1, n.length === 0) {
|
|
1313
|
+
this.options.report({
|
|
1314
|
+
state: "end",
|
|
1315
|
+
step: this.options.step,
|
|
1316
|
+
count: 0
|
|
1317
|
+
});
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
let r = n.reduce((e, t) => Math.min(e, t.time), Infinity), i = this.options.keep([...n].sort((e, t) => e.time - t.time)), a = 0, o = 0;
|
|
1321
|
+
e.forEach((n, s) => {
|
|
1322
|
+
let c = s + 1 < e.length ? e[s + 1].time : t;
|
|
1323
|
+
for (; o < i.length && i[o].time < n.time;) o++;
|
|
1324
|
+
let l = o;
|
|
1325
|
+
for (; o < i.length && i[o].time < c;) o++;
|
|
1326
|
+
o > l && r <= n.time && (this.pieces.set(n.time, i.slice(l, o)), a += o - l);
|
|
1327
|
+
}), this.options.report({
|
|
1328
|
+
state: "loaded",
|
|
1329
|
+
step: this.options.step,
|
|
1330
|
+
count: a
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
finish(e, t, n) {
|
|
1334
|
+
this.done = !0, this.options.report({
|
|
1335
|
+
state: e,
|
|
1336
|
+
step: this.options.step,
|
|
1337
|
+
count: t,
|
|
1338
|
+
...n === void 0 ? {} : { error: n }
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
}, fr = 1 / 3, pr = .25, mr = .5;
|
|
1342
|
+
function hr(e, t) {
|
|
1343
|
+
let n = (e.high - e.low) * pr;
|
|
1344
|
+
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * mr;
|
|
1345
|
+
}
|
|
1346
|
+
function gr(e) {
|
|
1347
|
+
return e.close >= e.open ? [
|
|
1348
|
+
e.open,
|
|
1349
|
+
e.low,
|
|
1350
|
+
e.high,
|
|
1351
|
+
e.close
|
|
1352
|
+
] : [
|
|
1353
|
+
e.open,
|
|
1354
|
+
e.high,
|
|
1355
|
+
e.low,
|
|
1356
|
+
e.close
|
|
1357
|
+
];
|
|
1358
|
+
}
|
|
1359
|
+
function _r(e, t, n) {
|
|
1360
|
+
let r = gr(e), i = [
|
|
1361
|
+
1,
|
|
1362
|
+
2,
|
|
1363
|
+
3
|
|
1364
|
+
].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
|
|
1365
|
+
return r.forEach((r, c) => {
|
|
1366
|
+
c > 0 && (s += a > 0 ? i[c - 1] / a : fr), !(c === 0 && t > 0) && o.push({
|
|
1367
|
+
price: r,
|
|
1368
|
+
time: e.time,
|
|
1369
|
+
at: (t + s) / n
|
|
1370
|
+
});
|
|
1371
|
+
}), o;
|
|
1372
|
+
}
|
|
1373
|
+
function vr(e, t = []) {
|
|
1374
|
+
let n = t.length > 0 && hr(e, t) ? t : [e], r = n.length, i = yr(n.flatMap((e, t) => _r(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
|
|
1375
|
+
return {
|
|
1376
|
+
bar: e,
|
|
1377
|
+
points: i,
|
|
1378
|
+
volumeAt: n.map((t, n) => (o += a > 0 ? (t.volume ?? 0) / a * (e.volume ?? 0) : (e.volume ?? 0) / r, {
|
|
1379
|
+
at: (n + 1) / r,
|
|
1380
|
+
volume: o
|
|
1381
|
+
}))
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
function yr(e, t) {
|
|
1385
|
+
let n = e.length - 1, r = e.map((e, r) => ({
|
|
1386
|
+
...e,
|
|
1387
|
+
price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
|
|
1388
|
+
})), i = (e, t) => {
|
|
1389
|
+
if (r[0].price === e || r[n].price === e || n < 2) return;
|
|
1390
|
+
let i = 1;
|
|
1391
|
+
for (let e = 2; e < n; e++) t(r[e].price, r[i].price) && (i = e);
|
|
1392
|
+
r[i] = {
|
|
1393
|
+
...r[i],
|
|
1394
|
+
price: e
|
|
1395
|
+
};
|
|
1396
|
+
};
|
|
1397
|
+
return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
|
|
1398
|
+
}
|
|
1399
|
+
function br(e, t) {
|
|
1400
|
+
let n = e.points;
|
|
1401
|
+
if (t <= n[0].at) return n[0].price;
|
|
1402
|
+
for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
|
|
1403
|
+
let r = n[e].at - n[e - 1].at;
|
|
1404
|
+
return r > 0 ? n[e - 1].price + (n[e].price - n[e - 1].price) * (t - n[e - 1].at) / r : n[e].price;
|
|
1405
|
+
}
|
|
1406
|
+
return n[n.length - 1].price;
|
|
1407
|
+
}
|
|
1408
|
+
var xr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
|
|
1409
|
+
function Sr(e, t) {
|
|
1410
|
+
let n = 0, r = 0;
|
|
1411
|
+
for (let i of e.volumeAt) {
|
|
1412
|
+
if (t >= i.at) {
|
|
1413
|
+
n = i.volume, r = i.at;
|
|
1414
|
+
continue;
|
|
1415
|
+
}
|
|
1416
|
+
return n + (i.volume - n) * (t - r) / (i.at - r);
|
|
1417
|
+
}
|
|
1418
|
+
return n;
|
|
1419
|
+
}
|
|
1420
|
+
function Cr(e, t) {
|
|
1421
|
+
let n = xr(t);
|
|
1422
|
+
if (n >= 1) return { ...e.bar };
|
|
1423
|
+
let r = br(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
|
|
1424
|
+
for (let t of e.points) {
|
|
1425
|
+
if (t.at > n) break;
|
|
1426
|
+
i = Math.max(i, t.price), a = Math.min(a, t.price);
|
|
1427
|
+
}
|
|
1428
|
+
return {
|
|
1429
|
+
time: e.bar.time,
|
|
1430
|
+
open: e.points[0].price,
|
|
1431
|
+
high: i,
|
|
1432
|
+
low: a,
|
|
1433
|
+
close: r,
|
|
1434
|
+
volume: Sr(e, n)
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
function wr(e, t) {
|
|
1438
|
+
let n = xr(t), r = 0;
|
|
1439
|
+
for (let t of e.points) {
|
|
1440
|
+
if (t.at > n) break;
|
|
1441
|
+
r = t.at;
|
|
1442
|
+
}
|
|
1443
|
+
return r;
|
|
1444
|
+
}
|
|
1445
|
+
function K(e, t, n) {
|
|
1446
|
+
let r = [], i = e.bar.time;
|
|
1447
|
+
for (let a of e.points) {
|
|
1448
|
+
if (a.at > n) break;
|
|
1449
|
+
i = a.time, a.at > t && r.push([a.price, a.time]);
|
|
1450
|
+
}
|
|
1451
|
+
let a = br(e, n);
|
|
1452
|
+
return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
|
|
1453
|
+
}
|
|
1454
|
+
//#endregion
|
|
1455
|
+
//#region src/replay/replayStep.ts
|
|
1456
|
+
var Tr = [
|
|
1457
|
+
"1m",
|
|
1458
|
+
"3m",
|
|
1459
|
+
"5m",
|
|
1460
|
+
"15m",
|
|
1461
|
+
"30m",
|
|
1462
|
+
"1h",
|
|
1463
|
+
"2h",
|
|
1464
|
+
"4h",
|
|
1465
|
+
"1d"
|
|
1466
|
+
];
|
|
1467
|
+
function Er(e, t) {
|
|
1468
|
+
let n = w(e);
|
|
1469
|
+
return n > 0 ? Tr.filter((e) => {
|
|
1470
|
+
let r = w(e);
|
|
1471
|
+
return r < n && n % r === 0 && t(e);
|
|
1472
|
+
}) : [];
|
|
1473
|
+
}
|
|
1474
|
+
function Dr(e, t, n) {
|
|
1475
|
+
let r = Er(t, n);
|
|
1476
|
+
if (e !== "auto") return r.includes(e) ? e : null;
|
|
1477
|
+
let i = w(t);
|
|
1478
|
+
return r.find((e) => i / w(e) <= 60) ?? null;
|
|
1479
|
+
}
|
|
1480
|
+
//#endregion
|
|
1134
1481
|
//#region src/Chart.ts
|
|
1135
|
-
var
|
|
1482
|
+
var Or = {
|
|
1136
1483
|
min: 0,
|
|
1137
1484
|
max: 100
|
|
1138
|
-
},
|
|
1139
|
-
function
|
|
1140
|
-
if (typeof e == "string" && e !== "exchange" && !
|
|
1485
|
+
}, kr = "exchange", Ar = kr;
|
|
1486
|
+
function jr(e) {
|
|
1487
|
+
if (typeof e == "string" && e !== "exchange" && !v(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
1141
1488
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
1142
1489
|
}
|
|
1143
|
-
function
|
|
1490
|
+
function Mr(e, t) {
|
|
1144
1491
|
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
|
|
1145
1492
|
return i === void 0 ? e : {
|
|
1146
1493
|
...e,
|
|
@@ -1148,11 +1495,11 @@ function Wn(e, t) {
|
|
|
1148
1495
|
timezone: i
|
|
1149
1496
|
};
|
|
1150
1497
|
}
|
|
1151
|
-
var
|
|
1152
|
-
static version = "1.
|
|
1498
|
+
var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontalLine", "crossLine"]), zr = new Set(["verticalLine", "crossLine"]), Br = class {
|
|
1499
|
+
static version = "1.53.0";
|
|
1153
1500
|
engine;
|
|
1154
1501
|
viewport;
|
|
1155
|
-
series = new
|
|
1502
|
+
series = new Mn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
|
|
1156
1503
|
themeManager;
|
|
1157
1504
|
layoutManager;
|
|
1158
1505
|
pluginManager;
|
|
@@ -1167,6 +1514,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1167
1514
|
execTeardown = null;
|
|
1168
1515
|
autoScrollOnNewBar = !0;
|
|
1169
1516
|
displayDataCache = null;
|
|
1517
|
+
reshapeMemo = new ot();
|
|
1518
|
+
displayDataStep;
|
|
1170
1519
|
indicatorUpdateFrom = null;
|
|
1171
1520
|
resolvedLayoutCache = null;
|
|
1172
1521
|
panelInfoCache = null;
|
|
@@ -1176,7 +1525,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1176
1525
|
renderDeferred = !1;
|
|
1177
1526
|
priceAxisWidth = o;
|
|
1178
1527
|
measureCtx;
|
|
1179
|
-
labelWidths = new
|
|
1528
|
+
labelWidths = new Qn();
|
|
1180
1529
|
containerSizeCache = null;
|
|
1181
1530
|
containerSizeCacheTime = 0;
|
|
1182
1531
|
lastEmittedRange = null;
|
|
@@ -1190,14 +1539,18 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1190
1539
|
indicatorEdit = null;
|
|
1191
1540
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
1192
1541
|
zoomAreaMode = !1;
|
|
1193
|
-
priceAxisAddButton = new
|
|
1542
|
+
priceAxisAddButton = new et();
|
|
1194
1543
|
displayTz = null;
|
|
1195
1544
|
timeZoneSetting = null;
|
|
1196
1545
|
symbolInfo = null;
|
|
1197
1546
|
symbolInfoSeq = 0;
|
|
1547
|
+
studyZoneHeld = !1;
|
|
1548
|
+
studyZone = null;
|
|
1549
|
+
studyZoneTimer = null;
|
|
1550
|
+
studyZoneReleaseQueued = !1;
|
|
1198
1551
|
sessionBreaks;
|
|
1199
1552
|
sessionShading;
|
|
1200
|
-
hostSessionHours = { ...
|
|
1553
|
+
hostSessionHours = { ...ke };
|
|
1201
1554
|
compareRenderer;
|
|
1202
1555
|
countdownInterval = null;
|
|
1203
1556
|
pausedFor = {
|
|
@@ -1216,17 +1569,22 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1216
1569
|
signalMarkerManager;
|
|
1217
1570
|
tradeZoneManager;
|
|
1218
1571
|
measureOverlay;
|
|
1219
|
-
selectionBoxOverlay = new
|
|
1572
|
+
selectionBoxOverlay = new ct();
|
|
1220
1573
|
replayManager;
|
|
1221
1574
|
replayBarUnsub = null;
|
|
1222
1575
|
replaySeeking = !1;
|
|
1223
1576
|
replaySession = null;
|
|
1577
|
+
replayCause = null;
|
|
1224
1578
|
replayStepsSeries = null;
|
|
1225
1579
|
replayCoarse = null;
|
|
1226
1580
|
replayRevealMarks = !0;
|
|
1227
1581
|
replayOffset = 0;
|
|
1582
|
+
replayPieces = null;
|
|
1583
|
+
replayLoader = null;
|
|
1584
|
+
replayForming = null;
|
|
1585
|
+
replayPhaseUnsub = null;
|
|
1228
1586
|
undoRedoManager;
|
|
1229
|
-
autoSaveScheduler = new
|
|
1587
|
+
autoSaveScheduler = new Tn((e) => this.saveState(e));
|
|
1230
1588
|
animator;
|
|
1231
1589
|
crosshairTooltip;
|
|
1232
1590
|
pinnedTooltip;
|
|
@@ -1238,14 +1596,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1238
1596
|
disposed = !1;
|
|
1239
1597
|
chartTypeOptions = {};
|
|
1240
1598
|
mainSeriesVisible = !0;
|
|
1241
|
-
priceLines = new
|
|
1242
|
-
symbolSeries = new
|
|
1599
|
+
priceLines = new tt();
|
|
1600
|
+
symbolSeries = new ht();
|
|
1243
1601
|
extendedHours = !0;
|
|
1244
1602
|
replayRestarting = !1;
|
|
1245
1603
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
1246
1604
|
gridRenderer;
|
|
1247
1605
|
priceAxis;
|
|
1248
|
-
leftPriceAxis = new
|
|
1606
|
+
leftPriceAxis = new $e();
|
|
1249
1607
|
leftScaleRequested = !1;
|
|
1250
1608
|
leftAxisWidth = o;
|
|
1251
1609
|
leftViewport = null;
|
|
@@ -1261,6 +1619,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1261
1619
|
priceUnit = null;
|
|
1262
1620
|
paneTitles = !0;
|
|
1263
1621
|
defaultAutoScale;
|
|
1622
|
+
priceFitPending = !0;
|
|
1623
|
+
seriesArriving = !0;
|
|
1264
1624
|
keyboardHandler = null;
|
|
1265
1625
|
a11y = null;
|
|
1266
1626
|
onWindowKeyDown = null;
|
|
@@ -1276,7 +1636,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1276
1636
|
snapshotKey = null;
|
|
1277
1637
|
historyCheckQueued = !1;
|
|
1278
1638
|
constructor(e, t) {
|
|
1279
|
-
t.timeZone != null &&
|
|
1639
|
+
t.timeZone != null && jr(t.timeZone), this.container = e, this.options = {
|
|
1280
1640
|
...t,
|
|
1281
1641
|
chartType: t.chartType ?? "candlestick"
|
|
1282
1642
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1314,15 +1674,15 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1314
1674
|
logScale: n.logScale ?? !0,
|
|
1315
1675
|
timeframes: n.timeframes ?? [],
|
|
1316
1676
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1317
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new
|
|
1318
|
-
oldestTime: () => this.series.bars()[0]?.time ?? null,
|
|
1677
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new Ln({
|
|
1678
|
+
oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
|
|
1319
1679
|
prepend: (e) => this.prependBars(e),
|
|
1320
1680
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1321
|
-
}), this.themeManager = new
|
|
1681
|
+
}), this.themeManager = new zn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Vn(t), "host", !1), this.layoutManager = new Wn(), this.indicatorEngine = new ze(), this.pluginManager = new or(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Pe(), zt(this.indicatorEngine), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.indicatorEngine.register(new ft(this.symbolSeries)), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.drawingManager = new je(), Rt(this.drawingManager), this.drawingRenderer = new Me(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
1322
1682
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1323
1683
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1324
1684
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1325
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1685
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new bt();
|
|
1326
1686
|
let i = "";
|
|
1327
1687
|
this.undoRedoManager.setOnChange(() => {
|
|
1328
1688
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1335,21 +1695,21 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1335
1695
|
primary: e[0] ?? null
|
|
1336
1696
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1337
1697
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
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
|
|
1698
|
+
}), this.drawingManager.setDataGetter(() => this.series.bars(), () => this.series.revision()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new vt({
|
|
1339
1699
|
enabled: this.features.trading,
|
|
1340
1700
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1341
|
-
}), this.tradingRenderer = new
|
|
1701
|
+
}), this.tradingRenderer = new yt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1342
1702
|
this.eventBus.emit(e, t);
|
|
1343
|
-
}), this.engine = new
|
|
1703
|
+
}), this.engine = new nt(e, t.maxPixelRatio);
|
|
1344
1704
|
let a = this.engine.dprManager.getContainerSize();
|
|
1345
|
-
if (this.viewport = new
|
|
1705
|
+
if (this.viewport = new xt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
|
|
1346
1706
|
freePan: t.freePan ?? !0,
|
|
1347
1707
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1348
1708
|
}), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1349
1709
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1350
1710
|
let t = this.viewport.isAtEnd();
|
|
1351
|
-
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
1352
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new
|
|
1711
|
+
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
|
|
1712
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Fe(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new $e(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new gt(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new Ee(), 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) => {
|
|
1353
1713
|
if (e !== null && t) {
|
|
1354
1714
|
let n = this.crosshairSeries(), r = e >= 0 && e < n.length ? n[e] : void 0;
|
|
1355
1715
|
this.chartLegend.setHoverBar(r ?? null, e > 0 ? n[e - 1] ?? null : null);
|
|
@@ -1358,20 +1718,20 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1358
1718
|
prevClose: e > 0 ? n[e - 1]?.close : void 0,
|
|
1359
1719
|
priceRange: i.priceRange,
|
|
1360
1720
|
plot: i.chartRect,
|
|
1361
|
-
barStepMs:
|
|
1362
|
-
timeUnit:
|
|
1721
|
+
barStepMs: Dt(n),
|
|
1722
|
+
timeUnit: u(n)
|
|
1363
1723
|
}) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
1364
1724
|
point: t,
|
|
1365
1725
|
bar: r,
|
|
1366
1726
|
barIndex: e
|
|
1367
1727
|
});
|
|
1368
1728
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
|
|
1369
|
-
}), this.chartLegend = new
|
|
1729
|
+
}), this.chartLegend = new xe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new Tt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new wt(), this.volumeProfile = new Ct(), this.marketProfile = new Ge(), this.depthHeatmap = new Ae(), this.periodLevels = new Ye(), this.pivotMarkers = new Ze(), this.barCountdown = new _e(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new lt(), this.sessionShading = new ut(), this.compareRenderer = new Se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1370
1730
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1371
1731
|
color: t.sessionBreaks.color,
|
|
1372
1732
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1373
1733
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1374
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
1734
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new De(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Xe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = x(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Kr(t.shapes)), t.font && this.themeManager.setFont(Gr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new He({
|
|
1375
1735
|
scrollBars: (e) => {
|
|
1376
1736
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1377
1737
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1388,17 +1748,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1388
1748
|
},
|
|
1389
1749
|
fitContent: () => this.fitContent()
|
|
1390
1750
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1391
|
-
this.a11y = new
|
|
1751
|
+
this.a11y = new nn(e, {
|
|
1392
1752
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1393
1753
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1394
1754
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
1395
1755
|
bars: () => this.getDisplayData(),
|
|
1396
1756
|
visibleRange: () => this.viewport.getState().visibleRange,
|
|
1397
1757
|
formatPrice: (e) => this.formatPrice(e),
|
|
1398
|
-
formatTime: (e) =>
|
|
1399
|
-
dateStyle: "medium",
|
|
1400
|
-
timeStyle: "short"
|
|
1401
|
-
}, this.displayTz)(e * l(this.getDisplayData())),
|
|
1758
|
+
formatTime: (e) => this.spokenBarTime(e),
|
|
1402
1759
|
showBar: (e) => this.setCrosshairTime(e)
|
|
1403
1760
|
}, t.a11y?.labels);
|
|
1404
1761
|
for (let e of [
|
|
@@ -1418,7 +1775,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1418
1775
|
}
|
|
1419
1776
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1420
1777
|
}
|
|
1421
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
1778
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Oe(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new pe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(At).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
|
|
1422
1779
|
this.eventBus.emit("alertTriggered", q(e)), this.eventBus.emit("dataUpdate", {
|
|
1423
1780
|
kind: "alert",
|
|
1424
1781
|
alert: "triggered",
|
|
@@ -1434,7 +1791,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1434
1791
|
this.eventBus.emit("alertExpired", q(e));
|
|
1435
1792
|
}), this.alertManager.on("updated", (e) => {
|
|
1436
1793
|
this.eventBus.emit("alertUpdate", q(e));
|
|
1437
|
-
}), this.signalMarkerManager = new
|
|
1794
|
+
}), this.signalMarkerManager = new dt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
|
|
1438
1795
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1439
1796
|
id: e.id,
|
|
1440
1797
|
source: e.source,
|
|
@@ -1442,14 +1799,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1442
1799
|
});
|
|
1443
1800
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1444
1801
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1445
|
-
}), this.tradeZoneManager = new
|
|
1802
|
+
}), this.tradeZoneManager = new _t(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
|
|
1446
1803
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1447
1804
|
id: e.id,
|
|
1448
1805
|
direction: e.direction
|
|
1449
1806
|
});
|
|
1450
1807
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1451
1808
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1452
|
-
}), this.replayManager = new
|
|
1809
|
+
}), this.replayManager = new it(), this.replayManager.on("complete", () => {
|
|
1453
1810
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1454
1811
|
t && this.eventBus.emit("replayComplete", {
|
|
1455
1812
|
barIndex: e,
|
|
@@ -1457,10 +1814,10 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1457
1814
|
});
|
|
1458
1815
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1459
1816
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1460
|
-
}), this.measureOverlay = new
|
|
1461
|
-
let e = new
|
|
1462
|
-
this.interactionManager.setPanHandler(new
|
|
1463
|
-
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.
|
|
1817
|
+
}), this.measureOverlay = new Ke(), this.interactionManager = new Be(e), this.features.panning) {
|
|
1818
|
+
let e = new $n();
|
|
1819
|
+
this.interactionManager.setPanHandler(new qe((t, n) => {
|
|
1820
|
+
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1464
1821
|
}, () => e.reset()));
|
|
1465
1822
|
}
|
|
1466
1823
|
if (this.interactionManager.setAxisStrips(() => ({
|
|
@@ -1471,11 +1828,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1471
1828
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1472
1829
|
}
|
|
1473
1830
|
})), this.features.zooming) {
|
|
1474
|
-
this.interactionManager.setZoomHandler(new
|
|
1831
|
+
this.interactionManager.setZoomHandler(new Et((e, t) => {
|
|
1475
1832
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1476
1833
|
}));
|
|
1477
|
-
let e = new
|
|
1478
|
-
this.
|
|
1834
|
+
let e = new ge((e) => {
|
|
1835
|
+
this.holdPriceScale(), this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1479
1836
|
}, (e) => {
|
|
1480
1837
|
let t = this.viewport.getState().chartRect.width;
|
|
1481
1838
|
this.viewport.zoom(1 / e - 1, t / 2), this.updateViewportAndRender();
|
|
@@ -1494,7 +1851,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1494
1851
|
y: t.y
|
|
1495
1852
|
});
|
|
1496
1853
|
})), 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) => {
|
|
1497
|
-
let t =
|
|
1854
|
+
let t = Jt(e.y, this.viewport.getState());
|
|
1498
1855
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1499
1856
|
price: t,
|
|
1500
1857
|
x: e.x,
|
|
@@ -1504,15 +1861,15 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1504
1861
|
...this.viewport.getState(),
|
|
1505
1862
|
data: this.getDisplayData()
|
|
1506
1863
|
})), this.features.alerts) {
|
|
1507
|
-
let e = new
|
|
1864
|
+
let e = new fe(this.alertManager, () => this.viewport.getState());
|
|
1508
1865
|
this.interactionManager.setAlertDragHandler(e);
|
|
1509
1866
|
}
|
|
1510
|
-
let o = new
|
|
1867
|
+
let o = new Je();
|
|
1511
1868
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
1512
1869
|
let t = this.getDisplayData();
|
|
1513
1870
|
if (t.length === 0) return;
|
|
1514
1871
|
let n = this.viewport.getState(), i = n.barWidth + n.barSpacing, a = Math.round((n.offset + e.x) / i);
|
|
1515
|
-
a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme(),
|
|
1872
|
+
a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme(), u(t), d(t) === !0), this.pinnedTooltip.reposition(this.viewport.getState(), this.series.bars()[a] ?? null, a, this.themeManager.getTheme()), this.engine.requestRender(r.Overlay));
|
|
1516
1873
|
}), this.interactionManager.setSignalMarkerHitTest((e) => this.eventBus.hasListeners("signalMarkerHover") || this.eventBus.hasListeners("signalMarkerClick") ? this.signalMarkerManager.markerAt(e, this.viewport.getState()) : null, (e, t) => this.eventBus.emit("signalMarkerHover", {
|
|
1517
1874
|
marker: e,
|
|
1518
1875
|
x: t.x,
|
|
@@ -1531,7 +1888,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1531
1888
|
x: e.x,
|
|
1532
1889
|
y: e.y
|
|
1533
1890
|
}), t.length === 0) return;
|
|
1534
|
-
let r =
|
|
1891
|
+
let r = qt(e.x, this.viewport.getState());
|
|
1535
1892
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1536
1893
|
bar: t[r],
|
|
1537
1894
|
barIndex: r,
|
|
@@ -1574,7 +1931,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1574
1931
|
end: () => {
|
|
1575
1932
|
let e = this.selectionBoxOverlay.end();
|
|
1576
1933
|
if (e && this.zoomAreaMode) {
|
|
1577
|
-
if (e.x1 - e.x0 <
|
|
1934
|
+
if (e.x1 - e.x0 < Lr) return;
|
|
1578
1935
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1579
1936
|
return;
|
|
1580
1937
|
}
|
|
@@ -1605,17 +1962,28 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1605
1962
|
this.loadSeries(e, !1);
|
|
1606
1963
|
}
|
|
1607
1964
|
loadSeries(e, t) {
|
|
1608
|
-
this.
|
|
1609
|
-
|
|
1965
|
+
if (this.replaySession && !t && e.length > 0 && !this.replayEndsFor(this.currentSymbol)) {
|
|
1966
|
+
this.loadDuringReplay(e);
|
|
1967
|
+
return;
|
|
1968
|
+
}
|
|
1969
|
+
this.snapshotKey = null, this.endReplaySession(), this.history.reset(), this.series.load(e), this.crosshairHandler.setData(this.series.bars()), this.displayDataCache = null, this.reshapeMemo.clear(), this.sessionBreaks.invalidateCache(), this.options.autoScale = this.defaultAutoScale, this.priceFitPending = !0;
|
|
1970
|
+
let n = this.series.bars();
|
|
1971
|
+
this.seriesArriving = n.length === 0;
|
|
1972
|
+
let r = n[n.length - 1];
|
|
1610
1973
|
t || (this.alertManager.clearLastValues(), r && this.alertManager.seedLastValue("price", r.close)), this.recalcIndicators(n), r && this.currentPriceLine.setPrice(r.close), this.updateViewportAndRender(!0), this.emitBars(n.length);
|
|
1611
1974
|
}
|
|
1975
|
+
loadDuringReplay(e) {
|
|
1976
|
+
this.snapshotKey = null, this.history.reset(), this.alertManager.clearLastValues();
|
|
1977
|
+
let t = e[e.length - 1];
|
|
1978
|
+
t && L(t) && this.alertManager.seedLastValue("price", t.close), this.replaySession && (this.replaySession.price = null), this.series.load(e);
|
|
1979
|
+
}
|
|
1612
1980
|
prependBars(e) {
|
|
1613
|
-
if (this.replaySession) return
|
|
1981
|
+
if (this.replaySession) return this.series.prepend(e).taken;
|
|
1614
1982
|
let t = this.getDisplayData(), n = Math.max(0, Math.min(t.length - 1, Math.floor(this.viewport.getState().visibleRange.from))), r = t[n]?.time, { added: i, taken: a } = this.series.prepend(e);
|
|
1615
1983
|
if (i === 0) return a;
|
|
1616
1984
|
let o = this.series.bars();
|
|
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) {
|
|
1618
|
-
let e = Math.round(
|
|
1985
|
+
if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.reshapeMemo.clear(), this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), r !== void 0) {
|
|
1986
|
+
let e = Math.round(M(r, this.getDisplayData()));
|
|
1619
1987
|
this.viewport.prependBars(e - n);
|
|
1620
1988
|
}
|
|
1621
1989
|
return this.updateViewportAndRender(), a;
|
|
@@ -1627,13 +1995,13 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1627
1995
|
return;
|
|
1628
1996
|
}
|
|
1629
1997
|
let n = this.series.bars();
|
|
1630
|
-
this.crosshairHandler.setData(n), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.recalcIndicators(n), n.length > 0 && this.currentPriceLine.setPrice(n[n.length - 1].close), this.updateViewportAndRender(t), this.emitBars(n.length);
|
|
1998
|
+
this.crosshairHandler.setData(n), this.displayDataCache = null, this.reshapeMemo.clear(), this.sessionBreaks.invalidateCache(), this.recalcIndicators(n), n.length > 0 && this.currentPriceLine.setPrice(n[n.length - 1].close), this.updateViewportAndRender(t), this.emitBars(n.length);
|
|
1631
1999
|
}
|
|
1632
2000
|
setHistoryLoader(e, t) {
|
|
1633
2001
|
this.historyFromStream = !1, this.hostHistoryLoader = e !== null, this.history.setLoader(e, t?.pageSize), this.checkHistory();
|
|
1634
2002
|
}
|
|
1635
2003
|
loadMoreHistory() {
|
|
1636
|
-
return this.
|
|
2004
|
+
return this.replayPages() ? this.history.loadMore() : Promise.resolve(0);
|
|
1637
2005
|
}
|
|
1638
2006
|
hasMoreHistory() {
|
|
1639
2007
|
return this.history.hasLoader() && this.history.hasMore();
|
|
@@ -1643,35 +2011,35 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1643
2011
|
}
|
|
1644
2012
|
checkHistory() {
|
|
1645
2013
|
this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
|
|
1646
|
-
if (this.historyCheckQueued = !1, this.
|
|
2014
|
+
if (this.historyCheckQueued = !1, !this.replayPages() || !this.history.hasLoader() || I(this.options.chartType)) return;
|
|
1647
2015
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
1648
2016
|
if (t.width <= 0) return;
|
|
1649
2017
|
let { from: n, to: r } = e;
|
|
1650
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
2018
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Ir, r - n));
|
|
1651
2019
|
}));
|
|
1652
2020
|
}
|
|
1653
|
-
useStreamHistory(e, t) {
|
|
2021
|
+
useStreamHistory(e, t, n = !0) {
|
|
1654
2022
|
if (this.hostHistoryLoader) return;
|
|
1655
|
-
let
|
|
1656
|
-
if (!
|
|
2023
|
+
let r = N(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
|
|
2024
|
+
if (!i || a === null || ue(a) !== null) {
|
|
1657
2025
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
1658
2026
|
return;
|
|
1659
2027
|
}
|
|
1660
|
-
let
|
|
1661
|
-
this.history.setLoader((e, t) =>
|
|
2028
|
+
let o = this.currentSymbol;
|
|
2029
|
+
this.history.setLoader((e, t) => i.call(r, o, a, e, t), t), this.historyFromStream = !0, n && this.checkHistory();
|
|
1662
2030
|
}
|
|
1663
2031
|
appendBar(e) {
|
|
1664
|
-
if (!
|
|
2032
|
+
if (!L(e)) return;
|
|
1665
2033
|
let t = this.series.append(e);
|
|
1666
2034
|
if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
|
|
1667
2035
|
this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
|
|
1668
2036
|
return;
|
|
1669
2037
|
}
|
|
1670
2038
|
let n = this.autoScrollOnNewBar && this.viewport.isAtEnd(), r = t.before, i = this.series.bars();
|
|
1671
|
-
this.crosshairHandler.setData(i), this.displayDataCache = null, this.recalcIndicatorsFrom(i, i.length - 2), this.currentPriceLine.setPrice(e.close), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
|
|
2039
|
+
this.crosshairHandler.setData(i), this.displayDataCache = null, this.recalcIndicatorsFrom(i, i.length - 2), this.currentPriceLine.setPrice(e.close, i[i.length - 2]?.close), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
|
|
1672
2040
|
}
|
|
1673
2041
|
appendBars(e) {
|
|
1674
|
-
if (e = e.filter(
|
|
2042
|
+
if (e = e.filter(L), e.length === 0) return;
|
|
1675
2043
|
let t = e[e.length - 1].close, n = this.series.appendMany(e);
|
|
1676
2044
|
if (n.refiltered && (this.displayDataCache = null), n.shown === 0) {
|
|
1677
2045
|
this.takeLivePrice(t), n.aside || this.scheduleRender();
|
|
@@ -1680,10 +2048,10 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1680
2048
|
let r = this.autoScrollOnNewBar && this.viewport.isAtEnd(), i = n.before;
|
|
1681
2049
|
this.displayDataCache = null;
|
|
1682
2050
|
let a = this.series.bars();
|
|
1683
|
-
this.recalcIndicatorsFrom(a, i - 1), this.crosshairHandler.setData(a), this.currentPriceLine.setPrice(t), this.updateViewportAndRender(r), a.length !== i && this.emitBars(a.length), this.followLivePrice(t);
|
|
2051
|
+
this.recalcIndicatorsFrom(a, i - 1), this.crosshairHandler.setData(a), this.currentPriceLine.setPrice(t, a[a.length - 2]?.close), this.updateViewportAndRender(r), a.length !== i && this.emitBars(a.length), this.followLivePrice(t);
|
|
1684
2052
|
}
|
|
1685
2053
|
updateLastBar(e) {
|
|
1686
|
-
if (!
|
|
2054
|
+
if (!L(e)) return;
|
|
1687
2055
|
let t = this.series.updateLast(e);
|
|
1688
2056
|
if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
|
|
1689
2057
|
this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
|
|
@@ -1704,6 +2072,29 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1704
2072
|
let n = this.series.bars();
|
|
1705
2073
|
this.recalcIndicatorsFrom(n, n.length - 1), this.followLivePrice(e.price), this.scheduleRender();
|
|
1706
2074
|
}
|
|
2075
|
+
updateBar(e) {
|
|
2076
|
+
if (!L(e)) return !1;
|
|
2077
|
+
let t = this.series.replace(e);
|
|
2078
|
+
return t.to === "none" ? !1 : (t.to === "shown" && t.changed && this.showCorrection(t.index), !0);
|
|
2079
|
+
}
|
|
2080
|
+
showCorrection(e) {
|
|
2081
|
+
let t = this.series.bars(), n = t[e];
|
|
2082
|
+
this.displayDataCache = null, this.reshapeMemo.clear(), this.indicatorEngine.deferRecalculateFrom(t, e), this.announceIndicatorUpdate(e), e === t.length - 1 && (this.currentPriceLine.setPrice(n.close, t[e - 1]?.close), this.alertManager.seedLastValue("price", n.close)), this.refreshShownBar(e), this.eventBus.emit("dataUpdate", {
|
|
2083
|
+
kind: "correction",
|
|
2084
|
+
time: n.time,
|
|
2085
|
+
index: e
|
|
2086
|
+
}), this.scheduleRender();
|
|
2087
|
+
}
|
|
2088
|
+
refreshShownBar(e) {
|
|
2089
|
+
let t = this.pinnedTooltip.isPinned() ? this.pinnedTooltip.getPinnedIndex() : -1, n = this.crosshairHandler.getReportedBarIndex();
|
|
2090
|
+
if (t < e && n === null) return;
|
|
2091
|
+
let r = this.isTimeAligned();
|
|
2092
|
+
if (r && t >= e) {
|
|
2093
|
+
let e = this.getDisplayData();
|
|
2094
|
+
e[t] && this.pinnedTooltip.pin(e[t], t, this.themeManager.getTheme(), u(e), d(e) === !0);
|
|
2095
|
+
}
|
|
2096
|
+
n !== null && (!r || n === e || n === e + 1) && this.crosshairHandler.refresh();
|
|
2097
|
+
}
|
|
1707
2098
|
getChartType() {
|
|
1708
2099
|
return this.options.chartType ?? "candlestick";
|
|
1709
2100
|
}
|
|
@@ -1715,14 +2106,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1715
2106
|
});
|
|
1716
2107
|
}
|
|
1717
2108
|
applyTimeSpacing() {
|
|
1718
|
-
let e = !this.tickStream && !
|
|
2109
|
+
let e = !this.tickStream && !I(this.options.chartType);
|
|
1719
2110
|
this.timeAxis.setTimesPastData(e), this.crosshairHandler.setTimesPastData(e);
|
|
1720
2111
|
}
|
|
1721
2112
|
setChartTypeOptions(e) {
|
|
1722
2113
|
this.chartTypeOptions = {
|
|
1723
2114
|
...this.chartTypeOptions,
|
|
1724
2115
|
...x(e)
|
|
1725
|
-
}, this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged();
|
|
2116
|
+
}, this.displayDataCache = null, this.updateViewportAndRender(!0), this.a11y?.refresh(!0), this.markStateChanged();
|
|
1726
2117
|
}
|
|
1727
2118
|
getChartTypeOptions() {
|
|
1728
2119
|
return x(this.chartTypeOptions);
|
|
@@ -1734,18 +2125,18 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1734
2125
|
return this.extendedHours;
|
|
1735
2126
|
}
|
|
1736
2127
|
sessionKeep(e) {
|
|
1737
|
-
return this.extendedHours ? null :
|
|
2128
|
+
return this.extendedHours ? null : Zt(this.symbolInfo, e);
|
|
1738
2129
|
}
|
|
1739
2130
|
reapplyExtendedHours() {
|
|
1740
2131
|
if (!this.series.refilter()) return;
|
|
1741
2132
|
let e = this.series.bars();
|
|
1742
|
-
this.crosshairHandler.setData(e), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.recalcIndicators(e), this.updateViewportAndRender(!0), this.emitBars(e.length);
|
|
2133
|
+
this.crosshairHandler.setData(e), this.displayDataCache = null, this.reshapeMemo.clear(), this.sessionBreaks.invalidateCache(), this.recalcIndicators(e), this.updateViewportAndRender(!0), this.emitBars(e.length);
|
|
1743
2134
|
}
|
|
1744
2135
|
quoteLines() {
|
|
1745
2136
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
1746
2137
|
}
|
|
1747
2138
|
setShapes(e) {
|
|
1748
|
-
let t =
|
|
2139
|
+
let t = Kr(e);
|
|
1749
2140
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
1750
2141
|
...this.themeManager.getTheme().shape,
|
|
1751
2142
|
...t
|
|
@@ -1757,7 +2148,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1757
2148
|
setFont(e) {
|
|
1758
2149
|
if (e === null) this.themeManager.setFont(null);
|
|
1759
2150
|
else {
|
|
1760
|
-
let t =
|
|
2151
|
+
let t = Gr(e);
|
|
1761
2152
|
if (Object.keys(t).length === 0) return;
|
|
1762
2153
|
this.themeManager.setFont(t);
|
|
1763
2154
|
}
|
|
@@ -1835,14 +2226,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1835
2226
|
this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
|
|
1836
2227
|
}
|
|
1837
2228
|
updateIndicatorNow(e, t) {
|
|
1838
|
-
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ?
|
|
2229
|
+
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? j(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
|
|
1839
2230
|
this.indicatorEngine.updateIndicator(e, t, this.series.bars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
1840
2231
|
instanceId: e,
|
|
1841
2232
|
change: "params"
|
|
1842
2233
|
}), this.requestMissingSymbols(e);
|
|
1843
2234
|
let a = this.indicatorEngine.getIndicatorConfig(e);
|
|
1844
2235
|
if (n?.placement === "overlay" && a && r && a.params[r] !== i) {
|
|
1845
|
-
let t =
|
|
2236
|
+
let t = b(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : b(i) ? null : a.pane ?? null;
|
|
1846
2237
|
(n ?? void 0) !== a.pane && (this.indicatorEngine.setPane(e, n), this.eventBus.emit("indicatorChange", {
|
|
1847
2238
|
instanceId: e,
|
|
1848
2239
|
change: "pane"
|
|
@@ -1853,7 +2244,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1853
2244
|
paneFor(e, t, n, r) {
|
|
1854
2245
|
if (n) return this.paneHostOf(n, r);
|
|
1855
2246
|
if (e.placement !== "overlay") return null;
|
|
1856
|
-
let i =
|
|
2247
|
+
let i = j(e), a = i ? b(t[i]) : null;
|
|
1857
2248
|
return a ? this.paneHostOf(a.instanceId, r) : null;
|
|
1858
2249
|
}
|
|
1859
2250
|
paneHostOf(e, t) {
|
|
@@ -1880,6 +2271,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1880
2271
|
setLeftPriceScaleVisible(e) {
|
|
1881
2272
|
this.leftScaleRequested = e, this.updateViewportAndRender();
|
|
1882
2273
|
}
|
|
2274
|
+
isLeftPriceScaleVisible() {
|
|
2275
|
+
return this.leftScaleRequested;
|
|
2276
|
+
}
|
|
1883
2277
|
isLeftPriceScaleShown() {
|
|
1884
2278
|
return this.features.priceAxis !== !1 && (this.leftScaleRequested || this.indicatorEngine.hasLeftScaleOverlays());
|
|
1885
2279
|
}
|
|
@@ -1896,13 +2290,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1896
2290
|
return {
|
|
1897
2291
|
...e,
|
|
1898
2292
|
priceRange: {
|
|
1899
|
-
min: t.min - n *
|
|
1900
|
-
max: t.max + n *
|
|
2293
|
+
min: t.min - n * Nr,
|
|
2294
|
+
max: t.max + n * Nr
|
|
1901
2295
|
},
|
|
1902
2296
|
logScale: !1,
|
|
1903
2297
|
scaleMode: "regular",
|
|
1904
2298
|
invertScale: !1,
|
|
1905
2299
|
formatPrice: void 0,
|
|
2300
|
+
pricePrecision: void 0,
|
|
1906
2301
|
priceUnit: void 0
|
|
1907
2302
|
};
|
|
1908
2303
|
}
|
|
@@ -1949,7 +2344,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1949
2344
|
this.indicatorEngine.setStyleDefaults(e, null);
|
|
1950
2345
|
return;
|
|
1951
2346
|
}
|
|
1952
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2347
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
|
|
1953
2348
|
this.indicatorEngine.setStyleDefaults(e, {
|
|
1954
2349
|
...r,
|
|
1955
2350
|
...i ? { plots: i } : {}
|
|
@@ -1957,7 +2352,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1957
2352
|
}
|
|
1958
2353
|
setPaneStyle(e, t) {
|
|
1959
2354
|
let n = this.paneOf(e);
|
|
1960
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ?
|
|
2355
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? oe(t) : null));
|
|
1961
2356
|
}
|
|
1962
2357
|
setPaneStyleNow(e, t) {
|
|
1963
2358
|
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());
|
|
@@ -1976,8 +2371,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
1976
2371
|
return this.pluginManager;
|
|
1977
2372
|
}
|
|
1978
2373
|
static indicators() {
|
|
1979
|
-
let e = new
|
|
1980
|
-
return
|
|
2374
|
+
let e = new ze();
|
|
2375
|
+
return zt(e), e.getAvailableIndicators();
|
|
1981
2376
|
}
|
|
1982
2377
|
setPanelPosition(e, t) {
|
|
1983
2378
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -2000,8 +2395,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2000
2395
|
paneMoveHost(e, t) {
|
|
2001
2396
|
let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
|
|
2002
2397
|
if (!n || !r) return;
|
|
2003
|
-
let i =
|
|
2004
|
-
if (r.placement === "overlay" && i &&
|
|
2398
|
+
let i = j(r);
|
|
2399
|
+
if (r.placement === "overlay" && i && b(n.params[i])) return;
|
|
2005
2400
|
if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
|
|
2006
2401
|
if (t === "new") {
|
|
2007
2402
|
let t = this.layoutManager.getPanels().some((t) => t.id === e);
|
|
@@ -2099,6 +2494,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2099
2494
|
setIndicatorValueLabelsVisible(e) {
|
|
2100
2495
|
this.features.indicatorValueLabels = e, this.syncRenderContext(), this.engine.requestRender();
|
|
2101
2496
|
}
|
|
2497
|
+
isIndicatorValueLabelsVisible() {
|
|
2498
|
+
return this.features.indicatorValueLabels;
|
|
2499
|
+
}
|
|
2102
2500
|
setPaneTitlesVisible(e) {
|
|
2103
2501
|
this.paneTitles = e, this.engine.requestRender();
|
|
2104
2502
|
}
|
|
@@ -2107,12 +2505,12 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2107
2505
|
return this.features.legend ? e + this.chartLegend.getHeight() : e;
|
|
2108
2506
|
}
|
|
2109
2507
|
isTimeAligned() {
|
|
2110
|
-
return
|
|
2508
|
+
return I(this.options.chartType) ? !1 : this.getDisplayData().length === this.series.length();
|
|
2111
2509
|
}
|
|
2112
2510
|
roundPrice(e) {
|
|
2113
2511
|
if (!Number.isFinite(e)) return e;
|
|
2114
2512
|
let t = this.stepAt(e);
|
|
2115
|
-
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(
|
|
2513
|
+
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(le(t)));
|
|
2116
2514
|
let { min: n, max: r } = this.viewport.getState().priceRange;
|
|
2117
2515
|
return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
|
|
2118
2516
|
}
|
|
@@ -2122,7 +2520,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2122
2520
|
}
|
|
2123
2521
|
stepAt(e) {
|
|
2124
2522
|
let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
|
|
2125
|
-
return t !== void 0 && t > 0 ? t : this.marketConfig ?
|
|
2523
|
+
return t !== void 0 && t > 0 ? t : this.marketConfig ? re(e, this.marketConfig) : void 0;
|
|
2126
2524
|
}
|
|
2127
2525
|
getPriceStep(e) {
|
|
2128
2526
|
let t = this.stepAt(e ?? this.lastClose());
|
|
@@ -2137,7 +2535,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2137
2535
|
return this.priceFormatter;
|
|
2138
2536
|
}
|
|
2139
2537
|
applyPriceFormat(e) {
|
|
2140
|
-
this.priceFormatter =
|
|
2538
|
+
this.priceFormatter = ne(e), this.priceUnit = e && typeof e != "function" ? g(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
|
|
2141
2539
|
}
|
|
2142
2540
|
setTimeFormatter(e) {
|
|
2143
2541
|
this.applyTimeFormatter(e), this.engine.requestRender();
|
|
@@ -2148,7 +2546,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2148
2546
|
formatPrice(e) {
|
|
2149
2547
|
if (this.priceFormatter) return this.priceFormatter(e);
|
|
2150
2548
|
let { min: t, max: n } = this.viewport.getState().priceRange;
|
|
2151
|
-
return
|
|
2549
|
+
return h(e, this.marketPricePrecision ?? c(t, n), this.numberLocale);
|
|
2152
2550
|
}
|
|
2153
2551
|
setDrawingTool(e) {
|
|
2154
2552
|
this.features.drawings && (e && this.features.drawingTools.length > 0 && !this.features.drawingTools.includes(e) || (e && this.setZoomAreaMode(!1), this.drawingManager.setActiveTool(e)));
|
|
@@ -2196,7 +2594,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2196
2594
|
}
|
|
2197
2595
|
autoFib() {
|
|
2198
2596
|
if (!this.features.drawings) return null;
|
|
2199
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
2597
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = Ot(e, t.visibleRange.from, t.visibleRange.to);
|
|
2200
2598
|
return n ? this.addDrawing({
|
|
2201
2599
|
type: "fibRetracement",
|
|
2202
2600
|
anchors: [n[0], n[1]]
|
|
@@ -2274,7 +2672,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2274
2672
|
recordUndo(e) {
|
|
2275
2673
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2276
2674
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2277
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2675
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Fr) {
|
|
2278
2676
|
this.undoRedoManager.replaceLast({
|
|
2279
2677
|
...n,
|
|
2280
2678
|
custom: {
|
|
@@ -2321,7 +2719,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2321
2719
|
x: t.x,
|
|
2322
2720
|
y: t.y
|
|
2323
2721
|
};
|
|
2324
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
2722
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = Jt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = P(t.x, n)), e === "pane") {
|
|
2325
2723
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2326
2724
|
e && (r.pane = e.instanceId);
|
|
2327
2725
|
}
|
|
@@ -2347,7 +2745,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2347
2745
|
...this.viewport.getState(),
|
|
2348
2746
|
data: this.getDisplayData()
|
|
2349
2747
|
};
|
|
2350
|
-
this.setVisibleRange(
|
|
2748
|
+
this.setVisibleRange(P(e.x0, t), P(e.x1, t));
|
|
2351
2749
|
}
|
|
2352
2750
|
lockAllDrawings() {
|
|
2353
2751
|
this.drawingManager.lockAllDrawings();
|
|
@@ -2392,7 +2790,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2392
2790
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2393
2791
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2394
2792
|
if (!t) continue;
|
|
2395
|
-
let r =
|
|
2793
|
+
let r = on(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2396
2794
|
key: e,
|
|
2397
2795
|
title: e
|
|
2398
2796
|
}));
|
|
@@ -2416,11 +2814,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2416
2814
|
}
|
|
2417
2815
|
getExportText(e = "csv", t = {}) {
|
|
2418
2816
|
let { bars: n, columns: r } = this.getExportData(t);
|
|
2419
|
-
return e === "json" ?
|
|
2817
|
+
return e === "json" ? E.toJSON(n, r) : E.toCSV(n, r);
|
|
2420
2818
|
}
|
|
2421
2819
|
download(e, t, n) {
|
|
2422
2820
|
let r = this.getExportText(e, n);
|
|
2423
|
-
e === "json" ?
|
|
2821
|
+
e === "json" ? E.download(r, t ?? "chart-data.json", "application/json") : E.download(r, t ?? "chart-data.csv", "text/csv");
|
|
2424
2822
|
}
|
|
2425
2823
|
setAutoSave(e, t = 5e3) {
|
|
2426
2824
|
this.autoSaveScheduler.enable(e, t);
|
|
@@ -2482,7 +2880,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2482
2880
|
this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
|
|
2483
2881
|
}
|
|
2484
2882
|
updateIndicatorStyleNow(e, t) {
|
|
2485
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2883
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
|
|
2486
2884
|
this.indicatorEngine.updateIndicatorStyle(e, {
|
|
2487
2885
|
...r,
|
|
2488
2886
|
...i ? { plots: i } : {}
|
|
@@ -2601,21 +2999,26 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2601
2999
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
2602
3000
|
}
|
|
2603
3001
|
async connect(e) {
|
|
2604
|
-
if (!
|
|
2605
|
-
this.snapshotKey = null, this.
|
|
2606
|
-
let n =
|
|
2607
|
-
this.replaySession ? this.series.
|
|
3002
|
+
if (!A(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
3003
|
+
this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new mt(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (t) => {
|
|
3004
|
+
let n = this.streamSeriesKey(e.adapter);
|
|
3005
|
+
n === this.snapshotKey && this.replaySession ? this.series.mergeSnapshot(t) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(t) : (this.replaySession && this.useStreamHistory(e.adapter, e.historyPageSize, !1), this.setData(t)), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
|
|
2608
3006
|
}), this.streamManager.on("barClose", (e) => {
|
|
2609
|
-
if (!
|
|
3007
|
+
if (!L(e)) return;
|
|
2610
3008
|
let t = this.series.placeStreamBar(e);
|
|
2611
|
-
if (t.refiltered && (this.displayDataCache = null), t.to === "
|
|
3009
|
+
if (t.refiltered && (this.displayDataCache = null), t.to === "none") {
|
|
3010
|
+
this.updateBar(e);
|
|
3011
|
+
return;
|
|
3012
|
+
}
|
|
3013
|
+
if (t.to === "aside" && this.followLivePrice(e.close), t.to !== "shown") return;
|
|
2612
3014
|
let n = this.autoScrollOnNewBar && this.viewport.isAtEnd(), r = t.before, i = this.series.bars();
|
|
2613
3015
|
this.crosshairHandler.setData(i), this.displayDataCache = null, this.recalcIndicatorsFrom(i, i.length - 2), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
|
|
3016
|
+
}), this.streamManager.on("barCorrection", (e) => {
|
|
3017
|
+
this.updateBar(e);
|
|
2614
3018
|
}), this.streamManager.on("barUpdate", (e) => {
|
|
2615
|
-
if (!
|
|
2616
|
-
this.replaySession || this.currentPriceLine.setPrice(e.close);
|
|
3019
|
+
if (!L(e)) return;
|
|
2617
3020
|
let t = this.series.placeStreamBar(e);
|
|
2618
|
-
if (t.refiltered && (this.displayDataCache = null), this.replaySession) return;
|
|
3021
|
+
if (t.refiltered && (this.displayDataCache = null), t.to === "none" || (this.replaySession || this.currentPriceLine.setPrice(e.close), this.replaySession)) return;
|
|
2619
3022
|
let n = t.before;
|
|
2620
3023
|
if (t.to !== "shown") {
|
|
2621
3024
|
this.scheduleRender();
|
|
@@ -2653,14 +3056,18 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2653
3056
|
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
|
|
2654
3057
|
let t = this.streamManager;
|
|
2655
3058
|
if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
|
|
2656
|
-
let n =
|
|
3059
|
+
let n = w(e.timeframe);
|
|
2657
3060
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
2658
3061
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
2659
3062
|
}, 1e3);
|
|
2660
3063
|
}
|
|
3064
|
+
streamSeriesKey(e) {
|
|
3065
|
+
let t = N(e), n = this.streamTimeframe, r = t instanceof at && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
|
|
3066
|
+
return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
|
|
3067
|
+
}
|
|
2661
3068
|
setStreamTarget(e, t) {
|
|
2662
3069
|
let n = this.announcedSymbol;
|
|
2663
|
-
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream =
|
|
3070
|
+
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = ue(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
2664
3071
|
symbol: e,
|
|
2665
3072
|
previous: n
|
|
2666
3073
|
})), this.useTimeframe(t);
|
|
@@ -2678,8 +3085,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2678
3085
|
async switchStream(e, t) {
|
|
2679
3086
|
if (!this.streamManager) return;
|
|
2680
3087
|
let n = this.streamAdapter;
|
|
2681
|
-
if (n && !
|
|
2682
|
-
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(
|
|
3088
|
+
if (n && !A(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
3089
|
+
this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(w(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
|
|
2683
3090
|
}
|
|
2684
3091
|
isIndicatorAllowed(e) {
|
|
2685
3092
|
let t = this.features.indicatorIds;
|
|
@@ -2694,11 +3101,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2694
3101
|
this.isTimeframeAllowed(e) && await this.switchStream(this.currentSymbol, e);
|
|
2695
3102
|
}
|
|
2696
3103
|
disconnectStream() {
|
|
2697
|
-
this.symbolInfoSeq++, this.priceLines.setBidAsk(null), this.streamManager &&= (this.streamManager.dispose(), null), this.historyFromStream &&= (this.history.setLoader(null), !1), this.streamAdapter = null, this.tickStream = !1, this.applyTimeSpacing();
|
|
3104
|
+
this.symbolInfoSeq++, this.releaseStudyZoneAfterCaller(), this.priceLines.setBidAsk(null), this.streamManager &&= (this.streamManager.dispose(), null), this.historyFromStream &&= (this.history.setLoader(null), !1), this.replayLoader?.loader.dispose(), this.replayLoader = null, this.streamAdapter = null, this.tickStream = !1, this.applyTimeSpacing();
|
|
2698
3105
|
}
|
|
2699
3106
|
connectExecution(e, t = {}) {
|
|
2700
3107
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
2701
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
3108
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = lr(e, {
|
|
2702
3109
|
onIntent: (e, t) => {
|
|
2703
3110
|
let n = (e) => t(e.payload);
|
|
2704
3111
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -2724,6 +3131,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2724
3131
|
setBarCountdownVisible(e) {
|
|
2725
3132
|
this.barCountdown.setVisible(e && this.features.barCountdown), this.engine.requestRender(r.Hover);
|
|
2726
3133
|
}
|
|
3134
|
+
isBarCountdownVisible() {
|
|
3135
|
+
return this.barCountdown.isVisible();
|
|
3136
|
+
}
|
|
2727
3137
|
setSessionBreaksVisible(e) {
|
|
2728
3138
|
this.sessionBreaks.setVisible(e), this.engine.requestRender(r.Background);
|
|
2729
3139
|
}
|
|
@@ -2734,19 +3144,50 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2734
3144
|
data: n,
|
|
2735
3145
|
color: r,
|
|
2736
3146
|
visible: !0
|
|
2737
|
-
}), this.updateViewportAndRender()
|
|
3147
|
+
}), this.updateViewportAndRender(), this.eventBus.emit("compareChange", {
|
|
3148
|
+
id: e,
|
|
3149
|
+
change: "add"
|
|
3150
|
+
}));
|
|
2738
3151
|
}
|
|
2739
3152
|
removeCompareSymbol(e) {
|
|
2740
|
-
this.compareRenderer.removeSymbol(e), this.updateViewportAndRender()
|
|
3153
|
+
this.compareRenderer.removeSymbol(e), this.updateViewportAndRender(), this.eventBus.emit("compareChange", {
|
|
3154
|
+
id: e,
|
|
3155
|
+
change: "remove"
|
|
3156
|
+
});
|
|
2741
3157
|
}
|
|
2742
3158
|
updateCompareData(e, t) {
|
|
2743
|
-
this.compareRenderer.setSymbolData(e, t), this.updateViewportAndRender()
|
|
3159
|
+
this.compareRenderer.setSymbolData(e, t), this.updateViewportAndRender(), this.eventBus.emit("compareChange", {
|
|
3160
|
+
id: e,
|
|
3161
|
+
change: "data"
|
|
3162
|
+
});
|
|
2744
3163
|
}
|
|
2745
3164
|
setCompareMode(e) {
|
|
2746
3165
|
this.compareRenderer.setMode(e), this.updateViewportAndRender();
|
|
2747
3166
|
}
|
|
3167
|
+
setCompareVisible(e, t) {
|
|
3168
|
+
this.compareRenderer.setSymbolVisible(e, t), this.updateViewportAndRender(), this.eventBus.emit("compareChange", {
|
|
3169
|
+
id: e,
|
|
3170
|
+
change: "visible"
|
|
3171
|
+
});
|
|
3172
|
+
}
|
|
3173
|
+
getCompareValues(e) {
|
|
3174
|
+
if (!this.comparesDrawn()) {
|
|
3175
|
+
let e = this.series.bars();
|
|
3176
|
+
return this.compareRenderer.valuesAt(e, null, e.length - 1);
|
|
3177
|
+
}
|
|
3178
|
+
let t = this.getDisplayData();
|
|
3179
|
+
return this.compareRenderer.valuesAt(t, this.viewport.getState(), e ?? t.length - 1);
|
|
3180
|
+
}
|
|
3181
|
+
comparesDrawn() {
|
|
3182
|
+
return this.isTimeAligned();
|
|
3183
|
+
}
|
|
2748
3184
|
clearCompareSymbols() {
|
|
3185
|
+
let e = this.compareRenderer.getSymbols().map((e) => e.id);
|
|
2749
3186
|
this.compareRenderer.clear(), this.updateViewportAndRender();
|
|
3187
|
+
for (let t of e) this.eventBus.emit("compareChange", {
|
|
3188
|
+
id: t,
|
|
3189
|
+
change: "remove"
|
|
3190
|
+
});
|
|
2750
3191
|
}
|
|
2751
3192
|
setLogScale(e) {
|
|
2752
3193
|
e && !this.features.logScale || (this.viewport.setLogScale(e), this.updateViewportAndRender());
|
|
@@ -2789,18 +3230,18 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2789
3230
|
goToTime(e) {
|
|
2790
3231
|
let t = this.getDisplayData();
|
|
2791
3232
|
if (t.length === 0 || !Number.isFinite(e)) return -1;
|
|
2792
|
-
let n = Math.max(0, Math.min(t.length - 1, Math.floor(
|
|
3233
|
+
let n = Math.max(0, Math.min(t.length - 1, Math.floor(M(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
|
|
2793
3234
|
return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
|
|
2794
3235
|
}
|
|
2795
3236
|
setVisibleRangePreset(e) {
|
|
2796
3237
|
let t = this.getDisplayData();
|
|
2797
3238
|
if (t.length === 0) return;
|
|
2798
|
-
let n = t.length - 1, r =
|
|
3239
|
+
let n = t.length - 1, r = u(t), i = It(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
2799
3240
|
if (a === null || a < t[0].time) {
|
|
2800
3241
|
this.fitContent();
|
|
2801
3242
|
return;
|
|
2802
3243
|
}
|
|
2803
|
-
let o =
|
|
3244
|
+
let o = M(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
|
|
2804
3245
|
this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
|
|
2805
3246
|
}
|
|
2806
3247
|
scrollToEnd() {
|
|
@@ -2825,7 +3266,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2825
3266
|
setVisibleRange(e, t) {
|
|
2826
3267
|
let n = this.getDisplayData();
|
|
2827
3268
|
if (n.length === 0) return;
|
|
2828
|
-
let r =
|
|
3269
|
+
let r = M(Math.min(e, t), n), i = M(Math.max(e, t), n);
|
|
2829
3270
|
this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
|
|
2830
3271
|
}
|
|
2831
3272
|
suspend() {
|
|
@@ -2931,7 +3372,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2931
3372
|
this.applyStyle(e, t.layer ?? "host", !0);
|
|
2932
3373
|
}
|
|
2933
3374
|
setOverrides(e, t = {}) {
|
|
2934
|
-
let n = t.layer ?? "host", { overrides: r, rejected: i } =
|
|
3375
|
+
let n = t.layer ?? "host", { overrides: r, rejected: i } = ie(e);
|
|
2935
3376
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
|
|
2936
3377
|
let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
|
|
2937
3378
|
this.themeManager.setOverrides(a, n) && this.styleChanged(n);
|
|
@@ -2950,7 +3391,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2950
3391
|
return this.themeManager.getStyleValue(e);
|
|
2951
3392
|
}
|
|
2952
3393
|
applyStyle(e, t, n) {
|
|
2953
|
-
let { overrides: r, rejected: i } =
|
|
3394
|
+
let { overrides: r, rejected: i } = ie(e);
|
|
2954
3395
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
|
|
2955
3396
|
}
|
|
2956
3397
|
styleChanged(e) {
|
|
@@ -2965,7 +3406,10 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2965
3406
|
}), this.engine.requestRender(r.Background);
|
|
2966
3407
|
}
|
|
2967
3408
|
setAutoScale(e) {
|
|
2968
|
-
this.options.autoScale = e, this.defaultAutoScale = e, this.updateViewportAndRender();
|
|
3409
|
+
this.options.autoScale = e, this.defaultAutoScale = e, !e && this.series.length() > 0 && (this.seriesArriving = !1), this.updateViewportAndRender();
|
|
3410
|
+
}
|
|
3411
|
+
holdPriceScale() {
|
|
3412
|
+
this.options.autoScale = !1, this.priceFitPending = !1;
|
|
2969
3413
|
}
|
|
2970
3414
|
isAutoScale() {
|
|
2971
3415
|
return this.options.autoScale !== !1;
|
|
@@ -2980,7 +3424,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2980
3424
|
e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
|
|
2981
3425
|
}
|
|
2982
3426
|
setCrosshairTime(e) {
|
|
2983
|
-
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(
|
|
3427
|
+
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(M(e, t));
|
|
2984
3428
|
n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
|
|
2985
3429
|
}
|
|
2986
3430
|
getData() {
|
|
@@ -2995,6 +3439,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
2995
3439
|
setVolumeVisible(e) {
|
|
2996
3440
|
this.volumeRenderer.setVisible(e), this.updateViewportAndRender();
|
|
2997
3441
|
}
|
|
3442
|
+
isVolumeVisible() {
|
|
3443
|
+
return this.features.volume && this.volumeRenderer.isVisible();
|
|
3444
|
+
}
|
|
2998
3445
|
setVolumeProfileVisible(e) {
|
|
2999
3446
|
this.volumeProfile.setVisible(e), this.engine.requestRender(r.Main);
|
|
3000
3447
|
}
|
|
@@ -3013,6 +3460,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3013
3460
|
setMarketProfileConfig(e) {
|
|
3014
3461
|
e.buckets !== void 0 && this.marketProfile.setBuckets(e.buckets), e.widthRatio !== void 0 && this.marketProfile.setWidthRatio(e.widthRatio), e.opacity !== void 0 && this.marketProfile.setOpacity(e.opacity), e.valueAreaPct !== void 0 && this.marketProfile.setValueAreaPct(e.valueAreaPct), e.highlightPoC !== void 0 && this.marketProfile.setHighlightPoC(e.highlightPoC), e.showStats !== void 0 && this.marketProfile.setShowStats(e.showStats), e.splitBySession !== void 0 && this.marketProfile.setSplitBySession(e.splitBySession), e.letters !== void 0 && this.marketProfile.setLetters(e.letters), this.engine.requestRender(r.Main);
|
|
3015
3462
|
}
|
|
3463
|
+
getMarketProfileConfig() {
|
|
3464
|
+
return this.marketProfile.getConfig();
|
|
3465
|
+
}
|
|
3016
3466
|
getMarketProfileStats() {
|
|
3017
3467
|
return this.marketProfile.getStats();
|
|
3018
3468
|
}
|
|
@@ -3025,6 +3475,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3025
3475
|
setDepthHeatmapConfig(e) {
|
|
3026
3476
|
e.opacity !== void 0 && this.depthHeatmap.setOpacity(e.opacity), e.capacity !== void 0 && this.depthHeatmap.setCapacity(e.capacity), this.engine.requestRender(r.Main);
|
|
3027
3477
|
}
|
|
3478
|
+
getDepthHeatmapConfig() {
|
|
3479
|
+
return this.depthHeatmap.getConfig();
|
|
3480
|
+
}
|
|
3028
3481
|
pushDepthSnapshot(e, t) {
|
|
3029
3482
|
let n = this.series.bars(), i = t ?? n[n.length - 1]?.time;
|
|
3030
3483
|
i === void 0 || !Number.isFinite(i) || (this.depthHeatmap.push(i, e), this.depthHeatmap.isVisible() && this.engine.requestRender(r.Main));
|
|
@@ -3041,8 +3494,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3041
3494
|
setPeriodLevelsPeriod(e) {
|
|
3042
3495
|
this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
|
|
3043
3496
|
}
|
|
3497
|
+
getPeriodLevelsPeriod() {
|
|
3498
|
+
return this.periodLevels.getPeriod();
|
|
3499
|
+
}
|
|
3044
3500
|
setTimeZone(e) {
|
|
3045
|
-
|
|
3501
|
+
jr(e), this.timeZoneSetting = e, this.applyTimeZone();
|
|
3046
3502
|
}
|
|
3047
3503
|
getTimeZone() {
|
|
3048
3504
|
return this.timeZoneSetting;
|
|
@@ -3051,7 +3507,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3051
3507
|
return this.displayTz;
|
|
3052
3508
|
}
|
|
3053
3509
|
getExchangeTimeZone() {
|
|
3054
|
-
return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e &&
|
|
3510
|
+
return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && v(e)) ?? null;
|
|
3055
3511
|
}
|
|
3056
3512
|
setTimezone(e) {
|
|
3057
3513
|
this.setTimeZone(e);
|
|
@@ -3068,13 +3524,46 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3068
3524
|
setTimezoneOffset(e) {
|
|
3069
3525
|
this.setTimeZone(e);
|
|
3070
3526
|
}
|
|
3527
|
+
applyExchangeZone() {
|
|
3528
|
+
let e = this.getExchangeTimeZone();
|
|
3529
|
+
this.timeAxis.setExchangeTimeZone(e), this.crosshairHandler.setExchangeTimeZone(e), this.crosshairTooltip.setExchangeTimeZone(e), this.pinnedTooltip.setExchangeTimeZone(e), this.studyZoneHeld || this.applyStudyZone(e);
|
|
3530
|
+
}
|
|
3531
|
+
applyStudyZone(e) {
|
|
3532
|
+
this.studyZone = e, this.streamManager?.setTimeZone(e), this.periodLevels.setExchangeTimeZone(e), this.marketProfile.setExchangeTimeZone(e);
|
|
3533
|
+
let t = this.series.bars();
|
|
3534
|
+
this.indicatorEngine.setExchangeTimeZone(e, t.length > 0 ? t : void 0) && t.length > 0 && this.announceIndicatorUpdate(0);
|
|
3535
|
+
}
|
|
3536
|
+
holdStudyZone() {
|
|
3537
|
+
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), st);
|
|
3538
|
+
}
|
|
3539
|
+
endStudyZoneWait() {
|
|
3540
|
+
this.studyZoneReleaseQueued = !1, this.studyZoneTimer !== null && (clearTimeout(this.studyZoneTimer), this.studyZoneTimer = null);
|
|
3541
|
+
}
|
|
3542
|
+
releaseStudyZone() {
|
|
3543
|
+
this.endStudyZoneWait(), this.studyZoneHeld && (this.studyZoneHeld = !1, this.applyStudyZone(this.getExchangeTimeZone()), this.disposed || this.updateViewportAndRender());
|
|
3544
|
+
}
|
|
3545
|
+
releaseStudyZoneAfterCaller() {
|
|
3546
|
+
this.studyZoneHeld && (this.endStudyZoneWait(), this.studyZoneReleaseQueued = !0, queueMicrotask(() => {
|
|
3547
|
+
!this.studyZoneReleaseQueued || this.disposed || this.releaseStudyZone();
|
|
3548
|
+
}));
|
|
3549
|
+
}
|
|
3550
|
+
spokenBarTime(e) {
|
|
3551
|
+
let t = this.getDisplayData(), n = e * u(t), r = this.numberLocale || "en-US";
|
|
3552
|
+
return d(t) === !0 ? de(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : de(r, {
|
|
3553
|
+
dateStyle: "medium",
|
|
3554
|
+
timeStyle: "short"
|
|
3555
|
+
}, this.displayTz)(n);
|
|
3556
|
+
}
|
|
3071
3557
|
applyTimeZone() {
|
|
3072
3558
|
let e = this.timeZoneSetting === "exchange" ? this.getExchangeTimeZone() ?? "UTC" : this.timeZoneSetting;
|
|
3073
3559
|
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();
|
|
3074
3560
|
}
|
|
3075
3561
|
setSymbolInfo(e) {
|
|
3562
|
+
this.studyZoneHeld = !1, this.endStudyZoneWait(), this.useSymbolInfo(e);
|
|
3563
|
+
}
|
|
3564
|
+
useSymbolInfo(e) {
|
|
3076
3565
|
let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
|
|
3077
|
-
this.symbolInfo = e ?
|
|
3566
|
+
this.symbolInfo = e ? Mr({
|
|
3078
3567
|
...e,
|
|
3079
3568
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
3080
3569
|
}, 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);
|
|
@@ -3085,12 +3574,12 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3085
3574
|
endMinute: n
|
|
3086
3575
|
}];
|
|
3087
3576
|
}), i = C(this.symbolInfo);
|
|
3088
|
-
this.sessionShading.replaceConfig(n.length > 0 && i &&
|
|
3577
|
+
this.sessionShading.replaceConfig(n.length > 0 && i && v(i) ? {
|
|
3089
3578
|
timeZone: i,
|
|
3090
3579
|
windows: n,
|
|
3091
3580
|
startMinute: n[0].startMinute,
|
|
3092
3581
|
endMinute: n[n.length - 1].endMinute
|
|
3093
|
-
} : this.hostSessionHours), this.timeZoneSetting === "exchange" && this.applyTimeZone(), this.reapplyExtendedHours(), this.updateViewportAndRender(), this.eventBus.emit("symbolInfoChange", { info: this.symbolInfo });
|
|
3582
|
+
} : this.hostSessionHours), this.timeZoneSetting === "exchange" && this.applyTimeZone(), this.applyExchangeZone(), this.reapplyExtendedHours(), this.updateViewportAndRender(), this.eventBus.emit("symbolInfoChange", { info: this.symbolInfo });
|
|
3094
3583
|
}
|
|
3095
3584
|
getSymbolInfo() {
|
|
3096
3585
|
return this.symbolInfo;
|
|
@@ -3099,7 +3588,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3099
3588
|
if (!e || typeof e != "object") return;
|
|
3100
3589
|
let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
|
|
3101
3590
|
if (!n(e.symbol)) return;
|
|
3102
|
-
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i =
|
|
3591
|
+
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Mr({
|
|
3103
3592
|
...r,
|
|
3104
3593
|
...e,
|
|
3105
3594
|
symbol: e.symbol || r?.symbol || t
|
|
@@ -3107,14 +3596,16 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3107
3596
|
r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
|
|
3108
3597
|
}
|
|
3109
3598
|
resolveStreamSymbol(e, t) {
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3599
|
+
let n = N(e), r = n.resolveSymbol?.bind(n);
|
|
3600
|
+
if (this.symbolInfo && this.symbolInfo.symbol !== t ? (r ? this.holdStudyZone() : this.studyZoneHeld = !1, this.useSymbolInfo(null)) : r && this.studyZoneHeld && this.holdStudyZone(), !r) {
|
|
3601
|
+
this.releaseStudyZone();
|
|
3602
|
+
return;
|
|
3603
|
+
}
|
|
3604
|
+
let i = ++this.symbolInfoSeq;
|
|
3605
|
+
Promise.resolve().then(() => r(t)).then((e) => {
|
|
3606
|
+
i === this.symbolInfoSeq && (e && this.currentSymbol === t ? this.setSymbolInfo(e) : this.releaseStudyZone());
|
|
3116
3607
|
}, (e) => {
|
|
3117
|
-
|
|
3608
|
+
i === this.symbolInfoSeq && (this.releaseStudyZone(), console.warn(`No symbol info for "${t}":`, e));
|
|
3118
3609
|
});
|
|
3119
3610
|
}
|
|
3120
3611
|
setPivotMarkersVisible(e) {
|
|
@@ -3126,6 +3617,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3126
3617
|
setPivotMarkersConfig(e) {
|
|
3127
3618
|
(e.left !== void 0 || e.right !== void 0) && this.pivotMarkers.setStrength(e.left ?? 5, e.right ?? e.left ?? 5), e.showLabels !== void 0 && this.pivotMarkers.setShowLabels(e.showLabels), e.structureLabels !== void 0 && this.pivotMarkers.setStructureLabels(e.structureLabels), this.engine.requestRender(r.Overlay);
|
|
3128
3619
|
}
|
|
3620
|
+
getPivotMarkersConfig() {
|
|
3621
|
+
return this.pivotMarkers.getConfig();
|
|
3622
|
+
}
|
|
3129
3623
|
setSessionShadingVisible(e) {
|
|
3130
3624
|
this.sessionShading.setVisible(e), this.engine.requestRender(r.Background);
|
|
3131
3625
|
}
|
|
@@ -3133,7 +3627,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3133
3627
|
return this.sessionShading.isVisible();
|
|
3134
3628
|
}
|
|
3135
3629
|
setSessionShadingConfig(e) {
|
|
3136
|
-
this.hostSessionHours =
|
|
3630
|
+
this.hostSessionHours = Nt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
|
|
3137
3631
|
}
|
|
3138
3632
|
setTooltipVisible(e) {
|
|
3139
3633
|
e || this.crosshairTooltip.hide();
|
|
@@ -3141,6 +3635,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3141
3635
|
setLegend(e) {
|
|
3142
3636
|
this.chartLegend.setConfig(e), this.engine.requestRender(r.Hover);
|
|
3143
3637
|
}
|
|
3638
|
+
isLegendVisible() {
|
|
3639
|
+
return this.features.legend && this.chartLegend.getConfig().visible;
|
|
3640
|
+
}
|
|
3144
3641
|
setSymbolName(e) {
|
|
3145
3642
|
this.chartLegend.setSymbol(e), this.engine.requestRender(r.Hover);
|
|
3146
3643
|
}
|
|
@@ -3152,11 +3649,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3152
3649
|
return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
|
|
3153
3650
|
}
|
|
3154
3651
|
async takeGpu(e, t, n) {
|
|
3155
|
-
let { gpu: r, reason: i } = await
|
|
3156
|
-
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ?
|
|
3652
|
+
let { gpu: r, reason: i } = await Mt(e);
|
|
3653
|
+
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? kt() > 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());
|
|
3157
3654
|
}
|
|
3158
3655
|
waitForGpu(e) {
|
|
3159
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
3656
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Kt(e) : null;
|
|
3160
3657
|
}
|
|
3161
3658
|
getRenderer() {
|
|
3162
3659
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -3182,10 +3679,23 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3182
3679
|
}
|
|
3183
3680
|
async copyScreenshot() {
|
|
3184
3681
|
if (!this.features.screenshot) return !1;
|
|
3682
|
+
let e = globalThis.ClipboardItem, t = typeof navigator > "u" ? void 0 : navigator.clipboard;
|
|
3683
|
+
if (!t?.write || !e) return !1;
|
|
3185
3684
|
try {
|
|
3186
3685
|
this.freshFrame();
|
|
3187
|
-
let
|
|
3188
|
-
|
|
3686
|
+
let n = k.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
|
|
3687
|
+
if (!e) throw Error("No chart image to copy");
|
|
3688
|
+
return e;
|
|
3689
|
+
});
|
|
3690
|
+
n.catch(() => {});
|
|
3691
|
+
let r;
|
|
3692
|
+
try {
|
|
3693
|
+
r = new e({ "image/png": n });
|
|
3694
|
+
} catch (t) {
|
|
3695
|
+
if (!(t instanceof TypeError)) throw t;
|
|
3696
|
+
r = new e({ "image/png": await n });
|
|
3697
|
+
}
|
|
3698
|
+
return await t.write([r]), !0;
|
|
3189
3699
|
} catch {
|
|
3190
3700
|
return !1;
|
|
3191
3701
|
}
|
|
@@ -3318,65 +3828,212 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3318
3828
|
}
|
|
3319
3829
|
replayStart(e) {
|
|
3320
3830
|
if (!this.features.replay) return;
|
|
3321
|
-
this.history.reset();
|
|
3322
3831
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
3323
3832
|
if (!this.replaySession) {
|
|
3324
3833
|
if (this.series.length() === 0) return;
|
|
3325
|
-
this.series.beginReplay(), this.replaySession =
|
|
3326
|
-
price: null,
|
|
3327
|
-
fedTime: null
|
|
3328
|
-
};
|
|
3834
|
+
this.series.beginReplay(), this.replaySession = ei(this.currentSymbol);
|
|
3329
3835
|
}
|
|
3330
|
-
let { steps:
|
|
3331
|
-
|
|
3332
|
-
let
|
|
3333
|
-
|
|
3334
|
-
let f =
|
|
3335
|
-
|
|
3836
|
+
let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
|
|
3837
|
+
c.animate = c.animate === !0;
|
|
3838
|
+
let l = this.series.inHoursShown(this.series.liveBars()), u = t > 0 && i === void 0 && a !== !1, d = c.startIndex;
|
|
3839
|
+
i !== void 0 && d === void 0 ? d = J(l, i) : u && d !== void 0 && (d += t);
|
|
3840
|
+
let f = u ? t : a && d !== void 0 && d > 0 ? Math.min(Math.floor(d), l.length - 1) : 0, p = f > 0 ? l.slice(f) : l;
|
|
3841
|
+
d !== void 0 && (c.startIndex = d - f), n.windowTime = f > 0 ? p[0]?.time ?? null : null, n.steps = r ?? null, n.stepsSymbol = this.currentSymbol, n.until = null, n.animate = c.animate, n.step = c.animate ? s ?? null : null, this.replayRevealMarks = o !== !1, this.useReplayLoader(n, !0);
|
|
3842
|
+
let m = r ? this.replayStepsOver(n, p, !0) : null;
|
|
3843
|
+
this.options.autoScale = !0, this.buildReplay(p, m, f);
|
|
3844
|
+
let h = this.replayStepsSeries;
|
|
3845
|
+
h && c.startIndex !== void 0 && (c.startIndex = li(h, p, c.startIndex));
|
|
3846
|
+
let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
|
|
3847
|
+
this.revealReplayMarks(this.replayRevealMarks ? _?.time ?? null : null), n.held && (n.held.state = c.paused ? "paused" : "playing", c.paused = !0), !c.paused && c.startIndex !== void 0 && c.startIndex >= 1 && this.replaySeek(c.startIndex - 1), this.replayManager.play(c);
|
|
3848
|
+
}
|
|
3849
|
+
buildReplay(e, t, n) {
|
|
3850
|
+
let r = this.replaySession?.animate === !0, i = r ? null : t;
|
|
3851
|
+
this.replayPieces = r && t ? fi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
|
|
3852
|
+
let a = this.replayRestarting;
|
|
3853
|
+
this.replayRestarting = !0;
|
|
3336
3854
|
try {
|
|
3337
|
-
this.replayManager.load(
|
|
3855
|
+
this.replayManager.load(i ?? e);
|
|
3338
3856
|
} finally {
|
|
3339
|
-
this.replayRestarting =
|
|
3857
|
+
this.replayRestarting = a;
|
|
3340
3858
|
}
|
|
3341
|
-
|
|
3342
|
-
let
|
|
3343
|
-
this.replayBarUnsub = this.replayManager.on("bar", ({ index:
|
|
3344
|
-
let
|
|
3345
|
-
if (f) {
|
|
3346
|
-
let r = f[e];
|
|
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;
|
|
3348
|
-
}
|
|
3349
|
-
m = e;
|
|
3350
|
-
let r = t + 1, i = p > 0 && r >= p && this.series.length() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
3859
|
+
this.replayBarUnsub?.(), this.replayPhaseUnsub?.();
|
|
3860
|
+
let o = -1, s = -1, c = null, l = i ?? e;
|
|
3861
|
+
this.replayBarUnsub = this.replayManager.on("bar", ({ index: t }) => {
|
|
3862
|
+
let n = t, a = e[t];
|
|
3351
3863
|
if (i) {
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
let
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3864
|
+
let r = i[t];
|
|
3865
|
+
n = Z(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? mi(c, r) : ui(e[n], i, t), a = di(i, e, t, n) ? e[n] : c;
|
|
3866
|
+
}
|
|
3867
|
+
let u = this.replayForming;
|
|
3868
|
+
this.replayForming = null, s = t;
|
|
3869
|
+
let d = n + 1, f = o > 0 && d >= o && this.series.length() === o, p = f && !this.replaySeeking, m = !p || this.autoScrollOnNewBar && this.viewport.isAtEnd(), h = this.series.length();
|
|
3870
|
+
if (f) {
|
|
3871
|
+
d > o && this.series.updateReplayed(e[o - 1]);
|
|
3872
|
+
for (let t = o; t < d - 1; t++) this.series.appendReplayed(e[t]);
|
|
3873
|
+
d > o ? this.series.appendReplayed(a) : this.series.updateReplayed(a), this.recalcIndicatorsFrom(this.series.bars(), Math.max(0, o - 1));
|
|
3874
|
+
} else this.series.showReplayed([...e.slice(0, n), a]), this.recalcIndicators(this.series.bars());
|
|
3875
|
+
o = d, this.replayCause === "older" && (this.viewport.prependBars(d - h), m = !1), this.currentPriceLine.setPrice(a.close, n > 0 ? e[n - 1].close : void 0), this.crosshairHandler.setData(this.series.bars());
|
|
3876
|
+
let g = l[t + 1]?.time ?? l[t].time + (t > 0 ? l[t].time - l[t - 1].time : 1);
|
|
3877
|
+
this.replaySession && (this.replaySession.until = g), this.replayRevealMarks && this.revealReplayMarks(g), this.displayDataCache = null, this.reshapeMemo.clear(), this.updateViewportAndRender(m), r ? this.feedReplayForming(e, t, u?.index === t ? u.path : this.replayPathOf(e, t), 1) : this.feedReplaySteps(l, t);
|
|
3878
|
+
let _ = this.replayCause === null ? p ? "play" : "seek" : "series";
|
|
3879
|
+
this.eventBus.emit("replayStep", {
|
|
3880
|
+
barIndex: n,
|
|
3881
|
+
time: e[n].time,
|
|
3882
|
+
stepTime: l[t].time,
|
|
3883
|
+
until: g,
|
|
3884
|
+
total: e.length,
|
|
3885
|
+
cause: _
|
|
3363
3886
|
});
|
|
3887
|
+
}), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
|
|
3888
|
+
if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
|
|
3889
|
+
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = pi() ? wr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = Cr(r, i);
|
|
3890
|
+
a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
|
|
3891
|
+
index: t,
|
|
3892
|
+
path: r
|
|
3893
|
+
}, this.drawFormingBar(c, t > 0 ? e[t - 1].close : void 0, a, s), this.feedReplayForming(e, t, r, i), this.loadReplaySteps(e, t);
|
|
3894
|
+
}));
|
|
3895
|
+
}
|
|
3896
|
+
drawFormingBar(e, t, n, r) {
|
|
3897
|
+
this.currentPriceLine.setPrice(e.close, t);
|
|
3898
|
+
let i = this.series.bars();
|
|
3899
|
+
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !Xr.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
|
|
3900
|
+
this.scheduleRender();
|
|
3901
|
+
return;
|
|
3902
|
+
}
|
|
3903
|
+
this.crosshairHandler.setData(i), this.reshapeMemo.clear(), this.updateViewportAndRender(r);
|
|
3904
|
+
}
|
|
3905
|
+
replayPathOf(e, t) {
|
|
3906
|
+
let n = e[t];
|
|
3907
|
+
return vr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
|
|
3908
|
+
}
|
|
3909
|
+
loadReplaySteps(e, t) {
|
|
3910
|
+
let n = this.replayLoader?.loader;
|
|
3911
|
+
if (!n) return;
|
|
3912
|
+
n.evictBefore(e[t].time);
|
|
3913
|
+
let r = this.replayManager.getStepMs();
|
|
3914
|
+
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(Yr / r) : 1);
|
|
3915
|
+
}
|
|
3916
|
+
useReplayLoader(e, t) {
|
|
3917
|
+
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Dr(e.step, r, (e) => A(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
|
|
3918
|
+
if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
|
|
3919
|
+
let o = N(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new dr({
|
|
3920
|
+
source: s ? (e, t) => s.call(o, c, i, e, t) : null,
|
|
3921
|
+
step: i,
|
|
3922
|
+
ratio: Math.max(1, Math.round(l / w(i))),
|
|
3923
|
+
barMs: l,
|
|
3924
|
+
keep: (e) => this.series.inHoursShown(e),
|
|
3925
|
+
report: (e) => this.eventBus.emit("replayStepsLoad", e)
|
|
3364
3926
|
});
|
|
3365
|
-
|
|
3366
|
-
|
|
3927
|
+
this.replayLoader = {
|
|
3928
|
+
key: a,
|
|
3929
|
+
loader: u
|
|
3930
|
+
};
|
|
3931
|
+
}
|
|
3932
|
+
feedReplayForming(e, t, n, r) {
|
|
3933
|
+
let i = this.replaySession, a = this.executionAdapter, o = e[t];
|
|
3934
|
+
if (!i || !a?.setMarkPrice || !o) return;
|
|
3935
|
+
let s = i.fedTime;
|
|
3936
|
+
if (s === null) {
|
|
3937
|
+
i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(Cr(n, r).close, o.time);
|
|
3938
|
+
return;
|
|
3939
|
+
}
|
|
3940
|
+
if (o.time < s || o.time === s && r <= i.fedFraction) return;
|
|
3941
|
+
let c = [];
|
|
3942
|
+
if (o.time > s) {
|
|
3943
|
+
let a = J(e, s);
|
|
3944
|
+
e[a]?.time === s && i.fedFraction < 1 && c.push(...K(this.replayPathOf(e, a), i.fedFraction, 1));
|
|
3945
|
+
let o = e.slice(Y(e, s), t), l = Math.ceil(o.length / oi);
|
|
3946
|
+
for (let e = 0; e < o.length; e += l) c.push(...si(o.slice(e, e + l)));
|
|
3947
|
+
c.push(...K(n, -1, r));
|
|
3948
|
+
} else c.push(...K(n, i.fedFraction, r));
|
|
3949
|
+
i.fedTime = o.time, i.fedFraction = r;
|
|
3950
|
+
for (let [e, t] of c) a.setMarkPrice(e, t);
|
|
3951
|
+
let l = c[c.length - 1]?.[0];
|
|
3952
|
+
l !== void 0 && this.tradingManager.setCurrentPrice(l);
|
|
3953
|
+
}
|
|
3954
|
+
followLiveChange(e) {
|
|
3955
|
+
let t = this.replaySession;
|
|
3956
|
+
t && (e.kind === "bar" && !(t.until !== null && e.time < t.until) || this.rebaseReplay(e.kind));
|
|
3957
|
+
}
|
|
3958
|
+
rebaseReplay(e) {
|
|
3959
|
+
let t = this.replaySession;
|
|
3960
|
+
if (!t) return;
|
|
3961
|
+
let n = this.series.inHoursShown(this.series.liveBars());
|
|
3962
|
+
if (n.length === 0) return;
|
|
3963
|
+
let r = t.windowTime === null ? 0 : Math.min(J(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
|
|
3964
|
+
this.useReplayLoader(t, !1);
|
|
3965
|
+
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : ri(o ?? i, t.until);
|
|
3966
|
+
if (s < 0 && this.canPageBackForReplay(t)) {
|
|
3967
|
+
this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
|
|
3968
|
+
return;
|
|
3969
|
+
}
|
|
3970
|
+
let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
|
|
3971
|
+
l || (t.held = null), t.symbol = this.currentSymbol;
|
|
3972
|
+
let d = this.replayManager.remainingMs();
|
|
3973
|
+
this.clearBarHolders(), t.animate && ni(t, this.replayCoarse, i);
|
|
3974
|
+
let f = this.replayRestarting;
|
|
3975
|
+
this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
|
|
3976
|
+
try {
|
|
3977
|
+
this.buildReplay(i, a, r), this.restartReplayAt(Math.max(0, s), d, !l && u === "playing");
|
|
3978
|
+
} finally {
|
|
3979
|
+
this.replayRestarting = f, this.replayCause = null;
|
|
3980
|
+
}
|
|
3981
|
+
let p = this.getReplayState();
|
|
3982
|
+
p !== c && !f && this.eventBus.emit("replayState", { state: p }), this.emitBars(this.series.length());
|
|
3983
|
+
}
|
|
3984
|
+
restartReplayAt(e, t, n) {
|
|
3985
|
+
this.replayManager.play({
|
|
3986
|
+
paused: !0,
|
|
3987
|
+
startIndex: e,
|
|
3988
|
+
...t === null ? {} : { duration: t }
|
|
3989
|
+
}), n && this.replayManager.resume();
|
|
3990
|
+
}
|
|
3991
|
+
clearBarHolders() {
|
|
3992
|
+
this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.sessionBreaks.invalidateCache();
|
|
3993
|
+
}
|
|
3994
|
+
replayStepsOver(e, t, n = !1) {
|
|
3995
|
+
if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
|
|
3996
|
+
let r = ci(this.series.inHoursShown(e.steps), t);
|
|
3997
|
+
return r && (n || ai(r, t)) ? r : null;
|
|
3998
|
+
}
|
|
3999
|
+
canPageBackForReplay(e) {
|
|
4000
|
+
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < Zr;
|
|
4001
|
+
}
|
|
4002
|
+
async pageBackForReplay(e) {
|
|
4003
|
+
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = Zr, this.rebaseReplay("older"));
|
|
4004
|
+
}
|
|
4005
|
+
holdReplay() {
|
|
4006
|
+
let e = this.replaySession;
|
|
4007
|
+
if (!e || e.held) return;
|
|
4008
|
+
let t = this.replayManager.getState() === "playing" ? "playing" : "paused", n = this.replayRestarting;
|
|
4009
|
+
this.replayRestarting = !0;
|
|
4010
|
+
try {
|
|
4011
|
+
this.replayManager.pause();
|
|
4012
|
+
} finally {
|
|
4013
|
+
this.replayRestarting = n;
|
|
4014
|
+
}
|
|
4015
|
+
e.held = {
|
|
4016
|
+
state: t,
|
|
4017
|
+
pagesBack: 0
|
|
4018
|
+
};
|
|
4019
|
+
}
|
|
4020
|
+
holdReplayFor(e) {
|
|
4021
|
+
this.replaySession && (this.replayEndsFor(e) ? this.replayStop() : this.holdReplay());
|
|
4022
|
+
}
|
|
4023
|
+
replayEndsFor(e) {
|
|
4024
|
+
let t = this.replaySession;
|
|
4025
|
+
return t !== null && this.replayTrades() && e !== t.symbol;
|
|
4026
|
+
}
|
|
4027
|
+
replayPages() {
|
|
4028
|
+
let e = this.replaySession;
|
|
4029
|
+
return e === null || e.windowTime === null && e.held === null;
|
|
3367
4030
|
}
|
|
3368
4031
|
revealReplayMarks(e) {
|
|
3369
4032
|
let t = e !== null && this.replayOffset > 0 ? this.replayCoarse?.[0]?.time ?? -Infinity : -Infinity;
|
|
3370
4033
|
this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
|
|
3371
4034
|
}
|
|
3372
4035
|
replaySeekToTime(e) {
|
|
3373
|
-
|
|
3374
|
-
let t = this.replayStepsSeries ?? this.replayCoarse, n = 0, r = t.length - 1;
|
|
3375
|
-
for (; n < r;) {
|
|
3376
|
-
let i = n + r + 1 >> 1;
|
|
3377
|
-
t[i].time < e ? n = i : r = i - 1;
|
|
3378
|
-
}
|
|
3379
|
-
this.replaySeek(n);
|
|
4036
|
+
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, ri(this.replayStepsSeries ?? this.replayCoarse, e)));
|
|
3380
4037
|
}
|
|
3381
4038
|
feedReplayPrice(e, t) {
|
|
3382
4039
|
let n = this.executionAdapter;
|
|
@@ -3396,26 +4053,31 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3396
4053
|
return;
|
|
3397
4054
|
}
|
|
3398
4055
|
if (i.time <= n.fedTime) return;
|
|
3399
|
-
let a = e.slice(
|
|
4056
|
+
let a = e.slice(Y(e, n.fedTime), t + 1);
|
|
3400
4057
|
n.fedTime = i.time;
|
|
3401
|
-
let o = Math.ceil(a.length /
|
|
3402
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
4058
|
+
let o = Math.ceil(a.length / oi);
|
|
4059
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of si(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
3403
4060
|
this.tradingManager.setCurrentPrice(i.close);
|
|
3404
4061
|
}
|
|
3405
4062
|
getReplayBarIndex() {
|
|
3406
4063
|
if (!this.replaySession) return -1;
|
|
4064
|
+
if (this.replayForming) return this.replayForming.index;
|
|
3407
4065
|
let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
|
|
3408
|
-
return t && this.replayCoarse ?
|
|
4066
|
+
return t && this.replayCoarse ? Z(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
|
|
3409
4067
|
}
|
|
3410
4068
|
replaySeekToBar(e) {
|
|
3411
4069
|
let t = this.replayStepsSeries;
|
|
3412
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
4070
|
+
this.replaySeek(t && this.replayCoarse ? li(t, this.replayCoarse, e) : e);
|
|
3413
4071
|
}
|
|
3414
4072
|
replayPause() {
|
|
3415
|
-
this.replayManager.pause();
|
|
4073
|
+
this.setHeldState("paused") || this.replayManager.pause();
|
|
3416
4074
|
}
|
|
3417
4075
|
replayResume() {
|
|
3418
|
-
this.replayManager.resume();
|
|
4076
|
+
this.setHeldState("playing") || this.replayManager.resume();
|
|
4077
|
+
}
|
|
4078
|
+
setHeldState(e) {
|
|
4079
|
+
let t = this.replaySession?.held;
|
|
4080
|
+
return t ? (t.state !== e && (t.state = e, this.eventBus.emit("replayState", { state: e })), !0) : !1;
|
|
3419
4081
|
}
|
|
3420
4082
|
replayStop() {
|
|
3421
4083
|
let e = this.replaySession, t = this.endReplaySession();
|
|
@@ -3441,10 +4103,10 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3441
4103
|
data: this.getDisplayData()
|
|
3442
4104
|
}, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
3443
4105
|
for (let e of t.anchors) {
|
|
3444
|
-
let t =
|
|
4106
|
+
let t = Bt(e.time, n), r = Ft(e.price, n);
|
|
3445
4107
|
i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
|
|
3446
4108
|
}
|
|
3447
|
-
return
|
|
4109
|
+
return Rr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), zr.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 ? {
|
|
3448
4110
|
x: i,
|
|
3449
4111
|
y: o,
|
|
3450
4112
|
width: a - i,
|
|
@@ -3455,7 +4117,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3455
4117
|
if (!this.replaySession) return null;
|
|
3456
4118
|
this.returnMarkToLive();
|
|
3457
4119
|
let e = this.series.endReplay();
|
|
3458
|
-
return this.replaySession = null, this.replayStepsSeries = null, this.replayCoarse = null, this.replayBarUnsub?.(), this.replayBarUnsub = null, this.replayManager.stop(), this.replayOffset = 0, this.revealReplayMarks(null), e;
|
|
4120
|
+
return this.replaySession = null, this.replayStepsSeries = null, this.replayCoarse = null, this.replayBarUnsub?.(), this.replayBarUnsub = null, this.replayPhaseUnsub?.(), this.replayPhaseUnsub = null, this.replayLoader?.loader.dispose(), this.replayLoader = null, this.replayPieces = null, this.replayForming = null, this.replayManager.stop(), this.replayOffset = 0, this.revealReplayMarks(null), e;
|
|
3459
4121
|
}
|
|
3460
4122
|
replaySeek(e) {
|
|
3461
4123
|
this.replaySeeking = !0;
|
|
@@ -3469,13 +4131,18 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3469
4131
|
this.replayManager.setSpeed(e);
|
|
3470
4132
|
}
|
|
3471
4133
|
getReplayState() {
|
|
3472
|
-
return this.replayManager.getState();
|
|
4134
|
+
return this.replaySession?.held?.state ?? this.replayManager.getState();
|
|
3473
4135
|
}
|
|
3474
4136
|
getReplayProgress() {
|
|
3475
|
-
|
|
4137
|
+
let e = this.replaySession, t = e ? this.replayCoarse?.[this.getReplayBarIndex()] : void 0;
|
|
4138
|
+
return {
|
|
4139
|
+
...this.replayManager.getProgress(),
|
|
4140
|
+
time: e?.until != null && t ? t.time : null,
|
|
4141
|
+
until: e?.until ?? null
|
|
4142
|
+
};
|
|
3476
4143
|
}
|
|
3477
4144
|
captureSnapshot() {
|
|
3478
|
-
return
|
|
4145
|
+
return T.capture({
|
|
3479
4146
|
getDrawings: () => this.getDrawings(),
|
|
3480
4147
|
getTheme: () => this.themeManager.getBaseTheme(),
|
|
3481
4148
|
getAlerts: () => this.getAlerts(),
|
|
@@ -3488,14 +4155,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3488
4155
|
});
|
|
3489
4156
|
}
|
|
3490
4157
|
restoreIndicators(e, t) {
|
|
3491
|
-
let n =
|
|
4158
|
+
let n = Vr(e), r = /* @__PURE__ */ new Map();
|
|
3492
4159
|
this.unrestoredIndicators = [];
|
|
3493
4160
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
3494
4161
|
if (t) {
|
|
3495
4162
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
3496
4163
|
for (let n of t) {
|
|
3497
4164
|
let t = e.get(n.instanceId);
|
|
3498
|
-
t &&
|
|
4165
|
+
t && Hr(n, t) && o.add(n.instanceId);
|
|
3499
4166
|
}
|
|
3500
4167
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
3501
4168
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -3503,8 +4170,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3503
4170
|
let s = (e) => {
|
|
3504
4171
|
let t = { ...e };
|
|
3505
4172
|
for (let [e, n] of Object.entries(t)) {
|
|
3506
|
-
let i =
|
|
3507
|
-
a && (t[e] =
|
|
4173
|
+
let i = b(n), a = i && r.get(i.instanceId);
|
|
4174
|
+
a && (t[e] = _(a, i.key));
|
|
3508
4175
|
}
|
|
3509
4176
|
return t;
|
|
3510
4177
|
};
|
|
@@ -3557,7 +4224,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3557
4224
|
let s = t.levels ?? null;
|
|
3558
4225
|
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
|
|
3559
4226
|
let c = t.intervals ?? null;
|
|
3560
|
-
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ?
|
|
4227
|
+
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? oe(t.paneStyle) : null);
|
|
3561
4228
|
}
|
|
3562
4229
|
restorePanes(e) {
|
|
3563
4230
|
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, {
|
|
@@ -3662,7 +4329,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3662
4329
|
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
3663
4330
|
let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
|
|
3664
4331
|
if (JSON.stringify(n) === JSON.stringify(i)) return r;
|
|
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) <
|
|
4332
|
+
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Fr && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
|
|
3666
4333
|
type: "indicators",
|
|
3667
4334
|
before: null,
|
|
3668
4335
|
after: null
|
|
@@ -3690,13 +4357,13 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3690
4357
|
}
|
|
3691
4358
|
saveState(e) {
|
|
3692
4359
|
if (!this.features.saveLoad) return null;
|
|
3693
|
-
let t = this.captureSnapshot(), n =
|
|
3694
|
-
return e &&
|
|
4360
|
+
let t = this.captureSnapshot(), n = T.serialize(t);
|
|
4361
|
+
return e && T.saveToStorage(e, t), n;
|
|
3695
4362
|
}
|
|
3696
4363
|
loadState(e) {
|
|
3697
4364
|
if (!this.features.saveLoad) return;
|
|
3698
|
-
let t =
|
|
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");
|
|
4365
|
+
let t = T.deserialize(e);
|
|
4366
|
+
this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, this.reshapeMemo.clear(), 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");
|
|
3700
4367
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
3701
4368
|
if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
|
|
3702
4369
|
this.alertManager.clearAlerts();
|
|
@@ -3706,7 +4373,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3706
4373
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
3707
4374
|
return r ? r + e.slice(t) : e;
|
|
3708
4375
|
}, r = t(e.channel), i = {
|
|
3709
|
-
...
|
|
4376
|
+
...Lt(e),
|
|
3710
4377
|
...e.target ? { target: t(e.target) } : {}
|
|
3711
4378
|
};
|
|
3712
4379
|
if (!e.expired) {
|
|
@@ -3726,28 +4393,28 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3726
4393
|
}
|
|
3727
4394
|
loadStateFromStorage(e) {
|
|
3728
4395
|
if (!this.features.saveLoad) return !1;
|
|
3729
|
-
let t =
|
|
3730
|
-
return t ? (this.loadState(
|
|
4396
|
+
let t = T.loadFromStorage(e);
|
|
4397
|
+
return t ? (this.loadState(T.serialize(t)), !0) : !1;
|
|
3731
4398
|
}
|
|
3732
4399
|
downloadState(e) {
|
|
3733
|
-
this.features.saveLoad &&
|
|
4400
|
+
this.features.saveLoad && T.downloadFile(this.captureSnapshot(), e);
|
|
3734
4401
|
}
|
|
3735
4402
|
async loadStateFromFile() {
|
|
3736
4403
|
if (!this.features.saveLoad) return;
|
|
3737
|
-
let e = await
|
|
3738
|
-
this.loadState(
|
|
4404
|
+
let e = await T.loadFromFile();
|
|
4405
|
+
this.loadState(T.serialize(e));
|
|
3739
4406
|
}
|
|
3740
4407
|
setLocale(e) {
|
|
3741
|
-
|
|
4408
|
+
ce(e), this.engine.requestRender();
|
|
3742
4409
|
}
|
|
3743
4410
|
setNumberLocale(e) {
|
|
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();
|
|
4411
|
+
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.pinnedTooltip.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
|
|
3745
4412
|
}
|
|
3746
4413
|
getNumberLocale() {
|
|
3747
4414
|
return this.numberLocale;
|
|
3748
4415
|
}
|
|
3749
4416
|
setMarket(e) {
|
|
3750
|
-
if (this.marketConfig = e, this.timeZoneSetting === "exchange" && this.applyTimeZone(), e.colorScheme) {
|
|
4417
|
+
if (this.marketConfig = e, this.studyZoneHeld = !1, this.endStudyZoneWait(), this.timeZoneSetting === "exchange" && this.applyTimeZone(), this.applyExchangeZone(), e.colorScheme) {
|
|
3751
4418
|
let t = {
|
|
3752
4419
|
...this.themeManager.getBaseTheme(),
|
|
3753
4420
|
candleUp: e.colorScheme.up,
|
|
@@ -3757,17 +4424,17 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3757
4424
|
};
|
|
3758
4425
|
this.themeManager.setTheme(t);
|
|
3759
4426
|
}
|
|
3760
|
-
e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
|
|
4427
|
+
e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender(), this.eventBus.emit("marketChange", { market: e });
|
|
3761
4428
|
}
|
|
3762
4429
|
applyPricePrecision(e) {
|
|
3763
|
-
this.marketPricePrecision = e, this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e), this.tradeZoneManager.setPricePrecision(e), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
|
|
4430
|
+
this.marketPricePrecision = e, this.viewport.setPricePrecision(e), this.pinnedTooltip.setPricePrecision(e), this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e), this.tradeZoneManager.setPricePrecision(e), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
|
|
3764
4431
|
}
|
|
3765
4432
|
getMarket() {
|
|
3766
4433
|
return this.marketConfig;
|
|
3767
4434
|
}
|
|
3768
4435
|
getPriceLimits() {
|
|
3769
4436
|
let e = this.marketConfig;
|
|
3770
|
-
return !e?.priceLimits?.enabled || !e.priceLimits.referencePrice ? null :
|
|
4437
|
+
return !e?.priceLimits?.enabled || !e.priceLimits.referencePrice ? null : p(e.priceLimits.referencePrice, e);
|
|
3771
4438
|
}
|
|
3772
4439
|
setPriceLimits(e) {
|
|
3773
4440
|
this.marketConfig?.priceLimits && (this.marketConfig = {
|
|
@@ -3797,18 +4464,24 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3797
4464
|
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 = "";
|
|
3798
4465
|
}
|
|
3799
4466
|
createChartRenderer(e) {
|
|
3800
|
-
let t =
|
|
3801
|
-
return t instanceof
|
|
4467
|
+
let t = Cn(e, (e) => this.pluginManager.getChartType(e));
|
|
4468
|
+
return t instanceof Le && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
3802
4469
|
}
|
|
3803
4470
|
crosshairSeries() {
|
|
3804
4471
|
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
3805
4472
|
}
|
|
3806
4473
|
getDisplayData() {
|
|
3807
|
-
|
|
3808
|
-
|
|
4474
|
+
let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? bn(e, (e) => this.stepAt(e)) : void 0;
|
|
4475
|
+
if (this.displayDataCache && t === this.displayDataStep) return this.displayDataCache;
|
|
3809
4476
|
if (e.length === 0) return e;
|
|
3810
|
-
let
|
|
3811
|
-
return this.
|
|
4477
|
+
let n = this.displaySeries(e, t);
|
|
4478
|
+
return this.displayDataCache = n, this.displayDataStep = t, n;
|
|
4479
|
+
}
|
|
4480
|
+
displaySeries(e, t) {
|
|
4481
|
+
let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
|
|
4482
|
+
if (n !== "pointAndFigure" || r(n)) return wn(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
|
|
4483
|
+
let { columns: i, boxSize: a } = un(e, this.chartTypeOptions, this.reshapeMemo);
|
|
4484
|
+
return this.chartRenderer instanceof Qe && this.chartRenderer.setBoxSize(a), i;
|
|
3812
4485
|
}
|
|
3813
4486
|
recalcIndicatorsFrom(e, t) {
|
|
3814
4487
|
this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
|
|
@@ -3850,23 +4523,23 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3850
4523
|
this.panelInfoCache = null, this.fitDataAndAxes(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
3851
4524
|
}
|
|
3852
4525
|
applyDataToViewport(e = !1) {
|
|
3853
|
-
let t = this.getDisplayData(), n = this.options.autoScale !== !1;
|
|
4526
|
+
let t = this.getDisplayData(), n = this.options.autoScale !== !1 || this.priceFitPending;
|
|
3854
4527
|
this.viewport.updateData(t, !1), e && (this.viewport.scrollToEnd(), this.viewport.updateData(t, !1));
|
|
3855
4528
|
let r = this.viewport.getState();
|
|
3856
4529
|
if (t.length > 0) {
|
|
3857
4530
|
let e = Math.max(0, Math.min(r.visibleRange.from, t.length - 1));
|
|
3858
4531
|
this.viewport.setScaleBaseline(t[e]?.close);
|
|
3859
4532
|
}
|
|
3860
|
-
return n && this.fitPriceScale(t,
|
|
4533
|
+
return n && this.fitPriceScale(t, this.viewport.getState()), t;
|
|
3861
4534
|
}
|
|
3862
4535
|
fitPriceScale(e, t) {
|
|
3863
4536
|
if (e.length === 0) return;
|
|
3864
|
-
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i =
|
|
4537
|
+
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = Jr(Jr(m(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && qr(e, n, r) ? this.volumeRenderer.getHeightRatio() + Pr : D;
|
|
3865
4538
|
this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
|
|
3866
4539
|
top: a,
|
|
3867
|
-
bottom:
|
|
4540
|
+
bottom: D
|
|
3868
4541
|
} : {
|
|
3869
|
-
top:
|
|
4542
|
+
top: D,
|
|
3870
4543
|
bottom: a
|
|
3871
4544
|
}), this.viewport.fitToPrices(i.min, i.max);
|
|
3872
4545
|
}
|
|
@@ -3876,14 +4549,19 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3876
4549
|
this.viewport.setChartRect(t.mainChartRect), this.fitDataAndAxes(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
3877
4550
|
}
|
|
3878
4551
|
fitDataAndAxes(e = !1) {
|
|
3879
|
-
this.applyDataToViewport(e);
|
|
3880
|
-
|
|
3881
|
-
|
|
4552
|
+
let t = this.applyDataToViewport(e), n = this.fitPriceAxisWidth();
|
|
4553
|
+
this.leftViewport = this.computeLeftViewport(), (this.fitLeftAxisWidth() || n) && this.applyDataToViewport(e), this.priceFitPending && this.priceFitDone(t) && (this.priceFitPending = !1);
|
|
4554
|
+
}
|
|
4555
|
+
priceFitDone(e) {
|
|
4556
|
+
let { chartRect: t, offset: n, barWidth: r, barSpacing: i } = this.viewport.getState();
|
|
4557
|
+
if (e.length === 0 || t.width <= 0) return !1;
|
|
4558
|
+
let a = n <= 0 && e.length * (r + i) - n <= t.width;
|
|
4559
|
+
return !(this.seriesArriving && a);
|
|
3882
4560
|
}
|
|
3883
4561
|
fitLeftAxisWidth() {
|
|
3884
4562
|
let e = this.leftViewport;
|
|
3885
4563
|
if (!e) return !1;
|
|
3886
|
-
let t = this.themeManager.getTheme(), n =
|
|
4564
|
+
let t = this.themeManager.getTheme(), n = Yn({
|
|
3887
4565
|
min: e.priceRange.min,
|
|
3888
4566
|
max: e.priceRange.max,
|
|
3889
4567
|
lastPrice: null,
|
|
@@ -3892,12 +4570,12 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3892
4570
|
fontFamily: t.font.family,
|
|
3893
4571
|
fontSizeSmall: t.font.sizeSmall,
|
|
3894
4572
|
measure: (e, t) => this.measureText(e, t)
|
|
3895
|
-
}), r =
|
|
4573
|
+
}), r = Xn(this.leftAxisWidth, n);
|
|
3896
4574
|
return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
3897
4575
|
}
|
|
3898
4576
|
fitPriceAxisWidth() {
|
|
3899
4577
|
if (!this.features.priceAxis) return !1;
|
|
3900
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
4578
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = Yn({
|
|
3901
4579
|
min: e.min,
|
|
3902
4580
|
max: e.max,
|
|
3903
4581
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -3908,14 +4586,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3908
4586
|
fontFamily: t.font.family,
|
|
3909
4587
|
fontSizeSmall: t.font.sizeSmall,
|
|
3910
4588
|
measure: (e, t) => this.measureText(e, t)
|
|
3911
|
-
}), r =
|
|
4589
|
+
}), r = Xn(this.priceAxisWidth, n);
|
|
3912
4590
|
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);
|
|
3913
4591
|
}
|
|
3914
4592
|
measureText(e, t) {
|
|
3915
4593
|
let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
|
|
3916
|
-
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () =>
|
|
4594
|
+
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => Ur(n, e, t));
|
|
3917
4595
|
let i = n ?? this.detachedMeasureContext();
|
|
3918
|
-
return i ?
|
|
4596
|
+
return i ? Ur(i, e, t) : e.length * 7;
|
|
3919
4597
|
}
|
|
3920
4598
|
detachedMeasureContext() {
|
|
3921
4599
|
return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
|
|
@@ -3956,7 +4634,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3956
4634
|
buildPanelRenderInfos() {
|
|
3957
4635
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
3958
4636
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
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) ?? { ...
|
|
4637
|
+
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) ?? { ...Or }, o = {
|
|
3960
4638
|
x: e.rect.x,
|
|
3961
4639
|
y: e.rect.y + 20,
|
|
3962
4640
|
width: e.rect.width,
|
|
@@ -3975,6 +4653,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
3975
4653
|
scaleMode: e.config.percentScale ? "percentage" : "regular",
|
|
3976
4654
|
scaleBaseline: e.config.percentScale ? this.paneBaseline(e.config.id, n, r) : void 0,
|
|
3977
4655
|
formatPrice: void 0,
|
|
4656
|
+
pricePrecision: void 0,
|
|
3978
4657
|
priceUnit: void 0,
|
|
3979
4658
|
invertScale: !!e.config.invertScale
|
|
3980
4659
|
}
|
|
@@ -4014,7 +4693,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
4014
4693
|
barCountdown: this.barCountdown,
|
|
4015
4694
|
sessionBreaks: this.sessionBreaks,
|
|
4016
4695
|
sessionShading: this.sessionShading,
|
|
4017
|
-
compareRenderer: this.compareRenderer,
|
|
4696
|
+
compareRenderer: this.comparesDrawn() ? this.compareRenderer : null,
|
|
4018
4697
|
alertManager: this.features.alerts ? this.alertManager : null,
|
|
4019
4698
|
measureOverlay: this.measureOverlay,
|
|
4020
4699
|
selectionBoxOverlay: this.selectionBoxOverlay,
|
|
@@ -4030,6 +4709,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
4030
4709
|
},
|
|
4031
4710
|
theme: this.themeManager.getTheme(),
|
|
4032
4711
|
data: n,
|
|
4712
|
+
seriesRevision: this.series.revision(),
|
|
4033
4713
|
numberLocale: this.numberLocale,
|
|
4034
4714
|
paneTitles: this.paneTitles,
|
|
4035
4715
|
indicatorValueLabels: this.features.indicatorValueLabels,
|
|
@@ -4038,7 +4718,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
4038
4718
|
});
|
|
4039
4719
|
}
|
|
4040
4720
|
drawOverlayPlugins(e, t) {
|
|
4041
|
-
let n =
|
|
4721
|
+
let n = tr(this.pluginManager.getOverlays(), t);
|
|
4042
4722
|
if (n.length === 0) return;
|
|
4043
4723
|
let r = {
|
|
4044
4724
|
viewport: this.viewport.getState(),
|
|
@@ -4059,11 +4739,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
|
|
|
4059
4739
|
};
|
|
4060
4740
|
}
|
|
4061
4741
|
};
|
|
4062
|
-
function
|
|
4742
|
+
function Vr(e) {
|
|
4063
4743
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
4064
4744
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
4065
4745
|
i.add(e.instanceId);
|
|
4066
|
-
let o = [e.pane, ...Object.values(e.params).map((e) =>
|
|
4746
|
+
let o = [e.pane, ...Object.values(e.params).map((e) => b(e)?.instanceId)];
|
|
4067
4747
|
for (let e of o) {
|
|
4068
4748
|
let n = e ? t.get(e) : void 0;
|
|
4069
4749
|
n && a(n);
|
|
@@ -4073,19 +4753,19 @@ function $n(e) {
|
|
|
4073
4753
|
for (let t of e) a(t);
|
|
4074
4754
|
return n;
|
|
4075
4755
|
}
|
|
4076
|
-
function
|
|
4756
|
+
function Hr(e, t) {
|
|
4077
4757
|
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);
|
|
4078
4758
|
}
|
|
4079
|
-
function
|
|
4759
|
+
function Ur(e, t, n) {
|
|
4080
4760
|
let r = e.font;
|
|
4081
4761
|
e.font = n;
|
|
4082
4762
|
let i = e.measureText(t).width;
|
|
4083
4763
|
return e.font = r, i;
|
|
4084
4764
|
}
|
|
4085
|
-
var
|
|
4086
|
-
function
|
|
4765
|
+
var Wr = 300;
|
|
4766
|
+
function Gr(e) {
|
|
4087
4767
|
let t = {}, n = e.family;
|
|
4088
|
-
typeof n == "string" && n.trim() !== "" && n.length <=
|
|
4768
|
+
typeof n == "string" && n.trim() !== "" && n.length <= Wr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
|
|
4089
4769
|
for (let n of [
|
|
4090
4770
|
"sizeSmall",
|
|
4091
4771
|
"sizeMedium",
|
|
@@ -4096,15 +4776,15 @@ function rr(e) {
|
|
|
4096
4776
|
}
|
|
4097
4777
|
return t;
|
|
4098
4778
|
}
|
|
4099
|
-
function
|
|
4779
|
+
function Kr(e) {
|
|
4100
4780
|
let t = e.tagRadius;
|
|
4101
4781
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
4102
4782
|
}
|
|
4103
|
-
function
|
|
4783
|
+
function qr(e, t, n) {
|
|
4104
4784
|
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
4105
4785
|
return !1;
|
|
4106
4786
|
}
|
|
4107
|
-
function
|
|
4787
|
+
function Jr(e, t) {
|
|
4108
4788
|
return e ? t ? {
|
|
4109
4789
|
min: Math.min(e.min, t.min),
|
|
4110
4790
|
max: Math.max(e.max, t.max)
|
|
@@ -4125,8 +4805,64 @@ function q(e) {
|
|
|
4125
4805
|
bars: e.bars
|
|
4126
4806
|
};
|
|
4127
4807
|
}
|
|
4128
|
-
var
|
|
4129
|
-
|
|
4808
|
+
var Yr = 8e3, Xr = new Set([
|
|
4809
|
+
"candlestick",
|
|
4810
|
+
"line",
|
|
4811
|
+
"area",
|
|
4812
|
+
"bar",
|
|
4813
|
+
"hollowCandle"
|
|
4814
|
+
]), Zr = 10, Qr = 50, $r = .001;
|
|
4815
|
+
function ei(e) {
|
|
4816
|
+
return {
|
|
4817
|
+
price: null,
|
|
4818
|
+
fedTime: null,
|
|
4819
|
+
fedFraction: 1,
|
|
4820
|
+
animate: !1,
|
|
4821
|
+
step: null,
|
|
4822
|
+
until: null,
|
|
4823
|
+
windowTime: null,
|
|
4824
|
+
steps: null,
|
|
4825
|
+
stepsSymbol: e,
|
|
4826
|
+
symbol: e,
|
|
4827
|
+
held: null
|
|
4828
|
+
};
|
|
4829
|
+
}
|
|
4830
|
+
function ti(e, t) {
|
|
4831
|
+
let n = e[t + 1];
|
|
4832
|
+
return n ? n.time - e[t].time : X(e);
|
|
4833
|
+
}
|
|
4834
|
+
function ni(e, t, n) {
|
|
4835
|
+
let r = e.fedTime;
|
|
4836
|
+
if (r === null || !t || t.length === 0 || n.length === 0) return;
|
|
4837
|
+
let i = ti(t, Z(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Z(n, a), s = n[o].time;
|
|
4838
|
+
if (s > a) return;
|
|
4839
|
+
let c = ti(n, o);
|
|
4840
|
+
if (a === s && o > 0) {
|
|
4841
|
+
e.fedTime = n[o - 1].time, e.fedFraction = 1;
|
|
4842
|
+
return;
|
|
4843
|
+
}
|
|
4844
|
+
e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
|
|
4845
|
+
}
|
|
4846
|
+
function ri(e, t) {
|
|
4847
|
+
let n = Y(e, t), r = e.length - 1;
|
|
4848
|
+
return n > r && r >= 0 && e[r].time + X(e) <= t ? r : Math.max(-1, n - 2);
|
|
4849
|
+
}
|
|
4850
|
+
function ii(e) {
|
|
4851
|
+
let t = Infinity;
|
|
4852
|
+
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
|
|
4853
|
+
return t;
|
|
4854
|
+
}
|
|
4855
|
+
function ai(e, t) {
|
|
4856
|
+
if (!(ii(e) < ii(t))) return !1;
|
|
4857
|
+
let n = Math.max(0, e.length - Qr);
|
|
4858
|
+
for (let r = n; r < e.length; r++) {
|
|
4859
|
+
let n = t[Z(t, e[r].time)], i = (n.high - n.low) * $r + 2 ** -52;
|
|
4860
|
+
if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
|
|
4861
|
+
}
|
|
4862
|
+
return !0;
|
|
4863
|
+
}
|
|
4864
|
+
var oi = 500;
|
|
4865
|
+
function J(e, t) {
|
|
4130
4866
|
let n = 0, r = e.length;
|
|
4131
4867
|
for (; n < r;) {
|
|
4132
4868
|
let i = n + r >> 1;
|
|
@@ -4134,7 +4870,7 @@ function cr(e, t) {
|
|
|
4134
4870
|
}
|
|
4135
4871
|
return n;
|
|
4136
4872
|
}
|
|
4137
|
-
function
|
|
4873
|
+
function Y(e, t) {
|
|
4138
4874
|
let n = 0, r = e.length;
|
|
4139
4875
|
for (; n < r;) {
|
|
4140
4876
|
let i = n + r >> 1;
|
|
@@ -4142,20 +4878,20 @@ function lr(e, t) {
|
|
|
4142
4878
|
}
|
|
4143
4879
|
return n;
|
|
4144
4880
|
}
|
|
4145
|
-
function
|
|
4881
|
+
function si(e) {
|
|
4146
4882
|
let t = 0, n = 0;
|
|
4147
4883
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
4148
4884
|
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];
|
|
4149
4885
|
return [...a ? [r, i] : [i, r], [o.close, o.time]];
|
|
4150
4886
|
}
|
|
4151
|
-
function
|
|
4887
|
+
function X(e) {
|
|
4152
4888
|
let t = 0;
|
|
4153
4889
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
4154
4890
|
return t > 0 ? t : Infinity;
|
|
4155
4891
|
}
|
|
4156
|
-
function
|
|
4892
|
+
function ci(e, t) {
|
|
4157
4893
|
if (t.length === 0) return null;
|
|
4158
|
-
let n = t[t.length - 1].time +
|
|
4894
|
+
let n = t[t.length - 1].time + X(t), r = e.filter((e) => jn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
4159
4895
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
4160
4896
|
if (i.length === 0) return null;
|
|
4161
4897
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -4163,7 +4899,7 @@ function fr(e, t) {
|
|
|
4163
4899
|
let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
|
|
4164
4900
|
return [...o, ...s];
|
|
4165
4901
|
}
|
|
4166
|
-
function
|
|
4902
|
+
function Z(e, t) {
|
|
4167
4903
|
let n = 0, r = e.length - 1;
|
|
4168
4904
|
for (; n < r;) {
|
|
4169
4905
|
let i = n + r + 1 >> 1;
|
|
@@ -4171,22 +4907,37 @@ function pr(e, t) {
|
|
|
4171
4907
|
}
|
|
4172
4908
|
return n;
|
|
4173
4909
|
}
|
|
4174
|
-
function
|
|
4910
|
+
function li(e, t, n) {
|
|
4175
4911
|
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;
|
|
4176
4912
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
4177
4913
|
return Math.max(0, a);
|
|
4178
4914
|
}
|
|
4179
|
-
function
|
|
4915
|
+
function ui(e, t, n) {
|
|
4180
4916
|
let r = n;
|
|
4181
4917
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
4182
4918
|
let i = {
|
|
4183
4919
|
...t[r],
|
|
4184
4920
|
time: e.time
|
|
4185
4921
|
};
|
|
4186
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
4922
|
+
for (let e = r + 1; e <= n; e++) i = mi(i, t[e]);
|
|
4187
4923
|
return i;
|
|
4188
4924
|
}
|
|
4189
|
-
function
|
|
4925
|
+
function di(e, t, n, r) {
|
|
4926
|
+
let i = e[n + 1], a = t[r + 1];
|
|
4927
|
+
return i !== void 0 && a !== void 0 && i.time >= a.time;
|
|
4928
|
+
}
|
|
4929
|
+
function fi(e, t) {
|
|
4930
|
+
let n = /* @__PURE__ */ new Map();
|
|
4931
|
+
for (let r of e) {
|
|
4932
|
+
let e = t[Z(t, r.time)].time, i = n.get(e);
|
|
4933
|
+
i ? i.push(r) : n.set(e, [r]);
|
|
4934
|
+
}
|
|
4935
|
+
return n;
|
|
4936
|
+
}
|
|
4937
|
+
function pi() {
|
|
4938
|
+
return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4939
|
+
}
|
|
4940
|
+
function mi(e, t) {
|
|
4190
4941
|
return {
|
|
4191
4942
|
time: e.time,
|
|
4192
4943
|
open: e.open,
|
|
@@ -4198,26 +4949,26 @@ function gr(e, t) {
|
|
|
4198
4949
|
}
|
|
4199
4950
|
//#endregion
|
|
4200
4951
|
//#region src/io/parseOHLCV.ts
|
|
4201
|
-
var
|
|
4952
|
+
var hi = [
|
|
4202
4953
|
"time",
|
|
4203
4954
|
"timestamp",
|
|
4204
4955
|
"date",
|
|
4205
4956
|
"datetime",
|
|
4206
4957
|
"t"
|
|
4207
|
-
],
|
|
4958
|
+
], gi = ["open", "o"], _i = ["high", "h"], vi = ["low", "l"], yi = ["close", "c"], bi = [
|
|
4208
4959
|
"volume",
|
|
4209
4960
|
"vol",
|
|
4210
4961
|
"v"
|
|
4211
4962
|
];
|
|
4212
|
-
function
|
|
4963
|
+
function xi(e) {
|
|
4213
4964
|
let t = e.trim();
|
|
4214
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
4965
|
+
return t ? t[0] === "[" || t[0] === "{" ? Si(t) : Ci(t) : {
|
|
4215
4966
|
data: [],
|
|
4216
4967
|
rowCount: 0,
|
|
4217
4968
|
skipped: 0
|
|
4218
4969
|
};
|
|
4219
4970
|
}
|
|
4220
|
-
function
|
|
4971
|
+
function Si(e) {
|
|
4221
4972
|
let t;
|
|
4222
4973
|
try {
|
|
4223
4974
|
t = JSON.parse(e);
|
|
@@ -4227,19 +4978,19 @@ function wr(e) {
|
|
|
4227
4978
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
4228
4979
|
let n = [], r = 0;
|
|
4229
4980
|
for (let e of t) {
|
|
4230
|
-
let t = Array.isArray(e) ?
|
|
4981
|
+
let t = Array.isArray(e) ? Oi(e) : Di(e);
|
|
4231
4982
|
t ? n.push(t) : r++;
|
|
4232
4983
|
}
|
|
4233
|
-
return
|
|
4984
|
+
return Ai(n, t.length, r);
|
|
4234
4985
|
}
|
|
4235
|
-
function
|
|
4986
|
+
function Ci(e) {
|
|
4236
4987
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
4237
4988
|
if (t.length === 0) return {
|
|
4238
4989
|
data: [],
|
|
4239
4990
|
rowCount: 0,
|
|
4240
4991
|
skipped: 0
|
|
4241
4992
|
};
|
|
4242
|
-
let n =
|
|
4993
|
+
let n = wi(t[0]), r = Ti(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ei(r) : {
|
|
4243
4994
|
time: 0,
|
|
4244
4995
|
open: 1,
|
|
4245
4996
|
high: 2,
|
|
@@ -4250,7 +5001,7 @@ function Tr(e) {
|
|
|
4250
5001
|
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");
|
|
4251
5002
|
let o = [], s = 0;
|
|
4252
5003
|
for (let e = +!!i; e < t.length; e++) {
|
|
4253
|
-
let r =
|
|
5004
|
+
let r = Ti(t[e], n), i = ki(r[a.time]), c = Q(r[a.open]), l = Q(r[a.high]), u = Q(r[a.low]), d = Q(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
4254
5005
|
if (i === null || ![
|
|
4255
5006
|
c,
|
|
4256
5007
|
l,
|
|
@@ -4269,9 +5020,9 @@ function Tr(e) {
|
|
|
4269
5020
|
volume: Number.isFinite(f) ? f : 0
|
|
4270
5021
|
});
|
|
4271
5022
|
}
|
|
4272
|
-
return
|
|
5023
|
+
return Ai(o, t.length - +!!i, s);
|
|
4273
5024
|
}
|
|
4274
|
-
function
|
|
5025
|
+
function wi(e) {
|
|
4275
5026
|
let t = {
|
|
4276
5027
|
",": 0,
|
|
4277
5028
|
";": 0,
|
|
@@ -4283,7 +5034,7 @@ function Er(e) {
|
|
|
4283
5034
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
4284
5035
|
return n;
|
|
4285
5036
|
}
|
|
4286
|
-
function
|
|
5037
|
+
function Ti(e, t) {
|
|
4287
5038
|
let n = [], r = "", i = !1;
|
|
4288
5039
|
for (let a = 0; a < e.length; a++) {
|
|
4289
5040
|
let o = e[a];
|
|
@@ -4291,25 +5042,25 @@ function Dr(e, t) {
|
|
|
4291
5042
|
}
|
|
4292
5043
|
return n.push(r), n;
|
|
4293
5044
|
}
|
|
4294
|
-
function
|
|
5045
|
+
function Ei(e) {
|
|
4295
5046
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
4296
5047
|
return {
|
|
4297
|
-
time: t(
|
|
4298
|
-
open: t(
|
|
4299
|
-
high: t(
|
|
4300
|
-
low: t(
|
|
4301
|
-
close: t(
|
|
4302
|
-
volume: t(
|
|
5048
|
+
time: t(hi),
|
|
5049
|
+
open: t(gi),
|
|
5050
|
+
high: t(_i),
|
|
5051
|
+
low: t(vi),
|
|
5052
|
+
close: t(yi),
|
|
5053
|
+
volume: t(bi)
|
|
4303
5054
|
};
|
|
4304
5055
|
}
|
|
4305
|
-
function
|
|
5056
|
+
function Di(e) {
|
|
4306
5057
|
let t = (t) => {
|
|
4307
5058
|
for (let n of t) {
|
|
4308
5059
|
if (e[n] !== void 0) return e[n];
|
|
4309
5060
|
let t = n.toUpperCase();
|
|
4310
5061
|
if (e[t] !== void 0) return e[t];
|
|
4311
5062
|
}
|
|
4312
|
-
}, n =
|
|
5063
|
+
}, n = ki(String(t(hi) ?? "")), r = Number(t(gi)), i = Number(t(_i)), a = Number(t(vi)), o = Number(t(yi)), s = Number(t(bi) ?? 0);
|
|
4313
5064
|
return n === null || ![
|
|
4314
5065
|
r,
|
|
4315
5066
|
i,
|
|
@@ -4324,9 +5075,9 @@ function kr(e) {
|
|
|
4324
5075
|
volume: Number.isFinite(s) ? s : 0
|
|
4325
5076
|
};
|
|
4326
5077
|
}
|
|
4327
|
-
function
|
|
5078
|
+
function Oi(e) {
|
|
4328
5079
|
if (e.length < 5) return null;
|
|
4329
|
-
let t =
|
|
5080
|
+
let t = ki(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;
|
|
4330
5081
|
return t === null || ![
|
|
4331
5082
|
n,
|
|
4332
5083
|
r,
|
|
@@ -4341,18 +5092,18 @@ function Ar(e) {
|
|
|
4341
5092
|
volume: Number.isFinite(o) ? o : 0
|
|
4342
5093
|
};
|
|
4343
5094
|
}
|
|
4344
|
-
function
|
|
5095
|
+
function Q(e) {
|
|
4345
5096
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
4346
5097
|
}
|
|
4347
|
-
function
|
|
5098
|
+
function ki(e) {
|
|
4348
5099
|
let t = e.trim();
|
|
4349
5100
|
if (!t) return null;
|
|
4350
5101
|
let n = Number(t);
|
|
4351
|
-
if (Number.isFinite(n) && n > 0) return
|
|
5102
|
+
if (Number.isFinite(n) && n > 0) return y(n);
|
|
4352
5103
|
let r = Date.parse(t);
|
|
4353
5104
|
return Number.isFinite(r) ? r : null;
|
|
4354
5105
|
}
|
|
4355
|
-
function
|
|
5106
|
+
function Ai(e, t, n) {
|
|
4356
5107
|
e.sort((e, t) => e.time - t.time);
|
|
4357
5108
|
let r = [];
|
|
4358
5109
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -4364,7 +5115,7 @@ function jr(e, t, n) {
|
|
|
4364
5115
|
}
|
|
4365
5116
|
//#endregion
|
|
4366
5117
|
//#region src/io/DragDropImporter.ts
|
|
4367
|
-
var
|
|
5118
|
+
var ji = class {
|
|
4368
5119
|
host;
|
|
4369
5120
|
overlay = null;
|
|
4370
5121
|
callbacks;
|
|
@@ -4385,19 +5136,19 @@ var Mr = class {
|
|
|
4385
5136
|
this.host.removeEventListener("dragenter", this.bound.dragenter), this.host.removeEventListener("dragover", this.bound.dragover), this.host.removeEventListener("dragleave", this.bound.dragleave), this.host.removeEventListener("drop", this.bound.drop), this.hideOverlay();
|
|
4386
5137
|
}
|
|
4387
5138
|
onDragEnter(e) {
|
|
4388
|
-
|
|
5139
|
+
Mi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
4389
5140
|
}
|
|
4390
5141
|
onDragOver(e) {
|
|
4391
|
-
|
|
5142
|
+
Mi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
4392
5143
|
}
|
|
4393
5144
|
onDragLeave(e) {
|
|
4394
|
-
|
|
5145
|
+
Mi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
4395
5146
|
}
|
|
4396
5147
|
async onDrop(e) {
|
|
4397
5148
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
4398
5149
|
let t = e.dataTransfer?.files?.[0];
|
|
4399
5150
|
if (t) try {
|
|
4400
|
-
let e =
|
|
5151
|
+
let e = xi(await t.text());
|
|
4401
5152
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
4402
5153
|
this.callbacks.onData(e.data, e, t);
|
|
4403
5154
|
} catch (e) {
|
|
@@ -4428,12 +5179,12 @@ var Mr = class {
|
|
|
4428
5179
|
this.overlay?.remove(), this.overlay = null;
|
|
4429
5180
|
}
|
|
4430
5181
|
};
|
|
4431
|
-
function
|
|
5182
|
+
function Mi(e) {
|
|
4432
5183
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
4433
5184
|
}
|
|
4434
5185
|
//#endregion
|
|
4435
5186
|
//#region src/state/layoutStorage.ts
|
|
4436
|
-
function
|
|
5187
|
+
function Ni(e) {
|
|
4437
5188
|
let t = {
|
|
4438
5189
|
id: e.id,
|
|
4439
5190
|
name: e.name,
|
|
@@ -4441,11 +5192,11 @@ function Z(e) {
|
|
|
4441
5192
|
};
|
|
4442
5193
|
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;
|
|
4443
5194
|
}
|
|
4444
|
-
var
|
|
4445
|
-
function
|
|
5195
|
+
var Pi = (e, t) => t.updatedAt - e.updatedAt;
|
|
5196
|
+
function Fi(e) {
|
|
4446
5197
|
if (typeof e != "object" || !e) return null;
|
|
4447
5198
|
let t = e;
|
|
4448
|
-
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null :
|
|
5199
|
+
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Ni({
|
|
4449
5200
|
id: t.id,
|
|
4450
5201
|
name: t.name,
|
|
4451
5202
|
updatedAt: t.updatedAt,
|
|
@@ -4454,17 +5205,17 @@ function Q(e) {
|
|
|
4454
5205
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
4455
5206
|
});
|
|
4456
5207
|
}
|
|
4457
|
-
function
|
|
4458
|
-
let t =
|
|
5208
|
+
function Ii(e) {
|
|
5209
|
+
let t = Fi(e), n = t ? e.content : void 0;
|
|
4459
5210
|
return t && typeof n == "string" ? {
|
|
4460
5211
|
...t,
|
|
4461
5212
|
content: n
|
|
4462
5213
|
} : null;
|
|
4463
5214
|
}
|
|
4464
|
-
function
|
|
5215
|
+
function Li(e = []) {
|
|
4465
5216
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
4466
5217
|
return {
|
|
4467
|
-
list: () => [...t.values()].map(
|
|
5218
|
+
list: () => [...t.values()].map(Ni).sort(Pi),
|
|
4468
5219
|
load: (e) => {
|
|
4469
5220
|
let n = t.get(e);
|
|
4470
5221
|
return n ? { ...n } : null;
|
|
@@ -4477,7 +5228,7 @@ function Fr(e = []) {
|
|
|
4477
5228
|
}
|
|
4478
5229
|
};
|
|
4479
5230
|
}
|
|
4480
|
-
function
|
|
5231
|
+
function Ri(e = "tcw:layouts:") {
|
|
4481
5232
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
4482
5233
|
let e;
|
|
4483
5234
|
try {
|
|
@@ -4485,10 +5236,10 @@ function Ir(e = "tcw:layouts:") {
|
|
|
4485
5236
|
} catch {
|
|
4486
5237
|
return [];
|
|
4487
5238
|
}
|
|
4488
|
-
return Array.isArray(e) ? e.map(
|
|
5239
|
+
return Array.isArray(e) ? e.map(Fi).filter((e) => e !== null) : [];
|
|
4489
5240
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
4490
5241
|
return {
|
|
4491
|
-
list: () => r().sort(
|
|
5242
|
+
list: () => r().sort(Pi),
|
|
4492
5243
|
load: (e) => {
|
|
4493
5244
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
4494
5245
|
return t && i !== null ? {
|
|
@@ -4497,7 +5248,7 @@ function Ir(e = "tcw:layouts:") {
|
|
|
4497
5248
|
} : null;
|
|
4498
5249
|
},
|
|
4499
5250
|
save: (e) => {
|
|
4500
|
-
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id),
|
|
5251
|
+
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Ni(e)]);
|
|
4501
5252
|
},
|
|
4502
5253
|
remove: (e) => {
|
|
4503
5254
|
i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
|
|
@@ -4506,14 +5257,14 @@ function Ir(e = "tcw:layouts:") {
|
|
|
4506
5257
|
}
|
|
4507
5258
|
//#endregion
|
|
4508
5259
|
//#region src/state/LayoutSession.ts
|
|
4509
|
-
var
|
|
5260
|
+
var zi = 80;
|
|
4510
5261
|
function $(e) {
|
|
4511
5262
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
4512
5263
|
}
|
|
4513
|
-
function
|
|
5264
|
+
function Bi() {
|
|
4514
5265
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
4515
5266
|
}
|
|
4516
|
-
function
|
|
5267
|
+
function Vi(e) {
|
|
4517
5268
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
4518
5269
|
return {
|
|
4519
5270
|
id: t,
|
|
@@ -4524,7 +5275,7 @@ function zr(e) {
|
|
|
4524
5275
|
...o === void 0 ? {} : { kind: o }
|
|
4525
5276
|
};
|
|
4526
5277
|
}
|
|
4527
|
-
var
|
|
5278
|
+
var Hi = class {
|
|
4528
5279
|
currentLayout = null;
|
|
4529
5280
|
savedContent = null;
|
|
4530
5281
|
dirty = !1;
|
|
@@ -4540,7 +5291,7 @@ var Br = class {
|
|
|
4540
5291
|
now;
|
|
4541
5292
|
newId;
|
|
4542
5293
|
constructor(e, t, n = {}) {
|
|
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 ??
|
|
5294
|
+
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 ?? Bi;
|
|
4544
5295
|
}
|
|
4545
5296
|
current() {
|
|
4546
5297
|
return this.currentLayout;
|
|
@@ -4556,7 +5307,7 @@ var Br = class {
|
|
|
4556
5307
|
}
|
|
4557
5308
|
async list() {
|
|
4558
5309
|
let e = await this.storage.list();
|
|
4559
|
-
return Array.isArray(e) ? e.map(
|
|
5310
|
+
return Array.isArray(e) ? e.map(Fi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
|
|
4560
5311
|
}
|
|
4561
5312
|
save() {
|
|
4562
5313
|
return this.queue(() => {
|
|
@@ -4570,7 +5321,7 @@ var Br = class {
|
|
|
4570
5321
|
}
|
|
4571
5322
|
open(e) {
|
|
4572
5323
|
return this.queue(async () => {
|
|
4573
|
-
let t =
|
|
5324
|
+
let t = Ii(await this.storage.load(e));
|
|
4574
5325
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
4575
5326
|
this.cancelTimer(), this.applying++;
|
|
4576
5327
|
try {
|
|
@@ -4580,13 +5331,13 @@ var Br = class {
|
|
|
4580
5331
|
} finally {
|
|
4581
5332
|
this.applying--;
|
|
4582
5333
|
}
|
|
4583
|
-
return this.cancelTimer(), this.currentLayout =
|
|
5334
|
+
return this.cancelTimer(), this.currentLayout = Vi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
4584
5335
|
});
|
|
4585
5336
|
}
|
|
4586
5337
|
rename(e, t) {
|
|
4587
5338
|
let n = $(t);
|
|
4588
5339
|
return n ? this.queue(async () => {
|
|
4589
|
-
let t =
|
|
5340
|
+
let t = Ii(await this.storage.load(e));
|
|
4590
5341
|
!t || t.id !== e || (await this.storage.save({
|
|
4591
5342
|
...t,
|
|
4592
5343
|
name: n
|
|
@@ -4664,7 +5415,7 @@ var Br = class {
|
|
|
4664
5415
|
content: n.content
|
|
4665
5416
|
};
|
|
4666
5417
|
await this.storage.save(r);
|
|
4667
|
-
let i =
|
|
5418
|
+
let i = Vi(r);
|
|
4668
5419
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
4669
5420
|
}
|
|
4670
5421
|
forget() {
|
|
@@ -4685,6 +5436,6 @@ var Br = class {
|
|
|
4685
5436
|
}
|
|
4686
5437
|
};
|
|
4687
5438
|
//#endregion
|
|
4688
|
-
export {
|
|
5439
|
+
export { In as C, z as D, L as E, on as O, zn as S, B as T, rr as _, Li as a, W as b, Br as c, Er as d, Dr as f, nr as g, ir as h, Ri as i, Ar as l, ar as m, zi as n, ji as o, or as p, $ as r, xi as s, Hi as t, kr as u, er as v, Pn as w, Wn as x, tr as y };
|
|
4689
5440
|
|
|
4690
|
-
//# sourceMappingURL=LayoutSession-
|
|
5441
|
+
//# sourceMappingURL=LayoutSession-D7uQq3jX.js.map
|