@sheetxl/sdk 0.8.0-beta.1 → 0.8.0-beta.11

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 (775) hide show
  1. package/README.md +1 -1
  2. package/THIRD-PARTY-NOTICES.md +1 -1
  3. package/browser/esm/B7aUIvgUjncMMD_i.mjs +394 -0
  4. package/browser/esm/BFagR2JeWs74iAG3.mjs +171 -0
  5. package/browser/esm/BGOFfpxr2jPIdqmV.mjs +40 -0
  6. package/browser/esm/BLoUBId2xZpXAK_H.mjs +698 -0
  7. package/browser/esm/BMyDRQ716j79h_bH.mjs +86 -0
  8. package/browser/esm/BVDiOXGMc5_FMGfy.mjs +400 -0
  9. package/browser/esm/BjkCiv5Jz6WYKZeu.mjs +598 -0
  10. package/browser/esm/BkBhLS0l6z8sxI6D.mjs +441 -0
  11. package/browser/esm/BnG31I6Oj_HEtSPS.mjs +167 -0
  12. package/browser/esm/BoV6zPBnfqCBCqZ7.mjs +7729 -0
  13. package/browser/esm/BpgskG1Er_lGQ_yS.mjs +142 -0
  14. package/browser/esm/BtvLTTfSBdAKplVG.mjs +466 -0
  15. package/browser/esm/C16ycKja6zG0crV_.mjs +55580 -0
  16. package/browser/esm/C2VbEI_XVAoseAwa.mjs +1552 -0
  17. package/browser/esm/C4MqfLn9Dm-l3OIk.mjs +540 -0
  18. package/browser/esm/C5E6zSGAALWf61n4.mjs +199 -0
  19. package/browser/esm/CHU6iu_WGlm7fLET.mjs +1001 -0
  20. package/browser/esm/CQYjO777cmAznUzK.mjs +527 -0
  21. package/browser/esm/CU3DmJ-YnVVrC1_k.mjs +1123 -0
  22. package/browser/esm/CV5EGEjG5_-CPpP0.mjs +8212 -0
  23. package/browser/esm/{uyWBMSIxMlt8n5Z3.mjs → CaB7J-xgfKO2uAkG.mjs} +2 -2
  24. package/browser/esm/CkxWugaJFjDGZNZ-.mjs +12 -0
  25. package/browser/esm/ClPfI4lODvCece29.mjs +632 -0
  26. package/browser/esm/ClbvFbFzFzXLBKNN.mjs +193 -0
  27. package/browser/esm/{DlPMeIyxT9tG_WDk.mjs → Ctjb0SsxV4K4MMqG.mjs} +179 -202
  28. package/browser/esm/D5np__Jb1euAyaLw.mjs +7 -0
  29. package/browser/esm/DEiPS3Dr-s4fPbVZ.mjs +607 -0
  30. package/browser/esm/DLLE0FZNsKxbBzRn.mjs +128 -0
  31. package/browser/esm/DWNzqw7DUKwoxjri.mjs +20 -0
  32. package/browser/esm/{B0HS42a7lga1k1U_.mjs → Dlmig06rIo7cInRk.mjs} +2 -2
  33. package/browser/esm/{f2G3QRgEbvFJcoa2.mjs → DvAaxH6z_tGvrRzl.mjs} +1704 -1008
  34. package/browser/esm/Dyq_ivuHvlXLwPCl.mjs +12831 -0
  35. package/browser/esm/PcHFjNzQsE54POri.mjs +1141 -0
  36. package/browser/esm/S2dNNx1a5ydRnARM.mjs +367 -0
  37. package/browser/esm/f1IoRb7tEb0QmCSt.mjs +110 -0
  38. package/browser/esm/gssVX_FH1XFN-twD.mjs +210 -0
  39. package/browser/esm/index.mjs +1759 -1161
  40. package/browser/esm/nvU0ClAbf0g94YBK.mjs +1695 -0
  41. package/browser/esm/zlLuW405RSguy4Kn.mjs +357 -0
  42. package/licenses/dependencies.txt +141 -141
  43. package/node/esm/2Kihw_-5lVTEnwMa.mjs +1132 -0
  44. package/node/esm/857CIBgQgGpnqrXk.mjs +199 -0
  45. package/node/esm/B084DssTcdBheTp_.mjs +7966 -0
  46. package/node/esm/B21JjOLghRoDOrkx.mjs +134 -0
  47. package/node/esm/BIRq1kT7lLRzns9t.mjs +610 -0
  48. package/node/esm/BIwObuhTJYf0jpUa.mjs +451 -0
  49. package/node/esm/Bbf1Pm9Gk7YpLTvg.mjs +12 -0
  50. package/node/esm/BqiexuA89caYnAPz.mjs +1135 -0
  51. package/node/esm/BrCKGFRsX_ezFJ4B.mjs +811 -0
  52. package/node/esm/CCN5vD410obwdz38.mjs +405 -0
  53. package/node/esm/{Cku7XiUvw1xrRasi.mjs → CDHdgJXH2vS71WMc.mjs} +1 -1
  54. package/node/esm/CGp6VZL-gZa9Uezx.mjs +1860 -0
  55. package/node/esm/CNCNJNg890KdgkWh.mjs +142 -0
  56. package/node/esm/CZICGK_ss0HoGHCP.mjs +7 -0
  57. package/node/esm/CZiqiay42tFTrLI4.mjs +171 -0
  58. package/node/esm/CdJHUJSBRHZoryPe.mjs +360 -0
  59. package/node/esm/Ct3h15sCus4Tgt6M.mjs +1762 -0
  60. package/node/esm/CwePQwTILHHjGDkZ.mjs +1033 -0
  61. package/node/esm/CzXT00vrQa1_gvW9.mjs +28 -0
  62. package/node/esm/D1TKBVmoKGAXf37B.mjs +402 -0
  63. package/node/esm/D2KBymQJd1XhpeQD.mjs +540 -0
  64. package/node/esm/D6e2z7eZpxOJXHc7.mjs +1783 -0
  65. package/node/esm/D8zEN-6ZdDqDvTxM.mjs +639 -0
  66. package/node/esm/DNRhGK-8Tr9xcRyc.mjs +8320 -0
  67. package/node/esm/DOU54VsOjG-m-NyQ.mjs +210 -0
  68. package/node/esm/DUTskXCXref-IJnI.mjs +133 -0
  69. package/node/esm/D_t5AUxSm7_icjzq.mjs +638 -0
  70. package/node/esm/Db0v7zXNnyjBIjjI.mjs +372 -0
  71. package/node/esm/De2IONBxQhz-Qbyh.mjs +596 -0
  72. package/node/esm/Df1bL6VFvrqIdSLB.mjs +40 -0
  73. package/node/esm/DkwIPzKc3UwdUIfM.mjs +86 -0
  74. package/node/esm/DrTZbfemSLq2mseG.mjs +111 -0
  75. package/node/esm/OVfaSb506tNSIvbv.mjs +57107 -0
  76. package/node/esm/cGwrLA1RCE-WhJ7w.mjs +255 -0
  77. package/node/esm/index.mjs +2873 -53929
  78. package/node/esm/mFiBSM7XgBHV9AY7.mjs +13010 -0
  79. package/node/esm/yavzZOiZW_EjG9lE.mjs +15 -0
  80. package/package.json +15 -17
  81. package/resources/contents.json +184 -0
  82. package/resources/fonts/arial-bold-italic.hinted.json +125 -0
  83. package/resources/fonts/arial-bold-italic.metrics.json +139 -0
  84. package/resources/fonts/arial-bold-italic.rows.json +9 -0
  85. package/resources/fonts/arial-bold.hinted.json +125 -0
  86. package/resources/fonts/arial-bold.metrics.json +139 -0
  87. package/resources/fonts/arial-bold.rows.json +9 -0
  88. package/resources/fonts/arial-italic.hinted.json +125 -0
  89. package/resources/fonts/arial-italic.metrics.json +139 -0
  90. package/resources/fonts/arial-italic.rows.json +9 -0
  91. package/resources/fonts/arial-regular.hinted.json +125 -0
  92. package/resources/fonts/arial-regular.metrics.json +139 -0
  93. package/resources/fonts/arial-regular.rows.json +9 -0
  94. package/resources/fonts/calibri-bold-italic.hinted.json +122 -0
  95. package/resources/fonts/calibri-bold-italic.metrics.json +137 -0
  96. package/resources/fonts/calibri-bold-italic.rows.json +9 -0
  97. package/resources/fonts/calibri-bold.hinted.json +122 -0
  98. package/resources/fonts/calibri-bold.metrics.json +137 -0
  99. package/resources/fonts/calibri-bold.rows.json +9 -0
  100. package/resources/fonts/calibri-italic.hinted.json +121 -0
  101. package/resources/fonts/calibri-italic.metrics.json +137 -0
  102. package/resources/fonts/calibri-italic.rows.json +9 -0
  103. package/resources/fonts/calibri-regular.hinted.json +121 -0
  104. package/resources/fonts/calibri-regular.metrics.json +137 -0
  105. package/resources/fonts/calibri-regular.rows.json +9 -0
  106. package/resources/fonts/cambria-bold-italic.hinted.json +105 -0
  107. package/resources/fonts/cambria-bold-italic.metrics.json +66 -0
  108. package/resources/fonts/cambria-bold-italic.rows.json +9 -0
  109. package/resources/fonts/cambria-bold.hinted.json +108 -0
  110. package/resources/fonts/cambria-bold.metrics.json +66 -0
  111. package/resources/fonts/cambria-bold.rows.json +9 -0
  112. package/resources/fonts/cambria-italic.hinted.json +102 -0
  113. package/resources/fonts/cambria-italic.metrics.json +66 -0
  114. package/resources/fonts/cambria-italic.rows.json +9 -0
  115. package/resources/fonts/cambria-regular.hinted.json +110 -0
  116. package/resources/fonts/cambria-regular.metrics.json +66 -0
  117. package/resources/fonts/cambria-regular.rows.json +9 -0
  118. package/resources/fonts/contents.json +406 -0
  119. package/resources/fonts/courier-new-bold-italic.hinted.json +11 -0
  120. package/resources/fonts/courier-new-bold-italic.metrics.json +143 -0
  121. package/resources/fonts/courier-new-bold-italic.rows.json +9 -0
  122. package/resources/fonts/courier-new-bold.hinted.json +11 -0
  123. package/resources/fonts/courier-new-bold.metrics.json +143 -0
  124. package/resources/fonts/courier-new-bold.rows.json +9 -0
  125. package/resources/fonts/courier-new-italic.hinted.json +11 -0
  126. package/resources/fonts/courier-new-italic.metrics.json +143 -0
  127. package/resources/fonts/courier-new-italic.rows.json +9 -0
  128. package/resources/fonts/courier-new-regular.hinted.json +11 -0
  129. package/resources/fonts/courier-new-regular.metrics.json +143 -0
  130. package/resources/fonts/courier-new-regular.rows.json +9 -0
  131. package/resources/fonts/times-new-roman-bold-italic.hinted.json +125 -0
  132. package/resources/fonts/times-new-roman-bold-italic.metrics.json +141 -0
  133. package/resources/fonts/times-new-roman-bold-italic.rows.json +9 -0
  134. package/resources/fonts/times-new-roman-bold.hinted.json +125 -0
  135. package/resources/fonts/times-new-roman-bold.metrics.json +141 -0
  136. package/resources/fonts/times-new-roman-bold.rows.json +9 -0
  137. package/resources/fonts/times-new-roman-italic.hinted.json +125 -0
  138. package/resources/fonts/times-new-roman-italic.metrics.json +143 -0
  139. package/resources/fonts/times-new-roman-italic.rows.json +9 -0
  140. package/resources/fonts/times-new-roman-regular.hinted.json +125 -0
  141. package/resources/fonts/times-new-roman-regular.metrics.json +141 -0
  142. package/resources/fonts/times-new-roman-regular.rows.json +9 -0
  143. package/resources/locales/de/model.msg.json +199 -21
  144. package/resources/locales/en/model.msg.json +207 -23
  145. package/types/scripting-api.json +10663 -0
  146. package/types/scripting-enums.json +435 -130
  147. package/types/scripting.d.ts +33010 -15730
  148. package/types/src/.generated/wasm/fonts.d.ts +161 -0
  149. package/types/src/.generated/wasm/fonts_bg.inline.d.ts +3 -0
  150. package/types/src/.generated/wasm/sdk.d.ts +122 -0
  151. package/types/src/.generated/wasm/sdk_bg.inline.d.ts +3 -0
  152. package/types/src/address/AddressUtils.d.ts +10 -1
  153. package/types/src/address/_StructuredAddress.d.ts +58 -0
  154. package/types/src/anchored/AbstractAnchored.d.ts +18 -8
  155. package/types/src/anchored/AnchoredMap.d.ts +2 -0
  156. package/types/src/anchored/IAnchoredMap.d.ts +52 -4
  157. package/types/src/autoFill/AutoFill.d.ts +316 -32
  158. package/types/src/autoFill/IAutoFill.d.ts +232 -15
  159. package/types/src/border/{IBorder.d.ts → IBorders.d.ts} +58 -41
  160. package/types/src/border/index.d.ts +1 -1
  161. package/types/src/calculation/Calculation.d.ts +584 -149
  162. package/types/src/calculation/ExternalBookBindings.d.ts +118 -0
  163. package/types/src/calculation/FormulaLiterals.d.ts +2 -1
  164. package/types/src/calculation/FormulaText.d.ts +98 -0
  165. package/types/src/calculation/ICalculation.d.ts +353 -88
  166. package/types/src/calculation/INamedFormulasCollection.d.ts +9 -8
  167. package/types/src/calculation/NamedFormulaCollection.d.ts +322 -115
  168. package/types/src/calculation/NamedLambdaFunction.d.ts +28 -0
  169. package/types/src/calculation/TokenType.d.ts +9 -0
  170. package/types/src/calculation/Types.d.ts +83 -2
  171. package/types/src/calculation/_CloneBoundary.d.ts +80 -0
  172. package/types/src/calculation/_FormulaToolkit.d.ts +9 -0
  173. package/types/src/calculation/_TableExtent.d.ts +60 -0
  174. package/types/src/calculation/_TableRename.d.ts +13 -0
  175. package/types/src/calculation/compiler/ASTTypes.d.ts +71 -0
  176. package/types/src/calculation/compiler/CompilerUtils.d.ts +152 -44
  177. package/types/src/calculation/compiler/FormulaCompiler.d.ts +29 -4
  178. package/types/src/calculation/compiler/FormulaParser.d.ts +1 -2
  179. package/types/src/calculation/compiler/LiteTransform.d.ts +17 -0
  180. package/types/src/calculation/compiler/ParserUtils.d.ts +42 -1
  181. package/types/src/calculation/compiler/SRParser.d.ts +2 -1
  182. package/types/src/calculation/compiler/Types.d.ts +79 -9
  183. package/types/src/calculation/engine/CalcBackend.d.ts +855 -0
  184. package/types/src/calculation/engine/index.d.ts +10 -0
  185. package/types/src/calculation/executor/CalcExecutor.d.ts +331 -33
  186. package/types/src/calculation/executor/CalcExecutorUtils.d.ts +49 -2
  187. package/types/src/calculation/executor/CircularReference.d.ts +2 -0
  188. package/types/src/calculation/formula/Formula.d.ts +67 -21
  189. package/types/src/calculation/formula/FormulaBlock.d.ts +131 -23
  190. package/types/src/calculation/formula/FormulaRecordView.d.ts +79 -0
  191. package/types/src/calculation/formula/FunctionValues.d.ts +10 -0
  192. package/types/src/calculation/formula/IFormulaBlock.d.ts +277 -67
  193. package/types/src/calculation/formula/LambdaValue.d.ts +51 -26
  194. package/types/src/calculation/formula/LazyValue.d.ts +96 -0
  195. package/types/src/calculation/formula/TokenUtils.d.ts +25 -1
  196. package/types/src/calculation/formula/index.d.ts +1 -0
  197. package/types/src/calculation/functions/FunctionDeclarations.d.ts +35 -0
  198. package/types/src/calculation/functions/Operators.d.ts +8 -0
  199. package/types/src/calculation/functions/expandDeclaration.d.ts +15 -0
  200. package/types/src/calculation/functions/initializeFunctions.d.ts +3 -2
  201. package/types/src/calculation/grid/CalcGrid.d.ts +443 -158
  202. package/types/src/calculation/grid/CalcGridBackend.d.ts +523 -0
  203. package/types/src/calculation/grid/CalcGridProxy.d.ts +135 -0
  204. package/types/src/calculation/grid/CalcGridUtils.d.ts +69 -12
  205. package/types/src/calculation/grid/FormulaEntry.d.ts +129 -0
  206. package/types/src/calculation/grid/FormulaHost.d.ts +284 -0
  207. package/types/src/calculation/grid/ICalcGrid.d.ts +528 -141
  208. package/types/src/calculation/grid/_CalcRequest.d.ts +299 -0
  209. package/types/src/calculation/grid/_CellValueRun.d.ts +21 -0
  210. package/types/src/calculation/grid/index.d.ts +4 -0
  211. package/types/src/calculation/index.d.ts +2 -0
  212. package/types/src/calculation/spatial/ContentfulSpatialValue.d.ts +6 -2
  213. package/types/src/calculation/spatial/FormulaSpatialValue.d.ts +364 -11
  214. package/types/src/calculation/spatial/SpillEntry.d.ts +20 -5
  215. package/types/src/calculation/spatial/TouchedWindows.d.ts +86 -0
  216. package/types/src/calculation/spatial/index.d.ts +1 -0
  217. package/types/src/calculation/state/CalcInputs.d.ts +41 -0
  218. package/types/src/calculation/state/CalcNode.d.ts +141 -30
  219. package/types/src/calculation/state/CalcScope.d.ts +46 -0
  220. package/types/src/calculation/state/CalcState.d.ts +32 -1
  221. package/types/src/calculation/state/CalculationContext.d.ts +50 -3
  222. package/types/src/calculation/state/IContextContainer.d.ts +141 -27
  223. package/types/src/calculation/state/_PendingOverlayGrid.d.ts +163 -0
  224. package/types/src/calculation/state/_ReadObservedGrid.d.ts +74 -8
  225. package/types/src/calculation/state/index.d.ts +1 -0
  226. package/types/src/calculation/symbol/ExternalSheetSymbols.d.ts +80 -0
  227. package/types/src/calculation/symbol/ISymbolRegistry.d.ts +23 -0
  228. package/types/src/calculation/symbol/IndirectSymbolProvider.d.ts +16 -2
  229. package/types/src/calculation/symbol/SheetSymbolProvider.d.ts +63 -3
  230. package/types/src/calculation/symbol/SymbolRegistry.d.ts +20 -0
  231. package/types/src/calculation/symbol/index.d.ts +3 -2
  232. package/types/src/calculation/toolkit/FormulaLiteralReader.d.ts +4 -0
  233. package/types/src/calculation/toolkit/FormulaTextParser.d.ts +10 -0
  234. package/types/src/calculation/toolkit/FunctionDeclarationTable.d.ts +4 -0
  235. package/types/src/calculation/toolkit/index.d.ts +12 -0
  236. package/types/src/cell/ICell.d.ts +357 -33
  237. package/types/src/cell/ICellHeader.d.ts +31 -8
  238. package/types/src/cell/ICellProtection.d.ts +50 -10
  239. package/types/src/cellRange/ICellHeaderRange.d.ts +6 -9
  240. package/types/src/cellRange/ICellHeaderRanges.d.ts +5 -0
  241. package/types/src/cellRange/ICellRange.d.ts +737 -130
  242. package/types/src/cellRange/ICellRanges.d.ts +31 -24
  243. package/types/src/chart/Chart.d.ts +246 -16
  244. package/types/src/chart/ChartCollection.d.ts +31 -0
  245. package/types/src/chart/IChart.d.ts +2058 -18
  246. package/types/src/chart/IChartCollection.d.ts +50 -0
  247. package/types/src/chart/_ChartParts.d.ts +1066 -0
  248. package/types/src/chart/_ChartSource.d.ts +47 -0
  249. package/types/src/chart/createChart.d.ts +26 -0
  250. package/types/src/chart/index.d.ts +5 -3
  251. package/types/src/chart/kinds/ChartKind.d.ts +252 -0
  252. package/types/src/chart/kinds/_Area.d.ts +3 -0
  253. package/types/src/chart/kinds/_Bar.d.ts +4 -0
  254. package/types/src/chart/kinds/_BoxWhisker.d.ts +4 -0
  255. package/types/src/chart/kinds/_Bubble.d.ts +3 -0
  256. package/types/src/chart/kinds/_Funnel.d.ts +4 -0
  257. package/types/src/chart/kinds/_Hierarchy.d.ts +31 -0
  258. package/types/src/chart/kinds/_Histogram.d.ts +4 -0
  259. package/types/src/chart/kinds/_HitKinds.d.ts +23 -0
  260. package/types/src/chart/kinds/_Line.d.ts +4 -0
  261. package/types/src/chart/kinds/_OfPie.d.ts +4 -0
  262. package/types/src/chart/kinds/_Pie.d.ts +4 -0
  263. package/types/src/chart/kinds/_Placeholder.d.ts +6 -0
  264. package/types/src/chart/kinds/_Radar.d.ts +4 -0
  265. package/types/src/chart/kinds/_Scatter.d.ts +8 -0
  266. package/types/src/chart/kinds/_Sunburst.d.ts +4 -0
  267. package/types/src/chart/kinds/_Surface.d.ts +4 -0
  268. package/types/src/chart/kinds/_Treemap.d.ts +4 -0
  269. package/types/src/chart/kinds/_Waterfall.d.ts +18 -0
  270. package/types/src/chart/kinds/_builtIns.d.ts +11 -0
  271. package/types/src/chart/layout/ChartLayout.d.ts +825 -0
  272. package/types/src/chart/layout/TextMeasurer.d.ts +38 -0
  273. package/types/src/chart/layout/_HitGeometry.d.ts +50 -0
  274. package/types/src/chart/layout/_HitTest.d.ts +36 -0
  275. package/types/src/chart/layout/_Layout.d.ts +25 -0
  276. package/types/src/chart/layout/_LayoutUtils.d.ts +97 -0
  277. package/types/src/chart/math/BoxStats.d.ts +35 -0
  278. package/types/src/chart/math/DateUnitCalcs.d.ts +80 -0
  279. package/types/src/chart/math/DisplayUnits.d.ts +53 -0
  280. package/types/src/chart/math/Histogram.d.ts +48 -0
  281. package/types/src/chart/math/OrdUnitCalcs.d.ts +166 -0
  282. package/types/src/chart/math/Treemap.d.ts +28 -0
  283. package/types/src/chart/math/Trendlines.d.ts +71 -0
  284. package/types/src/chart/math/UnitCalcs.d.ts +98 -0
  285. package/types/src/chart/model/ChartModel.d.ts +681 -0
  286. package/types/src/chart/model/_ChartType.d.ts +14 -0
  287. package/types/src/chart/model/_Edits.d.ts +489 -0
  288. package/types/src/chart/model/_Grouping.d.ts +83 -0
  289. package/types/src/chart/model/_Inference.d.ts +52 -0
  290. package/types/src/chart/model/_ModelFacts.d.ts +112 -0
  291. package/types/src/chart/model/_NewChart.d.ts +208 -0
  292. package/types/src/chart/model/_OfPie.d.ts +18 -0
  293. package/types/src/chart/resolve/_LegacyStyles.d.ts +48 -0
  294. package/types/src/chart/resolve/_Resolve.d.ts +51 -0
  295. package/types/src/chart/resolve/_ResolvedChart.d.ts +444 -0
  296. package/types/src/collections/ArraysGrid.d.ts +1 -1
  297. package/types/src/collections/IGrid.d.ts +1 -1
  298. package/types/src/collections/ISparseGrid.d.ts +9 -0
  299. package/types/src/collections/ISpatialMap.d.ts +59 -21
  300. package/types/src/collections/ImmutableList.d.ts +28 -0
  301. package/types/src/collections/MixedTypedArrayList.d.ts +168 -108
  302. package/types/src/collections/RTree.d.ts +116 -36
  303. package/types/src/collections/RepeatingList.d.ts +7 -0
  304. package/types/src/collections/ScalarGrid.d.ts +50 -0
  305. package/types/src/collections/SparseGrid.d.ts +7 -4
  306. package/types/src/collections/SpatialMap.d.ts +15 -29
  307. package/types/src/collections/SpatialMap3D.d.ts +2 -0
  308. package/types/src/collections/Tuple.d.ts +128 -16
  309. package/types/src/collections/_GridUtils.d.ts +19 -6
  310. package/types/src/collections/_SpatialUtils.d.ts +20 -2
  311. package/types/src/collections/index.d.ts +2 -1
  312. package/types/src/color/_BuiltInIndexDefs.d.ts +6 -0
  313. package/types/src/comment/Comment.d.ts +246 -0
  314. package/types/src/comment/CommentCollection.d.ts +40 -0
  315. package/types/src/comment/IComment.d.ts +377 -50
  316. package/types/src/comment/ICommentCollection.d.ts +90 -0
  317. package/types/src/comment/NoteMovable.d.ts +26 -0
  318. package/types/src/comment/_CommentUtils.d.ts +50 -0
  319. package/types/src/comment/_NoteBox.d.ts +67 -0
  320. package/types/src/comment/index.d.ts +1 -0
  321. package/types/src/condition/AnchoredConditional.d.ts +110 -19
  322. package/types/src/condition/BuiltInOperators/AbstractOperator.d.ts +42 -12
  323. package/types/src/condition/BuiltInOperators/AfterEqualToOperator.d.ts +2 -0
  324. package/types/src/condition/BuiltInOperators/AfterOperator.d.ts +2 -0
  325. package/types/src/condition/BuiltInOperators/AndOperator.d.ts +3 -1
  326. package/types/src/condition/BuiltInOperators/AverageOperator.d.ts +2 -0
  327. package/types/src/condition/BuiltInOperators/BeforeEqualToOperator.d.ts +2 -0
  328. package/types/src/condition/BuiltInOperators/BeforeOperator.d.ts +2 -0
  329. package/types/src/condition/BuiltInOperators/BetweenOperator.d.ts +2 -0
  330. package/types/src/condition/BuiltInOperators/ColorOperator.d.ts +4 -0
  331. package/types/src/condition/BuiltInOperators/ContainsOperator.d.ts +2 -0
  332. package/types/src/condition/BuiltInOperators/EndsWithOperator.d.ts +2 -0
  333. package/types/src/condition/BuiltInOperators/EqualToOperator.d.ts +4 -1
  334. package/types/src/condition/BuiltInOperators/ExpressionOperator.d.ts +5 -6
  335. package/types/src/condition/BuiltInOperators/GreaterThanEqualToOperator.d.ts +2 -0
  336. package/types/src/condition/BuiltInOperators/GreaterThanOperator.d.ts +2 -0
  337. package/types/src/condition/BuiltInOperators/IconOperator.d.ts +4 -0
  338. package/types/src/condition/BuiltInOperators/InSetOperator.d.ts +22 -5
  339. package/types/src/condition/BuiltInOperators/LessThanEqualToOperator.d.ts +2 -0
  340. package/types/src/condition/BuiltInOperators/LessThanOperator.d.ts +2 -0
  341. package/types/src/condition/BuiltInOperators/NotOperator.d.ts +2 -0
  342. package/types/src/condition/BuiltInOperators/OrOperator.d.ts +3 -1
  343. package/types/src/condition/BuiltInOperators/StartsWithOperator.d.ts +2 -0
  344. package/types/src/condition/BuiltInOperators/TimePeriodOperator.d.ts +2 -0
  345. package/types/src/condition/BuiltInOperators/TopNOperator.d.ts +6 -0
  346. package/types/src/condition/BuiltinSelectors/BaseSelector.d.ts +21 -6
  347. package/types/src/condition/BuiltinSelectors/DateSelector.d.ts +4 -5
  348. package/types/src/condition/BuiltinSelectors/DisplaySelector.d.ts +20 -0
  349. package/types/src/condition/BuiltinSelectors/TextLengthSelector.d.ts +7 -5
  350. package/types/src/condition/BuiltinSelectors/TimeSelector.d.ts +3 -5
  351. package/types/src/condition/BuiltinSelectors/WholeSelector.d.ts +3 -5
  352. package/types/src/condition/BuiltinSelectors/index.d.ts +12 -6
  353. package/types/src/condition/Condition.d.ts +19 -1
  354. package/types/src/condition/ICondition.d.ts +296 -75
  355. package/types/src/condition/_ConditionFormula.d.ts +152 -0
  356. package/types/src/condition/_ConditionUtils.d.ts +167 -13
  357. package/types/src/conditionalFormat/ConditionalEntry.d.ts +3 -3
  358. package/types/src/conditionalFormat/ConditionalFormat.d.ts +34 -17
  359. package/types/src/conditionalFormat/ConditionalFormatCollection.d.ts +19 -8
  360. package/types/src/conditionalFormat/IConditionalFormat.d.ts +16 -13
  361. package/types/src/conditionalFormat/IConditionalFormatCollection.d.ts +2 -0
  362. package/types/src/dataTable/DataTable.d.ts +67 -0
  363. package/types/src/dataTable/DataTableCollection.d.ts +19 -0
  364. package/types/src/dataTable/IDataTable.d.ts +99 -0
  365. package/types/src/dataTable/IDataTableCollection.d.ts +18 -0
  366. package/types/src/dataTable/index.d.ts +6 -0
  367. package/types/src/dataValidation/DataValidation.d.ts +70 -4
  368. package/types/src/dataValidation/DataValidationCollection.d.ts +23 -9
  369. package/types/src/dataValidation/IDataValidation.d.ts +150 -31
  370. package/types/src/dataValidation/IDataValidationCollection.d.ts +34 -2
  371. package/types/src/date/DateUtils.d.ts +20 -0
  372. package/types/src/date/_DateUtils.d.ts +91 -7
  373. package/types/src/documentProperties/DocumentProperties.d.ts +66 -0
  374. package/types/src/documentProperties/ICustomProperty.d.ts +69 -0
  375. package/types/src/documentProperties/IDocumentProperties.d.ts +110 -0
  376. package/types/src/documentProperties/index.d.ts +3 -0
  377. package/types/src/externalBook/ExternalBookCollection.d.ts +145 -12
  378. package/types/src/externalBook/ExternalBookName.d.ts +96 -0
  379. package/types/src/externalBook/IExternalBook.d.ts +171 -19
  380. package/types/src/externalBook/IExternalBookCollection.d.ts +79 -7
  381. package/types/src/externalBook/index.d.ts +1 -0
  382. package/types/src/{lib/file → file}/file.browser.d.ts +22 -8
  383. package/types/src/{lib/file → file}/file.node.d.ts +7 -2
  384. package/types/src/fill/IEffect.d.ts +5 -5
  385. package/types/src/fill/IFill.d.ts +129 -77
  386. package/types/src/fill/IFillable.d.ts +47 -0
  387. package/types/src/fill/IStroke.d.ts +204 -64
  388. package/types/src/fill/PaintUtils.d.ts +22 -0
  389. package/types/src/fill/RectAlignment.d.ts +20 -0
  390. package/types/src/fill/_Fills.d.ts +187 -0
  391. package/types/src/fill/_Stroke.d.ts +89 -0
  392. package/types/src/fill/index.d.ts +3 -0
  393. package/types/src/filter/IFilter.d.ts +188 -5
  394. package/types/src/font/AdvanceBuilder.d.ts +59 -0
  395. package/types/src/font/AdvanceTable.d.ts +228 -0
  396. package/types/src/font/CanvasAdvanceBuilder.d.ts +54 -0
  397. package/types/src/font/FontCapture.d.ts +4 -0
  398. package/types/src/font/FontCollection.d.ts +108 -0
  399. package/types/src/font/FontPlatform.d.ts +20 -0
  400. package/types/src/font/FontUtils.d.ts +5 -0
  401. package/types/src/font/IFont.d.ts +208 -61
  402. package/types/src/font/IFontCollection.d.ts +126 -22
  403. package/types/src/font/IFontStyle.d.ts +207 -0
  404. package/types/src/font/TableFileAdvanceBuilder.d.ts +36 -0
  405. package/types/src/font/_BuiltinFontTables.d.ts +10 -0
  406. package/types/src/font/_FontUtils.d.ts +11 -4
  407. package/types/src/font/_FontsVersion.d.ts +7 -0
  408. package/types/src/font/index.d.ts +2 -1
  409. package/types/src/font/platform.browser.d.ts +15 -0
  410. package/types/src/font/platform.node.d.ts +5 -0
  411. package/types/src/group/Group.d.ts +141 -0
  412. package/types/src/group/GroupMovableCollection.d.ts +41 -0
  413. package/types/src/group/IGroup.d.ts +129 -0
  414. package/types/src/group/index.d.ts +2 -0
  415. package/types/src/history/IHistory.d.ts +21 -3
  416. package/types/src/hyperlink/IHyperlink.d.ts +20 -1
  417. package/types/src/hyperlink/_Hyperlink.d.ts +5 -1
  418. package/types/src/i18n/LanguagePack.d.ts +12 -4
  419. package/types/src/index.d.ts +8 -0
  420. package/types/src/io/AbstractBackingStore.d.ts +24 -1
  421. package/types/src/io/ArrayBackingStore.d.ts +1 -1
  422. package/types/src/io/EmbeddedPart.d.ts +20 -0
  423. package/types/src/io/IEmbeddedPart.d.ts +63 -0
  424. package/types/src/io/IWorkbookIO.d.ts +185 -18
  425. package/types/src/io/WorkbookIO.d.ts +9 -0
  426. package/types/src/io/WorkbookOrigin.d.ts +20 -11
  427. package/types/src/io/WorkbookOriginProvider.d.ts +46 -0
  428. package/types/src/io/_XmlFragment.d.ts +49 -0
  429. package/types/src/io/index.d.ts +1 -0
  430. package/types/src/license/LicenseDetails.d.ts +1 -0
  431. package/types/src/license/LicenseManager.d.ts +25 -1
  432. package/types/src/license/Types.d.ts +38 -0
  433. package/types/src/license/_Utils.d.ts +39 -0
  434. package/types/src/license/details.d.ts +24 -0
  435. package/types/src/license/license-key.d.ts +49 -2
  436. package/types/src/license/runtime.browser.d.ts +46 -0
  437. package/types/src/{lib/utils/utils.node.d.ts → license/runtime.node.d.ts} +19 -12
  438. package/types/src/listener/IListener.d.ts +23 -6
  439. package/types/src/listener/ListenerEmitter.d.ts +55 -6
  440. package/types/src/model/AbstractModel.d.ts +14 -5
  441. package/types/src/movable/AbstractMovableContent.d.ts +182 -0
  442. package/types/src/movable/CustomElement.d.ts +4 -5
  443. package/types/src/movable/ErrorContent.d.ts +49 -0
  444. package/types/src/movable/FormControl.d.ts +285 -0
  445. package/types/src/movable/GroupMember.d.ts +87 -0
  446. package/types/src/movable/ICustomElement.d.ts +7 -2
  447. package/types/src/movable/IErrorContent.d.ts +23 -0
  448. package/types/src/movable/IFormControl.d.ts +455 -0
  449. package/types/src/movable/IMovable.d.ts +405 -60
  450. package/types/src/movable/IMovableCollection.d.ts +64 -4
  451. package/types/src/movable/Movable.d.ts +161 -50
  452. package/types/src/movable/MovableCollection.d.ts +21 -10
  453. package/types/src/movable/MovableContentRegistry.d.ts +113 -0
  454. package/types/src/movable/_BuiltInContents.d.ts +14 -0
  455. package/types/src/movable/_ContentFactory.d.ts +35 -0
  456. package/types/src/movable/_DrawnBounds.d.ts +37 -0
  457. package/types/src/movable/_InsertableCollection.d.ts +39 -0
  458. package/types/src/movable/_MovableUtils.d.ts +5 -0
  459. package/types/src/movable/_PendingContent.d.ts +25 -0
  460. package/types/src/movable/_PlacementUtils.d.ts +55 -0
  461. package/types/src/movable/_RotatedFrame.d.ts +20 -0
  462. package/types/src/movable/index.d.ts +7 -1
  463. package/types/src/named/AbstractNamed.d.ts +1 -1
  464. package/types/src/named/INamed.d.ts +34 -1
  465. package/types/src/named/INamedCollection.d.ts +28 -2
  466. package/types/src/named/NamedCollection.d.ts +32 -19
  467. package/types/src/numFmt/BuiltInFormats.d.ts +20 -7
  468. package/types/src/numFmt/IFormatEngine.d.ts +2 -0
  469. package/types/src/numFmt/NumberFormatParser.d.ts +5 -0
  470. package/types/src/numFmt/NumfmtFormatEngine.d.ts +2 -0
  471. package/types/src/numFmt/_FormatCell.d.ts +11 -2
  472. package/types/src/numFmt/_NumFmtUtils.d.ts +0 -1
  473. package/types/src/numFmt/vendor/numfmt/_sheetxl.d.ts +6 -0
  474. package/types/src/outline/IOutline.d.ts +186 -0
  475. package/types/src/outline/Outline.d.ts +157 -0
  476. package/types/src/outline/index.d.ts +2 -0
  477. package/types/src/person/IPerson.d.ts +99 -0
  478. package/types/src/person/IPersonCollection.d.ts +51 -0
  479. package/types/src/person/Person.d.ts +32 -0
  480. package/types/src/person/PersonCollection.d.ts +49 -0
  481. package/types/src/person/index.d.ts +4 -0
  482. package/types/src/picture/IPicture.d.ts +131 -4
  483. package/types/src/picture/Picture.d.ts +42 -14
  484. package/types/src/pivot/IPivotTable.d.ts +72 -0
  485. package/types/src/pivot/IPivotTableCollection.d.ts +25 -0
  486. package/types/src/pivot/PivotCache.d.ts +34 -0
  487. package/types/src/pivot/PivotTable.d.ts +61 -0
  488. package/types/src/pivot/PivotTableCollection.d.ts +25 -0
  489. package/types/src/pivot/_PivotXml.d.ts +24 -0
  490. package/types/src/pivot/index.d.ts +6 -0
  491. package/types/src/primitives/CompositeRangeStats.d.ts +2 -0
  492. package/types/src/primitives/Criteria.d.ts +1 -1
  493. package/types/src/primitives/Grouping.d.ts +65 -0
  494. package/types/src/primitives/LambdaBrand.d.ts +26 -0
  495. package/types/src/primitives/PrimitiveUtils.d.ts +56 -19
  496. package/types/src/primitives/Range.d.ts +133 -25
  497. package/types/src/primitives/RangeStats.d.ts +30 -2
  498. package/types/src/primitives/ReferenceRange.d.ts +44 -0
  499. package/types/src/primitives/Runtime.d.ts +15 -2
  500. package/types/src/primitives/environment.browser.d.ts +9 -0
  501. package/types/src/primitives/environment.node.d.ts +10 -0
  502. package/types/src/primitives/stats/AggregateStats.d.ts +49 -15
  503. package/types/src/primitives/stats/Cancellation.d.ts +13 -0
  504. package/types/src/primitives/stats/FrequencyStats.d.ts +10 -1
  505. package/types/src/primitives/stats/LookupIndex.d.ts +46 -0
  506. package/types/src/primitives/stats/Ranked.d.ts +1 -1
  507. package/types/src/primitives/stats/SortedNumbers.d.ts +4 -2
  508. package/types/src/primitives/stats/index.d.ts +1 -0
  509. package/types/src/print/IPageLayout.d.ts +635 -0
  510. package/types/src/print/PageLayout.d.ts +258 -0
  511. package/types/src/print/index.d.ts +1 -1
  512. package/types/src/protectedRange/IProtectedRange.d.ts +6 -2
  513. package/types/src/protectedRange/IProtectedRangeCollection.d.ts +2 -0
  514. package/types/src/protectedRange/ProtectedRange.d.ts +1 -4
  515. package/types/src/protectedRange/ProtectedRangeCollection.d.ts +19 -8
  516. package/types/src/protection/DefaultProtection.d.ts +12 -1
  517. package/types/src/protection/IProtection.d.ts +42 -2
  518. package/types/src/protection/PasswordHasher.d.ts +13 -0
  519. package/types/src/reference/ReferenceUtils.d.ts +80 -0
  520. package/types/src/reference/index.d.ts +2 -0
  521. package/types/src/resource/IResource.d.ts +21 -1
  522. package/types/src/resource/IResourceCollection.d.ts +9 -1
  523. package/types/src/resource/ResourceCollection.d.ts +6 -6
  524. package/types/src/richData/IRichDataKind.d.ts +22 -0
  525. package/types/src/richData/RichDataRegistry.d.ts +57 -0
  526. package/types/src/richData/RichText.d.ts +59 -0
  527. package/types/src/richData/index.d.ts +3 -0
  528. package/types/src/scripting/FunctionCollection.d.ts +49 -15
  529. package/types/src/scripting/IFunctionCollection.d.ts +62 -32
  530. package/types/src/scripting/IModule.d.ts +25 -0
  531. package/types/src/scripting/IModuleCollection.d.ts +17 -0
  532. package/types/src/scripting/IScript.d.ts +30 -28
  533. package/types/src/scripting/ITypedFunction.d.ts +1 -1
  534. package/types/src/scripting/Module.d.ts +34 -6
  535. package/types/src/scripting/ModuleCollection.d.ts +17 -12
  536. package/types/src/scripting/Runtime.d.ts +15 -0
  537. package/types/src/scripting/Scripts.d.ts +3 -7
  538. package/types/src/scripting/TypedFunction.d.ts +154 -18
  539. package/types/src/scripting/_FunctionIndex.d.ts +8 -3
  540. package/types/src/scripting/_ModuleUtils.d.ts +11 -1
  541. package/types/src/scripting/_ScriptUtils.d.ts +3 -0
  542. package/types/src/scripting/declarations.browser.d.ts +10 -0
  543. package/types/src/scripting/declarations.d.ts +52 -0
  544. package/types/src/scripting/declarations.node.d.ts +9 -0
  545. package/types/src/scripting/index.d.ts +3 -0
  546. package/types/src/selection/ChartElementSelection.d.ts +39 -0
  547. package/types/src/selection/IChartElementSelection.d.ts +103 -0
  548. package/types/src/selection/IItemSelection.d.ts +131 -0
  549. package/types/src/selection/IMovableSelection.d.ts +120 -0
  550. package/types/src/selection/IRangeSelection.d.ts +13 -8
  551. package/types/src/selection/ItemSelection.d.ts +49 -0
  552. package/types/src/selection/MovableSelection.d.ts +29 -0
  553. package/types/src/selection/RangeSelection.d.ts +19 -4
  554. package/types/src/selection/index.d.ts +4 -0
  555. package/types/src/shape/GeometryPreset.d.ts +197 -0
  556. package/types/src/shape/IGeometry.d.ts +380 -0
  557. package/types/src/shape/IShape.d.ts +342 -194
  558. package/types/src/shape/IShapeStyle.d.ts +109 -0
  559. package/types/src/shape/ITextBoxStyle.d.ts +85 -0
  560. package/types/src/shape/Shape.d.ts +107 -21
  561. package/types/src/shape/ShapeStyleUtils.d.ts +66 -0
  562. package/types/src/shape/_ConnectorFrame.d.ts +32 -0
  563. package/types/src/shape/_ConnectorRoute.d.ts +33 -0
  564. package/types/src/shape/_Connectors.d.ts +108 -0
  565. package/types/src/shape/_Geometry.d.ts +14 -0
  566. package/types/src/shape/_GeometryLoader.d.ts +21 -0
  567. package/types/src/shape/_ShapeStyle.d.ts +79 -0
  568. package/types/src/shape/_builtIn/_BuiltInChunks.d.ts +10 -0
  569. package/types/src/shape/_builtIn/_BuiltInDef.d.ts +9 -0
  570. package/types/src/shape/_builtIn/arrows.d.ts +6 -0
  571. package/types/src/shape/_builtIn/basic.d.ts +6 -0
  572. package/types/src/shape/_builtIn/callouts.d.ts +6 -0
  573. package/types/src/shape/_builtIn/flowchart.d.ts +6 -0
  574. package/types/src/shape/_builtIn/lines.d.ts +6 -0
  575. package/types/src/shape/_builtIn/math.d.ts +6 -0
  576. package/types/src/shape/_builtIn/other.d.ts +6 -0
  577. package/types/src/shape/_builtIn/rectangles.d.ts +6 -0
  578. package/types/src/shape/_builtIn/starsBanners.d.ts +6 -0
  579. package/types/src/shape/geometry/_strokeEnds.d.ts +7 -0
  580. package/types/src/shape/geometry/format.d.ts +3 -0
  581. package/types/src/shape/geometry/geometry.d.ts +85 -0
  582. package/types/src/shape/geometry/guides.d.ts +54 -0
  583. package/types/src/shape/geometry/handles.d.ts +14 -0
  584. package/types/src/shape/geometry/index.d.ts +7 -0
  585. package/types/src/shape/geometry/lineEnds.d.ts +54 -0
  586. package/types/src/shape/geometry/paths.d.ts +35 -0
  587. package/types/src/shape/geometry/segments.d.ts +114 -0
  588. package/types/src/shape/index.d.ts +4 -0
  589. package/types/src/sheet/CellRegion.d.ts +43 -3
  590. package/types/src/sheet/ICellContainerOptions.d.ts +50 -0
  591. package/types/src/sheet/IOpaqueSheet.d.ts +46 -0
  592. package/types/src/sheet/ISheet.d.ts +81 -931
  593. package/types/src/sheet/IWorksheet.d.ts +1514 -0
  594. package/types/src/sheet/{ISheetCollection.d.ts → IWorksheetCollection.d.ts} +38 -16
  595. package/types/src/sheet/NamedCellRange.d.ts +17 -8
  596. package/types/src/sheet/NamedRange.d.ts +10 -2
  597. package/types/src/sheet/OpaqueSheet.d.ts +114 -0
  598. package/types/src/sheet/SheetCell.d.ts +96 -39
  599. package/types/src/sheet/SheetRange.d.ts +130 -27
  600. package/types/src/sheet/SheetRanges.d.ts +33 -18
  601. package/types/src/sheet/Worksheet.d.ts +2250 -0
  602. package/types/src/sheet/WorksheetCollection.d.ts +39 -0
  603. package/types/src/sheet/_Anomalies.d.ts +109 -0
  604. package/types/src/sheet/_AnomalyFormulaChecks.d.ts +125 -0
  605. package/types/src/sheet/_AnomalyLabelChecks.d.ts +21 -0
  606. package/types/src/sheet/_CellBuffer.d.ts +224 -0
  607. package/types/src/sheet/_CopyUtils.d.ts +13 -6
  608. package/types/src/sheet/_HeldFormula.d.ts +69 -0
  609. package/types/src/sheet/_IgnoredErrors.d.ts +46 -0
  610. package/types/src/sheet/_InvalidSheetRange.d.ts +10 -9
  611. package/types/src/sheet/_Kinds.d.ts +34 -0
  612. package/types/src/sheet/_Labels.d.ts +38 -0
  613. package/types/src/sheet/_ListenerAnchor.d.ts +104 -0
  614. package/types/src/sheet/_RangeStateSweep.d.ts +15 -0
  615. package/types/src/sheet/_ScalarListFactory.d.ts +61 -0
  616. package/types/src/sheet/_SheetAutoFillUtils.d.ts +74 -0
  617. package/types/src/sheet/_SheetAutoFitUtils.d.ts +5 -5
  618. package/types/src/sheet/_SheetChangeEvent.d.ts +72 -0
  619. package/types/src/sheet/_SheetCoords.d.ts +3 -3
  620. package/types/src/sheet/_SheetEvents.d.ts +43 -0
  621. package/types/src/sheet/_SheetFilterUtils.d.ts +51 -3
  622. package/types/src/sheet/_SheetIntents.d.ts +314 -0
  623. package/types/src/sheet/_SheetMessages.d.ts +1 -1
  624. package/types/src/sheet/_SheetMutations.d.ts +185 -66
  625. package/types/src/sheet/_SheetSortUtils.d.ts +2 -2
  626. package/types/src/sheet/_SheetStateReader.d.ts +35 -11
  627. package/types/src/sheet/_SheetStateTypes.d.ts +143 -79
  628. package/types/src/sheet/_SheetUtils.d.ts +59 -41
  629. package/types/src/sheet/_WatchAnchor.d.ts +106 -0
  630. package/types/src/sheet/clipboard/RangeClipboardItems.d.ts +4 -4
  631. package/types/src/sheet/clipboard/SheetHTMLTableParser.d.ts +3 -3
  632. package/types/src/sheet/clipboard/SheetHTMLTableWriter.d.ts +3 -3
  633. package/types/src/sheet/index.d.ts +5 -2
  634. package/types/src/sheet/spatial/HeldFormulaEntry.d.ts +36 -0
  635. package/types/src/sheet/spatial/index.d.ts +1 -0
  636. package/types/src/sheet/style/SheetCellStyle.d.ts +223 -337
  637. package/types/src/sheet/style/SheetDirectStyle.d.ts +31 -20
  638. package/types/src/sheet/style/SheetNamedStyle.d.ts +19 -17
  639. package/types/src/sheet/style/SheetTableStyle.d.ts +5 -5
  640. package/types/src/sheet/style/_DigitWidth.d.ts +7 -0
  641. package/types/src/sheet/style/_Resolvers.d.ts +17 -10
  642. package/types/src/sheet/style/_StyleUtils.d.ts +34 -40
  643. package/types/src/sheetHeader/ISheetHeader.d.ts +96 -55
  644. package/types/src/sheetHeader/SheetCellHeader.d.ts +6 -0
  645. package/types/src/sheetHeader/SheetCellHeaderRange.d.ts +2 -0
  646. package/types/src/sheetHeader/SheetCellHeaderRanges.d.ts +2 -0
  647. package/types/src/sheetHeader/SheetHeader.d.ts +48 -27
  648. package/types/src/sheetHeader/_HeaderMetrics.d.ts +37 -0
  649. package/types/src/sheetHeader/_HeaderUtils.d.ts +5 -4
  650. package/types/src/sheetProtection/{ISheetProtection.d.ts → IWorksheetProtection.d.ts} +64 -30
  651. package/types/src/sheetProtection/WorksheetProtection.d.ts +51 -0
  652. package/types/src/sheetProtection/index.d.ts +1 -1
  653. package/types/src/sheetView/{ISheetView.d.ts → IWorksheetView.d.ts} +230 -69
  654. package/types/src/sheetView/WorksheetView.d.ts +139 -0
  655. package/types/src/sheetView/_SheetViewUtils.d.ts +5 -3
  656. package/types/src/sheetView/index.d.ts +1 -1
  657. package/types/src/slicer/ISlicer.d.ts +304 -17
  658. package/types/src/slicer/ISlicerStyle.d.ts +109 -0
  659. package/types/src/slicer/Slicer.d.ts +128 -13
  660. package/types/src/slicer/SlicerStyle.d.ts +25 -0
  661. package/types/src/slicer/_BuiltInSlicerStyles.d.ts +13 -0
  662. package/types/src/slicer/_SlicerUtils.d.ts +30 -0
  663. package/types/src/slicer/index.d.ts +1 -0
  664. package/types/src/sort/ISort.d.ts +39 -7
  665. package/types/src/string/IStringCollection.d.ts +5 -0
  666. package/types/src/string/StringCollection.d.ts +6 -6
  667. package/types/src/style/{IStyle.d.ts → ICellStyle.d.ts} +117 -85
  668. package/types/src/style/INamedStyleCollection.d.ts +72 -0
  669. package/types/src/style/ISlicerStyleCollection.d.ts +77 -0
  670. package/types/src/style/IStyleCollection.d.ts +91 -60
  671. package/types/src/style/ITableStyleCollection.d.ts +89 -0
  672. package/types/src/style/NamedStyleCollection.d.ts +39 -0
  673. package/types/src/style/SlicerStyleCollection.d.ts +46 -0
  674. package/types/src/style/StyleCollection.d.ts +81 -26
  675. package/types/src/style/TableStyleCollection.d.ts +49 -0
  676. package/types/src/style/_BuiltInStyleDefs.d.ts +9 -8
  677. package/types/src/style/_BuiltInStyleNames.d.ts +2 -2
  678. package/types/src/style/index.d.ts +7 -1
  679. package/types/src/table/AnchoredTable.d.ts +723 -78
  680. package/types/src/table/AutoTable.d.ts +8 -6
  681. package/types/src/table/ITable.d.ts +289 -49
  682. package/types/src/table/ITableCollection.d.ts +12 -0
  683. package/types/src/table/ITableStyle.d.ts +37 -37
  684. package/types/src/table/TableCollection.d.ts +19 -8
  685. package/types/src/table/_FilterField.d.ts +19 -6
  686. package/types/src/table/_NamedTable.d.ts +20 -4
  687. package/types/src/table/_NamedTableSource.d.ts +3 -2
  688. package/types/src/table/_SortField.d.ts +2 -0
  689. package/types/src/table/_TableColumn.d.ts +13 -2
  690. package/types/src/table/_TableMessages.d.ts +1 -0
  691. package/types/src/table/_TableUtils.d.ts +40 -0
  692. package/types/src/text/Bullet.d.ts +4 -0
  693. package/types/src/text/IText.d.ts +150 -15
  694. package/types/src/text/ITextFrame.d.ts +110 -1
  695. package/types/src/text/TextBoxAlignment.d.ts +25 -16
  696. package/types/src/text/TextEngine.d.ts +34 -0
  697. package/types/src/text/TextFrame.d.ts +8 -2
  698. package/types/src/text/TextLine.d.ts +4 -0
  699. package/types/src/text/TextParagraph.d.ts +4 -0
  700. package/types/src/text/TextRotation.d.ts +3 -3
  701. package/types/src/text/TextRun.d.ts +12 -2
  702. package/types/src/text/TextStacked.d.ts +83 -0
  703. package/types/src/text/TextWrapper.d.ts +32 -26
  704. package/types/src/text/_TextUtils.d.ts +5 -5
  705. package/types/src/text/_TextWrapperFallback.d.ts +49 -0
  706. package/types/src/text/impl/TabStrategy.d.ts +3 -1
  707. package/types/src/text/index.d.ts +1 -0
  708. package/types/src/text/richtext/IRichText.d.ts +50 -0
  709. package/types/src/text/richtext/index.d.ts +1 -1
  710. package/types/src/theme/ITheme.d.ts +153 -11
  711. package/types/src/theme/IThemeCollection.d.ts +2 -0
  712. package/types/src/theme/ThemeCollection.d.ts +16 -7
  713. package/types/src/theme/_OfficeFontScheme.d.ts +8 -0
  714. package/types/src/theme/_OfficeFormatScheme.d.ts +3 -0
  715. package/types/src/transaction/ITransaction.d.ts +277 -45
  716. package/types/src/transaction/Transaction.d.ts +108 -11
  717. package/types/src/transaction/TransactionUndoManager.d.ts +4 -1
  718. package/types/src/transaction/_BatchHandle.d.ts +118 -0
  719. package/types/src/type/AbstractCollection.d.ts +92 -0
  720. package/types/src/type/ICollection.d.ts +131 -1
  721. package/types/src/type/IProperties.d.ts +1 -1
  722. package/types/src/type/ITypes.d.ts +9 -7
  723. package/types/src/type/index.d.ts +1 -0
  724. package/types/src/utils/_CSSUtils.d.ts +4 -4
  725. package/types/src/wasm/_fontsWasm.d.ts +7 -0
  726. package/types/src/wasm/_sdkWasm.d.ts +7 -0
  727. package/types/src/wasm/fontsWasm.d.ts +32 -0
  728. package/types/src/wasm/index.d.ts +3 -0
  729. package/types/src/wasm/loader.browser.d.ts +9 -0
  730. package/types/src/wasm/loader.node.d.ts +9 -0
  731. package/types/src/wasm/sdkWasm.d.ts +32 -0
  732. package/types/src/workbook/IWorkbook.d.ts +404 -73
  733. package/types/src/workbook/Workbook.d.ts +196 -28
  734. package/types/src/workbook/WorkbookRange.d.ts +2 -2
  735. package/types/src/workbook/WorkbookRanges.d.ts +2 -2
  736. package/types/src/workbook/_WorkbookIntents.d.ts +36 -0
  737. package/types/src/workbook/_WorkbookMessages.d.ts +5 -0
  738. package/types/src/workbookProtection/IWorkbookProtection.d.ts +7 -0
  739. package/types/src/workbookProtection/WorkbookProtection.d.ts +3 -0
  740. package/types/src/workbookView/IWorkbookView.d.ts +94 -0
  741. package/types/src/workbookView/WorkbookView.d.ts +26 -0
  742. package/browser/cjs/B7_pDFYCVzt-3hUs.cjs +0 -1
  743. package/browser/cjs/BatsV2UUraVDCRXm.cjs +0 -57
  744. package/browser/cjs/CUz53T65cRGQRgvv.cjs +0 -33
  745. package/browser/cjs/DU0kYUtdFa3jK-im.cjs +0 -1
  746. package/browser/cjs/Dv3x6zut1ZRUt3IF.cjs +0 -10
  747. package/browser/cjs/Dv4yIPLV98M5zLHa.cjs +0 -1
  748. package/browser/cjs/a0Z-SXs_N71CtqYb.cjs +0 -1
  749. package/browser/cjs/index.cjs +0 -3
  750. package/browser/esm/6JKSOvc5czaQB2Bj.mjs +0 -109
  751. package/browser/esm/BtuJ9AGzeURtAsGo.mjs +0 -51241
  752. package/browser/esm/DGU6sM25u0EWCKl1.mjs +0 -824
  753. package/node/esm/-pxdn3M3tc6PLHs7.mjs +0 -114
  754. package/node/esm/0n5bslM9jhO1JnI2.mjs +0 -843
  755. package/types/src/cellRange/_GraphNode.d.ts +0 -38
  756. package/types/src/collections/OverlappingRangeIterator.d.ts +0 -91
  757. package/types/src/condition/BuiltinSelectors/ListSelector.d.ts +0 -12
  758. package/types/src/dataValidation/_Utils.d.ts +0 -10
  759. package/types/src/font/CanvasFontMeasurer.d.ts +0 -25
  760. package/types/src/font/FontKitFontMeasurer.d.ts +0 -11
  761. package/types/src/font/SimpleFontMeasurer.d.ts +0 -4
  762. package/types/src/lib/utils/_Utils.d.ts +0 -27
  763. package/types/src/lib/utils/utils.browser.d.ts +0 -33
  764. package/types/src/movable/IGroup.d.ts +0 -30
  765. package/types/src/movable/IMovableSelection.d.ts +0 -49
  766. package/types/src/print/IPrint.d.ts +0 -234
  767. package/types/src/sheet/Sheet.d.ts +0 -1107
  768. package/types/src/sheet/SheetCollection.d.ts +0 -18
  769. package/types/src/sheet/listener/RangesListener.d.ts +0 -32
  770. package/types/src/sheet/listener/RangesListenerEntry.d.ts +0 -19
  771. package/types/src/sheet/listener/index.d.ts +0 -3
  772. package/types/src/sheetProtection/SheetProtection.d.ts +0 -39
  773. package/types/src/sheetView/SheetView.d.ts +0 -113
  774. package/types/src/text/richtext/IStyledFont.d.ts +0 -330
  775. /package/types/src/{lib/utils → license}/banner.d.ts +0 -0
@@ -1,19 +1,19 @@
1
1
  /**
2
- * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.8.0-beta.1
2
+ * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.8.0-beta.11
3
3
  *
4
4
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
6
6
  */
7
- import { n as e } from "./B0HS42a7lga1k1U_.mjs";
8
- import { $t as t, At as n, B as r, Bt as i, Cn as a, Ct as o, Dn as s, Dt as c, En as l, Et as u, Ft as d, Gt as f, Ht as p, It as m, Jt as h, Lt as g, M as _, Mt as v, Nt as y, On as ee, Ot as b, Pt as te, Qt as ne, Rt as re, Sn as x, St as ie, Tn as S, Tt as ae, U as oe, Ut as C, Vt as w, Wt as T, Xt as E, Y as se, Yt as ce, Zt as le, _n as ue, _t as de, a as D, an as fe, at as pe, bn as me, bt as he, c as ge, cn as _e, ct as ve, d as ye, dn as be, dt as xe, en as O, f as Se, fn as Ce, ft as we, gn as Te, gt as Ee, h as De, hn as Oe, ht as ke, i as Ae, in as k, it as je, jt as Me, kt as Ne, l as A, ln as Pe, lt as Fe, m as Ie, mn as Le, mt as Re, n as ze, nn as Be, o as j, on as Ve, ot as He, p as Ue, pn as We, pt as Ge, qt as Ke, r as qe, rn as Je, rt as Ye, s as Xe, sn as Ze, st as Qe, t as $e, tn as M, u as et, un as tt, ut as nt, vn as rt, vt as it, wn as at, wt as ot, xn as N, xt as st, yn as ct, yt as lt, zt as ut } from "./BtuJ9AGzeURtAsGo.mjs";
9
- import { t as dt } from "./f2G3QRgEbvFJcoa2.mjs";
10
- import { FormulaError as P, ScalarType as F } from "@sheetxl/primitives";
11
- import { BufferUtils as ft, CommonUtils as I, CoordUtils as L, DOMUtils as pt, DefaultLanguagePackService as mt, ExpectedError as R, InvalidPasswordError as ht, MimeType as gt, Notifier as z, NullNotAllowedError as _t, OutOfBoundsError as B, PasswordRequiredError as vt, UndoManager as yt, messageKey as V, t as H } from "@sheetxl/utils";
7
+ import { a as e, l as t, o as n, t as r, u as i } from "./CU3DmJ-YnVVrC1_k.mjs";
8
+ import { A as a, Ar as o, Bi as s, Bt as c, C as l, Cn as u, Cr as d, D as f, Dr as p, E as m, Er as h, Fr as g, Ft as _, Gi as v, Gt as y, Hi as b, It as x, Ji as S, Jt as C, Ki as ee, Kt as te, Lt as ne, Mr as re, N as ie, Ni as ae, Nr as oe, O as se, Or as ce, Pr as le, Qr as ue, Ri as de, Rt as fe, S as pe, Sn as me, Sr as he, T as ge, Tr as _e, Ui as ve, Ur as ye, Vi as be, Vr as xe, Vt as Se, Wi as Ce, Wt as we, Xi as Te, Xr as Ee, Xt as De, Yi as Oe, Yt as w, Zi as ke, Zr as Ae, _i as je, _r as Me, a as Ne, ai as Pe, an as Fe, at as Ie, b as T, br as Le, bt as Re, ci as ze, ct as Be, di as Ve, dt as He, en as Ue, fi as We, fr as E, ft as Ge, gi as Ke, gn as qe, gr as Je, gt as Ye, hi as Xe, hn as Ze, hr as Qe, ht as $e, i as et, ii as tt, in as nt, it as rt, jr as it, k as at, kr as ot, lt as st, mi as ct, mr as lt, mt as ut, nn as D, oi as dt, on as ft, pi as pt, pr as mt, pt as ht, qi as O, qr as gt, qt as _t, r as vt, ri as k, rt as yt, si as bt, sn as xt, tn as St, ui as Ct, ut as wt, v as Tt, vr as Et, vt as Dt, w as A, wn as Ot, wr as kt, x as At, xr as jt, xt as Mt, y as j, yr as Nt, yt as Pt, zt as Ft } from "./C16ycKja6zG0crV_.mjs";
9
+ import { $t as It, B as Lt, Ct as Rt, E as zt, Gt as Bt, H as Vt, I as Ht, Kt as Ut, L as Wt, O as Gt, Qt as Kt, R as qt, St as Jt, V as Yt, W as Xt, Yt as M, at as Zt, ct as Qt, dt as $t, en as N, ft as P, lt as en, ot as tn, qt as F, rt as nn, st as rn, ut as an, z as on } from "./CV5EGEjG5_-CPpP0.mjs";
10
+ import { n as sn, t as cn } from "./BMyDRQ716j79h_bH.mjs";
11
+ import { t as ln } from "./gssVX_FH1XFN-twD.mjs";
12
+ import { FormulaError as I, ScalarType as L } from "@sheetxl/primitives";
13
+ import { BufferUtils as un, CommonUtils as R, CoordUtils as z, DOMUtils as dn, DefaultLanguagePackService as fn, ExpectedError as B, InvalidPasswordError as pn, MimeType as mn, Notifier as V, NullNotAllowedError as hn, OutOfBoundsError as H, PasswordRequiredError as gn, ProtectedError as U, UndoManager as _n, messageKey as W, t as G } from "@sheetxl/utils";
12
14
  export * from "@sheetxl/primitives";
13
15
  export * from "@sheetxl/utils";
14
- var bt;
15
- bt ||= {};
16
- var xt = class extends yt {
16
+ var vn, yn = class extends _n {
17
17
  constructor(e, t = 50) {
18
18
  super(t), this._transactions = e, this._floorId = e ? e.getCurrentCommit(!1).getId() : null, this._removeListener = e?.addListener({ onCommitChange: () => this._notifyOnStackChange() });
19
19
  }
@@ -97,6 +97,17 @@ var xt = class extends yt {
97
97
  let e = this._redoCommits().map((e) => e.getDescription());
98
98
  return e.length === 0 && this._repeatOperation !== null && e.push(this._repeatOperation.description), Object.freeze(e);
99
99
  }
100
+ getUndoEntries() {
101
+ return this._undoCommits().map(xn);
102
+ }
103
+ getRedoEntries() {
104
+ let e = this._redoCommits().map(xn);
105
+ return e.length === 0 && this._repeatOperation !== null && e.push({
106
+ description: this._repeatOperation.description,
107
+ author: null,
108
+ meta: bn
109
+ }), Object.freeze(e);
110
+ }
100
111
  addUndoOperation() {
101
112
  throw Error("TransactionUndoManager derives its stack from the commit log; commit a described transaction instead.");
102
113
  }
@@ -106,19 +117,23 @@ var xt = class extends yt {
106
117
  close() {
107
118
  this._removeListener?.();
108
119
  }
109
- }, St = class {
110
- constructor(e, t) {
111
- this._dirty = !1, this._store = e, this._savedCommitId = e.getCurrentCommit()?.getId() ?? null, this._emitter = new S(this);
112
- let n = this;
113
- this._removeStoreListener = e.addListener({
120
+ }, bn = Object.freeze({}), xn = (e) => ({
121
+ description: e.getDescription(),
122
+ author: e.getAuthor(),
123
+ meta: e.getMeta() ?? bn
124
+ }), Sn = class {
125
+ constructor(t, n) {
126
+ this._dirty = !1, this._store = t, this._savedCommitId = t.getCurrentCommit()?.getId() ?? null, this._emitter = new e(this);
127
+ let r = this;
128
+ this._removeStoreListener = t.addListener({
114
129
  onCommitEnd() {
115
- n._recompute();
130
+ r._recompute();
116
131
  },
117
132
  onCommitChange() {
118
- n._recompute();
133
+ r._recompute();
119
134
  }
120
- }), this._removeCommitListener = t?.addCommitListener({ onCommit(e) {
121
- e.store === n._store && n.markSaved(e.commitId);
135
+ }), this._removeCommitListener = n?.addCommitListener({ onCommit(e) {
136
+ e.store === r._store && r.markSaved(e.commitId);
122
137
  } });
123
138
  }
124
139
  getStore() {
@@ -143,9 +158,11 @@ var xt = class extends yt {
143
158
  close() {
144
159
  this._removeStoreListener?.(), this._removeCommitListener?.(), this._emitter.close();
145
160
  }
146
- }, U = class e {
147
- constructor(t, n = {}) {
148
- this._password = null, this._emitter = new S(this), this._path = t ?? null, this._name = n.name ?? null, this._format = n.format ?? null, this._size = n.size ?? null, this._canWrite = n.canWrite ?? e._defaultCanWrite(this._path), this._encryption = n.encryption ?? null;
161
+ };
162
+ vn ||= {};
163
+ var Cn, K = class t {
164
+ constructor(n, r = {}) {
165
+ this._password = null, this._emitter = new e(this), this._path = n ?? null, this._name = r.name ?? null, this._format = r.format ?? null, this._size = r.size ?? null, this._lastModified = r.lastModified ?? null, this._canWrite = r.canWrite ?? t._defaultCanWrite(this._path), this._encryption = r.encryption ?? null;
149
166
  }
150
167
  static _defaultCanWrite(e) {
151
168
  return !!e && !/^(https?:|data:|blob:)/i.test(e);
@@ -156,7 +173,7 @@ var xt = class extends yt {
156
173
  getName() {
157
174
  if (this._name !== null && this._name !== void 0) return this._name;
158
175
  let e = this._cleanPath();
159
- return e && N(e) || null;
176
+ return e && O(e) || null;
160
177
  }
161
178
  getPath() {
162
179
  return this._path;
@@ -167,7 +184,7 @@ var xt = class extends yt {
167
184
  getExtension() {
168
185
  let e = this._cleanPath();
169
186
  if (!e) return null;
170
- let t = x(e);
187
+ let t = S(e);
171
188
  return t ? t.toLowerCase() : null;
172
189
  }
173
190
  getEncryption() {
@@ -185,6 +202,9 @@ var xt = class extends yt {
185
202
  getSize() {
186
203
  return this._size;
187
204
  }
205
+ getLastModified() {
206
+ return this._lastModified;
207
+ }
188
208
  canWrite() {
189
209
  return this._canWrite;
190
210
  }
@@ -193,7 +213,7 @@ var xt = class extends yt {
193
213
  }
194
214
  update(e) {
195
215
  let t = !1;
196
- return e.path !== void 0 && e.path !== this._path && (this._path = e.path, t = !0), e.name !== void 0 && e.name !== this._name && (this._name = e.name, t = !0), e.format !== void 0 && e.format !== this._format && (this._format = e.format, t = !0), e.size !== void 0 && e.size !== this._size && (this._size = e.size, t = !0), e.canWrite !== void 0 && e.canWrite !== this._canWrite && (this._canWrite = e.canWrite, t = !0), e.encryption !== void 0 && e.encryption !== this._encryption && (this._encryption = e.encryption, t = !0), t && this._emitter.notify("onChange"), this;
216
+ return e.lastModified !== void 0 && e.lastModified !== this._lastModified && (this._lastModified = e.lastModified, t = !0), e.name !== void 0 && e.name !== this._name && (this._name = e.name, t = !0), e.format !== void 0 && e.format !== this._format && (this._format = e.format, t = !0), e.size !== void 0 && e.size !== this._size && (this._size = e.size, t = !0), e.canWrite !== void 0 && e.canWrite !== this._canWrite && (this._canWrite = e.canWrite, t = !0), e.encryption !== void 0 && e.encryption !== this._encryption && (this._encryption = e.encryption, t = !0), t && this._emitter.notify("onChange"), this;
197
217
  }
198
218
  addListeners(e, t) {
199
219
  return this._emitter.addListeners(e, t);
@@ -214,37 +234,59 @@ var xt = class extends yt {
214
234
  ];
215
235
  return `${t} ${(n / 1024 ** r).toFixed(2)}${i[Math.min(r, i.length - 1)]}`;
216
236
  }
217
- }, Ct = class {
237
+ }, q = /* @__PURE__ */ new WeakMap(), wn = /* @__PURE__ */ new Set(), Tn = (e) => q.get(e) ?? null, En = () => Array.from(wn, (e) => e.getOrigin()), Dn = class t {
238
+ constructor(n) {
239
+ this._released = !1, t._assertFree(n), this._emitter = new e(this), this._origin = n, q.set(n, this), wn.add(this);
240
+ }
241
+ getOrigin() {
242
+ return this._origin;
243
+ }
244
+ setOrigin(e) {
245
+ e !== this._origin && (t._assertFree(e), this._released || (q.delete(this._origin), q.set(e, this)), this._origin = e, this._emitter.notify("onOriginChange"));
246
+ }
247
+ release() {
248
+ this._released || (this._released = !0, q.get(this._origin) === this && q.delete(this._origin), wn.delete(this));
249
+ }
250
+ addListeners(e, t) {
251
+ return this._emitter.addListeners(e, t);
252
+ }
253
+ static _assertFree(e) {
254
+ if (q.has(e)) throw Error("This origin already backs an open workbook; an origin backs one workbook at a time.");
255
+ }
256
+ }, On = class {
218
257
  constructor() {
219
258
  this._defaultStringSourceType = "filepath";
220
259
  }
221
260
  async read(e) {
222
261
  let t = e.options ?? {}, n = e.source;
223
262
  if (typeof n == "function" && (n = n()), n && typeof n == "object" && typeof n.then == "function" && (n = await Promise.resolve(n)), n == null && (n = await this.resolveSource(e), n == null)) return null;
224
- let r = t.format, i = this._detectSourceType(n);
225
- if (!i) throw Error("Unable to detect source type from provided input.");
226
- let a, o, s = !1;
227
- if (i === "filepath") {
263
+ let r = n, i = await this.fileFromHandle(n);
264
+ i && (n = i);
265
+ let a = t.format, o = this._detectSourceType(n);
266
+ if (!o) throw Error("Unable to detect source type from provided input.");
267
+ let s, c, l = !1;
268
+ if (o === "filepath") {
228
269
  let e = typeof n == "string" && n.startsWith("file://") ? n.slice(7) : n;
229
- n = await this.filePathToFile(e), i = "file", s = !0;
270
+ n = await this.filePathToFile(e), o = "file", l = !0;
230
271
  }
231
- switch (i) {
272
+ switch (o) {
232
273
  case "file": {
233
- let e = n, t = e?.name, i = t ? `${N(t)}` : "";
234
- a = await e.arrayBuffer(), o = {
235
- format: r,
236
- ext: x(t),
237
- name: i,
238
- absolutePath: t,
274
+ let e = n, r = e?.name, o = r ? `${O(r)}` : "";
275
+ s = await e.arrayBuffer(), c = {
276
+ format: a,
277
+ ext: S(r),
278
+ name: o,
279
+ absolutePath: r,
239
280
  size: e.size,
240
- canWrite: s && this._canWriteLocalPath()
281
+ lastModified: e.lastModified,
282
+ canWrite: !t.asCopy && (!!i || l && this._canWriteLocalPath())
241
283
  };
242
284
  break;
243
285
  }
244
286
  case "blob": {
245
287
  let e = n;
246
- a = await e.arrayBuffer(), o = {
247
- format: r,
288
+ s = await e.arrayBuffer(), c = {
289
+ format: a,
248
290
  size: e.size
249
291
  };
250
292
  break;
@@ -256,68 +298,85 @@ var xt = class extends yt {
256
298
  let [, t] = n.split(",");
257
299
  e = t;
258
300
  } else e = n;
259
- a = ft.base64ToArrayBuffer(e), o = {
260
- format: r,
301
+ s = un.base64ToArrayBuffer(e), c = {
302
+ format: a,
261
303
  size: e.length
262
304
  };
263
305
  break;
264
306
  }
265
307
  case "fetch": {
266
- let e, t, i;
308
+ let e, t, r;
267
309
  if (typeof n == "string") e = n;
268
310
  else {
269
311
  if (!n || typeof n != "object" || !("input" in n)) throw Error("Invalid fetch source provided.");
270
312
  {
271
- let r = n;
272
- e = r.input, t = r.init, i = r.timeout;
313
+ let i = n;
314
+ e = i.input, t = i.init, r = i.timeout;
273
315
  }
274
316
  }
275
- let s = i || 3e4, c = new AbortController(), l = setTimeout(() => c.abort(), s), u = typeof e == "string" ? e : e.toString(), d = x(u);
317
+ let i = r || 3e4, o = new AbortController(), l = setTimeout(() => o.abort(), i), u = typeof e == "string" ? e : e.toString(), d = S(u);
276
318
  try {
277
319
  let n = await fetch(e, {
278
320
  ...t,
279
- signal: c.signal
321
+ signal: o.signal
280
322
  });
281
323
  if (clearTimeout(l), !n.ok) throw Error(`Failed to fetch: ${n.status} ${n.statusText}`);
282
- let i = await n.arrayBuffer();
283
- if (!i) throw Error(`Unable to fetched content: ${u}`);
284
- a = i, o = {
285
- format: r,
324
+ let r = await n.arrayBuffer();
325
+ if (!r) throw Error(`Unable to fetched content: ${u}`);
326
+ s = r, c = {
327
+ format: a,
286
328
  ext: d,
287
- name: N(u, !0),
329
+ name: O(u, !0),
288
330
  absolutePath: u
289
331
  };
290
332
  } catch (e) {
291
- throw clearTimeout(l), e.name === "AbortError" ? Error(`Fetch timeout after ${s}ms: ${u}`) : e;
333
+ throw clearTimeout(l), e.name === "AbortError" ? Error(`Fetch timeout after ${i}ms: ${u}`) : e;
292
334
  }
293
335
  break;
294
336
  }
295
337
  case "buffer":
296
- a = n, o = { format: r };
338
+ s = n, c = { format: a };
297
339
  break;
298
340
  case "stream": {
299
- let e = n.getReader(), t = [], i = 0;
341
+ let e = n.getReader(), t = [], r = 0;
300
342
  try {
301
343
  for (;;) {
302
- let { done: n, value: r } = await e.read();
344
+ let { done: n, value: i } = await e.read();
303
345
  if (n) break;
304
- t.push(r), i += r.length;
346
+ t.push(i), r += i.length;
305
347
  }
306
348
  } finally {
307
349
  e.releaseLock();
308
350
  }
309
- let s = new ArrayBuffer(i), c = new Uint8Array(s), l = 0;
310
- for (let e of t) c.set(e, l), l += e.length;
311
- a = s, o = { format: r };
351
+ let i = new ArrayBuffer(r), o = new Uint8Array(i), l = 0;
352
+ for (let e of t) o.set(e, l), l += e.length;
353
+ s = i, c = { format: a };
312
354
  break;
313
355
  }
314
- default: throw Error(`Unsupported source type: ${i}`);
356
+ default: throw Error(`Unsupported source type: ${o}`);
315
357
  }
316
- let c = await e.decode(a, {
317
- sourceType: i,
318
- ...o
358
+ c.canWrite && await this.findOpenOrigin(r, c) && (c.canWrite = !1);
359
+ let u = await e.decode(s, {
360
+ sourceType: o,
361
+ ...c
319
362
  });
320
- return c ? (await this.onWorkbookRead(c, n), c) : null;
363
+ return u ? (await this.onWorkbookRead(u, r), u) : null;
364
+ }
365
+ async findOpenOrigin(e, t) {
366
+ return t.absolutePath ? this.findOpenPath(t.absolutePath) : null;
367
+ }
368
+ findOpenPath(e, t) {
369
+ return En().find((n) => {
370
+ if (n === t || !n.canWrite()) return !1;
371
+ let r = n.getPath();
372
+ return !!r && this.isSamePath(r, e);
373
+ }) ?? null;
374
+ }
375
+ isSamePath(e, t) {
376
+ return e === t;
377
+ }
378
+ async fileFromHandle(e) {
379
+ return null;
321
380
  }
322
381
  async resolveSource(e) {
323
382
  return null;
@@ -338,25 +397,21 @@ var xt = class extends yt {
338
397
  }
339
398
  if (typeof File < "u" && e instanceof File) return "file";
340
399
  if (typeof Blob < "u" && e instanceof Blob) return "blob";
341
- let t = e instanceof ArrayBuffer || Object.prototype.toString.call(e) === "[object ArrayBuffer]", n = ArrayBuffer.isView(e), r = ft.isNodeBuffer(e);
400
+ let t = e instanceof ArrayBuffer || Object.prototype.toString.call(e) === "[object ArrayBuffer]", n = ArrayBuffer.isView(e), r = un.isNodeBuffer(e);
342
401
  return t || n || r ? "buffer" : typeof ReadableStream < "u" && e instanceof ReadableStream || Object.prototype.toString.call(e) === "[object ReadableStream]" || e && typeof e.getReader == "function" && e.locked !== void 0 ? "stream" : null;
343
402
  }
344
- }, wt = class extends Ct {
403
+ }, kn = class extends On {
345
404
  constructor(e, t) {
346
- super(), this._getWriteFormats = e, this._getReadFormats = t, this._defaultStringSourceType = "fetch", this._handleCache = /* @__PURE__ */ new WeakMap(), this._pendingOpenHandle = null;
405
+ super(), this._getWriteFormats = e, this._getReadFormats = t, this._defaultStringSourceType = "fetch", this._handleCache = /* @__PURE__ */ new WeakMap();
347
406
  }
348
- async read(e) {
349
- let t = e.source;
350
- return t && t.kind === "file" && typeof t.getFile == "function" ? (this._pendingOpenHandle = t, super.read({
351
- ...e,
352
- source: await t.getFile()
353
- })) : super.read(e);
407
+ async fileFromHandle(e) {
408
+ return jn(e) ? e.getFile() : null;
354
409
  }
355
410
  async resolveSource() {
356
411
  let e = await this._getReadFormats?.() ?? [];
357
412
  if (typeof globalThis.showOpenFilePicker == "function") try {
358
413
  let t = function(e) {
359
- let t = Tt(e);
414
+ let t = An(e);
360
415
  if (t.length <= 1) return t;
361
416
  let n = /* @__PURE__ */ new Set(), r = {};
362
417
  for (let e of t) for (let [t, i] of Object.entries(e.accept)) for (let e of i) n.has(e) || (n.add(e), (r[t] ??= []).push(e));
@@ -365,30 +420,35 @@ var xt = class extends yt {
365
420
  accept: r
366
421
  }, ...t];
367
422
  }(e), [n] = await globalThis.showOpenFilePicker(t.length ? { types: t } : void 0);
368
- return this._pendingOpenHandle = n, await n.getFile();
423
+ return n;
369
424
  } catch (e) {
370
425
  if (e?.name === "AbortError") return null;
371
426
  throw e;
372
427
  }
373
428
  let t = e.flatMap((e) => e.exts.map((e) => "." + e)).join(", ");
374
- return pt.openFileDialog(t);
429
+ return dn.openFileDialog(t);
430
+ }
431
+ async findOpenOrigin(e) {
432
+ return jn(e) ? this._findOpenHandle(e) : null;
375
433
  }
376
- async onWorkbookRead(e) {
377
- if (this._pendingOpenHandle) {
378
- let t = e.getOrigin?.();
379
- t && (this._handleCache.set(t, this._pendingOpenHandle), t instanceof U && t.update({ canWrite: !0 })), this._pendingOpenHandle = null;
434
+ async _findOpenHandle(e, t) {
435
+ for (let n of En()) {
436
+ if (n === t || !n.canWrite()) continue;
437
+ let r = this._handleCache.get(n);
438
+ if (r && typeof r.isSameEntry == "function" && await r.isSameEntry(e)) return n;
380
439
  }
440
+ return null;
441
+ }
442
+ async onWorkbookRead(e, t) {
443
+ if (!jn(t)) return;
444
+ let n = e.getOrigin?.();
445
+ n?.canWrite() && this._handleCache.set(n, t);
381
446
  }
382
447
  async filePathToFile(e) {
383
448
  throw Error(`Cannot read local file path '${e}' in browser environment. Use a file input element or fetch for remote URLs.`);
384
449
  }
385
450
  async write(e) {
386
451
  let { origin: t, suggestedName: n, format: r, encode: i, prompt: a } = e, o = [r, ...(await this._getWriteFormats()).filter((e) => e.key !== r.key)], s = typeof globalThis.showSaveFilePicker == "function", c = !a && t.canWrite() ? this._handleCache.get(t) : void 0;
387
- if (c?.name) {
388
- let e = t.getPath()?.split(/[/\\]/).pop();
389
- e && c.name !== e && (c = void 0);
390
- }
391
- let l = !!c;
392
452
  if (s) try {
393
453
  if (c) {
394
454
  let e = await async function(e) {
@@ -403,39 +463,46 @@ var xt = class extends yt {
403
463
  if (e === "denied") return null;
404
464
  e !== "granted" && (c = void 0);
405
465
  }
406
- c ||= await globalThis.showSaveFilePicker({
407
- suggestedName: n,
408
- types: Tt(o)
409
- });
410
- let e = Dt(c.name ?? n), a = o.find((t) => t.exts.some((t) => t.toLowerCase() === e)) ?? r, s = await i(a.key), u = new Blob([Et(s)], { type: a.mimeType || "application/octet-stream" }), d = await c.createWritable();
411
- return await d.write(u), await d.close(), this._handleCache.set(t, c), t instanceof U && t.update({
412
- size: u.size,
413
- ...l ? null : {
414
- path: c.name ?? n,
415
- name: null,
416
- format: a.key,
417
- canWrite: !0
418
- }
419
- }), t;
466
+ let a = !!c;
467
+ if (!a) {
468
+ c = await globalThis.showSaveFilePicker({
469
+ suggestedName: n,
470
+ types: An(o)
471
+ });
472
+ let t = await this._findOpenHandle(c, e.workbook?.getOrigin?.());
473
+ if (t) throw new B(G("error.io.openElsewhere", { name: t.getName() ?? c.name ?? "" }));
474
+ }
475
+ let s = Nn(c.name ?? n), l = o.find((e) => e.exts.some((e) => e.toLowerCase() === s)) ?? r, u = a ? t : new K(c.name ?? n, {
476
+ format: l.key,
477
+ canWrite: !0
478
+ }), d = await i(l.key, u);
479
+ if (!d) return null;
480
+ let f = new Blob([Mn(d)], { type: l.mimeType || "application/octet-stream" }), p = await c.createWritable();
481
+ if (await p.write(f), await p.close(), this._handleCache.set(u, c), u instanceof K) {
482
+ let e = await Promise.resolve(c.getFile?.()).then((e) => e?.lastModified ?? null, () => null);
483
+ u.update({
484
+ size: f.size,
485
+ lastModified: e
486
+ });
487
+ }
488
+ return u;
420
489
  } catch (e) {
421
490
  if (e?.name === "AbortError") return null;
422
- }
423
- let u = await i(r.key), d = new Blob([Et(u)], { type: r.mimeType || "application/octet-stream" }), f = t.getPath(), p = f ? f.split(/[/\\]/).pop() : null, m = p && Dt(p) ? p : n;
491
+ if (e instanceof B) throw e;
492
+ }
493
+ let l = t.getPath(), u = l ? l.split(/[/\\]/).pop() : null, d = u && r.exts.some((e) => e.toLowerCase() === Nn(u)) ? u : n, f = l !== d || t.canWrite() ? new K(d, {
494
+ format: r.key,
495
+ canWrite: !1
496
+ }) : t, p = await i(r.key, f);
497
+ if (!p) return null;
498
+ let m = new Blob([Mn(p)], { type: r.mimeType || "application/octet-stream" });
424
499
  return function(e, t) {
425
500
  let n = URL.createObjectURL(e), r = document.createElement("a");
426
501
  r.style.display = "none", r.href = n, r.download = t, document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(n);
427
- }(d, m), t instanceof U && t.update({
428
- size: d.size,
429
- ...t.getPath() === m ? null : {
430
- path: m,
431
- name: null,
432
- format: r.key,
433
- canWrite: !1
434
- }
435
- }), t;
502
+ }(m, d), f instanceof K && f.update({ size: m.size }), f;
436
503
  }
437
504
  };
438
- function Tt(e) {
505
+ function An(e) {
439
506
  return e.map((e) => {
440
507
  let t = e.mimeType && e.mimeType.includes("/") ? e.mimeType : "application/octet-stream";
441
508
  return {
@@ -444,228 +511,83 @@ function Tt(e) {
444
511
  };
445
512
  });
446
513
  }
447
- function Et(e) {
514
+ function jn(e) {
515
+ return !!e && e.kind === "file" && typeof e.getFile == "function";
516
+ }
517
+ function Mn(e) {
448
518
  if (typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) {
449
519
  let t = new ArrayBuffer(e.byteLength);
450
520
  return new Uint8Array(t).set(new Uint8Array(e)), t;
451
521
  }
452
522
  return e;
453
523
  }
454
- function Dt(e) {
524
+ function Nn(e) {
455
525
  let t = e.lastIndexOf(".");
456
526
  return t >= 0 ? e.slice(t + 1).toLowerCase() : "";
457
527
  }
458
- var Ot = class {
459
- constructor(e) {
460
- this._private = { input: e }, typeof e == "string" ? this._private.name = e : Object.assign(this._private, e);
461
- }
462
- toJSON() {
463
- return this._private.input;
464
- }
465
- getFamily() {
466
- return this._private.name;
467
- }
468
- getPitch() {
469
- return this._private.pitch;
470
- }
471
- getPanose() {
472
- return this._private.panose;
473
- }
474
- toString() {
475
- return typeof this._private.input == "string" ? this._private.input : JSON.stringify(this._private.input);
476
- }
477
- get isIFont() {
478
- return !0;
479
- }
480
- }, kt = e({
481
- findBestMatch: () => Pt,
482
- getFontList: () => Nt,
483
- setFontList: () => K
484
- }), At = [
485
- "Arial",
486
- "Arial Black",
487
- "Brush Script MT",
488
- "Calibri",
489
- "Comic Sans MS",
490
- "Courier New",
491
- "Garamond",
492
- "Georgia",
493
- "Impact",
494
- "Luminari",
495
- "Palatino Linotype",
496
- "Tahoma",
497
- "Times New Roman",
498
- "Trebuchet MS",
499
- "Verdana"
500
- ], W = /* @__PURE__ */ new Map();
501
- W.set(k.GenericName.Serif, ["Tahoma"]), W.set(k.GenericName.SanSerif, ["Calibri"]), W.set(k.GenericName.MonoSpace, ["Courier New"]), W.set(k.GenericName.Cursive, ["Comic Sans MS"]), W.set(k.GenericName.Fantasy, ["Luminari"]), W.set(k.GenericName.UISystem, ["Arial"]), W.set(k.GenericName.UISerif, ["Tahoma"]), W.set(k.GenericName.UISanSerif, ["Arial"]), W.set(k.GenericName.UIMonoSpace, ["Courier New"]), W.set(k.GenericName.UIRounded, ["Arial"]), W.set(k.GenericName.Math, []), W.set(k.GenericName.Emoji, []), W.set(k.GenericName.Fangsong, []);
502
- var G = /* @__PURE__ */ new Map(), jt = [];
503
- K(At);
504
- var Mt = eval;
505
- function K(e) {
506
- e || K(At);
507
- let t = [];
508
- for (let n = 0; n < e.length; n++) {
509
- let r = e[n];
510
- typeof r == "string" && (r = new Ot(r));
511
- let i = !0;
512
- try {
513
- i = Mt(`document.fonts.check('12px ${r.getFamily()}')`);
514
- } catch {}
515
- let a = {
516
- fontRef: r,
517
- loaded: i
518
- };
519
- t.push(a), G.set(r.getFamily(), a);
520
- }
521
- jt = Object.freeze(t);
522
- }
523
- function Nt() {
524
- return jt;
525
- }
526
- var q = /* @__PURE__ */ new Map();
527
- function Pt(e, t) {
528
- let n = q.get(e);
529
- if (n) return n.fontRef === null ? null : n;
530
- let r = [e];
531
- t?.fallbacks && (r = r.concat(t.fallbacks));
532
- let i = null;
533
- for (let e = 0; !i && e < r.length; e++) {
534
- let t = r[e];
535
- if (i = G.get(t), !i) {
536
- let e = W.get(t);
537
- if (e) for (let t = 0; !i && t < e.length; t++) i = G.get(e[t]);
538
- }
539
- }
540
- return i ? q.set(e, i) : q.set(e, {
541
- fontRef: null,
542
- loaded: !1
543
- }), i;
544
- }
545
- var Ft, It, J, Lt, Rt = e({
546
- DefaultFontSizes: () => zt,
547
- findNextFontSize: () => Bt
548
- }), zt = Object.freeze([
549
- 8,
550
- 9,
551
- 10,
552
- 11,
553
- 12,
554
- 14,
555
- 16,
556
- 18,
557
- 20,
558
- 22,
559
- 24,
560
- 26,
561
- 28,
562
- 30,
563
- 36,
564
- 48,
565
- 72
566
- ]);
567
- function Bt(e, t = !0, n = zt) {
568
- if (!n || n.length === 0) return e;
569
- if (e === void 0) return n[0];
570
- if (t && e >= n[n.length - 1] || !t && e <= n[0]) return e;
571
- let r = I.findEqualOrGreater(n, e);
572
- return t ? (n[r] === e && (r += 1), n[r] || --r, n[r]) : (--r, n[r]);
573
- }
574
- (Ft ||= {}).SortOn = {
528
+ (Cn ||= {}).SortOn = {
575
529
  Value: "value",
576
530
  FillColor: "fillColor",
577
531
  FontColor: "fontColor",
578
532
  Icon: "icon"
579
- }, (J = It ||= {}).Compound = {
580
- Single: "sng",
581
- Double: "dbl",
582
- ThickThin: "thickThin",
583
- ThinThick: "thinThick",
584
- Triple: "tri"
585
- }, J.Align = {
586
- Center: "ctr",
587
- Inset: "in",
588
- Outset: "outset"
589
- }, J.LineCap = {
590
- Butt: "butt",
591
- Round: "round",
592
- Square: "square"
593
- }, J.LineJoin = {
594
- Bevel: "bevel",
595
- Miter: "miter",
596
- Round: "round"
597
- }, J.PresetMarkerShape = {
598
- Single: "none",
599
- Double: "double",
600
- ThickThin: "thickThin",
601
- ThinThick: "thickThin"
602
- }, J.StrokeStyle = {
603
- None: "none",
604
- Dashed: "dashed",
605
- Dotted: "dotted",
606
- LargeDash: "lgDash",
607
- LargeDashDot: "lgDashDot",
608
- LargeDashDotDot: "lgDashDotDot",
609
- Solid: "solid",
610
- SysDash: "sysDash",
611
- SysDashDot: "sysDashDot",
612
- SysDashDotDot: "sysDashDotDot",
613
- SysDot: "sysDot"
614
- }, (Lt ||= {}).Type = {
615
- OuterShadow: "outerShadow",
616
- InnerShadow: "innerShadow",
617
- PresetShadow: "presetShadow",
618
- Glow: "glow",
619
- SoftEdge: "softEdge",
620
- Reflection: "reflection"
621
533
  };
622
- var Y = ut.BuiltInName, Vt = {
623
- [Y.Normal]: V("style.builtin.normal"),
624
- [Y.Comma]: V("style.builtin.comma"),
625
- [Y.Currency]: V("style.builtin.currency"),
626
- [Y.Percent]: V("style.builtin.percent"),
627
- [Y.Comma0]: V("style.builtin.comma0"),
628
- [Y.Currency0]: V("style.builtin.currency0"),
629
- [Y.Hyperlink]: V("style.builtin.hyperlink"),
630
- [Y.FollowedHyperlink]: V("style.builtin.followedHyperlink"),
631
- [Y.Note]: V("style.builtin.note"),
632
- [Y.WarningText]: V("style.builtin.warningText"),
633
- [Y.Title]: V("style.builtin.title"),
634
- [Y.Input]: V("style.builtin.input"),
635
- [Y.Output]: V("style.builtin.output"),
636
- [Y.Calculation]: V("style.builtin.calculation"),
637
- [Y.CheckCell]: V("style.builtin.checkCell"),
638
- [Y.LinkedCell]: V("style.builtin.linkedCell"),
639
- [Y.Total]: V("style.builtin.total"),
640
- [Y.Good]: V("style.builtin.good"),
641
- [Y.Bad]: V("style.builtin.bad"),
642
- [Y.Neutral]: V("style.builtin.neutral"),
643
- [Y.ExplanatoryText]: V("style.builtin.explanatoryText")
644
- }, Ht = V("style.builtin.heading"), Ut = V("style.builtin.accent"), Wt = V("style.builtin.accentTint"), Gt = /^Heading ([1-4])$/, Kt = /^Accent([1-6])$/, qt = /^(20|40|60)% - Accent([1-6])$/;
645
- function Jt(e) {
646
- let t = Vt[e];
534
+ var Pn = {
535
+ TopLeft: "tl",
536
+ Top: "t",
537
+ TopRight: "tr",
538
+ Left: "l",
539
+ Center: "ctr",
540
+ Right: "r",
541
+ BottomLeft: "bl",
542
+ Bottom: "b",
543
+ BottomRight: "br"
544
+ }, J = Zt.BuiltInName, Fn = {
545
+ [J.Normal]: W("style.builtin.normal"),
546
+ [J.Comma]: W("style.builtin.comma"),
547
+ [J.Currency]: W("style.builtin.currency"),
548
+ [J.Percent]: W("style.builtin.percent"),
549
+ [J.Comma0]: W("style.builtin.comma0"),
550
+ [J.Currency0]: W("style.builtin.currency0"),
551
+ [J.Hyperlink]: W("style.builtin.hyperlink"),
552
+ [J.FollowedHyperlink]: W("style.builtin.followedHyperlink"),
553
+ [J.Note]: W("style.builtin.note"),
554
+ [J.WarningText]: W("style.builtin.warningText"),
555
+ [J.Title]: W("style.builtin.title"),
556
+ [J.Input]: W("style.builtin.input"),
557
+ [J.Output]: W("style.builtin.output"),
558
+ [J.Calculation]: W("style.builtin.calculation"),
559
+ [J.CheckCell]: W("style.builtin.checkCell"),
560
+ [J.LinkedCell]: W("style.builtin.linkedCell"),
561
+ [J.Total]: W("style.builtin.total"),
562
+ [J.Good]: W("style.builtin.good"),
563
+ [J.Bad]: W("style.builtin.bad"),
564
+ [J.Neutral]: W("style.builtin.neutral"),
565
+ [J.ExplanatoryText]: W("style.builtin.explanatoryText")
566
+ }, In = W("style.builtin.heading"), Ln = W("style.builtin.accent"), Rn = W("style.builtin.accentTint"), zn = /^Heading ([1-4])$/, Bn = /^Accent([1-6])$/, Vn = /^(20|40|60)% - Accent([1-6])$/;
567
+ function Hn(e) {
568
+ let t = Fn[e];
647
569
  if (t) return { key: t };
648
- let n = Gt.exec(e);
570
+ let n = zn.exec(e);
649
571
  return n ? {
650
- key: Ht,
572
+ key: In,
651
573
  params: { n: +n[1] }
652
- } : (n = Kt.exec(e), n ? {
653
- key: Ut,
574
+ } : (n = Bn.exec(e), n ? {
575
+ key: Ln,
654
576
  params: { n: +n[1] }
655
- } : (n = qt.exec(e), n ? {
656
- key: Wt,
577
+ } : (n = Vn.exec(e), n ? {
578
+ key: Rn,
657
579
  params: {
658
580
  pct: +n[1],
659
581
  n: +n[2]
660
582
  }
661
583
  } : null));
662
584
  }
663
- var Yt, Xt, Zt, Qt, $t = (e, t, n, r, i) => {
585
+ var Un, Wn, Gn, Kn, qn = (e, t, n, r, i) => {
664
586
  let a = JSON.parse(JSON.stringify(e.definition));
665
587
  a.adjs ||= [];
666
588
  let o = "", s = 0, c = 0;
667
- t > 0 ? (c = t, s = 100 - t, o = H("op.lighterPercent", { percent: t })) : t < 0 && (s = 100 + t, o = H("op.darkerPercent", { percent: -t })), s && a.adjs.push({ [C.AdjustmentType.LumMod]: s }), c && a.adjs.push({ [C.AdjustmentType.LumOff]: c });
668
- let l = new w({
589
+ t > 0 ? (c = t, s = 100 - t, o = G("op.lighterPercent", { percent: t })) : t < 0 && (s = 100 + t, o = G("op.darkerPercent", { percent: -t })), s && a.adjs.push({ [$t.AdjustmentType.LumMod]: s }), c && a.adjs.push({ [$t.AdjustmentType.LumOff]: c });
590
+ let l = new en({
669
591
  val: a.val,
670
592
  adjs: a.adjs
671
593
  }, n), u = l.toString();
@@ -676,14 +598,14 @@ var Yt, Xt, Zt, Qt, $t = (e, t, n, r, i) => {
676
598
  definition: a
677
599
  };
678
600
  };
679
- function en(e, t, n, r) {
601
+ function Jn(e, t, n, r) {
680
602
  let i = [];
681
603
  for (let a = 0; a < e.length; a++) {
682
604
  let o = [];
683
605
  i.push(o);
684
606
  let s = (i) => {
685
- for (let s = 0; s < i.length; s++) o.push($t(e[a], i[s], t, n, r));
686
- }, c = new w({
607
+ for (let s = 0; s < i.length; s++) o.push(qn(e[a], i[s], t, n, r));
608
+ }, c = new en({
687
609
  val: e[a].definition.val,
688
610
  adjs: e[a].definition.adjs
689
611
  }, t).toHSLA().lum;
@@ -721,73 +643,61 @@ function en(e, t, n, r) {
721
643
  }
722
644
  return i;
723
645
  }
724
- (Yt ||= {}).buildPalette = en, Xt ||= {}, Zt ||= {}, Qt ||= {};
725
- var X = null;
726
- function tn() {
727
- if (!X) {
728
- let e = import("./6JKSOvc5czaQB2Bj.mjs").then(({ initializeFunctions: e }) => {
646
+ (Un ||= {}).buildPalette = Jn, Wn ||= {}, Gn ||= {}, Kn ||= {};
647
+ var Yn, Y = null;
648
+ function Xn() {
649
+ if (!Y) {
650
+ let e = import("./DLLE0FZNsKxbBzRn.mjs").then(({ initializeFunctions: e }) => {
729
651
  let t = e(() => null);
730
652
  return Object.freeze(Array.from(t.keys()));
731
653
  });
732
654
  e.catch(() => {
733
- X = null;
734
- }), X = e;
655
+ Y = null;
656
+ }), Y = e;
735
657
  }
736
- return X;
658
+ return Y;
737
659
  }
738
- function nn(e) {
739
- let t = e.trim();
740
- if (!t) return;
741
- let n;
742
- try {
743
- let e = dt.shared().tokenize(t, !1);
744
- if (e.errors.length > 0) return;
745
- n = e.tokens;
746
- } catch {
747
- return;
748
- }
749
- let i = 0, a = 0;
750
- if (n.length === 2) {
751
- let e = n[0].tokenType?.name;
752
- e === "MinOp" ? (i = -1, a = 1) : e === "PlusOp" && (i = 1, a = 1);
753
- }
754
- if (n.length - a !== 1) return;
755
- let o = n[a], s = o.image;
756
- try {
757
- switch (o.tokenType?.name) {
758
- case "NumberToken":
759
- case "ScientificDigit":
760
- case "DigitToken": {
761
- let e = oe(s).value;
762
- return i === 0 ? e : i * e;
763
- }
764
- case "StringToken": return i === 0 ? se(s).value : void 0;
765
- case "BooleanToken": return i === 0 ? _(s).value : void 0;
766
- case "LiteralError":
767
- case "RefError": return i === 0 ? r(s).value : void 0;
768
- default: return;
769
- }
770
- } catch {
771
- return;
772
- }
660
+ function Zn(e) {
661
+ return Ot.peek()?.readFormulaLiteral(e);
773
662
  }
774
- function rn(e, t) {
775
- let n = an(e), r = an(t);
776
- return n === r ? e === t ? 0 : typeof e == "number" && typeof t == "number" ? e < t ? -1 : 1 : typeof e == "string" && typeof t == "string" ? e < t ? -1 : +(e > t) : typeof e == "boolean" ? e ? 1 : -1 : P.isError(e) && P.isError(t) ? e.getCode() - t.getCode() : 0 : n - r;
663
+ function Qn(e, t) {
664
+ let n = $n(e), r = $n(t);
665
+ return n === r ? e === t ? 0 : typeof e == "number" && typeof t == "number" ? e < t ? -1 : 1 : typeof e == "string" && typeof t == "string" ? e < t ? -1 : +(e > t) : typeof e == "boolean" ? e ? 1 : -1 : I.isError(e) && I.isError(t) ? e.getCode() - t.getCode() : 0 : n - r;
777
666
  }
778
- function an(e) {
667
+ function $n(e) {
779
668
  if (e === null) return 0;
780
669
  switch (typeof e) {
781
670
  case "number": return 1;
782
671
  case "string": return 2;
783
672
  case "boolean": return 3;
784
- default: return P.isError(e) ? 4 : 5;
673
+ default: return I.isError(e) ? 4 : 5;
785
674
  }
786
675
  }
787
- var on = class {
676
+ (function(e) {
677
+ function t(e) {
678
+ return Ot.peek()?.getFunctionDeclaration(e) ?? null;
679
+ }
680
+ e.get = t, e.has = function(e) {
681
+ return t(e) !== null;
682
+ };
683
+ })(Yn ||= {});
684
+ var er = class {
788
685
  constructor(e) {
789
686
  this._children = e;
790
687
  }
688
+ getCoords() {
689
+ let e = this._children, t = null;
690
+ for (let n = 0; n < e.length; n++) {
691
+ let r = e[n].getCoords();
692
+ r && (t = t ? {
693
+ rowStart: Math.min(t.rowStart, r.rowStart),
694
+ colStart: Math.min(t.colStart, r.colStart),
695
+ rowEnd: Math.max(t.rowEnd, r.rowEnd),
696
+ colEnd: Math.max(t.colEnd, r.colEnd)
697
+ } : r);
698
+ }
699
+ return t;
700
+ }
791
701
  getSize() {
792
702
  let e = this._children, t = e.length, n = 0;
793
703
  for (let r = 0; r < t; r++) n += e[r].getSize();
@@ -816,19 +726,19 @@ var on = class {
816
726
  let n = t[e].getSortedNumbers().getValues();
817
727
  n.length > 0 && r.push(n);
818
728
  }
819
- e = new $e(function(e) {
729
+ e = new vt(function(e) {
820
730
  let t = e.length;
821
- if (t === 0) return sn;
731
+ if (t === 0) return tr;
822
732
  if (t === 1) return e[0];
823
733
  let n = e[0];
824
- for (let r = 1; r < t; r++) n = cn(n, e[r]);
734
+ for (let r = 1; r < t; r++) n = nr(n, e[r]);
825
735
  return Object.freeze(n);
826
736
  }(r)), this._sortedNumbers = e;
827
737
  }
828
738
  return e;
829
739
  }
830
740
  getRanked(e) {
831
- return ze(this._children, e, rn)[Symbol.iterator]();
741
+ return et(this._children, e, Qn)[Symbol.iterator]();
832
742
  }
833
743
  getFrequencies(e) {
834
744
  if (e) return this._mergeFrequencies(e);
@@ -836,7 +746,7 @@ var on = class {
836
746
  return t || (t = this._mergeFrequencies(), this._frequencies = t), t;
837
747
  }
838
748
  _mergeFrequencies(e) {
839
- let t = e?.keyFn ?? Ee, n = e?.limit, r = /* @__PURE__ */ new Map(), i = this._children, a = i.length, o = 0, s = 0, c = !1;
749
+ let t = e?.keyFn ?? lt, n = e?.limit, r = /* @__PURE__ */ new Map(), i = this._children, a = i.length, o = 0, s = 0, c = !1;
840
750
  for (let l = 0; l < a; l++) {
841
751
  let a = i[l].getFrequencies(e);
842
752
  o += a.getVisitedCount(), s += a.getTotalCount(), c ||= a.isTruncated();
@@ -849,22 +759,22 @@ var on = class {
849
759
  }) : c = !0, d = u.next();
850
760
  }
851
761
  }
852
- return ke.fromGroups(r, t, e, rn, o, s, c);
762
+ return mt.fromGroups(r, t, e, Qn, o, s, c);
853
763
  }
854
764
  getTypedCounts(e) {
855
765
  let t = this._typedCounts;
856
766
  if (!t) {
857
767
  let e = {
858
- [F.Number]: 0,
859
- [F.String]: 0,
860
- [F.Boolean]: 0,
861
- [F.Error]: 0,
862
- [F.RichData]: 0,
863
- [F.Null]: 0
768
+ [L.Number]: 0,
769
+ [L.String]: 0,
770
+ [L.Boolean]: 0,
771
+ [L.Error]: 0,
772
+ [L.RichData]: 0,
773
+ [L.Null]: 0
864
774
  }, n = this._children, r = n.length;
865
775
  for (let t = 0; t < r; t++) {
866
776
  let r = n[t].getTypedCounts();
867
- e[F.Number] += r[F.Number] ?? 0, e[F.String] += r[F.String] ?? 0, e[F.Boolean] += r[F.Boolean] ?? 0, e[F.Error] += r[F.Error] ?? 0, e[F.RichData] += r[F.RichData] ?? 0, e[F.Null] += r[F.Null] ?? 0;
777
+ e[L.Number] += r[L.Number] ?? 0, e[L.String] += r[L.String] ?? 0, e[L.Boolean] += r[L.Boolean] ?? 0, e[L.Error] += r[L.Error] ?? 0, e[L.RichData] += r[L.RichData] ?? 0, e[L.Null] += r[L.Null] ?? 0;
868
778
  }
869
779
  t = Object.freeze(e), this._typedCounts = t;
870
780
  }
@@ -885,12 +795,12 @@ var on = class {
885
795
  sum: 0,
886
796
  sumSq: 0,
887
797
  typed: {
888
- [F.Number]: 0,
889
- [F.String]: 0,
890
- [F.Boolean]: 0,
891
- [F.Error]: 0,
892
- [F.RichData]: 0,
893
- [F.Null]: 0
798
+ [L.Number]: 0,
799
+ [L.String]: 0,
800
+ [L.Boolean]: 0,
801
+ [L.Error]: 0,
802
+ [L.RichData]: 0,
803
+ [L.Null]: 0
894
804
  }
895
805
  };
896
806
  for (let i = 0; i < n; i++) {
@@ -899,169 +809,153 @@ var on = class {
899
809
  let a = n.numericalCount;
900
810
  a <= 0 || (r.numericalCount += a, r.sum += n.sum, r.sumSq += n.varP * a + n.sum * n.sum / a, (r.min === void 0 || n.min < r.min) && (r.min = n.min), (r.max === void 0 || n.max > r.max) && (r.max = n.max));
901
811
  }
902
- return qe(r);
812
+ return Ne(r);
903
813
  }
904
- }, sn = Object.freeze([]);
905
- function cn(e, t) {
814
+ }, tr = Object.freeze([]);
815
+ function nr(e, t) {
906
816
  let n = e.length, r = t.length, i = Array(n + r), a = 0, o = 0, s = 0;
907
817
  for (; a < n && o < r;) i[s++] = e[a] <= t[o] ? e[a++] : t[o++];
908
818
  for (; a < n;) i[s++] = e[a++];
909
819
  for (; o < r;) i[s++] = t[o++];
910
820
  return i;
911
821
  }
912
- var ln = class {
913
- constructor(e) {
914
- this.isIExternalBook = !0, this._json = e;
822
+ var rr, ir = class {
823
+ constructor(e, t) {
824
+ this._source = null, this.cacheId = e, this.part = t;
825
+ }
826
+ _hold(e) {
827
+ let t = this.part?.xml;
828
+ if (!t || this._source) return;
829
+ let n = te(t, "worksheetSource", "ref"), r = te(t, "worksheetSource", "sheet");
830
+ if (!n || !r || n.includes("#REF!")) return;
831
+ let i = e(r);
832
+ if (!i) return;
833
+ let a = {
834
+ formula: null,
835
+ wired: null,
836
+ last: null
837
+ };
838
+ this._source = a, i(`${Ae(r)}!${y(n)}`, (e) => {
839
+ a.formula = e.formula;
840
+ let t = e.formula.getExpression();
841
+ a.wired ??= t, e.formula.hasRefError() || (a.last = t);
842
+ });
915
843
  }
916
- getIdentity() {
917
- return this._json.identity;
844
+ getXML() {
845
+ let e = this.part?.xml ?? null, t = this._source;
846
+ if (!e || !t?.formula) return e;
847
+ let n = t.formula.hasRefError() ? t.last : t.formula.getExpression();
848
+ if (n === null || n === t.wired) return e;
849
+ let r = Mt(n);
850
+ return r ? C(C(e, "worksheetSource", "ref", _t(r.reference)), "worksheetSource", "sheet", r.sheet) : C(e, "worksheetSource", "ref", _t(n));
918
851
  }
919
- getSheetNames() {
920
- return this._json.sheetNames;
852
+ toJSON(e) {
853
+ let t = { cacheId: this.cacheId }, n = w.toJSON(this.part, e);
854
+ if (n) {
855
+ let e = this.getXML();
856
+ e !== null && (n.xml = e), t.part = n;
857
+ }
858
+ return t;
921
859
  }
922
- getDefinedNames() {
923
- return this._json.definedNames ?? [];
860
+ }, ar = class {
861
+ constructor(e, t) {
862
+ this._deleted = !1, this._json = { ...e }, this._deleteFromCollection = t ?? null;
924
863
  }
925
- getSheetData(e) {
926
- return this._json.sheetDataSet?.find((t) => t.sheetIndex === e) ?? null;
864
+ getId() {
865
+ return this._json.id;
927
866
  }
928
- toJSON() {
929
- return this._json;
867
+ getDisplayName() {
868
+ return this._json.displayName;
930
869
  }
931
- }, un = class {
932
- constructor(e) {
933
- this.isIExternalBookCollection = !0, this._items = (e?.json ?? []).map((e) => e ? new ln(e) : null);
870
+ getUserId() {
871
+ return this._json.userId ?? null;
934
872
  }
935
- [Symbol.iterator]() {
936
- return this.getItems()[Symbol.iterator]();
873
+ getProviderId() {
874
+ return this._json.providerId ?? null;
937
875
  }
938
- getItems() {
939
- let e = [], t = this._items.length;
940
- for (let n = 0; n < t; n++) {
941
- let t = this._items[n];
942
- t && e.push(t);
943
- }
944
- return e;
876
+ delete() {
877
+ this._deleted || (this._deleted = !0, this._deleteFromCollection?.(this));
945
878
  }
946
- getCount() {
947
- return this.getItems().length;
948
- }
949
- getByIndex(e) {
950
- return this._items[e - 1] ?? null;
879
+ isDeleted() {
880
+ return this._deleted;
951
881
  }
952
882
  toJSON() {
953
- return this._items.length === 0 ? null : this._items.map((e) => e?.toJSON() ?? null);
954
- }
955
- }, dn = class {
956
- constructor(e) {
957
- this._closed = !1, this._options = { ...e };
958
- let t = this;
959
- this._transactions = this._options.transactions ?? new s({ transient: !0 }), this._stateId = this._transactions.create(), this._transactionsRemoveListener = this._transactions.addStateListener(this._stateId, { onAfterStateChange(e, n, r) {
960
- t._emitter.notify("onCollectionChange");
961
- } }), this._emitter = new S(this, this._transactions), this._initState(e?.initial);
962
- }
963
- add(e, t, n) {
964
- let r = this;
965
- t && t.addListeners({ onDelete: (t) => {
966
- r._updateState((t) => {
967
- if (!t.modules[e]) return;
968
- let n = t.modules[e];
969
- if (n) {
970
- let i = { ...t };
971
- return r._options.onRemove?.(e, n), r._emitter.notify("onCollectionChange"), delete i.modules[e], i;
972
- }
973
- return t;
974
- }, V("op.deleteModule"));
975
- } }, { once: !0 });
976
- let i = this._getState()?.modules, a = i?.[e], o = n?.replace ?? !1;
977
- if (a && !o) throw Error(`Already existing '${e}'`);
978
- let s = { ...i };
979
- t ? (s[e] = t, r._options.onAdd?.(e, t), this._updateState({ modules: s }, V(o ? "op.saveScripts" : "op.addScript"))) : (delete s[e], r._options.onRemove?.(e, null), this._updateState({ modules: s }, V("op.removeScript"))), r._emitter.notify("onCollectionChange");
980
- }
981
- *[Symbol.iterator]() {
982
- yield* this.getItems();
983
- }
984
- getItems(e) {
985
- let t = this._getState();
986
- if (!t) return I.EmptyArray;
987
- let n = t.modules, r = Object.keys(n), i = r.length;
988
- if (i === 0) return I.EmptyArray;
989
- let a = [], o = e?.name ? e.name.toUpperCase() : null;
990
- for (let e = 0; e < i; e++) {
991
- let t = r[e], i = n[t], s = !0;
992
- o && o !== t.toUpperCase() && (s = !1), s && a.push(i);
993
- }
994
- return a ?? I.EmptyArray;
883
+ return { ...this._json };
995
884
  }
996
- getByName(e) {
997
- if (!e) return null;
998
- let t = this._getState();
999
- if (!t) return null;
1000
- let n = e.toUpperCase(), r = t.modules, i = Object.keys(r), a = i.length;
1001
- for (let e = 0; e < a; e++) {
1002
- let t = i[e];
1003
- if (n === t.toUpperCase()) return r[t];
1004
- }
1005
- return null;
885
+ get [Symbol.toStringTag]() {
886
+ return "[Person]";
1006
887
  }
1007
- getCount() {
1008
- let e = this._getState();
1009
- return e ? Object.keys(e.modules).length : 0;
888
+ toString() {
889
+ return `Person:${this.getDisplayName()}`;
1010
890
  }
1011
- beginCommit(e) {
1012
- return this._beginCommit(e);
891
+ get isIPerson() {
892
+ return !0;
1013
893
  }
1014
- _getState() {
1015
- if (this._closed) throw Error(H("error.model.modelClosed"));
1016
- return this._transactions.getState(this._stateId);
894
+ }, or = class extends ke {
895
+ constructor(e) {
896
+ super(), this._byId = /* @__PURE__ */ new Map(), this._byDisplayName = /* @__PURE__ */ new Map(), this._items = null, this._current = null, e && this.fromJSON(e);
1017
897
  }
1018
- _beginCommit(e) {
1019
- return this._transactions.beginCommit(typeof e == "string" ? { description: e } : e);
898
+ _getItems() {
899
+ return this._items ??= Array.from(this._byId.values());
1020
900
  }
1021
- _updateState(e, t = V("op.update"), n) {
1022
- if (!e) return;
1023
- let r = this._beginCommit(t);
1024
- try {
1025
- r.updateState(this._stateId, e), r.commit(n);
1026
- } catch (e) {
1027
- throw r.rollback(), e;
1028
- }
901
+ getCount() {
902
+ return this._byId.size;
1029
903
  }
1030
- _initState(e) {
1031
- let t = e ?? {};
1032
- this._updateState({ modules: t }, V("op.initialize"), { forceAmend: !0 });
1033
- let n = this._options.onAdd;
904
+ add(e) {
905
+ let t = typeof e == "string" ? { displayName: e } : e, n = t.id;
1034
906
  if (n) {
1035
- let e = Object.keys(t), r = e.length;
1036
- for (let i = 0; i < r; i++) {
1037
- let r = e[i];
1038
- n(r, t[r]);
1039
- }
907
+ let e = this._byId.get(n);
908
+ if (e) return e;
909
+ }
910
+ let r = t.displayName ?? "";
911
+ if (!n) {
912
+ let e = this._byDisplayName.get(r);
913
+ if (e) return e;
1040
914
  }
915
+ let i = new ar({
916
+ ...t,
917
+ displayName: r,
918
+ id: n ?? R.uuidV4().toUpperCase()
919
+ }, (e) => this._remove(e));
920
+ return this._byId.set(i.getId(), i), r && !this._byDisplayName.has(r) && this._byDisplayName.set(r, i), this._items = null, this._notifyCollectionChange(), i;
921
+ }
922
+ getById(e) {
923
+ return typeof e == "string" ? this._byId.get(e) ?? null : null;
924
+ }
925
+ getByDisplayName(e) {
926
+ return typeof e == "string" ? this._byDisplayName.get(e) ?? null : null;
927
+ }
928
+ getCurrent() {
929
+ return this._current ??= this.add("Author");
930
+ }
931
+ setCurrent(e) {
932
+ if (e !== null) {
933
+ if (typeof e == "object" && e.isIPerson) {
934
+ let t = e;
935
+ this._current = this.getById(t.getId()) ?? this.add(t.toJSON());
936
+ return;
937
+ }
938
+ this._current = this.add(e);
939
+ } else this._current = null;
1041
940
  }
1042
- addListeners(e, t) {
1043
- return this._emitter.addListeners(e, t);
941
+ _remove(e) {
942
+ this._byId.get(e.getId()) === e && (this._byId.delete(e.getId()), this._byDisplayName.get(e.getDisplayName()) === e && this._byDisplayName.delete(e.getDisplayName()), this._current === e && (this._current = null), this._items = null, this._notifyCollectionChange());
1044
943
  }
1045
944
  toJSON() {
1046
- let e = this._getState();
1047
- if (!e) return I.EmptyArray;
1048
- let t = e.modules, n = Object.keys(t), r = n.length, i = {};
1049
- for (let e = 0; e < r; e++) {
1050
- let r = n[e];
1051
- i[r] = t[r].toJSON();
1052
- }
1053
- return i;
1054
- }
1055
- isClosed() {
1056
- return this._closed;
945
+ return this._byId.size === 0 ? null : this._getItems().map((e) => e.toJSON());
1057
946
  }
1058
- close() {
1059
- this._closed || (this._emitter.notify("onClose"), this._closed = !0, this._transactionsRemoveListener?.());
947
+ fromJSON(e) {
948
+ if (!e) return;
949
+ let t = e.length;
950
+ for (let n = 0; n < t; n++) {
951
+ let t = e[n];
952
+ t && typeof t.id == "string" && this.add(t);
953
+ }
1060
954
  }
1061
- get isFunctionCollection() {
955
+ get isIPersonCollection() {
1062
956
  return !0;
1063
957
  }
1064
- }, fn = (e, t) => {
958
+ }, sr = (e, t) => {
1065
959
  let n = [0];
1066
960
  for (let t = 0; t < e.length; t++) e[t] === "\n" && n.push(t + 1);
1067
961
  let r = t.map((e) => ` ${((e) => {
@@ -1073,9 +967,9 @@ var ln = class {
1073
967
  return `${t + 1}:${e - n[t] + 1}`;
1074
968
  })(e.start)} ${e.code}: ${e.message}`), i = t.length;
1075
969
  return `Script has ${i} compile error${i === 1 ? "" : "s"}:\n${r.join("\n")}`;
1076
- }, pn = class {
1077
- constructor(e) {
1078
- this._options = e, this._emitter = new S(this), this._initState();
970
+ }, cr = class {
971
+ constructor(t) {
972
+ this._options = t, this._emitter = new e(this), this._initState();
1079
973
  }
1080
974
  _initState() {}
1081
975
  getModules() {
@@ -1084,26 +978,27 @@ var ln = class {
1084
978
  _builtInNames() {
1085
979
  try {
1086
980
  let e = this._options.getBuiltInFunctions?.();
1087
- if (!e) return I.EmptyArray;
981
+ if (!e) return R.EmptyArray;
1088
982
  let t = [];
1089
- for (let n of e.getItems()) n.isBuiltIn() && t.push(n.getName());
983
+ for (let n of e.getItems({ includeHidden: !0 })) n.isBuiltIn() && t.push(n.getName());
1090
984
  return t;
1091
985
  } catch {
1092
- return I.EmptyArray;
986
+ return R.EmptyArray;
1093
987
  }
1094
988
  }
1095
989
  async createModule(e) {
1096
990
  let t = await (await import("@sheetxl/scripting")).ScriptCompiler.compile({
1097
991
  builtInNames: this._builtInNames(),
992
+ minify: !0,
1098
993
  ...e
1099
994
  });
1100
- return t.module ? await T("scripts", t.module, e?.declarationsOnly ?? !1, t.diagnostics) : null;
995
+ return t.module ? await D(Fe.DEFAULT_MODULE, t.module, e?.declarationsOnly ?? !1, t.diagnostics) : null;
1101
996
  }
1102
997
  addModule(e, t, n) {
1103
998
  this._modules.add(e, t, n);
1104
999
  }
1105
1000
  async addModuleFromJSON(e, t, n) {
1106
- let r = await T(e, t);
1001
+ let r = await D(e, t);
1107
1002
  return this.addModule(e, r, n), r;
1108
1003
  }
1109
1004
  executeMacro(e, t, n) {
@@ -1119,7 +1014,7 @@ var ln = class {
1119
1014
  }
1120
1015
  async run(e, t) {
1121
1016
  try {
1122
- let n = typeof e == "string" ? await this.createModule({ source: e }) : await T("scripts", e), r = typeof e == "string" ? e : e?.source ?? "";
1017
+ let n = typeof e == "string" ? await this.createModule({ source: e }) : await D(Fe.DEFAULT_MODULE, e), r = typeof e == "string" ? e : e?.source ?? "";
1123
1018
  return await this._runModule(n, r, t);
1124
1019
  } catch (e) {
1125
1020
  return {
@@ -1136,17 +1031,23 @@ var ln = class {
1136
1031
  };
1137
1032
  let i = e.getDiagnostics(), a = i.filter((e) => e.severity === "error");
1138
1033
  if (a.length > 0) {
1139
- let e = Error(fn(t, a));
1034
+ let e = Error(sr(t, a));
1140
1035
  return e.diagnostics = a, {
1141
1036
  ok: !1,
1142
1037
  error: e,
1143
1038
  diagnostics: i
1144
1039
  };
1145
1040
  }
1146
- let o = e.getFunctions(), s = (await o.search({ type: "autoRun" }))[0] ?? (await o.search({ type: "macro" }))[0] ?? null;
1041
+ let o = e.getFunctions(), s = o.getItems({
1042
+ type: "autoRun",
1043
+ includeHidden: !0
1044
+ })[0] ?? o.getItems({
1045
+ type: "macro",
1046
+ includeHidden: !0
1047
+ })[0] ?? null;
1147
1048
  if (!s) return {
1148
1049
  ok: !1,
1149
- error: /* @__PURE__ */ Error("The script has no runnable entry. Export a default function taking the script context, e.g. `export default function run(ctx: IScript.ScriptContext) { ... }` (the workbook is `ctx.wb`; a macro may instead take its target first, e.g. `(sheet: ISheet, ctx)`).")
1050
+ error: /* @__PURE__ */ Error("The script has no runnable entry. Export a default function taking the script context, e.g. `export default function run(ctx: IScript.ScriptContext) { ... }` (the workbook is `ctx.wb`; a macro may instead take its target first, e.g. `(sheet: IWorksheet, ctx)`).")
1150
1051
  };
1151
1052
  let c = await s.execute(r, n);
1152
1053
  return {
@@ -1156,23 +1057,15 @@ var ln = class {
1156
1057
  diagnostics: i
1157
1058
  };
1158
1059
  }
1159
- async _searchable(e) {
1160
- let t = [];
1161
- if (e?.includeBuiltIn) {
1162
- await this._options.workbook?.getCalculation()?.start();
1163
- let e = this._options.getBuiltInFunctions?.();
1164
- e && t.push(e);
1165
- }
1166
- let n = this._modules;
1167
- if (!n || n.getCount() === 0) return t;
1168
- let r = e?.moduleName, i = r ? n.getItems({ name: r }) : n.getItems(), a = i.length;
1169
- for (let e = 0; e < a; e++) t.push(i[e].getFunctions());
1170
- return t;
1060
+ _searchable(e) {
1061
+ let t = this._modules;
1062
+ return t && t.getCount() !== 0 ? (e ? t.getItems({ name: e }) : t.getItems()).map((e) => e.getFunctions()) : R.EmptyArray;
1171
1063
  }
1172
1064
  async searchFunctions(e) {
1173
1065
  await this._emitter.notify("onBeforeSearch", { async: !0 });
1174
- let t = await this._searchable(e);
1175
- if (t.length === 0) return I.EmptyArray;
1066
+ let t = this._searchable(e?.moduleName);
1067
+ if (t.length === 0) return R.EmptyArray;
1068
+ if (t.length === 1) return t[0].search(e);
1176
1069
  let n = e?.limit, r = n === void 0 ? e : {
1177
1070
  ...e,
1178
1071
  limit: void 0
@@ -1187,38 +1080,12 @@ var ln = class {
1187
1080
  }
1188
1081
  }
1189
1082
  }
1190
- if (!i || i.length === 0) return I.EmptyArray;
1083
+ if (!i || i.length === 0) return R.EmptyArray;
1191
1084
  let o = e?.text ? e.text.trim().toUpperCase() : null;
1192
- return o && t.length > 1 && f(i, o), n !== void 0 && i.length > n ? i.slice(0, n) : i;
1193
- }
1194
- async getFunctionCategories(e) {
1195
- await this._emitter.notify("onBeforeSearch", { async: !0 });
1196
- let t = await this._searchable(e);
1197
- if (t.length === 0) return I.EmptyArray;
1198
- if (t.length === 1) return t[0].getCategories(e);
1199
- let n = e?.includeDeprecated ?? !1, r = /* @__PURE__ */ new Map(), i = (e) => {
1200
- let t = e.toUpperCase(), n = r.get(t);
1201
- n ? n.count++ : r.set(t, {
1202
- name: e,
1203
- count: 1
1204
- });
1205
- };
1206
- for (let n of await t[0].getCategories(e)) r.set(n.name.toUpperCase(), {
1207
- name: n.name,
1208
- count: n.count
1209
- });
1210
- for (let r = 1; r < t.length; r++) {
1211
- let a = await t[r].search(e?.type ? { type: e.type } : void 0);
1212
- for (let e = 0; e < a.length; e++) {
1213
- let o = a[e], s = o.getName().toUpperCase(), c = !1;
1214
- for (let e = 0; e < r && !c; e++) c = !!t[e].getByName(s);
1215
- if (c) continue;
1216
- let l = await o.getDescriptor().catch(() => null);
1217
- !n && l?.isDeprecated() || i(l?.getCategory() ?? "Uncategorized");
1218
- }
1219
- }
1220
- let a = Array.from(r.values());
1221
- return a.sort((e, t) => e.name.localeCompare(t.name)), a;
1085
+ return o ? nt(i, o) : i.sort((e, t) => {
1086
+ let n = e.getName().toUpperCase(), r = t.getName().toUpperCase();
1087
+ return n < r ? -1 : +(n > r);
1088
+ }), n !== void 0 && i.length > n ? i.slice(0, n) : i;
1222
1089
  }
1223
1090
  async start() {
1224
1091
  if (!this._modules) return this._startPromise || (this._startPromise = this._doStart(), this._startPromise.catch(() => {
@@ -1228,19 +1095,20 @@ var ln = class {
1228
1095
  async _doStart() {
1229
1096
  let e = this._options?.workbook, t = this._options?.json, n = {};
1230
1097
  if (t) {
1231
- let e = Object.keys(t);
1232
- for (let r = 0; r < e.length; r++) {
1233
- let i = e[r], a = t[i];
1098
+ let r = Object.keys(t);
1099
+ for (let i = 0; i < r.length; i++) {
1100
+ let a = r[i], o = t[a];
1234
1101
  try {
1235
- n[i] = await T(i, a);
1102
+ n[a] = await D(a, o, !1, [], o?.scope === "workbook" ? e : null);
1236
1103
  } catch (e) {
1237
- z.error(`Could not load script '${i}'; it will be unavailable.`, e);
1104
+ V.error(`Could not load script '${a}'; it will be unavailable.`, e);
1238
1105
  }
1239
1106
  }
1240
1107
  }
1241
- let r = this, i = new dn({
1108
+ let r = this, i = new Ze({
1242
1109
  transactions: this._options?.transactions,
1243
1110
  initial: n,
1111
+ isReadOnly: () => r.isReadOnly(),
1244
1112
  onRemove: (e, t) => {
1245
1113
  r._options?.onRemove?.(e, t);
1246
1114
  },
@@ -1250,15 +1118,18 @@ var ln = class {
1250
1118
  });
1251
1119
  this._modules = i;
1252
1120
  let a = i.getItems();
1253
- if (a.length === 0) return Promise.resolve(I.EmptyArray);
1121
+ if (a.length === 0) return Promise.resolve(R.EmptyArray);
1254
1122
  let o = a.length;
1255
1123
  for (let t = 0; t < o; t++) {
1256
1124
  let n = a[t];
1257
1125
  try {
1258
- let t = await n.getFunctions().search({ type: "autoRun" }), r = t.length;
1126
+ let t = n.getFunctions().getItems({
1127
+ type: "autoRun",
1128
+ includeHidden: !0
1129
+ }), r = t.length;
1259
1130
  for (let n = 0; n < r; n++) await t[n].execute(e);
1260
1131
  } catch (e) {
1261
- z.error("Error executing autoRun script:", e);
1132
+ V.error("Error executing autoRun script:", e);
1262
1133
  }
1263
1134
  }
1264
1135
  }
@@ -1266,7 +1137,7 @@ var ln = class {
1266
1137
  return this._emitter.addListeners(e, t);
1267
1138
  }
1268
1139
  isReadOnly() {
1269
- return !1 === this._options.workbook?.getProtection().isStructureAllowed();
1140
+ return this._options.workbook?._isStructureProtected?.() ?? !1;
1270
1141
  }
1271
1142
  toJSON() {
1272
1143
  this._emitter.notify("onBeforeSave");
@@ -1274,11 +1145,15 @@ var ln = class {
1274
1145
  if (!e) throw Error("Scripts is initializing.");
1275
1146
  return e.toJSON();
1276
1147
  }
1277
- }, mn = class {
1148
+ get isIScript() {
1149
+ return !0;
1150
+ }
1151
+ }, lr = class {
1278
1152
  constructor(e, t, n, r) {
1279
- this._mergedReading = [], this._colsReading = [], this._rowsReading = [], this._styles = n, this._topLeft = t ?? L.EmptyCell, this._sheet = new A({
1153
+ this._mergedReading = [], this._colsReading = [], this._rowsReading = [], this._styles = n, this._topLeft = t ?? z.EmptyCell, this._sheet = new A({
1280
1154
  runtime: e,
1281
1155
  styles: this._styles,
1156
+ calcOnLoad: "none",
1282
1157
  container: {
1283
1158
  getName: () => r,
1284
1159
  getIndex: () => 1
@@ -1286,45 +1161,49 @@ var ln = class {
1286
1161
  }), this._builder = this._sheet.getEntireRange().createSparseBuilder();
1287
1162
  }
1288
1163
  applyCSSStyle(e, t) {
1289
- let r = !1;
1290
- e.style || (e.style = {}, r = !0);
1291
- let o = e.style, s = { ...t };
1164
+ let n = !1;
1165
+ e.style || (e.style = {}, n = !0);
1166
+ let r = e.style, i = { ...t };
1292
1167
  if (t.msoIgnore) {
1293
- let e = t.msoIgnore.split(","), n = Object.keys(s);
1168
+ let e = t.msoIgnore.split(","), n = Object.keys(i);
1294
1169
  for (let t = 0; t < n.length; t++) {
1295
1170
  let r = n[t];
1296
- e.includes(r) && delete s[r];
1171
+ e.includes(r) && delete i[r];
1297
1172
  }
1298
1173
  }
1299
- let l = Me(s.fontFamily);
1300
- o.font = {}, l && (o.font.family = l.family, o.font.fallbacks = l.fallbacks, o.font.size = l.size), o.font.size = s.fontSize, o.font.weight = s.fontWeight, o.font.style = s.fontStyle, o.font.color = s.color;
1301
- let d = b(s.textDecoration);
1302
- o.font.underline = d.underline, o.font.strike = d.strike, s.textUnderlineStyle && (o.font.underline = Ne(s.textUnderlineStyle)), o.alignment = {}, s?.textAlign && (o.alignment.horizontal = c(s.textAlign)), s?.textAlign && !o.alignment.horizontal && s?.textAlign !== "general" && (s.textAlign === "center-across" ? o.alignment.horizontal = a.HorizontalAlignment.CenterContinuous : s.textAlign === "fill" ? o.alignment.horizontal = a.HorizontalAlignment.Fill : s.textAlign === "121" || s.textAlign === "010" ? (o.alignment.horizontal = a.HorizontalAlignment.Distributed, o.alignment.justifyLastLine = s.textAlign === "121") : console.warn("unknown text-align", s.textAlign)), s.verticalAlign && (s.verticalAlign.toLowerCase() === "super" ? o.font.verticalAlign = k.VerticalAlignment.Super : s.verticalAlign.toLowerCase() === "sup" ? o.font.verticalAlign = k.VerticalAlignment.Sub : o.alignment.vertical = n(s.verticalAlign), o.alignment.vertical || (s.verticalAlign === "121" ? o.alignment.vertical = a.VerticalAlignment.Distributed : console.warn("unknown vertical-align", s.verticalAlign))), s.msoCharIndentCount && (o.alignment.indent = s.msoCharIndentCount), s.whiteSpace && (o.alignment.overflow = s.whiteSpace === "no-wrap" || s.whiteSpace === "nowrap" ? a.Overflow.Visible : a.Overflow.Wrap), s.msoTextControl === "shrinktofit" && (o.alignment.overflow = a.Overflow.Shrink);
1303
- let f = null;
1304
- if (s.background ? f = s.background : s.backgroundColor && (f = s.backgroundColor), f && (o.fill = { color: f }), s.msoPattern) {
1305
- let e = y(s.msoPattern);
1306
- e && (e.patternType === i.BuiltInSheetPattern.Solid ? o.fill = { color: e.foreground } : e.patternType !== i.BuiltInSheetPattern.None && (f && (e.background = f), o.fill = e));
1307
- }
1308
- s.msoRotate !== void 0 && (o.alignment.rotation = u(s.msoRotate));
1309
- let p = (e, t) => {
1310
- e && (o.border ||= {}, o.border[e] = t);
1174
+ let a = Yt(i.fontFamily);
1175
+ r.font = {}, a && (r.font.family = a.family, r.font.fallbacks = a.fallbacks, r.font.size = a.size), r.font.size = i.fontSize, r.font.weight = i.fontWeight, r.font.style = i.fontStyle, r.font.color = i.color;
1176
+ let o = qt(i.textDecoration);
1177
+ r.font.underline = o.underline, r.font.strike = o.strike ? M.StrikeStyle.Single : M.StrikeStyle.None, i.textUnderlineStyle && (r.font.underline = on(i.textUnderlineStyle)), r.alignment = {}, i?.textAlign && (r.alignment.horizontal = Wt(i.textAlign)), i?.textAlign && !r.alignment.horizontal && i?.textAlign !== "general" && (i.textAlign === "center-across" ? r.alignment.horizontal = N.HorizontalAlignment.CenterContinuous : i.textAlign === "fill" ? r.alignment.horizontal = N.HorizontalAlignment.Fill : i.textAlign === "121" || i.textAlign === "010" ? (r.alignment.horizontal = N.HorizontalAlignment.Distributed, r.alignment.justifyLastLine = i.textAlign === "121") : console.warn("unknown text-align", i.textAlign)), i.verticalAlign && (i.verticalAlign.toLowerCase() === "super" ? r.font.baseline = F.Baseline.Superscript : i.verticalAlign.toLowerCase() === "sub" ? r.font.baseline = F.Baseline.Subscript : r.alignment.vertical = Lt(i.verticalAlign), r.alignment.vertical || (i.verticalAlign === "121" ? r.alignment.vertical = N.VerticalAlignment.Distributed : console.warn("unknown vertical-align", i.verticalAlign))), i.msoCharIndentCount && (r.alignment.indent = i.msoCharIndentCount), i.whiteSpace && (r.alignment.overflow = i.whiteSpace === "no-wrap" || i.whiteSpace === "nowrap" ? N.Overflow.Visible : N.Overflow.Wrap), i.msoTextControl === "shrinktofit" && (r.alignment.overflow = N.Overflow.Shrink);
1178
+ let s = null;
1179
+ if (i.background ? s = i.background : i.backgroundColor && (s = i.backgroundColor), s && (r.fill = { color: s }), i.msoPattern) {
1180
+ let e = Xt(i.msoPattern);
1181
+ e && (e.patternType === Qt.BuiltInSheetPattern.Solid ? r.fill = { color: e.foreground } : e.patternType !== Qt.BuiltInSheetPattern.None && (s && (e.background = s), r.fill = e));
1182
+ }
1183
+ i.layoutFlow === "vertical" || i.layoutFlow === "vertical-ideographic" ? r.alignment.stacked = !0 : i.msoRotate !== void 0 && (r.alignment.rotation = Ht(i.msoRotate));
1184
+ let c = (e, t) => {
1185
+ e && (r.borders ||= {}, r.borders[e] = t);
1311
1186
  };
1312
- s.border && s.border !== "none" && (p("top", s.border), p("left", s.border), p("right", s.border), p("bottom", s.border)), s.borderTop && p("top", s.borderTop), s.borderLeft && p("left", s.borderLeft), s.borderRight && p("right", s.borderRight), s.borderBottom && p("bottom", s.borderBottom), s.msoDiagonalUp && p("diagonalUp", s.msoDiagonalUp), s.msoDiagonalDown && p("diagonalDown", s.msoDiagonalDown);
1313
- let m = o.numberFormat;
1314
- s.msoNumberFormat && (m = te(s.msoNumberFormat), m.includes("\\") ? m = null : m === "Fixed" ? m = M.Styles.lookupStyle(o.numberFormat).formatType === M.Type.Number ? null : M.Type.Number : m === "Percent" && (m = M.Styles.lookupStyle(o.numberFormat).formatType === M.Type.Percentage ? null : M.Type.Percentage)), m && (o.numberFormat = m), e.style = this._styles.normalize(o), r && Object.keys(e.style).length === 0 && delete e.style;
1187
+ i.border && i.border !== "none" && (c("top", i.border), c("left", i.border), c("right", i.border), c("bottom", i.border)), i.borderTop && c("top", i.borderTop), i.borderLeft && c("left", i.borderLeft), i.borderRight && c("right", i.borderRight), i.borderBottom && c("bottom", i.borderBottom), i.msoDiagonalUp && c("diagonalUp", i.msoDiagonalUp), i.msoDiagonalDown && c("diagonalDown", i.msoDiagonalDown);
1188
+ let l = r.numberFormat;
1189
+ i.msoNumberFormat && (l = nn(i.msoNumberFormat), l.includes("\\") ? l = null : l === "Fixed" ? l = P.Styles.lookupStyle(r.numberFormat).formatType === P.Type.Number ? null : P.Type.Number : l === "Percent" && (l = P.Styles.lookupStyle(r.numberFormat).formatType === P.Type.Percentage ? null : P.Type.Percentage)), l && (r.numberFormat = l), e.style = this._styles.normalize(r), n && Object.keys(e.style).length === 0 && delete e.style;
1315
1190
  }
1316
1191
  onCell(e, t, n, r, i) {
1317
1192
  let a = r(i), o = { value: t === void 0 ? n ?? "" : t };
1318
- if (typeof o.value == "string" && o.value.length === 0 && (o.value = void 0), a && this.applyCSSStyle(o, a), i?.tagName.toUpperCase() === "TD") {
1193
+ if (typeof o.value == "string" && o.value.length === 0 && (o.value = void 0), a && this.applyCSSStyle(o, a), typeof o.value == "string" && /^#+$/.test(o.value)) {
1194
+ let e = o.style?.numberFormat;
1195
+ e && (Jt(e) || Rt(e)) && (o.value = I.BuiltIn.Num);
1196
+ }
1197
+ if (i?.tagName.toUpperCase() === "TD") {
1319
1198
  let e = o.style, t = e?.font ?? {};
1320
- (i.querySelectorAll("s").length > 0 || i.querySelectorAll("strike").length > 0) && (t.strike = !0), i.querySelectorAll("sub").length > 0 && (t.verticalAlign = k.VerticalAlignment.Sub), i.querySelectorAll("sup").length > 0 && (t.verticalAlign = k.VerticalAlignment.Super), (i.querySelectorAll("b").length > 0 || i.querySelectorAll("strong").length > 0) && (t.weight = 700), i.querySelectorAll("i").length > 0 && (t.style = k.Style.Italic), i.querySelectorAll("u").length > 0 && (t.underline = k.UnderlineStyle.Single), Object.keys(t).length > 0 && (e || (e = {}, o.style = e), e.font ||= t);
1199
+ (i.querySelectorAll("s").length > 0 || i.querySelectorAll("strike").length > 0) && (t.strike = M.StrikeStyle.Single), i.querySelectorAll("sub").length > 0 && (t.baseline = F.Baseline.Subscript), i.querySelectorAll("sup").length > 0 && (t.baseline = F.Baseline.Superscript), (i.querySelectorAll("b").length > 0 || i.querySelectorAll("strong").length > 0) && (t.weight = 700), i.querySelectorAll("i").length > 0 && (t.style = M.Style.Italic), i.querySelectorAll("u").length > 0 && (t.underline = M.UnderlineStyle.Single), Object.keys(t).length > 0 && (e || (e = {}, o.style = e), e.font || (e.font = t));
1321
1200
  let n = i.querySelectorAll("a");
1322
1201
  if (n.length > 0) {
1323
1202
  let e = n[0].getAttribute("href");
1324
1203
  e && (o.hyperlink = e);
1325
1204
  }
1326
1205
  }
1327
- if (!L.isSingleCell(e)) {
1206
+ if (!z.isSingleCell(e)) {
1328
1207
  let t = {
1329
1208
  rowStart: this._topLeft.rowIndex + e.rowStart,
1330
1209
  colStart: this._topLeft.colIndex + e.colStart,
@@ -1335,7 +1214,7 @@ var ln = class {
1335
1214
  }
1336
1215
  if (o.value === void 0 && !o.style && Object.keys(o).length <= 1) return;
1337
1216
  let s = this._builder, c = this._topLeft;
1338
- if (s.pushAt(c.rowIndex + e.rowStart, c.colIndex + e.colStart, o), !L.isSingleCell(e) && a.msoIgnore) {
1217
+ if (s.pushAt(c.rowIndex + e.rowStart, c.colIndex + e.colStart, o), !z.isSingleCell(e) && a.msoIgnore) {
1339
1218
  if (a.msoIgnore.includes("colspan")) {
1340
1219
  let t = {};
1341
1220
  a && this.applyCSSStyle(t, a);
@@ -1364,28 +1243,28 @@ var ln = class {
1364
1243
  let i = n(r);
1365
1244
  if (i.msoHeightSource !== "userset" || !r) return;
1366
1245
  let a = r.getAttribute("height") ?? i.height, o = null;
1367
- if (a && (o = v(a, this._styles.getNormal().getFont().getSize(), "px")), o === null) for (let e = 0; e < r.cells.length; e++) {
1368
- let t = r.cells[e], i = v(t.getAttribute("height") ?? n(t).height, this._styles.getNormal().getFont().getSize(), "px");
1369
- i !== null && (o = Math.max(i, o ?? 0));
1246
+ if (a && (o = Vt(a, this._styles.getNormal().getFont().getSize(), "px")), o === null) for (let e = 0; e < r.cells.length; e++) {
1247
+ let t = r.cells[e], i = t.getAttribute("height") ?? n(t).height, a = Vt(i, this._styles.getNormal().getFont().getSize(), "px");
1248
+ a !== null && (o = Math.max(a, o ?? 0));
1370
1249
  }
1371
1250
  o !== null && this._rowsReading.push({
1372
1251
  address: {
1373
1252
  min: this._topLeft.rowIndex + e,
1374
1253
  max: this._topLeft.rowIndex + e + t - 1
1375
1254
  },
1376
- update: { size: o * k.getDeviceScale() }
1255
+ update: { size: o * M.getDeviceScale() }
1377
1256
  });
1378
1257
  }
1379
1258
  onColumn(e, t, n, r) {
1380
1259
  let i = n(r);
1381
1260
  if (i.msoWidthSource !== "userset" || !r) return;
1382
1261
  let a = r.getAttribute("width") ?? i.width, o = null;
1383
- a && (o = v(a, this._styles.getNormal().getFont().getSize(), "px")), o !== null && this._colsReading.push({
1262
+ a && (o = Vt(a, this._styles.getNormal().getFont().getSize(), "px")), o !== null && this._colsReading.push({
1384
1263
  address: {
1385
1264
  min: this._topLeft.colIndex + e,
1386
1265
  max: this._topLeft.colIndex + e + t - 1
1387
1266
  },
1388
- update: { size: o * k.getDeviceScale() }
1267
+ update: { size: o * M.getDeviceScale() }
1389
1268
  });
1390
1269
  }
1391
1270
  onDone() {
@@ -1396,9 +1275,9 @@ var ln = class {
1396
1275
  sheet() {
1397
1276
  return this._sheet;
1398
1277
  }
1399
- }, hn = class {
1278
+ }, ur = class {
1400
1279
  constructor(e) {
1401
- if (!e) throw new _t("snapshot is required.");
1280
+ if (!e) throw new hn("snapshot is required.");
1402
1281
  this._snapshot = e;
1403
1282
  }
1404
1283
  getItemType() {
@@ -1428,10 +1307,10 @@ var ln = class {
1428
1307
  get isClipboardItem() {
1429
1308
  return !0;
1430
1309
  }
1431
- }, gn = class {
1310
+ }, dr = class {
1432
1311
  constructor(e, t, n, r, i) {
1433
- if (this._parsed = void 0, this._runtime = e, !t) throw new _t("nativeItems are required.");
1434
- this._topLeft = n ?? L.EmptyCell, this._native = t, this._markOptions = Object.freeze(r ?? {}), this._styles = i;
1312
+ if (this._parsed = void 0, this._runtime = e, !t) throw new hn("nativeItems are required.");
1313
+ this._topLeft = n ?? z.EmptyCell, this._native = t, this._markOptions = Object.freeze(r ?? {}), this._styles = i;
1435
1314
  }
1436
1315
  getItemType() {
1437
1316
  return "range";
@@ -1455,6 +1334,10 @@ var ln = class {
1455
1334
  if (this._snapshot) return this._snapshot;
1456
1335
  let t = this;
1457
1336
  return this._snapshot = {
1337
+ prepare: (n, r) => e.prepare?.(n, {
1338
+ ...t._markOptions,
1339
+ ...r
1340
+ }),
1458
1341
  copyTo: (n, r) => e.copyTo(n, {
1459
1342
  ...t._markOptions,
1460
1343
  ...r
@@ -1472,54 +1355,167 @@ var ln = class {
1472
1355
  async parse() {
1473
1356
  let e, t = this._native?.text, n = this._native.html;
1474
1357
  if (n === null && t && t.includes("<table")) try {
1475
- let e = new DOMParser().parseFromString(t, gt.Html), r = e.querySelector("parsererror");
1476
- if (r) throw new R("Unable to parse: " + r);
1358
+ let e = new DOMParser().parseFromString(t, mn.Html), r = e.querySelector("parsererror");
1359
+ if (r) throw new B("Unable to parse: " + r);
1477
1360
  n = e, t = null;
1478
1361
  } catch {
1479
1362
  console.warn("Discovered text as html table but could could not parse.");
1480
1363
  }
1481
1364
  try {
1482
- let r = new mn(this._runtime, this._topLeft, this._styles, n ? "HTML" : "Text");
1483
- await r.sheet().getCalculation().ready(), await r.sheet().getCalculation().stop();
1484
- let i = await Promise.resolve(t ? Ie(t) : [[]]), a;
1485
- if (Ue(n, i, r) ? (e = r.sheet(), a = e.getUsedRange()) : n = null, a) return this._parsed = {
1486
- copyTo: async (e, t) => (await e.copyFrom(a, t))?.getCoords() ?? null,
1487
- getCoords: () => a.getCoords(),
1488
- getSource: () => e,
1489
- getName: () => e.getName()
1490
- }, !0;
1365
+ let r = new lr(this._runtime, this._topLeft, this._styles, n ? "HTML" : "Text"), i = await Promise.resolve(t ? rt(t) : [[]]), a;
1366
+ if (yt(n, i, r) ? (e = r.sheet(), a = e.getUsedRange()) : n = null, a) {
1367
+ let t = a.getSnapshot();
1368
+ return this._parsed = {
1369
+ prepare: (e, n) => t.prepare?.(e, n),
1370
+ copyTo: (e, n) => t.copyTo(e, n),
1371
+ getCoords: () => a.getCoords(),
1372
+ getSource: () => e,
1373
+ getName: () => e.getName()
1374
+ }, !0;
1375
+ }
1491
1376
  } catch (e) {
1492
1377
  throw e;
1493
1378
  }
1494
1379
  if (!t && !n && this._native.image) {
1495
- let e = this;
1380
+ let e = await this._native.image.arrayBuffer(), t = null;
1496
1381
  return this._parsed = {
1497
- async copyTo(t, n) {
1498
- let r = t.getSheet(), i = await e._native.image.arrayBuffer(), a = await r.getMovables().addPicture({ source: { buffer: i } }, {
1499
- type: "picture",
1500
- description: V("op.copyImageFromClipboard")
1501
- });
1502
- return r.getView().selectMovables([a]), null;
1382
+ async prepare(n) {
1383
+ let r = n.getWorksheet();
1384
+ t = {
1385
+ sheet: r,
1386
+ options: await r.getMovables()._preparePicture({ source: { buffer: e } }, {
1387
+ type: "picture",
1388
+ description: W("op.copyImageFromClipboard"),
1389
+ autoSelect: !0
1390
+ })
1391
+ };
1392
+ },
1393
+ copyTo(e, n) {
1394
+ let r = e.getWorksheet();
1395
+ if (t?.sheet !== r) throw Error("The image was not prepared for this sheet.");
1396
+ return r.getMovables()._insertNow(t.options), null;
1503
1397
  },
1504
1398
  getName: () => "Image"
1505
1399
  }, !0;
1506
1400
  }
1507
- return !1;
1401
+ return this._parsed = null, !1;
1508
1402
  }
1509
1403
  get isClipboardItem() {
1510
1404
  return !0;
1511
1405
  }
1512
- }, Z = {
1406
+ }, fr = class {
1407
+ constructor(t) {
1408
+ this._closed = !1, this._kind = t.kind, this._id = t.id, this._part = t.part, this._styles = t.styles, this._tabColor = t.tabColor ? this._styles.parseColor(t.tabColor) : null, this._transactions = t.transactions, this._workbook = t.workbook ?? null, this._container = t.container, this._emitter = new e(this, this._transactions);
1409
+ }
1410
+ getKind() {
1411
+ return this._kind;
1412
+ }
1413
+ getId() {
1414
+ return this._id;
1415
+ }
1416
+ getName() {
1417
+ return this._container.getName();
1418
+ }
1419
+ setName(e, t) {
1420
+ return this._assertOpen(), this._container.setName(e, t), this;
1421
+ }
1422
+ getVisibility() {
1423
+ return this._closed ? k.Visibility.VeryHidden : this._container.getVisibility();
1424
+ }
1425
+ setVisibility(e = !0, t) {
1426
+ let n;
1427
+ return this._assertOpen(), n = !0 === e ? k.Visibility.Visible : !1 === e ? k.Visibility.Hidden : e, this._container.setVisibility(n, t), this;
1428
+ }
1429
+ getIndex() {
1430
+ return this._container.getIndex();
1431
+ }
1432
+ setIndex(e, t) {
1433
+ return this._assertOpen(), this._container.setIndex(e, t), this;
1434
+ }
1435
+ getTabColor() {
1436
+ return this._tabColor;
1437
+ }
1438
+ setTabColor(e) {
1439
+ return this._assertOpen(), this._tabColor = typeof e == "string" ? this._styles.parseColor(e) : e ?? null, this._notify("onTabColorChange"), this;
1440
+ }
1441
+ getWorkbook() {
1442
+ return this._workbook;
1443
+ }
1444
+ async select(e) {
1445
+ return await this._container.requestSelect(e), this;
1446
+ }
1447
+ delete() {
1448
+ if (this._closed) return;
1449
+ let e = this._transactions.beginCommit({ description: G("op.deleteSheet", { name: this.getName() }) });
1450
+ try {
1451
+ try {
1452
+ this._notify("onBeforeDelete");
1453
+ } catch (e) {
1454
+ throw e instanceof Error ? e : new B(e?.message ?? G("error.sheet.modelDelete"));
1455
+ }
1456
+ this._notify("onDelete"), e.commit();
1457
+ } catch (t) {
1458
+ throw e.rollback(), t;
1459
+ }
1460
+ }
1461
+ isDeleted() {
1462
+ return !this._container.isAttached();
1463
+ }
1464
+ addListeners(e, t) {
1465
+ return this._emitter.addListeners(e, t);
1466
+ }
1467
+ close() {
1468
+ this._closed ||= (this._notify("onClose"), this._emitter.close(), !0);
1469
+ }
1470
+ isClosed() {
1471
+ return this._closed;
1472
+ }
1473
+ _getPart() {
1474
+ return this._part;
1475
+ }
1476
+ _notify(e) {
1477
+ this._emitter.notify(e);
1478
+ }
1479
+ _assertOpen() {
1480
+ if (this._closed) throw Error(G("error.sheet.modelClosed"));
1481
+ }
1482
+ get [Symbol.toStringTag]() {
1483
+ return "[OpaqueSheet]";
1484
+ }
1485
+ toString() {
1486
+ return `[${this.getName() ?? "(untitled)"}]`;
1487
+ }
1488
+ get isISheet() {
1489
+ return !0;
1490
+ }
1491
+ get isIOpaqueSheet() {
1492
+ return !0;
1493
+ }
1494
+ };
1495
+ (rr ||= {}).Visibility = {
1496
+ Visible: "visible",
1497
+ Hidden: "hidden",
1498
+ VeryHidden: "veryHidden"
1499
+ };
1500
+ var X, pr = {
1513
1501
  showFormulaBar: !0,
1514
1502
  showTabs: !0,
1515
1503
  tabRatio: 600,
1516
1504
  showHorizontalScrollbar: !0,
1517
1505
  showVerticalScrollbar: !0,
1518
1506
  showStatusBar: !0,
1519
- activeSheetId: 0
1520
- }, Q = class {
1521
- constructor(e) {
1522
- this._emitter = new S(this), this._state = { ...Z }, e?.json && this._fromJSON(e?.json);
1507
+ activeSheetId: 0,
1508
+ firstTab: 0,
1509
+ windowBounds: null,
1510
+ minimized: !1,
1511
+ visibility: rr.Visibility.Visible,
1512
+ autoFilterDateGrouping: !0
1513
+ }, mr = class {
1514
+ constructor(t) {
1515
+ this._id = R.uuidV4(), this._emitter = new e(this), this._state = { ...pr }, t?.json && this._fromJSON(t?.json);
1516
+ }
1517
+ getId() {
1518
+ return this._id;
1523
1519
  }
1524
1520
  isShowFormulaBar() {
1525
1521
  return this._state.showFormulaBar;
@@ -1564,6 +1560,39 @@ var ln = class {
1564
1560
  let t = this._state, n = t.activeSheetId;
1565
1561
  return t.activeSheetId = e, n !== e && this._emitter.notify("onViewChange"), this;
1566
1562
  }
1563
+ getFirstTab() {
1564
+ return this._state.firstTab;
1565
+ }
1566
+ setFirstTab(e) {
1567
+ return this._set("firstTab", Math.max(0, Math.trunc(e)));
1568
+ }
1569
+ getWindowBounds() {
1570
+ return this._state.windowBounds;
1571
+ }
1572
+ setWindowBounds(e) {
1573
+ return this._set("windowBounds", e ? Object.freeze({ ...e }) : null);
1574
+ }
1575
+ isMinimized() {
1576
+ return this._state.minimized;
1577
+ }
1578
+ setMinimized(e) {
1579
+ return this._set("minimized", e);
1580
+ }
1581
+ getVisibility() {
1582
+ return this._state.visibility;
1583
+ }
1584
+ setVisibility(e) {
1585
+ return this._set("visibility", e);
1586
+ }
1587
+ isAutoFilterDateGrouping() {
1588
+ return this._state.autoFilterDateGrouping;
1589
+ }
1590
+ setAutoFilterDateGrouping(e) {
1591
+ return this._set("autoFilterDateGrouping", e);
1592
+ }
1593
+ _set(e, t) {
1594
+ return this._state[e] === t || (this._state[e] = t, this._emitter.notify("onViewChange")), this;
1595
+ }
1567
1596
  addListeners(e, t) {
1568
1597
  return this._emitter.addListeners(e, t);
1569
1598
  }
@@ -1571,7 +1600,7 @@ var ln = class {
1571
1600
  let e = {}, t = Object.keys(this._state), n = t.length;
1572
1601
  for (let r = 0; r < n; r++) {
1573
1602
  let n = t[r], i = this._state[n];
1574
- i != null && i !== Z[n] && (e[n] = i);
1603
+ i != null && i !== pr[n] && (e[n] = i);
1575
1604
  }
1576
1605
  return Object.keys(e).length === 0 && (e = null), e;
1577
1606
  }
@@ -1581,7 +1610,7 @@ var ln = class {
1581
1610
  }
1582
1611
  update(e, t = !0) {
1583
1612
  this._state = {
1584
- ...Z,
1613
+ ...pr,
1585
1614
  ...this._state,
1586
1615
  ...e
1587
1616
  }, t && this._emitter.notify("onViewChange");
@@ -1593,36 +1622,38 @@ var ln = class {
1593
1622
  let e = this.toJSON();
1594
1623
  return e ? JSON.stringify(e) : "DefaultWorkbookView";
1595
1624
  }
1596
- }, _n = Object.freeze({
1625
+ get isIWorkbookView() {
1626
+ return !0;
1627
+ }
1628
+ }, hr = Object.freeze({
1597
1629
  structure: !1,
1598
1630
  windows: !1,
1599
- revision: !1,
1631
+ revision: !0,
1600
1632
  password: null,
1601
1633
  revisionsPassword: null
1602
- }), vn = class extends ot {
1634
+ }), gr = class extends kt {
1603
1635
  isWindowsAllowed() {
1604
1636
  return this._isPropertyAllowed("windows");
1605
1637
  }
1606
1638
  isRevisionAllowed() {
1607
- return this._isPropertyAllowed("revision");
1639
+ return this.isLocked() && this._properties?.revision === void 0 ? !this._isReadOnly : this._isPropertyAllowed("revision");
1608
1640
  }
1609
1641
  isStructureAllowed() {
1610
1642
  return this._isPropertyAllowed("structure");
1611
1643
  }
1644
+ _getAllowedKey() {
1645
+ return "workbook";
1646
+ }
1612
1647
  _fromJSON(e) {
1613
1648
  this._properties = e;
1614
1649
  }
1615
1650
  _toJSON(e) {
1616
1651
  let t = this._properties;
1617
1652
  if (t) {
1618
- e = {
1619
- ...e,
1620
- ...t
1621
- };
1622
1653
  let n = Object.keys(t), r = n.length;
1623
1654
  for (let i = 0; i < r; i++) {
1624
1655
  let r = n[i], a = t[r];
1625
- a != null && a !== _n[r] && (e[r] = a);
1656
+ a != null && a !== hr[r] && (e[r] = a);
1626
1657
  }
1627
1658
  }
1628
1659
  return super._toJSON(e);
@@ -1630,62 +1661,260 @@ var ln = class {
1630
1661
  get [Symbol.toStringTag]() {
1631
1662
  return "[WorkbookProtection]";
1632
1663
  }
1664
+ get isIWorkbookProtection() {
1665
+ return !0;
1666
+ }
1633
1667
  };
1634
- function yn(e) {
1635
- return H("error.workbook.invalidSheetKey", { key: e });
1636
- }
1637
- var bn = class {
1668
+ (X ||= {}).Type = {
1669
+ Number: "number",
1670
+ Boolean: "boolean",
1671
+ Date: "date",
1672
+ String: "string",
1673
+ Float: "float"
1674
+ };
1675
+ var _r = (e) => {
1676
+ if (typeof e == "string") return {
1677
+ type: X.Type.String,
1678
+ value: e
1679
+ };
1680
+ if (typeof e == "boolean") return {
1681
+ type: X.Type.Boolean,
1682
+ value: e
1683
+ };
1684
+ if (typeof e == "number") {
1685
+ if (!Number.isFinite(e)) throw Error("A custom property value must be a finite number.");
1686
+ return {
1687
+ type: Number.isInteger(e) && e >= -2147483648 && e <= 2147483647 ? X.Type.Number : X.Type.Float,
1688
+ value: e
1689
+ };
1690
+ }
1691
+ if (e instanceof Date) {
1692
+ if (isNaN(e.getTime())) throw Error("A custom property value must be a valid date.");
1693
+ return {
1694
+ type: X.Type.Date,
1695
+ value: e.toISOString()
1696
+ };
1697
+ }
1698
+ throw Error("A custom property value must be a string, number, boolean or Date.");
1699
+ }, vr = class {
1638
1700
  constructor(e, t) {
1639
- this._add = e, this._get = t;
1701
+ this._json = e, this._owner = t;
1702
+ }
1703
+ getKey() {
1704
+ return this._json.key;
1705
+ }
1706
+ getType() {
1707
+ return this._json.type;
1708
+ }
1709
+ getLinkTarget() {
1710
+ return this._json.linkTarget ?? null;
1711
+ }
1712
+ getValue() {
1713
+ let { type: e, value: t } = this._json;
1714
+ return e === X.Type.Date ? new Date(t) : t;
1715
+ }
1716
+ setValue(e) {
1717
+ this._owner._assertCustomEditable(this), this._json = {
1718
+ ...this._json,
1719
+ ..._r(e)
1720
+ };
1721
+ }
1722
+ delete() {
1723
+ this._owner._removeCustom(this);
1724
+ }
1725
+ toJSON() {
1726
+ return { ...this._json };
1727
+ }
1728
+ }, yr = class {
1729
+ constructor(e) {
1730
+ this._json = {}, this._custom = [], this._assertOpen = e;
1731
+ }
1732
+ _text(e) {
1733
+ return this._json[e] ?? null;
1734
+ }
1735
+ _setText(e, t) {
1736
+ return this._assertOpen(), t == null || t === "" ? delete this._json[e] : this._json[e] = t, this;
1737
+ }
1738
+ getAuthor() {
1739
+ return this._text("author");
1740
+ }
1741
+ setAuthor(e) {
1742
+ return this._setText("author", e);
1743
+ }
1744
+ getCategory() {
1745
+ return this._text("category");
1746
+ }
1747
+ setCategory(e) {
1748
+ return this._setText("category", e);
1749
+ }
1750
+ getComments() {
1751
+ return this._text("comments");
1752
+ }
1753
+ setComments(e) {
1754
+ return this._setText("comments", e);
1755
+ }
1756
+ getCompany() {
1757
+ return this._text("company");
1758
+ }
1759
+ setCompany(e) {
1760
+ return this._setText("company", e);
1761
+ }
1762
+ getContentStatus() {
1763
+ return this._text("contentStatus");
1764
+ }
1765
+ setContentStatus(e) {
1766
+ return this._setText("contentStatus", e);
1767
+ }
1768
+ getCreationDate() {
1769
+ let e = this._json.creationDate;
1770
+ if (!e) return null;
1771
+ let t = new Date(e);
1772
+ return isNaN(t.getTime()) ? null : t;
1773
+ }
1774
+ getKeywords() {
1775
+ return this._text("keywords");
1776
+ }
1777
+ setKeywords(e) {
1778
+ return this._setText("keywords", e);
1779
+ }
1780
+ getLastAuthor() {
1781
+ return this._json.lastAuthor ?? null;
1782
+ }
1783
+ getManager() {
1784
+ return this._text("manager");
1785
+ }
1786
+ setManager(e) {
1787
+ return this._setText("manager", e);
1788
+ }
1789
+ getRevisionNumber() {
1790
+ return this._json.revisionNumber ?? null;
1791
+ }
1792
+ setRevisionNumber(e) {
1793
+ return this._assertOpen(), e != null && Number.isFinite(e) ? this._json.revisionNumber = e : delete this._json.revisionNumber, this;
1794
+ }
1795
+ getSubject() {
1796
+ return this._text("subject");
1797
+ }
1798
+ setSubject(e) {
1799
+ return this._setText("subject", e);
1800
+ }
1801
+ getTitle() {
1802
+ return this._text("title");
1803
+ }
1804
+ setTitle(e) {
1805
+ return this._setText("title", e);
1806
+ }
1807
+ getCustom() {
1808
+ return this._custom.slice();
1809
+ }
1810
+ getCustomProperty(e) {
1811
+ let t = e.toLowerCase();
1812
+ return this._custom.find((e) => e.getKey().toLowerCase() === t);
1813
+ }
1814
+ addCustomProperty(e, t) {
1815
+ if (this._assertOpen(), typeof e != "string" || e === "") throw Error("A custom property needs a name.");
1816
+ let n = this.getCustomProperty(e);
1817
+ if (n) return n.setValue(t), n;
1818
+ let r = new vr({
1819
+ key: e,
1820
+ ..._r(t)
1821
+ }, this);
1822
+ return this._custom.push(r), r;
1823
+ }
1824
+ deleteAllCustomProperties() {
1825
+ this._assertOpen(), this._custom = [];
1826
+ }
1827
+ _assertCustomEditable(e) {
1828
+ if (this._assertOpen(), !this._custom.includes(e)) throw Error("The custom property has been deleted.");
1829
+ }
1830
+ _removeCustom(e) {
1831
+ this._assertCustomEditable(e), this._custom = this._custom.filter((t) => t !== e);
1832
+ }
1833
+ fromJSON(e) {
1834
+ let { custom: t, ...n } = e ?? {};
1835
+ this._json = n, this._custom = (t ?? []).map((e) => new vr({ ...e }, this));
1836
+ }
1837
+ toJSON() {
1838
+ let e = { ...this._json };
1839
+ return this._custom.length > 0 && (e.custom = this._custom.map((e) => e.toJSON())), e;
1840
+ }
1841
+ };
1842
+ function br(e) {
1843
+ return G("error.workbook.invalidSheetKey", { key: e });
1844
+ }
1845
+ function xr(e) {
1846
+ return G("error.workbook.sheetNameNotFound", { sheetName: e });
1847
+ }
1848
+ function Sr(e, t) {
1849
+ return G(t === "chart" ? "error.workbook.sheetIsChart" : t === "macro" ? "error.workbook.sheetIsMacro" : "error.workbook.sheetIsDialog", { sheetName: e });
1850
+ }
1851
+ function Cr(e, t) {
1852
+ return t === "chart" ? G("error.workbook.selectedIsChart", { sheetName: e }) : t === "macro" ? G("error.workbook.selectedIsMacro", { sheetName: e }) : t === "dialog" ? G("error.workbook.selectedIsDialog", { sheetName: e }) : G("error.workbook.noWorksheet");
1853
+ }
1854
+ var wr = class extends ke {
1855
+ constructor(e, t, n, r) {
1856
+ super(), this._add = e, this._get = t, this._addListeners = n, this._getSelected = r;
1857
+ }
1858
+ getActive() {
1859
+ return this._getSelected();
1860
+ }
1861
+ getAt(e) {
1862
+ return this.getItems()[e] ?? null;
1863
+ }
1864
+ getByIndex(e) {
1865
+ return this.getItems()[e] ?? null;
1866
+ }
1867
+ getAll() {
1868
+ return this.getItems();
1640
1869
  }
1641
1870
  add(e) {
1642
1871
  return this._add(e);
1643
1872
  }
1644
- *[Symbol.iterator]() {
1645
- yield* this.getItems();
1646
- }
1647
- getItems(e) {
1873
+ _getItems(e) {
1648
1874
  return this._get(e?.name, e?.visibility);
1649
1875
  }
1650
1876
  getByName(e) {
1651
1877
  return this._get(e)?.[0] ?? null;
1652
1878
  }
1653
- getCount() {
1654
- return this._get().length;
1879
+ addListeners(e, t) {
1880
+ return this._addListeners(e, t);
1881
+ }
1882
+ get isIWorksheetCollection() {
1883
+ return !0;
1655
1884
  }
1656
- }, xn = /* @__PURE__ */ new RegExp(/[\\/\\*?:[\]]+/), Sn = /* @__PURE__ */ new RegExp(/\(((\d+)(?!.*\d))\)$/, "g");
1657
- function Cn(e) {
1658
- let t = H(V("workbook.defaultSheetName"), { n: e + 1 });
1885
+ }, Tr = /* @__PURE__ */ new RegExp(/[\\/\\*?:[\]]+/), Er = /* @__PURE__ */ new RegExp(/\(((\d+)(?!.*\d))\)$/, "g");
1886
+ function Dr(e) {
1887
+ let t = G(W("workbook.defaultSheetName"), { n: e + 1 });
1659
1888
  return t === "workbook.defaultSheetName" ? `Sheet${e + 1}` : t;
1660
1889
  }
1661
- function wn(e, t) {
1890
+ function Or(e, t) {
1662
1891
  return {
1663
- ...Xe,
1664
- getSheet: () => null,
1665
- toString: () => E(e, t)
1892
+ ...At,
1893
+ getWorksheet: () => null,
1894
+ toString: () => ye(e, t)
1666
1895
  };
1667
1896
  }
1668
- function Tn(e, t = !1) {
1669
- if (!e) throw Error(H("error.workbook.sheetNameBlank"));
1670
- if (xn.test(e)) {
1897
+ function kr(e, t = !1) {
1898
+ if (!e) throw Error(G("error.workbook.sheetNameBlank"));
1899
+ if (Tr.test(e)) {
1671
1900
  if (!t) throw Error(function(e) {
1672
- return e ? H("error.workbook.sheetNameInvalidCharsNamed", { sheetName: e }) : H("error.workbook.sheetNameInvalidChars");
1901
+ return e ? G("error.workbook.sheetNameInvalidCharsNamed", { sheetName: e }) : G("error.workbook.sheetNameInvalidChars");
1673
1902
  }(e));
1674
- e = e.replace(xn, "");
1903
+ e = e.replace(Tr, "");
1675
1904
  }
1676
- if (e.length === 0) throw Error(H("error.workbook.sheetNameBlank"));
1905
+ if (e.length === 0) throw Error(G("error.workbook.sheetNameBlank"));
1677
1906
  let n = e.length;
1678
1907
  if (n > 31) {
1679
- if (!t) throw Error(H("error.workbook.sheetNameTooLong"));
1908
+ if (!t) throw Error(G("error.workbook.sheetNameTooLong"));
1680
1909
  e = e.substring(0, 31);
1681
1910
  }
1682
1911
  if (e.charAt(0) === "'" || e.charAt(n - 1) === "'") {
1683
- if (!t) throw Error(H("error.workbook.sheetNameQuotes"));
1912
+ if (!t) throw Error(G("error.workbook.sheetNameQuotes"));
1684
1913
  e = e.replace(/^'|'$/g, "");
1685
1914
  }
1686
1915
  return e;
1687
1916
  }
1688
- var En, Dn, $ = class e extends ge {
1917
+ var Ar, jr = "workbook.activeSheet", Mr = class e extends l {
1689
1918
  constructor(e, t, n, r) {
1690
1919
  super(e, t, r), this._workbook = n;
1691
1920
  }
@@ -1696,23 +1925,24 @@ var En, Dn, $ = class e extends ge {
1696
1925
  let r = this._options;
1697
1926
  return n && (r = {
1698
1927
  ...this._options,
1699
- getOptions: j(this._options?.getOptions, n)
1928
+ getOptions: T(this._options?.getOptions, n)
1700
1929
  }), new e(t, this._internal, this._workbook, r);
1701
1930
  }
1702
1931
  _createRange(e, t) {
1703
- let n = e ? { ...e } : null, r = n ? this._workbook._getSheetRef(n.scope, O.Visibility.VeryHidden) : null;
1704
- if (!r) {
1705
- let e = this._workbook.getSelectedSheet();
1706
- return delete n?.scope, wn(n, n ? {
1707
- scope: h,
1932
+ let n = e ? { ...e } : null, r = this._workbook, i = n ? r._getSheetRef(n.scope, k.Visibility.VeryHidden) : null;
1933
+ if (i && !i.sheet.isIWorksheet) throw new B(Sr(i.name, i.sheet.getKind()));
1934
+ if (!i) {
1935
+ let e = r._anchorWorksheet();
1936
+ return delete n?.scope, Or(n, n ? {
1937
+ scope: g,
1708
1938
  ...e.getEntireRange().getCoords()
1709
1939
  } : null);
1710
1940
  }
1711
- let i = this._options;
1712
- return t && (i = {
1941
+ let a = this._options;
1942
+ return t && (a = {
1713
1943
  ...this._options,
1714
- getOptions: j(this._options.getOptions, t)
1715
- }), new On(e, D(r.sheet), this._workbook, i);
1944
+ getOptions: T(this._options.getOptions, t)
1945
+ }), new Nr(e, j(i.sheet), this._workbook, a);
1716
1946
  }
1717
1947
  async select(e) {
1718
1948
  let t = [], n = null, r = this.getCoords();
@@ -1720,8 +1950,8 @@ var En, Dn, $ = class e extends ge {
1720
1950
  let i = r[e];
1721
1951
  i && (n ||= i.scope, i && i.scope === n && t.push(i));
1722
1952
  }
1723
- n ||= this._workbook.getSelectedSheet().getName();
1724
- let i = this._workbook.getSheets().getByName(n);
1953
+ n ||= this._workbook.getWorksheet().getName();
1954
+ let i = this._workbook.getWorksheets().getByName(n);
1725
1955
  if (!i) return;
1726
1956
  let a = await i.getRanges(t).select(e), o = this._workbook._rangesAddressToCoords(a.getCoords());
1727
1957
  return this._createRanges(o);
@@ -1736,15 +1966,15 @@ var En, Dn, $ = class e extends ge {
1736
1966
  }
1737
1967
  getAddress(e) {
1738
1968
  let t = this._internal.getSheet(), n = t.getEntireRange().getCoords();
1739
- return ce(this.getCoords(), {
1969
+ return xe(this.getCoords(), {
1740
1970
  ...n,
1741
1971
  scope: t.getName()
1742
- }, E, ne, e);
1972
+ }, ye, Ee, e);
1743
1973
  }
1744
1974
  toString() {
1745
1975
  return this.getAddress();
1746
1976
  }
1747
- }, On = class e extends pe {
1977
+ }, Nr = class e extends st {
1748
1978
  constructor(e, t, n, r) {
1749
1979
  super(e, t, r), this._workbook = n;
1750
1980
  }
@@ -1752,17 +1982,17 @@ var En, Dn, $ = class e extends ge {
1752
1982
  let n = this._options;
1753
1983
  return t && (n = {
1754
1984
  ...this._options,
1755
- getOptions: j(this._options?.getOptions, t)
1756
- }), new $(e, this._internal, this._workbook, n);
1985
+ getOptions: T(this._options?.getOptions, t)
1986
+ }), new Mr(e, this._internal, this._workbook, n);
1757
1987
  }
1758
1988
  _createRange(t, n) {
1759
1989
  let r = this._internal;
1760
- if (!t) return Ae(r.getSheet(), r.getSheet().getEntireCoords());
1761
- if (r.validateCoords(t), r.getSheet().isClosed()) return Ae(null, r.getSheet().getEntireCoords(), t);
1990
+ if (!t) return Tt(r.getSheet(), r.getSheet().getEntireCoords());
1991
+ if (r.validateCoords(t), r.getSheet().isClosed()) return Tt(null, r.getSheet().getEntireCoords(), t);
1762
1992
  let i = this._options;
1763
1993
  return n && (i = {
1764
1994
  ...this._options,
1765
- getOptions: j(this._options?.getOptions, n)
1995
+ getOptions: T(this._options?.getOptions, n)
1766
1996
  }), new e(t, this._internal, this._workbook, i);
1767
1997
  }
1768
1998
  addListener(e, t) {
@@ -1775,7 +2005,7 @@ var En, Dn, $ = class e extends ge {
1775
2005
  }
1776
2006
  getAddress(e) {
1777
2007
  let t = this._internal.getSheet(), n = t?.getEntireRange().getCoords() ?? null;
1778
- return E(this.getCoords(), {
2008
+ return ye(this.getCoords(), {
1779
2009
  ...n,
1780
2010
  scope: t.getName()
1781
2011
  });
@@ -1783,131 +2013,144 @@ var En, Dn, $ = class e extends ge {
1783
2013
  toString() {
1784
2014
  return this.getAddress();
1785
2015
  }
1786
- }, kn = class {
1787
- constructor(e) {
1788
- this._lastTransactionUUID = null, this._closed = !1, this._listenerOrigin = null, this._lastOriginName = null, this._initializing = !0, this._isDate1904 = !1, this._locale = null, this._localeOverrides = null;
1789
- let t = typeof e == "string" ? { origin: e } : { ...e }, n = t.origin;
1790
- this._origin = typeof n == "string" ? new U(null, { name: n }) : n ?? new U(null), delete t.origin, this._lastOriginName = this._origin.getName(), this._listenerOrigin = this._origin.addListeners({ onChange: () => {
1791
- if (this._closed) return;
1792
- let e = this._origin.getName();
1793
- e !== this._lastOriginName && (this._lastOriginName = e, this._emitter.notify("onNameChange"));
1794
- } });
1795
- let r = t.json;
1796
- delete t.json, this._transactions = t.transactions ?? new s(), this._id = this._transactions.create(), this._ownTransactions = !t.transactions, this._emitter = new S(this, this._transactions), this._runtime = t.runtime ?? new We("Workbook Runtime", {
2016
+ }, Pr = (e) => !!e && typeof e == "object" && typeof e.getOrigin == "function", Fr = class {
2017
+ constructor(t) {
2018
+ this._isLoadingSheets = !1, this._lastTransactionUUID = null, this._starting = null, this._closed = !1, this._listenerOriginProvider = null, this._listenerOrigin = null, this._lastOriginName = null, this._initializing = !0, this._pivotCaches = [], this._pivotTableCollection = new we(() => {
2019
+ let e = [];
2020
+ for (let t of this.getWorksheets()) e.push(...t.getPivotTables());
2021
+ return e;
2022
+ }), this._people = new or(), this._commentCollection = new ht(null, (e, t, n) => {
2023
+ let r = [];
2024
+ for (let i of this.getWorksheets()) r.push(...i.getComments().getItems(e ? {
2025
+ address: e,
2026
+ ignoreHidden: t,
2027
+ fullyContained: n
2028
+ } : {
2029
+ ignoreHidden: t,
2030
+ fullyContained: n
2031
+ }));
2032
+ return r;
2033
+ }, (e, t) => this.addListeners({ onSheetsChange: e.onCollectionChange ? () => {
2034
+ e.onCollectionChange(this._commentCollection);
2035
+ } : void 0 }, t)), this._isDate1904 = !1, this._codeName = null, this._updateLinks = null, this._documentProperties = new yr(() => {
2036
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2037
+ }), this._locale = null, this._localeOverrides = null;
2038
+ let n = typeof t == "string" ? { origin: t } : { ...t }, r = n.origin;
2039
+ this._ownOriginProvider = !Pr(r), this._originProvider = Pr(r) ? r : new Dn(typeof r == "string" ? new K(null, { name: r }) : r ?? new K(null)), delete n.origin, this._bindOrigin(this._originProvider.getOrigin()), this._listenerOriginProvider = this._originProvider.addListeners({ onOriginChange: () => this._onOriginChange() });
2040
+ let a = n.json;
2041
+ delete n.json, this._transactions = n.transactions ?? new i(), this._id = this._transactions.create(), this._ownTransactions = !n.transactions, this._emitter = new e(this, this._transactions), this._runtime = n.runtime ?? new s("Workbook Runtime", {
1797
2042
  isDate1904: () => this._isDate1904,
1798
- getLocale: () => this._locale ?? Oe() ?? Le(),
2043
+ getNow: () => this._transactions.getCurrentCommit().getTimestamp(),
2044
+ getLocale: () => this._locale ?? b() ?? be(),
1799
2045
  getLocaleOverrides: () => this._localeOverrides
1800
- }), this._listenerLanguage = mt.addChangeListener(() => {
1801
- this._locale !== null || this._closed || this._notifyAllChange();
2046
+ }), this._listenerLanguage = fn.addChangeListener(() => {
2047
+ this._closed || this._notifyAllChange();
1802
2048
  });
1803
- let i = this, a = this._beginCommit({ description: V(r ? "op.openWorkbook" : "op.newWorkbook") });
2049
+ let o = this, c = this._beginCommit({ description: W(a ? "op.openWorkbook" : "op.newWorkbook") });
1804
2050
  try {
1805
- this._strings = t.strings ?? new he(), this._ownStrings = !t.strings, this._externalBooks = new un({ json: r?.externalBooks }), this._resources = t.resources ?? new st(), this._ownResources = !t.resources, this._createSheetName = t.createSheetNameCallback ?? Cn;
1806
- let e = t.createSheetCallback;
1807
- e ||= (e) => new A(e), this._sheetOnNameChange = /* @__PURE__ */ new Map(), this._sheetOnVisibilityChange = /* @__PURE__ */ new Map(), this._sheetOnIndexChange = /* @__PURE__ */ new Map(), this._createSheet = (t, n, r, a, o) => {
1808
- let s = null, c = {
1809
- runtime: i._runtime,
1810
- readonly: i._options.readonly ?? !1,
1811
- disableLoadAutoFit: i._options.disableLoadAutoFit ?? !1,
1812
- formulaTransform: i._options.formulaTransform,
1813
- opener: i._options.opener,
1814
- transactions: i._transactions,
1815
- styles: i._styles,
1816
- strings: i._strings,
1817
- resources: i._resources,
1818
- names: i._names,
1819
- workbook: i,
1820
- calculation: i._calculation,
1821
- resolveRange: (e) => i._options.resolveRange?.(e) ?? i.getRange(e),
2051
+ this._strings = n.strings ?? new Nt(), this._ownStrings = !n.strings, this._resources = n.resources ?? new Le(), this._ownResources = !n.resources, this._createSheetName = n.createSheetNameCallback ?? Dr;
2052
+ let e = n.createWorksheetCallback;
2053
+ e ||= (e) => new A(e), this._sheetOnNameChange = /* @__PURE__ */ new Map(), this._sheetOnVisibilityChange = /* @__PURE__ */ new Map(), this._sheetOnIndexChange = /* @__PURE__ */ new Map(), this._createSheet = (t, n, r, i, a, s, c) => {
2054
+ let l = null, u = {
2055
+ runtime: o._runtime,
2056
+ readonly: o._options.readonly ?? !1,
2057
+ disableLoadAutoFit: o._options.disableLoadAutoFit ?? !1,
2058
+ opener: o._options.opener,
2059
+ transactions: o._transactions,
2060
+ styles: o._styles,
2061
+ strings: o._strings,
2062
+ resources: o._resources,
2063
+ names: o._names,
2064
+ workbook: o,
2065
+ calculation: o._calculation,
2066
+ resolveRange: (e) => o._options.resolveRange?.(e) ?? o.getRange(e),
1822
2067
  container: {
1823
2068
  beforeFromJSON: (e) => {
1824
- s = e, i._addSheetRef({
2069
+ l = e, o._addSheetRef({
1825
2070
  name: n,
1826
2071
  id: t,
1827
- visibility: r ?? O.Visibility.Visible,
2072
+ visibility: r ?? k.Visibility.Visible,
2073
+ sheetId: a,
1828
2074
  sheet: e
1829
- }, a);
2075
+ }, i);
1830
2076
  },
1831
2077
  getName: () => {
1832
- let e = i._getSheetRef(s);
2078
+ let e = o._getSheetRef(l);
1833
2079
  return e ? e.name : n;
1834
2080
  },
1835
2081
  setName: (e, t) => {
1836
- i._getSheetRef(s) && i._setSheetName(s, e, t);
2082
+ o._getSheetRef(l) && o._setSheetName(l, e, t);
1837
2083
  },
1838
2084
  setNameChangeCallback: (e) => {
1839
- i._sheetOnNameChange.set(t, e);
2085
+ o._sheetOnNameChange.set(t, e);
1840
2086
  },
1841
2087
  getVisibility: () => {
1842
- let e = i._getSheetRef(s);
1843
- return e ? e.visibility : O.Visibility.Visible;
2088
+ let e = o._getSheetRef(l);
2089
+ return e ? e.visibility : k.Visibility.Visible;
1844
2090
  },
1845
2091
  setVisibility: (e, t) => {
1846
- i._setSheetVisibility(s, e, t);
2092
+ o._setSheetVisibility(l, e, t);
1847
2093
  },
1848
2094
  setVisibilityCallback: (e) => {
1849
- i._sheetOnVisibilityChange.set(t, e);
2095
+ o._sheetOnVisibilityChange.set(t, e);
1850
2096
  },
1851
- duplicate: () => i._duplicateSheet(s),
2097
+ duplicate: () => o._duplicateSheet(l),
1852
2098
  getIndex: () => {
1853
- let e = i._getSheetRef(s);
1854
- return e ? i._getOffsetForId(e.id, i._getSheetRefs(O.Visibility.VeryHidden)) : a;
2099
+ let e = o._getSheetRef(l);
2100
+ return e ? o._getOffsetForId(e.id, o._getSheetRefs(k.Visibility.VeryHidden)) : i;
1855
2101
  },
1856
2102
  setIndex: (e, t) => {
1857
- let n = i._getSheetRef(s, O.Visibility.VeryHidden);
1858
- return !!n && (i._moveSheet(n, e, t), !0);
2103
+ let n = o._getSheetRef(l, k.Visibility.VeryHidden);
2104
+ return !!n && (o._moveSheet(n, e, t), !0);
1859
2105
  },
1860
2106
  setIndexCallback: (e) => {
1861
- i._sheetOnIndexChange.set(t, e);
2107
+ o._sheetOnIndexChange.set(t, e);
1862
2108
  },
1863
- requestSelect: async () => (i._setSelectedSheet(s), await this._emitter.notify("onRequestSelect", {
1864
- source: i,
1865
- params: s,
1866
- async: !0
1867
- }), i.getSelectedSheet() === s)
2109
+ requestSelect: () => o._requestSelect(l)
1868
2110
  }
1869
2111
  };
1870
- return o && (c.json = o), s = e(c, n, a, r), s;
1871
- }, this._namedTableSource = new it({
1872
- getSheets: () => i._sheets ? i.getSheets().getItems() : I.EmptyArray,
1873
- addSheetsListener: (e, t) => i.addListeners({ onSheetsChange: e }, t)
1874
- }), this._names = t.names ?? new we({
1875
- addressToRanges: (e) => i.getRanges(e),
1876
- getCurrentScope: () => i.getSelectedSheet().getName(),
1877
- isReadOnly: () => i._options.readonly ?? !1,
1878
- transactions: i._transactions,
1879
- getSources: () => i._calculation ? [i._calculation.getNamedFormulas(), i._namedTableSource] : I.EmptyArray
1880
- }), this._ownNames = !t.names, this._calculation = t.calculation ?? new ye({
1881
- runtime: i._runtime,
1882
- functions: t.functions,
1883
- json: r?.calc,
2112
+ return s && (u.json = s), c !== void 0 && (u.uid = () => c), l = e(u, n, i, r), l;
2113
+ }, this._namedTableSource = new Me({
2114
+ getSheets: () => o._sheets ? o.getWorksheets().getItems() : R.EmptyArray,
2115
+ addSheetsListener: (e, t) => o.addListeners({ onSheetsChange: e }, t)
2116
+ }), this._names = n.names ?? new De({
2117
+ addressToRanges: (e) => o.getRanges(e),
2118
+ getCurrentScope: () => o.getSelectedWorksheet()?.getName() ?? null,
2119
+ isReadOnly: () => (o._options.readonly ?? !1) || o._isStructureProtected(),
2120
+ transactions: o._transactions,
2121
+ getSources: () => o._calculation ? [o._calculation.getNamedFormulas(), o._namedTableSource] : R.EmptyArray
2122
+ }), this._ownNames = !n.names, this._calculation = n.calculation ?? new m({
2123
+ runtime: o._runtime,
2124
+ functions: n.functions,
2125
+ json: a?.calc,
2126
+ isNamesReadOnly: () => o._isStructureProtected(),
1884
2127
  getActiveCell: () => {
1885
- let e = i.getSelectedSheet(), t = e?.getSelectedRange()?.getCoords();
1886
- return t ? {
2128
+ let e = o.getSelectedWorksheet(), t = e?.getSelectedRange()?.getCoords();
2129
+ return e && t ? {
1887
2130
  rowIndex: t.rowStart,
1888
2131
  colIndex: t.colStart,
1889
2132
  scope: e.getId()
1890
2133
  } : null;
1891
2134
  },
1892
- getRange: i.getRange.bind(i),
1893
- getRanges: i.getRanges.bind(i),
1894
- createGraphRanges: (e, t) => i._createGraphRanges(e, t),
2135
+ getRange: o.getRange.bind(o),
2136
+ getRanges: o.getRanges.bind(o),
2137
+ createGraphRanges: (e, t) => o._createGraphRanges(e, t),
1895
2138
  getSheetIndex: (e) => {
1896
2139
  if (e === void 0) {
1897
- let e = i.getSelectedSheet();
1898
- return e ? this._getSheetRefs(O.Visibility.VeryHidden).findIndex((t) => t.sheet === e) : -1;
2140
+ let e = o.getSelectedSheet();
2141
+ return e ? this._getSheetRefs(k.Visibility.VeryHidden).findIndex((t) => t.sheet === e) : -1;
1899
2142
  }
1900
- let t = this._getSheetRefs(O.Visibility.VeryHidden);
2143
+ let t = this._getSheetRefs(k.Visibility.VeryHidden);
1901
2144
  e = e.toLowerCase();
1902
2145
  let n = t.length;
1903
2146
  for (let r = 0; r < n; r++) if (t[r].name.toLowerCase() === e) return r;
1904
2147
  try {
1905
- An.address = e;
1906
- let t = this._names.getItems(An);
2148
+ Ir.address = e;
2149
+ let t = this._names.getItems(Ir);
1907
2150
  if (!t || t.length === 0) return -1;
1908
2151
  let n = t[0].getRanges?.()?.getCoords()?.[0]?.scope;
1909
2152
  if (!n) return -1;
1910
- let r = this._getSheetRefs(O.Visibility.VeryHidden);
2153
+ let r = this._getSheetRefs(k.Visibility.VeryHidden);
1911
2154
  n = n.toLowerCase();
1912
2155
  let i = r.length;
1913
2156
  for (let e = 0; e < i; e++) if (r[e].name.toLowerCase() === n) return e;
@@ -1916,37 +2159,50 @@ var En, Dn, $ = class e extends ge {
1916
2159
  }
1917
2160
  return -1;
1918
2161
  },
1919
- getSheetCount: () => i.getSheets().getItems({ visibility: O.Visibility.VeryHidden }).length,
1920
- getSheetById: (e) => {
1921
- let t = i.getSheets().getItems({ visibility: O.Visibility.VeryHidden }), n = t.length;
1922
- for (let r = 0; r < n; r++) if (t[r].getId() === e) return t[r];
1923
- return null;
1924
- },
1925
- getSheetByName: (e) => {
1926
- try {
1927
- return i.getSheets().getByName(e) ?? null;
1928
- } catch {
1929
- return null;
1930
- }
1931
- },
1932
- namedCollection: i._names,
1933
- strings: i._strings,
1934
- transactions: i._transactions,
1935
- names: r?.names,
1936
- formulaTransform: t.formulaTransform
1937
- }), this._ownCalculation = !t.calculation, this._scripts = this._createScripts(), this._ownNames = !t.names, this._options = Object.freeze({ ...t });
1938
- let n = async () => {
1939
- this._ownCalculation && await this._calculation.start(), await this._scripts.start(), this._starting = null;
2162
+ getSheetCount: () => o._getSheetRefs(k.Visibility.VeryHidden).length,
2163
+ externalBooks: a?.externalBooks,
2164
+ externalBookResolver: n.externalBookResolver,
2165
+ namedCollection: o._names,
2166
+ strings: o._strings,
2167
+ transactions: o._transactions,
2168
+ names: a?.names
2169
+ }), this._ownCalculation = !n.calculation, this._scripts = this._createScripts(a?.modules), this._ownNames = !n.names, this._options = Object.freeze({ ...n });
2170
+ let t = a?.sheets?.length ? a.sheets.map((e) => e.name) : [this._createSheetName(0)], r = t.map((e) => e + "-" + R.uuidV4()), i = (e) => {
2171
+ let t = a?.sheets?.[e]?.kind;
2172
+ return !!t && t !== k.Kind.Worksheet;
1940
2173
  };
1941
- this._starting = n(), this._starting?.catch(() => {}), r ? this._fromJSON(r) : (this._initState(), this._addSheet(!1)), this._sheets = new bn((e) => i._addSheetOptions(e), (e, t) => {
2174
+ this._calculation._setSheets(t.map((e, t) => i(t) ? [
2175
+ r[t],
2176
+ e,
2177
+ !0
2178
+ ] : [r[t], e]));
2179
+ let s = n.calcOnLoad ?? "auto", l = !1, u = (async () => {
2180
+ try {
2181
+ if (this._ownCalculation && s !== "none" && (s === "full" || s === "auto" && !0 === a?.calc?.fullCalcOnLoad ? await this._calculation.calculate({ full: !0 }) : await this._calculation.start(), this._closed)) return;
2182
+ await this._scripts.start();
2183
+ } finally {
2184
+ l = !0, this._starting = null;
2185
+ }
2186
+ })();
2187
+ l || (this._starting = u), this._starting?.catch(() => {}), a ? this._fromJSON(a, r) : (this._initState(), this._addSheet(!1, t[0], null, r[0])), this._sheets = new wr((e) => o._addSheetOptions(e), (e, t) => {
1942
2188
  if (e) {
1943
2189
  let n = this._getSheetRef(e, t);
1944
- return n ? [n.sheet] : I.EmptyArray;
2190
+ return n && Z(n) ? [n.sheet] : R.EmptyArray;
1945
2191
  }
1946
- return this._getSheets(t);
1947
- }), this._ownCalculation && this._calculation.hydrateNames(), this._emitter.notify("onLoad"), a.commit({ forceAmend: this._ownTransactions });
2192
+ return this._getWorksheets(t);
2193
+ }, (e, t) => {
2194
+ let n = e.onCollectionChange, r = e.onInvalidated;
2195
+ return o._emitter.addListeners({
2196
+ onSheetsChange: n ? () => {
2197
+ n(o._sheets);
2198
+ } : void 0,
2199
+ onInvalidated: r ? () => {
2200
+ r(o._sheets);
2201
+ } : void 0
2202
+ }, t);
2203
+ }, () => o.getSelectedWorksheet()), this._ownCalculation && (n.calcOnLoad ?? "auto") !== "none" && this._calculation.hydrateNames(), this._emitter.notify("onLoad"), this._ownTransactions ? c.amend() : c.commit();
1948
2204
  } catch (e) {
1949
- throw a.rollback(), e;
2205
+ throw c.rollback(), e;
1950
2206
  }
1951
2207
  this._initializing = !1;
1952
2208
  }
@@ -1954,22 +2210,14 @@ var En, Dn, $ = class e extends ge {
1954
2210
  let e = this._getSheetRefs();
1955
2211
  for (let t = (e ? e.length : 0) - 1; t >= 0; t--);
1956
2212
  let t = this._options;
1957
- this._isDate1904 = t.runtime?.isDate1904() ?? !1, this._locale = null, this._localeOverrides = null, this._theme = t.theme ?? new g().getDefaultTheme(), this._styles = t?.styles ?? new ae(this._theme), this._ownStyles = !t.styles, this._styles.getTheme() || this._styles.setTheme(this.getTheme()), this._activeSheetOffset = 0, this.setView(new Q()), this._listenerProtection?.(), this._protection = new vn(void 0, this._options.readonly ?? !1), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
2213
+ this._isDate1904 = t.runtime?.isDate1904() ?? !1, this._locale = null, this._localeOverrides = null, this._theme = t.theme ?? new oe().getDefaultTheme(), this._styles = t?.styles ?? new _e(this._theme), this._ownStyles = !t.styles, this._styles.getTheme() || this._styles.setTheme(this.getTheme()), this._activeSheetOffset = 0, this.setView(new mr()), this._listenerProtection?.(), this._protection = new gr(void 0, this._options.readonly ?? !1), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
1958
2214
  n._emitter.notify("onProtectionChange");
1959
2215
  } });
1960
2216
  let n = this;
1961
2217
  this._transactionsRemoveListener = this._transactions.addStateListener(this._id, {
1962
- async onAfterStateChange(e, t, r) {
1963
- if (t && t.activeSheetId !== void 0 && t.view === n.getView() && r.getId() === n._lastTransactionUUID && await n._getSheetRef({ id: t.activeSheetId })?.sheet.select(), t && r.getId() !== n._lastTransactionUUID) {
1964
- let r = n.getView().getActiveSheetId();
1965
- t.view === n.getView() && (r = t.activeSheetId);
1966
- let i = 0;
1967
- try {
1968
- i = n._getOffsetForId(r, e.sheetRefsVisible);
1969
- } catch {}
1970
- n._adjustRemoveSelectionIfRequired(i, r);
1971
- }
1972
- n._lastTransactionUUID = r.getId(), n._notifyAllChange();
2218
+ async onAfterStateChange(e, t, r, i, a) {
2219
+ let o = n._view, s = a?.[jr], c = r ? s?.before : s?.after, l = s?.viewId === o.getId() && c != null, u = l ? c : o.getActiveSheetId(), d = l && t.getId() === n._lastTransactionUUID ? n._getSheetRef({ id: u }) : null;
2220
+ d ? await d.sheet.select() : n._resyncActiveSheet(u, e), n._lastTransactionUUID = t.getId(), (r || i) && n._emitter.notify("onSheetsChange"), n._emitter.notify("onSelectedSheetChange"), n._emitter.notify("onViewChange");
1973
2221
  },
1974
2222
  onRestoreOrRevert() {
1975
2223
  n._ownCalculation, n._emitter.notify("onInvalidated");
@@ -2002,14 +2250,29 @@ var En, Dn, $ = class e extends ge {
2002
2250
  return this._closed ? null : this._origin.getName();
2003
2251
  }
2004
2252
  getOrigin() {
2005
- return this._origin;
2253
+ return this._originProvider.getOrigin();
2254
+ }
2255
+ _onOriginChange() {
2256
+ if (this._closed) return;
2257
+ let e = this._originProvider.getOrigin();
2258
+ if (e === this._origin) return;
2259
+ this._listenerOrigin?.();
2260
+ let t = this._lastOriginName;
2261
+ this._bindOrigin(e), this._emitter.notify("onOriginChange"), this._lastOriginName !== t && this._emitter.notify("onNameChange");
2262
+ }
2263
+ _bindOrigin(e) {
2264
+ this._origin = e, this._lastOriginName = e.getName(), this._listenerOrigin = e.addListeners({ onChange: () => {
2265
+ if (this._closed) return;
2266
+ let t = e.getName();
2267
+ t !== this._lastOriginName && (this._lastOriginName = t, this._emitter.notify("onNameChange"));
2268
+ } });
2006
2269
  }
2007
2270
  getView() {
2008
2271
  return this._view;
2009
2272
  }
2010
2273
  setView(e) {
2011
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2012
- if (!e) throw new R(H("error.sheet.emptyView"));
2274
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2275
+ if (!e) throw new B(G("error.sheet.emptyView"));
2013
2276
  this._listenerWorkbookView?.();
2014
2277
  let t = this, n = -1;
2015
2278
  return this._listenerWorkbookView = e.addListeners({ onViewChange: (e) => {
@@ -2021,8 +2284,8 @@ var En, Dn, $ = class e extends ge {
2021
2284
  return this._runtime;
2022
2285
  }
2023
2286
  setDate1904(e) {
2024
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2025
- return this._isDate1904 = e, this._notifyAllChange(), this;
2287
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2288
+ return this._isDate1904 === e || (this._isDate1904 = e, this._emitter.notify("onRegionalChange")), this;
2026
2289
  }
2027
2290
  getLocale() {
2028
2291
  return this._runtime.getLocale();
@@ -2031,21 +2294,21 @@ var En, Dn, $ = class e extends ge {
2031
2294
  return this._locale;
2032
2295
  }
2033
2296
  setLocale(e) {
2034
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2297
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2035
2298
  if (e) try {
2036
2299
  new Intl.Locale(e);
2037
2300
  } catch {
2038
- throw Error(H("error.workbook.invalidLocale", { locale: e }));
2301
+ throw Error(G("error.workbook.invalidLocale", { locale: e }));
2039
2302
  }
2040
- return this._locale === e || (this._locale = e, this._notifyAllChange()), this;
2303
+ return this._locale === e || (this._locale = e, this._emitter.notify("onRegionalChange")), this;
2041
2304
  }
2042
2305
  getLocaleOverrides() {
2043
2306
  return this._localeOverrides;
2044
2307
  }
2045
2308
  setLocaleOverrides(e) {
2046
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2309
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2047
2310
  let t = e && Object.keys(e).length > 0 ? e : null;
2048
- return this._localeOverrides = t, this._notifyAllChange(), this;
2311
+ return this._localeOverrides = t, this._emitter.notify("onRegionalChange"), this;
2049
2312
  }
2050
2313
  getStyles() {
2051
2314
  return this._styles;
@@ -2056,18 +2319,42 @@ var En, Dn, $ = class e extends ge {
2056
2319
  getTransactions() {
2057
2320
  return this._transactions;
2058
2321
  }
2322
+ getChanges(e) {
2323
+ let t = this._transactions, [n, r] = t.getLog(e ?? t.getCurrentCommit(!1).getId(), 2), i = [], a = this.getWorksheets().getItems({ visibility: k.Visibility.VeryHidden });
2324
+ for (let e = 0; e < a.length; e++) {
2325
+ let t = a[e];
2326
+ t instanceof A && i.push(...t._changeEventsOf(n, r ?? null));
2327
+ }
2328
+ return i;
2329
+ }
2059
2330
  getStrings() {
2060
2331
  return this._strings;
2061
2332
  }
2062
2333
  getExternalBooks() {
2063
- return this._externalBooks;
2334
+ return this._calculation.getExternalBooks();
2335
+ }
2336
+ getUpdateLinks() {
2337
+ return this._updateLinks;
2338
+ }
2339
+ setUpdateLinks(e) {
2340
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2341
+ return this._updateLinks = e, this;
2342
+ }
2343
+ getPivotTables() {
2344
+ return this._pivotTableCollection;
2345
+ }
2346
+ getComments() {
2347
+ return this._commentCollection;
2348
+ }
2349
+ getPeople() {
2350
+ return this._people;
2064
2351
  }
2065
2352
  getTheme() {
2066
2353
  return this._theme;
2067
2354
  }
2068
2355
  setTheme(e) {
2069
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2070
- if (!e) throw new R(H("error.workbook.notSetValue"));
2356
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2357
+ if (!e) throw new B(G("error.workbook.notSetValue"));
2071
2358
  let t = this._theme;
2072
2359
  return this._theme = e, this.getStyles().setTheme(e), this._emitter.notify("onThemeChange"), t;
2073
2360
  }
@@ -2076,54 +2363,90 @@ var En, Dn, $ = class e extends ge {
2076
2363
  }
2077
2364
  getSelectedSheet() {
2078
2365
  let e = this._getSheetRef(this.getSelectedSheetIndex());
2079
- return e ? e?.sheet : null;
2366
+ return e ? e.sheet : null;
2367
+ }
2368
+ getSelectedWorksheet() {
2369
+ let e = this._getSheetRef(this.getSelectedSheetIndex());
2370
+ return e && Z(e) ? e.sheet : null;
2371
+ }
2372
+ getActiveSheet() {
2373
+ return this.getSelectedWorksheet();
2374
+ }
2375
+ getActiveWorksheet() {
2376
+ return this.getSelectedWorksheet();
2080
2377
  }
2081
- getSheet(e, t = O.Visibility.Visible) {
2378
+ getSheets(e) {
2379
+ let t = this._getSheetRefs(e?.visibility ?? k.Visibility.Visible), n = Array(t.length);
2380
+ for (let e = 0; e < t.length; e++) n[e] = t[e].sheet;
2381
+ return n;
2382
+ }
2383
+ getSheet(e) {
2082
2384
  if (e === void 0) return this.getSelectedSheet();
2083
- if (!e) throw Error(H("error.workbook.sheetNameNotProvided"));
2385
+ if (!e) throw Error(G("error.workbook.sheetNameNotProvided"));
2386
+ let t = this._getSheetRef(e);
2387
+ if (!t) throw new H(xr(e));
2388
+ return t.sheet;
2389
+ }
2390
+ getWorksheet(e, t = k.Visibility.Visible) {
2391
+ if (typeof e == "number") return this.getWorksheetAt(e, t);
2392
+ if (e === void 0) return this._requireSelectedWorksheet();
2393
+ if (!e) throw Error(G("error.workbook.sheetNameNotProvided"));
2084
2394
  let n = this._getSheetRef(e, t);
2085
- if (!n) throw new B(H("error.workbook.sheetNameNotFound", { sheetName: e }));
2395
+ if (!n) throw new H(xr(e));
2396
+ if (!Z(n)) throw new H(Sr(n.name, n.sheet.getKind()));
2086
2397
  return n.sheet;
2087
2398
  }
2088
- getSheetAt(e, t = O.Visibility.Visible) {
2089
- let n = this._getSheetRef(e, t);
2090
- if (!n) throw new B(function(e) {
2091
- return H("error.workbook.sheetIndexNotFound", { index: e });
2399
+ getWorksheetAt(e, t = k.Visibility.Visible) {
2400
+ let n = this._getWorksheets(t)[e];
2401
+ if (!n) throw new H(function(e) {
2402
+ return G("error.workbook.sheetIndexNotFound", { index: e });
2092
2403
  }(e));
2093
- return n.sheet;
2404
+ return n;
2094
2405
  }
2095
- getSheets() {
2406
+ _requireSelectedWorksheet() {
2407
+ let e = this.getSelectedWorksheet();
2408
+ if (e) return e;
2409
+ let t = this.getSelectedSheet();
2410
+ throw new B(Cr(t?.getName() ?? "", t?.getKind() ?? k.Kind.Worksheet));
2411
+ }
2412
+ _anchorWorksheet() {
2413
+ return this.getSelectedWorksheet() || (this._getWorksheets(k.Visibility.VeryHidden)[0] ?? null);
2414
+ }
2415
+ getWorksheets() {
2096
2416
  return this._sheets;
2097
2417
  }
2098
- addSheet(e) {
2099
- return this.getSheets().add(e);
2418
+ addWorksheet(e) {
2419
+ return this.getWorksheets().add(e);
2100
2420
  }
2101
- _getSheets(e = O.Visibility.Visible) {
2421
+ _getWorksheets(e = k.Visibility.Visible) {
2102
2422
  let t = this._getSheetRefs(e), n = [], r = t.length;
2103
- for (let e = 0; e < r; e++) n.push(t[e].sheet);
2423
+ for (let e = 0; e < r; e++) {
2424
+ let r = t[e];
2425
+ Z(r) && n.push(r.sheet);
2426
+ }
2104
2427
  return n;
2105
2428
  }
2106
- _getSheetRefs(e = O.Visibility.Visible) {
2429
+ _getSheetRefs(e = k.Visibility.Visible) {
2107
2430
  let t = this._getState();
2108
- return t ? e === O.Visibility.Visible ? t.sheetRefsVisible : e === O.Visibility.Hidden ? t.sheetRefsVisibleAndHidden : e === O.Visibility.VeryHidden ? t.sheetRefsAll : I.EmptyArray : [];
2431
+ return t ? e === k.Visibility.Visible ? t.sheetRefsVisible : e === k.Visibility.Hidden ? t.sheetRefsVisibleAndHidden : e === k.Visibility.VeryHidden ? t.sheetRefsAll : R.EmptyArray : [];
2109
2432
  }
2110
- _getSheetRef(e, t = O.Visibility.Visible) {
2433
+ _getSheetRef(e, t = k.Visibility.Visible) {
2111
2434
  let n = null;
2112
- return typeof e == "number" ? this._getSheetRefs(t)[e] : (typeof e == "string" ? n = this._getState().refsByLowerCaseName.get(e.toLowerCase()) : e instanceof A ? n = this._getState().refsByInstance.get(e) : e?.id !== void 0 && (n = this._getState().refsById.get(e.id)), n);
2435
+ return typeof e == "number" ? this._getSheetRefs(t)[e] : (typeof e == "string" ? n = this._getState().refsByLowerCaseName.get(e.toLowerCase()) : !0 === e?.isISheet ? n = this._getState().refsByInstance.get(e) : e?.id !== void 0 && (n = this._getState().refsById.get(e.id)), n);
2113
2436
  }
2114
2437
  _validateNewSheetName(e, t = !0) {
2115
2438
  if (e == null) return e;
2116
- if (Tn(e), t && this._getState().sheetsByLowerCaseName.has(e.toLowerCase())) throw new R(H("error.workbook.nameTaken"));
2439
+ if (kr(e), t && this._getState().sheetsByLowerCaseName.has(e.toLowerCase())) throw new B(G("error.workbook.nameTaken"));
2117
2440
  return e.substring(0, 31);
2118
2441
  }
2119
2442
  findValidSheetName(e) {
2120
- e &&= Tn(e, !0);
2443
+ e &&= kr(e, !0);
2121
2444
  try {
2122
2445
  return function(e, t) {
2123
2446
  try {
2124
2447
  if (t(e)) return e;
2125
2448
  } catch {}
2126
- let n, r, i = Sn.exec(e);
2449
+ let n, r, i = Er.exec(e);
2127
2450
  for (i === null ? (n = e + " ", r = 1) : (n = e.substring(0, i.index), r = parseFloat(i[1])); r < 256;) {
2128
2451
  r++;
2129
2452
  let e = "(" + r + ")", i = n.substring(0, 31 - e.length) + e;
@@ -2138,36 +2461,25 @@ var En, Dn, $ = class e extends ge {
2138
2461
  }
2139
2462
  }
2140
2463
  isValidSheetNameCharacter(e) {
2141
- return !xn.test(e);
2464
+ return !Tr.test(e);
2465
+ }
2466
+ _isStructureProtected() {
2467
+ return !this._initializing && !this.getProtection().isStructureAllowed();
2142
2468
  }
2143
2469
  _addSheetOptions(e) {
2144
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2145
- if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2470
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2471
+ if (!this.getProtection().isStructureAllowed()) throw new U(G("error.workbook.protection"));
2146
2472
  let t, n = null;
2147
2473
  t = typeof e == "string" ? { name: e } : typeof e == "number" ? { index: e } : e, t = {
2148
2474
  ...t,
2149
- description: t?.description ?? V("op.addSheet")
2475
+ description: t?.description ?? W("op.addSheet")
2150
2476
  };
2151
2477
  let r = this.beginCommit(t);
2152
2478
  try {
2153
2479
  let e = t?.autoSelect ?? !1;
2154
2480
  n = this._addSheet(!0, t.name, t.index ?? null);
2155
- let i = this.getView().getActiveSheetId(), a, o;
2156
- if (!1 !== e) {
2157
- let t = this.getView().getActiveSheetId();
2158
- t = this._getSheetRef(n).id, e && (a = {
2159
- view: this.getView(),
2160
- activeSheetId: i
2161
- }, o = {
2162
- view: this.getView(),
2163
- activeSheetId: t
2164
- });
2165
- }
2166
- if (r.commit({
2167
- description: H("op.addSheetNamed", { name: n.getName() }),
2168
- viewBefore: a,
2169
- viewAfter: o
2170
- }), !1 !== e) {
2481
+ let i = this.getView().getActiveSheetId();
2482
+ if (e && this._recordActiveSheet(r, i, this._getSheetRef(n).id), r.commit({ description: G("op.addSheetNamed", { name: n.getName() }) }), !1 !== e) {
2171
2483
  let t = typeof e == "boolean" ? void 0 : e;
2172
2484
  n.select(t);
2173
2485
  }
@@ -2178,8 +2490,8 @@ var En, Dn, $ = class e extends ge {
2178
2490
  }
2179
2491
  _nextSheetName(e = null) {
2180
2492
  let t = e ? e.toLowerCase() : null, n = this._getState(), r = n.sheetsByLowerCaseName;
2181
- if (e && r.has(t)) throw new R(function(e) {
2182
- return H("error.workbook.nameDuplicate", { sheetName: e });
2493
+ if (e && r.has(t)) throw new B(function(e) {
2494
+ return G("error.workbook.nameDuplicate", { sheetName: e });
2183
2495
  }(e));
2184
2496
  t = (e = this._validateNewSheetName(e)) ? e.toLowerCase() : null;
2185
2497
  let i = n.lastId + 1;
@@ -2189,23 +2501,77 @@ var En, Dn, $ = class e extends ge {
2189
2501
  }
2190
2502
  return this._updateState({ lastId: i }), e;
2191
2503
  }
2192
- _addSheet(e, t = null, n = null) {
2504
+ _addSheet(e, t = null, n = null, r) {
2193
2505
  t = this._nextSheetName(t);
2194
- let r = this._getState(), i = this._createSheet(r.lastId, t, O.Visibility.Visible, n, null);
2195
- if (!i) throw new R(H("error.workbook.sheetNameBlank"));
2196
- return e && this._emitter.notify("onSheetsChange"), i;
2506
+ let i = this._getState(), a = this._createSheet(i.lastId, t, k.Visibility.Visible, n, void 0, null, r);
2507
+ if (!a) throw new B(G("error.workbook.sheetNameBlank"));
2508
+ return e && (this._tellSheets(), this._emitter.notify("onSheetsChange")), a;
2509
+ }
2510
+ _createOpaqueSheet(e, t, n, r, i, a, o, s, c) {
2511
+ let l = this, u = null;
2512
+ return u = new fr({
2513
+ kind: a,
2514
+ id: c ?? t + "-" + R.uuidV4(),
2515
+ part: o,
2516
+ tabColor: s,
2517
+ styles: this._styles,
2518
+ transactions: this._transactions,
2519
+ workbook: this,
2520
+ container: {
2521
+ getName: () => l._getSheetRef(u)?.name ?? t,
2522
+ setName: (e, t) => {
2523
+ l._setSheetName(u, e, t);
2524
+ },
2525
+ getVisibility: () => l._getSheetRef(u, k.Visibility.VeryHidden)?.visibility ?? k.Visibility.Visible,
2526
+ setVisibility: (e, t) => {
2527
+ l._setSheetVisibility(u, e, t);
2528
+ },
2529
+ getIndex: () => {
2530
+ let e = l._getSheetRef(u, k.Visibility.VeryHidden);
2531
+ return e ? l._getOffsetForId(e.id, l._getSheetRefs(k.Visibility.VeryHidden)) : -1;
2532
+ },
2533
+ setIndex: (e, t) => {
2534
+ let n = l._getSheetRef(u, k.Visibility.VeryHidden);
2535
+ n && l._moveSheet(n, e, t);
2536
+ },
2537
+ requestSelect: () => l._requestSelect(u),
2538
+ isAttached: () => !!l._getSheetRef(u, k.Visibility.VeryHidden)
2539
+ }
2540
+ }), this._sheetOnNameChange.set(e, () => u._notify("onNameChange")), this._sheetOnVisibilityChange.set(e, () => u._notify("onVisibilityChange")), this._sheetOnIndexChange.set(e, () => u._notify("onIndexChange")), this._addSheetRef({
2541
+ name: t,
2542
+ id: e,
2543
+ visibility: n ?? k.Visibility.Visible,
2544
+ sheetId: i,
2545
+ sheet: u
2546
+ }, r), u;
2547
+ }
2548
+ async _requestSelect(e) {
2549
+ return this._setSelectedSheet(e), await this._emitter.notify("onRequestSelect", {
2550
+ source: this,
2551
+ params: e,
2552
+ async: !0
2553
+ }), this.getSelectedSheet() === e;
2197
2554
  }
2198
2555
  _updateSheetRefStates(e) {
2199
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2200
- if (!this._initializing && !this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2556
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2557
+ if (!this._initializing && !this.getProtection().isStructureAllowed()) throw new U(G("error.workbook.protection"));
2201
2558
  let t = e, n = [], r = [], i = t.length;
2202
- for (let e = 0; e < i; e++) t[e].visibility === O.Visibility.Visible ? (n.push(t[e]), r.push(t[e])) : t[e].visibility === O.Visibility.Hidden && r.push(t[e]);
2559
+ for (let e = 0; e < i; e++) t[e].visibility === k.Visibility.Visible ? (n.push(t[e]), r.push(t[e])) : t[e].visibility === k.Visibility.Hidden && r.push(t[e]);
2203
2560
  this._updateState({
2204
2561
  sheetRefsAll: t,
2205
2562
  sheetRefsVisible: n,
2206
2563
  sheetRefsVisibleAndHidden: r
2207
2564
  });
2208
2565
  }
2566
+ _tellSheets() {
2567
+ if (this._isLoadingSheets) return;
2568
+ let e = this._getState().sheetRefsAll;
2569
+ this._calculation._setSheets(e.map((e) => Z(e) ? [e.sheet.getId(), e.name] : [
2570
+ e.sheet.getId(),
2571
+ e.name,
2572
+ !0
2573
+ ]));
2574
+ }
2209
2575
  _addSheetRef(e, t = null) {
2210
2576
  let n = this._getState(), r = n.sheetRefsAll, i = Math.max(0, Math.min(r.length, t ?? r.length)), a = [
2211
2577
  ...r.slice(0, i),
@@ -2230,9 +2596,9 @@ var En, Dn, $ = class e extends ge {
2230
2596
  p._validateDeleteSheet(e);
2231
2597
  },
2232
2598
  onDelete(e) {
2233
- let t = p._getSheetRef(e, O.Visibility.VeryHidden);
2599
+ let t = p._getSheetRef(e, k.Visibility.VeryHidden);
2234
2600
  if (!t) return;
2235
- let n = p._beginCommit({ description: H("op.deleteSheet", { name: t.name }) });
2601
+ let n = p._beginCommit({ description: G("op.deleteSheet", { name: t.name }) });
2236
2602
  try {
2237
2603
  let r = p._getState(), i = r.sheetRefsAll, a = p._getOffsetForId(t.id, i), s = [...i];
2238
2604
  s.splice(a, 1), p._updateSheetRefStates(s);
@@ -2247,7 +2613,7 @@ var En, Dn, $ = class e extends ge {
2247
2613
  let m = new Map(r.refsByInstance);
2248
2614
  m.delete(e), r.listenersSheets.get(t.id)();
2249
2615
  let h = new Map(r.listenersSheets);
2250
- h.delete(t.id), p._adjustRemoveSelectionIfRequired(a, t.id), p._adjustSheetNamesIfRequired(), p._sheetOnNameChange.delete(t.id), p._sheetOnVisibilityChange.delete(t.id), p._sheetOnIndexChange.delete(t.id), p._emitter.notify("onSheetsChange");
2616
+ h.delete(t.id), p._adjustRemoveSelectionIfRequired(a, t.id), p._adjustSheetNamesIfRequired(), p._sheetOnNameChange.delete(t.id), p._sheetOnVisibilityChange.delete(t.id), p._sheetOnIndexChange.delete(t.id), p._tellSheets(), p._emitter.notify("onSheetsChange");
2251
2617
  let g = new Set(r.sheetsCreated);
2252
2618
  g.has(o) && g.delete(o), p._updateState({
2253
2619
  refsById: c,
@@ -2262,14 +2628,14 @@ var En, Dn, $ = class e extends ge {
2262
2628
  throw n.rollback(), e;
2263
2629
  }
2264
2630
  }
2265
- }), r = o.addListeners({ onSelectionChange: (e) => {
2631
+ }, { transactional: !0 }), r = Z(e) ? e.sheet.addListeners({ onSelectionChange: (e) => {
2266
2632
  p.getView().getActiveSheetId() === p._getSheetRef(e)?.id && p._emitter.notify("onSelectionChange", {
2267
2633
  source: p,
2268
2634
  params: e
2269
2635
  });
2270
- } }, { transactional: !1 });
2636
+ } }, { transactional: !1 }) : null;
2271
2637
  m = new Map(n.listenersSheets), m.set(e.id, () => {
2272
- t(), r();
2638
+ t(), r?.();
2273
2639
  });
2274
2640
  }
2275
2641
  let h = n.lastId;
@@ -2282,7 +2648,27 @@ var En, Dn, $ = class e extends ge {
2282
2648
  listenersSheets: m
2283
2649
  }), this._adjustSheetNamesIfRequired();
2284
2650
  let g = new Set(this._getState().sheetsCreated);
2285
- return g.add(e.sheet), this._updateState({ sheetsCreated: g }), e;
2651
+ return g.add(e.sheet), this._updateState({ sheetsCreated: g }), this._tellSheets(), e;
2652
+ }
2653
+ _recordActiveSheet(e, t, n) {
2654
+ let r = this.getView().getId();
2655
+ e.setIntent(jr, (e) => ({
2656
+ viewId: r,
2657
+ before: e?.before ?? t,
2658
+ after: n
2659
+ }));
2660
+ }
2661
+ _resyncActiveSheet(e, t) {
2662
+ let n = t?.sheetRefsVisible;
2663
+ if (!n?.length) return;
2664
+ let r = -1, i = n.length;
2665
+ for (let t = 0; t < i; t++) if (n[t].id === e) {
2666
+ r = t;
2667
+ break;
2668
+ }
2669
+ r === -1 && (r = Math.min(Math.max(this._activeSheetOffset, 0), i - 1));
2670
+ let a = n[r].id;
2671
+ this._view.getActiveSheetId() === a ? this._activeSheetOffset = r : this._view.setActiveSheetId(a);
2286
2672
  }
2287
2673
  _adjustRemoveSelectionIfRequired(e, t) {
2288
2674
  if (this._view.getActiveSheetId() === t) {
@@ -2296,29 +2682,30 @@ var En, Dn, $ = class e extends ge {
2296
2682
  let n = this._view.getActiveSheetId();
2297
2683
  n ??= (this._view.setActiveSheetId(t), t);
2298
2684
  let r = e.refsById.get(n);
2299
- r || (this._view.setActiveSheetId(t), r = e.refsById.get(t), n = t), r.visibility === O.Visibility.Visible && (this._activeSheetOffset = this._getOffsetForId(n, e.sheetRefsVisible));
2685
+ r || (this._view.setActiveSheetId(t), r = e.refsById.get(t), n = t), r.visibility === k.Visibility.Visible && (this._activeSheetOffset = this._getOffsetForId(n, e.sheetRefsVisible));
2300
2686
  }
2301
2687
  _validateDeleteSheet(e) {
2302
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2303
- if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2688
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2689
+ if (!this.getProtection().isStructureAllowed()) throw new U(G("error.workbook.protection"));
2304
2690
  let t = this._getSheetRef(e);
2305
- if (!t) throw new R(function(e) {
2306
- return H("error.workbook.deleteKey", { key: e });
2691
+ if (!t) throw new B(function(e) {
2692
+ return G("error.workbook.deleteKey", { key: e });
2307
2693
  }(e));
2308
2694
  let n = this._getState().sheetRefsVisible;
2309
- if (n.length === 1 && n[0].id === t.id) throw new R(H("error.workbook.sheetOne"));
2695
+ if (n.length === 1 && n[0].id === t.id) throw new B(G("error.workbook.sheetOne"));
2310
2696
  }
2311
2697
  _getOffsetForId(e, t) {
2312
2698
  let n = t.length;
2313
2699
  for (let r = 0; r < n; r++) if (t[r].id === e) return r;
2314
- throw new R(H("error.workbook.noVisibleRefs"));
2700
+ throw new B(G("error.workbook.noVisibleRefs"));
2315
2701
  }
2316
2702
  find(e) {
2317
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2318
- let t = this._getSheets();
2703
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2704
+ let t = this._getWorksheets();
2705
+ if (t.length === 0) return { next: () => de };
2319
2706
  if (t.length === 1) return t[0].find(e);
2320
2707
  typeof e == "string" && (e = { text: e });
2321
- let n = !e?.reverse, r = e?.disableWrap ?? !1, i = this.getSelectedSheetIndex(), a = i, o = t[a], s = !1;
2708
+ let n = !e?.reverse, r = e?.disableWrap ?? !1, i = this._worksheetOffsetFrom(this.getSelectedSheetIndex(), t), a = i, o = t[a], s = !1;
2322
2709
  e = {
2323
2710
  ...e,
2324
2711
  disableWrap: !0
@@ -2331,7 +2718,7 @@ var En, Dn, $ = class e extends ge {
2331
2718
  rowIndex: t[0].rowStart
2332
2719
  };
2333
2720
  }
2334
- let f = L.createCellComparator(e?.axis, e?.reverse);
2721
+ let f = z.createCellComparator(e?.axis, e?.reverse);
2335
2722
  delete (e = { ...e }).from;
2336
2723
  let p = () => {
2337
2724
  if (!d && u.done && (s && a === i ? d = !0 : n ? (a++, a > t.length - 1 && (a = 0, s = !0)) : (a--, a < 0 && (a = t.length - 1, s = !0)), r && s && (d = !0), d || c || !s || a !== i || (d = !0), !d)) {
@@ -2341,7 +2728,7 @@ var En, Dn, $ = class e extends ge {
2341
2728
  }
2342
2729
  if (!d && s && a === i && (u.done || !c || !u.done && f(u.value.getCoords(), c) >= 0) && (d = !0), d) {
2343
2730
  let e = u;
2344
- return u = Ce, e;
2731
+ return u = de, e;
2345
2732
  }
2346
2733
  let p = u;
2347
2734
  return u = l.next(), p;
@@ -2353,11 +2740,11 @@ var En, Dn, $ = class e extends ge {
2353
2740
  } };
2354
2741
  }
2355
2742
  replace(e, t, n) {
2356
- let r = 0, i = null, a = typeof t == "function", o = n?.maxCount ?? 2 ** 53 - 1, s = !n?.maxCount, c = "", l = typeof t == "string" ? me(t) : null, u = n?.description ?? V("op.replace"), d = this._transactions.beginCommit({ description: u });
2743
+ let r = 0, i = null, a = typeof t == "function", o = n?.maxCount ?? 2 ** 53 - 1, s = !n?.maxCount, c = "", l = typeof t == "string" ? ee(t) : null, u = n?.description ?? W("op.replace"), d = this._transactions.beginCommit({ description: u });
2357
2744
  try {
2358
2745
  let u = null, f = null, p = e.next();
2359
2746
  for (; !p.done && r < o;) {
2360
- let o = p.value, s = o.getSheet();
2747
+ let o = p.value, s = o.getWorksheet();
2361
2748
  s !== u && (u = s, f !== null && f.apply(), f = u.getEntireRange().createSparseBuilder({
2362
2749
  axis: n?.axis,
2363
2750
  allowUnorderedWrites: !0
@@ -2365,13 +2752,10 @@ var En, Dn, $ = class e extends ge {
2365
2752
  let c = a ? t(o) : t;
2366
2753
  c !== void 0 && c !== o && (f.push(o, c), r++, i = o), p = e.next();
2367
2754
  }
2368
- f?.apply(), r === 1 && o === 1 && i && (c = i.getAddress()), r === 0 ? d.rollback() : d.commit({
2369
- description: n?.description ?? (s ? l === null ? V("op.replaceAll") : H("op.replaceAllWith", { value: l }) : c ? l === null ? H("op.replaceAt", { address: c }) : H("op.replaceAtWith", {
2370
- address: c,
2371
- value: l
2372
- }) : l === null ? V("op.replace") : H("op.replaceWith", { value: l })),
2373
- viewAfter: { selection: null }
2374
- });
2755
+ f?.apply(), r === 1 && o === 1 && i && (c = i.getAddress()), r === 0 ? d.rollback() : d.commit({ description: n?.description ?? (s ? l === null ? W("op.replaceAll") : G("op.replaceAllWith", { value: l }) : c ? l === null ? G("op.replaceAt", { address: c }) : G("op.replaceAtWith", {
2756
+ address: c,
2757
+ value: l
2758
+ }) : l === null ? W("op.replace") : G("op.replaceWith", { value: l })) });
2375
2759
  } catch (e) {
2376
2760
  throw d.rollback(), e;
2377
2761
  }
@@ -2388,91 +2772,119 @@ var En, Dn, $ = class e extends ge {
2388
2772
  let n = t.length;
2389
2773
  return n === 1 ? 0 : (e === void 0 && (e = this.getSelectedSheetIndex()), (e = Math.max(0, Math.min(e, n - 1))) <= 0 ? n - 1 : e - 1);
2390
2774
  }
2775
+ _worksheetOffsetFrom(e, t) {
2776
+ let n = this._getSheetRefs(), r = n.length;
2777
+ for (let i = 0; i < r; i++) {
2778
+ let a = n[(e + i) % r];
2779
+ if (!Z(a)) continue;
2780
+ let o = t.indexOf(a.sheet);
2781
+ if (o !== -1) return o;
2782
+ }
2783
+ return 0;
2784
+ }
2391
2785
  getNextSheet(e) {
2392
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2786
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2393
2787
  let t = this._getSheetRefs();
2394
2788
  return t[this._nextSheetIndex(e, t)]?.sheet ?? null;
2395
2789
  }
2396
2790
  getPreviousSheet(e) {
2397
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2791
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2398
2792
  let t = this._getSheetRefs();
2399
2793
  return t[this._prevSheetIndex(e, t)]?.sheet ?? null;
2400
2794
  }
2401
2795
  async _duplicateSheet(e) {
2402
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2403
- if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2796
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2797
+ if (!this.getProtection().isStructureAllowed()) throw new U(G("error.workbook.protection"));
2404
2798
  let t = this._getSheetRefs(), n = this.getSelectedSheetIndex(), r = null;
2405
2799
  if (e) {
2406
- if (r = this._getSheetRef(e), !r) throw new R(yn(r));
2800
+ if (r = this._getSheetRef(e), !r) throw new B(br(r));
2407
2801
  } else r = t[n];
2408
2802
  if (!r) return null;
2409
- let i = r.sheet, a = this._strings.beginPersist(), o = this.getResources().beginPersist(), s = this.getStyles().beginPersist(), c = null, l = this.beginCommit(H("op.duplicateNamed", { name: i.getName() }));
2803
+ if (!Z(r)) throw new B((i = r.name, G("error.workbook.sheetNotDuplicable", { sheetName: i })));
2804
+ var i;
2805
+ let a = r.sheet, o = this._strings.beginPersist(), s = this.getResources().beginPersist(), c = this.getStyles().beginPersist(), l = null, u = this.beginCommit(G("op.duplicateNamed", { name: a.getName() }));
2410
2806
  try {
2411
- let e = this._getState().refsByInstance.get(i), r = await i.toJSON(), a = t.length + 1, o = this.findValidSheetName(e.name), s = this._createSheet(a, o, e.visibility, n, r);
2412
- this._emitter.notify("onSheetsChange"), c = s, l.commit();
2807
+ let e = this._getState().refsByInstance.get(a), r = await a.toJSON(), i = t.length + 1, o = this.findValidSheetName(e.name), s = this._createSheet(i, o, e.visibility, n, void 0, r);
2808
+ this._tellSheets(), this._emitter.notify("onSheetsChange"), l = s, u.commit();
2413
2809
  } catch (e) {
2414
- throw l.rollback(), e;
2810
+ throw u.rollback(), e;
2415
2811
  } finally {
2416
- s.endPersist(), o.endPersist(), a.endPersist();
2812
+ c.endPersist(), s.endPersist(), o.endPersist();
2417
2813
  }
2418
- return c;
2814
+ return l;
2419
2815
  }
2420
2816
  _createRange(e, t) {
2421
- let n = e ? { ...e } : null, r = n ? this._getSheetRef(n.scope, O.Visibility.VeryHidden) : null;
2817
+ let n = e ? { ...e } : null, r = n ? this._getSheetRef(n.scope, k.Visibility.VeryHidden) : null;
2818
+ if (r && !Z(r)) throw new B(Sr(r.name, r.sheet.getKind()));
2422
2819
  if (!r) {
2423
- let e = this.getSelectedSheet();
2424
- return e ? (delete n?.scope, wn(n, n ? {
2425
- scope: h,
2820
+ let e = this._anchorWorksheet();
2821
+ return e ? (delete n?.scope, Or(n, n ? {
2822
+ scope: g,
2426
2823
  ...e.getEntireRange().getCoords()
2427
- } : null)) : void console.warn(H("error.workbook.noVisibleRefs"));
2824
+ } : null)) : void console.warn(G("error.workbook.noVisibleRefs"));
2428
2825
  }
2429
2826
  let i = r.sheet, a = null;
2430
- return t && (a = { getOptions: t }), new On(e, D(i), this, a);
2827
+ return t && (a = { getOptions: t }), new Nr(e, j(i), this, a);
2431
2828
  }
2432
2829
  _createRanges(e, t) {
2433
- let n = this.getSelectedSheet(), r = null;
2434
- return t && (r = { getOptions: t }), new $(e, D(n), this, r);
2830
+ let n = this._anchorWorksheet();
2831
+ if (!n) throw new B(Cr("", k.Kind.Worksheet));
2832
+ let r = null;
2833
+ return t && (r = { getOptions: t }), new Mr(e, j(n), this, r);
2435
2834
  }
2436
2835
  getRange(e, t) {
2437
2836
  if (e === void 0) return this.getSelectedRange(t);
2438
2837
  try {
2439
2838
  let n = this._rangesAddressToCoords(e);
2440
- if (n.length !== 1) throw new R(H("error.address.singleRangeOnlyAlt"));
2839
+ if (n.length !== 1) throw new B(G("error.address.singleRangeOnlyAlt"));
2441
2840
  return this._createRange(n[0], t);
2442
2841
  } catch (t) {
2443
- throw t instanceof B ? new B(t.message) : new R(t.message ?? o(e));
2842
+ throw t instanceof H ? new H(t.message) : new B(t.message ?? d(e));
2444
2843
  }
2445
2844
  }
2446
2845
  getCell(e) {
2447
2846
  if (e === void 0) return this.getSelectedCell();
2448
2847
  let t = this.getRange(e);
2449
- if (t.size > 1) throw new R(H("error.address.singleCellOnly"));
2848
+ if (t.size > 1) throw new B(G("error.address.singleCellOnly"));
2450
2849
  return t.getCell();
2451
2850
  }
2452
2851
  getRanges(e, t) {
2453
2852
  let n = this._rangesAddressToCoords(e);
2454
- if (n.length === 0) throw new R(o(e));
2853
+ if (n.length === 0) throw new B(d(e));
2455
2854
  return this._createRanges(n, t);
2456
2855
  }
2457
2856
  _createGraphRanges(e, t) {
2458
- let n = [];
2857
+ let n = [], r = this.getCalculation()?.getNamedFormulas() ?? null;
2459
2858
  for (let e = 0; e < t.length; e++) {
2460
- let r = t[e], i = (r.sheetName ? this._getSheetRef(r.sheetName, O.Visibility.VeryHidden) : null)?.sheet ?? this.getSelectedSheet();
2461
- i && n.push(new je(r, D(i), null));
2859
+ let i = t[e], a = i.sheetName ? this._getSheetRef(i.sheetName, k.Visibility.VeryHidden) : null, o = a && Z(a) ? a.sheet : this._anchorWorksheet();
2860
+ o && n.push(new Be(i, r, j(o), null));
2462
2861
  }
2463
2862
  for (let t = 0; t < e.length; t++) n.push(e[t]);
2464
- return n.length === 0 ? null : new $(n, D(this.getSelectedSheet()), this, null);
2863
+ let i = this._anchorWorksheet();
2864
+ return n.length !== 0 && i ? new Mr(n, j(i), this, null) : null;
2865
+ }
2866
+ getAnomalies(e) {
2867
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2868
+ let t = He(e), n = this._getWorksheets(k.Visibility.VeryHidden).map((e) => {
2869
+ let t = j(e);
2870
+ return {
2871
+ bounds: t.getSheet().getEntireCoords(),
2872
+ internal: t,
2873
+ qualified: !0
2874
+ };
2875
+ });
2876
+ return new wt(n, () => (this.getSelectedWorksheet() ?? this._getWorksheets(k.Visibility.VeryHidden)[0]).getEntireRange(), t);
2465
2877
  }
2466
2878
  getStats(e) {
2467
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2468
- let t = this._getSheets(O.Visibility.VeryHidden), n = t.length;
2879
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2880
+ let t = this._getWorksheets(k.Visibility.VeryHidden), n = t.length;
2469
2881
  if (n === 1) return t[0].getStats(e);
2470
2882
  let r = Array(n);
2471
2883
  for (let i = 0; i < n; i++) r[i] = t[i].getStats(e);
2472
- return new on(r);
2884
+ return new er(r);
2473
2885
  }
2474
2886
  _activeRangeCoords() {
2475
- let e = this.getSelectedSheet(), t = e.getSelection().getRanges().getCoords(), n = e.getName(), r = t.length, i = Array(r);
2887
+ let e = this._requireSelectedWorksheet(), t = e.getSelection().getRanges().getCoords(), n = e.getName(), r = t.length, i = Array(r);
2476
2888
  for (let e = 0; e < r; e++) {
2477
2889
  let r = t[e];
2478
2890
  i[e] = {
@@ -2492,34 +2904,42 @@ var En, Dn, $ = class e extends ge {
2492
2904
  return this.getRanges(this._activeRangeCoords(), e);
2493
2905
  }
2494
2906
  getSelectedCell() {
2495
- return this.getSelectedSheet().getSelectedCell();
2907
+ return this._requireSelectedWorksheet().getSelectedCell();
2496
2908
  }
2497
- _rangesAddressToCoords(e, n = !0, r = O.Visibility.Hidden) {
2498
- if (!e) throw new R(H("error.address.noAddress"));
2499
- let i = this.getSelectedSheet(), a = { ...i?.getEntireRange().getCoords() }, o = i?.getName();
2500
- if (o && (a.scope = o), typeof e == "string") {
2909
+ _rangesAddressToCoords(e, t = !0, n = k.Visibility.Hidden) {
2910
+ if (!e) throw new B(G("error.address.noAddress"));
2911
+ let r = this.getSelectedWorksheet(), i = { ...(r ?? this._anchorWorksheet())?.getEntireRange().getCoords() }, o = r?.getName();
2912
+ if (o && (i.scope = o), typeof e == "string") {
2501
2913
  let t = e.trim().toLowerCase();
2502
2914
  if (t === "r" || t === "c") {
2503
2915
  let n = this.getSelectedCell().getCoords(), r = {};
2504
2916
  t === "r" ? r.rowStart = r.rowEnd = n.rowIndex : r.colStart = r.colEnd = n.colIndex, e = r;
2505
2917
  }
2506
2918
  }
2507
- let s = this, c = le(e, a, t, (e) => {
2508
- if (!n) return null;
2919
+ let s = this, c = gt(e, i, ue, (e) => {
2920
+ if (!t) return null;
2509
2921
  if (typeof e == "string") {
2510
- let t = s.getNames().getByName(e)?.getRanges?.();
2511
- if (t) return t.getCoords();
2922
+ let t = a(e, {
2923
+ getTable: (e) => at(s.getNames().getByName(e)),
2924
+ getAnchor: () => r ? {
2925
+ sheet: r,
2926
+ coords: r.getSelectedCell().getCoords()
2927
+ } : null
2928
+ });
2929
+ if (t) return [t];
2930
+ let n = s.getNames().getByName(e)?.getRanges?.();
2931
+ if (n) return n.getCoords();
2512
2932
  }
2513
- throw new R(`Invalid sheet reference '${e}'.`);
2933
+ throw new B(`Invalid sheet reference '${e}'.`);
2514
2934
  }), l = c.length;
2515
- for (let e = 0; e < l; e++) this._validateCoords(c[e], r);
2935
+ for (let e = 0; e < l; e++) this._validateCoords(c[e], n);
2516
2936
  return c;
2517
2937
  }
2518
- _validateCoords(e, t = O.Visibility.Visible, n = H("error.sheet.oobRange")) {
2938
+ _validateCoords(e, t = k.Visibility.Visible, n = G("error.sheet.oobRange")) {
2519
2939
  if (e === null) return;
2520
- let r = this.getSheet(e.scope, t).getEntireRange().getCoords();
2521
- if (!L.isRangeWithinRange(e, r)) throw new B(n);
2522
- if (e.rowEnd < e.rowStart || e.colEnd < e.colStart) throw new R(H("error.address.invalidRangeInverted"));
2940
+ let r = this.getWorksheet(e.scope ?? void 0, t).getEntireRange().getCoords();
2941
+ if (!z.isRangeWithinRange(e, r)) throw new H(n);
2942
+ if (e.rowEnd < e.rowStart || e.colEnd < e.colStart) throw new B(G("error.address.invalidRangeInverted"));
2523
2943
  }
2524
2944
  _updateSheetRef(e, t) {
2525
2945
  let n = this._getState(), r = [...n.sheetRefsAll];
@@ -2536,19 +2956,19 @@ var En, Dn, $ = class e extends ge {
2536
2956
  refsByLowerCaseName: s,
2537
2957
  sheetsByLowerCaseName: c,
2538
2958
  refsByInstance: u
2539
- }), t;
2959
+ }), this._tellSheets(), t;
2540
2960
  }
2541
2961
  _setSheetName(e, t, n) {
2542
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2543
- if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2962
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2963
+ if (!this.getProtection().isStructureAllowed()) throw new U(G("error.workbook.protection"));
2544
2964
  let r = this._getSheetRef(e);
2545
- if (!r) throw new R(yn(e));
2965
+ if (!r) throw new B(br(e));
2546
2966
  if (t === r.name) return r.sheet;
2547
- if ((t = this._validateNewSheetName(t)) == null) throw new R(H("error.workbook.sheetNameNotProvided"));
2967
+ if ((t = this._validateNewSheetName(t)) == null) throw new B(G("error.workbook.sheetNameNotProvided"));
2548
2968
  let i = Object.freeze({
2549
2969
  ...r,
2550
2970
  name: t
2551
- }), a = null, o = this.beginCommit(V("op.renameSheet"));
2971
+ }), a = null, o = this.beginCommit(W("op.renameSheet"));
2552
2972
  try {
2553
2973
  let e = this._updateSheetRef(r, i);
2554
2974
  this._adjustSheetNamesIfRequired(), this._sheetOnNameChange.forEach((e, t) => {
@@ -2559,23 +2979,23 @@ var En, Dn, $ = class e extends ge {
2559
2979
  }
2560
2980
  return a;
2561
2981
  }
2562
- _setSheetVisibility(e, t = O.Visibility.Visible, n) {
2563
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2564
- if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2565
- let r = this._getSheetRef(e, O.Visibility.VeryHidden);
2982
+ _setSheetVisibility(e, t = k.Visibility.Visible, n) {
2983
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2984
+ if (!this.getProtection().isStructureAllowed()) throw new U(G("error.workbook.protection"));
2985
+ let r = this._getSheetRef(e, k.Visibility.VeryHidden);
2566
2986
  if (!r) return null;
2567
2987
  if (t === r.visibility) return;
2568
2988
  let i = null, a = "";
2569
- t === O.Visibility.Visible ? a = V("op.unhideSheet") : t === O.Visibility.Hidden ? a = V("op.hideSheet") : t === O.Visibility.VeryHidden && (a = V("op.veryHideSheet"));
2989
+ t === k.Visibility.Visible ? a = W("op.unhideSheet") : t === k.Visibility.Hidden ? a = W("op.hideSheet") : t === k.Visibility.VeryHidden && (a = W("op.veryHideSheet"));
2570
2990
  let o = this.beginCommit(a);
2571
2991
  try {
2572
2992
  let e = this._getState().sheetRefsVisible;
2573
- if (t !== O.Visibility.Visible && e.length === 1 && e[0].id === r.id) throw new R(H("error.workbook.sheetOne"));
2993
+ if (t !== k.Visibility.Visible && e.length === 1 && e[0].id === r.id) throw new B(G("error.workbook.sheetOne"));
2574
2994
  let a = {
2575
2995
  ...r,
2576
2996
  visibility: t
2577
2997
  }, s = -1;
2578
- t !== O.Visibility.Visible && (s = this._getOffsetForId(r.id, e)), i = this._updateSheetRef(r, a).sheet, t !== O.Visibility.Visible && this._adjustRemoveSelectionIfRequired(s, r.id), this._adjustSheetNamesIfRequired(), o.commit(n);
2998
+ t !== k.Visibility.Visible && (s = this._getOffsetForId(r.id, e)), i = this._updateSheetRef(r, a).sheet, t !== k.Visibility.Visible && this._adjustRemoveSelectionIfRequired(s, r.id), this._adjustSheetNamesIfRequired(), o.commit(n);
2579
2999
  } catch (e) {
2580
3000
  throw o.rollback(), e;
2581
3001
  }
@@ -2584,61 +3004,70 @@ var En, Dn, $ = class e extends ge {
2584
3004
  }), this._emitter.notify("onSheetsChange"), i;
2585
3005
  }
2586
3006
  _moveSheet(e, t, n) {
2587
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2588
- if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2589
- let r = null, i = this.beginCommit(H("op.moveSheetNamed", { name: e.name }));
3007
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
3008
+ if (!this.getProtection().isStructureAllowed()) throw new U(G("error.workbook.protection"));
3009
+ let r = null, i = this.beginCommit(G("op.moveSheetNamed", { name: e.name }));
2590
3010
  try {
2591
3011
  let a = this._getState(), o = a.sheetRefsVisible;
2592
- if (t < 0 || t > o.length - 1) throw new R(`Invalid to index: ${t}`);
2593
- let s = {
2594
- view: this.getView(),
2595
- activeSheetId: this.getView().getActiveSheetId()
2596
- }, c = a.sheetRefsAll, l = this._getOffsetForId(e.id, c), u = this._getOffsetForId(o[t].id, c);
3012
+ if (t < 0 || t > o.length - 1) throw new B(`Invalid to index: ${t}`);
3013
+ let s = this.getView().getActiveSheetId(), c = a.sheetRefsAll, l = this._getOffsetForId(e.id, c), u = this._getOffsetForId(o[t].id, c);
2597
3014
  if (l === u) return;
2598
3015
  let d = c[l], f = [...c];
2599
- f.splice(l, 1), f.splice(u, 0, d), this._updateSheetRefStates(f), this._adjustSheetNamesIfRequired(), this._sheetOnIndexChange.forEach((e, t) => {
3016
+ f.splice(l, 1), f.splice(u, 0, d), this._updateSheetRefStates(f), this._calculation._replaceSheetSpans?.(c.map((e) => e.sheet.getId()), f.map((e) => e.sheet.getId()), d.sheet.getId()), this._adjustSheetNamesIfRequired(), this._sheetOnIndexChange.forEach((e, t) => {
2600
3017
  t >= l && t <= u && e();
2601
- }), this._emitter.notify("onSheetsChange"), r = d.sheet, i.commit({
2602
- ...n,
2603
- viewBefore: s,
2604
- viewAfter: {
2605
- view: this.getView(),
2606
- activeSheetId: this.getView().getActiveSheetId()
2607
- }
2608
- });
3018
+ }), this._tellSheets(), this._emitter.notify("onSheetsChange"), r = d.sheet, this._recordActiveSheet(i, s, this.getView().getActiveSheetId()), i.commit(n);
2609
3019
  } catch (e) {
2610
3020
  throw i.rollback(), e;
2611
3021
  }
2612
3022
  return r;
2613
3023
  }
2614
3024
  _setSelectedSheet(e) {
2615
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
3025
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2616
3026
  let t = this._getSheetRef(e);
2617
- if (!t) throw new R(yn(e));
3027
+ if (!t) throw new B(br(e));
2618
3028
  let n = null;
2619
- return t.visibility !== O.Visibility.Visible && this._setSheetVisibility(t, O.Visibility.Visible), this._view.setActiveSheetId(t.id), n = t.sheet, n;
3029
+ return t.visibility !== k.Visibility.Visible && this._setSheetVisibility(t, k.Visibility.Visible), this._view.setActiveSheetId(t.id), n = t.sheet, n;
2620
3030
  }
2621
3031
  getProtection() {
2622
3032
  return this._protection;
2623
3033
  }
3034
+ getProperties() {
3035
+ return this._documentProperties;
3036
+ }
3037
+ getCodeName() {
3038
+ return this._codeName;
3039
+ }
2624
3040
  getNames() {
2625
3041
  return this._names;
2626
3042
  }
2627
3043
  getCalculation() {
2628
3044
  return this._calculation;
2629
3045
  }
2630
- createFormula(e, t) {
2631
- return this.getCalculation().createFormula(e, t);
3046
+ getFonts() {
3047
+ return Ct.getShared();
3048
+ }
3049
+ createFormula(e, t, n) {
3050
+ return this.getCalculation().createFormula(e, t, n);
2632
3051
  }
2633
3052
  evaluate(e, t) {
2634
3053
  return this.getCalculation().evaluate(e, t);
2635
3054
  }
2636
- whenCalculationReady() {
2637
- return this.getCalculation().ready();
3055
+ async whenCalculationReady() {
3056
+ let e = this._starting;
3057
+ return e ? e.then(() => this.getCalculation().ready()) : this.getCalculation().ready();
3058
+ }
3059
+ whenFontsReady() {
3060
+ return this.getFonts().whenReady();
3061
+ }
3062
+ async whenReady() {
3063
+ await Promise.all([this.whenCalculationReady(), this.whenFontsReady()]);
2638
3064
  }
2639
3065
  getScripts() {
2640
3066
  return this._scripts ||= this._createScripts(), this._scripts;
2641
3067
  }
3068
+ getModules() {
3069
+ return this.getScripts().getModules();
3070
+ }
2642
3071
  _notifyAllChange() {
2643
3072
  this._emitter.notify("onSheetsChange"), this._emitter.notify("onSelectedSheetChange"), this._emitter.notify("onViewChange");
2644
3073
  }
@@ -2650,19 +3079,20 @@ var En, Dn, $ = class e extends ge {
2650
3079
  return (n) => {
2651
3080
  let r = () => {
2652
3081
  let e = n.getSource();
3082
+ if (e.isInvalid()) return e;
2653
3083
  if (e.isICellRanges) {
2654
3084
  let n = [...e.getCoords()], r = n.length;
2655
3085
  for (let t = 0; t < r; t++) {
2656
3086
  let r = n[t];
2657
- !r.scope && e.getSheet().getName() && (n[t] = {
3087
+ !r.scope && e.getWorksheet().getName() && (n[t] = {
2658
3088
  ...r,
2659
- scope: e.getSheet().getName()
3089
+ scope: e.getWorksheet().getName()
2660
3090
  });
2661
3091
  }
2662
3092
  return t.getRanges(n);
2663
3093
  }
2664
3094
  if (e.isICellRange) {
2665
- let n = e.getCoords(), r = e.getSheet().getName();
3095
+ let n = e.getCoords(), r = e.getWorksheet().getName();
2666
3096
  return t.getRange({
2667
3097
  ...n,
2668
3098
  scope: r
@@ -2673,7 +3103,6 @@ var En, Dn, $ = class e extends ge {
2673
3103
  getSource: r,
2674
3104
  trigger: n.trigger,
2675
3105
  getFrom: () => t.getRanges(n.getFrom()),
2676
- getTo: () => t.getRange(n.getTo()),
2677
3106
  isDataChange: n.isDataChange,
2678
3107
  getTransactionId: n.getTransactionId,
2679
3108
  isUndo: n.isUndo,
@@ -2682,45 +3111,77 @@ var En, Dn, $ = class e extends ge {
2682
3111
  });
2683
3112
  };
2684
3113
  }
2685
- _fromJSON(e) {
2686
- if (this._emitter.notify("onBeforeLoad", { params: e }), this._initState(), !e.sheets || e.sheets.length === 0) throw new R(H("error.workbook.sheetOne"));
2687
- e.theme && (this._theme = new m(e.theme), this._styles.setTheme(this._theme));
2688
- let t = this._strings.beginPersist(), n = this._resources.beginPersist(), r = this._styles.beginPersist();
3114
+ _holdPivotCaches() {
3115
+ let e = this._pivotCaches;
3116
+ if (e.length === 0) return;
3117
+ let t = (e) => {
3118
+ let t = this._getSheetRef(e), n = t && Z(t) ? t.sheet : null;
3119
+ return n ? n._contentAddWatch(() => null) : null;
3120
+ };
3121
+ for (let n = 0; n < e.length; n++) e[n]._hold(t);
3122
+ }
3123
+ _fromJSON(e, t) {
3124
+ if (this._emitter.notify("onBeforeLoad", { params: e }), this._initState(), !e.sheets || e.sheets.length === 0) throw new B(G("error.workbook.sheetOne"));
3125
+ e.theme && (this._theme = new re(e.theme), this._styles.setTheme(this._theme));
3126
+ let n = this._strings.beginPersist(), r = this._resources.beginPersist(), i = this._styles.beginPersist();
2689
3127
  try {
2690
- t.fromJSON(e.strings), n.fromJSON(e.resources), r.fromJSON(e.styles), e.date1904 && (this._isDate1904 = !0), e.locale && (this._locale = e.locale), e.localeOverrides && (this._localeOverrides = e.localeOverrides), e.view ||= {};
2691
- let i = e.sheets, a = i.length, o = e.view.activeSheetId ?? null;
2692
- o !== null && (o = Math.min(Math.max(0, o), a - 1));
2693
- let s = null, c = null, l = -1;
2694
- for (let e = 0; e < a; e++) {
2695
- let t = i[e], n = t.visibility || O.Visibility.Visible, r = e;
2696
- c = r, n === O.Visibility.Visible ? (l++, s === null && (s = r)) : o !== null && o === r && (o = null), this._createSheet(r, t.name, n, l, t.sheet);
3128
+ n.fromJSON(e.strings), r.fromJSON(e.resources), i.fromJSON(e.styles), e.date1904 && (this._isDate1904 = !0), this._codeName = e.codeName ?? null, this._updateLinks = e.updateLinks ?? null, this._documentProperties.fromJSON(e.properties), e.locale && (this._locale = e.locale), e.localeOverrides && (this._localeOverrides = e.localeOverrides), e.view ||= {};
3129
+ let a = [], o = e.pivotCaches;
3130
+ if (o) {
3131
+ let e = r.fromResourceId.bind(r);
3132
+ for (let t = 0; t < o.length; t++) {
3133
+ let n = o[t];
3134
+ n && typeof n.cacheId == "number" && a.push(new ir(n.cacheId, w.fromJSON(n.part, e)));
3135
+ }
2697
3136
  }
2698
- this._updateState({ lastId: c }), e.view.activeSheetId = o ?? s, this.setView(new Q({ json: e.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
2699
- let u = this;
2700
- this._protection = new vn(e?.protection, this._options?.readonly), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
2701
- u._emitter.notify("onProtectionChange", { source: e });
2702
- } }), e.scripts && (this._scripts = this._createScripts(e.scripts)), this._emitter.notify("onLoad");
3137
+ this._pivotCaches = a, this._people.fromJSON(e.people);
3138
+ let s = e.sheets, c = s.length, l = e.view.activeSheetId ?? null;
3139
+ l !== null && (l = Math.min(Math.max(0, l), c - 1));
3140
+ let u = null, d = null;
3141
+ this._isLoadingSheets = !0;
3142
+ for (let e = 0; e < c; e++) {
3143
+ let n = s[e], i = n.visibility || k.Visibility.Visible, a = e;
3144
+ d = a, i === k.Visibility.Visible ? u === null && (u = a) : l !== null && l === a && (l = null);
3145
+ try {
3146
+ let o = n.kind ?? k.Kind.Worksheet;
3147
+ if (o !== k.Kind.Worksheet) {
3148
+ let s = n.sheet, c = w.fromJSON(s?.part, r.fromResourceId.bind(r));
3149
+ if (!c) throw new B(G("error.workbook.sheetPartMissing", { sheetName: n.name }));
3150
+ this._createOpaqueSheet(a, n.name, i, e, n.sheetId, o, c, s?.tabColor ?? null, t?.[e]);
3151
+ } else this._createSheet(a, n.name, i, e, n.sheetId, n.sheet, t?.[e]);
3152
+ } catch (e) {
3153
+ throw this._isLoadingSheets = !1, e;
3154
+ }
3155
+ }
3156
+ this._isLoadingSheets = !1, this._tellSheets(), this._holdPivotCaches(), this._updateState({ lastId: d }), e.view.activeSheetId = l ?? u, this.setView(new mr({ json: e.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
3157
+ let f = this;
3158
+ this._protection = new gr(e?.protection, this._options?.readonly), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
3159
+ f._emitter.notify("onProtectionChange", { source: e });
3160
+ } }), this._emitter.notify("onLoad");
2703
3161
  } finally {
2704
- r.endPersist(), n.endPersist(), t.endPersist();
3162
+ i.endPersist(), r.endPersist(), n.endPersist();
2705
3163
  }
2706
3164
  }
2707
3165
  _createScripts(e) {
2708
3166
  let t = this;
2709
- return new pn({
3167
+ return new cr({
2710
3168
  transactions: this._transactions,
2711
3169
  json: e,
2712
3170
  workbook: t,
2713
3171
  getBuiltInFunctions: () => t._calculation?.getFunctions(),
2714
3172
  onAdd: (e, n) => {
2715
3173
  let r = t._calculation;
2716
- r.getStatus() !== Ye.Status.Off && r.start().then(async () => {
2717
- let e = n.getFunctions().getItems({ type: "formula" }), t = e.length;
3174
+ r.getStatus() !== E.Status.Off && r.start().then(async () => {
3175
+ let e = n.getFunctions().getItems({
3176
+ type: "formula",
3177
+ includeHidden: !0
3178
+ }), t = e.length;
2718
3179
  for (let n = 0; n < t; n++) {
2719
3180
  let t = e[n];
2720
3181
  try {
2721
3182
  await this._calculation.getFunctions().add(t);
2722
3183
  } catch (e) {
2723
- z.error(e?.message ?? String(e), e);
3184
+ V.error(e?.message ?? String(e), e);
2724
3185
  }
2725
3186
  }
2726
3187
  }).catch(() => {});
@@ -2729,51 +3190,74 @@ var En, Dn, $ = class e extends ge {
2729
3190
  });
2730
3191
  }
2731
3192
  async toJSON(e) {
2732
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
2733
- await Promise.resolve(this._starting), await this._emitter.notify("onBeforeSave", { async: !0 });
2734
- let t = { sheets: [] }, n = e?.ignoreStyles ?? !1;
2735
- if (!n) {
3193
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
3194
+ await Promise.resolve(this._starting);
3195
+ let t = this.getCalculation();
3196
+ t.getStatus() !== E.Status.Off && (await t.ready(), await t._whenRequestsSettled?.()), await this._emitter.notify("onBeforeSave", { async: !0 });
3197
+ let n = { sheets: [] }, r = e?.ignoreStyles ?? !1;
3198
+ if (!r) {
2736
3199
  let e = this._theme.toJSON();
2737
- (e ? Object.keys(e).length : 0) > 0 && (t.theme = e);
3200
+ (e ? Object.keys(e).length : 0) > 0 && (n.theme = e);
2738
3201
  }
2739
3202
  if (this._scripts) {
2740
3203
  let e = this._scripts.toJSON();
2741
- e && Object.keys(e).length > 0 && (t.scripts = e);
3204
+ e && Object.keys(e).length > 0 && (n.modules = e);
2742
3205
  }
2743
- this._isDate1904 && (t.date1904 = !0), this._locale && (t.locale = this._locale), this._localeOverrides && (t.localeOverrides = this._localeOverrides);
2744
- let r = e?.ignoreResources ?? !1, i = this._strings.beginPersist(), a = r ? null : this._resources.beginPersist(), o = this._styles.beginPersist();
3206
+ this._isDate1904 && (n.date1904 = !0), this._codeName && (n.codeName = this._codeName), this._updateLinks && (n.updateLinks = this._updateLinks);
3207
+ let i = this._documentProperties.toJSON();
3208
+ Object.keys(i).length > 0 && (n.properties = i), this._locale && (n.locale = this._locale), this._localeOverrides && (n.localeOverrides = this._localeOverrides);
3209
+ let a = e?.resources ?? "embed", o = a === "ignore", s = this._strings.beginPersist(), c = o ? null : this._resources.beginPersist(), l = this._styles.beginPersist();
2745
3210
  try {
2746
- let s = this._getSheetRef(this.getSelectedSheetIndex()).id, c = s, l = null, u = this._getState(), d = u.sheetRefsAll, f = u.sheetsById, p = d.length;
2747
- for (let n = 0; n < p; n++) {
2748
- let r = d[n], i = n + 1, a = await f.get(r.id).toJSON(e), o = {
2749
- name: r.name,
2750
- sheet: a
3211
+ let t = this._getSheetRef(this.getSelectedSheetIndex()).id, i = t, u = null, d = this._getState(), f = d.sheetRefsAll, p = d.sheetsById, m = f.length;
3212
+ for (let r = 0; r < m; r++) {
3213
+ let a = f[r], o = r + 1, s, l = p.get(a.id);
3214
+ if (Z(a)) s = {
3215
+ name: a.name,
3216
+ sheet: await a.sheet.toJSON(e)
2751
3217
  };
2752
- r.visibility === O.Visibility.Visible ? l === null && (l = i) : o.visibility = r.visibility, r.id === s && (c = i), t.sheets.push(o);
3218
+ else {
3219
+ let e = l, t = c ? c.toResourceId.bind(c) : () => null, n = { part: w.toJSON(e._getPart(), t) }, r = e.getTabColor();
3220
+ r && (n.tabColor = r.toString()), s = {
3221
+ name: a.name,
3222
+ kind: e.getKind(),
3223
+ sheet: n
3224
+ };
3225
+ }
3226
+ a.sheetId !== void 0 && (s.sheetId = a.sheetId), a.visibility === k.Visibility.Visible ? u === null && (u = o) : s.visibility = a.visibility, a.id === t && (i = o), n.sheets.push(s);
3227
+ }
3228
+ if (!r) {
3229
+ let e = l.toJSON();
3230
+ e && Object.keys(e).length > 0 && (n.styles = e);
2753
3231
  }
2754
- if (!n) {
2755
- let e = o.toJSON();
2756
- e && Object.keys(e).length > 0 && (t.styles = e);
3232
+ let h = this.getProtection().toJSON();
3233
+ h && (n.protection = h);
3234
+ let g = this._calculation.toJSON();
3235
+ Object.keys(g).length > 0 && (n.calc = g);
3236
+ let _ = await s.toJSONAsync();
3237
+ _ && _.length > 0 && (n.strings = _);
3238
+ let v = this._calculation.getExternalBooks().toJSON();
3239
+ v && (n.externalBooks = v);
3240
+ let y = this._pivotCaches;
3241
+ if (y.length > 0) {
3242
+ let e = c ? c.toResourceId.bind(c) : () => null, t = /* @__PURE__ */ new Set();
3243
+ for (let e of this.getPivotTables()) t.add(e.getCacheId());
3244
+ let r = [];
3245
+ for (let n = 0; n < y.length; n++) t.has(y[n].cacheId) && r.push(y[n].toJSON(e));
3246
+ r.length > 0 && (n.pivotCaches = r);
2757
3247
  }
2758
- let m = this.getProtection().toJSON();
2759
- m && (t.protection = m);
2760
- let h = this._calculation.toJSON();
2761
- Object.keys(h).length > 0 && (t.calc = h);
2762
- let g = await i.toJSONAsync();
2763
- g && g.length > 0 && (t.strings = g);
2764
- let _ = this._externalBooks.toJSON();
2765
- if (_ && (t.externalBooks = _), !r) {
2766
- let e = await a.toJSONAsync();
2767
- e && e.length > 0 && (t.resources = e);
3248
+ let b = this._people.toJSON();
3249
+ if (b && (n.people = b), !o) {
3250
+ let e = await c.toJSONAsync(typeof a == "function" ? a : void 0);
3251
+ e && e.length > 0 && (n.resources = e);
2768
3252
  }
2769
- let v = this._calculation.getNamedFormulas().toJSON();
2770
- v && v.length > 0 && (t.names = v);
2771
- let y = this._view.toJSON();
2772
- y && (c === l ? delete y.activeSheetId : y.activeSheetId = c, Object.keys(y).length > 0 && (t.view = y));
3253
+ let x = this._calculation.getNamedFormulas().toJSON();
3254
+ x && x.length > 0 && (n.names = x);
3255
+ let S = this._view.toJSON();
3256
+ S && (i === u ? delete S.activeSheetId : S.activeSheetId = i, Object.keys(S).length > 0 && (n.view = S));
2773
3257
  } finally {
2774
- o.endPersist(), r || a.endPersist(), i.endPersist();
3258
+ l.endPersist(), o || c.endPersist(), s.endPersist();
2775
3259
  }
2776
- return this._emitter.notify("onSave", { params: t }), t;
3260
+ return this._emitter.notify("onSave", { params: n }), n;
2777
3261
  }
2778
3262
  isClosed() {
2779
3263
  return this._closed;
@@ -2791,19 +3275,24 @@ var En, Dn, $ = class e extends ge {
2791
3275
  } catch (e) {
2792
3276
  console.warn("error on close", e);
2793
3277
  }
2794
- this._ownResources, this._ownNames && this._names.close(), this._ownCalculation && this._calculation.close(), this._ownStyles, this._transactionsRemoveListener?.(), this._listenerLanguage?.(), this._listenerOrigin?.(), this._closed = !0;
3278
+ this._ownResources, this._ownNames && this._names.close(), this._ownCalculation && this._calculation.close(), this._ownStyles, this._transactionsRemoveListener?.(), this._listenerLanguage?.(), this._listenerOrigin?.(), this._listenerOriginProvider?.(), this._ownOriginProvider && this._originProvider instanceof Dn && this._originProvider.release(), this._closed = !0;
2795
3279
  }
2796
3280
  beginCommit(e) {
2797
- if (this._closed) throw Error(H("error.workbook.modelClosed"));
3281
+ if (this._closed) throw Error(G("error.workbook.modelClosed"));
2798
3282
  return this._beginCommit(typeof e == "string" ? { description: e } : e);
2799
3283
  }
2800
3284
  doBatch(e, t) {
2801
- let n = this;
2802
- return t = typeof t == "string" ? { description: t } : {
2803
- description: V("op.updateWorkbook"),
3285
+ let r = this;
3286
+ t = typeof t == "string" ? { description: t } : {
3287
+ description: W("op.updateWorkbook"),
2804
3288
  ...t
2805
- }, this._transactions.doBatch(e, t, (e, t) => {
2806
- e.getDepth() === 0 && (n._lastTransactionUUID = e.getId());
3289
+ };
3290
+ let i = n.bind(this._transactions, this, e);
3291
+ return this._transactions.doBatch(i.callback, {
3292
+ ...t,
3293
+ onChildCommit: i.onChildCommit
3294
+ }, (e, t) => {
3295
+ i.close(), e.getDepth() === 0 && (r._lastTransactionUUID = e.getId());
2807
3296
  });
2808
3297
  }
2809
3298
  _beginCommit(e) {
@@ -2815,7 +3304,7 @@ var En, Dn, $ = class e extends ge {
2815
3304
  _getState() {
2816
3305
  return this._transactions.getState(this._id);
2817
3306
  }
2818
- _updateState(e, t = V("op.updateWorkbook"), n) {
3307
+ _updateState(e, t = W("op.updateWorkbook"), n) {
2819
3308
  if (!e) return;
2820
3309
  let r = this._beginCommit(t);
2821
3310
  try {
@@ -2836,7 +3325,7 @@ var En, Dn, $ = class e extends ge {
2836
3325
  get isIWorkbook() {
2837
3326
  return !0;
2838
3327
  }
2839
- }, An = { address: null }, jn = class {
3328
+ }, Ir = { address: null }, Z = (e) => e.sheet.getKind() === k.Kind.Worksheet, Lr = class {
2840
3329
  constructor() {
2841
3330
  this._readFormats = [], this._writeFormats = [], this._encryptions = [];
2842
3331
  }
@@ -2853,9 +3342,7 @@ var En, Dn, $ = class e extends ge {
2853
3342
  if (n !== -1) {
2854
3343
  let t = [...this._encryptions];
2855
3344
  t[n] = e, this._encryptions = Object.freeze(t);
2856
- return;
2857
- }
2858
- this._encryptions = Object.freeze([...this._encryptions, e]);
3345
+ } else this._encryptions = Object.freeze([...this._encryptions, e]);
2859
3346
  }
2860
3347
  async getEncryption(e) {
2861
3348
  return this.peekEncryption(e);
@@ -2912,9 +3399,9 @@ var En, Dn, $ = class e extends ge {
2912
3399
  return !0;
2913
3400
  });
2914
3401
  }
2915
- }, Mn = (e) => !!e && typeof e == "object" && typeof e.getPath == "function" && typeof e.canWrite == "function", Nn = class {
3402
+ }, Rr = /* @__PURE__ */ new WeakMap(), zr = (e) => !!e && typeof e == "object" && typeof e.getPath == "function" && typeof e.canWrite == "function", Br = class {
2916
3403
  constructor() {
2917
- this._setInstalled = /* @__PURE__ */ new WeakSet(), this._backingStore = null, this._emitter = new S(this), this._registry = new jn(), this._defaultStore = new wt(() => this.getWriteFormats(), () => this.getReadFormats());
3404
+ this._setInstalled = /* @__PURE__ */ new WeakSet(), this._backingStore = null, this._emitter = new e(this), this._registry = new Lr(), this._defaultStore = new kn(() => this.getWriteFormats(), () => this.getReadFormats());
2918
3405
  }
2919
3406
  getBackingStore() {
2920
3407
  return this._backingStore ?? this._defaultStore;
@@ -2949,15 +3436,18 @@ var En, Dn, $ = class e extends ge {
2949
3436
  return this._registry.getWriteFormats(e);
2950
3437
  }
2951
3438
  getOrigin(e) {
2952
- return new U(e);
3439
+ return new K(e);
2953
3440
  }
2954
3441
  async read(e) {
2955
3442
  let t = null;
2956
3443
  if (typeof e == "string") e = { source: e };
2957
- else if (Mn(e)) {
3444
+ else if (zr(e)) {
2958
3445
  let n = e.getPath();
2959
3446
  if (!n) throw Error("Cannot read from an unbound origin (no path).");
2960
- t = e, e = { source: n };
3447
+ Tn(e) ? e = {
3448
+ source: n,
3449
+ asCopy: !0
3450
+ } : (t = e, e = { source: n });
2961
3451
  }
2962
3452
  let n = e ?? {}, { source: r = null, ...i } = n, a = this.getBackingStore();
2963
3453
  return (a.read ? a : this._defaultStore).read({
@@ -2973,21 +3463,23 @@ var En, Dn, $ = class e extends ge {
2973
3463
  search: i,
2974
3464
  ext: a
2975
3465
  }))[0];
2976
- if (!o) throw new R(H("error.io.readFormatUnavailable", { format: i ?? a }));
3466
+ if (!o) throw new B(G("error.io.readFormatUnavailable", { format: i ?? a }));
2977
3467
  let s = n?.typedCreateWorkbookOptions, c = s ? Object.keys(s).find((e) => e.toLowerCase() === o.key.toLowerCase()) : void 0, l = {
2978
3468
  ...n,
2979
3469
  ...c === void 0 ? void 0 : s[c]
2980
3470
  };
2981
- delete l.typedCreateWorkbookOptions, delete l.source;
2982
- let u = r ?? new U(t.absolutePath ?? null, {
3471
+ delete l.typedCreateWorkbookOptions, delete l.source, delete l.asCopy;
3472
+ let u = r ?? new K(t.absolutePath ?? null, {
2983
3473
  name: t.name ?? null,
2984
3474
  format: o.key,
2985
3475
  size: t.size ?? null,
3476
+ lastModified: t.lastModified ?? null,
2986
3477
  canWrite: t.canWrite ?? !1
2987
3478
  });
2988
- r instanceof U && r.update({
3479
+ r instanceof K && r.update({
2989
3480
  format: o.key,
2990
- size: t.size ?? null
3481
+ size: t.size ?? null,
3482
+ lastModified: t.lastModified ?? null
2991
3483
  }), l.createWorkbookOptions = {
2992
3484
  ...l.createWorkbookOptions || {},
2993
3485
  origin: u
@@ -3018,7 +3510,7 @@ var En, Dn, $ = class e extends ge {
3018
3510
  }
3019
3511
  async _decrypt(e, t, n) {
3020
3512
  let r = await this._registry.detectEncryption(e);
3021
- if (t instanceof U && t.update({ encryption: r ? r.key : null }), !r) return {
3513
+ if (t instanceof K && t.update({ encryption: r ? r.key : null }), !r) return {
3022
3514
  bytes: e,
3023
3515
  password: null
3024
3516
  };
@@ -3026,7 +3518,7 @@ var En, Dn, $ = class e extends ge {
3026
3518
  try {
3027
3519
  return i = await r.decode(e, t), !0;
3028
3520
  } catch (e) {
3029
- if (!(e instanceof ht)) throw e;
3521
+ if (!(e instanceof pn)) throw e;
3030
3522
  return !1;
3031
3523
  }
3032
3524
  };
@@ -3036,7 +3528,7 @@ var En, Dn, $ = class e extends ge {
3036
3528
  };
3037
3529
  if (!n?.onPassword) {
3038
3530
  let e = t.getName();
3039
- throw new vt(e ? H("error.io.passwordRequired", { name: e }) : H("error.io.passwordRequiredUnnamed"));
3531
+ throw new gn(e ? G("error.io.passwordRequired", { name: e }) : G("error.io.passwordRequiredUnnamed"));
3040
3532
  }
3041
3533
  let o = await Promise.resolve(n.onPassword({
3042
3534
  origin: t,
@@ -3048,95 +3540,117 @@ var En, Dn, $ = class e extends ge {
3048
3540
  bytes: i,
3049
3541
  password: o
3050
3542
  };
3051
- throw new ht(H("error.io.passwordIncorrect"));
3543
+ throw new pn(G("error.io.passwordIncorrect"));
3052
3544
  }
3053
3545
  async writeArrayBuffer(e, t) {
3054
3546
  if (!t?.format) throw Error("A format must be specified to write to an ArrayBuffer (e.g. { format: 'xlsx' }).");
3055
3547
  let n = (await this._registry.getWriteFormats({ search: t.format }))[0];
3056
- if (!n) throw new R(H("error.io.writeFormatUnavailable", { format: t.format }));
3548
+ if (!n) throw new B(G("error.io.writeFormatUnavailable", { format: t.format }));
3057
3549
  return this._writeArrayBuffer(e, n, t);
3058
3550
  }
3059
3551
  async write(e, t, n) {
3552
+ return typeof t == "string" || zr(t) ? this._write(e, t, !1, n) : this._write(e, e?.getOrigin?.(), !0, t ?? n);
3553
+ }
3554
+ async writeAs(e, t, n) {
3555
+ if (!t) throw Error("A target must be provided for writeAs (use write(workbook) for a plain save).");
3556
+ return this._write(e, t, !0, n);
3557
+ }
3558
+ async _write(e, t, n, r) {
3060
3559
  if (!e) throw Error("Workbook must be provided.");
3061
3560
  if (!e.isIWorkbook) throw Error("Invalid workbook model provided. Must be an instance of IWorkbook.");
3062
- let r = n, i = null;
3063
- typeof t == "string" ? i = this.getOrigin(t) : Mn(t) ? i = t : t && (r = t);
3064
- let a = !i, o = i ?? e.getOrigin(), s = o.getFormat(), c;
3065
- if ((r?.format || s) && (c = (await this._registry.getWriteFormats({ search: r?.format ?? s ?? void 0 }))[0]), c || o.getPath() && o.canWrite() && o.getExtension() || (c = (await this._registry.getWriteFormats({ ext: "sxl" }))[0] ?? (await this._registry.getWriteFormats())[0]), !c) throw new R(H("error.io.writeFormatUnresolved"));
3066
- if (i && typeof t == "string") {
3561
+ let i = typeof t == "string" ? this.getOrigin(t) : t, a = i.getFormat(), o;
3562
+ if ((r?.format || a) && (o = (await this._registry.getWriteFormats({ search: r?.format ?? a ?? void 0 }))[0]), o || i.getPath() && i.canWrite() && i.getExtension() || (o = (await this._registry.getWriteFormats({ ext: "sxl" }))[0] ?? (await this._registry.getWriteFormats())[0]), !o) throw new B(G("error.io.writeFormatUnresolved"));
3563
+ let s = i.getExtension();
3564
+ if (r?.format && s && i.getPath() && i.canWrite() && !o.exts.includes(s)) {
3565
+ let e = (await this._registry.getWriteFormats({ ext: s }))[0];
3566
+ if (e && e.key !== o.key) {
3567
+ let e = i.getPath().split(/[/\\]/).pop();
3568
+ throw new B(G("error.io.writeFormatMismatch", {
3569
+ format: r.format,
3570
+ file: e
3571
+ }));
3572
+ }
3573
+ }
3574
+ if (typeof t == "string") {
3067
3575
  let e = i.getPath();
3068
- e && !x(e) && i.update?.({ path: `${e}.${c.exts[0]}` });
3576
+ i = new K(S(e) ? e : `${e}.${o.exts[0]}`, { format: o.key });
3069
3577
  }
3070
- let l = o.getEncryption(), u = e.getOrigin?.(), d = (o instanceof U ? o.getPassword() : null) ?? (u instanceof U ? u.getPassword() : null), f = o.isEncrypted() || (u?.isEncrypted() ?? !1), p = r?.password === void 0 ? d ?? (f ? void 0 : null) : r.password, m = null;
3071
- if (p === void 0) {
3072
- if (f) {
3073
- let e = o.getName();
3074
- throw new vt(e ? H("error.io.passwordRequiredSave", { name: e }) : H("error.io.passwordRequiredSaveUnnamed"));
3578
+ let c = i.getEncryption(), l = e.getOrigin?.(), u = (i instanceof K ? i.getPassword() : null) ?? (l instanceof K ? l.getPassword() : null), d = i.isEncrypted() || (l?.isEncrypted() ?? !1), f = r?.password === void 0 ? u ?? (d ? void 0 : null) : r.password, p = null;
3579
+ if (f === void 0) {
3580
+ if (d) {
3581
+ let e = i.getName();
3582
+ throw new gn(e ? G("error.io.passwordRequiredSave", { name: e }) : G("error.io.passwordRequiredSaveUnnamed"));
3075
3583
  }
3076
- } else if (p !== null && (m = await this._registry.getEncryption(l), !m)) throw new R(H("error.io.encryptionUnavailable"));
3077
- let h = `${o.getName() ?? H("workbook.defaultName")}.${c.exts[0]}`, g = r?.progress, _ = !1, v = this, y = null, ee = {
3584
+ } else if (f !== null && (p = await this._registry.getEncryption(c), !p)) throw new B(G("error.io.encryptionUnavailable"));
3585
+ let m = `${i.getName() ?? G("workbook.defaultName")}.${o.exts[0]}`, h = r?.progress, g = !i.getPath() || !i.canWrite() || !!r?.prompt, _ = !1, v = this, y = null, b = [], x = {
3078
3586
  workbook: e,
3079
- format: c,
3080
- origin: o,
3081
- suggestedName: h,
3587
+ format: o,
3588
+ origin: i,
3589
+ suggestedName: m,
3082
3590
  prompt: r?.prompt,
3083
- async encode(t) {
3084
- await (async () => {
3085
- _ || (_ = !0, g?.onStart && await Promise.resolve(g.onStart(o)));
3086
- })(), y = e.getTransactions?.()?.getCurrentCommit() ?? y;
3087
- let n = t ? (await v._registry.getWriteFormats({ search: t }))[0] ?? c : c, i = await v._writeArrayBuffer(e, n, r);
3088
- return m ? m.encode(i, p) : i;
3591
+ async encode(t, a) {
3592
+ let s = a ?? i;
3593
+ await (async (e) => {
3594
+ _ || (_ = !0, h?.onStart && await Promise.resolve(h.onStart(e)));
3595
+ })(s), y = e.getTransactions?.()?.getCurrentCommit() ?? y;
3596
+ let c = t ? (await v._registry.getWriteFormats({ search: t }))[0] ?? o : o, l = [], u = ((e, t) => ({
3597
+ onStart: e?.onStart ? (t, n) => e.onStart(t, n) : void 0,
3598
+ onProgress: e?.onProgress ? (t, n) => e.onProgress(t, n) : void 0,
3599
+ onError: e?.onError ? (t) => e.onError(t) : void 0,
3600
+ onComplete: e?.onComplete ? (t) => e.onComplete(t) : void 0,
3601
+ onWarning: (n, r) => {
3602
+ t.push({
3603
+ message: n ?? "",
3604
+ context: r
3605
+ }), e?.onWarning?.(n, r);
3606
+ }
3607
+ }))(h, l), d = await v._writeArrayBuffer(e, c, {
3608
+ ...r,
3609
+ progress: u
3610
+ }), m = Rr.get(s);
3611
+ if (l.some((e) => !m?.has(e.message)) && r?.onWarnings) {
3612
+ let t = await Promise.resolve(r.onWarnings({
3613
+ workbook: e,
3614
+ origin: s,
3615
+ warnings: l,
3616
+ save: n,
3617
+ canCancel: !g
3618
+ }));
3619
+ if (!g && !1 === t) return null;
3620
+ }
3621
+ return b = l, p ? p.encode(d, f) : d;
3089
3622
  }
3090
- }, b = null;
3623
+ }, C = null;
3091
3624
  try {
3092
3625
  let t = this.getBackingStore();
3093
3626
  if (!t.write) throw Error("The active backing store is read-only (no write implementation).");
3094
- if (b = await t.write(ee), b) {
3095
- p !== void 0 && b instanceof U && (b.setPassword(p), b.update({ encryption: m ? m.key : null }));
3627
+ if (C = await t.write(x), C) {
3628
+ if (f !== void 0 && C instanceof K && (C.setPassword(f), C.update({ encryption: p ? p.key : null })), b.length) {
3629
+ let e = Rr.get(C) ?? /* @__PURE__ */ new Set();
3630
+ for (let t of b) e.add(t.message);
3631
+ Rr.set(C, e);
3632
+ }
3633
+ n && C !== e.getOrigin() && Tn(e.getOrigin())?.setOrigin(C);
3096
3634
  let t = y ?? e.getTransactions?.()?.getCurrentCommit() ?? null;
3097
3635
  this._emitter.notify("onWrite", {
3098
3636
  params: {
3099
3637
  workbook: e,
3100
- origin: b,
3638
+ origin: C,
3101
3639
  commitId: t?.getId() ?? null,
3102
- save: a
3640
+ save: n
3103
3641
  },
3104
3642
  transactional: !1
3105
3643
  });
3106
3644
  }
3107
- g?.onComplete && await Promise.resolve(g.onComplete(b));
3645
+ h?.onComplete && await Promise.resolve(h.onComplete(C));
3108
3646
  } catch (e) {
3109
3647
  let t = e instanceof Error ? e : Error(String(e));
3110
- throw g?.onError && await Promise.resolve(g.onError(t)), g?.onComplete && await Promise.resolve(g.onComplete(null)), t instanceof R ? t : Error(H("error.io.writeFailed", { reason: t.message }), { cause: e });
3111
- }
3112
- return b;
3113
- }
3114
- async writeAs(e, t, n) {
3115
- if (!t) throw Error("A target must be provided for writeAs (use write(workbook) for a plain save).");
3116
- let r = e?.getOrigin?.();
3117
- if (!(r instanceof U)) return this.write(e, t, n);
3118
- let i = typeof t == "string" ? t : t.getPath(), a = i && x(i)?.toLowerCase() || null, o = a ? (await this._registry.getWriteFormats({ search: a }))[0]?.key ?? a : null, s = {
3119
- path: r.getPath(),
3120
- name: r.getName(),
3121
- format: r.getFormat(),
3122
- canWrite: r.canWrite()
3123
- };
3124
- r.update({
3125
- path: i,
3126
- name: typeof t == "string" ? null : t.getName(),
3127
- format: o,
3128
- canWrite: i != null
3129
- });
3130
- let c = null;
3131
- try {
3132
- c = await this.write(e, void 0, n);
3133
- } finally {
3134
- c || r.update(s);
3648
+ throw h?.onError && await Promise.resolve(h.onError(t)), h?.onComplete && await Promise.resolve(h.onComplete(null)), t instanceof B ? t : Error(G("error.io.writeFailed", { reason: t.message }), { cause: e });
3135
3649
  }
3136
- return c;
3650
+ return C;
3137
3651
  }
3138
3652
  _stripExtension(e) {
3139
- let t = x(e);
3653
+ let t = S(e);
3140
3654
  return t ? e.slice(0, e.length - t.length - 1) : e;
3141
3655
  }
3142
3656
  _baseName(e) {
@@ -3156,21 +3670,24 @@ var En, Dn, $ = class e extends ge {
3156
3670
  async _readArrayBuffer(e, t, n) {
3157
3671
  if (!e) throw Error("ArrayBuffer must be specified.");
3158
3672
  if (!t) throw Error("format must be specified.");
3159
- if (e.byteLength === 0) return new kn(n?.createWorkbookOptions);
3673
+ if (e.byteLength === 0) return new Fr(n?.createWorkbookOptions);
3160
3674
  let r = t.handler;
3161
3675
  if (!r) throw Error(`Unable to resolve a read handler for '${t.key}'.`);
3162
3676
  let i;
3163
3677
  try {
3164
3678
  i = await r(e, n);
3165
3679
  } catch (e) {
3166
- throw e instanceof R ? e : new R(H("error.io.readFailed", {
3680
+ throw e instanceof B ? e : new B(G("error.io.readFailed", {
3167
3681
  format: t.description ?? t.key,
3168
3682
  reason: e?.message ?? String(e)
3169
3683
  }), { cause: e });
3170
3684
  }
3171
- return i;
3685
+ return await Ue(), i;
3686
+ }
3687
+ get isIWorkbookIO() {
3688
+ return !0;
3172
3689
  }
3173
- }, Pn = new Nn(), Fn = class {
3690
+ }, Vr = new Br(), Hr = class {
3174
3691
  constructor() {
3175
3692
  this._buffer = null, this._formatKey = null;
3176
3693
  }
@@ -3179,44 +3696,125 @@ var En, Dn, $ = class e extends ge {
3179
3696
  }
3180
3697
  async write(e) {
3181
3698
  let t = await e.encode();
3182
- return this._buffer = t, this._formatKey = e.format.key, e.origin;
3699
+ return t ? (this._buffer = t, this._formatKey = e.format.key, e.origin) : null;
3183
3700
  }
3184
3701
  async read(e) {
3185
3702
  return this._buffer ? e.decode(this._buffer, { format: this._formatKey ?? void 0 }) : null;
3186
3703
  }
3187
- }, In = "locales", Ln = "fonts", Rn = [{
3188
- kind: In,
3189
- files: [{
3190
- suffix: ".msg.json",
3191
- async extract(e) {
3192
- let t = e.relPath.split("/");
3193
- return t.length === 2 ? {
3194
- locale: t[0],
3195
- role: "messages"
3196
- } : null;
3197
- },
3198
- place: (e, t) => t ? `${t}/${e}` : null
3199
- }]
3704
+ }, Ur = "locales", Wr = "fonts", Gr = {
3705
+ suffix: ".msg.json",
3706
+ async extract(e) {
3707
+ let t = e.relPath.split("/");
3708
+ return t.length === 2 ? {
3709
+ locale: t[0],
3710
+ role: "messages"
3711
+ } : null;
3712
+ },
3713
+ place: (e, t) => t ? `${t}/${e}` : null
3714
+ }, Kr = [
3715
+ ".woff2",
3716
+ ".woff",
3717
+ ".ttf",
3718
+ ".otf",
3719
+ ".ttc",
3720
+ ".otc"
3721
+ ].map((e) => ({
3722
+ suffix: e,
3723
+ place: (e, t) => t ? `${t}/${e}` : e
3724
+ })), qr = {
3725
+ suffix: ".metrics.json",
3726
+ async extract(e) {
3727
+ let t = await e.readJson();
3728
+ return t?.format === "sheetxl-font-metrics/1" ? {
3729
+ family: t.family,
3730
+ weight: t.weight,
3731
+ italic: t.italic
3732
+ } : null;
3733
+ },
3734
+ place: (e, t) => t ? `${t}/${e}` : e
3735
+ }, Jr = [{
3736
+ kind: Ur,
3737
+ files: [Gr]
3200
3738
  }, {
3201
- kind: Ln,
3739
+ kind: Wr,
3202
3740
  files: [
3203
- ".woff2",
3204
- ".woff",
3205
- ".ttf",
3206
- ".otf",
3207
- ".ttc"
3208
- ].map((e) => ({
3209
- suffix: e,
3210
- place: (e, t) => t ? `${t}/${e}` : e
3211
- }))
3741
+ qr,
3742
+ {
3743
+ suffix: ".hinted.json",
3744
+ async extract(e) {
3745
+ let t = await e.readJson();
3746
+ return t?.format === "sheetxl-font-hinting/1" ? {
3747
+ family: t.family,
3748
+ weight: t.weight,
3749
+ italic: t.italic,
3750
+ hinted: !0
3751
+ } : null;
3752
+ },
3753
+ place: qr.place
3754
+ },
3755
+ {
3756
+ suffix: ".rows.json",
3757
+ async extract(e) {
3758
+ let t = await e.readJson();
3759
+ return t?.format === "sheetxl-font-rows/1" ? {
3760
+ family: t.family,
3761
+ weight: t.weight,
3762
+ italic: t.italic,
3763
+ rows: !0
3764
+ } : null;
3765
+ },
3766
+ place: qr.place
3767
+ },
3768
+ ...Kr
3769
+ ]
3212
3770
  }];
3213
- En ||= {}, Dn ||= {};
3214
- var zn, Bn = e({ nowWithPrecision: () => Vn });
3215
- function Vn(e = 6e4) {
3216
- return new Date(Math.floor(Date.now() / e) * e);
3771
+ async function Yr(e, t) {
3772
+ let { Chart: n } = await import("./Dyq_ivuHvlXLwPCl.mjs");
3773
+ return new n({
3774
+ json: e,
3775
+ getStyles: t?.getStyles
3776
+ });
3217
3777
  }
3218
- zn ||= {};
3219
- var Hn = class extends Ge {
3778
+ Ar ||= {};
3779
+ var Q = null;
3780
+ function Xr() {
3781
+ if (!Q) {
3782
+ let e = import("./DWNzqw7DUKwoxjri.mjs").then((e) => e.loadScriptingDeclarations());
3783
+ e.catch(() => {
3784
+ Q = null;
3785
+ }), Q = e;
3786
+ }
3787
+ return Q;
3788
+ }
3789
+ var Zr, Qr, $r, $ = null;
3790
+ function ei() {
3791
+ if (!$) {
3792
+ let e = import("./DWNzqw7DUKwoxjri.mjs").then((e) => e.loadScriptingApi()).then((e) => JSON.parse(e));
3793
+ e.catch(() => {
3794
+ $ = null;
3795
+ }), $ = e;
3796
+ }
3797
+ return $;
3798
+ }
3799
+ Zr ||= {}, (Qr ||= {}).Type = {
3800
+ Button: "button",
3801
+ CheckBox: "checkBox",
3802
+ OptionButton: "optionButton",
3803
+ ListBox: "listBox",
3804
+ DropDown: "dropDown",
3805
+ ScrollBar: "scrollBar",
3806
+ Spinner: "spinner",
3807
+ GroupBox: "groupBox",
3808
+ Label: "label",
3809
+ EditBox: "editBox",
3810
+ Dialog: "dialog",
3811
+ Unknown: "formControl"
3812
+ }, ($r ||= {}).DropStyle = {
3813
+ Combo: "combo",
3814
+ ComboEdit: "comboEdit",
3815
+ Simple: "simple"
3816
+ };
3817
+ var ti = class extends qe {
3220
3818
  constructor(e) {
3221
3819
  super(e);
3222
3820
  }
@@ -3229,8 +3827,8 @@ var Hn = class extends Ge {
3229
3827
  colEnd: (e?.size?.width ?? 5) - 1,
3230
3828
  rowEnd: (e?.size?.height ?? 5) - 1
3231
3829
  },
3232
- getRanges: (e) => null
3830
+ getRanges: (e) => new pe(null)
3233
3831
  }, super._initializeOptions(e);
3234
3832
  }
3235
- }, Un = "0.8.0-beta.1", Wn = "Fri Aug 28 2026";
3236
- export { Fe as AddressUtils, Fn as ArrayBackingStore, Se as AutoFill, Wn as BUILD_DATE, w as Color, Re as Condition, Bn as DateUtils, Nn as DefaultWorkbookIO, gn as ExternalRangeClipboardItem, Ln as FONTS_KIND, Rt as FontUtils, De as GeomUtils, lt as IAnchored, Je as IBorder, Ye as ICalculation, xe as ICell, Qt as ICellHeaderRange, nt as ICellRange, Zt as ICellRanges, C as IColor, de as ICondition, ve as IConditionalFormat, Qe as IDataValidation, Lt as IEffect, i as IFill, k as IFont, kt as IFontCollection, zn as IMovable, Dn as IPicture, En as IPrint, Xt as IResource, O as ISheet, He as ISheetView, Ft as ISort, It as IStroke, ut as IStyle, d as ITableStyle, at as IText, a as ITextFrame, Yt as ITheme, re as IThemeCollection, bt as IWorkbookIO, In as LOCALES_KIND, Ke as LicenseManager, M as NumberFormat, hn as RangeClipboardItem, ee as Registry, ie as Resource, st as ResourceCollection, Rn as SHEETXL_RESOURCE_KINDS, p as SYSTEM_COLOR_CSS_PREFIX, A as Sheet, Ot as SimpleFontFace, Be as Sort, he as StringCollection, ae as StyleCollection, Hn as Table, rt as TextRotation, ct as TextUtils, m as Theme, g as ThemeCollection, l as TransactionConflictError, St as TransactionSaveStateManager, s as TransactionStore, xt as TransactionUndoManager, be as Tuple, Un as VERSION, kn as Workbook, Pn as WorkbookIO, U as WorkbookOrigin, Q as WorkbookView, Jt as builtInStyleNameDisplay, et as createCellRangeCounts, tn as getBuiltInFunctionNames, Ve as getLanguagePack, Te as getLocaleProfile, Ze as localizeBoolean, _e as localizeErrorLabel, ue as makeLocaleProfile, Pe as parseBooleanLocal, tt as parseErrorLocal, nn as parseFormulaLiteral, fe as registerSdkLocales };
3833
+ }, ni = "0.8.0-beta.11", ri = "2026-10-23T19:00:05.446Z";
3834
+ export { ke as AbstractCollection, r as AbstractMovableContent, Ye as AddressUtils, Hr as ArrayBackingStore, ie as AutoFill, ri as BUILD_DATE, se as ChartElementSelection, cn as ChartKinds, en as Color, me as Condition, tt as DateUtils, Br as DefaultWorkbookIO, _ as EXTERNAL_LINK_PATH_REL_TYPE, dr as ExternalRangeClipboardItem, Wr as FONTS_KIND, Ut as FontUtils, u as FormulaText, Yn as FunctionDeclarations, Ie as GeomUtils, Et as IAnchored, Bt as IBorders, E as ICalculation, Re as ICell, Kn as ICellHeaderRange, Je as ICellRange, Gn as ICellRanges, Zt as ICellStyle, $t as IColor, Qe as ICondition, $e as IConditionalFormat, X as ICustomProperty, ut as IDataValidation, $r as IDropDown, tn as IEffect, Qt as IFill, M as IFont, Ct as IFontCollection, F as IFontStyle, Qr as IFormControl, ln as IGeometry, Zr as IMovable, f as IPageLayout, Ar as IPicture, Wn as IResource, Fe as IScript, Gt as IShape, k as ISheet, h as ISlicerStyle, Cn as ISort, rn as IStroke, it as ITable, o as ITableStyle, Oe as IText, N as ITextFrame, Un as ITheme, le as IThemeCollection, vn as IWorkbookIO, rr as IWorkbookView, Ge as IWorksheetView, Ur as LOCALES_KIND, he as LicenseManager, St as MovableContentRegistry, ot as NamedStyleCollection, P as NumberFormat, sn as PaintUtils, or as PersonCollection, ur as RangeClipboardItem, Pn as RectAlignment, Te as Registry, jt as Resource, Le as ResourceCollection, dt as RichDataRegistry, bt as RichText, ze as RichTextKind, Jr as SHEETXL_RESOURCE_KINDS, an as SYSTEM_COLOR_CSS_PREFIX, zt as ShapeStyleUtils, Ve as SimpleFontFace, p as SlicerStyleCollection, Pe as Sort, Nt as StringCollection, _e as StyleCollection, ti as Table, ce as TableStyleCollection, Ce as TextRotation, ve as TextStacked, v as TextUtils, re as Theme, oe as ThemeCollection, t as TransactionConflictError, Sn as TransactionSaveStateManager, i as TransactionStore, yn as TransactionUndoManager, ae as Tuple, ni as VERSION, Fr as Workbook, Vr as WorkbookIO, K as WorkbookOrigin, mr as WorkbookView, A as Worksheet, Hn as builtInStyleNameDisplay, ge as createCellRangeCounts, Yr as createChart, x as externalBookClosedName, ne as externalBookFileName, fe as externalBookLocation, Ft as externalBookOpenName, Dt as findLabel, Xn as getBuiltInFunctionNames, pt as getLanguagePack, Kt as getLocaleProfile, ft as getScriptRuntime, ei as getScriptingApi, Xr as getScriptingDeclarations, ct as localizeBoolean, Xe as localizeErrorLabel, It as makeLocaleProfile, Pt as normalizeLabel, Ke as parseBooleanLocal, je as parseErrorLocal, c as parseExternalScope, Zn as parseFormulaLiteral, We as registerSdkLocales, Se as sourceEntryFromPath, xt as withScriptRuntime };