@tradecanvas/chart 1.12.0 → 1.13.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 (61) hide show
  1. package/README.md +45 -1
  2. package/dist/Chart.d.ts +66 -7
  3. package/dist/Chart.d.ts.map +1 -1
  4. package/dist/LayoutSession-BOUFA2gH.cjs +2 -0
  5. package/dist/LayoutSession-BOUFA2gH.cjs.map +1 -0
  6. package/dist/{LayoutSession-2yRujs2S.js → LayoutSession-CiDh-H9-.js} +473 -322
  7. package/dist/LayoutSession-CiDh-H9-.js.map +1 -0
  8. package/dist/ThemeManager.d.ts +36 -2
  9. package/dist/ThemeManager.d.ts.map +1 -1
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +25 -25
  14. package/dist/index.js.map +1 -1
  15. package/dist/style/styleOptions.d.ts +8 -0
  16. package/dist/style/styleOptions.d.ts.map +1 -0
  17. package/dist/widget/ChartWidget.d.ts +58 -1
  18. package/dist/widget/ChartWidget.d.ts.map +1 -1
  19. package/dist/widget/ChartWidgetGrid.d.ts +16 -1
  20. package/dist/widget/ChartWidgetGrid.d.ts.map +1 -1
  21. package/dist/widget/WidgetAccountPanel.d.ts.map +1 -1
  22. package/dist/widget/WidgetAlertsPanel.d.ts.map +1 -1
  23. package/dist/widget/WidgetChartNav.d.ts.map +1 -1
  24. package/dist/widget/WidgetContextMenu.d.ts.map +1 -1
  25. package/dist/widget/WidgetDataWindow.d.ts.map +1 -1
  26. package/dist/widget/WidgetDepthLadder.d.ts.map +1 -1
  27. package/dist/widget/WidgetDrawingSettings.d.ts.map +1 -1
  28. package/dist/widget/WidgetDrawingSidebar.d.ts +9 -1
  29. package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
  30. package/dist/widget/WidgetGoToDate.d.ts.map +1 -1
  31. package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -1
  32. package/dist/widget/WidgetObjectTree.d.ts.map +1 -1
  33. package/dist/widget/WidgetReplayBar.d.ts.map +1 -1
  34. package/dist/widget/WidgetStatusBar.d.ts +10 -1
  35. package/dist/widget/WidgetStatusBar.d.ts.map +1 -1
  36. package/dist/widget/WidgetStyles.d.ts.map +1 -1
  37. package/dist/widget/WidgetSymbolInfo.d.ts.map +1 -1
  38. package/dist/widget/WidgetToolbar.d.ts +6 -0
  39. package/dist/widget/WidgetToolbar.d.ts.map +1 -1
  40. package/dist/widget/hostButtons.d.ts +5 -0
  41. package/dist/widget/hostButtons.d.ts.map +1 -0
  42. package/dist/widget/hostMenus.d.ts +7 -0
  43. package/dist/widget/hostMenus.d.ts.map +1 -0
  44. package/dist/widget/index.cjs +45 -12
  45. package/dist/widget/index.cjs.map +1 -1
  46. package/dist/widget/index.d.ts +3 -1
  47. package/dist/widget/index.d.ts.map +1 -1
  48. package/dist/widget/index.js +1584 -1137
  49. package/dist/widget/index.js.map +1 -1
  50. package/dist/widget/legendValues.d.ts +4 -2
  51. package/dist/widget/legendValues.d.ts.map +1 -1
  52. package/dist/widget/types.d.ts +90 -0
  53. package/dist/widget/types.d.ts.map +1 -1
  54. package/dist/widget/widgetConfig.d.ts +12 -0
  55. package/dist/widget/widgetConfig.d.ts.map +1 -1
  56. package/dist/widget/widgetFeatures.d.ts +74 -0
  57. package/dist/widget/widgetFeatures.d.ts.map +1 -0
  58. package/package.json +3 -3
  59. package/dist/LayoutSession-1uhJw0L7.cjs +0 -2
  60. package/dist/LayoutSession-1uhJw0L7.cjs.map +0 -1
  61. package/dist/LayoutSession-2yRujs2S.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, computePriceLimits as c, formatPrice as l, fractionTick as u, indicatorSource as d, isValidTimeZone as f, mergeBar as p, normalizeBarTime as m, parseIndicatorSource as h, priceFormatterFor as g, readChartTypeOptions as _, sessionMinute as v, setLocale as ee, stepDecimals as te, tickBarCount as ne, timeframeToMs as y, volumeColor as b, zonedDateFormatter as re } from "@tradecanvas/commons";
2
- import { AlertDragHandler as ie, AlertManager as ae, Animator as oe, AreaRenderer as se, AxisDragHandler as ce, BarCountdown as le, BarRenderer as ue, BaselineRenderer as de, CandlestickRenderer as fe, ChartLegend as pe, ChartStateManager as x, CompareRenderer as me, CompareSymbolIndicator as he, CorrelationCoefficientIndicator as ge, CorrelationLogIndicator as _e, CrosshairHandler as ve, CrosshairTooltip as ye, CurrentPriceLine as be, DEFAULT_SESSION_HOURS as xe, DataExporter as S, DepthHeatmapRenderer as Se, DrawingManager as Ce, DrawingRenderer as we, EquivolumeRenderer as Te, EventBus as Ee, GridRenderer as De, HLCAreaRenderer as Oe, HiLoRenderer as C, HollowCandleRenderer as ke, IndicatorEngine as w, InteractionManager as Ae, KagiRenderer as je, KeyboardHandler as Me, LineRenderer as Ne, LineWithMarkersRenderer as Pe, MarketProfileRenderer as Fe, MeasureOverlay as Ie, PanHandler as Le, PaneResizeHandler as Re, PeriodLevelsRenderer as ze, PinnedTooltip as Be, PivotMarkersRenderer as Ve, PointAndFigureRenderer as T, PriceAxis as E, PriceAxisAddButton as He, PriceLines as Ue, RenderEngine as We, RenkoRenderer as Ge, ReplayManager as Ke, Screenshot as D, SelectionBoxOverlay as qe, SessionBreaks as Je, SessionShading as Ye, SignalMarkerManager as Xe, SpreadIndicator as Ze, StepLineRenderer as Qe, StreamManager as $e, SymbolSeriesStore as et, TimeAxis as tt, TradeZoneManager as nt, TradingManager as rt, TradingRenderer as it, UndoRedoManager as at, Viewport as ot, VolumeCandleRenderer as st, VolumeProfileRenderer as ct, VolumeRenderer as lt, Watermark as ut, ZoomHandler as dt, barTimeStepMs as ft, findDominantSwing as pt, gpuContextsLeft as mt, isRegularSession as ht, loadWebGL as gt, mergeSessionHours as _t, rangePresetStart as vt, readAlertOptions as yt, registerBuiltInDrawingTools as bt, registerBuiltInIndicators as O, servesTimeframe as k, sourceParam as A, timestampToBarIndex as j, toHeikinAshi as xt, toKagi as St, toLineBreak as Ct, toPointAndFigure as wt, toRangeBars as Tt, toRenko as M, whenGpuContextFree as Et, withResampling as Dt, xToBarIndex as Ot, xToTime as N, yToPrice as P } 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, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, chartStyleValue as c, computePriceLimits as l, formatPrice as u, fractionTick as d, indicatorSource as f, isValidTimeZone as p, mergeBar as m, normalizeBarTime as h, parseIndicatorSource as g, priceFormatterFor as _, readChartStyleOverrides as v, readChartTypeOptions as y, readIndicatorPlotStyles as b, readPaneStyle as ee, resolveChartTheme as te, sessionMinute as x, setLocale as ne, stepDecimals as re, tickBarCount as ie, timeframeToMs as ae, volumeColor as oe, zonedDateFormatter as se } from "@tradecanvas/commons";
2
+ import { AlertDragHandler as ce, AlertManager as le, Animator as ue, AreaRenderer as de, AxisDragHandler as fe, BarCountdown as pe, BarRenderer as me, BaselineRenderer as he, CandlestickRenderer as ge, ChartLegend as _e, ChartStateManager as S, CompareRenderer as ve, CompareSymbolIndicator as ye, CorrelationCoefficientIndicator as be, CorrelationLogIndicator as xe, CrosshairHandler as Se, CrosshairTooltip as Ce, CurrentPriceLine as we, DEFAULT_SESSION_HOURS as Te, DataExporter as C, DepthHeatmapRenderer as Ee, DrawingManager as De, DrawingRenderer as Oe, EquivolumeRenderer as ke, EventBus as Ae, GridRenderer as je, HLCAreaRenderer as Me, HiLoRenderer as w, HollowCandleRenderer as Ne, IndicatorEngine as T, InteractionManager as Pe, KagiRenderer as Fe, KeyboardHandler as Ie, LineRenderer as Le, LineWithMarkersRenderer as Re, MarketProfileRenderer as ze, MeasureOverlay as Be, PanHandler as Ve, PaneResizeHandler as He, PeriodLevelsRenderer as Ue, PinnedTooltip as We, PivotMarkersRenderer as Ge, PointAndFigureRenderer as E, PriceAxis as D, PriceAxisAddButton as Ke, PriceLines as qe, RenderEngine as Je, RenkoRenderer as Ye, ReplayManager as Xe, Screenshot as O, SelectionBoxOverlay as Ze, SessionBreaks as Qe, SessionShading as $e, SignalMarkerManager as et, SpreadIndicator as tt, StepLineRenderer as nt, StreamManager as rt, SymbolSeriesStore as it, TimeAxis as at, TradeZoneManager as ot, TradingManager as st, TradingRenderer as ct, UndoRedoManager as lt, Viewport as ut, VolumeCandleRenderer as dt, VolumeProfileRenderer as ft, VolumeRenderer as pt, Watermark as mt, ZoomHandler as ht, barTimeStepMs as gt, findDominantSwing as _t, gpuContextsLeft as vt, isRegularSession as yt, loadWebGL as bt, mergeSessionHours as xt, rangePresetStart as St, readAlertOptions as Ct, registerBuiltInDrawingTools as wt, registerBuiltInIndicators as k, servesTimeframe as A, sourceParam as j, timestampToBarIndex as M, toHeikinAshi as Tt, toKagi as Et, toLineBreak as Dt, toPointAndFigure as Ot, toRangeBars as kt, toRenko as N, whenGpuContextFree as At, withResampling as jt, xToBarIndex as Mt, xToTime as P, yToPrice as F } from "@tradecanvas/core";
3
3
  //#region src/regularHours.ts
4
- var kt = 864e5, At = 10;
5
- function jt(e, t) {
4
+ var Nt = 864e5, Pt = 10;
5
+ function Ft(e, t) {
6
6
  let n = e?.timezone;
7
- if (!n || !f(n) || t.length < 2) return null;
7
+ if (!n || !p(n) || t.length < 2) return null;
8
8
  let r = (e?.sessions ?? []).flatMap((e) => {
9
- let t = v(e.start), n = v(e.end);
9
+ let t = x(e.start), n = x(e.end);
10
10
  return t === null || n === null ? [] : [{
11
11
  startMinute: t,
12
12
  endMinute: n
@@ -14,34 +14,34 @@ function jt(e, t) {
14
14
  });
15
15
  if (r.length === 0) return null;
16
16
  let i = Infinity;
17
- for (let e = Math.max(1, t.length - At); e < t.length; e++) {
18
- let n = m(t[e].time) - m(t[e - 1].time);
17
+ for (let e = Math.max(1, t.length - Pt); e < t.length; e++) {
18
+ let n = h(t[e].time) - h(t[e - 1].time);
19
19
  n > 0 && n < i && (i = n);
20
20
  }
21
- if (!(i < kt)) return null;
21
+ if (!(i < Nt)) return null;
22
22
  let a = {
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) => ht(m(e), a);
28
+ return (e) => yt(h(e), a);
29
29
  }
30
30
  //#endregion
31
31
  //#region src/chartA11y.ts
32
- var F = {
32
+ var I = {
33
33
  role: "chart",
34
34
  summary: "{what}. Last price {close}.",
35
35
  empty: "Chart, no data.",
36
36
  view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
37
37
  bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
38
38
  keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
39
- }, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Mt = [
39
+ }, L = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), It = [
40
40
  "role",
41
41
  "aria-roledescription",
42
42
  "aria-label",
43
43
  "aria-describedby"
44
- ], Nt = 400, Pt = 1e3, Ft = class {
44
+ ], Lt = 400, Rt = 1e3, zt = class {
45
45
  live;
46
46
  help;
47
47
  labels;
@@ -55,20 +55,20 @@ var F = {
55
55
  };
56
56
  constructor(e, t, n = {}) {
57
57
  this.container = e, this.source = t, this.labels = {
58
- ...F,
58
+ ...I,
59
59
  ...n
60
60
  };
61
- for (let t of Mt) this.before.set(t, e.getAttribute(t));
62
- e.setAttribute("role", "application"), this.help = L("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 = L("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 It) this.before.set(t, e.getAttribute(t));
62
+ e.setAttribute("role", "application"), this.help = Bt("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 = Bt("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
- ...F,
66
+ ...I,
67
67
  ...e
68
68
  }, this.applyLabels();
69
69
  }
70
70
  refresh(e = !1) {
71
- let t = Pt - (Date.now() - this.summaryAt);
71
+ let t = Rt - (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 F = {
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
- }, Nt);
83
+ }, Lt);
84
84
  }
85
85
  readBar(e) {
86
86
  let t = this.source.bars();
@@ -93,13 +93,13 @@ var F = {
93
93
  let i = t[this.cursor];
94
94
  this.source.showBar(i.time);
95
95
  let a = this.source.formatPrice;
96
- this.say(I(this.labels.bar, {
96
+ this.say(L(this.labels.bar, {
97
97
  time: this.source.formatTime(i.time),
98
98
  open: a(i.open),
99
99
  high: a(i.high),
100
100
  low: a(i.low),
101
101
  close: a(i.close),
102
- volume: It(i.volume ?? 0)
102
+ volume: Vt(i.volume ?? 0)
103
103
  }));
104
104
  }
105
105
  destroy() {
@@ -118,7 +118,7 @@ var F = {
118
118
  this.labels.typeName ? this.labels.typeName(t) : t,
119
119
  this.source.timeframe()
120
120
  ].filter(Boolean).join(", ");
121
- return I(this.labels.summary, {
121
+ return L(this.labels.summary, {
122
122
  what: n,
123
123
  close: this.source.formatPrice(e[e.length - 1].close)
124
124
  });
@@ -128,7 +128,7 @@ var F = {
128
128
  if (e.length === 0) return this.labels.empty;
129
129
  let t = this.source.visibleRange(), n = Math.max(0, Math.min(e.length - 1, Math.ceil(t.from))), r = Math.max(n, Math.min(e.length - 1, Math.floor(t.to))), i = -Infinity, a = Infinity;
130
130
  for (let t = n; t <= r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
131
- return I(this.labels.view, {
131
+ return L(this.labels.view, {
132
132
  count: r - n + 1,
133
133
  from: this.source.formatTime(e[n].time),
134
134
  to: this.source.formatTime(e[r].time),
@@ -140,7 +140,7 @@ var F = {
140
140
  this.live.textContent = e;
141
141
  }
142
142
  };
143
- function L(e, t) {
143
+ function Bt(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 L(e, t) {
154
154
  border: "0"
155
155
  }), n;
156
156
  }
157
- function It(e) {
157
+ function Vt(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 Lt(e, t, n, r) {
162
+ function Ht(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 Lt(e, t, n, r) {
169
169
  }
170
170
  //#endregion
171
171
  //#region src/charts/ChartTypeStrategy.ts
172
- function Rt(e) {
172
+ function Ut(e) {
173
173
  switch (e) {
174
174
  case "candlestick":
175
175
  case "heikinAshi":
176
176
  case "lineBreak":
177
- case "rangeBars": return new fe();
178
- case "line": return new Ne();
179
- case "area": return new se();
180
- case "bar": return new ue();
181
- case "hollowCandle": return new ke();
182
- case "baseline": return new de();
183
- case "renko": return new Ge();
184
- case "kagi": return new je();
185
- case "pointAndFigure": return new T();
186
- case "volumeCandles": return new st();
187
- case "equivolume": return new Te();
188
- case "hlcArea": return new Oe();
189
- case "stepLine": return new Qe();
190
- case "lineWithMarkers": return new Pe();
191
- case "hiLo": return new C();
192
- default: return new fe();
177
+ case "rangeBars": return new ge();
178
+ case "line": return new Le();
179
+ case "area": return new de();
180
+ case "bar": return new me();
181
+ case "hollowCandle": return new Ne();
182
+ case "baseline": return new he();
183
+ case "renko": return new Ye();
184
+ case "kagi": return new Fe();
185
+ case "pointAndFigure": return new E();
186
+ case "volumeCandles": return new dt();
187
+ case "equivolume": return new ke();
188
+ case "hlcArea": return new Me();
189
+ case "stepLine": return new nt();
190
+ case "lineWithMarkers": return new Re();
191
+ case "hiLo": return new w();
192
+ default: return new ge();
193
193
  }
194
194
  }
195
- function zt(e, t, n = {}) {
195
+ function Wt(e, t, n = {}) {
196
196
  if (t.length === 0) return t;
197
197
  switch (e) {
198
- case "heikinAshi": return xt(t);
198
+ case "heikinAshi": return Tt(t);
199
199
  case "renko": {
200
200
  let e = n.renko?.boxSize;
201
- return typeof e == "number" ? M(t, { brickSize: e }) : M(t, {
201
+ return typeof e == "number" ? N(t, { brickSize: e }) : N(t, {
202
202
  brickSize: 0,
203
203
  useATR: !0,
204
204
  atrPeriod: n.renko?.atrPeriod ?? 14
205
205
  });
206
206
  }
207
- case "lineBreak": return Ct(t, n.lineBreak?.lines ?? 3);
208
- case "kagi": return St(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
209
- case "pointAndFigure": return wt(t, Ht(t, n), n.pointAndFigure?.reversal ?? 3);
207
+ case "lineBreak": return Dt(t, n.lineBreak?.lines ?? 3);
208
+ case "kagi": return Et(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
209
+ case "pointAndFigure": return Ot(t, qt(t, n), n.pointAndFigure?.reversal ?? 3);
210
210
  case "rangeBars": {
211
211
  let e = n.rangeBars?.range;
212
- return Tt(t, { rangeSize: typeof e == "number" ? e : Ut(t) * .005 });
212
+ return kt(t, { rangeSize: typeof e == "number" ? e : Jt(t) * .005 });
213
213
  }
214
214
  default: return t;
215
215
  }
216
216
  }
217
- function Bt(e) {
217
+ function Gt(e) {
218
218
  switch (e) {
219
219
  case "heikinAshi":
220
220
  case "renko":
@@ -225,30 +225,30 @@ function Bt(e) {
225
225
  default: return !1;
226
226
  }
227
227
  }
228
- function Vt(e) {
229
- return e !== "heikinAshi" && Bt(e);
228
+ function Kt(e) {
229
+ return e !== "heikinAshi" && Gt(e);
230
230
  }
231
- function Ht(e, t = {}) {
231
+ function qt(e, t = {}) {
232
232
  let n = t.pointAndFigure?.boxSize;
233
- return typeof n == "number" ? n : Ut(e) * .01;
233
+ return typeof n == "number" ? n : Jt(e) * .01;
234
234
  }
235
- function Ut(e) {
235
+ function Jt(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 Wt(e, t) {
240
+ function Yt(e, t) {
241
241
  let n = t?.(e);
242
- return n ? n.createRenderer() : Rt(e);
242
+ return n ? n.createRenderer() : Ut(e);
243
243
  }
244
- function Gt(e, t, n, r) {
244
+ function Xt(e, t, n, r) {
245
245
  if (t.length === 0) return t;
246
246
  let i = n?.(e);
247
- return i?.transform ? i.transform(t) : zt(e, t, r);
247
+ return i?.transform ? i.transform(t) : Wt(e, t, r);
248
248
  }
249
249
  //#endregion
250
250
  //#region src/state/AutoSaveScheduler.ts
251
- var Kt = class {
251
+ var Zt = class {
252
252
  timer = null;
253
253
  delayMs = 0;
254
254
  key = null;
@@ -283,7 +283,7 @@ function R(e) {
283
283
  let { open: t, high: n, low: r, close: i } = e;
284
284
  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
285
  }
286
- function qt(e) {
286
+ function Qt(e) {
287
287
  return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
288
288
  }
289
289
  function z(e) {
@@ -303,7 +303,7 @@ var B = class {
303
303
  let t = [];
304
304
  for (let n = 0; n < e.length; n++) {
305
305
  let r = e[n];
306
- R(r) && t.push(qt(r) ? r : z(r));
306
+ R(r) && t.push(Qt(r) ? r : z(r));
307
307
  }
308
308
  this.data = t;
309
309
  }
@@ -311,7 +311,7 @@ var B = class {
311
311
  let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
312
312
  for (let r = 0; r < e.length; r++) {
313
313
  let i = e[r];
314
- !R(i) || i.time >= t || n.push(qt(i) ? i : z(i));
314
+ !R(i) || i.time >= t || n.push(Qt(i) ? i : z(i));
315
315
  }
316
316
  if (n.length === 0) return 0;
317
317
  n.sort((e, t) => e.time - t.time);
@@ -332,7 +332,7 @@ var B = class {
332
332
  this.data[this.data.length - 1] = t;
333
333
  }
334
334
  updateLastBarFromTick(e) {
335
- 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] = p(this.data[this.data.length - 1], e)));
335
+ 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] = m(this.data[this.data.length - 1], e)));
336
336
  }
337
337
  getLength() {
338
338
  return this.data.length;
@@ -340,7 +340,7 @@ var B = class {
340
340
  clear() {
341
341
  this.data = [];
342
342
  }
343
- }, Jt = 5e3, Yt = 6e4, Xt = 500, Zt = class {
343
+ }, $t = 5e3, en = 6e4, tn = 500, nn = class {
344
344
  loader = null;
345
345
  pageSize = 500;
346
346
  loading = !1;
@@ -381,7 +381,7 @@ var B = class {
381
381
  try {
382
382
  r = await e(t, this.pageSize);
383
383
  } catch (e) {
384
- return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Yt, Jt * 2 ** (this.failures - 1)), this.emit({
384
+ return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(en, $t * 2 ** (this.failures - 1)), this.emit({
385
385
  state: "error",
386
386
  count: 0,
387
387
  error: e instanceof Error ? e.message : String(e)
@@ -411,34 +411,116 @@ var B = class {
411
411
  now() {
412
412
  return this.host.now ? this.host.now() : Date.now();
413
413
  }
414
- }, Qt = class {
415
- theme;
414
+ }, rn = class t {
415
+ base;
416
416
  shape = null;
417
- constructor(t) {
418
- !t || t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
417
+ chartType = "candlestick";
418
+ host = {};
419
+ user = /* @__PURE__ */ new Map();
420
+ effective = null;
421
+ constructor(e) {
422
+ this.base = t.read(e);
423
+ }
424
+ static read(t) {
425
+ if (!t || t === "dark") return { ...e };
426
+ if (t === "light") return { ...n };
427
+ let { style: r, ...i } = t;
428
+ return i;
419
429
  }
420
430
  getTheme() {
421
- return this.theme;
431
+ return this.effective ??= te(this.base, this.chartType, this.merged()), this.effective;
422
432
  }
423
- setTheme(t) {
424
- t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t }, this.shape && (this.theme = {
425
- ...this.theme,
433
+ getBaseTheme() {
434
+ return this.base;
435
+ }
436
+ setTheme(e) {
437
+ this.base = t.read(e), this.shape && (this.base = {
438
+ ...this.base,
426
439
  shape: {
427
- ...this.theme.shape,
440
+ ...this.base.shape,
428
441
  ...this.shape
429
442
  }
430
- });
443
+ }), this.effective = null;
431
444
  }
432
445
  setShape(e) {
433
- this.shape = e ? { ...e } : null, this.theme = {
434
- ...this.theme,
446
+ this.shape = e ? { ...e } : null, this.base = {
447
+ ...this.base,
435
448
  shape: e ? {
436
- ...this.theme.shape,
449
+ ...this.base.shape,
437
450
  ...e
438
- } : this.theme.shape
451
+ } : this.base.shape
452
+ }, this.effective = null;
453
+ }
454
+ setChartType(e) {
455
+ e !== this.chartType && (this.chartType = e, this.effective = null);
456
+ }
457
+ applyOverrides(e, t) {
458
+ let n = { ...this.layer(t) };
459
+ for (let [t, r] of Object.entries(e)) r == null ? delete n[t] : n[t] = r;
460
+ return this.setLayer(t, n);
461
+ }
462
+ setOverrides(e, t) {
463
+ return this.setLayer(t, { ...e });
464
+ }
465
+ resetOverrides(e, t) {
466
+ if (!t) return this.setLayer(e, {});
467
+ let n = { ...this.layer(e) };
468
+ for (let e of t) delete n[e];
469
+ return this.setLayer(e, n);
470
+ }
471
+ getOverrides(e) {
472
+ return { ...this.layer(e) };
473
+ }
474
+ getUserOverrides() {
475
+ let e = {};
476
+ for (let [t, n] of this.user) Object.keys(n).length > 0 && (e[t] = { ...n });
477
+ return e;
478
+ }
479
+ setUserOverrides(e) {
480
+ 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);
481
+ }
482
+ getStyleValue(e) {
483
+ return c(this.base, this.merged(), e, this.chartType);
484
+ }
485
+ layer(e) {
486
+ return e === "host" ? this.host : this.user.get(this.base.name) ?? {};
487
+ }
488
+ setLayer(e, t) {
489
+ return JSON.stringify(t) === JSON.stringify(this.layer(e)) ? !1 : (e === "host" ? this.host = t : Object.keys(t).length > 0 ? this.user.set(this.base.name, t) : this.user.delete(this.base.name), this.effective = null, !0);
490
+ }
491
+ merged() {
492
+ return {
493
+ ...this.host,
494
+ ...this.user.get(this.base.name)
439
495
  };
440
496
  }
441
- }, $t = 200, en = 80, V = (e) => e.position === "top" || e.position === "bottom", tn = class {
497
+ };
498
+ //#endregion
499
+ //#region src/style/styleOptions.ts
500
+ function an(e, t) {
501
+ return t ? {
502
+ ...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
503
+ ...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
504
+ ...t.style === void 0 ? {} : { [`crosshair.${e}.style`]: t.style },
505
+ ...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
506
+ } : {};
507
+ }
508
+ function on(e) {
509
+ let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
510
+ return {
511
+ ...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
512
+ ...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
513
+ ...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
514
+ ...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
515
+ ...an("horizontal", n?.hLine),
516
+ ...an("vertical", n?.vLine),
517
+ ...r === void 0 ? {} : { "crosshair.labelBackground": r },
518
+ ...e.overrides
519
+ };
520
+ }
521
+ //#endregion
522
+ //#region src/layout/LayoutManager.ts
523
+ var sn = 200, cn = 80, V = (e) => e.position === "top" || e.position === "bottom", ln = class {
442
524
  panels = [];
443
525
  containerWidth = 0;
444
526
  containerHeight = 0;
@@ -454,8 +536,8 @@ var B = class {
454
536
  this.panels.push({
455
537
  id: e,
456
538
  position: n,
457
- size: r ?? (a ? $t : t),
458
- minSize: a ? en : i,
539
+ size: r ?? (a ? sn : t),
540
+ minSize: a ? cn : i,
459
541
  content: {
460
542
  type: "indicator",
461
543
  indicatorInstanceId: e
@@ -524,7 +606,7 @@ var B = class {
524
606
  let r = this.panels.find((t) => t.id === e);
525
607
  if (r) {
526
608
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
527
- r.position = n, a !== o && (r.size = o ? $t : t, r.minSize = o ? en : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
609
+ r.position = n, a !== o && (r.size = o ? sn : t, r.minSize = o ? cn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
528
610
  }
529
611
  }
530
612
  setPanelSize(e, t) {
@@ -640,24 +722,24 @@ var B = class {
640
722
  getMainChartRect() {
641
723
  return this.resolve().mainChartRect;
642
724
  }
643
- }, nn = 14, rn = 14, an = 22, on = 4;
644
- function sn(e) {
645
- let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: u } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
725
+ }, un = 14, dn = 14, fn = 22, pn = 4;
726
+ function mn(e) {
727
+ let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
646
728
  t,
647
729
  n,
648
730
  r
649
731
  ], m = a;
650
732
  for (let t of p) {
651
733
  if (!Number.isFinite(t)) continue;
652
- let n = e.format ? e.format(t) : l(t, d, i), r = e.format ? n : l(t, f, i);
653
- m = Math.max(m, u(n, `500 ${c}px ${o}`) + nn, u(r, `bold 11px ${o}`) + rn, u(r, `600 ${c}px ${o}`) + an);
734
+ let n = e.format ? e.format(t) : u(t, d, i), r = e.format ? n : u(t, f, i);
735
+ m = Math.max(m, l(n, `500 ${c}px ${o}`) + un, l(r, `bold 11px ${o}`) + dn, l(r, `600 ${c}px ${o}`) + fn);
654
736
  }
655
- return m <= a ? a : Math.ceil(m / on) * on;
737
+ return m <= a ? a : Math.ceil(m / pn) * pn;
656
738
  }
657
- function cn(e, t) {
739
+ function hn(e, t) {
658
740
  return t > e || t <= e - 12 ? t : e;
659
741
  }
660
- var ln = class {
742
+ var gn = class {
661
743
  netY = 0;
662
744
  travelX = 0;
663
745
  engaged = !1;
@@ -673,8 +755,8 @@ var ln = class {
673
755
  }
674
756
  return this.engaged;
675
757
  }
676
- }, un = 1;
677
- function dn(e, t) {
758
+ }, _n = 1;
759
+ function vn(e, t) {
678
760
  return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
679
761
  }
680
762
  function H(e) {
@@ -688,24 +770,24 @@ function H(e) {
688
770
  //#endregion
689
771
  //#region src/plugins/registry.ts
690
772
  var U = /* @__PURE__ */ new Map();
691
- function fn(e) {
773
+ function yn(e) {
692
774
  U.set(H(e), e);
693
775
  }
694
- function pn(e) {
776
+ function bn(e) {
695
777
  return U.delete(e);
696
778
  }
697
- function mn() {
779
+ function xn() {
698
780
  return [...U.values()];
699
781
  }
700
- function hn() {
782
+ function Sn() {
701
783
  U.clear();
702
784
  }
703
785
  //#endregion
704
786
  //#region src/plugins/PluginManager.ts
705
- var gn = class {
787
+ var Cn = class {
706
788
  plugins = /* @__PURE__ */ new Map();
707
789
  constructor(e, t = {}) {
708
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of mn()) this.add(e);
790
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of xn()) this.add(e);
709
791
  for (let e of t.plugins ?? []) this.add(e);
710
792
  }
711
793
  register(e) {
@@ -735,15 +817,15 @@ var gn = class {
735
817
  add(e) {
736
818
  this.plugins.set(H(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
737
819
  }
738
- }, _n = {
820
+ }, wn = {
739
821
  orderPlace: (e, t) => e.placeOrder(t),
740
822
  orderModify: (e, t) => e.modifyOrder(t),
741
823
  orderCancel: (e, t) => e.cancelOrder(t),
742
824
  positionModify: (e, t) => e.modifyPosition(t),
743
825
  positionClose: (e, t) => e.closePosition(t),
744
- positionReverse: (e, t, n) => vn(e, t, n)
826
+ positionReverse: (e, t, n) => Tn(e, t, n)
745
827
  };
746
- async function vn(e, t, n) {
828
+ async function Tn(e, t, n) {
747
829
  let { reversing: r } = n;
748
830
  if (!r.has(t.positionId)) {
749
831
  r.add(t.positionId);
@@ -772,7 +854,7 @@ async function vn(e, t, n) {
772
854
  }
773
855
  }
774
856
  }
775
- function yn(e, t) {
857
+ function En(e, t) {
776
858
  let n = [], r = null, i = {
777
859
  positions: () => r ?? t.getPositions?.() ?? [],
778
860
  reversing: /* @__PURE__ */ new Set()
@@ -782,8 +864,8 @@ function yn(e, t) {
782
864
  e.data && t.onFill?.(e.data);
783
865
  };
784
866
  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));
785
- for (let r of Object.keys(_n)) {
786
- let a = _n[r], o = t.onIntent(r, (n) => {
867
+ for (let r of Object.keys(wn)) {
868
+ let a = wn[r], o = t.onIntent(r, (n) => {
787
869
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
788
870
  message: `Execution command failed: ${r}`,
789
871
  cause: e
@@ -797,16 +879,16 @@ function yn(e, t) {
797
879
  }
798
880
  //#endregion
799
881
  //#region src/Chart.ts
800
- var bn = {
882
+ var Dn = {
801
883
  min: 0,
802
884
  max: 100
803
- }, xn = 0xe8d4a51000, Sn = "exchange";
804
- function Cn(e) {
805
- if (typeof e == "string" && e !== "exchange" && !f(e)) throw RangeError(`Unknown time zone: ${e}`);
885
+ }, On = 0xe8d4a51000, kn = "exchange";
886
+ function An(e) {
887
+ if (typeof e == "string" && e !== "exchange" && !p(e)) throw RangeError(`Unknown time zone: ${e}`);
806
888
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
807
889
  }
808
- var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
809
- static version = "1.12.0";
890
+ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
891
+ static version = "1.13.0";
810
892
  engine;
811
893
  viewport;
812
894
  dataManager;
@@ -827,6 +909,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
827
909
  indicatorUpdateFrom = null;
828
910
  resolvedLayoutCache = null;
829
911
  panelInfoCache = null;
912
+ paneStyles = /* @__PURE__ */ new Map();
913
+ lastBackground = null;
830
914
  renderScheduled = !1;
831
915
  priceAxisWidth = a;
832
916
  measureCtx;
@@ -842,14 +926,14 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
842
926
  indicatorHistoryDepth = 0;
843
927
  removedDrawingAlerts = /* @__PURE__ */ new Map();
844
928
  zoomAreaMode = !1;
845
- priceAxisAddButton = new He();
929
+ priceAxisAddButton = new Ke();
846
930
  displayTz = null;
847
931
  timezoneSetting = null;
848
932
  symbolInfo = null;
849
933
  symbolInfoSeq = 0;
850
934
  sessionBreaks;
851
935
  sessionShading;
852
- hostSessionHours = { ...xe };
936
+ hostSessionHours = { ...Te };
853
937
  compareRenderer;
854
938
  countdownInterval = null;
855
939
  volumeRenderer;
@@ -862,7 +946,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
862
946
  signalMarkerManager;
863
947
  tradeZoneManager;
864
948
  measureOverlay;
865
- selectionBoxOverlay = new qe();
949
+ selectionBoxOverlay = new Ze();
866
950
  replayManager;
867
951
  replayBarUnsub = null;
868
952
  replaySeeking = !1;
@@ -870,7 +954,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
870
954
  replayStepsSeries = null;
871
955
  replayCoarse = null;
872
956
  undoRedoManager;
873
- autoSaveScheduler = new Kt((e) => this.saveState(e));
957
+ autoSaveScheduler = new Zt((e) => this.saveState(e));
874
958
  animator;
875
959
  crosshairTooltip;
876
960
  pinnedTooltip;
@@ -882,15 +966,15 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
882
966
  disposed = !1;
883
967
  chartTypeOptions = {};
884
968
  mainSeriesVisible = !0;
885
- priceLines = new Ue();
886
- symbolSeries = new et();
969
+ priceLines = new qe();
970
+ symbolSeries = new it();
887
971
  extendedHours = !0;
888
972
  replayRestarting = !1;
889
973
  fullSeries = null;
890
974
  requestedSymbols = /* @__PURE__ */ new Set();
891
975
  gridRenderer;
892
976
  priceAxis;
893
- leftPriceAxis = new E();
977
+ leftPriceAxis = new D();
894
978
  leftScaleRequested = !1;
895
979
  leftAxisWidth = a;
896
980
  leftViewport = null;
@@ -920,7 +1004,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
920
1004
  snapshotKey = null;
921
1005
  historyCheckQueued = !1;
922
1006
  constructor(e, t) {
923
- t.timeZone != null && Cn(t.timeZone), this.container = e, this.options = {
1007
+ t.timeZone != null && An(t.timeZone), this.container = e, this.options = {
924
1008
  ...t,
925
1009
  chartType: t.chartType ?? "candlestick"
926
1010
  }, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
@@ -958,15 +1042,15 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
958
1042
  logScale: n.logScale ?? !0,
959
1043
  timeframes: n.timeframes ?? [],
960
1044
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
961
- }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new B(), this.history = new Zt({
1045
+ }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new B(), this.history = new nn({
962
1046
  oldestTime: () => this.dataManager.getData()[0]?.time ?? null,
963
1047
  prepend: (e) => this.prependBars(e),
964
1048
  emit: (e) => this.eventBus.emit("historyLoad", e)
965
- }), this.themeManager = new Qt(t.theme), this.layoutManager = new tn(), this.indicatorEngine = new w(), this.pluginManager = new gn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ee(), O(this.indicatorEngine), this.indicatorEngine.register(new he(this.symbolSeries)), this.indicatorEngine.register(new Ze(this.symbolSeries)), this.indicatorEngine.register(new ge(this.symbolSeries)), this.indicatorEngine.register(new _e(this.symbolSeries)), this.drawingManager = new Ce(), bt(this.drawingManager), this.drawingRenderer = new we(this.drawingManager), this.drawingManager.setRequestRender(() => {
1049
+ }), this.themeManager = new rn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(on(t), "host", !1), this.layoutManager = new ln(), this.indicatorEngine = new T(), this.pluginManager = new Cn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ae(), k(this.indicatorEngine), this.indicatorEngine.register(new ye(this.symbolSeries)), this.indicatorEngine.register(new tt(this.symbolSeries)), this.indicatorEngine.register(new be(this.symbolSeries)), this.indicatorEngine.register(new xe(this.symbolSeries)), this.drawingManager = new De(), wt(this.drawingManager), this.drawingRenderer = new Oe(this.drawingManager), this.drawingManager.setRequestRender(() => {
966
1050
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
967
1051
  }), this.drawingManager.setEventCallback((e, t) => {
968
1052
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
969
- }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new at();
1053
+ }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new lt();
970
1054
  let i = "";
971
1055
  this.undoRedoManager.setOnChange(() => {
972
1056
  let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
@@ -979,21 +1063,21 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
979
1063
  primary: e[0] ?? null
980
1064
  })), this.drawingManager.setForeignHistory((e, t) => {
981
1065
  e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
982
- }), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new rt({
1066
+ }), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new st({
983
1067
  enabled: this.features.trading,
984
1068
  contextMenu: { enabled: this.features.tradingContextMenu }
985
- }), this.tradingRenderer = new it(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
1069
+ }), this.tradingRenderer = new ct(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
986
1070
  this.eventBus.emit(e, t);
987
- }), this.engine = new We(e);
1071
+ }), this.engine = new Je(e);
988
1072
  let a = this.engine.dprManager.getContainerSize();
989
- if (this.viewport = new ot(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
1073
+ if (this.viewport = new ut(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
990
1074
  freePan: t.freePan ?? !0,
991
1075
  minVisibleBars: t.panLimits?.minVisibleBars ?? 3
992
1076
  }), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
993
1077
  if (e.width <= 0 || e.height <= 0) return;
994
1078
  let t = this.viewport.isAtEnd();
995
1079
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
996
- }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new De(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new E(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new tt(), this.crosshairHandler = new ve(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
1080
+ }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new je(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new D(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new at(), this.crosshairHandler = new Se(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
997
1081
  if (e !== null && t) {
998
1082
  let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
999
1083
  this.chartLegend.setHoverBar(r ?? null);
@@ -1002,19 +1086,19 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1002
1086
  prevClose: e > 0 ? n[e - 1]?.close : void 0,
1003
1087
  priceRange: i.priceRange,
1004
1088
  plot: i.chartRect,
1005
- barStepMs: ft(n)
1089
+ barStepMs: gt(n)
1006
1090
  }) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
1007
1091
  point: t,
1008
1092
  bar: r,
1009
1093
  barIndex: e
1010
1094
  });
1011
1095
  } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
1012
- }), this.chartLegend = new pe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new ut(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new lt(), this.volumeProfile = new ct(), this.marketProfile = new Fe(), this.depthHeatmap = new Se(), this.periodLevels = new ze(), this.pivotMarkers = new Ve(), this.barCountdown = new le(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new Je(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new Ye(), this.compareRenderer = new me(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1096
+ }), this.chartLegend = new _e(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new mt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new pt(), this.volumeProfile = new ft(), this.marketProfile = new ze(), this.depthHeatmap = new Ee(), this.periodLevels = new Ue(), this.pivotMarkers = new Ge(), this.barCountdown = new pe(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new Qe(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new $e(), this.compareRenderer = new ve(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1013
1097
  visible: t.sessionBreaks.visible ?? !0,
1014
1098
  color: t.sessionBreaks.color,
1015
1099
  lineStyle: t.sessionBreaks.lineStyle,
1016
1100
  lineWidth: t.sessionBreaks.lineWidth
1017
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new oe(), this.crosshairTooltip = new ye(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Be(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = _(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Mn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Me({
1101
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new ue(), this.crosshairTooltip = new Ce(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new We(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = y(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(zn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ie({
1018
1102
  scrollBars: (e) => {
1019
1103
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1020
1104
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1031,17 +1115,17 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1031
1115
  },
1032
1116
  fitContent: () => this.fitContent()
1033
1117
  }), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
1034
- this.a11y = new Ft(e, {
1118
+ this.a11y = new zt(e, {
1035
1119
  symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
1036
1120
  timeframe: () => this.streamTimeframe ?? "",
1037
1121
  chartType: () => this.options.chartType ?? "candlestick",
1038
1122
  bars: () => this.getDisplayData(),
1039
1123
  visibleRange: () => this.viewport.getState().visibleRange,
1040
1124
  formatPrice: (e) => this.formatPrice(e),
1041
- formatTime: (e) => re(this.numberLocale || "en-US", {
1125
+ formatTime: (e) => se(this.numberLocale || "en-US", {
1042
1126
  dateStyle: "medium",
1043
1127
  timeStyle: "short"
1044
- }, this.displayTz)(e > xn ? e : e * 1e3),
1128
+ }, this.displayTz)(e > On ? e : e * 1e3),
1045
1129
  showBar: (e) => this.setCrosshairTime(e)
1046
1130
  }, t.a11y?.labels);
1047
1131
  for (let e of [
@@ -1061,7 +1145,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1061
1145
  }
1062
1146
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1063
1147
  }
1064
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new be(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new ae(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
1148
+ }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new we(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new le(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
1065
1149
  this.eventBus.emit("alertTriggered", G(e)), this.eventBus.emit("dataUpdate", {
1066
1150
  alert: "triggered",
1067
1151
  alertId: e.id,
@@ -1076,7 +1160,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1076
1160
  this.eventBus.emit("alertExpired", G(e));
1077
1161
  }), this.alertManager.on("updated", (e) => {
1078
1162
  this.eventBus.emit("alertUpdate", G(e));
1079
- }), this.signalMarkerManager = new Xe(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
1163
+ }), this.signalMarkerManager = new et(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
1080
1164
  this.eventBus.emit("signalMarkerAdd", {
1081
1165
  id: e.id,
1082
1166
  source: e.source,
@@ -1084,18 +1168,18 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1084
1168
  });
1085
1169
  }), this.signalMarkerManager.on("removed", (e) => {
1086
1170
  this.eventBus.emit("signalMarkerRemove", { id: e });
1087
- }), this.tradeZoneManager = new nt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
1171
+ }), this.tradeZoneManager = new ot(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
1088
1172
  this.eventBus.emit("tradeZoneAdd", {
1089
1173
  id: e.id,
1090
1174
  direction: e.direction
1091
1175
  });
1092
1176
  }), this.tradeZoneManager.on("removed", (e) => {
1093
1177
  this.eventBus.emit("tradeZoneRemove", { id: e });
1094
- }), this.replayManager = new Ke(), this.replayManager.on("stateChange", (e) => {
1178
+ }), this.replayManager = new Xe(), this.replayManager.on("stateChange", (e) => {
1095
1179
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
1096
- }), this.measureOverlay = new Ie(), this.interactionManager = new Ae(e), this.features.panning) {
1097
- let e = new ln();
1098
- this.interactionManager.setPanHandler(new Le((t, n) => {
1180
+ }), this.measureOverlay = new Be(), this.interactionManager = new Pe(e), this.features.panning) {
1181
+ let e = new gn();
1182
+ this.interactionManager.setPanHandler(new Ve((t, n) => {
1099
1183
  t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1100
1184
  }, () => e.reset()));
1101
1185
  }
@@ -1107,10 +1191,10 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1107
1191
  scales: !this.indicatorEngine.hasLeftScaleOverlays()
1108
1192
  }
1109
1193
  })), this.features.zooming) {
1110
- this.interactionManager.setZoomHandler(new dt((e, t) => {
1194
+ this.interactionManager.setZoomHandler(new ht((e, t) => {
1111
1195
  this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
1112
1196
  }));
1113
- let e = new ce((e) => {
1197
+ let e = new fe((e) => {
1114
1198
  this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1115
1199
  }, (e) => {
1116
1200
  let t = this.viewport.getState().chartRect.width;
@@ -1130,7 +1214,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1130
1214
  y: t.y
1131
1215
  });
1132
1216
  })), 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) => {
1133
- let t = P(e.y, this.viewport.getState());
1217
+ let t = F(e.y, this.viewport.getState());
1134
1218
  Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
1135
1219
  price: t,
1136
1220
  x: e.x,
@@ -1140,10 +1224,10 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1140
1224
  ...this.viewport.getState(),
1141
1225
  data: this.getDisplayData()
1142
1226
  })), this.features.alerts) {
1143
- let e = new ie(this.alertManager, () => this.viewport.getState());
1227
+ let e = new ce(this.alertManager, () => this.viewport.getState());
1144
1228
  this.interactionManager.setAlertDragHandler(e);
1145
1229
  }
1146
- let o = new Re();
1230
+ let o = new He();
1147
1231
  o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
1148
1232
  let t = this.getDisplayData();
1149
1233
  if (t.length === 0) return;
@@ -1167,7 +1251,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1167
1251
  x: e.x,
1168
1252
  y: e.y
1169
1253
  }), t.length === 0) return;
1170
- let r = Ot(e.x, this.viewport.getState());
1254
+ let r = Mt(e.x, this.viewport.getState());
1171
1255
  r < 0 || r >= t.length || this.eventBus.emit("barClick", {
1172
1256
  bar: t[r],
1173
1257
  barIndex: r,
@@ -1207,7 +1291,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1207
1291
  end: () => {
1208
1292
  let e = this.selectionBoxOverlay.end();
1209
1293
  if (e && this.zoomAreaMode) {
1210
- if (e.x1 - e.x0 < On) return;
1294
+ if (e.x1 - e.x0 < Fn) return;
1211
1295
  this.zoomToBox(e), this.setZoomAreaMode(!1);
1212
1296
  return;
1213
1297
  }
@@ -1244,7 +1328,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1244
1328
  if (this.replaySession) return 0;
1245
1329
  let t = null;
1246
1330
  if (this.fullSeries) {
1247
- let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => zn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
1331
+ let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => Kn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
1248
1332
  this.fullSeries = [...i, ...this.fullSeries];
1249
1333
  let a = this.sessionKeep(this.fullSeries);
1250
1334
  t = i.length, e = a ? i.filter((e) => a(e.time)) : i;
@@ -1253,7 +1337,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1253
1337
  if (a === 0) return t ?? 0;
1254
1338
  let o = this.dataManager.getData();
1255
1339
  if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), i !== void 0) {
1256
- let e = Math.round(j(i, this.getDisplayData()));
1340
+ let e = Math.round(M(i, this.getDisplayData()));
1257
1341
  this.viewport.prependBars(e - r);
1258
1342
  }
1259
1343
  return this.updateViewportAndRender(), t ?? a;
@@ -1284,15 +1368,15 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1284
1368
  }
1285
1369
  checkHistory() {
1286
1370
  this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
1287
- if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || Vt(this.options.chartType)) return;
1371
+ if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || Kt(this.options.chartType)) return;
1288
1372
  let { from: e, to: t } = this.viewport.getState().visibleRange;
1289
- this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Dn, t - e));
1373
+ this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Pn, t - e));
1290
1374
  }));
1291
1375
  }
1292
1376
  useStreamHistory(e, t) {
1293
1377
  if (this.hostHistoryLoader) return;
1294
- let n = Dt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1295
- if (!r || i === null || ne(i) !== null) {
1378
+ let n = jt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1379
+ if (!r || i === null || ie(i) !== null) {
1296
1380
  this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
1297
1381
  return;
1298
1382
  }
@@ -1352,7 +1436,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1352
1436
  }
1353
1437
  setChartType(e) {
1354
1438
  let t = this.options.chartType ?? "candlestick";
1355
- this.options.chartType = e, this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
1439
+ this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
1356
1440
  type: e,
1357
1441
  previous: t
1358
1442
  });
@@ -1360,11 +1444,11 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1360
1444
  setChartTypeOptions(e) {
1361
1445
  this.chartTypeOptions = {
1362
1446
  ...this.chartTypeOptions,
1363
- ..._(e)
1447
+ ...y(e)
1364
1448
  }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged();
1365
1449
  }
1366
1450
  getChartTypeOptions() {
1367
- return _(this.chartTypeOptions);
1451
+ return y(this.chartTypeOptions);
1368
1452
  }
1369
1453
  setExtendedHours(e) {
1370
1454
  e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
@@ -1373,7 +1457,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1373
1457
  return this.extendedHours;
1374
1458
  }
1375
1459
  sessionKeep(e) {
1376
- return this.extendedHours ? null : jt(this.symbolInfo, e);
1460
+ return this.extendedHours ? null : Ft(this.symbolInfo, e);
1377
1461
  }
1378
1462
  shownBars(e) {
1379
1463
  let t = this.sessionKeep(e);
@@ -1414,7 +1498,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1414
1498
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
1415
1499
  }
1416
1500
  setShapes(e) {
1417
- let t = Mn(e);
1501
+ let t = zn(e);
1418
1502
  t.tagRadius !== void 0 && (this.themeManager.setShape({
1419
1503
  ...this.themeManager.getTheme().shape,
1420
1504
  ...t
@@ -1486,14 +1570,14 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1486
1570
  this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
1487
1571
  }
1488
1572
  updateIndicatorNow(e, t) {
1489
- let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? A(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
1573
+ let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? j(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
1490
1574
  this.indicatorEngine.updateIndicator(e, t, this.dataManager.getData()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
1491
1575
  instanceId: e,
1492
1576
  change: "params"
1493
1577
  }), this.requestMissingSymbols(e);
1494
1578
  let a = this.indicatorEngine.getIndicatorConfig(e);
1495
1579
  if (n?.placement === "overlay" && a && r && a.params[r] !== i) {
1496
- let t = h(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : h(i) ? null : a.pane ?? null;
1580
+ let t = g(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : g(i) ? null : a.pane ?? null;
1497
1581
  (n ?? void 0) !== a.pane && (this.indicatorEngine.setPane(e, n), this.eventBus.emit("indicatorChange", {
1498
1582
  instanceId: e,
1499
1583
  change: "pane"
@@ -1504,7 +1588,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1504
1588
  paneFor(e, t, n, r) {
1505
1589
  if (n) return this.paneHostOf(n, r);
1506
1590
  if (e.placement !== "overlay") return null;
1507
- let i = A(e), a = i ? h(t[i]) : null;
1591
+ let i = j(e), a = i ? g(t[i]) : null;
1508
1592
  return a ? this.paneHostOf(a.instanceId, r) : null;
1509
1593
  }
1510
1594
  paneHostOf(e, t) {
@@ -1547,8 +1631,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1547
1631
  return {
1548
1632
  ...e,
1549
1633
  priceRange: {
1550
- min: t.min - n * Tn,
1551
- max: t.max + n * Tn
1634
+ min: t.min - n * Mn,
1635
+ max: t.max + n * Mn
1552
1636
  },
1553
1637
  logScale: !1,
1554
1638
  scaleMode: "regular",
@@ -1578,7 +1662,9 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1578
1662
  detachIndicator(e) {
1579
1663
  if (!this.indicatorEngine.getIndicatorConfig(e)) return;
1580
1664
  let t = this.layoutManager.getPanels().find((t) => t.id === e), n = this.indicatorEngine.getPaneMembers(e), r = t ? n.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null : null;
1581
- this.indicatorEngine.removeIndicator(e), r ? (this.indicatorEngine.setPane(r, null), this.layoutManager.renamePanel(e, r)) : this.layoutManager.removePanel(e);
1665
+ this.indicatorEngine.removeIndicator(e);
1666
+ let i = this.paneStyles.get(e);
1667
+ this.paneStyles.delete(e), r ? (this.indicatorEngine.setPane(r, null), this.layoutManager.renamePanel(e, r), i && this.paneStyles.set(r, i)) : this.layoutManager.removePanel(e);
1582
1668
  for (let e of n) e !== r && this.indicatorEngine.setPane(e, r), this.eventBus.emit("indicatorChange", {
1583
1669
  instanceId: e,
1584
1670
  change: "pane"
@@ -1588,6 +1674,28 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1588
1674
  getIndicatorStyle(e) {
1589
1675
  return this.indicatorEngine.getIndicatorStyle(e);
1590
1676
  }
1677
+ setIndicatorDefaults(e, t) {
1678
+ if (!t) {
1679
+ this.indicatorEngine.setStyleDefaults(e, null);
1680
+ return;
1681
+ }
1682
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : b(n);
1683
+ this.indicatorEngine.setStyleDefaults(e, {
1684
+ ...r,
1685
+ ...i ? { plots: i } : {}
1686
+ });
1687
+ }
1688
+ setPaneStyle(e, t) {
1689
+ let n = this.paneOf(e);
1690
+ this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? ee(t) : null));
1691
+ }
1692
+ setPaneStyleNow(e, t) {
1693
+ 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());
1694
+ }
1695
+ getPaneStyle(e) {
1696
+ let t = this.paneStyles.get(this.paneOf(e));
1697
+ return t ? { ...t } : null;
1698
+ }
1591
1699
  getIndicatorOutput(e) {
1592
1700
  return this.indicatorEngine.getOutput(e);
1593
1701
  }
@@ -1598,8 +1706,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1598
1706
  return this.pluginManager;
1599
1707
  }
1600
1708
  static indicators() {
1601
- let e = new w();
1602
- return O(e), e.getAvailableIndicators();
1709
+ let e = new T();
1710
+ return k(e), e.getAvailableIndicators();
1603
1711
  }
1604
1712
  setPanelPosition(e, t) {
1605
1713
  this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
@@ -1622,8 +1730,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1622
1730
  paneMoveHost(e, t) {
1623
1731
  let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
1624
1732
  if (!n || !r) return;
1625
- let i = A(r);
1626
- if (r.placement === "overlay" && i && h(n.params[i])) return;
1733
+ let i = j(r);
1734
+ if (r.placement === "overlay" && i && g(n.params[i])) return;
1627
1735
  if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
1628
1736
  if (t === "new") {
1629
1737
  let t = this.layoutManager.getPanels().some((t) => t.id === e);
@@ -1637,14 +1745,15 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1637
1745
  if (n === void 0 || !r) return !1;
1638
1746
  let i = r.pane, a = this.layoutManager.getPanels().some((t) => t.id === e), o = new Set([e]);
1639
1747
  if (a) {
1640
- let t = this.indicatorEngine.getPaneMembers(e), r = new Set(this.indicatorEngine.getDependents(e)), i = t.filter((e) => !r.has(e)), a = i.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null;
1641
- if (a) {
1642
- this.indicatorEngine.setPane(a, null), this.layoutManager.renamePanel(e, a);
1748
+ let t = this.indicatorEngine.getPaneMembers(e), r = new Set(this.indicatorEngine.getDependents(e)), i = t.filter((e) => !r.has(e)), a = i.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null, s = this.paneStyles.get(e);
1749
+ if (this.paneStyles.delete(e), a) {
1750
+ this.indicatorEngine.setPane(a, null), this.layoutManager.renamePanel(e, a), s && this.paneStyles.set(a, s);
1643
1751
  for (let e of i) e !== a && this.indicatorEngine.setPane(e, a);
1644
1752
  } else {
1645
1753
  this.layoutManager.removePanel(e);
1646
1754
  for (let e of i) this.indicatorEngine.setPane(e, null);
1647
1755
  }
1756
+ this.panelInfoCache = null;
1648
1757
  for (let i of t) r.has(i) && this.indicatorEngine.setPane(i, n ?? e), o.add(i);
1649
1758
  }
1650
1759
  if (this.indicatorEngine.setPane(e, n), t === "new") {
@@ -1728,12 +1837,12 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1728
1837
  return this.features.legend ? e + this.chartLegend.getHeight() : e;
1729
1838
  }
1730
1839
  isTimeAligned() {
1731
- return Vt(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
1840
+ return Kt(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
1732
1841
  }
1733
1842
  roundPrice(e) {
1734
1843
  if (!Number.isFinite(e)) return e;
1735
1844
  let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
1736
- if (t !== void 0 && t > 0) return Number((Math.round(e / t) * t).toFixed(te(t)));
1845
+ if (t !== void 0 && t > 0) return Number((Math.round(e / t) * t).toFixed(re(t)));
1737
1846
  let { min: n, max: r } = this.viewport.getState().priceRange;
1738
1847
  return Number(e.toFixed(this.marketPricePrecision ?? s(n, r)));
1739
1848
  }
@@ -1744,7 +1853,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1744
1853
  return this.priceFormatter;
1745
1854
  }
1746
1855
  applyPriceFormat(e) {
1747
- this.priceFormatter = g(e), this.priceUnit = e && typeof e != "function" ? u(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
1856
+ this.priceFormatter = _(e), this.priceUnit = e && typeof e != "function" ? d(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
1748
1857
  }
1749
1858
  setTimeFormatter(e) {
1750
1859
  this.applyTimeFormatter(e), this.engine.requestRender();
@@ -1755,7 +1864,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1755
1864
  formatPrice(e) {
1756
1865
  if (this.priceFormatter) return this.priceFormatter(e);
1757
1866
  let { min: t, max: n } = this.viewport.getState().priceRange;
1758
- return l(e, this.marketPricePrecision ?? s(t, n), this.numberLocale);
1867
+ return u(e, this.marketPricePrecision ?? s(t, n), this.numberLocale);
1759
1868
  }
1760
1869
  setDrawingTool(e) {
1761
1870
  this.features.drawings && (e && this.features.drawingTools.length > 0 && !this.features.drawingTools.includes(e) || (e && this.setZoomAreaMode(!1), this.drawingManager.setActiveTool(e)));
@@ -1800,7 +1909,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1800
1909
  }
1801
1910
  autoFib() {
1802
1911
  if (!this.features.drawings) return null;
1803
- let e = this.getDisplayData(), t = this.viewport.getState(), n = pt(e, t.visibleRange.from, t.visibleRange.to);
1912
+ let e = this.getDisplayData(), t = this.viewport.getState(), n = _t(e, t.visibleRange.from, t.visibleRange.to);
1804
1913
  return n ? this.addDrawing({
1805
1914
  type: "fibRetracement",
1806
1915
  anchors: [n[0], n[1]]
@@ -1875,7 +1984,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1875
1984
  recordUndo(e) {
1876
1985
  if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
1877
1986
  let t = performance.now(), n = this.undoRedoManager.last();
1878
- if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < En) {
1987
+ if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Nn) {
1879
1988
  this.undoRedoManager.replaceLast({
1880
1989
  ...n,
1881
1990
  custom: {
@@ -1922,7 +2031,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1922
2031
  x: t.x,
1923
2032
  y: t.y
1924
2033
  };
1925
- if ((e === "plot" || e === "priceAxis") && (r.price = P(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = N(t.x, n)), e === "pane") {
2034
+ if ((e === "plot" || e === "priceAxis") && (r.price = F(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = P(t.x, n)), e === "pane") {
1926
2035
  let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
1927
2036
  e && (r.pane = e.instanceId);
1928
2037
  }
@@ -1948,7 +2057,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1948
2057
  ...this.viewport.getState(),
1949
2058
  data: this.getDisplayData()
1950
2059
  };
1951
- this.setVisibleRange(N(e.x0, t), N(e.x1, t));
2060
+ this.setVisibleRange(P(e.x0, t), P(e.x1, t));
1952
2061
  }
1953
2062
  lockAllDrawings() {
1954
2063
  this.drawingManager.lockAllDrawings();
@@ -1993,7 +2102,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1993
2102
  for (let e of this.indicatorEngine.getActiveIndicators()) {
1994
2103
  let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
1995
2104
  if (!t) continue;
1996
- let r = Lt(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2105
+ let r = Ht(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
1997
2106
  key: e,
1998
2107
  title: e
1999
2108
  }));
@@ -2017,11 +2126,11 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2017
2126
  }
2018
2127
  getExportText(e = "csv", t = {}) {
2019
2128
  let { bars: n, columns: r } = this.getExportData(t);
2020
- return e === "json" ? S.toJSON(n, r) : S.toCSV(n, r);
2129
+ return e === "json" ? C.toJSON(n, r) : C.toCSV(n, r);
2021
2130
  }
2022
2131
  download(e, t, n) {
2023
2132
  let r = this.getExportText(e, n);
2024
- e === "json" ? S.download(r, t ?? "chart-data.json", "application/json") : S.download(r, t ?? "chart-data.csv", "text/csv");
2133
+ e === "json" ? C.download(r, t ?? "chart-data.json", "application/json") : C.download(r, t ?? "chart-data.csv", "text/csv");
2025
2134
  }
2026
2135
  setAutoSave(e, t = 5e3) {
2027
2136
  this.autoSaveScheduler.enable(e, t);
@@ -2071,7 +2180,11 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2071
2180
  this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
2072
2181
  }
2073
2182
  updateIndicatorStyleNow(e, t) {
2074
- this.indicatorEngine.updateIndicatorStyle(e, t), this.engine.requestRender(), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2183
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : b(n);
2184
+ this.indicatorEngine.updateIndicatorStyle(e, {
2185
+ ...r,
2186
+ ...i ? { plots: i } : {}
2187
+ }), this.engine.requestRender(), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2075
2188
  instanceId: e,
2076
2189
  change: "style"
2077
2190
  });
@@ -2177,8 +2290,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2177
2290
  this.features.trading && this.tradingManager.setConfig(e);
2178
2291
  }
2179
2292
  async connect(e) {
2180
- if (!k(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
2181
- this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new $e(), this.streamManager.on("snapshot", (t) => {
2293
+ if (!A(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
2294
+ this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new rt(), this.streamManager.on("snapshot", (t) => {
2182
2295
  let n = `${this.currentSymbol}|${this.streamTimeframe}`;
2183
2296
  this.replaySession ? this.replaySession.live.setData(t) : n === this.snapshotKey && this.dataManager.getLength() > 0 ? this.mergeSnapshot(t) : this.setData(t), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
2184
2297
  }), this.streamManager.on("barClose", (e) => {
@@ -2227,7 +2340,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2227
2340
  }), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
2228
2341
  let t = this.streamManager;
2229
2342
  if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
2230
- let n = y(e.timeframe);
2343
+ let n = ae(e.timeframe);
2231
2344
  this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
2232
2345
  this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
2233
2346
  }, 1e3);
@@ -2245,8 +2358,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2245
2358
  async switchStream(e, t) {
2246
2359
  if (!this.streamManager) return;
2247
2360
  let n = this.streamAdapter;
2248
- if (n && !k(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2249
- this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(y(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
2361
+ if (n && !A(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2362
+ this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(ae(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
2250
2363
  }
2251
2364
  isTimeframeAllowed(e) {
2252
2365
  let t = this.features.timeframes;
@@ -2261,7 +2374,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2261
2374
  }
2262
2375
  connectExecution(e, t = {}) {
2263
2376
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
2264
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = yn(e, {
2377
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = En(e, {
2265
2378
  onIntent: (e, t) => {
2266
2379
  let n = (e) => t(e.payload);
2267
2380
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -2352,18 +2465,18 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2352
2465
  goToTime(e) {
2353
2466
  let t = this.getDisplayData();
2354
2467
  if (t.length === 0 || !Number.isFinite(e)) return -1;
2355
- 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;
2468
+ 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;
2356
2469
  return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
2357
2470
  }
2358
2471
  setVisibleRangePreset(e) {
2359
2472
  let t = this.getDisplayData();
2360
2473
  if (t.length === 0) return;
2361
- let n = t.length - 1, r = t[n].time > xn ? 1 : 1e3, i = vt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
2474
+ let n = t.length - 1, r = t[n].time > On ? 1 : 1e3, i = St(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
2362
2475
  if (a === null || a < t[0].time) {
2363
2476
  this.fitContent();
2364
2477
  return;
2365
2478
  }
2366
- let o = j(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
2479
+ let o = M(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
2367
2480
  this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
2368
2481
  }
2369
2482
  scrollToEnd() {
@@ -2377,7 +2490,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2377
2490
  setVisibleRange(e, t) {
2378
2491
  let n = this.dataManager.getData();
2379
2492
  if (n.length === 0) return;
2380
- let r = j(Math.min(e, t), n), i = j(Math.max(e, t), n);
2493
+ let r = M(Math.min(e, t), n), i = M(Math.max(e, t), n);
2381
2494
  this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
2382
2495
  }
2383
2496
  setPanLimits(e) {
@@ -2411,10 +2524,41 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2411
2524
  this.eventBus.disableTauriBridge();
2412
2525
  }
2413
2526
  setTheme(e) {
2414
- this.themeManager.setTheme(e), this.syncRenderContext(), this.container.style.backgroundColor = this.themeManager.getTheme().background, this.engine.requestRender(), this.eventBus.emit("themeChange", { theme: e }), this.markStateChanged();
2527
+ this.themeManager.setTheme(e), this.syncRenderContext(), this.container.style.backgroundColor = this.themeManager.getTheme().background, this.lastBackground = this.themeManager.getTheme().background, this.engine.requestRender(), this.eventBus.emit("themeChange", { theme: e }), this.markStateChanged();
2415
2528
  }
2416
2529
  getTheme() {
2417
- return this.themeManager.getTheme();
2530
+ return this.themeManager.getBaseTheme();
2531
+ }
2532
+ applyOverrides(e, t = {}) {
2533
+ this.applyStyle(e, t.layer ?? "host", !0);
2534
+ }
2535
+ setOverrides(e, t = {}) {
2536
+ let n = t.layer ?? "host", { overrides: r, rejected: i } = v(e);
2537
+ i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
2538
+ let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
2539
+ this.themeManager.setOverrides(a, n) && this.styleChanged(n);
2540
+ }
2541
+ resetOverrides(e, t = {}) {
2542
+ let n = t.layer ?? "host";
2543
+ this.themeManager.resetOverrides(n, e) && this.styleChanged(n);
2544
+ }
2545
+ getOverrides(e = {}) {
2546
+ return this.themeManager.getOverrides(e.layer ?? "host");
2547
+ }
2548
+ getStyle() {
2549
+ return this.themeManager.getTheme().style;
2550
+ }
2551
+ getStyleValue(e) {
2552
+ return this.themeManager.getStyleValue(e);
2553
+ }
2554
+ applyStyle(e, t, n) {
2555
+ let { overrides: r, rejected: i } = v(e);
2556
+ i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
2557
+ }
2558
+ styleChanged(e) {
2559
+ this.syncRenderContext();
2560
+ let t = this.themeManager.getTheme().background;
2561
+ t !== this.lastBackground && (this.container.style.backgroundColor = t, this.lastBackground = t), this.engine.requestRender(), this.eventBus.emit("styleChange", { layer: e }), e === "user" && this.markStateChanged();
2418
2562
  }
2419
2563
  setWatermark(e, t) {
2420
2564
  this.watermark.setConfig({
@@ -2438,7 +2582,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2438
2582
  e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
2439
2583
  }
2440
2584
  setCrosshairTime(e) {
2441
- let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(j(e, t));
2585
+ let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(M(e, t));
2442
2586
  n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
2443
2587
  }
2444
2588
  getData() {
@@ -2500,7 +2644,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2500
2644
  this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
2501
2645
  }
2502
2646
  setTimezone(e) {
2503
- Cn(e), this.timezoneSetting = e, this.applyTimezone();
2647
+ An(e), this.timezoneSetting = e, this.applyTimezone();
2504
2648
  }
2505
2649
  getTimezone() {
2506
2650
  return this.timezoneSetting;
@@ -2509,7 +2653,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2509
2653
  return this.displayTz;
2510
2654
  }
2511
2655
  applyTimezone() {
2512
- let e = this.symbolInfo?.timezone, t = this.timezoneSetting === "exchange" ? e && f(e) ? e : "UTC" : this.timezoneSetting;
2656
+ let e = this.symbolInfo?.timezone, t = this.timezoneSetting === "exchange" ? e && p(e) ? e : "UTC" : this.timezoneSetting;
2513
2657
  this.displayTz = t, this.timeAxis.setTimezoneOffset(t), this.crosshairHandler.setTimezoneOffset(t), this.crosshairTooltip.setTimezoneOffset(t), this.pinnedTooltip.setTimezone(t), this.sessionBreaks.setTimezone(t), this.engine.requestRender();
2514
2658
  }
2515
2659
  setSymbolInfo(e) {
@@ -2518,13 +2662,13 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2518
2662
  sessions: e.sessions?.map((e) => ({ ...e }))
2519
2663
  } : null, this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
2520
2664
  let t = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
2521
- let t = v(e.start), n = v(e.end);
2665
+ let t = x(e.start), n = x(e.end);
2522
2666
  return t === null || n === null ? [] : [{
2523
2667
  startMinute: t,
2524
2668
  endMinute: n
2525
2669
  }];
2526
2670
  }), n = this.symbolInfo?.timezone;
2527
- this.sessionShading.replaceConfig(t.length > 0 && n && f(n) ? {
2671
+ this.sessionShading.replaceConfig(t.length > 0 && n && p(n) ? {
2528
2672
  timeZone: n,
2529
2673
  windows: t,
2530
2674
  startMinute: t[0].startMinute,
@@ -2563,7 +2707,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2563
2707
  return this.sessionShading.isVisible();
2564
2708
  }
2565
2709
  setSessionShadingConfig(e) {
2566
- this.hostSessionHours = _t(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
2710
+ this.hostSessionHours = xt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
2567
2711
  }
2568
2712
  setTooltipVisible(e) {
2569
2713
  e || this.crosshairTooltip.hide();
@@ -2582,11 +2726,11 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2582
2726
  return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
2583
2727
  }
2584
2728
  async takeGpu(e, t, n) {
2585
- let { gpu: r, reason: i } = await gt(e);
2586
- return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? mt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
2729
+ let { gpu: r, reason: i } = await bt(e);
2730
+ return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? vt() > 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());
2587
2731
  }
2588
2732
  waitForGpu(e) {
2589
- this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Et(e) : null;
2733
+ this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? At(e) : null;
2590
2734
  }
2591
2735
  getRenderer() {
2592
2736
  return this.engine.getGpu() ? "webgl" : "canvas";
@@ -2604,23 +2748,23 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2604
2748
  this.engine.getGpu() && this.engine.renderNow();
2605
2749
  }
2606
2750
  screenshot(e) {
2607
- this.features.screenshot && (this.freshFrame(), D.download(this.container, e, this.themeManager.getTheme().background));
2751
+ this.features.screenshot && (this.freshFrame(), O.download(this.container, e, this.themeManager.getTheme().background));
2608
2752
  }
2609
2753
  async copyScreenshot() {
2610
2754
  if (!this.features.screenshot) return !1;
2611
2755
  try {
2612
2756
  this.freshFrame();
2613
- let e = await D.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
2757
+ let e = await O.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
2614
2758
  return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
2615
2759
  } catch {
2616
2760
  return !1;
2617
2761
  }
2618
2762
  }
2619
2763
  screenshotDataURL() {
2620
- return this.features.screenshot ? (this.freshFrame(), D.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
2764
+ return this.features.screenshot ? (this.freshFrame(), O.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
2621
2765
  }
2622
2766
  async screenshotBlob() {
2623
- return this.features.screenshot ? (this.freshFrame(), D.toBlob(this.container, this.themeManager.getTheme().background)) : null;
2767
+ return this.features.screenshot ? (this.freshFrame(), O.toBlob(this.container, this.themeManager.getTheme().background)) : null;
2624
2768
  }
2625
2769
  addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
2626
2770
  if (!this.features.alerts) return null;
@@ -2753,20 +2897,20 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2753
2897
  fedTime: null
2754
2898
  };
2755
2899
  }
2756
- let t = this.shownBars(this.replaySession.live.getData()), { steps: n, ...r } = e ?? {}, i = n ? Rn(n, t) : null;
2900
+ let t = this.shownBars(this.replaySession.live.getData()), { steps: n, ...r } = e ?? {}, i = n ? Gn(n, t) : null;
2757
2901
  this.replayStepsSeries = i, this.replayCoarse = t, this.options.autoScale = !0, this.replayRestarting = !0;
2758
2902
  try {
2759
2903
  this.replayManager.load(i ?? t);
2760
2904
  } finally {
2761
2905
  this.replayRestarting = !1;
2762
2906
  }
2763
- i && r.startIndex !== void 0 && (r.startIndex = Vn(i, t, r.startIndex)), this.replayBarUnsub?.();
2907
+ i && r.startIndex !== void 0 && (r.startIndex = Jn(i, t, r.startIndex)), this.replayBarUnsub?.();
2764
2908
  let a = -1, o = -1, s = null, c = i ?? t;
2765
2909
  this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
2766
2910
  let n = e, r = t[e];
2767
2911
  if (i) {
2768
2912
  let c = i[e];
2769
- n = Bn(t, c.time), s = s !== null && o === e - 1 && n === a - 1 && s ? Un(s, c) : Hn(t[n], i, e), r = s;
2913
+ n = qn(t, c.time), s = s !== null && o === e - 1 && n === a - 1 && s ? Xn(s, c) : Yn(t[n], i, e), r = s;
2770
2914
  }
2771
2915
  o = e;
2772
2916
  let l = n + 1, u = a > 0 && l >= a && this.dataManager.getLength() === a, d = !(u && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
@@ -2811,20 +2955,20 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2811
2955
  return;
2812
2956
  }
2813
2957
  if (i.time <= n.fedTime) return;
2814
- let a = e.slice(Fn(e, n.fedTime), t + 1);
2958
+ let a = e.slice(Hn(e, n.fedTime), t + 1);
2815
2959
  n.fedTime = i.time;
2816
- let o = Math.ceil(a.length / Pn);
2817
- for (let e = 0; e < a.length; e += o) for (let [t, n] of In(a.slice(e, e + o))) r.setMarkPrice(t, n);
2960
+ let o = Math.ceil(a.length / Vn);
2961
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of Un(a.slice(e, e + o))) r.setMarkPrice(t, n);
2818
2962
  this.tradingManager.setCurrentPrice(i.close);
2819
2963
  }
2820
2964
  getReplayBarIndex() {
2821
2965
  if (!this.replaySession) return -1;
2822
2966
  let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
2823
- return t && this.replayCoarse ? Bn(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
2967
+ return t && this.replayCoarse ? qn(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
2824
2968
  }
2825
2969
  replaySeekToBar(e) {
2826
2970
  let t = this.replayStepsSeries;
2827
- this.replaySeek(t && this.replayCoarse ? Vn(t, this.replayCoarse, e) : e);
2971
+ this.replaySeek(t && this.replayCoarse ? Jn(t, this.replayCoarse, e) : e);
2828
2972
  }
2829
2973
  replayPause() {
2830
2974
  this.replayManager.pause();
@@ -2869,11 +3013,12 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2869
3013
  return this.replayManager.getProgress();
2870
3014
  }
2871
3015
  captureSnapshot() {
2872
- return x.capture({
3016
+ return S.capture({
2873
3017
  getDrawings: () => this.getDrawings(),
2874
- getTheme: () => this.getTheme(),
3018
+ getTheme: () => this.themeManager.getBaseTheme(),
2875
3019
  getAlerts: () => this.getAlerts(),
2876
- getIndicators: () => this.getIndicatorSetup()
3020
+ getIndicators: () => this.getIndicatorSetup(),
3021
+ getOverrides: () => this.themeManager.getUserOverrides()
2877
3022
  }, {
2878
3023
  chartType: this.options.chartType,
2879
3024
  chartTypeOptions: this.getChartTypeOptions(),
@@ -2881,14 +3026,14 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2881
3026
  });
2882
3027
  }
2883
3028
  restoreIndicators(e, t) {
2884
- let n = An(e), r = /* @__PURE__ */ new Map();
3029
+ let n = Ln(e), r = /* @__PURE__ */ new Map();
2885
3030
  this.unrestoredIndicators = [];
2886
3031
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
2887
3032
  if (t) {
2888
3033
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
2889
3034
  for (let n of t) {
2890
3035
  let t = e.get(n.instanceId);
2891
- t && jn(n, t) && o.add(n.instanceId);
3036
+ t && Rn(n, t) && o.add(n.instanceId);
2892
3037
  }
2893
3038
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
2894
3039
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -2896,8 +3041,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2896
3041
  let s = (e) => {
2897
3042
  let t = { ...e };
2898
3043
  for (let [e, n] of Object.entries(t)) {
2899
- let i = h(n), a = i && r.get(i.instanceId);
2900
- a && (t[e] = d(a, i.key));
3044
+ let i = g(n), a = i && r.get(i.instanceId);
3045
+ a && (t[e] = f(a, i.key));
2901
3046
  }
2902
3047
  return t;
2903
3048
  };
@@ -2936,15 +3081,19 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2936
3081
  return this.restorePanes(a), this.updateViewportAndRender(), r;
2937
3082
  }
2938
3083
  restoreLooks(e, t) {
2939
- let n = this.indicatorEngine.getIndicatorStyle(e);
3084
+ let { plots: n, ...r } = this.indicatorEngine.getIndicatorStyle(e) ?? {
3085
+ colors: [],
3086
+ lineWidths: [],
3087
+ opacity: 1
3088
+ }, { plots: i, ...a } = t.style ?? {};
2940
3089
  t.style && JSON.stringify({
2941
- ...n,
2942
- ...t.style
2943
- }) !== JSON.stringify(n) && this.updateIndicatorStyle(e, t.style);
2944
- let r = this.indicatorEngine.getIndicatorConfig(e);
2945
- (t.visible ?? !0) !== (r?.visible ?? !0) && this.setIndicatorVisible(e, t.visible ?? !0);
2946
- let i = t.levels ?? null;
2947
- JSON.stringify(i) !== JSON.stringify(r?.levels ?? null) && this.setIndicatorLevels(e, i);
3090
+ ...r,
3091
+ ...a
3092
+ }) !== JSON.stringify(r) && this.updateIndicatorStyle(e, a), JSON.stringify(i ?? {}) !== JSON.stringify(n ?? {}) && (this.indicatorEngine.setPlotStyles(e, i ?? null), this.engine.requestRender());
3093
+ let o = this.indicatorEngine.getIndicatorConfig(e);
3094
+ (t.visible ?? !0) !== (o?.visible ?? !0) && this.setIndicatorVisible(e, t.visible ?? !0);
3095
+ let s = t.levels ?? null;
3096
+ JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s), this.setPaneStyleNow(e, t.paneStyle ? ee(t.paneStyle) : null);
2948
3097
  }
2949
3098
  restorePanes(e) {
2950
3099
  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, {
@@ -2971,6 +3120,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2971
3120
  levels: i?.levels?.slice(),
2972
3121
  pane: n.pane,
2973
3122
  scale: i?.scale,
3123
+ ...r && this.paneStyles.has(n.instanceId) ? { paneStyle: { ...this.paneStyles.get(n.instanceId) } } : {},
2974
3124
  ...r ? {
2975
3125
  paneSize: r.size,
2976
3126
  paneOrder: e.indexOf(r),
@@ -3024,7 +3174,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3024
3174
  if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
3025
3175
  let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
3026
3176
  if (JSON.stringify(n) === JSON.stringify(i)) return r;
3027
- let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < En && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3177
+ let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Nn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3028
3178
  type: "indicators",
3029
3179
  before: null,
3030
3180
  after: null
@@ -3052,13 +3202,13 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3052
3202
  }
3053
3203
  saveState(e) {
3054
3204
  if (!this.features.saveLoad) return null;
3055
- let t = this.captureSnapshot(), n = x.serialize(t);
3056
- return e && x.saveToStorage(e, t), n;
3205
+ let t = this.captureSnapshot(), n = S.serialize(t);
3206
+ return e && S.saveToStorage(e, t), n;
3057
3207
  }
3058
3208
  loadState(e) {
3059
3209
  if (!this.features.saveLoad) return;
3060
- let t = x.deserialize(e);
3061
- this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), t.theme && this.setTheme(t.theme);
3210
+ let t = S.deserialize(e);
3211
+ 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");
3062
3212
  let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
3063
3213
  if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
3064
3214
  this.alertManager.clearAlerts();
@@ -3068,7 +3218,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3068
3218
  let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
3069
3219
  return r ? r + e.slice(t) : e;
3070
3220
  }, r = t(e.channel), i = {
3071
- ...yt(e),
3221
+ ...Ct(e),
3072
3222
  ...e.target ? { target: t(e.target) } : {}
3073
3223
  };
3074
3224
  if (!e.expired) {
@@ -3088,19 +3238,19 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3088
3238
  }
3089
3239
  loadStateFromStorage(e) {
3090
3240
  if (!this.features.saveLoad) return !1;
3091
- let t = x.loadFromStorage(e);
3092
- return t ? (this.loadState(x.serialize(t)), !0) : !1;
3241
+ let t = S.loadFromStorage(e);
3242
+ return t ? (this.loadState(S.serialize(t)), !0) : !1;
3093
3243
  }
3094
3244
  downloadState(e) {
3095
- this.features.saveLoad && x.downloadFile(this.captureSnapshot(), e);
3245
+ this.features.saveLoad && S.downloadFile(this.captureSnapshot(), e);
3096
3246
  }
3097
3247
  async loadStateFromFile() {
3098
3248
  if (!this.features.saveLoad) return;
3099
- let e = await x.loadFromFile();
3100
- this.loadState(x.serialize(e));
3249
+ let e = await S.loadFromFile();
3250
+ this.loadState(S.serialize(e));
3101
3251
  }
3102
3252
  setLocale(e) {
3103
- ee(e), this.engine.requestRender();
3253
+ ne(e), this.engine.requestRender();
3104
3254
  }
3105
3255
  setNumberLocale(e) {
3106
3256
  this.numberLocale = e, this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
@@ -3111,26 +3261,26 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3111
3261
  setMarket(e) {
3112
3262
  if (this.marketConfig = e, e.colorScheme) {
3113
3263
  let t = {
3114
- ...this.themeManager.getTheme(),
3264
+ ...this.themeManager.getBaseTheme(),
3115
3265
  candleUp: e.colorScheme.up,
3116
3266
  candleDown: e.colorScheme.down,
3117
3267
  candleUpWick: e.colorScheme.up,
3118
3268
  candleDownWick: e.colorScheme.down,
3119
- volumeUp: b(e.colorScheme.up),
3120
- volumeDown: b(e.colorScheme.down)
3269
+ volumeUp: oe(e.colorScheme.up),
3270
+ volumeDown: oe(e.colorScheme.down)
3121
3271
  };
3122
3272
  this.themeManager.setTheme(t);
3123
3273
  }
3124
3274
  e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
3125
3275
  }
3126
3276
  applyPricePrecision(e) {
3127
- this.marketPricePrecision = e, this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? wn), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3277
+ this.marketPricePrecision = e, this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? jn), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3128
3278
  }
3129
3279
  getMarket() {
3130
3280
  return this.marketConfig;
3131
3281
  }
3132
3282
  setPriceLimits(e) {
3133
- this.marketConfig && (c(e, this.marketConfig) && (this.marketConfig.priceLimits = {
3283
+ this.marketConfig && (l(e, this.marketConfig) && (this.marketConfig.priceLimits = {
3134
3284
  ...this.marketConfig.priceLimits,
3135
3285
  referencePrice: e
3136
3286
  }), this.engine.requestRender());
@@ -3154,15 +3304,15 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3154
3304
  this.disposed = !0, 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.container.innerHTML = "";
3155
3305
  }
3156
3306
  createChartRenderer(e) {
3157
- let t = Wt(e, (e) => this.pluginManager.getChartType(e));
3158
- return t instanceof C && t.setPriceText((e) => this.formatPrice(e)), t;
3307
+ let t = Yt(e, (e) => this.pluginManager.getChartType(e));
3308
+ return t instanceof w && t.setPriceText((e) => this.formatPrice(e)), t;
3159
3309
  }
3160
3310
  getDisplayData() {
3161
3311
  if (this.displayDataCache) return this.displayDataCache;
3162
3312
  let e = this.dataManager.getData();
3163
3313
  if (e.length === 0) return e;
3164
- let t = Gt(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3165
- return this.chartRenderer instanceof T && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(Ht(e, this.chartTypeOptions)), this.displayDataCache = t, t;
3314
+ let t = Xt(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3315
+ return this.chartRenderer instanceof E && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(qt(e, this.chartTypeOptions)), this.displayDataCache = t, t;
3166
3316
  }
3167
3317
  recalcIndicatorsFrom(e, t) {
3168
3318
  this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
@@ -3194,7 +3344,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3194
3344
  this.viewport.setScaleBaseline(t[e]?.close);
3195
3345
  }
3196
3346
  if (n) {
3197
- let e = Nn(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
3347
+ let e = Bn(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
3198
3348
  if (e) {
3199
3349
  let t = r.priceRange, n = Math.min(t.min, e.min), i = Math.max(t.max, e.max);
3200
3350
  if (n < t.min || i > t.max) {
@@ -3218,7 +3368,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3218
3368
  fitLeftAxisWidth() {
3219
3369
  let e = this.leftViewport;
3220
3370
  if (!e) return !1;
3221
- let t = this.themeManager.getTheme(), n = sn({
3371
+ let t = this.themeManager.getTheme(), n = mn({
3222
3372
  min: e.priceRange.min,
3223
3373
  max: e.priceRange.max,
3224
3374
  lastPrice: null,
@@ -3227,12 +3377,12 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3227
3377
  fontFamily: t.font.family,
3228
3378
  fontSizeSmall: t.font.sizeSmall,
3229
3379
  measure: (e, t) => this.measureText(e, t)
3230
- }), r = cn(this.leftAxisWidth, n);
3380
+ }), r = hn(this.leftAxisWidth, n);
3231
3381
  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);
3232
3382
  }
3233
3383
  fitPriceAxisWidth() {
3234
3384
  if (!this.features.priceAxis) return !1;
3235
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = sn({
3385
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = mn({
3236
3386
  min: e.min,
3237
3387
  max: e.max,
3238
3388
  lastPrice: this.currentPriceLine.getPrice(),
@@ -3242,7 +3392,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3242
3392
  fontFamily: t.font.family,
3243
3393
  fontSizeSmall: t.font.sizeSmall,
3244
3394
  measure: (e, t) => this.measureText(e, t)
3245
- }), r = cn(this.priceAxisWidth, n);
3395
+ }), r = hn(this.priceAxisWidth, n);
3246
3396
  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);
3247
3397
  }
3248
3398
  measureText(e, t) {
@@ -3286,15 +3436,16 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3286
3436
  buildPanelRenderInfos() {
3287
3437
  if (this.panelInfoCache) return this.panelInfoCache;
3288
3438
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
3289
- 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 = {
3439
+ 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) ?? { ...Dn }, o = {
3290
3440
  x: e.rect.x,
3291
3441
  y: e.rect.y + 20,
3292
3442
  width: e.rect.width,
3293
3443
  height: Math.max(0, e.rect.height - 20)
3294
- };
3444
+ }, s = this.paneStyles.get(e.config.id);
3295
3445
  return {
3296
3446
  instanceId: e.config.id,
3297
3447
  members: this.indicatorEngine.getPaneMembers(e.config.id),
3448
+ ...s ? { style: s } : {},
3298
3449
  rect: e.rect,
3299
3450
  viewport: {
3300
3451
  ...t,
@@ -3367,7 +3518,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3367
3518
  });
3368
3519
  }
3369
3520
  drawOverlayPlugins(e, t) {
3370
- let n = dn(this.pluginManager.getOverlays(), t);
3521
+ let n = vn(this.pluginManager.getOverlays(), t);
3371
3522
  if (n.length === 0) return;
3372
3523
  let r = {
3373
3524
  viewport: this.viewport.getState(),
@@ -3378,7 +3529,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3378
3529
  }
3379
3530
  buildPriceLimits() {
3380
3531
  if (!this.marketConfig?.priceLimits?.enabled || !this.marketConfig.priceLimits.referencePrice) return null;
3381
- let e = c(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
3532
+ let e = l(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
3382
3533
  return e ? {
3383
3534
  ...e,
3384
3535
  colors: this.marketConfig.colorScheme ? {
@@ -3389,11 +3540,11 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3389
3540
  } : null;
3390
3541
  }
3391
3542
  };
3392
- function An(e) {
3543
+ function Ln(e) {
3393
3544
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
3394
3545
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
3395
3546
  i.add(e.instanceId);
3396
- let o = [e.pane, ...Object.values(e.params).map((e) => h(e)?.instanceId)];
3547
+ let o = [e.pane, ...Object.values(e.params).map((e) => g(e)?.instanceId)];
3397
3548
  for (let e of o) {
3398
3549
  let n = e ? t.get(e) : void 0;
3399
3550
  n && a(n);
@@ -3403,10 +3554,10 @@ function An(e) {
3403
3554
  for (let t of e) a(t);
3404
3555
  return n;
3405
3556
  }
3406
- function jn(e, t) {
3557
+ function Rn(e, t) {
3407
3558
  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);
3408
3559
  }
3409
- function Mn(e) {
3560
+ function zn(e) {
3410
3561
  let t = e.tagRadius;
3411
3562
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
3412
3563
  }
@@ -3416,7 +3567,7 @@ var W = new Set([
3416
3567
  "correlation",
3417
3568
  "correlationlog"
3418
3569
  ]);
3419
- function Nn(e, t) {
3570
+ function Bn(e, t) {
3420
3571
  return e ? t ? {
3421
3572
  min: Math.min(e.min, t.min),
3422
3573
  max: Math.max(e.max, t.max)
@@ -3437,8 +3588,8 @@ function G(e) {
3437
3588
  bars: e.bars
3438
3589
  };
3439
3590
  }
3440
- var Pn = 500;
3441
- function Fn(e, t) {
3591
+ var Vn = 500;
3592
+ function Hn(e, t) {
3442
3593
  let n = 0, r = e.length;
3443
3594
  for (; n < r;) {
3444
3595
  let i = n + r >> 1;
@@ -3446,20 +3597,20 @@ function Fn(e, t) {
3446
3597
  }
3447
3598
  return n;
3448
3599
  }
3449
- function In(e) {
3600
+ function Un(e) {
3450
3601
  let t = 0, n = 0;
3451
3602
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
3452
3603
  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];
3453
3604
  return [...a ? [r, i] : [i, r], [o.close, o.time]];
3454
3605
  }
3455
- function Ln(e) {
3606
+ function Wn(e) {
3456
3607
  let t = 0;
3457
3608
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
3458
3609
  return t > 0 ? t : Infinity;
3459
3610
  }
3460
- function Rn(e, t) {
3611
+ function Gn(e, t) {
3461
3612
  if (t.length === 0) return null;
3462
- let n = t[t.length - 1].time + Ln(t), r = e.filter((e) => zn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
3613
+ let n = t[t.length - 1].time + Wn(t), r = e.filter((e) => Kn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
3463
3614
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
3464
3615
  if (i.length === 0) return null;
3465
3616
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -3467,7 +3618,7 @@ function Rn(e, t) {
3467
3618
  let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
3468
3619
  return [...o, ...s];
3469
3620
  }
3470
- function zn(e) {
3621
+ function Kn(e) {
3471
3622
  return [
3472
3623
  e.time,
3473
3624
  e.open,
@@ -3476,7 +3627,7 @@ function zn(e) {
3476
3627
  e.close
3477
3628
  ].every(Number.isFinite);
3478
3629
  }
3479
- function Bn(e, t) {
3630
+ function qn(e, t) {
3480
3631
  let n = 0, r = e.length - 1;
3481
3632
  for (; n < r;) {
3482
3633
  let i = n + r + 1 >> 1;
@@ -3484,22 +3635,22 @@ function Bn(e, t) {
3484
3635
  }
3485
3636
  return n;
3486
3637
  }
3487
- function Vn(e, t, n) {
3638
+ function Jn(e, t, n) {
3488
3639
  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;
3489
3640
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
3490
3641
  return Math.max(0, a);
3491
3642
  }
3492
- function Hn(e, t, n) {
3643
+ function Yn(e, t, n) {
3493
3644
  let r = n;
3494
3645
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
3495
3646
  let i = {
3496
3647
  ...t[r],
3497
3648
  time: e.time
3498
3649
  };
3499
- for (let e = r + 1; e <= n; e++) i = Un(i, t[e]);
3650
+ for (let e = r + 1; e <= n; e++) i = Xn(i, t[e]);
3500
3651
  return i;
3501
3652
  }
3502
- function Un(e, t) {
3653
+ function Xn(e, t) {
3503
3654
  return {
3504
3655
  time: e.time,
3505
3656
  open: e.open,
@@ -3512,31 +3663,31 @@ function Un(e, t) {
3512
3663
  function K(e, t) {
3513
3664
  let n = e[e.length - 1];
3514
3665
  if (!n) return "append";
3515
- let r = m(t.time), i = m(n.time);
3666
+ let r = h(t.time), i = h(n.time);
3516
3667
  return r > i ? "append" : r === i ? "update" : "stale";
3517
3668
  }
3518
3669
  //#endregion
3519
3670
  //#region src/io/parseOHLCV.ts
3520
- var Wn = [
3671
+ var Zn = [
3521
3672
  "time",
3522
3673
  "timestamp",
3523
3674
  "date",
3524
3675
  "datetime",
3525
3676
  "t"
3526
- ], Gn = ["open", "o"], Kn = ["high", "h"], qn = ["low", "l"], Jn = ["close", "c"], Yn = [
3677
+ ], Qn = ["open", "o"], $n = ["high", "h"], er = ["low", "l"], tr = ["close", "c"], nr = [
3527
3678
  "volume",
3528
3679
  "vol",
3529
3680
  "v"
3530
3681
  ];
3531
- function Xn(e) {
3682
+ function rr(e) {
3532
3683
  let t = e.trim();
3533
- return t ? t[0] === "[" || t[0] === "{" ? Zn(t) : Qn(t) : {
3684
+ return t ? t[0] === "[" || t[0] === "{" ? ir(t) : ar(t) : {
3534
3685
  data: [],
3535
3686
  rowCount: 0,
3536
3687
  skipped: 0
3537
3688
  };
3538
3689
  }
3539
- function Zn(e) {
3690
+ function ir(e) {
3540
3691
  let t;
3541
3692
  try {
3542
3693
  t = JSON.parse(e);
@@ -3546,19 +3697,19 @@ function Zn(e) {
3546
3697
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
3547
3698
  let n = [], r = 0;
3548
3699
  for (let e of t) {
3549
- let t = Array.isArray(e) ? nr(e) : tr(e);
3700
+ let t = Array.isArray(e) ? lr(e) : cr(e);
3550
3701
  t ? n.push(t) : r++;
3551
3702
  }
3552
- return rr(n, t.length, r);
3703
+ return ur(n, t.length, r);
3553
3704
  }
3554
- function Qn(e) {
3705
+ function ar(e) {
3555
3706
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
3556
3707
  if (t.length === 0) return {
3557
3708
  data: [],
3558
3709
  rowCount: 0,
3559
3710
  skipped: 0
3560
3711
  };
3561
- let n = $n(t[0]), r = q(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? er(r) : {
3712
+ let n = or(t[0]), r = q(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? sr(r) : {
3562
3713
  time: 0,
3563
3714
  open: 1,
3564
3715
  high: 2,
@@ -3588,9 +3739,9 @@ function Qn(e) {
3588
3739
  volume: Number.isFinite(f) ? f : 0
3589
3740
  });
3590
3741
  }
3591
- return rr(o, t.length - +!!i, s);
3742
+ return ur(o, t.length - +!!i, s);
3592
3743
  }
3593
- function $n(e) {
3744
+ function or(e) {
3594
3745
  let t = {
3595
3746
  ",": 0,
3596
3747
  ";": 0,
@@ -3610,25 +3761,25 @@ function q(e, t) {
3610
3761
  }
3611
3762
  return n.push(r), n;
3612
3763
  }
3613
- function er(e) {
3764
+ function sr(e) {
3614
3765
  let t = (t) => e.findIndex((e) => t.includes(e));
3615
3766
  return {
3616
- time: t(Wn),
3617
- open: t(Gn),
3618
- high: t(Kn),
3619
- low: t(qn),
3620
- close: t(Jn),
3621
- volume: t(Yn)
3767
+ time: t(Zn),
3768
+ open: t(Qn),
3769
+ high: t($n),
3770
+ low: t(er),
3771
+ close: t(tr),
3772
+ volume: t(nr)
3622
3773
  };
3623
3774
  }
3624
- function tr(e) {
3775
+ function cr(e) {
3625
3776
  let t = (t) => {
3626
3777
  for (let n of t) {
3627
3778
  if (e[n] !== void 0) return e[n];
3628
3779
  let t = n.toUpperCase();
3629
3780
  if (e[t] !== void 0) return e[t];
3630
3781
  }
3631
- }, n = Y(String(t(Wn) ?? "")), r = Number(t(Gn)), i = Number(t(Kn)), a = Number(t(qn)), o = Number(t(Jn)), s = Number(t(Yn) ?? 0);
3782
+ }, n = Y(String(t(Zn) ?? "")), r = Number(t(Qn)), i = Number(t($n)), a = Number(t(er)), o = Number(t(tr)), s = Number(t(nr) ?? 0);
3632
3783
  return n === null || ![
3633
3784
  r,
3634
3785
  i,
@@ -3643,7 +3794,7 @@ function tr(e) {
3643
3794
  volume: Number.isFinite(s) ? s : 0
3644
3795
  };
3645
3796
  }
3646
- function nr(e) {
3797
+ function lr(e) {
3647
3798
  if (e.length < 5) return null;
3648
3799
  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;
3649
3800
  return t === null || ![
@@ -3671,7 +3822,7 @@ function Y(e) {
3671
3822
  let r = Date.parse(t);
3672
3823
  return Number.isFinite(r) ? r : null;
3673
3824
  }
3674
- function rr(e, t, n) {
3825
+ function ur(e, t, n) {
3675
3826
  e.sort((e, t) => e.time - t.time);
3676
3827
  let r = [];
3677
3828
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -3683,7 +3834,7 @@ function rr(e, t, n) {
3683
3834
  }
3684
3835
  //#endregion
3685
3836
  //#region src/io/DragDropImporter.ts
3686
- var ir = class {
3837
+ var dr = class {
3687
3838
  host;
3688
3839
  overlay = null;
3689
3840
  callbacks;
@@ -3716,7 +3867,7 @@ var ir = class {
3716
3867
  e.preventDefault(), this.depth = 0, this.hideOverlay();
3717
3868
  let t = e.dataTransfer?.files?.[0];
3718
3869
  if (t) try {
3719
- let e = Xn(await t.text());
3870
+ let e = rr(await t.text());
3720
3871
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
3721
3872
  this.callbacks.onData(e.data, e, t);
3722
3873
  } catch (e) {
@@ -3760,7 +3911,7 @@ function Z(e) {
3760
3911
  };
3761
3912
  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;
3762
3913
  }
3763
- var ar = (e, t) => t.updatedAt - e.updatedAt;
3914
+ var fr = (e, t) => t.updatedAt - e.updatedAt;
3764
3915
  function Q(e) {
3765
3916
  if (typeof e != "object" || !e) return null;
3766
3917
  let t = e;
@@ -3773,17 +3924,17 @@ function Q(e) {
3773
3924
  kind: typeof t.kind == "string" ? t.kind : void 0
3774
3925
  });
3775
3926
  }
3776
- function or(e) {
3927
+ function pr(e) {
3777
3928
  let t = Q(e), n = t ? e.content : void 0;
3778
3929
  return t && typeof n == "string" ? {
3779
3930
  ...t,
3780
3931
  content: n
3781
3932
  } : null;
3782
3933
  }
3783
- function sr(e = []) {
3934
+ function mr(e = []) {
3784
3935
  let t = new Map(e.map((e) => [e.id, { ...e }]));
3785
3936
  return {
3786
- list: () => [...t.values()].map(Z).sort(ar),
3937
+ list: () => [...t.values()].map(Z).sort(fr),
3787
3938
  load: (e) => {
3788
3939
  let n = t.get(e);
3789
3940
  return n ? { ...n } : null;
@@ -3796,7 +3947,7 @@ function sr(e = []) {
3796
3947
  }
3797
3948
  };
3798
3949
  }
3799
- function cr(e = "tcw:layouts:") {
3950
+ function hr(e = "tcw:layouts:") {
3800
3951
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
3801
3952
  let e;
3802
3953
  try {
@@ -3807,7 +3958,7 @@ function cr(e = "tcw:layouts:") {
3807
3958
  return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
3808
3959
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
3809
3960
  return {
3810
- list: () => r().sort(ar),
3961
+ list: () => r().sort(fr),
3811
3962
  load: (e) => {
3812
3963
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
3813
3964
  return t && i !== null ? {
@@ -3825,14 +3976,14 @@ function cr(e = "tcw:layouts:") {
3825
3976
  }
3826
3977
  //#endregion
3827
3978
  //#region src/state/LayoutSession.ts
3828
- var lr = 80;
3979
+ var gr = 80;
3829
3980
  function $(e) {
3830
3981
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
3831
3982
  }
3832
- function ur() {
3983
+ function _r() {
3833
3984
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
3834
3985
  }
3835
- function dr(e) {
3986
+ function vr(e) {
3836
3987
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
3837
3988
  return {
3838
3989
  id: t,
@@ -3843,7 +3994,7 @@ function dr(e) {
3843
3994
  ...o === void 0 ? {} : { kind: o }
3844
3995
  };
3845
3996
  }
3846
- var fr = class {
3997
+ var yr = class {
3847
3998
  currentLayout = null;
3848
3999
  savedContent = null;
3849
4000
  dirty = !1;
@@ -3859,7 +4010,7 @@ var fr = class {
3859
4010
  now;
3860
4011
  newId;
3861
4012
  constructor(e, t, n = {}) {
3862
- 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 ?? ur;
4013
+ 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 ?? _r;
3863
4014
  }
3864
4015
  current() {
3865
4016
  return this.currentLayout;
@@ -3889,7 +4040,7 @@ var fr = class {
3889
4040
  }
3890
4041
  open(e) {
3891
4042
  return this.queue(async () => {
3892
- let t = or(await this.storage.load(e));
4043
+ let t = pr(await this.storage.load(e));
3893
4044
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
3894
4045
  this.cancelTimer(), this.applying++;
3895
4046
  try {
@@ -3899,13 +4050,13 @@ var fr = class {
3899
4050
  } finally {
3900
4051
  this.applying--;
3901
4052
  }
3902
- return this.cancelTimer(), this.currentLayout = dr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
4053
+ return this.cancelTimer(), this.currentLayout = vr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
3903
4054
  });
3904
4055
  }
3905
4056
  rename(e, t) {
3906
4057
  let n = $(t);
3907
4058
  return n ? this.queue(async () => {
3908
- let t = or(await this.storage.load(e));
4059
+ let t = pr(await this.storage.load(e));
3909
4060
  !t || t.id !== e || (await this.storage.save({
3910
4061
  ...t,
3911
4062
  name: n
@@ -3983,7 +4134,7 @@ var fr = class {
3983
4134
  content: n.content
3984
4135
  };
3985
4136
  await this.storage.save(r);
3986
- let i = dr(r);
4137
+ let i = vr(r);
3987
4138
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
3988
4139
  }
3989
4140
  forget() {
@@ -4004,6 +4155,6 @@ var fr = class {
4004
4155
  }
4005
4156
  };
4006
4157
  //#endregion
4007
- export { Lt as C, B as S, H as _, sr as a, Xt as b, kn as c, hn as d, mn as f, dn as g, un as h, cr as i, Sn as l, pn as m, lr as n, ir as o, fn as p, $ as r, Xn as s, fr as t, gn as u, tn as v, Jt as x, Qt as y };
4158
+ export { Ht as C, B as S, H as _, mr as a, tn as b, In as c, Sn as d, xn as f, vn as g, _n as h, hr as i, kn as l, bn as m, gr as n, dr as o, yn as p, $ as r, rr as s, yr as t, Cn as u, ln as v, $t as x, rn as y };
4008
4159
 
4009
- //# sourceMappingURL=LayoutSession-2yRujs2S.js.map
4160
+ //# sourceMappingURL=LayoutSession-CiDh-H9-.js.map