@tradecanvas/chart 1.65.0 → 1.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/Chart.d.ts +18 -0
- package/dist/Chart.d.ts.map +1 -1
- package/dist/LayoutSession-Cz0hZtIT.cjs +2 -0
- package/dist/LayoutSession-Cz0hZtIT.cjs.map +1 -0
- package/dist/{LayoutSession-D3-26EZU.js → LayoutSession-DOUhFovg.js} +427 -417
- package/dist/LayoutSession-DOUhFovg.js.map +1 -0
- package/dist/i18n-BsstZ9md.cjs +2 -0
- package/dist/i18n-BsstZ9md.cjs.map +1 -0
- package/dist/{i18n-BMypRqyL.js → i18n-DUmd4Z_r.js} +9 -1
- package/dist/i18n-DUmd4Z_r.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/widget/ChartWidget.d.ts +38 -0
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/WidgetDrawingSettings.d.ts +2 -0
- package/dist/widget/WidgetDrawingSettings.d.ts.map +1 -1
- package/dist/widget/WidgetInlineText.d.ts +76 -0
- package/dist/widget/WidgetInlineText.d.ts.map +1 -0
- package/dist/widget/WidgetObjectTree.d.ts.map +1 -1
- package/dist/widget/drawingSettingsTabs.d.ts.map +1 -1
- package/dist/widget/index.cjs +45 -22
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +1458 -1186
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/locales/ar.d.ts.map +1 -1
- package/dist/widget/locales/cs.d.ts.map +1 -1
- package/dist/widget/locales/da.d.ts.map +1 -1
- package/dist/widget/locales/de.d.ts.map +1 -1
- package/dist/widget/locales/el.d.ts.map +1 -1
- package/dist/widget/locales/en.d.ts +4 -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 +113 -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/widgetConfig.d.ts.map +1 -1
- package/dist/widget/widgetUI.d.ts +16 -0
- package/dist/widget/widgetUI.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-D3-26EZU.js.map +0 -1
- package/dist/LayoutSession-DV6i7ZxO.cjs +0 -2
- package/dist/LayoutSession-DV6i7ZxO.cjs.map +0 -1
- package/dist/i18n-BMypRqyL.js.map +0 -1
- package/dist/i18n-Gg731RKU.cjs +0 -2
- package/dist/i18n-Gg731RKU.cjs.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, createMarketTheme as h, formatPrice as g, fractionTick as _, indicatorSource as v, isValidTimeZone as y, mergeBar as ee, niceNumber as te, normalizeBarTime as b, parseIndicatorSource as x, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as
|
|
2
|
-
import { AlertDragHandler as
|
|
1
|
+
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, createMarketTheme as h, formatPrice as g, fractionTick as _, indicatorSource as v, isValidTimeZone as y, mergeBar as ee, niceNumber as te, normalizeBarTime as b, parseIndicatorSource as x, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as ae, readIndicatorPlotStyles as oe, readPaneStyle as se, resolveChartTheme as ce, sessionMinute as S, setLocale as le, stepDecimals as ue, symbolTimeZone as C, tickBarCount as de, timeframeToMs as w, zonedDateFormatter as fe } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as pe, AlertManager as me, Animator as he, AreaRenderer as ge, AxisDragHandler as _e, BarCountdown as ve, BarRenderer as ye, BaselineRenderer as be, CandlestickRenderer as xe, ChartLegend as Se, ChartStateManager as T, CompareRenderer as Ce, CompareSymbolIndicator as we, CompareSymbolPaneIndicator as Te, CorrelationCoefficientIndicator as Ee, CorrelationLogIndicator as De, CrosshairHandler as Oe, CrosshairTooltip as ke, CurrentPriceLine as Ae, DEFAULT_SESSION_HOURS as je, DataExporter as E, DepthHeatmapRenderer as Me, DrawingManager as Ne, DrawingRenderer as Pe, EquivolumeRenderer as Fe, EventBus as Ie, GridRenderer as Le, HLCAreaRenderer as Re, HiLoRenderer as ze, HollowCandleRenderer as Be, IndicatorEngine as Ve, InteractionManager as He, KagiRenderer as Ue, KeyboardHandler as We, LineRenderer as Ge, LineWithMarkersRenderer as Ke, MarketProfileRenderer as qe, MeasureOverlay as Je, PRICE_AXIS_ADD_STRIP as Ye, PRICE_SCALE_MARGIN as D, PanHandler as Xe, PaneResizeHandler as Ze, PeriodLevelsRenderer as Qe, PinnedTooltip as $e, PivotMarkersRenderer as et, PointAndFigureRenderer as tt, PriceAxis as nt, PriceAxisAddButton as rt, PriceLines as it, RenderEngine as at, RenkoRenderer as ot, ReplayManager as st, ResamplingAdapter as ct, ReshapeMemo as lt, SYMBOL_INDICATOR_IDS as O, SYMBOL_ZONE_WAIT_MS as ut, Screenshot as k, SelectionBoxOverlay as dt, SessionBreaks as ft, SessionShading as pt, SignalMarkerManager as mt, SpreadIndicator as ht, StepLineRenderer as gt, StreamManager as _t, SymbolSeriesStore as vt, TimeAxis as yt, TradeZoneManager as bt, TradingManager as xt, TradingRenderer as St, UndoRedoManager as Ct, Viewport as wt, VolumeCandleRenderer as Tt, VolumeProfileRenderer as Et, VolumeRenderer as Dt, Watermark as Ot, ZoomHandler as kt, axisTimes as A, barTimeStepMs as At, findDominantSwing as jt, gpuContextsLeft as Mt, isPriceLevelAlert as Nt, isRegularSession as Pt, loadWebGL as Ft, mergeSessionHours as It, pointAndFigureColumns as Lt, rangePresetStart as Rt, readAlertOptions as zt, registerBuiltInDrawingTools as Bt, registerBuiltInIndicators as Vt, servesTimeframe as j, sourceParam as M, timestampToBarIndex as N, toHeikinAshi as Ht, toKagi as Ut, toLineBreak as Wt, toRangeBars as Gt, toRenko as Kt, whenGpuContextFree as qt, withResampling as P, xToBarIndex as Jt, xToTime as F, yToPrice as Yt } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
let n =
|
|
4
|
+
var Xt = 864e5, Zt = 10;
|
|
5
|
+
function Qt(e, t) {
|
|
6
|
+
let n = C(e);
|
|
7
7
|
if (!n || !y(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
9
|
-
let t =
|
|
9
|
+
let t = S(e.start), n = S(e.end);
|
|
10
10
|
return t === null || n === null ? [] : [{
|
|
11
11
|
startMinute: t,
|
|
12
12
|
endMinute: n
|
|
@@ -14,11 +14,11 @@ function en(e, t) {
|
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
16
|
let i = u(t), a = Infinity;
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
17
|
+
for (let e = Math.max(1, t.length - Zt); 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 < Xt)) return null;
|
|
22
22
|
let o = {
|
|
23
23
|
timeZone: n,
|
|
24
24
|
windows: r,
|
|
@@ -29,19 +29,19 @@ function en(e, t) {
|
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var $t = {
|
|
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
|
-
}, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e),
|
|
39
|
+
}, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), en = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], tn = 400, nn = 1e3, rn = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var tn = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
|
|
58
|
+
...$t,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of en) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = an("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 = an("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
|
+
...$t,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = nn - (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 tn = {
|
|
|
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
|
+
}, tn);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -99,7 +99,7 @@ var tn = {
|
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: on(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -140,7 +140,7 @@ var tn = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function an(e, t) {
|
|
144
144
|
let n = document.createElement(e);
|
|
145
145
|
return n.className = t, Object.assign(n.style, {
|
|
146
146
|
position: "absolute",
|
|
@@ -154,17 +154,17 @@ function sn(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function on(e) {
|
|
158
158
|
return Number.isInteger(e) ? String(e) : e.toFixed(2);
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/indicatorLabel.ts
|
|
162
|
-
var
|
|
162
|
+
var sn = 3, cn = {
|
|
163
163
|
stochrsi: 4,
|
|
164
164
|
ichimoku: 4
|
|
165
165
|
};
|
|
166
|
-
function
|
|
167
|
-
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0,
|
|
166
|
+
function ln(e, t, n, r) {
|
|
167
|
+
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, cn[e] ?? sn).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
|
|
168
168
|
return [
|
|
169
169
|
e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
|
|
170
170
|
...a,
|
|
@@ -173,52 +173,52 @@ function dn(e, t, n, r) {
|
|
|
173
173
|
}
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region src/charts/ChartTypeStrategy.ts
|
|
176
|
-
function
|
|
176
|
+
function un(e) {
|
|
177
177
|
switch (e) {
|
|
178
178
|
case "candlestick":
|
|
179
179
|
case "heikinAshi":
|
|
180
180
|
case "lineBreak":
|
|
181
|
-
case "rangeBars": return new
|
|
182
|
-
case "line": return new
|
|
183
|
-
case "area": return new
|
|
184
|
-
case "bar": return new
|
|
185
|
-
case "hollowCandle": return new
|
|
186
|
-
case "baseline": return new
|
|
187
|
-
case "renko": return new
|
|
188
|
-
case "kagi": return new
|
|
189
|
-
case "pointAndFigure": return new
|
|
190
|
-
case "volumeCandles": return new
|
|
191
|
-
case "equivolume": return new
|
|
192
|
-
case "hlcArea": return new
|
|
193
|
-
case "stepLine": return new
|
|
194
|
-
case "lineWithMarkers": return new
|
|
195
|
-
case "hiLo": return new
|
|
196
|
-
default: return new
|
|
181
|
+
case "rangeBars": return new xe();
|
|
182
|
+
case "line": return new Ge();
|
|
183
|
+
case "area": return new ge();
|
|
184
|
+
case "bar": return new ye();
|
|
185
|
+
case "hollowCandle": return new Be();
|
|
186
|
+
case "baseline": return new be();
|
|
187
|
+
case "renko": return new ot();
|
|
188
|
+
case "kagi": return new Ue();
|
|
189
|
+
case "pointAndFigure": return new tt();
|
|
190
|
+
case "volumeCandles": return new Tt();
|
|
191
|
+
case "equivolume": return new Fe();
|
|
192
|
+
case "hlcArea": return new Re();
|
|
193
|
+
case "stepLine": return new gt();
|
|
194
|
+
case "lineWithMarkers": return new Ke();
|
|
195
|
+
case "hiLo": return new ze();
|
|
196
|
+
default: return new xe();
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function dn(e, t, n = {}, r, i) {
|
|
200
200
|
if (t.length === 0) return t;
|
|
201
201
|
switch (e) {
|
|
202
|
-
case "heikinAshi": return
|
|
202
|
+
case "heikinAshi": return Ht(t);
|
|
203
203
|
case "renko": {
|
|
204
204
|
let e = n.renko?.boxSize;
|
|
205
|
-
return typeof e == "number" ?
|
|
205
|
+
return typeof e == "number" ? Kt(t, { brickSize: e }, i) : Kt(t, {
|
|
206
206
|
brickSize: 0,
|
|
207
207
|
useATR: !0,
|
|
208
208
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
209
209
|
}, i);
|
|
210
210
|
}
|
|
211
|
-
case "lineBreak": return
|
|
212
|
-
case "kagi": return
|
|
213
|
-
case "pointAndFigure": return
|
|
214
|
-
case "rangeBars": return
|
|
215
|
-
rangeSize:
|
|
211
|
+
case "lineBreak": return Wt(t, n.lineBreak?.lines ?? 3);
|
|
212
|
+
case "kagi": return Ut(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
|
|
213
|
+
case "pointAndFigure": return pn(t, n, i).columns;
|
|
214
|
+
case "rangeBars": return Gt(t, {
|
|
215
|
+
rangeSize: Cn(t, n, r),
|
|
216
216
|
includeForming: !0
|
|
217
217
|
}, i);
|
|
218
218
|
default: return t;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function fn(e) {
|
|
222
222
|
switch (e) {
|
|
223
223
|
case "heikinAshi":
|
|
224
224
|
case "renko":
|
|
@@ -230,71 +230,71 @@ function mn(e) {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
function L(e) {
|
|
233
|
-
return e !== "heikinAshi" &&
|
|
233
|
+
return e !== "heikinAshi" && fn(e);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
return Lt(e,
|
|
235
|
+
function pn(e, t = {}, n) {
|
|
236
|
+
return Lt(e, gn(e, t), t.pointAndFigure?.reversal ?? 3, n);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
239
|
-
function
|
|
238
|
+
var mn = 50, hn = .01;
|
|
239
|
+
function gn(e, t = {}) {
|
|
240
240
|
let n = t.pointAndFigure?.boxSize;
|
|
241
241
|
if (typeof n == "number") return n;
|
|
242
|
-
let r =
|
|
243
|
-
return r > 0 ?
|
|
242
|
+
let r = _n(e, e.length > 1 ? e.length - 1 : e.length);
|
|
243
|
+
return r > 0 ? Sn(te(r / mn, !0)) : Math.abs(e[e.length - 1]?.close ?? 0) * hn || 1;
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function _n(e, t) {
|
|
246
246
|
let n = -Infinity, r = Infinity;
|
|
247
247
|
for (let i = 0; i < t; i++) e[i].high > n && (n = e[i].high), e[i].low < r && (r = e[i].low);
|
|
248
248
|
let i = n - r;
|
|
249
249
|
return Number.isFinite(i) ? i : 0;
|
|
250
250
|
}
|
|
251
|
-
var
|
|
252
|
-
function
|
|
251
|
+
var vn = 100, yn = 3, bn = .01, xn = 15, Sn = (e) => Number(e.toPrecision(xn));
|
|
252
|
+
function Cn(e, t = {}, n) {
|
|
253
253
|
let r = t.rangeBars?.range;
|
|
254
254
|
if (typeof r == "number") return r;
|
|
255
|
-
let i = e.length >=
|
|
256
|
-
return
|
|
255
|
+
let i = e.length >= yn ? Tn(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
|
|
256
|
+
return On(Sn(te(i > 0 ? i : a * bn || 1, !0)), n);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function wn(e) {
|
|
259
259
|
let t = e.length - 1;
|
|
260
260
|
return {
|
|
261
|
-
from: Math.max(0, t -
|
|
261
|
+
from: Math.max(0, t - vn),
|
|
262
262
|
end: t
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
|
-
function
|
|
266
|
-
let { from: t, end: n } =
|
|
265
|
+
function Tn(e) {
|
|
266
|
+
let { from: t, end: n } = wn(e), r = 0;
|
|
267
267
|
for (let i = t; i < n; i++) {
|
|
268
268
|
let { high: t, low: n } = e[i], a = i > 0 ? e[i - 1].close : n;
|
|
269
269
|
r += Math.max(t - n, Math.abs(t - a), Math.abs(n - a));
|
|
270
270
|
}
|
|
271
271
|
return n > t ? r / (n - t) : 0;
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
let { from: n, end: r } =
|
|
273
|
+
function En(e, t) {
|
|
274
|
+
let { from: n, end: r } = wn(e);
|
|
275
275
|
if (r <= n) return t(e[e.length - 1]?.close ?? 0);
|
|
276
276
|
let i = -Infinity, a = Infinity;
|
|
277
277
|
for (let t = n; t < r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
|
|
278
|
-
return
|
|
278
|
+
return Dn(t(i), t(a));
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function Dn(e, t) {
|
|
281
281
|
return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
|
|
282
282
|
}
|
|
283
|
-
function
|
|
284
|
-
return t === void 0 || !(t > 0) ? e :
|
|
283
|
+
function On(e, t) {
|
|
284
|
+
return t === void 0 || !(t > 0) ? e : Sn(Math.max(1, Math.round(e / t)) * t);
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function kn(e, t) {
|
|
287
287
|
let n = t?.(e);
|
|
288
|
-
return n ? n.createRenderer() :
|
|
288
|
+
return n ? n.createRenderer() : un(e);
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function An(e, t, n, r, i, a) {
|
|
291
291
|
if (t.length === 0) return t;
|
|
292
292
|
let o = n?.(e);
|
|
293
|
-
return o?.transform ? o.transform(t) :
|
|
293
|
+
return o?.transform ? o.transform(t) : dn(e, t, r, i, a);
|
|
294
294
|
}
|
|
295
295
|
//#endregion
|
|
296
296
|
//#region src/state/AutoSaveScheduler.ts
|
|
297
|
-
var
|
|
297
|
+
var jn = class {
|
|
298
298
|
timer = null;
|
|
299
299
|
delayMs = 0;
|
|
300
300
|
key = null;
|
|
@@ -329,7 +329,7 @@ function R(e) {
|
|
|
329
329
|
let { open: t, high: n, low: r, close: i } = e;
|
|
330
330
|
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));
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function Mn(e) {
|
|
333
333
|
return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
|
|
334
334
|
}
|
|
335
335
|
function z(e) {
|
|
@@ -343,24 +343,24 @@ function z(e) {
|
|
|
343
343
|
function B(e, t) {
|
|
344
344
|
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;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function Nn(e, t) {
|
|
347
347
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
348
348
|
if (e[n].time === t) return n;
|
|
349
349
|
if (e[n].time < t) return -1;
|
|
350
350
|
}
|
|
351
351
|
return -1;
|
|
352
352
|
}
|
|
353
|
-
var
|
|
353
|
+
var Pn = {
|
|
354
354
|
index: -1,
|
|
355
355
|
changed: !1
|
|
356
356
|
};
|
|
357
|
-
function
|
|
357
|
+
function Fn(e, t) {
|
|
358
358
|
if (e.length === 0) return t;
|
|
359
359
|
let n = b(t);
|
|
360
360
|
return u(e) === 1 ? n : n / 1e3;
|
|
361
361
|
}
|
|
362
|
-
function
|
|
363
|
-
let n =
|
|
362
|
+
function In(e, t) {
|
|
363
|
+
let n = Fn(e, t.time);
|
|
364
364
|
return n === t.time ? t : {
|
|
365
365
|
...t,
|
|
366
366
|
time: n
|
|
@@ -369,7 +369,7 @@ function Rn(e, t) {
|
|
|
369
369
|
var V = class {
|
|
370
370
|
data = [];
|
|
371
371
|
withSeriesTime(e) {
|
|
372
|
-
return
|
|
372
|
+
return In(this.data, e);
|
|
373
373
|
}
|
|
374
374
|
getData() {
|
|
375
375
|
return this.data;
|
|
@@ -378,7 +378,7 @@ var V = class {
|
|
|
378
378
|
let t = [];
|
|
379
379
|
for (let n = 0; n < e.length; n++) {
|
|
380
380
|
let r = e[n];
|
|
381
|
-
R(r) && t.push(
|
|
381
|
+
R(r) && t.push(Mn(r) ? r : z(r));
|
|
382
382
|
}
|
|
383
383
|
this.data = t;
|
|
384
384
|
}
|
|
@@ -387,7 +387,7 @@ var V = class {
|
|
|
387
387
|
for (let r = 0; r < e.length; r++) {
|
|
388
388
|
if (!R(e[r])) continue;
|
|
389
389
|
let i = this.withSeriesTime(e[r]);
|
|
390
|
-
i.time >= t || n.push(
|
|
390
|
+
i.time >= t || n.push(Mn(i) ? i : z(i));
|
|
391
391
|
}
|
|
392
392
|
if (n.length === 0) return 0;
|
|
393
393
|
n.sort((e, t) => e.time - t.time);
|
|
@@ -408,9 +408,9 @@ var V = class {
|
|
|
408
408
|
this.data[this.data.length - 1] = t;
|
|
409
409
|
}
|
|
410
410
|
replaceBar(e) {
|
|
411
|
-
if (!R(e)) return
|
|
412
|
-
let t = this.withSeriesTime(e), n =
|
|
413
|
-
if (n < 0) return
|
|
411
|
+
if (!R(e)) return Pn;
|
|
412
|
+
let t = this.withSeriesTime(e), n = Nn(this.data, t.time);
|
|
413
|
+
if (n < 0) return Pn;
|
|
414
414
|
let r = z(t);
|
|
415
415
|
return B(this.data[n], r) ? {
|
|
416
416
|
index: n,
|
|
@@ -440,7 +440,7 @@ function U(e, t) {
|
|
|
440
440
|
let r = b(t.time), i = b(n.time);
|
|
441
441
|
return r > i ? "append" : r === i ? "update" : "stale";
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function Ln(e) {
|
|
444
444
|
return [
|
|
445
445
|
e.time,
|
|
446
446
|
e.open,
|
|
@@ -449,7 +449,7 @@ function zn(e) {
|
|
|
449
449
|
e.close
|
|
450
450
|
].every(Number.isFinite);
|
|
451
451
|
}
|
|
452
|
-
var
|
|
452
|
+
var Rn = class {
|
|
453
453
|
shown = new V();
|
|
454
454
|
whole = null;
|
|
455
455
|
aside = null;
|
|
@@ -489,7 +489,7 @@ var Bn = class {
|
|
|
489
489
|
}
|
|
490
490
|
let t = null, n = e;
|
|
491
491
|
if (this.whole) {
|
|
492
|
-
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(
|
|
492
|
+
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(Ln).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);
|
|
493
493
|
this.whole = [...a, ...this.whole];
|
|
494
494
|
let o = this.hoursFilter(this.whole);
|
|
495
495
|
t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
|
|
@@ -501,8 +501,8 @@ var Bn = class {
|
|
|
501
501
|
};
|
|
502
502
|
}
|
|
503
503
|
mergeSnapshot(e) {
|
|
504
|
-
if (this.aside) return this.aside.setData(
|
|
505
|
-
let t =
|
|
504
|
+
if (this.aside) return this.aside.setData(zn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
|
|
505
|
+
let t = zn(this.whole ?? this.shown.getData(), e);
|
|
506
506
|
return t ? (this.shown.setData(this.regularOnly(t)), !0) : !1;
|
|
507
507
|
}
|
|
508
508
|
refilter() {
|
|
@@ -559,7 +559,7 @@ var Bn = class {
|
|
|
559
559
|
mergeTick(e) {
|
|
560
560
|
if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
|
|
561
561
|
let t = this.whole ? this.hoursFilter(this.whole) : null;
|
|
562
|
-
if (t && this.whole && !t(
|
|
562
|
+
if (t && this.whole && !t(Fn(this.whole, e.time))) return this.wrote("hidden", !1);
|
|
563
563
|
let n = this.shown.getLength();
|
|
564
564
|
this.shown.updateLastBarFromTick(e);
|
|
565
565
|
let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
|
|
@@ -602,7 +602,7 @@ var Bn = class {
|
|
|
602
602
|
});
|
|
603
603
|
}
|
|
604
604
|
if (!R(e)) return H;
|
|
605
|
-
let t = this.inSeriesUnit(e), n = this.whole, r = n ?
|
|
605
|
+
let t = this.inSeriesUnit(e), n = this.whole, r = n ? Nn(n, t.time) : -1;
|
|
606
606
|
if (n) {
|
|
607
607
|
if (r < 0 || !R(n[r])) return H;
|
|
608
608
|
let e = this.hoursFilter(n);
|
|
@@ -636,7 +636,7 @@ var Bn = class {
|
|
|
636
636
|
this.shown.updateLastBar(e);
|
|
637
637
|
}
|
|
638
638
|
inSeriesUnit(e) {
|
|
639
|
-
return
|
|
639
|
+
return In(this.whole ?? this.shown.getData(), e);
|
|
640
640
|
}
|
|
641
641
|
replaceHidden(e, t, n) {
|
|
642
642
|
let r = z(n), i = !B(e[t], r);
|
|
@@ -673,14 +673,14 @@ var Bn = class {
|
|
|
673
673
|
return !r || r(e.time);
|
|
674
674
|
}
|
|
675
675
|
};
|
|
676
|
-
function
|
|
676
|
+
function zn(e, t) {
|
|
677
677
|
let n = t[0]?.time, r = 0;
|
|
678
678
|
for (; n !== void 0 && r < e.length && e[r].time < n;) r++;
|
|
679
679
|
return r === 0 || r === e.length ? null : e.slice(0, r).concat(t);
|
|
680
680
|
}
|
|
681
681
|
//#endregion
|
|
682
682
|
//#region src/HistoryPager.ts
|
|
683
|
-
var
|
|
683
|
+
var Bn = 5e3, Vn = 6e4, Hn = 500, Un = class {
|
|
684
684
|
loader = null;
|
|
685
685
|
pageSize = 500;
|
|
686
686
|
loading = !1;
|
|
@@ -732,7 +732,7 @@ var Hn = 5e3, Un = 6e4, Wn = 500, Gn = class {
|
|
|
732
732
|
try {
|
|
733
733
|
r = await e(t, this.pageSize);
|
|
734
734
|
} catch (e) {
|
|
735
|
-
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(
|
|
735
|
+
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Vn, Bn * 2 ** (this.failures - 1)), this.emit({
|
|
736
736
|
state: "error",
|
|
737
737
|
count: 0,
|
|
738
738
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -765,10 +765,10 @@ var Hn = 5e3, Un = 6e4, Wn = 500, Gn = class {
|
|
|
765
765
|
};
|
|
766
766
|
//#endregion
|
|
767
767
|
//#region src/ThemeManager.ts
|
|
768
|
-
function
|
|
768
|
+
function Wn(e, t) {
|
|
769
769
|
return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
|
|
770
770
|
}
|
|
771
|
-
var
|
|
771
|
+
var Gn = class t {
|
|
772
772
|
base;
|
|
773
773
|
shape = null;
|
|
774
774
|
font = null;
|
|
@@ -787,13 +787,13 @@ var qn = class t {
|
|
|
787
787
|
return i;
|
|
788
788
|
}
|
|
789
789
|
getTheme() {
|
|
790
|
-
return this.effective ??=
|
|
790
|
+
return this.effective ??= ce(this.base, this.chartType, this.merged()), this.effective;
|
|
791
791
|
}
|
|
792
792
|
getBaseTheme() {
|
|
793
793
|
return this.base;
|
|
794
794
|
}
|
|
795
795
|
setTheme(e) {
|
|
796
|
-
let n = t.read(e), r = this.font !== null &&
|
|
796
|
+
let n = t.read(e), r = this.font !== null && Wn(n.font, this.base.font);
|
|
797
797
|
this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
|
|
798
798
|
...this.base,
|
|
799
799
|
shape: {
|
|
@@ -875,7 +875,7 @@ var qn = class t {
|
|
|
875
875
|
};
|
|
876
876
|
//#endregion
|
|
877
877
|
//#region src/style/styleOptions.ts
|
|
878
|
-
function
|
|
878
|
+
function Kn(e, t) {
|
|
879
879
|
return t ? {
|
|
880
880
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
881
881
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -883,22 +883,22 @@ function Jn(e, t) {
|
|
|
883
883
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
884
884
|
} : {};
|
|
885
885
|
}
|
|
886
|
-
function
|
|
886
|
+
function qn(e) {
|
|
887
887
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
888
888
|
return {
|
|
889
889
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
890
890
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
891
891
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
892
892
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
893
|
-
...
|
|
894
|
-
...
|
|
893
|
+
...Kn("horizontal", n?.hLine),
|
|
894
|
+
...Kn("vertical", n?.vLine),
|
|
895
895
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
896
896
|
...e.overrides
|
|
897
897
|
};
|
|
898
898
|
}
|
|
899
899
|
//#endregion
|
|
900
900
|
//#region src/layout/LayoutManager.ts
|
|
901
|
-
var
|
|
901
|
+
var Jn = 200, Yn = 80, W = (e) => e.position === "top" || e.position === "bottom", Xn = class {
|
|
902
902
|
panels = [];
|
|
903
903
|
containerWidth = 0;
|
|
904
904
|
containerHeight = 0;
|
|
@@ -915,8 +915,8 @@ var Xn = 200, Zn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
915
915
|
this.panels.push({
|
|
916
916
|
id: e,
|
|
917
917
|
position: n,
|
|
918
|
-
size: r ?? (a ?
|
|
919
|
-
minSize: a ?
|
|
918
|
+
size: r ?? (a ? Jn : t),
|
|
919
|
+
minSize: a ? Yn : i,
|
|
920
920
|
content: {
|
|
921
921
|
type: "indicator",
|
|
922
922
|
indicatorInstanceId: e
|
|
@@ -985,7 +985,7 @@ var Xn = 200, Zn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
985
985
|
let r = this.panels.find((t) => t.id === e);
|
|
986
986
|
if (r) {
|
|
987
987
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
988
|
-
r.position = n, a !== o && (r.size = o ?
|
|
988
|
+
r.position = n, a !== o && (r.size = o ? Jn : t, r.minSize = o ? Yn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
991
|
setPanelSize(e, t) {
|
|
@@ -1105,8 +1105,8 @@ var Xn = 200, Zn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
1105
1105
|
getMainChartRect() {
|
|
1106
1106
|
return this.resolve().mainChartRect;
|
|
1107
1107
|
}
|
|
1108
|
-
},
|
|
1109
|
-
function
|
|
1108
|
+
}, Zn = 14, Qn = 14, $n = 22, er = 4;
|
|
1109
|
+
function tr(e) {
|
|
1110
1110
|
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] : [
|
|
1111
1111
|
t,
|
|
1112
1112
|
n,
|
|
@@ -1115,16 +1115,16 @@ function rr(e) {
|
|
|
1115
1115
|
for (let t of f) {
|
|
1116
1116
|
if (!Number.isFinite(t)) continue;
|
|
1117
1117
|
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : g(t, u, i), r = e.format ? n : g(t, d, i);
|
|
1118
|
-
p = Math.max(p, l(n, `500 ${s}px ${a}`) +
|
|
1118
|
+
p = Math.max(p, l(n, `500 ${s}px ${a}`) + Zn, l(r, `bold 11px ${a}`) + Qn, l(r, `600 ${s}px ${a}`) + $n);
|
|
1119
1119
|
}
|
|
1120
|
-
return p <= o ? o : Math.ceil(p /
|
|
1120
|
+
return p <= o ? o : Math.ceil(p / er) * er;
|
|
1121
1121
|
}
|
|
1122
|
-
function
|
|
1122
|
+
function nr(e, t) {
|
|
1123
1123
|
return t > e || t <= e - 12 ? t : e;
|
|
1124
1124
|
}
|
|
1125
1125
|
//#endregion
|
|
1126
1126
|
//#region src/layout/labelWidths.ts
|
|
1127
|
-
var
|
|
1127
|
+
var rr = 512, ir = class {
|
|
1128
1128
|
widths = /* @__PURE__ */ new Map();
|
|
1129
1129
|
fonts;
|
|
1130
1130
|
forget = () => this.widths.clear();
|
|
@@ -1135,12 +1135,12 @@ var ar = 512, or = class {
|
|
|
1135
1135
|
let r = `${t}\n${e}`, i = this.widths.get(r);
|
|
1136
1136
|
if (i !== void 0) return i;
|
|
1137
1137
|
let a = n();
|
|
1138
|
-
return this.widths.size >=
|
|
1138
|
+
return this.widths.size >= rr && this.widths.clear(), this.widths.set(r, a), a;
|
|
1139
1139
|
}
|
|
1140
1140
|
destroy() {
|
|
1141
1141
|
this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
|
|
1142
1142
|
}
|
|
1143
|
-
},
|
|
1143
|
+
}, ar = class {
|
|
1144
1144
|
netY = 0;
|
|
1145
1145
|
travelX = 0;
|
|
1146
1146
|
engaged = !1;
|
|
@@ -1156,8 +1156,8 @@ var ar = 512, or = class {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
return this.engaged;
|
|
1158
1158
|
}
|
|
1159
|
-
},
|
|
1160
|
-
function
|
|
1159
|
+
}, or = 1;
|
|
1160
|
+
function sr(e, t) {
|
|
1161
1161
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
1162
1162
|
}
|
|
1163
1163
|
function G(e) {
|
|
@@ -1171,24 +1171,24 @@ function G(e) {
|
|
|
1171
1171
|
//#endregion
|
|
1172
1172
|
//#region src/plugins/registry.ts
|
|
1173
1173
|
var K = /* @__PURE__ */ new Map();
|
|
1174
|
-
function
|
|
1174
|
+
function cr(e) {
|
|
1175
1175
|
K.set(G(e), e);
|
|
1176
1176
|
}
|
|
1177
|
-
function
|
|
1177
|
+
function lr(e) {
|
|
1178
1178
|
return K.delete(e);
|
|
1179
1179
|
}
|
|
1180
|
-
function
|
|
1180
|
+
function ur() {
|
|
1181
1181
|
return [...K.values()];
|
|
1182
1182
|
}
|
|
1183
|
-
function
|
|
1183
|
+
function dr() {
|
|
1184
1184
|
K.clear();
|
|
1185
1185
|
}
|
|
1186
1186
|
//#endregion
|
|
1187
1187
|
//#region src/plugins/PluginManager.ts
|
|
1188
|
-
var
|
|
1188
|
+
var fr = class {
|
|
1189
1189
|
plugins = /* @__PURE__ */ new Map();
|
|
1190
1190
|
constructor(e, t = {}) {
|
|
1191
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
1191
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of ur()) this.add(e);
|
|
1192
1192
|
for (let e of t.plugins ?? []) this.add(e);
|
|
1193
1193
|
}
|
|
1194
1194
|
register(e) {
|
|
@@ -1218,15 +1218,15 @@ var mr = class {
|
|
|
1218
1218
|
add(e) {
|
|
1219
1219
|
this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
1220
1220
|
}
|
|
1221
|
-
},
|
|
1221
|
+
}, pr = {
|
|
1222
1222
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
1223
1223
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
1224
1224
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
1225
1225
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
1226
1226
|
positionClose: (e, t) => e.closePosition(t),
|
|
1227
|
-
positionReverse: (e, t, n) =>
|
|
1227
|
+
positionReverse: (e, t, n) => mr(e, t, n)
|
|
1228
1228
|
};
|
|
1229
|
-
async function
|
|
1229
|
+
async function mr(e, t, n) {
|
|
1230
1230
|
let { reversing: r } = n;
|
|
1231
1231
|
if (!r.has(t.positionId)) {
|
|
1232
1232
|
r.add(t.positionId);
|
|
@@ -1255,7 +1255,7 @@ async function gr(e, t, n) {
|
|
|
1255
1255
|
}
|
|
1256
1256
|
}
|
|
1257
1257
|
}
|
|
1258
|
-
function
|
|
1258
|
+
function hr(e, t) {
|
|
1259
1259
|
let n = [], r = null, i = {
|
|
1260
1260
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
1261
1261
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -1265,8 +1265,8 @@ function _r(e, t) {
|
|
|
1265
1265
|
e.data && t.onFill?.(e.data);
|
|
1266
1266
|
};
|
|
1267
1267
|
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));
|
|
1268
|
-
for (let r of Object.keys(
|
|
1269
|
-
let a =
|
|
1268
|
+
for (let r of Object.keys(pr)) {
|
|
1269
|
+
let a = pr[r], o = t.onIntent(r, (n) => {
|
|
1270
1270
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
1271
1271
|
message: `Execution command failed: ${r}`,
|
|
1272
1272
|
cause: e
|
|
@@ -1280,7 +1280,7 @@ function _r(e, t) {
|
|
|
1280
1280
|
}
|
|
1281
1281
|
//#endregion
|
|
1282
1282
|
//#region src/replay/ReplayStepLoader.ts
|
|
1283
|
-
var
|
|
1283
|
+
var gr = 1e3, _r = class {
|
|
1284
1284
|
pieces = /* @__PURE__ */ new Map();
|
|
1285
1285
|
asked = /* @__PURE__ */ new Set();
|
|
1286
1286
|
inFlight = !1;
|
|
@@ -1313,7 +1313,7 @@ var vr = 1e3, yr = class {
|
|
|
1313
1313
|
this.done = !0;
|
|
1314
1314
|
}
|
|
1315
1315
|
ask(e, t) {
|
|
1316
|
-
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(
|
|
1316
|
+
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(gr / 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);
|
|
1317
1317
|
for (let e of l) this.asked.add(e.time);
|
|
1318
1318
|
this.inFlight = !0, a({
|
|
1319
1319
|
state: "loading",
|
|
@@ -1354,12 +1354,12 @@ var vr = 1e3, yr = class {
|
|
|
1354
1354
|
...n === void 0 ? {} : { error: n }
|
|
1355
1355
|
});
|
|
1356
1356
|
}
|
|
1357
|
-
},
|
|
1358
|
-
function
|
|
1359
|
-
let n = (e.high - e.low) *
|
|
1360
|
-
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length *
|
|
1357
|
+
}, vr = 1 / 3, yr = .25, br = .5;
|
|
1358
|
+
function xr(e, t) {
|
|
1359
|
+
let n = (e.high - e.low) * yr;
|
|
1360
|
+
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * br;
|
|
1361
1361
|
}
|
|
1362
|
-
function
|
|
1362
|
+
function Sr(e) {
|
|
1363
1363
|
return e.close >= e.open ? [
|
|
1364
1364
|
e.open,
|
|
1365
1365
|
e.low,
|
|
@@ -1372,22 +1372,22 @@ function wr(e) {
|
|
|
1372
1372
|
e.close
|
|
1373
1373
|
];
|
|
1374
1374
|
}
|
|
1375
|
-
function
|
|
1376
|
-
let r =
|
|
1375
|
+
function Cr(e, t, n) {
|
|
1376
|
+
let r = Sr(e), i = [
|
|
1377
1377
|
1,
|
|
1378
1378
|
2,
|
|
1379
1379
|
3
|
|
1380
1380
|
].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
|
|
1381
1381
|
return r.forEach((r, c) => {
|
|
1382
|
-
c > 0 && (s += a > 0 ? i[c - 1] / a :
|
|
1382
|
+
c > 0 && (s += a > 0 ? i[c - 1] / a : vr), !(c === 0 && t > 0) && o.push({
|
|
1383
1383
|
price: r,
|
|
1384
1384
|
time: e.time,
|
|
1385
1385
|
at: (t + s) / n
|
|
1386
1386
|
});
|
|
1387
1387
|
}), o;
|
|
1388
1388
|
}
|
|
1389
|
-
function
|
|
1390
|
-
let n = t.length > 0 &&
|
|
1389
|
+
function wr(e, t = []) {
|
|
1390
|
+
let n = t.length > 0 && xr(e, t) ? t : [e], r = n.length, i = Tr(n.flatMap((e, t) => Cr(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
|
|
1391
1391
|
return {
|
|
1392
1392
|
bar: e,
|
|
1393
1393
|
points: i,
|
|
@@ -1397,7 +1397,7 @@ function Er(e, t = []) {
|
|
|
1397
1397
|
}))
|
|
1398
1398
|
};
|
|
1399
1399
|
}
|
|
1400
|
-
function
|
|
1400
|
+
function Tr(e, t) {
|
|
1401
1401
|
let n = e.length - 1, r = e.map((e, r) => ({
|
|
1402
1402
|
...e,
|
|
1403
1403
|
price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
|
|
@@ -1412,7 +1412,7 @@ function Dr(e, t) {
|
|
|
1412
1412
|
};
|
|
1413
1413
|
return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
|
|
1414
1414
|
}
|
|
1415
|
-
function
|
|
1415
|
+
function Er(e, t) {
|
|
1416
1416
|
let n = e.points;
|
|
1417
1417
|
if (t <= n[0].at) return n[0].price;
|
|
1418
1418
|
for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
|
|
@@ -1421,8 +1421,8 @@ function Or(e, t) {
|
|
|
1421
1421
|
}
|
|
1422
1422
|
return n[n.length - 1].price;
|
|
1423
1423
|
}
|
|
1424
|
-
var
|
|
1425
|
-
function
|
|
1424
|
+
var Dr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
|
|
1425
|
+
function Or(e, t) {
|
|
1426
1426
|
let n = 0, r = 0;
|
|
1427
1427
|
for (let i of e.volumeAt) {
|
|
1428
1428
|
if (t >= i.at) {
|
|
@@ -1433,10 +1433,10 @@ function Ar(e, t) {
|
|
|
1433
1433
|
}
|
|
1434
1434
|
return n;
|
|
1435
1435
|
}
|
|
1436
|
-
function
|
|
1437
|
-
let n =
|
|
1436
|
+
function kr(e, t) {
|
|
1437
|
+
let n = Dr(t);
|
|
1438
1438
|
if (n >= 1) return { ...e.bar };
|
|
1439
|
-
let r =
|
|
1439
|
+
let r = Er(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
|
|
1440
1440
|
for (let t of e.points) {
|
|
1441
1441
|
if (t.at > n) break;
|
|
1442
1442
|
i = Math.max(i, t.price), a = Math.min(a, t.price);
|
|
@@ -1447,11 +1447,11 @@ function jr(e, t) {
|
|
|
1447
1447
|
high: i,
|
|
1448
1448
|
low: a,
|
|
1449
1449
|
close: r,
|
|
1450
|
-
volume:
|
|
1450
|
+
volume: Or(e, n)
|
|
1451
1451
|
};
|
|
1452
1452
|
}
|
|
1453
|
-
function
|
|
1454
|
-
let n =
|
|
1453
|
+
function Ar(e, t) {
|
|
1454
|
+
let n = Dr(t), r = 0;
|
|
1455
1455
|
for (let t of e.points) {
|
|
1456
1456
|
if (t.at > n) break;
|
|
1457
1457
|
r = t.at;
|
|
@@ -1464,12 +1464,12 @@ function q(e, t, n) {
|
|
|
1464
1464
|
if (a.at > n) break;
|
|
1465
1465
|
i = a.time, a.at > t && r.push([a.price, a.time]);
|
|
1466
1466
|
}
|
|
1467
|
-
let a =
|
|
1467
|
+
let a = Er(e, n);
|
|
1468
1468
|
return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
|
|
1469
1469
|
}
|
|
1470
1470
|
//#endregion
|
|
1471
1471
|
//#region src/replay/replayStep.ts
|
|
1472
|
-
var
|
|
1472
|
+
var jr = [
|
|
1473
1473
|
"1m",
|
|
1474
1474
|
"3m",
|
|
1475
1475
|
"5m",
|
|
@@ -1480,51 +1480,51 @@ var Nr = [
|
|
|
1480
1480
|
"4h",
|
|
1481
1481
|
"1d"
|
|
1482
1482
|
];
|
|
1483
|
-
function
|
|
1484
|
-
let n =
|
|
1485
|
-
return n > 0 ?
|
|
1486
|
-
let r =
|
|
1483
|
+
function Mr(e, t) {
|
|
1484
|
+
let n = w(e);
|
|
1485
|
+
return n > 0 ? jr.filter((e) => {
|
|
1486
|
+
let r = w(e);
|
|
1487
1487
|
return r < n && n % r === 0 && t(e);
|
|
1488
1488
|
}) : [];
|
|
1489
1489
|
}
|
|
1490
|
-
function
|
|
1491
|
-
let r =
|
|
1490
|
+
function Nr(e, t, n) {
|
|
1491
|
+
let r = Mr(t, n);
|
|
1492
1492
|
if (e !== "auto") return r.includes(e) ? e : null;
|
|
1493
|
-
let i =
|
|
1494
|
-
return r.find((e) => i /
|
|
1493
|
+
let i = w(t);
|
|
1494
|
+
return r.find((e) => i / w(e) <= 60) ?? null;
|
|
1495
1495
|
}
|
|
1496
1496
|
//#endregion
|
|
1497
1497
|
//#region src/Chart.ts
|
|
1498
|
-
var
|
|
1498
|
+
var Pr = {
|
|
1499
1499
|
min: 0,
|
|
1500
1500
|
max: 100
|
|
1501
|
-
},
|
|
1502
|
-
function
|
|
1501
|
+
}, Fr = "exchange", Ir = Fr;
|
|
1502
|
+
function Lr(e) {
|
|
1503
1503
|
if (typeof e == "string" && e !== "exchange" && !y(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
1504
1504
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
1505
1505
|
}
|
|
1506
|
-
function
|
|
1507
|
-
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r :
|
|
1506
|
+
function Rr(e, t) {
|
|
1507
|
+
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
|
|
1508
1508
|
return i === void 0 ? e : {
|
|
1509
1509
|
...e,
|
|
1510
1510
|
timeZone: i,
|
|
1511
1511
|
timezone: i
|
|
1512
1512
|
};
|
|
1513
1513
|
}
|
|
1514
|
-
var
|
|
1515
|
-
function
|
|
1514
|
+
var zr = .08, Br = a ** -7, Vr = 800, Hr = 24;
|
|
1515
|
+
function Ur(e) {
|
|
1516
1516
|
return e.length > 0 ? { renames: e } : {};
|
|
1517
1517
|
}
|
|
1518
|
-
var
|
|
1518
|
+
var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
1519
1519
|
ArrowLeft: [-1, 0],
|
|
1520
1520
|
ArrowRight: [1, 0],
|
|
1521
1521
|
ArrowUp: [0, -1],
|
|
1522
1522
|
ArrowDown: [0, 1]
|
|
1523
|
-
},
|
|
1524
|
-
static version = "1.
|
|
1523
|
+
}, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set(["verticalLine", "crossLine"]), Xr = class {
|
|
1524
|
+
static version = "1.67.0";
|
|
1525
1525
|
engine;
|
|
1526
1526
|
viewport;
|
|
1527
|
-
series = new
|
|
1527
|
+
series = new Rn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
|
|
1528
1528
|
themeManager;
|
|
1529
1529
|
layoutManager;
|
|
1530
1530
|
pluginManager;
|
|
@@ -1540,7 +1540,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1540
1540
|
autoScrollOnNewBar = !0;
|
|
1541
1541
|
displayDataCache = null;
|
|
1542
1542
|
indicatorsOnDrawn = null;
|
|
1543
|
-
reshapeMemo = new
|
|
1543
|
+
reshapeMemo = new lt();
|
|
1544
1544
|
displayDataStep;
|
|
1545
1545
|
indicatorUpdateFrom = null;
|
|
1546
1546
|
resolvedLayoutCache = null;
|
|
@@ -1551,7 +1551,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1551
1551
|
renderDeferred = !1;
|
|
1552
1552
|
priceAxisWidth = o;
|
|
1553
1553
|
measureCtx;
|
|
1554
|
-
labelWidths = new
|
|
1554
|
+
labelWidths = new ir();
|
|
1555
1555
|
containerSizeCache = null;
|
|
1556
1556
|
containerSizeCacheTime = 0;
|
|
1557
1557
|
lastEmittedRange = null;
|
|
@@ -1566,7 +1566,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1566
1566
|
indicatorEdit = null;
|
|
1567
1567
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
1568
1568
|
zoomAreaMode = !1;
|
|
1569
|
-
priceAxisAddButton = new
|
|
1569
|
+
priceAxisAddButton = new rt();
|
|
1570
1570
|
displayTz = null;
|
|
1571
1571
|
timeZoneSetting = null;
|
|
1572
1572
|
symbolInfo = null;
|
|
@@ -1577,7 +1577,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1577
1577
|
studyZoneReleaseQueued = !1;
|
|
1578
1578
|
sessionBreaks;
|
|
1579
1579
|
sessionShading;
|
|
1580
|
-
hostSessionHours = { ...
|
|
1580
|
+
hostSessionHours = { ...je };
|
|
1581
1581
|
compareRenderer;
|
|
1582
1582
|
countdownInterval = null;
|
|
1583
1583
|
pausedFor = {
|
|
@@ -1596,7 +1596,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1596
1596
|
signalMarkerManager;
|
|
1597
1597
|
tradeZoneManager;
|
|
1598
1598
|
measureOverlay;
|
|
1599
|
-
selectionBoxOverlay = new
|
|
1599
|
+
selectionBoxOverlay = new dt();
|
|
1600
1600
|
replayManager;
|
|
1601
1601
|
replayBarUnsub = null;
|
|
1602
1602
|
replaySeeking = !1;
|
|
@@ -1611,7 +1611,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1611
1611
|
replayForming = null;
|
|
1612
1612
|
replayPhaseUnsub = null;
|
|
1613
1613
|
undoRedoManager;
|
|
1614
|
-
autoSaveScheduler = new
|
|
1614
|
+
autoSaveScheduler = new jn((e) => this.saveState(e));
|
|
1615
1615
|
animator;
|
|
1616
1616
|
crosshairTooltip;
|
|
1617
1617
|
pinnedTooltip;
|
|
@@ -1623,14 +1623,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1623
1623
|
disposed = !1;
|
|
1624
1624
|
chartTypeOptions = {};
|
|
1625
1625
|
mainSeriesVisible = !0;
|
|
1626
|
-
priceLines = new
|
|
1627
|
-
symbolSeries = new
|
|
1626
|
+
priceLines = new it();
|
|
1627
|
+
symbolSeries = new vt();
|
|
1628
1628
|
extendedHours = !0;
|
|
1629
1629
|
replayRestarting = !1;
|
|
1630
1630
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
1631
1631
|
gridRenderer;
|
|
1632
1632
|
priceAxis;
|
|
1633
|
-
leftPriceAxis = new
|
|
1633
|
+
leftPriceAxis = new nt();
|
|
1634
1634
|
leftScaleRequested = !1;
|
|
1635
1635
|
leftAxisWidth = o;
|
|
1636
1636
|
leftViewport = null;
|
|
@@ -1663,7 +1663,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1663
1663
|
snapshotKey = null;
|
|
1664
1664
|
historyCheckQueued = !1;
|
|
1665
1665
|
constructor(e, t) {
|
|
1666
|
-
t.timeZone != null &&
|
|
1666
|
+
t.timeZone != null && Lr(t.timeZone), this.container = e, this.options = {
|
|
1667
1667
|
...t,
|
|
1668
1668
|
chartType: t.chartType ?? "candlestick"
|
|
1669
1669
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1702,15 +1702,15 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1702
1702
|
logScale: n.logScale ?? !0,
|
|
1703
1703
|
timeframes: n.timeframes ?? [],
|
|
1704
1704
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1705
|
-
}, 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
|
|
1705
|
+
}, 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 Un({
|
|
1706
1706
|
oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
|
|
1707
1707
|
prepend: (e) => this.prependBars(e),
|
|
1708
1708
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1709
|
-
}), this.themeManager = new
|
|
1709
|
+
}), this.themeManager = new Gn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(qn(t), "host", !1), this.layoutManager = new Xn(), this.indicatorEngine = new Ve(), this.pluginManager = new fr(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ie(), Vt(this.indicatorEngine), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.indicatorEngine.register(new ht(this.symbolSeries)), this.indicatorEngine.register(new Ee(this.symbolSeries)), this.indicatorEngine.register(new De(this.symbolSeries)), this.drawingManager = new Ne(), Bt(this.drawingManager), this.drawingRenderer = new Pe(this.drawingManager), this.drawingRenderer.setKeepOut(() => this.legendKeepOut()), this.drawingRenderer.setTimeFormat((e) => this.crosshairHandler.formatTime(e, this.getDisplayData())), this.drawingManager.setRequestRender(() => {
|
|
1710
1710
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1711
1711
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1712
1712
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1713
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1713
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new Ct();
|
|
1714
1714
|
let i = "";
|
|
1715
1715
|
this.undoRedoManager.setOnChange(() => {
|
|
1716
1716
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1723,23 +1723,23 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1723
1723
|
primary: e[0] ?? null
|
|
1724
1724
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1725
1725
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1726
|
-
}), 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
|
|
1726
|
+
}), 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 xt({
|
|
1727
1727
|
enabled: this.features.trading,
|
|
1728
1728
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1729
|
-
}), this.tradingRenderer = new
|
|
1729
|
+
}), this.tradingRenderer = new St(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1730
1730
|
this.eventBus.emit(e, t);
|
|
1731
|
-
}), this.engine = new
|
|
1731
|
+
}), this.engine = new at(e, t.maxPixelRatio);
|
|
1732
1732
|
let a = this.engine.dprManager.getContainerSize();
|
|
1733
|
-
if (this.viewport = new
|
|
1733
|
+
if (this.viewport = new wt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
|
|
1734
1734
|
freePan: t.freePan ?? !0,
|
|
1735
1735
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1736
1736
|
}), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1737
1737
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1738
1738
|
let t = this.viewport.isAtEnd();
|
|
1739
1739
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
|
|
1740
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new
|
|
1740
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Le(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new nt(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new yt(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new Oe(), 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) => {
|
|
1741
1741
|
if (e !== null && t) {
|
|
1742
|
-
let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o =
|
|
1742
|
+
let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o = A(n), s = i ? o[e]?.time ?? i.time : void 0;
|
|
1743
1743
|
this.chartLegend.setHoverBar(i ?? null, e > 0 ? n[e - 1] ?? null : null), this.features.legend && this.engine.requestRender(r.Hover);
|
|
1744
1744
|
let c = this.viewport.getState(), l = t.y >= c.chartRect.y && t.y <= c.chartRect.y + c.chartRect.height;
|
|
1745
1745
|
if (i && l && this.features.crosshairTooltip) {
|
|
@@ -1767,14 +1767,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1767
1767
|
let e = this.crosshairHandler.getSyncedSlot();
|
|
1768
1768
|
e !== null && this.showSyncedBar(e);
|
|
1769
1769
|
}
|
|
1770
|
-
}), this.chartLegend = new
|
|
1770
|
+
}), this.chartLegend = new Se(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
|
|
1771
1771
|
this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), this.engine.requestRender();
|
|
1772
|
-
}), this.watermark = new
|
|
1772
|
+
}), this.watermark = new Ot(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Dt(), this.volumeProfile = new Et(), this.marketProfile = new qe(), this.depthHeatmap = new Me(), this.periodLevels = new Qe(), this.pivotMarkers = new et(), this.barCountdown = new ve(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new ft(), this.sessionShading = new pt(), this.compareRenderer = new Ce(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1773
1773
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1774
1774
|
color: t.sessionBreaks.color,
|
|
1775
1775
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1776
1776
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1777
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
1777
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new he(), this.crosshairTooltip = new ke(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new $e(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = ae(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(ni(t.shapes)), t.font && this.themeManager.setFont(ti(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new We({
|
|
1778
1778
|
scrollBars: (e) => {
|
|
1779
1779
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1780
1780
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1791,7 +1791,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1791
1791
|
},
|
|
1792
1792
|
fitContent: () => this.fitContent()
|
|
1793
1793
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1794
|
-
this.a11y = new
|
|
1794
|
+
this.a11y = new rn(e, {
|
|
1795
1795
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1796
1796
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1797
1797
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
@@ -1822,7 +1822,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1822
1822
|
}
|
|
1823
1823
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1824
1824
|
}
|
|
1825
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
1825
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ae(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new me(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(Nt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
|
|
1826
1826
|
this.eventBus.emit("alertTriggered", J(e)), this.eventBus.emit("dataUpdate", {
|
|
1827
1827
|
kind: "alert",
|
|
1828
1828
|
alert: "triggered",
|
|
@@ -1838,7 +1838,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1838
1838
|
this.eventBus.emit("alertExpired", J(e));
|
|
1839
1839
|
}), this.alertManager.on("updated", (e) => {
|
|
1840
1840
|
this.eventBus.emit("alertUpdate", J(e));
|
|
1841
|
-
}), this.signalMarkerManager = new
|
|
1841
|
+
}), this.signalMarkerManager = new mt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
|
|
1842
1842
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1843
1843
|
id: e.id,
|
|
1844
1844
|
source: e.source,
|
|
@@ -1846,14 +1846,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1846
1846
|
});
|
|
1847
1847
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1848
1848
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1849
|
-
}), this.tradeZoneManager = new
|
|
1849
|
+
}), this.tradeZoneManager = new bt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
|
|
1850
1850
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1851
1851
|
id: e.id,
|
|
1852
1852
|
direction: e.direction
|
|
1853
1853
|
});
|
|
1854
1854
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1855
1855
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1856
|
-
}), this.replayManager = new
|
|
1856
|
+
}), this.replayManager = new st(), this.replayManager.on("complete", () => {
|
|
1857
1857
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1858
1858
|
t && this.eventBus.emit("replayComplete", {
|
|
1859
1859
|
barIndex: e,
|
|
@@ -1861,9 +1861,9 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1861
1861
|
});
|
|
1862
1862
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1863
1863
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1864
|
-
}), this.measureOverlay = new
|
|
1865
|
-
let e = new
|
|
1866
|
-
this.interactionManager.setPanHandler(new
|
|
1864
|
+
}), this.measureOverlay = new Je(), this.interactionManager = new He(e), this.features.panning) {
|
|
1865
|
+
let e = new ar();
|
|
1866
|
+
this.interactionManager.setPanHandler(new Xe((t, n) => {
|
|
1867
1867
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1868
1868
|
}, () => e.reset()));
|
|
1869
1869
|
}
|
|
@@ -1875,10 +1875,10 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1875
1875
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1876
1876
|
}
|
|
1877
1877
|
})), this.features.zooming) {
|
|
1878
|
-
this.interactionManager.setZoomHandler(new
|
|
1878
|
+
this.interactionManager.setZoomHandler(new kt((e, t) => {
|
|
1879
1879
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1880
1880
|
}));
|
|
1881
|
-
let e = new
|
|
1881
|
+
let e = new _e((e) => {
|
|
1882
1882
|
this.holdPriceScale(), this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1883
1883
|
}, (e) => {
|
|
1884
1884
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -1903,7 +1903,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1903
1903
|
y: t.y
|
|
1904
1904
|
});
|
|
1905
1905
|
})), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.applyPriceAxisAdd(), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
|
|
1906
|
-
let t =
|
|
1906
|
+
let t = Yt(e.y, this.viewport.getState());
|
|
1907
1907
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1908
1908
|
price: t,
|
|
1909
1909
|
x: e.x,
|
|
@@ -1913,10 +1913,10 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1913
1913
|
...this.viewport.getState(),
|
|
1914
1914
|
data: this.getDisplayData()
|
|
1915
1915
|
})), this.features.alerts) {
|
|
1916
|
-
let e = new
|
|
1916
|
+
let e = new pe(this.alertManager, () => this.viewport.getState());
|
|
1917
1917
|
this.interactionManager.setAlertDragHandler(e);
|
|
1918
1918
|
}
|
|
1919
|
-
let o = new
|
|
1919
|
+
let o = new Ze();
|
|
1920
1920
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
1921
1921
|
let t = this.getDisplayData();
|
|
1922
1922
|
if (t.length === 0) return;
|
|
@@ -1940,7 +1940,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1940
1940
|
x: e.x,
|
|
1941
1941
|
y: e.y
|
|
1942
1942
|
}), t.length === 0) return;
|
|
1943
|
-
let r =
|
|
1943
|
+
let r = Jt(e.x, this.viewport.getState());
|
|
1944
1944
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1945
1945
|
bar: t[r],
|
|
1946
1946
|
barIndex: r,
|
|
@@ -1985,7 +1985,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1985
1985
|
end: () => {
|
|
1986
1986
|
let e = this.selectionBoxOverlay.end();
|
|
1987
1987
|
if (e && this.zoomAreaMode) {
|
|
1988
|
-
if (e.x1 - e.x0 <
|
|
1988
|
+
if (e.x1 - e.x0 < Gr) return;
|
|
1989
1989
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1990
1990
|
return;
|
|
1991
1991
|
}
|
|
@@ -2069,13 +2069,13 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2069
2069
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
2070
2070
|
if (t.width <= 0) return;
|
|
2071
2071
|
let { from: n, to: r } = e;
|
|
2072
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
2072
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Wr, r - n));
|
|
2073
2073
|
}));
|
|
2074
2074
|
}
|
|
2075
2075
|
useStreamHistory(e, t, n = !0) {
|
|
2076
2076
|
if (this.hostHistoryLoader) return;
|
|
2077
2077
|
let r = P(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
|
|
2078
|
-
if (!i || a === null ||
|
|
2078
|
+
if (!i || a === null || de(a) !== null) {
|
|
2079
2079
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
2080
2080
|
return;
|
|
2081
2081
|
}
|
|
@@ -2172,11 +2172,11 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2172
2172
|
setChartTypeOptions(e) {
|
|
2173
2173
|
this.chartTypeOptions = {
|
|
2174
2174
|
...this.chartTypeOptions,
|
|
2175
|
-
...
|
|
2175
|
+
...ae(e)
|
|
2176
2176
|
}, this.displayDataCache = null, this.updateViewportAndRender(!0), this.fitFewColumns(), this.a11y?.refresh(!0), this.markStateChanged();
|
|
2177
2177
|
}
|
|
2178
2178
|
getChartTypeOptions() {
|
|
2179
|
-
return
|
|
2179
|
+
return ae(this.chartTypeOptions);
|
|
2180
2180
|
}
|
|
2181
2181
|
setExtendedHours(e) {
|
|
2182
2182
|
e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
|
|
@@ -2185,7 +2185,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2185
2185
|
return this.extendedHours;
|
|
2186
2186
|
}
|
|
2187
2187
|
sessionKeep(e) {
|
|
2188
|
-
return this.extendedHours ? null :
|
|
2188
|
+
return this.extendedHours ? null : Qt(this.symbolInfo, e);
|
|
2189
2189
|
}
|
|
2190
2190
|
reapplyExtendedHours() {
|
|
2191
2191
|
if (!this.series.refilter()) return;
|
|
@@ -2196,7 +2196,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2196
2196
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
2197
2197
|
}
|
|
2198
2198
|
setShapes(e) {
|
|
2199
|
-
let t =
|
|
2199
|
+
let t = ni(e);
|
|
2200
2200
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
2201
2201
|
...this.themeManager.getTheme().shape,
|
|
2202
2202
|
...t
|
|
@@ -2208,7 +2208,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2208
2208
|
setFont(e) {
|
|
2209
2209
|
if (e === null) this.themeManager.setFont(null);
|
|
2210
2210
|
else {
|
|
2211
|
-
let t =
|
|
2211
|
+
let t = ti(e);
|
|
2212
2212
|
if (Object.keys(t).length === 0) return;
|
|
2213
2213
|
this.themeManager.setFont(t);
|
|
2214
2214
|
}
|
|
@@ -2259,7 +2259,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2259
2259
|
setSymbolSeries(e, t) {
|
|
2260
2260
|
e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
|
|
2261
2261
|
let n = this.indicatorBars(), r = !1;
|
|
2262
|
-
for (let t of this.indicatorEngine.getActiveIndicators()) !
|
|
2262
|
+
for (let t of this.indicatorEngine.getActiveIndicators()) !O.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
|
|
2263
2263
|
r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
|
|
2264
2264
|
}
|
|
2265
2265
|
forgetUnreadSymbols() {
|
|
@@ -2273,13 +2273,13 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2273
2273
|
let e = /* @__PURE__ */ new Set();
|
|
2274
2274
|
for (let t of this.indicatorEngine.getActiveIndicators()) {
|
|
2275
2275
|
let n = t.params.symbol;
|
|
2276
|
-
|
|
2276
|
+
O.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
|
|
2277
2277
|
}
|
|
2278
2278
|
return [...e];
|
|
2279
2279
|
}
|
|
2280
2280
|
requestMissingSymbols(e) {
|
|
2281
2281
|
this.forgetUnreadSymbols();
|
|
2282
|
-
let t = this.indicatorEngine.getIndicatorConfig(e), n = t &&
|
|
2282
|
+
let t = this.indicatorEngine.getIndicatorConfig(e), n = t && O.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
|
|
2283
2283
|
!n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
|
|
2284
2284
|
}
|
|
2285
2285
|
updateIndicator(e, t) {
|
|
@@ -2350,8 +2350,8 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2350
2350
|
return {
|
|
2351
2351
|
...e,
|
|
2352
2352
|
priceRange: {
|
|
2353
|
-
min: t.min - n *
|
|
2354
|
-
max: t.max + n *
|
|
2353
|
+
min: t.min - n * zr,
|
|
2354
|
+
max: t.max + n * zr
|
|
2355
2355
|
},
|
|
2356
2356
|
logScale: !1,
|
|
2357
2357
|
scaleMode: "regular",
|
|
@@ -2404,7 +2404,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2404
2404
|
this.indicatorEngine.setStyleDefaults(e, null);
|
|
2405
2405
|
return;
|
|
2406
2406
|
}
|
|
2407
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2407
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : oe(n);
|
|
2408
2408
|
this.indicatorEngine.setStyleDefaults(e, {
|
|
2409
2409
|
...r,
|
|
2410
2410
|
...i ? { plots: i } : {}
|
|
@@ -2412,7 +2412,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2412
2412
|
}
|
|
2413
2413
|
setPaneStyle(e, t) {
|
|
2414
2414
|
let n = this.paneOf(e);
|
|
2415
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ?
|
|
2415
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? se(t) : null));
|
|
2416
2416
|
}
|
|
2417
2417
|
setPaneStyleNow(e, t) {
|
|
2418
2418
|
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());
|
|
@@ -2431,8 +2431,8 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2431
2431
|
return this.pluginManager;
|
|
2432
2432
|
}
|
|
2433
2433
|
static indicators() {
|
|
2434
|
-
let e = new
|
|
2435
|
-
return
|
|
2434
|
+
let e = new Ve();
|
|
2435
|
+
return Vt(e), e.getAvailableIndicators();
|
|
2436
2436
|
}
|
|
2437
2437
|
setPanelPosition(e, t) {
|
|
2438
2438
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -2596,7 +2596,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2596
2596
|
roundPrice(e) {
|
|
2597
2597
|
if (!Number.isFinite(e)) return e;
|
|
2598
2598
|
let t = this.stepAt(e);
|
|
2599
|
-
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(
|
|
2599
|
+
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(ue(t)));
|
|
2600
2600
|
let { min: n, max: r } = this.viewport.getState().priceRange;
|
|
2601
2601
|
return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
|
|
2602
2602
|
}
|
|
@@ -2693,14 +2693,24 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2693
2693
|
return this.drawingManager.removeDrawings(e);
|
|
2694
2694
|
}
|
|
2695
2695
|
nudgeSelectedDrawings(e) {
|
|
2696
|
-
let t =
|
|
2696
|
+
let t = qr[e.key];
|
|
2697
2697
|
if (!t || !this.features.drawings || e.ctrlKey || e.metaKey || e.altKey) return !1;
|
|
2698
|
-
let n = e.shiftKey ?
|
|
2698
|
+
let n = e.shiftKey ? Kr : 1, r = {
|
|
2699
2699
|
...this.viewport.getState(),
|
|
2700
2700
|
data: this.getDisplayData()
|
|
2701
2701
|
};
|
|
2702
2702
|
return this.drawingManager.nudge(t[0] * n, t[1] * n, r);
|
|
2703
2703
|
}
|
|
2704
|
+
getDrawingTextRect(e) {
|
|
2705
|
+
return this.drawingManager.isShown(e) ? this.drawingManager.textBoxOf(e, {
|
|
2706
|
+
...this.viewport.getState(),
|
|
2707
|
+
data: this.getDisplayData()
|
|
2708
|
+
}) : null;
|
|
2709
|
+
}
|
|
2710
|
+
amendNewDrawing(e, t) {
|
|
2711
|
+
let n = this.drawingManager.amendNew(e, t);
|
|
2712
|
+
return n && this.markStateChanged(), n;
|
|
2713
|
+
}
|
|
2704
2714
|
takeBackDrawing(e) {
|
|
2705
2715
|
this.features.drawings && (this.drawingManager.takeBack(e), this.markStateChanged());
|
|
2706
2716
|
}
|
|
@@ -2779,7 +2789,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2779
2789
|
recordUndo(e) {
|
|
2780
2790
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2781
2791
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2782
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2792
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Vr) {
|
|
2783
2793
|
this.undoRedoManager.replaceLast({
|
|
2784
2794
|
...n,
|
|
2785
2795
|
custom: {
|
|
@@ -2826,7 +2836,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2826
2836
|
x: t.x,
|
|
2827
2837
|
y: t.y
|
|
2828
2838
|
};
|
|
2829
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
2839
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = Yt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = F(t.x, n)), e === "pane") {
|
|
2830
2840
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2831
2841
|
e && (r.pane = e.instanceId);
|
|
2832
2842
|
}
|
|
@@ -2834,7 +2844,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2834
2844
|
}
|
|
2835
2845
|
applyPriceAxisAdd() {
|
|
2836
2846
|
let e = this.features.priceAxisAddButton && this.features.crosshair;
|
|
2837
|
-
this.priceAxisAddButton.setEnabled(e), this.tradingManager.setTagInset(e ?
|
|
2847
|
+
this.priceAxisAddButton.setEnabled(e), this.tradingManager.setTagInset(e ? Ye : 0);
|
|
2838
2848
|
}
|
|
2839
2849
|
setPriceAxisAddButton(e) {
|
|
2840
2850
|
this.features.priceAxisAddButton = e, this.applyPriceAxisAdd(), this.engine.requestRender(r.Overlay);
|
|
@@ -2901,7 +2911,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2901
2911
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2902
2912
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2903
2913
|
if (!t) continue;
|
|
2904
|
-
let r =
|
|
2914
|
+
let r = ln(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2905
2915
|
key: e,
|
|
2906
2916
|
title: e
|
|
2907
2917
|
}));
|
|
@@ -2925,11 +2935,11 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2925
2935
|
}
|
|
2926
2936
|
getExportText(e = "csv", t = {}) {
|
|
2927
2937
|
let { bars: n, columns: r } = this.getExportData(t);
|
|
2928
|
-
return e === "json" ?
|
|
2938
|
+
return e === "json" ? E.toJSON(n, r) : E.toCSV(n, r);
|
|
2929
2939
|
}
|
|
2930
2940
|
download(e, t, n) {
|
|
2931
2941
|
let r = this.getExportText(e, n);
|
|
2932
|
-
e === "json" ?
|
|
2942
|
+
e === "json" ? E.download(r, t ?? "chart-data.json", "application/json") : E.download(r, t ?? "chart-data.csv", "text/csv");
|
|
2933
2943
|
}
|
|
2934
2944
|
setAutoSave(e, t = 5e3) {
|
|
2935
2945
|
this.autoSaveScheduler.enable(e, t);
|
|
@@ -2991,7 +3001,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2991
3001
|
this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
|
|
2992
3002
|
}
|
|
2993
3003
|
updateIndicatorStyleNow(e, t) {
|
|
2994
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
3004
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : oe(n);
|
|
2995
3005
|
this.indicatorEngine.updateIndicatorStyle(e, {
|
|
2996
3006
|
...r,
|
|
2997
3007
|
...i ? { plots: i } : {}
|
|
@@ -3112,7 +3122,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3112
3122
|
}
|
|
3113
3123
|
async connect(e) {
|
|
3114
3124
|
if (!j(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
3115
|
-
this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new
|
|
3125
|
+
this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new _t(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (t) => {
|
|
3116
3126
|
let n = this.streamSeriesKey(e.adapter);
|
|
3117
3127
|
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);
|
|
3118
3128
|
}), this.streamManager.on("barClose", (e) => {
|
|
@@ -3168,18 +3178,18 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3168
3178
|
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
|
|
3169
3179
|
let t = this.streamManager;
|
|
3170
3180
|
if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
|
|
3171
|
-
let n =
|
|
3181
|
+
let n = w(e.timeframe);
|
|
3172
3182
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
3173
3183
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
3174
3184
|
}, 1e3);
|
|
3175
3185
|
}
|
|
3176
3186
|
streamSeriesKey(e) {
|
|
3177
|
-
let t = P(e), n = this.streamTimeframe, r = t instanceof
|
|
3187
|
+
let t = P(e), n = this.streamTimeframe, r = t instanceof ct && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
|
|
3178
3188
|
return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
|
|
3179
3189
|
}
|
|
3180
3190
|
setStreamTarget(e, t) {
|
|
3181
3191
|
let n = this.announcedSymbol;
|
|
3182
|
-
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream =
|
|
3192
|
+
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = de(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
3183
3193
|
symbol: e,
|
|
3184
3194
|
previous: n
|
|
3185
3195
|
})), this.useTimeframe(t);
|
|
@@ -3198,7 +3208,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3198
3208
|
if (!this.streamManager) return;
|
|
3199
3209
|
let n = this.streamAdapter;
|
|
3200
3210
|
if (n && !j(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
3201
|
-
this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(
|
|
3211
|
+
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);
|
|
3202
3212
|
}
|
|
3203
3213
|
isIndicatorAllowed(e) {
|
|
3204
3214
|
let t = this.features.indicatorIds;
|
|
@@ -3217,7 +3227,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3217
3227
|
}
|
|
3218
3228
|
connectExecution(e, t = {}) {
|
|
3219
3229
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
3220
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
3230
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = hr(e, {
|
|
3221
3231
|
onIntent: (e, t) => {
|
|
3222
3232
|
let n = (e) => t(e.payload);
|
|
3223
3233
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -3356,7 +3366,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3356
3366
|
setVisibleRangePreset(e) {
|
|
3357
3367
|
let t = this.getDisplayData();
|
|
3358
3368
|
if (t.length === 0) return;
|
|
3359
|
-
let n = t.length - 1, r = u(t), i =
|
|
3369
|
+
let n = t.length - 1, r = u(t), i = Rt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
3360
3370
|
if (a === null || a < t[0].time) {
|
|
3361
3371
|
this.fitContent();
|
|
3362
3372
|
return;
|
|
@@ -3554,7 +3564,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3554
3564
|
}
|
|
3555
3565
|
let t = this.crosshairSeries(), n = e >= 0 && e < t.length ? t[e] : void 0, r = n && e > 0 ? t[e - 1] : void 0;
|
|
3556
3566
|
this.crosshairHandler.getPosition() || this.chartLegend.setHoverBar(n ?? null, r ?? null);
|
|
3557
|
-
let i = n ?
|
|
3567
|
+
let i = n ? A(t)[e]?.time ?? n.time : void 0;
|
|
3558
3568
|
this.eventBus.emit("crosshairSync", {
|
|
3559
3569
|
barIndex: e,
|
|
3560
3570
|
...n ? { bar: n } : {},
|
|
@@ -3633,7 +3643,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3633
3643
|
return this.periodLevels.getPeriod();
|
|
3634
3644
|
}
|
|
3635
3645
|
setTimeZone(e) {
|
|
3636
|
-
|
|
3646
|
+
Lr(e), this.timeZoneSetting = e, this.applyTimeZone();
|
|
3637
3647
|
}
|
|
3638
3648
|
getTimeZone() {
|
|
3639
3649
|
return this.timeZoneSetting;
|
|
@@ -3642,7 +3652,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3642
3652
|
return this.displayTz;
|
|
3643
3653
|
}
|
|
3644
3654
|
getExchangeTimeZone() {
|
|
3645
|
-
return [
|
|
3655
|
+
return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && y(e)) ?? null;
|
|
3646
3656
|
}
|
|
3647
3657
|
setTimezone(e) {
|
|
3648
3658
|
this.setTimeZone(e);
|
|
@@ -3669,7 +3679,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3669
3679
|
this.indicatorEngine.setExchangeTimeZone(e, t.length > 0 ? t : void 0) && t.length > 0 && this.announceIndicatorUpdate(0);
|
|
3670
3680
|
}
|
|
3671
3681
|
holdStudyZone() {
|
|
3672
|
-
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(),
|
|
3682
|
+
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), ut);
|
|
3673
3683
|
}
|
|
3674
3684
|
endStudyZoneWait() {
|
|
3675
3685
|
this.studyZoneReleaseQueued = !1, this.studyZoneTimer !== null && (clearTimeout(this.studyZoneTimer), this.studyZoneTimer = null);
|
|
@@ -3684,7 +3694,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3684
3694
|
}
|
|
3685
3695
|
spokenBarTime(e) {
|
|
3686
3696
|
let t = this.getDisplayData(), n = e * u(t), r = this.numberLocale || "en-US";
|
|
3687
|
-
return d(t) === !0 ?
|
|
3697
|
+
return d(t) === !0 ? fe(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : fe(r, {
|
|
3688
3698
|
dateStyle: "medium",
|
|
3689
3699
|
timeStyle: "short"
|
|
3690
3700
|
}, this.displayTz)(n);
|
|
@@ -3697,18 +3707,18 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3697
3707
|
this.studyZoneHeld = !1, this.endStudyZoneWait(), this.useSymbolInfo(e);
|
|
3698
3708
|
}
|
|
3699
3709
|
useSymbolInfo(e) {
|
|
3700
|
-
let t = e && this.symbolInfo?.symbol === e.symbol ?
|
|
3701
|
-
this.symbolInfo = e ?
|
|
3710
|
+
let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
|
|
3711
|
+
this.symbolInfo = e ? Rr({
|
|
3702
3712
|
...e,
|
|
3703
3713
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
3704
3714
|
}, 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);
|
|
3705
3715
|
let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
|
|
3706
|
-
let t =
|
|
3716
|
+
let t = S(e.start), n = S(e.end);
|
|
3707
3717
|
return t === null || n === null ? [] : [{
|
|
3708
3718
|
startMinute: t,
|
|
3709
3719
|
endMinute: n
|
|
3710
3720
|
}];
|
|
3711
|
-
}), i =
|
|
3721
|
+
}), i = C(this.symbolInfo);
|
|
3712
3722
|
this.sessionShading.replaceConfig(n.length > 0 && i && y(i) ? {
|
|
3713
3723
|
timeZone: i,
|
|
3714
3724
|
windows: n,
|
|
@@ -3723,11 +3733,11 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3723
3733
|
if (!e || typeof e != "object") return;
|
|
3724
3734
|
let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
|
|
3725
3735
|
if (!n(e.symbol)) return;
|
|
3726
|
-
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i =
|
|
3736
|
+
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Rr({
|
|
3727
3737
|
...r,
|
|
3728
3738
|
...e,
|
|
3729
3739
|
symbol: e.symbol || r?.symbol || t
|
|
3730
|
-
},
|
|
3740
|
+
}, C(r));
|
|
3731
3741
|
r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
|
|
3732
3742
|
}
|
|
3733
3743
|
resolveStreamSymbol(e, t) {
|
|
@@ -3788,7 +3798,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3788
3798
|
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? Mt() > 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());
|
|
3789
3799
|
}
|
|
3790
3800
|
waitForGpu(e) {
|
|
3791
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
3801
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? qt(e) : null;
|
|
3792
3802
|
}
|
|
3793
3803
|
getRenderer() {
|
|
3794
3804
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -3810,7 +3820,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3810
3820
|
this.engine.getGpu() && this.engine.renderNow();
|
|
3811
3821
|
}
|
|
3812
3822
|
screenshot(e) {
|
|
3813
|
-
this.features.screenshot && (this.freshFrame(),
|
|
3823
|
+
this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
|
|
3814
3824
|
}
|
|
3815
3825
|
async copyScreenshot() {
|
|
3816
3826
|
if (!this.features.screenshot) return !1;
|
|
@@ -3818,7 +3828,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3818
3828
|
if (!t?.write || !e) return !1;
|
|
3819
3829
|
try {
|
|
3820
3830
|
this.freshFrame();
|
|
3821
|
-
let n =
|
|
3831
|
+
let n = k.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
|
|
3822
3832
|
if (!e) throw Error("No chart image to copy");
|
|
3823
3833
|
return e;
|
|
3824
3834
|
});
|
|
@@ -3836,10 +3846,10 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3836
3846
|
}
|
|
3837
3847
|
}
|
|
3838
3848
|
screenshotDataURL() {
|
|
3839
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3849
|
+
return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
3840
3850
|
}
|
|
3841
3851
|
async screenshotBlob() {
|
|
3842
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3852
|
+
return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
3843
3853
|
}
|
|
3844
3854
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
3845
3855
|
if (!this.features.alerts) return null;
|
|
@@ -3967,7 +3977,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3967
3977
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
3968
3978
|
if (!this.replaySession) {
|
|
3969
3979
|
if (this.series.length() === 0) return;
|
|
3970
|
-
this.series.beginReplay(), this.replaySession =
|
|
3980
|
+
this.series.beginReplay(), this.replaySession = ui(this.currentSymbol);
|
|
3971
3981
|
}
|
|
3972
3982
|
let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
|
|
3973
3983
|
c.animate = c.animate === !0;
|
|
@@ -3978,13 +3988,13 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3978
3988
|
let m = r ? this.replayStepsOver(n, p, !0) : null;
|
|
3979
3989
|
this.options.autoScale = !0, this.buildReplay(p, m, f);
|
|
3980
3990
|
let h = this.replayStepsSeries;
|
|
3981
|
-
h && c.startIndex !== void 0 && (c.startIndex =
|
|
3991
|
+
h && c.startIndex !== void 0 && (c.startIndex = yi(h, p, c.startIndex));
|
|
3982
3992
|
let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
|
|
3983
3993
|
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);
|
|
3984
3994
|
}
|
|
3985
3995
|
buildReplay(e, t, n) {
|
|
3986
3996
|
let r = this.replaySession?.animate === !0, i = r ? null : t;
|
|
3987
|
-
this.replayPieces = r && t ?
|
|
3997
|
+
this.replayPieces = r && t ? Si(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
|
|
3988
3998
|
let a = this.replayRestarting;
|
|
3989
3999
|
this.replayRestarting = !0;
|
|
3990
4000
|
try {
|
|
@@ -3998,7 +4008,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3998
4008
|
let n = t, a = e[t];
|
|
3999
4009
|
if (i) {
|
|
4000
4010
|
let r = i[t];
|
|
4001
|
-
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ?
|
|
4011
|
+
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? wi(c, r) : bi(e[n], i, t), a = xi(i, e, t, n) ? e[n] : c;
|
|
4002
4012
|
}
|
|
4003
4013
|
let u = this.replayForming;
|
|
4004
4014
|
this.replayForming = null, s = t;
|
|
@@ -4022,7 +4032,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4022
4032
|
});
|
|
4023
4033
|
}), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
|
|
4024
4034
|
if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
|
|
4025
|
-
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i =
|
|
4035
|
+
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = Ci() ? Ar(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = kr(r, i);
|
|
4026
4036
|
a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
|
|
4027
4037
|
index: t,
|
|
4028
4038
|
path: r
|
|
@@ -4032,7 +4042,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4032
4042
|
drawFormingBar(e, t, n, r) {
|
|
4033
4043
|
this.currentPriceLine.setPrice(e.close, t);
|
|
4034
4044
|
let i = this.series.bars();
|
|
4035
|
-
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !
|
|
4045
|
+
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !oi.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
|
|
4036
4046
|
this.scheduleRender();
|
|
4037
4047
|
return;
|
|
4038
4048
|
}
|
|
@@ -4040,22 +4050,22 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4040
4050
|
}
|
|
4041
4051
|
replayPathOf(e, t) {
|
|
4042
4052
|
let n = e[t];
|
|
4043
|
-
return
|
|
4053
|
+
return wr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
|
|
4044
4054
|
}
|
|
4045
4055
|
loadReplaySteps(e, t) {
|
|
4046
4056
|
let n = this.replayLoader?.loader;
|
|
4047
4057
|
if (!n) return;
|
|
4048
4058
|
n.evictBefore(e[t].time);
|
|
4049
4059
|
let r = this.replayManager.getStepMs();
|
|
4050
|
-
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(
|
|
4060
|
+
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(ai / r) : 1);
|
|
4051
4061
|
}
|
|
4052
4062
|
useReplayLoader(e, t) {
|
|
4053
|
-
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ?
|
|
4063
|
+
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Nr(e.step, r, (e) => j(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
|
|
4054
4064
|
if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
|
|
4055
|
-
let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l =
|
|
4065
|
+
let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new _r({
|
|
4056
4066
|
source: s ? (e, t) => s.call(o, c, i, e, t) : null,
|
|
4057
4067
|
step: i,
|
|
4058
|
-
ratio: Math.max(1, Math.round(l /
|
|
4068
|
+
ratio: Math.max(1, Math.round(l / w(i))),
|
|
4059
4069
|
barMs: l,
|
|
4060
4070
|
keep: (e) => this.series.inHoursShown(e),
|
|
4061
4071
|
report: (e) => this.eventBus.emit("replayStepsLoad", e)
|
|
@@ -4070,7 +4080,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4070
4080
|
if (!i || !a?.setMarkPrice || !o) return;
|
|
4071
4081
|
let s = i.fedTime;
|
|
4072
4082
|
if (s === null) {
|
|
4073
|
-
i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(
|
|
4083
|
+
i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(kr(n, r).close, o.time);
|
|
4074
4084
|
return;
|
|
4075
4085
|
}
|
|
4076
4086
|
if (o.time < s || o.time === s && r <= i.fedFraction) return;
|
|
@@ -4078,8 +4088,8 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4078
4088
|
if (o.time > s) {
|
|
4079
4089
|
let a = Y(e, s);
|
|
4080
4090
|
e[a]?.time === s && i.fedFraction < 1 && c.push(...q(this.replayPathOf(e, a), i.fedFraction, 1));
|
|
4081
|
-
let o = e.slice(X(e, s), t), l = Math.ceil(o.length /
|
|
4082
|
-
for (let e = 0; e < o.length; e += l) c.push(...
|
|
4091
|
+
let o = e.slice(X(e, s), t), l = Math.ceil(o.length / gi);
|
|
4092
|
+
for (let e = 0; e < o.length; e += l) c.push(..._i(o.slice(e, e + l)));
|
|
4083
4093
|
c.push(...q(n, -1, r));
|
|
4084
4094
|
} else c.push(...q(n, i.fedFraction, r));
|
|
4085
4095
|
i.fedTime = o.time, i.fedFraction = r;
|
|
@@ -4098,7 +4108,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4098
4108
|
if (n.length === 0) return;
|
|
4099
4109
|
let r = t.windowTime === null ? 0 : Math.min(Y(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
|
|
4100
4110
|
this.useReplayLoader(t, !1);
|
|
4101
|
-
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 :
|
|
4111
|
+
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : pi(o ?? i, t.until);
|
|
4102
4112
|
if (s < 0 && this.canPageBackForReplay(t)) {
|
|
4103
4113
|
this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
|
|
4104
4114
|
return;
|
|
@@ -4106,7 +4116,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4106
4116
|
let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
|
|
4107
4117
|
l || (t.held = null), t.symbol = this.currentSymbol;
|
|
4108
4118
|
let d = this.replayManager.remainingMs();
|
|
4109
|
-
this.clearBarHolders(), t.animate &&
|
|
4119
|
+
this.clearBarHolders(), t.animate && fi(t, this.replayCoarse, i);
|
|
4110
4120
|
let f = this.replayRestarting;
|
|
4111
4121
|
this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
|
|
4112
4122
|
try {
|
|
@@ -4129,14 +4139,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4129
4139
|
}
|
|
4130
4140
|
replayStepsOver(e, t, n = !1) {
|
|
4131
4141
|
if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
|
|
4132
|
-
let r =
|
|
4133
|
-
return r && (n ||
|
|
4142
|
+
let r = vi(this.series.inHoursShown(e.steps), t);
|
|
4143
|
+
return r && (n || hi(r, t)) ? r : null;
|
|
4134
4144
|
}
|
|
4135
4145
|
canPageBackForReplay(e) {
|
|
4136
|
-
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) <
|
|
4146
|
+
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < si;
|
|
4137
4147
|
}
|
|
4138
4148
|
async pageBackForReplay(e) {
|
|
4139
|
-
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack =
|
|
4149
|
+
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = si, this.rebaseReplay("older"));
|
|
4140
4150
|
}
|
|
4141
4151
|
holdReplay() {
|
|
4142
4152
|
let e = this.replaySession;
|
|
@@ -4169,7 +4179,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4169
4179
|
this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
|
|
4170
4180
|
}
|
|
4171
4181
|
replaySeekToTime(e) {
|
|
4172
|
-
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0,
|
|
4182
|
+
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, pi(this.replayStepsSeries ?? this.replayCoarse, e)));
|
|
4173
4183
|
}
|
|
4174
4184
|
feedReplayPrice(e, t) {
|
|
4175
4185
|
let n = this.executionAdapter;
|
|
@@ -4191,8 +4201,8 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4191
4201
|
if (i.time <= n.fedTime) return;
|
|
4192
4202
|
let a = e.slice(X(e, n.fedTime), t + 1);
|
|
4193
4203
|
n.fedTime = i.time;
|
|
4194
|
-
let o = Math.ceil(a.length /
|
|
4195
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
4204
|
+
let o = Math.ceil(a.length / gi);
|
|
4205
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of _i(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
4196
4206
|
this.tradingManager.setCurrentPrice(i.close);
|
|
4197
4207
|
}
|
|
4198
4208
|
getReplayBarIndex() {
|
|
@@ -4203,7 +4213,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4203
4213
|
}
|
|
4204
4214
|
replaySeekToBar(e) {
|
|
4205
4215
|
let t = this.replayStepsSeries;
|
|
4206
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
4216
|
+
this.replaySeek(t && this.replayCoarse ? yi(t, this.replayCoarse, e) : e);
|
|
4207
4217
|
}
|
|
4208
4218
|
replayPause() {
|
|
4209
4219
|
this.setHeldState("paused") || this.replayManager.pause();
|
|
@@ -4241,10 +4251,10 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4241
4251
|
if (!n) return null;
|
|
4242
4252
|
let r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
4243
4253
|
for (let e of t.anchors) {
|
|
4244
|
-
let
|
|
4245
|
-
i = Math.min(i,
|
|
4254
|
+
let { x: r, y: c } = this.drawingManager.anchorPoint(t.type, e, n);
|
|
4255
|
+
i = Math.min(i, r), a = Math.max(a, r), o = Math.min(o, c), s = Math.max(s, c);
|
|
4246
4256
|
}
|
|
4247
|
-
return
|
|
4257
|
+
return Jr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Yr.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 ? {
|
|
4248
4258
|
x: i,
|
|
4249
4259
|
y: o,
|
|
4250
4260
|
width: a - i,
|
|
@@ -4280,7 +4290,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4280
4290
|
};
|
|
4281
4291
|
}
|
|
4282
4292
|
captureSnapshot() {
|
|
4283
|
-
return
|
|
4293
|
+
return T.capture({
|
|
4284
4294
|
getDrawings: () => [...this.getDrawings().filter((e) => e.paneId === void 0 || this.layoutManager.getPanels().some((t) => t.id === e.paneId)), ...this.keptPaneDrawings],
|
|
4285
4295
|
getTheme: () => this.themeManager.getBaseTheme(),
|
|
4286
4296
|
getAlerts: () => this.getAlerts(),
|
|
@@ -4293,14 +4303,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4293
4303
|
});
|
|
4294
4304
|
}
|
|
4295
4305
|
restoreIndicators(e, t) {
|
|
4296
|
-
let n =
|
|
4306
|
+
let n = Zr(e), r = /* @__PURE__ */ new Map();
|
|
4297
4307
|
this.unrestoredIndicators = [];
|
|
4298
4308
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
4299
4309
|
if (t) {
|
|
4300
4310
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
4301
4311
|
for (let n of t) {
|
|
4302
4312
|
let t = e.get(n.instanceId);
|
|
4303
|
-
t &&
|
|
4313
|
+
t && Qr(n, t) && o.add(n.instanceId);
|
|
4304
4314
|
}
|
|
4305
4315
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
4306
4316
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -4362,7 +4372,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4362
4372
|
let s = t.levels ?? null;
|
|
4363
4373
|
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
|
|
4364
4374
|
let c = t.intervals ?? null;
|
|
4365
|
-
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ?
|
|
4375
|
+
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? se(t.paneStyle) : null);
|
|
4366
4376
|
}
|
|
4367
4377
|
restorePanes(e) {
|
|
4368
4378
|
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, {
|
|
@@ -4475,7 +4485,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4475
4485
|
}
|
|
4476
4486
|
let o = this.getIndicatorSetup();
|
|
4477
4487
|
if (JSON.stringify(n) === JSON.stringify(o)) return a;
|
|
4478
|
-
let s = performance.now(), c = this.undoRedoManager.last(), l = e !== void 0 && c?.type === "indicators" && c.indicators?.subject === e && s - (c.indicators.at ?? 0) <
|
|
4488
|
+
let s = performance.now(), c = this.undoRedoManager.last(), l = e !== void 0 && c?.type === "indicators" && c.indicators?.subject === e && s - (c.indicators.at ?? 0) < Vr && JSON.stringify(c.indicators.after) === JSON.stringify(n), u = {
|
|
4479
4489
|
type: "indicators",
|
|
4480
4490
|
before: null,
|
|
4481
4491
|
after: null
|
|
@@ -4486,7 +4496,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4486
4496
|
...c.indicators,
|
|
4487
4497
|
after: o,
|
|
4488
4498
|
at: s,
|
|
4489
|
-
...
|
|
4499
|
+
...Ur([...c.indicators.renames ?? [], ...r])
|
|
4490
4500
|
}
|
|
4491
4501
|
}) : this.undoRedoManager.push({
|
|
4492
4502
|
...u,
|
|
@@ -4495,7 +4505,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4495
4505
|
after: o,
|
|
4496
4506
|
subject: e,
|
|
4497
4507
|
at: s,
|
|
4498
|
-
...
|
|
4508
|
+
...Ur(r)
|
|
4499
4509
|
}
|
|
4500
4510
|
}), a;
|
|
4501
4511
|
}
|
|
@@ -4529,19 +4539,19 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4529
4539
|
let t = this.layoutManager.getPanels().find((t) => t.id === e);
|
|
4530
4540
|
if (!t || t.position !== "top" && t.position !== "bottom" || this.layoutManager.isPanelShownCollapsed(e)) return null;
|
|
4531
4541
|
let n = this.buildPanelRenderInfos().find((t) => t.instanceId === e);
|
|
4532
|
-
return !n || n.viewport.chartRect.height <
|
|
4542
|
+
return !n || n.viewport.chartRect.height < Hr ? null : {
|
|
4533
4543
|
...n.viewport,
|
|
4534
4544
|
data: this.getDisplayData()
|
|
4535
4545
|
};
|
|
4536
4546
|
}
|
|
4537
4547
|
saveState(e) {
|
|
4538
4548
|
if (!this.features.saveLoad) return null;
|
|
4539
|
-
let t = this.captureSnapshot(), n =
|
|
4540
|
-
return e &&
|
|
4549
|
+
let t = this.captureSnapshot(), n = T.serialize(t);
|
|
4550
|
+
return e && T.saveToStorage(e, t), n;
|
|
4541
4551
|
}
|
|
4542
4552
|
loadState(e) {
|
|
4543
4553
|
if (!this.features.saveLoad) return;
|
|
4544
|
-
let t =
|
|
4554
|
+
let t = T.deserialize(e);
|
|
4545
4555
|
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");
|
|
4546
4556
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
4547
4557
|
this.drawingManager.renamePanes(n);
|
|
@@ -4554,7 +4564,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4554
4564
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
4555
4565
|
return r ? r + e.slice(t) : e;
|
|
4556
4566
|
}, r = t(e.channel), i = {
|
|
4557
|
-
...
|
|
4567
|
+
...zt(e),
|
|
4558
4568
|
...e.target ? { target: t(e.target) } : {}
|
|
4559
4569
|
};
|
|
4560
4570
|
if (!e.expired) {
|
|
@@ -4574,19 +4584,19 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4574
4584
|
}
|
|
4575
4585
|
loadStateFromStorage(e) {
|
|
4576
4586
|
if (!this.features.saveLoad) return !1;
|
|
4577
|
-
let t =
|
|
4578
|
-
return t ? (this.loadState(
|
|
4587
|
+
let t = T.loadFromStorage(e);
|
|
4588
|
+
return t ? (this.loadState(T.serialize(t)), !0) : !1;
|
|
4579
4589
|
}
|
|
4580
4590
|
downloadState(e) {
|
|
4581
|
-
this.features.saveLoad &&
|
|
4591
|
+
this.features.saveLoad && T.downloadFile(this.captureSnapshot(), e);
|
|
4582
4592
|
}
|
|
4583
4593
|
async loadStateFromFile() {
|
|
4584
4594
|
if (!this.features.saveLoad) return;
|
|
4585
|
-
let e = await
|
|
4586
|
-
this.loadState(
|
|
4595
|
+
let e = await T.loadFromFile();
|
|
4596
|
+
this.loadState(T.serialize(e));
|
|
4587
4597
|
}
|
|
4588
4598
|
setLocale(e) {
|
|
4589
|
-
|
|
4599
|
+
le(e), this.engine.requestRender();
|
|
4590
4600
|
}
|
|
4591
4601
|
setNumberLocale(e) {
|
|
4592
4602
|
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();
|
|
@@ -4636,14 +4646,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4636
4646
|
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 = "";
|
|
4637
4647
|
}
|
|
4638
4648
|
createChartRenderer(e) {
|
|
4639
|
-
let t =
|
|
4640
|
-
return t instanceof
|
|
4649
|
+
let t = kn(e, (e) => this.pluginManager.getChartType(e));
|
|
4650
|
+
return t instanceof ze && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
4641
4651
|
}
|
|
4642
4652
|
crosshairSeries() {
|
|
4643
4653
|
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
4644
4654
|
}
|
|
4645
4655
|
getDisplayData() {
|
|
4646
|
-
let e = this.series.bars(), t = this.options.chartType === "rangeBars" ?
|
|
4656
|
+
let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? En(e, (e) => this.stepAt(e)) : void 0;
|
|
4647
4657
|
if (this.displayDataCache && t === this.displayDataStep) return this.displayDataCache;
|
|
4648
4658
|
if (e.length === 0) return e;
|
|
4649
4659
|
let n = this.displaySeries(e, t);
|
|
@@ -4651,9 +4661,9 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4651
4661
|
}
|
|
4652
4662
|
displaySeries(e, t) {
|
|
4653
4663
|
let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
|
|
4654
|
-
if (n !== "pointAndFigure" || r(n)) return
|
|
4655
|
-
let { columns: i, boxSize: a } =
|
|
4656
|
-
return this.chartRenderer instanceof
|
|
4664
|
+
if (n !== "pointAndFigure" || r(n)) return An(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
|
|
4665
|
+
let { columns: i, boxSize: a } = pn(e, this.chartTypeOptions, this.reshapeMemo);
|
|
4666
|
+
return this.chartRenderer instanceof tt && this.chartRenderer.setBoxSize(a), i;
|
|
4657
4667
|
}
|
|
4658
4668
|
recalcIndicatorsFrom(e, t) {
|
|
4659
4669
|
if (!this.isTimeAligned()) return this.recalcIndicators(e);
|
|
@@ -4665,7 +4675,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4665
4675
|
}
|
|
4666
4676
|
exportBars() {
|
|
4667
4677
|
if (this.isTimeAligned()) return this.series.bars();
|
|
4668
|
-
let e = this.getDisplayData(), t =
|
|
4678
|
+
let e = this.getDisplayData(), t = A(e);
|
|
4669
4679
|
return e.map((e, n) => ({
|
|
4670
4680
|
...e,
|
|
4671
4681
|
time: t[n]?.time ?? e.time
|
|
@@ -4724,12 +4734,12 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4724
4734
|
}
|
|
4725
4735
|
fitPriceScale(e, t) {
|
|
4726
4736
|
if (e.length === 0) return;
|
|
4727
|
-
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i =
|
|
4737
|
+
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = ii(ii(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() && ri(e, n, r) ? this.volumeRenderer.getHeightRatio() + Br : D;
|
|
4728
4738
|
this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
|
|
4729
4739
|
top: a,
|
|
4730
|
-
bottom:
|
|
4740
|
+
bottom: D
|
|
4731
4741
|
} : {
|
|
4732
|
-
top:
|
|
4742
|
+
top: D,
|
|
4733
4743
|
bottom: a
|
|
4734
4744
|
}), this.viewport.fitToPrices(i.min, i.max);
|
|
4735
4745
|
}
|
|
@@ -4751,7 +4761,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4751
4761
|
fitLeftAxisWidth() {
|
|
4752
4762
|
let e = this.leftViewport;
|
|
4753
4763
|
if (!e) return !1;
|
|
4754
|
-
let t = this.themeManager.getTheme(), n =
|
|
4764
|
+
let t = this.themeManager.getTheme(), n = tr({
|
|
4755
4765
|
min: e.priceRange.min,
|
|
4756
4766
|
max: e.priceRange.max,
|
|
4757
4767
|
lastPrice: null,
|
|
@@ -4760,12 +4770,12 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4760
4770
|
fontFamily: t.font.family,
|
|
4761
4771
|
fontSizeSmall: t.font.sizeSmall,
|
|
4762
4772
|
measure: (e, t) => this.measureText(e, t)
|
|
4763
|
-
}), r =
|
|
4773
|
+
}), r = nr(this.leftAxisWidth, n);
|
|
4764
4774
|
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);
|
|
4765
4775
|
}
|
|
4766
4776
|
fitPriceAxisWidth() {
|
|
4767
4777
|
if (!this.features.priceAxis) return !1;
|
|
4768
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
4778
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = tr({
|
|
4769
4779
|
min: e.min,
|
|
4770
4780
|
max: e.max,
|
|
4771
4781
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -4776,14 +4786,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4776
4786
|
fontFamily: t.font.family,
|
|
4777
4787
|
fontSizeSmall: t.font.sizeSmall,
|
|
4778
4788
|
measure: (e, t) => this.measureText(e, t)
|
|
4779
|
-
}), r =
|
|
4789
|
+
}), r = nr(this.priceAxisWidth, n);
|
|
4780
4790
|
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);
|
|
4781
4791
|
}
|
|
4782
4792
|
measureText(e, t) {
|
|
4783
4793
|
let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
|
|
4784
|
-
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () =>
|
|
4794
|
+
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => $r(n, e, t));
|
|
4785
4795
|
let i = n ?? this.detachedMeasureContext();
|
|
4786
|
-
return i ?
|
|
4796
|
+
return i ? $r(i, e, t) : e.length * 7;
|
|
4787
4797
|
}
|
|
4788
4798
|
detachedMeasureContext() {
|
|
4789
4799
|
return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
|
|
@@ -4824,7 +4834,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4824
4834
|
buildPanelRenderInfos() {
|
|
4825
4835
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
4826
4836
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
4827
|
-
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) ?? { ...
|
|
4837
|
+
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) ?? { ...Pr }, o = {
|
|
4828
4838
|
x: e.rect.x,
|
|
4829
4839
|
y: e.rect.y + 20,
|
|
4830
4840
|
width: e.rect.width,
|
|
@@ -4909,7 +4919,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4909
4919
|
});
|
|
4910
4920
|
}
|
|
4911
4921
|
drawOverlayPlugins(e, t) {
|
|
4912
|
-
let n =
|
|
4922
|
+
let n = sr(this.pluginManager.getOverlays(), t);
|
|
4913
4923
|
if (n.length === 0) return;
|
|
4914
4924
|
let r = {
|
|
4915
4925
|
viewport: this.viewport.getState(),
|
|
@@ -4930,7 +4940,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4930
4940
|
};
|
|
4931
4941
|
}
|
|
4932
4942
|
};
|
|
4933
|
-
function
|
|
4943
|
+
function Zr(e) {
|
|
4934
4944
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
4935
4945
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
4936
4946
|
i.add(e.instanceId);
|
|
@@ -4944,19 +4954,19 @@ function $r(e) {
|
|
|
4944
4954
|
for (let t of e) a(t);
|
|
4945
4955
|
return n;
|
|
4946
4956
|
}
|
|
4947
|
-
function
|
|
4957
|
+
function Qr(e, t) {
|
|
4948
4958
|
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);
|
|
4949
4959
|
}
|
|
4950
|
-
function
|
|
4960
|
+
function $r(e, t, n) {
|
|
4951
4961
|
let r = e.font;
|
|
4952
4962
|
e.font = n;
|
|
4953
4963
|
let i = e.measureText(t).width;
|
|
4954
4964
|
return e.font = r, i;
|
|
4955
4965
|
}
|
|
4956
|
-
var
|
|
4957
|
-
function
|
|
4966
|
+
var ei = 300;
|
|
4967
|
+
function ti(e) {
|
|
4958
4968
|
let t = {}, n = e.family;
|
|
4959
|
-
typeof n == "string" && n.trim() !== "" && n.length <=
|
|
4969
|
+
typeof n == "string" && n.trim() !== "" && n.length <= ei && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
|
|
4960
4970
|
for (let n of [
|
|
4961
4971
|
"sizeSmall",
|
|
4962
4972
|
"sizeMedium",
|
|
@@ -4967,15 +4977,15 @@ function ri(e) {
|
|
|
4967
4977
|
}
|
|
4968
4978
|
return t;
|
|
4969
4979
|
}
|
|
4970
|
-
function
|
|
4980
|
+
function ni(e) {
|
|
4971
4981
|
let t = e.tagRadius;
|
|
4972
4982
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
4973
4983
|
}
|
|
4974
|
-
function
|
|
4984
|
+
function ri(e, t, n) {
|
|
4975
4985
|
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
4976
4986
|
return !1;
|
|
4977
4987
|
}
|
|
4978
|
-
function
|
|
4988
|
+
function ii(e, t) {
|
|
4979
4989
|
return e ? t ? {
|
|
4980
4990
|
min: Math.min(e.min, t.min),
|
|
4981
4991
|
max: Math.max(e.max, t.max)
|
|
@@ -4996,14 +5006,14 @@ function J(e) {
|
|
|
4996
5006
|
bars: e.bars
|
|
4997
5007
|
};
|
|
4998
5008
|
}
|
|
4999
|
-
var
|
|
5009
|
+
var ai = 8e3, oi = new Set([
|
|
5000
5010
|
"candlestick",
|
|
5001
5011
|
"line",
|
|
5002
5012
|
"area",
|
|
5003
5013
|
"bar",
|
|
5004
5014
|
"hollowCandle"
|
|
5005
|
-
]),
|
|
5006
|
-
function
|
|
5015
|
+
]), si = 10, ci = 50, li = .001;
|
|
5016
|
+
function ui(e) {
|
|
5007
5017
|
return {
|
|
5008
5018
|
price: null,
|
|
5009
5019
|
fedTime: null,
|
|
@@ -5018,41 +5028,41 @@ function fi(e) {
|
|
|
5018
5028
|
held: null
|
|
5019
5029
|
};
|
|
5020
5030
|
}
|
|
5021
|
-
function
|
|
5031
|
+
function di(e, t) {
|
|
5022
5032
|
let n = e[t + 1];
|
|
5023
5033
|
return n ? n.time - e[t].time : Z(e);
|
|
5024
5034
|
}
|
|
5025
|
-
function
|
|
5035
|
+
function fi(e, t, n) {
|
|
5026
5036
|
let r = e.fedTime;
|
|
5027
5037
|
if (r === null || !t || t.length === 0 || n.length === 0) return;
|
|
5028
|
-
let i =
|
|
5038
|
+
let i = di(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
|
|
5029
5039
|
if (s > a) return;
|
|
5030
|
-
let c =
|
|
5040
|
+
let c = di(n, o);
|
|
5031
5041
|
if (a === s && o > 0) {
|
|
5032
5042
|
e.fedTime = n[o - 1].time, e.fedFraction = 1;
|
|
5033
5043
|
return;
|
|
5034
5044
|
}
|
|
5035
5045
|
e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
|
|
5036
5046
|
}
|
|
5037
|
-
function
|
|
5047
|
+
function pi(e, t) {
|
|
5038
5048
|
let n = X(e, t), r = e.length - 1;
|
|
5039
5049
|
return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
|
|
5040
5050
|
}
|
|
5041
|
-
function
|
|
5051
|
+
function mi(e) {
|
|
5042
5052
|
let t = Infinity;
|
|
5043
5053
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
|
|
5044
5054
|
return t;
|
|
5045
5055
|
}
|
|
5046
|
-
function
|
|
5047
|
-
if (!(
|
|
5048
|
-
let n = Math.max(0, e.length -
|
|
5056
|
+
function hi(e, t) {
|
|
5057
|
+
if (!(mi(e) < mi(t))) return !1;
|
|
5058
|
+
let n = Math.max(0, e.length - ci);
|
|
5049
5059
|
for (let r = n; r < e.length; r++) {
|
|
5050
|
-
let n = t[Q(t, e[r].time)], i = (n.high - n.low) *
|
|
5060
|
+
let n = t[Q(t, e[r].time)], i = (n.high - n.low) * li + 2 ** -52;
|
|
5051
5061
|
if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
|
|
5052
5062
|
}
|
|
5053
5063
|
return !0;
|
|
5054
5064
|
}
|
|
5055
|
-
var
|
|
5065
|
+
var gi = 500;
|
|
5056
5066
|
function Y(e, t) {
|
|
5057
5067
|
let n = 0, r = e.length;
|
|
5058
5068
|
for (; n < r;) {
|
|
@@ -5069,7 +5079,7 @@ function X(e, t) {
|
|
|
5069
5079
|
}
|
|
5070
5080
|
return n;
|
|
5071
5081
|
}
|
|
5072
|
-
function
|
|
5082
|
+
function _i(e) {
|
|
5073
5083
|
let t = 0, n = 0;
|
|
5074
5084
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
5075
5085
|
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];
|
|
@@ -5080,9 +5090,9 @@ function Z(e) {
|
|
|
5080
5090
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
5081
5091
|
return t > 0 ? t : Infinity;
|
|
5082
5092
|
}
|
|
5083
|
-
function
|
|
5093
|
+
function vi(e, t) {
|
|
5084
5094
|
if (t.length === 0) return null;
|
|
5085
|
-
let n = t[t.length - 1].time + Z(t), r = e.filter((e) =>
|
|
5095
|
+
let n = t[t.length - 1].time + Z(t), r = e.filter((e) => Ln(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
5086
5096
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
5087
5097
|
if (i.length === 0) return null;
|
|
5088
5098
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -5098,26 +5108,26 @@ function Q(e, t) {
|
|
|
5098
5108
|
}
|
|
5099
5109
|
return n;
|
|
5100
5110
|
}
|
|
5101
|
-
function
|
|
5111
|
+
function yi(e, t, n) {
|
|
5102
5112
|
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;
|
|
5103
5113
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
5104
5114
|
return Math.max(0, a);
|
|
5105
5115
|
}
|
|
5106
|
-
function
|
|
5116
|
+
function bi(e, t, n) {
|
|
5107
5117
|
let r = n;
|
|
5108
5118
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
5109
5119
|
let i = {
|
|
5110
5120
|
...t[r],
|
|
5111
5121
|
time: e.time
|
|
5112
5122
|
};
|
|
5113
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
5123
|
+
for (let e = r + 1; e <= n; e++) i = wi(i, t[e]);
|
|
5114
5124
|
return i;
|
|
5115
5125
|
}
|
|
5116
|
-
function
|
|
5126
|
+
function xi(e, t, n, r) {
|
|
5117
5127
|
let i = e[n + 1], a = t[r + 1];
|
|
5118
5128
|
return i !== void 0 && a !== void 0 && i.time >= a.time;
|
|
5119
5129
|
}
|
|
5120
|
-
function
|
|
5130
|
+
function Si(e, t) {
|
|
5121
5131
|
let n = /* @__PURE__ */ new Map();
|
|
5122
5132
|
for (let r of e) {
|
|
5123
5133
|
let e = t[Q(t, r.time)].time, i = n.get(e);
|
|
@@ -5125,10 +5135,10 @@ function wi(e, t) {
|
|
|
5125
5135
|
}
|
|
5126
5136
|
return n;
|
|
5127
5137
|
}
|
|
5128
|
-
function
|
|
5138
|
+
function Ci() {
|
|
5129
5139
|
return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5130
5140
|
}
|
|
5131
|
-
function
|
|
5141
|
+
function wi(e, t) {
|
|
5132
5142
|
return {
|
|
5133
5143
|
time: e.time,
|
|
5134
5144
|
open: e.open,
|
|
@@ -5140,26 +5150,26 @@ function Ei(e, t) {
|
|
|
5140
5150
|
}
|
|
5141
5151
|
//#endregion
|
|
5142
5152
|
//#region src/io/parseOHLCV.ts
|
|
5143
|
-
var
|
|
5153
|
+
var Ti = [
|
|
5144
5154
|
"time",
|
|
5145
5155
|
"timestamp",
|
|
5146
5156
|
"date",
|
|
5147
5157
|
"datetime",
|
|
5148
5158
|
"t"
|
|
5149
|
-
],
|
|
5159
|
+
], Ei = ["open", "o"], Di = ["high", "h"], Oi = ["low", "l"], ki = ["close", "c"], Ai = [
|
|
5150
5160
|
"volume",
|
|
5151
5161
|
"vol",
|
|
5152
5162
|
"v"
|
|
5153
5163
|
];
|
|
5154
|
-
function
|
|
5164
|
+
function ji(e) {
|
|
5155
5165
|
let t = e.trim();
|
|
5156
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
5166
|
+
return t ? t[0] === "[" || t[0] === "{" ? Mi(t) : Ni(t) : {
|
|
5157
5167
|
data: [],
|
|
5158
5168
|
rowCount: 0,
|
|
5159
5169
|
skipped: 0
|
|
5160
5170
|
};
|
|
5161
5171
|
}
|
|
5162
|
-
function
|
|
5172
|
+
function Mi(e) {
|
|
5163
5173
|
let t;
|
|
5164
5174
|
try {
|
|
5165
5175
|
t = JSON.parse(e);
|
|
@@ -5169,19 +5179,19 @@ function Pi(e) {
|
|
|
5169
5179
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
5170
5180
|
let n = [], r = 0;
|
|
5171
5181
|
for (let e of t) {
|
|
5172
|
-
let t = Array.isArray(e) ?
|
|
5182
|
+
let t = Array.isArray(e) ? Ri(e) : Li(e);
|
|
5173
5183
|
t ? n.push(t) : r++;
|
|
5174
5184
|
}
|
|
5175
|
-
return
|
|
5185
|
+
return Bi(n, t.length, r);
|
|
5176
5186
|
}
|
|
5177
|
-
function
|
|
5187
|
+
function Ni(e) {
|
|
5178
5188
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
5179
5189
|
if (t.length === 0) return {
|
|
5180
5190
|
data: [],
|
|
5181
5191
|
rowCount: 0,
|
|
5182
5192
|
skipped: 0
|
|
5183
5193
|
};
|
|
5184
|
-
let n =
|
|
5194
|
+
let n = Pi(t[0]), r = Fi(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ii(r) : {
|
|
5185
5195
|
time: 0,
|
|
5186
5196
|
open: 1,
|
|
5187
5197
|
high: 2,
|
|
@@ -5192,7 +5202,7 @@ function Fi(e) {
|
|
|
5192
5202
|
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");
|
|
5193
5203
|
let o = [], s = 0;
|
|
5194
5204
|
for (let e = +!!i; e < t.length; e++) {
|
|
5195
|
-
let r =
|
|
5205
|
+
let r = Fi(t[e], n), i = zi(r[a.time]), c = $(r[a.open]), l = $(r[a.high]), u = $(r[a.low]), d = $(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
5196
5206
|
if (i === null || ![
|
|
5197
5207
|
c,
|
|
5198
5208
|
l,
|
|
@@ -5211,9 +5221,9 @@ function Fi(e) {
|
|
|
5211
5221
|
volume: Number.isFinite(f) ? f : 0
|
|
5212
5222
|
});
|
|
5213
5223
|
}
|
|
5214
|
-
return
|
|
5224
|
+
return Bi(o, t.length - +!!i, s);
|
|
5215
5225
|
}
|
|
5216
|
-
function
|
|
5226
|
+
function Pi(e) {
|
|
5217
5227
|
let t = {
|
|
5218
5228
|
",": 0,
|
|
5219
5229
|
";": 0,
|
|
@@ -5225,7 +5235,7 @@ function Ii(e) {
|
|
|
5225
5235
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
5226
5236
|
return n;
|
|
5227
5237
|
}
|
|
5228
|
-
function
|
|
5238
|
+
function Fi(e, t) {
|
|
5229
5239
|
let n = [], r = "", i = !1;
|
|
5230
5240
|
for (let a = 0; a < e.length; a++) {
|
|
5231
5241
|
let o = e[a];
|
|
@@ -5233,25 +5243,25 @@ function Li(e, t) {
|
|
|
5233
5243
|
}
|
|
5234
5244
|
return n.push(r), n;
|
|
5235
5245
|
}
|
|
5236
|
-
function
|
|
5246
|
+
function Ii(e) {
|
|
5237
5247
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
5238
5248
|
return {
|
|
5239
|
-
time: t(
|
|
5240
|
-
open: t(
|
|
5241
|
-
high: t(
|
|
5242
|
-
low: t(
|
|
5243
|
-
close: t(
|
|
5244
|
-
volume: t(
|
|
5249
|
+
time: t(Ti),
|
|
5250
|
+
open: t(Ei),
|
|
5251
|
+
high: t(Di),
|
|
5252
|
+
low: t(Oi),
|
|
5253
|
+
close: t(ki),
|
|
5254
|
+
volume: t(Ai)
|
|
5245
5255
|
};
|
|
5246
5256
|
}
|
|
5247
|
-
function
|
|
5257
|
+
function Li(e) {
|
|
5248
5258
|
let t = (t) => {
|
|
5249
5259
|
for (let n of t) {
|
|
5250
5260
|
if (e[n] !== void 0) return e[n];
|
|
5251
5261
|
let t = n.toUpperCase();
|
|
5252
5262
|
if (e[t] !== void 0) return e[t];
|
|
5253
5263
|
}
|
|
5254
|
-
}, n =
|
|
5264
|
+
}, n = zi(String(t(Ti) ?? "")), r = Number(t(Ei)), i = Number(t(Di)), a = Number(t(Oi)), o = Number(t(ki)), s = Number(t(Ai) ?? 0);
|
|
5255
5265
|
return n === null || ![
|
|
5256
5266
|
r,
|
|
5257
5267
|
i,
|
|
@@ -5266,9 +5276,9 @@ function zi(e) {
|
|
|
5266
5276
|
volume: Number.isFinite(s) ? s : 0
|
|
5267
5277
|
};
|
|
5268
5278
|
}
|
|
5269
|
-
function
|
|
5279
|
+
function Ri(e) {
|
|
5270
5280
|
if (e.length < 5) return null;
|
|
5271
|
-
let t =
|
|
5281
|
+
let t = zi(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;
|
|
5272
5282
|
return t === null || ![
|
|
5273
5283
|
n,
|
|
5274
5284
|
r,
|
|
@@ -5286,7 +5296,7 @@ function Bi(e) {
|
|
|
5286
5296
|
function $(e) {
|
|
5287
5297
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
5288
5298
|
}
|
|
5289
|
-
function
|
|
5299
|
+
function zi(e) {
|
|
5290
5300
|
let t = e.trim();
|
|
5291
5301
|
if (!t) return null;
|
|
5292
5302
|
let n = Number(t);
|
|
@@ -5294,7 +5304,7 @@ function Vi(e) {
|
|
|
5294
5304
|
let r = Date.parse(t);
|
|
5295
5305
|
return Number.isFinite(r) ? r : null;
|
|
5296
5306
|
}
|
|
5297
|
-
function
|
|
5307
|
+
function Bi(e, t, n) {
|
|
5298
5308
|
e.sort((e, t) => e.time - t.time);
|
|
5299
5309
|
let r = [];
|
|
5300
5310
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -5306,7 +5316,7 @@ function Hi(e, t, n) {
|
|
|
5306
5316
|
}
|
|
5307
5317
|
//#endregion
|
|
5308
5318
|
//#region src/io/DragDropImporter.ts
|
|
5309
|
-
var
|
|
5319
|
+
var Vi = class {
|
|
5310
5320
|
host;
|
|
5311
5321
|
overlay = null;
|
|
5312
5322
|
callbacks;
|
|
@@ -5327,19 +5337,19 @@ var Ui = class {
|
|
|
5327
5337
|
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();
|
|
5328
5338
|
}
|
|
5329
5339
|
onDragEnter(e) {
|
|
5330
|
-
|
|
5340
|
+
Hi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
5331
5341
|
}
|
|
5332
5342
|
onDragOver(e) {
|
|
5333
|
-
|
|
5343
|
+
Hi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
5334
5344
|
}
|
|
5335
5345
|
onDragLeave(e) {
|
|
5336
|
-
|
|
5346
|
+
Hi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
5337
5347
|
}
|
|
5338
5348
|
async onDrop(e) {
|
|
5339
5349
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
5340
5350
|
let t = e.dataTransfer?.files?.[0];
|
|
5341
5351
|
if (t) try {
|
|
5342
|
-
let e =
|
|
5352
|
+
let e = ji(await t.text());
|
|
5343
5353
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
5344
5354
|
this.callbacks.onData(e.data, e, t);
|
|
5345
5355
|
} catch (e) {
|
|
@@ -5370,12 +5380,12 @@ var Ui = class {
|
|
|
5370
5380
|
this.overlay?.remove(), this.overlay = null;
|
|
5371
5381
|
}
|
|
5372
5382
|
};
|
|
5373
|
-
function
|
|
5383
|
+
function Hi(e) {
|
|
5374
5384
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
5375
5385
|
}
|
|
5376
5386
|
//#endregion
|
|
5377
5387
|
//#region src/state/layoutStorage.ts
|
|
5378
|
-
function
|
|
5388
|
+
function Ui(e) {
|
|
5379
5389
|
let t = {
|
|
5380
5390
|
id: e.id,
|
|
5381
5391
|
name: e.name,
|
|
@@ -5383,11 +5393,11 @@ function Gi(e) {
|
|
|
5383
5393
|
};
|
|
5384
5394
|
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;
|
|
5385
5395
|
}
|
|
5386
|
-
var
|
|
5387
|
-
function
|
|
5396
|
+
var Wi = (e, t) => t.updatedAt - e.updatedAt;
|
|
5397
|
+
function Gi(e) {
|
|
5388
5398
|
if (typeof e != "object" || !e) return null;
|
|
5389
5399
|
let t = e;
|
|
5390
|
-
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null :
|
|
5400
|
+
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Ui({
|
|
5391
5401
|
id: t.id,
|
|
5392
5402
|
name: t.name,
|
|
5393
5403
|
updatedAt: t.updatedAt,
|
|
@@ -5396,17 +5406,17 @@ function qi(e) {
|
|
|
5396
5406
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
5397
5407
|
});
|
|
5398
5408
|
}
|
|
5399
|
-
function
|
|
5400
|
-
let t =
|
|
5409
|
+
function Ki(e) {
|
|
5410
|
+
let t = Gi(e), n = t ? e.content : void 0;
|
|
5401
5411
|
return t && typeof n == "string" ? {
|
|
5402
5412
|
...t,
|
|
5403
5413
|
content: n
|
|
5404
5414
|
} : null;
|
|
5405
5415
|
}
|
|
5406
|
-
function
|
|
5416
|
+
function qi(e = []) {
|
|
5407
5417
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
5408
5418
|
return {
|
|
5409
|
-
list: () => [...t.values()].map(
|
|
5419
|
+
list: () => [...t.values()].map(Ui).sort(Wi),
|
|
5410
5420
|
load: (e) => {
|
|
5411
5421
|
let n = t.get(e);
|
|
5412
5422
|
return n ? { ...n } : null;
|
|
@@ -5419,7 +5429,7 @@ function Yi(e = []) {
|
|
|
5419
5429
|
}
|
|
5420
5430
|
};
|
|
5421
5431
|
}
|
|
5422
|
-
function
|
|
5432
|
+
function Ji(e = "tcw:layouts:") {
|
|
5423
5433
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
5424
5434
|
let e;
|
|
5425
5435
|
try {
|
|
@@ -5427,10 +5437,10 @@ function Xi(e = "tcw:layouts:") {
|
|
|
5427
5437
|
} catch {
|
|
5428
5438
|
return [];
|
|
5429
5439
|
}
|
|
5430
|
-
return Array.isArray(e) ? e.map(
|
|
5440
|
+
return Array.isArray(e) ? e.map(Gi).filter((e) => e !== null) : [];
|
|
5431
5441
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
5432
5442
|
return {
|
|
5433
|
-
list: () => r().sort(
|
|
5443
|
+
list: () => r().sort(Wi),
|
|
5434
5444
|
load: (e) => {
|
|
5435
5445
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
5436
5446
|
return t && i !== null ? {
|
|
@@ -5439,7 +5449,7 @@ function Xi(e = "tcw:layouts:") {
|
|
|
5439
5449
|
} : null;
|
|
5440
5450
|
},
|
|
5441
5451
|
save: (e) => {
|
|
5442
|
-
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id),
|
|
5452
|
+
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Ui(e)]);
|
|
5443
5453
|
},
|
|
5444
5454
|
remove: (e) => {
|
|
5445
5455
|
i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
|
|
@@ -5448,14 +5458,14 @@ function Xi(e = "tcw:layouts:") {
|
|
|
5448
5458
|
}
|
|
5449
5459
|
//#endregion
|
|
5450
5460
|
//#region src/state/LayoutSession.ts
|
|
5451
|
-
var
|
|
5452
|
-
function
|
|
5461
|
+
var Yi = 80;
|
|
5462
|
+
function Xi(e) {
|
|
5453
5463
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
5454
5464
|
}
|
|
5455
|
-
function
|
|
5465
|
+
function Zi() {
|
|
5456
5466
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
5457
5467
|
}
|
|
5458
|
-
function
|
|
5468
|
+
function Qi(e) {
|
|
5459
5469
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
5460
5470
|
return {
|
|
5461
5471
|
id: t,
|
|
@@ -5466,7 +5476,7 @@ function ea(e) {
|
|
|
5466
5476
|
...o === void 0 ? {} : { kind: o }
|
|
5467
5477
|
};
|
|
5468
5478
|
}
|
|
5469
|
-
var
|
|
5479
|
+
var $i = class {
|
|
5470
5480
|
currentLayout = null;
|
|
5471
5481
|
savedContent = null;
|
|
5472
5482
|
dirty = !1;
|
|
@@ -5482,7 +5492,7 @@ var ta = class {
|
|
|
5482
5492
|
now;
|
|
5483
5493
|
newId;
|
|
5484
5494
|
constructor(e, t, n = {}) {
|
|
5485
|
-
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 ??
|
|
5495
|
+
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 ?? Zi;
|
|
5486
5496
|
}
|
|
5487
5497
|
current() {
|
|
5488
5498
|
return this.currentLayout;
|
|
@@ -5498,7 +5508,7 @@ var ta = class {
|
|
|
5498
5508
|
}
|
|
5499
5509
|
async list() {
|
|
5500
5510
|
let e = await this.storage.list();
|
|
5501
|
-
return Array.isArray(e) ? e.map(
|
|
5511
|
+
return Array.isArray(e) ? e.map(Gi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
|
|
5502
5512
|
}
|
|
5503
5513
|
save() {
|
|
5504
5514
|
return this.queue(() => {
|
|
@@ -5507,12 +5517,12 @@ var ta = class {
|
|
|
5507
5517
|
});
|
|
5508
5518
|
}
|
|
5509
5519
|
saveAs(e) {
|
|
5510
|
-
let t =
|
|
5520
|
+
let t = Xi(e);
|
|
5511
5521
|
return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
|
|
5512
5522
|
}
|
|
5513
5523
|
open(e) {
|
|
5514
5524
|
return this.queue(async () => {
|
|
5515
|
-
let t =
|
|
5525
|
+
let t = Ki(await this.storage.load(e));
|
|
5516
5526
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
5517
5527
|
this.cancelTimer(), this.applying++;
|
|
5518
5528
|
try {
|
|
@@ -5522,13 +5532,13 @@ var ta = class {
|
|
|
5522
5532
|
} finally {
|
|
5523
5533
|
this.applying--;
|
|
5524
5534
|
}
|
|
5525
|
-
return this.cancelTimer(), this.currentLayout =
|
|
5535
|
+
return this.cancelTimer(), this.currentLayout = Qi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
5526
5536
|
});
|
|
5527
5537
|
}
|
|
5528
5538
|
rename(e, t) {
|
|
5529
|
-
let n =
|
|
5539
|
+
let n = Xi(t);
|
|
5530
5540
|
return n ? this.queue(async () => {
|
|
5531
|
-
let t =
|
|
5541
|
+
let t = Ki(await this.storage.load(e));
|
|
5532
5542
|
!t || t.id !== e || (await this.storage.save({
|
|
5533
5543
|
...t,
|
|
5534
5544
|
name: n
|
|
@@ -5606,7 +5616,7 @@ var ta = class {
|
|
|
5606
5616
|
content: n.content
|
|
5607
5617
|
};
|
|
5608
5618
|
await this.storage.save(r);
|
|
5609
|
-
let i =
|
|
5619
|
+
let i = Qi(r);
|
|
5610
5620
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
5611
5621
|
}
|
|
5612
5622
|
forget() {
|
|
@@ -5627,6 +5637,6 @@ var ta = class {
|
|
|
5627
5637
|
}
|
|
5628
5638
|
};
|
|
5629
5639
|
//#endregion
|
|
5630
|
-
export {
|
|
5640
|
+
export { Hn as C, B as D, R as E, ln as O, Gn as S, V as T, lr as _, qi as a, G as b, Xr as c, Mr as d, Nr as f, cr as g, ur as h, Ji as i, Ir as l, dr as m, Yi as n, Vi as o, fr as p, Xi as r, ji as s, $i as t, Fr as u, or as v, Bn as w, Xn as x, sr as y };
|
|
5631
5641
|
|
|
5632
|
-
//# sourceMappingURL=LayoutSession-
|
|
5642
|
+
//# sourceMappingURL=LayoutSession-DOUhFovg.js.map
|