@tradecanvas/chart 1.60.0 → 1.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart.d.ts +37 -0
- package/dist/Chart.d.ts.map +1 -1
- package/dist/{LayoutSession-CXCLFIvS.js → LayoutSession-D1OOl-zS.js} +323 -254
- package/dist/LayoutSession-D1OOl-zS.js.map +1 -0
- package/dist/LayoutSession-D4mWBj_P.cjs +2 -0
- package/dist/LayoutSession-D4mWBj_P.cjs.map +1 -0
- package/dist/i18n-BISr49ZU.cjs +2 -0
- package/dist/i18n-BISr49ZU.cjs.map +1 -0
- package/dist/{i18n-BaJ3lo-i.js → i18n-CbKY8gH2.js} +33 -1
- package/dist/i18n-CbKY8gH2.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/widget/ChartWidget.d.ts +14 -0
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/WidgetContextMenu.d.ts +9 -1
- package/dist/widget/WidgetContextMenu.d.ts.map +1 -1
- package/dist/widget/WidgetDrawingSettings.d.ts +12 -1
- package/dist/widget/WidgetDrawingSettings.d.ts.map +1 -1
- package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
- package/dist/widget/WidgetSelectionToolbar.d.ts +5 -1
- package/dist/widget/WidgetSelectionToolbar.d.ts.map +1 -1
- package/dist/widget/drawingSettingsTabs.d.ts +23 -2
- package/dist/widget/drawingSettingsTabs.d.ts.map +1 -1
- package/dist/widget/index.cjs +25 -6
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +1646 -1504
- 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 +16 -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 +449 -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/types.d.ts +2 -1
- package/dist/widget/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-C5qP7hiA.cjs +0 -2
- package/dist/LayoutSession-C5qP7hiA.cjs.map +0 -1
- package/dist/LayoutSession-CXCLFIvS.js.map +0 -1
- package/dist/i18n-BaJ3lo-i.js.map +0 -1
- package/dist/i18n-SIiP0kRx.cjs +0 -2
- package/dist/i18n-SIiP0kRx.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 S, readIndicatorPlotStyles as ae, readPaneStyle as oe, resolveChartTheme as se, sessionMinute as C, setLocale as ce, stepDecimals as le, symbolTimeZone as w, tickBarCount as ue, timeframeToMs as T, zonedDateFormatter as de } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as fe, AlertManager as pe, Animator as me, AreaRenderer as he, AxisDragHandler as ge, BarCountdown as _e, BarRenderer as ve, BaselineRenderer as ye, CandlestickRenderer as be, ChartLegend as xe, ChartStateManager as E, CompareRenderer as Se, CompareSymbolIndicator as Ce, CompareSymbolPaneIndicator as we, CorrelationCoefficientIndicator as Te, CorrelationLogIndicator as Ee, CrosshairHandler as De, CrosshairTooltip as Oe, CurrentPriceLine as ke, DEFAULT_SESSION_HOURS as Ae, DataExporter as D, DepthHeatmapRenderer as je, DrawingManager as Me, DrawingRenderer as Ne, EquivolumeRenderer as Pe, EventBus as Fe, GridRenderer as Ie, HLCAreaRenderer as Le, HiLoRenderer as Re, HollowCandleRenderer as ze, IndicatorEngine as Be, InteractionManager as Ve, KagiRenderer as He, KeyboardHandler as Ue, LineRenderer as We, LineWithMarkersRenderer as Ge, MarketProfileRenderer as Ke, MeasureOverlay as qe, PRICE_AXIS_ADD_STRIP as Je, PRICE_SCALE_MARGIN as O, PanHandler as Ye, PaneResizeHandler as Xe, PeriodLevelsRenderer as Ze, PinnedTooltip as Qe, PivotMarkersRenderer as $e, PointAndFigureRenderer as et, PriceAxis as tt, PriceAxisAddButton as nt, PriceLines as rt, RenderEngine as it, RenkoRenderer as at, ReplayManager as ot, ResamplingAdapter as st, ReshapeMemo as ct, SYMBOL_INDICATOR_IDS as k, SYMBOL_ZONE_WAIT_MS as lt, Screenshot as A, SelectionBoxOverlay as ut, SessionBreaks as dt, SessionShading as ft, SignalMarkerManager as pt, SpreadIndicator as mt, StepLineRenderer as ht, StreamManager as gt, SymbolSeriesStore as _t, TimeAxis as vt, TradeZoneManager as yt, TradingManager as bt, TradingRenderer as xt, UndoRedoManager as St, Viewport as Ct, VolumeCandleRenderer as wt, VolumeProfileRenderer as Tt, VolumeRenderer as Et, Watermark as Dt, ZoomHandler as Ot, axisTimes as kt, barTimeStepMs as At, findDominantSwing as jt, gpuContextsLeft as Mt, isPriceLevelAlert as Nt, isRegularSession as Pt, loadWebGL as Ft, mergeSessionHours as It, pointAndFigureColumns as Lt, priceToY as Rt, rangePresetStart as zt, readAlertOptions as Bt, registerBuiltInDrawingTools as Vt, registerBuiltInIndicators as Ht, servesTimeframe as j, sourceParam as M, timeToX as Ut, timestampToBarIndex as N, toHeikinAshi as Wt, toKagi as Gt, toLineBreak as Kt, toRangeBars as qt, toRenko as Jt, whenGpuContextFree as Yt, withResampling as P, xToBarIndex as Xt, xToTime as F, yToPrice as Zt } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
4
|
var Qt = 864e5, $t = 10;
|
|
5
5
|
function en(e, t) {
|
|
6
|
-
let n =
|
|
6
|
+
let n = w(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 = C(e.start), n = C(e.end);
|
|
10
10
|
return t === null || n === null ? [] : [{
|
|
11
11
|
startMinute: t,
|
|
12
12
|
endMinute: n
|
|
@@ -178,22 +178,22 @@ function fn(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 be();
|
|
182
|
+
case "line": return new We();
|
|
183
|
+
case "area": return new he();
|
|
184
|
+
case "bar": return new ve();
|
|
185
|
+
case "hollowCandle": return new ze();
|
|
186
|
+
case "baseline": return new ye();
|
|
187
|
+
case "renko": return new at();
|
|
188
|
+
case "kagi": return new He();
|
|
189
|
+
case "pointAndFigure": return new et();
|
|
190
|
+
case "volumeCandles": return new wt();
|
|
191
|
+
case "equivolume": return new Pe();
|
|
192
|
+
case "hlcArea": return new Le();
|
|
193
|
+
case "stepLine": return new ht();
|
|
194
|
+
case "lineWithMarkers": return new Ge();
|
|
195
|
+
case "hiLo": return new Re();
|
|
196
|
+
default: return new be();
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
function pn(e, t, n = {}, r, i) {
|
|
@@ -787,7 +787,7 @@ var qn = class t {
|
|
|
787
787
|
return i;
|
|
788
788
|
}
|
|
789
789
|
getTheme() {
|
|
790
|
-
return this.effective ??=
|
|
790
|
+
return this.effective ??= se(this.base, this.chartType, this.merged()), this.effective;
|
|
791
791
|
}
|
|
792
792
|
getBaseTheme() {
|
|
793
793
|
return this.base;
|
|
@@ -1481,17 +1481,17 @@ var Nr = [
|
|
|
1481
1481
|
"1d"
|
|
1482
1482
|
];
|
|
1483
1483
|
function Pr(e, t) {
|
|
1484
|
-
let n =
|
|
1484
|
+
let n = T(e);
|
|
1485
1485
|
return n > 0 ? Nr.filter((e) => {
|
|
1486
|
-
let r =
|
|
1486
|
+
let r = T(e);
|
|
1487
1487
|
return r < n && n % r === 0 && t(e);
|
|
1488
1488
|
}) : [];
|
|
1489
1489
|
}
|
|
1490
1490
|
function Fr(e, t, n) {
|
|
1491
1491
|
let r = Pr(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 = T(t);
|
|
1494
|
+
return r.find((e) => i / T(e) <= 60) ?? null;
|
|
1495
1495
|
}
|
|
1496
1496
|
//#endregion
|
|
1497
1497
|
//#region src/Chart.ts
|
|
@@ -1504,15 +1504,19 @@ function zr(e) {
|
|
|
1504
1504
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
1505
1505
|
}
|
|
1506
1506
|
function Br(e, t) {
|
|
1507
|
-
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r :
|
|
1507
|
+
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : w(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 Vr = .08, Hr = a ** -7, Ur = 800, Wr =
|
|
1515
|
-
|
|
1514
|
+
var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 24;
|
|
1515
|
+
function Gr(e) {
|
|
1516
|
+
return e.length > 0 ? { renames: e } : {};
|
|
1517
|
+
}
|
|
1518
|
+
var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set(["verticalLine", "crossLine"]), Xr = class {
|
|
1519
|
+
static version = "1.62.0";
|
|
1516
1520
|
engine;
|
|
1517
1521
|
viewport;
|
|
1518
1522
|
series = new Bn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
|
|
@@ -1531,7 +1535,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1531
1535
|
autoScrollOnNewBar = !0;
|
|
1532
1536
|
displayDataCache = null;
|
|
1533
1537
|
indicatorsOnDrawn = null;
|
|
1534
|
-
reshapeMemo = new
|
|
1538
|
+
reshapeMemo = new ct();
|
|
1535
1539
|
displayDataStep;
|
|
1536
1540
|
indicatorUpdateFrom = null;
|
|
1537
1541
|
resolvedLayoutCache = null;
|
|
@@ -1557,7 +1561,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1557
1561
|
indicatorEdit = null;
|
|
1558
1562
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
1559
1563
|
zoomAreaMode = !1;
|
|
1560
|
-
priceAxisAddButton = new
|
|
1564
|
+
priceAxisAddButton = new nt();
|
|
1561
1565
|
displayTz = null;
|
|
1562
1566
|
timeZoneSetting = null;
|
|
1563
1567
|
symbolInfo = null;
|
|
@@ -1568,7 +1572,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1568
1572
|
studyZoneReleaseQueued = !1;
|
|
1569
1573
|
sessionBreaks;
|
|
1570
1574
|
sessionShading;
|
|
1571
|
-
hostSessionHours = { ...
|
|
1575
|
+
hostSessionHours = { ...Ae };
|
|
1572
1576
|
compareRenderer;
|
|
1573
1577
|
countdownInterval = null;
|
|
1574
1578
|
pausedFor = {
|
|
@@ -1587,7 +1591,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1587
1591
|
signalMarkerManager;
|
|
1588
1592
|
tradeZoneManager;
|
|
1589
1593
|
measureOverlay;
|
|
1590
|
-
selectionBoxOverlay = new
|
|
1594
|
+
selectionBoxOverlay = new ut();
|
|
1591
1595
|
replayManager;
|
|
1592
1596
|
replayBarUnsub = null;
|
|
1593
1597
|
replaySeeking = !1;
|
|
@@ -1614,14 +1618,14 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1614
1618
|
disposed = !1;
|
|
1615
1619
|
chartTypeOptions = {};
|
|
1616
1620
|
mainSeriesVisible = !0;
|
|
1617
|
-
priceLines = new
|
|
1618
|
-
symbolSeries = new
|
|
1621
|
+
priceLines = new rt();
|
|
1622
|
+
symbolSeries = new _t();
|
|
1619
1623
|
extendedHours = !0;
|
|
1620
1624
|
replayRestarting = !1;
|
|
1621
1625
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
1622
1626
|
gridRenderer;
|
|
1623
1627
|
priceAxis;
|
|
1624
|
-
leftPriceAxis = new
|
|
1628
|
+
leftPriceAxis = new tt();
|
|
1625
1629
|
leftScaleRequested = !1;
|
|
1626
1630
|
leftAxisWidth = o;
|
|
1627
1631
|
leftViewport = null;
|
|
@@ -1697,11 +1701,11 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1697
1701
|
oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
|
|
1698
1702
|
prepend: (e) => this.prependBars(e),
|
|
1699
1703
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1700
|
-
}), this.themeManager = new qn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Yn(t), "host", !1), this.layoutManager = new Qn(), this.indicatorEngine = new
|
|
1704
|
+
}), this.themeManager = new qn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Yn(t), "host", !1), this.layoutManager = new Qn(), this.indicatorEngine = new Be(), this.pluginManager = new mr(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Fe(), Ht(this.indicatorEngine), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new mt(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.indicatorEngine.register(new Ee(this.symbolSeries)), this.drawingManager = new Me(), Vt(this.drawingManager), this.drawingRenderer = new Ne(this.drawingManager), this.drawingRenderer.setKeepOut(() => this.legendKeepOut()), this.drawingManager.setRequestRender(() => {
|
|
1701
1705
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1702
1706
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1703
1707
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1704
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1708
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new St();
|
|
1705
1709
|
let i = "";
|
|
1706
1710
|
this.undoRedoManager.setOnChange(() => {
|
|
1707
1711
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1714,23 +1718,23 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1714
1718
|
primary: e[0] ?? null
|
|
1715
1719
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1716
1720
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1717
|
-
}), 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
|
|
1721
|
+
}), 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 bt({
|
|
1718
1722
|
enabled: this.features.trading,
|
|
1719
1723
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1720
|
-
}), this.tradingRenderer = new
|
|
1724
|
+
}), this.tradingRenderer = new xt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1721
1725
|
this.eventBus.emit(e, t);
|
|
1722
|
-
}), this.engine = new
|
|
1726
|
+
}), this.engine = new it(e, t.maxPixelRatio);
|
|
1723
1727
|
let a = this.engine.dprManager.getContainerSize();
|
|
1724
|
-
if (this.viewport = new
|
|
1728
|
+
if (this.viewport = new Ct(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
|
|
1725
1729
|
freePan: t.freePan ?? !0,
|
|
1726
1730
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1727
1731
|
}), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1728
1732
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1729
1733
|
let t = this.viewport.isAtEnd();
|
|
1730
1734
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
|
|
1731
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new
|
|
1735
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Ie(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new tt(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new vt(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new De(), 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) => {
|
|
1732
1736
|
if (e !== null && t) {
|
|
1733
|
-
let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o =
|
|
1737
|
+
let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o = kt(n), s = i ? o[e]?.time ?? i.time : void 0;
|
|
1734
1738
|
this.chartLegend.setHoverBar(i ?? null, e > 0 ? n[e - 1] ?? null : null), this.features.legend && this.engine.requestRender(r.Hover);
|
|
1735
1739
|
let c = this.viewport.getState(), l = t.y >= c.chartRect.y && t.y <= c.chartRect.y + c.chartRect.height;
|
|
1736
1740
|
if (i && l && this.features.crosshairTooltip) {
|
|
@@ -1758,14 +1762,14 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1758
1762
|
let e = this.crosshairHandler.getSyncedSlot();
|
|
1759
1763
|
e !== null && this.showSyncedBar(e);
|
|
1760
1764
|
}
|
|
1761
|
-
}), this.chartLegend = new
|
|
1765
|
+
}), this.chartLegend = new xe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
|
|
1762
1766
|
this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), this.engine.requestRender();
|
|
1763
|
-
}), this.watermark = new
|
|
1767
|
+
}), this.watermark = new Dt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Et(), this.volumeProfile = new Tt(), this.marketProfile = new Ke(), this.depthHeatmap = new je(), this.periodLevels = new Ze(), this.pivotMarkers = new $e(), this.barCountdown = new _e(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new dt(), this.sessionShading = new ft(), this.compareRenderer = new Se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1764
1768
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1765
1769
|
color: t.sessionBreaks.color,
|
|
1766
1770
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1767
1771
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1768
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
1772
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new Oe(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Qe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = S(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 Ue({
|
|
1769
1773
|
scrollBars: (e) => {
|
|
1770
1774
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1771
1775
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1809,7 +1813,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1809
1813
|
}
|
|
1810
1814
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1811
1815
|
}
|
|
1812
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
1816
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ke(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new pe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(Nt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
|
|
1813
1817
|
this.eventBus.emit("alertTriggered", J(e)), this.eventBus.emit("dataUpdate", {
|
|
1814
1818
|
kind: "alert",
|
|
1815
1819
|
alert: "triggered",
|
|
@@ -1825,7 +1829,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1825
1829
|
this.eventBus.emit("alertExpired", J(e));
|
|
1826
1830
|
}), this.alertManager.on("updated", (e) => {
|
|
1827
1831
|
this.eventBus.emit("alertUpdate", J(e));
|
|
1828
|
-
}), this.signalMarkerManager = new
|
|
1832
|
+
}), this.signalMarkerManager = new pt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
|
|
1829
1833
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1830
1834
|
id: e.id,
|
|
1831
1835
|
source: e.source,
|
|
@@ -1833,14 +1837,14 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1833
1837
|
});
|
|
1834
1838
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1835
1839
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1836
|
-
}), this.tradeZoneManager = new
|
|
1840
|
+
}), this.tradeZoneManager = new yt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
|
|
1837
1841
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1838
1842
|
id: e.id,
|
|
1839
1843
|
direction: e.direction
|
|
1840
1844
|
});
|
|
1841
1845
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1842
1846
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1843
|
-
}), this.replayManager = new
|
|
1847
|
+
}), this.replayManager = new ot(), this.replayManager.on("complete", () => {
|
|
1844
1848
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1845
1849
|
t && this.eventBus.emit("replayComplete", {
|
|
1846
1850
|
barIndex: e,
|
|
@@ -1848,9 +1852,9 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1848
1852
|
});
|
|
1849
1853
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1850
1854
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1851
|
-
}), this.measureOverlay = new
|
|
1855
|
+
}), this.measureOverlay = new qe(), this.interactionManager = new Ve(e), this.features.panning) {
|
|
1852
1856
|
let e = new sr();
|
|
1853
|
-
this.interactionManager.setPanHandler(new
|
|
1857
|
+
this.interactionManager.setPanHandler(new Ye((t, n) => {
|
|
1854
1858
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1855
1859
|
}, () => e.reset()));
|
|
1856
1860
|
}
|
|
@@ -1862,10 +1866,10 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1862
1866
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1863
1867
|
}
|
|
1864
1868
|
})), this.features.zooming) {
|
|
1865
|
-
this.interactionManager.setZoomHandler(new
|
|
1869
|
+
this.interactionManager.setZoomHandler(new Ot((e, t) => {
|
|
1866
1870
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1867
1871
|
}));
|
|
1868
|
-
let e = new
|
|
1872
|
+
let e = new ge((e) => {
|
|
1869
1873
|
this.holdPriceScale(), this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1870
1874
|
}, (e) => {
|
|
1871
1875
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -1878,7 +1882,12 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1878
1882
|
if (this.features.crosshair && this.interactionManager.setCrosshairHandler(this.crosshairHandler), this.features.drawings && (this.interactionManager.setDrawingManager(this.drawingManager, () => ({
|
|
1879
1883
|
...this.viewport.getState(),
|
|
1880
1884
|
data: this.getDisplayData()
|
|
1881
|
-
})), this.
|
|
1885
|
+
})), this.drawingManager.setPanes({
|
|
1886
|
+
paneAt: (e) => this.drawingPaneAt(e),
|
|
1887
|
+
viewportOf: (e) => this.drawingPaneViewport(e),
|
|
1888
|
+
hasPane: (e) => this.layoutManager.getPanels().some((t) => t.id === e),
|
|
1889
|
+
valuesAt: (e, t) => this.indicatorEngine.getPaneValuesAt(e, t)
|
|
1890
|
+
}), this.interactionManager.setDrawingDoubleClick((e) => this.eventBus.emit("drawingDoubleClick", { id: e })), this.interactionManager.setDrawingContextMenu((e, t) => {
|
|
1882
1891
|
this.drawingManager.select(e) && this.eventBus.emit("drawingContextMenu", {
|
|
1883
1892
|
id: e,
|
|
1884
1893
|
x: t.x,
|
|
@@ -1895,10 +1904,10 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1895
1904
|
...this.viewport.getState(),
|
|
1896
1905
|
data: this.getDisplayData()
|
|
1897
1906
|
})), this.features.alerts) {
|
|
1898
|
-
let e = new
|
|
1907
|
+
let e = new fe(this.alertManager, () => this.viewport.getState());
|
|
1899
1908
|
this.interactionManager.setAlertDragHandler(e);
|
|
1900
1909
|
}
|
|
1901
|
-
let o = new
|
|
1910
|
+
let o = new Xe();
|
|
1902
1911
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
1903
1912
|
let t = this.getDisplayData();
|
|
1904
1913
|
if (t.length === 0) return;
|
|
@@ -1952,20 +1961,22 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1952
1961
|
this.measureOverlay.end();
|
|
1953
1962
|
}
|
|
1954
1963
|
});
|
|
1955
|
-
let s = (e) => {
|
|
1956
|
-
let t = this.viewport.getState().chartRect;
|
|
1964
|
+
let s, c = (e) => {
|
|
1965
|
+
let t = s ? this.drawingPaneViewport(s) : null, n = t ? t.chartRect : this.viewport.getState().chartRect;
|
|
1957
1966
|
return {
|
|
1958
|
-
x: Math.max(
|
|
1959
|
-
y: Math.max(
|
|
1967
|
+
x: Math.max(n.x, Math.min(n.x + n.width, e.x)),
|
|
1968
|
+
y: Math.max(n.y, Math.min(n.y + n.height, e.y))
|
|
1960
1969
|
};
|
|
1961
1970
|
};
|
|
1962
1971
|
this.interactionManager.setBoxSelectHandlers({
|
|
1963
|
-
begin: (e) =>
|
|
1964
|
-
|
|
1972
|
+
begin: (e) => {
|
|
1973
|
+
s = this.zoomAreaMode ? void 0 : this.drawingPaneAt(e), this.selectionBoxOverlay.begin(c(e));
|
|
1974
|
+
},
|
|
1975
|
+
move: (e) => this.selectionBoxOverlay.update(c(e)),
|
|
1965
1976
|
end: () => {
|
|
1966
1977
|
let e = this.selectionBoxOverlay.end();
|
|
1967
1978
|
if (e && this.zoomAreaMode) {
|
|
1968
|
-
if (e.x1 - e.x0 <
|
|
1979
|
+
if (e.x1 - e.x0 < qr) return;
|
|
1969
1980
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1970
1981
|
return;
|
|
1971
1982
|
}
|
|
@@ -1974,10 +1985,10 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
1974
1985
|
...this.viewport.getState(),
|
|
1975
1986
|
data: this.getDisplayData()
|
|
1976
1987
|
};
|
|
1977
|
-
e.isClick ? this.drawingManager.toggleSelectionAt({
|
|
1988
|
+
s !== null && (e.isClick ? this.drawingManager.toggleSelectionAt({
|
|
1978
1989
|
x: e.x1,
|
|
1979
1990
|
y: e.y1
|
|
1980
|
-
}, t) : this.drawingManager.selectInRect(e, t), this.engine.requestRender(r.Overlay);
|
|
1991
|
+
}, t) : this.drawingManager.selectInRect(e, t, s), this.engine.requestRender(r.Overlay));
|
|
1981
1992
|
},
|
|
1982
1993
|
cancel: () => {
|
|
1983
1994
|
this.selectionBoxOverlay.cancel(), this.setZoomAreaMode(!1);
|
|
@@ -2049,13 +2060,13 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2049
2060
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
2050
2061
|
if (t.width <= 0) return;
|
|
2051
2062
|
let { from: n, to: r } = e;
|
|
2052
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
2063
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Kr, r - n));
|
|
2053
2064
|
}));
|
|
2054
2065
|
}
|
|
2055
2066
|
useStreamHistory(e, t, n = !0) {
|
|
2056
2067
|
if (this.hostHistoryLoader) return;
|
|
2057
2068
|
let r = P(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
|
|
2058
|
-
if (!i || a === null ||
|
|
2069
|
+
if (!i || a === null || ue(a) !== null) {
|
|
2059
2070
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
2060
2071
|
return;
|
|
2061
2072
|
}
|
|
@@ -2152,11 +2163,11 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2152
2163
|
setChartTypeOptions(e) {
|
|
2153
2164
|
this.chartTypeOptions = {
|
|
2154
2165
|
...this.chartTypeOptions,
|
|
2155
|
-
...
|
|
2166
|
+
...S(e)
|
|
2156
2167
|
}, this.displayDataCache = null, this.updateViewportAndRender(!0), this.fitFewColumns(), this.a11y?.refresh(!0), this.markStateChanged();
|
|
2157
2168
|
}
|
|
2158
2169
|
getChartTypeOptions() {
|
|
2159
|
-
return
|
|
2170
|
+
return S(this.chartTypeOptions);
|
|
2160
2171
|
}
|
|
2161
2172
|
setExtendedHours(e) {
|
|
2162
2173
|
e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
|
|
@@ -2176,7 +2187,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2176
2187
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
2177
2188
|
}
|
|
2178
2189
|
setShapes(e) {
|
|
2179
|
-
let t =
|
|
2190
|
+
let t = ni(e);
|
|
2180
2191
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
2181
2192
|
...this.themeManager.getTheme().shape,
|
|
2182
2193
|
...t
|
|
@@ -2188,7 +2199,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2188
2199
|
setFont(e) {
|
|
2189
2200
|
if (e === null) this.themeManager.setFont(null);
|
|
2190
2201
|
else {
|
|
2191
|
-
let t =
|
|
2202
|
+
let t = ti(e);
|
|
2192
2203
|
if (Object.keys(t).length === 0) return;
|
|
2193
2204
|
this.themeManager.setFont(t);
|
|
2194
2205
|
}
|
|
@@ -2239,7 +2250,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2239
2250
|
setSymbolSeries(e, t) {
|
|
2240
2251
|
e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
|
|
2241
2252
|
let n = this.indicatorBars(), r = !1;
|
|
2242
|
-
for (let t of this.indicatorEngine.getActiveIndicators()) !
|
|
2253
|
+
for (let t of this.indicatorEngine.getActiveIndicators()) !k.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
|
|
2243
2254
|
r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
|
|
2244
2255
|
}
|
|
2245
2256
|
forgetUnreadSymbols() {
|
|
@@ -2253,13 +2264,13 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2253
2264
|
let e = /* @__PURE__ */ new Set();
|
|
2254
2265
|
for (let t of this.indicatorEngine.getActiveIndicators()) {
|
|
2255
2266
|
let n = t.params.symbol;
|
|
2256
|
-
|
|
2267
|
+
k.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
|
|
2257
2268
|
}
|
|
2258
2269
|
return [...e];
|
|
2259
2270
|
}
|
|
2260
2271
|
requestMissingSymbols(e) {
|
|
2261
2272
|
this.forgetUnreadSymbols();
|
|
2262
|
-
let t = this.indicatorEngine.getIndicatorConfig(e), n = t &&
|
|
2273
|
+
let t = this.indicatorEngine.getIndicatorConfig(e), n = t && k.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
|
|
2263
2274
|
!n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
|
|
2264
2275
|
}
|
|
2265
2276
|
updateIndicator(e, t) {
|
|
@@ -2369,7 +2380,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2369
2380
|
let t = this.layoutManager.getPanels().find((t) => t.id === e), n = this.indicatorEngine.getPaneMembers(e), r = t ? n.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null : null;
|
|
2370
2381
|
this.indicatorEngine.removeIndicator(e);
|
|
2371
2382
|
let i = this.paneStyles.get(e);
|
|
2372
|
-
this.paneStyles.delete(e), r ? (this.indicatorEngine.setPane(r, null), this.
|
|
2383
|
+
this.paneStyles.delete(e), r ? (this.indicatorEngine.setPane(r, null), this.renamePane(e, r), i && this.paneStyles.set(r, i)) : this.layoutManager.removePanel(e);
|
|
2373
2384
|
for (let e of n) e !== r && this.indicatorEngine.setPane(e, r), this.eventBus.emit("indicatorChange", {
|
|
2374
2385
|
instanceId: e,
|
|
2375
2386
|
change: "pane"
|
|
@@ -2384,7 +2395,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2384
2395
|
this.indicatorEngine.setStyleDefaults(e, null);
|
|
2385
2396
|
return;
|
|
2386
2397
|
}
|
|
2387
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2398
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
|
|
2388
2399
|
this.indicatorEngine.setStyleDefaults(e, {
|
|
2389
2400
|
...r,
|
|
2390
2401
|
...i ? { plots: i } : {}
|
|
@@ -2392,7 +2403,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2392
2403
|
}
|
|
2393
2404
|
setPaneStyle(e, t) {
|
|
2394
2405
|
let n = this.paneOf(e);
|
|
2395
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ?
|
|
2406
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? oe(t) : null));
|
|
2396
2407
|
}
|
|
2397
2408
|
setPaneStyleNow(e, t) {
|
|
2398
2409
|
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());
|
|
@@ -2411,7 +2422,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2411
2422
|
return this.pluginManager;
|
|
2412
2423
|
}
|
|
2413
2424
|
static indicators() {
|
|
2414
|
-
let e = new
|
|
2425
|
+
let e = new Be();
|
|
2415
2426
|
return Ht(e), e.getAvailableIndicators();
|
|
2416
2427
|
}
|
|
2417
2428
|
setPanelPosition(e, t) {
|
|
@@ -2452,7 +2463,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2452
2463
|
if (a) {
|
|
2453
2464
|
let t = this.indicatorEngine.getPaneMembers(e), r = new Set(this.indicatorEngine.getDependents(e)), i = t.filter((e) => !r.has(e)), a = i.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null, s = this.paneStyles.get(e);
|
|
2454
2465
|
if (this.paneStyles.delete(e), a) {
|
|
2455
|
-
this.indicatorEngine.setPane(a, null), this.
|
|
2466
|
+
this.indicatorEngine.setPane(a, null), this.renamePane(e, a), s && this.paneStyles.set(a, s);
|
|
2456
2467
|
for (let e of i) e !== a && this.indicatorEngine.setPane(e, a);
|
|
2457
2468
|
} else {
|
|
2458
2469
|
this.layoutManager.removePanel(e);
|
|
@@ -2576,7 +2587,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2576
2587
|
roundPrice(e) {
|
|
2577
2588
|
if (!Number.isFinite(e)) return e;
|
|
2578
2589
|
let t = this.stepAt(e);
|
|
2579
|
-
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(
|
|
2590
|
+
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(le(t)));
|
|
2580
2591
|
let { min: n, max: r } = this.viewport.getState().priceRange;
|
|
2581
2592
|
return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
|
|
2582
2593
|
}
|
|
@@ -2654,7 +2665,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2654
2665
|
this.drawingManager.setDrawings(e), this.dropOrphanDrawingAlerts(), this.announceStateChange();
|
|
2655
2666
|
}
|
|
2656
2667
|
addDrawing(e) {
|
|
2657
|
-
if (!this.features.drawings) return null;
|
|
2668
|
+
if (!this.features.drawings || e.paneId !== void 0 && !this.takesDrawing(e.paneId, e.type)) return null;
|
|
2658
2669
|
let t = this.drawingManager.addDrawing(e);
|
|
2659
2670
|
return this.markStateChanged(), t;
|
|
2660
2671
|
}
|
|
@@ -2672,6 +2683,18 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2672
2683
|
removeDrawings(e) {
|
|
2673
2684
|
return this.drawingManager.removeDrawings(e);
|
|
2674
2685
|
}
|
|
2686
|
+
takeBackDrawing(e) {
|
|
2687
|
+
this.features.drawings && (this.drawingManager.takeBack(e), this.markStateChanged());
|
|
2688
|
+
}
|
|
2689
|
+
removeAll(e = "all") {
|
|
2690
|
+
return this.undoRedoManager.group(() => {
|
|
2691
|
+
let t = e === "indicators" ? 0 : this.removeDrawings(this.getDrawings().map((e) => e.id)), n = e === "drawings" ? [] : this.getActiveIndicators().map((e) => e.instanceId);
|
|
2692
|
+
return n.length > 0 && this.removeIndicators(n), {
|
|
2693
|
+
drawings: t,
|
|
2694
|
+
indicators: n.length
|
|
2695
|
+
};
|
|
2696
|
+
});
|
|
2697
|
+
}
|
|
2675
2698
|
getDrawingToolDescriptor(e) {
|
|
2676
2699
|
let t = this.drawingManager.getDescriptor(e);
|
|
2677
2700
|
return t ? structuredClone(t) : null;
|
|
@@ -2793,7 +2816,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2793
2816
|
}
|
|
2794
2817
|
applyPriceAxisAdd() {
|
|
2795
2818
|
let e = this.features.priceAxisAddButton && this.features.crosshair;
|
|
2796
|
-
this.priceAxisAddButton.setEnabled(e), this.tradingManager.setTagInset(e ?
|
|
2819
|
+
this.priceAxisAddButton.setEnabled(e), this.tradingManager.setTagInset(e ? Je : 0);
|
|
2797
2820
|
}
|
|
2798
2821
|
setPriceAxisAddButton(e) {
|
|
2799
2822
|
this.features.priceAxisAddButton = e, this.applyPriceAxisAdd(), this.engine.requestRender(r.Overlay);
|
|
@@ -2884,11 +2907,11 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2884
2907
|
}
|
|
2885
2908
|
getExportText(e = "csv", t = {}) {
|
|
2886
2909
|
let { bars: n, columns: r } = this.getExportData(t);
|
|
2887
|
-
return e === "json" ?
|
|
2910
|
+
return e === "json" ? D.toJSON(n, r) : D.toCSV(n, r);
|
|
2888
2911
|
}
|
|
2889
2912
|
download(e, t, n) {
|
|
2890
2913
|
let r = this.getExportText(e, n);
|
|
2891
|
-
e === "json" ?
|
|
2914
|
+
e === "json" ? D.download(r, t ?? "chart-data.json", "application/json") : D.download(r, t ?? "chart-data.csv", "text/csv");
|
|
2892
2915
|
}
|
|
2893
2916
|
setAutoSave(e, t = 5e3) {
|
|
2894
2917
|
this.autoSaveScheduler.enable(e, t);
|
|
@@ -2950,7 +2973,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
2950
2973
|
this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
|
|
2951
2974
|
}
|
|
2952
2975
|
updateIndicatorStyleNow(e, t) {
|
|
2953
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2976
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
|
|
2954
2977
|
this.indicatorEngine.updateIndicatorStyle(e, {
|
|
2955
2978
|
...r,
|
|
2956
2979
|
...i ? { plots: i } : {}
|
|
@@ -3071,7 +3094,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3071
3094
|
}
|
|
3072
3095
|
async connect(e) {
|
|
3073
3096
|
if (!j(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
3074
|
-
this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new
|
|
3097
|
+
this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new gt(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (t) => {
|
|
3075
3098
|
let n = this.streamSeriesKey(e.adapter);
|
|
3076
3099
|
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);
|
|
3077
3100
|
}), this.streamManager.on("barClose", (e) => {
|
|
@@ -3127,18 +3150,18 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3127
3150
|
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
|
|
3128
3151
|
let t = this.streamManager;
|
|
3129
3152
|
if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
|
|
3130
|
-
let n =
|
|
3153
|
+
let n = T(e.timeframe);
|
|
3131
3154
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
3132
3155
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
3133
3156
|
}, 1e3);
|
|
3134
3157
|
}
|
|
3135
3158
|
streamSeriesKey(e) {
|
|
3136
|
-
let t = P(e), n = this.streamTimeframe, r = t instanceof
|
|
3159
|
+
let t = P(e), n = this.streamTimeframe, r = t instanceof st && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
|
|
3137
3160
|
return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
|
|
3138
3161
|
}
|
|
3139
3162
|
setStreamTarget(e, t) {
|
|
3140
3163
|
let n = this.announcedSymbol;
|
|
3141
|
-
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream =
|
|
3164
|
+
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = ue(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
3142
3165
|
symbol: e,
|
|
3143
3166
|
previous: n
|
|
3144
3167
|
})), this.useTimeframe(t);
|
|
@@ -3157,7 +3180,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3157
3180
|
if (!this.streamManager) return;
|
|
3158
3181
|
let n = this.streamAdapter;
|
|
3159
3182
|
if (n && !j(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
3160
|
-
this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(
|
|
3183
|
+
this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(T(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
|
|
3161
3184
|
}
|
|
3162
3185
|
isIndicatorAllowed(e) {
|
|
3163
3186
|
let t = this.features.indicatorIds;
|
|
@@ -3513,7 +3536,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3513
3536
|
}
|
|
3514
3537
|
let t = this.crosshairSeries(), n = e >= 0 && e < t.length ? t[e] : void 0, r = n && e > 0 ? t[e - 1] : void 0;
|
|
3515
3538
|
this.crosshairHandler.getPosition() || this.chartLegend.setHoverBar(n ?? null, r ?? null);
|
|
3516
|
-
let i = n ?
|
|
3539
|
+
let i = n ? kt(t)[e]?.time ?? n.time : void 0;
|
|
3517
3540
|
this.eventBus.emit("crosshairSync", {
|
|
3518
3541
|
barIndex: e,
|
|
3519
3542
|
...n ? { bar: n } : {},
|
|
@@ -3601,7 +3624,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3601
3624
|
return this.displayTz;
|
|
3602
3625
|
}
|
|
3603
3626
|
getExchangeTimeZone() {
|
|
3604
|
-
return [
|
|
3627
|
+
return [w(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && y(e)) ?? null;
|
|
3605
3628
|
}
|
|
3606
3629
|
setTimezone(e) {
|
|
3607
3630
|
this.setTimeZone(e);
|
|
@@ -3628,7 +3651,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3628
3651
|
this.indicatorEngine.setExchangeTimeZone(e, t.length > 0 ? t : void 0) && t.length > 0 && this.announceIndicatorUpdate(0);
|
|
3629
3652
|
}
|
|
3630
3653
|
holdStudyZone() {
|
|
3631
|
-
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(),
|
|
3654
|
+
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), lt);
|
|
3632
3655
|
}
|
|
3633
3656
|
endStudyZoneWait() {
|
|
3634
3657
|
this.studyZoneReleaseQueued = !1, this.studyZoneTimer !== null && (clearTimeout(this.studyZoneTimer), this.studyZoneTimer = null);
|
|
@@ -3643,7 +3666,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3643
3666
|
}
|
|
3644
3667
|
spokenBarTime(e) {
|
|
3645
3668
|
let t = this.getDisplayData(), n = e * u(t), r = this.numberLocale || "en-US";
|
|
3646
|
-
return d(t) === !0 ?
|
|
3669
|
+
return d(t) === !0 ? de(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : de(r, {
|
|
3647
3670
|
dateStyle: "medium",
|
|
3648
3671
|
timeStyle: "short"
|
|
3649
3672
|
}, this.displayTz)(n);
|
|
@@ -3656,18 +3679,18 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3656
3679
|
this.studyZoneHeld = !1, this.endStudyZoneWait(), this.useSymbolInfo(e);
|
|
3657
3680
|
}
|
|
3658
3681
|
useSymbolInfo(e) {
|
|
3659
|
-
let t = e && this.symbolInfo?.symbol === e.symbol ?
|
|
3682
|
+
let t = e && this.symbolInfo?.symbol === e.symbol ? w(this.symbolInfo) : void 0;
|
|
3660
3683
|
this.symbolInfo = e ? Br({
|
|
3661
3684
|
...e,
|
|
3662
3685
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
3663
3686
|
}, 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);
|
|
3664
3687
|
let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
|
|
3665
|
-
let t =
|
|
3688
|
+
let t = C(e.start), n = C(e.end);
|
|
3666
3689
|
return t === null || n === null ? [] : [{
|
|
3667
3690
|
startMinute: t,
|
|
3668
3691
|
endMinute: n
|
|
3669
3692
|
}];
|
|
3670
|
-
}), i =
|
|
3693
|
+
}), i = w(this.symbolInfo);
|
|
3671
3694
|
this.sessionShading.replaceConfig(n.length > 0 && i && y(i) ? {
|
|
3672
3695
|
timeZone: i,
|
|
3673
3696
|
windows: n,
|
|
@@ -3686,7 +3709,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3686
3709
|
...r,
|
|
3687
3710
|
...e,
|
|
3688
3711
|
symbol: e.symbol || r?.symbol || t
|
|
3689
|
-
},
|
|
3712
|
+
}, w(r));
|
|
3690
3713
|
r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
|
|
3691
3714
|
}
|
|
3692
3715
|
resolveStreamSymbol(e, t) {
|
|
@@ -3769,7 +3792,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3769
3792
|
this.engine.getGpu() && this.engine.renderNow();
|
|
3770
3793
|
}
|
|
3771
3794
|
screenshot(e) {
|
|
3772
|
-
this.features.screenshot && (this.freshFrame(),
|
|
3795
|
+
this.features.screenshot && (this.freshFrame(), A.download(this.container, e, this.themeManager.getTheme().background));
|
|
3773
3796
|
}
|
|
3774
3797
|
async copyScreenshot() {
|
|
3775
3798
|
if (!this.features.screenshot) return !1;
|
|
@@ -3777,7 +3800,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3777
3800
|
if (!t?.write || !e) return !1;
|
|
3778
3801
|
try {
|
|
3779
3802
|
this.freshFrame();
|
|
3780
|
-
let n =
|
|
3803
|
+
let n = A.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
|
|
3781
3804
|
if (!e) throw Error("No chart image to copy");
|
|
3782
3805
|
return e;
|
|
3783
3806
|
});
|
|
@@ -3795,10 +3818,10 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3795
3818
|
}
|
|
3796
3819
|
}
|
|
3797
3820
|
screenshotDataURL() {
|
|
3798
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3821
|
+
return this.features.screenshot ? (this.freshFrame(), A.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
3799
3822
|
}
|
|
3800
3823
|
async screenshotBlob() {
|
|
3801
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3824
|
+
return this.features.screenshot ? (this.freshFrame(), A.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
3802
3825
|
}
|
|
3803
3826
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
3804
3827
|
if (!this.features.alerts) return null;
|
|
@@ -3841,6 +3864,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3841
3864
|
return this.features.alerts && this.drawingLevelsNow(e) !== null;
|
|
3842
3865
|
}
|
|
3843
3866
|
drawingLevelsNow(e) {
|
|
3867
|
+
if (this.drawingManager.getDrawings().find((t) => t.id === e)?.paneId !== void 0) return null;
|
|
3844
3868
|
let t = this.replaySession ? this.series.liveBars() : this.getDisplayData();
|
|
3845
3869
|
if (t.length === 0) return null;
|
|
3846
3870
|
let n = {
|
|
@@ -3925,7 +3949,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3925
3949
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
3926
3950
|
if (!this.replaySession) {
|
|
3927
3951
|
if (this.series.length() === 0) return;
|
|
3928
|
-
this.series.beginReplay(), this.replaySession =
|
|
3952
|
+
this.series.beginReplay(), this.replaySession = ui(this.currentSymbol);
|
|
3929
3953
|
}
|
|
3930
3954
|
let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
|
|
3931
3955
|
c.animate = c.animate === !0;
|
|
@@ -3936,13 +3960,13 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3936
3960
|
let m = r ? this.replayStepsOver(n, p, !0) : null;
|
|
3937
3961
|
this.options.autoScale = !0, this.buildReplay(p, m, f);
|
|
3938
3962
|
let h = this.replayStepsSeries;
|
|
3939
|
-
h && c.startIndex !== void 0 && (c.startIndex =
|
|
3963
|
+
h && c.startIndex !== void 0 && (c.startIndex = yi(h, p, c.startIndex));
|
|
3940
3964
|
let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
|
|
3941
3965
|
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);
|
|
3942
3966
|
}
|
|
3943
3967
|
buildReplay(e, t, n) {
|
|
3944
3968
|
let r = this.replaySession?.animate === !0, i = r ? null : t;
|
|
3945
|
-
this.replayPieces = r && t ?
|
|
3969
|
+
this.replayPieces = r && t ? Si(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
|
|
3946
3970
|
let a = this.replayRestarting;
|
|
3947
3971
|
this.replayRestarting = !0;
|
|
3948
3972
|
try {
|
|
@@ -3956,7 +3980,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3956
3980
|
let n = t, a = e[t];
|
|
3957
3981
|
if (i) {
|
|
3958
3982
|
let r = i[t];
|
|
3959
|
-
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ?
|
|
3983
|
+
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;
|
|
3960
3984
|
}
|
|
3961
3985
|
let u = this.replayForming;
|
|
3962
3986
|
this.replayForming = null, s = t;
|
|
@@ -3980,7 +4004,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3980
4004
|
});
|
|
3981
4005
|
}), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
|
|
3982
4006
|
if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
|
|
3983
|
-
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i =
|
|
4007
|
+
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = Ci() ? Mr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = jr(r, i);
|
|
3984
4008
|
a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
|
|
3985
4009
|
index: t,
|
|
3986
4010
|
path: r
|
|
@@ -3990,7 +4014,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
3990
4014
|
drawFormingBar(e, t, n, r) {
|
|
3991
4015
|
this.currentPriceLine.setPrice(e.close, t);
|
|
3992
4016
|
let i = this.series.bars();
|
|
3993
|
-
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !
|
|
4017
|
+
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !oi.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
|
|
3994
4018
|
this.scheduleRender();
|
|
3995
4019
|
return;
|
|
3996
4020
|
}
|
|
@@ -4005,15 +4029,15 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4005
4029
|
if (!n) return;
|
|
4006
4030
|
n.evictBefore(e[t].time);
|
|
4007
4031
|
let r = this.replayManager.getStepMs();
|
|
4008
|
-
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(
|
|
4032
|
+
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(ai / r) : 1);
|
|
4009
4033
|
}
|
|
4010
4034
|
useReplayLoader(e, t) {
|
|
4011
4035
|
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Fr(e.step, r, (e) => j(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
|
|
4012
4036
|
if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
|
|
4013
|
-
let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l =
|
|
4037
|
+
let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = T(r), u = new yr({
|
|
4014
4038
|
source: s ? (e, t) => s.call(o, c, i, e, t) : null,
|
|
4015
4039
|
step: i,
|
|
4016
|
-
ratio: Math.max(1, Math.round(l /
|
|
4040
|
+
ratio: Math.max(1, Math.round(l / T(i))),
|
|
4017
4041
|
barMs: l,
|
|
4018
4042
|
keep: (e) => this.series.inHoursShown(e),
|
|
4019
4043
|
report: (e) => this.eventBus.emit("replayStepsLoad", e)
|
|
@@ -4036,8 +4060,8 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4036
4060
|
if (o.time > s) {
|
|
4037
4061
|
let a = Y(e, s);
|
|
4038
4062
|
e[a]?.time === s && i.fedFraction < 1 && c.push(...q(this.replayPathOf(e, a), i.fedFraction, 1));
|
|
4039
|
-
let o = e.slice(X(e, s), t), l = Math.ceil(o.length /
|
|
4040
|
-
for (let e = 0; e < o.length; e += l) c.push(...
|
|
4063
|
+
let o = e.slice(X(e, s), t), l = Math.ceil(o.length / gi);
|
|
4064
|
+
for (let e = 0; e < o.length; e += l) c.push(..._i(o.slice(e, e + l)));
|
|
4041
4065
|
c.push(...q(n, -1, r));
|
|
4042
4066
|
} else c.push(...q(n, i.fedFraction, r));
|
|
4043
4067
|
i.fedTime = o.time, i.fedFraction = r;
|
|
@@ -4056,7 +4080,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4056
4080
|
if (n.length === 0) return;
|
|
4057
4081
|
let r = t.windowTime === null ? 0 : Math.min(Y(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
|
|
4058
4082
|
this.useReplayLoader(t, !1);
|
|
4059
|
-
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 :
|
|
4083
|
+
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : pi(o ?? i, t.until);
|
|
4060
4084
|
if (s < 0 && this.canPageBackForReplay(t)) {
|
|
4061
4085
|
this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
|
|
4062
4086
|
return;
|
|
@@ -4064,7 +4088,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4064
4088
|
let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
|
|
4065
4089
|
l || (t.held = null), t.symbol = this.currentSymbol;
|
|
4066
4090
|
let d = this.replayManager.remainingMs();
|
|
4067
|
-
this.clearBarHolders(), t.animate &&
|
|
4091
|
+
this.clearBarHolders(), t.animate && fi(t, this.replayCoarse, i);
|
|
4068
4092
|
let f = this.replayRestarting;
|
|
4069
4093
|
this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
|
|
4070
4094
|
try {
|
|
@@ -4087,14 +4111,14 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4087
4111
|
}
|
|
4088
4112
|
replayStepsOver(e, t, n = !1) {
|
|
4089
4113
|
if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
|
|
4090
|
-
let r =
|
|
4091
|
-
return r && (n ||
|
|
4114
|
+
let r = vi(this.series.inHoursShown(e.steps), t);
|
|
4115
|
+
return r && (n || hi(r, t)) ? r : null;
|
|
4092
4116
|
}
|
|
4093
4117
|
canPageBackForReplay(e) {
|
|
4094
|
-
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) <
|
|
4118
|
+
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < si;
|
|
4095
4119
|
}
|
|
4096
4120
|
async pageBackForReplay(e) {
|
|
4097
|
-
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack =
|
|
4121
|
+
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = si, this.rebaseReplay("older"));
|
|
4098
4122
|
}
|
|
4099
4123
|
holdReplay() {
|
|
4100
4124
|
let e = this.replaySession;
|
|
@@ -4127,7 +4151,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4127
4151
|
this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
|
|
4128
4152
|
}
|
|
4129
4153
|
replaySeekToTime(e) {
|
|
4130
|
-
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0,
|
|
4154
|
+
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, pi(this.replayStepsSeries ?? this.replayCoarse, e)));
|
|
4131
4155
|
}
|
|
4132
4156
|
feedReplayPrice(e, t) {
|
|
4133
4157
|
let n = this.executionAdapter;
|
|
@@ -4149,8 +4173,8 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4149
4173
|
if (i.time <= n.fedTime) return;
|
|
4150
4174
|
let a = e.slice(X(e, n.fedTime), t + 1);
|
|
4151
4175
|
n.fedTime = i.time;
|
|
4152
|
-
let o = Math.ceil(a.length /
|
|
4153
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
4176
|
+
let o = Math.ceil(a.length / gi);
|
|
4177
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of _i(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
4154
4178
|
this.tradingManager.setCurrentPrice(i.close);
|
|
4155
4179
|
}
|
|
4156
4180
|
getReplayBarIndex() {
|
|
@@ -4161,7 +4185,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4161
4185
|
}
|
|
4162
4186
|
replaySeekToBar(e) {
|
|
4163
4187
|
let t = this.replayStepsSeries;
|
|
4164
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
4188
|
+
this.replaySeek(t && this.replayCoarse ? yi(t, this.replayCoarse, e) : e);
|
|
4165
4189
|
}
|
|
4166
4190
|
replayPause() {
|
|
4167
4191
|
this.setHeldState("paused") || this.replayManager.pause();
|
|
@@ -4192,15 +4216,17 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4192
4216
|
getDrawingRect(e) {
|
|
4193
4217
|
let t = this.drawingManager.getDrawings().find((t) => t.id === e);
|
|
4194
4218
|
if (!t || !this.drawingManager.isShown(e) || t.anchors.length === 0) return null;
|
|
4195
|
-
let n = {
|
|
4219
|
+
let n = t.paneId === void 0 ? {
|
|
4196
4220
|
...this.viewport.getState(),
|
|
4197
4221
|
data: this.getDisplayData()
|
|
4198
|
-
}
|
|
4222
|
+
} : this.drawingPaneViewport(t.paneId);
|
|
4223
|
+
if (!n) return null;
|
|
4224
|
+
let r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
4199
4225
|
for (let e of t.anchors) {
|
|
4200
4226
|
let t = Ut(e.time, n), r = Rt(e.price, n);
|
|
4201
4227
|
i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
|
|
4202
4228
|
}
|
|
4203
|
-
return
|
|
4229
|
+
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 ? {
|
|
4204
4230
|
x: i,
|
|
4205
4231
|
y: o,
|
|
4206
4232
|
width: a - i,
|
|
@@ -4236,8 +4262,8 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4236
4262
|
};
|
|
4237
4263
|
}
|
|
4238
4264
|
captureSnapshot() {
|
|
4239
|
-
return
|
|
4240
|
-
getDrawings: () => this.getDrawings(),
|
|
4265
|
+
return E.capture({
|
|
4266
|
+
getDrawings: () => [...this.getDrawings().filter((e) => e.paneId === void 0 || this.layoutManager.getPanels().some((t) => t.id === e.paneId)), ...this.keptPaneDrawings],
|
|
4241
4267
|
getTheme: () => this.themeManager.getBaseTheme(),
|
|
4242
4268
|
getAlerts: () => this.getAlerts(),
|
|
4243
4269
|
getIndicators: () => this.getIndicatorSetup(),
|
|
@@ -4249,14 +4275,14 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4249
4275
|
});
|
|
4250
4276
|
}
|
|
4251
4277
|
restoreIndicators(e, t) {
|
|
4252
|
-
let n =
|
|
4278
|
+
let n = Zr(e), r = /* @__PURE__ */ new Map();
|
|
4253
4279
|
this.unrestoredIndicators = [];
|
|
4254
4280
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
4255
4281
|
if (t) {
|
|
4256
4282
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
4257
4283
|
for (let n of t) {
|
|
4258
4284
|
let t = e.get(n.instanceId);
|
|
4259
|
-
t &&
|
|
4285
|
+
t && Qr(n, t) && o.add(n.instanceId);
|
|
4260
4286
|
}
|
|
4261
4287
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
4262
4288
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -4318,7 +4344,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4318
4344
|
let s = t.levels ?? null;
|
|
4319
4345
|
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
|
|
4320
4346
|
let c = t.intervals ?? null;
|
|
4321
|
-
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ?
|
|
4347
|
+
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? oe(t.paneStyle) : null);
|
|
4322
4348
|
}
|
|
4323
4349
|
restorePanes(e) {
|
|
4324
4350
|
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, {
|
|
@@ -4421,45 +4447,88 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4421
4447
|
}
|
|
4422
4448
|
recordIndicators(e, t) {
|
|
4423
4449
|
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
4424
|
-
let n = this.getIndicatorSetup(), r =
|
|
4425
|
-
|
|
4426
|
-
let a
|
|
4450
|
+
let n = this.getIndicatorSetup(), r = [], i = this.paneRenames;
|
|
4451
|
+
this.paneRenames = r;
|
|
4452
|
+
let a;
|
|
4453
|
+
try {
|
|
4454
|
+
a = this.withoutIndicatorHistory(t);
|
|
4455
|
+
} finally {
|
|
4456
|
+
this.paneRenames = i;
|
|
4457
|
+
}
|
|
4458
|
+
let o = this.getIndicatorSetup();
|
|
4459
|
+
if (JSON.stringify(n) === JSON.stringify(o)) return a;
|
|
4460
|
+
let s = performance.now(), c = this.undoRedoManager.last(), l = e !== void 0 && c?.type === "indicators" && c.indicators?.subject === e && s - (c.indicators.at ?? 0) < Ur && JSON.stringify(c.indicators.after) === JSON.stringify(n), u = {
|
|
4427
4461
|
type: "indicators",
|
|
4428
4462
|
before: null,
|
|
4429
4463
|
after: null
|
|
4430
4464
|
};
|
|
4431
|
-
return
|
|
4432
|
-
...
|
|
4465
|
+
return l && c?.indicators ? JSON.stringify(c.indicators.before) === JSON.stringify(o) ? this.undoRedoManager.dropLast() : this.undoRedoManager.replaceLast({
|
|
4466
|
+
...u,
|
|
4433
4467
|
indicators: {
|
|
4434
|
-
...
|
|
4435
|
-
after:
|
|
4436
|
-
at:
|
|
4468
|
+
...c.indicators,
|
|
4469
|
+
after: o,
|
|
4470
|
+
at: s,
|
|
4471
|
+
...Gr([...c.indicators.renames ?? [], ...r])
|
|
4437
4472
|
}
|
|
4438
4473
|
}) : this.undoRedoManager.push({
|
|
4439
|
-
...
|
|
4474
|
+
...u,
|
|
4440
4475
|
indicators: {
|
|
4441
4476
|
before: n,
|
|
4442
|
-
after:
|
|
4477
|
+
after: o,
|
|
4443
4478
|
subject: e,
|
|
4444
|
-
at:
|
|
4479
|
+
at: s,
|
|
4480
|
+
...Gr(r)
|
|
4445
4481
|
}
|
|
4446
|
-
}),
|
|
4482
|
+
}), a;
|
|
4447
4483
|
}
|
|
4448
4484
|
applyIndicatorStep(e, t) {
|
|
4449
4485
|
let n = e.indicators;
|
|
4450
|
-
|
|
4486
|
+
if (!n) return;
|
|
4487
|
+
this.withoutIndicatorHistory(() => this.restoreIndicators(t === "undo" ? n.before : n.after, !0));
|
|
4488
|
+
let r = n.renames ?? [], i = t === "undo" ? [...r].reverse().map(([e, t]) => [t, e]) : r;
|
|
4489
|
+
for (let [e, t] of i) this.drawingManager.renamePanes(new Map([[e, t]]));
|
|
4490
|
+
this.markStateChanged();
|
|
4491
|
+
}
|
|
4492
|
+
keptPaneDrawings = [];
|
|
4493
|
+
takesDrawing(e, t) {
|
|
4494
|
+
return this.layoutManager.getPanels().some((t) => t.id === e) ? !this.drawingManager.getDescriptor(t)?.priceOnly : !1;
|
|
4495
|
+
}
|
|
4496
|
+
paneRenames = null;
|
|
4497
|
+
renamePane(e, t) {
|
|
4498
|
+
this.layoutManager.renamePanel(e, t), this.drawingManager.renamePanes(new Map([[e, t]])), this.paneRenames?.push([e, t]);
|
|
4499
|
+
}
|
|
4500
|
+
drawingPaneAt(e) {
|
|
4501
|
+
let t = (t) => e.x >= t.x && e.x <= t.x + t.width && e.y >= t.y && e.y <= t.y + t.height;
|
|
4502
|
+
if (!t(this.viewport.getState().chartRect)) {
|
|
4503
|
+
for (let e of this.layoutManager.getPanels()) {
|
|
4504
|
+
let n = this.drawingPaneViewport(e.id);
|
|
4505
|
+
if (n && t(n.chartRect)) return e.id;
|
|
4506
|
+
}
|
|
4507
|
+
return null;
|
|
4508
|
+
}
|
|
4509
|
+
}
|
|
4510
|
+
drawingPaneViewport(e) {
|
|
4511
|
+
let t = this.layoutManager.getPanels().find((t) => t.id === e);
|
|
4512
|
+
if (!t || t.position !== "top" && t.position !== "bottom" || this.layoutManager.isPanelShownCollapsed(e)) return null;
|
|
4513
|
+
let n = this.buildPanelRenderInfos().find((t) => t.instanceId === e);
|
|
4514
|
+
return !n || n.viewport.chartRect.height < Wr ? null : {
|
|
4515
|
+
...n.viewport,
|
|
4516
|
+
data: this.getDisplayData()
|
|
4517
|
+
};
|
|
4451
4518
|
}
|
|
4452
4519
|
saveState(e) {
|
|
4453
4520
|
if (!this.features.saveLoad) return null;
|
|
4454
|
-
let t = this.captureSnapshot(), n =
|
|
4455
|
-
return e &&
|
|
4521
|
+
let t = this.captureSnapshot(), n = E.serialize(t);
|
|
4522
|
+
return e && E.saveToStorage(e, t), n;
|
|
4456
4523
|
}
|
|
4457
4524
|
loadState(e) {
|
|
4458
4525
|
if (!this.features.saveLoad) return;
|
|
4459
|
-
let t =
|
|
4526
|
+
let t = E.deserialize(e);
|
|
4460
4527
|
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");
|
|
4461
4528
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
4462
|
-
|
|
4529
|
+
this.drawingManager.renamePanes(n);
|
|
4530
|
+
let r = new Set(this.unrestoredIndicators.map((e) => e.instanceId)), i = this.drawingManager.getDrawings(), a = i.filter((e) => e.paneId === void 0 || this.takesDrawing(e.paneId, e.type));
|
|
4531
|
+
if (this.keptPaneDrawings = i.filter((e) => e.paneId !== void 0 && r.has(e.paneId)), a.length !== i.length && this.drawingManager.setDrawings(a), this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
|
|
4463
4532
|
this.alertManager.clearAlerts();
|
|
4464
4533
|
for (let e of t.alerts) {
|
|
4465
4534
|
if (e.triggered && !e.repeating) continue;
|
|
@@ -4487,19 +4556,19 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4487
4556
|
}
|
|
4488
4557
|
loadStateFromStorage(e) {
|
|
4489
4558
|
if (!this.features.saveLoad) return !1;
|
|
4490
|
-
let t =
|
|
4491
|
-
return t ? (this.loadState(
|
|
4559
|
+
let t = E.loadFromStorage(e);
|
|
4560
|
+
return t ? (this.loadState(E.serialize(t)), !0) : !1;
|
|
4492
4561
|
}
|
|
4493
4562
|
downloadState(e) {
|
|
4494
|
-
this.features.saveLoad &&
|
|
4563
|
+
this.features.saveLoad && E.downloadFile(this.captureSnapshot(), e);
|
|
4495
4564
|
}
|
|
4496
4565
|
async loadStateFromFile() {
|
|
4497
4566
|
if (!this.features.saveLoad) return;
|
|
4498
|
-
let e = await
|
|
4499
|
-
this.loadState(
|
|
4567
|
+
let e = await E.loadFromFile();
|
|
4568
|
+
this.loadState(E.serialize(e));
|
|
4500
4569
|
}
|
|
4501
4570
|
setLocale(e) {
|
|
4502
|
-
|
|
4571
|
+
ce(e), this.engine.requestRender();
|
|
4503
4572
|
}
|
|
4504
4573
|
setNumberLocale(e) {
|
|
4505
4574
|
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();
|
|
@@ -4550,7 +4619,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4550
4619
|
}
|
|
4551
4620
|
createChartRenderer(e) {
|
|
4552
4621
|
let t = jn(e, (e) => this.pluginManager.getChartType(e));
|
|
4553
|
-
return t instanceof
|
|
4622
|
+
return t instanceof Re && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
4554
4623
|
}
|
|
4555
4624
|
crosshairSeries() {
|
|
4556
4625
|
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
@@ -4566,7 +4635,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4566
4635
|
let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
|
|
4567
4636
|
if (n !== "pointAndFigure" || r(n)) return Mn(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
|
|
4568
4637
|
let { columns: i, boxSize: a } = hn(e, this.chartTypeOptions, this.reshapeMemo);
|
|
4569
|
-
return this.chartRenderer instanceof
|
|
4638
|
+
return this.chartRenderer instanceof et && this.chartRenderer.setBoxSize(a), i;
|
|
4570
4639
|
}
|
|
4571
4640
|
recalcIndicatorsFrom(e, t) {
|
|
4572
4641
|
if (!this.isTimeAligned()) return this.recalcIndicators(e);
|
|
@@ -4578,7 +4647,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4578
4647
|
}
|
|
4579
4648
|
exportBars() {
|
|
4580
4649
|
if (this.isTimeAligned()) return this.series.bars();
|
|
4581
|
-
let e = this.getDisplayData(), t =
|
|
4650
|
+
let e = this.getDisplayData(), t = kt(e);
|
|
4582
4651
|
return e.map((e, n) => ({
|
|
4583
4652
|
...e,
|
|
4584
4653
|
time: t[n]?.time ?? e.time
|
|
@@ -4637,12 +4706,12 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4637
4706
|
}
|
|
4638
4707
|
fitPriceScale(e, t) {
|
|
4639
4708
|
if (e.length === 0) return;
|
|
4640
|
-
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i =
|
|
4709
|
+
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() + Hr : O;
|
|
4641
4710
|
this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
|
|
4642
4711
|
top: a,
|
|
4643
|
-
bottom:
|
|
4712
|
+
bottom: O
|
|
4644
4713
|
} : {
|
|
4645
|
-
top:
|
|
4714
|
+
top: O,
|
|
4646
4715
|
bottom: a
|
|
4647
4716
|
}), this.viewport.fitToPrices(i.min, i.max);
|
|
4648
4717
|
}
|
|
@@ -4694,9 +4763,9 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4694
4763
|
}
|
|
4695
4764
|
measureText(e, t) {
|
|
4696
4765
|
let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
|
|
4697
|
-
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () =>
|
|
4766
|
+
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => $r(n, e, t));
|
|
4698
4767
|
let i = n ?? this.detachedMeasureContext();
|
|
4699
|
-
return i ?
|
|
4768
|
+
return i ? $r(i, e, t) : e.length * 7;
|
|
4700
4769
|
}
|
|
4701
4770
|
detachedMeasureContext() {
|
|
4702
4771
|
return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
|
|
@@ -4843,7 +4912,7 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontal
|
|
|
4843
4912
|
};
|
|
4844
4913
|
}
|
|
4845
4914
|
};
|
|
4846
|
-
function
|
|
4915
|
+
function Zr(e) {
|
|
4847
4916
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
4848
4917
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
4849
4918
|
i.add(e.instanceId);
|
|
@@ -4857,19 +4926,19 @@ function Yr(e) {
|
|
|
4857
4926
|
for (let t of e) a(t);
|
|
4858
4927
|
return n;
|
|
4859
4928
|
}
|
|
4860
|
-
function
|
|
4929
|
+
function Qr(e, t) {
|
|
4861
4930
|
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);
|
|
4862
4931
|
}
|
|
4863
|
-
function
|
|
4932
|
+
function $r(e, t, n) {
|
|
4864
4933
|
let r = e.font;
|
|
4865
4934
|
e.font = n;
|
|
4866
4935
|
let i = e.measureText(t).width;
|
|
4867
4936
|
return e.font = r, i;
|
|
4868
4937
|
}
|
|
4869
|
-
var
|
|
4870
|
-
function
|
|
4938
|
+
var ei = 300;
|
|
4939
|
+
function ti(e) {
|
|
4871
4940
|
let t = {}, n = e.family;
|
|
4872
|
-
typeof n == "string" && n.trim() !== "" && n.length <=
|
|
4941
|
+
typeof n == "string" && n.trim() !== "" && n.length <= ei && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
|
|
4873
4942
|
for (let n of [
|
|
4874
4943
|
"sizeSmall",
|
|
4875
4944
|
"sizeMedium",
|
|
@@ -4880,15 +4949,15 @@ function $r(e) {
|
|
|
4880
4949
|
}
|
|
4881
4950
|
return t;
|
|
4882
4951
|
}
|
|
4883
|
-
function
|
|
4952
|
+
function ni(e) {
|
|
4884
4953
|
let t = e.tagRadius;
|
|
4885
4954
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
4886
4955
|
}
|
|
4887
|
-
function
|
|
4956
|
+
function ri(e, t, n) {
|
|
4888
4957
|
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
4889
4958
|
return !1;
|
|
4890
4959
|
}
|
|
4891
|
-
function
|
|
4960
|
+
function ii(e, t) {
|
|
4892
4961
|
return e ? t ? {
|
|
4893
4962
|
min: Math.min(e.min, t.min),
|
|
4894
4963
|
max: Math.max(e.max, t.max)
|
|
@@ -4909,14 +4978,14 @@ function J(e) {
|
|
|
4909
4978
|
bars: e.bars
|
|
4910
4979
|
};
|
|
4911
4980
|
}
|
|
4912
|
-
var
|
|
4981
|
+
var ai = 8e3, oi = new Set([
|
|
4913
4982
|
"candlestick",
|
|
4914
4983
|
"line",
|
|
4915
4984
|
"area",
|
|
4916
4985
|
"bar",
|
|
4917
4986
|
"hollowCandle"
|
|
4918
|
-
]),
|
|
4919
|
-
function
|
|
4987
|
+
]), si = 10, ci = 50, li = .001;
|
|
4988
|
+
function ui(e) {
|
|
4920
4989
|
return {
|
|
4921
4990
|
price: null,
|
|
4922
4991
|
fedTime: null,
|
|
@@ -4931,41 +5000,41 @@ function ci(e) {
|
|
|
4931
5000
|
held: null
|
|
4932
5001
|
};
|
|
4933
5002
|
}
|
|
4934
|
-
function
|
|
5003
|
+
function di(e, t) {
|
|
4935
5004
|
let n = e[t + 1];
|
|
4936
5005
|
return n ? n.time - e[t].time : Z(e);
|
|
4937
5006
|
}
|
|
4938
|
-
function
|
|
5007
|
+
function fi(e, t, n) {
|
|
4939
5008
|
let r = e.fedTime;
|
|
4940
5009
|
if (r === null || !t || t.length === 0 || n.length === 0) return;
|
|
4941
|
-
let i =
|
|
5010
|
+
let i = di(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
|
|
4942
5011
|
if (s > a) return;
|
|
4943
|
-
let c =
|
|
5012
|
+
let c = di(n, o);
|
|
4944
5013
|
if (a === s && o > 0) {
|
|
4945
5014
|
e.fedTime = n[o - 1].time, e.fedFraction = 1;
|
|
4946
5015
|
return;
|
|
4947
5016
|
}
|
|
4948
5017
|
e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
|
|
4949
5018
|
}
|
|
4950
|
-
function
|
|
5019
|
+
function pi(e, t) {
|
|
4951
5020
|
let n = X(e, t), r = e.length - 1;
|
|
4952
5021
|
return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
|
|
4953
5022
|
}
|
|
4954
|
-
function
|
|
5023
|
+
function mi(e) {
|
|
4955
5024
|
let t = Infinity;
|
|
4956
5025
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
|
|
4957
5026
|
return t;
|
|
4958
5027
|
}
|
|
4959
|
-
function
|
|
4960
|
-
if (!(
|
|
4961
|
-
let n = Math.max(0, e.length -
|
|
5028
|
+
function hi(e, t) {
|
|
5029
|
+
if (!(mi(e) < mi(t))) return !1;
|
|
5030
|
+
let n = Math.max(0, e.length - ci);
|
|
4962
5031
|
for (let r = n; r < e.length; r++) {
|
|
4963
|
-
let n = t[Q(t, e[r].time)], i = (n.high - n.low) *
|
|
5032
|
+
let n = t[Q(t, e[r].time)], i = (n.high - n.low) * li + 2 ** -52;
|
|
4964
5033
|
if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
|
|
4965
5034
|
}
|
|
4966
5035
|
return !0;
|
|
4967
5036
|
}
|
|
4968
|
-
var
|
|
5037
|
+
var gi = 500;
|
|
4969
5038
|
function Y(e, t) {
|
|
4970
5039
|
let n = 0, r = e.length;
|
|
4971
5040
|
for (; n < r;) {
|
|
@@ -4982,7 +5051,7 @@ function X(e, t) {
|
|
|
4982
5051
|
}
|
|
4983
5052
|
return n;
|
|
4984
5053
|
}
|
|
4985
|
-
function
|
|
5054
|
+
function _i(e) {
|
|
4986
5055
|
let t = 0, n = 0;
|
|
4987
5056
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
4988
5057
|
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];
|
|
@@ -4993,7 +5062,7 @@ function Z(e) {
|
|
|
4993
5062
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
4994
5063
|
return t > 0 ? t : Infinity;
|
|
4995
5064
|
}
|
|
4996
|
-
function
|
|
5065
|
+
function vi(e, t) {
|
|
4997
5066
|
if (t.length === 0) return null;
|
|
4998
5067
|
let n = t[t.length - 1].time + Z(t), r = e.filter((e) => zn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
4999
5068
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
@@ -5011,26 +5080,26 @@ function Q(e, t) {
|
|
|
5011
5080
|
}
|
|
5012
5081
|
return n;
|
|
5013
5082
|
}
|
|
5014
|
-
function
|
|
5083
|
+
function yi(e, t, n) {
|
|
5015
5084
|
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;
|
|
5016
5085
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
5017
5086
|
return Math.max(0, a);
|
|
5018
5087
|
}
|
|
5019
|
-
function
|
|
5088
|
+
function bi(e, t, n) {
|
|
5020
5089
|
let r = n;
|
|
5021
5090
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
5022
5091
|
let i = {
|
|
5023
5092
|
...t[r],
|
|
5024
5093
|
time: e.time
|
|
5025
5094
|
};
|
|
5026
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
5095
|
+
for (let e = r + 1; e <= n; e++) i = wi(i, t[e]);
|
|
5027
5096
|
return i;
|
|
5028
5097
|
}
|
|
5029
|
-
function
|
|
5098
|
+
function xi(e, t, n, r) {
|
|
5030
5099
|
let i = e[n + 1], a = t[r + 1];
|
|
5031
5100
|
return i !== void 0 && a !== void 0 && i.time >= a.time;
|
|
5032
5101
|
}
|
|
5033
|
-
function
|
|
5102
|
+
function Si(e, t) {
|
|
5034
5103
|
let n = /* @__PURE__ */ new Map();
|
|
5035
5104
|
for (let r of e) {
|
|
5036
5105
|
let e = t[Q(t, r.time)].time, i = n.get(e);
|
|
@@ -5038,10 +5107,10 @@ function bi(e, t) {
|
|
|
5038
5107
|
}
|
|
5039
5108
|
return n;
|
|
5040
5109
|
}
|
|
5041
|
-
function
|
|
5110
|
+
function Ci() {
|
|
5042
5111
|
return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5043
5112
|
}
|
|
5044
|
-
function
|
|
5113
|
+
function wi(e, t) {
|
|
5045
5114
|
return {
|
|
5046
5115
|
time: e.time,
|
|
5047
5116
|
open: e.open,
|
|
@@ -5053,26 +5122,26 @@ function Si(e, t) {
|
|
|
5053
5122
|
}
|
|
5054
5123
|
//#endregion
|
|
5055
5124
|
//#region src/io/parseOHLCV.ts
|
|
5056
|
-
var
|
|
5125
|
+
var Ti = [
|
|
5057
5126
|
"time",
|
|
5058
5127
|
"timestamp",
|
|
5059
5128
|
"date",
|
|
5060
5129
|
"datetime",
|
|
5061
5130
|
"t"
|
|
5062
|
-
],
|
|
5131
|
+
], Ei = ["open", "o"], Di = ["high", "h"], Oi = ["low", "l"], ki = ["close", "c"], Ai = [
|
|
5063
5132
|
"volume",
|
|
5064
5133
|
"vol",
|
|
5065
5134
|
"v"
|
|
5066
5135
|
];
|
|
5067
|
-
function
|
|
5136
|
+
function ji(e) {
|
|
5068
5137
|
let t = e.trim();
|
|
5069
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
5138
|
+
return t ? t[0] === "[" || t[0] === "{" ? Mi(t) : Ni(t) : {
|
|
5070
5139
|
data: [],
|
|
5071
5140
|
rowCount: 0,
|
|
5072
5141
|
skipped: 0
|
|
5073
5142
|
};
|
|
5074
5143
|
}
|
|
5075
|
-
function
|
|
5144
|
+
function Mi(e) {
|
|
5076
5145
|
let t;
|
|
5077
5146
|
try {
|
|
5078
5147
|
t = JSON.parse(e);
|
|
@@ -5082,19 +5151,19 @@ function Ai(e) {
|
|
|
5082
5151
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
5083
5152
|
let n = [], r = 0;
|
|
5084
5153
|
for (let e of t) {
|
|
5085
|
-
let t = Array.isArray(e) ?
|
|
5154
|
+
let t = Array.isArray(e) ? Ri(e) : Li(e);
|
|
5086
5155
|
t ? n.push(t) : r++;
|
|
5087
5156
|
}
|
|
5088
|
-
return
|
|
5157
|
+
return Bi(n, t.length, r);
|
|
5089
5158
|
}
|
|
5090
|
-
function
|
|
5159
|
+
function Ni(e) {
|
|
5091
5160
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
5092
5161
|
if (t.length === 0) return {
|
|
5093
5162
|
data: [],
|
|
5094
5163
|
rowCount: 0,
|
|
5095
5164
|
skipped: 0
|
|
5096
5165
|
};
|
|
5097
|
-
let n =
|
|
5166
|
+
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) : {
|
|
5098
5167
|
time: 0,
|
|
5099
5168
|
open: 1,
|
|
5100
5169
|
high: 2,
|
|
@@ -5105,7 +5174,7 @@ function ji(e) {
|
|
|
5105
5174
|
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");
|
|
5106
5175
|
let o = [], s = 0;
|
|
5107
5176
|
for (let e = +!!i; e < t.length; e++) {
|
|
5108
|
-
let r =
|
|
5177
|
+
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;
|
|
5109
5178
|
if (i === null || ![
|
|
5110
5179
|
c,
|
|
5111
5180
|
l,
|
|
@@ -5124,9 +5193,9 @@ function ji(e) {
|
|
|
5124
5193
|
volume: Number.isFinite(f) ? f : 0
|
|
5125
5194
|
});
|
|
5126
5195
|
}
|
|
5127
|
-
return
|
|
5196
|
+
return Bi(o, t.length - +!!i, s);
|
|
5128
5197
|
}
|
|
5129
|
-
function
|
|
5198
|
+
function Pi(e) {
|
|
5130
5199
|
let t = {
|
|
5131
5200
|
",": 0,
|
|
5132
5201
|
";": 0,
|
|
@@ -5138,7 +5207,7 @@ function Mi(e) {
|
|
|
5138
5207
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
5139
5208
|
return n;
|
|
5140
5209
|
}
|
|
5141
|
-
function
|
|
5210
|
+
function Fi(e, t) {
|
|
5142
5211
|
let n = [], r = "", i = !1;
|
|
5143
5212
|
for (let a = 0; a < e.length; a++) {
|
|
5144
5213
|
let o = e[a];
|
|
@@ -5146,25 +5215,25 @@ function Ni(e, t) {
|
|
|
5146
5215
|
}
|
|
5147
5216
|
return n.push(r), n;
|
|
5148
5217
|
}
|
|
5149
|
-
function
|
|
5218
|
+
function Ii(e) {
|
|
5150
5219
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
5151
5220
|
return {
|
|
5152
|
-
time: t(
|
|
5153
|
-
open: t(
|
|
5154
|
-
high: t(
|
|
5155
|
-
low: t(
|
|
5156
|
-
close: t(
|
|
5157
|
-
volume: t(
|
|
5221
|
+
time: t(Ti),
|
|
5222
|
+
open: t(Ei),
|
|
5223
|
+
high: t(Di),
|
|
5224
|
+
low: t(Oi),
|
|
5225
|
+
close: t(ki),
|
|
5226
|
+
volume: t(Ai)
|
|
5158
5227
|
};
|
|
5159
5228
|
}
|
|
5160
|
-
function
|
|
5229
|
+
function Li(e) {
|
|
5161
5230
|
let t = (t) => {
|
|
5162
5231
|
for (let n of t) {
|
|
5163
5232
|
if (e[n] !== void 0) return e[n];
|
|
5164
5233
|
let t = n.toUpperCase();
|
|
5165
5234
|
if (e[t] !== void 0) return e[t];
|
|
5166
5235
|
}
|
|
5167
|
-
}, n =
|
|
5236
|
+
}, 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);
|
|
5168
5237
|
return n === null || ![
|
|
5169
5238
|
r,
|
|
5170
5239
|
i,
|
|
@@ -5179,9 +5248,9 @@ function Fi(e) {
|
|
|
5179
5248
|
volume: Number.isFinite(s) ? s : 0
|
|
5180
5249
|
};
|
|
5181
5250
|
}
|
|
5182
|
-
function
|
|
5251
|
+
function Ri(e) {
|
|
5183
5252
|
if (e.length < 5) return null;
|
|
5184
|
-
let t =
|
|
5253
|
+
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;
|
|
5185
5254
|
return t === null || ![
|
|
5186
5255
|
n,
|
|
5187
5256
|
r,
|
|
@@ -5199,7 +5268,7 @@ function Ii(e) {
|
|
|
5199
5268
|
function $(e) {
|
|
5200
5269
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
5201
5270
|
}
|
|
5202
|
-
function
|
|
5271
|
+
function zi(e) {
|
|
5203
5272
|
let t = e.trim();
|
|
5204
5273
|
if (!t) return null;
|
|
5205
5274
|
let n = Number(t);
|
|
@@ -5207,7 +5276,7 @@ function Li(e) {
|
|
|
5207
5276
|
let r = Date.parse(t);
|
|
5208
5277
|
return Number.isFinite(r) ? r : null;
|
|
5209
5278
|
}
|
|
5210
|
-
function
|
|
5279
|
+
function Bi(e, t, n) {
|
|
5211
5280
|
e.sort((e, t) => e.time - t.time);
|
|
5212
5281
|
let r = [];
|
|
5213
5282
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -5219,7 +5288,7 @@ function Ri(e, t, n) {
|
|
|
5219
5288
|
}
|
|
5220
5289
|
//#endregion
|
|
5221
5290
|
//#region src/io/DragDropImporter.ts
|
|
5222
|
-
var
|
|
5291
|
+
var Vi = class {
|
|
5223
5292
|
host;
|
|
5224
5293
|
overlay = null;
|
|
5225
5294
|
callbacks;
|
|
@@ -5240,19 +5309,19 @@ var zi = class {
|
|
|
5240
5309
|
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();
|
|
5241
5310
|
}
|
|
5242
5311
|
onDragEnter(e) {
|
|
5243
|
-
|
|
5312
|
+
Hi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
5244
5313
|
}
|
|
5245
5314
|
onDragOver(e) {
|
|
5246
|
-
|
|
5315
|
+
Hi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
5247
5316
|
}
|
|
5248
5317
|
onDragLeave(e) {
|
|
5249
|
-
|
|
5318
|
+
Hi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
5250
5319
|
}
|
|
5251
5320
|
async onDrop(e) {
|
|
5252
5321
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
5253
5322
|
let t = e.dataTransfer?.files?.[0];
|
|
5254
5323
|
if (t) try {
|
|
5255
|
-
let e =
|
|
5324
|
+
let e = ji(await t.text());
|
|
5256
5325
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
5257
5326
|
this.callbacks.onData(e.data, e, t);
|
|
5258
5327
|
} catch (e) {
|
|
@@ -5283,12 +5352,12 @@ var zi = class {
|
|
|
5283
5352
|
this.overlay?.remove(), this.overlay = null;
|
|
5284
5353
|
}
|
|
5285
5354
|
};
|
|
5286
|
-
function
|
|
5355
|
+
function Hi(e) {
|
|
5287
5356
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
5288
5357
|
}
|
|
5289
5358
|
//#endregion
|
|
5290
5359
|
//#region src/state/layoutStorage.ts
|
|
5291
|
-
function
|
|
5360
|
+
function Ui(e) {
|
|
5292
5361
|
let t = {
|
|
5293
5362
|
id: e.id,
|
|
5294
5363
|
name: e.name,
|
|
@@ -5296,11 +5365,11 @@ function Vi(e) {
|
|
|
5296
5365
|
};
|
|
5297
5366
|
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;
|
|
5298
5367
|
}
|
|
5299
|
-
var
|
|
5300
|
-
function
|
|
5368
|
+
var Wi = (e, t) => t.updatedAt - e.updatedAt;
|
|
5369
|
+
function Gi(e) {
|
|
5301
5370
|
if (typeof e != "object" || !e) return null;
|
|
5302
5371
|
let t = e;
|
|
5303
|
-
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null :
|
|
5372
|
+
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Ui({
|
|
5304
5373
|
id: t.id,
|
|
5305
5374
|
name: t.name,
|
|
5306
5375
|
updatedAt: t.updatedAt,
|
|
@@ -5309,17 +5378,17 @@ function Ui(e) {
|
|
|
5309
5378
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
5310
5379
|
});
|
|
5311
5380
|
}
|
|
5312
|
-
function
|
|
5313
|
-
let t =
|
|
5381
|
+
function Ki(e) {
|
|
5382
|
+
let t = Gi(e), n = t ? e.content : void 0;
|
|
5314
5383
|
return t && typeof n == "string" ? {
|
|
5315
5384
|
...t,
|
|
5316
5385
|
content: n
|
|
5317
5386
|
} : null;
|
|
5318
5387
|
}
|
|
5319
|
-
function
|
|
5388
|
+
function qi(e = []) {
|
|
5320
5389
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
5321
5390
|
return {
|
|
5322
|
-
list: () => [...t.values()].map(
|
|
5391
|
+
list: () => [...t.values()].map(Ui).sort(Wi),
|
|
5323
5392
|
load: (e) => {
|
|
5324
5393
|
let n = t.get(e);
|
|
5325
5394
|
return n ? { ...n } : null;
|
|
@@ -5332,7 +5401,7 @@ function Gi(e = []) {
|
|
|
5332
5401
|
}
|
|
5333
5402
|
};
|
|
5334
5403
|
}
|
|
5335
|
-
function
|
|
5404
|
+
function Ji(e = "tcw:layouts:") {
|
|
5336
5405
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
5337
5406
|
let e;
|
|
5338
5407
|
try {
|
|
@@ -5340,10 +5409,10 @@ function Ki(e = "tcw:layouts:") {
|
|
|
5340
5409
|
} catch {
|
|
5341
5410
|
return [];
|
|
5342
5411
|
}
|
|
5343
|
-
return Array.isArray(e) ? e.map(
|
|
5412
|
+
return Array.isArray(e) ? e.map(Gi).filter((e) => e !== null) : [];
|
|
5344
5413
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
5345
5414
|
return {
|
|
5346
|
-
list: () => r().sort(
|
|
5415
|
+
list: () => r().sort(Wi),
|
|
5347
5416
|
load: (e) => {
|
|
5348
5417
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
5349
5418
|
return t && i !== null ? {
|
|
@@ -5352,7 +5421,7 @@ function Ki(e = "tcw:layouts:") {
|
|
|
5352
5421
|
} : null;
|
|
5353
5422
|
},
|
|
5354
5423
|
save: (e) => {
|
|
5355
|
-
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id),
|
|
5424
|
+
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Ui(e)]);
|
|
5356
5425
|
},
|
|
5357
5426
|
remove: (e) => {
|
|
5358
5427
|
i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
|
|
@@ -5361,14 +5430,14 @@ function Ki(e = "tcw:layouts:") {
|
|
|
5361
5430
|
}
|
|
5362
5431
|
//#endregion
|
|
5363
5432
|
//#region src/state/LayoutSession.ts
|
|
5364
|
-
var
|
|
5365
|
-
function
|
|
5433
|
+
var Yi = 80;
|
|
5434
|
+
function Xi(e) {
|
|
5366
5435
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
5367
5436
|
}
|
|
5368
|
-
function
|
|
5437
|
+
function Zi() {
|
|
5369
5438
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
5370
5439
|
}
|
|
5371
|
-
function
|
|
5440
|
+
function Qi(e) {
|
|
5372
5441
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
5373
5442
|
return {
|
|
5374
5443
|
id: t,
|
|
@@ -5379,7 +5448,7 @@ function Xi(e) {
|
|
|
5379
5448
|
...o === void 0 ? {} : { kind: o }
|
|
5380
5449
|
};
|
|
5381
5450
|
}
|
|
5382
|
-
var
|
|
5451
|
+
var $i = class {
|
|
5383
5452
|
currentLayout = null;
|
|
5384
5453
|
savedContent = null;
|
|
5385
5454
|
dirty = !1;
|
|
@@ -5395,7 +5464,7 @@ var Zi = class {
|
|
|
5395
5464
|
now;
|
|
5396
5465
|
newId;
|
|
5397
5466
|
constructor(e, t, n = {}) {
|
|
5398
|
-
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 ??
|
|
5467
|
+
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;
|
|
5399
5468
|
}
|
|
5400
5469
|
current() {
|
|
5401
5470
|
return this.currentLayout;
|
|
@@ -5411,7 +5480,7 @@ var Zi = class {
|
|
|
5411
5480
|
}
|
|
5412
5481
|
async list() {
|
|
5413
5482
|
let e = await this.storage.list();
|
|
5414
|
-
return Array.isArray(e) ? e.map(
|
|
5483
|
+
return Array.isArray(e) ? e.map(Gi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
|
|
5415
5484
|
}
|
|
5416
5485
|
save() {
|
|
5417
5486
|
return this.queue(() => {
|
|
@@ -5420,12 +5489,12 @@ var Zi = class {
|
|
|
5420
5489
|
});
|
|
5421
5490
|
}
|
|
5422
5491
|
saveAs(e) {
|
|
5423
|
-
let t =
|
|
5492
|
+
let t = Xi(e);
|
|
5424
5493
|
return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
|
|
5425
5494
|
}
|
|
5426
5495
|
open(e) {
|
|
5427
5496
|
return this.queue(async () => {
|
|
5428
|
-
let t =
|
|
5497
|
+
let t = Ki(await this.storage.load(e));
|
|
5429
5498
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
5430
5499
|
this.cancelTimer(), this.applying++;
|
|
5431
5500
|
try {
|
|
@@ -5435,13 +5504,13 @@ var Zi = class {
|
|
|
5435
5504
|
} finally {
|
|
5436
5505
|
this.applying--;
|
|
5437
5506
|
}
|
|
5438
|
-
return this.cancelTimer(), this.currentLayout =
|
|
5507
|
+
return this.cancelTimer(), this.currentLayout = Qi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
5439
5508
|
});
|
|
5440
5509
|
}
|
|
5441
5510
|
rename(e, t) {
|
|
5442
|
-
let n =
|
|
5511
|
+
let n = Xi(t);
|
|
5443
5512
|
return n ? this.queue(async () => {
|
|
5444
|
-
let t =
|
|
5513
|
+
let t = Ki(await this.storage.load(e));
|
|
5445
5514
|
!t || t.id !== e || (await this.storage.save({
|
|
5446
5515
|
...t,
|
|
5447
5516
|
name: n
|
|
@@ -5519,7 +5588,7 @@ var Zi = class {
|
|
|
5519
5588
|
content: n.content
|
|
5520
5589
|
};
|
|
5521
5590
|
await this.storage.save(r);
|
|
5522
|
-
let i =
|
|
5591
|
+
let i = Qi(r);
|
|
5523
5592
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
5524
5593
|
}
|
|
5525
5594
|
forget() {
|
|
@@ -5540,6 +5609,6 @@ var Zi = class {
|
|
|
5540
5609
|
}
|
|
5541
5610
|
};
|
|
5542
5611
|
//#endregion
|
|
5543
|
-
export { Wn as C, B as D, R as E, dn as O, qn as S, V as T, dr as _,
|
|
5612
|
+
export { Wn as C, B as D, R as E, dn as O, qn as S, V as T, dr as _, qi as a, G as b, Xr as c, Pr as d, Fr as f, ur as g, fr as h, Ji as i, Rr as l, pr as m, Yi as n, Vi as o, mr as p, Xi as r, ji as s, $i as t, Lr as u, cr as v, Hn as w, Qn as x, lr as y };
|
|
5544
5613
|
|
|
5545
|
-
//# sourceMappingURL=LayoutSession-
|
|
5614
|
+
//# sourceMappingURL=LayoutSession-D1OOl-zS.js.map
|