@sheetxl/sdk 0.4.7 → 0.4.9

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 (105) hide show
  1. package/browser/cjs/{CTgAiNQSJWKDXtSb.cjs → B-re3P7cjOaJW97v.cjs} +1 -1
  2. package/browser/cjs/{CpQaIOppX0XX2vDs.cjs → B4xf1YLqOOQ2BAAw.cjs} +1 -1
  3. package/browser/cjs/{C7jcUOUYJ2X1723F.cjs → BQX47jn1fcYJXavn.cjs} +1 -1
  4. package/browser/cjs/{CFDfrZYpwJRAnqAR.cjs → BZSt5E8X7SYSVhPs.cjs} +1 -1
  5. package/browser/cjs/{BWBs6iqfyZ0GsJE4.cjs → B_RNceQBZ8p6fj3Q.cjs} +1 -1
  6. package/browser/cjs/{DGdXny4PhjplfkC8.cjs → BbwQg7G0IFkXlUYY.cjs} +1 -1
  7. package/browser/cjs/BjwfHgXl1fEZAU3g.cjs +60 -0
  8. package/browser/cjs/{Cq8C2sU4L0DDq1nt.cjs → Bm5UJ5gS-Q06VEPK.cjs} +3 -3
  9. package/browser/cjs/{DCE0ThfupHz4dExl.cjs → C3td5E8SlcrJ5Mv-.cjs} +2 -2
  10. package/browser/cjs/{DxHxLHgNLyk4kHII.cjs → CGHOtBonLRy9pyo4.cjs} +1 -1
  11. package/browser/cjs/{6d3bcsuz9iJTDGvt.cjs → CS2JAHasZYfPuOEI.cjs} +1 -1
  12. package/browser/cjs/{BlL2UupE4BH4n7lH.cjs → CSkIIY8fgAYcsfJ0.cjs} +1 -1
  13. package/browser/cjs/{rN4aMEc1eBkMR2xM.cjs → CTM9G6roqBNmXvvV.cjs} +1 -1
  14. package/browser/cjs/{BF03tNf6FACTW2M1.cjs → Cje8OteEkSLIh4eg.cjs} +1 -1
  15. package/browser/cjs/{CKAWSQ-n6UNHU-hc.cjs → CnRawGcFEjRg8E7W.cjs} +1 -1
  16. package/browser/cjs/{C8dCjjzUV8qwdDyY.cjs → Cq-KGEktCK47S1ii.cjs} +1 -1
  17. package/browser/cjs/{DHWkQl03P54-vXOf.cjs → CqczY8H5IIx8Ki4Z.cjs} +1 -1
  18. package/browser/cjs/{7hsXTISvYl_-AEI4.cjs → DLVyZuPozs2kGRVY.cjs} +1 -1
  19. package/browser/cjs/{DHgtrwpUI5XOg7d1.cjs → DQtLMWxJks5D1_ut.cjs} +1 -1
  20. package/browser/cjs/{Dqu2WvbX6a1aE5xC.cjs → DSeBxJODV2wiVBFh.cjs} +1 -1
  21. package/browser/cjs/{tW5W8i2ldWqC6qS6.cjs → DSx2MKFyVvU32PBX.cjs} +1 -1
  22. package/browser/cjs/{DBiTStWkvXPR682m.cjs → DlgBYRYQwJb2Cmz0.cjs} +2 -2
  23. package/browser/cjs/{BqIfUTtyJpRLQeBh.cjs → DmMxyZPbvj8EvAvA.cjs} +1 -1
  24. package/browser/cjs/{CTaWGldoSi20ppOB.cjs → DxXvv5mYl4GyI4oU.cjs} +2 -2
  25. package/browser/cjs/{D_Fa302YxFJsewFt.cjs → K35RWj2GxR0lKfCY.cjs} +4 -4
  26. package/browser/cjs/{BpSDBJvAuyi5MV4H.cjs → L5ui83i8s4hwRnmo.cjs} +1 -1
  27. package/browser/cjs/{Dbd52SpYjQAQQ5Lc.cjs → Ntd4n6__drNXyV8Q.cjs} +1 -1
  28. package/browser/cjs/{BJ4lmW1HbLGZjqYu.cjs → OpVs8OmX1WcXQ1RU.cjs} +1 -1
  29. package/browser/cjs/{DwKQDFaICO4XJiQP.cjs → WZhB_pgRZi4U_oXo.cjs} +1 -1
  30. package/browser/cjs/{jFKQv7BqosgG5wqZ.cjs → eL9bgEPz6WhChraJ.cjs} +1 -1
  31. package/browser/cjs/index.cjs +2 -2
  32. package/browser/cjs/{DywksQ9WhhEXRisJ.cjs → nRRE57j_GGf6KVD8.cjs} +2 -2
  33. package/browser/cjs/{DsrvFA9fg9a6po6E.cjs → pPmY7gcYQCH96lE4.cjs} +1 -1
  34. package/browser/cjs/{C0WJFEDJ-cCWjcBd.cjs → xjh_alRipVqo8cZy.cjs} +4 -4
  35. package/browser/esm/{CyJTPCg49Ayb10Cc.mjs → -vEyF-b1iAJfL3xp.mjs} +1 -1
  36. package/{node/esm/DWBtRi2bSzC5jB9g.mjs → browser/esm/225JOcHgUUs1EIBP.mjs} +1 -1
  37. package/{node/esm/D5KVTjr2EmlbSlqA.mjs → browser/esm/6U_gCZNSSMBtVpQI.mjs} +1 -1
  38. package/browser/esm/{fIysOOIiYgNN68HE.mjs → 9sdhSM-1zkdTJ6pD.mjs} +2 -2
  39. package/browser/esm/{C2eLT-S7YabeVmqP.mjs → B5GEE2P8-Fc2ApiM.mjs} +2 -2
  40. package/browser/esm/{hN_K8NeXpcz4iPIv.mjs → BEWDCb-GzXXALTyM.mjs} +1 -1
  41. package/browser/esm/{CLLoQxyOJ_Z7Gds5.mjs → BMWawWgFuxMRf1cM.mjs} +1 -1
  42. package/browser/esm/{03v5sl7XOndtoL-G.mjs → BRW_h-uc47yzfnF7.mjs} +1 -1
  43. package/browser/esm/{MnEtIp1GtVYvlTrd.mjs → BhPXhyivX9t4qJ2l.mjs} +2 -2
  44. package/{node/esm/DlqGesRjfLTrJKgg.mjs → browser/esm/Br12zSs0kOLavLkw.mjs} +1 -1
  45. package/browser/esm/{PHTLYFNEcFRTTZjW.mjs → BsN1Iav913PM0DTb.mjs} +1 -1
  46. package/browser/esm/{C_DwMCFSMcWnoIwK.mjs → C8aGSiCyYUCLobsp.mjs} +1 -1
  47. package/{node/esm/BuI-yMlpUfw49Oow.mjs → browser/esm/CT933Kus8lsY5BJ2.mjs} +1 -1
  48. package/{node/esm/CwtNIBfb8cQFnon9.mjs → browser/esm/CYI5_V7h9SYP9uuu.mjs} +1 -1
  49. package/browser/esm/{C-RoZoZhc8t772TX.mjs → CatWZ5LT2Nm4rT4U.mjs} +1 -1
  50. package/browser/esm/{BrAZxLRrSyV8ELMx.mjs → Cu1bjUPEdAVn7e23.mjs} +1 -1
  51. package/browser/esm/{CxESS_8aLfFd9BEQ.mjs → CydkHy4FDohjJzxv.mjs} +1 -1
  52. package/browser/esm/{CwIOLGhRJdAkKIOi.mjs → CzRlLyr7iG0quh7r.mjs} +4 -4
  53. package/browser/esm/{BaLZyV45yCbQaBfM.mjs → DStq39R2rKQKUU7b.mjs} +1 -1
  54. package/browser/esm/{BqQiq-XS5D-JTJst.mjs → DbT42LuoRjjQ7Rtu.mjs} +3 -3
  55. package/browser/esm/{L-B0MJe7T_mxt531.mjs → DdU01D1n6S9BZnIr.mjs} +1 -1
  56. package/{node/esm/5OOhquvuSSvB_Sz_.mjs → browser/esm/De2OxC60SZUNAEyp.mjs} +1 -1
  57. package/{node/esm/DL2DtlHAUZJnDDoc.mjs → browser/esm/DtJRjSTG45Z8JwZ-.mjs} +1 -1
  58. package/browser/esm/{ClUbKXbYfZrM1bNQ.mjs → DwOgeqVyZwdrw1FB.mjs} +4327 -4281
  59. package/browser/esm/{CDUTOpO9dpto60rs.mjs → HTu8yzgCTwbf9HU4.mjs} +2 -2
  60. package/browser/esm/{BSRIjPNiFI9MHx6a.mjs → LpwVK3fzNuCZJlGb.mjs} +1 -1
  61. package/browser/esm/{DqYD7Pwq-h0AXxGK.mjs → PC3F5BEQCLQN_a3x.mjs} +1 -1
  62. package/browser/esm/{DmwpX7Xjg27xsk_1.mjs → P_0pzZ_mRTUIQOo8.mjs} +1 -1
  63. package/{node/esm/CdrNW0JQ0yB-SxC_.mjs → browser/esm/SwZDnMDw8b9gb6VD.mjs} +1 -1
  64. package/browser/esm/{DlAY6wqiiIdu-6y8.mjs → _N05nCCXsyDthwPS.mjs} +1 -1
  65. package/browser/esm/{CO8ll5ptWPRWdrBE.mjs → cthDTk2_8Syhe1Uh.mjs} +1 -1
  66. package/browser/esm/{B8vhsfmKZSvo8-oA.mjs → eYXmF3L6pehVXEBJ.mjs} +4 -4
  67. package/browser/esm/index.mjs +2 -2
  68. package/browser/esm/{C87kLt3HvlVAz0bj.mjs → leTtDbQ6871lFfJe.mjs} +1 -1
  69. package/licenses/dependencies.txt +3 -3
  70. package/node/esm/{CyJTPCg49Ayb10Cc.mjs → -vEyF-b1iAJfL3xp.mjs} +1 -1
  71. package/{browser/esm/DWBtRi2bSzC5jB9g.mjs → node/esm/225JOcHgUUs1EIBP.mjs} +1 -1
  72. package/{browser/esm/D5KVTjr2EmlbSlqA.mjs → node/esm/6U_gCZNSSMBtVpQI.mjs} +1 -1
  73. package/node/esm/{hN_K8NeXpcz4iPIv.mjs → BEWDCb-GzXXALTyM.mjs} +1 -1
  74. package/node/esm/{ss0E0ImKqaM9PLnb.mjs → BIsxN-sskhnDr5fG.mjs} +1 -1
  75. package/node/esm/{BmzTjZEMiIi2QZIs.mjs → BMwuCJEUqdaa7U-p.mjs} +1 -1
  76. package/node/esm/{03v5sl7XOndtoL-G.mjs → BRW_h-uc47yzfnF7.mjs} +1 -1
  77. package/{browser/esm/DlqGesRjfLTrJKgg.mjs → node/esm/Br12zSs0kOLavLkw.mjs} +1 -1
  78. package/{browser/esm/BuI-yMlpUfw49Oow.mjs → node/esm/CT933Kus8lsY5BJ2.mjs} +1 -1
  79. package/{browser/esm/CwtNIBfb8cQFnon9.mjs → node/esm/CYI5_V7h9SYP9uuu.mjs} +1 -1
  80. package/node/esm/{C-RoZoZhc8t772TX.mjs → CatWZ5LT2Nm4rT4U.mjs} +1 -1
  81. package/node/esm/{DLttoMNI6LnfLYIB.mjs → CswjcUAc3OQ1SAwa.mjs} +2 -2
  82. package/node/esm/{BBD0A_0vMQBc5mWv.mjs → Cu9r1uru0-RQmPlz.mjs} +1 -1
  83. package/node/esm/{CxESS_8aLfFd9BEQ.mjs → CydkHy4FDohjJzxv.mjs} +1 -1
  84. package/node/esm/{C4NjlVoV7QIf6GXJ.mjs → D6NZZinV6uCFvvPK.mjs} +3 -3
  85. package/node/esm/{DrcP55cxxwmtG7Uh.mjs → D8eFLYgEWXBVLJzP.mjs} +1 -1
  86. package/node/esm/{DDGFRI84LyOAkEas.mjs → DRFDJvGYzZ2y7MNr.mjs} +1 -1
  87. package/node/esm/{Cn0XhtLpVXC_K8BX.mjs → DU-md5cmoqIFoIRF.mjs} +2 -2
  88. package/node/esm/{CyGm4o8Xmfc3zuf2.mjs → DYiuMNxXQxzsyogd.mjs} +1 -1
  89. package/{browser/esm/5OOhquvuSSvB_Sz_.mjs → node/esm/De2OxC60SZUNAEyp.mjs} +1 -1
  90. package/node/esm/{mDWB8qemoaxtXCCC.mjs → Dfr8q3AEbG7QZ6Xr.mjs} +1 -1
  91. package/{browser/esm/DL2DtlHAUZJnDDoc.mjs → node/esm/DtJRjSTG45Z8JwZ-.mjs} +1 -1
  92. package/node/esm/{BoCo_XZSaWnYUyEw.mjs → Dtn71I8yWx6At8T4.mjs} +1 -1
  93. package/node/esm/{DvbJ0OGEPM6DQezz.mjs → DxQdDzIhBW98FzK0.mjs} +4 -4
  94. package/node/esm/{BSRIjPNiFI9MHx6a.mjs → LpwVK3fzNuCZJlGb.mjs} +1 -1
  95. package/node/esm/{DmwpX7Xjg27xsk_1.mjs → P_0pzZ_mRTUIQOo8.mjs} +1 -1
  96. package/{browser/esm/CdrNW0JQ0yB-SxC_.mjs → node/esm/SwZDnMDw8b9gb6VD.mjs} +1 -1
  97. package/node/esm/{DUsv5RuDBTtak99P.mjs → V08nP8uFHLrde5Md.mjs} +1 -1
  98. package/node/esm/{DlAY6wqiiIdu-6y8.mjs → _N05nCCXsyDthwPS.mjs} +1 -1
  99. package/node/esm/{BYbj39ttSAs0ZbP5.mjs → bLL4P-mQqtHnzf3p.mjs} +1 -1
  100. package/node/esm/{DRS_JwYa09Hf895m.mjs → bz-ja27axdBXn18A.mjs} +2 -2
  101. package/node/esm/index.mjs +377 -331
  102. package/package.json +4 -4
  103. package/types/index.d.ts +31 -4
  104. package/types/scripting.d.ts +35 -6
  105. package/browser/cjs/qaXx7XlwJvmixvMF.cjs +0 -60
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.4.7
2
+ * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.4.9
3
3
  *
4
4
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
@@ -1630,13 +1630,13 @@ class fe extends ae {
1630
1630
  }
1631
1631
  const pe = () => {
1632
1632
  try {
1633
- return "0.4.7";
1633
+ return "0.4.9";
1634
1634
  } catch (t5) {
1635
1635
  return "";
1636
1636
  }
1637
1637
  }, _e = () => {
1638
1638
  try {
1639
- return "Wed Aug 06 2025";
1639
+ return "Thu Aug 07 2025";
1640
1640
  } catch (t5) {
1641
1641
  return "";
1642
1642
  }
@@ -10869,8 +10869,8 @@ class Jm {
10869
10869
  toDate() {
10870
10870
  return this._t !== s.Number ? null : this._rs ? this.getNumberFormat().asDate : null;
10871
10871
  }
10872
- toText() {
10873
- return this.getNumberFormat().displayText;
10872
+ toText(t5) {
10873
+ return this.getNumberFormat(t5).displayText;
10874
10874
  }
10875
10875
  toTextUnformatted(t5) {
10876
10876
  if (t5) {
@@ -14174,7 +14174,7 @@ class t_ {
14174
14174
  async _initialize() {
14175
14175
  const t5 = await Fe._validate(true), e2 = n_();
14176
14176
  this._calcScope = e2, this._runtime = new e_(this._options, t5);
14177
- const { initializeBuiltIns: n2 } = await import("./DLttoMNI6LnfLYIB.mjs"), r2 = this;
14177
+ const { initializeBuiltIns: n2 } = await import("./CswjcUAc3OQ1SAwa.mjs"), r2 = this;
14178
14178
  return this._builtInFunctions = Object.freeze(n2(() => r2)), { builtInFunctions: this._builtInFunctions, calcScope: this._calcScope };
14179
14179
  }
14180
14180
  getBuiltInFunctions() {
@@ -14347,7 +14347,7 @@ class e_ {
14347
14347
  }
14348
14348
  getVersion() {
14349
14349
  try {
14350
- const t5 = "0.4.7";
14350
+ const t5 = "0.4.9";
14351
14351
  if (-1 === t5.indexOf(".env.")) return `${t5}`;
14352
14352
  } catch (t5) {
14353
14353
  return "local";
@@ -14872,7 +14872,7 @@ class R_ extends El {
14872
14872
  this._context = r2;
14873
14873
  const o2 = await r2._initialize(), s2 = o2.builtInFunctions;
14874
14874
  this._functions = new I_({ transactions: this._transactions, context: r2, readonlyFunctions: s2 });
14875
- const i2 = await import("./CyGm4o8Xmfc3zuf2.mjs");
14875
+ const i2 = await import("./DYiuMNxXQxzsyogd.mjs");
14876
14876
  this._formulaParser = new i2.FormulaParser(), this._scope = o2.calcScope, this._status = dp.Status.Ready, this._emitter.notify("onStatusChange"), this._emitter.notify("onReady");
14877
14877
  } catch (t5) {
14878
14878
  throw this._status = dp.Status.Off, this._emitter.notify("onError", t5), this._emitter.notify("onStatusChange"), t5;
@@ -15849,7 +15849,7 @@ class eS {
15849
15849
  if (this._closed) throw new Error(Sl);
15850
15850
  if (!t5) throw new Error(K_);
15851
15851
  if (!t5.getName || "string" == typeof t5) throw new Error("Add must take a 'INamed' object. To add a string use 'addReference'.");
15852
- this._validateName(t5.getName(), t5.getScope(), false);
15852
+ if (this._validateName(t5.getName(), t5.getScope(), false), this._options.isReadOnly?.()) throw new Error("Names are read-only.");
15853
15853
  const e2 = this._beginCommit(`Insert Named Item '${t5.getName()}'`), n2 = this._add([t5]);
15854
15854
  if (null === n2) return e2.rollback(), null;
15855
15855
  const r2 = n2.itemsByKey.get(t5.getName().toLowerCase());
@@ -17768,7 +17768,7 @@ class HS {
17768
17768
  }
17769
17769
  }
17770
17770
  async function VS() {
17771
- const { getCrypto: t5 } = await import("./BBD0A_0vMQBc5mWv.mjs");
17771
+ const { getCrypto: t5 } = await import("./Cu9r1uru0-RQmPlz.mjs");
17772
17772
  return t5();
17773
17773
  }
17774
17774
  const GS = async (t5, e2, ...n2) => {
@@ -17828,10 +17828,12 @@ class qS {
17828
17828
  }
17829
17829
  }
17830
17830
  class JS {
17831
- constructor(t5) {
17832
- this._emitter = null, this._emitter = new yl(this), this.fromJSON(t5);
17831
+ constructor(t5, e2 = false) {
17832
+ this._emitter = null, this._emitter = new yl(this), this.fromJSON(t5), this._isReadOnly = e2;
17833
17833
  }
17834
17834
  async lock(t5, e2, n2, r2) {
17835
+ if (this._isReadOnly) return this;
17836
+ if (this.isLocked() && !this._isPaused) throw new Error("Cannot lock an already locked object. Use unlock first.");
17835
17837
  try {
17836
17838
  this._validatePassword();
17837
17839
  } catch (t6) {
@@ -17845,6 +17847,7 @@ class JS {
17845
17847
  return t5 = t5 ?? {}, this._updateProperties(t5), this._properties = t5, this._password = o2, this._emitter.notify("onLockChange"), this._emitter.notify("onChange"), this;
17846
17848
  }
17847
17849
  async unlock(t5) {
17850
+ if (this._isReadOnly) throw new Error("Cannot unlock a readonly workbook.");
17848
17851
  return await this._validatePassword(t5), this._clearProperties(), this._password = null, this._identities = null, this._password = null, this._emitter.notify("onLockChange"), this._emitter.notify("onChange"), this;
17849
17852
  }
17850
17853
  checkPassword(t5) {
@@ -17865,6 +17868,9 @@ class JS {
17865
17868
  isLocked() {
17866
17869
  return null !== this._properties && !this._isPaused;
17867
17870
  }
17871
+ isReadOnly() {
17872
+ return this._isReadOnly;
17873
+ }
17868
17874
  async _validatePassword(t5) {
17869
17875
  const e2 = this._password;
17870
17876
  if (!(t5 && 0 !== t5.length || e2 && e2.hash)) return true;
@@ -17876,6 +17882,7 @@ class JS {
17876
17882
  return this._properties;
17877
17883
  }
17878
17884
  _isPropertyAllowed(t5) {
17885
+ if (this._isReadOnly) return false;
17879
17886
  if (!this.isLocked()) return true;
17880
17887
  const e2 = this._properties[t5];
17881
17888
  return "boolean" == typeof e2 && e2;
@@ -18566,14 +18573,14 @@ const sw = () => [];
18566
18573
  let iw = 0;
18567
18574
  class aw {
18568
18575
  constructor(t5) {
18569
- this._lastTransactionUUID = null, this._emitter = null, this._initializing = true, this._emitterMovables = null, this._rangesListenerSorted = null, this._lastCellDecoded = { address: null, coords: null }, this._lastCellSelected = { coords: null, cell: null }, this._lastCellRead = { coords: null, cell: null }, this._lastValueRead = { range: null, isDateOrTime: null }, this._lastGetRangeRead = {}, this._lastUsedCoordsRead = { coords: null, range: null }, this._lastActiveRead = { selection: null, range: null, ranges: null }, this._lastRangeRead = { address: null, range: null, ranges: null }, this._isDataColumn = true, this._isDate1904 = false, this._colHeaders = null, this._colHeadersShiftCallback = null, this._colHeadersListener = null, this._colHeadersRemoveListener = null, this._rowHeaders = null, this._rowHeadersShiftCallback = null, this._rowHeadersListener = null, this._rowHeadersRemoveListener = null, this._initialized = false, this._closed = false;
18576
+ this._lastTransactionUUID = null, this._emitter = null, this._initializing = true, this._emitterMovables = null, this._rangesListenerSorted = null, this._lastCellDecoded = { address: null, coords: null }, this._lastCellSelected = { coords: null, cell: null }, this._lastCellRead = { coords: null, cell: null }, this._lastValueRead = { range: null, isDateOrTime: null }, this._lastGetRangeRead = {}, this._lastUsedCoordsRead = { coords: null, range: null }, this._lastActiveRead = { selection: null, range: null, ranges: null }, this._lastRangeRead = { address: null, range: null, ranges: null }, this._isDataColumn = true, this._isDate1904 = false, this._colHeaders = null, this._colHeadersShiftCallback = null, this._colHeadersListener = null, this._colHeadersRemoveListener = null, this._rowHeaders = null, this._rowHeadersShiftCallback = null, this._rowHeadersListener = null, this._rowHeadersRemoveListener = null, this._closed = false;
18570
18577
  const e2 = Object.freeze({ ...t5 });
18571
18578
  Fe._validate(true), this._transactions = e2.transactions ?? new ue(), this._ownTransactions = !e2.transactions;
18572
18579
  const n2 = this._beginCommit({ description: "New Sheet" }), r2 = this;
18573
18580
  try {
18574
18581
  this._entireCoords = Object.freeze({ colStart: 0, rowStart: 0, colEnd: (e2.maxColumns ?? QS) - 1, rowEnd: (e2.maxRows ?? tw) - 1 }), this._strings = e2.strings ?? new hp(), this._ownStrings = !e2.strings;
18575
18582
  const t6 = e2.styles ?? new rp();
18576
- this._styles = t6, this._ownStyles = !e2.styles, this._names = e2.names ?? new eS({ addressToRanges: (t7) => r2.getRanges(t7), getCurrentScope: () => r2.getName(), transactions: r2._transactions }), this._ownNames = !e2.names, this._namesRemoveListener = this._names.addListeners({ onCollectionChange: (t7) => {
18583
+ this._styles = t6, this._ownStyles = !e2.styles, this._names = e2.names ?? new eS({ addressToRanges: (t7) => r2.getRanges(t7), getCurrentScope: () => r2.getName(), isReadOnly: () => r2._options.readonly ?? false, transactions: r2._transactions }), this._ownNames = !e2.names, this._namesRemoveListener = this._names.addListeners({ onCollectionChange: (t7) => {
18577
18584
  r2._calculateFull();
18578
18585
  } }, { transactional: false }), this._calculation = e2.calculation ?? new R_({ getNamed: (t7, e3) => {
18579
18586
  lw.address = t7, lw.scope = e3;
@@ -18618,6 +18625,7 @@ class aw {
18618
18625
  _createRange(t5, e2, n2 = null) {
18619
18626
  if (!t5) return gf(this, this._entireCoords);
18620
18627
  if (this._validateCoords(t5), this._closed) return gf(null, this._entireCoords, t5);
18628
+ null === n2 && this._options.readonly && (n2 = "Readonly sheet");
18621
18629
  let r2 = null;
18622
18630
  return (e2 || n2) && (r2 = { getOptions: e2, readOnly: n2 }), new ZS(((t6) => {
18623
18631
  if (!t6) return null;
@@ -18627,7 +18635,7 @@ class aw {
18627
18635
  }
18628
18636
  _createRanges(t5, e2, n2 = null) {
18629
18637
  let r2 = null;
18630
- return (e2 || n2) && (r2 = { getOptions: e2, readOnly: n2 }), new YS(t5, this, r2);
18638
+ return null === n2 && this._options.readonly && (n2 = "Readonly sheet"), (e2 || n2) && (r2 = { getOptions: e2, readOnly: n2 }), new YS(t5, this, r2);
18631
18639
  }
18632
18640
  getRange(t5, e2) {
18633
18641
  let n2 = !e2 && t5 && (void 0 !== t5.rowStart || "string" == typeof t5);
@@ -18683,16 +18691,17 @@ class aw {
18683
18691
  _createRangeError(t5) {
18684
18692
  return t5 ? new Error(Pu) : new Error(Hu(t5));
18685
18693
  }
18686
- _protectionCheck(t5 = null, e2 = null) {
18694
+ _protectionCheck(t5 = null, e2 = null, n2 = null) {
18687
18695
  if (t5 && this._closed) return;
18696
+ if (!this._initializing && this._options.readonly) throw new Error(((t6 = "update") => `Unable to ${t6}, this sheet is readonly.`)(n2));
18688
18697
  e2 && !Array.isArray(e2) && (e2 = [e2]);
18689
- const n2 = t5(e2), r2 = this.getProtection(), o2 = r2?.getProperties();
18690
- if (o2) {
18691
- if (0 === n2.length) throw new Error(nd);
18692
- if (n2) {
18693
- const t6 = n2.length;
18698
+ const r2 = t5(e2), o2 = this.getProtection(), s2 = o2?.getProperties();
18699
+ if (s2) {
18700
+ if (0 === r2.length) throw new Error(nd);
18701
+ if (r2) {
18702
+ const t6 = r2.length;
18694
18703
  for (let e3 = 0; e3 < t6; e3++) {
18695
- if (true !== r2[n2[e3]]) throw new Error(rd());
18704
+ if (true !== o2[r2[e3]]) throw new Error(rd());
18696
18705
  }
18697
18706
  }
18698
18707
  }
@@ -18843,41 +18852,67 @@ class aw {
18843
18852
  const h2 = s2 || !t5?.ignoreEmptyIntersections;
18844
18853
  let u2 = t5.includeRangeTypes;
18845
18854
  true === u2 && (u2 = Qu);
18846
- const d2 = u2 ? this._rangeStateIterator({ bounds: n2, orientation: r2, reverse: o2, includeRangeTypes: u2, excludeHidden: t5.excludeHidden, byCell: true }) : Tl, g2 = e2?.cellValuesGrid ?? null;
18847
- let m2 = g2 ? g2.entries(a2) : Tl, f2 = m2.next(), p2 = null, _2 = null, S2 = null;
18848
- f2.done || (p2 = f2.value[0], _2 = f2.value[1]);
18849
- let w2 = d2.next(), y2 = null;
18850
- const E2 = r2 !== i.Orientation.Row;
18851
- let b2;
18852
- const C2 = Y.createCellComparator(r2, o2);
18855
+ const d2 = this._getState().contentfulSpatial, g2 = u2 ? this._rangeStateIterator({ bounds: n2, orientation: r2, reverse: o2, includeRangeTypes: u2, excludeHidden: t5.excludeHidden, byCell: true }) : Tl, m2 = t5?.includeMergeOverflow ?? false, f2 = e2?.cellValuesGrid ?? null;
18856
+ let p2 = f2 ? f2.entries(a2) : Tl, _2 = p2.next(), S2 = null, w2 = null, y2 = null;
18857
+ _2.done || (S2 = _2.value[0], w2 = _2.value[1]);
18858
+ let E2 = g2.next(), b2 = null;
18859
+ const C2 = r2 !== i.Orientation.Row;
18853
18860
  let v2;
18854
- if (!w2.done) {
18855
- const t6 = w2.value;
18856
- v2 = t6.start, y2 = t6.intersection;
18861
+ const x2 = Y.createCellComparator(r2, o2);
18862
+ let I2;
18863
+ if (!E2.done) {
18864
+ const t6 = E2.value;
18865
+ I2 = t6.start, b2 = t6.intersection;
18857
18866
  }
18858
- b2 = (t6) => {
18867
+ v2 = (t6) => {
18859
18868
  let e3 = null, n3 = null, r3 = null, o3 = false, s3 = false;
18860
- if (p2 && v2) {
18861
- const t7 = C2(p2, v2);
18862
- t7 < 0 ? (e3 = p2, n3 = _2, o3 = true) : t7 > 0 ? (e3 = v2, r3 = y2, s3 = true) : (e3 = p2, n3 = _2, r3 = y2, o3 = true, s3 = true);
18863
- } else if (p2) e3 = p2, n3 = _2, o3 = true;
18869
+ if (S2 && I2) {
18870
+ const t7 = x2(S2, I2);
18871
+ t7 < 0 ? (e3 = S2, n3 = w2, o3 = true) : t7 > 0 ? (e3 = I2, r3 = b2, s3 = true) : (e3 = S2, n3 = w2, r3 = b2, o3 = true, s3 = true);
18872
+ } else if (S2) e3 = S2, n3 = w2, o3 = true;
18864
18873
  else {
18865
- if (!v2 || !h2) return Ml;
18866
- e3 = v2, r3 = y2, s3 = true;
18874
+ if (!I2 || !h2) return Ml;
18875
+ e3 = I2, r3 = b2, s3 = true;
18867
18876
  }
18868
- if (o3 && (f2 = m2.next(), f2.done ? p2 = null : (p2 = f2.value[0], _2 = f2.value[1])), s3) {
18869
- const t7 = h2 ? void 0 : p2;
18870
- if (w2 = d2.next(t7), w2.done) v2 = null, y2 = null;
18877
+ if (o3 && (_2 = p2.next(), _2.done ? S2 = null : (S2 = _2.value[0], w2 = _2.value[1])), s3) {
18878
+ const t7 = h2 ? void 0 : S2;
18879
+ if (E2 = g2.next(t7), E2.done) I2 = null, b2 = null;
18871
18880
  else {
18872
- const t8 = w2.value;
18873
- v2 = t8.cell, y2 = t8.intersection;
18881
+ const t8 = E2.value;
18882
+ I2 = t8.cell, b2 = t8.intersection;
18883
+ }
18884
+ }
18885
+ let i2 = false;
18886
+ const a3 = e3.rowIndex, l3 = e3.colIndex;
18887
+ C2 || (i2 = a3 === y2?.rowIndex);
18888
+ let c3 = false;
18889
+ C2 || (c3 = a3 === S2?.rowIndex);
18890
+ let u3 = null;
18891
+ if (i2) u3 = y2;
18892
+ else if (m2 && !y2) {
18893
+ ww.rowStart = a3, ww.rowEnd = a3, ww.colStart = l3 - 5, ww.colEnd = l3 - 1;
18894
+ const t7 = d2.search(ww, false);
18895
+ if (t7.length > 0) {
18896
+ t7.sort(Y.columnFirstRangeComparator);
18897
+ const e4 = t7[t7.length - 1];
18898
+ u3 = { colIndex: e4.colStart, rowIndex: e4.rowStart };
18899
+ }
18900
+ }
18901
+ let f3 = null;
18902
+ if (c3) f3 = S2;
18903
+ else if (m2 && !S2) {
18904
+ ww.colStart = l3 + 1, ww.rowStart = a3, ww.colEnd = l3 + 5, ww.rowEnd = a3;
18905
+ const t7 = d2.search(ww, false);
18906
+ if (t7.length > 0) {
18907
+ t7.sort(Y.columnFirstRangeComparator);
18908
+ const e4 = t7[0];
18909
+ f3 = { colIndex: e4.colStart, rowIndex: e4.rowStart };
18874
18910
  }
18875
18911
  }
18876
- const i2 = E2 ? null : e3.rowIndex === S2?.rowIndex, a3 = E2 ? null : e3.rowIndex === p2?.rowIndex, l3 = { done: false, value: [e3, n3, r3, i2 ? S2 : null, a3 ? p2 : null] };
18877
- return o3 && (S2 = e3), l3;
18912
+ return o3 && (y2 = e3), { done: false, value: [e3, n3, r3, u3, f3] };
18878
18913
  };
18879
- let x2 = { next: b2, return: (t6) => null, throw: (t6) => null };
18880
- return s2 && (x2 = new Pc(x2, a2)), x2;
18914
+ let R2 = { next: v2, return: (t6) => null, throw: (t6) => null };
18915
+ return s2 && (R2 = new Pc(R2, a2)), R2;
18881
18916
  }
18882
18917
  _indexMerges(t5, e2 = null) {
18883
18918
  if (!(t5 && 0 !== t5.length || e2 && 0 !== e2.length)) return;
@@ -18905,18 +18940,19 @@ class aw {
18905
18940
  this._updateState({ mergeSpatial: o2 }), r2.commit();
18906
18941
  }
18907
18942
  _updateStyles(t5, e2, n2, r2 = false) {
18908
- this._protectionCheck(() => ["formatCells"], t5);
18909
- const o2 = this._beginCommit({ description: n2?.description ?? "Update Style" }), s2 = If(t5);
18943
+ const o2 = n2?.description ?? "Update Style";
18944
+ this._protectionCheck(() => ["formatCells"], t5, o2);
18945
+ const s2 = this._beginCommit({ description: o2 }), i2 = If(t5);
18910
18946
  try {
18911
- const i2 = this._getState();
18912
- if (!i2) return bt.EmptyArray;
18913
- const a2 = i2.directStyleSpatial, l2 = o2.getId(), c2 = a2.clone(l2);
18914
- let h2 = i2.continuousFillSpatial;
18947
+ const o3 = this._getState();
18948
+ if (!o3) return bt.EmptyArray;
18949
+ const a2 = o3.directStyleSpatial, l2 = s2.getId(), c2 = a2.clone(l2);
18950
+ let h2 = o3.continuousFillSpatial;
18915
18951
  const u2 = !h2.isEmpty();
18916
18952
  let d2 = null;
18917
18953
  const g2 = this._styles, m2 = t5.length;
18918
18954
  for (let n3 = 0; n3 < m2; n3++) {
18919
- const o3 = (t6, e3) => {
18955
+ const o4 = (t6, e3) => {
18920
18956
  let n4 = null;
18921
18957
  const r3 = mm(0, e3, () => {
18922
18958
  if (n4) return n4;
@@ -18924,11 +18960,11 @@ class aw {
18924
18960
  return n4 = Am(g2, t6, e4), n4;
18925
18961
  });
18926
18962
  return t6.cloneWithUpdate(r3);
18927
- }, s3 = t5[n3], i3 = s3.value, a3 = void 0 !== i3 ? i3 : e2, l3 = o3(new Nm(g2, s3), a3), h3 = (t6, e3) => {
18963
+ }, s3 = t5[n3], i3 = s3.value, a3 = void 0 !== i3 ? i3 : e2, l3 = o4(new Nm(g2, s3), a3), h3 = (t6, e3) => {
18928
18964
  if (r2 && t6.value && t6.value.getProperties()?.numberFormat) return t6;
18929
18965
  const n4 = Y.sanitizeRange(t6);
18930
18966
  let s4 = null, i4 = t6.value;
18931
- "function" == typeof a3 && i4 ? s4 = o3(i4, a3) : (i4 || (i4 = new Nm(g2, n4)), s4 = i4.cloneWithUpdate(e3.value._p ?? null)), s4.isEmpty() && (s4 = null);
18967
+ "function" == typeof a3 && i4 ? s4 = o4(i4, a3) : (i4 || (i4 = new Nm(g2, n4)), s4 = i4.cloneWithUpdate(e3.value._p ?? null)), s4.isEmpty() && (s4 = null);
18932
18968
  let l4 = false;
18933
18969
  if (s4) {
18934
18970
  const t7 = s4._p?.alignment?.horizontal;
@@ -18950,9 +18986,9 @@ class aw {
18950
18986
  const e3 = "boolean" == typeof n2.autoFit ? Sw : n2.autoFit;
18951
18987
  this._autoFit(t5, e3);
18952
18988
  }
18953
- this._emitter.notify("onStyleChange"), r2 ? o2.commit({ forceAmend: true }) : this._commitAndAutoSelect(o2, s2, n2?.autoSelect, { viewAfter: { ranges: t5 } });
18989
+ this._emitter.notify("onStyleChange"), r2 ? s2.commit({ forceAmend: true }) : this._commitAndAutoSelect(s2, i2, n2?.autoSelect, { viewAfter: { ranges: t5 } });
18954
18990
  } catch (t6) {
18955
- throw o2.rollback(), t6;
18991
+ throw s2.rollback(), t6;
18956
18992
  }
18957
18993
  }
18958
18994
  _createIncrementalUpdater(t5, e2 = null, n2) {
@@ -19113,73 +19149,75 @@ class aw {
19113
19149
  }
19114
19150
  }
19115
19151
  _sort(t5, e2) {
19116
- this._protectionCheck(() => ["sort"], t5), "boolean" == typeof e2 && (e2 = { reverse: e2 });
19117
- let n2 = 1, r2 = 1, o2 = false;
19118
- const s2 = this._getMerges([t5]);
19119
- if (s2.length > 0) {
19120
- o2 = true;
19121
- let e3 = s2[0];
19122
- if (n2 = e3.colEnd - e3.colStart + 1, r2 = e3.rowEnd - e3.rowStart + 1, (t5.colEnd - t5.colStart + 1) % n2 != 0 || (t5.rowEnd - t5.rowStart + 1) % r2 != 0) throw new Error(ud);
19123
- const i2 = s2.length;
19124
- for (let t6 = 1; t6 < i2; t6++) {
19125
- const e4 = s2[t6];
19126
- if (e4.colEnd - e4.colStart + 1 !== n2 || e4.rowEnd - e4.rowStart + 1 !== r2) throw new Error(ud);
19127
- }
19128
- }
19129
- const a2 = e2?.orientation ?? i.Orientation.Row, l2 = a2 === i.Orientation.Row;
19130
- let c2 = e2?.offset ?? 0, h2 = t5;
19131
- e2?.hasHeader && (h2 = { ...h2 }, l2 ? h2.rowStart += r2 : h2.colStart += n2, c2 = Math.max(c2 - 1, 0));
19132
- const u2 = { offset: c2, reverse: e2?.reverse ?? vl.DefaultRangeOptions.reverse, collatorOptions: e2?.collatorOptions ?? vl.DefaultRangeOptions.collatorOptions }, d2 = l2 ? h2.colStart : h2.rowStart, g2 = l2 ? h2.colEnd - h2.colStart : h2.rowEnd - h2.rowStart, m2 = [];
19152
+ "boolean" == typeof e2 && (e2 = { reverse: e2 });
19153
+ const n2 = e2?.description ?? "Sort " + (e2?.reverse ? "Descending" : "Ascending");
19154
+ this._protectionCheck(() => ["sort"], t5, n2);
19155
+ let r2 = 1, o2 = 1, s2 = false;
19156
+ const a2 = this._getMerges([t5]);
19157
+ if (a2.length > 0) {
19158
+ s2 = true;
19159
+ let e3 = a2[0];
19160
+ if (r2 = e3.colEnd - e3.colStart + 1, o2 = e3.rowEnd - e3.rowStart + 1, (t5.colEnd - t5.colStart + 1) % r2 != 0 || (t5.rowEnd - t5.rowStart + 1) % o2 != 0) throw new Error(ud);
19161
+ const n3 = a2.length;
19162
+ for (let t6 = 1; t6 < n3; t6++) {
19163
+ const e4 = a2[t6];
19164
+ if (e4.colEnd - e4.colStart + 1 !== r2 || e4.rowEnd - e4.rowStart + 1 !== o2) throw new Error(ud);
19165
+ }
19166
+ }
19167
+ const l2 = e2?.orientation ?? i.Orientation.Row, c2 = l2 === i.Orientation.Row;
19168
+ let h2 = e2?.offset ?? 0, u2 = t5;
19169
+ e2?.hasHeader && (u2 = { ...u2 }, c2 ? u2.rowStart += o2 : u2.colStart += r2, h2 = Math.max(h2 - 1, 0));
19170
+ const d2 = { offset: h2, reverse: e2?.reverse ?? vl.DefaultRangeOptions.reverse, collatorOptions: e2?.collatorOptions ?? vl.DefaultRangeOptions.collatorOptions }, g2 = c2 ? u2.colStart : u2.rowStart, m2 = c2 ? u2.colEnd - u2.colStart : u2.rowEnd - u2.rowStart, f2 = [];
19133
19171
  if (e2?.fields) {
19134
19172
  const t6 = e2?.fields.length ?? 0;
19135
19173
  for (let n3 = 0; n3 < t6; n3++) {
19136
19174
  let t7 = e2.fields[n3];
19137
- "number" == typeof t7 && (t7 = { offset: t7 }), m2.push(t7);
19175
+ "number" == typeof t7 && (t7 = { offset: t7 }), f2.push(t7);
19138
19176
  }
19139
- } else m2.push(u2);
19140
- const f2 = m2.length;
19141
- for (let t6 = 0; t6 < f2; t6++) {
19142
- const e3 = m2[t6] = { ...u2, ...m2[t6] };
19143
- if (e3.offset < 0 || e3.offset > g2) throw new zt("The sort offset is outside of the bounds of the sort.");
19144
- e3.offset += d2;
19145
- }
19146
- const p2 = [];
19147
- let _2 = null, S2 = null, w2 = null, y2 = Number.MIN_SAFE_INTEGER;
19148
- m2.sort((t6, e3) => t6.offset - e3.offset);
19149
- let E2 = null;
19150
- const b2 = e2?.includeHidden ?? false;
19151
- if (!b2) {
19152
- const t6 = _f(l2 ? this._rowHeaders : this._colHeaders);
19153
- E2 = Al(t6);
19154
- }
19155
- const C2 = this._cellIterator({ bounds: h2, orientation: a2, excludeHidden: !b2 && a2, includeRangeTypes: { [Yu.Type.Style]: false, [Yu.Type.Merge]: false } }), v2 = l2 ? r2 : n2;
19156
- let x2 = (l2 ? h2.rowStart : h2.colStart) - v2, I2 = C2.next();
19157
- for (; !I2.done; ) {
19158
- const t6 = I2.value.context, e3 = t6.getCell();
19159
- if (o2 && !e3.isTopLeft()) {
19160
- I2 = C2.next();
19177
+ } else f2.push(d2);
19178
+ const p2 = f2.length;
19179
+ for (let t6 = 0; t6 < p2; t6++) {
19180
+ const e3 = f2[t6] = { ...d2, ...f2[t6] };
19181
+ if (e3.offset < 0 || e3.offset > m2) throw new zt("The sort offset is outside of the bounds of the sort.");
19182
+ e3.offset += g2;
19183
+ }
19184
+ const _2 = [];
19185
+ let S2 = null, w2 = null, y2 = null, E2 = Number.MIN_SAFE_INTEGER;
19186
+ f2.sort((t6, e3) => t6.offset - e3.offset);
19187
+ let b2 = null;
19188
+ const C2 = e2?.includeHidden ?? false;
19189
+ if (!C2) {
19190
+ const t6 = _f(c2 ? this._rowHeaders : this._colHeaders);
19191
+ b2 = Al(t6);
19192
+ }
19193
+ const v2 = this._cellIterator({ bounds: u2, orientation: l2, excludeHidden: !C2 && l2, includeRangeTypes: { [Yu.Type.Style]: false, [Yu.Type.Merge]: false } }), x2 = c2 ? o2 : r2;
19194
+ let I2 = (c2 ? u2.rowStart : u2.colStart) - x2, R2 = v2.next();
19195
+ for (; !R2.done; ) {
19196
+ const t6 = R2.value.context, e3 = t6.getCell();
19197
+ if (s2 && !e3.isTopLeft()) {
19198
+ R2 = v2.next();
19161
19199
  continue;
19162
19200
  }
19163
- const n3 = t6.getCoords(), r3 = l2 ? n3.rowIndex : n3.colIndex, s3 = l2 ? n3.colIndex : n3.rowIndex;
19164
- if (x2 !== r3) {
19165
- for (x2 += v2, E2 && (x2 = E2(x2)); x2 < r3; ) p2.push(null), x2 += v2;
19166
- S2 = [], w2 = [], _2 = { minorIndex: r3, values: S2, sortValues: w2 }, p2.push(_2), x2 = r3, y2 = m2[0].offset;
19201
+ const n3 = t6.getCoords(), r3 = c2 ? n3.rowIndex : n3.colIndex, o3 = c2 ? n3.colIndex : n3.rowIndex;
19202
+ if (I2 !== r3) {
19203
+ for (I2 += x2, b2 && (I2 = b2(I2)); I2 < r3; ) _2.push(null), I2 += x2;
19204
+ w2 = [], y2 = [], S2 = { minorIndex: r3, values: w2, sortValues: y2 }, _2.push(S2), I2 = r3, E2 = f2[0].offset;
19167
19205
  }
19168
- for (; s3 > y2; ) {
19169
- const t7 = m2[w2.length];
19170
- y2 = t7 ? t7.offset : Number.MAX_SAFE_INTEGER, s3 > y2 && w2.push(null);
19206
+ for (; o3 > E2; ) {
19207
+ const t7 = f2[y2.length];
19208
+ E2 = t7 ? t7.offset : Number.MAX_SAFE_INTEGER, o3 > E2 && y2.push(null);
19171
19209
  }
19172
- s3 === y2 && w2.push(e3), S2.push(e3), I2 = C2.next();
19210
+ o3 === E2 && y2.push(e3), w2.push(e3), R2 = v2.next();
19173
19211
  }
19174
- if (!_2) return;
19175
- if (0 === p2.length) return;
19176
- const R2 = /* @__PURE__ */ new Map(), A2 = /* @__PURE__ */ new Map(), M2 = e2?.collators ?? vl.DefaultCollators, T2 = M2.length;
19177
- for (let t6 = 0; t6 < T2; t6++) R2.set(M2[t6].type, M2[t6].compare), A2.set(M2[t6].type, t6);
19178
- let N2 = null, F2 = null, k2 = null;
19179
- p2.sort((t6, e3) => {
19180
- const n3 = m2.length;
19212
+ if (!S2) return;
19213
+ if (0 === _2.length) return;
19214
+ const A2 = /* @__PURE__ */ new Map(), M2 = /* @__PURE__ */ new Map(), T2 = e2?.collators ?? vl.DefaultCollators, N2 = T2.length;
19215
+ for (let t6 = 0; t6 < N2; t6++) A2.set(T2[t6].type, T2[t6].compare), M2.set(T2[t6].type, t6);
19216
+ let F2 = null, k2 = null, O2 = null;
19217
+ _2.sort((t6, e3) => {
19218
+ const n3 = f2.length;
19181
19219
  for (let r3 = 0; r3 < n3; r3++) {
19182
- const n4 = m2[r3], o3 = t6 ? t6.sortValues[r3] : null, s3 = e3 ? e3.sortValues[r3] : null, i2 = o3 ? o3.getValue() : null, a3 = s3 ? s3.getValue() : null, l3 = null === i2, c3 = null === a3;
19220
+ const n4 = f2[r3], o3 = t6 ? t6.sortValues[r3] : null, s3 = e3 ? e3.sortValues[r3] : null, i2 = o3 ? o3.getValue() : null, a3 = s3 ? s3.getValue() : null, l3 = null === i2, c3 = null === a3;
19183
19221
  if (i2 === a3) continue;
19184
19222
  if (l3 && c3) return 0;
19185
19223
  if (!l3 && c3) return -1;
@@ -19187,40 +19225,40 @@ class aw {
19187
19225
  const h3 = o3.getType(), u3 = s3.getType();
19188
19226
  let d3 = 0;
19189
19227
  if (h3 !== u3) {
19190
- let t7 = A2.get(h3);
19191
- d3 = A2.get(u3) - t7;
19228
+ let t7 = M2.get(h3);
19229
+ d3 = M2.get(u3) - t7;
19192
19230
  } else {
19193
- let t7 = F2;
19194
- if (N2 !== h3) {
19195
- t7 = R2.get(h3), F2 = t7, N2 = h3;
19196
- let e4 = A2.get(u3);
19197
- const r4 = M2[e4].defaultOptions;
19198
- k2 = { ...r4, ...n4.collatorOptions };
19231
+ let t7 = k2;
19232
+ if (F2 !== h3) {
19233
+ t7 = A2.get(h3), k2 = t7, F2 = h3;
19234
+ let e4 = M2.get(u3);
19235
+ const r4 = T2[e4].defaultOptions;
19236
+ O2 = { ...r4, ...n4.collatorOptions };
19199
19237
  }
19200
- d3 = t7(i2, a3, k2);
19238
+ d3 = t7(i2, a3, O2);
19201
19239
  }
19202
19240
  return n4.reverse && (d3 *= -1), d3;
19203
19241
  }
19204
19242
  return 0;
19205
19243
  });
19206
- const O2 = this._beginCommit({ description: e2?.description ?? "Sort " + (e2?.reverse ? "Descending" : "Ascending") });
19207
- let D2 = [h2];
19208
- b2 || (D2 = this._getVisible(D2, { orientations: l2 ? i.Orientations.Row : i.Orientations.Column })), this._clear(D2, void 0, void 0, true);
19209
- const L2 = this._createIncrementalUpdater({ orientation: a2 });
19210
- let B2 = l2 ? h2.rowStart : h2.colStart;
19211
- const z2 = p2.length;
19212
- for (let t6 = 0; t6 < z2; t6++) {
19213
- const e3 = p2[t6];
19214
- if (E2 && (B2 = E2(B2)), e3) {
19244
+ const D2 = this._beginCommit({ description: n2 });
19245
+ let L2 = [u2];
19246
+ C2 || (L2 = this._getVisible(L2, { orientations: c2 ? i.Orientations.Row : i.Orientations.Column })), this._clear(L2, void 0, void 0, true);
19247
+ const B2 = this._createIncrementalUpdater({ orientation: l2 });
19248
+ let z2 = c2 ? u2.rowStart : u2.colStart;
19249
+ const P2 = _2.length;
19250
+ for (let t6 = 0; t6 < P2; t6++) {
19251
+ const e3 = _2[t6];
19252
+ if (b2 && (z2 = b2(z2)), e3) {
19215
19253
  const t7 = e3.values, n3 = t7.length;
19216
19254
  for (let e4 = 0; e4 < n3; e4++) {
19217
- const n4 = t7[e4], r3 = l2 ? B2 : n4.getCoords().rowIndex, o3 = l2 ? n4.getCoords().colIndex : B2;
19218
- L2.pushAt(r3, o3, n4);
19255
+ const n4 = t7[e4], r3 = c2 ? z2 : n4.getCoords().rowIndex, o3 = c2 ? n4.getCoords().colIndex : z2;
19256
+ B2.pushAt(r3, o3, n4);
19219
19257
  }
19220
19258
  }
19221
- B2 += v2;
19259
+ z2 += x2;
19222
19260
  }
19223
- return L2.apply(), O2.commit(), h2;
19261
+ return B2.apply(), D2.commit(), u2;
19224
19262
  }
19225
19263
  _autoFill(t5, e2, n2) {
19226
19264
  const { direction: r2, amount: o2 } = ((t6, e3) => {
@@ -19362,20 +19400,21 @@ class aw {
19362
19400
  return true;
19363
19401
  }
19364
19402
  _setHyperlinks(t5, e2, n2) {
19365
- this._protectionCheck(() => ["insertHyperlinks", "formatCells"], t5);
19366
- const r2 = Af(t5), o2 = this._beginCommit({ description: n2?.description ?? "Set Hyperlink" });
19367
- let s2 = null;
19403
+ const r2 = n2?.description ?? "Set Hyperlink";
19404
+ this._protectionCheck(() => ["insertHyperlinks", "formatCells"], t5, r2);
19405
+ const o2 = Af(t5), s2 = this._beginCommit({ description: r2 });
19406
+ let a2 = null;
19368
19407
  try {
19369
- const a2 = this._getState();
19370
- if (!a2) return bt.EmptyArray;
19371
- const l2 = a2.hyperlinkSpatial;
19408
+ const r3 = this._getState();
19409
+ if (!r3) return bt.EmptyArray;
19410
+ const l2 = r3.hyperlinkSpatial;
19372
19411
  let c2 = l2;
19373
- let h2 = a2.directStyleSpatial.clone();
19412
+ let h2 = r3.directStyleSpatial.clone();
19374
19413
  const u2 = t5.length;
19375
19414
  for (let n3 = 0; n3 < u2; n3++) {
19376
- const r3 = t5[n3];
19415
+ const r4 = t5[n3];
19377
19416
  let o3 = null;
19378
- const a3 = r3.value, u3 = void 0 !== a3 ? a3 : e2;
19417
+ const s3 = r4.value, u3 = void 0 !== s3 ? s3 : e2;
19379
19418
  let d2;
19380
19419
  if (null !== u3) {
19381
19420
  if (u3.isIHyperlink) d2 = { ...u3._j }, o3 = u3.getDisplayText();
@@ -19385,31 +19424,31 @@ class aw {
19385
19424
  delete e3.displayText, d2 = e3, o3 = t6.displayText ?? t6.address;
19386
19425
  }
19387
19426
  } else d2 = null;
19388
- if (s2 = Y.unionRanges(s2, r3), l2 === c2 && (c2 = l2.clone()), null !== d2 || l2.size() > 0) {
19427
+ if (a2 = Y.unionRanges(a2, r4), l2 === c2 && (c2 = l2.clone()), null !== d2 || l2.size() > 0) {
19389
19428
  if (o3 && e2) {
19390
19429
  const t6 = this._createIncrementalUpdater({ orientation: i.Orientation.Column }, void 0, { isHyperlink: true });
19391
- for (let e3 = r3.colStart; e3 <= r3.colEnd; e3++) for (let n4 = r3.rowStart; n4 <= r3.rowEnd; n4++) t6.pushAt(n4, e3, o3);
19430
+ for (let e3 = r4.colStart; e3 <= r4.colEnd; e3++) for (let n4 = r4.rowStart; n4 <= r4.rowEnd; n4++) t6.pushAt(n4, e3, o3);
19392
19431
  t6.apply();
19393
19432
  }
19394
- if (null === d2) this._getRangedEntries("hyperlinkSpatial", [r3], { onEntry: (t6, e3) => (c2.insertNonOverlapping({ ...e3, value: d2 }), e3.value) });
19433
+ if (null === d2) this._getRangedEntries("hyperlinkSpatial", [r4], { onEntry: (t6, e3) => (c2.insertNonOverlapping({ ...e3, value: d2 }), e3.value) });
19395
19434
  else {
19396
- c2.insertNonOverlapping({ ...r3, value: d2 });
19435
+ c2.insertNonOverlapping({ ...r4, value: d2 });
19397
19436
  const t6 = this._styles, e3 = (e4) => {
19398
19437
  const n4 = e4.value ?? new Nm(t6, Y.sanitizeRange(e4));
19399
- let r4 = { ...n4.getPropertiesAt(0, 0, null) };
19400
- if (r4.named) {
19401
- const e5 = t6.getNamed(r4.named)?.getRanged().getPropertiesAt(0, 0, null);
19402
- r4 = bt.mergeContentful(e5, r4);
19438
+ let r5 = { ...n4.getPropertiesAt(0, 0, null) };
19439
+ if (r5.named) {
19440
+ const e5 = t6.getNamed(r5.named)?.getRanged().getPropertiesAt(0, 0, null);
19441
+ r5 = bt.mergeContentful(e5, r5);
19403
19442
  }
19404
- return delete r4.font, r4.named = Ha.BuiltInName.Hyperlink, { ...e4, value: n4.cloneWithUpdate(r4) };
19443
+ return delete r5.font, r5.named = Ha.BuiltInName.Hyperlink, { ...e4, value: n4.cloneWithUpdate(r5) };
19405
19444
  };
19406
- h2.insertNonOverlapping({ ...r3, value: null }, { onIntersect: e3 });
19445
+ h2.insertNonOverlapping({ ...r4, value: null }, { onIntersect: e3 });
19407
19446
  }
19408
19447
  }
19409
19448
  }
19410
- this._lastUsedCoordsRead.coords = null, this._updateState({ hyperlinkSpatial: c2, directStyleSpatial: h2 }), this._commitAndAutoSelect(o2, r2, n2?.autoSelect, { viewAfter: { ranges: t5 } });
19449
+ this._lastUsedCoordsRead.coords = null, this._updateState({ hyperlinkSpatial: c2, directStyleSpatial: h2 }), this._commitAndAutoSelect(s2, o2, n2?.autoSelect, { viewAfter: { ranges: t5 } });
19411
19450
  } catch (t6) {
19412
- throw o2.rollback(), t6;
19451
+ throw s2.rollback(), t6;
19413
19452
  }
19414
19453
  }
19415
19454
  _updateFormulaSpatial(t5, e2, n2, r2) {
@@ -19540,37 +19579,37 @@ class aw {
19540
19579
  n2.invalidate(t5), n2.calculate(e2);
19541
19580
  }
19542
19581
  _calculateFull() {
19543
- this._initialized && bt.debounce(() => {
19582
+ this._initializing || bt.debounce(() => {
19544
19583
  this._getState()?.calcGraph.calculate({ full: true });
19545
19584
  }, 100)();
19546
19585
  }
19547
19586
  _setComments(t5, e2, n2) {
19548
- const r2 = Af(t5), o2 = this._beginCommit({ description: n2?.description ?? "Set Comments" });
19549
- let s2 = null;
19587
+ const r2 = n2?.description ?? "Set Comments", o2 = Af(t5), s2 = this._beginCommit({ description: r2 });
19588
+ let i2 = null;
19550
19589
  try {
19551
- const i2 = this._getState();
19552
- if (!i2) return bt.EmptyArray;
19553
- const a2 = i2.commentsSpatial;
19590
+ const r3 = this._getState();
19591
+ if (!r3) return bt.EmptyArray;
19592
+ const a2 = r3.commentsSpatial;
19554
19593
  let l2 = a2;
19555
19594
  const c2 = t5.length;
19556
19595
  for (let n3 = 0; n3 < c2; n3++) {
19557
- const r3 = t5[n3];
19596
+ const r4 = t5[n3];
19558
19597
  let o3 = null;
19559
19598
  if (null !== e2) {
19560
19599
  let t6 = e2;
19561
19600
  if (!t6) continue;
19562
19601
  o3 = "string" == typeof t6 ? { content: { runs: { text: t6 } } } : { ...t6 };
19563
19602
  }
19564
- s2 = Y.unionRanges(s2, r3), a2 === l2 && (l2 = a2.clone()), l2.insertNonOverlapping({ ...r3, value: o3 });
19603
+ i2 = Y.unionRanges(i2, r4), a2 === l2 && (l2 = a2.clone()), l2.insertNonOverlapping({ ...r4, value: o3 });
19565
19604
  }
19566
- this._lastUsedCoordsRead.coords = null, this._updateState({ commentsSpatial: l2 }), this._commitAndAutoSelect(o2, r2, n2?.autoSelect, { viewAfter: { ranges: t5 } });
19605
+ this._lastUsedCoordsRead.coords = null, this._updateState({ commentsSpatial: l2 }), this._commitAndAutoSelect(s2, o2, n2?.autoSelect, { viewAfter: { ranges: t5 } });
19567
19606
  } catch (t6) {
19568
- throw o2.rollback(), t6;
19607
+ throw s2.rollback(), t6;
19569
19608
  }
19570
19609
  }
19571
19610
  _clear(t5, e2 = null, n2, r2 = false, o2 = false) {
19572
19611
  let s2 = null, i2 = "Clear", a2 = false, l2 = false, c2 = false, h2 = false;
19573
- e2 === wd.Content.Formulas ? (i2 = `${i2} Formulas`, h2 = true) : e2 === wd.Content.Values ? (i2 = `${i2} Values`, h2 = true) : e2 === wd.Content.Formats ? (i2 = `${i2} Formats`, a2 = true, s2 = ["formatCells"]) : e2 === wd.Content.Comments ? (i2 = `${i2} Comments`, c2 = true) : e2 === wd.Content.Hyperlinks ? (i2 = `${i2} Hyperlinks`, l2 = true, s2 = ["formatCells"]) : (s2 = [], i2 = `${i2} All`, h2 = true, a2 = true, l2 = true, c2 = true), null !== s2 && this._protectionCheck(() => s2, t5);
19612
+ e2 === wd.Content.Formulas ? (i2 = `${i2} Formulas`, h2 = true) : e2 === wd.Content.Values ? (i2 = `${i2} Values`, h2 = true) : e2 === wd.Content.Formats ? (i2 = `${i2} Formats`, a2 = true, s2 = ["formatCells"]) : e2 === wd.Content.Comments ? (i2 = `${i2} Comments`, c2 = true) : e2 === wd.Content.Hyperlinks ? (i2 = `${i2} Hyperlinks`, l2 = true, s2 = ["formatCells"]) : (s2 = [], i2 = `${i2} All`, h2 = true, a2 = true, l2 = true, c2 = true), null !== s2 && this._protectionCheck(() => s2, t5, n2?.description ?? i2);
19574
19613
  const u2 = Af(t5), d2 = this._beginCommit({ description: n2?.description ?? i2 });
19575
19614
  let g2 = this._getState(), m2 = g2.cellValuesGrid, f2 = g2.calcGraph, p2 = g2.contentfulSpatial, _2 = g2.formulaSpatial, S2 = g2.spillSpatial, w2 = g2.pendingSpatial, y2 = g2.calcErrorsSpatial, E2 = g2.rangesListenerSpatial2;
19576
19615
  h2 && (m2 = m2.clone(), f2 = f2.clone(), p2 = p2.clone(), _2 = _2.clone(), S2 = S2.clone(), w2 = w2.clone(), y2 = y2.clone());
@@ -20004,7 +20043,7 @@ class aw {
20004
20043
  }, apply: (t6) => {
20005
20044
  console.log("apply Filter", t6);
20006
20045
  }, processUpdate: () => {
20007
- }, isProtected: () => !r2.getProtection().isAutoFilterAllowed() });
20046
+ }, isProtected: () => !r2._initializing && !r2.getProtection().isAutoFilterAllowed() });
20008
20047
  }
20009
20048
  insertFilter(t5) {
20010
20049
  const e2 = this._rangeToCoords(t5, () => ["autoFilter"]);
@@ -20066,64 +20105,64 @@ class aw {
20066
20105
  r2 = r2 ?? ((t6, e3) => {
20067
20106
  o2._validateCoords(t6, e3 ?? cd);
20068
20107
  });
20069
- const s2 = (e2 ?? this._getDefaultShiftOrientation(t5[0])) === i.Orientation.Column;
20070
- if (this._protectionCheck(() => [s2 ? "insertColumns" : "insertRows"], t5), bh(t5)) throw new Error("We can't insert cells with overlapping selections.");
20071
- const a2 = this._entireCoords;
20072
- let l2 = a2.colEnd, c2 = a2.rowEnd;
20073
- const h2 = Af(t5), u2 = this._beginCommit({ description: n2?.description ?? "Insert Cells", operation: { name: "insertCells" } }), d2 = u2.getState(this), g2 = s2 ? i.Direction.Right : i.Direction.Down;
20108
+ const s2 = n2?.description ?? "Insert Cells", a2 = (e2 ?? this._getDefaultShiftOrientation(t5[0])) === i.Orientation.Column;
20109
+ if (this._protectionCheck(() => [a2 ? "insertColumns" : "insertRows"], t5, s2), bh(t5)) throw new Error("We can't insert cells with overlapping selections.");
20110
+ const l2 = this._entireCoords;
20111
+ let c2 = l2.colEnd, h2 = l2.rowEnd;
20112
+ const u2 = Af(t5), d2 = this._beginCommit({ description: s2, operation: { name: "insertCells" } }), g2 = d2.getState(this), m2 = a2 ? i.Direction.Right : i.Direction.Down;
20074
20113
  try {
20075
- let e3 = d2.cellValuesGrid, o3 = d2.contentfulSpatial, m2 = d2.unlockSpatial, f2 = d2.mergeSpatial, p2 = d2.directStyleSpatial, _2 = d2.continuousFillSpatial, S2 = d2.conditionalSpatial, w2 = d2.hyperlinkSpatial, y2 = d2.commentsSpatial, E2 = d2.movableSpatial, b2 = d2.tableSpatial, C2 = d2.calcGraph, v2 = d2.rangesListenerSpatial2, x2 = d2.rangeListenerSpatial, I2 = d2.rangesListenerMap;
20114
+ let e3 = g2.cellValuesGrid, o3 = g2.contentfulSpatial, s3 = g2.unlockSpatial, f2 = g2.mergeSpatial, p2 = g2.directStyleSpatial, _2 = g2.continuousFillSpatial, S2 = g2.conditionalSpatial, w2 = g2.hyperlinkSpatial, y2 = g2.commentsSpatial, E2 = g2.movableSpatial, b2 = g2.tableSpatial, C2 = g2.calcGraph, v2 = g2.rangesListenerSpatial2, x2 = g2.rangeListenerSpatial, I2 = g2.rangesListenerMap;
20076
20115
  const R2 = /* @__PURE__ */ new Map(), A2 = Pl(t5.slice(), i.Direction.Left), M2 = A2.length;
20077
20116
  for (let t6 = 0; t6 < M2; t6++) {
20078
20117
  const n3 = A2[t6];
20079
- l2 = Math.min(l2, n3.colStart), c2 = Math.min(c2, n3.rowStart);
20080
- const i2 = s2 ? n3.colEnd - n3.colStart + 1 : n3.rowEnd - n3.rowStart + 1, h3 = e3.getCoords();
20081
- if (h3) {
20082
- const t7 = { ...n3, colEnd: s2 ? Math.max(n3.colEnd, h3?.colEnd ?? n3.colStart) + (n3.colEnd - n3.colStart + 1) : n3.colStart, rowEnd: s2 ? n3.rowStart : Math.max(n3.rowEnd, h3?.rowEnd ?? n3.rowStart) + (n3.rowEnd - n3.rowStart + 1) }, a3 = o3.search(t7), l3 = a3.length;
20118
+ c2 = Math.min(c2, n3.colStart), h2 = Math.min(h2, n3.rowStart);
20119
+ const i2 = a2 ? n3.colEnd - n3.colStart + 1 : n3.rowEnd - n3.rowStart + 1, u3 = e3.getCoords();
20120
+ if (u3) {
20121
+ const t7 = { ...n3, colEnd: a2 ? Math.max(n3.colEnd, u3?.colEnd ?? n3.colStart) + (n3.colEnd - n3.colStart + 1) : n3.colStart, rowEnd: a2 ? n3.rowStart : Math.max(n3.rowEnd, u3?.rowEnd ?? n3.rowStart) + (n3.rowEnd - n3.rowStart + 1) }, s4 = o3.search(t7), l3 = s4.length;
20083
20122
  for (let t8 = 0; t8 < l3; t8++) {
20084
- const e4 = a3[t8], o4 = { ...n3 };
20085
- s2 ? o4.colEnd = Math.max(o4.colEnd, e4.colEnd) + i2 : o4.rowEnd = Math.max(o4.rowEnd, e4.rowEnd) + i2, r2(o4);
20123
+ const e4 = s4[t8], o4 = { ...n3 };
20124
+ a2 ? o4.colEnd = Math.max(o4.colEnd, e4.colEnd) + i2 : o4.rowEnd = Math.max(o4.rowEnd, e4.rowEnd) + i2, r2(o4);
20086
20125
  }
20087
- e3 = e3.clone(), e3.shift(n3, g2), this._updateState({ cellValuesGrid: e3 });
20126
+ e3 = e3.clone(), e3.shift(n3, m2), this._updateState({ cellValuesGrid: e3 });
20088
20127
  }
20089
- const u3 = n3.colStart <= a2.colStart && n3.colEnd >= a2.colEnd, M3 = n3.rowStart <= a2.rowStart && n3.rowEnd >= a2.rowEnd, T3 = (t7, e4, n4, r3) => {
20128
+ const d3 = n3.colStart <= l2.colStart && n3.colEnd >= l2.colEnd, M3 = n3.rowStart <= l2.rowStart && n3.rowEnd >= l2.rowEnd, T3 = (t7, e4, n4, r3) => {
20090
20129
  let o4 = null;
20091
20130
  n4 > 1 && (o4 = t7.at(n4 - 1));
20092
- const s3 = r3 - n4 + 1;
20093
- e4?.(n4, s3), o4 && t7.updateHeaderPairs([{ address: { min: n4, max: r3 }, update: o4 }]);
20131
+ const s4 = r3 - n4 + 1;
20132
+ e4?.(n4, s4), o4 && t7.updateHeaderPairs([{ address: { min: n4, max: r3 }, update: o4 }]);
20094
20133
  };
20095
- u3 && T3(this._rowHeaders, this._rowHeadersShiftCallback, n3.rowStart, n3.rowEnd), M3 && T3(this._colHeaders, this._colHeadersShiftCallback, n3.colStart, n3.colEnd), o3 = o3.shift({ range: n3, direction: g2, cloneIfUpdate: o3 === d2.contentfulSpatial, coordValidator: r2 }), m2 = m2.shift({ range: n3, direction: g2, cloneIfUpdate: m2 === d2.unlockSpatial, coordValidator: r2 }), f2 = f2.shift({ range: n3, direction: g2, cloneIfUpdate: f2 === d2.mergeSpatial, coordValidator: r2 }), p2 = p2.shift({ range: n3, direction: g2, cloneIfUpdate: p2 === d2.directStyleSpatial, coordValidator: r2 }), _2 = _2.shift({ range: n3, direction: g2, cloneIfUpdate: _2 === d2.continuousFillSpatial, coordValidator: r2 }), S2 = S2.shift({ range: n3, direction: g2, cloneIfUpdate: S2 === d2.conditionalSpatial, coordValidator: r2 }), w2 = w2.shift({ range: n3, direction: g2, cloneIfUpdate: w2 === d2.hyperlinkSpatial, coordValidator: r2 }), y2 = y2.shift({ range: n3, direction: g2, cloneIfUpdate: y2 === d2.commentsSpatial, coordValidator: r2 }), E2 = E2.shift({ range: n3, direction: g2, cloneIfUpdate: E2 === d2.movableSpatial, coordValidator: r2 }), b2 = b2.shift({ range: n3, direction: g2, cloneIfUpdate: b2 === d2.tableSpatial, coordValidator: r2 }), C2 = C2.shift({ range: n3, direction: g2, cloneIfUpdate: C2 === d2.calcGraph }), x2 = x2.shift({ range: n3, direction: g2, cloneIfUpdate: x2 === d2.rangeListenerSpatial, onShift: (t7) => {
20096
- I2 === d2.rangesListenerMap && (I2 = new Map(I2)), this._processListenerShift(I2, R2, d2.rangesListenerMap, t7);
20097
- } }), v2 = v2.shift({ range: n3, direction: g2, cloneIfUpdate: v2 === d2.rangesListenerSpatial2, coordValidator: r2 });
20134
+ d3 && T3(this._rowHeaders, this._rowHeadersShiftCallback, n3.rowStart, n3.rowEnd), M3 && T3(this._colHeaders, this._colHeadersShiftCallback, n3.colStart, n3.colEnd), o3 = o3.shift({ range: n3, direction: m2, cloneIfUpdate: o3 === g2.contentfulSpatial, coordValidator: r2 }), s3 = s3.shift({ range: n3, direction: m2, cloneIfUpdate: s3 === g2.unlockSpatial, coordValidator: r2 }), f2 = f2.shift({ range: n3, direction: m2, cloneIfUpdate: f2 === g2.mergeSpatial, coordValidator: r2 }), p2 = p2.shift({ range: n3, direction: m2, cloneIfUpdate: p2 === g2.directStyleSpatial, coordValidator: r2 }), _2 = _2.shift({ range: n3, direction: m2, cloneIfUpdate: _2 === g2.continuousFillSpatial, coordValidator: r2 }), S2 = S2.shift({ range: n3, direction: m2, cloneIfUpdate: S2 === g2.conditionalSpatial, coordValidator: r2 }), w2 = w2.shift({ range: n3, direction: m2, cloneIfUpdate: w2 === g2.hyperlinkSpatial, coordValidator: r2 }), y2 = y2.shift({ range: n3, direction: m2, cloneIfUpdate: y2 === g2.commentsSpatial, coordValidator: r2 }), E2 = E2.shift({ range: n3, direction: m2, cloneIfUpdate: E2 === g2.movableSpatial, coordValidator: r2 }), b2 = b2.shift({ range: n3, direction: m2, cloneIfUpdate: b2 === g2.tableSpatial, coordValidator: r2 }), C2 = C2.shift({ range: n3, direction: m2, cloneIfUpdate: C2 === g2.calcGraph }), x2 = x2.shift({ range: n3, direction: m2, cloneIfUpdate: x2 === g2.rangeListenerSpatial, onShift: (t7) => {
20135
+ I2 === g2.rangesListenerMap && (I2 = new Map(I2)), this._processListenerShift(I2, R2, g2.rangesListenerMap, t7);
20136
+ } }), v2 = v2.shift({ range: n3, direction: m2, cloneIfUpdate: v2 === g2.rangesListenerSpatial2, coordValidator: r2 });
20098
20137
  }
20099
- let T2 = d2.formulaSpatial, N2 = d2.spillSpatial, F2 = d2.pendingSpatial;
20100
- C2 !== d2.calcGraph && (T2 = T2.clone(), N2 = N2.clone(), F2 = F2.clone()), this._updateState({ contentfulSpatial: o3, unlockSpatial: m2, mergeSpatial: f2, directStyleSpatial: p2, continuousFillSpatial: _2, conditionalSpatial: S2, hyperlinkSpatial: w2, commentsSpatial: y2, movableSpatial: E2, tableSpatial: b2, calcGraph: C2, formulaSpatial: T2, spillSpatial: N2, pendingSpatial: F2, rangesListenerSpatial2: v2, rangeListenerSpatial: x2, rangesListenerMap: I2 }), this._commitAndAutoSelect(u2, h2, n2?.autoSelect, { viewAfter: { ranges: A2, listeners: R2 } });
20138
+ let T2 = g2.formulaSpatial, N2 = g2.spillSpatial, F2 = g2.pendingSpatial;
20139
+ C2 !== g2.calcGraph && (T2 = T2.clone(), N2 = N2.clone(), F2 = F2.clone()), this._updateState({ contentfulSpatial: o3, unlockSpatial: s3, mergeSpatial: f2, directStyleSpatial: p2, continuousFillSpatial: _2, conditionalSpatial: S2, hyperlinkSpatial: w2, commentsSpatial: y2, movableSpatial: E2, tableSpatial: b2, calcGraph: C2, formulaSpatial: T2, spillSpatial: N2, pendingSpatial: F2, rangesListenerSpatial2: v2, rangeListenerSpatial: x2, rangesListenerMap: I2 }), this._commitAndAutoSelect(d2, u2, n2?.autoSelect, { viewAfter: { ranges: A2, listeners: R2 } });
20101
20140
  } catch (t6) {
20102
- if (console.warn(t6), u2.rollback(), t6 instanceof zt) throw new Error(t6.message ?? cd);
20141
+ if (console.warn(t6), d2.rollback(), t6 instanceof zt) throw new Error(t6.message ?? cd);
20103
20142
  throw t6;
20104
20143
  }
20105
20144
  }
20106
20145
  _deleteCells(t5, e2, n2) {
20107
- const r2 = (e2 ?? this._getDefaultShiftOrientation(t5[0])) === i.Orientation.Column;
20108
- if (this._protectionCheck(() => [r2 ? "deleteColumns" : "deleteRows"], t5), bh(t5)) throw new Error("We can't delete cells with overlapping selections.");
20109
- const o2 = this._entireCoords;
20110
- let s2 = o2.colEnd, a2 = o2.rowEnd;
20111
- const l2 = r2 ? i.Direction.Left : i.Direction.Up, c2 = Af(t5), h2 = this._beginCommit({ description: n2?.description ?? "Delete Cells", operation: { name: "deleteCells" } }), u2 = h2.getState(this);
20146
+ const r2 = (e2 ?? this._getDefaultShiftOrientation(t5[0])) === i.Orientation.Column, o2 = n2?.description ?? "Delete Cells";
20147
+ if (this._protectionCheck(() => [r2 ? "deleteColumns" : "deleteRows"], t5, o2), bh(t5)) throw new Error("We can't delete cells with overlapping selections.");
20148
+ const s2 = this._entireCoords;
20149
+ let a2 = s2.colEnd, l2 = s2.rowEnd;
20150
+ const c2 = r2 ? i.Direction.Left : i.Direction.Up, h2 = Af(t5), u2 = this._beginCommit({ description: o2, operation: { name: "deleteCells" } }), d2 = u2.getState(this);
20112
20151
  try {
20113
- let e3 = u2.cellValuesGrid, r3 = u2.contentfulSpatial, d2 = u2.mergeSpatial, g2 = u2.unlockSpatial, m2 = u2.directStyleSpatial, f2 = u2.continuousFillSpatial, p2 = u2.conditionalSpatial, _2 = u2.hyperlinkSpatial, S2 = u2.commentsSpatial, w2 = u2.movableSpatial, y2 = u2.movableMapModel, E2 = u2.tableSpatial, b2 = u2.tableMapModel, C2 = u2.calcGraph, v2 = u2.rangesListenerSpatial2, x2 = u2.rangeListenerSpatial, I2 = u2.rangesListenerMap;
20152
+ let e3 = d2.cellValuesGrid, r3 = d2.contentfulSpatial, o3 = d2.mergeSpatial, g2 = d2.unlockSpatial, m2 = d2.directStyleSpatial, f2 = d2.continuousFillSpatial, p2 = d2.conditionalSpatial, _2 = d2.hyperlinkSpatial, S2 = d2.commentsSpatial, w2 = d2.movableSpatial, y2 = d2.movableMapModel, E2 = d2.tableSpatial, b2 = d2.tableMapModel, C2 = d2.calcGraph, v2 = d2.rangesListenerSpatial2, x2 = d2.rangeListenerSpatial, I2 = d2.rangesListenerMap;
20114
20153
  const R2 = /* @__PURE__ */ new Map(), A2 = Pl(t5.slice(), i.Direction.Left), M2 = A2.length;
20115
20154
  for (let t6 = 0; t6 < M2; t6++) {
20116
20155
  const n3 = A2[t6];
20117
- s2 = Math.min(s2, n3.colStart), a2 = Math.min(a2, n3.rowStart);
20118
- e3.getCoords() && (e3 = e3.clone(), e3.shift(n3, l2), this._updateState({ cellValuesGrid: e3 }));
20119
- const i2 = n3.colStart <= o2.colStart && n3.colEnd >= o2.colEnd, c3 = n3.rowStart <= o2.rowStart && n3.rowEnd >= o2.rowEnd;
20120
- i2 && this._rowHeadersShiftCallback(n3.rowStart, -1 * (n3.rowEnd - n3.rowStart + 1)), c3 && this._colHeadersShiftCallback(n3.colStart, -1 * (n3.colEnd - n3.colStart + 1)), r3 = r3.shift({ range: n3, direction: l2, cloneIfUpdate: r3 === u2.contentfulSpatial }), g2 = g2.shift({ range: n3, direction: l2, cloneIfUpdate: g2 === u2.unlockSpatial }), d2 = d2.shift({ range: n3, direction: l2, cloneIfUpdate: d2 === u2.mergeSpatial }), m2 = m2.shift({ range: n3, direction: l2, cloneIfUpdate: m2 === u2.directStyleSpatial }), f2 = f2.shift({ range: n3, direction: l2, cloneIfUpdate: f2 === u2.continuousFillSpatial }), p2 = p2.shift({ range: n3, direction: l2, cloneIfUpdate: p2 === u2.conditionalSpatial }), _2 = _2.shift({ range: n3, direction: l2, cloneIfUpdate: _2 === u2.hyperlinkSpatial }), S2 = S2.shift({ range: n3, direction: l2, cloneIfUpdate: S2 === u2.commentsSpatial }), w2 = w2.shift({ range: n3, direction: l2, cloneIfUpdate: w2 === u2.movableSpatial }), E2 = E2.shift({ range: n3, direction: l2, cloneIfUpdate: E2 === u2.tableSpatial }), C2 = C2.shift({ range: n3, direction: l2, cloneIfUpdate: C2 === u2.calcGraph }), x2 = x2.shift({ range: n3, direction: l2, cloneIfUpdate: x2 === u2.rangeListenerSpatial, onShift: (t7) => {
20121
- I2 === u2.rangesListenerMap && (I2 = new Map(I2)), this._processListenerShift(I2, R2, u2.rangesListenerMap, t7);
20122
- } }), v2 = v2.shift({ range: n3, direction: l2, cloneIfUpdate: v2 === u2.rangesListenerSpatial2 });
20123
- }
20124
- this._updateState({ contentfulSpatial: r3, unlockSpatial: g2, mergeSpatial: d2, directStyleSpatial: m2, continuousFillSpatial: f2, conditionalSpatial: p2, hyperlinkSpatial: _2, commentsSpatial: S2, movableSpatial: w2, movableMapModel: y2, tableSpatial: E2, tableMapModel: b2, calcGraph: C2, rangesListenerSpatial2: v2, rangeListenerSpatial: x2, rangesListenerMap: I2 }), this._commitAndAutoSelect(h2, c2, n2?.autoSelect, { viewAfter: { ranges: A2, listeners: R2 } });
20156
+ a2 = Math.min(a2, n3.colStart), l2 = Math.min(l2, n3.rowStart);
20157
+ e3.getCoords() && (e3 = e3.clone(), e3.shift(n3, c2), this._updateState({ cellValuesGrid: e3 }));
20158
+ const i2 = n3.colStart <= s2.colStart && n3.colEnd >= s2.colEnd, h3 = n3.rowStart <= s2.rowStart && n3.rowEnd >= s2.rowEnd;
20159
+ i2 && this._rowHeadersShiftCallback(n3.rowStart, -1 * (n3.rowEnd - n3.rowStart + 1)), h3 && this._colHeadersShiftCallback(n3.colStart, -1 * (n3.colEnd - n3.colStart + 1)), r3 = r3.shift({ range: n3, direction: c2, cloneIfUpdate: r3 === d2.contentfulSpatial }), g2 = g2.shift({ range: n3, direction: c2, cloneIfUpdate: g2 === d2.unlockSpatial }), o3 = o3.shift({ range: n3, direction: c2, cloneIfUpdate: o3 === d2.mergeSpatial }), m2 = m2.shift({ range: n3, direction: c2, cloneIfUpdate: m2 === d2.directStyleSpatial }), f2 = f2.shift({ range: n3, direction: c2, cloneIfUpdate: f2 === d2.continuousFillSpatial }), p2 = p2.shift({ range: n3, direction: c2, cloneIfUpdate: p2 === d2.conditionalSpatial }), _2 = _2.shift({ range: n3, direction: c2, cloneIfUpdate: _2 === d2.hyperlinkSpatial }), S2 = S2.shift({ range: n3, direction: c2, cloneIfUpdate: S2 === d2.commentsSpatial }), w2 = w2.shift({ range: n3, direction: c2, cloneIfUpdate: w2 === d2.movableSpatial }), E2 = E2.shift({ range: n3, direction: c2, cloneIfUpdate: E2 === d2.tableSpatial }), C2 = C2.shift({ range: n3, direction: c2, cloneIfUpdate: C2 === d2.calcGraph }), x2 = x2.shift({ range: n3, direction: c2, cloneIfUpdate: x2 === d2.rangeListenerSpatial, onShift: (t7) => {
20160
+ I2 === d2.rangesListenerMap && (I2 = new Map(I2)), this._processListenerShift(I2, R2, d2.rangesListenerMap, t7);
20161
+ } }), v2 = v2.shift({ range: n3, direction: c2, cloneIfUpdate: v2 === d2.rangesListenerSpatial2 });
20162
+ }
20163
+ this._updateState({ contentfulSpatial: r3, unlockSpatial: g2, mergeSpatial: o3, directStyleSpatial: m2, continuousFillSpatial: f2, conditionalSpatial: p2, hyperlinkSpatial: _2, commentsSpatial: S2, movableSpatial: w2, movableMapModel: y2, tableSpatial: E2, tableMapModel: b2, calcGraph: C2, rangesListenerSpatial2: v2, rangeListenerSpatial: x2, rangesListenerMap: I2 }), this._commitAndAutoSelect(u2, h2, n2?.autoSelect, { viewAfter: { ranges: A2, listeners: R2 } });
20125
20164
  } catch (t6) {
20126
- if (h2.rollback(), t6 instanceof zt) throw new Error(t6.message ?? cd);
20165
+ if (u2.rollback(), t6 instanceof zt) throw new Error(t6.message ?? cd);
20127
20166
  throw t6;
20128
20167
  }
20129
20168
  }
@@ -20134,7 +20173,11 @@ class aw {
20134
20173
  let r2;
20135
20174
  const o2 = ef(t5, this._entireCoords, true), a2 = tf(t5, this._entireCoords, true);
20136
20175
  !o2 && a2 ? (e2.orientations = e2.orientations ?? i.Orientations.Column, r2 = `${n2} ${NS}`) : !a2 && o2 ? (e2.orientations = e2.orientations ?? i.Orientations.Row, r2 = `${n2} ${TS}`) : a2 && o2 ? (e2.orientations = e2.orientations ?? i.Orientations.Both, r2 = `${n2} All`) : (e2.orientations = e2.orientations ?? i.Orientations.Both, r2 = `${n2}`);
20137
- const l2 = e2.orientations !== i.Orientations.Row, c2 = e2.orientations !== i.Orientations.Column, h2 = l2 && (false === e2.expandOnly || e2.expandOnly === i.Orientation.Row), u2 = c2 && (false === e2.expandOnly || e2.expandOnly === i.Orientation.Column), d2 = e2.minContent, g2 = Af(t5), m2 = this._beginCommit({ description: e2.description ?? r2 });
20176
+ let l2 = e2.orientations !== i.Orientations.Row;
20177
+ this._colHeaders.isProtected() && (l2 = false);
20178
+ let c2 = e2.orientations !== i.Orientations.Column;
20179
+ if (this._rowHeaders.isProtected() && (c2 = false), !c2 && !l2) return;
20180
+ const h2 = l2 && (false === e2.expandOnly || e2.expandOnly === i.Orientation.Row), u2 = c2 && (false === e2.expandOnly || e2.expandOnly === i.Orientation.Column), d2 = e2.minContent, g2 = Af(t5), m2 = this._beginCommit({ description: e2.description ?? r2 });
20138
20181
  try {
20139
20182
  let n3 = Number.MAX_SAFE_INTEGER, r3 = Number.MIN_SAFE_INTEGER, o3 = false, a3 = "", f2 = -1, p2 = false, _2 = false, S2 = false, w2 = Number.MAX_SAFE_INTEGER, y2 = Number.MIN_SAFE_INTEGER;
20140
20183
  const E2 = this._styles.getNormal(), b2 = this._cellOptions, C2 = e2.orientations === i.Orientations.Row, v2 = /* @__PURE__ */ new Map(), x2 = Rc(t5, 1);
@@ -21327,7 +21370,7 @@ class aw {
21327
21370
  }
21328
21371
  close() {
21329
21372
  if (this._closed) return;
21330
- this._protectionRemoveListener?.(), this._protection = new XS();
21373
+ this._protectionRemoveListener?.(), this._protection = new XS(void 0, this._options.readonly);
21331
21374
  const t5 = this._getState().tableMapModel.keys();
21332
21375
  for (const e2 of t5) e2.close();
21333
21376
  this._searchMovables().forEach((t6) => {
@@ -21411,7 +21454,7 @@ class aw {
21411
21454
  t5._lastCellDecoded.address = null, t5._lastCellSelected.coords = null, t5._lastCellRead.coords = null, t5._lastValueRead.range = null, t5._lastGetRangeRead = {}, t5._lastUsedCoordsRead.coords = null, t5._lastActiveRead.selection = null, t5._lastRangeRead.address = null;
21412
21455
  };
21413
21456
  this._transactionsRemoveListener = this._transactions.addStateListener(this, { onBeforeCommitStart(e3, n3, r3) {
21414
- if (t5._initialized && !n3?.skipProtectionCheck) {
21457
+ if (!t5._initializing && !n3?.skipProtectionCheck) {
21415
21458
  if (t5.getProtection().isLocked()) throw new Error(nd);
21416
21459
  }
21417
21460
  }, async onBeforeCommitEnd(e3, n3, r3) {
@@ -21524,7 +21567,7 @@ class aw {
21524
21567
  } }, c2 = new HS({ sheet: this });
21525
21568
  this._view = c2, this._clearState(), this._viewRemoveListener = c2.addListeners(l2, { transactional: false }), this._viewListener = l2, this._colHeadersRemoveListener?.();
21526
21569
  const h2 = () => Math.round(this._defaultFontDims().width);
21527
- this._colHeaders = new FS({ sheet: t5, orientation: i.Orientation.Column, maxSheetCoords: this._entireCoords, transactions: this._transactions, isProtected: () => !t5.getProtection().isFormatColumnsAllowed(), getTextAt: (t6) => {
21570
+ this._colHeaders = new FS({ sheet: t5, orientation: i.Orientation.Column, maxSheetCoords: this._entireCoords, transactions: this._transactions, isProtected: () => !t5._initializing && !t5.getProtection().isFormatColumnsAllowed(), getTextAt: (t6) => {
21528
21571
  const e3 = this.getView().getColumnHeaderStyle();
21529
21572
  return e3 === D_.HeaderTextStyle.A1 ? nw(t6) : e3 === D_.HeaderTextStyle.Zero ? ew(t6) : e3 === D_.HeaderTextStyle.One ? rw(t6) : void 0;
21530
21573
  }, defaultSize: () => {
@@ -21534,7 +21577,7 @@ class aw {
21534
21577
  this._colHeadersShiftCallback = t6;
21535
21578
  } }), this._colHeadersRemoveListener = this._colHeaders.addListeners(this._colHeadersListener, { transactional: true }), this._rowHeadersRemoveListener?.();
21536
21579
  const u2 = wi.getDeviceScale();
21537
- this._rowHeaders = new FS({ sheet: t5, orientation: i.Orientation.Row, maxSheetCoords: this._entireCoords, transactions: this._transactions, isProtected: () => !t5.getProtection().isFormatRowsAllowed(), getTextAt: (t6) => {
21580
+ this._rowHeaders = new FS({ sheet: t5, orientation: i.Orientation.Row, maxSheetCoords: this._entireCoords, transactions: this._transactions, isProtected: () => !t5._initializing && !t5.getProtection().isFormatRowsAllowed(), getTextAt: (t6) => {
21538
21581
  const e3 = this.getView().getRowHeaderStyle();
21539
21582
  return e3 === D_.HeaderTextStyle.One ? rw(t6) : e3 === D_.HeaderTextStyle.Zero ? ew(t6) : e3 === D_.HeaderTextStyle.A1 ? nw(t6) : void 0;
21540
21583
  }, defaultSize: () => this._defaultRowHeight(), scaleFactor: () => u2, minSize: () => 0, maxSize: () => 409, setContainerShiftedCallback: (t6) => {
@@ -21557,10 +21600,10 @@ class aw {
21557
21600
  return await this._autoSelect(e3 ?? true, Af(n4)), true;
21558
21601
  }
21559
21602
  return window.open(t6, n3 ?? "_blank", r3), true;
21560
- } }, this._emptyCell = new Km(this._cellOptions), this._initialized = true;
21603
+ } }, this._emptyCell = new Km(this._cellOptions);
21561
21604
  }
21562
21605
  _clearState() {
21563
- this._lastGetRangeRead = null, this._lastCellDecoded.address = null, this._lastCellSelected.coords = null, this._lastCellRead.coords = null, this._protectionRemoveListener?.(), this._protection = new XS(), this._protectionRemoveListener = this._protection.addListeners({ onChange() {
21606
+ this._lastGetRangeRead = null, this._lastCellDecoded.address = null, this._lastCellSelected.coords = null, this._lastCellRead.coords = null, this._protectionRemoveListener?.(), this._protection = new XS(void 0, this._options.readonly), this._protectionRemoveListener = this._protection.addListeners({ onChange() {
21564
21607
  if (t5._closed) throw new Error(dd);
21565
21608
  t5._getState().movableMapModel.forEach((t6) => {
21566
21609
  t6.value.processProtectionCallback?.();
@@ -21648,15 +21691,16 @@ class aw {
21648
21691
  const e3 = i2().value;
21649
21692
  if (!e3.currentName) return;
21650
21693
  if (e3.currentName.toLowerCase() === t6.toLowerCase()) return;
21651
- s2._protectionCheck(() => ["objects"]);
21652
- const n3 = s2._beginCommit({ description: "Set Table Name" });
21694
+ const n3 = "Set Table Name";
21695
+ s2._protectionCheck(() => ["objects"], void 0, n3);
21696
+ const r3 = s2._beginCommit({ description: n3 });
21653
21697
  try {
21654
- const r3 = s2._getState()?.tableMapName, o3 = t6.toLocaleLowerCase();
21655
- if (r3.has(o3)) throw new Error(((t7) => `Name must be unique: '${t7}' is already in use.`)(t6));
21656
- const i3 = new Map(r3);
21657
- i3.delete(e3.currentName), e3.currentName = o3, i3.set(o3, e3.model), s2._updateState({ tableMapName: i3 }), n3.commit();
21698
+ const n4 = s2._getState()?.tableMapName, o3 = t6.toLocaleLowerCase();
21699
+ if (n4.has(o3)) throw new Error(((t7) => `Name must be unique: '${t7}' is already in use.`)(t6));
21700
+ const i3 = new Map(n4);
21701
+ i3.delete(e3.currentName), e3.currentName = o3, i3.set(o3, e3.model), s2._updateState({ tableMapName: i3 }), r3.commit();
21658
21702
  } catch (t7) {
21659
- throw n3.rollback(), t7;
21703
+ throw r3.rollback(), t7;
21660
21704
  }
21661
21705
  }, setContainerCoords(t6, e3) {
21662
21706
  if (!t6) return;
@@ -21671,13 +21715,14 @@ class aw {
21671
21715
  }, deleteFromContainer(t6) {
21672
21716
  const e3 = i2();
21673
21717
  if (!e3) return;
21674
- s2._protectionCheck(() => ["objects"]);
21675
- const n3 = e3.value.model, r3 = s2._beginCommit({ description: t6?.description ?? `Delete Table '${n3.getName()}` }), o3 = s2._getState(), l3 = o3.tableSpatial.clone(), c3 = o3.tableMapModel, h2 = new Map(c3), u2 = o3.tableMapName, d2 = new Map(u2);
21676
- l3.remove(e3, a2), h2.delete(n3), d2.delete(n3.getName().toLocaleLowerCase()), e3.value.processDeleteCallback?.(), s2._updateState({ tableSpatial: l3, tableMapModel: h2, tableMapName: d2 }), s2._emitter.notify("onTablesChange"), r3.commit({ viewAfter: { sheet: s2, view: s2.getView(), selection: Af([n3.getAnchorCoords()]) } });
21718
+ const n3 = e3.value.model, r3 = t6?.description ?? `Delete Table '${n3.getName()}`;
21719
+ s2._protectionCheck(() => ["objects"], void 0, r3);
21720
+ const o3 = s2._beginCommit({ description: r3 }), l3 = s2._getState(), c3 = l3.tableSpatial.clone(), h2 = l3.tableMapModel, u2 = new Map(h2), d2 = l3.tableMapName, g2 = new Map(d2);
21721
+ c3.remove(e3, a2), u2.delete(n3), g2.delete(n3.getName().toLocaleLowerCase()), e3.value.processDeleteCallback?.(), s2._updateState({ tableSpatial: c3, tableMapModel: u2, tableMapName: g2 }), s2._emitter.notify("onTablesChange"), o3.commit({ viewAfter: { sheet: s2, view: s2.getView(), selection: Af([n3.getAnchorCoords()]) } });
21677
21722
  }, setContainerDeleteCallback(t6) {
21678
21723
  const e3 = i2()?.value ?? n2;
21679
21724
  e3 && (e3.processDeleteCallback = t6, e3.removeListener?.());
21680
- }, isProtected: () => s2.getProtection().isLocked(), setContainerProtectionCallback(t6) {
21725
+ }, isProtected: () => !s2._initializing && s2.getProtection().isLocked(), setContainerProtectionCallback(t6) {
21681
21726
  (i2()?.value ?? n2).processProtectionCallback = t6;
21682
21727
  }, setContainerShiftCallback(t6) {
21683
21728
  (i2()?.value ?? n2).processShiftCallback = t6;
@@ -21777,9 +21822,10 @@ class aw {
21777
21822
  if (u2) return;
21778
21823
  const r3 = i2();
21779
21824
  if (!r3) return;
21780
- c2._protectionCheck(() => ["objects"]);
21781
- const o3 = c2._beginCommit({ description: e3 ?? "Update Drawing" }), a3 = c2._getState()?.movableSpatial, l3 = a3.clone(), h3 = c2._getState()?.movableMapModel, d3 = new Map(h3);
21782
- false !== t6(r3, l3, d3) && (c2._updateState({ movableSpatial: l3, movableMapModel: d3 }), n3 && (c2._emitterMovables.notify("onCollectionChange", { source: c2, transactional: true }), c2._emitter.notify("onMovablesChange")), o3.commit({ viewAfter: (t7) => {
21825
+ const o3 = e3 ?? "Update Drawing";
21826
+ c2._protectionCheck(() => ["objects"], void 0, o3);
21827
+ const a3 = c2._beginCommit({ description: o3 }), l3 = c2._getState()?.movableSpatial, h3 = l3.clone(), d3 = c2._getState()?.movableMapModel, g3 = new Map(d3);
21828
+ false !== t6(r3, h3, g3) && (c2._updateState({ movableSpatial: h3, movableMapModel: g3 }), n3 && (c2._emitterMovables.notify("onCollectionChange", { source: c2, transactional: true }), c2._emitter.notify("onMovablesChange")), a3.commit({ viewAfter: (t7) => {
21783
21829
  if (s2.value.model.isSelected() && !t7?.movableSelection?.includes(s2.value.model)) {
21784
21830
  const e4 = [...t7?.movableSelection ?? []];
21785
21831
  return e4.push(s2.value.model), { ...t7, view: this.getView(), movableSelection: e4 };
@@ -21856,7 +21902,7 @@ class aw {
21856
21902
  for (let t7 = 0; t7 < r3; t7++) n3[t7].value.processZIndexCallback?.();
21857
21903
  }, setContainerDeleteCallback(t6) {
21858
21904
  (i2()?.value ?? o2).processDeleteCallback = t6;
21859
- }, isProtected: () => !c2.getProtection().isObjectsAllowed(), setContainerProtectionCallback(t6) {
21905
+ }, isProtected: () => !c2._initializing && !c2.getProtection().isObjectsAllowed(), setContainerProtectionCallback(t6) {
21860
21906
  (i2()?.value ?? o2).processProtectionCallback = t6;
21861
21907
  }, setContainerShiftCallback(t6) {
21862
21908
  (i2()?.value ?? o2).processShiftCallback = t6;
@@ -22049,10 +22095,10 @@ class aw {
22049
22095
  }
22050
22096
  const lw = { address: null, scope: null }, cw = { colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }, hw = { colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }, uw = { colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }, dw = { includeHidden: false };
22051
22097
  Object.freeze({ [wd.Content.Values]: Number.MAX_SAFE_INTEGER, [wd.Content.Formulas]: Number.MAX_SAFE_INTEGER }), Object.freeze({ [wd.Content.Values]: 1, [wd.Content.Formulas]: 1 });
22052
- const gw = { ignoreDataChanges: false }, mw = { colStart: -1, rowStart: -1, colEnd: -1, rowEnd: -1 }, fw = [{ colIndex: -1, rowIndex: -1 }, null, null, null, null], pw = [wd.Content.Values], _w = { size: null, autoSize: true }, Sw = { skipCustomSize: true, expandOnly: true, minContent: true }, ww = { showFormulaBar: true, showTabs: true, tabRatio: 600, showHorizontalScrollbar: true, showVerticalScrollbar: true, showStatusBar: true, activeSheetId: null };
22053
- class yw {
22098
+ const gw = { ignoreDataChanges: false }, mw = { colStart: -1, rowStart: -1, colEnd: -1, rowEnd: -1 }, fw = [{ colIndex: -1, rowIndex: -1 }, null, null, null, null], pw = [wd.Content.Values], _w = { size: null, autoSize: true }, Sw = { skipCustomSize: true, expandOnly: true, minContent: true }, ww = { rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }, yw = { showFormulaBar: true, showTabs: true, tabRatio: 600, showHorizontalScrollbar: true, showVerticalScrollbar: true, showStatusBar: true, activeSheetId: null };
22099
+ class Ew {
22054
22100
  constructor(t5) {
22055
- this._emitter = null, this._emitter = new yl(this), this._state = { ...ww }, t5?.json && this._fromJSON(t5?.json);
22101
+ this._emitter = null, this._emitter = new yl(this), this._state = { ...yw }, t5?.json && this._fromJSON(t5?.json);
22056
22102
  }
22057
22103
  isShowFormulaBar() {
22058
22104
  return this._state.showFormulaBar;
@@ -22104,7 +22150,7 @@ class yw {
22104
22150
  const e2 = Object.keys(this._state);
22105
22151
  for (let n2 = 0; n2 < e2.length; n2++) {
22106
22152
  const r2 = this._state[e2[n2]];
22107
- null != r2 && r2 !== ww[e2[n2]] && (t5[e2[n2]] = r2);
22153
+ null != r2 && r2 !== yw[e2[n2]] && (t5[e2[n2]] = r2);
22108
22154
  }
22109
22155
  return 0 === Object.keys(t5).length && (t5 = null), t5;
22110
22156
  }
@@ -22113,10 +22159,10 @@ class yw {
22113
22159
  this.update(n2, e2);
22114
22160
  }
22115
22161
  update(t5, e2 = true) {
22116
- this._state = { ...ww, ...this._state, ...t5 }, e2 && this._emitter.notify("onViewChange");
22162
+ this._state = { ...yw, ...this._state, ...t5 }, e2 && this._emitter.notify("onViewChange");
22117
22163
  }
22118
22164
  }
22119
- class Ew {
22165
+ class bw {
22120
22166
  constructor(t5) {
22121
22167
  this._emitter = null, this._closed = false, this._options = { ...t5 };
22122
22168
  const e2 = this;
@@ -22224,10 +22270,10 @@ class Ew {
22224
22270
  return true;
22225
22271
  }
22226
22272
  }
22227
- let bw;
22228
- const Cw = "SheetXL", vw = bw || (bw = bt.deepFreeze({ ISheet: { Visibility: G_.Visibility }, ICell: { Content: wd.Content, CalcStatus: wd.CalcStatus }, IColor: { Named: aa.Named, Scheme: aa.Scheme, Type: aa.Type, AdjustmentType: aa.AdjustmentType }, Direction: v }), bw);
22229
- let xw;
22230
- class Iw extends p_ {
22273
+ let Cw;
22274
+ const vw = "SheetXL", xw = Cw || (Cw = bt.deepFreeze({ ISheet: { Visibility: G_.Visibility }, ICell: { Content: wd.Content, CalcStatus: wd.CalcStatus }, IColor: { Named: aa.Named, Scheme: aa.Scheme, Type: aa.Type, AdjustmentType: aa.AdjustmentType }, Direction: v }), Cw);
22275
+ let Iw;
22276
+ class Rw extends p_ {
22231
22277
  constructor(t5, e2, n2, r2 = null, o2 = false) {
22232
22278
  super(t5, e2, n2, r2, o2);
22233
22279
  }
@@ -22275,9 +22321,9 @@ class Iw extends p_ {
22275
22321
  }({});
22276
22322
  }
22277
22323
  try {
22278
- g_({ getPosition: () => n4.getCell().getCoords() }), xw = globalThis[Cw], globalThis[Cw] = vw;
22324
+ g_({ getPosition: () => n4.getCell().getCoords() }), Iw = globalThis[vw], globalThis[vw] = xw;
22279
22325
  const e3 = this._fn;
22280
- o2 = e3.call(s2, ...t6), xw ? (globalThis[Cw] = xw, xw = void 0) : delete globalThis[Cw], m_();
22326
+ o2 = e3.call(s2, ...t6), Iw ? (globalThis[vw] = Iw, Iw = void 0) : delete globalThis[vw], m_();
22281
22327
  } catch (t7) {
22282
22328
  throw t7;
22283
22329
  } finally {
@@ -22294,7 +22340,7 @@ class Iw extends p_ {
22294
22340
  }
22295
22341
  }
22296
22342
  }
22297
- class Rw {
22343
+ class Aw {
22298
22344
  constructor(t5) {
22299
22345
  this._emitter = null;
22300
22346
  const e2 = t5.json;
@@ -22323,7 +22369,7 @@ class Rw {
22323
22369
  return this._json;
22324
22370
  }
22325
22371
  }
22326
- const Aw = async (t5, e2) => {
22372
+ const Mw = async (t5, e2) => {
22327
22373
  let n2 = null;
22328
22374
  try {
22329
22375
  g_(null);
@@ -22347,17 +22393,17 @@ const Aw = async (t5, e2) => {
22347
22393
  let o2 = n2[r2];
22348
22394
  if (!o2 && e2.behavior.default && (o2 = n2.default), !o2) throw new Error(`Found the descriptor for '${r2}' but not the function. The descriptor manifest must be corrupt.`);
22349
22395
  return o2;
22350
- }, Mw = async (t5, e2 = false) => {
22396
+ }, Tw = async (t5, e2 = false) => {
22351
22397
  const n2 = t5?.functions, r2 = /* @__PURE__ */ new Map();
22352
22398
  if (n2) for (let o2 = 0; o2 < n2.length; o2++) {
22353
22399
  const s2 = n2[o2], i2 = s2[0], a2 = s2[1];
22354
22400
  let l2, c2 = e2 ? () => {
22355
- } : await Aw(t5, i2);
22356
- l2 = i2.context && i2.context !== f_.Context.Calculation ? new Iw(i2, c2, () => null, a2) : new p_(i2, c2, () => null, a2), r2.set(i2.name.toUpperCase(), l2);
22401
+ } : await Mw(t5, i2);
22402
+ l2 = i2.context && i2.context !== f_.Context.Calculation ? new Rw(i2, c2, () => null, a2) : new p_(i2, c2, () => null, a2), r2.set(i2.name.toUpperCase(), l2);
22357
22403
  }
22358
- return new Rw({ json: t5, readonlyFunctions: r2 });
22404
+ return new Aw({ json: t5, readonlyFunctions: r2 });
22359
22405
  };
22360
- class Tw {
22406
+ class Nw {
22361
22407
  constructor(t5) {
22362
22408
  this._options = t5, this._initState();
22363
22409
  }
@@ -22367,8 +22413,8 @@ class Tw {
22367
22413
  return this._modules;
22368
22414
  }
22369
22415
  async createModule(t5) {
22370
- const e2 = await import("./DRS_JwYa09Hf895m.mjs"), n2 = await e2.ScriptingUtils.compileTypescript(t5);
22371
- return n2 ? await Mw(n2, t5?.declarationsOnly ?? false) : null;
22416
+ const e2 = await import("./bz-ja27axdBXn18A.mjs"), n2 = await e2.ScriptingUtils.compileTypescript(t5);
22417
+ return n2 ? await Tw(n2, t5?.declarationsOnly ?? false) : null;
22372
22418
  }
22373
22419
  addModule(t5, e2, n2) {
22374
22420
  this._modules.add(t5, e2, n2);
@@ -22404,11 +22450,11 @@ class Tw {
22404
22450
  if (e2) {
22405
22451
  const t6 = Object.keys(e2);
22406
22452
  for (let r3 = 0; r3 < t6.length; r3++) {
22407
- const o3 = t6[r3], s3 = e2[o3], i2 = await Mw(s3);
22453
+ const o3 = t6[r3], s3 = e2[o3], i2 = await Tw(s3);
22408
22454
  n2[o3] = i2;
22409
22455
  }
22410
22456
  }
22411
- const r2 = new Ew({ transactions: this._options?.transactions, initial: n2, onRemove: this._options?.onRemove, onAdd: this._options?.onAdd });
22457
+ const r2 = new bw({ transactions: this._options?.transactions, initial: n2, onRemove: this._options?.onRemove, onAdd: this._options?.onAdd });
22412
22458
  this._modules = r2;
22413
22459
  const o2 = r2.search();
22414
22460
  if (0 === o2.length) return Promise.resolve(bt.EmptyArray);
@@ -22432,8 +22478,8 @@ class Tw {
22432
22478
  return t5.toJSON();
22433
22479
  }
22434
22480
  }
22435
- const Nw = Object.freeze({ lockStructure: false, lockWindows: false, lockRevision: false, workbookPassword: null, revisionsPassword: null });
22436
- class Fw extends JS {
22481
+ const Fw = Object.freeze({ lockStructure: false, lockWindows: false, lockRevision: false, workbookPassword: null, revisionsPassword: null });
22482
+ class kw extends JS {
22437
22483
  isWindowsAllowed() {
22438
22484
  return this._isPropertyAllowed("windows");
22439
22485
  }
@@ -22450,17 +22496,17 @@ class Fw extends JS {
22450
22496
  let e2 = this._properties;
22451
22497
  if (e2) {
22452
22498
  t5 = { ...t5, ...e2 };
22453
- const n2 = Object.keys(e2);
22454
- for (let r2 = 0; r2 < n2.length; r2++) {
22455
- const o2 = e2[n2[r2]];
22456
- null != o2 && o2 !== Nw[n2[r2]] && (t5[n2[r2]] = o2);
22499
+ const n2 = Object.keys(e2), r2 = n2.length;
22500
+ for (let o2 = 0; o2 < r2; o2++) {
22501
+ const r3 = n2[o2], s2 = e2[r3];
22502
+ null != s2 && s2 !== Fw[r3] && (t5[r3] = s2);
22457
22503
  }
22458
22504
  }
22459
22505
  return super._toJSON(t5);
22460
22506
  }
22461
22507
  }
22462
- const kw = (t5) => `Invalid SheetKey: ${t5}`, Ow = "A workbook must contain at least one visible worksheet.", Dw = "Internal error no visible sheetRefs", Lw = "Workbook has been closed. No further operations are allowed.", Bw = "This workbook structure is protected. To make a change, unprotect the workbook. You might be requested to enter a password.", zw = "A sheet name", Pw = `${zw} can not be blank.`, jw = `${zw} can not be longer than 31 characters.`, $w = `${zw} can not begin or end with a "'" (single quote).`;
22463
- class Hw {
22508
+ const Ow = (t5) => `Invalid SheetKey: ${t5}`, Dw = "A workbook must contain at least one visible worksheet.", Lw = "Internal error no visible sheetRefs", Bw = "Workbook has been closed. No further operations are allowed.", zw = "This workbook structure is protected. To make a change, unprotect the workbook. You might be requested to enter a password.", Pw = "A sheet name", jw = `${Pw} can not be blank.`, $w = `${Pw} can not be longer than 31 characters.`, Hw = `${Pw} can not begin or end with a "'" (single quote).`;
22509
+ class Vw {
22464
22510
  constructor(t5, e2) {
22465
22511
  this._add = t5, this._get = e2;
22466
22512
  }
@@ -22477,25 +22523,25 @@ class Hw {
22477
22523
  return this._get().length;
22478
22524
  }
22479
22525
  }
22480
- const Vw = new RegExp(/[\\/\\*?:[\]]+/), Gw = new RegExp(/\(((\d+)(?!.*\d))\)$/, "g"), Uw = (t5) => `Sheet${t5 + 1}`, Ww = (t5, e2) => ({ ...df, getSource: () => null, toString: () => fu(t5, e2) }), qw = (t5, e2 = false) => {
22481
- if (!t5) throw new Error(Pw);
22482
- if (Vw.test(t5)) {
22483
- if (!e2) throw new Error(((t6) => `${t6 ? `'${t6}'` : zw} can not contain any of the following characters '\\ , / , * , ? , : , [ , ]'.`)(t5));
22484
- t5 = t5.replace(Vw, "");
22526
+ const Gw = new RegExp(/[\\/\\*?:[\]]+/), Uw = new RegExp(/\(((\d+)(?!.*\d))\)$/, "g"), Ww = (t5) => `Sheet${t5 + 1}`, qw = (t5, e2) => ({ ...df, getSource: () => null, toString: () => fu(t5, e2) }), Jw = (t5, e2 = false) => {
22527
+ if (!t5) throw new Error(jw);
22528
+ if (Gw.test(t5)) {
22529
+ if (!e2) throw new Error(((t6) => `${t6 ? `'${t6}'` : Pw} can not contain any of the following characters '\\ , / , * , ? , : , [ , ]'.`)(t5));
22530
+ t5 = t5.replace(Gw, "");
22485
22531
  }
22486
- if (0 === t5.length) throw new Error(Pw);
22532
+ if (0 === t5.length) throw new Error(jw);
22487
22533
  const n2 = t5.length;
22488
22534
  if (n2 > 31) {
22489
- if (!e2) throw new Error(jw);
22535
+ if (!e2) throw new Error($w);
22490
22536
  t5 = t5.substring(0, 31);
22491
22537
  }
22492
22538
  if ("'" === t5.charAt(0) || "'" === t5.charAt(n2 - 1)) {
22493
- if (!e2) throw new Error($w);
22539
+ if (!e2) throw new Error(Hw);
22494
22540
  t5 = t5.replace(/^'|'$/g, "");
22495
22541
  }
22496
22542
  return t5;
22497
22543
  };
22498
- class Jw extends YS {
22544
+ class Kw extends YS {
22499
22545
  constructor(t5, e2, n2, r2) {
22500
22546
  super(t5, e2, r2), this._workbook = n2;
22501
22547
  }
@@ -22504,16 +22550,16 @@ class Jw extends YS {
22504
22550
  }
22505
22551
  _createRanges(t5, e2) {
22506
22552
  let n2 = this._options;
22507
- return e2 && (n2 = { ...this._options, getOptions: bf(this._options?.getOptions, e2) }), new Jw(t5, this._sheet, this._workbook, n2);
22553
+ return e2 && (n2 = { ...this._options, getOptions: bf(this._options?.getOptions, e2) }), new Kw(t5, this._sheet, this._workbook, n2);
22508
22554
  }
22509
22555
  _createRange(t5, e2) {
22510
22556
  const n2 = t5 ? { ...t5 } : null;
22511
22557
  if (!(n2 ? this._workbook._getSheetRef(n2.sheetName, G_.Visibility.VeryHidden) : null)) {
22512
22558
  const t6 = this._workbook.getSelectedSheet();
22513
- return delete n2?.sheetName, Ww(n2, n2 ? { sheetName: Zh, ...t6.getEntireRange().getCoords() } : null);
22559
+ return delete n2?.sheetName, qw(n2, n2 ? { sheetName: Zh, ...t6.getEntireRange().getCoords() } : null);
22514
22560
  }
22515
22561
  let r2 = this._options;
22516
- return e2 && (r2 = { ...this._options, getOptions: bf(this._options.getOptions, e2) }), new Kw(t5, this._sheet, this._workbook, r2);
22562
+ return e2 && (r2 = { ...this._options, getOptions: bf(this._options.getOptions, e2) }), new Xw(t5, this._sheet, this._workbook, r2);
22517
22563
  }
22518
22564
  async select(t5) {
22519
22565
  const e2 = [];
@@ -22543,20 +22589,20 @@ class Jw extends YS {
22543
22589
  return yu(t5, r2, fu, cu);
22544
22590
  }
22545
22591
  }
22546
- class Kw extends ZS {
22592
+ class Xw extends ZS {
22547
22593
  constructor(t5, e2, n2, r2) {
22548
22594
  super(t5, e2, r2), this._workbook = n2;
22549
22595
  }
22550
22596
  _createRanges(t5, e2) {
22551
22597
  let n2 = this._options;
22552
- return e2 && (n2 = { ...this._options, getOptions: bf(this._options?.getOptions, e2) }), new Jw(t5, this._sheet, this._workbook, n2);
22598
+ return e2 && (n2 = { ...this._options, getOptions: bf(this._options?.getOptions, e2) }), new Kw(t5, this._sheet, this._workbook, n2);
22553
22599
  }
22554
22600
  _createRange(t5, e2) {
22555
22601
  const n2 = this._sheet;
22556
22602
  if (!t5) return gf(n2, n2._entireCoords);
22557
22603
  if (n2._validateCoords(t5), n2._closed) return gf(null, n2._entireCoords, t5);
22558
22604
  let r2 = this._options;
22559
- return e2 && (r2 = { ...this._options, getOptions: bf(this._options?.getOptions, e2) }), new Kw(t5, this._sheet, this._workbook, r2);
22605
+ return e2 && (r2 = { ...this._options, getOptions: bf(this._options?.getOptions, e2) }), new Xw(t5, this._sheet, this._workbook, r2);
22560
22606
  }
22561
22607
  getSource() {
22562
22608
  return this._workbook;
@@ -22575,18 +22621,18 @@ class Kw extends ZS {
22575
22621
  return super.addListener(n2, e2);
22576
22622
  }
22577
22623
  }
22578
- class Xw {
22624
+ class Yw {
22579
22625
  constructor(t5) {
22580
- this._lastTransactionUUID = null, this._emitter = null, this._names = null, this._calculation = null, this._isDate1904 = false, this._closed = false;
22626
+ this._lastTransactionUUID = null, this._closed = false, this._initializing = true, this._emitter = null, this._names = null, this._calculation = null, this._isDate1904 = false;
22581
22627
  const e2 = this, n2 = { ...t5 }, r2 = n2.json;
22582
22628
  delete n2.json, this._transactions = n2.transactions ?? new ue(), this._ownTransactions = !n2.transactions, this._emitter = new yl(this, this._transactions);
22583
22629
  const o2 = this._beginCommit({ description: (r2 ? "Open" : "New") + " Workbook" });
22584
22630
  try {
22585
- this._strings = n2.strings ?? new hp(), this._ownStrings = !n2.strings, this._resources = n2.resources ?? new lp(), this._ownResources = !n2.resources, this._createSheetName = n2.createSheetNameCallback ?? Uw;
22631
+ this._strings = n2.strings ?? new hp(), this._ownStrings = !n2.strings, this._resources = n2.resources ?? new lp(), this._ownResources = !n2.resources, this._createSheetName = n2.createSheetNameCallback ?? Ww;
22586
22632
  let t6 = n2.createSheetCallback;
22587
22633
  t6 || (t6 = (t7) => new aw(t7)), this._sheetOnNameChange = /* @__PURE__ */ new Map(), this._sheetOnVisibilityChange = /* @__PURE__ */ new Map(), this._sheetOnIndexChange = /* @__PURE__ */ new Map(), this._createSheet = (n3, r3, o3, s3, i2) => {
22588
22634
  let a2 = null;
22589
- const l2 = { date1904: e2.isDate1904(), transactions: e2._transactions, styles: e2._styles, strings: e2._strings, resources: e2._resources, names: e2._names, calculation: e2._calculation, resolveRange: (t7) => e2._options.resolveRange?.(t7) ?? e2.getRange(t7), container: { beforeFromJSON: (t7) => {
22635
+ const l2 = { date1904: e2.isDate1904(), readonly: e2._options.readonly ?? false, transactions: e2._transactions, styles: e2._styles, strings: e2._strings, resources: e2._resources, names: e2._names, calculation: e2._calculation, resolveRange: (t7) => e2._options.resolveRange?.(t7) ?? e2.getRange(t7), container: { beforeFromJSON: (t7) => {
22590
22636
  a2 = t7, e2._addSheetRef({ name: r3, id: n3, visibility: o3 ?? G_.Visibility.Visible, sheet: t7 }, s3);
22591
22637
  }, getName: () => {
22592
22638
  const t7 = e2._getSheetRef(a2);
@@ -22612,10 +22658,10 @@ class Xw {
22612
22658
  return !!n4 && (e2._moveSheet(n4, t7), true);
22613
22659
  }, requestSelect: async () => (e2._setSelectedSheet(a2), await this._emitter.notify("onRequestSelect", { source: e2, params: a2, async: true }), e2.getSelectedSheet() === a2) } };
22614
22660
  return i2 && (l2.json = i2), a2 = t6(l2, r3, s3, o3), a2;
22615
- }, this._names = n2.names ?? new eS({ addressToRanges: (t7) => e2.getRanges(t7), getCurrentScope: () => e2.getSelectedSheet().getName(), transactions: e2._transactions }), this._ownNames = !n2.names, this._calculation = n2.calculation ?? new R_({ getNamed: (t7, e3) => {
22661
+ }, this._names = n2.names ?? new eS({ addressToRanges: (t7) => e2.getRanges(t7), getCurrentScope: () => e2.getSelectedSheet().getName(), isReadOnly: () => e2._options.readonly ?? false, transactions: e2._transactions }), this._ownNames = !n2.names, this._calculation = n2.calculation ?? new R_({ getNamed: (t7, e3) => {
22616
22662
  try {
22617
- Yw.address = t7, Yw.scope = e3;
22618
- const n3 = this._names.search(Yw);
22663
+ Zw.address = t7, Zw.scope = e3;
22664
+ const n3 = this._names.search(Zw);
22619
22665
  return n3 && 0 !== n3.length ? n3[0].getRanges().getCoords() : null;
22620
22666
  } catch (t8) {
22621
22667
  return null;
@@ -22626,8 +22672,8 @@ class Xw {
22626
22672
  t7 = t7.toLowerCase();
22627
22673
  for (let e3 = 0; e3 < n3.length; e3++) if (n3[e3].name.toLowerCase() === t7) return e3;
22628
22674
  try {
22629
- Yw.address = t7, Yw.scope = void 0;
22630
- const e3 = this._names.search(Yw);
22675
+ Zw.address = t7, Zw.scope = void 0;
22676
+ const e3 = this._names.search(Zw);
22631
22677
  if (!e3 || 0 === e3.length) return -1;
22632
22678
  const n4 = e3[0].getRanges().getCoords()?.[0];
22633
22679
  let r3 = n4?.sheetName;
@@ -22647,12 +22693,12 @@ class Xw {
22647
22693
  } catch (t6) {
22648
22694
  throw o2.rollback(), t6;
22649
22695
  }
22650
- this._sheets = new Hw((t6) => e2._addSheetOptions(t6), (t6, e3) => t6 ? [this.getSheet(t6, e3)] : this._getSheets(e3));
22696
+ this._sheets = new Vw((t6) => e2._addSheetOptions(t6), (t6, e3) => t6 ? [this.getSheet(t6, e3)] : this._getSheets(e3)), this._initializing = false;
22651
22697
  }
22652
22698
  _initState() {
22653
22699
  let t5 = this._getSheetRefs();
22654
22700
  for (let e3 = t5 && t5.length - 1; e3 >= 0; e3--) ;
22655
- this._isDate1904 = this._options.date1904 ?? false, this._theme = this._options.theme ?? new fl().getDefaultTheme(), this._styles = this._options?.styles ?? new rp(this._theme), this._ownStyles = !this._options.styles, this._styles.getTheme() || this._styles.setTheme(this.getTheme()), this._activeSheetOffset = 0, this.setView(new yw()), this._listenerProtection?.(), this._protection = new Fw(), this._listenerProtection = this._protection.addListeners({ onChange: (t6) => {
22701
+ this._isDate1904 = this._options.date1904 ?? false, this._theme = this._options.theme ?? new fl().getDefaultTheme(), this._styles = this._options?.styles ?? new rp(this._theme), this._ownStyles = !this._options.styles, this._styles.getTheme() || this._styles.setTheme(this.getTheme()), this._activeSheetOffset = 0, this.setView(new Ew()), this._listenerProtection?.(), this._protection = new kw(void 0, this._options.readonly ?? false), this._listenerProtection = this._protection.addListeners({ onChange: (t6) => {
22656
22702
  e2._emitter.notify("onProtectionChange");
22657
22703
  } });
22658
22704
  const e2 = this;
@@ -22680,7 +22726,7 @@ class Xw {
22680
22726
  return this._view;
22681
22727
  }
22682
22728
  setView(t5) {
22683
- if (this._closed) throw new Error(Lw);
22729
+ if (this._closed) throw new Error(Bw);
22684
22730
  if (!t5) throw new Error("View can not be empty.");
22685
22731
  this._listenerWorkbookView?.();
22686
22732
  const e2 = this;
@@ -22693,7 +22739,7 @@ class Xw {
22693
22739
  return this._isDate1904;
22694
22740
  }
22695
22741
  setDate1904(t5) {
22696
- if (this._closed) throw new Error(Lw);
22742
+ if (this._closed) throw new Error(Bw);
22697
22743
  return this._isDate1904 = t5, this._notifyAllChange(), this;
22698
22744
  }
22699
22745
  getStyles() {
@@ -22712,7 +22758,7 @@ class Xw {
22712
22758
  return this._theme;
22713
22759
  }
22714
22760
  setTheme(t5) {
22715
- if (this._closed) throw new Error(Lw);
22761
+ if (this._closed) throw new Error(Bw);
22716
22762
  if (!t5) throw new Error("A value must be provided.");
22717
22763
  const e2 = this._theme;
22718
22764
  return this._theme = t5, this.getStyles().setTheme(t5), this._emitter.notify("onThemeChange"), e2;
@@ -22757,18 +22803,18 @@ class Xw {
22757
22803
  }
22758
22804
  _validateNewSheetName(t5, e2 = true) {
22759
22805
  if (null == t5) return t5;
22760
- if (qw(t5), e2 && this._getState().sheetsByLowerCaseName.has(t5.toLowerCase())) throw new Error("That name is already taken. Try a different one.");
22806
+ if (Jw(t5), e2 && this._getState().sheetsByLowerCaseName.has(t5.toLowerCase())) throw new Error("That name is already taken. Try a different one.");
22761
22807
  return t5.substring(0, 31);
22762
22808
  }
22763
22809
  findValidSheetName(t5) {
22764
- t5 && (t5 = qw(t5, true));
22810
+ t5 && (t5 = Jw(t5, true));
22765
22811
  try {
22766
22812
  return ((t6, e2) => {
22767
22813
  try {
22768
22814
  if (e2(t6)) return t6;
22769
22815
  } catch (t7) {
22770
22816
  }
22771
- let n2, r2, o2 = Gw.exec(t6);
22817
+ let n2, r2, o2 = Uw.exec(t6);
22772
22818
  for (null !== o2 ? (n2 = t6.substring(0, o2.index), r2 = parseFloat(o2[1])) : (n2 = t6 + " ", r2 = 1); r2 < 256; ) {
22773
22819
  r2++;
22774
22820
  const t7 = "(" + r2 + ")", o3 = n2.substring(0, 31 - t7.length) + t7;
@@ -22784,11 +22830,11 @@ class Xw {
22784
22830
  }
22785
22831
  }
22786
22832
  isValidSheetNameCharacter(t5) {
22787
- return !Vw.test(t5);
22833
+ return !Gw.test(t5);
22788
22834
  }
22789
22835
  _addSheetOptions(t5) {
22790
- if (this._closed) throw new Error(Lw);
22791
- if (!this.getProtection().isStructureAllowed()) throw new Error(Bw);
22836
+ if (this._closed) throw new Error(Bw);
22837
+ if (!this.getProtection().isStructureAllowed()) throw new Error(zw);
22792
22838
  let e2 = null;
22793
22839
  t5 = { ...t5, description: t5?.description ?? "Add Sheet" };
22794
22840
  const n2 = this.beginCommit(t5);
@@ -22824,12 +22870,12 @@ class Xw {
22824
22870
  _addSheet(t5, e2 = null, n2 = null) {
22825
22871
  e2 = this._nextSheetName(e2);
22826
22872
  const r2 = this._getState(), o2 = this._createSheet(r2.lastId, e2, G_.Visibility.Visible, n2, null);
22827
- if (!o2) throw new Error(Pw);
22873
+ if (!o2) throw new Error(jw);
22828
22874
  return t5 && this._emitter.notify("onSheetsChange"), o2;
22829
22875
  }
22830
22876
  _updateSheetRefStates(t5) {
22831
- if (this._closed) throw new Error(Lw);
22832
- if (!this.getProtection().isStructureAllowed()) throw new Error(Bw);
22877
+ if (this._closed) throw new Error(Bw);
22878
+ if (!this._initializing && !this.getProtection().isStructureAllowed()) throw new Error(zw);
22833
22879
  const e2 = t5, n2 = [], r2 = [];
22834
22880
  for (let t6 = 0; t6 < e2.length; t6++) e2[t6].visibility === G_.Visibility.Visible ? (n2.push(e2[t6]), r2.push(e2[t6])) : e2[t6].visibility === G_.Visibility.Hidden && r2.push(e2[t6]);
22835
22881
  this._updateState({ sheetRefsAll: e2, sheetRefsVisible: n2, sheetRefsVisibleAndHidden: r2 });
@@ -22902,19 +22948,19 @@ class Xw {
22902
22948
  t5.refsById.get(n2).visibility === G_.Visibility.Visible && (this._activeSheetOffset = this._findOffsetForId(n2, t5.sheetRefsVisible));
22903
22949
  }
22904
22950
  _validateDeleteSheet(t5) {
22905
- if (this._closed) throw new Error(Lw);
22906
- if (!this.getProtection().isStructureAllowed()) throw new Error(Bw);
22951
+ if (this._closed) throw new Error(Bw);
22952
+ if (!this.getProtection().isStructureAllowed()) throw new Error(zw);
22907
22953
  let e2 = this._getSheetRef(t5);
22908
22954
  if (!e2) throw new Error(((t6) => `Invalid reference for delete: ${t6}`)(t5));
22909
22955
  const n2 = this._getState().sheetRefsVisible;
22910
- if (1 === n2.length && n2[0].id === e2.id) throw new Error(Ow);
22956
+ if (1 === n2.length && n2[0].id === e2.id) throw new Error(Dw);
22911
22957
  }
22912
22958
  _findOffsetForId(t5, e2) {
22913
22959
  for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2].id === t5) return n2;
22914
- throw new Error(Dw);
22960
+ throw new Error(Lw);
22915
22961
  }
22916
22962
  find(t5, e2) {
22917
- if (this._closed) throw new Error(Lw);
22963
+ if (this._closed) throw new Error(Bw);
22918
22964
  const n2 = this._getSheets();
22919
22965
  if (1 === n2.length) return n2[0].find(t5, e2);
22920
22966
  const r2 = !e2?.reverse;
@@ -22969,22 +23015,22 @@ class Xw {
22969
23015
  return 1 === e2.length ? 0 : (void 0 === t5 && (t5 = this.getSelectedSheetIndex()), (t5 = Math.max(0, Math.min(t5, e2.length - 1))) <= 0 ? e2.length - 1 : t5 - 1);
22970
23016
  }
22971
23017
  getNextSheet(t5) {
22972
- if (this._closed) throw new Error(Lw);
23018
+ if (this._closed) throw new Error(Bw);
22973
23019
  const e2 = this._getSheetRefs();
22974
23020
  return e2[this._nextSheetIndex(t5, e2)]?.sheet ?? null;
22975
23021
  }
22976
23022
  getPreviousSheet(t5) {
22977
- if (this._closed) throw new Error(Lw);
23023
+ if (this._closed) throw new Error(Bw);
22978
23024
  const e2 = this._getSheetRefs();
22979
23025
  return e2[this._prevSheetIndex(t5, e2)]?.sheet ?? null;
22980
23026
  }
22981
23027
  async _duplicateSheet(t5) {
22982
- if (this._closed) throw new Error(Lw);
22983
- if (!this.getProtection().isStructureAllowed()) throw new Error(Bw);
23028
+ if (this._closed) throw new Error(Bw);
23029
+ if (!this.getProtection().isStructureAllowed()) throw new Error(zw);
22984
23030
  const e2 = this._getSheetRefs(), n2 = this.getSelectedSheetIndex();
22985
23031
  let r2 = null;
22986
23032
  if (t5) {
22987
- if (r2 = this._getSheetRef(t5), !r2) throw new Error(kw(r2));
23033
+ if (r2 = this._getSheetRef(t5), !r2) throw new Error(Ow(r2));
22988
23034
  } else r2 = e2[n2];
22989
23035
  if (!r2) return null;
22990
23036
  const o2 = r2.sheet, s2 = this._strings.beginPersist(), i2 = this.getResources().beginPersist(), a2 = this.getStyles().beginPersist();
@@ -23004,16 +23050,16 @@ class Xw {
23004
23050
  const n2 = t5 ? { ...t5 } : null;
23005
23051
  if (!(n2 ? this._getSheetRef(n2.sheetName, G_.Visibility.VeryHidden) : null)) {
23006
23052
  const t6 = this.getSelectedSheet();
23007
- return t6 ? (delete n2?.sheetName, Ww(n2, n2 ? { sheetName: Zh, ...t6.getEntireRange().getCoords() } : null)) : void console.warn(Dw);
23053
+ return t6 ? (delete n2?.sheetName, qw(n2, n2 ? { sheetName: Zh, ...t6.getEntireRange().getCoords() } : null)) : void console.warn(Lw);
23008
23054
  }
23009
23055
  const r2 = this.getSelectedSheet();
23010
23056
  let o2 = null;
23011
- return e2 && (o2 = { getOptions: e2 }), new Kw(t5, r2, this, o2);
23057
+ return e2 && (o2 = { getOptions: e2 }), new Xw(t5, r2, this, o2);
23012
23058
  }
23013
23059
  _createRanges(t5, e2) {
23014
23060
  const n2 = this.getSelectedSheet();
23015
23061
  let r2 = null;
23016
- return e2 && (r2 = { getOptions: e2 }), new Jw(t5, n2, this, r2);
23062
+ return e2 && (r2 = { getOptions: e2 }), new Kw(t5, n2, this, r2);
23017
23063
  }
23018
23064
  getRange(t5, e2) {
23019
23065
  try {
@@ -23086,10 +23132,10 @@ class Xw {
23086
23132
  return h2.set(c2, e2), this._updateState({ refsById: o2, refsByLowerCaseName: a2, sheetsByLowerCaseName: l2, refsByInstance: h2 }), e2;
23087
23133
  }
23088
23134
  _setSheetName(t5, e2) {
23089
- if (this._closed) throw new Error(Lw);
23090
- if (!this.getProtection().isStructureAllowed()) throw new Error(Bw);
23135
+ if (this._closed) throw new Error(Bw);
23136
+ if (!this.getProtection().isStructureAllowed()) throw new Error(zw);
23091
23137
  const n2 = this._getSheetRef(t5);
23092
- if (!n2) throw new Error(kw(t5));
23138
+ if (!n2) throw new Error(Ow(t5));
23093
23139
  if (e2 === n2.name) return n2.sheet;
23094
23140
  e2 = this._validateNewSheetName(e2);
23095
23141
  const r2 = Object.freeze({ ...n2, name: e2 });
@@ -23106,8 +23152,8 @@ class Xw {
23106
23152
  return o2;
23107
23153
  }
23108
23154
  _setSheetVisibility(t5, e2 = G_.Visibility.Visible) {
23109
- if (this._closed) throw new Error(Lw);
23110
- if (!this.getProtection().isStructureAllowed()) throw new Error(Bw);
23155
+ if (this._closed) throw new Error(Bw);
23156
+ if (!this.getProtection().isStructureAllowed()) throw new Error(zw);
23111
23157
  const n2 = this._getSheetRef(t5);
23112
23158
  if (!n2) return null;
23113
23159
  if (e2 === n2.visibility) return;
@@ -23116,7 +23162,7 @@ class Xw {
23116
23162
  const s2 = this.beginCommit(o2);
23117
23163
  try {
23118
23164
  const t6 = this._getState().sheetRefsVisible;
23119
- if (e2 !== G_.Visibility.Visible && 1 === t6.length && t6[0].id === n2.id) throw new Error(Ow);
23165
+ if (e2 !== G_.Visibility.Visible && 1 === t6.length && t6[0].id === n2.id) throw new Error(Dw);
23120
23166
  const o3 = { ...n2, visibility: e2 };
23121
23167
  let i2 = -1;
23122
23168
  e2 !== G_.Visibility.Visible && (i2 = this._findOffsetForId(n2.id, t6));
@@ -23130,8 +23176,8 @@ class Xw {
23130
23176
  }), this._emitter.notify("onSheetsChange"), r2;
23131
23177
  }
23132
23178
  _moveSheet(t5, e2) {
23133
- if (this._closed) throw new Error(Lw);
23134
- if (!this.getProtection().isStructureAllowed()) throw new Error(Bw);
23179
+ if (this._closed) throw new Error(Bw);
23180
+ if (!this.getProtection().isStructureAllowed()) throw new Error(zw);
23135
23181
  let n2 = null;
23136
23182
  const r2 = this.beginCommit(`Move Sheet '${t5.name}'`);
23137
23183
  try {
@@ -23150,14 +23196,14 @@ class Xw {
23150
23196
  return n2;
23151
23197
  }
23152
23198
  _setSelectedSheet(t5) {
23153
- if (this._closed) throw new Error(Lw);
23199
+ if (this._closed) throw new Error(Bw);
23154
23200
  const e2 = this._getSheetRef(t5);
23155
- if (!e2) throw new Error(kw(t5));
23201
+ if (!e2) throw new Error(Ow(t5));
23156
23202
  let n2 = null;
23157
23203
  return e2.visibility !== G_.Visibility.Visible && this._setSheetVisibility(e2, G_.Visibility.Visible), this._view.setActiveSheetId(e2.id), n2 = e2.sheet, n2;
23158
23204
  }
23159
23205
  getProtection() {
23160
- return this._protection ?? null;
23206
+ return this._protection;
23161
23207
  }
23162
23208
  getNames() {
23163
23209
  return this._names;
@@ -23196,7 +23242,7 @@ class Xw {
23196
23242
  };
23197
23243
  }
23198
23244
  _fromJSON(t5) {
23199
- if (this._emitter.notify("onBeforeLoad", { params: t5 }), this._initState(), !t5.sheets || 0 === t5.sheets.length) throw new Error(Ow);
23245
+ if (this._emitter.notify("onBeforeLoad", { params: t5 }), this._initState(), !t5.sheets || 0 === t5.sheets.length) throw new Error(Dw);
23200
23246
  t5.theme && (this._theme = new gl(t5.theme), this._styles.setTheme(this._theme));
23201
23247
  const e2 = this._strings.beginPersist(), n2 = this._resources.beginPersist(), r2 = this._styles.beginPersist();
23202
23248
  try {
@@ -23209,9 +23255,9 @@ class Xw {
23209
23255
  const e3 = o2[t6], n3 = e3.visibility || G_.Visibility.Visible, r3 = t6 + 1;
23210
23256
  n3 === G_.Visibility.Visible ? a2 = r3 : null !== i2 && i2 === r3 && (i2 = null), this._createSheet(r3, e3.name, n3, void 0, e3.sheet);
23211
23257
  }
23212
- this._updateState({ lastId: a2 }), t5.names && this._names.fromJSON(t5.names), t5.view.activeSheetId = i2 ?? a2, this.setView(new yw({ json: t5.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
23258
+ this._updateState({ lastId: a2 }), t5.names && this._names.fromJSON(t5.names), t5.view.activeSheetId = i2 ?? a2, this.setView(new Ew({ json: t5.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
23213
23259
  const l2 = this;
23214
- this._protection = new Fw(t5?.protection), this._listenerProtection = this._protection.addListeners({ onChange: (t6) => {
23260
+ this._protection = new kw(t5?.protection, this._options?.readonly), this._listenerProtection = this._protection.addListeners({ onChange: (t6) => {
23215
23261
  l2._emitter.notify("onProtectionChange", { source: t6 });
23216
23262
  } }), t5.scripts && (this._scripts = this._createScripts(t5.scripts)), this._emitter.notify("onLoad");
23217
23263
  } finally {
@@ -23219,7 +23265,7 @@ class Xw {
23219
23265
  }
23220
23266
  }
23221
23267
  _createScripts(t5) {
23222
- return new Tw({ transactions: this._transactions, json: t5, workbook: this, onAdd: (t6, e2) => {
23268
+ return new Nw({ transactions: this._transactions, json: t5, workbook: this, onAdd: (t6, e2) => {
23223
23269
  const n2 = this._calculation;
23224
23270
  n2.getStatus() !== dp.Status.Off && n2.start().then(() => {
23225
23271
  const t7 = e2.getFunctions().search({ type: "formula" });
@@ -23232,7 +23278,7 @@ class Xw {
23232
23278
  } });
23233
23279
  }
23234
23280
  async toJSON(t5 = false) {
23235
- if (this._closed) throw new Error(Lw);
23281
+ if (this._closed) throw new Error(Bw);
23236
23282
  await this._emitter.notify("onBeforeSave", { async: true });
23237
23283
  const e2 = { sheets: [] };
23238
23284
  await Promise.resolve(this._starting);
@@ -23287,7 +23333,7 @@ class Xw {
23287
23333
  this._ownResources, this._ownNames && this._names.close(), this._ownsCalculation && this._calculation.close(), this._ownStyles, this._transactionsRemoveListener?.(), this._closed = true;
23288
23334
  }
23289
23335
  beginCommit(t5) {
23290
- if (this._closed) throw new Error(Lw);
23336
+ if (this._closed) throw new Error(Bw);
23291
23337
  return this._beginCommit("string" == typeof t5 ? { description: t5 } : t5);
23292
23338
  }
23293
23339
  doBatch(t5, e2) {
@@ -23327,7 +23373,7 @@ class Xw {
23327
23373
  return true;
23328
23374
  }
23329
23375
  }
23330
- const Yw = { address: null, scope: null };
23376
+ const Zw = { address: null, scope: null };
23331
23377
  export {
23332
23378
  Nf as AddressUtils,
23333
23379
  x as AnchorLocation,
@@ -23409,8 +23455,8 @@ export {
23409
23455
  T as TypesUtils,
23410
23456
  ae as UndoManager,
23411
23457
  Bt as UserError,
23412
- Xw as Workbook,
23413
- yw as WorkbookView,
23458
+ Yw as Workbook,
23459
+ Ew as WorkbookView,
23414
23460
  DS as a,
23415
23461
  OS as b,
23416
23462
  Ph as c,