@tradecanvas/chart 1.61.0 → 1.63.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 (67) hide show
  1. package/dist/Chart.d.ts +12 -0
  2. package/dist/Chart.d.ts.map +1 -1
  3. package/dist/{LayoutSession-BQvEMVYA.js → LayoutSession-B65QLG6S.js} +142 -121
  4. package/dist/LayoutSession-B65QLG6S.js.map +1 -0
  5. package/dist/LayoutSession-K38h-AF0.cjs +2 -0
  6. package/dist/LayoutSession-K38h-AF0.cjs.map +1 -0
  7. package/dist/{i18n-DJ4XwjQ1.js → i18n-D5fU6Iwy.js} +35 -1
  8. package/dist/i18n-D5fU6Iwy.js.map +1 -0
  9. package/dist/i18n-DxRoJCYV.cjs +2 -0
  10. package/dist/i18n-DxRoJCYV.cjs.map +1 -0
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/widget/ChartWidget.d.ts +4 -0
  14. package/dist/widget/ChartWidget.d.ts.map +1 -1
  15. package/dist/widget/WidgetDrawingSettings.d.ts +12 -1
  16. package/dist/widget/WidgetDrawingSettings.d.ts.map +1 -1
  17. package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
  18. package/dist/widget/WidgetSelectionToolbar.d.ts +5 -1
  19. package/dist/widget/WidgetSelectionToolbar.d.ts.map +1 -1
  20. package/dist/widget/drawingSettingsTabs.d.ts +23 -2
  21. package/dist/widget/drawingSettingsTabs.d.ts.map +1 -1
  22. package/dist/widget/index.cjs +23 -4
  23. package/dist/widget/index.cjs.map +1 -1
  24. package/dist/widget/index.js +1603 -1487
  25. package/dist/widget/index.js.map +1 -1
  26. package/dist/widget/locales/ar.d.ts.map +1 -1
  27. package/dist/widget/locales/cs.d.ts.map +1 -1
  28. package/dist/widget/locales/da.d.ts.map +1 -1
  29. package/dist/widget/locales/de.d.ts.map +1 -1
  30. package/dist/widget/locales/el.d.ts.map +1 -1
  31. package/dist/widget/locales/en.d.ts +17 -0
  32. package/dist/widget/locales/en.d.ts.map +1 -1
  33. package/dist/widget/locales/es.d.ts.map +1 -1
  34. package/dist/widget/locales/et.d.ts.map +1 -1
  35. package/dist/widget/locales/fa.d.ts.map +1 -1
  36. package/dist/widget/locales/fr.d.ts.map +1 -1
  37. package/dist/widget/locales/he.d.ts.map +1 -1
  38. package/dist/widget/locales/hu.d.ts.map +1 -1
  39. package/dist/widget/locales/id.d.ts.map +1 -1
  40. package/dist/widget/locales/index.cjs +1 -1
  41. package/dist/widget/locales/index.cjs.map +1 -1
  42. package/dist/widget/locales/index.js +477 -1
  43. package/dist/widget/locales/index.js.map +1 -1
  44. package/dist/widget/locales/it.d.ts.map +1 -1
  45. package/dist/widget/locales/ja.d.ts.map +1 -1
  46. package/dist/widget/locales/ko.d.ts.map +1 -1
  47. package/dist/widget/locales/ms.d.ts.map +1 -1
  48. package/dist/widget/locales/nb.d.ts.map +1 -1
  49. package/dist/widget/locales/nl.d.ts.map +1 -1
  50. package/dist/widget/locales/pl.d.ts.map +1 -1
  51. package/dist/widget/locales/pt.d.ts.map +1 -1
  52. package/dist/widget/locales/ro.d.ts.map +1 -1
  53. package/dist/widget/locales/ru.d.ts.map +1 -1
  54. package/dist/widget/locales/sk.d.ts.map +1 -1
  55. package/dist/widget/locales/sv.d.ts.map +1 -1
  56. package/dist/widget/locales/th.d.ts.map +1 -1
  57. package/dist/widget/locales/tr.d.ts.map +1 -1
  58. package/dist/widget/locales/vi.d.ts.map +1 -1
  59. package/dist/widget/locales/zh.d.ts.map +1 -1
  60. package/dist/widget/locales/zhHant.d.ts.map +1 -1
  61. package/package.json +3 -3
  62. package/dist/LayoutSession-BQvEMVYA.js.map +0 -1
  63. package/dist/LayoutSession-CbcTJnyw.cjs +0 -2
  64. package/dist/LayoutSession-CbcTJnyw.cjs.map +0 -1
  65. package/dist/i18n-BWqZTNzQ.cjs +0 -2
  66. package/dist/i18n-BWqZTNzQ.cjs.map +0 -1
  67. package/dist/i18n-DJ4XwjQ1.js.map +0 -1
@@ -1515,8 +1515,13 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 24;
1515
1515
  function Gr(e) {
1516
1516
  return e.length > 0 ? { renames: e } : {};
1517
1517
  }
1518
- var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set(["verticalLine", "crossLine"]), Xr = class {
1519
- static version = "1.61.0";
1518
+ var Kr = 20, qr = 8, Jr = 10, Yr = {
1519
+ ArrowLeft: [-1, 0],
1520
+ ArrowRight: [1, 0],
1521
+ ArrowUp: [0, -1],
1522
+ ArrowDown: [0, 1]
1523
+ }, Xr = new Set(["horizontalLine", "crossLine"]), Zr = new Set(["verticalLine", "crossLine"]), Qr = class {
1524
+ static version = "1.63.0";
1520
1525
  engine;
1521
1526
  viewport;
1522
1527
  series = new Bn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
@@ -1769,7 +1774,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
1769
1774
  color: t.sessionBreaks.color,
1770
1775
  lineStyle: t.sessionBreaks.lineStyle,
1771
1776
  lineWidth: t.sessionBreaks.lineWidth
1772
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new Oe(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Qe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = S(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(ni(t.shapes)), t.font && this.themeManager.setFont(ti(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ue({
1777
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new Oe(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Qe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = S(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(ii(t.shapes)), t.font && this.themeManager.setFont(ri(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ue({
1773
1778
  scrollBars: (e) => {
1774
1779
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1775
1780
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1811,6 +1816,10 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
1811
1816
  e.preventDefault(), this.a11y.readBar(e.key === "." ? 1 : -1);
1812
1817
  return;
1813
1818
  }
1819
+ if (this.nudgeSelectedDrawings(e)) {
1820
+ e.preventDefault();
1821
+ return;
1822
+ }
1814
1823
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1815
1824
  }
1816
1825
  }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ke(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new pe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(Nt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
@@ -2187,7 +2196,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
2187
2196
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
2188
2197
  }
2189
2198
  setShapes(e) {
2190
- let t = ni(e);
2199
+ let t = ii(e);
2191
2200
  t.tagRadius !== void 0 && (this.themeManager.setShape({
2192
2201
  ...this.themeManager.getTheme().shape,
2193
2202
  ...t
@@ -2199,7 +2208,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
2199
2208
  setFont(e) {
2200
2209
  if (e === null) this.themeManager.setFont(null);
2201
2210
  else {
2202
- let t = ti(e);
2211
+ let t = ri(e);
2203
2212
  if (Object.keys(t).length === 0) return;
2204
2213
  this.themeManager.setFont(t);
2205
2214
  }
@@ -2683,6 +2692,18 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
2683
2692
  removeDrawings(e) {
2684
2693
  return this.drawingManager.removeDrawings(e);
2685
2694
  }
2695
+ nudgeSelectedDrawings(e) {
2696
+ let t = Yr[e.key];
2697
+ if (!t || !this.features.drawings || e.ctrlKey || e.metaKey || e.altKey) return !1;
2698
+ let n = e.shiftKey ? Jr : 1, r = {
2699
+ ...this.viewport.getState(),
2700
+ data: this.getDisplayData()
2701
+ };
2702
+ return this.drawingManager.nudge(t[0] * n, t[1] * n, r);
2703
+ }
2704
+ takeBackDrawing(e) {
2705
+ this.features.drawings && (this.drawingManager.takeBack(e), this.markStateChanged());
2706
+ }
2686
2707
  removeAll(e = "all") {
2687
2708
  return this.undoRedoManager.group(() => {
2688
2709
  let t = e === "indicators" ? 0 : this.removeDrawings(this.getDrawings().map((e) => e.id)), n = e === "drawings" ? [] : this.getActiveIndicators().map((e) => e.instanceId);
@@ -3946,7 +3967,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
3946
3967
  let t = this.replaySession ? this.replayOffset : 0;
3947
3968
  if (!this.replaySession) {
3948
3969
  if (this.series.length() === 0) return;
3949
- this.series.beginReplay(), this.replaySession = ui(this.currentSymbol);
3970
+ this.series.beginReplay(), this.replaySession = fi(this.currentSymbol);
3950
3971
  }
3951
3972
  let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
3952
3973
  c.animate = c.animate === !0;
@@ -3957,13 +3978,13 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
3957
3978
  let m = r ? this.replayStepsOver(n, p, !0) : null;
3958
3979
  this.options.autoScale = !0, this.buildReplay(p, m, f);
3959
3980
  let h = this.replayStepsSeries;
3960
- h && c.startIndex !== void 0 && (c.startIndex = yi(h, p, c.startIndex));
3981
+ h && c.startIndex !== void 0 && (c.startIndex = xi(h, p, c.startIndex));
3961
3982
  let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
3962
3983
  this.revealReplayMarks(this.replayRevealMarks ? _?.time ?? null : null), n.held && (n.held.state = c.paused ? "paused" : "playing", c.paused = !0), !c.paused && c.startIndex !== void 0 && c.startIndex >= 1 && this.replaySeek(c.startIndex - 1), this.replayManager.play(c);
3963
3984
  }
3964
3985
  buildReplay(e, t, n) {
3965
3986
  let r = this.replaySession?.animate === !0, i = r ? null : t;
3966
- this.replayPieces = r && t ? Si(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
3987
+ this.replayPieces = r && t ? wi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
3967
3988
  let a = this.replayRestarting;
3968
3989
  this.replayRestarting = !0;
3969
3990
  try {
@@ -3977,7 +3998,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
3977
3998
  let n = t, a = e[t];
3978
3999
  if (i) {
3979
4000
  let r = i[t];
3980
- n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? wi(c, r) : bi(e[n], i, t), a = xi(i, e, t, n) ? e[n] : c;
4001
+ n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? Ei(c, r) : Si(e[n], i, t), a = Ci(i, e, t, n) ? e[n] : c;
3981
4002
  }
3982
4003
  let u = this.replayForming;
3983
4004
  this.replayForming = null, s = t;
@@ -4001,7 +4022,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4001
4022
  });
4002
4023
  }), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
4003
4024
  if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
4004
- let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = Ci() ? Mr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = jr(r, i);
4025
+ let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = Ti() ? Mr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = jr(r, i);
4005
4026
  a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
4006
4027
  index: t,
4007
4028
  path: r
@@ -4011,7 +4032,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4011
4032
  drawFormingBar(e, t, n, r) {
4012
4033
  this.currentPriceLine.setPrice(e.close, t);
4013
4034
  let i = this.series.bars();
4014
- if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !oi.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
4035
+ if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !ci.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
4015
4036
  this.scheduleRender();
4016
4037
  return;
4017
4038
  }
@@ -4026,7 +4047,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4026
4047
  if (!n) return;
4027
4048
  n.evictBefore(e[t].time);
4028
4049
  let r = this.replayManager.getStepMs();
4029
- n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(ai / r) : 1);
4050
+ n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(si / r) : 1);
4030
4051
  }
4031
4052
  useReplayLoader(e, t) {
4032
4053
  let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Fr(e.step, r, (e) => j(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
@@ -4057,8 +4078,8 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4057
4078
  if (o.time > s) {
4058
4079
  let a = Y(e, s);
4059
4080
  e[a]?.time === s && i.fedFraction < 1 && c.push(...q(this.replayPathOf(e, a), i.fedFraction, 1));
4060
- let o = e.slice(X(e, s), t), l = Math.ceil(o.length / gi);
4061
- for (let e = 0; e < o.length; e += l) c.push(..._i(o.slice(e, e + l)));
4081
+ let o = e.slice(X(e, s), t), l = Math.ceil(o.length / vi);
4082
+ for (let e = 0; e < o.length; e += l) c.push(...yi(o.slice(e, e + l)));
4062
4083
  c.push(...q(n, -1, r));
4063
4084
  } else c.push(...q(n, i.fedFraction, r));
4064
4085
  i.fedTime = o.time, i.fedFraction = r;
@@ -4077,7 +4098,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4077
4098
  if (n.length === 0) return;
4078
4099
  let r = t.windowTime === null ? 0 : Math.min(Y(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
4079
4100
  this.useReplayLoader(t, !1);
4080
- let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : pi(o ?? i, t.until);
4101
+ let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : hi(o ?? i, t.until);
4081
4102
  if (s < 0 && this.canPageBackForReplay(t)) {
4082
4103
  this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
4083
4104
  return;
@@ -4085,7 +4106,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4085
4106
  let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
4086
4107
  l || (t.held = null), t.symbol = this.currentSymbol;
4087
4108
  let d = this.replayManager.remainingMs();
4088
- this.clearBarHolders(), t.animate && fi(t, this.replayCoarse, i);
4109
+ this.clearBarHolders(), t.animate && mi(t, this.replayCoarse, i);
4089
4110
  let f = this.replayRestarting;
4090
4111
  this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
4091
4112
  try {
@@ -4108,14 +4129,14 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4108
4129
  }
4109
4130
  replayStepsOver(e, t, n = !1) {
4110
4131
  if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
4111
- let r = vi(this.series.inHoursShown(e.steps), t);
4112
- return r && (n || hi(r, t)) ? r : null;
4132
+ let r = bi(this.series.inHoursShown(e.steps), t);
4133
+ return r && (n || _i(r, t)) ? r : null;
4113
4134
  }
4114
4135
  canPageBackForReplay(e) {
4115
- return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < si;
4136
+ return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < li;
4116
4137
  }
4117
4138
  async pageBackForReplay(e) {
4118
- this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = si, this.rebaseReplay("older"));
4139
+ this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = li, this.rebaseReplay("older"));
4119
4140
  }
4120
4141
  holdReplay() {
4121
4142
  let e = this.replaySession;
@@ -4148,7 +4169,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4148
4169
  this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
4149
4170
  }
4150
4171
  replaySeekToTime(e) {
4151
- !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, pi(this.replayStepsSeries ?? this.replayCoarse, e)));
4172
+ !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, hi(this.replayStepsSeries ?? this.replayCoarse, e)));
4152
4173
  }
4153
4174
  feedReplayPrice(e, t) {
4154
4175
  let n = this.executionAdapter;
@@ -4170,8 +4191,8 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4170
4191
  if (i.time <= n.fedTime) return;
4171
4192
  let a = e.slice(X(e, n.fedTime), t + 1);
4172
4193
  n.fedTime = i.time;
4173
- let o = Math.ceil(a.length / gi);
4174
- for (let e = 0; e < a.length; e += o) for (let [t, n] of _i(a.slice(e, e + o))) r.setMarkPrice(t, n);
4194
+ let o = Math.ceil(a.length / vi);
4195
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of yi(a.slice(e, e + o))) r.setMarkPrice(t, n);
4175
4196
  this.tradingManager.setCurrentPrice(i.close);
4176
4197
  }
4177
4198
  getReplayBarIndex() {
@@ -4182,7 +4203,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4182
4203
  }
4183
4204
  replaySeekToBar(e) {
4184
4205
  let t = this.replayStepsSeries;
4185
- this.replaySeek(t && this.replayCoarse ? yi(t, this.replayCoarse, e) : e);
4206
+ this.replaySeek(t && this.replayCoarse ? xi(t, this.replayCoarse, e) : e);
4186
4207
  }
4187
4208
  replayPause() {
4188
4209
  this.setHeldState("paused") || this.replayManager.pause();
@@ -4223,7 +4244,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4223
4244
  let t = Ut(e.time, n), r = Rt(e.price, n);
4224
4245
  i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
4225
4246
  }
4226
- return Jr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Yr.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
4247
+ return Xr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Zr.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
4227
4248
  x: i,
4228
4249
  y: o,
4229
4250
  width: a - i,
@@ -4272,14 +4293,14 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4272
4293
  });
4273
4294
  }
4274
4295
  restoreIndicators(e, t) {
4275
- let n = Zr(e), r = /* @__PURE__ */ new Map();
4296
+ let n = $r(e), r = /* @__PURE__ */ new Map();
4276
4297
  this.unrestoredIndicators = [];
4277
4298
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
4278
4299
  if (t) {
4279
4300
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
4280
4301
  for (let n of t) {
4281
4302
  let t = e.get(n.instanceId);
4282
- t && Qr(n, t) && o.add(n.instanceId);
4303
+ t && ei(n, t) && o.add(n.instanceId);
4283
4304
  }
4284
4305
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
4285
4306
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -4703,7 +4724,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4703
4724
  }
4704
4725
  fitPriceScale(e, t) {
4705
4726
  if (e.length === 0) return;
4706
- let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = ii(ii(m(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && ri(e, n, r) ? this.volumeRenderer.getHeightRatio() + Hr : O;
4727
+ let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = oi(oi(m(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && ai(e, n, r) ? this.volumeRenderer.getHeightRatio() + Hr : O;
4707
4728
  this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
4708
4729
  top: a,
4709
4730
  bottom: O
@@ -4760,9 +4781,9 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4760
4781
  }
4761
4782
  measureText(e, t) {
4762
4783
  let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
4763
- if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => $r(n, e, t));
4784
+ if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => ti(n, e, t));
4764
4785
  let i = n ?? this.detachedMeasureContext();
4765
- return i ? $r(i, e, t) : e.length * 7;
4786
+ return i ? ti(i, e, t) : e.length * 7;
4766
4787
  }
4767
4788
  detachedMeasureContext() {
4768
4789
  return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
@@ -4909,7 +4930,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4909
4930
  };
4910
4931
  }
4911
4932
  };
4912
- function Zr(e) {
4933
+ function $r(e) {
4913
4934
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
4914
4935
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
4915
4936
  i.add(e.instanceId);
@@ -4923,19 +4944,19 @@ function Zr(e) {
4923
4944
  for (let t of e) a(t);
4924
4945
  return n;
4925
4946
  }
4926
- function Qr(e, t) {
4947
+ function ei(e, t) {
4927
4948
  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);
4928
4949
  }
4929
- function $r(e, t, n) {
4950
+ function ti(e, t, n) {
4930
4951
  let r = e.font;
4931
4952
  e.font = n;
4932
4953
  let i = e.measureText(t).width;
4933
4954
  return e.font = r, i;
4934
4955
  }
4935
- var ei = 300;
4936
- function ti(e) {
4956
+ var ni = 300;
4957
+ function ri(e) {
4937
4958
  let t = {}, n = e.family;
4938
- typeof n == "string" && n.trim() !== "" && n.length <= ei && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4959
+ typeof n == "string" && n.trim() !== "" && n.length <= ni && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4939
4960
  for (let n of [
4940
4961
  "sizeSmall",
4941
4962
  "sizeMedium",
@@ -4946,15 +4967,15 @@ function ti(e) {
4946
4967
  }
4947
4968
  return t;
4948
4969
  }
4949
- function ni(e) {
4970
+ function ii(e) {
4950
4971
  let t = e.tagRadius;
4951
4972
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
4952
4973
  }
4953
- function ri(e, t, n) {
4974
+ function ai(e, t, n) {
4954
4975
  for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
4955
4976
  return !1;
4956
4977
  }
4957
- function ii(e, t) {
4978
+ function oi(e, t) {
4958
4979
  return e ? t ? {
4959
4980
  min: Math.min(e.min, t.min),
4960
4981
  max: Math.max(e.max, t.max)
@@ -4975,14 +4996,14 @@ function J(e) {
4975
4996
  bars: e.bars
4976
4997
  };
4977
4998
  }
4978
- var ai = 8e3, oi = new Set([
4999
+ var si = 8e3, ci = new Set([
4979
5000
  "candlestick",
4980
5001
  "line",
4981
5002
  "area",
4982
5003
  "bar",
4983
5004
  "hollowCandle"
4984
- ]), si = 10, ci = 50, li = .001;
4985
- function ui(e) {
5005
+ ]), li = 10, ui = 50, di = .001;
5006
+ function fi(e) {
4986
5007
  return {
4987
5008
  price: null,
4988
5009
  fedTime: null,
@@ -4997,41 +5018,41 @@ function ui(e) {
4997
5018
  held: null
4998
5019
  };
4999
5020
  }
5000
- function di(e, t) {
5021
+ function pi(e, t) {
5001
5022
  let n = e[t + 1];
5002
5023
  return n ? n.time - e[t].time : Z(e);
5003
5024
  }
5004
- function fi(e, t, n) {
5025
+ function mi(e, t, n) {
5005
5026
  let r = e.fedTime;
5006
5027
  if (r === null || !t || t.length === 0 || n.length === 0) return;
5007
- let i = di(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
5028
+ let i = pi(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
5008
5029
  if (s > a) return;
5009
- let c = di(n, o);
5030
+ let c = pi(n, o);
5010
5031
  if (a === s && o > 0) {
5011
5032
  e.fedTime = n[o - 1].time, e.fedFraction = 1;
5012
5033
  return;
5013
5034
  }
5014
5035
  e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
5015
5036
  }
5016
- function pi(e, t) {
5037
+ function hi(e, t) {
5017
5038
  let n = X(e, t), r = e.length - 1;
5018
5039
  return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
5019
5040
  }
5020
- function mi(e) {
5041
+ function gi(e) {
5021
5042
  let t = Infinity;
5022
5043
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
5023
5044
  return t;
5024
5045
  }
5025
- function hi(e, t) {
5026
- if (!(mi(e) < mi(t))) return !1;
5027
- let n = Math.max(0, e.length - ci);
5046
+ function _i(e, t) {
5047
+ if (!(gi(e) < gi(t))) return !1;
5048
+ let n = Math.max(0, e.length - ui);
5028
5049
  for (let r = n; r < e.length; r++) {
5029
- let n = t[Q(t, e[r].time)], i = (n.high - n.low) * li + 2 ** -52;
5050
+ let n = t[Q(t, e[r].time)], i = (n.high - n.low) * di + 2 ** -52;
5030
5051
  if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
5031
5052
  }
5032
5053
  return !0;
5033
5054
  }
5034
- var gi = 500;
5055
+ var vi = 500;
5035
5056
  function Y(e, t) {
5036
5057
  let n = 0, r = e.length;
5037
5058
  for (; n < r;) {
@@ -5048,7 +5069,7 @@ function X(e, t) {
5048
5069
  }
5049
5070
  return n;
5050
5071
  }
5051
- function _i(e) {
5072
+ function yi(e) {
5052
5073
  let t = 0, n = 0;
5053
5074
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
5054
5075
  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];
@@ -5059,7 +5080,7 @@ function Z(e) {
5059
5080
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
5060
5081
  return t > 0 ? t : Infinity;
5061
5082
  }
5062
- function vi(e, t) {
5083
+ function bi(e, t) {
5063
5084
  if (t.length === 0) return null;
5064
5085
  let n = t[t.length - 1].time + Z(t), r = e.filter((e) => zn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
5065
5086
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
@@ -5077,26 +5098,26 @@ function Q(e, t) {
5077
5098
  }
5078
5099
  return n;
5079
5100
  }
5080
- function yi(e, t, n) {
5101
+ function xi(e, t, n) {
5081
5102
  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;
5082
5103
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
5083
5104
  return Math.max(0, a);
5084
5105
  }
5085
- function bi(e, t, n) {
5106
+ function Si(e, t, n) {
5086
5107
  let r = n;
5087
5108
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
5088
5109
  let i = {
5089
5110
  ...t[r],
5090
5111
  time: e.time
5091
5112
  };
5092
- for (let e = r + 1; e <= n; e++) i = wi(i, t[e]);
5113
+ for (let e = r + 1; e <= n; e++) i = Ei(i, t[e]);
5093
5114
  return i;
5094
5115
  }
5095
- function xi(e, t, n, r) {
5116
+ function Ci(e, t, n, r) {
5096
5117
  let i = e[n + 1], a = t[r + 1];
5097
5118
  return i !== void 0 && a !== void 0 && i.time >= a.time;
5098
5119
  }
5099
- function Si(e, t) {
5120
+ function wi(e, t) {
5100
5121
  let n = /* @__PURE__ */ new Map();
5101
5122
  for (let r of e) {
5102
5123
  let e = t[Q(t, r.time)].time, i = n.get(e);
@@ -5104,10 +5125,10 @@ function Si(e, t) {
5104
5125
  }
5105
5126
  return n;
5106
5127
  }
5107
- function Ci() {
5128
+ function Ti() {
5108
5129
  return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
5109
5130
  }
5110
- function wi(e, t) {
5131
+ function Ei(e, t) {
5111
5132
  return {
5112
5133
  time: e.time,
5113
5134
  open: e.open,
@@ -5119,26 +5140,26 @@ function wi(e, t) {
5119
5140
  }
5120
5141
  //#endregion
5121
5142
  //#region src/io/parseOHLCV.ts
5122
- var Ti = [
5143
+ var Di = [
5123
5144
  "time",
5124
5145
  "timestamp",
5125
5146
  "date",
5126
5147
  "datetime",
5127
5148
  "t"
5128
- ], Ei = ["open", "o"], Di = ["high", "h"], Oi = ["low", "l"], ki = ["close", "c"], Ai = [
5149
+ ], Oi = ["open", "o"], ki = ["high", "h"], Ai = ["low", "l"], ji = ["close", "c"], Mi = [
5129
5150
  "volume",
5130
5151
  "vol",
5131
5152
  "v"
5132
5153
  ];
5133
- function ji(e) {
5154
+ function Ni(e) {
5134
5155
  let t = e.trim();
5135
- return t ? t[0] === "[" || t[0] === "{" ? Mi(t) : Ni(t) : {
5156
+ return t ? t[0] === "[" || t[0] === "{" ? Pi(t) : Fi(t) : {
5136
5157
  data: [],
5137
5158
  rowCount: 0,
5138
5159
  skipped: 0
5139
5160
  };
5140
5161
  }
5141
- function Mi(e) {
5162
+ function Pi(e) {
5142
5163
  let t;
5143
5164
  try {
5144
5165
  t = JSON.parse(e);
@@ -5148,19 +5169,19 @@ function Mi(e) {
5148
5169
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
5149
5170
  let n = [], r = 0;
5150
5171
  for (let e of t) {
5151
- let t = Array.isArray(e) ? Ri(e) : Li(e);
5172
+ let t = Array.isArray(e) ? Bi(e) : zi(e);
5152
5173
  t ? n.push(t) : r++;
5153
5174
  }
5154
- return Bi(n, t.length, r);
5175
+ return Hi(n, t.length, r);
5155
5176
  }
5156
- function Ni(e) {
5177
+ function Fi(e) {
5157
5178
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
5158
5179
  if (t.length === 0) return {
5159
5180
  data: [],
5160
5181
  rowCount: 0,
5161
5182
  skipped: 0
5162
5183
  };
5163
- let n = Pi(t[0]), r = Fi(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ii(r) : {
5184
+ let n = Ii(t[0]), r = Li(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ri(r) : {
5164
5185
  time: 0,
5165
5186
  open: 1,
5166
5187
  high: 2,
@@ -5171,7 +5192,7 @@ function Ni(e) {
5171
5192
  if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
5172
5193
  let o = [], s = 0;
5173
5194
  for (let e = +!!i; e < t.length; e++) {
5174
- let r = Fi(t[e], n), i = zi(r[a.time]), c = $(r[a.open]), l = $(r[a.high]), u = $(r[a.low]), d = $(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
5195
+ let r = Li(t[e], n), i = Vi(r[a.time]), c = $(r[a.open]), l = $(r[a.high]), u = $(r[a.low]), d = $(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
5175
5196
  if (i === null || ![
5176
5197
  c,
5177
5198
  l,
@@ -5190,9 +5211,9 @@ function Ni(e) {
5190
5211
  volume: Number.isFinite(f) ? f : 0
5191
5212
  });
5192
5213
  }
5193
- return Bi(o, t.length - +!!i, s);
5214
+ return Hi(o, t.length - +!!i, s);
5194
5215
  }
5195
- function Pi(e) {
5216
+ function Ii(e) {
5196
5217
  let t = {
5197
5218
  ",": 0,
5198
5219
  ";": 0,
@@ -5204,7 +5225,7 @@ function Pi(e) {
5204
5225
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
5205
5226
  return n;
5206
5227
  }
5207
- function Fi(e, t) {
5228
+ function Li(e, t) {
5208
5229
  let n = [], r = "", i = !1;
5209
5230
  for (let a = 0; a < e.length; a++) {
5210
5231
  let o = e[a];
@@ -5212,25 +5233,25 @@ function Fi(e, t) {
5212
5233
  }
5213
5234
  return n.push(r), n;
5214
5235
  }
5215
- function Ii(e) {
5236
+ function Ri(e) {
5216
5237
  let t = (t) => e.findIndex((e) => t.includes(e));
5217
5238
  return {
5218
- time: t(Ti),
5219
- open: t(Ei),
5220
- high: t(Di),
5221
- low: t(Oi),
5222
- close: t(ki),
5223
- volume: t(Ai)
5239
+ time: t(Di),
5240
+ open: t(Oi),
5241
+ high: t(ki),
5242
+ low: t(Ai),
5243
+ close: t(ji),
5244
+ volume: t(Mi)
5224
5245
  };
5225
5246
  }
5226
- function Li(e) {
5247
+ function zi(e) {
5227
5248
  let t = (t) => {
5228
5249
  for (let n of t) {
5229
5250
  if (e[n] !== void 0) return e[n];
5230
5251
  let t = n.toUpperCase();
5231
5252
  if (e[t] !== void 0) return e[t];
5232
5253
  }
5233
- }, n = zi(String(t(Ti) ?? "")), r = Number(t(Ei)), i = Number(t(Di)), a = Number(t(Oi)), o = Number(t(ki)), s = Number(t(Ai) ?? 0);
5254
+ }, n = Vi(String(t(Di) ?? "")), r = Number(t(Oi)), i = Number(t(ki)), a = Number(t(Ai)), o = Number(t(ji)), s = Number(t(Mi) ?? 0);
5234
5255
  return n === null || ![
5235
5256
  r,
5236
5257
  i,
@@ -5245,9 +5266,9 @@ function Li(e) {
5245
5266
  volume: Number.isFinite(s) ? s : 0
5246
5267
  };
5247
5268
  }
5248
- function Ri(e) {
5269
+ function Bi(e) {
5249
5270
  if (e.length < 5) return null;
5250
- let t = zi(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
5271
+ let t = Vi(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;
5251
5272
  return t === null || ![
5252
5273
  n,
5253
5274
  r,
@@ -5265,7 +5286,7 @@ function Ri(e) {
5265
5286
  function $(e) {
5266
5287
  return e === void 0 || e.trim() === "" ? NaN : Number(e);
5267
5288
  }
5268
- function zi(e) {
5289
+ function Vi(e) {
5269
5290
  let t = e.trim();
5270
5291
  if (!t) return null;
5271
5292
  let n = Number(t);
@@ -5273,7 +5294,7 @@ function zi(e) {
5273
5294
  let r = Date.parse(t);
5274
5295
  return Number.isFinite(r) ? r : null;
5275
5296
  }
5276
- function Bi(e, t, n) {
5297
+ function Hi(e, t, n) {
5277
5298
  e.sort((e, t) => e.time - t.time);
5278
5299
  let r = [];
5279
5300
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -5285,7 +5306,7 @@ function Bi(e, t, n) {
5285
5306
  }
5286
5307
  //#endregion
5287
5308
  //#region src/io/DragDropImporter.ts
5288
- var Vi = class {
5309
+ var Ui = class {
5289
5310
  host;
5290
5311
  overlay = null;
5291
5312
  callbacks;
@@ -5306,19 +5327,19 @@ var Vi = class {
5306
5327
  this.host.removeEventListener("dragenter", this.bound.dragenter), this.host.removeEventListener("dragover", this.bound.dragover), this.host.removeEventListener("dragleave", this.bound.dragleave), this.host.removeEventListener("drop", this.bound.drop), this.hideOverlay();
5307
5328
  }
5308
5329
  onDragEnter(e) {
5309
- Hi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5330
+ Wi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5310
5331
  }
5311
5332
  onDragOver(e) {
5312
- Hi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5333
+ Wi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5313
5334
  }
5314
5335
  onDragLeave(e) {
5315
- Hi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5336
+ Wi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5316
5337
  }
5317
5338
  async onDrop(e) {
5318
5339
  e.preventDefault(), this.depth = 0, this.hideOverlay();
5319
5340
  let t = e.dataTransfer?.files?.[0];
5320
5341
  if (t) try {
5321
- let e = ji(await t.text());
5342
+ let e = Ni(await t.text());
5322
5343
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
5323
5344
  this.callbacks.onData(e.data, e, t);
5324
5345
  } catch (e) {
@@ -5349,12 +5370,12 @@ var Vi = class {
5349
5370
  this.overlay?.remove(), this.overlay = null;
5350
5371
  }
5351
5372
  };
5352
- function Hi(e) {
5373
+ function Wi(e) {
5353
5374
  return e.dataTransfer?.types?.includes("Files") ?? !1;
5354
5375
  }
5355
5376
  //#endregion
5356
5377
  //#region src/state/layoutStorage.ts
5357
- function Ui(e) {
5378
+ function Gi(e) {
5358
5379
  let t = {
5359
5380
  id: e.id,
5360
5381
  name: e.name,
@@ -5362,11 +5383,11 @@ function Ui(e) {
5362
5383
  };
5363
5384
  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;
5364
5385
  }
5365
- var Wi = (e, t) => t.updatedAt - e.updatedAt;
5366
- function Gi(e) {
5386
+ var Ki = (e, t) => t.updatedAt - e.updatedAt;
5387
+ function qi(e) {
5367
5388
  if (typeof e != "object" || !e) return null;
5368
5389
  let t = e;
5369
- return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Ui({
5390
+ return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Gi({
5370
5391
  id: t.id,
5371
5392
  name: t.name,
5372
5393
  updatedAt: t.updatedAt,
@@ -5375,17 +5396,17 @@ function Gi(e) {
5375
5396
  kind: typeof t.kind == "string" ? t.kind : void 0
5376
5397
  });
5377
5398
  }
5378
- function Ki(e) {
5379
- let t = Gi(e), n = t ? e.content : void 0;
5399
+ function Ji(e) {
5400
+ let t = qi(e), n = t ? e.content : void 0;
5380
5401
  return t && typeof n == "string" ? {
5381
5402
  ...t,
5382
5403
  content: n
5383
5404
  } : null;
5384
5405
  }
5385
- function qi(e = []) {
5406
+ function Yi(e = []) {
5386
5407
  let t = new Map(e.map((e) => [e.id, { ...e }]));
5387
5408
  return {
5388
- list: () => [...t.values()].map(Ui).sort(Wi),
5409
+ list: () => [...t.values()].map(Gi).sort(Ki),
5389
5410
  load: (e) => {
5390
5411
  let n = t.get(e);
5391
5412
  return n ? { ...n } : null;
@@ -5398,7 +5419,7 @@ function qi(e = []) {
5398
5419
  }
5399
5420
  };
5400
5421
  }
5401
- function Ji(e = "tcw:layouts:") {
5422
+ function Xi(e = "tcw:layouts:") {
5402
5423
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
5403
5424
  let e;
5404
5425
  try {
@@ -5406,10 +5427,10 @@ function Ji(e = "tcw:layouts:") {
5406
5427
  } catch {
5407
5428
  return [];
5408
5429
  }
5409
- return Array.isArray(e) ? e.map(Gi).filter((e) => e !== null) : [];
5430
+ return Array.isArray(e) ? e.map(qi).filter((e) => e !== null) : [];
5410
5431
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
5411
5432
  return {
5412
- list: () => r().sort(Wi),
5433
+ list: () => r().sort(Ki),
5413
5434
  load: (e) => {
5414
5435
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
5415
5436
  return t && i !== null ? {
@@ -5418,7 +5439,7 @@ function Ji(e = "tcw:layouts:") {
5418
5439
  } : null;
5419
5440
  },
5420
5441
  save: (e) => {
5421
- localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Ui(e)]);
5442
+ localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Gi(e)]);
5422
5443
  },
5423
5444
  remove: (e) => {
5424
5445
  i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
@@ -5427,14 +5448,14 @@ function Ji(e = "tcw:layouts:") {
5427
5448
  }
5428
5449
  //#endregion
5429
5450
  //#region src/state/LayoutSession.ts
5430
- var Yi = 80;
5431
- function Xi(e) {
5451
+ var Zi = 80;
5452
+ function Qi(e) {
5432
5453
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
5433
5454
  }
5434
- function Zi() {
5455
+ function $i() {
5435
5456
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
5436
5457
  }
5437
- function Qi(e) {
5458
+ function ea(e) {
5438
5459
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
5439
5460
  return {
5440
5461
  id: t,
@@ -5445,7 +5466,7 @@ function Qi(e) {
5445
5466
  ...o === void 0 ? {} : { kind: o }
5446
5467
  };
5447
5468
  }
5448
- var $i = class {
5469
+ var ta = class {
5449
5470
  currentLayout = null;
5450
5471
  savedContent = null;
5451
5472
  dirty = !1;
@@ -5461,7 +5482,7 @@ var $i = class {
5461
5482
  now;
5462
5483
  newId;
5463
5484
  constructor(e, t, n = {}) {
5464
- this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? Zi;
5485
+ 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 ?? $i;
5465
5486
  }
5466
5487
  current() {
5467
5488
  return this.currentLayout;
@@ -5477,7 +5498,7 @@ var $i = class {
5477
5498
  }
5478
5499
  async list() {
5479
5500
  let e = await this.storage.list();
5480
- return Array.isArray(e) ? e.map(Gi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5501
+ return Array.isArray(e) ? e.map(qi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5481
5502
  }
5482
5503
  save() {
5483
5504
  return this.queue(() => {
@@ -5486,12 +5507,12 @@ var $i = class {
5486
5507
  });
5487
5508
  }
5488
5509
  saveAs(e) {
5489
- let t = Xi(e);
5510
+ let t = Qi(e);
5490
5511
  return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
5491
5512
  }
5492
5513
  open(e) {
5493
5514
  return this.queue(async () => {
5494
- let t = Ki(await this.storage.load(e));
5515
+ let t = Ji(await this.storage.load(e));
5495
5516
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
5496
5517
  this.cancelTimer(), this.applying++;
5497
5518
  try {
@@ -5501,13 +5522,13 @@ var $i = class {
5501
5522
  } finally {
5502
5523
  this.applying--;
5503
5524
  }
5504
- return this.cancelTimer(), this.currentLayout = Qi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5525
+ return this.cancelTimer(), this.currentLayout = ea(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5505
5526
  });
5506
5527
  }
5507
5528
  rename(e, t) {
5508
- let n = Xi(t);
5529
+ let n = Qi(t);
5509
5530
  return n ? this.queue(async () => {
5510
- let t = Ki(await this.storage.load(e));
5531
+ let t = Ji(await this.storage.load(e));
5511
5532
  !t || t.id !== e || (await this.storage.save({
5512
5533
  ...t,
5513
5534
  name: n
@@ -5585,7 +5606,7 @@ var $i = class {
5585
5606
  content: n.content
5586
5607
  };
5587
5608
  await this.storage.save(r);
5588
- let i = Qi(r);
5609
+ let i = ea(r);
5589
5610
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
5590
5611
  }
5591
5612
  forget() {
@@ -5606,6 +5627,6 @@ var $i = class {
5606
5627
  }
5607
5628
  };
5608
5629
  //#endregion
5609
- export { Wn as C, B as D, R as E, dn as O, qn as S, V as T, dr as _, qi as a, G as b, Xr as c, Pr as d, Fr as f, ur as g, fr as h, Ji as i, Rr as l, pr as m, Yi as n, Vi as o, mr as p, Xi as r, ji as s, $i as t, Lr as u, cr as v, Hn as w, Qn as x, lr as y };
5630
+ export { Wn as C, B as D, R as E, dn as O, qn as S, V as T, dr as _, Yi as a, G as b, Qr as c, Pr as d, Fr as f, ur as g, fr as h, Xi as i, Rr as l, pr as m, Zi as n, Ui as o, mr as p, Qi as r, Ni as s, ta as t, Lr as u, cr as v, Hn as w, Qn as x, lr as y };
5610
5631
 
5611
- //# sourceMappingURL=LayoutSession-BQvEMVYA.js.map
5632
+ //# sourceMappingURL=LayoutSession-B65QLG6S.js.map