@tradecanvas/chart 1.53.1 → 1.54.1

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.
Files changed (81) hide show
  1. package/dist/Chart.d.ts +55 -1
  2. package/dist/Chart.d.ts.map +1 -1
  3. package/dist/LayoutSession-Breef1mg.cjs +2 -0
  4. package/dist/LayoutSession-Breef1mg.cjs.map +1 -0
  5. package/dist/{LayoutSession-B2WYXhzD.js → LayoutSession-C5aHWgk7.js} +615 -516
  6. package/dist/LayoutSession-C5aHWgk7.js.map +1 -0
  7. package/dist/charts/ChartTypeStrategy.d.ts +11 -2
  8. package/dist/charts/ChartTypeStrategy.d.ts.map +1 -1
  9. package/dist/{i18n-CwCzRLKW.js → i18n-DGsh8zmc.js} +3 -1
  10. package/dist/i18n-DGsh8zmc.js.map +1 -0
  11. package/dist/i18n-GirmlAsM.cjs +2 -0
  12. package/dist/i18n-GirmlAsM.cjs.map +1 -0
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.d.ts +5 -4
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +72 -72
  17. package/dist/indicatorLabel.d.ts +3 -2
  18. package/dist/indicatorLabel.d.ts.map +1 -1
  19. package/dist/layout/LayoutManager.d.ts +4 -0
  20. package/dist/layout/LayoutManager.d.ts.map +1 -1
  21. package/dist/widget/ChartWidget.d.ts +24 -0
  22. package/dist/widget/ChartWidget.d.ts.map +1 -1
  23. package/dist/widget/WidgetDataWindow.d.ts +4 -0
  24. package/dist/widget/WidgetDataWindow.d.ts.map +1 -1
  25. package/dist/widget/WidgetDrawingSidebar.d.ts +6 -0
  26. package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
  27. package/dist/widget/WidgetIndicatorLegend.d.ts +12 -1
  28. package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -1
  29. package/dist/widget/WidgetToolbar.d.ts.map +1 -1
  30. package/dist/widget/WidgetWatchlist.d.ts.map +1 -1
  31. package/dist/widget/formControls.d.ts +2 -0
  32. package/dist/widget/formControls.d.ts.map +1 -1
  33. package/dist/widget/index.cjs +37 -29
  34. package/dist/widget/index.cjs.map +1 -1
  35. package/dist/widget/index.js +1753 -1684
  36. package/dist/widget/index.js.map +1 -1
  37. package/dist/widget/legendValues.d.ts +6 -0
  38. package/dist/widget/legendValues.d.ts.map +1 -1
  39. package/dist/widget/locales/ar.d.ts.map +1 -1
  40. package/dist/widget/locales/cs.d.ts.map +1 -1
  41. package/dist/widget/locales/da.d.ts.map +1 -1
  42. package/dist/widget/locales/de.d.ts.map +1 -1
  43. package/dist/widget/locales/el.d.ts.map +1 -1
  44. package/dist/widget/locales/en.d.ts +1 -0
  45. package/dist/widget/locales/en.d.ts.map +1 -1
  46. package/dist/widget/locales/es.d.ts.map +1 -1
  47. package/dist/widget/locales/et.d.ts.map +1 -1
  48. package/dist/widget/locales/fa.d.ts.map +1 -1
  49. package/dist/widget/locales/fr.d.ts.map +1 -1
  50. package/dist/widget/locales/he.d.ts.map +1 -1
  51. package/dist/widget/locales/hu.d.ts.map +1 -1
  52. package/dist/widget/locales/id.d.ts.map +1 -1
  53. package/dist/widget/locales/index.cjs +1 -1
  54. package/dist/widget/locales/index.cjs.map +1 -1
  55. package/dist/widget/locales/index.js +29 -1
  56. package/dist/widget/locales/index.js.map +1 -1
  57. package/dist/widget/locales/it.d.ts.map +1 -1
  58. package/dist/widget/locales/ja.d.ts.map +1 -1
  59. package/dist/widget/locales/ko.d.ts.map +1 -1
  60. package/dist/widget/locales/ms.d.ts.map +1 -1
  61. package/dist/widget/locales/nb.d.ts.map +1 -1
  62. package/dist/widget/locales/nl.d.ts.map +1 -1
  63. package/dist/widget/locales/pl.d.ts.map +1 -1
  64. package/dist/widget/locales/pt.d.ts.map +1 -1
  65. package/dist/widget/locales/ro.d.ts.map +1 -1
  66. package/dist/widget/locales/ru.d.ts.map +1 -1
  67. package/dist/widget/locales/sk.d.ts.map +1 -1
  68. package/dist/widget/locales/sv.d.ts.map +1 -1
  69. package/dist/widget/locales/th.d.ts.map +1 -1
  70. package/dist/widget/locales/tr.d.ts.map +1 -1
  71. package/dist/widget/locales/vi.d.ts.map +1 -1
  72. package/dist/widget/locales/zh.d.ts.map +1 -1
  73. package/dist/widget/locales/zhHant.d.ts.map +1 -1
  74. package/dist/widget/widgetCompare.d.ts.map +1 -1
  75. package/package.json +3 -3
  76. package/dist/LayoutSession-B2WYXhzD.js.map +0 -1
  77. package/dist/LayoutSession-DTb03S73.cjs +0 -2
  78. package/dist/LayoutSession-DTb03S73.cjs.map +0 -1
  79. package/dist/i18n-CwCzRLKW.js.map +0 -1
  80. package/dist/i18n-D7B7uFrN.cjs +0 -2
  81. package/dist/i18n-D7B7uFrN.cjs.map +0 -1
@@ -1,12 +1,12 @@
1
- import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, formatPrice as h, fractionTick as g, indicatorSource as _, isValidTimeZone as v, mergeBar as ee, niceNumber as te, normalizeBarTime as y, parseIndicatorSource as b, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as x, readIndicatorPlotStyles as ae, readPaneStyle as oe, resolveChartTheme as se, sessionMinute as S, setLocale as ce, stepDecimals as le, symbolTimeZone as C, tickBarCount as ue, timeframeToMs as w, zonedDateFormatter as de } from "@tradecanvas/commons";
2
- import { AlertDragHandler as fe, AlertManager as pe, Animator as me, AreaRenderer as he, AxisDragHandler as ge, BarCountdown as _e, BarRenderer as ve, BaselineRenderer as ye, CandlestickRenderer as be, ChartLegend as xe, ChartStateManager as T, CompareRenderer as Se, CompareSymbolIndicator as Ce, CorrelationCoefficientIndicator as we, CorrelationLogIndicator as Te, CrosshairHandler as Ee, CrosshairTooltip as De, CurrentPriceLine as Oe, DEFAULT_SESSION_HOURS as ke, DataExporter as E, DepthHeatmapRenderer as Ae, DrawingManager as je, DrawingRenderer as Me, EquivolumeRenderer as Ne, EventBus as Pe, GridRenderer as Fe, HLCAreaRenderer as Ie, HiLoRenderer as Le, HollowCandleRenderer as Re, IndicatorEngine as ze, InteractionManager as Be, KagiRenderer as Ve, KeyboardHandler as He, LineRenderer as Ue, LineWithMarkersRenderer as We, MarketProfileRenderer as Ge, MeasureOverlay as Ke, PRICE_SCALE_MARGIN as D, PanHandler as qe, PaneResizeHandler as Je, PeriodLevelsRenderer as Ye, PinnedTooltip as Xe, PivotMarkersRenderer as Ze, PointAndFigureRenderer as Qe, PriceAxis as $e, PriceAxisAddButton as et, PriceLines as tt, RenderEngine as nt, RenkoRenderer as rt, ReplayManager as it, ResamplingAdapter as at, ReshapeMemo as ot, SYMBOL_INDICATOR_IDS as O, SYMBOL_ZONE_WAIT_MS as st, Screenshot as k, SelectionBoxOverlay as ct, SessionBreaks as lt, SessionShading as ut, SignalMarkerManager as dt, SpreadIndicator as ft, StepLineRenderer as pt, StreamManager as mt, SymbolSeriesStore as ht, TimeAxis as gt, TradeZoneManager as _t, TradingManager as vt, TradingRenderer as yt, UndoRedoManager as bt, Viewport as xt, VolumeCandleRenderer as St, VolumeProfileRenderer as Ct, VolumeRenderer as wt, Watermark as Tt, ZoomHandler as Et, barTimeStepMs as Dt, findDominantSwing as Ot, gpuContextsLeft as kt, isPriceLevelAlert as At, isRegularSession as jt, loadWebGL as Mt, mergeSessionHours as Nt, pointAndFigureColumns as Pt, priceToY as Ft, rangePresetStart as It, readAlertOptions as Lt, registerBuiltInDrawingTools as Rt, registerBuiltInIndicators as zt, servesTimeframe as A, sourceParam as j, timeToX as Bt, timestampToBarIndex as M, toHeikinAshi as Vt, toKagi as Ht, toLineBreak as Ut, toRangeBars as Wt, toRenko as Gt, whenGpuContextFree as Kt, withResampling as N, xToBarIndex as qt, xToTime as P, yToPrice as Jt } from "@tradecanvas/core";
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";
3
3
  //#region src/regularHours.ts
4
4
  var Yt = 864e5, Xt = 10;
5
5
  function Zt(e, t) {
6
- let n = C(e);
6
+ let n = w(e);
7
7
  if (!n || !v(n) || t.length < 2) return null;
8
8
  let r = (e?.sessions ?? []).flatMap((e) => {
9
- let t = S(e.start), n = S(e.end);
9
+ let t = C(e.start), n = C(e.end);
10
10
  return t === null || n === null ? [] : [{
11
11
  startMinute: t,
12
12
  endMinute: n
@@ -36,7 +36,7 @@ var Qt = {
36
36
  view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
37
37
  bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
38
38
  keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
39
- }, F = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), $t = [
39
+ }, L = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), $t = [
40
40
  "role",
41
41
  "aria-roledescription",
42
42
  "aria-label",
@@ -93,7 +93,7 @@ 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(F(this.labels.bar, {
96
+ this.say(L(this.labels.bar, {
97
97
  time: this.source.formatTime(i.time),
98
98
  open: a(i.open),
99
99
  high: a(i.high),
@@ -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 F(this.labels.summary, {
121
+ return L(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 F(this.labels.view, {
131
+ return L(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),
@@ -159,8 +159,9 @@ function an(e) {
159
159
  }
160
160
  //#endregion
161
161
  //#region src/indicatorLabel.ts
162
- function on(e, t, n, r) {
163
- let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, 3).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
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] : [];
164
165
  return [
165
166
  e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
166
167
  ...a,
@@ -169,17 +170,17 @@ function on(e, t, n, r) {
169
170
  }
170
171
  //#endregion
171
172
  //#region src/charts/ChartTypeStrategy.ts
172
- function sn(e) {
173
+ function ln(e) {
173
174
  switch (e) {
174
175
  case "candlestick":
175
176
  case "heikinAshi":
176
177
  case "lineBreak":
177
- case "rangeBars": return new be();
178
+ case "rangeBars": return new ye();
178
179
  case "line": return new Ue();
179
- case "area": return new he();
180
- case "bar": return new ve();
180
+ case "area": return new me();
181
+ case "bar": return new _e();
181
182
  case "hollowCandle": return new Re();
182
- case "baseline": return new ye();
183
+ case "baseline": return new ve();
183
184
  case "renko": return new rt();
184
185
  case "kagi": return new Ve();
185
186
  case "pointAndFigure": return new Qe();
@@ -189,10 +190,10 @@ function sn(e) {
189
190
  case "stepLine": return new pt();
190
191
  case "lineWithMarkers": return new We();
191
192
  case "hiLo": return new Le();
192
- default: return new be();
193
+ default: return new ye();
193
194
  }
194
195
  }
195
- function cn(e, t, n = {}, r, i) {
196
+ function un(e, t, n = {}, r, i) {
196
197
  if (t.length === 0) return t;
197
198
  switch (e) {
198
199
  case "heikinAshi": return Vt(t);
@@ -206,15 +207,15 @@ function cn(e, t, n = {}, r, i) {
206
207
  }
207
208
  case "lineBreak": return Ut(t, n.lineBreak?.lines ?? 3);
208
209
  case "kagi": return Ht(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
209
- case "pointAndFigure": return un(t, n, i).columns;
210
+ case "pointAndFigure": return fn(t, n, i).columns;
210
211
  case "rangeBars": return Wt(t, {
211
- rangeSize: _n(t, n, r),
212
+ rangeSize: xn(t, n, r),
212
213
  includeForming: !0
213
214
  }, i);
214
215
  default: return t;
215
216
  }
216
217
  }
217
- function ln(e) {
218
+ function dn(e) {
218
219
  switch (e) {
219
220
  case "heikinAshi":
220
221
  case "renko":
@@ -225,65 +226,72 @@ function ln(e) {
225
226
  default: return !1;
226
227
  }
227
228
  }
228
- function I(e) {
229
- return e !== "heikinAshi" && ln(e);
229
+ function R(e) {
230
+ return e !== "heikinAshi" && dn(e);
230
231
  }
231
- function un(e, t = {}, n) {
232
- let r = t.pointAndFigure?.boxSize;
233
- return Pt(e, typeof r == "number" ? r : dn(e) * .01, t.pointAndFigure?.reversal ?? 3, n);
232
+ function fn(e, t = {}, n) {
233
+ return Pt(e, hn(e, t), t.pointAndFigure?.reversal ?? 3, n);
234
234
  }
235
- function dn(e) {
236
- let t = 0;
237
- for (let n of e) t += n.close;
238
- return t / e.length;
235
+ var pn = 50, mn = .01;
236
+ function hn(e, t = {}) {
237
+ let n = t.pointAndFigure?.boxSize;
238
+ 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;
241
+ }
242
+ function gn(e, t) {
243
+ let n = -Infinity, r = Infinity;
244
+ for (let i = 0; i < t; i++) e[i].high > n && (n = e[i].high), e[i].low < r && (r = e[i].low);
245
+ let i = n - r;
246
+ return Number.isFinite(i) ? i : 0;
239
247
  }
240
- var fn = 100, pn = 3, mn = .01, hn = 15, gn = (e) => Number(e.toPrecision(hn));
241
- function _n(e, t = {}, n) {
248
+ var _n = 100, vn = 3, yn = .01, bn = 15, z = (e) => Number(e.toPrecision(bn));
249
+ function xn(e, t = {}, n) {
242
250
  let r = t.rangeBars?.range;
243
251
  if (typeof r == "number") return r;
244
- let i = e.length >= pn ? yn(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
245
- return Sn(gn(te(i > 0 ? i : a * mn || 1, !0)), n);
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);
246
254
  }
247
- function vn(e) {
255
+ function Sn(e) {
248
256
  let t = e.length - 1;
249
257
  return {
250
- from: Math.max(0, t - fn),
258
+ from: Math.max(0, t - _n),
251
259
  end: t
252
260
  };
253
261
  }
254
- function yn(e) {
255
- let { from: t, end: n } = vn(e), r = 0;
262
+ function Cn(e) {
263
+ let { from: t, end: n } = Sn(e), r = 0;
256
264
  for (let i = t; i < n; i++) {
257
265
  let { high: t, low: n } = e[i], a = i > 0 ? e[i - 1].close : n;
258
266
  r += Math.max(t - n, Math.abs(t - a), Math.abs(n - a));
259
267
  }
260
268
  return n > t ? r / (n - t) : 0;
261
269
  }
262
- function bn(e, t) {
263
- let { from: n, end: r } = vn(e);
270
+ function wn(e, t) {
271
+ let { from: n, end: r } = Sn(e);
264
272
  if (r <= n) return t(e[e.length - 1]?.close ?? 0);
265
273
  let i = -Infinity, a = Infinity;
266
274
  for (let t = n; t < r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
267
- return xn(t(i), t(a));
275
+ return Tn(t(i), t(a));
268
276
  }
269
- function xn(e, t) {
277
+ function Tn(e, t) {
270
278
  return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
271
279
  }
272
- function Sn(e, t) {
273
- return t === void 0 || !(t > 0) ? e : gn(Math.max(1, Math.round(e / t)) * t);
280
+ function En(e, t) {
281
+ return t === void 0 || !(t > 0) ? e : z(Math.max(1, Math.round(e / t)) * t);
274
282
  }
275
- function Cn(e, t) {
283
+ function Dn(e, t) {
276
284
  let n = t?.(e);
277
- return n ? n.createRenderer() : sn(e);
285
+ return n ? n.createRenderer() : ln(e);
278
286
  }
279
- function wn(e, t, n, r, i, a) {
287
+ function On(e, t, n, r, i, a) {
280
288
  if (t.length === 0) return t;
281
289
  let o = n?.(e);
282
- return o?.transform ? o.transform(t) : cn(e, t, r, i, a);
290
+ return o?.transform ? o.transform(t) : un(e, t, r, i, a);
283
291
  }
284
292
  //#endregion
285
293
  //#region src/state/AutoSaveScheduler.ts
286
- var Tn = class {
294
+ var kn = class {
287
295
  timer = null;
288
296
  delayMs = 0;
289
297
  key = null;
@@ -313,15 +321,15 @@ var Tn = class {
313
321
  };
314
322
  //#endregion
315
323
  //#region src/DataManager.ts
316
- function L(e) {
324
+ function B(e) {
317
325
  if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
318
326
  let { open: t, high: n, low: r, close: i } = e;
319
327
  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));
320
328
  }
321
- function En(e) {
329
+ function An(e) {
322
330
  return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
323
331
  }
324
- function R(e) {
332
+ function V(e) {
325
333
  return {
326
334
  ...e,
327
335
  high: Math.max(e.open, e.high, e.low, e.close),
@@ -329,36 +337,36 @@ function R(e) {
329
337
  volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
330
338
  };
331
339
  }
332
- function z(e, t) {
340
+ function H(e, t) {
333
341
  return e === t || e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume;
334
342
  }
335
- function Dn(e, t) {
343
+ function jn(e, t) {
336
344
  for (let n = e.length - 1; n >= 0; n--) {
337
345
  if (e[n].time === t) return n;
338
346
  if (e[n].time < t) return -1;
339
347
  }
340
348
  return -1;
341
349
  }
342
- var On = {
350
+ var Mn = {
343
351
  index: -1,
344
352
  changed: !1
345
353
  };
346
- function kn(e, t) {
354
+ function Nn(e, t) {
347
355
  if (e.length === 0) return t;
348
- let n = y(t);
356
+ let n = b(t);
349
357
  return u(e) === 1 ? n : n / 1e3;
350
358
  }
351
- function An(e, t) {
352
- let n = kn(e, t.time);
359
+ function Pn(e, t) {
360
+ let n = Nn(e, t.time);
353
361
  return n === t.time ? t : {
354
362
  ...t,
355
363
  time: n
356
364
  };
357
365
  }
358
- var B = class {
366
+ var U = class {
359
367
  data = [];
360
368
  withSeriesTime(e) {
361
- return An(this.data, e);
369
+ return Pn(this.data, e);
362
370
  }
363
371
  getData() {
364
372
  return this.data;
@@ -367,16 +375,16 @@ var B = class {
367
375
  let t = [];
368
376
  for (let n = 0; n < e.length; n++) {
369
377
  let r = e[n];
370
- L(r) && t.push(En(r) ? r : R(r));
378
+ B(r) && t.push(An(r) ? r : V(r));
371
379
  }
372
380
  this.data = t;
373
381
  }
374
382
  prependBars(e) {
375
383
  let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
376
384
  for (let r = 0; r < e.length; r++) {
377
- if (!L(e[r])) continue;
385
+ if (!B(e[r])) continue;
378
386
  let i = this.withSeriesTime(e[r]);
379
- i.time >= t || n.push(En(i) ? i : R(i));
387
+ i.time >= t || n.push(An(i) ? i : V(i));
380
388
  }
381
389
  if (n.length === 0) return 0;
382
390
  n.sort((e, t) => e.time - t.time);
@@ -385,11 +393,11 @@ var B = class {
385
393
  return n.length = r, this.data = n.concat(this.data), r;
386
394
  }
387
395
  appendBar(e) {
388
- L(e) && this.data.push(R(this.withSeriesTime(e)));
396
+ B(e) && this.data.push(V(this.withSeriesTime(e)));
389
397
  }
390
398
  updateLastBar(e) {
391
- if (!L(e)) return;
392
- let t = R(this.withSeriesTime(e));
399
+ if (!B(e)) return;
400
+ let t = V(this.withSeriesTime(e));
393
401
  if (this.data.length === 0) {
394
402
  this.data.push(t);
395
403
  return;
@@ -397,11 +405,11 @@ var B = class {
397
405
  this.data[this.data.length - 1] = t;
398
406
  }
399
407
  replaceBar(e) {
400
- if (!L(e)) return On;
401
- let t = this.withSeriesTime(e), n = Dn(this.data, t.time);
402
- if (n < 0) return On;
403
- let r = R(t);
404
- return z(this.data[n], r) ? {
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) ? {
405
413
  index: n,
406
414
  changed: !1
407
415
  } : (this.data[n] = r, {
@@ -410,7 +418,7 @@ var B = class {
410
418
  });
411
419
  }
412
420
  updateLastBarFromTick(e) {
413
- this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = ee(this.data[this.data.length - 1], this.withSeriesTime(e))));
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))));
414
422
  }
415
423
  getLength() {
416
424
  return this.data.length;
@@ -418,18 +426,18 @@ var B = class {
418
426
  clear() {
419
427
  this.data = [];
420
428
  }
421
- }, V = {
429
+ }, W = {
422
430
  to: "none",
423
431
  index: -1,
424
432
  changed: !1
425
433
  };
426
- function H(e, t) {
434
+ function G(e, t) {
427
435
  let n = e[e.length - 1];
428
436
  if (!n) return "append";
429
- let r = y(t.time), i = y(n.time);
437
+ let r = b(t.time), i = b(n.time);
430
438
  return r > i ? "append" : r === i ? "update" : "stale";
431
439
  }
432
- function jn(e) {
440
+ function Fn(e) {
433
441
  return [
434
442
  e.time,
435
443
  e.open,
@@ -438,8 +446,8 @@ function jn(e) {
438
446
  e.close
439
447
  ].every(Number.isFinite);
440
448
  }
441
- var Mn = class {
442
- shown = new B();
449
+ var In = class {
450
+ shown = new U();
443
451
  whole = null;
444
452
  aside = null;
445
453
  shownRevision = 0;
@@ -478,7 +486,7 @@ var Mn = class {
478
486
  }
479
487
  let t = null, n = e;
480
488
  if (this.whole) {
481
- let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(jn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
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);
482
490
  this.whole = [...a, ...this.whole];
483
491
  let o = this.hoursFilter(this.whole);
484
492
  t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
@@ -490,8 +498,8 @@ var Mn = class {
490
498
  };
491
499
  }
492
500
  mergeSnapshot(e) {
493
- if (this.aside) return this.aside.setData(Nn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
494
- let t = Nn(this.whole ?? this.shown.getData(), e);
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);
495
503
  return t ? (this.shown.setData(this.regularOnly(t)), !0) : !1;
496
504
  }
497
505
  refilter() {
@@ -548,7 +556,7 @@ var Mn = class {
548
556
  mergeTick(e) {
549
557
  if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
550
558
  let t = this.whole ? this.hoursFilter(this.whole) : null;
551
- if (t && this.whole && !t(kn(this.whole, e.time))) return this.wrote("hidden", !1);
559
+ if (t && this.whole && !t(Nn(this.whole, e.time))) return this.wrote("hidden", !1);
552
560
  let n = this.shown.getLength();
553
561
  this.shown.updateLastBarFromTick(e);
554
562
  let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
@@ -560,14 +568,14 @@ var Mn = class {
560
568
  }
561
569
  placeStreamBar(e) {
562
570
  if (this.aside) {
563
- let t = H(this.aside.getData(), e);
571
+ let t = G(this.aside.getData(), e);
564
572
  return t === "append" ? this.aside.appendBar(e) : t === "update" && this.aside.updateLastBar(e), this.wrote(t === "stale" ? "none" : "aside", !1);
565
573
  }
566
- let t = this.inSeriesUnit(e), n = H(this.whole ?? this.shown.getData(), t);
574
+ let t = this.inSeriesUnit(e), n = G(this.whole ?? this.shown.getData(), t);
567
575
  if (n === "stale") return this.wrote("none", !1);
568
576
  let r = this.startWholeSeries(t, n);
569
577
  if (!this.take(t, n)) return this.wrote("hidden", r);
570
- let i = this.shown.getLength(), a = H(this.shown.getData(), t);
578
+ let i = this.shown.getLength(), a = G(this.shown.getData(), t);
571
579
  return a === "stale" ? {
572
580
  to: "none",
573
581
  before: i,
@@ -581,7 +589,7 @@ var Mn = class {
581
589
  replace(e) {
582
590
  if (this.aside) {
583
591
  let { index: t, changed: n } = this.aside.replaceBar(e);
584
- return t < 0 ? V : (n && this.onLiveChange({
592
+ return t < 0 ? W : (n && this.onLiveChange({
585
593
  kind: "bar",
586
594
  time: this.aside.getData()[t].time
587
595
  }), {
@@ -590,22 +598,22 @@ var Mn = class {
590
598
  changed: n
591
599
  });
592
600
  }
593
- if (!L(e)) return V;
594
- let t = this.inSeriesUnit(e), n = this.whole, r = n ? Dn(n, t.time) : -1;
601
+ if (!B(e)) return W;
602
+ let t = this.inSeriesUnit(e), n = this.whole, r = n ? jn(n, t.time) : -1;
595
603
  if (n) {
596
- if (r < 0 || !L(n[r])) return V;
604
+ if (r < 0 || !B(n[r])) return W;
597
605
  let e = this.hoursFilter(n);
598
606
  if (e && !e(t.time)) return this.replaceHidden(n, r, t);
599
607
  }
600
608
  let { index: i, changed: a } = this.shown.replaceBar(t);
601
- return i < 0 ? V : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
609
+ return i < 0 ? W : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
602
610
  to: "shown",
603
611
  index: i,
604
612
  changed: a
605
613
  });
606
614
  }
607
615
  beginReplay() {
608
- this.aside || (this.aside = new B(), this.aside.setData(this.whole ?? this.shown.getData()));
616
+ this.aside || (this.aside = new U(), this.aside.setData(this.whole ?? this.shown.getData()));
609
617
  }
610
618
  endReplay() {
611
619
  let e = this.aside;
@@ -625,10 +633,10 @@ var Mn = class {
625
633
  this.shown.updateLastBar(e);
626
634
  }
627
635
  inSeriesUnit(e) {
628
- return An(this.whole ?? this.shown.getData(), e);
636
+ return Pn(this.whole ?? this.shown.getData(), e);
629
637
  }
630
638
  replaceHidden(e, t, n) {
631
- let r = R(n), i = !z(e[t], r);
639
+ let r = V(n), i = !H(e[t], r);
632
640
  return i && (e[t] = r), {
633
641
  to: "hidden",
634
642
  index: -1,
@@ -662,14 +670,14 @@ var Mn = class {
662
670
  return !r || r(e.time);
663
671
  }
664
672
  };
665
- function Nn(e, t) {
673
+ function Ln(e, t) {
666
674
  let n = t[0]?.time, r = 0;
667
675
  for (; n !== void 0 && r < e.length && e[r].time < n;) r++;
668
676
  return r === 0 || r === e.length ? null : e.slice(0, r).concat(t);
669
677
  }
670
678
  //#endregion
671
679
  //#region src/HistoryPager.ts
672
- var Pn = 5e3, Fn = 6e4, In = 500, Ln = class {
680
+ var Rn = 5e3, zn = 6e4, Bn = 500, Vn = class {
673
681
  loader = null;
674
682
  pageSize = 500;
675
683
  loading = !1;
@@ -721,7 +729,7 @@ var Pn = 5e3, Fn = 6e4, In = 500, Ln = class {
721
729
  try {
722
730
  r = await e(t, this.pageSize);
723
731
  } catch (e) {
724
- return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Fn, Pn * 2 ** (this.failures - 1)), this.emit({
732
+ return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(zn, Rn * 2 ** (this.failures - 1)), this.emit({
725
733
  state: "error",
726
734
  count: 0,
727
735
  error: e instanceof Error ? e.message : String(e)
@@ -754,10 +762,10 @@ var Pn = 5e3, Fn = 6e4, In = 500, Ln = class {
754
762
  };
755
763
  //#endregion
756
764
  //#region src/ThemeManager.ts
757
- function Rn(e, t) {
765
+ function Hn(e, t) {
758
766
  return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
759
767
  }
760
- var zn = class t {
768
+ var Un = class t {
761
769
  base;
762
770
  shape = null;
763
771
  font = null;
@@ -776,13 +784,13 @@ var zn = class t {
776
784
  return i;
777
785
  }
778
786
  getTheme() {
779
- return this.effective ??= se(this.base, this.chartType, this.merged()), this.effective;
787
+ return this.effective ??= oe(this.base, this.chartType, this.merged()), this.effective;
780
788
  }
781
789
  getBaseTheme() {
782
790
  return this.base;
783
791
  }
784
792
  setTheme(e) {
785
- let n = t.read(e), r = this.font !== null && Rn(n.font, this.base.font);
793
+ let n = t.read(e), r = this.font !== null && Hn(n.font, this.base.font);
786
794
  this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
787
795
  ...this.base,
788
796
  shape: {
@@ -864,7 +872,7 @@ var zn = class t {
864
872
  };
865
873
  //#endregion
866
874
  //#region src/style/styleOptions.ts
867
- function Bn(e, t) {
875
+ function Wn(e, t) {
868
876
  return t ? {
869
877
  ...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
870
878
  ...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
@@ -872,28 +880,29 @@ function Bn(e, t) {
872
880
  ...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
873
881
  } : {};
874
882
  }
875
- function Vn(e) {
883
+ function Gn(e) {
876
884
  let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
877
885
  return {
878
886
  ...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
879
887
  ...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
880
888
  ...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
881
889
  ...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
882
- ...Bn("horizontal", n?.hLine),
883
- ...Bn("vertical", n?.vLine),
890
+ ...Wn("horizontal", n?.hLine),
891
+ ...Wn("vertical", n?.vLine),
884
892
  ...r === void 0 ? {} : { "crosshair.labelBackground": r },
885
893
  ...e.overrides
886
894
  };
887
895
  }
888
896
  //#endregion
889
897
  //#region src/layout/LayoutManager.ts
890
- var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom", Wn = class {
898
+ var Kn = 200, qn = 80, K = (e) => e.position === "top" || e.position === "bottom", Jn = class {
891
899
  panels = [];
892
900
  containerWidth = 0;
893
901
  containerHeight = 0;
894
902
  priceAxisWidth = o;
895
903
  leftAxisWidth = 0;
896
904
  maximized = null;
905
+ aside = /* @__PURE__ */ new Set();
897
906
  resize(e, t) {
898
907
  this.containerWidth = e, this.containerHeight = t;
899
908
  }
@@ -903,8 +912,8 @@ var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom
903
912
  this.panels.push({
904
913
  id: e,
905
914
  position: n,
906
- size: r ?? (a ? Hn : t),
907
- minSize: a ? Un : i,
915
+ size: r ?? (a ? Kn : t),
916
+ minSize: a ? qn : i,
908
917
  content: {
909
918
  type: "indicator",
910
919
  indicatorInstanceId: e
@@ -923,14 +932,14 @@ var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom
923
932
  }
924
933
  setPanelCollapsed(e, t) {
925
934
  let n = this.panels.find((t) => t.id === e);
926
- return !n || !U(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
935
+ return !n || !K(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
927
936
  }
928
937
  isPanelCollapsed(e) {
929
938
  return !!this.panels.find((t) => t.id === e)?.collapsed;
930
939
  }
931
940
  isPanelShownCollapsed(e) {
932
941
  let t = this.panels.find((t) => t.id === e);
933
- return !t || !U(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
942
+ return !t || !K(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
934
943
  }
935
944
  setPanelScale(e, t) {
936
945
  let n = this.panels.find((t) => t.id === e);
@@ -946,7 +955,7 @@ var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom
946
955
  }
947
956
  setMaximizedPanel(e) {
948
957
  let t = e === null ? null : this.panels.find((t) => t.id === e);
949
- return e !== null && (!t || !U(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
958
+ return e !== null && (!t || !K(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
950
959
  }
951
960
  getMaximizedPanel() {
952
961
  return this.maximized;
@@ -967,19 +976,19 @@ var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom
967
976
  this.panels = [...this.panels].sort((e, n) => t(e) - t(n));
968
977
  }
969
978
  shownSize(e, t) {
970
- return U(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
979
+ return K(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
971
980
  }
972
981
  setPanelPosition(e, n) {
973
982
  let r = this.panels.find((t) => t.id === e);
974
983
  if (r) {
975
984
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
976
- r.position = n, a !== o && (r.size = o ? Hn : t, r.minSize = o ? Un : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
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));
977
986
  }
978
987
  }
979
988
  setPanelSize(e, t) {
980
989
  let n = this.panels.find((t) => t.id === e);
981
990
  if (n) {
982
- let e = U(n) ? this.containerHeight - s - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
991
+ let e = K(n) ? this.containerHeight - s - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
983
992
  n.size = Math.max(n.minSize, r), n.collapsed = void 0, this.maximized = null;
984
993
  }
985
994
  }
@@ -992,105 +1001,109 @@ var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom
992
1001
  getPanels() {
993
1002
  return this.panels;
994
1003
  }
1004
+ setPanelsAside(e) {
1005
+ let t = e.size !== this.aside.size || [...e].some((e) => !this.aside.has(e));
1006
+ return this.aside = new Set(e), t;
1007
+ }
995
1008
  resolve() {
996
- let e = this.panels.filter((e) => e.position === "left"), t = this.panels.filter((e) => e.position === "right"), n = this.panels.filter((e) => e.position === "top"), r = this.panels.filter((e) => e.position === "bottom"), i = (n.length + r.length - 1) * 20, a = this.maximized ? this.panels.find((e) => e.id === this.maximized) : void 0, o = Math.max(a?.minSize ?? 0, this.containerHeight - s - 48 - i), c = (e) => this.shownSize(e, o), l = e.reduce((e, t) => e + t.size, 0), u = t.reduce((e, t) => e + t.size, 0), d = n.reduce((e, t) => e + c(t), 0), f = r.reduce((e, t) => e + c(t), 0), p = l + this.leftAxisWidth, m = {
997
- x: p,
998
- y: d,
999
- width: Math.max(0, this.containerWidth - p - u - this.priceAxisWidth),
1000
- height: Math.max(0, this.containerHeight - d - f - s)
1001
- }, h = [], g = [], _ = 0;
1002
- for (let t of e) h.push({
1003
- config: t,
1009
+ let e = this.panels.filter((e) => !this.aside.has(e.id)), t = e.filter((e) => e.position === "left"), n = e.filter((e) => e.position === "right"), r = e.filter((e) => e.position === "top"), i = e.filter((e) => e.position === "bottom"), a = (r.length + i.length - 1) * 20, o = this.maximized ? e.find((e) => e.id === this.maximized) : void 0, c = Math.max(o?.minSize ?? 0, this.containerHeight - s - 48 - a), l = (e) => this.shownSize(e, c), u = t.reduce((e, t) => e + t.size, 0), d = n.reduce((e, t) => e + t.size, 0), f = r.reduce((e, t) => e + l(t), 0), p = i.reduce((e, t) => e + l(t), 0), m = u + this.leftAxisWidth, h = {
1010
+ x: m,
1011
+ y: f,
1012
+ width: Math.max(0, this.containerWidth - m - d - this.priceAxisWidth),
1013
+ height: Math.max(0, this.containerHeight - f - p - s)
1014
+ }, g = [], _ = [], v = 0;
1015
+ for (let e of t) g.push({
1016
+ config: e,
1004
1017
  rect: {
1005
- x: _,
1018
+ x: v,
1006
1019
  y: 0,
1007
- width: t.size,
1020
+ width: e.size,
1008
1021
  height: this.containerHeight - s
1009
1022
  }
1010
- }), g.push({
1011
- panelId: t.id,
1023
+ }), _.push({
1024
+ panelId: e.id,
1012
1025
  rect: {
1013
- x: _ + t.size - 2,
1026
+ x: v + e.size - 2,
1014
1027
  y: 0,
1015
1028
  width: 4,
1016
1029
  height: this.containerHeight
1017
1030
  },
1018
1031
  orientation: "vertical"
1019
- }), _ += t.size;
1020
- let v = 0;
1021
- for (let e of n) {
1022
- let t = c(e);
1023
- h.push({
1032
+ }), v += e.size;
1033
+ let y = 0;
1034
+ for (let e of r) {
1035
+ let t = l(e);
1036
+ g.push({
1024
1037
  config: e,
1025
1038
  rect: {
1026
- x: p,
1027
- y: v,
1028
- width: m.width,
1039
+ x: m,
1040
+ y,
1041
+ width: h.width,
1029
1042
  height: t
1030
1043
  }
1031
- }), g.push({
1044
+ }), _.push({
1032
1045
  panelId: e.id,
1033
1046
  rect: {
1034
- x: p,
1035
- y: v + t - 2,
1036
- width: m.width,
1047
+ x: m,
1048
+ y: y + t - 2,
1049
+ width: h.width,
1037
1050
  height: 4
1038
1051
  },
1039
1052
  orientation: "horizontal"
1040
- }), v += t;
1053
+ }), y += t;
1041
1054
  }
1042
- v = m.y + m.height;
1043
- for (let e of r) {
1044
- let t = c(e);
1045
- h.push({
1055
+ y = h.y + h.height;
1056
+ for (let e of i) {
1057
+ let t = l(e);
1058
+ g.push({
1046
1059
  config: e,
1047
1060
  rect: {
1048
- x: p,
1049
- y: v,
1050
- width: m.width,
1061
+ x: m,
1062
+ y,
1063
+ width: h.width,
1051
1064
  height: t
1052
1065
  }
1053
- }), g.push({
1066
+ }), _.push({
1054
1067
  panelId: e.id,
1055
1068
  rect: {
1056
- x: p,
1057
- y: v - 2,
1058
- width: m.width,
1069
+ x: m,
1070
+ y: y - 2,
1071
+ width: h.width,
1059
1072
  height: 4
1060
1073
  },
1061
1074
  orientation: "horizontal"
1062
- }), v += t;
1075
+ }), y += t;
1063
1076
  }
1064
- _ = p + m.width + this.priceAxisWidth;
1065
- for (let e of t) h.push({
1077
+ v = m + h.width + this.priceAxisWidth;
1078
+ for (let e of n) g.push({
1066
1079
  config: e,
1067
1080
  rect: {
1068
- x: _,
1081
+ x: v,
1069
1082
  y: 0,
1070
1083
  width: e.size,
1071
1084
  height: this.containerHeight - s
1072
1085
  }
1073
- }), g.push({
1086
+ }), _.push({
1074
1087
  panelId: e.id,
1075
1088
  rect: {
1076
- x: _ - 2,
1089
+ x: v - 2,
1077
1090
  y: 0,
1078
1091
  width: 4,
1079
1092
  height: this.containerHeight
1080
1093
  },
1081
1094
  orientation: "vertical"
1082
- }), _ += e.size;
1095
+ }), v += e.size;
1083
1096
  return {
1084
- mainChartRect: m,
1085
- panels: h,
1086
- dividers: g
1097
+ mainChartRect: h,
1098
+ panels: g,
1099
+ dividers: _
1087
1100
  };
1088
1101
  }
1089
1102
  getMainChartRect() {
1090
1103
  return this.resolve().mainChartRect;
1091
1104
  }
1092
- }, Gn = 14, Kn = 14, qn = 22, Jn = 4;
1093
- function Yn(e) {
1105
+ }, Yn = 14, Xn = 14, Zn = 22, Qn = 4;
1106
+ function $n(e) {
1094
1107
  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] : [
1095
1108
  t,
1096
1109
  n,
@@ -1099,16 +1112,16 @@ function Yn(e) {
1099
1112
  for (let t of f) {
1100
1113
  if (!Number.isFinite(t)) continue;
1101
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);
1102
- p = Math.max(p, l(n, `500 ${s}px ${a}`) + Gn, l(r, `bold 11px ${a}`) + Kn, l(r, `600 ${s}px ${a}`) + qn);
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);
1103
1116
  }
1104
- return p <= o ? o : Math.ceil(p / Jn) * Jn;
1117
+ return p <= o ? o : Math.ceil(p / Qn) * Qn;
1105
1118
  }
1106
- function Xn(e, t) {
1119
+ function er(e, t) {
1107
1120
  return t > e || t <= e - 12 ? t : e;
1108
1121
  }
1109
1122
  //#endregion
1110
1123
  //#region src/layout/labelWidths.ts
1111
- var Zn = 512, Qn = class {
1124
+ var tr = 512, nr = class {
1112
1125
  widths = /* @__PURE__ */ new Map();
1113
1126
  fonts;
1114
1127
  forget = () => this.widths.clear();
@@ -1119,12 +1132,12 @@ var Zn = 512, Qn = class {
1119
1132
  let r = `${t}\n${e}`, i = this.widths.get(r);
1120
1133
  if (i !== void 0) return i;
1121
1134
  let a = n();
1122
- return this.widths.size >= Zn && this.widths.clear(), this.widths.set(r, a), a;
1135
+ return this.widths.size >= tr && this.widths.clear(), this.widths.set(r, a), a;
1123
1136
  }
1124
1137
  destroy() {
1125
1138
  this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
1126
1139
  }
1127
- }, $n = class {
1140
+ }, rr = class {
1128
1141
  netY = 0;
1129
1142
  travelX = 0;
1130
1143
  engaged = !1;
@@ -1140,11 +1153,11 @@ var Zn = 512, Qn = class {
1140
1153
  }
1141
1154
  return this.engaged;
1142
1155
  }
1143
- }, er = 1;
1144
- function tr(e, t) {
1156
+ }, ir = 1;
1157
+ function ar(e, t) {
1145
1158
  return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
1146
1159
  }
1147
- function W(e) {
1160
+ function q(e) {
1148
1161
  switch (e.kind) {
1149
1162
  case "indicator": return `indicator:${e.plugin.descriptor.id}`;
1150
1163
  case "drawing": return `drawing:${e.plugin.descriptor.type}`;
@@ -1154,25 +1167,25 @@ function W(e) {
1154
1167
  }
1155
1168
  //#endregion
1156
1169
  //#region src/plugins/registry.ts
1157
- var G = /* @__PURE__ */ new Map();
1158
- function nr(e) {
1159
- G.set(W(e), e);
1170
+ var J = /* @__PURE__ */ new Map();
1171
+ function or(e) {
1172
+ J.set(q(e), e);
1160
1173
  }
1161
- function rr(e) {
1162
- return G.delete(e);
1174
+ function sr(e) {
1175
+ return J.delete(e);
1163
1176
  }
1164
- function ir() {
1165
- return [...G.values()];
1177
+ function cr() {
1178
+ return [...J.values()];
1166
1179
  }
1167
- function ar() {
1168
- G.clear();
1180
+ function lr() {
1181
+ J.clear();
1169
1182
  }
1170
1183
  //#endregion
1171
1184
  //#region src/plugins/PluginManager.ts
1172
- var or = class {
1185
+ var ur = class {
1173
1186
  plugins = /* @__PURE__ */ new Map();
1174
1187
  constructor(e, t = {}) {
1175
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of ir()) this.add(e);
1188
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of cr()) this.add(e);
1176
1189
  for (let e of t.plugins ?? []) this.add(e);
1177
1190
  }
1178
1191
  register(e) {
@@ -1200,17 +1213,17 @@ var or = class {
1200
1213
  return e;
1201
1214
  }
1202
1215
  add(e) {
1203
- this.plugins.set(W(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1216
+ this.plugins.set(q(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1204
1217
  }
1205
- }, sr = {
1218
+ }, dr = {
1206
1219
  orderPlace: (e, t) => e.placeOrder(t),
1207
1220
  orderModify: (e, t) => e.modifyOrder(t),
1208
1221
  orderCancel: (e, t) => e.cancelOrder(t),
1209
1222
  positionModify: (e, t) => e.modifyPosition(t),
1210
1223
  positionClose: (e, t) => e.closePosition(t),
1211
- positionReverse: (e, t, n) => cr(e, t, n)
1224
+ positionReverse: (e, t, n) => fr(e, t, n)
1212
1225
  };
1213
- async function cr(e, t, n) {
1226
+ async function fr(e, t, n) {
1214
1227
  let { reversing: r } = n;
1215
1228
  if (!r.has(t.positionId)) {
1216
1229
  r.add(t.positionId);
@@ -1239,7 +1252,7 @@ async function cr(e, t, n) {
1239
1252
  }
1240
1253
  }
1241
1254
  }
1242
- function lr(e, t) {
1255
+ function pr(e, t) {
1243
1256
  let n = [], r = null, i = {
1244
1257
  positions: () => r ?? t.getPositions?.() ?? [],
1245
1258
  reversing: /* @__PURE__ */ new Set()
@@ -1249,8 +1262,8 @@ function lr(e, t) {
1249
1262
  e.data && t.onFill?.(e.data);
1250
1263
  };
1251
1264
  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));
1252
- for (let r of Object.keys(sr)) {
1253
- let a = sr[r], o = t.onIntent(r, (n) => {
1265
+ for (let r of Object.keys(dr)) {
1266
+ let a = dr[r], o = t.onIntent(r, (n) => {
1254
1267
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
1255
1268
  message: `Execution command failed: ${r}`,
1256
1269
  cause: e
@@ -1264,7 +1277,7 @@ function lr(e, t) {
1264
1277
  }
1265
1278
  //#endregion
1266
1279
  //#region src/replay/ReplayStepLoader.ts
1267
- var ur = 1e3, dr = class {
1280
+ var mr = 1e3, hr = class {
1268
1281
  pieces = /* @__PURE__ */ new Map();
1269
1282
  asked = /* @__PURE__ */ new Set();
1270
1283
  inFlight = !1;
@@ -1297,7 +1310,7 @@ var ur = 1e3, dr = class {
1297
1310
  this.done = !0;
1298
1311
  }
1299
1312
  ask(e, t) {
1300
- let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(ur / n)), s = Math.min(e.length, t + o), c = s < e.length ? e[s].time : e[e.length - 1].time + r, l = e.slice(t, s);
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);
1301
1314
  for (let e of l) this.asked.add(e.time);
1302
1315
  this.inFlight = !0, a({
1303
1316
  state: "loading",
@@ -1338,12 +1351,12 @@ var ur = 1e3, dr = class {
1338
1351
  ...n === void 0 ? {} : { error: n }
1339
1352
  });
1340
1353
  }
1341
- }, fr = 1 / 3, pr = .25, mr = .5;
1342
- function hr(e, t) {
1343
- let n = (e.high - e.low) * pr;
1344
- return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * mr;
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;
1345
1358
  }
1346
- function gr(e) {
1359
+ function br(e) {
1347
1360
  return e.close >= e.open ? [
1348
1361
  e.open,
1349
1362
  e.low,
@@ -1356,22 +1369,22 @@ function gr(e) {
1356
1369
  e.close
1357
1370
  ];
1358
1371
  }
1359
- function _r(e, t, n) {
1360
- let r = gr(e), i = [
1372
+ function xr(e, t, n) {
1373
+ let r = br(e), i = [
1361
1374
  1,
1362
1375
  2,
1363
1376
  3
1364
1377
  ].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
1365
1378
  return r.forEach((r, c) => {
1366
- c > 0 && (s += a > 0 ? i[c - 1] / a : fr), !(c === 0 && t > 0) && o.push({
1379
+ c > 0 && (s += a > 0 ? i[c - 1] / a : gr), !(c === 0 && t > 0) && o.push({
1367
1380
  price: r,
1368
1381
  time: e.time,
1369
1382
  at: (t + s) / n
1370
1383
  });
1371
1384
  }), o;
1372
1385
  }
1373
- function vr(e, t = []) {
1374
- let n = t.length > 0 && hr(e, t) ? t : [e], r = n.length, i = yr(n.flatMap((e, t) => _r(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
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;
1375
1388
  return {
1376
1389
  bar: e,
1377
1390
  points: i,
@@ -1381,7 +1394,7 @@ function vr(e, t = []) {
1381
1394
  }))
1382
1395
  };
1383
1396
  }
1384
- function yr(e, t) {
1397
+ function Cr(e, t) {
1385
1398
  let n = e.length - 1, r = e.map((e, r) => ({
1386
1399
  ...e,
1387
1400
  price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
@@ -1396,7 +1409,7 @@ function yr(e, t) {
1396
1409
  };
1397
1410
  return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
1398
1411
  }
1399
- function br(e, t) {
1412
+ function wr(e, t) {
1400
1413
  let n = e.points;
1401
1414
  if (t <= n[0].at) return n[0].price;
1402
1415
  for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
@@ -1405,8 +1418,8 @@ function br(e, t) {
1405
1418
  }
1406
1419
  return n[n.length - 1].price;
1407
1420
  }
1408
- var xr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
1409
- function Sr(e, t) {
1421
+ var Tr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
1422
+ function Er(e, t) {
1410
1423
  let n = 0, r = 0;
1411
1424
  for (let i of e.volumeAt) {
1412
1425
  if (t >= i.at) {
@@ -1417,10 +1430,10 @@ function Sr(e, t) {
1417
1430
  }
1418
1431
  return n;
1419
1432
  }
1420
- function Cr(e, t) {
1421
- let n = xr(t);
1433
+ function Dr(e, t) {
1434
+ let n = Tr(t);
1422
1435
  if (n >= 1) return { ...e.bar };
1423
- let r = br(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
1436
+ let r = wr(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
1424
1437
  for (let t of e.points) {
1425
1438
  if (t.at > n) break;
1426
1439
  i = Math.max(i, t.price), a = Math.min(a, t.price);
@@ -1431,29 +1444,29 @@ function Cr(e, t) {
1431
1444
  high: i,
1432
1445
  low: a,
1433
1446
  close: r,
1434
- volume: Sr(e, n)
1447
+ volume: Er(e, n)
1435
1448
  };
1436
1449
  }
1437
- function wr(e, t) {
1438
- let n = xr(t), r = 0;
1450
+ function Or(e, t) {
1451
+ let n = Tr(t), r = 0;
1439
1452
  for (let t of e.points) {
1440
1453
  if (t.at > n) break;
1441
1454
  r = t.at;
1442
1455
  }
1443
1456
  return r;
1444
1457
  }
1445
- function K(e, t, n) {
1458
+ function Y(e, t, n) {
1446
1459
  let r = [], i = e.bar.time;
1447
1460
  for (let a of e.points) {
1448
1461
  if (a.at > n) break;
1449
1462
  i = a.time, a.at > t && r.push([a.price, a.time]);
1450
1463
  }
1451
- let a = br(e, n);
1464
+ let a = wr(e, n);
1452
1465
  return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
1453
1466
  }
1454
1467
  //#endregion
1455
1468
  //#region src/replay/replayStep.ts
1456
- var Tr = [
1469
+ var kr = [
1457
1470
  "1m",
1458
1471
  "3m",
1459
1472
  "5m",
@@ -1464,42 +1477,42 @@ var Tr = [
1464
1477
  "4h",
1465
1478
  "1d"
1466
1479
  ];
1467
- function Er(e, t) {
1468
- let n = w(e);
1469
- return n > 0 ? Tr.filter((e) => {
1470
- let r = w(e);
1480
+ function Ar(e, t) {
1481
+ let n = T(e);
1482
+ return n > 0 ? kr.filter((e) => {
1483
+ let r = T(e);
1471
1484
  return r < n && n % r === 0 && t(e);
1472
1485
  }) : [];
1473
1486
  }
1474
- function Dr(e, t, n) {
1475
- let r = Er(t, n);
1487
+ function jr(e, t, n) {
1488
+ let r = Ar(t, n);
1476
1489
  if (e !== "auto") return r.includes(e) ? e : null;
1477
- let i = w(t);
1478
- return r.find((e) => i / w(e) <= 60) ?? null;
1490
+ let i = T(t);
1491
+ return r.find((e) => i / T(e) <= 60) ?? null;
1479
1492
  }
1480
1493
  //#endregion
1481
1494
  //#region src/Chart.ts
1482
- var Or = {
1495
+ var Mr = {
1483
1496
  min: 0,
1484
1497
  max: 100
1485
- }, kr = "exchange", Ar = kr;
1486
- function jr(e) {
1498
+ }, Nr = "exchange", Pr = Nr;
1499
+ function Fr(e) {
1487
1500
  if (typeof e == "string" && e !== "exchange" && !v(e)) throw RangeError(`Unknown time zone: ${e}`);
1488
1501
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
1489
1502
  }
1490
- function Mr(e, t) {
1491
- let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
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);
1492
1505
  return i === void 0 ? e : {
1493
1506
  ...e,
1494
1507
  timeZone: i,
1495
1508
  timezone: i
1496
1509
  };
1497
1510
  }
1498
- var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontalLine", "crossLine"]), zr = new Set(["verticalLine", "crossLine"]), Br = class {
1499
- static version = "1.53.1";
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.54.1";
1500
1513
  engine;
1501
1514
  viewport;
1502
- series = new Mn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
1515
+ series = new In((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
1503
1516
  themeManager;
1504
1517
  layoutManager;
1505
1518
  pluginManager;
@@ -1514,6 +1527,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1514
1527
  execTeardown = null;
1515
1528
  autoScrollOnNewBar = !0;
1516
1529
  displayDataCache = null;
1530
+ indicatorsOnDrawn = null;
1517
1531
  reshapeMemo = new ot();
1518
1532
  displayDataStep;
1519
1533
  indicatorUpdateFrom = null;
@@ -1525,13 +1539,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1525
1539
  renderDeferred = !1;
1526
1540
  priceAxisWidth = o;
1527
1541
  measureCtx;
1528
- labelWidths = new Qn();
1542
+ labelWidths = new nr();
1529
1543
  containerSizeCache = null;
1530
1544
  containerSizeCacheTime = 0;
1531
1545
  lastEmittedRange = null;
1532
1546
  lastEmittedPriceRange = null;
1533
1547
  lastEmittedBarWidth = null;
1534
1548
  chartLegend;
1549
+ legendStack = null;
1535
1550
  watermark;
1536
1551
  barCountdown;
1537
1552
  unrestoredIndicators = [];
@@ -1584,7 +1599,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1584
1599
  replayForming = null;
1585
1600
  replayPhaseUnsub = null;
1586
1601
  undoRedoManager;
1587
- autoSaveScheduler = new Tn((e) => this.saveState(e));
1602
+ autoSaveScheduler = new kn((e) => this.saveState(e));
1588
1603
  animator;
1589
1604
  crosshairTooltip;
1590
1605
  pinnedTooltip;
@@ -1636,7 +1651,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1636
1651
  snapshotKey = null;
1637
1652
  historyCheckQueued = !1;
1638
1653
  constructor(e, t) {
1639
- t.timeZone != null && jr(t.timeZone), this.container = e, this.options = {
1654
+ t.timeZone != null && Fr(t.timeZone), this.container = e, this.options = {
1640
1655
  ...t,
1641
1656
  chartType: t.chartType ?? "candlestick"
1642
1657
  }, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
@@ -1674,11 +1689,11 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1674
1689
  logScale: n.logScale ?? !0,
1675
1690
  timeframes: n.timeframes ?? [],
1676
1691
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
1677
- }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new Ln({
1692
+ }, 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({
1678
1693
  oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
1679
1694
  prepend: (e) => this.prependBars(e),
1680
1695
  emit: (e) => this.eventBus.emit("historyLoad", e)
1681
- }), this.themeManager = new zn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Vn(t), "host", !1), this.layoutManager = new Wn(), this.indicatorEngine = new ze(), this.pluginManager = new or(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Pe(), zt(this.indicatorEngine), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.indicatorEngine.register(new ft(this.symbolSeries)), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.drawingManager = new je(), Rt(this.drawingManager), this.drawingRenderer = new Me(this.drawingManager), this.drawingManager.setRequestRender(() => {
1696
+ }), 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(() => {
1682
1697
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
1683
1698
  }), this.drawingManager.setEventCallback((e, t) => {
1684
1699
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
@@ -1711,27 +1726,42 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1711
1726
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
1712
1727
  }, 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) => {
1713
1728
  if (e !== null && t) {
1714
- let n = this.crosshairSeries(), r = e >= 0 && e < n.length ? n[e] : void 0;
1715
- this.chartLegend.setHoverBar(r ?? null, e > 0 ? n[e - 1] ?? null : null);
1716
- let i = this.viewport.getState(), a = t.y >= i.chartRect.y && t.y <= i.chartRect.y + i.chartRect.height;
1717
- r && a && this.features.crosshairTooltip ? this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize(), {
1718
- prevClose: e > 0 ? n[e - 1]?.close : void 0,
1719
- priceRange: i.priceRange,
1720
- plot: i.chartRect,
1721
- barStepMs: Dt(n),
1722
- timeUnit: u(n)
1723
- }) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
1729
+ 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;
1730
+ this.chartLegend.setHoverBar(i ?? null, e > 0 ? n[e - 1] ?? null : null), this.features.legend && this.engine.requestRender(r.Hover);
1731
+ let c = this.viewport.getState(), l = t.y >= c.chartRect.y && t.y <= c.chartRect.y + c.chartRect.height;
1732
+ if (i && l && this.features.crosshairTooltip) {
1733
+ let e = s === i.time ? i : {
1734
+ ...i,
1735
+ time: s ?? i.time
1736
+ };
1737
+ this.crosshairTooltip.show(t, e, this.themeManager.getTheme(), this.cachedContainerSize(), {
1738
+ prevClose: a,
1739
+ priceRange: c.priceRange,
1740
+ plot: c.chartRect,
1741
+ barStepMs: Dt(o),
1742
+ timeUnit: u(o)
1743
+ });
1744
+ } else this.crosshairTooltip.hide();
1745
+ this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), i ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
1724
1746
  point: t,
1725
- bar: r,
1726
- barIndex: e
1747
+ bar: i,
1748
+ barIndex: e,
1749
+ ...s === void 0 ? {} : { time: s },
1750
+ ...a === void 0 ? {} : { prevClose: a }
1727
1751
  });
1728
- } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
1729
- }), this.chartLegend = new xe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new Tt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new wt(), this.volumeProfile = new Ct(), this.marketProfile = new Ge(), this.depthHeatmap = new Ae(), this.periodLevels = new Ye(), this.pivotMarkers = new Ze(), this.barCountdown = new _e(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new lt(), this.sessionShading = new ut(), this.compareRenderer = new Se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1752
+ } else {
1753
+ this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.features.legend && this.engine.requestRender(r.Hover), this.eventBus.emit("crosshairLeave", {});
1754
+ let e = this.crosshairHandler.getSyncedSlot();
1755
+ e !== null && this.showSyncedBar(e);
1756
+ }
1757
+ }), this.chartLegend = new be(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
1758
+ this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), this.engine.requestRender();
1759
+ }), 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({
1730
1760
  visible: t.sessionBreaks.visible ?? !0,
1731
1761
  color: t.sessionBreaks.color,
1732
1762
  lineStyle: t.sessionBreaks.lineStyle,
1733
1763
  lineWidth: t.sessionBreaks.lineWidth
1734
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new De(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Xe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = x(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Kr(t.shapes)), t.font && this.themeManager.setFont(Gr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new He({
1764
+ }) : 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({
1735
1765
  scrollBars: (e) => {
1736
1766
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1737
1767
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1775,8 +1805,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1775
1805
  }
1776
1806
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1777
1807
  }
1778
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Oe(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new pe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(At).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
1779
- this.eventBus.emit("alertTriggered", q(e)), this.eventBus.emit("dataUpdate", {
1808
+ }, 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) => {
1809
+ this.eventBus.emit("alertTriggered", X(e)), this.eventBus.emit("dataUpdate", {
1780
1810
  kind: "alert",
1781
1811
  alert: "triggered",
1782
1812
  alertId: e.id,
@@ -1784,13 +1814,13 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1784
1814
  message: e.message
1785
1815
  });
1786
1816
  }), this.alertManager.on("added", (e) => {
1787
- this.eventBus.emit("alertAdd", q(e));
1817
+ this.eventBus.emit("alertAdd", X(e));
1788
1818
  }), this.alertManager.on("removed", (e) => {
1789
1819
  this.eventBus.emit("alertRemove", { id: e });
1790
1820
  }), this.alertManager.on("expired", (e) => {
1791
- this.eventBus.emit("alertExpired", q(e));
1821
+ this.eventBus.emit("alertExpired", X(e));
1792
1822
  }), this.alertManager.on("updated", (e) => {
1793
- this.eventBus.emit("alertUpdate", q(e));
1823
+ this.eventBus.emit("alertUpdate", X(e));
1794
1824
  }), this.signalMarkerManager = new dt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
1795
1825
  this.eventBus.emit("signalMarkerAdd", {
1796
1826
  id: e.id,
@@ -1815,7 +1845,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1815
1845
  }), this.replayManager.on("stateChange", (e) => {
1816
1846
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
1817
1847
  }), this.measureOverlay = new Ke(), this.interactionManager = new Be(e), this.features.panning) {
1818
- let e = new $n();
1848
+ let e = new rr();
1819
1849
  this.interactionManager.setPanHandler(new qe((t, n) => {
1820
1850
  t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1821
1851
  }, () => e.reset()));
@@ -1831,7 +1861,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1831
1861
  this.interactionManager.setZoomHandler(new Et((e, t) => {
1832
1862
  this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
1833
1863
  }));
1834
- let e = new ge((e) => {
1864
+ let e = new he((e) => {
1835
1865
  this.holdPriceScale(), this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1836
1866
  }, (e) => {
1837
1867
  let t = this.viewport.getState().chartRect.width;
@@ -1861,7 +1891,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1861
1891
  ...this.viewport.getState(),
1862
1892
  data: this.getDisplayData()
1863
1893
  })), this.features.alerts) {
1864
- let e = new fe(this.alertManager, () => this.viewport.getState());
1894
+ let e = new de(this.alertManager, () => this.viewport.getState());
1865
1895
  this.interactionManager.setAlertDragHandler(e);
1866
1896
  }
1867
1897
  let o = new Je();
@@ -1931,7 +1961,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1931
1961
  end: () => {
1932
1962
  let e = this.selectionBoxOverlay.end();
1933
1963
  if (e && this.zoomAreaMode) {
1934
- if (e.x1 - e.x0 < Lr) return;
1964
+ if (e.x1 - e.x0 < Vr) return;
1935
1965
  this.zoomToBox(e), this.setZoomAreaMode(!1);
1936
1966
  return;
1937
1967
  }
@@ -1970,12 +2000,12 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1970
2000
  let n = this.series.bars();
1971
2001
  this.seriesArriving = n.length === 0;
1972
2002
  let r = n[n.length - 1];
1973
- t || (this.alertManager.clearLastValues(), r && this.alertManager.seedLastValue("price", r.close)), this.recalcIndicators(n), r && this.currentPriceLine.setPrice(r.close), this.updateViewportAndRender(!0), this.emitBars(n.length);
2003
+ t || (this.alertManager.clearLastValues(), r && this.alertManager.seedLastValue("price", r.close)), this.recalcIndicators(n), r && this.currentPriceLine.setPrice(r.close), this.updateViewportAndRender(!0), this.fitFewColumns(), this.emitBars(n.length);
1974
2004
  }
1975
2005
  loadDuringReplay(e) {
1976
2006
  this.snapshotKey = null, this.history.reset(), this.alertManager.clearLastValues();
1977
2007
  let t = e[e.length - 1];
1978
- t && L(t) && this.alertManager.seedLastValue("price", t.close), this.replaySession && (this.replaySession.price = null), this.series.load(e);
2008
+ t && B(t) && this.alertManager.seedLastValue("price", t.close), this.replaySession && (this.replaySession.price = null), this.series.load(e);
1979
2009
  }
1980
2010
  prependBars(e) {
1981
2011
  if (this.replaySession) return this.series.prepend(e).taken;
@@ -1983,7 +2013,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1983
2013
  if (i === 0) return a;
1984
2014
  let o = this.series.bars();
1985
2015
  if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.reshapeMemo.clear(), this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), r !== void 0) {
1986
- let e = Math.round(M(r, this.getDisplayData()));
2016
+ let e = Math.round(P(r, this.getDisplayData()));
1987
2017
  this.viewport.prependBars(e - n);
1988
2018
  }
1989
2019
  return this.updateViewportAndRender(), a;
@@ -2011,17 +2041,17 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2011
2041
  }
2012
2042
  checkHistory() {
2013
2043
  this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
2014
- if (this.historyCheckQueued = !1, !this.replayPages() || !this.history.hasLoader() || I(this.options.chartType)) return;
2044
+ if (this.historyCheckQueued = !1, !this.replayPages() || !this.history.hasLoader() || R(this.options.chartType)) return;
2015
2045
  let { visibleRange: e, chartRect: t } = this.viewport.getState();
2016
2046
  if (t.width <= 0) return;
2017
2047
  let { from: n, to: r } = e;
2018
- this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Ir, r - n));
2048
+ this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Br, r - n));
2019
2049
  }));
2020
2050
  }
2021
2051
  useStreamHistory(e, t, n = !0) {
2022
2052
  if (this.hostHistoryLoader) return;
2023
- let r = N(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
2024
- if (!i || a === null || ue(a) !== null) {
2053
+ let r = F(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
2054
+ if (!i || a === null || le(a) !== null) {
2025
2055
  this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
2026
2056
  return;
2027
2057
  }
@@ -2029,7 +2059,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2029
2059
  this.history.setLoader((e, t) => i.call(r, o, a, e, t), t), this.historyFromStream = !0, n && this.checkHistory();
2030
2060
  }
2031
2061
  appendBar(e) {
2032
- if (!L(e)) return;
2062
+ if (!B(e)) return;
2033
2063
  let t = this.series.append(e);
2034
2064
  if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
2035
2065
  this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
@@ -2039,7 +2069,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2039
2069
  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);
2040
2070
  }
2041
2071
  appendBars(e) {
2042
- if (e = e.filter(L), e.length === 0) return;
2072
+ if (e = e.filter(B), e.length === 0) return;
2043
2073
  let t = e[e.length - 1].close, n = this.series.appendMany(e);
2044
2074
  if (n.refiltered && (this.displayDataCache = null), n.shown === 0) {
2045
2075
  this.takeLivePrice(t), n.aside || this.scheduleRender();
@@ -2051,7 +2081,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2051
2081
  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);
2052
2082
  }
2053
2083
  updateLastBar(e) {
2054
- if (!L(e)) return;
2084
+ if (!B(e)) return;
2055
2085
  let t = this.series.updateLast(e);
2056
2086
  if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
2057
2087
  this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
@@ -2073,7 +2103,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2073
2103
  this.recalcIndicatorsFrom(n, n.length - 1), this.followLivePrice(e.price), this.scheduleRender();
2074
2104
  }
2075
2105
  updateBar(e) {
2076
- if (!L(e)) return !1;
2106
+ if (!B(e)) return !1;
2077
2107
  let t = this.series.replace(e);
2078
2108
  return t.to === "none" ? !1 : (t.to === "shown" && t.changed && this.showCorrection(t.index), !0);
2079
2109
  }
@@ -2100,23 +2130,29 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2100
2130
  }
2101
2131
  setChartType(e) {
2102
2132
  let t = this.options.chartType ?? "candlestick";
2103
- this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.applyTimeSpacing(), this.updateViewportAndRender(!0), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
2133
+ this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.applyTimeSpacing(), this.updateViewportAndRender(!0), this.fitFewColumns(), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
2104
2134
  type: e,
2105
2135
  previous: t
2106
2136
  });
2107
2137
  }
2138
+ fitFewColumns() {
2139
+ let e = this.options.chartType;
2140
+ if (!R(e) || this.pluginManager.getChartType(e)) return;
2141
+ let t = this.getDisplayData().length, { chartRect: n, barWidth: r, barSpacing: i } = this.viewport.getState(), a = n.width / (r + i);
2142
+ t > 0 && a > t + this.viewport.getRightMargin() && this.fitContent();
2143
+ }
2108
2144
  applyTimeSpacing() {
2109
- let e = !this.tickStream && !I(this.options.chartType);
2145
+ let e = !this.tickStream && !R(this.options.chartType);
2110
2146
  this.timeAxis.setTimesPastData(e), this.crosshairHandler.setTimesPastData(e);
2111
2147
  }
2112
2148
  setChartTypeOptions(e) {
2113
2149
  this.chartTypeOptions = {
2114
2150
  ...this.chartTypeOptions,
2115
- ...x(e)
2116
- }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.a11y?.refresh(!0), this.markStateChanged();
2151
+ ...S(e)
2152
+ }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.fitFewColumns(), this.a11y?.refresh(!0), this.markStateChanged();
2117
2153
  }
2118
2154
  getChartTypeOptions() {
2119
- return x(this.chartTypeOptions);
2155
+ return S(this.chartTypeOptions);
2120
2156
  }
2121
2157
  setExtendedHours(e) {
2122
2158
  e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
@@ -2136,7 +2172,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2136
2172
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
2137
2173
  }
2138
2174
  setShapes(e) {
2139
- let t = Kr(e);
2175
+ let t = Xr(e);
2140
2176
  t.tagRadius !== void 0 && (this.themeManager.setShape({
2141
2177
  ...this.themeManager.getTheme().shape,
2142
2178
  ...t
@@ -2148,7 +2184,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2148
2184
  setFont(e) {
2149
2185
  if (e === null) this.themeManager.setFont(null);
2150
2186
  else {
2151
- let t = Gr(e);
2187
+ let t = Yr(e);
2152
2188
  if (Object.keys(t).length === 0) return;
2153
2189
  this.themeManager.setFont(t);
2154
2190
  }
@@ -2186,7 +2222,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2186
2222
  }
2187
2223
  addIndicatorNow(e, t, n, r) {
2188
2224
  if (!this.isIndicatorAllowed(e)) return null;
2189
- let i = this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e), a = i ? this.paneFor(i, t, r.pane) : null, o = this.indicatorEngine.addIndicator(e, t, this.series.bars(), {
2225
+ let i = this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e), a = i ? this.paneFor(i, t, r.pane) : null, o = this.indicatorEngine.addIndicator(e, t, this.indicatorBars(), {
2190
2226
  ...a ? { pane: a } : {},
2191
2227
  ...r.scale === "left" ? { scale: "left" } : {},
2192
2228
  ...r.instanceId ? { instanceId: r.instanceId } : {}
@@ -2198,8 +2234,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2198
2234
  }
2199
2235
  setSymbolSeries(e, t) {
2200
2236
  e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
2201
- let n = this.series.bars(), r = !1;
2202
- 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);
2237
+ let n = this.indicatorBars(), r = !1;
2238
+ 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);
2203
2239
  r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
2204
2240
  }
2205
2241
  forgetUnreadSymbols() {
@@ -2213,27 +2249,27 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2213
2249
  let e = /* @__PURE__ */ new Set();
2214
2250
  for (let t of this.indicatorEngine.getActiveIndicators()) {
2215
2251
  let n = t.params.symbol;
2216
- O.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
2252
+ k.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
2217
2253
  }
2218
2254
  return [...e];
2219
2255
  }
2220
2256
  requestMissingSymbols(e) {
2221
2257
  this.forgetUnreadSymbols();
2222
- let t = this.indicatorEngine.getIndicatorConfig(e), n = t && O.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
2258
+ let t = this.indicatorEngine.getIndicatorConfig(e), n = t && k.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
2223
2259
  !n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
2224
2260
  }
2225
2261
  updateIndicator(e, t) {
2226
2262
  this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
2227
2263
  }
2228
2264
  updateIndicatorNow(e, t) {
2229
- let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? j(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
2230
- this.indicatorEngine.updateIndicator(e, t, this.series.bars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2265
+ let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? N(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
2266
+ this.indicatorEngine.updateIndicator(e, t, this.indicatorBars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2231
2267
  instanceId: e,
2232
2268
  change: "params"
2233
2269
  }), this.requestMissingSymbols(e);
2234
2270
  let a = this.indicatorEngine.getIndicatorConfig(e);
2235
2271
  if (n?.placement === "overlay" && a && r && a.params[r] !== i) {
2236
- let t = b(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : b(i) ? null : a.pane ?? null;
2272
+ let t = x(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : x(i) ? null : a.pane ?? null;
2237
2273
  (n ?? void 0) !== a.pane && (this.indicatorEngine.setPane(e, n), this.eventBus.emit("indicatorChange", {
2238
2274
  instanceId: e,
2239
2275
  change: "pane"
@@ -2244,7 +2280,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2244
2280
  paneFor(e, t, n, r) {
2245
2281
  if (n) return this.paneHostOf(n, r);
2246
2282
  if (e.placement !== "overlay") return null;
2247
- let i = j(e), a = i ? b(t[i]) : null;
2283
+ let i = N(e), a = i ? x(t[i]) : null;
2248
2284
  return a ? this.paneHostOf(a.instanceId, r) : null;
2249
2285
  }
2250
2286
  paneHostOf(e, t) {
@@ -2290,8 +2326,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2290
2326
  return {
2291
2327
  ...e,
2292
2328
  priceRange: {
2293
- min: t.min - n * Nr,
2294
- max: t.max + n * Nr
2329
+ min: t.min - n * Lr,
2330
+ max: t.max + n * Lr
2295
2331
  },
2296
2332
  logScale: !1,
2297
2333
  scaleMode: "regular",
@@ -2344,7 +2380,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2344
2380
  this.indicatorEngine.setStyleDefaults(e, null);
2345
2381
  return;
2346
2382
  }
2347
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
2383
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ie(n);
2348
2384
  this.indicatorEngine.setStyleDefaults(e, {
2349
2385
  ...r,
2350
2386
  ...i ? { plots: i } : {}
@@ -2352,7 +2388,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2352
2388
  }
2353
2389
  setPaneStyle(e, t) {
2354
2390
  let n = this.paneOf(e);
2355
- this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? oe(t) : null));
2391
+ this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? ae(t) : null));
2356
2392
  }
2357
2393
  setPaneStyleNow(e, t) {
2358
2394
  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());
@@ -2395,8 +2431,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2395
2431
  paneMoveHost(e, t) {
2396
2432
  let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
2397
2433
  if (!n || !r) return;
2398
- let i = j(r);
2399
- if (r.placement === "overlay" && i && b(n.params[i])) return;
2434
+ let i = N(r);
2435
+ if (r.placement === "overlay" && i && x(n.params[i])) return;
2400
2436
  if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
2401
2437
  if (t === "new") {
2402
2438
  let t = this.layoutManager.getPanels().some((t) => t.id === e);
@@ -2504,13 +2540,33 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2504
2540
  let e = this.viewport.getState().chartRect.y;
2505
2541
  return this.features.legend ? e + this.chartLegend.getHeight() : e;
2506
2542
  }
2543
+ setLegendStack(e) {
2544
+ let t = e && e.width > 0 && e.height > 0 ? {
2545
+ width: e.width,
2546
+ height: e.height
2547
+ } : null;
2548
+ t === this.legendStack || t !== null && this.legendStack !== null && t.width === this.legendStack.width && t.height === this.legendStack.height || (this.legendStack = t, this.engine.requestRender());
2549
+ }
2550
+ legendKeepOut() {
2551
+ let e = this.viewport.getState().chartRect, t = this.getLegendBottom(), n = [], r = this.features.legend ? this.chartLegend.getWidth() : 0;
2552
+ return r > 0 && t > e.y && n.push({
2553
+ x: e.x,
2554
+ y: e.y,
2555
+ width: r,
2556
+ height: t - e.y
2557
+ }), this.legendStack && n.push({
2558
+ x: e.x,
2559
+ y: t,
2560
+ ...this.legendStack
2561
+ }), n;
2562
+ }
2507
2563
  isTimeAligned() {
2508
- return I(this.options.chartType) ? !1 : this.getDisplayData().length === this.series.length();
2564
+ return R(this.options.chartType) ? !1 : this.getDisplayData().length === this.series.length();
2509
2565
  }
2510
2566
  roundPrice(e) {
2511
2567
  if (!Number.isFinite(e)) return e;
2512
2568
  let t = this.stepAt(e);
2513
- if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(le(t)));
2569
+ if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(ce(t)));
2514
2570
  let { min: n, max: r } = this.viewport.getState().priceRange;
2515
2571
  return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
2516
2572
  }
@@ -2520,7 +2576,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2520
2576
  }
2521
2577
  stepAt(e) {
2522
2578
  let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
2523
- return t !== void 0 && t > 0 ? t : this.marketConfig ? re(e, this.marketConfig) : void 0;
2579
+ return t !== void 0 && t > 0 ? t : this.marketConfig ? ne(e, this.marketConfig) : void 0;
2524
2580
  }
2525
2581
  getPriceStep(e) {
2526
2582
  let t = this.stepAt(e ?? this.lastClose());
@@ -2535,7 +2591,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2535
2591
  return this.priceFormatter;
2536
2592
  }
2537
2593
  applyPriceFormat(e) {
2538
- this.priceFormatter = ne(e), this.priceUnit = e && typeof e != "function" ? g(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
2594
+ 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);
2539
2595
  }
2540
2596
  setTimeFormatter(e) {
2541
2597
  this.applyTimeFormatter(e), this.engine.requestRender();
@@ -2672,7 +2728,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2672
2728
  recordUndo(e) {
2673
2729
  if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
2674
2730
  let t = performance.now(), n = this.undoRedoManager.last();
2675
- if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Fr) {
2731
+ if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < zr) {
2676
2732
  this.undoRedoManager.replaceLast({
2677
2733
  ...n,
2678
2734
  custom: {
@@ -2719,7 +2775,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2719
2775
  x: t.x,
2720
2776
  y: t.y
2721
2777
  };
2722
- if ((e === "plot" || e === "priceAxis") && (r.price = Jt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = P(t.x, n)), e === "pane") {
2778
+ 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") {
2723
2779
  let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
2724
2780
  e && (r.pane = e.instanceId);
2725
2781
  }
@@ -2745,7 +2801,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2745
2801
  ...this.viewport.getState(),
2746
2802
  data: this.getDisplayData()
2747
2803
  };
2748
- this.setVisibleRange(P(e.x0, t), P(e.x1, t));
2804
+ this.setVisibleRange(I(e.x0, t), I(e.x1, t));
2749
2805
  }
2750
2806
  lockAllDrawings() {
2751
2807
  this.drawingManager.lockAllDrawings();
@@ -2776,7 +2832,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2776
2832
  });
2777
2833
  }
2778
2834
  getExportData(e = {}) {
2779
- let t = this.series.bars(), n = 0, r = t.length - 1;
2835
+ let t = this.exportBars(), n = 0, r = t.length - 1;
2780
2836
  if (e.range === "visible") {
2781
2837
  let { visibleRange: e } = this.viewport.getState();
2782
2838
  n = Math.max(0, e.from), r = Math.min(t.length - 1, e.to);
@@ -2790,7 +2846,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2790
2846
  for (let e of this.indicatorEngine.getActiveIndicators()) {
2791
2847
  let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
2792
2848
  if (!t) continue;
2793
- let r = on(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2849
+ 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) => ({
2794
2850
  key: e,
2795
2851
  title: e
2796
2852
  }));
@@ -2814,11 +2870,11 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2814
2870
  }
2815
2871
  getExportText(e = "csv", t = {}) {
2816
2872
  let { bars: n, columns: r } = this.getExportData(t);
2817
- return e === "json" ? E.toJSON(n, r) : E.toCSV(n, r);
2873
+ return e === "json" ? D.toJSON(n, r) : D.toCSV(n, r);
2818
2874
  }
2819
2875
  download(e, t, n) {
2820
2876
  let r = this.getExportText(e, n);
2821
- e === "json" ? E.download(r, t ?? "chart-data.json", "application/json") : E.download(r, t ?? "chart-data.csv", "text/csv");
2877
+ e === "json" ? D.download(r, t ?? "chart-data.json", "application/json") : D.download(r, t ?? "chart-data.csv", "text/csv");
2822
2878
  }
2823
2879
  setAutoSave(e, t = 5e3) {
2824
2880
  this.autoSaveScheduler.enable(e, t);
@@ -2880,7 +2936,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2880
2936
  this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
2881
2937
  }
2882
2938
  updateIndicatorStyleNow(e, t) {
2883
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
2939
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ie(n);
2884
2940
  this.indicatorEngine.updateIndicatorStyle(e, {
2885
2941
  ...r,
2886
2942
  ...i ? { plots: i } : {}
@@ -2973,6 +3029,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2973
3029
  kind: "bars",
2974
3030
  length: e
2975
3031
  });
3032
+ let t = this.crosshairHandler.getSyncedSlot();
3033
+ t !== null && this.showSyncedBar(t);
2976
3034
  }
2977
3035
  followLivePrice(e) {
2978
3036
  this.replayTrades() || this.tradingManager.setCurrentPrice(e), this.features.alerts && this.checkAlerts(e);
@@ -2984,27 +3042,26 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2984
3042
  this.replaySession || this.collectIndicatorValues(n), this.alertManager.checkChannels(n, { together: !0 }), this.alertManager.checkDrawings(e);
2985
3043
  }
2986
3044
  collectIndicatorValues(e) {
2987
- let t = this.series.bars();
2988
- if (t.length === 0) return;
2989
- let n = t.length - 1, r = this.alertManager.getAlerts().flatMap((e) => e.target ? [e.channel, e.target] : [e.channel]);
2990
- for (let t of r) {
2991
- if (e.has(t)) continue;
2992
- let r = t.indexOf(":");
2993
- if (r < 0) continue;
2994
- let i = this.indicatorEngine.getOutput(t.slice(0, r))?.series?.[n]?.[t.slice(r + 1)];
2995
- typeof i == "number" && Number.isFinite(i) && e.set(t, i);
3045
+ if (this.series.length() === 0) return;
3046
+ let t = this.alertManager.getAlerts().flatMap((e) => e.target ? [e.channel, e.target] : [e.channel]);
3047
+ for (let n of t) {
3048
+ if (e.has(n)) continue;
3049
+ let t = n.indexOf(":");
3050
+ if (t < 0) continue;
3051
+ let r = this.indicatorEngine.getOutput(n.slice(0, t))?.series, i = r?.[r.length - 1]?.[n.slice(t + 1)];
3052
+ typeof i == "number" && Number.isFinite(i) && e.set(n, i);
2996
3053
  }
2997
3054
  }
2998
3055
  setTradingConfig(e) {
2999
3056
  this.features.trading && this.tradingManager.setConfig(e);
3000
3057
  }
3001
3058
  async connect(e) {
3002
- if (!A(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
3059
+ if (!M(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
3003
3060
  this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new mt(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (t) => {
3004
3061
  let n = this.streamSeriesKey(e.adapter);
3005
3062
  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);
3006
3063
  }), this.streamManager.on("barClose", (e) => {
3007
- if (!L(e)) return;
3064
+ if (!B(e)) return;
3008
3065
  let t = this.series.placeStreamBar(e);
3009
3066
  if (t.refiltered && (this.displayDataCache = null), t.to === "none") {
3010
3067
  this.updateBar(e);
@@ -3016,7 +3073,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3016
3073
  }), this.streamManager.on("barCorrection", (e) => {
3017
3074
  this.updateBar(e);
3018
3075
  }), this.streamManager.on("barUpdate", (e) => {
3019
- if (!L(e)) return;
3076
+ if (!B(e)) return;
3020
3077
  let t = this.series.placeStreamBar(e);
3021
3078
  if (t.refiltered && (this.displayDataCache = null), t.to === "none" || (this.replaySession || this.currentPriceLine.setPrice(e.close), this.replaySession)) return;
3022
3079
  let n = t.before;
@@ -3056,18 +3113,18 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3056
3113
  }), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
3057
3114
  let t = this.streamManager;
3058
3115
  if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
3059
- let n = w(e.timeframe);
3116
+ let n = T(e.timeframe);
3060
3117
  this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
3061
3118
  this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
3062
3119
  }, 1e3);
3063
3120
  }
3064
3121
  streamSeriesKey(e) {
3065
- let t = N(e), n = this.streamTimeframe, r = t instanceof at && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
3122
+ let t = F(e), n = this.streamTimeframe, r = t instanceof at && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
3066
3123
  return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
3067
3124
  }
3068
3125
  setStreamTarget(e, t) {
3069
3126
  let n = this.announcedSymbol;
3070
- this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = ue(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
3127
+ 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", {
3071
3128
  symbol: e,
3072
3129
  previous: n
3073
3130
  })), this.useTimeframe(t);
@@ -3085,8 +3142,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3085
3142
  async switchStream(e, t) {
3086
3143
  if (!this.streamManager) return;
3087
3144
  let n = this.streamAdapter;
3088
- if (n && !A(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
3089
- this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(w(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
3145
+ if (n && !M(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
3146
+ 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);
3090
3147
  }
3091
3148
  isIndicatorAllowed(e) {
3092
3149
  let t = this.features.indicatorIds;
@@ -3105,7 +3162,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3105
3162
  }
3106
3163
  connectExecution(e, t = {}) {
3107
3164
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
3108
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = lr(e, {
3165
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = pr(e, {
3109
3166
  onIntent: (e, t) => {
3110
3167
  let n = (e) => t(e.payload);
3111
3168
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -3181,6 +3238,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3181
3238
  comparesDrawn() {
3182
3239
  return this.isTimeAligned();
3183
3240
  }
3241
+ panesOffChartType() {
3242
+ let e = this.indicatorEngine.getActiveIndicators(), t = new Set(e.filter((e) => e.offChartType).map((e) => e.instanceId)), n = /* @__PURE__ */ new Set();
3243
+ for (let r of this.layoutManager.getPanels()) {
3244
+ let i = e.filter((e) => e.instanceId === r.id || e.pane === r.id);
3245
+ i.length > 0 && i.every((e) => t.has(e.instanceId)) && n.add(r.id);
3246
+ }
3247
+ return n;
3248
+ }
3184
3249
  clearCompareSymbols() {
3185
3250
  let e = this.compareRenderer.getSymbols().map((e) => e.id);
3186
3251
  this.compareRenderer.clear(), this.updateViewportAndRender();
@@ -3230,7 +3295,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3230
3295
  goToTime(e) {
3231
3296
  let t = this.getDisplayData();
3232
3297
  if (t.length === 0 || !Number.isFinite(e)) return -1;
3233
- let n = Math.max(0, Math.min(t.length - 1, Math.floor(M(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
3298
+ 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;
3234
3299
  return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
3235
3300
  }
3236
3301
  setVisibleRangePreset(e) {
@@ -3241,7 +3306,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3241
3306
  this.fitContent();
3242
3307
  return;
3243
3308
  }
3244
- let o = M(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
3309
+ let o = P(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
3245
3310
  this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
3246
3311
  }
3247
3312
  scrollToEnd() {
@@ -3266,7 +3331,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3266
3331
  setVisibleRange(e, t) {
3267
3332
  let n = this.getDisplayData();
3268
3333
  if (n.length === 0) return;
3269
- let r = M(Math.min(e, t), n), i = M(Math.max(e, t), n);
3334
+ let r = P(Math.min(e, t), n), i = P(Math.max(e, t), n);
3270
3335
  this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
3271
3336
  }
3272
3337
  suspend() {
@@ -3372,7 +3437,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3372
3437
  this.applyStyle(e, t.layer ?? "host", !0);
3373
3438
  }
3374
3439
  setOverrides(e, t = {}) {
3375
- let n = t.layer ?? "host", { overrides: r, rejected: i } = ie(e);
3440
+ let n = t.layer ?? "host", { overrides: r, rejected: i } = re(e);
3376
3441
  i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
3377
3442
  let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
3378
3443
  this.themeManager.setOverrides(a, n) && this.styleChanged(n);
@@ -3391,7 +3456,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3391
3456
  return this.themeManager.getStyleValue(e);
3392
3457
  }
3393
3458
  applyStyle(e, t, n) {
3394
- let { overrides: r, rejected: i } = ie(e);
3459
+ let { overrides: r, rejected: i } = re(e);
3395
3460
  i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
3396
3461
  }
3397
3462
  styleChanged(e) {
@@ -3424,8 +3489,23 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3424
3489
  e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
3425
3490
  }
3426
3491
  setCrosshairTime(e) {
3427
- let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(M(e, t));
3428
- n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
3492
+ let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(P(e, t));
3493
+ n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.showSyncedBar(n), this.engine.requestRender(r.Hover));
3494
+ }
3495
+ showSyncedBar(e) {
3496
+ if (e === null) {
3497
+ this.crosshairHandler.getPosition() || this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairSync", { barIndex: null });
3498
+ return;
3499
+ }
3500
+ let t = this.crosshairSeries(), n = e >= 0 && e < t.length ? t[e] : void 0, r = n && e > 0 ? t[e - 1] : void 0;
3501
+ this.crosshairHandler.getPosition() || this.chartLegend.setHoverBar(n ?? null, r ?? null);
3502
+ let i = n ? j(t)[e]?.time ?? n.time : void 0;
3503
+ this.eventBus.emit("crosshairSync", {
3504
+ barIndex: e,
3505
+ ...n ? { bar: n } : {},
3506
+ ...i === void 0 ? {} : { time: i },
3507
+ ...r ? { prevClose: r.close } : {}
3508
+ });
3429
3509
  }
3430
3510
  getData() {
3431
3511
  return this.series.bars();
@@ -3498,7 +3578,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3498
3578
  return this.periodLevels.getPeriod();
3499
3579
  }
3500
3580
  setTimeZone(e) {
3501
- jr(e), this.timeZoneSetting = e, this.applyTimeZone();
3581
+ Fr(e), this.timeZoneSetting = e, this.applyTimeZone();
3502
3582
  }
3503
3583
  getTimeZone() {
3504
3584
  return this.timeZoneSetting;
@@ -3507,7 +3587,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3507
3587
  return this.displayTz;
3508
3588
  }
3509
3589
  getExchangeTimeZone() {
3510
- return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && v(e)) ?? null;
3590
+ return [w(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && v(e)) ?? null;
3511
3591
  }
3512
3592
  setTimezone(e) {
3513
3593
  this.setTimeZone(e);
@@ -3549,7 +3629,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3549
3629
  }
3550
3630
  spokenBarTime(e) {
3551
3631
  let t = this.getDisplayData(), n = e * u(t), r = this.numberLocale || "en-US";
3552
- return d(t) === !0 ? de(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : de(r, {
3632
+ return d(t) === !0 ? ue(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : ue(r, {
3553
3633
  dateStyle: "medium",
3554
3634
  timeStyle: "short"
3555
3635
  }, this.displayTz)(n);
@@ -3562,18 +3642,18 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3562
3642
  this.studyZoneHeld = !1, this.endStudyZoneWait(), this.useSymbolInfo(e);
3563
3643
  }
3564
3644
  useSymbolInfo(e) {
3565
- let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
3566
- this.symbolInfo = e ? Mr({
3645
+ let t = e && this.symbolInfo?.symbol === e.symbol ? w(this.symbolInfo) : void 0;
3646
+ this.symbolInfo = e ? Ir({
3567
3647
  ...e,
3568
3648
  sessions: e.sessions?.map((e) => ({ ...e }))
3569
3649
  }, 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);
3570
3650
  let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
3571
- let t = S(e.start), n = S(e.end);
3651
+ let t = C(e.start), n = C(e.end);
3572
3652
  return t === null || n === null ? [] : [{
3573
3653
  startMinute: t,
3574
3654
  endMinute: n
3575
3655
  }];
3576
- }), i = C(this.symbolInfo);
3656
+ }), i = w(this.symbolInfo);
3577
3657
  this.sessionShading.replaceConfig(n.length > 0 && i && v(i) ? {
3578
3658
  timeZone: i,
3579
3659
  windows: n,
@@ -3588,15 +3668,15 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3588
3668
  if (!e || typeof e != "object") return;
3589
3669
  let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
3590
3670
  if (!n(e.symbol)) return;
3591
- let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Mr({
3671
+ let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Ir({
3592
3672
  ...r,
3593
3673
  ...e,
3594
3674
  symbol: e.symbol || r?.symbol || t
3595
- }, C(r));
3675
+ }, w(r));
3596
3676
  r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
3597
3677
  }
3598
3678
  resolveStreamSymbol(e, t) {
3599
- let n = N(e), r = n.resolveSymbol?.bind(n);
3679
+ let n = F(e), r = n.resolveSymbol?.bind(n);
3600
3680
  if (this.symbolInfo && this.symbolInfo.symbol !== t ? (r ? this.holdStudyZone() : this.studyZoneHeld = !1, this.useSymbolInfo(null)) : r && this.studyZoneHeld && this.holdStudyZone(), !r) {
3601
3681
  this.releaseStudyZone();
3602
3682
  return;
@@ -3675,7 +3755,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3675
3755
  this.engine.getGpu() && this.engine.renderNow();
3676
3756
  }
3677
3757
  screenshot(e) {
3678
- this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
3758
+ this.features.screenshot && (this.freshFrame(), A.download(this.container, e, this.themeManager.getTheme().background));
3679
3759
  }
3680
3760
  async copyScreenshot() {
3681
3761
  if (!this.features.screenshot) return !1;
@@ -3683,7 +3763,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3683
3763
  if (!t?.write || !e) return !1;
3684
3764
  try {
3685
3765
  this.freshFrame();
3686
- let n = k.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
3766
+ let n = A.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
3687
3767
  if (!e) throw Error("No chart image to copy");
3688
3768
  return e;
3689
3769
  });
@@ -3701,10 +3781,10 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3701
3781
  }
3702
3782
  }
3703
3783
  screenshotDataURL() {
3704
- return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
3784
+ return this.features.screenshot ? (this.freshFrame(), A.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
3705
3785
  }
3706
3786
  async screenshotBlob() {
3707
- return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
3787
+ return this.features.screenshot ? (this.freshFrame(), A.toBlob(this.container, this.themeManager.getTheme().background)) : null;
3708
3788
  }
3709
3789
  addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
3710
3790
  if (!this.features.alerts) return null;
@@ -3831,24 +3911,24 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3831
3911
  let t = this.replaySession ? this.replayOffset : 0;
3832
3912
  if (!this.replaySession) {
3833
3913
  if (this.series.length() === 0) return;
3834
- this.series.beginReplay(), this.replaySession = ei(this.currentSymbol);
3914
+ this.series.beginReplay(), this.replaySession = ii(this.currentSymbol);
3835
3915
  }
3836
3916
  let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
3837
3917
  c.animate = c.animate === !0;
3838
3918
  let l = this.series.inHoursShown(this.series.liveBars()), u = t > 0 && i === void 0 && a !== !1, d = c.startIndex;
3839
- i !== void 0 && d === void 0 ? d = J(l, i) : u && d !== void 0 && (d += t);
3919
+ i !== void 0 && d === void 0 ? d = Z(l, i) : u && d !== void 0 && (d += t);
3840
3920
  let f = u ? t : a && d !== void 0 && d > 0 ? Math.min(Math.floor(d), l.length - 1) : 0, p = f > 0 ? l.slice(f) : l;
3841
3921
  d !== void 0 && (c.startIndex = d - f), n.windowTime = f > 0 ? p[0]?.time ?? null : null, n.steps = r ?? null, n.stepsSymbol = this.currentSymbol, n.until = null, n.animate = c.animate, n.step = c.animate ? s ?? null : null, this.replayRevealMarks = o !== !1, this.useReplayLoader(n, !0);
3842
3922
  let m = r ? this.replayStepsOver(n, p, !0) : null;
3843
3923
  this.options.autoScale = !0, this.buildReplay(p, m, f);
3844
3924
  let h = this.replayStepsSeries;
3845
- h && c.startIndex !== void 0 && (c.startIndex = li(h, p, c.startIndex));
3925
+ h && c.startIndex !== void 0 && (c.startIndex = hi(h, p, c.startIndex));
3846
3926
  let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
3847
3927
  this.revealReplayMarks(this.replayRevealMarks ? _?.time ?? null : null), n.held && (n.held.state = c.paused ? "paused" : "playing", c.paused = !0), !c.paused && c.startIndex !== void 0 && c.startIndex >= 1 && this.replaySeek(c.startIndex - 1), this.replayManager.play(c);
3848
3928
  }
3849
3929
  buildReplay(e, t, n) {
3850
3930
  let r = this.replaySession?.animate === !0, i = r ? null : t;
3851
- this.replayPieces = r && t ? fi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
3931
+ this.replayPieces = r && t ? vi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
3852
3932
  let a = this.replayRestarting;
3853
3933
  this.replayRestarting = !0;
3854
3934
  try {
@@ -3862,7 +3942,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3862
3942
  let n = t, a = e[t];
3863
3943
  if (i) {
3864
3944
  let r = i[t];
3865
- n = Z(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? mi(c, r) : ui(e[n], i, t), a = di(i, e, t, n) ? e[n] : c;
3945
+ 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;
3866
3946
  }
3867
3947
  let u = this.replayForming;
3868
3948
  this.replayForming = null, s = t;
@@ -3886,7 +3966,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3886
3966
  });
3887
3967
  }), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
3888
3968
  if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
3889
- let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = pi() ? wr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = Cr(r, i);
3969
+ 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);
3890
3970
  a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
3891
3971
  index: t,
3892
3972
  path: r
@@ -3896,7 +3976,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3896
3976
  drawFormingBar(e, t, n, r) {
3897
3977
  this.currentPriceLine.setPrice(e.close, t);
3898
3978
  let i = this.series.bars();
3899
- if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !Xr.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
3979
+ if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !ei.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
3900
3980
  this.scheduleRender();
3901
3981
  return;
3902
3982
  }
@@ -3904,22 +3984,22 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3904
3984
  }
3905
3985
  replayPathOf(e, t) {
3906
3986
  let n = e[t];
3907
- return vr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
3987
+ return Sr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
3908
3988
  }
3909
3989
  loadReplaySteps(e, t) {
3910
3990
  let n = this.replayLoader?.loader;
3911
3991
  if (!n) return;
3912
3992
  n.evictBefore(e[t].time);
3913
3993
  let r = this.replayManager.getStepMs();
3914
- n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(Yr / r) : 1);
3994
+ n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil($r / r) : 1);
3915
3995
  }
3916
3996
  useReplayLoader(e, t) {
3917
- let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Dr(e.step, r, (e) => A(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
3997
+ 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}`;
3918
3998
  if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
3919
- let o = N(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new dr({
3999
+ let o = F(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = T(r), u = new hr({
3920
4000
  source: s ? (e, t) => s.call(o, c, i, e, t) : null,
3921
4001
  step: i,
3922
- ratio: Math.max(1, Math.round(l / w(i))),
4002
+ ratio: Math.max(1, Math.round(l / T(i))),
3923
4003
  barMs: l,
3924
4004
  keep: (e) => this.series.inHoursShown(e),
3925
4005
  report: (e) => this.eventBus.emit("replayStepsLoad", e)
@@ -3934,18 +4014,18 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3934
4014
  if (!i || !a?.setMarkPrice || !o) return;
3935
4015
  let s = i.fedTime;
3936
4016
  if (s === null) {
3937
- i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(Cr(n, r).close, o.time);
4017
+ i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(Dr(n, r).close, o.time);
3938
4018
  return;
3939
4019
  }
3940
4020
  if (o.time < s || o.time === s && r <= i.fedFraction) return;
3941
4021
  let c = [];
3942
4022
  if (o.time > s) {
3943
- let a = J(e, s);
3944
- e[a]?.time === s && i.fedFraction < 1 && c.push(...K(this.replayPathOf(e, a), i.fedFraction, 1));
3945
- let o = e.slice(Y(e, s), t), l = Math.ceil(o.length / oi);
3946
- for (let e = 0; e < o.length; e += l) c.push(...si(o.slice(e, e + l)));
3947
- c.push(...K(n, -1, r));
3948
- } else c.push(...K(n, i.fedFraction, r));
4023
+ let a = Z(e, s);
4024
+ e[a]?.time === s && i.fedFraction < 1 && c.push(...Y(this.replayPathOf(e, a), i.fedFraction, 1));
4025
+ let o = e.slice(di(e, s), t), l = Math.ceil(o.length / ui);
4026
+ for (let e = 0; e < o.length; e += l) c.push(...fi(o.slice(e, e + l)));
4027
+ c.push(...Y(n, -1, r));
4028
+ } else c.push(...Y(n, i.fedFraction, r));
3949
4029
  i.fedTime = o.time, i.fedFraction = r;
3950
4030
  for (let [e, t] of c) a.setMarkPrice(e, t);
3951
4031
  let l = c[c.length - 1]?.[0];
@@ -3960,9 +4040,9 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3960
4040
  if (!t) return;
3961
4041
  let n = this.series.inHoursShown(this.series.liveBars());
3962
4042
  if (n.length === 0) return;
3963
- let r = t.windowTime === null ? 0 : Math.min(J(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
4043
+ let r = t.windowTime === null ? 0 : Math.min(Z(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
3964
4044
  this.useReplayLoader(t, !1);
3965
- let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : ri(o ?? i, t.until);
4045
+ let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : si(o ?? i, t.until);
3966
4046
  if (s < 0 && this.canPageBackForReplay(t)) {
3967
4047
  this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
3968
4048
  return;
@@ -3970,7 +4050,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3970
4050
  let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
3971
4051
  l || (t.held = null), t.symbol = this.currentSymbol;
3972
4052
  let d = this.replayManager.remainingMs();
3973
- this.clearBarHolders(), t.animate && ni(t, this.replayCoarse, i);
4053
+ this.clearBarHolders(), t.animate && oi(t, this.replayCoarse, i);
3974
4054
  let f = this.replayRestarting;
3975
4055
  this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
3976
4056
  try {
@@ -3993,14 +4073,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3993
4073
  }
3994
4074
  replayStepsOver(e, t, n = !1) {
3995
4075
  if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
3996
- let r = ci(this.series.inHoursShown(e.steps), t);
3997
- return r && (n || ai(r, t)) ? r : null;
4076
+ let r = mi(this.series.inHoursShown(e.steps), t);
4077
+ return r && (n || li(r, t)) ? r : null;
3998
4078
  }
3999
4079
  canPageBackForReplay(e) {
4000
- return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < Zr;
4080
+ return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < ti;
4001
4081
  }
4002
4082
  async pageBackForReplay(e) {
4003
- this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = Zr, this.rebaseReplay("older"));
4083
+ this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = ti, this.rebaseReplay("older"));
4004
4084
  }
4005
4085
  holdReplay() {
4006
4086
  let e = this.replaySession;
@@ -4033,7 +4113,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4033
4113
  this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
4034
4114
  }
4035
4115
  replaySeekToTime(e) {
4036
- !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, ri(this.replayStepsSeries ?? this.replayCoarse, e)));
4116
+ !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, si(this.replayStepsSeries ?? this.replayCoarse, e)));
4037
4117
  }
4038
4118
  feedReplayPrice(e, t) {
4039
4119
  let n = this.executionAdapter;
@@ -4053,21 +4133,21 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4053
4133
  return;
4054
4134
  }
4055
4135
  if (i.time <= n.fedTime) return;
4056
- let a = e.slice(Y(e, n.fedTime), t + 1);
4136
+ let a = e.slice(di(e, n.fedTime), t + 1);
4057
4137
  n.fedTime = i.time;
4058
- let o = Math.ceil(a.length / oi);
4059
- for (let e = 0; e < a.length; e += o) for (let [t, n] of si(a.slice(e, e + o))) r.setMarkPrice(t, n);
4138
+ let o = Math.ceil(a.length / ui);
4139
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of fi(a.slice(e, e + o))) r.setMarkPrice(t, n);
4060
4140
  this.tradingManager.setCurrentPrice(i.close);
4061
4141
  }
4062
4142
  getReplayBarIndex() {
4063
4143
  if (!this.replaySession) return -1;
4064
4144
  if (this.replayForming) return this.replayForming.index;
4065
4145
  let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
4066
- return t && this.replayCoarse ? Z(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
4146
+ return t && this.replayCoarse ? Q(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
4067
4147
  }
4068
4148
  replaySeekToBar(e) {
4069
4149
  let t = this.replayStepsSeries;
4070
- this.replaySeek(t && this.replayCoarse ? li(t, this.replayCoarse, e) : e);
4150
+ this.replaySeek(t && this.replayCoarse ? hi(t, this.replayCoarse, e) : e);
4071
4151
  }
4072
4152
  replayPause() {
4073
4153
  this.setHeldState("paused") || this.replayManager.pause();
@@ -4106,7 +4186,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4106
4186
  let t = Bt(e.time, n), r = Ft(e.price, n);
4107
4187
  i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
4108
4188
  }
4109
- return Rr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), zr.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
4189
+ 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 ? {
4110
4190
  x: i,
4111
4191
  y: o,
4112
4192
  width: a - i,
@@ -4142,7 +4222,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4142
4222
  };
4143
4223
  }
4144
4224
  captureSnapshot() {
4145
- return T.capture({
4225
+ return E.capture({
4146
4226
  getDrawings: () => this.getDrawings(),
4147
4227
  getTheme: () => this.themeManager.getBaseTheme(),
4148
4228
  getAlerts: () => this.getAlerts(),
@@ -4155,14 +4235,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4155
4235
  });
4156
4236
  }
4157
4237
  restoreIndicators(e, t) {
4158
- let n = Vr(e), r = /* @__PURE__ */ new Map();
4238
+ let n = Gr(e), r = /* @__PURE__ */ new Map();
4159
4239
  this.unrestoredIndicators = [];
4160
4240
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
4161
4241
  if (t) {
4162
4242
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
4163
4243
  for (let n of t) {
4164
4244
  let t = e.get(n.instanceId);
4165
- t && Hr(n, t) && o.add(n.instanceId);
4245
+ t && Kr(n, t) && o.add(n.instanceId);
4166
4246
  }
4167
4247
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
4168
4248
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -4170,7 +4250,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4170
4250
  let s = (e) => {
4171
4251
  let t = { ...e };
4172
4252
  for (let [e, n] of Object.entries(t)) {
4173
- let i = b(n), a = i && r.get(i.instanceId);
4253
+ let i = x(n), a = i && r.get(i.instanceId);
4174
4254
  a && (t[e] = _(a, i.key));
4175
4255
  }
4176
4256
  return t;
@@ -4224,7 +4304,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4224
4304
  let s = t.levels ?? null;
4225
4305
  JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
4226
4306
  let c = t.intervals ?? null;
4227
- JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? oe(t.paneStyle) : null);
4307
+ JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? ae(t.paneStyle) : null);
4228
4308
  }
4229
4309
  restorePanes(e) {
4230
4310
  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, {
@@ -4329,7 +4409,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4329
4409
  if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
4330
4410
  let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
4331
4411
  if (JSON.stringify(n) === JSON.stringify(i)) return r;
4332
- let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Fr && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
4412
+ 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 = {
4333
4413
  type: "indicators",
4334
4414
  before: null,
4335
4415
  after: null
@@ -4357,12 +4437,12 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4357
4437
  }
4358
4438
  saveState(e) {
4359
4439
  if (!this.features.saveLoad) return null;
4360
- let t = this.captureSnapshot(), n = T.serialize(t);
4361
- return e && T.saveToStorage(e, t), n;
4440
+ let t = this.captureSnapshot(), n = E.serialize(t);
4441
+ return e && E.saveToStorage(e, t), n;
4362
4442
  }
4363
4443
  loadState(e) {
4364
4444
  if (!this.features.saveLoad) return;
4365
- let t = T.deserialize(e);
4445
+ let t = E.deserialize(e);
4366
4446
  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");
4367
4447
  let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
4368
4448
  if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
@@ -4393,19 +4473,19 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4393
4473
  }
4394
4474
  loadStateFromStorage(e) {
4395
4475
  if (!this.features.saveLoad) return !1;
4396
- let t = T.loadFromStorage(e);
4397
- return t ? (this.loadState(T.serialize(t)), !0) : !1;
4476
+ let t = E.loadFromStorage(e);
4477
+ return t ? (this.loadState(E.serialize(t)), !0) : !1;
4398
4478
  }
4399
4479
  downloadState(e) {
4400
- this.features.saveLoad && T.downloadFile(this.captureSnapshot(), e);
4480
+ this.features.saveLoad && E.downloadFile(this.captureSnapshot(), e);
4401
4481
  }
4402
4482
  async loadStateFromFile() {
4403
4483
  if (!this.features.saveLoad) return;
4404
- let e = await T.loadFromFile();
4405
- this.loadState(T.serialize(e));
4484
+ let e = await E.loadFromFile();
4485
+ this.loadState(E.serialize(e));
4406
4486
  }
4407
4487
  setLocale(e) {
4408
- ce(e), this.engine.requestRender();
4488
+ se(e), this.engine.requestRender();
4409
4489
  }
4410
4490
  setNumberLocale(e) {
4411
4491
  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();
@@ -4443,13 +4523,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4443
4523
  ...this.marketConfig.priceLimits,
4444
4524
  referencePrice: e
4445
4525
  }
4446
- }, this.engine.requestRender());
4526
+ }, this.syncRenderContext(), this.engine.requestRender());
4447
4527
  }
4448
4528
  getFeatures() {
4449
4529
  return this.features;
4450
4530
  }
4451
4531
  setFeatures(e) {
4452
- Object.assign(this.features, e), (e.crosshair === !1 || e.crosshairTooltip === !1) && this.crosshairTooltip.hide(), e.grid !== void 0 && this.engine.requestRender(r.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.updateViewportAndRender()), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
4532
+ let t = this.getLegendBottom();
4533
+ Object.assign(this.features, e), e.legend !== void 0 && this.getLegendBottom() !== t && this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), (e.crosshair === !1 || e.crosshairTooltip === !1) && this.crosshairTooltip.hide(), e.grid !== void 0 && this.engine.requestRender(r.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.updateViewportAndRender()), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
4453
4534
  }
4454
4535
  resize() {
4455
4536
  let e = this.engine.dprManager.readContainerSize();
@@ -4464,14 +4545,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4464
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 = "";
4465
4546
  }
4466
4547
  createChartRenderer(e) {
4467
- let t = Cn(e, (e) => this.pluginManager.getChartType(e));
4548
+ let t = Dn(e, (e) => this.pluginManager.getChartType(e));
4468
4549
  return t instanceof Le && t.setPriceText((e) => this.formatPrice(e)), t;
4469
4550
  }
4470
4551
  crosshairSeries() {
4471
4552
  return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
4472
4553
  }
4473
4554
  getDisplayData() {
4474
- let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? bn(e, (e) => this.stepAt(e)) : void 0;
4555
+ let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? wn(e, (e) => this.stepAt(e)) : void 0;
4475
4556
  if (this.displayDataCache && t === this.displayDataStep) return this.displayDataCache;
4476
4557
  if (e.length === 0) return e;
4477
4558
  let n = this.displaySeries(e, t);
@@ -4479,15 +4560,31 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4479
4560
  }
4480
4561
  displaySeries(e, t) {
4481
4562
  let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
4482
- if (n !== "pointAndFigure" || r(n)) return wn(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
4483
- let { columns: i, boxSize: a } = un(e, this.chartTypeOptions, this.reshapeMemo);
4563
+ if (n !== "pointAndFigure" || r(n)) return On(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
4564
+ let { columns: i, boxSize: a } = fn(e, this.chartTypeOptions, this.reshapeMemo);
4484
4565
  return this.chartRenderer instanceof Qe && this.chartRenderer.setBoxSize(a), i;
4485
4566
  }
4486
4567
  recalcIndicatorsFrom(e, t) {
4487
- this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
4568
+ if (!this.isTimeAligned()) return this.recalcIndicators(e);
4569
+ this.indicatorEngine.recalculateFrom(e, t), this.indicatorsOnDrawn = null, this.announceIndicatorUpdate(t);
4488
4570
  }
4489
4571
  recalcIndicators(e) {
4490
- this.indicatorEngine.recalculateAll(e), this.announceIndicatorUpdate(0);
4572
+ let t = this.indicatorBars(e);
4573
+ this.indicatorEngine.recalculateAll(t), this.indicatorsOnDrawn = t === e ? null : t, this.announceIndicatorUpdate(0);
4574
+ }
4575
+ exportBars() {
4576
+ if (this.isTimeAligned()) return this.series.bars();
4577
+ let e = this.getDisplayData(), t = j(e);
4578
+ return e.map((e, n) => ({
4579
+ ...e,
4580
+ time: t[n]?.time ?? e.time
4581
+ }));
4582
+ }
4583
+ indicatorBars(e = this.series.bars()) {
4584
+ return this.isTimeAligned() ? e : this.getDisplayData();
4585
+ }
4586
+ syncIndicatorBars(e) {
4587
+ (this.isTimeAligned() ? this.indicatorsOnDrawn === null : this.indicatorsOnDrawn === e) || this.recalcIndicators(this.series.bars());
4491
4588
  }
4492
4589
  announceIndicatorUpdate(e) {
4493
4590
  if (this.indicatorUpdateFrom !== null) {
@@ -4523,7 +4620,9 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4523
4620
  this.panelInfoCache = null, this.fitDataAndAxes(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
4524
4621
  }
4525
4622
  applyDataToViewport(e = !1) {
4526
- let t = this.getDisplayData(), n = this.options.autoScale !== !1 || this.priceFitPending;
4623
+ let t = this.getDisplayData();
4624
+ this.syncIndicatorBars(t);
4625
+ let n = this.options.autoScale !== !1 || this.priceFitPending;
4527
4626
  this.viewport.updateData(t, !1), e && (this.viewport.scrollToEnd(), this.viewport.updateData(t, !1));
4528
4627
  let r = this.viewport.getState();
4529
4628
  if (t.length > 0) {
@@ -4534,17 +4633,17 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4534
4633
  }
4535
4634
  fitPriceScale(e, t) {
4536
4635
  if (e.length === 0) return;
4537
- let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = Jr(Jr(m(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && qr(e, n, r) ? this.volumeRenderer.getHeightRatio() + Pr : D;
4636
+ 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;
4538
4637
  this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
4539
4638
  top: a,
4540
- bottom: D
4639
+ bottom: O
4541
4640
  } : {
4542
- top: D,
4641
+ top: O,
4543
4642
  bottom: a
4544
4643
  }), this.viewport.fitToPrices(i.min, i.max);
4545
4644
  }
4546
4645
  updateViewportAndRender(e = !1) {
4547
- this.resolvedLayoutCache = null, this.panelInfoCache = null, this.layoutManager.setLeftAxisWidth(this.isLeftPriceScaleShown() ? this.leftAxisWidth : 0);
4646
+ this.indicatorEngine.setBarsTimed(this.comparesDrawn()), this.layoutManager.setPanelsAside(this.panesOffChartType()), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.layoutManager.setLeftAxisWidth(this.isLeftPriceScaleShown() ? this.leftAxisWidth : 0);
4548
4647
  let t = this.getResolvedLayout();
4549
4648
  this.viewport.setChartRect(t.mainChartRect), this.fitDataAndAxes(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
4550
4649
  }
@@ -4561,7 +4660,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4561
4660
  fitLeftAxisWidth() {
4562
4661
  let e = this.leftViewport;
4563
4662
  if (!e) return !1;
4564
- let t = this.themeManager.getTheme(), n = Yn({
4663
+ let t = this.themeManager.getTheme(), n = $n({
4565
4664
  min: e.priceRange.min,
4566
4665
  max: e.priceRange.max,
4567
4666
  lastPrice: null,
@@ -4570,12 +4669,12 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4570
4669
  fontFamily: t.font.family,
4571
4670
  fontSizeSmall: t.font.sizeSmall,
4572
4671
  measure: (e, t) => this.measureText(e, t)
4573
- }), r = Xn(this.leftAxisWidth, n);
4672
+ }), r = er(this.leftAxisWidth, n);
4574
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);
4575
4674
  }
4576
4675
  fitPriceAxisWidth() {
4577
4676
  if (!this.features.priceAxis) return !1;
4578
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = Yn({
4677
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = $n({
4579
4678
  min: e.min,
4580
4679
  max: e.max,
4581
4680
  lastPrice: this.currentPriceLine.getPrice(),
@@ -4586,14 +4685,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4586
4685
  fontFamily: t.font.family,
4587
4686
  fontSizeSmall: t.font.sizeSmall,
4588
4687
  measure: (e, t) => this.measureText(e, t)
4589
- }), r = Xn(this.priceAxisWidth, n);
4688
+ }), r = er(this.priceAxisWidth, n);
4590
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);
4591
4690
  }
4592
4691
  measureText(e, t) {
4593
4692
  let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
4594
- if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => Ur(n, e, t));
4693
+ if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => qr(n, e, t));
4595
4694
  let i = n ?? this.detachedMeasureContext();
4596
- return i ? Ur(i, e, t) : e.length * 7;
4695
+ return i ? qr(i, e, t) : e.length * 7;
4597
4696
  }
4598
4697
  detachedMeasureContext() {
4599
4698
  return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
@@ -4634,7 +4733,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4634
4733
  buildPanelRenderInfos() {
4635
4734
  if (this.panelInfoCache) return this.panelInfoCache;
4636
4735
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
4637
- let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...Or }, o = {
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) ?? { ...Mr }, o = {
4638
4737
  x: e.rect.x,
4639
4738
  y: e.rect.y + 20,
4640
4739
  width: e.rect.width,
@@ -4718,7 +4817,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4718
4817
  });
4719
4818
  }
4720
4819
  drawOverlayPlugins(e, t) {
4721
- let n = tr(this.pluginManager.getOverlays(), t);
4820
+ let n = ar(this.pluginManager.getOverlays(), t);
4722
4821
  if (n.length === 0) return;
4723
4822
  let r = {
4724
4823
  viewport: this.viewport.getState(),
@@ -4739,11 +4838,11 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4739
4838
  };
4740
4839
  }
4741
4840
  };
4742
- function Vr(e) {
4841
+ function Gr(e) {
4743
4842
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
4744
4843
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
4745
4844
  i.add(e.instanceId);
4746
- let o = [e.pane, ...Object.values(e.params).map((e) => b(e)?.instanceId)];
4845
+ let o = [e.pane, ...Object.values(e.params).map((e) => x(e)?.instanceId)];
4747
4846
  for (let e of o) {
4748
4847
  let n = e ? t.get(e) : void 0;
4749
4848
  n && a(n);
@@ -4753,19 +4852,19 @@ function Vr(e) {
4753
4852
  for (let t of e) a(t);
4754
4853
  return n;
4755
4854
  }
4756
- function Hr(e, t) {
4855
+ function Kr(e, t) {
4757
4856
  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);
4758
4857
  }
4759
- function Ur(e, t, n) {
4858
+ function qr(e, t, n) {
4760
4859
  let r = e.font;
4761
4860
  e.font = n;
4762
4861
  let i = e.measureText(t).width;
4763
4862
  return e.font = r, i;
4764
4863
  }
4765
- var Wr = 300;
4766
- function Gr(e) {
4864
+ var Jr = 300;
4865
+ function Yr(e) {
4767
4866
  let t = {}, n = e.family;
4768
- typeof n == "string" && n.trim() !== "" && n.length <= Wr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4867
+ typeof n == "string" && n.trim() !== "" && n.length <= Jr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4769
4868
  for (let n of [
4770
4869
  "sizeSmall",
4771
4870
  "sizeMedium",
@@ -4776,21 +4875,21 @@ function Gr(e) {
4776
4875
  }
4777
4876
  return t;
4778
4877
  }
4779
- function Kr(e) {
4878
+ function Xr(e) {
4780
4879
  let t = e.tagRadius;
4781
4880
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
4782
4881
  }
4783
- function qr(e, t, n) {
4882
+ function Zr(e, t, n) {
4784
4883
  for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
4785
4884
  return !1;
4786
4885
  }
4787
- function Jr(e, t) {
4886
+ function Qr(e, t) {
4788
4887
  return e ? t ? {
4789
4888
  min: Math.min(e.min, t.min),
4790
4889
  max: Math.max(e.max, t.max)
4791
4890
  } : e : t;
4792
4891
  }
4793
- function q(e) {
4892
+ function X(e) {
4794
4893
  return {
4795
4894
  id: e.id,
4796
4895
  price: e.price,
@@ -4805,14 +4904,14 @@ function q(e) {
4805
4904
  bars: e.bars
4806
4905
  };
4807
4906
  }
4808
- var Yr = 8e3, Xr = new Set([
4907
+ var $r = 8e3, ei = new Set([
4809
4908
  "candlestick",
4810
4909
  "line",
4811
4910
  "area",
4812
4911
  "bar",
4813
4912
  "hollowCandle"
4814
- ]), Zr = 10, Qr = 50, $r = .001;
4815
- function ei(e) {
4913
+ ]), ti = 10, ni = 50, ri = .001;
4914
+ function ii(e) {
4816
4915
  return {
4817
4916
  price: null,
4818
4917
  fedTime: null,
@@ -4827,42 +4926,42 @@ function ei(e) {
4827
4926
  held: null
4828
4927
  };
4829
4928
  }
4830
- function ti(e, t) {
4929
+ function ai(e, t) {
4831
4930
  let n = e[t + 1];
4832
- return n ? n.time - e[t].time : X(e);
4931
+ return n ? n.time - e[t].time : pi(e);
4833
4932
  }
4834
- function ni(e, t, n) {
4933
+ function oi(e, t, n) {
4835
4934
  let r = e.fedTime;
4836
4935
  if (r === null || !t || t.length === 0 || n.length === 0) return;
4837
- let i = ti(t, Z(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Z(n, a), s = n[o].time;
4936
+ let i = ai(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
4838
4937
  if (s > a) return;
4839
- let c = ti(n, o);
4938
+ let c = ai(n, o);
4840
4939
  if (a === s && o > 0) {
4841
4940
  e.fedTime = n[o - 1].time, e.fedFraction = 1;
4842
4941
  return;
4843
4942
  }
4844
4943
  e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
4845
4944
  }
4846
- function ri(e, t) {
4847
- let n = Y(e, t), r = e.length - 1;
4848
- return n > r && r >= 0 && e[r].time + X(e) <= t ? r : Math.max(-1, n - 2);
4945
+ function si(e, t) {
4946
+ let n = di(e, t), r = e.length - 1;
4947
+ return n > r && r >= 0 && e[r].time + pi(e) <= t ? r : Math.max(-1, n - 2);
4849
4948
  }
4850
- function ii(e) {
4949
+ function ci(e) {
4851
4950
  let t = Infinity;
4852
4951
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
4853
4952
  return t;
4854
4953
  }
4855
- function ai(e, t) {
4856
- if (!(ii(e) < ii(t))) return !1;
4857
- let n = Math.max(0, e.length - Qr);
4954
+ function li(e, t) {
4955
+ if (!(ci(e) < ci(t))) return !1;
4956
+ let n = Math.max(0, e.length - ni);
4858
4957
  for (let r = n; r < e.length; r++) {
4859
- let n = t[Z(t, e[r].time)], i = (n.high - n.low) * $r + 2 ** -52;
4958
+ let n = t[Q(t, e[r].time)], i = (n.high - n.low) * ri + 2 ** -52;
4860
4959
  if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
4861
4960
  }
4862
4961
  return !0;
4863
4962
  }
4864
- var oi = 500;
4865
- function J(e, t) {
4963
+ var ui = 500;
4964
+ function Z(e, t) {
4866
4965
  let n = 0, r = e.length;
4867
4966
  for (; n < r;) {
4868
4967
  let i = n + r >> 1;
@@ -4870,7 +4969,7 @@ function J(e, t) {
4870
4969
  }
4871
4970
  return n;
4872
4971
  }
4873
- function Y(e, t) {
4972
+ function di(e, t) {
4874
4973
  let n = 0, r = e.length;
4875
4974
  for (; n < r;) {
4876
4975
  let i = n + r >> 1;
@@ -4878,20 +4977,20 @@ function Y(e, t) {
4878
4977
  }
4879
4978
  return n;
4880
4979
  }
4881
- function si(e) {
4980
+ function fi(e) {
4882
4981
  let t = 0, n = 0;
4883
4982
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
4884
4983
  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];
4885
4984
  return [...a ? [r, i] : [i, r], [o.close, o.time]];
4886
4985
  }
4887
- function X(e) {
4986
+ function pi(e) {
4888
4987
  let t = 0;
4889
4988
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
4890
4989
  return t > 0 ? t : Infinity;
4891
4990
  }
4892
- function ci(e, t) {
4991
+ function mi(e, t) {
4893
4992
  if (t.length === 0) return null;
4894
- let n = t[t.length - 1].time + X(t), r = e.filter((e) => jn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
4993
+ 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 = [];
4895
4994
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
4896
4995
  if (i.length === 0) return null;
4897
4996
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -4899,7 +4998,7 @@ function ci(e, t) {
4899
4998
  let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
4900
4999
  return [...o, ...s];
4901
5000
  }
4902
- function Z(e, t) {
5001
+ function Q(e, t) {
4903
5002
  let n = 0, r = e.length - 1;
4904
5003
  for (; n < r;) {
4905
5004
  let i = n + r + 1 >> 1;
@@ -4907,37 +5006,37 @@ function Z(e, t) {
4907
5006
  }
4908
5007
  return n;
4909
5008
  }
4910
- function li(e, t, n) {
5009
+ function hi(e, t, n) {
4911
5010
  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;
4912
5011
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
4913
5012
  return Math.max(0, a);
4914
5013
  }
4915
- function ui(e, t, n) {
5014
+ function gi(e, t, n) {
4916
5015
  let r = n;
4917
5016
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
4918
5017
  let i = {
4919
5018
  ...t[r],
4920
5019
  time: e.time
4921
5020
  };
4922
- for (let e = r + 1; e <= n; e++) i = mi(i, t[e]);
5021
+ for (let e = r + 1; e <= n; e++) i = bi(i, t[e]);
4923
5022
  return i;
4924
5023
  }
4925
- function di(e, t, n, r) {
5024
+ function _i(e, t, n, r) {
4926
5025
  let i = e[n + 1], a = t[r + 1];
4927
5026
  return i !== void 0 && a !== void 0 && i.time >= a.time;
4928
5027
  }
4929
- function fi(e, t) {
5028
+ function vi(e, t) {
4930
5029
  let n = /* @__PURE__ */ new Map();
4931
5030
  for (let r of e) {
4932
- let e = t[Z(t, r.time)].time, i = n.get(e);
5031
+ let e = t[Q(t, r.time)].time, i = n.get(e);
4933
5032
  i ? i.push(r) : n.set(e, [r]);
4934
5033
  }
4935
5034
  return n;
4936
5035
  }
4937
- function pi() {
5036
+ function yi() {
4938
5037
  return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
4939
5038
  }
4940
- function mi(e, t) {
5039
+ function bi(e, t) {
4941
5040
  return {
4942
5041
  time: e.time,
4943
5042
  open: e.open,
@@ -4949,26 +5048,26 @@ function mi(e, t) {
4949
5048
  }
4950
5049
  //#endregion
4951
5050
  //#region src/io/parseOHLCV.ts
4952
- var hi = [
5051
+ var xi = [
4953
5052
  "time",
4954
5053
  "timestamp",
4955
5054
  "date",
4956
5055
  "datetime",
4957
5056
  "t"
4958
- ], gi = ["open", "o"], _i = ["high", "h"], vi = ["low", "l"], yi = ["close", "c"], bi = [
5057
+ ], Si = ["open", "o"], Ci = ["high", "h"], wi = ["low", "l"], Ti = ["close", "c"], Ei = [
4959
5058
  "volume",
4960
5059
  "vol",
4961
5060
  "v"
4962
5061
  ];
4963
- function xi(e) {
5062
+ function Di(e) {
4964
5063
  let t = e.trim();
4965
- return t ? t[0] === "[" || t[0] === "{" ? Si(t) : Ci(t) : {
5064
+ return t ? t[0] === "[" || t[0] === "{" ? Oi(t) : ki(t) : {
4966
5065
  data: [],
4967
5066
  rowCount: 0,
4968
5067
  skipped: 0
4969
5068
  };
4970
5069
  }
4971
- function Si(e) {
5070
+ function Oi(e) {
4972
5071
  let t;
4973
5072
  try {
4974
5073
  t = JSON.parse(e);
@@ -4978,19 +5077,19 @@ function Si(e) {
4978
5077
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
4979
5078
  let n = [], r = 0;
4980
5079
  for (let e of t) {
4981
- let t = Array.isArray(e) ? Oi(e) : Di(e);
5080
+ let t = Array.isArray(e) ? Pi(e) : Ni(e);
4982
5081
  t ? n.push(t) : r++;
4983
5082
  }
4984
- return Ai(n, t.length, r);
5083
+ return Ii(n, t.length, r);
4985
5084
  }
4986
- function Ci(e) {
5085
+ function ki(e) {
4987
5086
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
4988
5087
  if (t.length === 0) return {
4989
5088
  data: [],
4990
5089
  rowCount: 0,
4991
5090
  skipped: 0
4992
5091
  };
4993
- let n = wi(t[0]), r = Ti(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ei(r) : {
5092
+ 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) : {
4994
5093
  time: 0,
4995
5094
  open: 1,
4996
5095
  high: 2,
@@ -5001,7 +5100,7 @@ function Ci(e) {
5001
5100
  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");
5002
5101
  let o = [], s = 0;
5003
5102
  for (let e = +!!i; e < t.length; e++) {
5004
- let r = Ti(t[e], n), i = ki(r[a.time]), c = Q(r[a.open]), l = Q(r[a.high]), u = Q(r[a.low]), d = Q(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
5103
+ 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;
5005
5104
  if (i === null || ![
5006
5105
  c,
5007
5106
  l,
@@ -5020,9 +5119,9 @@ function Ci(e) {
5020
5119
  volume: Number.isFinite(f) ? f : 0
5021
5120
  });
5022
5121
  }
5023
- return Ai(o, t.length - +!!i, s);
5122
+ return Ii(o, t.length - +!!i, s);
5024
5123
  }
5025
- function wi(e) {
5124
+ function Ai(e) {
5026
5125
  let t = {
5027
5126
  ",": 0,
5028
5127
  ";": 0,
@@ -5034,7 +5133,7 @@ function wi(e) {
5034
5133
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
5035
5134
  return n;
5036
5135
  }
5037
- function Ti(e, t) {
5136
+ function ji(e, t) {
5038
5137
  let n = [], r = "", i = !1;
5039
5138
  for (let a = 0; a < e.length; a++) {
5040
5139
  let o = e[a];
@@ -5042,25 +5141,25 @@ function Ti(e, t) {
5042
5141
  }
5043
5142
  return n.push(r), n;
5044
5143
  }
5045
- function Ei(e) {
5144
+ function Mi(e) {
5046
5145
  let t = (t) => e.findIndex((e) => t.includes(e));
5047
5146
  return {
5048
- time: t(hi),
5049
- open: t(gi),
5050
- high: t(_i),
5051
- low: t(vi),
5052
- close: t(yi),
5053
- volume: t(bi)
5147
+ time: t(xi),
5148
+ open: t(Si),
5149
+ high: t(Ci),
5150
+ low: t(wi),
5151
+ close: t(Ti),
5152
+ volume: t(Ei)
5054
5153
  };
5055
5154
  }
5056
- function Di(e) {
5155
+ function Ni(e) {
5057
5156
  let t = (t) => {
5058
5157
  for (let n of t) {
5059
5158
  if (e[n] !== void 0) return e[n];
5060
5159
  let t = n.toUpperCase();
5061
5160
  if (e[t] !== void 0) return e[t];
5062
5161
  }
5063
- }, n = ki(String(t(hi) ?? "")), r = Number(t(gi)), i = Number(t(_i)), a = Number(t(vi)), o = Number(t(yi)), s = Number(t(bi) ?? 0);
5162
+ }, 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);
5064
5163
  return n === null || ![
5065
5164
  r,
5066
5165
  i,
@@ -5075,9 +5174,9 @@ function Di(e) {
5075
5174
  volume: Number.isFinite(s) ? s : 0
5076
5175
  };
5077
5176
  }
5078
- function Oi(e) {
5177
+ function Pi(e) {
5079
5178
  if (e.length < 5) return null;
5080
- let t = ki(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
5179
+ 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;
5081
5180
  return t === null || ![
5082
5181
  n,
5083
5182
  r,
@@ -5092,18 +5191,18 @@ function Oi(e) {
5092
5191
  volume: Number.isFinite(o) ? o : 0
5093
5192
  };
5094
5193
  }
5095
- function Q(e) {
5194
+ function $(e) {
5096
5195
  return e === void 0 || e.trim() === "" ? NaN : Number(e);
5097
5196
  }
5098
- function ki(e) {
5197
+ function Fi(e) {
5099
5198
  let t = e.trim();
5100
5199
  if (!t) return null;
5101
5200
  let n = Number(t);
5102
- if (Number.isFinite(n) && n > 0) return y(n);
5201
+ if (Number.isFinite(n) && n > 0) return b(n);
5103
5202
  let r = Date.parse(t);
5104
5203
  return Number.isFinite(r) ? r : null;
5105
5204
  }
5106
- function Ai(e, t, n) {
5205
+ function Ii(e, t, n) {
5107
5206
  e.sort((e, t) => e.time - t.time);
5108
5207
  let r = [];
5109
5208
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -5115,7 +5214,7 @@ function Ai(e, t, n) {
5115
5214
  }
5116
5215
  //#endregion
5117
5216
  //#region src/io/DragDropImporter.ts
5118
- var ji = class {
5217
+ var Li = class {
5119
5218
  host;
5120
5219
  overlay = null;
5121
5220
  callbacks;
@@ -5136,19 +5235,19 @@ var ji = class {
5136
5235
  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();
5137
5236
  }
5138
5237
  onDragEnter(e) {
5139
- Mi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5238
+ Ri(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5140
5239
  }
5141
5240
  onDragOver(e) {
5142
- Mi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5241
+ Ri(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5143
5242
  }
5144
5243
  onDragLeave(e) {
5145
- Mi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5244
+ Ri(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5146
5245
  }
5147
5246
  async onDrop(e) {
5148
5247
  e.preventDefault(), this.depth = 0, this.hideOverlay();
5149
5248
  let t = e.dataTransfer?.files?.[0];
5150
5249
  if (t) try {
5151
- let e = xi(await t.text());
5250
+ let e = Di(await t.text());
5152
5251
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
5153
5252
  this.callbacks.onData(e.data, e, t);
5154
5253
  } catch (e) {
@@ -5179,12 +5278,12 @@ var ji = class {
5179
5278
  this.overlay?.remove(), this.overlay = null;
5180
5279
  }
5181
5280
  };
5182
- function Mi(e) {
5281
+ function Ri(e) {
5183
5282
  return e.dataTransfer?.types?.includes("Files") ?? !1;
5184
5283
  }
5185
5284
  //#endregion
5186
5285
  //#region src/state/layoutStorage.ts
5187
- function Ni(e) {
5286
+ function zi(e) {
5188
5287
  let t = {
5189
5288
  id: e.id,
5190
5289
  name: e.name,
@@ -5192,11 +5291,11 @@ function Ni(e) {
5192
5291
  };
5193
5292
  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;
5194
5293
  }
5195
- var Pi = (e, t) => t.updatedAt - e.updatedAt;
5196
- function Fi(e) {
5294
+ var Bi = (e, t) => t.updatedAt - e.updatedAt;
5295
+ function Vi(e) {
5197
5296
  if (typeof e != "object" || !e) return null;
5198
5297
  let t = e;
5199
- return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Ni({
5298
+ return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : zi({
5200
5299
  id: t.id,
5201
5300
  name: t.name,
5202
5301
  updatedAt: t.updatedAt,
@@ -5205,17 +5304,17 @@ function Fi(e) {
5205
5304
  kind: typeof t.kind == "string" ? t.kind : void 0
5206
5305
  });
5207
5306
  }
5208
- function Ii(e) {
5209
- let t = Fi(e), n = t ? e.content : void 0;
5307
+ function Hi(e) {
5308
+ let t = Vi(e), n = t ? e.content : void 0;
5210
5309
  return t && typeof n == "string" ? {
5211
5310
  ...t,
5212
5311
  content: n
5213
5312
  } : null;
5214
5313
  }
5215
- function Li(e = []) {
5314
+ function Ui(e = []) {
5216
5315
  let t = new Map(e.map((e) => [e.id, { ...e }]));
5217
5316
  return {
5218
- list: () => [...t.values()].map(Ni).sort(Pi),
5317
+ list: () => [...t.values()].map(zi).sort(Bi),
5219
5318
  load: (e) => {
5220
5319
  let n = t.get(e);
5221
5320
  return n ? { ...n } : null;
@@ -5228,7 +5327,7 @@ function Li(e = []) {
5228
5327
  }
5229
5328
  };
5230
5329
  }
5231
- function Ri(e = "tcw:layouts:") {
5330
+ function Wi(e = "tcw:layouts:") {
5232
5331
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
5233
5332
  let e;
5234
5333
  try {
@@ -5236,10 +5335,10 @@ function Ri(e = "tcw:layouts:") {
5236
5335
  } catch {
5237
5336
  return [];
5238
5337
  }
5239
- return Array.isArray(e) ? e.map(Fi).filter((e) => e !== null) : [];
5338
+ return Array.isArray(e) ? e.map(Vi).filter((e) => e !== null) : [];
5240
5339
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
5241
5340
  return {
5242
- list: () => r().sort(Pi),
5341
+ list: () => r().sort(Bi),
5243
5342
  load: (e) => {
5244
5343
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
5245
5344
  return t && i !== null ? {
@@ -5248,7 +5347,7 @@ function Ri(e = "tcw:layouts:") {
5248
5347
  } : null;
5249
5348
  },
5250
5349
  save: (e) => {
5251
- localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Ni(e)]);
5350
+ localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), zi(e)]);
5252
5351
  },
5253
5352
  remove: (e) => {
5254
5353
  i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
@@ -5257,14 +5356,14 @@ function Ri(e = "tcw:layouts:") {
5257
5356
  }
5258
5357
  //#endregion
5259
5358
  //#region src/state/LayoutSession.ts
5260
- var zi = 80;
5261
- function $(e) {
5359
+ var Gi = 80;
5360
+ function Ki(e) {
5262
5361
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
5263
5362
  }
5264
- function Bi() {
5363
+ function qi() {
5265
5364
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
5266
5365
  }
5267
- function Vi(e) {
5366
+ function Ji(e) {
5268
5367
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
5269
5368
  return {
5270
5369
  id: t,
@@ -5275,7 +5374,7 @@ function Vi(e) {
5275
5374
  ...o === void 0 ? {} : { kind: o }
5276
5375
  };
5277
5376
  }
5278
- var Hi = class {
5377
+ var Yi = class {
5279
5378
  currentLayout = null;
5280
5379
  savedContent = null;
5281
5380
  dirty = !1;
@@ -5291,7 +5390,7 @@ var Hi = class {
5291
5390
  now;
5292
5391
  newId;
5293
5392
  constructor(e, t, n = {}) {
5294
- this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? Bi;
5393
+ 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;
5295
5394
  }
5296
5395
  current() {
5297
5396
  return this.currentLayout;
@@ -5307,7 +5406,7 @@ var Hi = class {
5307
5406
  }
5308
5407
  async list() {
5309
5408
  let e = await this.storage.list();
5310
- return Array.isArray(e) ? e.map(Fi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5409
+ return Array.isArray(e) ? e.map(Vi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5311
5410
  }
5312
5411
  save() {
5313
5412
  return this.queue(() => {
@@ -5316,12 +5415,12 @@ var Hi = class {
5316
5415
  });
5317
5416
  }
5318
5417
  saveAs(e) {
5319
- let t = $(e);
5418
+ let t = Ki(e);
5320
5419
  return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
5321
5420
  }
5322
5421
  open(e) {
5323
5422
  return this.queue(async () => {
5324
- let t = Ii(await this.storage.load(e));
5423
+ let t = Hi(await this.storage.load(e));
5325
5424
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
5326
5425
  this.cancelTimer(), this.applying++;
5327
5426
  try {
@@ -5331,13 +5430,13 @@ var Hi = class {
5331
5430
  } finally {
5332
5431
  this.applying--;
5333
5432
  }
5334
- return this.cancelTimer(), this.currentLayout = Vi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5433
+ return this.cancelTimer(), this.currentLayout = Ji(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5335
5434
  });
5336
5435
  }
5337
5436
  rename(e, t) {
5338
- let n = $(t);
5437
+ let n = Ki(t);
5339
5438
  return n ? this.queue(async () => {
5340
- let t = Ii(await this.storage.load(e));
5439
+ let t = Hi(await this.storage.load(e));
5341
5440
  !t || t.id !== e || (await this.storage.save({
5342
5441
  ...t,
5343
5442
  name: n
@@ -5415,7 +5514,7 @@ var Hi = class {
5415
5514
  content: n.content
5416
5515
  };
5417
5516
  await this.storage.save(r);
5418
- let i = Vi(r);
5517
+ let i = Ji(r);
5419
5518
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
5420
5519
  }
5421
5520
  forget() {
@@ -5436,6 +5535,6 @@ var Hi = class {
5436
5535
  }
5437
5536
  };
5438
5537
  //#endregion
5439
- export { In as C, z as D, L as E, on as O, zn as S, B as T, rr as _, Li as a, W as b, Br as c, Er as d, Dr as f, nr as g, ir as h, Ri as i, Ar as l, ar as m, zi as n, ji as o, or as p, $ as r, xi as s, Hi as t, kr as u, er as v, Pn as w, Wn as x, tr as y };
5538
+ 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 };
5440
5539
 
5441
- //# sourceMappingURL=LayoutSession-B2WYXhzD.js.map
5540
+ //# sourceMappingURL=LayoutSession-C5aHWgk7.js.map