@tradecanvas/chart 1.51.0 → 1.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/Chart.d.ts +174 -6
  2. package/dist/Chart.d.ts.map +1 -1
  3. package/dist/DataManager.d.ts +24 -0
  4. package/dist/DataManager.d.ts.map +1 -1
  5. package/dist/{LayoutSession-Qkx1huV-.js → LayoutSession-4SLt8-0u.js} +680 -419
  6. package/dist/LayoutSession-4SLt8-0u.js.map +1 -0
  7. package/dist/LayoutSession-BOtFzvMm.cjs +2 -0
  8. package/dist/LayoutSession-BOtFzvMm.cjs.map +1 -0
  9. package/dist/SeriesStore.d.ts +31 -0
  10. package/dist/SeriesStore.d.ts.map +1 -1
  11. package/dist/charts/ChartTypeStrategy.d.ts +32 -5
  12. package/dist/charts/ChartTypeStrategy.d.ts.map +1 -1
  13. package/dist/frameworks/feedBars.d.ts +22 -6
  14. package/dist/frameworks/feedBars.d.ts.map +1 -1
  15. package/dist/i18n-BjW5GVrO.cjs +2 -0
  16. package/dist/i18n-BjW5GVrO.cjs.map +1 -0
  17. package/dist/{i18n-DFTQ73Cz.js → i18n-C7b-2BJ5.js} +19 -1
  18. package/dist/i18n-C7b-2BJ5.js.map +1 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +6 -6
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +119 -96
  24. package/dist/index.js.map +1 -1
  25. package/dist/io/resampleOHLCV.d.ts +10 -4
  26. package/dist/io/resampleOHLCV.d.ts.map +1 -1
  27. package/dist/widget/ChartWidget.d.ts +238 -9
  28. package/dist/widget/ChartWidget.d.ts.map +1 -1
  29. package/dist/widget/ChartWidgetGrid.d.ts.map +1 -1
  30. package/dist/widget/WidgetDataWindow.d.ts +7 -0
  31. package/dist/widget/WidgetDataWindow.d.ts.map +1 -1
  32. package/dist/widget/WidgetIndicatorLegend.d.ts +21 -3
  33. package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -1
  34. package/dist/widget/WidgetIndicatorSettings.d.ts.map +1 -1
  35. package/dist/widget/WidgetObjectTree.d.ts +7 -1
  36. package/dist/widget/WidgetObjectTree.d.ts.map +1 -1
  37. package/dist/widget/WidgetSettings.d.ts +11 -3
  38. package/dist/widget/WidgetSettings.d.ts.map +1 -1
  39. package/dist/widget/chartSettingsStore.d.ts +76 -0
  40. package/dist/widget/chartSettingsStore.d.ts.map +1 -0
  41. package/dist/widget/chartTemplates.d.ts.map +1 -1
  42. package/dist/widget/compareLegend.d.ts +20 -0
  43. package/dist/widget/compareLegend.d.ts.map +1 -0
  44. package/dist/widget/index.cjs +103 -28
  45. package/dist/widget/index.cjs.map +1 -1
  46. package/dist/widget/index.d.ts +1 -1
  47. package/dist/widget/index.d.ts.map +1 -1
  48. package/dist/widget/index.js +2454 -1860
  49. package/dist/widget/index.js.map +1 -1
  50. package/dist/widget/indicatorInputWords.d.ts +19 -0
  51. package/dist/widget/indicatorInputWords.d.ts.map +1 -0
  52. package/dist/widget/locales/ar.d.ts.map +1 -1
  53. package/dist/widget/locales/cs.d.ts.map +1 -1
  54. package/dist/widget/locales/da.d.ts.map +1 -1
  55. package/dist/widget/locales/de.d.ts.map +1 -1
  56. package/dist/widget/locales/el.d.ts.map +1 -1
  57. package/dist/widget/locales/en.d.ts +9 -0
  58. package/dist/widget/locales/en.d.ts.map +1 -1
  59. package/dist/widget/locales/es.d.ts.map +1 -1
  60. package/dist/widget/locales/et.d.ts.map +1 -1
  61. package/dist/widget/locales/fa.d.ts.map +1 -1
  62. package/dist/widget/locales/fr.d.ts.map +1 -1
  63. package/dist/widget/locales/he.d.ts.map +1 -1
  64. package/dist/widget/locales/hu.d.ts.map +1 -1
  65. package/dist/widget/locales/id.d.ts.map +1 -1
  66. package/dist/widget/locales/index.cjs +1 -1
  67. package/dist/widget/locales/index.cjs.map +1 -1
  68. package/dist/widget/locales/index.js +253 -1
  69. package/dist/widget/locales/index.js.map +1 -1
  70. package/dist/widget/locales/it.d.ts.map +1 -1
  71. package/dist/widget/locales/ja.d.ts.map +1 -1
  72. package/dist/widget/locales/ko.d.ts.map +1 -1
  73. package/dist/widget/locales/ms.d.ts.map +1 -1
  74. package/dist/widget/locales/nb.d.ts.map +1 -1
  75. package/dist/widget/locales/nl.d.ts.map +1 -1
  76. package/dist/widget/locales/pl.d.ts.map +1 -1
  77. package/dist/widget/locales/pt.d.ts.map +1 -1
  78. package/dist/widget/locales/ro.d.ts.map +1 -1
  79. package/dist/widget/locales/ru.d.ts.map +1 -1
  80. package/dist/widget/locales/sk.d.ts.map +1 -1
  81. package/dist/widget/locales/sv.d.ts.map +1 -1
  82. package/dist/widget/locales/th.d.ts.map +1 -1
  83. package/dist/widget/locales/tr.d.ts.map +1 -1
  84. package/dist/widget/locales/vi.d.ts.map +1 -1
  85. package/dist/widget/locales/zh.d.ts.map +1 -1
  86. package/dist/widget/locales/zhHant.d.ts.map +1 -1
  87. package/dist/widget/settingsRows.d.ts +12 -3
  88. package/dist/widget/settingsRows.d.ts.map +1 -1
  89. package/dist/widget/symbolInfoView.d.ts.map +1 -1
  90. package/dist/widget/types.d.ts +60 -7
  91. package/dist/widget/types.d.ts.map +1 -1
  92. package/dist/widget/widgetCompare.d.ts +18 -0
  93. package/dist/widget/widgetCompare.d.ts.map +1 -1
  94. package/dist/widget/widgetLayout.d.ts +13 -1
  95. package/dist/widget/widgetLayout.d.ts.map +1 -1
  96. package/dist/widget/widgetSettingsLook.d.ts +3 -1
  97. package/dist/widget/widgetSettingsLook.d.ts.map +1 -1
  98. package/dist/widget/widgetShareState.d.ts +8 -0
  99. package/dist/widget/widgetShareState.d.ts.map +1 -1
  100. package/dist/widget/widgetTimezones.d.ts +4 -1
  101. package/dist/widget/widgetTimezones.d.ts.map +1 -1
  102. package/package.json +3 -3
  103. package/dist/LayoutSession-DuV9kpdQ.cjs +0 -2
  104. package/dist/LayoutSession-DuV9kpdQ.cjs.map +0 -1
  105. package/dist/LayoutSession-Qkx1huV-.js.map +0 -1
  106. package/dist/i18n-Bg_UJSNs.cjs +0 -2
  107. package/dist/i18n-Bg_UJSNs.cjs.map +0 -1
  108. package/dist/i18n-DFTQ73Cz.js.map +0 -1
@@ -1,47 +1,47 @@
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, barTimeUnit as l, chartStyleValue as u, computePriceLimits as d, computePriceRange as f, formatPrice as p, fractionTick as m, indicatorSource as h, isValidTimeZone as g, mergeBar as _, normalizeBarTime as v, parseIndicatorSource as y, priceFormatterFor as ee, priceStepAt as te, readChartStyleOverrides as b, readChartTypeOptions as x, readIndicatorPlotStyles as ne, readPaneStyle as re, resolveChartTheme as ie, sessionMinute as S, setLocale as ae, stepDecimals as oe, symbolTimeZone as C, tickBarCount as se, timeframeToMs as ce, zonedDateFormatter as le } from "@tradecanvas/commons";
2
- import { AlertDragHandler as ue, AlertManager as de, Animator as fe, AreaRenderer as pe, AxisDragHandler as me, BarCountdown as he, BarRenderer as ge, BaselineRenderer as _e, CandlestickRenderer as ve, ChartLegend as ye, ChartStateManager as w, CompareRenderer as be, CompareSymbolIndicator as xe, CorrelationCoefficientIndicator as Se, CorrelationLogIndicator as Ce, CrosshairHandler as we, CrosshairTooltip as Te, CurrentPriceLine as Ee, DEFAULT_SESSION_HOURS as De, DataExporter as T, DepthHeatmapRenderer as Oe, DrawingManager as ke, DrawingRenderer as Ae, EquivolumeRenderer as je, EventBus as Me, GridRenderer as Ne, HLCAreaRenderer as Pe, HiLoRenderer as Fe, HollowCandleRenderer as Ie, IndicatorEngine as Le, InteractionManager as Re, KagiRenderer as ze, KeyboardHandler as Be, LineRenderer as Ve, LineWithMarkersRenderer as He, MarketProfileRenderer as Ue, MeasureOverlay as We, PRICE_SCALE_MARGIN as E, PanHandler as Ge, PaneResizeHandler as Ke, PeriodLevelsRenderer as qe, PinnedTooltip as Je, PivotMarkersRenderer as Ye, PointAndFigureRenderer as D, PriceAxis as Xe, PriceAxisAddButton as Ze, PriceLines as Qe, RenderEngine as $e, RenkoRenderer as et, ReplayManager as tt, SYMBOL_INDICATOR_IDS as O, Screenshot as k, SelectionBoxOverlay as nt, SessionBreaks as rt, SessionShading as it, SignalMarkerManager as at, SpreadIndicator as ot, StepLineRenderer as st, StreamManager as ct, SymbolSeriesStore as lt, TimeAxis as ut, TradeZoneManager as dt, TradingManager as ft, TradingRenderer as pt, UndoRedoManager as mt, Viewport as ht, VolumeCandleRenderer as gt, VolumeProfileRenderer as _t, VolumeRenderer as vt, Watermark as yt, ZoomHandler as bt, barTimeStepMs as xt, findDominantSwing as St, gpuContextsLeft as Ct, isRegularSession as wt, loadWebGL as Tt, mergeSessionHours as Et, priceToY as Dt, rangePresetStart as Ot, readAlertOptions as kt, registerBuiltInDrawingTools as At, registerBuiltInIndicators as jt, servesTimeframe as Mt, sourceParam as A, timeToX as Nt, timestampToBarIndex as j, toHeikinAshi as Pt, toKagi as Ft, toLineBreak as It, toPointAndFigure as Lt, toRangeBars as Rt, toRenko as zt, whenGpuContextFree as Bt, withResampling as Vt, xToBarIndex as Ht, xToTime as M, yToPrice as N } 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 ee, niceNumber as te, normalizeBarTime as y, parseIndicatorSource as b, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as x, 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 ue, 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 D, HollowCandleRenderer as Le, IndicatorEngine as Re, InteractionManager as ze, KagiRenderer as Be, KeyboardHandler as Ve, LineRenderer as He, LineWithMarkersRenderer as Ue, MarketProfileRenderer as We, MeasureOverlay as Ge, PRICE_SCALE_MARGIN as O, PanHandler as Ke, PaneResizeHandler as qe, PeriodLevelsRenderer as Je, PinnedTooltip as Ye, PivotMarkersRenderer as Xe, PointAndFigureRenderer as Ze, PriceAxis as Qe, PriceAxisAddButton as $e, PriceLines as et, RenderEngine as tt, RenkoRenderer as nt, ReplayManager as rt, ResamplingAdapter as it, ReshapeMemo as at, SYMBOL_INDICATOR_IDS as k, SYMBOL_ZONE_WAIT_MS as ot, Screenshot as A, SelectionBoxOverlay as st, SessionBreaks as ct, SessionShading as lt, SignalMarkerManager as ut, SpreadIndicator as dt, StepLineRenderer as ft, StreamManager as pt, SymbolSeriesStore as mt, TimeAxis as ht, TradeZoneManager as gt, TradingManager as _t, TradingRenderer as vt, UndoRedoManager as yt, Viewport as bt, VolumeCandleRenderer as xt, VolumeProfileRenderer as St, VolumeRenderer as Ct, Watermark as wt, ZoomHandler as Tt, barTimeStepMs as Et, findDominantSwing as Dt, gpuContextsLeft as Ot, isPriceLevelAlert as kt, isRegularSession as At, loadWebGL as jt, mergeSessionHours as Mt, pointAndFigureColumns as Nt, priceToY as Pt, rangePresetStart as Ft, readAlertOptions as It, registerBuiltInDrawingTools as Lt, registerBuiltInIndicators as Rt, servesTimeframe as zt, sourceParam as j, timeToX as Bt, timestampToBarIndex as M, toHeikinAshi as Vt, toKagi as Ht, toLineBreak as Ut, toRangeBars as Wt, toRenko as Gt, whenGpuContextFree as Kt, withResampling as N, xToBarIndex as qt, xToTime as P, yToPrice as Jt } from "@tradecanvas/core";
3
3
  //#region src/regularHours.ts
4
- var Ut = 864e5, Wt = 10;
5
- function Gt(e, t) {
6
- let n = C(e);
7
- if (!n || !g(n) || t.length < 2) return null;
4
+ var Yt = 864e5, Xt = 10;
5
+ function Zt(e, t) {
6
+ let n = w(e);
7
+ if (!n || !v(n) || t.length < 2) return null;
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
13
13
  }];
14
14
  });
15
15
  if (r.length === 0) return null;
16
- let i = l(t), a = Infinity;
17
- for (let e = Math.max(1, t.length - Wt); e < t.length; e++) {
16
+ let i = u(t), a = Infinity;
17
+ for (let e = Math.max(1, t.length - Xt); e < t.length; e++) {
18
18
  let n = (t[e].time - t[e - 1].time) * i;
19
19
  n > 0 && n < a && (a = n);
20
20
  }
21
- if (!(a < Ut)) return null;
21
+ if (!(a < Yt)) return null;
22
22
  let o = {
23
23
  timeZone: n,
24
24
  windows: r,
25
25
  startMinute: r[0].startMinute,
26
26
  endMinute: r[r.length - 1].endMinute
27
27
  };
28
- return (e) => wt(e * i, o);
28
+ return (e) => At(e * i, o);
29
29
  }
30
30
  //#endregion
31
31
  //#region src/chartA11y.ts
32
- var P = {
32
+ var Qt = {
33
33
  role: "chart",
34
34
  summary: "{what}. Last price {close}.",
35
35
  empty: "Chart, no data.",
36
36
  view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
37
37
  bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
38
38
  keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
39
- }, F = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Kt = [
39
+ }, F = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), $t = [
40
40
  "role",
41
41
  "aria-roledescription",
42
42
  "aria-label",
43
43
  "aria-describedby"
44
- ], qt = 400, Jt = 1e3, Yt = class {
44
+ ], en = 400, tn = 1e3, nn = class {
45
45
  live;
46
46
  help;
47
47
  labels;
@@ -55,20 +55,20 @@ var P = {
55
55
  };
56
56
  constructor(e, t, n = {}) {
57
57
  this.container = e, this.source = t, this.labels = {
58
- ...P,
58
+ ...Qt,
59
59
  ...n
60
60
  };
61
- for (let t of Kt) this.before.set(t, e.getAttribute(t));
62
- e.setAttribute("role", "application"), this.help = I("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = I("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
61
+ for (let t of $t) this.before.set(t, e.getAttribute(t));
62
+ e.setAttribute("role", "application"), this.help = rn("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = rn("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
63
63
  }
64
64
  setLabels(e) {
65
65
  this.labels = {
66
- ...P,
66
+ ...Qt,
67
67
  ...e
68
68
  }, this.applyLabels();
69
69
  }
70
70
  refresh(e = !1) {
71
- let t = Jt - (Date.now() - this.summaryAt);
71
+ let t = tn - (Date.now() - this.summaryAt);
72
72
  if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
73
73
  this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
74
74
  return;
@@ -80,7 +80,7 @@ var P = {
80
80
  viewMoved() {
81
81
  this.cursor = null, this.viewTimer && clearTimeout(this.viewTimer), this.viewTimer = setTimeout(() => {
82
82
  this.viewTimer = null, this.say(this.viewText());
83
- }, qt);
83
+ }, en);
84
84
  }
85
85
  readBar(e) {
86
86
  let t = this.source.bars();
@@ -99,7 +99,7 @@ var P = {
99
99
  high: a(i.high),
100
100
  low: a(i.low),
101
101
  close: a(i.close),
102
- volume: Xt(i.volume ?? 0)
102
+ volume: an(i.volume ?? 0)
103
103
  }));
104
104
  }
105
105
  destroy() {
@@ -140,7 +140,7 @@ var P = {
140
140
  this.live.textContent = e;
141
141
  }
142
142
  };
143
- function I(e, t) {
143
+ function rn(e, t) {
144
144
  let n = document.createElement(e);
145
145
  return n.className = t, Object.assign(n.style, {
146
146
  position: "absolute",
@@ -154,12 +154,12 @@ function I(e, t) {
154
154
  border: "0"
155
155
  }), n;
156
156
  }
157
- function Xt(e) {
157
+ function an(e) {
158
158
  return Number.isInteger(e) ? String(e) : e.toFixed(2);
159
159
  }
160
160
  //#endregion
161
161
  //#region src/indicatorLabel.ts
162
- function L(e, t, n, r) {
162
+ function on(e, t, n, r) {
163
163
  let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, 3).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
164
164
  return [
165
165
  e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
@@ -169,52 +169,52 @@ function L(e, t, n, r) {
169
169
  }
170
170
  //#endregion
171
171
  //#region src/charts/ChartTypeStrategy.ts
172
- function Zt(e) {
172
+ function sn(e) {
173
173
  switch (e) {
174
174
  case "candlestick":
175
175
  case "heikinAshi":
176
176
  case "lineBreak":
177
- case "rangeBars": return new ve();
178
- case "line": return new Ve();
179
- case "area": return new pe();
180
- case "bar": return new ge();
181
- case "hollowCandle": return new Ie();
182
- case "baseline": return new _e();
183
- case "renko": return new et();
184
- case "kagi": return new ze();
185
- case "pointAndFigure": return new D();
186
- case "volumeCandles": return new gt();
187
- case "equivolume": return new je();
188
- case "hlcArea": return new Pe();
189
- case "stepLine": return new st();
190
- case "lineWithMarkers": return new He();
191
- case "hiLo": return new Fe();
192
- default: return new ve();
177
+ case "rangeBars": return new be();
178
+ case "line": return new He();
179
+ case "area": return new he();
180
+ case "bar": return new ve();
181
+ case "hollowCandle": return new Le();
182
+ case "baseline": return new ye();
183
+ case "renko": return new nt();
184
+ case "kagi": return new Be();
185
+ case "pointAndFigure": return new Ze();
186
+ case "volumeCandles": return new xt();
187
+ case "equivolume": return new Ne();
188
+ case "hlcArea": return new Ie();
189
+ case "stepLine": return new ft();
190
+ case "lineWithMarkers": return new Ue();
191
+ case "hiLo": return new D();
192
+ default: return new be();
193
193
  }
194
194
  }
195
- function Qt(e, t, n = {}) {
195
+ function cn(e, t, n = {}, r, i) {
196
196
  if (t.length === 0) return t;
197
197
  switch (e) {
198
- case "heikinAshi": return Pt(t);
198
+ case "heikinAshi": return Vt(t);
199
199
  case "renko": {
200
200
  let e = n.renko?.boxSize;
201
- return typeof e == "number" ? zt(t, { brickSize: e }) : zt(t, {
201
+ return typeof e == "number" ? Gt(t, { brickSize: e }, i) : Gt(t, {
202
202
  brickSize: 0,
203
203
  useATR: !0,
204
204
  atrPeriod: n.renko?.atrPeriod ?? 14
205
- });
206
- }
207
- case "lineBreak": return It(t, n.lineBreak?.lines ?? 3);
208
- case "kagi": return Ft(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
209
- case "pointAndFigure": return Lt(t, en(t, n), n.pointAndFigure?.reversal ?? 3);
210
- case "rangeBars": {
211
- let e = n.rangeBars?.range;
212
- return Rt(t, { rangeSize: typeof e == "number" ? e : tn(t) * .005 });
205
+ }, i);
213
206
  }
207
+ case "lineBreak": return Ut(t, n.lineBreak?.lines ?? 3);
208
+ case "kagi": return Ht(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
209
+ case "pointAndFigure": return un(t, n, i).columns;
210
+ case "rangeBars": return Wt(t, {
211
+ rangeSize: _n(t, n, r),
212
+ includeForming: !0
213
+ }, i);
214
214
  default: return t;
215
215
  }
216
216
  }
217
- function $t(e) {
217
+ function ln(e) {
218
218
  switch (e) {
219
219
  case "heikinAshi":
220
220
  case "renko":
@@ -225,30 +225,65 @@ function $t(e) {
225
225
  default: return !1;
226
226
  }
227
227
  }
228
- function R(e) {
229
- return e !== "heikinAshi" && $t(e);
228
+ function I(e) {
229
+ return e !== "heikinAshi" && ln(e);
230
230
  }
231
- function en(e, t = {}) {
232
- let n = t.pointAndFigure?.boxSize;
233
- return typeof n == "number" ? n : tn(e) * .01;
231
+ function un(e, t = {}, n) {
232
+ let r = t.pointAndFigure?.boxSize;
233
+ return Nt(e, typeof r == "number" ? r : dn(e) * .01, t.pointAndFigure?.reversal ?? 3, n);
234
234
  }
235
- function tn(e) {
235
+ function dn(e) {
236
236
  let t = 0;
237
237
  for (let n of e) t += n.close;
238
238
  return t / e.length;
239
239
  }
240
- function nn(e, t) {
240
+ var fn = 100, pn = 3, mn = .01, hn = 15, gn = (e) => Number(e.toPrecision(hn));
241
+ function _n(e, t = {}, n) {
242
+ let r = t.rangeBars?.range;
243
+ if (typeof r == "number") return r;
244
+ let i = e.length >= pn ? yn(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
245
+ return Sn(gn(te(i > 0 ? i : a * mn || 1, !0)), n);
246
+ }
247
+ function vn(e) {
248
+ let t = e.length - 1;
249
+ return {
250
+ from: Math.max(0, t - fn),
251
+ end: t
252
+ };
253
+ }
254
+ function yn(e) {
255
+ let { from: t, end: n } = vn(e), r = 0;
256
+ for (let i = t; i < n; i++) {
257
+ let { high: t, low: n } = e[i], a = i > 0 ? e[i - 1].close : n;
258
+ r += Math.max(t - n, Math.abs(t - a), Math.abs(n - a));
259
+ }
260
+ return n > t ? r / (n - t) : 0;
261
+ }
262
+ function bn(e, t) {
263
+ let { from: n, end: r } = vn(e);
264
+ if (r <= n) return t(e[e.length - 1]?.close ?? 0);
265
+ let i = -Infinity, a = Infinity;
266
+ for (let t = n; t < r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
267
+ return xn(t(i), t(a));
268
+ }
269
+ function xn(e, t) {
270
+ return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
271
+ }
272
+ function Sn(e, t) {
273
+ return t === void 0 || !(t > 0) ? e : gn(Math.max(1, Math.round(e / t)) * t);
274
+ }
275
+ function Cn(e, t) {
241
276
  let n = t?.(e);
242
- return n ? n.createRenderer() : Zt(e);
277
+ return n ? n.createRenderer() : sn(e);
243
278
  }
244
- function rn(e, t, n, r) {
279
+ function wn(e, t, n, r, i, a) {
245
280
  if (t.length === 0) return t;
246
- let i = n?.(e);
247
- return i?.transform ? i.transform(t) : Qt(e, t, r);
281
+ let o = n?.(e);
282
+ return o?.transform ? o.transform(t) : cn(e, t, r, i, a);
248
283
  }
249
284
  //#endregion
250
285
  //#region src/state/AutoSaveScheduler.ts
251
- var an = class {
286
+ var Tn = class {
252
287
  timer = null;
253
288
  delayMs = 0;
254
289
  key = null;
@@ -278,15 +313,15 @@ var an = class {
278
313
  };
279
314
  //#endregion
280
315
  //#region src/DataManager.ts
281
- function z(e) {
316
+ function L(e) {
282
317
  if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
283
318
  let { open: t, high: n, low: r, close: i } = e;
284
319
  return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
285
320
  }
286
- function on(e) {
321
+ function En(e) {
287
322
  return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
288
323
  }
289
- function B(e) {
324
+ function R(e) {
290
325
  return {
291
326
  ...e,
292
327
  high: Math.max(e.open, e.high, e.low, e.close),
@@ -294,22 +329,36 @@ function B(e) {
294
329
  volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
295
330
  };
296
331
  }
297
- function sn(e, t) {
332
+ function z(e, t) {
333
+ return e === t || e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume;
334
+ }
335
+ function Dn(e, t) {
336
+ for (let n = e.length - 1; n >= 0; n--) {
337
+ if (e[n].time === t) return n;
338
+ if (e[n].time < t) return -1;
339
+ }
340
+ return -1;
341
+ }
342
+ var On = {
343
+ index: -1,
344
+ changed: !1
345
+ };
346
+ function kn(e, t) {
298
347
  if (e.length === 0) return t;
299
- let n = v(t);
300
- return l(e) === 1 ? n : n / 1e3;
348
+ let n = y(t);
349
+ return u(e) === 1 ? n : n / 1e3;
301
350
  }
302
- function cn(e, t) {
303
- let n = sn(e, t.time);
351
+ function An(e, t) {
352
+ let n = kn(e, t.time);
304
353
  return n === t.time ? t : {
305
354
  ...t,
306
355
  time: n
307
356
  };
308
357
  }
309
- var V = class {
358
+ var B = class {
310
359
  data = [];
311
360
  withSeriesTime(e) {
312
- return cn(this.data, e);
361
+ return An(this.data, e);
313
362
  }
314
363
  getData() {
315
364
  return this.data;
@@ -318,16 +367,16 @@ var V = class {
318
367
  let t = [];
319
368
  for (let n = 0; n < e.length; n++) {
320
369
  let r = e[n];
321
- z(r) && t.push(on(r) ? r : B(r));
370
+ L(r) && t.push(En(r) ? r : R(r));
322
371
  }
323
372
  this.data = t;
324
373
  }
325
374
  prependBars(e) {
326
375
  let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
327
376
  for (let r = 0; r < e.length; r++) {
328
- if (!z(e[r])) continue;
377
+ if (!L(e[r])) continue;
329
378
  let i = this.withSeriesTime(e[r]);
330
- i.time >= t || n.push(on(i) ? i : B(i));
379
+ i.time >= t || n.push(En(i) ? i : R(i));
331
380
  }
332
381
  if (n.length === 0) return 0;
333
382
  n.sort((e, t) => e.time - t.time);
@@ -336,19 +385,32 @@ var V = class {
336
385
  return n.length = r, this.data = n.concat(this.data), r;
337
386
  }
338
387
  appendBar(e) {
339
- z(e) && this.data.push(B(this.withSeriesTime(e)));
388
+ L(e) && this.data.push(R(this.withSeriesTime(e)));
340
389
  }
341
390
  updateLastBar(e) {
342
- if (!z(e)) return;
343
- let t = B(this.withSeriesTime(e));
391
+ if (!L(e)) return;
392
+ let t = R(this.withSeriesTime(e));
344
393
  if (this.data.length === 0) {
345
394
  this.data.push(t);
346
395
  return;
347
396
  }
348
397
  this.data[this.data.length - 1] = t;
349
398
  }
399
+ replaceBar(e) {
400
+ if (!L(e)) return On;
401
+ let t = this.withSeriesTime(e), n = Dn(this.data, t.time);
402
+ if (n < 0) return On;
403
+ let r = R(t);
404
+ return z(this.data[n], r) ? {
405
+ index: n,
406
+ changed: !1
407
+ } : (this.data[n] = r, {
408
+ index: n,
409
+ changed: !0
410
+ });
411
+ }
350
412
  updateLastBarFromTick(e) {
351
- this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = _(this.data[this.data.length - 1], this.withSeriesTime(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))));
352
414
  }
353
415
  getLength() {
354
416
  return this.data.length;
@@ -356,16 +418,18 @@ var V = class {
356
418
  clear() {
357
419
  this.data = [];
358
420
  }
421
+ }, V = {
422
+ to: "none",
423
+ index: -1,
424
+ changed: !1
359
425
  };
360
- //#endregion
361
- //#region src/SeriesStore.ts
362
426
  function H(e, t) {
363
427
  let n = e[e.length - 1];
364
428
  if (!n) return "append";
365
- let r = v(t.time), i = v(n.time);
429
+ let r = y(t.time), i = y(n.time);
366
430
  return r > i ? "append" : r === i ? "update" : "stale";
367
431
  }
368
- function ln(e) {
432
+ function jn(e) {
369
433
  return [
370
434
  e.time,
371
435
  e.open,
@@ -374,10 +438,11 @@ function ln(e) {
374
438
  e.close
375
439
  ].every(Number.isFinite);
376
440
  }
377
- var un = class {
378
- shown = new V();
441
+ var Mn = class {
442
+ shown = new B();
379
443
  whole = null;
380
444
  aside = null;
445
+ shownRevision = 0;
381
446
  constructor(e) {
382
447
  this.hoursFilter = e;
383
448
  }
@@ -387,6 +452,9 @@ var un = class {
387
452
  length() {
388
453
  return this.shown.getLength();
389
454
  }
455
+ revision() {
456
+ return this.shownRevision;
457
+ }
390
458
  liveBars() {
391
459
  return this.aside?.getData() ?? this.whole ?? this.shown.getData();
392
460
  }
@@ -396,7 +464,7 @@ var un = class {
396
464
  prepend(e) {
397
465
  let t = null, n = e;
398
466
  if (this.whole) {
399
- let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(ln).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
467
+ let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(jn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
400
468
  this.whole = [...a, ...this.whole];
401
469
  let o = this.hoursFilter(this.whole);
402
470
  t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
@@ -466,7 +534,7 @@ var un = class {
466
534
  mergeTick(e) {
467
535
  if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
468
536
  let t = this.whole ? this.hoursFilter(this.whole) : null;
469
- if (t && this.whole && !t(sn(this.whole, e.time))) return this.wrote("hidden", !1);
537
+ if (t && this.whole && !t(kn(this.whole, e.time))) return this.wrote("hidden", !1);
470
538
  let n = this.shown.getLength();
471
539
  this.shown.updateLastBarFromTick(e);
472
540
  let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
@@ -496,11 +564,34 @@ var un = class {
496
564
  refiltered: r
497
565
  });
498
566
  }
567
+ replace(e) {
568
+ if (this.aside) {
569
+ let { index: t, changed: n } = this.aside.replaceBar(e);
570
+ return t < 0 ? V : {
571
+ to: "aside",
572
+ index: -1,
573
+ changed: n
574
+ };
575
+ }
576
+ if (!L(e)) return V;
577
+ let t = this.inSeriesUnit(e), n = this.whole, r = n ? Dn(n, t.time) : -1;
578
+ if (n) {
579
+ if (r < 0 || !L(n[r])) return V;
580
+ let e = this.hoursFilter(n);
581
+ if (e && !e(t.time)) return this.replaceHidden(n, r, t);
582
+ }
583
+ let { index: i, changed: a } = this.shown.replaceBar(t);
584
+ return i < 0 ? V : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
585
+ to: "shown",
586
+ index: i,
587
+ changed: a
588
+ });
589
+ }
499
590
  loadAside(e) {
500
591
  this.aside?.setData(e);
501
592
  }
502
593
  beginReplay() {
503
- this.aside || (this.aside = new V(), this.aside.setData(this.whole ?? this.shown.getData()));
594
+ this.aside || (this.aside = new B(), this.aside.setData(this.whole ?? this.shown.getData()));
504
595
  }
505
596
  endReplay() {
506
597
  let e = this.aside;
@@ -520,7 +611,15 @@ var un = class {
520
611
  this.shown.updateLastBar(e);
521
612
  }
522
613
  inSeriesUnit(e) {
523
- return cn(this.whole ?? this.shown.getData(), e);
614
+ return An(this.whole ?? this.shown.getData(), e);
615
+ }
616
+ replaceHidden(e, t, n) {
617
+ let r = R(n), i = !z(e[t], r);
618
+ return i && (e[t] = r), {
619
+ to: "hidden",
620
+ index: -1,
621
+ changed: i
622
+ };
524
623
  }
525
624
  wrote(e, t) {
526
625
  return {
@@ -548,7 +647,7 @@ var un = class {
548
647
  let r = this.hoursFilter(n);
549
648
  return !r || r(e.time);
550
649
  }
551
- }, dn = 5e3, fn = 6e4, pn = 500, mn = class {
650
+ }, Nn = 5e3, Pn = 6e4, Fn = 500, In = class {
552
651
  loader = null;
553
652
  pageSize = 500;
554
653
  loading = !1;
@@ -589,7 +688,7 @@ var un = class {
589
688
  try {
590
689
  r = await e(t, this.pageSize);
591
690
  } catch (e) {
592
- return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(fn, dn * 2 ** (this.failures - 1)), this.emit({
691
+ return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Pn, Nn * 2 ** (this.failures - 1)), this.emit({
593
692
  state: "error",
594
693
  count: 0,
595
694
  error: e instanceof Error ? e.message : String(e)
@@ -622,10 +721,10 @@ var un = class {
622
721
  };
623
722
  //#endregion
624
723
  //#region src/ThemeManager.ts
625
- function hn(e, t) {
724
+ function Ln(e, t) {
626
725
  return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
627
726
  }
628
- var gn = class t {
727
+ var Rn = class t {
629
728
  base;
630
729
  shape = null;
631
730
  font = null;
@@ -644,13 +743,13 @@ var gn = class t {
644
743
  return i;
645
744
  }
646
745
  getTheme() {
647
- return this.effective ??= ie(this.base, this.chartType, this.merged()), this.effective;
746
+ return this.effective ??= oe(this.base, this.chartType, this.merged()), this.effective;
648
747
  }
649
748
  getBaseTheme() {
650
749
  return this.base;
651
750
  }
652
751
  setTheme(e) {
653
- let n = t.read(e), r = this.font !== null && hn(n.font, this.base.font);
752
+ let n = t.read(e), r = this.font !== null && Ln(n.font, this.base.font);
654
753
  this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
655
754
  ...this.base,
656
755
  shape: {
@@ -715,7 +814,7 @@ var gn = class t {
715
814
  return JSON.stringify(e) === JSON.stringify(this.getUserOverrides()) ? !1 : (this.user = new Map(Object.entries(e).map(([e, t]) => [e, { ...t }])), this.effective = null, !0);
716
815
  }
717
816
  getStyleValue(e) {
718
- return u(this.base, this.merged(), e, this.chartType);
817
+ return f(this.base, this.merged(), e, this.chartType);
719
818
  }
720
819
  layer(e) {
721
820
  return e === "host" ? this.host : this.user.get(this.base.name) ?? {};
@@ -732,7 +831,7 @@ var gn = class t {
732
831
  };
733
832
  //#endregion
734
833
  //#region src/style/styleOptions.ts
735
- function _n(e, t) {
834
+ function zn(e, t) {
736
835
  return t ? {
737
836
  ...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
738
837
  ...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
@@ -740,22 +839,22 @@ function _n(e, t) {
740
839
  ...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
741
840
  } : {};
742
841
  }
743
- function vn(e) {
842
+ function Bn(e) {
744
843
  let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
745
844
  return {
746
845
  ...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
747
846
  ...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
748
847
  ...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
749
848
  ...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
750
- ..._n("horizontal", n?.hLine),
751
- ..._n("vertical", n?.vLine),
849
+ ...zn("horizontal", n?.hLine),
850
+ ...zn("vertical", n?.vLine),
752
851
  ...r === void 0 ? {} : { "crosshair.labelBackground": r },
753
852
  ...e.overrides
754
853
  };
755
854
  }
756
855
  //#endregion
757
856
  //#region src/layout/LayoutManager.ts
758
- var yn = 200, bn = 80, U = (e) => e.position === "top" || e.position === "bottom", xn = class {
857
+ var Vn = 200, Hn = 80, U = (e) => e.position === "top" || e.position === "bottom", Un = class {
759
858
  panels = [];
760
859
  containerWidth = 0;
761
860
  containerHeight = 0;
@@ -771,8 +870,8 @@ var yn = 200, bn = 80, U = (e) => e.position === "top" || e.position === "bottom
771
870
  this.panels.push({
772
871
  id: e,
773
872
  position: n,
774
- size: r ?? (a ? yn : t),
775
- minSize: a ? bn : i,
873
+ size: r ?? (a ? Vn : t),
874
+ minSize: a ? Hn : i,
776
875
  content: {
777
876
  type: "indicator",
778
877
  indicatorInstanceId: e
@@ -841,7 +940,7 @@ var yn = 200, bn = 80, U = (e) => e.position === "top" || e.position === "bottom
841
940
  let r = this.panels.find((t) => t.id === e);
842
941
  if (r) {
843
942
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
844
- r.position = n, a !== o && (r.size = o ? yn : t, r.minSize = o ? bn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
943
+ r.position = n, a !== o && (r.size = o ? Vn : t, r.minSize = o ? Hn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
845
944
  }
846
945
  }
847
946
  setPanelSize(e, t) {
@@ -957,26 +1056,26 @@ var yn = 200, bn = 80, U = (e) => e.position === "top" || e.position === "bottom
957
1056
  getMainChartRect() {
958
1057
  return this.resolve().mainChartRect;
959
1058
  }
960
- }, Sn = 14, Cn = 14, wn = 22, Tn = 4;
961
- function En(e) {
1059
+ }, Wn = 14, Gn = 14, Kn = 22, qn = 4;
1060
+ function Jn(e) {
962
1061
  let { min: t, max: n, lastPrice: r, locale: i, fontFamily: a, fontSizeSmall: s, measure: l } = e, u = e.tagPrecision ?? c(t, n), d = u, f = r === null ? [t, n] : [
963
1062
  t,
964
1063
  n,
965
1064
  r
966
- ], m = o;
1065
+ ], p = o;
967
1066
  for (let t of f) {
968
1067
  if (!Number.isFinite(t)) continue;
969
- let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : p(t, u, i), r = e.format ? n : p(t, d, i);
970
- m = Math.max(m, l(n, `500 ${s}px ${a}`) + Sn, l(r, `bold 11px ${a}`) + Cn, l(r, `600 ${s}px ${a}`) + wn);
1068
+ let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : h(t, u, i), r = e.format ? n : h(t, d, i);
1069
+ p = Math.max(p, l(n, `500 ${s}px ${a}`) + Wn, l(r, `bold 11px ${a}`) + Gn, l(r, `600 ${s}px ${a}`) + Kn);
971
1070
  }
972
- return m <= o ? o : Math.ceil(m / Tn) * Tn;
1071
+ return p <= o ? o : Math.ceil(p / qn) * qn;
973
1072
  }
974
- function Dn(e, t) {
1073
+ function Yn(e, t) {
975
1074
  return t > e || t <= e - 12 ? t : e;
976
1075
  }
977
1076
  //#endregion
978
1077
  //#region src/layout/labelWidths.ts
979
- var On = 512, kn = class {
1078
+ var Xn = 512, Zn = class {
980
1079
  widths = /* @__PURE__ */ new Map();
981
1080
  fonts;
982
1081
  forget = () => this.widths.clear();
@@ -987,12 +1086,12 @@ var On = 512, kn = class {
987
1086
  let r = `${t}\n${e}`, i = this.widths.get(r);
988
1087
  if (i !== void 0) return i;
989
1088
  let a = n();
990
- return this.widths.size >= On && this.widths.clear(), this.widths.set(r, a), a;
1089
+ return this.widths.size >= Xn && this.widths.clear(), this.widths.set(r, a), a;
991
1090
  }
992
1091
  destroy() {
993
1092
  this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
994
1093
  }
995
- }, An = class {
1094
+ }, Qn = class {
996
1095
  netY = 0;
997
1096
  travelX = 0;
998
1097
  engaged = !1;
@@ -1008,11 +1107,11 @@ var On = 512, kn = class {
1008
1107
  }
1009
1108
  return this.engaged;
1010
1109
  }
1011
- }, jn = 1;
1012
- function W(e, t) {
1110
+ }, $n = 1;
1111
+ function er(e, t) {
1013
1112
  return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
1014
1113
  }
1015
- function G(e) {
1114
+ function W(e) {
1016
1115
  switch (e.kind) {
1017
1116
  case "indicator": return `indicator:${e.plugin.descriptor.id}`;
1018
1117
  case "drawing": return `drawing:${e.plugin.descriptor.type}`;
@@ -1022,25 +1121,25 @@ function G(e) {
1022
1121
  }
1023
1122
  //#endregion
1024
1123
  //#region src/plugins/registry.ts
1025
- var K = /* @__PURE__ */ new Map();
1026
- function Mn(e) {
1027
- K.set(G(e), e);
1124
+ var G = /* @__PURE__ */ new Map();
1125
+ function tr(e) {
1126
+ G.set(W(e), e);
1028
1127
  }
1029
- function Nn(e) {
1030
- return K.delete(e);
1128
+ function nr(e) {
1129
+ return G.delete(e);
1031
1130
  }
1032
- function Pn() {
1033
- return [...K.values()];
1131
+ function rr() {
1132
+ return [...G.values()];
1034
1133
  }
1035
- function Fn() {
1036
- K.clear();
1134
+ function ir() {
1135
+ G.clear();
1037
1136
  }
1038
1137
  //#endregion
1039
1138
  //#region src/plugins/PluginManager.ts
1040
- var In = class {
1139
+ var ar = class {
1041
1140
  plugins = /* @__PURE__ */ new Map();
1042
1141
  constructor(e, t = {}) {
1043
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of Pn()) this.add(e);
1142
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of rr()) this.add(e);
1044
1143
  for (let e of t.plugins ?? []) this.add(e);
1045
1144
  }
1046
1145
  register(e) {
@@ -1068,17 +1167,17 @@ var In = class {
1068
1167
  return e;
1069
1168
  }
1070
1169
  add(e) {
1071
- this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1170
+ this.plugins.set(W(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1072
1171
  }
1073
- }, Ln = {
1172
+ }, or = {
1074
1173
  orderPlace: (e, t) => e.placeOrder(t),
1075
1174
  orderModify: (e, t) => e.modifyOrder(t),
1076
1175
  orderCancel: (e, t) => e.cancelOrder(t),
1077
1176
  positionModify: (e, t) => e.modifyPosition(t),
1078
1177
  positionClose: (e, t) => e.closePosition(t),
1079
- positionReverse: (e, t, n) => Rn(e, t, n)
1178
+ positionReverse: (e, t, n) => sr(e, t, n)
1080
1179
  };
1081
- async function Rn(e, t, n) {
1180
+ async function sr(e, t, n) {
1082
1181
  let { reversing: r } = n;
1083
1182
  if (!r.has(t.positionId)) {
1084
1183
  r.add(t.positionId);
@@ -1107,7 +1206,7 @@ async function Rn(e, t, n) {
1107
1206
  }
1108
1207
  }
1109
1208
  }
1110
- function zn(e, t) {
1209
+ function cr(e, t) {
1111
1210
  let n = [], r = null, i = {
1112
1211
  positions: () => r ?? t.getPositions?.() ?? [],
1113
1212
  reversing: /* @__PURE__ */ new Set()
@@ -1117,8 +1216,8 @@ function zn(e, t) {
1117
1216
  e.data && t.onFill?.(e.data);
1118
1217
  };
1119
1218
  e.on("orders", a), e.on("positions", o), e.on("error", s), e.on("fill", c), n.push(() => e.off("orders", a), () => e.off("positions", o), () => e.off("error", s), () => e.off("fill", c));
1120
- for (let r of Object.keys(Ln)) {
1121
- let a = Ln[r], o = t.onIntent(r, (n) => {
1219
+ for (let r of Object.keys(or)) {
1220
+ let a = or[r], o = t.onIntent(r, (n) => {
1122
1221
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
1123
1222
  message: `Execution command failed: ${r}`,
1124
1223
  cause: e
@@ -1132,27 +1231,27 @@ function zn(e, t) {
1132
1231
  }
1133
1232
  //#endregion
1134
1233
  //#region src/Chart.ts
1135
- var Bn = {
1234
+ var lr = {
1136
1235
  min: 0,
1137
1236
  max: 100
1138
- }, Vn = "exchange", Hn = Vn;
1139
- function Un(e) {
1140
- if (typeof e == "string" && e !== "exchange" && !g(e)) throw RangeError(`Unknown time zone: ${e}`);
1237
+ }, ur = "exchange", dr = ur;
1238
+ function fr(e) {
1239
+ if (typeof e == "string" && e !== "exchange" && !v(e)) throw RangeError(`Unknown time zone: ${e}`);
1141
1240
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
1142
1241
  }
1143
- function Wn(e, t) {
1144
- let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
1242
+ function pr(e, t) {
1243
+ let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : w(e);
1145
1244
  return i === void 0 ? e : {
1146
1245
  ...e,
1147
1246
  timeZone: i,
1148
1247
  timezone: i
1149
1248
  };
1150
1249
  }
1151
- var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontalLine", "crossLine"]), Zn = new Set(["verticalLine", "crossLine"]), Qn = class {
1152
- static version = "1.51.0";
1250
+ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontalLine", "crossLine"]), br = new Set(["verticalLine", "crossLine"]), xr = class {
1251
+ static version = "1.52.0";
1153
1252
  engine;
1154
1253
  viewport;
1155
- series = new un((e) => this.sessionKeep(e));
1254
+ series = new Mn((e) => this.sessionKeep(e));
1156
1255
  themeManager;
1157
1256
  layoutManager;
1158
1257
  pluginManager;
@@ -1167,6 +1266,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1167
1266
  execTeardown = null;
1168
1267
  autoScrollOnNewBar = !0;
1169
1268
  displayDataCache = null;
1269
+ reshapeMemo = new at();
1270
+ displayDataStep;
1170
1271
  indicatorUpdateFrom = null;
1171
1272
  resolvedLayoutCache = null;
1172
1273
  panelInfoCache = null;
@@ -1176,7 +1277,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1176
1277
  renderDeferred = !1;
1177
1278
  priceAxisWidth = o;
1178
1279
  measureCtx;
1179
- labelWidths = new kn();
1280
+ labelWidths = new Zn();
1180
1281
  containerSizeCache = null;
1181
1282
  containerSizeCacheTime = 0;
1182
1283
  lastEmittedRange = null;
@@ -1190,14 +1291,18 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1190
1291
  indicatorEdit = null;
1191
1292
  removedDrawingAlerts = /* @__PURE__ */ new Map();
1192
1293
  zoomAreaMode = !1;
1193
- priceAxisAddButton = new Ze();
1294
+ priceAxisAddButton = new $e();
1194
1295
  displayTz = null;
1195
1296
  timeZoneSetting = null;
1196
1297
  symbolInfo = null;
1197
1298
  symbolInfoSeq = 0;
1299
+ studyZoneHeld = !1;
1300
+ studyZone = null;
1301
+ studyZoneTimer = null;
1302
+ studyZoneReleaseQueued = !1;
1198
1303
  sessionBreaks;
1199
1304
  sessionShading;
1200
- hostSessionHours = { ...De };
1305
+ hostSessionHours = { ...ke };
1201
1306
  compareRenderer;
1202
1307
  countdownInterval = null;
1203
1308
  pausedFor = {
@@ -1216,7 +1321,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1216
1321
  signalMarkerManager;
1217
1322
  tradeZoneManager;
1218
1323
  measureOverlay;
1219
- selectionBoxOverlay = new nt();
1324
+ selectionBoxOverlay = new st();
1220
1325
  replayManager;
1221
1326
  replayBarUnsub = null;
1222
1327
  replaySeeking = !1;
@@ -1226,7 +1331,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1226
1331
  replayRevealMarks = !0;
1227
1332
  replayOffset = 0;
1228
1333
  undoRedoManager;
1229
- autoSaveScheduler = new an((e) => this.saveState(e));
1334
+ autoSaveScheduler = new Tn((e) => this.saveState(e));
1230
1335
  animator;
1231
1336
  crosshairTooltip;
1232
1337
  pinnedTooltip;
@@ -1238,14 +1343,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1238
1343
  disposed = !1;
1239
1344
  chartTypeOptions = {};
1240
1345
  mainSeriesVisible = !0;
1241
- priceLines = new Qe();
1242
- symbolSeries = new lt();
1346
+ priceLines = new et();
1347
+ symbolSeries = new mt();
1243
1348
  extendedHours = !0;
1244
1349
  replayRestarting = !1;
1245
1350
  requestedSymbols = /* @__PURE__ */ new Set();
1246
1351
  gridRenderer;
1247
1352
  priceAxis;
1248
- leftPriceAxis = new Xe();
1353
+ leftPriceAxis = new Qe();
1249
1354
  leftScaleRequested = !1;
1250
1355
  leftAxisWidth = o;
1251
1356
  leftViewport = null;
@@ -1261,6 +1366,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1261
1366
  priceUnit = null;
1262
1367
  paneTitles = !0;
1263
1368
  defaultAutoScale;
1369
+ priceFitPending = !0;
1370
+ seriesArriving = !0;
1264
1371
  keyboardHandler = null;
1265
1372
  a11y = null;
1266
1373
  onWindowKeyDown = null;
@@ -1276,7 +1383,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1276
1383
  snapshotKey = null;
1277
1384
  historyCheckQueued = !1;
1278
1385
  constructor(e, t) {
1279
- t.timeZone != null && Un(t.timeZone), this.container = e, this.options = {
1386
+ t.timeZone != null && fr(t.timeZone), this.container = e, this.options = {
1280
1387
  ...t,
1281
1388
  chartType: t.chartType ?? "candlestick"
1282
1389
  }, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
@@ -1314,15 +1421,15 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1314
1421
  logScale: n.logScale ?? !0,
1315
1422
  timeframes: n.timeframes ?? [],
1316
1423
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
1317
- }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new mn({
1424
+ }, 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 In({
1318
1425
  oldestTime: () => this.series.bars()[0]?.time ?? null,
1319
1426
  prepend: (e) => this.prependBars(e),
1320
1427
  emit: (e) => this.eventBus.emit("historyLoad", e)
1321
- }), this.themeManager = new gn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(vn(t), "host", !1), this.layoutManager = new xn(), this.indicatorEngine = new Le(), this.pluginManager = new In(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Me(), jt(this.indicatorEngine), this.indicatorEngine.register(new xe(this.symbolSeries)), this.indicatorEngine.register(new ot(this.symbolSeries)), this.indicatorEngine.register(new Se(this.symbolSeries)), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.drawingManager = new ke(), At(this.drawingManager), this.drawingRenderer = new Ae(this.drawingManager), this.drawingManager.setRequestRender(() => {
1428
+ }), this.themeManager = new Rn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Bn(t), "host", !1), this.layoutManager = new Un(), this.indicatorEngine = new Re(), this.pluginManager = new ar(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Pe(), Rt(this.indicatorEngine), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.indicatorEngine.register(new dt(this.symbolSeries)), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.drawingManager = new je(), Lt(this.drawingManager), this.drawingRenderer = new Me(this.drawingManager), this.drawingManager.setRequestRender(() => {
1322
1429
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
1323
1430
  }), this.drawingManager.setEventCallback((e, t) => {
1324
1431
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
1325
- }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new mt();
1432
+ }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new yt();
1326
1433
  let i = "";
1327
1434
  this.undoRedoManager.setOnChange(() => {
1328
1435
  let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
@@ -1335,21 +1442,21 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1335
1442
  primary: e[0] ?? null
1336
1443
  })), this.drawingManager.setForeignHistory((e, t) => {
1337
1444
  e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
1338
- }), this.drawingManager.setDataGetter(() => this.series.bars()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new ft({
1445
+ }), this.drawingManager.setDataGetter(() => this.series.bars(), () => this.series.revision()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new _t({
1339
1446
  enabled: this.features.trading,
1340
1447
  contextMenu: { enabled: this.features.tradingContextMenu }
1341
- }), this.tradingRenderer = new pt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
1448
+ }), this.tradingRenderer = new vt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
1342
1449
  this.eventBus.emit(e, t);
1343
- }), this.engine = new $e(e, t.maxPixelRatio);
1450
+ }), this.engine = new tt(e, t.maxPixelRatio);
1344
1451
  let a = this.engine.dprManager.getContainerSize();
1345
- if (this.viewport = new ht(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
1452
+ if (this.viewport = new bt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
1346
1453
  freePan: t.freePan ?? !0,
1347
1454
  minVisibleBars: t.panLimits?.minVisibleBars ?? 3
1348
1455
  }), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
1349
1456
  if (e.width <= 0 || e.height <= 0) return;
1350
1457
  let t = this.viewport.isAtEnd();
1351
1458
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
1352
- }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Ne(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Xe(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new ut(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new we(), 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) => {
1459
+ }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Fe(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Qe(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new ht(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new Ee(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setDataSource(() => this.crosshairSeries()), this.crosshairHandler.setCallback((e, t) => {
1353
1460
  if (e !== null && t) {
1354
1461
  let n = this.crosshairSeries(), r = e >= 0 && e < n.length ? n[e] : void 0;
1355
1462
  this.chartLegend.setHoverBar(r ?? null, e > 0 ? n[e - 1] ?? null : null);
@@ -1358,20 +1465,20 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1358
1465
  prevClose: e > 0 ? n[e - 1]?.close : void 0,
1359
1466
  priceRange: i.priceRange,
1360
1467
  plot: i.chartRect,
1361
- barStepMs: xt(n),
1362
- timeUnit: l(n)
1468
+ barStepMs: Et(n),
1469
+ timeUnit: u(n)
1363
1470
  }) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
1364
1471
  point: t,
1365
1472
  bar: r,
1366
1473
  barIndex: e
1367
1474
  });
1368
1475
  } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
1369
- }), this.chartLegend = new ye(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new yt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new vt(), this.volumeProfile = new _t(), this.marketProfile = new Ue(), this.depthHeatmap = new Oe(), this.periodLevels = new qe(), this.pivotMarkers = new Ye(), this.barCountdown = new he(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new rt(), this.sessionShading = new it(), this.compareRenderer = new be(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1476
+ }), this.chartLegend = new xe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new wt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Ct(), this.volumeProfile = new St(), this.marketProfile = new We(), this.depthHeatmap = new Ae(), this.periodLevels = new Je(), this.pivotMarkers = new Xe(), this.barCountdown = new _e(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new ct(), this.sessionShading = new lt(), this.compareRenderer = new Se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1370
1477
  visible: t.sessionBreaks.visible ?? !0,
1371
1478
  color: t.sessionBreaks.color,
1372
1479
  lineStyle: t.sessionBreaks.lineStyle,
1373
1480
  lineWidth: t.sessionBreaks.lineWidth
1374
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new fe(), this.crosshairTooltip = new Te(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Je(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = x(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(ir(t.shapes)), t.font && this.themeManager.setFont(rr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Be({
1481
+ }) : 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 Ye(), 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(Dr(t.shapes)), t.font && this.themeManager.setFont(Er(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ve({
1375
1482
  scrollBars: (e) => {
1376
1483
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1377
1484
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1388,17 +1495,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1388
1495
  },
1389
1496
  fitContent: () => this.fitContent()
1390
1497
  }), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
1391
- this.a11y = new Yt(e, {
1498
+ this.a11y = new nn(e, {
1392
1499
  symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
1393
1500
  timeframe: () => this.streamTimeframe ?? "",
1394
1501
  chartType: () => this.options.chartType ?? "candlestick",
1395
1502
  bars: () => this.getDisplayData(),
1396
1503
  visibleRange: () => this.viewport.getState().visibleRange,
1397
1504
  formatPrice: (e) => this.formatPrice(e),
1398
- formatTime: (e) => le(this.numberLocale || "en-US", {
1399
- dateStyle: "medium",
1400
- timeStyle: "short"
1401
- }, this.displayTz)(e * l(this.getDisplayData())),
1505
+ formatTime: (e) => this.spokenBarTime(e),
1402
1506
  showBar: (e) => this.setCrosshairTime(e)
1403
1507
  }, t.a11y?.labels);
1404
1508
  for (let e of [
@@ -1418,8 +1522,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1418
1522
  }
1419
1523
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1420
1524
  }
1421
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ee(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new de(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
1422
- this.eventBus.emit("alertTriggered", q(e)), this.eventBus.emit("dataUpdate", {
1525
+ }, 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(kt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
1526
+ this.eventBus.emit("alertTriggered", K(e)), this.eventBus.emit("dataUpdate", {
1423
1527
  kind: "alert",
1424
1528
  alert: "triggered",
1425
1529
  alertId: e.id,
@@ -1427,14 +1531,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1427
1531
  message: e.message
1428
1532
  });
1429
1533
  }), this.alertManager.on("added", (e) => {
1430
- this.eventBus.emit("alertAdd", q(e));
1534
+ this.eventBus.emit("alertAdd", K(e));
1431
1535
  }), this.alertManager.on("removed", (e) => {
1432
1536
  this.eventBus.emit("alertRemove", { id: e });
1433
1537
  }), this.alertManager.on("expired", (e) => {
1434
- this.eventBus.emit("alertExpired", q(e));
1538
+ this.eventBus.emit("alertExpired", K(e));
1435
1539
  }), this.alertManager.on("updated", (e) => {
1436
- this.eventBus.emit("alertUpdate", q(e));
1437
- }), this.signalMarkerManager = new at(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
1540
+ this.eventBus.emit("alertUpdate", K(e));
1541
+ }), this.signalMarkerManager = new ut(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
1438
1542
  this.eventBus.emit("signalMarkerAdd", {
1439
1543
  id: e.id,
1440
1544
  source: e.source,
@@ -1442,14 +1546,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1442
1546
  });
1443
1547
  }), this.signalMarkerManager.on("removed", (e) => {
1444
1548
  this.eventBus.emit("signalMarkerRemove", { id: e });
1445
- }), this.tradeZoneManager = new dt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
1549
+ }), this.tradeZoneManager = new gt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
1446
1550
  this.eventBus.emit("tradeZoneAdd", {
1447
1551
  id: e.id,
1448
1552
  direction: e.direction
1449
1553
  });
1450
1554
  }), this.tradeZoneManager.on("removed", (e) => {
1451
1555
  this.eventBus.emit("tradeZoneRemove", { id: e });
1452
- }), this.replayManager = new tt(), this.replayManager.on("complete", () => {
1556
+ }), this.replayManager = new rt(), this.replayManager.on("complete", () => {
1453
1557
  let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
1454
1558
  t && this.eventBus.emit("replayComplete", {
1455
1559
  barIndex: e,
@@ -1457,10 +1561,10 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1457
1561
  });
1458
1562
  }), this.replayManager.on("stateChange", (e) => {
1459
1563
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
1460
- }), this.measureOverlay = new We(), this.interactionManager = new Re(e), this.features.panning) {
1461
- let e = new An();
1462
- this.interactionManager.setPanHandler(new Ge((t, n) => {
1463
- t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1564
+ }), this.measureOverlay = new Ge(), this.interactionManager = new ze(e), this.features.panning) {
1565
+ let e = new Qn();
1566
+ this.interactionManager.setPanHandler(new Ke((t, n) => {
1567
+ t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1464
1568
  }, () => e.reset()));
1465
1569
  }
1466
1570
  if (this.interactionManager.setAxisStrips(() => ({
@@ -1471,11 +1575,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1471
1575
  scales: !this.indicatorEngine.hasLeftScaleOverlays()
1472
1576
  }
1473
1577
  })), this.features.zooming) {
1474
- this.interactionManager.setZoomHandler(new bt((e, t) => {
1578
+ this.interactionManager.setZoomHandler(new Tt((e, t) => {
1475
1579
  this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
1476
1580
  }));
1477
- let e = new me((e) => {
1478
- this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1581
+ let e = new ge((e) => {
1582
+ this.holdPriceScale(), this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1479
1583
  }, (e) => {
1480
1584
  let t = this.viewport.getState().chartRect.width;
1481
1585
  this.viewport.zoom(1 / e - 1, t / 2), this.updateViewportAndRender();
@@ -1494,7 +1598,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1494
1598
  y: t.y
1495
1599
  });
1496
1600
  })), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.priceAxisAddButton.setEnabled(this.features.priceAxisAddButton && this.features.crosshair), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
1497
- let t = N(e.y, this.viewport.getState());
1601
+ let t = Jt(e.y, this.viewport.getState());
1498
1602
  Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
1499
1603
  price: t,
1500
1604
  x: e.x,
@@ -1504,15 +1608,15 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1504
1608
  ...this.viewport.getState(),
1505
1609
  data: this.getDisplayData()
1506
1610
  })), this.features.alerts) {
1507
- let e = new ue(this.alertManager, () => this.viewport.getState());
1611
+ let e = new fe(this.alertManager, () => this.viewport.getState());
1508
1612
  this.interactionManager.setAlertDragHandler(e);
1509
1613
  }
1510
- let o = new Ke();
1614
+ let o = new qe();
1511
1615
  o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
1512
1616
  let t = this.getDisplayData();
1513
1617
  if (t.length === 0) return;
1514
1618
  let n = this.viewport.getState(), i = n.barWidth + n.barSpacing, a = Math.round((n.offset + e.x) / i);
1515
- a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme(), l(t)), this.pinnedTooltip.reposition(this.viewport.getState(), this.series.bars()[a] ?? null, a, this.themeManager.getTheme()), this.engine.requestRender(r.Overlay));
1619
+ a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme(), u(t), d(t) === !0), this.pinnedTooltip.reposition(this.viewport.getState(), this.series.bars()[a] ?? null, a, this.themeManager.getTheme()), this.engine.requestRender(r.Overlay));
1516
1620
  }), this.interactionManager.setSignalMarkerHitTest((e) => this.eventBus.hasListeners("signalMarkerHover") || this.eventBus.hasListeners("signalMarkerClick") ? this.signalMarkerManager.markerAt(e, this.viewport.getState()) : null, (e, t) => this.eventBus.emit("signalMarkerHover", {
1517
1621
  marker: e,
1518
1622
  x: t.x,
@@ -1531,7 +1635,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1531
1635
  x: e.x,
1532
1636
  y: e.y
1533
1637
  }), t.length === 0) return;
1534
- let r = Ht(e.x, this.viewport.getState());
1638
+ let r = qt(e.x, this.viewport.getState());
1535
1639
  r < 0 || r >= t.length || this.eventBus.emit("barClick", {
1536
1640
  bar: t[r],
1537
1641
  barIndex: r,
@@ -1574,7 +1678,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1574
1678
  end: () => {
1575
1679
  let e = this.selectionBoxOverlay.end();
1576
1680
  if (e && this.zoomAreaMode) {
1577
- if (e.x1 - e.x0 < Yn) return;
1681
+ if (e.x1 - e.x0 < vr) return;
1578
1682
  this.zoomToBox(e), this.setZoomAreaMode(!1);
1579
1683
  return;
1580
1684
  }
@@ -1605,8 +1709,10 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1605
1709
  this.loadSeries(e, !1);
1606
1710
  }
1607
1711
  loadSeries(e, t) {
1608
- this.snapshotKey = null, this.endReplaySession(), this.history.reset(), this.series.load(e), this.crosshairHandler.setData(this.series.bars()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.options.autoScale = this.defaultAutoScale;
1609
- let n = this.series.bars(), r = n[n.length - 1];
1712
+ this.snapshotKey = null, this.endReplaySession(), this.history.reset(), this.series.load(e), this.crosshairHandler.setData(this.series.bars()), this.displayDataCache = null, this.reshapeMemo.clear(), this.sessionBreaks.invalidateCache(), this.options.autoScale = this.defaultAutoScale, this.priceFitPending = !0;
1713
+ let n = this.series.bars();
1714
+ this.seriesArriving = n.length === 0;
1715
+ let r = n[n.length - 1];
1610
1716
  t || (this.alertManager.clearLastValues(), r && this.alertManager.seedLastValue("price", r.close)), this.recalcIndicators(n), r && this.currentPriceLine.setPrice(r.close), this.updateViewportAndRender(!0), this.emitBars(n.length);
1611
1717
  }
1612
1718
  prependBars(e) {
@@ -1614,8 +1720,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1614
1720
  let t = this.getDisplayData(), n = Math.max(0, Math.min(t.length - 1, Math.floor(this.viewport.getState().visibleRange.from))), r = t[n]?.time, { added: i, taken: a } = this.series.prepend(e);
1615
1721
  if (i === 0) return a;
1616
1722
  let o = this.series.bars();
1617
- if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), r !== void 0) {
1618
- let e = Math.round(j(r, this.getDisplayData()));
1723
+ 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) {
1724
+ let e = Math.round(M(r, this.getDisplayData()));
1619
1725
  this.viewport.prependBars(e - n);
1620
1726
  }
1621
1727
  return this.updateViewportAndRender(), a;
@@ -1627,7 +1733,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1627
1733
  return;
1628
1734
  }
1629
1735
  let n = this.series.bars();
1630
- this.crosshairHandler.setData(n), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.recalcIndicators(n), n.length > 0 && this.currentPriceLine.setPrice(n[n.length - 1].close), this.updateViewportAndRender(t), this.emitBars(n.length);
1736
+ this.crosshairHandler.setData(n), this.displayDataCache = null, this.reshapeMemo.clear(), this.sessionBreaks.invalidateCache(), this.recalcIndicators(n), n.length > 0 && this.currentPriceLine.setPrice(n[n.length - 1].close), this.updateViewportAndRender(t), this.emitBars(n.length);
1631
1737
  }
1632
1738
  setHistoryLoader(e, t) {
1633
1739
  this.historyFromStream = !1, this.hostHistoryLoader = e !== null, this.history.setLoader(e, t?.pageSize), this.checkHistory();
@@ -1643,17 +1749,17 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1643
1749
  }
1644
1750
  checkHistory() {
1645
1751
  this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
1646
- if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || R(this.options.chartType)) return;
1752
+ if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || I(this.options.chartType)) return;
1647
1753
  let { visibleRange: e, chartRect: t } = this.viewport.getState();
1648
1754
  if (t.width <= 0) return;
1649
1755
  let { from: n, to: r } = e;
1650
- this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Jn, r - n));
1756
+ this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(_r, r - n));
1651
1757
  }));
1652
1758
  }
1653
1759
  useStreamHistory(e, t) {
1654
1760
  if (this.hostHistoryLoader) return;
1655
- let n = Vt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1656
- if (!r || i === null || se(i) !== null) {
1761
+ let n = N(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1762
+ if (!r || i === null || le(i) !== null) {
1657
1763
  this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
1658
1764
  return;
1659
1765
  }
@@ -1661,17 +1767,17 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1661
1767
  this.history.setLoader((e, t) => r.call(n, a, i, e, t), t), this.historyFromStream = !0, this.checkHistory();
1662
1768
  }
1663
1769
  appendBar(e) {
1664
- if (!z(e)) return;
1770
+ if (!L(e)) return;
1665
1771
  let t = this.series.append(e);
1666
1772
  if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
1667
1773
  this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
1668
1774
  return;
1669
1775
  }
1670
1776
  let n = this.autoScrollOnNewBar && this.viewport.isAtEnd(), r = t.before, i = this.series.bars();
1671
- this.crosshairHandler.setData(i), this.displayDataCache = null, this.recalcIndicatorsFrom(i, i.length - 2), this.currentPriceLine.setPrice(e.close), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
1777
+ this.crosshairHandler.setData(i), this.displayDataCache = null, this.recalcIndicatorsFrom(i, i.length - 2), this.currentPriceLine.setPrice(e.close, i[i.length - 2]?.close), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
1672
1778
  }
1673
1779
  appendBars(e) {
1674
- if (e = e.filter(z), e.length === 0) return;
1780
+ if (e = e.filter(L), e.length === 0) return;
1675
1781
  let t = e[e.length - 1].close, n = this.series.appendMany(e);
1676
1782
  if (n.refiltered && (this.displayDataCache = null), n.shown === 0) {
1677
1783
  this.takeLivePrice(t), n.aside || this.scheduleRender();
@@ -1680,10 +1786,10 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1680
1786
  let r = this.autoScrollOnNewBar && this.viewport.isAtEnd(), i = n.before;
1681
1787
  this.displayDataCache = null;
1682
1788
  let a = this.series.bars();
1683
- this.recalcIndicatorsFrom(a, i - 1), this.crosshairHandler.setData(a), this.currentPriceLine.setPrice(t), this.updateViewportAndRender(r), a.length !== i && this.emitBars(a.length), this.followLivePrice(t);
1789
+ this.recalcIndicatorsFrom(a, i - 1), this.crosshairHandler.setData(a), this.currentPriceLine.setPrice(t, a[a.length - 2]?.close), this.updateViewportAndRender(r), a.length !== i && this.emitBars(a.length), this.followLivePrice(t);
1684
1790
  }
1685
1791
  updateLastBar(e) {
1686
- if (!z(e)) return;
1792
+ if (!L(e)) return;
1687
1793
  let t = this.series.updateLast(e);
1688
1794
  if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
1689
1795
  this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
@@ -1704,6 +1810,29 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1704
1810
  let n = this.series.bars();
1705
1811
  this.recalcIndicatorsFrom(n, n.length - 1), this.followLivePrice(e.price), this.scheduleRender();
1706
1812
  }
1813
+ updateBar(e) {
1814
+ if (!L(e)) return !1;
1815
+ let t = this.series.replace(e);
1816
+ return t.to === "none" ? !1 : (t.to === "shown" && t.changed && this.showCorrection(t.index), !0);
1817
+ }
1818
+ showCorrection(e) {
1819
+ let t = this.series.bars(), n = t[e];
1820
+ this.displayDataCache = null, this.reshapeMemo.clear(), this.indicatorEngine.deferRecalculateFrom(t, e), this.announceIndicatorUpdate(e), e === t.length - 1 && (this.currentPriceLine.setPrice(n.close, t[e - 1]?.close), this.alertManager.seedLastValue("price", n.close)), this.refreshShownBar(e), this.eventBus.emit("dataUpdate", {
1821
+ kind: "correction",
1822
+ time: n.time,
1823
+ index: e
1824
+ }), this.scheduleRender();
1825
+ }
1826
+ refreshShownBar(e) {
1827
+ let t = this.pinnedTooltip.isPinned() ? this.pinnedTooltip.getPinnedIndex() : -1, n = this.crosshairHandler.getReportedBarIndex();
1828
+ if (t < e && n === null) return;
1829
+ let r = this.isTimeAligned();
1830
+ if (r && t >= e) {
1831
+ let e = this.getDisplayData();
1832
+ e[t] && this.pinnedTooltip.pin(e[t], t, this.themeManager.getTheme(), u(e), d(e) === !0);
1833
+ }
1834
+ n !== null && (!r || n === e || n === e + 1) && this.crosshairHandler.refresh();
1835
+ }
1707
1836
  getChartType() {
1708
1837
  return this.options.chartType ?? "candlestick";
1709
1838
  }
@@ -1715,17 +1844,17 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1715
1844
  });
1716
1845
  }
1717
1846
  applyTimeSpacing() {
1718
- let e = !this.tickStream && !R(this.options.chartType);
1847
+ let e = !this.tickStream && !I(this.options.chartType);
1719
1848
  this.timeAxis.setTimesPastData(e), this.crosshairHandler.setTimesPastData(e);
1720
1849
  }
1721
1850
  setChartTypeOptions(e) {
1722
1851
  this.chartTypeOptions = {
1723
1852
  ...this.chartTypeOptions,
1724
- ...x(e)
1725
- }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged();
1853
+ ...S(e)
1854
+ }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.a11y?.refresh(!0), this.markStateChanged();
1726
1855
  }
1727
1856
  getChartTypeOptions() {
1728
- return x(this.chartTypeOptions);
1857
+ return S(this.chartTypeOptions);
1729
1858
  }
1730
1859
  setExtendedHours(e) {
1731
1860
  e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
@@ -1734,18 +1863,18 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1734
1863
  return this.extendedHours;
1735
1864
  }
1736
1865
  sessionKeep(e) {
1737
- return this.extendedHours ? null : Gt(this.symbolInfo, e);
1866
+ return this.extendedHours ? null : Zt(this.symbolInfo, e);
1738
1867
  }
1739
1868
  reapplyExtendedHours() {
1740
1869
  if (!this.series.refilter()) return;
1741
1870
  let e = this.series.bars();
1742
- this.crosshairHandler.setData(e), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.recalcIndicators(e), this.updateViewportAndRender(!0), this.emitBars(e.length);
1871
+ this.crosshairHandler.setData(e), this.displayDataCache = null, this.reshapeMemo.clear(), this.sessionBreaks.invalidateCache(), this.recalcIndicators(e), this.updateViewportAndRender(!0), this.emitBars(e.length);
1743
1872
  }
1744
1873
  quoteLines() {
1745
1874
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
1746
1875
  }
1747
1876
  setShapes(e) {
1748
- let t = ir(e);
1877
+ let t = Dr(e);
1749
1878
  t.tagRadius !== void 0 && (this.themeManager.setShape({
1750
1879
  ...this.themeManager.getTheme().shape,
1751
1880
  ...t
@@ -1757,7 +1886,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1757
1886
  setFont(e) {
1758
1887
  if (e === null) this.themeManager.setFont(null);
1759
1888
  else {
1760
- let t = rr(e);
1889
+ let t = Er(e);
1761
1890
  if (Object.keys(t).length === 0) return;
1762
1891
  this.themeManager.setFont(t);
1763
1892
  }
@@ -1808,7 +1937,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1808
1937
  setSymbolSeries(e, t) {
1809
1938
  e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
1810
1939
  let n = this.series.bars(), r = !1;
1811
- 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);
1940
+ 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);
1812
1941
  r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
1813
1942
  }
1814
1943
  forgetUnreadSymbols() {
@@ -1822,27 +1951,27 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1822
1951
  let e = /* @__PURE__ */ new Set();
1823
1952
  for (let t of this.indicatorEngine.getActiveIndicators()) {
1824
1953
  let n = t.params.symbol;
1825
- O.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
1954
+ k.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
1826
1955
  }
1827
1956
  return [...e];
1828
1957
  }
1829
1958
  requestMissingSymbols(e) {
1830
1959
  this.forgetUnreadSymbols();
1831
- let t = this.indicatorEngine.getIndicatorConfig(e), n = t && O.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
1960
+ let t = this.indicatorEngine.getIndicatorConfig(e), n = t && k.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
1832
1961
  !n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
1833
1962
  }
1834
1963
  updateIndicator(e, t) {
1835
1964
  this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
1836
1965
  }
1837
1966
  updateIndicatorNow(e, t) {
1838
- let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? A(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
1967
+ let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? j(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
1839
1968
  this.indicatorEngine.updateIndicator(e, t, this.series.bars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
1840
1969
  instanceId: e,
1841
1970
  change: "params"
1842
1971
  }), this.requestMissingSymbols(e);
1843
1972
  let a = this.indicatorEngine.getIndicatorConfig(e);
1844
1973
  if (n?.placement === "overlay" && a && r && a.params[r] !== i) {
1845
- let t = y(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : y(i) ? null : a.pane ?? null;
1974
+ let t = b(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : b(i) ? null : a.pane ?? null;
1846
1975
  (n ?? void 0) !== a.pane && (this.indicatorEngine.setPane(e, n), this.eventBus.emit("indicatorChange", {
1847
1976
  instanceId: e,
1848
1977
  change: "pane"
@@ -1853,7 +1982,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1853
1982
  paneFor(e, t, n, r) {
1854
1983
  if (n) return this.paneHostOf(n, r);
1855
1984
  if (e.placement !== "overlay") return null;
1856
- let i = A(e), a = i ? y(t[i]) : null;
1985
+ let i = j(e), a = i ? b(t[i]) : null;
1857
1986
  return a ? this.paneHostOf(a.instanceId, r) : null;
1858
1987
  }
1859
1988
  paneHostOf(e, t) {
@@ -1880,6 +2009,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1880
2009
  setLeftPriceScaleVisible(e) {
1881
2010
  this.leftScaleRequested = e, this.updateViewportAndRender();
1882
2011
  }
2012
+ isLeftPriceScaleVisible() {
2013
+ return this.leftScaleRequested;
2014
+ }
1883
2015
  isLeftPriceScaleShown() {
1884
2016
  return this.features.priceAxis !== !1 && (this.leftScaleRequested || this.indicatorEngine.hasLeftScaleOverlays());
1885
2017
  }
@@ -1896,13 +2028,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1896
2028
  return {
1897
2029
  ...e,
1898
2030
  priceRange: {
1899
- min: t.min - n * Gn,
1900
- max: t.max + n * Gn
2031
+ min: t.min - n * mr,
2032
+ max: t.max + n * mr
1901
2033
  },
1902
2034
  logScale: !1,
1903
2035
  scaleMode: "regular",
1904
2036
  invertScale: !1,
1905
2037
  formatPrice: void 0,
2038
+ pricePrecision: void 0,
1906
2039
  priceUnit: void 0
1907
2040
  };
1908
2041
  }
@@ -1949,7 +2082,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1949
2082
  this.indicatorEngine.setStyleDefaults(e, null);
1950
2083
  return;
1951
2084
  }
1952
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ne(n);
2085
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ie(n);
1953
2086
  this.indicatorEngine.setStyleDefaults(e, {
1954
2087
  ...r,
1955
2088
  ...i ? { plots: i } : {}
@@ -1957,7 +2090,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1957
2090
  }
1958
2091
  setPaneStyle(e, t) {
1959
2092
  let n = this.paneOf(e);
1960
- this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? re(t) : null));
2093
+ this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? ae(t) : null));
1961
2094
  }
1962
2095
  setPaneStyleNow(e, t) {
1963
2096
  JSON.stringify(t) !== JSON.stringify(this.paneStyles.get(e) ?? null) && (t ? this.paneStyles.set(e, t) : this.paneStyles.delete(e), this.panelInfoCache = null, this.syncRenderContext(), this.engine.requestRender(), this.markStateChanged());
@@ -1976,8 +2109,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
1976
2109
  return this.pluginManager;
1977
2110
  }
1978
2111
  static indicators() {
1979
- let e = new Le();
1980
- return jt(e), e.getAvailableIndicators();
2112
+ let e = new Re();
2113
+ return Rt(e), e.getAvailableIndicators();
1981
2114
  }
1982
2115
  setPanelPosition(e, t) {
1983
2116
  this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
@@ -2000,8 +2133,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2000
2133
  paneMoveHost(e, t) {
2001
2134
  let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
2002
2135
  if (!n || !r) return;
2003
- let i = A(r);
2004
- if (r.placement === "overlay" && i && y(n.params[i])) return;
2136
+ let i = j(r);
2137
+ if (r.placement === "overlay" && i && b(n.params[i])) return;
2005
2138
  if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
2006
2139
  if (t === "new") {
2007
2140
  let t = this.layoutManager.getPanels().some((t) => t.id === e);
@@ -2099,6 +2232,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2099
2232
  setIndicatorValueLabelsVisible(e) {
2100
2233
  this.features.indicatorValueLabels = e, this.syncRenderContext(), this.engine.requestRender();
2101
2234
  }
2235
+ isIndicatorValueLabelsVisible() {
2236
+ return this.features.indicatorValueLabels;
2237
+ }
2102
2238
  setPaneTitlesVisible(e) {
2103
2239
  this.paneTitles = e, this.engine.requestRender();
2104
2240
  }
@@ -2107,12 +2243,12 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2107
2243
  return this.features.legend ? e + this.chartLegend.getHeight() : e;
2108
2244
  }
2109
2245
  isTimeAligned() {
2110
- return R(this.options.chartType) ? !1 : this.getDisplayData().length === this.series.length();
2246
+ return I(this.options.chartType) ? !1 : this.getDisplayData().length === this.series.length();
2111
2247
  }
2112
2248
  roundPrice(e) {
2113
2249
  if (!Number.isFinite(e)) return e;
2114
2250
  let t = this.stepAt(e);
2115
- if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(oe(t)));
2251
+ if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(ce(t)));
2116
2252
  let { min: n, max: r } = this.viewport.getState().priceRange;
2117
2253
  return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
2118
2254
  }
@@ -2122,7 +2258,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2122
2258
  }
2123
2259
  stepAt(e) {
2124
2260
  let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
2125
- return t !== void 0 && t > 0 ? t : this.marketConfig ? te(e, this.marketConfig) : void 0;
2261
+ return t !== void 0 && t > 0 ? t : this.marketConfig ? re(e, this.marketConfig) : void 0;
2126
2262
  }
2127
2263
  getPriceStep(e) {
2128
2264
  let t = this.stepAt(e ?? this.lastClose());
@@ -2137,7 +2273,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2137
2273
  return this.priceFormatter;
2138
2274
  }
2139
2275
  applyPriceFormat(e) {
2140
- this.priceFormatter = ee(e), this.priceUnit = e && typeof e != "function" ? m(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
2276
+ this.priceFormatter = ne(e), this.priceUnit = e && typeof e != "function" ? g(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
2141
2277
  }
2142
2278
  setTimeFormatter(e) {
2143
2279
  this.applyTimeFormatter(e), this.engine.requestRender();
@@ -2148,7 +2284,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2148
2284
  formatPrice(e) {
2149
2285
  if (this.priceFormatter) return this.priceFormatter(e);
2150
2286
  let { min: t, max: n } = this.viewport.getState().priceRange;
2151
- return p(e, this.marketPricePrecision ?? c(t, n), this.numberLocale);
2287
+ return h(e, this.marketPricePrecision ?? c(t, n), this.numberLocale);
2152
2288
  }
2153
2289
  setDrawingTool(e) {
2154
2290
  this.features.drawings && (e && this.features.drawingTools.length > 0 && !this.features.drawingTools.includes(e) || (e && this.setZoomAreaMode(!1), this.drawingManager.setActiveTool(e)));
@@ -2196,7 +2332,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2196
2332
  }
2197
2333
  autoFib() {
2198
2334
  if (!this.features.drawings) return null;
2199
- let e = this.getDisplayData(), t = this.viewport.getState(), n = St(e, t.visibleRange.from, t.visibleRange.to);
2335
+ let e = this.getDisplayData(), t = this.viewport.getState(), n = Dt(e, t.visibleRange.from, t.visibleRange.to);
2200
2336
  return n ? this.addDrawing({
2201
2337
  type: "fibRetracement",
2202
2338
  anchors: [n[0], n[1]]
@@ -2274,7 +2410,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2274
2410
  recordUndo(e) {
2275
2411
  if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
2276
2412
  let t = performance.now(), n = this.undoRedoManager.last();
2277
- if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < qn) {
2413
+ if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < gr) {
2278
2414
  this.undoRedoManager.replaceLast({
2279
2415
  ...n,
2280
2416
  custom: {
@@ -2321,7 +2457,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2321
2457
  x: t.x,
2322
2458
  y: t.y
2323
2459
  };
2324
- if ((e === "plot" || e === "priceAxis") && (r.price = N(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = M(t.x, n)), e === "pane") {
2460
+ if ((e === "plot" || e === "priceAxis") && (r.price = Jt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = P(t.x, n)), e === "pane") {
2325
2461
  let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
2326
2462
  e && (r.pane = e.instanceId);
2327
2463
  }
@@ -2347,7 +2483,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2347
2483
  ...this.viewport.getState(),
2348
2484
  data: this.getDisplayData()
2349
2485
  };
2350
- this.setVisibleRange(M(e.x0, t), M(e.x1, t));
2486
+ this.setVisibleRange(P(e.x0, t), P(e.x1, t));
2351
2487
  }
2352
2488
  lockAllDrawings() {
2353
2489
  this.drawingManager.lockAllDrawings();
@@ -2392,7 +2528,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2392
2528
  for (let e of this.indicatorEngine.getActiveIndicators()) {
2393
2529
  let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
2394
2530
  if (!t) continue;
2395
- let r = L(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2531
+ let r = on(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2396
2532
  key: e,
2397
2533
  title: e
2398
2534
  }));
@@ -2416,11 +2552,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2416
2552
  }
2417
2553
  getExportText(e = "csv", t = {}) {
2418
2554
  let { bars: n, columns: r } = this.getExportData(t);
2419
- return e === "json" ? T.toJSON(n, r) : T.toCSV(n, r);
2555
+ return e === "json" ? E.toJSON(n, r) : E.toCSV(n, r);
2420
2556
  }
2421
2557
  download(e, t, n) {
2422
2558
  let r = this.getExportText(e, n);
2423
- e === "json" ? T.download(r, t ?? "chart-data.json", "application/json") : T.download(r, t ?? "chart-data.csv", "text/csv");
2559
+ e === "json" ? E.download(r, t ?? "chart-data.json", "application/json") : E.download(r, t ?? "chart-data.csv", "text/csv");
2424
2560
  }
2425
2561
  setAutoSave(e, t = 5e3) {
2426
2562
  this.autoSaveScheduler.enable(e, t);
@@ -2482,7 +2618,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2482
2618
  this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
2483
2619
  }
2484
2620
  updateIndicatorStyleNow(e, t) {
2485
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ne(n);
2621
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ie(n);
2486
2622
  this.indicatorEngine.updateIndicatorStyle(e, {
2487
2623
  ...r,
2488
2624
  ...i ? { plots: i } : {}
@@ -2601,21 +2737,26 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2601
2737
  this.features.trading && this.tradingManager.setConfig(e);
2602
2738
  }
2603
2739
  async connect(e) {
2604
- if (!Mt(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
2605
- this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new ct(), this.streamManager.on("snapshot", (t) => {
2606
- let n = `${this.currentSymbol}|${this.streamTimeframe}`;
2740
+ if (!zt(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
2741
+ this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new pt(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (t) => {
2742
+ let n = this.streamSeriesKey(e.adapter);
2607
2743
  this.replaySession ? this.series.loadAside(t) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(t) : this.setData(t), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
2608
2744
  }), this.streamManager.on("barClose", (e) => {
2609
- if (!z(e)) return;
2745
+ if (!L(e)) return;
2610
2746
  let t = this.series.placeStreamBar(e);
2611
- if (t.refiltered && (this.displayDataCache = null), t.to === "aside" && this.followLivePrice(e.close), t.to !== "shown") return;
2747
+ if (t.refiltered && (this.displayDataCache = null), t.to === "none") {
2748
+ this.updateBar(e);
2749
+ return;
2750
+ }
2751
+ if (t.to === "aside" && this.followLivePrice(e.close), t.to !== "shown") return;
2612
2752
  let n = this.autoScrollOnNewBar && this.viewport.isAtEnd(), r = t.before, i = this.series.bars();
2613
2753
  this.crosshairHandler.setData(i), this.displayDataCache = null, this.recalcIndicatorsFrom(i, i.length - 2), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
2754
+ }), this.streamManager.on("barCorrection", (e) => {
2755
+ this.updateBar(e);
2614
2756
  }), this.streamManager.on("barUpdate", (e) => {
2615
- if (!z(e)) return;
2616
- this.replaySession || this.currentPriceLine.setPrice(e.close);
2757
+ if (!L(e)) return;
2617
2758
  let t = this.series.placeStreamBar(e);
2618
- if (t.refiltered && (this.displayDataCache = null), this.replaySession) return;
2759
+ if (t.refiltered && (this.displayDataCache = null), t.to === "none" || (this.replaySession || this.currentPriceLine.setPrice(e.close), this.replaySession)) return;
2619
2760
  let n = t.before;
2620
2761
  if (t.to !== "shown") {
2621
2762
  this.scheduleRender();
@@ -2653,14 +2794,18 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2653
2794
  }), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
2654
2795
  let t = this.streamManager;
2655
2796
  if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
2656
- let n = ce(e.timeframe);
2797
+ let n = ue(e.timeframe);
2657
2798
  this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
2658
2799
  this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
2659
2800
  }, 1e3);
2660
2801
  }
2802
+ streamSeriesKey(e) {
2803
+ let t = N(e), n = this.streamTimeframe, r = t instanceof it && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
2804
+ return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
2805
+ }
2661
2806
  setStreamTarget(e, t) {
2662
2807
  let n = this.announcedSymbol;
2663
- this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = se(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
2808
+ 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", {
2664
2809
  symbol: e,
2665
2810
  previous: n
2666
2811
  })), this.useTimeframe(t);
@@ -2678,8 +2823,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2678
2823
  async switchStream(e, t) {
2679
2824
  if (!this.streamManager) return;
2680
2825
  let n = this.streamAdapter;
2681
- if (n && !Mt(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2682
- this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(ce(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
2826
+ if (n && !zt(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2827
+ this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(ue(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
2683
2828
  }
2684
2829
  isIndicatorAllowed(e) {
2685
2830
  let t = this.features.indicatorIds;
@@ -2694,11 +2839,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2694
2839
  this.isTimeframeAllowed(e) && await this.switchStream(this.currentSymbol, e);
2695
2840
  }
2696
2841
  disconnectStream() {
2697
- this.symbolInfoSeq++, this.priceLines.setBidAsk(null), this.streamManager &&= (this.streamManager.dispose(), null), this.historyFromStream &&= (this.history.setLoader(null), !1), this.streamAdapter = null, this.tickStream = !1, this.applyTimeSpacing();
2842
+ this.symbolInfoSeq++, this.releaseStudyZoneAfterCaller(), this.priceLines.setBidAsk(null), this.streamManager &&= (this.streamManager.dispose(), null), this.historyFromStream &&= (this.history.setLoader(null), !1), this.streamAdapter = null, this.tickStream = !1, this.applyTimeSpacing();
2698
2843
  }
2699
2844
  connectExecution(e, t = {}) {
2700
2845
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
2701
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = zn(e, {
2846
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = cr(e, {
2702
2847
  onIntent: (e, t) => {
2703
2848
  let n = (e) => t(e.payload);
2704
2849
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -2724,6 +2869,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2724
2869
  setBarCountdownVisible(e) {
2725
2870
  this.barCountdown.setVisible(e && this.features.barCountdown), this.engine.requestRender(r.Hover);
2726
2871
  }
2872
+ isBarCountdownVisible() {
2873
+ return this.barCountdown.isVisible();
2874
+ }
2727
2875
  setSessionBreaksVisible(e) {
2728
2876
  this.sessionBreaks.setVisible(e), this.engine.requestRender(r.Background);
2729
2877
  }
@@ -2734,19 +2882,50 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2734
2882
  data: n,
2735
2883
  color: r,
2736
2884
  visible: !0
2737
- }), this.updateViewportAndRender());
2885
+ }), this.updateViewportAndRender(), this.eventBus.emit("compareChange", {
2886
+ id: e,
2887
+ change: "add"
2888
+ }));
2738
2889
  }
2739
2890
  removeCompareSymbol(e) {
2740
- this.compareRenderer.removeSymbol(e), this.updateViewportAndRender();
2891
+ this.compareRenderer.removeSymbol(e), this.updateViewportAndRender(), this.eventBus.emit("compareChange", {
2892
+ id: e,
2893
+ change: "remove"
2894
+ });
2741
2895
  }
2742
2896
  updateCompareData(e, t) {
2743
- this.compareRenderer.setSymbolData(e, t), this.updateViewportAndRender();
2897
+ this.compareRenderer.setSymbolData(e, t), this.updateViewportAndRender(), this.eventBus.emit("compareChange", {
2898
+ id: e,
2899
+ change: "data"
2900
+ });
2744
2901
  }
2745
2902
  setCompareMode(e) {
2746
2903
  this.compareRenderer.setMode(e), this.updateViewportAndRender();
2747
2904
  }
2905
+ setCompareVisible(e, t) {
2906
+ this.compareRenderer.setSymbolVisible(e, t), this.updateViewportAndRender(), this.eventBus.emit("compareChange", {
2907
+ id: e,
2908
+ change: "visible"
2909
+ });
2910
+ }
2911
+ getCompareValues(e) {
2912
+ if (!this.comparesDrawn()) {
2913
+ let e = this.series.bars();
2914
+ return this.compareRenderer.valuesAt(e, null, e.length - 1);
2915
+ }
2916
+ let t = this.getDisplayData();
2917
+ return this.compareRenderer.valuesAt(t, this.viewport.getState(), e ?? t.length - 1);
2918
+ }
2919
+ comparesDrawn() {
2920
+ return this.isTimeAligned();
2921
+ }
2748
2922
  clearCompareSymbols() {
2923
+ let e = this.compareRenderer.getSymbols().map((e) => e.id);
2749
2924
  this.compareRenderer.clear(), this.updateViewportAndRender();
2925
+ for (let t of e) this.eventBus.emit("compareChange", {
2926
+ id: t,
2927
+ change: "remove"
2928
+ });
2750
2929
  }
2751
2930
  setLogScale(e) {
2752
2931
  e && !this.features.logScale || (this.viewport.setLogScale(e), this.updateViewportAndRender());
@@ -2789,18 +2968,18 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2789
2968
  goToTime(e) {
2790
2969
  let t = this.getDisplayData();
2791
2970
  if (t.length === 0 || !Number.isFinite(e)) return -1;
2792
- let n = Math.max(0, Math.min(t.length - 1, Math.floor(j(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
2971
+ let n = Math.max(0, Math.min(t.length - 1, Math.floor(M(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
2793
2972
  return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
2794
2973
  }
2795
2974
  setVisibleRangePreset(e) {
2796
2975
  let t = this.getDisplayData();
2797
2976
  if (t.length === 0) return;
2798
- let n = t.length - 1, r = l(t), i = Ot(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
2977
+ let n = t.length - 1, r = u(t), i = Ft(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
2799
2978
  if (a === null || a < t[0].time) {
2800
2979
  this.fitContent();
2801
2980
  return;
2802
2981
  }
2803
- let o = j(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
2982
+ let o = M(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
2804
2983
  this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
2805
2984
  }
2806
2985
  scrollToEnd() {
@@ -2825,7 +3004,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2825
3004
  setVisibleRange(e, t) {
2826
3005
  let n = this.getDisplayData();
2827
3006
  if (n.length === 0) return;
2828
- let r = j(Math.min(e, t), n), i = j(Math.max(e, t), n);
3007
+ let r = M(Math.min(e, t), n), i = M(Math.max(e, t), n);
2829
3008
  this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
2830
3009
  }
2831
3010
  suspend() {
@@ -2931,7 +3110,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2931
3110
  this.applyStyle(e, t.layer ?? "host", !0);
2932
3111
  }
2933
3112
  setOverrides(e, t = {}) {
2934
- let n = t.layer ?? "host", { overrides: r, rejected: i } = b(e);
3113
+ let n = t.layer ?? "host", { overrides: r, rejected: i } = x(e);
2935
3114
  i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
2936
3115
  let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
2937
3116
  this.themeManager.setOverrides(a, n) && this.styleChanged(n);
@@ -2950,7 +3129,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2950
3129
  return this.themeManager.getStyleValue(e);
2951
3130
  }
2952
3131
  applyStyle(e, t, n) {
2953
- let { overrides: r, rejected: i } = b(e);
3132
+ let { overrides: r, rejected: i } = x(e);
2954
3133
  i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
2955
3134
  }
2956
3135
  styleChanged(e) {
@@ -2965,7 +3144,10 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2965
3144
  }), this.engine.requestRender(r.Background);
2966
3145
  }
2967
3146
  setAutoScale(e) {
2968
- this.options.autoScale = e, this.defaultAutoScale = e, this.updateViewportAndRender();
3147
+ this.options.autoScale = e, this.defaultAutoScale = e, !e && this.series.length() > 0 && (this.seriesArriving = !1), this.updateViewportAndRender();
3148
+ }
3149
+ holdPriceScale() {
3150
+ this.options.autoScale = !1, this.priceFitPending = !1;
2969
3151
  }
2970
3152
  isAutoScale() {
2971
3153
  return this.options.autoScale !== !1;
@@ -2980,7 +3162,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2980
3162
  e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
2981
3163
  }
2982
3164
  setCrosshairTime(e) {
2983
- let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(j(e, t));
3165
+ let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(M(e, t));
2984
3166
  n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
2985
3167
  }
2986
3168
  getData() {
@@ -2995,6 +3177,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
2995
3177
  setVolumeVisible(e) {
2996
3178
  this.volumeRenderer.setVisible(e), this.updateViewportAndRender();
2997
3179
  }
3180
+ isVolumeVisible() {
3181
+ return this.features.volume && this.volumeRenderer.isVisible();
3182
+ }
2998
3183
  setVolumeProfileVisible(e) {
2999
3184
  this.volumeProfile.setVisible(e), this.engine.requestRender(r.Main);
3000
3185
  }
@@ -3013,6 +3198,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3013
3198
  setMarketProfileConfig(e) {
3014
3199
  e.buckets !== void 0 && this.marketProfile.setBuckets(e.buckets), e.widthRatio !== void 0 && this.marketProfile.setWidthRatio(e.widthRatio), e.opacity !== void 0 && this.marketProfile.setOpacity(e.opacity), e.valueAreaPct !== void 0 && this.marketProfile.setValueAreaPct(e.valueAreaPct), e.highlightPoC !== void 0 && this.marketProfile.setHighlightPoC(e.highlightPoC), e.showStats !== void 0 && this.marketProfile.setShowStats(e.showStats), e.splitBySession !== void 0 && this.marketProfile.setSplitBySession(e.splitBySession), e.letters !== void 0 && this.marketProfile.setLetters(e.letters), this.engine.requestRender(r.Main);
3015
3200
  }
3201
+ getMarketProfileConfig() {
3202
+ return this.marketProfile.getConfig();
3203
+ }
3016
3204
  getMarketProfileStats() {
3017
3205
  return this.marketProfile.getStats();
3018
3206
  }
@@ -3025,6 +3213,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3025
3213
  setDepthHeatmapConfig(e) {
3026
3214
  e.opacity !== void 0 && this.depthHeatmap.setOpacity(e.opacity), e.capacity !== void 0 && this.depthHeatmap.setCapacity(e.capacity), this.engine.requestRender(r.Main);
3027
3215
  }
3216
+ getDepthHeatmapConfig() {
3217
+ return this.depthHeatmap.getConfig();
3218
+ }
3028
3219
  pushDepthSnapshot(e, t) {
3029
3220
  let n = this.series.bars(), i = t ?? n[n.length - 1]?.time;
3030
3221
  i === void 0 || !Number.isFinite(i) || (this.depthHeatmap.push(i, e), this.depthHeatmap.isVisible() && this.engine.requestRender(r.Main));
@@ -3041,8 +3232,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3041
3232
  setPeriodLevelsPeriod(e) {
3042
3233
  this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
3043
3234
  }
3235
+ getPeriodLevelsPeriod() {
3236
+ return this.periodLevels.getPeriod();
3237
+ }
3044
3238
  setTimeZone(e) {
3045
- Un(e), this.timeZoneSetting = e, this.applyTimeZone();
3239
+ fr(e), this.timeZoneSetting = e, this.applyTimeZone();
3046
3240
  }
3047
3241
  getTimeZone() {
3048
3242
  return this.timeZoneSetting;
@@ -3051,7 +3245,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3051
3245
  return this.displayTz;
3052
3246
  }
3053
3247
  getExchangeTimeZone() {
3054
- return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && g(e)) ?? null;
3248
+ return [w(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && v(e)) ?? null;
3055
3249
  }
3056
3250
  setTimezone(e) {
3057
3251
  this.setTimeZone(e);
@@ -3068,29 +3262,62 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3068
3262
  setTimezoneOffset(e) {
3069
3263
  this.setTimeZone(e);
3070
3264
  }
3265
+ applyExchangeZone() {
3266
+ let e = this.getExchangeTimeZone();
3267
+ this.timeAxis.setExchangeTimeZone(e), this.crosshairHandler.setExchangeTimeZone(e), this.crosshairTooltip.setExchangeTimeZone(e), this.pinnedTooltip.setExchangeTimeZone(e), this.studyZoneHeld || this.applyStudyZone(e);
3268
+ }
3269
+ applyStudyZone(e) {
3270
+ this.studyZone = e, this.streamManager?.setTimeZone(e), this.periodLevels.setExchangeTimeZone(e), this.marketProfile.setExchangeTimeZone(e);
3271
+ let t = this.series.bars();
3272
+ this.indicatorEngine.setExchangeTimeZone(e, t.length > 0 ? t : void 0) && t.length > 0 && this.announceIndicatorUpdate(0);
3273
+ }
3274
+ holdStudyZone() {
3275
+ this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), ot);
3276
+ }
3277
+ endStudyZoneWait() {
3278
+ this.studyZoneReleaseQueued = !1, this.studyZoneTimer !== null && (clearTimeout(this.studyZoneTimer), this.studyZoneTimer = null);
3279
+ }
3280
+ releaseStudyZone() {
3281
+ this.endStudyZoneWait(), this.studyZoneHeld && (this.studyZoneHeld = !1, this.applyStudyZone(this.getExchangeTimeZone()), this.disposed || this.updateViewportAndRender());
3282
+ }
3283
+ releaseStudyZoneAfterCaller() {
3284
+ this.studyZoneHeld && (this.endStudyZoneWait(), this.studyZoneReleaseQueued = !0, queueMicrotask(() => {
3285
+ !this.studyZoneReleaseQueued || this.disposed || this.releaseStudyZone();
3286
+ }));
3287
+ }
3288
+ spokenBarTime(e) {
3289
+ let t = this.getDisplayData(), n = e * u(t), r = this.numberLocale || "en-US";
3290
+ return d(t) === !0 ? de(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : de(r, {
3291
+ dateStyle: "medium",
3292
+ timeStyle: "short"
3293
+ }, this.displayTz)(n);
3294
+ }
3071
3295
  applyTimeZone() {
3072
3296
  let e = this.timeZoneSetting === "exchange" ? this.getExchangeTimeZone() ?? "UTC" : this.timeZoneSetting;
3073
3297
  this.displayTz = e, this.timeAxis.setTimezoneOffset(e), this.crosshairHandler.setTimezoneOffset(e), this.crosshairTooltip.setTimezoneOffset(e), this.pinnedTooltip.setTimezone(e), this.sessionBreaks.setTimezone(e), this.engine.requestRender();
3074
3298
  }
3075
3299
  setSymbolInfo(e) {
3076
- let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
3077
- this.symbolInfo = e ? Wn({
3300
+ this.studyZoneHeld = !1, this.endStudyZoneWait(), this.useSymbolInfo(e);
3301
+ }
3302
+ useSymbolInfo(e) {
3303
+ let t = e && this.symbolInfo?.symbol === e.symbol ? w(this.symbolInfo) : void 0;
3304
+ this.symbolInfo = e ? pr({
3078
3305
  ...e,
3079
3306
  sessions: e.sessions?.map((e) => ({ ...e }))
3080
3307
  }, 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);
3081
3308
  let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
3082
- let t = S(e.start), n = S(e.end);
3309
+ let t = C(e.start), n = C(e.end);
3083
3310
  return t === null || n === null ? [] : [{
3084
3311
  startMinute: t,
3085
3312
  endMinute: n
3086
3313
  }];
3087
- }), i = C(this.symbolInfo);
3088
- this.sessionShading.replaceConfig(n.length > 0 && i && g(i) ? {
3314
+ }), i = w(this.symbolInfo);
3315
+ this.sessionShading.replaceConfig(n.length > 0 && i && v(i) ? {
3089
3316
  timeZone: i,
3090
3317
  windows: n,
3091
3318
  startMinute: n[0].startMinute,
3092
3319
  endMinute: n[n.length - 1].endMinute
3093
- } : this.hostSessionHours), this.timeZoneSetting === "exchange" && this.applyTimeZone(), this.reapplyExtendedHours(), this.updateViewportAndRender(), this.eventBus.emit("symbolInfoChange", { info: this.symbolInfo });
3320
+ } : this.hostSessionHours), this.timeZoneSetting === "exchange" && this.applyTimeZone(), this.applyExchangeZone(), this.reapplyExtendedHours(), this.updateViewportAndRender(), this.eventBus.emit("symbolInfoChange", { info: this.symbolInfo });
3094
3321
  }
3095
3322
  getSymbolInfo() {
3096
3323
  return this.symbolInfo;
@@ -3099,22 +3326,24 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3099
3326
  if (!e || typeof e != "object") return;
3100
3327
  let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
3101
3328
  if (!n(e.symbol)) return;
3102
- let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Wn({
3329
+ let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = pr({
3103
3330
  ...r,
3104
3331
  ...e,
3105
3332
  symbol: e.symbol || r?.symbol || t
3106
- }, C(r));
3333
+ }, w(r));
3107
3334
  r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
3108
3335
  }
3109
3336
  resolveStreamSymbol(e, t) {
3110
- this.symbolInfo && this.symbolInfo.symbol !== t && this.setSymbolInfo(null);
3111
- let n = e.resolveSymbol?.bind(e);
3112
- if (!n) return;
3113
- let r = ++this.symbolInfoSeq;
3114
- Promise.resolve().then(() => n(t)).then((e) => {
3115
- e && r === this.symbolInfoSeq && this.currentSymbol === t && this.setSymbolInfo(e);
3337
+ let n = N(e), r = n.resolveSymbol?.bind(n);
3338
+ if (this.symbolInfo && this.symbolInfo.symbol !== t ? (r ? this.holdStudyZone() : this.studyZoneHeld = !1, this.useSymbolInfo(null)) : r && this.studyZoneHeld && this.holdStudyZone(), !r) {
3339
+ this.releaseStudyZone();
3340
+ return;
3341
+ }
3342
+ let i = ++this.symbolInfoSeq;
3343
+ Promise.resolve().then(() => r(t)).then((e) => {
3344
+ i === this.symbolInfoSeq && (e && this.currentSymbol === t ? this.setSymbolInfo(e) : this.releaseStudyZone());
3116
3345
  }, (e) => {
3117
- r === this.symbolInfoSeq && console.warn(`No symbol info for "${t}":`, e);
3346
+ i === this.symbolInfoSeq && (this.releaseStudyZone(), console.warn(`No symbol info for "${t}":`, e));
3118
3347
  });
3119
3348
  }
3120
3349
  setPivotMarkersVisible(e) {
@@ -3126,6 +3355,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3126
3355
  setPivotMarkersConfig(e) {
3127
3356
  (e.left !== void 0 || e.right !== void 0) && this.pivotMarkers.setStrength(e.left ?? 5, e.right ?? e.left ?? 5), e.showLabels !== void 0 && this.pivotMarkers.setShowLabels(e.showLabels), e.structureLabels !== void 0 && this.pivotMarkers.setStructureLabels(e.structureLabels), this.engine.requestRender(r.Overlay);
3128
3357
  }
3358
+ getPivotMarkersConfig() {
3359
+ return this.pivotMarkers.getConfig();
3360
+ }
3129
3361
  setSessionShadingVisible(e) {
3130
3362
  this.sessionShading.setVisible(e), this.engine.requestRender(r.Background);
3131
3363
  }
@@ -3133,7 +3365,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3133
3365
  return this.sessionShading.isVisible();
3134
3366
  }
3135
3367
  setSessionShadingConfig(e) {
3136
- this.hostSessionHours = Et(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
3368
+ this.hostSessionHours = Mt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
3137
3369
  }
3138
3370
  setTooltipVisible(e) {
3139
3371
  e || this.crosshairTooltip.hide();
@@ -3141,6 +3373,9 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3141
3373
  setLegend(e) {
3142
3374
  this.chartLegend.setConfig(e), this.engine.requestRender(r.Hover);
3143
3375
  }
3376
+ isLegendVisible() {
3377
+ return this.features.legend && this.chartLegend.getConfig().visible;
3378
+ }
3144
3379
  setSymbolName(e) {
3145
3380
  this.chartLegend.setSymbol(e), this.engine.requestRender(r.Hover);
3146
3381
  }
@@ -3152,11 +3387,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3152
3387
  return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
3153
3388
  }
3154
3389
  async takeGpu(e, t, n) {
3155
- let { gpu: r, reason: i } = await Tt(e);
3156
- return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? Ct() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
3390
+ let { gpu: r, reason: i } = await jt(e);
3391
+ return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? Ot() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
3157
3392
  }
3158
3393
  waitForGpu(e) {
3159
- this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Bt(e) : null;
3394
+ this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Kt(e) : null;
3160
3395
  }
3161
3396
  getRenderer() {
3162
3397
  return this.engine.getGpu() ? "webgl" : "canvas";
@@ -3178,23 +3413,36 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3178
3413
  this.engine.getGpu() && this.engine.renderNow();
3179
3414
  }
3180
3415
  screenshot(e) {
3181
- this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
3416
+ this.features.screenshot && (this.freshFrame(), A.download(this.container, e, this.themeManager.getTheme().background));
3182
3417
  }
3183
3418
  async copyScreenshot() {
3184
3419
  if (!this.features.screenshot) return !1;
3420
+ let e = globalThis.ClipboardItem, t = typeof navigator > "u" ? void 0 : navigator.clipboard;
3421
+ if (!t?.write || !e) return !1;
3185
3422
  try {
3186
3423
  this.freshFrame();
3187
- let e = await k.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
3188
- return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
3424
+ let n = A.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
3425
+ if (!e) throw Error("No chart image to copy");
3426
+ return e;
3427
+ });
3428
+ n.catch(() => {});
3429
+ let r;
3430
+ try {
3431
+ r = new e({ "image/png": n });
3432
+ } catch (t) {
3433
+ if (!(t instanceof TypeError)) throw t;
3434
+ r = new e({ "image/png": await n });
3435
+ }
3436
+ return await t.write([r]), !0;
3189
3437
  } catch {
3190
3438
  return !1;
3191
3439
  }
3192
3440
  }
3193
3441
  screenshotDataURL() {
3194
- return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
3442
+ return this.features.screenshot ? (this.freshFrame(), A.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
3195
3443
  }
3196
3444
  async screenshotBlob() {
3197
- return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
3445
+ return this.features.screenshot ? (this.freshFrame(), A.toBlob(this.container, this.themeManager.getTheme().background)) : null;
3198
3446
  }
3199
3447
  addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
3200
3448
  if (!this.features.alerts) return null;
@@ -3328,23 +3576,23 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3328
3576
  };
3329
3577
  }
3330
3578
  let { steps: n, startTime: r, hideHistory: i, revealMarks: a, ...o } = e ?? {}, s = this.series.inHoursShown(this.series.liveBars()), c = t > 0 && r === void 0 && i !== !1, l = o.startIndex;
3331
- r !== void 0 && l === void 0 ? l = cr(s, r) : c && l !== void 0 && (l += t);
3579
+ r !== void 0 && l === void 0 ? l = jr(s, r) : c && l !== void 0 && (l += t);
3332
3580
  let u = c ? t : i && l !== void 0 && l > 0 ? Math.min(Math.floor(l), s.length - 1) : 0, d = u > 0 ? s.slice(u) : s;
3333
3581
  l !== void 0 && (o.startIndex = l - u), this.replayOffset = u, this.replayRevealMarks = a !== !1;
3334
- let f = n ? fr(n, d) : null;
3582
+ let f = n ? Fr(n, d) : null;
3335
3583
  this.replayStepsSeries = f, this.replayCoarse = d, this.options.autoScale = !0, this.replayRestarting = !0;
3336
3584
  try {
3337
3585
  this.replayManager.load(f ?? d);
3338
3586
  } finally {
3339
3587
  this.replayRestarting = !1;
3340
3588
  }
3341
- f && o.startIndex !== void 0 && (o.startIndex = mr(f, d, o.startIndex)), this.replayBarUnsub?.();
3589
+ f && o.startIndex !== void 0 && (o.startIndex = Lr(f, d, o.startIndex)), this.replayBarUnsub?.();
3342
3590
  let p = -1, m = -1, h = null, g = f ?? d;
3343
3591
  this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
3344
3592
  let t = e, n = d[e];
3345
3593
  if (f) {
3346
3594
  let r = f[e];
3347
- t = pr(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? gr(h, r) : hr(d[t], f, e), n = h;
3595
+ t = Ir(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? zr(h, r) : Rr(d[t], f, e), n = h;
3348
3596
  }
3349
3597
  m = e;
3350
3598
  let r = t + 1, i = p > 0 && r >= p && this.series.length() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
@@ -3355,7 +3603,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3355
3603
  } else this.series.showReplayed([...d.slice(0, t), n]), this.recalcIndicators(this.series.bars());
3356
3604
  p = r, this.currentPriceLine.setPrice(n.close, t > 0 ? d[t - 1].close : void 0), this.crosshairHandler.setData(this.series.bars());
3357
3605
  let o = g[e + 1]?.time ?? g[e].time + (e > 0 ? g[e].time - g[e - 1].time : 1);
3358
- this.replayRevealMarks && this.revealReplayMarks(o), this.displayDataCache = null, this.updateViewportAndRender(a), this.feedReplaySteps(g, e), this.eventBus.emit("replayStep", {
3606
+ this.replayRevealMarks && this.revealReplayMarks(o), this.displayDataCache = null, this.reshapeMemo.clear(), this.updateViewportAndRender(a), this.feedReplaySteps(g, e), this.eventBus.emit("replayStep", {
3359
3607
  barIndex: t,
3360
3608
  time: d[t].time,
3361
3609
  until: o,
@@ -3396,20 +3644,20 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3396
3644
  return;
3397
3645
  }
3398
3646
  if (i.time <= n.fedTime) return;
3399
- let a = e.slice(lr(e, n.fedTime), t + 1);
3647
+ let a = e.slice(Mr(e, n.fedTime), t + 1);
3400
3648
  n.fedTime = i.time;
3401
- let o = Math.ceil(a.length / sr);
3402
- for (let e = 0; e < a.length; e += o) for (let [t, n] of ur(a.slice(e, e + o))) r.setMarkPrice(t, n);
3649
+ let o = Math.ceil(a.length / Ar);
3650
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of Nr(a.slice(e, e + o))) r.setMarkPrice(t, n);
3403
3651
  this.tradingManager.setCurrentPrice(i.close);
3404
3652
  }
3405
3653
  getReplayBarIndex() {
3406
3654
  if (!this.replaySession) return -1;
3407
3655
  let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
3408
- return t && this.replayCoarse ? pr(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
3656
+ return t && this.replayCoarse ? Ir(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
3409
3657
  }
3410
3658
  replaySeekToBar(e) {
3411
3659
  let t = this.replayStepsSeries;
3412
- this.replaySeek(t && this.replayCoarse ? mr(t, this.replayCoarse, e) : e);
3660
+ this.replaySeek(t && this.replayCoarse ? Lr(t, this.replayCoarse, e) : e);
3413
3661
  }
3414
3662
  replayPause() {
3415
3663
  this.replayManager.pause();
@@ -3441,10 +3689,10 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3441
3689
  data: this.getDisplayData()
3442
3690
  }, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
3443
3691
  for (let e of t.anchors) {
3444
- let t = Nt(e.time, n), r = Dt(e.price, n);
3692
+ let t = Bt(e.time, n), r = Pt(e.price, n);
3445
3693
  i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
3446
3694
  }
3447
- return Xn.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Zn.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 ? {
3695
+ return yr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), br.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
3448
3696
  x: i,
3449
3697
  y: o,
3450
3698
  width: a - i,
@@ -3475,7 +3723,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3475
3723
  return this.replayManager.getProgress();
3476
3724
  }
3477
3725
  captureSnapshot() {
3478
- return w.capture({
3726
+ return T.capture({
3479
3727
  getDrawings: () => this.getDrawings(),
3480
3728
  getTheme: () => this.themeManager.getBaseTheme(),
3481
3729
  getAlerts: () => this.getAlerts(),
@@ -3488,14 +3736,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3488
3736
  });
3489
3737
  }
3490
3738
  restoreIndicators(e, t) {
3491
- let n = $n(e), r = /* @__PURE__ */ new Map();
3739
+ let n = Sr(e), r = /* @__PURE__ */ new Map();
3492
3740
  this.unrestoredIndicators = [];
3493
3741
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
3494
3742
  if (t) {
3495
3743
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
3496
3744
  for (let n of t) {
3497
3745
  let t = e.get(n.instanceId);
3498
- t && er(n, t) && o.add(n.instanceId);
3746
+ t && Cr(n, t) && o.add(n.instanceId);
3499
3747
  }
3500
3748
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
3501
3749
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -3503,8 +3751,8 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3503
3751
  let s = (e) => {
3504
3752
  let t = { ...e };
3505
3753
  for (let [e, n] of Object.entries(t)) {
3506
- let i = y(n), a = i && r.get(i.instanceId);
3507
- a && (t[e] = h(a, i.key));
3754
+ let i = b(n), a = i && r.get(i.instanceId);
3755
+ a && (t[e] = _(a, i.key));
3508
3756
  }
3509
3757
  return t;
3510
3758
  };
@@ -3557,7 +3805,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3557
3805
  let s = t.levels ?? null;
3558
3806
  JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
3559
3807
  let c = t.intervals ?? null;
3560
- JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? re(t.paneStyle) : null);
3808
+ JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? ae(t.paneStyle) : null);
3561
3809
  }
3562
3810
  restorePanes(e) {
3563
3811
  for (let [t, n] of e) t.paneSize !== void 0 && this.layoutManager.setPanelSize(n, t.paneSize), (t.paneSize !== void 0 || t.paneCollapsed) && this.layoutManager.setPanelCollapsed(n, !!t.paneCollapsed), t.paneSize !== void 0 && this.layoutManager.setPanelScale(n, {
@@ -3662,7 +3910,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3662
3910
  if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
3663
3911
  let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
3664
3912
  if (JSON.stringify(n) === JSON.stringify(i)) return r;
3665
- let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < qn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3913
+ let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < gr && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3666
3914
  type: "indicators",
3667
3915
  before: null,
3668
3916
  after: null
@@ -3690,13 +3938,13 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3690
3938
  }
3691
3939
  saveState(e) {
3692
3940
  if (!this.features.saveLoad) return null;
3693
- let t = this.captureSnapshot(), n = w.serialize(t);
3694
- return e && w.saveToStorage(e, t), n;
3941
+ let t = this.captureSnapshot(), n = T.serialize(t);
3942
+ return e && T.saveToStorage(e, t), n;
3695
3943
  }
3696
3944
  loadState(e) {
3697
3945
  if (!this.features.saveLoad) return;
3698
- let t = w.deserialize(e);
3699
- this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), (t.theme === "dark" || t.theme === "light") && this.setTheme(t.theme), t.version >= 3 && this.themeManager.setUserOverrides(t.overrides ?? {}) && this.styleChanged("user");
3946
+ let t = T.deserialize(e);
3947
+ this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, this.reshapeMemo.clear(), t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), (t.theme === "dark" || t.theme === "light") && this.setTheme(t.theme), t.version >= 3 && this.themeManager.setUserOverrides(t.overrides ?? {}) && this.styleChanged("user");
3700
3948
  let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
3701
3949
  if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
3702
3950
  this.alertManager.clearAlerts();
@@ -3706,7 +3954,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3706
3954
  let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
3707
3955
  return r ? r + e.slice(t) : e;
3708
3956
  }, r = t(e.channel), i = {
3709
- ...kt(e),
3957
+ ...It(e),
3710
3958
  ...e.target ? { target: t(e.target) } : {}
3711
3959
  };
3712
3960
  if (!e.expired) {
@@ -3726,28 +3974,28 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3726
3974
  }
3727
3975
  loadStateFromStorage(e) {
3728
3976
  if (!this.features.saveLoad) return !1;
3729
- let t = w.loadFromStorage(e);
3730
- return t ? (this.loadState(w.serialize(t)), !0) : !1;
3977
+ let t = T.loadFromStorage(e);
3978
+ return t ? (this.loadState(T.serialize(t)), !0) : !1;
3731
3979
  }
3732
3980
  downloadState(e) {
3733
- this.features.saveLoad && w.downloadFile(this.captureSnapshot(), e);
3981
+ this.features.saveLoad && T.downloadFile(this.captureSnapshot(), e);
3734
3982
  }
3735
3983
  async loadStateFromFile() {
3736
3984
  if (!this.features.saveLoad) return;
3737
- let e = await w.loadFromFile();
3738
- this.loadState(w.serialize(e));
3985
+ let e = await T.loadFromFile();
3986
+ this.loadState(T.serialize(e));
3739
3987
  }
3740
3988
  setLocale(e) {
3741
- ae(e), this.engine.requestRender();
3989
+ se(e), this.engine.requestRender();
3742
3990
  }
3743
3991
  setNumberLocale(e) {
3744
- this.numberLocale = e, this.viewport.setNumberLocale(e), this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.timeAxis.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
3992
+ this.numberLocale = e, this.viewport.setNumberLocale(e), this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.timeAxis.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.pinnedTooltip.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
3745
3993
  }
3746
3994
  getNumberLocale() {
3747
3995
  return this.numberLocale;
3748
3996
  }
3749
3997
  setMarket(e) {
3750
- if (this.marketConfig = e, this.timeZoneSetting === "exchange" && this.applyTimeZone(), e.colorScheme) {
3998
+ if (this.marketConfig = e, this.studyZoneHeld = !1, this.endStudyZoneWait(), this.timeZoneSetting === "exchange" && this.applyTimeZone(), this.applyExchangeZone(), e.colorScheme) {
3751
3999
  let t = {
3752
4000
  ...this.themeManager.getBaseTheme(),
3753
4001
  candleUp: e.colorScheme.up,
@@ -3757,17 +4005,17 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3757
4005
  };
3758
4006
  this.themeManager.setTheme(t);
3759
4007
  }
3760
- e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
4008
+ e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender(), this.eventBus.emit("marketChange", { market: e });
3761
4009
  }
3762
4010
  applyPricePrecision(e) {
3763
- this.marketPricePrecision = e, this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e), this.tradeZoneManager.setPricePrecision(e), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
4011
+ this.marketPricePrecision = e, this.viewport.setPricePrecision(e), this.pinnedTooltip.setPricePrecision(e), this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e), this.tradeZoneManager.setPricePrecision(e), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3764
4012
  }
3765
4013
  getMarket() {
3766
4014
  return this.marketConfig;
3767
4015
  }
3768
4016
  getPriceLimits() {
3769
4017
  let e = this.marketConfig;
3770
- return !e?.priceLimits?.enabled || !e.priceLimits.referencePrice ? null : d(e.priceLimits.referencePrice, e);
4018
+ return !e?.priceLimits?.enabled || !e.priceLimits.referencePrice ? null : p(e.priceLimits.referencePrice, e);
3771
4019
  }
3772
4020
  setPriceLimits(e) {
3773
4021
  this.marketConfig?.priceLimits && (this.marketConfig = {
@@ -3797,18 +4045,24 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3797
4045
  this.disposed = !0, this.stopWatchingVisibility?.(), this.stopWatchingVisibility = null, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.labelWidths.destroy(), this.container.innerHTML = "";
3798
4046
  }
3799
4047
  createChartRenderer(e) {
3800
- let t = nn(e, (e) => this.pluginManager.getChartType(e));
3801
- return t instanceof Fe && t.setPriceText((e) => this.formatPrice(e)), t;
4048
+ let t = Cn(e, (e) => this.pluginManager.getChartType(e));
4049
+ return t instanceof D && t.setPriceText((e) => this.formatPrice(e)), t;
3802
4050
  }
3803
4051
  crosshairSeries() {
3804
4052
  return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
3805
4053
  }
3806
4054
  getDisplayData() {
3807
- if (this.displayDataCache) return this.displayDataCache;
3808
- let e = this.series.bars();
4055
+ let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? bn(e, (e) => this.stepAt(e)) : void 0;
4056
+ if (this.displayDataCache && t === this.displayDataStep) return this.displayDataCache;
3809
4057
  if (e.length === 0) return e;
3810
- let t = rn(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3811
- return this.chartRenderer instanceof D && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(en(e, this.chartTypeOptions)), this.displayDataCache = t, t;
4058
+ let n = this.displaySeries(e, t);
4059
+ return this.displayDataCache = n, this.displayDataStep = t, n;
4060
+ }
4061
+ displaySeries(e, t) {
4062
+ let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
4063
+ if (n !== "pointAndFigure" || r(n)) return wn(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
4064
+ let { columns: i, boxSize: a } = un(e, this.chartTypeOptions, this.reshapeMemo);
4065
+ return this.chartRenderer instanceof Ze && this.chartRenderer.setBoxSize(a), i;
3812
4066
  }
3813
4067
  recalcIndicatorsFrom(e, t) {
3814
4068
  this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
@@ -3850,23 +4104,23 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3850
4104
  this.panelInfoCache = null, this.fitDataAndAxes(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
3851
4105
  }
3852
4106
  applyDataToViewport(e = !1) {
3853
- let t = this.getDisplayData(), n = this.options.autoScale !== !1;
4107
+ let t = this.getDisplayData(), n = this.options.autoScale !== !1 || this.priceFitPending;
3854
4108
  this.viewport.updateData(t, !1), e && (this.viewport.scrollToEnd(), this.viewport.updateData(t, !1));
3855
4109
  let r = this.viewport.getState();
3856
4110
  if (t.length > 0) {
3857
4111
  let e = Math.max(0, Math.min(r.visibleRange.from, t.length - 1));
3858
4112
  this.viewport.setScaleBaseline(t[e]?.close);
3859
4113
  }
3860
- return n && this.fitPriceScale(t, r), t;
4114
+ return n && this.fitPriceScale(t, this.viewport.getState()), t;
3861
4115
  }
3862
4116
  fitPriceScale(e, t) {
3863
4117
  if (e.length === 0) return;
3864
- let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = or(or(f(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && ar(e, n, r) ? this.volumeRenderer.getHeightRatio() + Kn : E;
4118
+ let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = kr(kr(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() && Or(e, n, r) ? this.volumeRenderer.getHeightRatio() + hr : O;
3865
4119
  this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
3866
4120
  top: a,
3867
- bottom: E
4121
+ bottom: O
3868
4122
  } : {
3869
- top: E,
4123
+ top: O,
3870
4124
  bottom: a
3871
4125
  }), this.viewport.fitToPrices(i.min, i.max);
3872
4126
  }
@@ -3876,14 +4130,19 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3876
4130
  this.viewport.setChartRect(t.mainChartRect), this.fitDataAndAxes(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
3877
4131
  }
3878
4132
  fitDataAndAxes(e = !1) {
3879
- this.applyDataToViewport(e);
3880
- let t = this.fitPriceAxisWidth();
3881
- this.leftViewport = this.computeLeftViewport(), (this.fitLeftAxisWidth() || t) && this.applyDataToViewport(e);
4133
+ let t = this.applyDataToViewport(e), n = this.fitPriceAxisWidth();
4134
+ this.leftViewport = this.computeLeftViewport(), (this.fitLeftAxisWidth() || n) && this.applyDataToViewport(e), this.priceFitPending && this.priceFitDone(t) && (this.priceFitPending = !1);
4135
+ }
4136
+ priceFitDone(e) {
4137
+ let { chartRect: t, offset: n, barWidth: r, barSpacing: i } = this.viewport.getState();
4138
+ if (e.length === 0 || t.width <= 0) return !1;
4139
+ let a = n <= 0 && e.length * (r + i) - n <= t.width;
4140
+ return !(this.seriesArriving && a);
3882
4141
  }
3883
4142
  fitLeftAxisWidth() {
3884
4143
  let e = this.leftViewport;
3885
4144
  if (!e) return !1;
3886
- let t = this.themeManager.getTheme(), n = En({
4145
+ let t = this.themeManager.getTheme(), n = Jn({
3887
4146
  min: e.priceRange.min,
3888
4147
  max: e.priceRange.max,
3889
4148
  lastPrice: null,
@@ -3892,12 +4151,12 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3892
4151
  fontFamily: t.font.family,
3893
4152
  fontSizeSmall: t.font.sizeSmall,
3894
4153
  measure: (e, t) => this.measureText(e, t)
3895
- }), r = Dn(this.leftAxisWidth, n);
4154
+ }), r = Yn(this.leftAxisWidth, n);
3896
4155
  return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
3897
4156
  }
3898
4157
  fitPriceAxisWidth() {
3899
4158
  if (!this.features.priceAxis) return !1;
3900
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = En({
4159
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = Jn({
3901
4160
  min: e.min,
3902
4161
  max: e.max,
3903
4162
  lastPrice: this.currentPriceLine.getPrice(),
@@ -3908,14 +4167,14 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3908
4167
  fontFamily: t.font.family,
3909
4168
  fontSizeSmall: t.font.sizeSmall,
3910
4169
  measure: (e, t) => this.measureText(e, t)
3911
- }), r = Dn(this.priceAxisWidth, n);
4170
+ }), r = Yn(this.priceAxisWidth, n);
3912
4171
  return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
3913
4172
  }
3914
4173
  measureText(e, t) {
3915
4174
  let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
3916
- if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => tr(n, e, t));
4175
+ if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => wr(n, e, t));
3917
4176
  let i = n ?? this.detachedMeasureContext();
3918
- return i ? tr(i, e, t) : e.length * 7;
4177
+ return i ? wr(i, e, t) : e.length * 7;
3919
4178
  }
3920
4179
  detachedMeasureContext() {
3921
4180
  return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
@@ -3956,7 +4215,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3956
4215
  buildPanelRenderInfos() {
3957
4216
  if (this.panelInfoCache) return this.panelInfoCache;
3958
4217
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
3959
- let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...Bn }, o = {
4218
+ 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) ?? { ...lr }, o = {
3960
4219
  x: e.rect.x,
3961
4220
  y: e.rect.y + 20,
3962
4221
  width: e.rect.width,
@@ -3975,6 +4234,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
3975
4234
  scaleMode: e.config.percentScale ? "percentage" : "regular",
3976
4235
  scaleBaseline: e.config.percentScale ? this.paneBaseline(e.config.id, n, r) : void 0,
3977
4236
  formatPrice: void 0,
4237
+ pricePrecision: void 0,
3978
4238
  priceUnit: void 0,
3979
4239
  invertScale: !!e.config.invertScale
3980
4240
  }
@@ -4014,7 +4274,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
4014
4274
  barCountdown: this.barCountdown,
4015
4275
  sessionBreaks: this.sessionBreaks,
4016
4276
  sessionShading: this.sessionShading,
4017
- compareRenderer: this.compareRenderer,
4277
+ compareRenderer: this.comparesDrawn() ? this.compareRenderer : null,
4018
4278
  alertManager: this.features.alerts ? this.alertManager : null,
4019
4279
  measureOverlay: this.measureOverlay,
4020
4280
  selectionBoxOverlay: this.selectionBoxOverlay,
@@ -4030,6 +4290,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
4030
4290
  },
4031
4291
  theme: this.themeManager.getTheme(),
4032
4292
  data: n,
4293
+ seriesRevision: this.series.revision(),
4033
4294
  numberLocale: this.numberLocale,
4034
4295
  paneTitles: this.paneTitles,
4035
4296
  indicatorValueLabels: this.features.indicatorValueLabels,
@@ -4038,7 +4299,7 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
4038
4299
  });
4039
4300
  }
4040
4301
  drawOverlayPlugins(e, t) {
4041
- let n = W(this.pluginManager.getOverlays(), t);
4302
+ let n = er(this.pluginManager.getOverlays(), t);
4042
4303
  if (n.length === 0) return;
4043
4304
  let r = {
4044
4305
  viewport: this.viewport.getState(),
@@ -4059,11 +4320,11 @@ var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontal
4059
4320
  };
4060
4321
  }
4061
4322
  };
4062
- function $n(e) {
4323
+ function Sr(e) {
4063
4324
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
4064
4325
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
4065
4326
  i.add(e.instanceId);
4066
- let o = [e.pane, ...Object.values(e.params).map((e) => y(e)?.instanceId)];
4327
+ let o = [e.pane, ...Object.values(e.params).map((e) => b(e)?.instanceId)];
4067
4328
  for (let e of o) {
4068
4329
  let n = e ? t.get(e) : void 0;
4069
4330
  n && a(n);
@@ -4073,19 +4334,19 @@ function $n(e) {
4073
4334
  for (let t of e) a(t);
4074
4335
  return n;
4075
4336
  }
4076
- function er(e, t) {
4337
+ function Cr(e, t) {
4077
4338
  return e.id === t.id && (e.pane ?? null) === (t.pane ?? null) && (e.scale ?? null) === (t.scale ?? null) && e.position === void 0 == (t.position === void 0);
4078
4339
  }
4079
- function tr(e, t, n) {
4340
+ function wr(e, t, n) {
4080
4341
  let r = e.font;
4081
4342
  e.font = n;
4082
4343
  let i = e.measureText(t).width;
4083
4344
  return e.font = r, i;
4084
4345
  }
4085
- var nr = 300;
4086
- function rr(e) {
4346
+ var Tr = 300;
4347
+ function Er(e) {
4087
4348
  let t = {}, n = e.family;
4088
- typeof n == "string" && n.trim() !== "" && n.length <= nr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4349
+ typeof n == "string" && n.trim() !== "" && n.length <= Tr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4089
4350
  for (let n of [
4090
4351
  "sizeSmall",
4091
4352
  "sizeMedium",
@@ -4096,21 +4357,21 @@ function rr(e) {
4096
4357
  }
4097
4358
  return t;
4098
4359
  }
4099
- function ir(e) {
4360
+ function Dr(e) {
4100
4361
  let t = e.tagRadius;
4101
4362
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
4102
4363
  }
4103
- function ar(e, t, n) {
4364
+ function Or(e, t, n) {
4104
4365
  for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
4105
4366
  return !1;
4106
4367
  }
4107
- function or(e, t) {
4368
+ function kr(e, t) {
4108
4369
  return e ? t ? {
4109
4370
  min: Math.min(e.min, t.min),
4110
4371
  max: Math.max(e.max, t.max)
4111
4372
  } : e : t;
4112
4373
  }
4113
- function q(e) {
4374
+ function K(e) {
4114
4375
  return {
4115
4376
  id: e.id,
4116
4377
  price: e.price,
@@ -4125,8 +4386,8 @@ function q(e) {
4125
4386
  bars: e.bars
4126
4387
  };
4127
4388
  }
4128
- var sr = 500;
4129
- function cr(e, t) {
4389
+ var Ar = 500;
4390
+ function jr(e, t) {
4130
4391
  let n = 0, r = e.length;
4131
4392
  for (; n < r;) {
4132
4393
  let i = n + r >> 1;
@@ -4134,7 +4395,7 @@ function cr(e, t) {
4134
4395
  }
4135
4396
  return n;
4136
4397
  }
4137
- function lr(e, t) {
4398
+ function Mr(e, t) {
4138
4399
  let n = 0, r = e.length;
4139
4400
  for (; n < r;) {
4140
4401
  let i = n + r >> 1;
@@ -4142,20 +4403,20 @@ function lr(e, t) {
4142
4403
  }
4143
4404
  return n;
4144
4405
  }
4145
- function ur(e) {
4406
+ function Nr(e) {
4146
4407
  let t = 0, n = 0;
4147
4408
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
4148
4409
  let r = [e[t].low, e[t].time], i = [e[n].high, e[n].time], a = t === n ? e[t].close >= e[t].open : t < n, o = e[e.length - 1];
4149
4410
  return [...a ? [r, i] : [i, r], [o.close, o.time]];
4150
4411
  }
4151
- function dr(e) {
4412
+ function Pr(e) {
4152
4413
  let t = 0;
4153
4414
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
4154
4415
  return t > 0 ? t : Infinity;
4155
4416
  }
4156
- function fr(e, t) {
4417
+ function Fr(e, t) {
4157
4418
  if (t.length === 0) return null;
4158
- let n = t[t.length - 1].time + dr(t), r = e.filter((e) => ln(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
4419
+ let n = t[t.length - 1].time + Pr(t), r = e.filter((e) => jn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
4159
4420
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
4160
4421
  if (i.length === 0) return null;
4161
4422
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -4163,7 +4424,7 @@ function fr(e, t) {
4163
4424
  let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
4164
4425
  return [...o, ...s];
4165
4426
  }
4166
- function pr(e, t) {
4427
+ function Ir(e, t) {
4167
4428
  let n = 0, r = e.length - 1;
4168
4429
  for (; n < r;) {
4169
4430
  let i = n + r + 1 >> 1;
@@ -4171,22 +4432,22 @@ function pr(e, t) {
4171
4432
  }
4172
4433
  return n;
4173
4434
  }
4174
- function mr(e, t, n) {
4435
+ function Lr(e, t, n) {
4175
4436
  let r = Math.max(0, Math.min(Math.floor(Number.isFinite(n) ? n : 0), t.length - 1)), i = r + 1 < t.length ? t[r + 1].time : Infinity, a = -1;
4176
4437
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
4177
4438
  return Math.max(0, a);
4178
4439
  }
4179
- function hr(e, t, n) {
4440
+ function Rr(e, t, n) {
4180
4441
  let r = n;
4181
4442
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
4182
4443
  let i = {
4183
4444
  ...t[r],
4184
4445
  time: e.time
4185
4446
  };
4186
- for (let e = r + 1; e <= n; e++) i = gr(i, t[e]);
4447
+ for (let e = r + 1; e <= n; e++) i = zr(i, t[e]);
4187
4448
  return i;
4188
4449
  }
4189
- function gr(e, t) {
4450
+ function zr(e, t) {
4190
4451
  return {
4191
4452
  time: e.time,
4192
4453
  open: e.open,
@@ -4198,26 +4459,26 @@ function gr(e, t) {
4198
4459
  }
4199
4460
  //#endregion
4200
4461
  //#region src/io/parseOHLCV.ts
4201
- var _r = [
4462
+ var Br = [
4202
4463
  "time",
4203
4464
  "timestamp",
4204
4465
  "date",
4205
4466
  "datetime",
4206
4467
  "t"
4207
- ], vr = ["open", "o"], yr = ["high", "h"], br = ["low", "l"], xr = ["close", "c"], Sr = [
4468
+ ], Vr = ["open", "o"], Hr = ["high", "h"], Ur = ["low", "l"], Wr = ["close", "c"], Gr = [
4208
4469
  "volume",
4209
4470
  "vol",
4210
4471
  "v"
4211
4472
  ];
4212
- function Cr(e) {
4473
+ function q(e) {
4213
4474
  let t = e.trim();
4214
- return t ? t[0] === "[" || t[0] === "{" ? wr(t) : Tr(t) : {
4475
+ return t ? t[0] === "[" || t[0] === "{" ? Kr(t) : qr(t) : {
4215
4476
  data: [],
4216
4477
  rowCount: 0,
4217
4478
  skipped: 0
4218
4479
  };
4219
4480
  }
4220
- function wr(e) {
4481
+ function Kr(e) {
4221
4482
  let t;
4222
4483
  try {
4223
4484
  t = JSON.parse(e);
@@ -4227,19 +4488,19 @@ function wr(e) {
4227
4488
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
4228
4489
  let n = [], r = 0;
4229
4490
  for (let e of t) {
4230
- let t = Array.isArray(e) ? Ar(e) : kr(e);
4491
+ let t = Array.isArray(e) ? Qr(e) : Zr(e);
4231
4492
  t ? n.push(t) : r++;
4232
4493
  }
4233
- return jr(n, t.length, r);
4494
+ return $r(n, t.length, r);
4234
4495
  }
4235
- function Tr(e) {
4496
+ function qr(e) {
4236
4497
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
4237
4498
  if (t.length === 0) return {
4238
4499
  data: [],
4239
4500
  rowCount: 0,
4240
4501
  skipped: 0
4241
4502
  };
4242
- let n = Er(t[0]), r = Dr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Or(r) : {
4503
+ let n = Jr(t[0]), r = Yr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Xr(r) : {
4243
4504
  time: 0,
4244
4505
  open: 1,
4245
4506
  high: 2,
@@ -4250,7 +4511,7 @@ function Tr(e) {
4250
4511
  if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
4251
4512
  let o = [], s = 0;
4252
4513
  for (let e = +!!i; e < t.length; e++) {
4253
- let r = Dr(t[e], n), i = Y(r[a.time]), c = J(r[a.open]), l = J(r[a.high]), u = J(r[a.low]), d = J(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
4514
+ let r = Yr(t[e], n), i = Y(r[a.time]), c = J(r[a.open]), l = J(r[a.high]), u = J(r[a.low]), d = J(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
4254
4515
  if (i === null || ![
4255
4516
  c,
4256
4517
  l,
@@ -4269,9 +4530,9 @@ function Tr(e) {
4269
4530
  volume: Number.isFinite(f) ? f : 0
4270
4531
  });
4271
4532
  }
4272
- return jr(o, t.length - +!!i, s);
4533
+ return $r(o, t.length - +!!i, s);
4273
4534
  }
4274
- function Er(e) {
4535
+ function Jr(e) {
4275
4536
  let t = {
4276
4537
  ",": 0,
4277
4538
  ";": 0,
@@ -4283,7 +4544,7 @@ function Er(e) {
4283
4544
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
4284
4545
  return n;
4285
4546
  }
4286
- function Dr(e, t) {
4547
+ function Yr(e, t) {
4287
4548
  let n = [], r = "", i = !1;
4288
4549
  for (let a = 0; a < e.length; a++) {
4289
4550
  let o = e[a];
@@ -4291,25 +4552,25 @@ function Dr(e, t) {
4291
4552
  }
4292
4553
  return n.push(r), n;
4293
4554
  }
4294
- function Or(e) {
4555
+ function Xr(e) {
4295
4556
  let t = (t) => e.findIndex((e) => t.includes(e));
4296
4557
  return {
4297
- time: t(_r),
4298
- open: t(vr),
4299
- high: t(yr),
4300
- low: t(br),
4301
- close: t(xr),
4302
- volume: t(Sr)
4558
+ time: t(Br),
4559
+ open: t(Vr),
4560
+ high: t(Hr),
4561
+ low: t(Ur),
4562
+ close: t(Wr),
4563
+ volume: t(Gr)
4303
4564
  };
4304
4565
  }
4305
- function kr(e) {
4566
+ function Zr(e) {
4306
4567
  let t = (t) => {
4307
4568
  for (let n of t) {
4308
4569
  if (e[n] !== void 0) return e[n];
4309
4570
  let t = n.toUpperCase();
4310
4571
  if (e[t] !== void 0) return e[t];
4311
4572
  }
4312
- }, n = Y(String(t(_r) ?? "")), r = Number(t(vr)), i = Number(t(yr)), a = Number(t(br)), o = Number(t(xr)), s = Number(t(Sr) ?? 0);
4573
+ }, n = Y(String(t(Br) ?? "")), r = Number(t(Vr)), i = Number(t(Hr)), a = Number(t(Ur)), o = Number(t(Wr)), s = Number(t(Gr) ?? 0);
4313
4574
  return n === null || ![
4314
4575
  r,
4315
4576
  i,
@@ -4324,7 +4585,7 @@ function kr(e) {
4324
4585
  volume: Number.isFinite(s) ? s : 0
4325
4586
  };
4326
4587
  }
4327
- function Ar(e) {
4588
+ function Qr(e) {
4328
4589
  if (e.length < 5) return null;
4329
4590
  let t = Y(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
4330
4591
  return t === null || ![
@@ -4348,11 +4609,11 @@ function Y(e) {
4348
4609
  let t = e.trim();
4349
4610
  if (!t) return null;
4350
4611
  let n = Number(t);
4351
- if (Number.isFinite(n) && n > 0) return v(n);
4612
+ if (Number.isFinite(n) && n > 0) return y(n);
4352
4613
  let r = Date.parse(t);
4353
4614
  return Number.isFinite(r) ? r : null;
4354
4615
  }
4355
- function jr(e, t, n) {
4616
+ function $r(e, t, n) {
4356
4617
  e.sort((e, t) => e.time - t.time);
4357
4618
  let r = [];
4358
4619
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -4364,7 +4625,7 @@ function jr(e, t, n) {
4364
4625
  }
4365
4626
  //#endregion
4366
4627
  //#region src/io/DragDropImporter.ts
4367
- var Mr = class {
4628
+ var ei = class {
4368
4629
  host;
4369
4630
  overlay = null;
4370
4631
  callbacks;
@@ -4397,7 +4658,7 @@ var Mr = class {
4397
4658
  e.preventDefault(), this.depth = 0, this.hideOverlay();
4398
4659
  let t = e.dataTransfer?.files?.[0];
4399
4660
  if (t) try {
4400
- let e = Cr(await t.text());
4661
+ let e = q(await t.text());
4401
4662
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
4402
4663
  this.callbacks.onData(e.data, e, t);
4403
4664
  } catch (e) {
@@ -4441,7 +4702,7 @@ function Z(e) {
4441
4702
  };
4442
4703
  return e.symbol !== void 0 && (t.symbol = e.symbol), e.timeframe !== void 0 && (t.timeframe = e.timeframe), e.kind !== void 0 && (t.kind = e.kind), t;
4443
4704
  }
4444
- var Nr = (e, t) => t.updatedAt - e.updatedAt;
4705
+ var ti = (e, t) => t.updatedAt - e.updatedAt;
4445
4706
  function Q(e) {
4446
4707
  if (typeof e != "object" || !e) return null;
4447
4708
  let t = e;
@@ -4454,17 +4715,17 @@ function Q(e) {
4454
4715
  kind: typeof t.kind == "string" ? t.kind : void 0
4455
4716
  });
4456
4717
  }
4457
- function Pr(e) {
4718
+ function ni(e) {
4458
4719
  let t = Q(e), n = t ? e.content : void 0;
4459
4720
  return t && typeof n == "string" ? {
4460
4721
  ...t,
4461
4722
  content: n
4462
4723
  } : null;
4463
4724
  }
4464
- function Fr(e = []) {
4725
+ function ri(e = []) {
4465
4726
  let t = new Map(e.map((e) => [e.id, { ...e }]));
4466
4727
  return {
4467
- list: () => [...t.values()].map(Z).sort(Nr),
4728
+ list: () => [...t.values()].map(Z).sort(ti),
4468
4729
  load: (e) => {
4469
4730
  let n = t.get(e);
4470
4731
  return n ? { ...n } : null;
@@ -4477,7 +4738,7 @@ function Fr(e = []) {
4477
4738
  }
4478
4739
  };
4479
4740
  }
4480
- function Ir(e = "tcw:layouts:") {
4741
+ function ii(e = "tcw:layouts:") {
4481
4742
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
4482
4743
  let e;
4483
4744
  try {
@@ -4488,7 +4749,7 @@ function Ir(e = "tcw:layouts:") {
4488
4749
  return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
4489
4750
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
4490
4751
  return {
4491
- list: () => r().sort(Nr),
4752
+ list: () => r().sort(ti),
4492
4753
  load: (e) => {
4493
4754
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
4494
4755
  return t && i !== null ? {
@@ -4506,14 +4767,14 @@ function Ir(e = "tcw:layouts:") {
4506
4767
  }
4507
4768
  //#endregion
4508
4769
  //#region src/state/LayoutSession.ts
4509
- var Lr = 80;
4770
+ var ai = 80;
4510
4771
  function $(e) {
4511
4772
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
4512
4773
  }
4513
- function Rr() {
4774
+ function oi() {
4514
4775
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
4515
4776
  }
4516
- function zr(e) {
4777
+ function si(e) {
4517
4778
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
4518
4779
  return {
4519
4780
  id: t,
@@ -4524,7 +4785,7 @@ function zr(e) {
4524
4785
  ...o === void 0 ? {} : { kind: o }
4525
4786
  };
4526
4787
  }
4527
- var Br = class {
4788
+ var ci = class {
4528
4789
  currentLayout = null;
4529
4790
  savedContent = null;
4530
4791
  dirty = !1;
@@ -4540,7 +4801,7 @@ var Br = class {
4540
4801
  now;
4541
4802
  newId;
4542
4803
  constructor(e, t, n = {}) {
4543
- this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? Rr;
4804
+ 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 ?? oi;
4544
4805
  }
4545
4806
  current() {
4546
4807
  return this.currentLayout;
@@ -4570,7 +4831,7 @@ var Br = class {
4570
4831
  }
4571
4832
  open(e) {
4572
4833
  return this.queue(async () => {
4573
- let t = Pr(await this.storage.load(e));
4834
+ let t = ni(await this.storage.load(e));
4574
4835
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
4575
4836
  this.cancelTimer(), this.applying++;
4576
4837
  try {
@@ -4580,13 +4841,13 @@ var Br = class {
4580
4841
  } finally {
4581
4842
  this.applying--;
4582
4843
  }
4583
- return this.cancelTimer(), this.currentLayout = zr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
4844
+ return this.cancelTimer(), this.currentLayout = si(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
4584
4845
  });
4585
4846
  }
4586
4847
  rename(e, t) {
4587
4848
  let n = $(t);
4588
4849
  return n ? this.queue(async () => {
4589
- let t = Pr(await this.storage.load(e));
4850
+ let t = ni(await this.storage.load(e));
4590
4851
  !t || t.id !== e || (await this.storage.save({
4591
4852
  ...t,
4592
4853
  name: n
@@ -4664,7 +4925,7 @@ var Br = class {
4664
4925
  content: n.content
4665
4926
  };
4666
4927
  await this.storage.save(r);
4667
- let i = zr(r);
4928
+ let i = si(r);
4668
4929
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
4669
4930
  }
4670
4931
  forget() {
@@ -4685,6 +4946,6 @@ var Br = class {
4685
4946
  }
4686
4947
  };
4687
4948
  //#endregion
4688
- export { V as C, dn as S, L as T, W as _, Fr as a, gn as b, Qn as c, In as d, Fn as f, jn as g, Nn as h, Ir as i, Hn as l, Mn as m, Lr as n, Mr as o, Pn as p, $ as r, Cr as s, Br as t, Vn as u, G as v, z as w, pn as x, xn as y };
4949
+ export { B as C, on as E, Nn as S, z as T, er as _, ri as a, Rn as b, xr as c, ar as d, ir as f, $n as g, nr as h, ii as i, dr as l, tr as m, ai as n, ei as o, rr as p, $ as r, q as s, ci as t, ur as u, W as v, L as w, Fn as x, Un as y };
4689
4950
 
4690
- //# sourceMappingURL=LayoutSession-Qkx1huV-.js.map
4951
+ //# sourceMappingURL=LayoutSession-4SLt8-0u.js.map