@tradecanvas/chart 1.56.0 → 1.57.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.
@@ -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, formatPrice as h, fractionTick as g, indicatorSource as _, isValidTimeZone as v, mergeBar as y, niceNumber as ee, normalizeBarTime as b, parseIndicatorSource as x, priceFormatterFor as te, priceStepAt as ne, readChartStyleOverrides as re, readChartTypeOptions as S, readIndicatorPlotStyles as ie, readPaneStyle as ae, resolveChartTheme as oe, sessionMinute as C, setLocale as se, stepDecimals as ce, symbolTimeZone as w, tickBarCount as le, timeframeToMs as T, zonedDateFormatter as ue } from "@tradecanvas/commons";
2
- import { AlertDragHandler as de, AlertManager as fe, Animator as pe, AreaRenderer as me, AxisDragHandler as he, BarCountdown as ge, BarRenderer as _e, BaselineRenderer as ve, CandlestickRenderer as ye, ChartLegend as be, ChartStateManager as E, CompareRenderer as xe, CompareSymbolIndicator as Se, CompareSymbolPaneIndicator as Ce, CorrelationCoefficientIndicator as we, CorrelationLogIndicator as Te, CrosshairHandler as Ee, CrosshairTooltip as De, CurrentPriceLine as Oe, DEFAULT_SESSION_HOURS as ke, DataExporter as D, DepthHeatmapRenderer as Ae, DrawingManager as je, DrawingRenderer as Me, EquivolumeRenderer as Ne, EventBus as Pe, GridRenderer as Fe, HLCAreaRenderer as Ie, HiLoRenderer as Le, HollowCandleRenderer as Re, IndicatorEngine as ze, InteractionManager as Be, KagiRenderer as Ve, KeyboardHandler as He, LineRenderer as Ue, LineWithMarkersRenderer as We, MarketProfileRenderer as Ge, MeasureOverlay as Ke, PRICE_SCALE_MARGIN as O, PanHandler as qe, PaneResizeHandler as Je, PeriodLevelsRenderer as Ye, PinnedTooltip as Xe, PivotMarkersRenderer as Ze, PointAndFigureRenderer as Qe, PriceAxis as $e, PriceAxisAddButton as et, PriceLines as tt, RenderEngine as nt, RenkoRenderer as rt, ReplayManager as it, ResamplingAdapter as at, ReshapeMemo as ot, SYMBOL_INDICATOR_IDS as k, SYMBOL_ZONE_WAIT_MS as st, Screenshot as A, SelectionBoxOverlay as ct, SessionBreaks as lt, SessionShading as ut, SignalMarkerManager as dt, SpreadIndicator as ft, StepLineRenderer as pt, StreamManager as mt, SymbolSeriesStore as ht, TimeAxis as gt, TradeZoneManager as _t, TradingManager as vt, TradingRenderer as yt, UndoRedoManager as bt, Viewport as xt, VolumeCandleRenderer as St, VolumeProfileRenderer as Ct, VolumeRenderer as wt, Watermark as Tt, ZoomHandler as Et, axisTimes as j, barTimeStepMs as Dt, findDominantSwing as Ot, gpuContextsLeft as kt, isPriceLevelAlert as At, isRegularSession as jt, loadWebGL as Mt, mergeSessionHours as Nt, pointAndFigureColumns as Pt, priceToY as Ft, rangePresetStart as It, readAlertOptions as Lt, registerBuiltInDrawingTools as Rt, registerBuiltInIndicators as zt, servesTimeframe as M, sourceParam as N, timeToX as Bt, timestampToBarIndex as P, toHeikinAshi as Vt, toKagi as Ht, toLineBreak as Ut, toRangeBars as Wt, toRenko as Gt, whenGpuContextFree as Kt, withResampling as F, xToBarIndex as qt, xToTime as I, yToPrice as Jt } from "@tradecanvas/core";
1
+ import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, createMarketTheme as h, formatPrice as g, fractionTick as _, indicatorSource as v, isValidTimeZone as y, mergeBar as ee, niceNumber as te, normalizeBarTime as b, parseIndicatorSource as x, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as ae, readIndicatorPlotStyles as oe, readPaneStyle as se, resolveChartTheme as ce, sessionMinute as S, setLocale as le, stepDecimals as ue, symbolTimeZone as C, tickBarCount as de, timeframeToMs as w, zonedDateFormatter as fe } from "@tradecanvas/commons";
2
+ import { AlertDragHandler as pe, AlertManager as me, Animator as he, AreaRenderer as ge, AxisDragHandler as _e, BarCountdown as ve, BarRenderer as ye, BaselineRenderer as be, CandlestickRenderer as xe, ChartLegend as Se, ChartStateManager as T, CompareRenderer as Ce, CompareSymbolIndicator as we, CompareSymbolPaneIndicator as Te, CorrelationCoefficientIndicator as Ee, CorrelationLogIndicator as De, CrosshairHandler as Oe, CrosshairTooltip as ke, CurrentPriceLine as Ae, DEFAULT_SESSION_HOURS as je, DataExporter as E, DepthHeatmapRenderer as Me, DrawingManager as Ne, DrawingRenderer as Pe, EquivolumeRenderer as Fe, EventBus as Ie, GridRenderer as Le, HLCAreaRenderer as Re, HiLoRenderer as ze, HollowCandleRenderer as Be, IndicatorEngine as Ve, InteractionManager as He, KagiRenderer as Ue, KeyboardHandler as We, LineRenderer as Ge, LineWithMarkersRenderer as Ke, MarketProfileRenderer as qe, MeasureOverlay as Je, PRICE_SCALE_MARGIN as D, 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 O, SYMBOL_ZONE_WAIT_MS as lt, Screenshot as k, 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 A, barTimeStepMs as kt, findDominantSwing as At, gpuContextsLeft as jt, isPriceLevelAlert as Mt, isRegularSession as Nt, loadWebGL as Pt, mergeSessionHours as Ft, pointAndFigureColumns as It, priceToY as Lt, rangePresetStart as Rt, readAlertOptions as zt, registerBuiltInDrawingTools as Bt, registerBuiltInIndicators as Vt, servesTimeframe as j, sourceParam as M, timeToX as Ht, timestampToBarIndex as N, toHeikinAshi as Ut, toKagi as Wt, toLineBreak as Gt, toRangeBars as Kt, toRenko as qt, whenGpuContextFree as Jt, withResampling as P, xToBarIndex as Yt, xToTime as F, yToPrice as Xt } from "@tradecanvas/core";
3
3
  //#region src/regularHours.ts
4
- var Yt = 864e5, Xt = 10;
5
- function Zt(e, t) {
6
- let n = w(e);
7
- if (!n || !v(n) || t.length < 2) return null;
4
+ var Zt = 864e5, Qt = 10;
5
+ function $t(e, t) {
6
+ let n = C(e);
7
+ if (!n || !y(n) || t.length < 2) return null;
8
8
  let r = (e?.sessions ?? []).flatMap((e) => {
9
- let t = C(e.start), n = C(e.end);
9
+ let t = S(e.start), n = S(e.end);
10
10
  return t === null || n === null ? [] : [{
11
11
  startMinute: t,
12
12
  endMinute: n
@@ -14,34 +14,34 @@ function Zt(e, t) {
14
14
  });
15
15
  if (r.length === 0) return null;
16
16
  let i = u(t), a = Infinity;
17
- for (let e = Math.max(1, t.length - Xt); e < t.length; e++) {
17
+ for (let e = Math.max(1, t.length - Qt); e < t.length; e++) {
18
18
  let n = (t[e].time - t[e - 1].time) * i;
19
19
  n > 0 && n < a && (a = n);
20
20
  }
21
- if (!(a < Yt)) return null;
21
+ if (!(a < Zt)) return null;
22
22
  let o = {
23
23
  timeZone: n,
24
24
  windows: r,
25
25
  startMinute: r[0].startMinute,
26
26
  endMinute: r[r.length - 1].endMinute
27
27
  };
28
- return (e) => jt(e * i, o);
28
+ return (e) => Nt(e * i, o);
29
29
  }
30
30
  //#endregion
31
31
  //#region src/chartA11y.ts
32
- var Qt = {
32
+ var en = {
33
33
  role: "chart",
34
34
  summary: "{what}. Last price {close}.",
35
35
  empty: "Chart, no data.",
36
36
  view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
37
37
  bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
38
38
  keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
39
- }, L = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), $t = [
39
+ }, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), tn = [
40
40
  "role",
41
41
  "aria-roledescription",
42
42
  "aria-label",
43
43
  "aria-describedby"
44
- ], en = 400, tn = 1e3, nn = class {
44
+ ], nn = 400, rn = 1e3, an = class {
45
45
  live;
46
46
  help;
47
47
  labels;
@@ -55,20 +55,20 @@ var Qt = {
55
55
  };
56
56
  constructor(e, t, n = {}) {
57
57
  this.container = e, this.source = t, this.labels = {
58
- ...Qt,
58
+ ...en,
59
59
  ...n
60
60
  };
61
- for (let t of $t) this.before.set(t, e.getAttribute(t));
62
- e.setAttribute("role", "application"), this.help = rn("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = rn("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
61
+ for (let t of tn) this.before.set(t, e.getAttribute(t));
62
+ e.setAttribute("role", "application"), this.help = on("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = on("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
63
63
  }
64
64
  setLabels(e) {
65
65
  this.labels = {
66
- ...Qt,
66
+ ...en,
67
67
  ...e
68
68
  }, this.applyLabels();
69
69
  }
70
70
  refresh(e = !1) {
71
- let t = tn - (Date.now() - this.summaryAt);
71
+ let t = rn - (Date.now() - this.summaryAt);
72
72
  if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
73
73
  this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
74
74
  return;
@@ -80,7 +80,7 @@ var Qt = {
80
80
  viewMoved() {
81
81
  this.cursor = null, this.viewTimer && clearTimeout(this.viewTimer), this.viewTimer = setTimeout(() => {
82
82
  this.viewTimer = null, this.say(this.viewText());
83
- }, en);
83
+ }, nn);
84
84
  }
85
85
  readBar(e) {
86
86
  let t = this.source.bars();
@@ -93,13 +93,13 @@ var Qt = {
93
93
  let i = t[this.cursor];
94
94
  this.source.showBar(i.time);
95
95
  let a = this.source.formatPrice;
96
- this.say(L(this.labels.bar, {
96
+ this.say(I(this.labels.bar, {
97
97
  time: this.source.formatTime(i.time),
98
98
  open: a(i.open),
99
99
  high: a(i.high),
100
100
  low: a(i.low),
101
101
  close: a(i.close),
102
- volume: an(i.volume ?? 0)
102
+ volume: sn(i.volume ?? 0)
103
103
  }));
104
104
  }
105
105
  destroy() {
@@ -118,7 +118,7 @@ var Qt = {
118
118
  this.labels.typeName ? this.labels.typeName(t) : t,
119
119
  this.source.timeframe()
120
120
  ].filter(Boolean).join(", ");
121
- return L(this.labels.summary, {
121
+ return I(this.labels.summary, {
122
122
  what: n,
123
123
  close: this.source.formatPrice(e[e.length - 1].close)
124
124
  });
@@ -128,7 +128,7 @@ var Qt = {
128
128
  if (e.length === 0) return this.labels.empty;
129
129
  let t = this.source.visibleRange(), n = Math.max(0, Math.min(e.length - 1, Math.ceil(t.from))), r = Math.max(n, Math.min(e.length - 1, Math.floor(t.to))), i = -Infinity, a = Infinity;
130
130
  for (let t = n; t <= r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
131
- return L(this.labels.view, {
131
+ return I(this.labels.view, {
132
132
  count: r - n + 1,
133
133
  from: this.source.formatTime(e[n].time),
134
134
  to: this.source.formatTime(e[r].time),
@@ -140,7 +140,7 @@ var Qt = {
140
140
  this.live.textContent = e;
141
141
  }
142
142
  };
143
- function rn(e, t) {
143
+ function on(e, t) {
144
144
  let n = document.createElement(e);
145
145
  return n.className = t, Object.assign(n.style, {
146
146
  position: "absolute",
@@ -154,14 +154,17 @@ function rn(e, t) {
154
154
  border: "0"
155
155
  }), n;
156
156
  }
157
- function an(e) {
157
+ function sn(e) {
158
158
  return Number.isInteger(e) ? String(e) : e.toFixed(2);
159
159
  }
160
160
  //#endregion
161
161
  //#region src/indicatorLabel.ts
162
- var on = 3, sn = { stochrsi: 4 };
163
- function cn(e, t, n, r) {
164
- let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, sn[e] ?? on).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
162
+ var cn = 3, ln = {
163
+ stochrsi: 4,
164
+ ichimoku: 4
165
+ };
166
+ function un(e, t, n, r) {
167
+ let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, ln[e] ?? cn).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
165
168
  return [
166
169
  e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
167
170
  ...a,
@@ -170,52 +173,52 @@ function cn(e, t, n, r) {
170
173
  }
171
174
  //#endregion
172
175
  //#region src/charts/ChartTypeStrategy.ts
173
- function ln(e) {
176
+ function dn(e) {
174
177
  switch (e) {
175
178
  case "candlestick":
176
179
  case "heikinAshi":
177
180
  case "lineBreak":
178
- case "rangeBars": return new ye();
179
- case "line": return new Ue();
180
- case "area": return new me();
181
- case "bar": return new _e();
182
- case "hollowCandle": return new Re();
183
- case "baseline": return new ve();
184
- case "renko": return new rt();
185
- case "kagi": return new Ve();
186
- case "pointAndFigure": return new Qe();
187
- case "volumeCandles": return new St();
188
- case "equivolume": return new Ne();
189
- case "hlcArea": return new Ie();
190
- case "stepLine": return new pt();
191
- case "lineWithMarkers": return new We();
192
- case "hiLo": return new Le();
193
- default: return new ye();
181
+ case "rangeBars": return new xe();
182
+ case "line": return new Ge();
183
+ case "area": return new ge();
184
+ case "bar": return new ye();
185
+ case "hollowCandle": return new Be();
186
+ case "baseline": return new be();
187
+ case "renko": return new at();
188
+ case "kagi": return new Ue();
189
+ case "pointAndFigure": return new et();
190
+ case "volumeCandles": return new wt();
191
+ case "equivolume": return new Fe();
192
+ case "hlcArea": return new Re();
193
+ case "stepLine": return new ht();
194
+ case "lineWithMarkers": return new Ke();
195
+ case "hiLo": return new ze();
196
+ default: return new xe();
194
197
  }
195
198
  }
196
- function un(e, t, n = {}, r, i) {
199
+ function fn(e, t, n = {}, r, i) {
197
200
  if (t.length === 0) return t;
198
201
  switch (e) {
199
- case "heikinAshi": return Vt(t);
202
+ case "heikinAshi": return Ut(t);
200
203
  case "renko": {
201
204
  let e = n.renko?.boxSize;
202
- return typeof e == "number" ? Gt(t, { brickSize: e }, i) : Gt(t, {
205
+ return typeof e == "number" ? qt(t, { brickSize: e }, i) : qt(t, {
203
206
  brickSize: 0,
204
207
  useATR: !0,
205
208
  atrPeriod: n.renko?.atrPeriod ?? 14
206
209
  }, i);
207
210
  }
208
- case "lineBreak": return Ut(t, n.lineBreak?.lines ?? 3);
209
- case "kagi": return Ht(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
210
- case "pointAndFigure": return fn(t, n, i).columns;
211
- case "rangeBars": return Wt(t, {
212
- rangeSize: xn(t, n, r),
211
+ case "lineBreak": return Gt(t, n.lineBreak?.lines ?? 3);
212
+ case "kagi": return Wt(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
213
+ case "pointAndFigure": return mn(t, n, i).columns;
214
+ case "rangeBars": return Kt(t, {
215
+ rangeSize: wn(t, n, r),
213
216
  includeForming: !0
214
217
  }, i);
215
218
  default: return t;
216
219
  }
217
220
  }
218
- function dn(e) {
221
+ function pn(e) {
219
222
  switch (e) {
220
223
  case "heikinAshi":
221
224
  case "renko":
@@ -226,72 +229,72 @@ function dn(e) {
226
229
  default: return !1;
227
230
  }
228
231
  }
229
- function R(e) {
230
- return e !== "heikinAshi" && dn(e);
232
+ function L(e) {
233
+ return e !== "heikinAshi" && pn(e);
231
234
  }
232
- function fn(e, t = {}, n) {
233
- return Pt(e, hn(e, t), t.pointAndFigure?.reversal ?? 3, n);
235
+ function mn(e, t = {}, n) {
236
+ return It(e, _n(e, t), t.pointAndFigure?.reversal ?? 3, n);
234
237
  }
235
- var pn = 50, mn = .01;
236
- function hn(e, t = {}) {
238
+ var hn = 50, gn = .01;
239
+ function _n(e, t = {}) {
237
240
  let n = t.pointAndFigure?.boxSize;
238
241
  if (typeof n == "number") return n;
239
- let r = gn(e, e.length > 1 ? e.length - 1 : e.length);
240
- return r > 0 ? z(ee(r / pn, !0)) : Math.abs(e[e.length - 1]?.close ?? 0) * mn || 1;
242
+ let r = vn(e, e.length > 1 ? e.length - 1 : e.length);
243
+ return r > 0 ? Cn(te(r / hn, !0)) : Math.abs(e[e.length - 1]?.close ?? 0) * gn || 1;
241
244
  }
242
- function gn(e, t) {
245
+ function vn(e, t) {
243
246
  let n = -Infinity, r = Infinity;
244
247
  for (let i = 0; i < t; i++) e[i].high > n && (n = e[i].high), e[i].low < r && (r = e[i].low);
245
248
  let i = n - r;
246
249
  return Number.isFinite(i) ? i : 0;
247
250
  }
248
- var _n = 100, vn = 3, yn = .01, bn = 15, z = (e) => Number(e.toPrecision(bn));
249
- function xn(e, t = {}, n) {
251
+ var yn = 100, bn = 3, xn = .01, Sn = 15, Cn = (e) => Number(e.toPrecision(Sn));
252
+ function wn(e, t = {}, n) {
250
253
  let r = t.rangeBars?.range;
251
254
  if (typeof r == "number") return r;
252
- let i = e.length >= vn ? Cn(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
253
- return En(z(ee(i > 0 ? i : a * yn || 1, !0)), n);
255
+ let i = e.length >= bn ? En(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
256
+ return kn(Cn(te(i > 0 ? i : a * xn || 1, !0)), n);
254
257
  }
255
- function Sn(e) {
258
+ function Tn(e) {
256
259
  let t = e.length - 1;
257
260
  return {
258
- from: Math.max(0, t - _n),
261
+ from: Math.max(0, t - yn),
259
262
  end: t
260
263
  };
261
264
  }
262
- function Cn(e) {
263
- let { from: t, end: n } = Sn(e), r = 0;
265
+ function En(e) {
266
+ let { from: t, end: n } = Tn(e), r = 0;
264
267
  for (let i = t; i < n; i++) {
265
268
  let { high: t, low: n } = e[i], a = i > 0 ? e[i - 1].close : n;
266
269
  r += Math.max(t - n, Math.abs(t - a), Math.abs(n - a));
267
270
  }
268
271
  return n > t ? r / (n - t) : 0;
269
272
  }
270
- function wn(e, t) {
271
- let { from: n, end: r } = Sn(e);
273
+ function Dn(e, t) {
274
+ let { from: n, end: r } = Tn(e);
272
275
  if (r <= n) return t(e[e.length - 1]?.close ?? 0);
273
276
  let i = -Infinity, a = Infinity;
274
277
  for (let t = n; t < r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
275
- return Tn(t(i), t(a));
278
+ return On(t(i), t(a));
276
279
  }
277
- function Tn(e, t) {
280
+ function On(e, t) {
278
281
  return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
279
282
  }
280
- function En(e, t) {
281
- return t === void 0 || !(t > 0) ? e : z(Math.max(1, Math.round(e / t)) * t);
283
+ function kn(e, t) {
284
+ return t === void 0 || !(t > 0) ? e : Cn(Math.max(1, Math.round(e / t)) * t);
282
285
  }
283
- function Dn(e, t) {
286
+ function An(e, t) {
284
287
  let n = t?.(e);
285
- return n ? n.createRenderer() : ln(e);
288
+ return n ? n.createRenderer() : dn(e);
286
289
  }
287
- function On(e, t, n, r, i, a) {
290
+ function jn(e, t, n, r, i, a) {
288
291
  if (t.length === 0) return t;
289
292
  let o = n?.(e);
290
- return o?.transform ? o.transform(t) : un(e, t, r, i, a);
293
+ return o?.transform ? o.transform(t) : fn(e, t, r, i, a);
291
294
  }
292
295
  //#endregion
293
296
  //#region src/state/AutoSaveScheduler.ts
294
- var kn = class {
297
+ var Mn = class {
295
298
  timer = null;
296
299
  delayMs = 0;
297
300
  key = null;
@@ -321,15 +324,15 @@ var kn = class {
321
324
  };
322
325
  //#endregion
323
326
  //#region src/DataManager.ts
324
- function B(e) {
327
+ function R(e) {
325
328
  if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
326
329
  let { open: t, high: n, low: r, close: i } = e;
327
330
  return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
328
331
  }
329
- function An(e) {
332
+ function Nn(e) {
330
333
  return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
331
334
  }
332
- function V(e) {
335
+ function z(e) {
333
336
  return {
334
337
  ...e,
335
338
  high: Math.max(e.open, e.high, e.low, e.close),
@@ -337,36 +340,36 @@ function V(e) {
337
340
  volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
338
341
  };
339
342
  }
340
- function H(e, t) {
343
+ function B(e, t) {
341
344
  return e === t || e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume;
342
345
  }
343
- function jn(e, t) {
346
+ function Pn(e, t) {
344
347
  for (let n = e.length - 1; n >= 0; n--) {
345
348
  if (e[n].time === t) return n;
346
349
  if (e[n].time < t) return -1;
347
350
  }
348
351
  return -1;
349
352
  }
350
- var Mn = {
353
+ var Fn = {
351
354
  index: -1,
352
355
  changed: !1
353
356
  };
354
- function Nn(e, t) {
357
+ function In(e, t) {
355
358
  if (e.length === 0) return t;
356
359
  let n = b(t);
357
360
  return u(e) === 1 ? n : n / 1e3;
358
361
  }
359
- function Pn(e, t) {
360
- let n = Nn(e, t.time);
362
+ function Ln(e, t) {
363
+ let n = In(e, t.time);
361
364
  return n === t.time ? t : {
362
365
  ...t,
363
366
  time: n
364
367
  };
365
368
  }
366
- var U = class {
369
+ var V = class {
367
370
  data = [];
368
371
  withSeriesTime(e) {
369
- return Pn(this.data, e);
372
+ return Ln(this.data, e);
370
373
  }
371
374
  getData() {
372
375
  return this.data;
@@ -375,16 +378,16 @@ var U = class {
375
378
  let t = [];
376
379
  for (let n = 0; n < e.length; n++) {
377
380
  let r = e[n];
378
- B(r) && t.push(An(r) ? r : V(r));
381
+ R(r) && t.push(Nn(r) ? r : z(r));
379
382
  }
380
383
  this.data = t;
381
384
  }
382
385
  prependBars(e) {
383
386
  let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
384
387
  for (let r = 0; r < e.length; r++) {
385
- if (!B(e[r])) continue;
388
+ if (!R(e[r])) continue;
386
389
  let i = this.withSeriesTime(e[r]);
387
- i.time >= t || n.push(An(i) ? i : V(i));
390
+ i.time >= t || n.push(Nn(i) ? i : z(i));
388
391
  }
389
392
  if (n.length === 0) return 0;
390
393
  n.sort((e, t) => e.time - t.time);
@@ -393,11 +396,11 @@ var U = class {
393
396
  return n.length = r, this.data = n.concat(this.data), r;
394
397
  }
395
398
  appendBar(e) {
396
- B(e) && this.data.push(V(this.withSeriesTime(e)));
399
+ R(e) && this.data.push(z(this.withSeriesTime(e)));
397
400
  }
398
401
  updateLastBar(e) {
399
- if (!B(e)) return;
400
- let t = V(this.withSeriesTime(e));
402
+ if (!R(e)) return;
403
+ let t = z(this.withSeriesTime(e));
401
404
  if (this.data.length === 0) {
402
405
  this.data.push(t);
403
406
  return;
@@ -405,11 +408,11 @@ var U = class {
405
408
  this.data[this.data.length - 1] = t;
406
409
  }
407
410
  replaceBar(e) {
408
- if (!B(e)) return Mn;
409
- let t = this.withSeriesTime(e), n = jn(this.data, t.time);
410
- if (n < 0) return Mn;
411
- let r = V(t);
412
- return H(this.data[n], r) ? {
411
+ if (!R(e)) return Fn;
412
+ let t = this.withSeriesTime(e), n = Pn(this.data, t.time);
413
+ if (n < 0) return Fn;
414
+ let r = z(t);
415
+ return B(this.data[n], r) ? {
413
416
  index: n,
414
417
  changed: !1
415
418
  } : (this.data[n] = r, {
@@ -418,7 +421,7 @@ var U = class {
418
421
  });
419
422
  }
420
423
  updateLastBarFromTick(e) {
421
- this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = y(this.data[this.data.length - 1], this.withSeriesTime(e))));
424
+ this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = ee(this.data[this.data.length - 1], this.withSeriesTime(e))));
422
425
  }
423
426
  getLength() {
424
427
  return this.data.length;
@@ -426,18 +429,18 @@ var U = class {
426
429
  clear() {
427
430
  this.data = [];
428
431
  }
429
- }, W = {
432
+ }, H = {
430
433
  to: "none",
431
434
  index: -1,
432
435
  changed: !1
433
436
  };
434
- function G(e, t) {
437
+ function U(e, t) {
435
438
  let n = e[e.length - 1];
436
439
  if (!n) return "append";
437
440
  let r = b(t.time), i = b(n.time);
438
441
  return r > i ? "append" : r === i ? "update" : "stale";
439
442
  }
440
- function Fn(e) {
443
+ function Rn(e) {
441
444
  return [
442
445
  e.time,
443
446
  e.open,
@@ -446,8 +449,8 @@ function Fn(e) {
446
449
  e.close
447
450
  ].every(Number.isFinite);
448
451
  }
449
- var In = class {
450
- shown = new U();
452
+ var zn = class {
453
+ shown = new V();
451
454
  whole = null;
452
455
  aside = null;
453
456
  shownRevision = 0;
@@ -486,7 +489,7 @@ var In = class {
486
489
  }
487
490
  let t = null, n = e;
488
491
  if (this.whole) {
489
- let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(Fn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
492
+ let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(Rn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
490
493
  this.whole = [...a, ...this.whole];
491
494
  let o = this.hoursFilter(this.whole);
492
495
  t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
@@ -498,8 +501,8 @@ var In = class {
498
501
  };
499
502
  }
500
503
  mergeSnapshot(e) {
501
- if (this.aside) return this.aside.setData(Ln(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
502
- let t = Ln(this.whole ?? this.shown.getData(), e);
504
+ if (this.aside) return this.aside.setData(Bn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
505
+ let t = Bn(this.whole ?? this.shown.getData(), e);
503
506
  return t ? (this.shown.setData(this.regularOnly(t)), !0) : !1;
504
507
  }
505
508
  refilter() {
@@ -556,7 +559,7 @@ var In = class {
556
559
  mergeTick(e) {
557
560
  if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
558
561
  let t = this.whole ? this.hoursFilter(this.whole) : null;
559
- if (t && this.whole && !t(Nn(this.whole, e.time))) return this.wrote("hidden", !1);
562
+ if (t && this.whole && !t(In(this.whole, e.time))) return this.wrote("hidden", !1);
560
563
  let n = this.shown.getLength();
561
564
  this.shown.updateLastBarFromTick(e);
562
565
  let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
@@ -568,14 +571,14 @@ var In = class {
568
571
  }
569
572
  placeStreamBar(e) {
570
573
  if (this.aside) {
571
- let t = G(this.aside.getData(), e);
574
+ let t = U(this.aside.getData(), e);
572
575
  return t === "append" ? this.aside.appendBar(e) : t === "update" && this.aside.updateLastBar(e), this.wrote(t === "stale" ? "none" : "aside", !1);
573
576
  }
574
- let t = this.inSeriesUnit(e), n = G(this.whole ?? this.shown.getData(), t);
577
+ let t = this.inSeriesUnit(e), n = U(this.whole ?? this.shown.getData(), t);
575
578
  if (n === "stale") return this.wrote("none", !1);
576
579
  let r = this.startWholeSeries(t, n);
577
580
  if (!this.take(t, n)) return this.wrote("hidden", r);
578
- let i = this.shown.getLength(), a = G(this.shown.getData(), t);
581
+ let i = this.shown.getLength(), a = U(this.shown.getData(), t);
579
582
  return a === "stale" ? {
580
583
  to: "none",
581
584
  before: i,
@@ -589,7 +592,7 @@ var In = class {
589
592
  replace(e) {
590
593
  if (this.aside) {
591
594
  let { index: t, changed: n } = this.aside.replaceBar(e);
592
- return t < 0 ? W : (n && this.onLiveChange({
595
+ return t < 0 ? H : (n && this.onLiveChange({
593
596
  kind: "bar",
594
597
  time: this.aside.getData()[t].time
595
598
  }), {
@@ -598,22 +601,22 @@ var In = class {
598
601
  changed: n
599
602
  });
600
603
  }
601
- if (!B(e)) return W;
602
- let t = this.inSeriesUnit(e), n = this.whole, r = n ? jn(n, t.time) : -1;
604
+ if (!R(e)) return H;
605
+ let t = this.inSeriesUnit(e), n = this.whole, r = n ? Pn(n, t.time) : -1;
603
606
  if (n) {
604
- if (r < 0 || !B(n[r])) return W;
607
+ if (r < 0 || !R(n[r])) return H;
605
608
  let e = this.hoursFilter(n);
606
609
  if (e && !e(t.time)) return this.replaceHidden(n, r, t);
607
610
  }
608
611
  let { index: i, changed: a } = this.shown.replaceBar(t);
609
- return i < 0 ? W : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
612
+ return i < 0 ? H : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
610
613
  to: "shown",
611
614
  index: i,
612
615
  changed: a
613
616
  });
614
617
  }
615
618
  beginReplay() {
616
- this.aside || (this.aside = new U(), this.aside.setData(this.whole ?? this.shown.getData()));
619
+ this.aside || (this.aside = new V(), this.aside.setData(this.whole ?? this.shown.getData()));
617
620
  }
618
621
  endReplay() {
619
622
  let e = this.aside;
@@ -633,10 +636,10 @@ var In = class {
633
636
  this.shown.updateLastBar(e);
634
637
  }
635
638
  inSeriesUnit(e) {
636
- return Pn(this.whole ?? this.shown.getData(), e);
639
+ return Ln(this.whole ?? this.shown.getData(), e);
637
640
  }
638
641
  replaceHidden(e, t, n) {
639
- let r = V(n), i = !H(e[t], r);
642
+ let r = z(n), i = !B(e[t], r);
640
643
  return i && (e[t] = r), {
641
644
  to: "hidden",
642
645
  index: -1,
@@ -670,14 +673,14 @@ var In = class {
670
673
  return !r || r(e.time);
671
674
  }
672
675
  };
673
- function Ln(e, t) {
676
+ function Bn(e, t) {
674
677
  let n = t[0]?.time, r = 0;
675
678
  for (; n !== void 0 && r < e.length && e[r].time < n;) r++;
676
679
  return r === 0 || r === e.length ? null : e.slice(0, r).concat(t);
677
680
  }
678
681
  //#endregion
679
682
  //#region src/HistoryPager.ts
680
- var Rn = 5e3, zn = 6e4, Bn = 500, Vn = class {
683
+ var Vn = 5e3, Hn = 6e4, Un = 500, Wn = class {
681
684
  loader = null;
682
685
  pageSize = 500;
683
686
  loading = !1;
@@ -729,7 +732,7 @@ var Rn = 5e3, zn = 6e4, Bn = 500, Vn = class {
729
732
  try {
730
733
  r = await e(t, this.pageSize);
731
734
  } catch (e) {
732
- return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(zn, Rn * 2 ** (this.failures - 1)), this.emit({
735
+ return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Hn, Vn * 2 ** (this.failures - 1)), this.emit({
733
736
  state: "error",
734
737
  count: 0,
735
738
  error: e instanceof Error ? e.message : String(e)
@@ -762,10 +765,10 @@ var Rn = 5e3, zn = 6e4, Bn = 500, Vn = class {
762
765
  };
763
766
  //#endregion
764
767
  //#region src/ThemeManager.ts
765
- function Hn(e, t) {
768
+ function Gn(e, t) {
766
769
  return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
767
770
  }
768
- var Un = class t {
771
+ var Kn = class t {
769
772
  base;
770
773
  shape = null;
771
774
  font = null;
@@ -784,13 +787,13 @@ var Un = class t {
784
787
  return i;
785
788
  }
786
789
  getTheme() {
787
- return this.effective ??= oe(this.base, this.chartType, this.merged()), this.effective;
790
+ return this.effective ??= ce(this.base, this.chartType, this.merged()), this.effective;
788
791
  }
789
792
  getBaseTheme() {
790
793
  return this.base;
791
794
  }
792
795
  setTheme(e) {
793
- let n = t.read(e), r = this.font !== null && Hn(n.font, this.base.font);
796
+ let n = t.read(e), r = this.font !== null && Gn(n.font, this.base.font);
794
797
  this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
795
798
  ...this.base,
796
799
  shape: {
@@ -872,7 +875,7 @@ var Un = class t {
872
875
  };
873
876
  //#endregion
874
877
  //#region src/style/styleOptions.ts
875
- function Wn(e, t) {
878
+ function qn(e, t) {
876
879
  return t ? {
877
880
  ...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
878
881
  ...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
@@ -880,22 +883,22 @@ function Wn(e, t) {
880
883
  ...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
881
884
  } : {};
882
885
  }
883
- function Gn(e) {
886
+ function Jn(e) {
884
887
  let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
885
888
  return {
886
889
  ...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
887
890
  ...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
888
891
  ...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
889
892
  ...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
890
- ...Wn("horizontal", n?.hLine),
891
- ...Wn("vertical", n?.vLine),
893
+ ...qn("horizontal", n?.hLine),
894
+ ...qn("vertical", n?.vLine),
892
895
  ...r === void 0 ? {} : { "crosshair.labelBackground": r },
893
896
  ...e.overrides
894
897
  };
895
898
  }
896
899
  //#endregion
897
900
  //#region src/layout/LayoutManager.ts
898
- var Kn = 200, qn = 80, K = (e) => e.position === "top" || e.position === "bottom", Jn = class {
901
+ var Yn = 200, Xn = 80, W = (e) => e.position === "top" || e.position === "bottom", Zn = class {
899
902
  panels = [];
900
903
  containerWidth = 0;
901
904
  containerHeight = 0;
@@ -912,8 +915,8 @@ var Kn = 200, qn = 80, K = (e) => e.position === "top" || e.position === "bottom
912
915
  this.panels.push({
913
916
  id: e,
914
917
  position: n,
915
- size: r ?? (a ? Kn : t),
916
- minSize: a ? qn : i,
918
+ size: r ?? (a ? Yn : t),
919
+ minSize: a ? Xn : i,
917
920
  content: {
918
921
  type: "indicator",
919
922
  indicatorInstanceId: e
@@ -932,14 +935,14 @@ var Kn = 200, qn = 80, K = (e) => e.position === "top" || e.position === "bottom
932
935
  }
933
936
  setPanelCollapsed(e, t) {
934
937
  let n = this.panels.find((t) => t.id === e);
935
- return !n || !K(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
938
+ return !n || !W(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
936
939
  }
937
940
  isPanelCollapsed(e) {
938
941
  return !!this.panels.find((t) => t.id === e)?.collapsed;
939
942
  }
940
943
  isPanelShownCollapsed(e) {
941
944
  let t = this.panels.find((t) => t.id === e);
942
- return !t || !K(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
945
+ return !t || !W(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
943
946
  }
944
947
  setPanelScale(e, t) {
945
948
  let n = this.panels.find((t) => t.id === e);
@@ -955,7 +958,7 @@ var Kn = 200, qn = 80, K = (e) => e.position === "top" || e.position === "bottom
955
958
  }
956
959
  setMaximizedPanel(e) {
957
960
  let t = e === null ? null : this.panels.find((t) => t.id === e);
958
- return e !== null && (!t || !K(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
961
+ return e !== null && (!t || !W(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
959
962
  }
960
963
  getMaximizedPanel() {
961
964
  return this.maximized;
@@ -976,19 +979,19 @@ var Kn = 200, qn = 80, K = (e) => e.position === "top" || e.position === "bottom
976
979
  this.panels = [...this.panels].sort((e, n) => t(e) - t(n));
977
980
  }
978
981
  shownSize(e, t) {
979
- return K(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
982
+ return W(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
980
983
  }
981
984
  setPanelPosition(e, n) {
982
985
  let r = this.panels.find((t) => t.id === e);
983
986
  if (r) {
984
987
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
985
- r.position = n, a !== o && (r.size = o ? Kn : t, r.minSize = o ? qn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
988
+ r.position = n, a !== o && (r.size = o ? Yn : t, r.minSize = o ? Xn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
986
989
  }
987
990
  }
988
991
  setPanelSize(e, t) {
989
992
  let n = this.panels.find((t) => t.id === e);
990
993
  if (n) {
991
- let e = K(n) ? this.containerHeight - s - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
994
+ let e = W(n) ? this.containerHeight - s - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
992
995
  n.size = Math.max(n.minSize, r), n.collapsed = void 0, this.maximized = null;
993
996
  }
994
997
  }
@@ -1102,8 +1105,8 @@ var Kn = 200, qn = 80, K = (e) => e.position === "top" || e.position === "bottom
1102
1105
  getMainChartRect() {
1103
1106
  return this.resolve().mainChartRect;
1104
1107
  }
1105
- }, Yn = 14, Xn = 14, Zn = 22, Qn = 4;
1106
- function $n(e) {
1108
+ }, Qn = 14, $n = 14, er = 22, tr = 4;
1109
+ function nr(e) {
1107
1110
  let { min: t, max: n, lastPrice: r, locale: i, fontFamily: a, fontSizeSmall: s, measure: l } = e, u = e.tagPrecision ?? c(t, n), d = u, f = r === null ? [t, n] : [
1108
1111
  t,
1109
1112
  n,
@@ -1111,17 +1114,17 @@ function $n(e) {
1111
1114
  ], p = o;
1112
1115
  for (let t of f) {
1113
1116
  if (!Number.isFinite(t)) continue;
1114
- let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : h(t, u, i), r = e.format ? n : h(t, d, i);
1115
- p = Math.max(p, l(n, `500 ${s}px ${a}`) + Yn, l(r, `bold 11px ${a}`) + Xn, l(r, `600 ${s}px ${a}`) + Zn);
1117
+ let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : g(t, u, i), r = e.format ? n : g(t, d, i);
1118
+ p = Math.max(p, l(n, `500 ${s}px ${a}`) + Qn, l(r, `bold 11px ${a}`) + $n, l(r, `600 ${s}px ${a}`) + er);
1116
1119
  }
1117
- return p <= o ? o : Math.ceil(p / Qn) * Qn;
1120
+ return p <= o ? o : Math.ceil(p / tr) * tr;
1118
1121
  }
1119
- function er(e, t) {
1122
+ function rr(e, t) {
1120
1123
  return t > e || t <= e - 12 ? t : e;
1121
1124
  }
1122
1125
  //#endregion
1123
1126
  //#region src/layout/labelWidths.ts
1124
- var tr = 512, nr = class {
1127
+ var ir = 512, ar = class {
1125
1128
  widths = /* @__PURE__ */ new Map();
1126
1129
  fonts;
1127
1130
  forget = () => this.widths.clear();
@@ -1132,12 +1135,12 @@ var tr = 512, nr = class {
1132
1135
  let r = `${t}\n${e}`, i = this.widths.get(r);
1133
1136
  if (i !== void 0) return i;
1134
1137
  let a = n();
1135
- return this.widths.size >= tr && this.widths.clear(), this.widths.set(r, a), a;
1138
+ return this.widths.size >= ir && this.widths.clear(), this.widths.set(r, a), a;
1136
1139
  }
1137
1140
  destroy() {
1138
1141
  this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
1139
1142
  }
1140
- }, rr = class {
1143
+ }, or = class {
1141
1144
  netY = 0;
1142
1145
  travelX = 0;
1143
1146
  engaged = !1;
@@ -1153,11 +1156,11 @@ var tr = 512, nr = class {
1153
1156
  }
1154
1157
  return this.engaged;
1155
1158
  }
1156
- }, ir = 1;
1157
- function ar(e, t) {
1159
+ }, sr = 1;
1160
+ function cr(e, t) {
1158
1161
  return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
1159
1162
  }
1160
- function q(e) {
1163
+ function G(e) {
1161
1164
  switch (e.kind) {
1162
1165
  case "indicator": return `indicator:${e.plugin.descriptor.id}`;
1163
1166
  case "drawing": return `drawing:${e.plugin.descriptor.type}`;
@@ -1167,25 +1170,25 @@ function q(e) {
1167
1170
  }
1168
1171
  //#endregion
1169
1172
  //#region src/plugins/registry.ts
1170
- var J = /* @__PURE__ */ new Map();
1171
- function or(e) {
1172
- J.set(q(e), e);
1173
+ var K = /* @__PURE__ */ new Map();
1174
+ function lr(e) {
1175
+ K.set(G(e), e);
1173
1176
  }
1174
- function sr(e) {
1175
- return J.delete(e);
1177
+ function ur(e) {
1178
+ return K.delete(e);
1176
1179
  }
1177
- function cr() {
1178
- return [...J.values()];
1180
+ function dr() {
1181
+ return [...K.values()];
1179
1182
  }
1180
- function lr() {
1181
- J.clear();
1183
+ function fr() {
1184
+ K.clear();
1182
1185
  }
1183
1186
  //#endregion
1184
1187
  //#region src/plugins/PluginManager.ts
1185
- var ur = class {
1188
+ var pr = class {
1186
1189
  plugins = /* @__PURE__ */ new Map();
1187
1190
  constructor(e, t = {}) {
1188
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of cr()) this.add(e);
1191
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of dr()) this.add(e);
1189
1192
  for (let e of t.plugins ?? []) this.add(e);
1190
1193
  }
1191
1194
  register(e) {
@@ -1213,17 +1216,17 @@ var ur = class {
1213
1216
  return e;
1214
1217
  }
1215
1218
  add(e) {
1216
- this.plugins.set(q(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1219
+ this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1217
1220
  }
1218
- }, dr = {
1221
+ }, mr = {
1219
1222
  orderPlace: (e, t) => e.placeOrder(t),
1220
1223
  orderModify: (e, t) => e.modifyOrder(t),
1221
1224
  orderCancel: (e, t) => e.cancelOrder(t),
1222
1225
  positionModify: (e, t) => e.modifyPosition(t),
1223
1226
  positionClose: (e, t) => e.closePosition(t),
1224
- positionReverse: (e, t, n) => fr(e, t, n)
1227
+ positionReverse: (e, t, n) => hr(e, t, n)
1225
1228
  };
1226
- async function fr(e, t, n) {
1229
+ async function hr(e, t, n) {
1227
1230
  let { reversing: r } = n;
1228
1231
  if (!r.has(t.positionId)) {
1229
1232
  r.add(t.positionId);
@@ -1252,7 +1255,7 @@ async function fr(e, t, n) {
1252
1255
  }
1253
1256
  }
1254
1257
  }
1255
- function pr(e, t) {
1258
+ function gr(e, t) {
1256
1259
  let n = [], r = null, i = {
1257
1260
  positions: () => r ?? t.getPositions?.() ?? [],
1258
1261
  reversing: /* @__PURE__ */ new Set()
@@ -1262,8 +1265,8 @@ function pr(e, t) {
1262
1265
  e.data && t.onFill?.(e.data);
1263
1266
  };
1264
1267
  e.on("orders", a), e.on("positions", o), e.on("error", s), e.on("fill", c), n.push(() => e.off("orders", a), () => e.off("positions", o), () => e.off("error", s), () => e.off("fill", c));
1265
- for (let r of Object.keys(dr)) {
1266
- let a = dr[r], o = t.onIntent(r, (n) => {
1268
+ for (let r of Object.keys(mr)) {
1269
+ let a = mr[r], o = t.onIntent(r, (n) => {
1267
1270
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
1268
1271
  message: `Execution command failed: ${r}`,
1269
1272
  cause: e
@@ -1277,7 +1280,7 @@ function pr(e, t) {
1277
1280
  }
1278
1281
  //#endregion
1279
1282
  //#region src/replay/ReplayStepLoader.ts
1280
- var mr = 1e3, hr = class {
1283
+ var _r = 1e3, vr = class {
1281
1284
  pieces = /* @__PURE__ */ new Map();
1282
1285
  asked = /* @__PURE__ */ new Set();
1283
1286
  inFlight = !1;
@@ -1310,7 +1313,7 @@ var mr = 1e3, hr = class {
1310
1313
  this.done = !0;
1311
1314
  }
1312
1315
  ask(e, t) {
1313
- let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(mr / n)), s = Math.min(e.length, t + o), c = s < e.length ? e[s].time : e[e.length - 1].time + r, l = e.slice(t, s);
1316
+ let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(_r / n)), s = Math.min(e.length, t + o), c = s < e.length ? e[s].time : e[e.length - 1].time + r, l = e.slice(t, s);
1314
1317
  for (let e of l) this.asked.add(e.time);
1315
1318
  this.inFlight = !0, a({
1316
1319
  state: "loading",
@@ -1351,12 +1354,12 @@ var mr = 1e3, hr = class {
1351
1354
  ...n === void 0 ? {} : { error: n }
1352
1355
  });
1353
1356
  }
1354
- }, gr = 1 / 3, _r = .25, vr = .5;
1355
- function yr(e, t) {
1356
- let n = (e.high - e.low) * _r;
1357
- return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * vr;
1357
+ }, yr = 1 / 3, br = .25, xr = .5;
1358
+ function Sr(e, t) {
1359
+ let n = (e.high - e.low) * br;
1360
+ return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * xr;
1358
1361
  }
1359
- function br(e) {
1362
+ function Cr(e) {
1360
1363
  return e.close >= e.open ? [
1361
1364
  e.open,
1362
1365
  e.low,
@@ -1369,22 +1372,22 @@ function br(e) {
1369
1372
  e.close
1370
1373
  ];
1371
1374
  }
1372
- function xr(e, t, n) {
1373
- let r = br(e), i = [
1375
+ function wr(e, t, n) {
1376
+ let r = Cr(e), i = [
1374
1377
  1,
1375
1378
  2,
1376
1379
  3
1377
1380
  ].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
1378
1381
  return r.forEach((r, c) => {
1379
- c > 0 && (s += a > 0 ? i[c - 1] / a : gr), !(c === 0 && t > 0) && o.push({
1382
+ c > 0 && (s += a > 0 ? i[c - 1] / a : yr), !(c === 0 && t > 0) && o.push({
1380
1383
  price: r,
1381
1384
  time: e.time,
1382
1385
  at: (t + s) / n
1383
1386
  });
1384
1387
  }), o;
1385
1388
  }
1386
- function Sr(e, t = []) {
1387
- let n = t.length > 0 && yr(e, t) ? t : [e], r = n.length, i = Cr(n.flatMap((e, t) => xr(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
1389
+ function Tr(e, t = []) {
1390
+ let n = t.length > 0 && Sr(e, t) ? t : [e], r = n.length, i = Er(n.flatMap((e, t) => wr(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
1388
1391
  return {
1389
1392
  bar: e,
1390
1393
  points: i,
@@ -1394,7 +1397,7 @@ function Sr(e, t = []) {
1394
1397
  }))
1395
1398
  };
1396
1399
  }
1397
- function Cr(e, t) {
1400
+ function Er(e, t) {
1398
1401
  let n = e.length - 1, r = e.map((e, r) => ({
1399
1402
  ...e,
1400
1403
  price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
@@ -1409,7 +1412,7 @@ function Cr(e, t) {
1409
1412
  };
1410
1413
  return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
1411
1414
  }
1412
- function wr(e, t) {
1415
+ function Dr(e, t) {
1413
1416
  let n = e.points;
1414
1417
  if (t <= n[0].at) return n[0].price;
1415
1418
  for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
@@ -1418,8 +1421,8 @@ function wr(e, t) {
1418
1421
  }
1419
1422
  return n[n.length - 1].price;
1420
1423
  }
1421
- var Tr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
1422
- function Er(e, t) {
1424
+ var Or = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
1425
+ function kr(e, t) {
1423
1426
  let n = 0, r = 0;
1424
1427
  for (let i of e.volumeAt) {
1425
1428
  if (t >= i.at) {
@@ -1430,10 +1433,10 @@ function Er(e, t) {
1430
1433
  }
1431
1434
  return n;
1432
1435
  }
1433
- function Dr(e, t) {
1434
- let n = Tr(t);
1436
+ function Ar(e, t) {
1437
+ let n = Or(t);
1435
1438
  if (n >= 1) return { ...e.bar };
1436
- let r = wr(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
1439
+ let r = Dr(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
1437
1440
  for (let t of e.points) {
1438
1441
  if (t.at > n) break;
1439
1442
  i = Math.max(i, t.price), a = Math.min(a, t.price);
@@ -1444,29 +1447,29 @@ function Dr(e, t) {
1444
1447
  high: i,
1445
1448
  low: a,
1446
1449
  close: r,
1447
- volume: Er(e, n)
1450
+ volume: kr(e, n)
1448
1451
  };
1449
1452
  }
1450
- function Or(e, t) {
1451
- let n = Tr(t), r = 0;
1453
+ function jr(e, t) {
1454
+ let n = Or(t), r = 0;
1452
1455
  for (let t of e.points) {
1453
1456
  if (t.at > n) break;
1454
1457
  r = t.at;
1455
1458
  }
1456
1459
  return r;
1457
1460
  }
1458
- function Y(e, t, n) {
1461
+ function q(e, t, n) {
1459
1462
  let r = [], i = e.bar.time;
1460
1463
  for (let a of e.points) {
1461
1464
  if (a.at > n) break;
1462
1465
  i = a.time, a.at > t && r.push([a.price, a.time]);
1463
1466
  }
1464
- let a = wr(e, n);
1467
+ let a = Dr(e, n);
1465
1468
  return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
1466
1469
  }
1467
1470
  //#endregion
1468
1471
  //#region src/replay/replayStep.ts
1469
- var kr = [
1472
+ var Mr = [
1470
1473
  "1m",
1471
1474
  "3m",
1472
1475
  "5m",
@@ -1477,42 +1480,42 @@ var kr = [
1477
1480
  "4h",
1478
1481
  "1d"
1479
1482
  ];
1480
- function Ar(e, t) {
1481
- let n = T(e);
1482
- return n > 0 ? kr.filter((e) => {
1483
- let r = T(e);
1483
+ function Nr(e, t) {
1484
+ let n = w(e);
1485
+ return n > 0 ? Mr.filter((e) => {
1486
+ let r = w(e);
1484
1487
  return r < n && n % r === 0 && t(e);
1485
1488
  }) : [];
1486
1489
  }
1487
- function jr(e, t, n) {
1488
- let r = Ar(t, n);
1490
+ function Pr(e, t, n) {
1491
+ let r = Nr(t, n);
1489
1492
  if (e !== "auto") return r.includes(e) ? e : null;
1490
- let i = T(t);
1491
- return r.find((e) => i / T(e) <= 60) ?? null;
1493
+ let i = w(t);
1494
+ return r.find((e) => i / w(e) <= 60) ?? null;
1492
1495
  }
1493
1496
  //#endregion
1494
1497
  //#region src/Chart.ts
1495
- var Mr = {
1498
+ var Fr = {
1496
1499
  min: 0,
1497
1500
  max: 100
1498
- }, Nr = "exchange", Pr = Nr;
1499
- function Fr(e) {
1500
- if (typeof e == "string" && e !== "exchange" && !v(e)) throw RangeError(`Unknown time zone: ${e}`);
1501
+ }, Ir = "exchange", Lr = Ir;
1502
+ function Rr(e) {
1503
+ if (typeof e == "string" && e !== "exchange" && !y(e)) throw RangeError(`Unknown time zone: ${e}`);
1501
1504
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
1502
1505
  }
1503
- function Ir(e, t) {
1504
- let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : w(e);
1506
+ function zr(e, t) {
1507
+ let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
1505
1508
  return i === void 0 ? e : {
1506
1509
  ...e,
1507
1510
  timeZone: i,
1508
1511
  timezone: i
1509
1512
  };
1510
1513
  }
1511
- var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontalLine", "crossLine"]), Ur = new Set(["verticalLine", "crossLine"]), Wr = class {
1512
- static version = "1.56.0";
1514
+ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontalLine", "crossLine"]), Kr = new Set(["verticalLine", "crossLine"]), qr = class {
1515
+ static version = "1.57.0";
1513
1516
  engine;
1514
1517
  viewport;
1515
- series = new In((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
1518
+ series = new zn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
1516
1519
  themeManager;
1517
1520
  layoutManager;
1518
1521
  pluginManager;
@@ -1528,7 +1531,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1528
1531
  autoScrollOnNewBar = !0;
1529
1532
  displayDataCache = null;
1530
1533
  indicatorsOnDrawn = null;
1531
- reshapeMemo = new ot();
1534
+ reshapeMemo = new ct();
1532
1535
  displayDataStep;
1533
1536
  indicatorUpdateFrom = null;
1534
1537
  resolvedLayoutCache = null;
@@ -1539,7 +1542,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1539
1542
  renderDeferred = !1;
1540
1543
  priceAxisWidth = o;
1541
1544
  measureCtx;
1542
- labelWidths = new nr();
1545
+ labelWidths = new ar();
1543
1546
  containerSizeCache = null;
1544
1547
  containerSizeCacheTime = 0;
1545
1548
  lastEmittedRange = null;
@@ -1554,7 +1557,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1554
1557
  indicatorEdit = null;
1555
1558
  removedDrawingAlerts = /* @__PURE__ */ new Map();
1556
1559
  zoomAreaMode = !1;
1557
- priceAxisAddButton = new et();
1560
+ priceAxisAddButton = new nt();
1558
1561
  displayTz = null;
1559
1562
  timeZoneSetting = null;
1560
1563
  symbolInfo = null;
@@ -1565,7 +1568,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1565
1568
  studyZoneReleaseQueued = !1;
1566
1569
  sessionBreaks;
1567
1570
  sessionShading;
1568
- hostSessionHours = { ...ke };
1571
+ hostSessionHours = { ...je };
1569
1572
  compareRenderer;
1570
1573
  countdownInterval = null;
1571
1574
  pausedFor = {
@@ -1584,7 +1587,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1584
1587
  signalMarkerManager;
1585
1588
  tradeZoneManager;
1586
1589
  measureOverlay;
1587
- selectionBoxOverlay = new ct();
1590
+ selectionBoxOverlay = new ut();
1588
1591
  replayManager;
1589
1592
  replayBarUnsub = null;
1590
1593
  replaySeeking = !1;
@@ -1599,7 +1602,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1599
1602
  replayForming = null;
1600
1603
  replayPhaseUnsub = null;
1601
1604
  undoRedoManager;
1602
- autoSaveScheduler = new kn((e) => this.saveState(e));
1605
+ autoSaveScheduler = new Mn((e) => this.saveState(e));
1603
1606
  animator;
1604
1607
  crosshairTooltip;
1605
1608
  pinnedTooltip;
@@ -1611,14 +1614,14 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1611
1614
  disposed = !1;
1612
1615
  chartTypeOptions = {};
1613
1616
  mainSeriesVisible = !0;
1614
- priceLines = new tt();
1615
- symbolSeries = new ht();
1617
+ priceLines = new rt();
1618
+ symbolSeries = new _t();
1616
1619
  extendedHours = !0;
1617
1620
  replayRestarting = !1;
1618
1621
  requestedSymbols = /* @__PURE__ */ new Set();
1619
1622
  gridRenderer;
1620
1623
  priceAxis;
1621
- leftPriceAxis = new $e();
1624
+ leftPriceAxis = new tt();
1622
1625
  leftScaleRequested = !1;
1623
1626
  leftAxisWidth = o;
1624
1627
  leftViewport = null;
@@ -1651,7 +1654,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1651
1654
  snapshotKey = null;
1652
1655
  historyCheckQueued = !1;
1653
1656
  constructor(e, t) {
1654
- t.timeZone != null && Fr(t.timeZone), this.container = e, this.options = {
1657
+ t.timeZone != null && Rr(t.timeZone), this.container = e, this.options = {
1655
1658
  ...t,
1656
1659
  chartType: t.chartType ?? "candlestick"
1657
1660
  }, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
@@ -1690,15 +1693,15 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1690
1693
  logScale: n.logScale ?? !0,
1691
1694
  timeframes: n.timeframes ?? [],
1692
1695
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
1693
- }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new Vn({
1696
+ }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new Wn({
1694
1697
  oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
1695
1698
  prepend: (e) => this.prependBars(e),
1696
1699
  emit: (e) => this.eventBus.emit("historyLoad", e)
1697
- }), this.themeManager = new Un(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Gn(t), "host", !1), this.layoutManager = new Jn(), this.indicatorEngine = new ze(), this.pluginManager = new ur(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Pe(), zt(this.indicatorEngine), this.indicatorEngine.register(new Se(this.symbolSeries)), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.indicatorEngine.register(new ft(this.symbolSeries)), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.drawingManager = new je(), Rt(this.drawingManager), this.drawingRenderer = new Me(this.drawingManager), this.drawingRenderer.setKeepOut(() => this.legendKeepOut()), this.drawingManager.setRequestRender(() => {
1700
+ }), this.themeManager = new Kn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Jn(t), "host", !1), this.layoutManager = new Zn(), this.indicatorEngine = new Ve(), this.pluginManager = new pr(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ie(), Vt(this.indicatorEngine), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.indicatorEngine.register(new mt(this.symbolSeries)), this.indicatorEngine.register(new Ee(this.symbolSeries)), this.indicatorEngine.register(new De(this.symbolSeries)), this.drawingManager = new Ne(), Bt(this.drawingManager), this.drawingRenderer = new Pe(this.drawingManager), this.drawingRenderer.setKeepOut(() => this.legendKeepOut()), this.drawingManager.setRequestRender(() => {
1698
1701
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
1699
1702
  }), this.drawingManager.setEventCallback((e, t) => {
1700
1703
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
1701
- }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new bt();
1704
+ }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new St();
1702
1705
  let i = "";
1703
1706
  this.undoRedoManager.setOnChange(() => {
1704
1707
  let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
@@ -1711,23 +1714,23 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1711
1714
  primary: e[0] ?? null
1712
1715
  })), this.drawingManager.setForeignHistory((e, t) => {
1713
1716
  e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
1714
- }), this.drawingManager.setDataGetter(() => this.series.bars(), () => this.series.revision()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new vt({
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 bt({
1715
1718
  enabled: this.features.trading,
1716
1719
  contextMenu: { enabled: this.features.tradingContextMenu }
1717
- }), this.tradingRenderer = new yt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
1720
+ }), this.tradingRenderer = new xt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
1718
1721
  this.eventBus.emit(e, t);
1719
- }), this.engine = new nt(e, t.maxPixelRatio);
1722
+ }), this.engine = new it(e, t.maxPixelRatio);
1720
1723
  let a = this.engine.dprManager.getContainerSize();
1721
- if (this.viewport = new xt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
1724
+ 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({
1722
1725
  freePan: t.freePan ?? !0,
1723
1726
  minVisibleBars: t.panLimits?.minVisibleBars ?? 3
1724
1727
  }), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
1725
1728
  if (e.width <= 0 || e.height <= 0) return;
1726
1729
  let t = this.viewport.isAtEnd();
1727
1730
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
1728
- }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Fe(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new $e(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new gt(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new Ee(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setDataSource(() => this.crosshairSeries()), this.crosshairHandler.setCallback((e, t) => {
1731
+ }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Le(), 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 Oe(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setDataSource(() => this.crosshairSeries()), this.crosshairHandler.setCallback((e, t) => {
1729
1732
  if (e !== null && t) {
1730
- let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o = j(n), s = i ? o[e]?.time ?? i.time : void 0;
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 = A(n), s = i ? o[e]?.time ?? i.time : void 0;
1731
1734
  this.chartLegend.setHoverBar(i ?? null, e > 0 ? n[e - 1] ?? null : null), this.features.legend && this.engine.requestRender(r.Hover);
1732
1735
  let c = this.viewport.getState(), l = t.y >= c.chartRect.y && t.y <= c.chartRect.y + c.chartRect.height;
1733
1736
  if (i && l && this.features.crosshairTooltip) {
@@ -1739,7 +1742,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1739
1742
  prevClose: a,
1740
1743
  priceRange: c.priceRange,
1741
1744
  plot: c.chartRect,
1742
- barStepMs: Dt(o),
1745
+ barStepMs: kt(o),
1743
1746
  timeUnit: u(o)
1744
1747
  });
1745
1748
  } else this.crosshairTooltip.hide();
@@ -1755,14 +1758,14 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1755
1758
  let e = this.crosshairHandler.getSyncedSlot();
1756
1759
  e !== null && this.showSyncedBar(e);
1757
1760
  }
1758
- }), this.chartLegend = new be(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
1761
+ }), this.chartLegend = new Se(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
1759
1762
  this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), this.engine.requestRender();
1760
- }), this.watermark = new Tt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new wt(), this.volumeProfile = new Ct(), this.marketProfile = new Ge(), this.depthHeatmap = new Ae(), this.periodLevels = new Ye(), this.pivotMarkers = new Ze(), this.barCountdown = new ge(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new lt(), this.sessionShading = new ut(), this.compareRenderer = new xe(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1763
+ }), this.watermark = new Dt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Et(), this.volumeProfile = new Tt(), this.marketProfile = new qe(), this.depthHeatmap = new Me(), this.periodLevels = new Ze(), this.pivotMarkers = new $e(), this.barCountdown = new ve(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new dt(), this.sessionShading = new ft(), this.compareRenderer = new Ce(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1761
1764
  visible: t.sessionBreaks.visible ?? !0,
1762
1765
  color: t.sessionBreaks.color,
1763
1766
  lineStyle: t.sessionBreaks.lineStyle,
1764
1767
  lineWidth: t.sessionBreaks.lineWidth
1765
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new pe(), this.crosshairTooltip = new De(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Xe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = S(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Xr(t.shapes)), t.font && this.themeManager.setFont(Yr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new He({
1768
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new he(), this.crosshairTooltip = new ke(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Qe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = ae(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape($r(t.shapes)), t.font && this.themeManager.setFont(Qr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new We({
1766
1769
  scrollBars: (e) => {
1767
1770
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1768
1771
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1779,7 +1782,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1779
1782
  },
1780
1783
  fitContent: () => this.fitContent()
1781
1784
  }), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
1782
- this.a11y = new nn(e, {
1785
+ this.a11y = new an(e, {
1783
1786
  symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
1784
1787
  timeframe: () => this.streamTimeframe ?? "",
1785
1788
  chartType: () => this.options.chartType ?? "candlestick",
@@ -1806,8 +1809,8 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1806
1809
  }
1807
1810
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1808
1811
  }
1809
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Oe(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new fe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(At).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
1810
- this.eventBus.emit("alertTriggered", X(e)), this.eventBus.emit("dataUpdate", {
1812
+ }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ae(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new me(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(Mt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
1813
+ this.eventBus.emit("alertTriggered", J(e)), this.eventBus.emit("dataUpdate", {
1811
1814
  kind: "alert",
1812
1815
  alert: "triggered",
1813
1816
  alertId: e.id,
@@ -1815,14 +1818,14 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1815
1818
  message: e.message
1816
1819
  });
1817
1820
  }), this.alertManager.on("added", (e) => {
1818
- this.eventBus.emit("alertAdd", X(e));
1821
+ this.eventBus.emit("alertAdd", J(e));
1819
1822
  }), this.alertManager.on("removed", (e) => {
1820
1823
  this.eventBus.emit("alertRemove", { id: e });
1821
1824
  }), this.alertManager.on("expired", (e) => {
1822
- this.eventBus.emit("alertExpired", X(e));
1825
+ this.eventBus.emit("alertExpired", J(e));
1823
1826
  }), this.alertManager.on("updated", (e) => {
1824
- this.eventBus.emit("alertUpdate", X(e));
1825
- }), this.signalMarkerManager = new dt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
1827
+ this.eventBus.emit("alertUpdate", J(e));
1828
+ }), this.signalMarkerManager = new pt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
1826
1829
  this.eventBus.emit("signalMarkerAdd", {
1827
1830
  id: e.id,
1828
1831
  source: e.source,
@@ -1830,14 +1833,14 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1830
1833
  });
1831
1834
  }), this.signalMarkerManager.on("removed", (e) => {
1832
1835
  this.eventBus.emit("signalMarkerRemove", { id: e });
1833
- }), this.tradeZoneManager = new _t(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
1836
+ }), this.tradeZoneManager = new yt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
1834
1837
  this.eventBus.emit("tradeZoneAdd", {
1835
1838
  id: e.id,
1836
1839
  direction: e.direction
1837
1840
  });
1838
1841
  }), this.tradeZoneManager.on("removed", (e) => {
1839
1842
  this.eventBus.emit("tradeZoneRemove", { id: e });
1840
- }), this.replayManager = new it(), this.replayManager.on("complete", () => {
1843
+ }), this.replayManager = new ot(), this.replayManager.on("complete", () => {
1841
1844
  let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
1842
1845
  t && this.eventBus.emit("replayComplete", {
1843
1846
  barIndex: e,
@@ -1845,9 +1848,9 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1845
1848
  });
1846
1849
  }), this.replayManager.on("stateChange", (e) => {
1847
1850
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
1848
- }), this.measureOverlay = new Ke(), this.interactionManager = new Be(e), this.features.panning) {
1849
- let e = new rr();
1850
- this.interactionManager.setPanHandler(new qe((t, n) => {
1851
+ }), this.measureOverlay = new Je(), this.interactionManager = new He(e), this.features.panning) {
1852
+ let e = new or();
1853
+ this.interactionManager.setPanHandler(new Ye((t, n) => {
1851
1854
  t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1852
1855
  }, () => e.reset()));
1853
1856
  }
@@ -1859,10 +1862,10 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1859
1862
  scales: !this.indicatorEngine.hasLeftScaleOverlays()
1860
1863
  }
1861
1864
  })), this.features.zooming) {
1862
- this.interactionManager.setZoomHandler(new Et((e, t) => {
1865
+ this.interactionManager.setZoomHandler(new Ot((e, t) => {
1863
1866
  this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
1864
1867
  }));
1865
- let e = new he((e) => {
1868
+ let e = new _e((e) => {
1866
1869
  this.holdPriceScale(), this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1867
1870
  }, (e) => {
1868
1871
  let t = this.viewport.getState().chartRect.width;
@@ -1882,7 +1885,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1882
1885
  y: t.y
1883
1886
  });
1884
1887
  })), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.priceAxisAddButton.setEnabled(this.features.priceAxisAddButton && this.features.crosshair), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
1885
- let t = Jt(e.y, this.viewport.getState());
1888
+ let t = Xt(e.y, this.viewport.getState());
1886
1889
  Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
1887
1890
  price: t,
1888
1891
  x: e.x,
@@ -1892,10 +1895,10 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1892
1895
  ...this.viewport.getState(),
1893
1896
  data: this.getDisplayData()
1894
1897
  })), this.features.alerts) {
1895
- let e = new de(this.alertManager, () => this.viewport.getState());
1898
+ let e = new pe(this.alertManager, () => this.viewport.getState());
1896
1899
  this.interactionManager.setAlertDragHandler(e);
1897
1900
  }
1898
- let o = new Je();
1901
+ let o = new Xe();
1899
1902
  o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
1900
1903
  let t = this.getDisplayData();
1901
1904
  if (t.length === 0) return;
@@ -1919,7 +1922,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1919
1922
  x: e.x,
1920
1923
  y: e.y
1921
1924
  }), t.length === 0) return;
1922
- let r = qt(e.x, this.viewport.getState());
1925
+ let r = Yt(e.x, this.viewport.getState());
1923
1926
  r < 0 || r >= t.length || this.eventBus.emit("barClick", {
1924
1927
  bar: t[r],
1925
1928
  barIndex: r,
@@ -1962,7 +1965,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
1962
1965
  end: () => {
1963
1966
  let e = this.selectionBoxOverlay.end();
1964
1967
  if (e && this.zoomAreaMode) {
1965
- if (e.x1 - e.x0 < Vr) return;
1968
+ if (e.x1 - e.x0 < Wr) return;
1966
1969
  this.zoomToBox(e), this.setZoomAreaMode(!1);
1967
1970
  return;
1968
1971
  }
@@ -2006,7 +2009,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2006
2009
  loadDuringReplay(e) {
2007
2010
  this.snapshotKey = null, this.history.reset(), this.alertManager.clearLastValues();
2008
2011
  let t = e[e.length - 1];
2009
- t && B(t) && this.alertManager.seedLastValue("price", t.close), this.replaySession && (this.replaySession.price = null), this.series.load(e);
2012
+ t && R(t) && this.alertManager.seedLastValue("price", t.close), this.replaySession && (this.replaySession.price = null), this.series.load(e);
2010
2013
  }
2011
2014
  prependBars(e) {
2012
2015
  if (this.replaySession) return this.series.prepend(e).taken;
@@ -2014,7 +2017,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2014
2017
  if (i === 0) return a;
2015
2018
  let o = this.series.bars();
2016
2019
  if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.reshapeMemo.clear(), this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), r !== void 0) {
2017
- let e = Math.round(P(r, this.getDisplayData()));
2020
+ let e = Math.round(N(r, this.getDisplayData()));
2018
2021
  this.viewport.prependBars(e - n);
2019
2022
  }
2020
2023
  return this.updateViewportAndRender(), a;
@@ -2042,17 +2045,17 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2042
2045
  }
2043
2046
  checkHistory() {
2044
2047
  this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
2045
- if (this.historyCheckQueued = !1, !this.replayPages() || !this.history.hasLoader() || R(this.options.chartType)) return;
2048
+ if (this.historyCheckQueued = !1, !this.replayPages() || !this.history.hasLoader() || L(this.options.chartType)) return;
2046
2049
  let { visibleRange: e, chartRect: t } = this.viewport.getState();
2047
2050
  if (t.width <= 0) return;
2048
2051
  let { from: n, to: r } = e;
2049
- this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Br, r - n));
2052
+ this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Ur, r - n));
2050
2053
  }));
2051
2054
  }
2052
2055
  useStreamHistory(e, t, n = !0) {
2053
2056
  if (this.hostHistoryLoader) return;
2054
- let r = F(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
2055
- if (!i || a === null || le(a) !== null) {
2057
+ let r = P(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
2058
+ if (!i || a === null || de(a) !== null) {
2056
2059
  this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
2057
2060
  return;
2058
2061
  }
@@ -2060,7 +2063,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2060
2063
  this.history.setLoader((e, t) => i.call(r, o, a, e, t), t), this.historyFromStream = !0, n && this.checkHistory();
2061
2064
  }
2062
2065
  appendBar(e) {
2063
- if (!B(e)) return;
2066
+ if (!R(e)) return;
2064
2067
  let t = this.series.append(e);
2065
2068
  if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
2066
2069
  this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
@@ -2070,7 +2073,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2070
2073
  this.crosshairHandler.setData(i), this.displayDataCache = null, this.recalcIndicatorsFrom(i, i.length - 2), this.currentPriceLine.setPrice(e.close, i[i.length - 2]?.close), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
2071
2074
  }
2072
2075
  appendBars(e) {
2073
- if (e = e.filter(B), e.length === 0) return;
2076
+ if (e = e.filter(R), e.length === 0) return;
2074
2077
  let t = e[e.length - 1].close, n = this.series.appendMany(e);
2075
2078
  if (n.refiltered && (this.displayDataCache = null), n.shown === 0) {
2076
2079
  this.takeLivePrice(t), n.aside || this.scheduleRender();
@@ -2082,7 +2085,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2082
2085
  this.recalcIndicatorsFrom(a, i - 1), this.crosshairHandler.setData(a), this.currentPriceLine.setPrice(t, a[a.length - 2]?.close), this.updateViewportAndRender(r), a.length !== i && this.emitBars(a.length), this.followLivePrice(t);
2083
2086
  }
2084
2087
  updateLastBar(e) {
2085
- if (!B(e)) return;
2088
+ if (!R(e)) return;
2086
2089
  let t = this.series.updateLast(e);
2087
2090
  if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
2088
2091
  this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
@@ -2104,7 +2107,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2104
2107
  this.recalcIndicatorsFrom(n, n.length - 1), this.followLivePrice(e.price), this.scheduleRender();
2105
2108
  }
2106
2109
  updateBar(e) {
2107
- if (!B(e)) return !1;
2110
+ if (!R(e)) return !1;
2108
2111
  let t = this.series.replace(e);
2109
2112
  return t.to === "none" ? !1 : (t.to === "shown" && t.changed && this.showCorrection(t.index), !0);
2110
2113
  }
@@ -2138,22 +2141,22 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2138
2141
  }
2139
2142
  fitFewColumns() {
2140
2143
  let e = this.options.chartType;
2141
- if (!R(e) || this.pluginManager.getChartType(e)) return;
2144
+ if (!L(e) || this.pluginManager.getChartType(e)) return;
2142
2145
  let t = this.getDisplayData().length, { chartRect: n, barWidth: r, barSpacing: i } = this.viewport.getState(), a = n.width / (r + i);
2143
2146
  t > 0 && a > t + this.viewport.getRightMargin() && this.fitContent();
2144
2147
  }
2145
2148
  applyTimeSpacing() {
2146
- let e = !this.tickStream && !R(this.options.chartType);
2149
+ let e = !this.tickStream && !L(this.options.chartType);
2147
2150
  this.timeAxis.setTimesPastData(e), this.crosshairHandler.setTimesPastData(e);
2148
2151
  }
2149
2152
  setChartTypeOptions(e) {
2150
2153
  this.chartTypeOptions = {
2151
2154
  ...this.chartTypeOptions,
2152
- ...S(e)
2155
+ ...ae(e)
2153
2156
  }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.fitFewColumns(), this.a11y?.refresh(!0), this.markStateChanged();
2154
2157
  }
2155
2158
  getChartTypeOptions() {
2156
- return S(this.chartTypeOptions);
2159
+ return ae(this.chartTypeOptions);
2157
2160
  }
2158
2161
  setExtendedHours(e) {
2159
2162
  e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
@@ -2162,7 +2165,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2162
2165
  return this.extendedHours;
2163
2166
  }
2164
2167
  sessionKeep(e) {
2165
- return this.extendedHours ? null : Zt(this.symbolInfo, e);
2168
+ return this.extendedHours ? null : $t(this.symbolInfo, e);
2166
2169
  }
2167
2170
  reapplyExtendedHours() {
2168
2171
  if (!this.series.refilter()) return;
@@ -2173,7 +2176,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2173
2176
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
2174
2177
  }
2175
2178
  setShapes(e) {
2176
- let t = Xr(e);
2179
+ let t = $r(e);
2177
2180
  t.tagRadius !== void 0 && (this.themeManager.setShape({
2178
2181
  ...this.themeManager.getTheme().shape,
2179
2182
  ...t
@@ -2185,7 +2188,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2185
2188
  setFont(e) {
2186
2189
  if (e === null) this.themeManager.setFont(null);
2187
2190
  else {
2188
- let t = Yr(e);
2191
+ let t = Qr(e);
2189
2192
  if (Object.keys(t).length === 0) return;
2190
2193
  this.themeManager.setFont(t);
2191
2194
  }
@@ -2236,7 +2239,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2236
2239
  setSymbolSeries(e, t) {
2237
2240
  e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
2238
2241
  let n = this.indicatorBars(), r = !1;
2239
- 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);
2242
+ for (let t of this.indicatorEngine.getActiveIndicators()) !O.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
2240
2243
  r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
2241
2244
  }
2242
2245
  forgetUnreadSymbols() {
@@ -2250,20 +2253,20 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2250
2253
  let e = /* @__PURE__ */ new Set();
2251
2254
  for (let t of this.indicatorEngine.getActiveIndicators()) {
2252
2255
  let n = t.params.symbol;
2253
- k.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
2256
+ O.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
2254
2257
  }
2255
2258
  return [...e];
2256
2259
  }
2257
2260
  requestMissingSymbols(e) {
2258
2261
  this.forgetUnreadSymbols();
2259
- let t = this.indicatorEngine.getIndicatorConfig(e), n = t && k.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
2262
+ let t = this.indicatorEngine.getIndicatorConfig(e), n = t && O.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
2260
2263
  !n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
2261
2264
  }
2262
2265
  updateIndicator(e, t) {
2263
2266
  this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
2264
2267
  }
2265
2268
  updateIndicatorNow(e, t) {
2266
- let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? N(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
2269
+ let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? M(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
2267
2270
  this.indicatorEngine.updateIndicator(e, t, this.indicatorBars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2268
2271
  instanceId: e,
2269
2272
  change: "params"
@@ -2281,7 +2284,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2281
2284
  paneFor(e, t, n, r) {
2282
2285
  if (n) return this.paneHostOf(n, r);
2283
2286
  if (e.placement !== "overlay") return null;
2284
- let i = N(e), a = i ? x(t[i]) : null;
2287
+ let i = M(e), a = i ? x(t[i]) : null;
2285
2288
  return a ? this.paneHostOf(a.instanceId, r) : null;
2286
2289
  }
2287
2290
  paneHostOf(e, t) {
@@ -2327,8 +2330,8 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2327
2330
  return {
2328
2331
  ...e,
2329
2332
  priceRange: {
2330
- min: t.min - n * Lr,
2331
- max: t.max + n * Lr
2333
+ min: t.min - n * Br,
2334
+ max: t.max + n * Br
2332
2335
  },
2333
2336
  logScale: !1,
2334
2337
  scaleMode: "regular",
@@ -2381,7 +2384,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2381
2384
  this.indicatorEngine.setStyleDefaults(e, null);
2382
2385
  return;
2383
2386
  }
2384
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ie(n);
2387
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : oe(n);
2385
2388
  this.indicatorEngine.setStyleDefaults(e, {
2386
2389
  ...r,
2387
2390
  ...i ? { plots: i } : {}
@@ -2389,7 +2392,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2389
2392
  }
2390
2393
  setPaneStyle(e, t) {
2391
2394
  let n = this.paneOf(e);
2392
- this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? ae(t) : null));
2395
+ this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? se(t) : null));
2393
2396
  }
2394
2397
  setPaneStyleNow(e, t) {
2395
2398
  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());
@@ -2408,8 +2411,8 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2408
2411
  return this.pluginManager;
2409
2412
  }
2410
2413
  static indicators() {
2411
- let e = new ze();
2412
- return zt(e), e.getAvailableIndicators();
2414
+ let e = new Ve();
2415
+ return Vt(e), e.getAvailableIndicators();
2413
2416
  }
2414
2417
  setPanelPosition(e, t) {
2415
2418
  this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
@@ -2432,7 +2435,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2432
2435
  paneMoveHost(e, t) {
2433
2436
  let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
2434
2437
  if (!n || !r) return;
2435
- let i = N(r);
2438
+ let i = M(r);
2436
2439
  if (r.placement === "overlay" && i && x(n.params[i])) return;
2437
2440
  if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
2438
2441
  if (t === "new") {
@@ -2568,12 +2571,12 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2568
2571
  }), n;
2569
2572
  }
2570
2573
  isTimeAligned() {
2571
- return R(this.options.chartType) ? !1 : this.getDisplayData().length === this.series.length();
2574
+ return L(this.options.chartType) ? !1 : this.getDisplayData().length === this.series.length();
2572
2575
  }
2573
2576
  roundPrice(e) {
2574
2577
  if (!Number.isFinite(e)) return e;
2575
2578
  let t = this.stepAt(e);
2576
- if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(ce(t)));
2579
+ if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(ue(t)));
2577
2580
  let { min: n, max: r } = this.viewport.getState().priceRange;
2578
2581
  return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
2579
2582
  }
@@ -2583,7 +2586,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2583
2586
  }
2584
2587
  stepAt(e) {
2585
2588
  let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
2586
- return t !== void 0 && t > 0 ? t : this.marketConfig ? ne(e, this.marketConfig) : void 0;
2589
+ return t !== void 0 && t > 0 ? t : this.marketConfig ? re(e, this.marketConfig) : void 0;
2587
2590
  }
2588
2591
  getPriceStep(e) {
2589
2592
  let t = this.stepAt(e ?? this.lastClose());
@@ -2598,7 +2601,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2598
2601
  return this.priceFormatter;
2599
2602
  }
2600
2603
  applyPriceFormat(e) {
2601
- this.priceFormatter = te(e), this.priceUnit = e && typeof e != "function" ? g(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
2604
+ this.priceFormatter = ne(e), this.priceUnit = e && typeof e != "function" ? _(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
2602
2605
  }
2603
2606
  setTimeFormatter(e) {
2604
2607
  this.applyTimeFormatter(e), this.engine.requestRender();
@@ -2609,7 +2612,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2609
2612
  formatPrice(e) {
2610
2613
  if (this.priceFormatter) return this.priceFormatter(e);
2611
2614
  let { min: t, max: n } = this.viewport.getState().priceRange;
2612
- return h(e, this.marketPricePrecision ?? c(t, n), this.numberLocale);
2615
+ return g(e, this.marketPricePrecision ?? c(t, n), this.numberLocale);
2613
2616
  }
2614
2617
  setDrawingTool(e) {
2615
2618
  this.features.drawings && (e && this.features.drawingTools.length > 0 && !this.features.drawingTools.includes(e) || (e && this.setZoomAreaMode(!1), this.drawingManager.setActiveTool(e)));
@@ -2657,7 +2660,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2657
2660
  }
2658
2661
  autoFib() {
2659
2662
  if (!this.features.drawings) return null;
2660
- let e = this.getDisplayData(), t = this.viewport.getState(), n = Ot(e, t.visibleRange.from, t.visibleRange.to);
2663
+ let e = this.getDisplayData(), t = this.viewport.getState(), n = At(e, t.visibleRange.from, t.visibleRange.to);
2661
2664
  return n ? this.addDrawing({
2662
2665
  type: "fibRetracement",
2663
2666
  anchors: [n[0], n[1]]
@@ -2735,7 +2738,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2735
2738
  recordUndo(e) {
2736
2739
  if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
2737
2740
  let t = performance.now(), n = this.undoRedoManager.last();
2738
- if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < zr) {
2741
+ if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Hr) {
2739
2742
  this.undoRedoManager.replaceLast({
2740
2743
  ...n,
2741
2744
  custom: {
@@ -2782,7 +2785,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2782
2785
  x: t.x,
2783
2786
  y: t.y
2784
2787
  };
2785
- if ((e === "plot" || e === "priceAxis") && (r.price = Jt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = I(t.x, n)), e === "pane") {
2788
+ if ((e === "plot" || e === "priceAxis") && (r.price = Xt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = F(t.x, n)), e === "pane") {
2786
2789
  let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
2787
2790
  e && (r.pane = e.instanceId);
2788
2791
  }
@@ -2808,7 +2811,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2808
2811
  ...this.viewport.getState(),
2809
2812
  data: this.getDisplayData()
2810
2813
  };
2811
- this.setVisibleRange(I(e.x0, t), I(e.x1, t));
2814
+ this.setVisibleRange(F(e.x0, t), F(e.x1, t));
2812
2815
  }
2813
2816
  lockAllDrawings() {
2814
2817
  this.drawingManager.lockAllDrawings();
@@ -2853,7 +2856,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2853
2856
  for (let e of this.indicatorEngine.getActiveIndicators()) {
2854
2857
  let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
2855
2858
  if (!t) continue;
2856
- let r = cn(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2859
+ let r = un(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2857
2860
  key: e,
2858
2861
  title: e
2859
2862
  }));
@@ -2877,11 +2880,11 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2877
2880
  }
2878
2881
  getExportText(e = "csv", t = {}) {
2879
2882
  let { bars: n, columns: r } = this.getExportData(t);
2880
- return e === "json" ? D.toJSON(n, r) : D.toCSV(n, r);
2883
+ return e === "json" ? E.toJSON(n, r) : E.toCSV(n, r);
2881
2884
  }
2882
2885
  download(e, t, n) {
2883
2886
  let r = this.getExportText(e, n);
2884
- e === "json" ? D.download(r, t ?? "chart-data.json", "application/json") : D.download(r, t ?? "chart-data.csv", "text/csv");
2887
+ e === "json" ? E.download(r, t ?? "chart-data.json", "application/json") : E.download(r, t ?? "chart-data.csv", "text/csv");
2885
2888
  }
2886
2889
  setAutoSave(e, t = 5e3) {
2887
2890
  this.autoSaveScheduler.enable(e, t);
@@ -2943,7 +2946,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
2943
2946
  this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
2944
2947
  }
2945
2948
  updateIndicatorStyleNow(e, t) {
2946
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ie(n);
2949
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : oe(n);
2947
2950
  this.indicatorEngine.updateIndicatorStyle(e, {
2948
2951
  ...r,
2949
2952
  ...i ? { plots: i } : {}
@@ -3063,12 +3066,12 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3063
3066
  this.features.trading && this.tradingManager.setConfig(e);
3064
3067
  }
3065
3068
  async connect(e) {
3066
- if (!M(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
3067
- this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new mt(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (t) => {
3069
+ if (!j(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
3070
+ 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) => {
3068
3071
  let n = this.streamSeriesKey(e.adapter);
3069
3072
  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);
3070
3073
  }), this.streamManager.on("barClose", (e) => {
3071
- if (!B(e)) return;
3074
+ if (!R(e)) return;
3072
3075
  let t = this.series.placeStreamBar(e);
3073
3076
  if (t.refiltered && (this.displayDataCache = null), t.to === "none") {
3074
3077
  this.updateBar(e);
@@ -3080,7 +3083,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3080
3083
  }), this.streamManager.on("barCorrection", (e) => {
3081
3084
  this.updateBar(e);
3082
3085
  }), this.streamManager.on("barUpdate", (e) => {
3083
- if (!B(e)) return;
3086
+ if (!R(e)) return;
3084
3087
  let t = this.series.placeStreamBar(e);
3085
3088
  if (t.refiltered && (this.displayDataCache = null), t.to === "none" || (this.replaySession || this.currentPriceLine.setPrice(e.close), this.replaySession)) return;
3086
3089
  let n = t.before;
@@ -3120,18 +3123,18 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3120
3123
  }), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
3121
3124
  let t = this.streamManager;
3122
3125
  if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
3123
- let n = T(e.timeframe);
3126
+ let n = w(e.timeframe);
3124
3127
  this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
3125
3128
  this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
3126
3129
  }, 1e3);
3127
3130
  }
3128
3131
  streamSeriesKey(e) {
3129
- let t = F(e), n = this.streamTimeframe, r = t instanceof at && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
3132
+ let t = P(e), n = this.streamTimeframe, r = t instanceof st && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
3130
3133
  return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
3131
3134
  }
3132
3135
  setStreamTarget(e, t) {
3133
3136
  let n = this.announcedSymbol;
3134
- this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = le(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
3137
+ this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = de(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
3135
3138
  symbol: e,
3136
3139
  previous: n
3137
3140
  })), this.useTimeframe(t);
@@ -3149,8 +3152,8 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3149
3152
  async switchStream(e, t) {
3150
3153
  if (!this.streamManager) return;
3151
3154
  let n = this.streamAdapter;
3152
- if (n && !M(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
3153
- 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);
3155
+ if (n && !j(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
3156
+ this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(w(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
3154
3157
  }
3155
3158
  isIndicatorAllowed(e) {
3156
3159
  let t = this.features.indicatorIds;
@@ -3169,7 +3172,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3169
3172
  }
3170
3173
  connectExecution(e, t = {}) {
3171
3174
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
3172
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = pr(e, {
3175
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = gr(e, {
3173
3176
  onIntent: (e, t) => {
3174
3177
  let n = (e) => t(e.payload);
3175
3178
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -3302,18 +3305,18 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3302
3305
  goToTime(e) {
3303
3306
  let t = this.getDisplayData();
3304
3307
  if (t.length === 0 || !Number.isFinite(e)) return -1;
3305
- let n = Math.max(0, Math.min(t.length - 1, Math.floor(P(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
3308
+ let n = Math.max(0, Math.min(t.length - 1, Math.floor(N(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
3306
3309
  return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
3307
3310
  }
3308
3311
  setVisibleRangePreset(e) {
3309
3312
  let t = this.getDisplayData();
3310
3313
  if (t.length === 0) return;
3311
- let n = t.length - 1, r = u(t), i = It(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
3314
+ let n = t.length - 1, r = u(t), i = Rt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
3312
3315
  if (a === null || a < t[0].time) {
3313
3316
  this.fitContent();
3314
3317
  return;
3315
3318
  }
3316
- let o = P(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
3319
+ let o = N(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
3317
3320
  this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
3318
3321
  }
3319
3322
  scrollToEnd() {
@@ -3338,7 +3341,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3338
3341
  setVisibleRange(e, t) {
3339
3342
  let n = this.getDisplayData();
3340
3343
  if (n.length === 0) return;
3341
- let r = P(Math.min(e, t), n), i = P(Math.max(e, t), n);
3344
+ let r = N(Math.min(e, t), n), i = N(Math.max(e, t), n);
3342
3345
  this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
3343
3346
  }
3344
3347
  suspend() {
@@ -3444,7 +3447,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3444
3447
  this.applyStyle(e, t.layer ?? "host", !0);
3445
3448
  }
3446
3449
  setOverrides(e, t = {}) {
3447
- let n = t.layer ?? "host", { overrides: r, rejected: i } = re(e);
3450
+ let n = t.layer ?? "host", { overrides: r, rejected: i } = ie(e);
3448
3451
  i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
3449
3452
  let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
3450
3453
  this.themeManager.setOverrides(a, n) && this.styleChanged(n);
@@ -3463,7 +3466,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3463
3466
  return this.themeManager.getStyleValue(e);
3464
3467
  }
3465
3468
  applyStyle(e, t, n) {
3466
- let { overrides: r, rejected: i } = re(e);
3469
+ let { overrides: r, rejected: i } = ie(e);
3467
3470
  i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
3468
3471
  }
3469
3472
  styleChanged(e) {
@@ -3496,7 +3499,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3496
3499
  e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
3497
3500
  }
3498
3501
  setCrosshairTime(e) {
3499
- let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(P(e, t));
3502
+ let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(N(e, t));
3500
3503
  n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.showSyncedBar(n), this.engine.requestRender(r.Hover));
3501
3504
  }
3502
3505
  showSyncedBar(e) {
@@ -3506,7 +3509,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3506
3509
  }
3507
3510
  let t = this.crosshairSeries(), n = e >= 0 && e < t.length ? t[e] : void 0, r = n && e > 0 ? t[e - 1] : void 0;
3508
3511
  this.crosshairHandler.getPosition() || this.chartLegend.setHoverBar(n ?? null, r ?? null);
3509
- let i = n ? j(t)[e]?.time ?? n.time : void 0;
3512
+ let i = n ? A(t)[e]?.time ?? n.time : void 0;
3510
3513
  this.eventBus.emit("crosshairSync", {
3511
3514
  barIndex: e,
3512
3515
  ...n ? { bar: n } : {},
@@ -3585,7 +3588,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3585
3588
  return this.periodLevels.getPeriod();
3586
3589
  }
3587
3590
  setTimeZone(e) {
3588
- Fr(e), this.timeZoneSetting = e, this.applyTimeZone();
3591
+ Rr(e), this.timeZoneSetting = e, this.applyTimeZone();
3589
3592
  }
3590
3593
  getTimeZone() {
3591
3594
  return this.timeZoneSetting;
@@ -3594,7 +3597,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3594
3597
  return this.displayTz;
3595
3598
  }
3596
3599
  getExchangeTimeZone() {
3597
- return [w(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && v(e)) ?? null;
3600
+ return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && y(e)) ?? null;
3598
3601
  }
3599
3602
  setTimezone(e) {
3600
3603
  this.setTimeZone(e);
@@ -3621,7 +3624,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3621
3624
  this.indicatorEngine.setExchangeTimeZone(e, t.length > 0 ? t : void 0) && t.length > 0 && this.announceIndicatorUpdate(0);
3622
3625
  }
3623
3626
  holdStudyZone() {
3624
- this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), st);
3627
+ this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), lt);
3625
3628
  }
3626
3629
  endStudyZoneWait() {
3627
3630
  this.studyZoneReleaseQueued = !1, this.studyZoneTimer !== null && (clearTimeout(this.studyZoneTimer), this.studyZoneTimer = null);
@@ -3636,7 +3639,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3636
3639
  }
3637
3640
  spokenBarTime(e) {
3638
3641
  let t = this.getDisplayData(), n = e * u(t), r = this.numberLocale || "en-US";
3639
- return d(t) === !0 ? ue(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : ue(r, {
3642
+ return d(t) === !0 ? fe(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : fe(r, {
3640
3643
  dateStyle: "medium",
3641
3644
  timeStyle: "short"
3642
3645
  }, this.displayTz)(n);
@@ -3649,19 +3652,19 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3649
3652
  this.studyZoneHeld = !1, this.endStudyZoneWait(), this.useSymbolInfo(e);
3650
3653
  }
3651
3654
  useSymbolInfo(e) {
3652
- let t = e && this.symbolInfo?.symbol === e.symbol ? w(this.symbolInfo) : void 0;
3653
- this.symbolInfo = e ? Ir({
3655
+ let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
3656
+ this.symbolInfo = e ? zr({
3654
3657
  ...e,
3655
3658
  sessions: e.sessions?.map((e) => ({ ...e }))
3656
3659
  }, 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);
3657
3660
  let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
3658
- let t = C(e.start), n = C(e.end);
3661
+ let t = S(e.start), n = S(e.end);
3659
3662
  return t === null || n === null ? [] : [{
3660
3663
  startMinute: t,
3661
3664
  endMinute: n
3662
3665
  }];
3663
- }), i = w(this.symbolInfo);
3664
- this.sessionShading.replaceConfig(n.length > 0 && i && v(i) ? {
3666
+ }), i = C(this.symbolInfo);
3667
+ this.sessionShading.replaceConfig(n.length > 0 && i && y(i) ? {
3665
3668
  timeZone: i,
3666
3669
  windows: n,
3667
3670
  startMinute: n[0].startMinute,
@@ -3675,15 +3678,15 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3675
3678
  if (!e || typeof e != "object") return;
3676
3679
  let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
3677
3680
  if (!n(e.symbol)) return;
3678
- let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Ir({
3681
+ let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = zr({
3679
3682
  ...r,
3680
3683
  ...e,
3681
3684
  symbol: e.symbol || r?.symbol || t
3682
- }, w(r));
3685
+ }, C(r));
3683
3686
  r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
3684
3687
  }
3685
3688
  resolveStreamSymbol(e, t) {
3686
- let n = F(e), r = n.resolveSymbol?.bind(n);
3689
+ let n = P(e), r = n.resolveSymbol?.bind(n);
3687
3690
  if (this.symbolInfo && this.symbolInfo.symbol !== t ? (r ? this.holdStudyZone() : this.studyZoneHeld = !1, this.useSymbolInfo(null)) : r && this.studyZoneHeld && this.holdStudyZone(), !r) {
3688
3691
  this.releaseStudyZone();
3689
3692
  return;
@@ -3714,7 +3717,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3714
3717
  return this.sessionShading.isVisible();
3715
3718
  }
3716
3719
  setSessionShadingConfig(e) {
3717
- this.hostSessionHours = Nt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
3720
+ this.hostSessionHours = Ft(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
3718
3721
  }
3719
3722
  setTooltipVisible(e) {
3720
3723
  e || this.crosshairTooltip.hide();
@@ -3736,11 +3739,11 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3736
3739
  return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
3737
3740
  }
3738
3741
  async takeGpu(e, t, n) {
3739
- let { gpu: r, reason: i } = await Mt(e);
3740
- return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? kt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
3742
+ let { gpu: r, reason: i } = await Pt(e);
3743
+ return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? jt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
3741
3744
  }
3742
3745
  waitForGpu(e) {
3743
- this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Kt(e) : null;
3746
+ this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Jt(e) : null;
3744
3747
  }
3745
3748
  getRenderer() {
3746
3749
  return this.engine.getGpu() ? "webgl" : "canvas";
@@ -3762,7 +3765,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3762
3765
  this.engine.getGpu() && this.engine.renderNow();
3763
3766
  }
3764
3767
  screenshot(e) {
3765
- this.features.screenshot && (this.freshFrame(), A.download(this.container, e, this.themeManager.getTheme().background));
3768
+ this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
3766
3769
  }
3767
3770
  async copyScreenshot() {
3768
3771
  if (!this.features.screenshot) return !1;
@@ -3770,7 +3773,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3770
3773
  if (!t?.write || !e) return !1;
3771
3774
  try {
3772
3775
  this.freshFrame();
3773
- let n = A.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
3776
+ let n = k.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
3774
3777
  if (!e) throw Error("No chart image to copy");
3775
3778
  return e;
3776
3779
  });
@@ -3788,10 +3791,10 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3788
3791
  }
3789
3792
  }
3790
3793
  screenshotDataURL() {
3791
- return this.features.screenshot ? (this.freshFrame(), A.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
3794
+ return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
3792
3795
  }
3793
3796
  async screenshotBlob() {
3794
- return this.features.screenshot ? (this.freshFrame(), A.toBlob(this.container, this.themeManager.getTheme().background)) : null;
3797
+ return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
3795
3798
  }
3796
3799
  addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
3797
3800
  if (!this.features.alerts) return null;
@@ -3918,24 +3921,24 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3918
3921
  let t = this.replaySession ? this.replayOffset : 0;
3919
3922
  if (!this.replaySession) {
3920
3923
  if (this.series.length() === 0) return;
3921
- this.series.beginReplay(), this.replaySession = ii(this.currentSymbol);
3924
+ this.series.beginReplay(), this.replaySession = si(this.currentSymbol);
3922
3925
  }
3923
3926
  let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
3924
3927
  c.animate = c.animate === !0;
3925
3928
  let l = this.series.inHoursShown(this.series.liveBars()), u = t > 0 && i === void 0 && a !== !1, d = c.startIndex;
3926
- i !== void 0 && d === void 0 ? d = Z(l, i) : u && d !== void 0 && (d += t);
3929
+ i !== void 0 && d === void 0 ? d = Y(l, i) : u && d !== void 0 && (d += t);
3927
3930
  let f = u ? t : a && d !== void 0 && d > 0 ? Math.min(Math.floor(d), l.length - 1) : 0, p = f > 0 ? l.slice(f) : l;
3928
3931
  d !== void 0 && (c.startIndex = d - f), n.windowTime = f > 0 ? p[0]?.time ?? null : null, n.steps = r ?? null, n.stepsSymbol = this.currentSymbol, n.until = null, n.animate = c.animate, n.step = c.animate ? s ?? null : null, this.replayRevealMarks = o !== !1, this.useReplayLoader(n, !0);
3929
3932
  let m = r ? this.replayStepsOver(n, p, !0) : null;
3930
3933
  this.options.autoScale = !0, this.buildReplay(p, m, f);
3931
3934
  let h = this.replayStepsSeries;
3932
- h && c.startIndex !== void 0 && (c.startIndex = hi(h, p, c.startIndex));
3935
+ h && c.startIndex !== void 0 && (c.startIndex = gi(h, p, c.startIndex));
3933
3936
  let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
3934
3937
  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);
3935
3938
  }
3936
3939
  buildReplay(e, t, n) {
3937
3940
  let r = this.replaySession?.animate === !0, i = r ? null : t;
3938
- this.replayPieces = r && t ? vi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
3941
+ this.replayPieces = r && t ? yi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
3939
3942
  let a = this.replayRestarting;
3940
3943
  this.replayRestarting = !0;
3941
3944
  try {
@@ -3949,7 +3952,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3949
3952
  let n = t, a = e[t];
3950
3953
  if (i) {
3951
3954
  let r = i[t];
3952
- n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? bi(c, r) : gi(e[n], i, t), a = _i(i, e, t, n) ? e[n] : c;
3955
+ n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? xi(c, r) : _i(e[n], i, t), a = vi(i, e, t, n) ? e[n] : c;
3953
3956
  }
3954
3957
  let u = this.replayForming;
3955
3958
  this.replayForming = null, s = t;
@@ -3973,7 +3976,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3973
3976
  });
3974
3977
  }), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
3975
3978
  if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
3976
- let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = yi() ? Or(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = Dr(r, i);
3979
+ let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = bi() ? jr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = Ar(r, i);
3977
3980
  a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
3978
3981
  index: t,
3979
3982
  path: r
@@ -3983,7 +3986,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3983
3986
  drawFormingBar(e, t, n, r) {
3984
3987
  this.currentPriceLine.setPrice(e.close, t);
3985
3988
  let i = this.series.bars();
3986
- if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !ei.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
3989
+ if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !ri.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
3987
3990
  this.scheduleRender();
3988
3991
  return;
3989
3992
  }
@@ -3991,22 +3994,22 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
3991
3994
  }
3992
3995
  replayPathOf(e, t) {
3993
3996
  let n = e[t];
3994
- return Sr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
3997
+ return Tr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
3995
3998
  }
3996
3999
  loadReplaySteps(e, t) {
3997
4000
  let n = this.replayLoader?.loader;
3998
4001
  if (!n) return;
3999
4002
  n.evictBefore(e[t].time);
4000
4003
  let r = this.replayManager.getStepMs();
4001
- n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil($r / r) : 1);
4004
+ n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(ni / r) : 1);
4002
4005
  }
4003
4006
  useReplayLoader(e, t) {
4004
- let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? jr(e.step, r, (e) => M(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
4007
+ let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Pr(e.step, r, (e) => j(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
4005
4008
  if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
4006
- let o = F(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = T(r), u = new hr({
4009
+ let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new vr({
4007
4010
  source: s ? (e, t) => s.call(o, c, i, e, t) : null,
4008
4011
  step: i,
4009
- ratio: Math.max(1, Math.round(l / T(i))),
4012
+ ratio: Math.max(1, Math.round(l / w(i))),
4010
4013
  barMs: l,
4011
4014
  keep: (e) => this.series.inHoursShown(e),
4012
4015
  report: (e) => this.eventBus.emit("replayStepsLoad", e)
@@ -4021,18 +4024,18 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4021
4024
  if (!i || !a?.setMarkPrice || !o) return;
4022
4025
  let s = i.fedTime;
4023
4026
  if (s === null) {
4024
- i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(Dr(n, r).close, o.time);
4027
+ i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(Ar(n, r).close, o.time);
4025
4028
  return;
4026
4029
  }
4027
4030
  if (o.time < s || o.time === s && r <= i.fedFraction) return;
4028
4031
  let c = [];
4029
4032
  if (o.time > s) {
4030
- let a = Z(e, s);
4031
- e[a]?.time === s && i.fedFraction < 1 && c.push(...Y(this.replayPathOf(e, a), i.fedFraction, 1));
4032
- let o = e.slice(di(e, s), t), l = Math.ceil(o.length / ui);
4033
- for (let e = 0; e < o.length; e += l) c.push(...fi(o.slice(e, e + l)));
4034
- c.push(...Y(n, -1, r));
4035
- } else c.push(...Y(n, i.fedFraction, r));
4033
+ let a = Y(e, s);
4034
+ e[a]?.time === s && i.fedFraction < 1 && c.push(...q(this.replayPathOf(e, a), i.fedFraction, 1));
4035
+ let o = e.slice(X(e, s), t), l = Math.ceil(o.length / pi);
4036
+ for (let e = 0; e < o.length; e += l) c.push(...mi(o.slice(e, e + l)));
4037
+ c.push(...q(n, -1, r));
4038
+ } else c.push(...q(n, i.fedFraction, r));
4036
4039
  i.fedTime = o.time, i.fedFraction = r;
4037
4040
  for (let [e, t] of c) a.setMarkPrice(e, t);
4038
4041
  let l = c[c.length - 1]?.[0];
@@ -4047,9 +4050,9 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4047
4050
  if (!t) return;
4048
4051
  let n = this.series.inHoursShown(this.series.liveBars());
4049
4052
  if (n.length === 0) return;
4050
- let r = t.windowTime === null ? 0 : Math.min(Z(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
4053
+ let r = t.windowTime === null ? 0 : Math.min(Y(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
4051
4054
  this.useReplayLoader(t, !1);
4052
- let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : si(o ?? i, t.until);
4055
+ let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : ui(o ?? i, t.until);
4053
4056
  if (s < 0 && this.canPageBackForReplay(t)) {
4054
4057
  this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
4055
4058
  return;
@@ -4057,7 +4060,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4057
4060
  let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
4058
4061
  l || (t.held = null), t.symbol = this.currentSymbol;
4059
4062
  let d = this.replayManager.remainingMs();
4060
- this.clearBarHolders(), t.animate && oi(t, this.replayCoarse, i);
4063
+ this.clearBarHolders(), t.animate && li(t, this.replayCoarse, i);
4061
4064
  let f = this.replayRestarting;
4062
4065
  this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
4063
4066
  try {
@@ -4080,14 +4083,14 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4080
4083
  }
4081
4084
  replayStepsOver(e, t, n = !1) {
4082
4085
  if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
4083
- let r = mi(this.series.inHoursShown(e.steps), t);
4084
- return r && (n || li(r, t)) ? r : null;
4086
+ let r = hi(this.series.inHoursShown(e.steps), t);
4087
+ return r && (n || fi(r, t)) ? r : null;
4085
4088
  }
4086
4089
  canPageBackForReplay(e) {
4087
- return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < ti;
4090
+ return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < ii;
4088
4091
  }
4089
4092
  async pageBackForReplay(e) {
4090
- this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = ti, this.rebaseReplay("older"));
4093
+ this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = ii, this.rebaseReplay("older"));
4091
4094
  }
4092
4095
  holdReplay() {
4093
4096
  let e = this.replaySession;
@@ -4120,7 +4123,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4120
4123
  this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
4121
4124
  }
4122
4125
  replaySeekToTime(e) {
4123
- !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, si(this.replayStepsSeries ?? this.replayCoarse, e)));
4126
+ !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, ui(this.replayStepsSeries ?? this.replayCoarse, e)));
4124
4127
  }
4125
4128
  feedReplayPrice(e, t) {
4126
4129
  let n = this.executionAdapter;
@@ -4140,10 +4143,10 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4140
4143
  return;
4141
4144
  }
4142
4145
  if (i.time <= n.fedTime) return;
4143
- let a = e.slice(di(e, n.fedTime), t + 1);
4146
+ let a = e.slice(X(e, n.fedTime), t + 1);
4144
4147
  n.fedTime = i.time;
4145
- let o = Math.ceil(a.length / ui);
4146
- for (let e = 0; e < a.length; e += o) for (let [t, n] of fi(a.slice(e, e + o))) r.setMarkPrice(t, n);
4148
+ let o = Math.ceil(a.length / pi);
4149
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of mi(a.slice(e, e + o))) r.setMarkPrice(t, n);
4147
4150
  this.tradingManager.setCurrentPrice(i.close);
4148
4151
  }
4149
4152
  getReplayBarIndex() {
@@ -4154,7 +4157,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4154
4157
  }
4155
4158
  replaySeekToBar(e) {
4156
4159
  let t = this.replayStepsSeries;
4157
- this.replaySeek(t && this.replayCoarse ? hi(t, this.replayCoarse, e) : e);
4160
+ this.replaySeek(t && this.replayCoarse ? gi(t, this.replayCoarse, e) : e);
4158
4161
  }
4159
4162
  replayPause() {
4160
4163
  this.setHeldState("paused") || this.replayManager.pause();
@@ -4190,10 +4193,10 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4190
4193
  data: this.getDisplayData()
4191
4194
  }, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
4192
4195
  for (let e of t.anchors) {
4193
- let t = Bt(e.time, n), r = Ft(e.price, n);
4196
+ let t = Ht(e.time, n), r = Lt(e.price, n);
4194
4197
  i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
4195
4198
  }
4196
- return Hr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Ur.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 ? {
4199
+ return Gr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Kr.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 ? {
4197
4200
  x: i,
4198
4201
  y: o,
4199
4202
  width: a - i,
@@ -4229,7 +4232,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4229
4232
  };
4230
4233
  }
4231
4234
  captureSnapshot() {
4232
- return E.capture({
4235
+ return T.capture({
4233
4236
  getDrawings: () => this.getDrawings(),
4234
4237
  getTheme: () => this.themeManager.getBaseTheme(),
4235
4238
  getAlerts: () => this.getAlerts(),
@@ -4242,14 +4245,14 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4242
4245
  });
4243
4246
  }
4244
4247
  restoreIndicators(e, t) {
4245
- let n = Gr(e), r = /* @__PURE__ */ new Map();
4248
+ let n = Jr(e), r = /* @__PURE__ */ new Map();
4246
4249
  this.unrestoredIndicators = [];
4247
4250
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
4248
4251
  if (t) {
4249
4252
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
4250
4253
  for (let n of t) {
4251
4254
  let t = e.get(n.instanceId);
4252
- t && Kr(n, t) && o.add(n.instanceId);
4255
+ t && Yr(n, t) && o.add(n.instanceId);
4253
4256
  }
4254
4257
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
4255
4258
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -4258,7 +4261,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4258
4261
  let t = { ...e };
4259
4262
  for (let [e, n] of Object.entries(t)) {
4260
4263
  let i = x(n), a = i && r.get(i.instanceId);
4261
- a && (t[e] = _(a, i.key));
4264
+ a && (t[e] = v(a, i.key));
4262
4265
  }
4263
4266
  return t;
4264
4267
  };
@@ -4311,7 +4314,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4311
4314
  let s = t.levels ?? null;
4312
4315
  JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
4313
4316
  let c = t.intervals ?? null;
4314
- JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? ae(t.paneStyle) : null);
4317
+ JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? se(t.paneStyle) : null);
4315
4318
  }
4316
4319
  restorePanes(e) {
4317
4320
  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, {
@@ -4416,7 +4419,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4416
4419
  if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
4417
4420
  let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
4418
4421
  if (JSON.stringify(n) === JSON.stringify(i)) return r;
4419
- let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < zr && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
4422
+ let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Hr && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
4420
4423
  type: "indicators",
4421
4424
  before: null,
4422
4425
  after: null
@@ -4444,12 +4447,12 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4444
4447
  }
4445
4448
  saveState(e) {
4446
4449
  if (!this.features.saveLoad) return null;
4447
- let t = this.captureSnapshot(), n = E.serialize(t);
4448
- return e && E.saveToStorage(e, t), n;
4450
+ let t = this.captureSnapshot(), n = T.serialize(t);
4451
+ return e && T.saveToStorage(e, t), n;
4449
4452
  }
4450
4453
  loadState(e) {
4451
4454
  if (!this.features.saveLoad) return;
4452
- let t = E.deserialize(e);
4455
+ let t = T.deserialize(e);
4453
4456
  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");
4454
4457
  let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
4455
4458
  if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
@@ -4460,7 +4463,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4460
4463
  let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
4461
4464
  return r ? r + e.slice(t) : e;
4462
4465
  }, r = t(e.channel), i = {
4463
- ...Lt(e),
4466
+ ...zt(e),
4464
4467
  ...e.target ? { target: t(e.target) } : {}
4465
4468
  };
4466
4469
  if (!e.expired) {
@@ -4480,19 +4483,19 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4480
4483
  }
4481
4484
  loadStateFromStorage(e) {
4482
4485
  if (!this.features.saveLoad) return !1;
4483
- let t = E.loadFromStorage(e);
4484
- return t ? (this.loadState(E.serialize(t)), !0) : !1;
4486
+ let t = T.loadFromStorage(e);
4487
+ return t ? (this.loadState(T.serialize(t)), !0) : !1;
4485
4488
  }
4486
4489
  downloadState(e) {
4487
- this.features.saveLoad && E.downloadFile(this.captureSnapshot(), e);
4490
+ this.features.saveLoad && T.downloadFile(this.captureSnapshot(), e);
4488
4491
  }
4489
4492
  async loadStateFromFile() {
4490
4493
  if (!this.features.saveLoad) return;
4491
- let e = await E.loadFromFile();
4492
- this.loadState(E.serialize(e));
4494
+ let e = await T.loadFromFile();
4495
+ this.loadState(T.serialize(e));
4493
4496
  }
4494
4497
  setLocale(e) {
4495
- se(e), this.engine.requestRender();
4498
+ le(e), this.engine.requestRender();
4496
4499
  }
4497
4500
  setNumberLocale(e) {
4498
4501
  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();
@@ -4501,17 +4504,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4501
4504
  return this.numberLocale;
4502
4505
  }
4503
4506
  setMarket(e) {
4504
- if (this.marketConfig = e, this.studyZoneHeld = !1, this.endStudyZoneWait(), this.timeZoneSetting === "exchange" && this.applyTimeZone(), this.applyExchangeZone(), e.colorScheme) {
4505
- let t = {
4506
- ...this.themeManager.getBaseTheme(),
4507
- candleUp: e.colorScheme.up,
4508
- candleDown: e.colorScheme.down,
4509
- candleUpWick: e.colorScheme.up,
4510
- candleDownWick: e.colorScheme.down
4511
- };
4512
- this.themeManager.setTheme(t);
4513
- }
4514
- e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender(), this.eventBus.emit("marketChange", { market: e });
4507
+ this.marketConfig = e, this.studyZoneHeld = !1, this.endStudyZoneWait(), this.timeZoneSetting === "exchange" && this.applyTimeZone(), this.applyExchangeZone(), e.colorScheme && this.themeManager.setTheme(h(this.themeManager.getBaseTheme(), e.colorScheme)), e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender(), this.eventBus.emit("marketChange", { market: e });
4515
4508
  }
4516
4509
  applyPricePrecision(e) {
4517
4510
  this.marketPricePrecision = e, this.viewport.setPricePrecision(e), this.pinnedTooltip.setPricePrecision(e), this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e), this.tradeZoneManager.setPricePrecision(e), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
@@ -4552,14 +4545,14 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4552
4545
  this.disposed = !0, this.stopWatchingVisibility?.(), this.stopWatchingVisibility = null, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.labelWidths.destroy(), this.container.innerHTML = "";
4553
4546
  }
4554
4547
  createChartRenderer(e) {
4555
- let t = Dn(e, (e) => this.pluginManager.getChartType(e));
4556
- return t instanceof Le && t.setPriceText((e) => this.formatPrice(e)), t;
4548
+ let t = An(e, (e) => this.pluginManager.getChartType(e));
4549
+ return t instanceof ze && t.setPriceText((e) => this.formatPrice(e)), t;
4557
4550
  }
4558
4551
  crosshairSeries() {
4559
4552
  return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
4560
4553
  }
4561
4554
  getDisplayData() {
4562
- let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? wn(e, (e) => this.stepAt(e)) : void 0;
4555
+ let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? Dn(e, (e) => this.stepAt(e)) : void 0;
4563
4556
  if (this.displayDataCache && t === this.displayDataStep) return this.displayDataCache;
4564
4557
  if (e.length === 0) return e;
4565
4558
  let n = this.displaySeries(e, t);
@@ -4567,9 +4560,9 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4567
4560
  }
4568
4561
  displaySeries(e, t) {
4569
4562
  let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
4570
- if (n !== "pointAndFigure" || r(n)) return On(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
4571
- let { columns: i, boxSize: a } = fn(e, this.chartTypeOptions, this.reshapeMemo);
4572
- return this.chartRenderer instanceof Qe && this.chartRenderer.setBoxSize(a), i;
4563
+ if (n !== "pointAndFigure" || r(n)) return jn(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
4564
+ let { columns: i, boxSize: a } = mn(e, this.chartTypeOptions, this.reshapeMemo);
4565
+ return this.chartRenderer instanceof et && this.chartRenderer.setBoxSize(a), i;
4573
4566
  }
4574
4567
  recalcIndicatorsFrom(e, t) {
4575
4568
  if (!this.isTimeAligned()) return this.recalcIndicators(e);
@@ -4581,7 +4574,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4581
4574
  }
4582
4575
  exportBars() {
4583
4576
  if (this.isTimeAligned()) return this.series.bars();
4584
- let e = this.getDisplayData(), t = j(e);
4577
+ let e = this.getDisplayData(), t = A(e);
4585
4578
  return e.map((e, n) => ({
4586
4579
  ...e,
4587
4580
  time: t[n]?.time ?? e.time
@@ -4640,12 +4633,12 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4640
4633
  }
4641
4634
  fitPriceScale(e, t) {
4642
4635
  if (e.length === 0) return;
4643
- let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = Qr(Qr(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() && Zr(e, n, r) ? this.volumeRenderer.getHeightRatio() + Rr : O;
4636
+ let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = ti(ti(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() && ei(e, n, r) ? this.volumeRenderer.getHeightRatio() + Vr : D;
4644
4637
  this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
4645
4638
  top: a,
4646
- bottom: O
4639
+ bottom: D
4647
4640
  } : {
4648
- top: O,
4641
+ top: D,
4649
4642
  bottom: a
4650
4643
  }), this.viewport.fitToPrices(i.min, i.max);
4651
4644
  }
@@ -4667,7 +4660,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4667
4660
  fitLeftAxisWidth() {
4668
4661
  let e = this.leftViewport;
4669
4662
  if (!e) return !1;
4670
- let t = this.themeManager.getTheme(), n = $n({
4663
+ let t = this.themeManager.getTheme(), n = nr({
4671
4664
  min: e.priceRange.min,
4672
4665
  max: e.priceRange.max,
4673
4666
  lastPrice: null,
@@ -4676,12 +4669,12 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4676
4669
  fontFamily: t.font.family,
4677
4670
  fontSizeSmall: t.font.sizeSmall,
4678
4671
  measure: (e, t) => this.measureText(e, t)
4679
- }), r = er(this.leftAxisWidth, n);
4672
+ }), r = rr(this.leftAxisWidth, n);
4680
4673
  return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
4681
4674
  }
4682
4675
  fitPriceAxisWidth() {
4683
4676
  if (!this.features.priceAxis) return !1;
4684
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = $n({
4677
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = nr({
4685
4678
  min: e.min,
4686
4679
  max: e.max,
4687
4680
  lastPrice: this.currentPriceLine.getPrice(),
@@ -4692,14 +4685,14 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4692
4685
  fontFamily: t.font.family,
4693
4686
  fontSizeSmall: t.font.sizeSmall,
4694
4687
  measure: (e, t) => this.measureText(e, t)
4695
- }), r = er(this.priceAxisWidth, n);
4688
+ }), r = rr(this.priceAxisWidth, n);
4696
4689
  return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
4697
4690
  }
4698
4691
  measureText(e, t) {
4699
4692
  let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
4700
- if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => qr(n, e, t));
4693
+ if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => Xr(n, e, t));
4701
4694
  let i = n ?? this.detachedMeasureContext();
4702
- return i ? qr(i, e, t) : e.length * 7;
4695
+ return i ? Xr(i, e, t) : e.length * 7;
4703
4696
  }
4704
4697
  detachedMeasureContext() {
4705
4698
  return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
@@ -4740,7 +4733,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4740
4733
  buildPanelRenderInfos() {
4741
4734
  if (this.panelInfoCache) return this.panelInfoCache;
4742
4735
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
4743
- let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...Mr }, o = {
4736
+ let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...Fr }, o = {
4744
4737
  x: e.rect.x,
4745
4738
  y: e.rect.y + 20,
4746
4739
  width: e.rect.width,
@@ -4825,7 +4818,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4825
4818
  });
4826
4819
  }
4827
4820
  drawOverlayPlugins(e, t) {
4828
- let n = ar(this.pluginManager.getOverlays(), t);
4821
+ let n = cr(this.pluginManager.getOverlays(), t);
4829
4822
  if (n.length === 0) return;
4830
4823
  let r = {
4831
4824
  viewport: this.viewport.getState(),
@@ -4846,7 +4839,7 @@ var Lr = .08, Rr = a ** -7, zr = 800, Br = 20, Vr = 8, Hr = new Set(["horizontal
4846
4839
  };
4847
4840
  }
4848
4841
  };
4849
- function Gr(e) {
4842
+ function Jr(e) {
4850
4843
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
4851
4844
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
4852
4845
  i.add(e.instanceId);
@@ -4860,19 +4853,19 @@ function Gr(e) {
4860
4853
  for (let t of e) a(t);
4861
4854
  return n;
4862
4855
  }
4863
- function Kr(e, t) {
4856
+ function Yr(e, t) {
4864
4857
  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);
4865
4858
  }
4866
- function qr(e, t, n) {
4859
+ function Xr(e, t, n) {
4867
4860
  let r = e.font;
4868
4861
  e.font = n;
4869
4862
  let i = e.measureText(t).width;
4870
4863
  return e.font = r, i;
4871
4864
  }
4872
- var Jr = 300;
4873
- function Yr(e) {
4865
+ var Zr = 300;
4866
+ function Qr(e) {
4874
4867
  let t = {}, n = e.family;
4875
- typeof n == "string" && n.trim() !== "" && n.length <= Jr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4868
+ typeof n == "string" && n.trim() !== "" && n.length <= Zr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4876
4869
  for (let n of [
4877
4870
  "sizeSmall",
4878
4871
  "sizeMedium",
@@ -4883,21 +4876,21 @@ function Yr(e) {
4883
4876
  }
4884
4877
  return t;
4885
4878
  }
4886
- function Xr(e) {
4879
+ function $r(e) {
4887
4880
  let t = e.tagRadius;
4888
4881
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
4889
4882
  }
4890
- function Zr(e, t, n) {
4883
+ function ei(e, t, n) {
4891
4884
  for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
4892
4885
  return !1;
4893
4886
  }
4894
- function Qr(e, t) {
4887
+ function ti(e, t) {
4895
4888
  return e ? t ? {
4896
4889
  min: Math.min(e.min, t.min),
4897
4890
  max: Math.max(e.max, t.max)
4898
4891
  } : e : t;
4899
4892
  }
4900
- function X(e) {
4893
+ function J(e) {
4901
4894
  return {
4902
4895
  id: e.id,
4903
4896
  price: e.price,
@@ -4912,14 +4905,14 @@ function X(e) {
4912
4905
  bars: e.bars
4913
4906
  };
4914
4907
  }
4915
- var $r = 8e3, ei = new Set([
4908
+ var ni = 8e3, ri = new Set([
4916
4909
  "candlestick",
4917
4910
  "line",
4918
4911
  "area",
4919
4912
  "bar",
4920
4913
  "hollowCandle"
4921
- ]), ti = 10, ni = 50, ri = .001;
4922
- function ii(e) {
4914
+ ]), ii = 10, ai = 50, oi = .001;
4915
+ function si(e) {
4923
4916
  return {
4924
4917
  price: null,
4925
4918
  fedTime: null,
@@ -4934,42 +4927,42 @@ function ii(e) {
4934
4927
  held: null
4935
4928
  };
4936
4929
  }
4937
- function ai(e, t) {
4930
+ function ci(e, t) {
4938
4931
  let n = e[t + 1];
4939
- return n ? n.time - e[t].time : pi(e);
4932
+ return n ? n.time - e[t].time : Z(e);
4940
4933
  }
4941
- function oi(e, t, n) {
4934
+ function li(e, t, n) {
4942
4935
  let r = e.fedTime;
4943
4936
  if (r === null || !t || t.length === 0 || n.length === 0) return;
4944
- let i = ai(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
4937
+ let i = ci(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
4945
4938
  if (s > a) return;
4946
- let c = ai(n, o);
4939
+ let c = ci(n, o);
4947
4940
  if (a === s && o > 0) {
4948
4941
  e.fedTime = n[o - 1].time, e.fedFraction = 1;
4949
4942
  return;
4950
4943
  }
4951
4944
  e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
4952
4945
  }
4953
- function si(e, t) {
4954
- let n = di(e, t), r = e.length - 1;
4955
- return n > r && r >= 0 && e[r].time + pi(e) <= t ? r : Math.max(-1, n - 2);
4946
+ function ui(e, t) {
4947
+ let n = X(e, t), r = e.length - 1;
4948
+ return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
4956
4949
  }
4957
- function ci(e) {
4950
+ function di(e) {
4958
4951
  let t = Infinity;
4959
4952
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
4960
4953
  return t;
4961
4954
  }
4962
- function li(e, t) {
4963
- if (!(ci(e) < ci(t))) return !1;
4964
- let n = Math.max(0, e.length - ni);
4955
+ function fi(e, t) {
4956
+ if (!(di(e) < di(t))) return !1;
4957
+ let n = Math.max(0, e.length - ai);
4965
4958
  for (let r = n; r < e.length; r++) {
4966
- let n = t[Q(t, e[r].time)], i = (n.high - n.low) * ri + 2 ** -52;
4959
+ let n = t[Q(t, e[r].time)], i = (n.high - n.low) * oi + 2 ** -52;
4967
4960
  if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
4968
4961
  }
4969
4962
  return !0;
4970
4963
  }
4971
- var ui = 500;
4972
- function Z(e, t) {
4964
+ var pi = 500;
4965
+ function Y(e, t) {
4973
4966
  let n = 0, r = e.length;
4974
4967
  for (; n < r;) {
4975
4968
  let i = n + r >> 1;
@@ -4977,7 +4970,7 @@ function Z(e, t) {
4977
4970
  }
4978
4971
  return n;
4979
4972
  }
4980
- function di(e, t) {
4973
+ function X(e, t) {
4981
4974
  let n = 0, r = e.length;
4982
4975
  for (; n < r;) {
4983
4976
  let i = n + r >> 1;
@@ -4985,20 +4978,20 @@ function di(e, t) {
4985
4978
  }
4986
4979
  return n;
4987
4980
  }
4988
- function fi(e) {
4981
+ function mi(e) {
4989
4982
  let t = 0, n = 0;
4990
4983
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
4991
4984
  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];
4992
4985
  return [...a ? [r, i] : [i, r], [o.close, o.time]];
4993
4986
  }
4994
- function pi(e) {
4987
+ function Z(e) {
4995
4988
  let t = 0;
4996
4989
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
4997
4990
  return t > 0 ? t : Infinity;
4998
4991
  }
4999
- function mi(e, t) {
4992
+ function hi(e, t) {
5000
4993
  if (t.length === 0) return null;
5001
- let n = t[t.length - 1].time + pi(t), r = e.filter((e) => Fn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
4994
+ let n = t[t.length - 1].time + Z(t), r = e.filter((e) => Rn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
5002
4995
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
5003
4996
  if (i.length === 0) return null;
5004
4997
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -5014,26 +5007,26 @@ function Q(e, t) {
5014
5007
  }
5015
5008
  return n;
5016
5009
  }
5017
- function hi(e, t, n) {
5010
+ function gi(e, t, n) {
5018
5011
  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;
5019
5012
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
5020
5013
  return Math.max(0, a);
5021
5014
  }
5022
- function gi(e, t, n) {
5015
+ function _i(e, t, n) {
5023
5016
  let r = n;
5024
5017
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
5025
5018
  let i = {
5026
5019
  ...t[r],
5027
5020
  time: e.time
5028
5021
  };
5029
- for (let e = r + 1; e <= n; e++) i = bi(i, t[e]);
5022
+ for (let e = r + 1; e <= n; e++) i = xi(i, t[e]);
5030
5023
  return i;
5031
5024
  }
5032
- function _i(e, t, n, r) {
5025
+ function vi(e, t, n, r) {
5033
5026
  let i = e[n + 1], a = t[r + 1];
5034
5027
  return i !== void 0 && a !== void 0 && i.time >= a.time;
5035
5028
  }
5036
- function vi(e, t) {
5029
+ function yi(e, t) {
5037
5030
  let n = /* @__PURE__ */ new Map();
5038
5031
  for (let r of e) {
5039
5032
  let e = t[Q(t, r.time)].time, i = n.get(e);
@@ -5041,10 +5034,10 @@ function vi(e, t) {
5041
5034
  }
5042
5035
  return n;
5043
5036
  }
5044
- function yi() {
5037
+ function bi() {
5045
5038
  return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
5046
5039
  }
5047
- function bi(e, t) {
5040
+ function xi(e, t) {
5048
5041
  return {
5049
5042
  time: e.time,
5050
5043
  open: e.open,
@@ -5056,26 +5049,26 @@ function bi(e, t) {
5056
5049
  }
5057
5050
  //#endregion
5058
5051
  //#region src/io/parseOHLCV.ts
5059
- var xi = [
5052
+ var Si = [
5060
5053
  "time",
5061
5054
  "timestamp",
5062
5055
  "date",
5063
5056
  "datetime",
5064
5057
  "t"
5065
- ], Si = ["open", "o"], Ci = ["high", "h"], wi = ["low", "l"], Ti = ["close", "c"], Ei = [
5058
+ ], Ci = ["open", "o"], wi = ["high", "h"], Ti = ["low", "l"], Ei = ["close", "c"], Di = [
5066
5059
  "volume",
5067
5060
  "vol",
5068
5061
  "v"
5069
5062
  ];
5070
- function Di(e) {
5063
+ function Oi(e) {
5071
5064
  let t = e.trim();
5072
- return t ? t[0] === "[" || t[0] === "{" ? Oi(t) : ki(t) : {
5065
+ return t ? t[0] === "[" || t[0] === "{" ? ki(t) : Ai(t) : {
5073
5066
  data: [],
5074
5067
  rowCount: 0,
5075
5068
  skipped: 0
5076
5069
  };
5077
5070
  }
5078
- function Oi(e) {
5071
+ function ki(e) {
5079
5072
  let t;
5080
5073
  try {
5081
5074
  t = JSON.parse(e);
@@ -5085,19 +5078,19 @@ function Oi(e) {
5085
5078
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
5086
5079
  let n = [], r = 0;
5087
5080
  for (let e of t) {
5088
- let t = Array.isArray(e) ? Pi(e) : Ni(e);
5081
+ let t = Array.isArray(e) ? Fi(e) : Pi(e);
5089
5082
  t ? n.push(t) : r++;
5090
5083
  }
5091
- return Ii(n, t.length, r);
5084
+ return Li(n, t.length, r);
5092
5085
  }
5093
- function ki(e) {
5086
+ function Ai(e) {
5094
5087
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
5095
5088
  if (t.length === 0) return {
5096
5089
  data: [],
5097
5090
  rowCount: 0,
5098
5091
  skipped: 0
5099
5092
  };
5100
- let n = Ai(t[0]), r = ji(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Mi(r) : {
5093
+ let n = ji(t[0]), r = Mi(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ni(r) : {
5101
5094
  time: 0,
5102
5095
  open: 1,
5103
5096
  high: 2,
@@ -5108,7 +5101,7 @@ function ki(e) {
5108
5101
  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");
5109
5102
  let o = [], s = 0;
5110
5103
  for (let e = +!!i; e < t.length; e++) {
5111
- let r = ji(t[e], n), i = Fi(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;
5104
+ let r = Mi(t[e], n), i = Ii(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;
5112
5105
  if (i === null || ![
5113
5106
  c,
5114
5107
  l,
@@ -5127,9 +5120,9 @@ function ki(e) {
5127
5120
  volume: Number.isFinite(f) ? f : 0
5128
5121
  });
5129
5122
  }
5130
- return Ii(o, t.length - +!!i, s);
5123
+ return Li(o, t.length - +!!i, s);
5131
5124
  }
5132
- function Ai(e) {
5125
+ function ji(e) {
5133
5126
  let t = {
5134
5127
  ",": 0,
5135
5128
  ";": 0,
@@ -5141,7 +5134,7 @@ function Ai(e) {
5141
5134
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
5142
5135
  return n;
5143
5136
  }
5144
- function ji(e, t) {
5137
+ function Mi(e, t) {
5145
5138
  let n = [], r = "", i = !1;
5146
5139
  for (let a = 0; a < e.length; a++) {
5147
5140
  let o = e[a];
@@ -5149,25 +5142,25 @@ function ji(e, t) {
5149
5142
  }
5150
5143
  return n.push(r), n;
5151
5144
  }
5152
- function Mi(e) {
5145
+ function Ni(e) {
5153
5146
  let t = (t) => e.findIndex((e) => t.includes(e));
5154
5147
  return {
5155
- time: t(xi),
5156
- open: t(Si),
5157
- high: t(Ci),
5158
- low: t(wi),
5159
- close: t(Ti),
5160
- volume: t(Ei)
5148
+ time: t(Si),
5149
+ open: t(Ci),
5150
+ high: t(wi),
5151
+ low: t(Ti),
5152
+ close: t(Ei),
5153
+ volume: t(Di)
5161
5154
  };
5162
5155
  }
5163
- function Ni(e) {
5156
+ function Pi(e) {
5164
5157
  let t = (t) => {
5165
5158
  for (let n of t) {
5166
5159
  if (e[n] !== void 0) return e[n];
5167
5160
  let t = n.toUpperCase();
5168
5161
  if (e[t] !== void 0) return e[t];
5169
5162
  }
5170
- }, n = Fi(String(t(xi) ?? "")), r = Number(t(Si)), i = Number(t(Ci)), a = Number(t(wi)), o = Number(t(Ti)), s = Number(t(Ei) ?? 0);
5163
+ }, n = Ii(String(t(Si) ?? "")), r = Number(t(Ci)), i = Number(t(wi)), a = Number(t(Ti)), o = Number(t(Ei)), s = Number(t(Di) ?? 0);
5171
5164
  return n === null || ![
5172
5165
  r,
5173
5166
  i,
@@ -5182,9 +5175,9 @@ function Ni(e) {
5182
5175
  volume: Number.isFinite(s) ? s : 0
5183
5176
  };
5184
5177
  }
5185
- function Pi(e) {
5178
+ function Fi(e) {
5186
5179
  if (e.length < 5) return null;
5187
- let t = Fi(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;
5180
+ let t = Ii(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;
5188
5181
  return t === null || ![
5189
5182
  n,
5190
5183
  r,
@@ -5202,7 +5195,7 @@ function Pi(e) {
5202
5195
  function $(e) {
5203
5196
  return e === void 0 || e.trim() === "" ? NaN : Number(e);
5204
5197
  }
5205
- function Fi(e) {
5198
+ function Ii(e) {
5206
5199
  let t = e.trim();
5207
5200
  if (!t) return null;
5208
5201
  let n = Number(t);
@@ -5210,7 +5203,7 @@ function Fi(e) {
5210
5203
  let r = Date.parse(t);
5211
5204
  return Number.isFinite(r) ? r : null;
5212
5205
  }
5213
- function Ii(e, t, n) {
5206
+ function Li(e, t, n) {
5214
5207
  e.sort((e, t) => e.time - t.time);
5215
5208
  let r = [];
5216
5209
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -5222,7 +5215,7 @@ function Ii(e, t, n) {
5222
5215
  }
5223
5216
  //#endregion
5224
5217
  //#region src/io/DragDropImporter.ts
5225
- var Li = class {
5218
+ var Ri = class {
5226
5219
  host;
5227
5220
  overlay = null;
5228
5221
  callbacks;
@@ -5243,19 +5236,19 @@ var Li = class {
5243
5236
  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();
5244
5237
  }
5245
5238
  onDragEnter(e) {
5246
- Ri(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5239
+ zi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5247
5240
  }
5248
5241
  onDragOver(e) {
5249
- Ri(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5242
+ zi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5250
5243
  }
5251
5244
  onDragLeave(e) {
5252
- Ri(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5245
+ zi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5253
5246
  }
5254
5247
  async onDrop(e) {
5255
5248
  e.preventDefault(), this.depth = 0, this.hideOverlay();
5256
5249
  let t = e.dataTransfer?.files?.[0];
5257
5250
  if (t) try {
5258
- let e = Di(await t.text());
5251
+ let e = Oi(await t.text());
5259
5252
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
5260
5253
  this.callbacks.onData(e.data, e, t);
5261
5254
  } catch (e) {
@@ -5286,12 +5279,12 @@ var Li = class {
5286
5279
  this.overlay?.remove(), this.overlay = null;
5287
5280
  }
5288
5281
  };
5289
- function Ri(e) {
5282
+ function zi(e) {
5290
5283
  return e.dataTransfer?.types?.includes("Files") ?? !1;
5291
5284
  }
5292
5285
  //#endregion
5293
5286
  //#region src/state/layoutStorage.ts
5294
- function zi(e) {
5287
+ function Bi(e) {
5295
5288
  let t = {
5296
5289
  id: e.id,
5297
5290
  name: e.name,
@@ -5299,11 +5292,11 @@ function zi(e) {
5299
5292
  };
5300
5293
  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;
5301
5294
  }
5302
- var Bi = (e, t) => t.updatedAt - e.updatedAt;
5303
- function Vi(e) {
5295
+ var Vi = (e, t) => t.updatedAt - e.updatedAt;
5296
+ function Hi(e) {
5304
5297
  if (typeof e != "object" || !e) return null;
5305
5298
  let t = e;
5306
- return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : zi({
5299
+ return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Bi({
5307
5300
  id: t.id,
5308
5301
  name: t.name,
5309
5302
  updatedAt: t.updatedAt,
@@ -5312,17 +5305,17 @@ function Vi(e) {
5312
5305
  kind: typeof t.kind == "string" ? t.kind : void 0
5313
5306
  });
5314
5307
  }
5315
- function Hi(e) {
5316
- let t = Vi(e), n = t ? e.content : void 0;
5308
+ function Ui(e) {
5309
+ let t = Hi(e), n = t ? e.content : void 0;
5317
5310
  return t && typeof n == "string" ? {
5318
5311
  ...t,
5319
5312
  content: n
5320
5313
  } : null;
5321
5314
  }
5322
- function Ui(e = []) {
5315
+ function Wi(e = []) {
5323
5316
  let t = new Map(e.map((e) => [e.id, { ...e }]));
5324
5317
  return {
5325
- list: () => [...t.values()].map(zi).sort(Bi),
5318
+ list: () => [...t.values()].map(Bi).sort(Vi),
5326
5319
  load: (e) => {
5327
5320
  let n = t.get(e);
5328
5321
  return n ? { ...n } : null;
@@ -5335,7 +5328,7 @@ function Ui(e = []) {
5335
5328
  }
5336
5329
  };
5337
5330
  }
5338
- function Wi(e = "tcw:layouts:") {
5331
+ function Gi(e = "tcw:layouts:") {
5339
5332
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
5340
5333
  let e;
5341
5334
  try {
@@ -5343,10 +5336,10 @@ function Wi(e = "tcw:layouts:") {
5343
5336
  } catch {
5344
5337
  return [];
5345
5338
  }
5346
- return Array.isArray(e) ? e.map(Vi).filter((e) => e !== null) : [];
5339
+ return Array.isArray(e) ? e.map(Hi).filter((e) => e !== null) : [];
5347
5340
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
5348
5341
  return {
5349
- list: () => r().sort(Bi),
5342
+ list: () => r().sort(Vi),
5350
5343
  load: (e) => {
5351
5344
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
5352
5345
  return t && i !== null ? {
@@ -5355,7 +5348,7 @@ function Wi(e = "tcw:layouts:") {
5355
5348
  } : null;
5356
5349
  },
5357
5350
  save: (e) => {
5358
- localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), zi(e)]);
5351
+ localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Bi(e)]);
5359
5352
  },
5360
5353
  remove: (e) => {
5361
5354
  i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
@@ -5364,14 +5357,14 @@ function Wi(e = "tcw:layouts:") {
5364
5357
  }
5365
5358
  //#endregion
5366
5359
  //#region src/state/LayoutSession.ts
5367
- var Gi = 80;
5368
- function Ki(e) {
5360
+ var Ki = 80;
5361
+ function qi(e) {
5369
5362
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
5370
5363
  }
5371
- function qi() {
5364
+ function Ji() {
5372
5365
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
5373
5366
  }
5374
- function Ji(e) {
5367
+ function Yi(e) {
5375
5368
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
5376
5369
  return {
5377
5370
  id: t,
@@ -5382,7 +5375,7 @@ function Ji(e) {
5382
5375
  ...o === void 0 ? {} : { kind: o }
5383
5376
  };
5384
5377
  }
5385
- var Yi = class {
5378
+ var Xi = class {
5386
5379
  currentLayout = null;
5387
5380
  savedContent = null;
5388
5381
  dirty = !1;
@@ -5398,7 +5391,7 @@ var Yi = class {
5398
5391
  now;
5399
5392
  newId;
5400
5393
  constructor(e, t, n = {}) {
5401
- 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 ?? qi;
5394
+ 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 ?? Ji;
5402
5395
  }
5403
5396
  current() {
5404
5397
  return this.currentLayout;
@@ -5414,7 +5407,7 @@ var Yi = class {
5414
5407
  }
5415
5408
  async list() {
5416
5409
  let e = await this.storage.list();
5417
- return Array.isArray(e) ? e.map(Vi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5410
+ return Array.isArray(e) ? e.map(Hi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5418
5411
  }
5419
5412
  save() {
5420
5413
  return this.queue(() => {
@@ -5423,12 +5416,12 @@ var Yi = class {
5423
5416
  });
5424
5417
  }
5425
5418
  saveAs(e) {
5426
- let t = Ki(e);
5419
+ let t = qi(e);
5427
5420
  return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
5428
5421
  }
5429
5422
  open(e) {
5430
5423
  return this.queue(async () => {
5431
- let t = Hi(await this.storage.load(e));
5424
+ let t = Ui(await this.storage.load(e));
5432
5425
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
5433
5426
  this.cancelTimer(), this.applying++;
5434
5427
  try {
@@ -5438,13 +5431,13 @@ var Yi = class {
5438
5431
  } finally {
5439
5432
  this.applying--;
5440
5433
  }
5441
- return this.cancelTimer(), this.currentLayout = Ji(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5434
+ return this.cancelTimer(), this.currentLayout = Yi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5442
5435
  });
5443
5436
  }
5444
5437
  rename(e, t) {
5445
- let n = Ki(t);
5438
+ let n = qi(t);
5446
5439
  return n ? this.queue(async () => {
5447
- let t = Hi(await this.storage.load(e));
5440
+ let t = Ui(await this.storage.load(e));
5448
5441
  !t || t.id !== e || (await this.storage.save({
5449
5442
  ...t,
5450
5443
  name: n
@@ -5522,7 +5515,7 @@ var Yi = class {
5522
5515
  content: n.content
5523
5516
  };
5524
5517
  await this.storage.save(r);
5525
- let i = Ji(r);
5518
+ let i = Yi(r);
5526
5519
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
5527
5520
  }
5528
5521
  forget() {
@@ -5543,6 +5536,6 @@ var Yi = class {
5543
5536
  }
5544
5537
  };
5545
5538
  //#endregion
5546
- export { Bn as C, H as D, B as E, cn as O, Un as S, U as T, sr as _, Ui as a, q as b, Wr as c, Ar as d, jr as f, or as g, cr as h, Wi as i, Pr as l, lr as m, Gi as n, Li as o, ur as p, Ki as r, Di as s, Yi as t, Nr as u, ir as v, Rn as w, Jn as x, ar as y };
5539
+ export { Un as C, B as D, R as E, un as O, Kn as S, V as T, ur as _, Wi as a, G as b, qr as c, Nr as d, Pr as f, lr as g, dr as h, Gi as i, Lr as l, fr as m, Ki as n, Ri as o, pr as p, qi as r, Oi as s, Xi as t, Ir as u, sr as v, Vn as w, Zn as x, cr as y };
5547
5540
 
5548
- //# sourceMappingURL=LayoutSession-CmxR_iG8.js.map
5541
+ //# sourceMappingURL=LayoutSession-BXmESQTc.js.map