@sheetxl/sdk 0.7.27 → 0.7.28-beta.1

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 (600) hide show
  1. package/THIRD-PARTY-NOTICES.md +34 -0
  2. package/browser/cjs/B7_pDFYCVzt-3hUs.cjs +1 -0
  3. package/browser/cjs/D590vnHyyrIYenQ7.cjs +33 -0
  4. package/browser/cjs/DfVZ_U2YapkL3Y3y.cjs +1 -0
  5. package/browser/cjs/DsII2GRIYGbaZjIE.cjs +1 -0
  6. package/browser/cjs/Dv3x6zut1ZRUt3IF.cjs +10 -0
  7. package/browser/cjs/index.cjs +3 -6
  8. package/browser/cjs/nE4y6hua6AwWSil7.cjs +1 -0
  9. package/browser/cjs/nMss3hrHzgX9s6dC.cjs +57 -0
  10. package/browser/esm/AyOmyt_vaPirbWnn.mjs +49986 -0
  11. package/browser/esm/BJ5lU2Y0r4Vy8n4q.mjs +109 -0
  12. package/browser/esm/BvaEmG7AaTSm7dFt.mjs +818 -0
  13. package/browser/esm/CWKJatjtHKfWtM2b.mjs +503 -0
  14. package/browser/esm/CkhE5KvHQvKzw4Ll.mjs +4436 -0
  15. package/browser/esm/Dpwf1IgHZjpEpK-K.mjs +24 -0
  16. package/browser/esm/index.mjs +3225 -62
  17. package/browser/esm/uFvYxePB3xD2HrP0.mjs +14 -0
  18. package/licenses/dependencies.txt +74 -193
  19. package/node/esm/CYXOvL3qwWeDE0xf.mjs +114 -0
  20. package/node/esm/Dgmq_XXiU2AQw1tX.mjs +22 -0
  21. package/node/esm/index.mjs +53620 -23262
  22. package/node/esm/qxrG4h6T0dAo8eZ6.mjs +837 -0
  23. package/package.json +19 -14
  24. package/resources/contents.json +21 -0
  25. package/resources/locales/contents.json +19 -0
  26. package/resources/locales/de/grammar.json +16 -0
  27. package/resources/locales/de/model.msg.json +510 -0
  28. package/resources/locales/en/model.msg.json +525 -0
  29. package/types/index.d.ts +2 -21294
  30. package/types/scripting-enums.json +1009 -0
  31. package/types/scripting.d.ts +26540 -31455
  32. package/types/src/address/AddressUtils.d.ts +252 -0
  33. package/types/src/address/_AddressMessages.d.ts +7 -0
  34. package/types/src/address/index.d.ts +35 -0
  35. package/types/src/anchored/AbstractAnchored.d.ts +200 -0
  36. package/types/src/anchored/Anchored.d.ts +154 -0
  37. package/types/src/anchored/AnchoredMap.d.ts +178 -0
  38. package/types/src/anchored/IAnchored.d.ts +118 -0
  39. package/types/src/anchored/IAnchoredMap.d.ts +207 -0
  40. package/types/src/anchored/_AnchorMessages.d.ts +3 -0
  41. package/types/src/anchored/index.d.ts +2 -0
  42. package/types/src/autoFill/AutoFill.d.ts +161 -0
  43. package/types/src/autoFill/IAutoFill.d.ts +117 -0
  44. package/types/src/autoFill/index.d.ts +3 -0
  45. package/types/src/border/IBorder.d.ts +284 -0
  46. package/types/src/border/index.d.ts +2 -0
  47. package/types/src/calculation/Calculation.d.ts +440 -0
  48. package/types/src/calculation/FormulaLiterals.d.ts +18 -0
  49. package/types/src/calculation/ICalculation.d.ts +1016 -0
  50. package/types/src/calculation/INamedFormulasCollection.d.ts +141 -0
  51. package/types/src/calculation/NamedFormulaCollection.d.ts +671 -0
  52. package/types/src/calculation/TokenType.d.ts +117 -0
  53. package/types/src/calculation/Types.d.ts +110 -0
  54. package/types/src/calculation/_CalculationMessages.d.ts +3 -0
  55. package/types/src/calculation/builtInNames.d.ts +2 -0
  56. package/types/src/calculation/compiler/ASTTypes.d.ts +180 -0
  57. package/types/src/calculation/compiler/CompilerLocale.d.ts +69 -0
  58. package/types/src/calculation/compiler/CompilerUtils.d.ts +331 -0
  59. package/types/src/calculation/compiler/FormulaCompiler.d.ts +69 -0
  60. package/types/src/calculation/compiler/FormulaLexer.d.ts +85 -0
  61. package/types/src/calculation/compiler/FormulaParser.d.ts +270 -0
  62. package/types/src/calculation/compiler/FormulaSeparators.d.ts +35 -0
  63. package/types/src/calculation/compiler/LiteTransform.d.ts +15 -0
  64. package/types/src/calculation/compiler/ParserUtils.d.ts +167 -0
  65. package/types/src/calculation/compiler/SRLexer.d.ts +19 -0
  66. package/types/src/calculation/compiler/SRParser.d.ts +38 -0
  67. package/types/src/calculation/compiler/Types.d.ts +274 -0
  68. package/types/src/calculation/compiler/index.d.ts +3 -0
  69. package/types/src/calculation/executor/CalcExecutor.d.ts +115 -0
  70. package/types/src/calculation/executor/CalcExecutorUtils.d.ts +11 -0
  71. package/types/src/calculation/executor/index.d.ts +3 -0
  72. package/types/src/calculation/formula/Formula.d.ts +168 -0
  73. package/types/src/calculation/formula/FormulaBlock.d.ts +207 -0
  74. package/types/src/calculation/formula/IFormulaBlock.d.ts +181 -0
  75. package/types/src/calculation/formula/LambdaValue.d.ts +166 -0
  76. package/types/src/calculation/formula/TokenUtils.d.ts +26 -0
  77. package/types/src/calculation/formula/index.d.ts +4 -0
  78. package/types/src/calculation/functions/Operators.d.ts +30 -0
  79. package/types/src/calculation/functions/index.d.ts +2 -0
  80. package/types/src/calculation/functions/initializeFunctions.d.ts +22 -0
  81. package/types/src/calculation/grid/CalcGrid.d.ts +205 -0
  82. package/types/src/calculation/grid/CalcGridUtils.d.ts +172 -0
  83. package/types/src/calculation/grid/ICalcGrid.d.ts +500 -0
  84. package/types/src/calculation/grid/index.d.ts +3 -0
  85. package/types/src/calculation/index.d.ts +5 -0
  86. package/types/src/calculation/spatial/ContentfulSpatialValue.d.ts +25 -0
  87. package/types/src/calculation/spatial/FormulaSpatialValue.d.ts +120 -0
  88. package/types/src/calculation/spatial/PrecedentSpatialValue.d.ts +115 -0
  89. package/types/src/calculation/spatial/SpillEntry.d.ts +40 -0
  90. package/types/src/calculation/spatial/index.d.ts +5 -0
  91. package/types/src/calculation/state/CalcNode.d.ts +71 -0
  92. package/types/src/calculation/state/CalcScope.d.ts +35 -0
  93. package/types/src/calculation/state/CalcState.d.ts +28 -0
  94. package/types/src/calculation/state/CalculationContext.d.ts +125 -0
  95. package/types/src/calculation/state/IContextContainer.d.ts +320 -0
  96. package/types/src/calculation/state/index.d.ts +6 -0
  97. package/types/src/calculation/symbol/FunctionSymbolProvider.d.ts +44 -0
  98. package/types/src/calculation/symbol/ISymbolRegistry.d.ts +93 -0
  99. package/types/src/calculation/symbol/IndirectSymbolProvider.d.ts +144 -0
  100. package/types/src/calculation/symbol/SheetSymbolProvider.d.ts +18 -0
  101. package/types/src/calculation/symbol/SymbolRegistry.d.ts +19 -0
  102. package/types/src/calculation/symbol/TableColumnSymbolProvider.d.ts +21 -0
  103. package/types/src/calculation/symbol/TableSymbolProvider.d.ts +19 -0
  104. package/types/src/calculation/symbol/index.d.ts +9 -0
  105. package/types/src/cell/ICell.d.ts +672 -0
  106. package/types/src/cell/ICellHeader.d.ts +142 -0
  107. package/types/src/cell/ICellProtection.d.ts +41 -0
  108. package/types/src/cell/index.d.ts +4 -0
  109. package/types/src/cellRange/ICellHeaderRange.d.ts +306 -0
  110. package/types/src/cellRange/ICellHeaderRanges.d.ts +107 -0
  111. package/types/src/cellRange/ICellRange.d.ts +2509 -0
  112. package/types/src/cellRange/ICellRanges.d.ts +407 -0
  113. package/types/src/cellRange/ICellRegion.d.ts +133 -0
  114. package/types/src/cellRange/_GraphNode.d.ts +38 -0
  115. package/types/src/cellRange/index.d.ts +6 -0
  116. package/types/src/chart/Chart.d.ts +53 -0
  117. package/types/src/chart/IChart.d.ts +42 -0
  118. package/types/src/chart/index.d.ts +5 -0
  119. package/types/src/collections/ArraysGrid.d.ts +72 -0
  120. package/types/src/collections/BooleanList.d.ts +67 -0
  121. package/types/src/collections/GridMap.d.ts +47 -0
  122. package/types/src/collections/HashMap.d.ts +15 -0
  123. package/types/src/collections/IGrid.d.ts +278 -0
  124. package/types/src/collections/IList.d.ts +89 -0
  125. package/types/src/collections/IMap.d.ts +45 -0
  126. package/types/src/collections/IReadableList.d.ts +120 -0
  127. package/types/src/collections/ISortedMap.d.ts +171 -0
  128. package/types/src/collections/ISparseGrid.d.ts +61 -0
  129. package/types/src/collections/ISparseList.d.ts +103 -0
  130. package/types/src/collections/ISpatialMap.d.ts +515 -0
  131. package/types/src/collections/ISpatialMap3D.d.ts +116 -0
  132. package/types/src/collections/IWritableList.d.ts +41 -0
  133. package/types/src/collections/ImmutableList.d.ts +52 -0
  134. package/types/src/collections/IteratorUtils.d.ts +91 -0
  135. package/types/src/collections/MixedTypedArrayList.d.ts +140 -0
  136. package/types/src/collections/OverlappingRangeIterator.d.ts +91 -0
  137. package/types/src/collections/RTree.d.ts +111 -0
  138. package/types/src/collections/RepeatingList.d.ts +20 -0
  139. package/types/src/collections/SortedMap.d.ts +396 -0
  140. package/types/src/collections/SparseGrid.d.ts +99 -0
  141. package/types/src/collections/SparseList.d.ts +90 -0
  142. package/types/src/collections/SpatialMap.d.ts +102 -0
  143. package/types/src/collections/SpatialMap3D.d.ts +64 -0
  144. package/types/src/collections/Tuple.d.ts +160 -0
  145. package/types/src/collections/_CollectionUtils.d.ts +25 -0
  146. package/types/src/collections/_GridUtils.d.ts +268 -0
  147. package/types/src/collections/_RunUtils.d.ts +170 -0
  148. package/types/src/collections/_SpatialUtils.d.ts +115 -0
  149. package/types/src/collections/index.d.ts +21 -0
  150. package/types/src/color/Color.d.ts +120 -0
  151. package/types/src/color/ColorSpace.d.ts +45 -0
  152. package/types/src/color/IColor.d.ts +1110 -0
  153. package/types/src/color/_BuiltInIndexDefs.d.ts +4 -0
  154. package/types/src/color/_BuiltInNamedDefs.d.ts +29 -0
  155. package/types/src/color/_BuiltInSchemeDefs.d.ts +7 -0
  156. package/types/src/color/_ColorUtils.d.ts +93 -0
  157. package/types/src/color/index.d.ts +3 -0
  158. package/types/src/comment/IComment.d.ts +108 -0
  159. package/types/src/comment/index.d.ts +2 -0
  160. package/types/src/condition/AnchoredConditional.d.ts +263 -0
  161. package/types/src/condition/BuiltInOperators/AbstractOperator.d.ts +83 -0
  162. package/types/src/condition/BuiltInOperators/AfterEqualToOperator.d.ts +8 -0
  163. package/types/src/condition/BuiltInOperators/AfterOperator.d.ts +8 -0
  164. package/types/src/condition/BuiltInOperators/AndOperator.d.ts +12 -0
  165. package/types/src/condition/BuiltInOperators/AverageOperator.d.ts +12 -0
  166. package/types/src/condition/BuiltInOperators/BeforeEqualToOperator.d.ts +8 -0
  167. package/types/src/condition/BuiltInOperators/BeforeOperator.d.ts +8 -0
  168. package/types/src/condition/BuiltInOperators/BetweenOperator.d.ts +12 -0
  169. package/types/src/condition/BuiltInOperators/BlankOperator.d.ts +9 -0
  170. package/types/src/condition/BuiltInOperators/ColorOperator.d.ts +8 -0
  171. package/types/src/condition/BuiltInOperators/ContainsOperator.d.ts +8 -0
  172. package/types/src/condition/BuiltInOperators/EndsWithOperator.d.ts +8 -0
  173. package/types/src/condition/BuiltInOperators/EqualToOperator.d.ts +11 -0
  174. package/types/src/condition/BuiltInOperators/ErrorOperator.d.ts +9 -0
  175. package/types/src/condition/BuiltInOperators/ExpressionOperator.d.ts +17 -0
  176. package/types/src/condition/BuiltInOperators/GreaterThanEqualToOperator.d.ts +8 -0
  177. package/types/src/condition/BuiltInOperators/GreaterThanOperator.d.ts +8 -0
  178. package/types/src/condition/BuiltInOperators/IconOperator.d.ts +8 -0
  179. package/types/src/condition/BuiltInOperators/InSetOperator.d.ts +14 -0
  180. package/types/src/condition/BuiltInOperators/LessThanEqualToOperator.d.ts +8 -0
  181. package/types/src/condition/BuiltInOperators/LessThanOperator.d.ts +8 -0
  182. package/types/src/condition/BuiltInOperators/NotOperator.d.ts +12 -0
  183. package/types/src/condition/BuiltInOperators/OrOperator.d.ts +12 -0
  184. package/types/src/condition/BuiltInOperators/StartsWithOperator.d.ts +8 -0
  185. package/types/src/condition/BuiltInOperators/TimePeriodOperator.d.ts +13 -0
  186. package/types/src/condition/BuiltInOperators/TopNOperator.d.ts +12 -0
  187. package/types/src/condition/BuiltInOperators/UniqueOperator.d.ts +8 -0
  188. package/types/src/condition/BuiltInOperators/ValidEmailOperator.d.ts +8 -0
  189. package/types/src/condition/BuiltInOperators/ValidUrlOperator.d.ts +8 -0
  190. package/types/src/condition/BuiltInOperators/index.d.ts +59 -0
  191. package/types/src/condition/BuiltinSelectors/BaseSelector.d.ts +43 -0
  192. package/types/src/condition/BuiltinSelectors/DateSelector.d.ts +14 -0
  193. package/types/src/condition/BuiltinSelectors/ListSelector.d.ts +12 -0
  194. package/types/src/condition/BuiltinSelectors/TextLengthSelector.d.ts +16 -0
  195. package/types/src/condition/BuiltinSelectors/TimeSelector.d.ts +14 -0
  196. package/types/src/condition/BuiltinSelectors/WholeSelector.d.ts +14 -0
  197. package/types/src/condition/BuiltinSelectors/index.d.ts +18 -0
  198. package/types/src/condition/Condition.d.ts +123 -0
  199. package/types/src/condition/ICondition.d.ts +915 -0
  200. package/types/src/condition/_ConditionUtils.d.ts +190 -0
  201. package/types/src/condition/index.d.ts +3 -0
  202. package/types/src/conditionalFormat/ConditionalEntry.d.ts +20 -0
  203. package/types/src/conditionalFormat/ConditionalFormat.d.ts +190 -0
  204. package/types/src/conditionalFormat/ConditionalFormatCollection.d.ts +20 -0
  205. package/types/src/conditionalFormat/IConditionalFormat.d.ts +518 -0
  206. package/types/src/conditionalFormat/IConditionalFormatCollection.d.ts +70 -0
  207. package/types/src/conditionalFormat/_ConditionalMessages.d.ts +2 -0
  208. package/types/src/conditionalFormat/index.d.ts +3 -0
  209. package/types/src/dataValidation/DataValidation.d.ts +121 -0
  210. package/types/src/dataValidation/DataValidationCollection.d.ts +20 -0
  211. package/types/src/dataValidation/IDataValidation.d.ts +327 -0
  212. package/types/src/dataValidation/IDataValidationCollection.d.ts +63 -0
  213. package/types/src/dataValidation/_DataValidationMessages.d.ts +2 -0
  214. package/types/src/dataValidation/_Utils.d.ts +10 -0
  215. package/types/src/dataValidation/index.d.ts +3 -0
  216. package/types/src/date/DateUtils.d.ts +8 -0
  217. package/types/src/date/_DateUtils.d.ts +122 -0
  218. package/types/src/date/index.d.ts +2 -0
  219. package/types/src/externalBook/ExternalBookCollection.d.ts +36 -0
  220. package/types/src/externalBook/IExternalBook.d.ts +97 -0
  221. package/types/src/externalBook/IExternalBookCollection.d.ts +29 -0
  222. package/types/src/externalBook/index.d.ts +3 -0
  223. package/types/src/fill/IEffect.d.ts +389 -0
  224. package/types/src/fill/IFill.d.ts +597 -0
  225. package/types/src/fill/IStroke.d.ts +265 -0
  226. package/types/src/fill/_BuiltInPatterns.d.ts +27 -0
  227. package/types/src/fill/index.d.ts +4 -0
  228. package/types/src/filter/IFilter.d.ts +83 -0
  229. package/types/src/filter/index.d.ts +2 -0
  230. package/types/src/font/CanvasFontMeasurer.d.ts +25 -0
  231. package/types/src/font/ExtendedTextMetrics.d.ts +1 -0
  232. package/types/src/font/Font.d.ts +19 -0
  233. package/types/src/font/FontKitFontMeasurer.d.ts +11 -0
  234. package/types/src/font/FontUtils.d.ts +9 -0
  235. package/types/src/font/IFont.d.ts +261 -0
  236. package/types/src/font/IFontCollection.d.ts +31 -0
  237. package/types/src/font/SimpleFontMeasurer.d.ts +4 -0
  238. package/types/src/font/_FontUtils.d.ts +22 -0
  239. package/types/src/font/index.d.ts +5 -0
  240. package/types/src/history/IHistory.d.ts +110 -0
  241. package/types/src/history/index.d.ts +2 -0
  242. package/types/src/hyperlink/IHyperlink.d.ts +96 -0
  243. package/types/src/hyperlink/_Hyperlink.d.ts +21 -0
  244. package/types/src/hyperlink/index.d.ts +2 -0
  245. package/types/src/i18n/LanguagePack.d.ts +97 -0
  246. package/types/src/i18n/LocaleProfile.d.ts +15 -0
  247. package/types/src/i18n/_CurrencyData.d.ts +20 -0
  248. package/types/src/i18n/functionLocales.d.ts +6 -0
  249. package/types/src/i18n/index.d.ts +4 -0
  250. package/types/src/i18n/locales.d.ts +3 -0
  251. package/types/src/index.d.ts +71 -0
  252. package/types/src/io/AbstractBackingStore.d.ts +53 -0
  253. package/types/src/io/ArrayBackingStore.d.ts +34 -0
  254. package/types/src/io/IWorkbookIO.d.ts +1322 -0
  255. package/types/src/io/WorkbookIO.d.ts +91 -0
  256. package/types/src/io/WorkbookOrigin.d.ts +114 -0
  257. package/types/src/io/WorkbookRegistry.d.ts +49 -0
  258. package/types/src/io/index.d.ts +5 -0
  259. package/types/src/lib/file/file.browser.d.ts +41 -0
  260. package/types/src/lib/file/file.node.d.ts +25 -0
  261. package/types/src/lib/utils/_Utils.d.ts +20 -0
  262. package/types/src/lib/utils/banner.d.ts +6 -0
  263. package/types/src/lib/utils/utils.browser.d.ts +28 -0
  264. package/types/src/lib/utils/utils.node.d.ts +42 -0
  265. package/types/src/license/LicenseDetails.d.ts +22 -0
  266. package/types/src/license/LicenseManager.d.ts +63 -0
  267. package/types/src/license/index.d.ts +3 -0
  268. package/types/src/license/license-key.d.ts +33 -0
  269. package/types/src/listener/IListener.d.ts +62 -0
  270. package/types/src/listener/ListenerEmitter.d.ts +47 -0
  271. package/types/src/listener/index.d.ts +2 -0
  272. package/types/src/model/AbstractModel.d.ts +90 -0
  273. package/types/src/model/IModel.d.ts +108 -0
  274. package/types/src/model/_ModelMessages.d.ts +2 -0
  275. package/types/src/model/index.d.ts +3 -0
  276. package/types/src/movable/CustomElement.d.ts +42 -0
  277. package/types/src/movable/ICustomElement.d.ts +29 -0
  278. package/types/src/movable/IGroup.d.ts +30 -0
  279. package/types/src/movable/IMovable.d.ts +327 -0
  280. package/types/src/movable/IMovableCollection.d.ts +129 -0
  281. package/types/src/movable/IMovableSelection.d.ts +49 -0
  282. package/types/src/movable/Movable.d.ts +221 -0
  283. package/types/src/movable/MovableCollection.d.ts +29 -0
  284. package/types/src/movable/_MovableUtils.d.ts +4 -0
  285. package/types/src/movable/index.d.ts +4 -0
  286. package/types/src/named/AbstractNamed.d.ts +41 -0
  287. package/types/src/named/INamed.d.ts +225 -0
  288. package/types/src/named/INamedCollection.d.ts +230 -0
  289. package/types/src/named/NamedCollection.d.ts +302 -0
  290. package/types/src/named/_BuiltInNamed.d.ts +6 -0
  291. package/types/src/named/index.d.ts +3 -0
  292. package/types/src/numFmt/BuiltInFormats.d.ts +49 -0
  293. package/types/src/numFmt/IFormatEngine.d.ts +149 -0
  294. package/types/src/numFmt/NumberFormatBuilder.d.ts +46 -0
  295. package/types/src/numFmt/NumberFormatParser.d.ts +168 -0
  296. package/types/src/numFmt/NumberFormatStyles.d.ts +43 -0
  297. package/types/src/numFmt/NumberFormatType.d.ts +79 -0
  298. package/types/src/numFmt/NumfmtFormatEngine.d.ts +33 -0
  299. package/types/src/numFmt/_BuiltInNumberFormats.d.ts +12 -0
  300. package/types/src/numFmt/_FormatCell.d.ts +52 -0
  301. package/types/src/numFmt/_NumFmtUtils.d.ts +102 -0
  302. package/types/src/numFmt/index.d.ts +105 -0
  303. package/types/src/numFmt/vendor/numfmt/_sheetxl.d.ts +15 -0
  304. package/types/src/numFmt/vendor/numfmt/index.d.ts +721 -0
  305. package/types/src/picture/IPicture.d.ts +69 -0
  306. package/types/src/picture/Picture.d.ts +67 -0
  307. package/types/src/picture/index.d.ts +2 -0
  308. package/types/src/primitives/CompositeRangeStats.d.ts +63 -0
  309. package/types/src/primitives/Criteria.d.ts +35 -0
  310. package/types/src/primitives/FormulaContext.d.ts +2 -0
  311. package/types/src/primitives/PrimitiveUtils.d.ts +255 -0
  312. package/types/src/primitives/Range.d.ts +221 -0
  313. package/types/src/primitives/RangeStats.d.ts +48 -0
  314. package/types/src/primitives/ReferenceRange.d.ts +19 -0
  315. package/types/src/primitives/Runtime.d.ts +55 -0
  316. package/types/src/primitives/ScalarCollation.d.ts +174 -0
  317. package/types/src/primitives/TextFold.d.ts +62 -0
  318. package/types/src/primitives/_PrimitiveMessages.d.ts +3 -0
  319. package/types/src/primitives/index.d.ts +7 -0
  320. package/types/src/primitives/stats/AggregateStats.d.ts +119 -0
  321. package/types/src/primitives/stats/Cancellation.d.ts +43 -0
  322. package/types/src/primitives/stats/FrequencyStats.d.ts +94 -0
  323. package/types/src/primitives/stats/Ranked.d.ts +26 -0
  324. package/types/src/primitives/stats/ScalarOrder.d.ts +18 -0
  325. package/types/src/primitives/stats/SortedNumbers.d.ts +48 -0
  326. package/types/src/primitives/stats/index.d.ts +7 -0
  327. package/types/src/print/IPrint.d.ts +234 -0
  328. package/types/src/print/index.d.ts +2 -0
  329. package/types/src/protectedRange/IProtectedRange.d.ts +239 -0
  330. package/types/src/protectedRange/IProtectedRangeCollection.d.ts +73 -0
  331. package/types/src/protectedRange/ProtectedRange.d.ts +101 -0
  332. package/types/src/protectedRange/ProtectedRangeCollection.d.ts +21 -0
  333. package/types/src/protectedRange/index.d.ts +3 -0
  334. package/types/src/protection/DefaultProtection.d.ts +43 -0
  335. package/types/src/protection/IProtection.d.ts +170 -0
  336. package/types/src/protection/PasswordHasher.d.ts +35 -0
  337. package/types/src/protection/index.d.ts +6 -0
  338. package/types/src/resource/IResource.d.ts +98 -0
  339. package/types/src/resource/IResourceCollection.d.ts +96 -0
  340. package/types/src/resource/Resource.d.ts +39 -0
  341. package/types/src/resource/ResourceCollection.d.ts +19 -0
  342. package/types/src/resource/_ResourceMessages.d.ts +4 -0
  343. package/types/src/resource/index.d.ts +5 -0
  344. package/types/src/resource/resourceKinds.d.ts +23 -0
  345. package/types/src/richData/index.d.ts +1 -0
  346. package/types/src/scripting/FunctionCollection.d.ts +88 -0
  347. package/types/src/scripting/IFunctionCollection.d.ts +208 -0
  348. package/types/src/scripting/IModule.d.ts +82 -0
  349. package/types/src/scripting/IModuleCollection.d.ts +79 -0
  350. package/types/src/scripting/IScript.d.ts +289 -0
  351. package/types/src/scripting/ITypedFunction.d.ts +61 -0
  352. package/types/src/scripting/MacroFunction.d.ts +15 -0
  353. package/types/src/scripting/Module.d.ts +39 -0
  354. package/types/src/scripting/ModuleCollection.d.ts +56 -0
  355. package/types/src/scripting/Runtime.d.ts +16 -0
  356. package/types/src/scripting/Scripts.d.ts +79 -0
  357. package/types/src/scripting/TypedFunction.d.ts +161 -0
  358. package/types/src/scripting/_FunctionIndex.d.ts +111 -0
  359. package/types/src/scripting/_FunctionMessages.d.ts +6 -0
  360. package/types/src/scripting/_ModuleUtils.d.ts +5 -0
  361. package/types/src/scripting/_ScriptUtils.d.ts +18 -0
  362. package/types/src/scripting/enumManifest.browser.d.ts +9 -0
  363. package/types/src/scripting/enumManifest.node.d.ts +13 -0
  364. package/types/src/scripting/index.d.ts +4 -0
  365. package/types/src/selection/IRangeSelection.d.ts +307 -0
  366. package/types/src/selection/RangeSelection.d.ts +144 -0
  367. package/types/src/selection/_RangeSelectionUtils.d.ts +32 -0
  368. package/types/src/selection/index.d.ts +2 -0
  369. package/types/src/shape/IShape.d.ts +279 -0
  370. package/types/src/shape/Shape.d.ts +54 -0
  371. package/types/src/shape/index.d.ts +2 -0
  372. package/types/src/sheet/CellRegion.d.ts +106 -0
  373. package/types/src/sheet/ICellContainerOptions.d.ts +97 -0
  374. package/types/src/sheet/ISheet.d.ts +1074 -0
  375. package/types/src/sheet/ISheetCollection.d.ts +70 -0
  376. package/types/src/sheet/NamedCellRange.d.ts +45 -0
  377. package/types/src/sheet/NamedRange.d.ts +30 -0
  378. package/types/src/sheet/Sheet.d.ts +1068 -0
  379. package/types/src/sheet/SheetCell.d.ts +335 -0
  380. package/types/src/sheet/SheetCollection.d.ts +18 -0
  381. package/types/src/sheet/SheetRange.d.ts +362 -0
  382. package/types/src/sheet/SheetRanges.d.ts +225 -0
  383. package/types/src/sheet/_CopyUtils.d.ts +33 -0
  384. package/types/src/sheet/_InvalidSheetRange.d.ts +70 -0
  385. package/types/src/sheet/_SheetAutoFitUtils.d.ts +18 -0
  386. package/types/src/sheet/_SheetCoords.d.ts +54 -0
  387. package/types/src/sheet/_SheetFilterUtils.d.ts +9 -0
  388. package/types/src/sheet/_SheetMessages.d.ts +11 -0
  389. package/types/src/sheet/_SheetMutations.d.ts +137 -0
  390. package/types/src/sheet/_SheetSortUtils.d.ts +9 -0
  391. package/types/src/sheet/_SheetStateReader.d.ts +161 -0
  392. package/types/src/sheet/_SheetStateTypes.d.ts +446 -0
  393. package/types/src/sheet/_SheetUtils.d.ts +265 -0
  394. package/types/src/sheet/clipboard/IHTMLParser.d.ts +92 -0
  395. package/types/src/sheet/clipboard/RangeClipboardItems.d.ts +55 -0
  396. package/types/src/sheet/clipboard/SheetHTMLTableParser.d.ts +29 -0
  397. package/types/src/sheet/clipboard/SheetHTMLTableWriter.d.ts +46 -0
  398. package/types/src/sheet/clipboard/_ClipboardUtils.d.ts +10 -0
  399. package/types/src/sheet/clipboard/index.d.ts +2 -0
  400. package/types/src/sheet/index.d.ts +6 -0
  401. package/types/src/sheet/listener/RangesListener.d.ts +32 -0
  402. package/types/src/sheet/listener/RangesListenerEntry.d.ts +19 -0
  403. package/types/src/sheet/listener/index.d.ts +3 -0
  404. package/types/src/sheet/spatial/MergeEntry.d.ts +17 -0
  405. package/types/src/sheet/spatial/index.d.ts +2 -0
  406. package/types/src/sheet/style/SheetCellStyle.d.ts +540 -0
  407. package/types/src/sheet/style/SheetDirectStyle.d.ts +130 -0
  408. package/types/src/sheet/style/SheetNamedStyle.d.ts +47 -0
  409. package/types/src/sheet/style/SheetTableStyle.d.ts +47 -0
  410. package/types/src/sheet/style/UsedRangeSpatialMap.d.ts +80 -0
  411. package/types/src/sheet/style/_Resolvers.d.ts +41 -0
  412. package/types/src/sheet/style/_StyleUtils.d.ts +69 -0
  413. package/types/src/sheet/style/index.d.ts +1 -0
  414. package/types/src/sheetHeader/ISheetHeader.d.ts +217 -0
  415. package/types/src/sheetHeader/SheetCellHeader.d.ts +61 -0
  416. package/types/src/sheetHeader/SheetCellHeaderRange.d.ts +54 -0
  417. package/types/src/sheetHeader/SheetCellHeaderRanges.d.ts +46 -0
  418. package/types/src/sheetHeader/SheetHeader.d.ts +257 -0
  419. package/types/src/sheetHeader/_HeaderUtils.d.ts +94 -0
  420. package/types/src/sheetHeader/_InvalidSheetHeaderRange.d.ts +7 -0
  421. package/types/src/sheetHeader/index.d.ts +2 -0
  422. package/types/src/sheetProtection/ISheetProtection.d.ts +150 -0
  423. package/types/src/sheetProtection/SheetProtection.d.ts +39 -0
  424. package/types/src/sheetProtection/index.d.ts +2 -0
  425. package/types/src/sheetView/ISheetView.d.ts +439 -0
  426. package/types/src/sheetView/SheetView.d.ts +113 -0
  427. package/types/src/sheetView/_SheetViewUtils.d.ts +19 -0
  428. package/types/src/sheetView/index.d.ts +2 -0
  429. package/types/src/slicer/ISlicer.d.ts +38 -0
  430. package/types/src/slicer/Slicer.d.ts +41 -0
  431. package/types/src/slicer/index.d.ts +2 -0
  432. package/types/src/sort/ISort.d.ts +318 -0
  433. package/types/src/sort/Sort.d.ts +48 -0
  434. package/types/src/sort/_SortUtils.d.ts +12 -0
  435. package/types/src/sort/index.d.ts +3 -0
  436. package/types/src/string/IStringCollection.d.ts +50 -0
  437. package/types/src/string/StringCollection.d.ts +26 -0
  438. package/types/src/string/index.d.ts +3 -0
  439. package/types/src/style/IStyle.d.ts +485 -0
  440. package/types/src/style/IStyleCollection.d.ts +292 -0
  441. package/types/src/style/StyleCollection.d.ts +125 -0
  442. package/types/src/style/_BuiltInStyleDefs.d.ts +18 -0
  443. package/types/src/style/_BuiltInStyleNames.d.ts +20 -0
  444. package/types/src/style/index.d.ts +5 -0
  445. package/types/src/table/AnchoredTable.d.ts +349 -0
  446. package/types/src/table/AutoTable.d.ts +64 -0
  447. package/types/src/table/ITable.d.ts +714 -0
  448. package/types/src/table/ITableCollection.d.ts +88 -0
  449. package/types/src/table/ITableStyle.d.ts +318 -0
  450. package/types/src/table/Table.d.ts +8 -0
  451. package/types/src/table/TableCollection.d.ts +20 -0
  452. package/types/src/table/_AutoTableColumn.d.ts +27 -0
  453. package/types/src/table/_BuiltInTableStyles.d.ts +9 -0
  454. package/types/src/table/_FilterField.d.ts +30 -0
  455. package/types/src/table/_NamedTable.d.ts +84 -0
  456. package/types/src/table/_NamedTableSource.d.ts +57 -0
  457. package/types/src/table/_SortField.d.ts +29 -0
  458. package/types/src/table/_TableColumn.d.ts +51 -0
  459. package/types/src/table/_TableMessages.d.ts +5 -0
  460. package/types/src/table/_TableUtils.d.ts +94 -0
  461. package/types/src/table/index.d.ts +5 -0
  462. package/types/src/text/AutoNumberingScheme.d.ts +175 -0
  463. package/types/src/text/Bullet.d.ts +34 -0
  464. package/types/src/text/IText.d.ts +53 -0
  465. package/types/src/text/ITextFrame.d.ts +313 -0
  466. package/types/src/text/TextBoxAlignment.d.ts +141 -0
  467. package/types/src/text/TextFrame.d.ts +43 -0
  468. package/types/src/text/TextLine.d.ts +24 -0
  469. package/types/src/text/TextParagraph.d.ts +61 -0
  470. package/types/src/text/TextRotation.d.ts +106 -0
  471. package/types/src/text/TextRun.d.ts +85 -0
  472. package/types/src/text/TextUtils.d.ts +165 -0
  473. package/types/src/text/TextVisitor.d.ts +11 -0
  474. package/types/src/text/TextWrapper.d.ts +78 -0
  475. package/types/src/text/_TextUtils.d.ts +90 -0
  476. package/types/src/text/impl/Phrase.d.ts +3 -0
  477. package/types/src/text/impl/TabStrategy.d.ts +9 -0
  478. package/types/src/text/impl/WordWrapUtils.d.ts +6 -0
  479. package/types/src/text/index.d.ts +7 -0
  480. package/types/src/text/richtext/IStyledFont.d.ts +330 -0
  481. package/types/src/text/richtext/index.d.ts +2 -0
  482. package/types/src/theme/ITheme.d.ts +252 -0
  483. package/types/src/theme/IThemeCollection.d.ts +84 -0
  484. package/types/src/theme/ThemeCollection.d.ts +62 -0
  485. package/types/src/theme/_BuiltInColorSchemes.d.ts +3 -0
  486. package/types/src/theme/_BuiltInFontSchemes.d.ts +3 -0
  487. package/types/src/theme/_BuiltInThemeDefs.d.ts +3 -0
  488. package/types/src/theme/_ThemeMessages.d.ts +3 -0
  489. package/types/src/theme/_ThemeUtils.d.ts +3 -0
  490. package/types/src/theme/index.d.ts +4 -0
  491. package/types/src/transaction/ITransaction.d.ts +594 -0
  492. package/types/src/transaction/Transaction.d.ts +184 -0
  493. package/types/src/transaction/TransactionSaveStateManager.d.ts +85 -0
  494. package/types/src/transaction/TransactionUndoManager.d.ts +60 -0
  495. package/types/src/transaction/index.d.ts +5 -0
  496. package/types/src/type/ICollection.d.ts +110 -0
  497. package/types/src/type/IProperties.d.ts +51 -0
  498. package/types/src/type/ITypes.d.ts +69 -0
  499. package/types/src/type/Registry.d.ts +66 -0
  500. package/types/src/type/index.d.ts +5 -0
  501. package/types/src/utils/GeomUtils.d.ts +61 -0
  502. package/types/src/utils/ObjectPath.d.ts +9 -0
  503. package/types/src/utils/Profiler.d.ts +38 -0
  504. package/types/src/utils/_CSSUtils.d.ts +156 -0
  505. package/types/src/utils/_GeomUtils.d.ts +14 -0
  506. package/types/src/utils/_RangeCoordUtils.d.ts +84 -0
  507. package/types/src/utils/_RangeSetUtils.d.ts +55 -0
  508. package/types/src/utils/index.d.ts +2 -0
  509. package/types/src/workbook/IWorkbook.d.ts +711 -0
  510. package/types/src/workbook/Workbook.d.ts +342 -0
  511. package/types/src/workbook/WorkbookRange.d.ts +25 -0
  512. package/types/src/workbook/WorkbookRanges.d.ts +39 -0
  513. package/types/src/workbook/_WorkbookMessages.d.ts +8 -0
  514. package/types/src/workbook/_WorkbookUtils.d.ts +35 -0
  515. package/types/src/workbook/index.d.ts +3 -0
  516. package/types/src/workbookProtection/IWorkbookProtection.d.ts +57 -0
  517. package/types/src/workbookProtection/WorkbookProtection.d.ts +14 -0
  518. package/types/src/workbookProtection/index.d.ts +2 -0
  519. package/types/src/workbookView/IWorkbookView.d.ts +134 -0
  520. package/types/src/workbookView/WorkbookView.d.ts +49 -0
  521. package/types/src/workbookView/index.d.ts +3 -0
  522. package/browser/cjs/-P9BHlnCf8OF6D_m.cjs +0 -6
  523. package/browser/cjs/4kU87sIrnTEoJHwl.cjs +0 -6
  524. package/browser/cjs/B8mBx-uU2X9Qvdnr.cjs +0 -6
  525. package/browser/cjs/BD9lJn7w8OVsIwgC.cjs +0 -6
  526. package/browser/cjs/BI57E6P5MbZI3G2Z.cjs +0 -6
  527. package/browser/cjs/BRgYzaAY9tLpJe7C.cjs +0 -6
  528. package/browser/cjs/BdoGTvcTjso5IcRq.cjs +0 -15
  529. package/browser/cjs/C3ScwpfBnQ8JeHF-.cjs +0 -6
  530. package/browser/cjs/CI8H5FLYtzy-Y2TO.cjs +0 -55
  531. package/browser/cjs/ClUc2Qdf-BFmgsJR.cjs +0 -6
  532. package/browser/cjs/CsEmF6ZwF-2A9AvC.cjs +0 -6
  533. package/browser/cjs/D6eH4loatnriRosn.cjs +0 -124
  534. package/browser/cjs/DJTioC8laMAxiW-z.cjs +0 -6
  535. package/browser/cjs/DN6U4mb4Jt2b37q-.cjs +0 -7
  536. package/browser/cjs/DfNwTsshId9JPwTK.cjs +0 -6
  537. package/browser/cjs/DnQwOaG_1n5GvCnM.cjs +0 -6
  538. package/browser/cjs/DtOYNHcDq5p3S21C.cjs +0 -6
  539. package/browser/cjs/Dy2xo5nrA4OFe7w4.cjs +0 -6
  540. package/browser/cjs/EzhtX7d4GOngN0Se.cjs +0 -6
  541. package/browser/cjs/FBky5iT5me5H1I0-.cjs +0 -6
  542. package/browser/cjs/JcziJrpVHeAEo8Iv.cjs +0 -6
  543. package/browser/cjs/LABm2VcP5Duieabc.cjs +0 -6
  544. package/browser/cjs/OZxxkm3CI5jiE3O-.cjs +0 -6
  545. package/browser/cjs/W8_0e_fQB-spiB55.cjs +0 -6
  546. package/browser/cjs/nS_oDgpzBeOV487v.cjs +0 -6
  547. package/browser/cjs/srhqHYaGNtcM9evy.cjs +0 -6
  548. package/browser/cjs/v2J4J4s0rRAvsx4v.cjs +0 -6
  549. package/browser/esm/8Cdp6eg5fQM4U0CD.mjs +0 -10
  550. package/browser/esm/BvtSjnucMGltTjeM.mjs +0 -426
  551. package/browser/esm/Bzw2Xms8ZtifZcAF.mjs +0 -10
  552. package/browser/esm/C9ojFSLlGrdG3EDE.mjs +0 -10
  553. package/browser/esm/CPxdCZqGhuQENst8.mjs +0 -10
  554. package/browser/esm/CQXqHgLFDd57bQSy.mjs +0 -10
  555. package/browser/esm/CRlsrdZLcL-QKyo2.mjs +0 -12
  556. package/browser/esm/CUqge0vhYI_M8Hpg.mjs +0 -10
  557. package/browser/esm/C__wCYJcwKkBqp8t.mjs +0 -10
  558. package/browser/esm/Cou0jxSdkKrqQBPA.mjs +0 -10
  559. package/browser/esm/CtGy0C3HHvNhQ3j5.mjs +0 -10
  560. package/browser/esm/Ctol2MswJyCxIJcQ.mjs +0 -10
  561. package/browser/esm/D7tUJDQqPM4e3FEC.mjs +0 -10
  562. package/browser/esm/DB5Wpq1m-bJ7gpBF.mjs +0 -10
  563. package/browser/esm/DLXAhFMo3NyECo8b.mjs +0 -23842
  564. package/browser/esm/DTlPJulnTLqG3WSw.mjs +0 -10
  565. package/browser/esm/DwfM2tfEPAzMl86c.mjs +0 -10
  566. package/browser/esm/Dx0TIy0V5EVTNOEZ.mjs +0 -10
  567. package/browser/esm/Dxfd2MfY8kHHUtnu.mjs +0 -4022
  568. package/browser/esm/E0SwR3N6qggAhdBh.mjs +0 -10
  569. package/browser/esm/JGdZf2WBzvkRao7-.mjs +0 -10
  570. package/browser/esm/NAcqiYlYK4mm9q_F.mjs +0 -10
  571. package/browser/esm/NGg21AIVBhRCHoOh.mjs +0 -10
  572. package/browser/esm/PjtmxdNFMVskYmPB.mjs +0 -10
  573. package/browser/esm/a_LQ18tLbXq3N9hu.mjs +0 -10
  574. package/browser/esm/hXx5ZKLpc4RvmCjH.mjs +0 -10
  575. package/browser/esm/zoqPtKWJmGQs1ZUb.mjs +0 -5653
  576. package/node/esm/7QlvuodPxz-B25P9.mjs +0 -10
  577. package/node/esm/8Cdp6eg5fQM4U0CD.mjs +0 -10
  578. package/node/esm/B94PecmbGgqY0k9O.mjs +0 -13
  579. package/node/esm/BpvIVwL4NNRKuaD7.mjs +0 -10
  580. package/node/esm/Bzw2Xms8ZtifZcAF.mjs +0 -10
  581. package/node/esm/C9ojFSLlGrdG3EDE.mjs +0 -10
  582. package/node/esm/CQXqHgLFDd57bQSy.mjs +0 -10
  583. package/node/esm/CSg2ysafDv5h1zz2.mjs +0 -2458
  584. package/node/esm/CUqge0vhYI_M8Hpg.mjs +0 -10
  585. package/node/esm/C__wCYJcwKkBqp8t.mjs +0 -10
  586. package/node/esm/Cou0jxSdkKrqQBPA.mjs +0 -10
  587. package/node/esm/CtlHMovXY4x1NgI6.mjs +0 -10
  588. package/node/esm/Ctol2MswJyCxIJcQ.mjs +0 -10
  589. package/node/esm/Cv3hTIkdeILrJGYc.mjs +0 -10
  590. package/node/esm/D7tUJDQqPM4e3FEC.mjs +0 -10
  591. package/node/esm/DTlPJulnTLqG3WSw.mjs +0 -10
  592. package/node/esm/Dvg1Ay14DLNhMgmD.mjs +0 -10
  593. package/node/esm/DwfM2tfEPAzMl86c.mjs +0 -10
  594. package/node/esm/Dx0TIy0V5EVTNOEZ.mjs +0 -10
  595. package/node/esm/F5A4vdvxqRt8hFAs.mjs +0 -10
  596. package/node/esm/NGg21AIVBhRCHoOh.mjs +0 -10
  597. package/node/esm/PjtmxdNFMVskYmPB.mjs +0 -10
  598. package/node/esm/a_LQ18tLbXq3N9hu.mjs +0 -10
  599. package/node/esm/hXx5ZKLpc4RvmCjH.mjs +0 -10
  600. package/node/esm/lUsLEOryW9viP9g7.mjs +0 -1072
@@ -1,65 +1,3228 @@
1
+ /**
2
+ * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.7.28-beta.1
3
+ *
4
+ * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
+ * License: The license can be found at https://www.sheetxl.com/license.
6
+ */
7
+ import { n as e } from "./Dpwf1IgHZjpEpK-K.mjs";
8
+ import { $t as t, At as n, Bt as r, Cn as i, Ct as a, Dn as o, Dt as s, En as c, Et as l, Ft as u, H as d, Ht as f, It as p, J as m, Jt as h, Kt as g, Lt as _, Mt as v, Nt as y, Ot as ee, Pt as b, Qt as te, Rt as ne, Sn as x, St as re, Tn as ie, Tt as ae, Ut as S, Vt as oe, Wt as se, Xt as ce, Yt as C, Zt as le, _n as ue, _t as de, a as w, an as fe, at as pe, bn as T, bt as me, c as he, cn as ge, ct as _e, d as ve, dn as ye, dt as be, en as E, f as xe, fn as Se, ft as Ce, gn as we, gt as Te, h as Ee, hn as De, ht as Oe, i as ke, in as Ae, it as je, j as Me, jt as D, kt as Ne, l as O, ln as Pe, lt as Fe, m as Ie, mn as Le, mt as Re, n as ze, nn as Be, nt as Ve, o as k, on as He, ot as Ue, p as We, pn as Ge, pt as Ke, qt as qe, r as Je, rn as A, rt as Ye, s as Xe, sn as Ze, st as Qe, t as $e, tn as et, u as tt, un as nt, ut as rt, vn as it, vt as at, wn as j, wt as ot, xn as M, xt as st, yn as ct, yt as lt, z as ut, zt as N } from "./AyOmyt_vaPirbWnn.mjs";
9
+ import { t as dt } from "./CkhE5KvHQvKzw4Ll.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";
1
12
  export * from "@sheetxl/primitives";
2
13
  export * from "@sheetxl/utils";
3
- import { M as t, A as l, B as r, K as i, C as n, W as I, a8 as c, n as C, G as m, E as S, _ as T, s as u, J as F, O as b, U as d, Q as h, q as p, $ as x, p as R, o as U, l as g, X as A, H as k, I as y, a9 as D, a6 as E, Y as M, x as P, a0 as V, v as f, w, a2 as B, a3 as L, L as N, N as W, P as v, a7 as G, R as H, z as O, aa as _, S as j, Z as q, D as z, y as J, a1 as K, u as Q, a4 as X, a5 as Y, i as Z, j as $, k as aa, V as ea, ac as sa, ab as oa } from "./DLXAhFMo3NyECo8b.mjs";
4
- /**
5
- * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.7.27
6
- *
7
- * (C) 2025-present SheetXL Inc. & Michael T. Ford
8
- * License: The license can be found at https://www.sheetxl.com/license.
9
- */
10
- export {
11
- t as AddressUtils,
12
- l as AutoFill,
13
- r as BUILD_DATE,
14
- i as Calculation,
15
- n as Color,
16
- I as DateUtils,
17
- c as ExternalRangeClipboardItem,
18
- C as FontUtils,
19
- m as GeomUtils,
20
- S as IAnchored,
21
- T as IAutoFilter,
22
- u as IBorder,
23
- F as ICalculation,
24
- b as ICell,
25
- d as ICellHeaderRange,
26
- h as ICellRange,
27
- p as IColor,
28
- x as IConditionalFormat,
29
- R as IFill,
30
- U as IFont,
31
- g as IFontCollection,
32
- A as IMovable,
33
- k as IPicture,
34
- y as IPrint,
35
- D as ISheet,
36
- E as ISheetView,
37
- M as ISort,
38
- P as IStyle,
39
- V as ITableStyle,
40
- f as IText,
41
- w as ITextFrame,
42
- B as ITheme,
43
- L as IThemeCollection,
44
- N as LicenseManager,
45
- W as NumberFormat,
46
- v as Picture,
47
- G as RangeClipboardItem,
48
- H as Resource,
49
- O as ResourceCollection,
50
- _ as Sheet,
51
- j as SimpleFontFace,
52
- q as Sort,
53
- z as StringCollection,
54
- J as StyleCollection,
55
- K as Table,
56
- Q as TextUtils,
57
- X as Theme,
58
- Y as ThemeCollection,
59
- Z as TransactionStore,
60
- $ as TransactionUndoManager,
61
- aa as Tuple,
62
- ea as VERSION,
63
- sa as Workbook,
64
- oa as WorkbookView
14
+ var bt;
15
+ bt ||= {};
16
+ var xt = class extends yt {
17
+ constructor(e, t = 50) {
18
+ super(t), this._transactions = e, this._floorId = e ? e.getCurrentCommit(!1).getId() : null, this._removeListener = e?.addListener({ onCommitChange: () => this._notifyOnStackChange() });
19
+ }
20
+ _undoCommits(e = this.maxStack) {
21
+ let t = this._transactions;
22
+ if (!t) return [];
23
+ let n = t.getLog(t.getCurrentCommit(!1).getId(), 2 ** 53 - 1), r = [];
24
+ for (let t = 0; t < n.length && r.length < e; t++) {
25
+ let e = n[t];
26
+ if (e.getId() === this._floorId || t === n.length - 1) break;
27
+ e.getDescription() && r.push(e);
28
+ }
29
+ return r;
30
+ }
31
+ _redoCommits(e = this.maxStack) {
32
+ let t = this._transactions;
33
+ if (!t) return [];
34
+ let n = t.getCurrentCommit(!1).getId(), r = t.getTipCommit().getId();
35
+ if (r === n) return [];
36
+ let i = t.getLog(r, 2 ** 53 - 1), a = [], o = !1;
37
+ for (let e of i) {
38
+ if (e.getId() === n) {
39
+ o = !0;
40
+ break;
41
+ }
42
+ a.push(e);
43
+ }
44
+ if (!o) return [];
45
+ a.reverse();
46
+ let s = [];
47
+ for (let t of a) if (t.getDescription() && s.push(t), s.length >= e) break;
48
+ return s;
49
+ }
50
+ undo(e = 1) {
51
+ let t = this._transactions;
52
+ if (!t) return;
53
+ let n = !1;
54
+ try {
55
+ for (let r = 0; r < e; r++) {
56
+ let [e] = this._undoCommits(1);
57
+ if (!e) break;
58
+ t.revert(e.getId()), n = !0;
59
+ }
60
+ } finally {
61
+ n && this._notifyOnStackChange();
62
+ }
63
+ }
64
+ redo(e = 1) {
65
+ let t = this._transactions;
66
+ if (!t) return;
67
+ let n = !1;
68
+ try {
69
+ for (let r = 0; r < e; r++) {
70
+ let [e] = this._redoCommits(1);
71
+ if (!e) {
72
+ r === 0 && this._repeatOperation?.repeat();
73
+ break;
74
+ }
75
+ t.restore(e.getId()), n = !0;
76
+ }
77
+ } finally {
78
+ n && this._notifyOnStackChange();
79
+ }
80
+ }
81
+ hasUndo() {
82
+ return this._undoCommits(1).length > 0;
83
+ }
84
+ hasRedo() {
85
+ return this._redoCommits(1).length > 0 || this._repeatOperation !== null;
86
+ }
87
+ getTopUndoDescription() {
88
+ return this._undoCommits(1)[0]?.getDescription() ?? null;
89
+ }
90
+ getTopRedoDescription() {
91
+ return this._repeatOperation === null ? this._redoCommits(1)[0]?.getDescription() ?? null : this._repeatOperation.description;
92
+ }
93
+ getUndoDescriptions() {
94
+ return this._undoCommits().map((e) => e.getDescription());
95
+ }
96
+ getRedoDescriptions() {
97
+ let e = this._redoCommits().map((e) => e.getDescription());
98
+ return e.length === 0 && this._repeatOperation !== null && e.push(this._repeatOperation.description), Object.freeze(e);
99
+ }
100
+ addUndoOperation() {
101
+ throw Error("TransactionUndoManager derives its stack from the commit log; commit a described transaction instead.");
102
+ }
103
+ clear(e = !0) {
104
+ this._transactions && (this._floorId = this._transactions.getCurrentCommit(!1).getId()), super.clear(e);
105
+ }
106
+ close() {
107
+ this._removeListener?.();
108
+ }
109
+ }, St = class {
110
+ constructor(e, t) {
111
+ this._dirty = !1, this._store = e, this._savedCommitId = e.getCurrentCommit()?.getId() ?? null, this._emitter = new j(this);
112
+ let n = this;
113
+ this._removeStoreListener = e.addListener({
114
+ onCommitEnd() {
115
+ n._recompute();
116
+ },
117
+ onCommitChange() {
118
+ n._recompute();
119
+ }
120
+ }), this._removeCommitListener = t?.addCommitListener({ onCommit(e) {
121
+ e.store === n._store && n.markSaved(e.commitId);
122
+ } });
123
+ }
124
+ getStore() {
125
+ return this._store;
126
+ }
127
+ isDirty() {
128
+ return (this._store.getCurrentCommit()?.getId() ?? null) !== this._savedCommitId;
129
+ }
130
+ getSavedCommitId() {
131
+ return this._savedCommitId;
132
+ }
133
+ markSaved(e = this._store.getCurrentCommit()?.getId() ?? null) {
134
+ e !== this._savedCommitId && (this._savedCommitId = e ?? null, this._recompute());
135
+ }
136
+ addListeners(e, t) {
137
+ return this._emitter.addListeners(e, t);
138
+ }
139
+ _recompute() {
140
+ let e = this.isDirty();
141
+ e !== this._dirty && (this._dirty = e, this._emitter.notify(e ? "onDirty" : "onClean", { transactional: !1 }));
142
+ }
143
+ close() {
144
+ this._removeStoreListener?.(), this._removeCommitListener?.(), this._emitter.close();
145
+ }
146
+ }, U = class e {
147
+ constructor(t, n = {}) {
148
+ this._password = null, this._emitter = new j(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;
149
+ }
150
+ static _defaultCanWrite(e) {
151
+ return !!e && !/^(https?:|data:|blob:)/i.test(e);
152
+ }
153
+ _cleanPath() {
154
+ return this._path ? this._path.split(/[?#]/)[0] : null;
155
+ }
156
+ getName() {
157
+ if (this._name !== null && this._name !== void 0) return this._name;
158
+ let e = this._cleanPath();
159
+ return e && T(e) || null;
160
+ }
161
+ getPath() {
162
+ return this._path;
163
+ }
164
+ getFormat() {
165
+ return this._format ? this._format : this.getExtension();
166
+ }
167
+ getExtension() {
168
+ let e = this._cleanPath();
169
+ if (!e) return null;
170
+ let t = M(e);
171
+ return t ? t.toLowerCase() : null;
172
+ }
173
+ getEncryption() {
174
+ return this._encryption;
175
+ }
176
+ isEncrypted() {
177
+ return this._encryption !== null || this._password !== null;
178
+ }
179
+ setPassword(e) {
180
+ this._password !== (e ?? null) && (this._password = e ?? null, this._password === null && (this._encryption = null), this._emitter.notify("onChange"));
181
+ }
182
+ getPassword() {
183
+ return this._password;
184
+ }
185
+ getSize() {
186
+ return this._size;
187
+ }
188
+ canWrite() {
189
+ return this._canWrite;
190
+ }
191
+ setName(e) {
192
+ this.update({ name: e });
193
+ }
194
+ update(e) {
195
+ 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;
197
+ }
198
+ addListeners(e, t) {
199
+ return this._emitter.addListeners(e, t);
200
+ }
201
+ get [Symbol.toStringTag]() {
202
+ return "[Origin]";
203
+ }
204
+ toString() {
205
+ let e = this._cleanPath(), t = e ? e.split(/[/\\]/).pop() || e : this._name ?? "(unbound)", n = this._size;
206
+ if (n == null) return t;
207
+ if (n < 1024) return `${t} ${n}B`;
208
+ let r = Math.floor(Math.log(n) / Math.log(1024)), i = [
209
+ "B",
210
+ "KB",
211
+ "MB",
212
+ "GB",
213
+ "TB"
214
+ ];
215
+ return `${t} ${(n / 1024 ** r).toFixed(2)}${i[Math.min(r, i.length - 1)]}`;
216
+ }
217
+ }, Ct = class {
218
+ constructor() {
219
+ this._defaultStringSourceType = "filepath";
220
+ }
221
+ async read(e) {
222
+ let t = e.options ?? {}, n = e.source;
223
+ 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") {
228
+ let e = typeof n == "string" && n.startsWith("file://") ? n.slice(7) : n;
229
+ n = await this.filePathToFile(e), i = "file", s = !0;
230
+ }
231
+ switch (i) {
232
+ case "file": {
233
+ let e = n, t = e?.name, i = t ? `${T(t)}` : "";
234
+ a = await e.arrayBuffer(), o = {
235
+ format: r,
236
+ ext: M(t),
237
+ name: i,
238
+ absolutePath: t,
239
+ size: e.size,
240
+ canWrite: s && this._canWriteLocalPath()
241
+ };
242
+ break;
243
+ }
244
+ case "blob": {
245
+ let e = n;
246
+ a = await e.arrayBuffer(), o = {
247
+ format: r,
248
+ size: e.size
249
+ };
250
+ break;
251
+ }
252
+ case "base64": {
253
+ let e;
254
+ if (n && typeof n == "object" && "base64" in n) e = n.base64;
255
+ else if (typeof n == "string" && n.startsWith("data:")) {
256
+ let [, t] = n.split(",");
257
+ e = t;
258
+ } else e = n;
259
+ a = ft.base64ToArrayBuffer(e), o = {
260
+ format: r,
261
+ size: e.length
262
+ };
263
+ break;
264
+ }
265
+ case "fetch": {
266
+ let e, t, i;
267
+ if (typeof n == "string") e = n;
268
+ else {
269
+ if (!n || typeof n != "object" || !("input" in n)) throw Error("Invalid fetch source provided.");
270
+ {
271
+ let r = n;
272
+ e = r.input, t = r.init, i = r.timeout;
273
+ }
274
+ }
275
+ let s = i || 3e4, c = new AbortController(), l = setTimeout(() => c.abort(), s), u = typeof e == "string" ? e : e.toString(), d = M(u);
276
+ try {
277
+ let n = await fetch(e, {
278
+ ...t,
279
+ signal: c.signal
280
+ });
281
+ 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,
286
+ ext: d,
287
+ name: T(u, !0),
288
+ absolutePath: u
289
+ };
290
+ } catch (e) {
291
+ throw clearTimeout(l), e.name === "AbortError" ? Error(`Fetch timeout after ${s}ms: ${u}`) : e;
292
+ }
293
+ break;
294
+ }
295
+ case "buffer":
296
+ a = n, o = { format: r };
297
+ break;
298
+ case "stream": {
299
+ let e = n.getReader(), t = [], i = 0;
300
+ try {
301
+ for (;;) {
302
+ let { done: n, value: r } = await e.read();
303
+ if (n) break;
304
+ t.push(r), i += r.length;
305
+ }
306
+ } finally {
307
+ e.releaseLock();
308
+ }
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 };
312
+ break;
313
+ }
314
+ default: throw Error(`Unsupported source type: ${i}`);
315
+ }
316
+ let c = await e.decode(a, {
317
+ sourceType: i,
318
+ ...o
319
+ });
320
+ return c ? (await this.onWorkbookRead(c, n), c) : null;
321
+ }
322
+ async resolveSource(e) {
323
+ return null;
324
+ }
325
+ async onWorkbookRead(e, t) {}
326
+ _canWriteLocalPath() {
327
+ return !1;
328
+ }
329
+ _detectSourceType(e) {
330
+ if (e && typeof e == "object" && "base64" in e) return "base64";
331
+ if (e && typeof e == "object" && "input" in e) return "fetch";
332
+ if (typeof e == "string") {
333
+ if (e.startsWith("data:")) return "base64";
334
+ if (e.startsWith("http://") || e.startsWith("https://")) return "fetch";
335
+ if (e.startsWith("file://")) return "filepath";
336
+ let t = this._defaultStringSourceType;
337
+ return e.startsWith("./") || e.startsWith("../") || e.startsWith("/") || /^[a-zA-Z]:[/\\]/.test(e), t;
338
+ }
339
+ if (typeof File < "u" && e instanceof File) return "file";
340
+ 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);
342
+ 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
+ }
344
+ }, wt = class extends Ct {
345
+ constructor(e, t) {
346
+ super(), this._getWriteFormats = e, this._getReadFormats = t, this._defaultStringSourceType = "fetch", this._handleCache = /* @__PURE__ */ new WeakMap(), this._pendingOpenHandle = null;
347
+ }
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);
354
+ }
355
+ async resolveSource() {
356
+ let e = await this._getReadFormats?.() ?? [];
357
+ if (typeof globalThis.showOpenFilePicker == "function") try {
358
+ let t = function(e) {
359
+ let t = Tt(e);
360
+ if (t.length <= 1) return t;
361
+ let n = /* @__PURE__ */ new Set(), r = {};
362
+ 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));
363
+ return [{
364
+ description: "All Supported",
365
+ accept: r
366
+ }, ...t];
367
+ }(e), [n] = await globalThis.showOpenFilePicker(t.length ? { types: t } : void 0);
368
+ return this._pendingOpenHandle = n, await n.getFile();
369
+ } catch (e) {
370
+ if (e?.name === "AbortError") return null;
371
+ throw e;
372
+ }
373
+ let t = e.flatMap((e) => e.exts.map((e) => "." + e)).join(", ");
374
+ return pt.openFileDialog(t);
375
+ }
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;
380
+ }
381
+ }
382
+ async filePathToFile(e) {
383
+ throw Error(`Cannot read local file path '${e}' in browser environment. Use a file input element or fetch for remote URLs.`);
384
+ }
385
+ async write(e) {
386
+ 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
+ if (s) try {
393
+ if (c) {
394
+ let e = await async function(e) {
395
+ try {
396
+ if (typeof e.queryPermission != "function") return "granted";
397
+ let t = { mode: "readwrite" };
398
+ return await e.queryPermission(t) === "granted" || await e.requestPermission(t) === "granted" ? "granted" : "denied";
399
+ } catch {
400
+ return "unavailable";
401
+ }
402
+ }(c);
403
+ if (e === "denied") return null;
404
+ e !== "granted" && (c = void 0);
405
+ }
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;
420
+ } catch (e) {
421
+ 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;
424
+ return function(e, t) {
425
+ let n = URL.createObjectURL(e), r = document.createElement("a");
426
+ 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;
436
+ }
437
+ };
438
+ function Tt(e) {
439
+ return e.map((e) => {
440
+ let t = e.mimeType && e.mimeType.includes("/") ? e.mimeType : "application/octet-stream";
441
+ return {
442
+ description: e.description ?? e.key,
443
+ accept: { [t]: e.exts.map((e) => "." + e) }
444
+ };
445
+ });
446
+ }
447
+ function Et(e) {
448
+ if (typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) {
449
+ let t = new ArrayBuffer(e.byteLength);
450
+ return new Uint8Array(t).set(new Uint8Array(e)), t;
451
+ }
452
+ return e;
453
+ }
454
+ function Dt(e) {
455
+ let t = e.lastIndexOf(".");
456
+ return t >= 0 ? e.slice(t + 1).toLowerCase() : "";
457
+ }
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(A.GenericName.Serif, ["Tahoma"]), W.set(A.GenericName.SanSerif, ["Calibri"]), W.set(A.GenericName.MonoSpace, ["Courier New"]), W.set(A.GenericName.Cursive, ["Comic Sans MS"]), W.set(A.GenericName.Fantasy, ["Luminari"]), W.set(A.GenericName.UISystem, ["Arial"]), W.set(A.GenericName.UISerif, ["Tahoma"]), W.set(A.GenericName.UISanSerif, ["Arial"]), W.set(A.GenericName.UIMonoSpace, ["Courier New"]), W.set(A.GenericName.UIRounded, ["Arial"]), W.set(A.GenericName.Math, []), W.set(A.GenericName.Emoji, []), W.set(A.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 = {
575
+ Value: "value",
576
+ FillColor: "fillColor",
577
+ FontColor: "fontColor",
578
+ 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
+ };
622
+ var Y = ne.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];
647
+ if (t) return { key: t };
648
+ let n = Gt.exec(e);
649
+ return n ? {
650
+ key: Ht,
651
+ params: { n: +n[1] }
652
+ } : (n = Kt.exec(e), n ? {
653
+ key: Ut,
654
+ params: { n: +n[1] }
655
+ } : (n = qt.exec(e), n ? {
656
+ key: Wt,
657
+ params: {
658
+ pct: +n[1],
659
+ n: +n[2]
660
+ }
661
+ } : null));
662
+ }
663
+ var Yt, Xt, Zt, Qt, $t = (e, t, n, i, a) => {
664
+ let o = JSON.parse(JSON.stringify(e.definition));
665
+ o.adjs ||= [];
666
+ let s = "", c = 0, l = 0;
667
+ t > 0 ? (l = t, c = 100 - t, s = H("op.lighterPercent", { percent: t })) : t < 0 && (c = 100 + t, s = H("op.darkerPercent", { percent: -t })), c && o.adjs.push({ [f.AdjustmentType.LumMod]: c }), l && o.adjs.push({ [f.AdjustmentType.LumOff]: l });
668
+ let u = new r({
669
+ val: o.val,
670
+ adjs: o.adjs
671
+ }, n), d = u.toString();
672
+ i?.set(d, u);
673
+ let p = u.toRGBA().toString();
674
+ return a?.set(p, u), {
675
+ description: e.description + ", " + s,
676
+ definition: o
677
+ };
678
+ };
679
+ function en(e, t, n, i) {
680
+ let a = [];
681
+ for (let o = 0; o < e.length; o++) {
682
+ let s = [];
683
+ a.push(s);
684
+ let c = (r) => {
685
+ for (let a = 0; a < r.length; a++) s.push($t(e[o], r[a], t, n, i));
686
+ }, l = new r({
687
+ val: e[o].definition.val,
688
+ adjs: e[o].definition.adjs
689
+ }, t).toHSLA().lum;
690
+ c(l === 0 ? [
691
+ 50,
692
+ 35,
693
+ 25,
694
+ 15,
695
+ 5
696
+ ] : l === 100 ? [
697
+ -5,
698
+ -15,
699
+ -25,
700
+ -35,
701
+ -50
702
+ ] : l <= 20 ? [
703
+ 90,
704
+ 75,
705
+ 50,
706
+ 25,
707
+ 10
708
+ ] : l >= 80 ? [
709
+ -10,
710
+ -25,
711
+ -50,
712
+ -75,
713
+ -90
714
+ ] : [
715
+ 80,
716
+ 60,
717
+ 40,
718
+ -25,
719
+ -50
720
+ ]);
721
+ }
722
+ return a;
723
+ }
724
+ (Yt ||= {}).buildPalette = en, Xt ||= {}, Zt ||= {}, Qt ||= {};
725
+ var X = null;
726
+ function tn() {
727
+ if (!X) {
728
+ let e = import("./BJ5lU2Y0r4Vy8n4q.mjs").then(({ initializeFunctions: e }) => {
729
+ let t = e(() => null);
730
+ return Object.freeze(Array.from(t.keys()));
731
+ });
732
+ e.catch(() => {
733
+ X = null;
734
+ }), X = e;
735
+ }
736
+ return X;
737
+ }
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 r = 0, i = 0;
750
+ if (n.length === 2) {
751
+ let e = n[0].tokenType?.name;
752
+ e === "MinOp" ? (r = -1, i = 1) : e === "PlusOp" && (r = 1, i = 1);
753
+ }
754
+ if (n.length - i !== 1) return;
755
+ let a = n[i], o = a.image;
756
+ try {
757
+ switch (a.tokenType?.name) {
758
+ case "NumberToken":
759
+ case "ScientificDigit":
760
+ case "DigitToken": {
761
+ let e = d(o).value;
762
+ return r === 0 ? e : r * e;
763
+ }
764
+ case "StringToken": return r === 0 ? m(o).value : void 0;
765
+ case "BooleanToken": return r === 0 ? Me(o).value : void 0;
766
+ case "LiteralError":
767
+ case "RefError": return r === 0 ? ut(o).value : void 0;
768
+ default: return;
769
+ }
770
+ } catch {
771
+ return;
772
+ }
773
+ }
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;
777
+ }
778
+ function an(e) {
779
+ if (e === null) return 0;
780
+ switch (typeof e) {
781
+ case "number": return 1;
782
+ case "string": return 2;
783
+ case "boolean": return 3;
784
+ default: return P.isError(e) ? 4 : 5;
785
+ }
786
+ }
787
+ var on = class {
788
+ constructor(e) {
789
+ this._children = e;
790
+ }
791
+ getSize() {
792
+ let e = this._children, t = e.length, n = 0;
793
+ for (let r = 0; r < t; r++) n += e[r].getSize();
794
+ return n;
795
+ }
796
+ getCount() {
797
+ let e = this._children, t = e.length, n = 0;
798
+ for (let r = 0; r < t; r++) n += e[r].getCount();
799
+ return n;
800
+ }
801
+ getAggregates(e) {
802
+ if (e) return this._mergeAggregates(e);
803
+ let t = this._aggregates;
804
+ return t || (t = this._mergeAggregates(), this._aggregates = t), t;
805
+ }
806
+ getSnappedSum(e) {
807
+ let t = e ?? this.getAggregates().sum ?? 0, n = this._children;
808
+ for (let e = n.length - 1; e >= 0; e--) if (n[e].getAggregates().numericalCount > 0) return n[e].getSnappedSum(t);
809
+ return t;
810
+ }
811
+ getSortedNumbers() {
812
+ let e = this._sortedNumbers;
813
+ if (!e) {
814
+ let t = this._children, n = t.length, r = [];
815
+ for (let e = 0; e < n; e++) {
816
+ let n = t[e].getSortedNumbers().getValues();
817
+ n.length > 0 && r.push(n);
818
+ }
819
+ e = new $e(function(e) {
820
+ let t = e.length;
821
+ if (t === 0) return sn;
822
+ if (t === 1) return e[0];
823
+ let n = e[0];
824
+ for (let r = 1; r < t; r++) n = cn(n, e[r]);
825
+ return Object.freeze(n);
826
+ }(r)), this._sortedNumbers = e;
827
+ }
828
+ return e;
829
+ }
830
+ getRanked(e) {
831
+ return ze(this._children, e, rn)[Symbol.iterator]();
832
+ }
833
+ getFrequencies(e) {
834
+ if (e) return this._mergeFrequencies(e);
835
+ let t = this._frequencies;
836
+ return t || (t = this._mergeFrequencies(), this._frequencies = t), t;
837
+ }
838
+ _mergeFrequencies(e) {
839
+ let t = e?.keyFn ?? Oe, n = e?.limit, r = /* @__PURE__ */ new Map(), i = this._children, a = i.length, o = 0, s = 0, c = !1;
840
+ for (let l = 0; l < a; l++) {
841
+ let a = i[l].getFrequencies(e);
842
+ o += a.getVisitedCount(), s += a.getTotalCount(), c ||= a.isTruncated();
843
+ let u = a.getValueCounts(), d = u.next();
844
+ for (; !d.done;) {
845
+ let [e, i] = d.value, a = t(e), o = r.get(a);
846
+ o ? o.count += i : n === void 0 || r.size < n ? r.set(a, {
847
+ value: e,
848
+ count: i
849
+ }) : c = !0, d = u.next();
850
+ }
851
+ }
852
+ return Re.fromGroups(r, t, e, rn, o, s, c);
853
+ }
854
+ getTypedCounts(e) {
855
+ let t = this._typedCounts;
856
+ if (!t) {
857
+ 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
864
+ }, n = this._children, r = n.length;
865
+ for (let t = 0; t < r; t++) {
866
+ 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;
868
+ }
869
+ t = Object.freeze(e), this._typedCounts = t;
870
+ }
871
+ if (e === void 0) return t;
872
+ let n = {}, r = e.length;
873
+ for (let i = 0; i < r; i++) n[e[i]] = t[e[i]] ?? 0;
874
+ return n;
875
+ }
876
+ get isIRangeStats() {
877
+ return !0;
878
+ }
879
+ _mergeAggregates(e) {
880
+ let t = this._children, n = t.length, r = {
881
+ count: 0,
882
+ min: void 0,
883
+ max: void 0,
884
+ numericalCount: 0,
885
+ sum: 0,
886
+ sumSq: 0,
887
+ 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
894
+ }
895
+ };
896
+ for (let i = 0; i < n; i++) {
897
+ let n = t[i].getAggregates(e);
898
+ r.count += n.count;
899
+ let a = n.numericalCount;
900
+ 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
+ }
902
+ return Je(r);
903
+ }
904
+ }, sn = Object.freeze([]);
905
+ function cn(e, t) {
906
+ let n = e.length, r = t.length, i = Array(n + r), a = 0, o = 0, s = 0;
907
+ for (; a < n && o < r;) i[s++] = e[a] <= t[o] ? e[a++] : t[o++];
908
+ for (; a < n;) i[s++] = e[a++];
909
+ for (; o < r;) i[s++] = t[o++];
910
+ return i;
911
+ }
912
+ var ln = class {
913
+ constructor(e) {
914
+ this.isIExternalBook = !0, this._json = e;
915
+ }
916
+ getIdentity() {
917
+ return this._json.identity;
918
+ }
919
+ getSheetNames() {
920
+ return this._json.sheetNames;
921
+ }
922
+ getDefinedNames() {
923
+ return this._json.definedNames ?? [];
924
+ }
925
+ getSheetData(e) {
926
+ return this._json.sheetDataSet?.find((t) => t.sheetIndex === e) ?? null;
927
+ }
928
+ toJSON() {
929
+ return this._json;
930
+ }
931
+ }, un = class {
932
+ constructor(e) {
933
+ this.isIExternalBookCollection = !0, this._items = (e?.json ?? []).map((e) => e ? new ln(e) : null);
934
+ }
935
+ [Symbol.iterator]() {
936
+ return this.getItems()[Symbol.iterator]();
937
+ }
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;
945
+ }
946
+ getCount() {
947
+ return this.getItems().length;
948
+ }
949
+ getByIndex(e) {
950
+ return this._items[e - 1] ?? null;
951
+ }
952
+ 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 c({ 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 j(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;
995
+ }
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;
1006
+ }
1007
+ getCount() {
1008
+ let e = this._getState();
1009
+ return e ? Object.keys(e.modules).length : 0;
1010
+ }
1011
+ beginCommit(e) {
1012
+ return this._beginCommit(e);
1013
+ }
1014
+ _getState() {
1015
+ if (this._closed) throw Error(H("error.model.modelClosed"));
1016
+ return this._transactions.getState(this._stateId);
1017
+ }
1018
+ _beginCommit(e) {
1019
+ return this._transactions.beginCommit(typeof e == "string" ? { description: e } : e);
1020
+ }
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
+ }
1029
+ }
1030
+ _initState(e) {
1031
+ let t = e ?? {};
1032
+ this._updateState({ modules: t }, V("op.initialize"), { forceAmend: !0 });
1033
+ let n = this._options.onAdd;
1034
+ 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
+ }
1040
+ }
1041
+ }
1042
+ addListeners(e, t) {
1043
+ return this._emitter.addListeners(e, t);
1044
+ }
1045
+ 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;
1057
+ }
1058
+ close() {
1059
+ this._closed || (this._emitter.notify("onClose"), this._closed = !0, this._transactionsRemoveListener?.());
1060
+ }
1061
+ get isFunctionCollection() {
1062
+ return !0;
1063
+ }
1064
+ }, fn = (e, t) => {
1065
+ let n = [0];
1066
+ for (let t = 0; t < e.length; t++) e[t] === "\n" && n.push(t + 1);
1067
+ let r = t.map((e) => ` ${((e) => {
1068
+ let t = 0, r = n.length - 1;
1069
+ for (; t < r;) {
1070
+ let i = t + r + 1 >> 1;
1071
+ n[i] <= e ? t = i : r = i - 1;
1072
+ }
1073
+ return `${t + 1}:${e - n[t] + 1}`;
1074
+ })(e.start)} ${e.code}: ${e.message}`), i = t.length;
1075
+ 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 j(this), this._initState();
1079
+ }
1080
+ _initState() {}
1081
+ getModules() {
1082
+ return this._modules;
1083
+ }
1084
+ _builtInNames() {
1085
+ try {
1086
+ let e = this._options.getBuiltInFunctions?.();
1087
+ if (!e) return I.EmptyArray;
1088
+ let t = [];
1089
+ for (let n of e.getItems()) n.isBuiltIn() && t.push(n.getName());
1090
+ return t;
1091
+ } catch {
1092
+ return I.EmptyArray;
1093
+ }
1094
+ }
1095
+ async createModule(e) {
1096
+ let t = await (await import("@sheetxl/scripting")).ScriptCompiler.compile({
1097
+ builtInNames: this._builtInNames(),
1098
+ ...e
1099
+ });
1100
+ return t.module ? await S("scripts", t.module, e?.declarationsOnly ?? !1, t.diagnostics) : null;
1101
+ }
1102
+ addModule(e, t, n) {
1103
+ this._modules.add(e, t, n);
1104
+ }
1105
+ async addModuleFromJSON(e, t, n) {
1106
+ let r = await S(e, t);
1107
+ return this.addModule(e, r, n), r;
1108
+ }
1109
+ executeMacro(e, t, n) {
1110
+ let r = this._modules.getItems({ name: t }), i = r.length;
1111
+ for (let t = 0; t < i; t++) {
1112
+ let i = r[t].getFunctions().getByName(e);
1113
+ if (i) return i.execute(this._options.workbook, {
1114
+ applyResult: !0,
1115
+ ...n
1116
+ });
1117
+ }
1118
+ throw Error(`No macro ${e} found.`);
1119
+ }
1120
+ async run(e, t) {
1121
+ try {
1122
+ let n = typeof e == "string" ? await this.createModule({ source: e }) : await S("scripts", e), r = typeof e == "string" ? e : e?.source ?? "";
1123
+ return await this._runModule(n, r, t);
1124
+ } catch (e) {
1125
+ return {
1126
+ ok: !1,
1127
+ error: e
1128
+ };
1129
+ }
1130
+ }
1131
+ async _runModule(e, t, n) {
1132
+ let r = this._options?.workbook;
1133
+ if (!e) return {
1134
+ ok: !1,
1135
+ error: /* @__PURE__ */ Error("The script did not compile to a module.")
1136
+ };
1137
+ let i = e.getDiagnostics(), a = i.filter((e) => e.severity === "error");
1138
+ if (a.length > 0) {
1139
+ let e = Error(fn(t, a));
1140
+ return e.diagnostics = a, {
1141
+ ok: !1,
1142
+ error: e,
1143
+ diagnostics: i
1144
+ };
1145
+ }
1146
+ let o = e.getFunctions(), s = (await o.search({ type: "autoRun" }))[0] ?? (await o.search({ type: "macro" }))[0] ?? null;
1147
+ if (!s) return {
1148
+ 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)`).")
1150
+ };
1151
+ let c = await s.execute(r, n);
1152
+ return {
1153
+ ok: !0,
1154
+ result: c?.results,
1155
+ commitId: c?.commitId,
1156
+ diagnostics: i
1157
+ };
1158
+ }
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;
1171
+ }
1172
+ async searchFunctions(e) {
1173
+ await this._emitter.notify("onBeforeSearch", { async: !0 });
1174
+ let t = await this._searchable(e);
1175
+ if (t.length === 0) return I.EmptyArray;
1176
+ let n = e?.limit, r = n === void 0 ? e : {
1177
+ ...e,
1178
+ limit: void 0
1179
+ }, i, a = /* @__PURE__ */ new Set();
1180
+ for (let e = 0; e < t.length; e++) {
1181
+ let n = await t[e].search(r);
1182
+ if (n.length !== 0) {
1183
+ i ||= [];
1184
+ for (let e = 0; e < n.length; e++) {
1185
+ let t = n[e], r = t.getName().toUpperCase();
1186
+ a.has(r) || (a.add(r), i.push(t));
1187
+ }
1188
+ }
1189
+ }
1190
+ if (!i || i.length === 0) return I.EmptyArray;
1191
+ let o = e?.text ? e.text.trim().toUpperCase() : null;
1192
+ return o && t.length > 1 && se(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;
1222
+ }
1223
+ async start() {
1224
+ if (!this._modules) return this._startPromise || (this._startPromise = this._doStart(), this._startPromise.catch(() => {
1225
+ this._startPromise = void 0;
1226
+ })), this._startPromise;
1227
+ }
1228
+ async _doStart() {
1229
+ let e = this._options?.workbook, t = this._options?.json, n = {};
1230
+ 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];
1234
+ try {
1235
+ n[i] = await S(i, a);
1236
+ } catch (e) {
1237
+ z.error(`Could not load script '${i}'; it will be unavailable.`, e);
1238
+ }
1239
+ }
1240
+ }
1241
+ let r = this, i = new dn({
1242
+ transactions: this._options?.transactions,
1243
+ initial: n,
1244
+ onRemove: (e, t) => {
1245
+ r._options?.onRemove?.(e, t);
1246
+ },
1247
+ onAdd: (e, t) => {
1248
+ r._emitter.notify("onChange"), r._options?.onAdd?.(e, t);
1249
+ }
1250
+ });
1251
+ this._modules = i;
1252
+ let a = i.getItems();
1253
+ if (a.length === 0) return Promise.resolve(I.EmptyArray);
1254
+ let o = a.length;
1255
+ for (let t = 0; t < o; t++) {
1256
+ let n = a[t];
1257
+ try {
1258
+ let t = await n.getFunctions().search({ type: "autoRun" }), r = t.length;
1259
+ for (let n = 0; n < r; n++) await t[n].execute(e);
1260
+ } catch (e) {
1261
+ z.error("Error executing autoRun script:", e);
1262
+ }
1263
+ }
1264
+ }
1265
+ addListeners(e, t) {
1266
+ return this._emitter.addListeners(e, t);
1267
+ }
1268
+ isReadOnly() {
1269
+ return !1 === this._options.workbook?.getProtection().isStructureAllowed();
1270
+ }
1271
+ toJSON() {
1272
+ this._emitter.notify("onBeforeSave");
1273
+ let e = this._modules;
1274
+ if (!e) throw Error("Scripts is initializing.");
1275
+ return e.toJSON();
1276
+ }
1277
+ }, mn = class {
1278
+ constructor(e, t, n, r) {
1279
+ this._mergedReading = [], this._colsReading = [], this._rowsReading = [], this._styles = n, this._topLeft = t ?? L.EmptyCell, this._sheet = new O({
1280
+ runtime: e,
1281
+ styles: this._styles,
1282
+ container: {
1283
+ getName: () => r,
1284
+ getIndex: () => 1
1285
+ }
1286
+ }), this._builder = this._sheet.getEntireRange().createSparseBuilder();
1287
+ }
1288
+ applyCSSStyle(e, t) {
1289
+ let r = !1;
1290
+ e.style || (e.style = {}, r = !0);
1291
+ let i = e.style, a = { ...t };
1292
+ if (t.msoIgnore) {
1293
+ let e = t.msoIgnore.split(","), n = Object.keys(a);
1294
+ for (let t = 0; t < n.length; t++) {
1295
+ let r = n[t];
1296
+ e.includes(r) && delete a[r];
1297
+ }
1298
+ }
1299
+ let o = n(a.fontFamily);
1300
+ i.font = {}, o && (i.font.family = o.family, i.font.fallbacks = o.fallbacks, i.font.size = o.size), i.font.size = a.fontSize, i.font.weight = a.fontWeight, i.font.style = a.fontStyle, i.font.color = a.color;
1301
+ let c = s(a.textDecoration);
1302
+ i.font.underline = c.underline, i.font.strike = c.strike, a.textUnderlineStyle && (i.font.underline = ee(a.textUnderlineStyle)), i.alignment = {}, a?.textAlign && (i.alignment.horizontal = l(a.textAlign)), a?.textAlign && !i.alignment.horizontal && a?.textAlign !== "general" && (a.textAlign === "center-across" ? i.alignment.horizontal = x.HorizontalAlignment.CenterContinuous : a.textAlign === "fill" ? i.alignment.horizontal = x.HorizontalAlignment.Fill : a.textAlign === "121" || a.textAlign === "010" ? (i.alignment.horizontal = x.HorizontalAlignment.Distributed, i.alignment.justifyLastLine = a.textAlign === "121") : console.warn("unknown text-align", a.textAlign)), a.verticalAlign && (a.verticalAlign.toLowerCase() === "super" ? i.font.verticalAlign = A.VerticalAlignment.Super : a.verticalAlign.toLowerCase() === "sup" ? i.font.verticalAlign = A.VerticalAlignment.Sub : i.alignment.vertical = Ne(a.verticalAlign), i.alignment.vertical || (a.verticalAlign === "121" ? i.alignment.vertical = x.VerticalAlignment.Distributed : console.warn("unknown vertical-align", a.verticalAlign))), a.msoCharIndentCount && (i.alignment.indent = a.msoCharIndentCount), a.whiteSpace && (i.alignment.overflow = a.whiteSpace === "no-wrap" || a.whiteSpace === "nowrap" ? x.Overflow.Visible : x.Overflow.Wrap), a.msoTextControl === "shrinktofit" && (i.alignment.overflow = x.Overflow.Shrink);
1303
+ let u = null;
1304
+ if (a.background ? u = a.background : a.backgroundColor && (u = a.backgroundColor), u && (i.fill = { color: u }), a.msoPattern) {
1305
+ let e = v(a.msoPattern);
1306
+ e && (e.patternType === N.BuiltInSheetPattern.Solid ? i.fill = { color: e.foreground } : e.patternType !== N.BuiltInSheetPattern.None && (u && (e.background = u), i.fill = e));
1307
+ }
1308
+ a.msoRotate !== void 0 && (i.alignment.rotation = ae(a.msoRotate));
1309
+ let d = (e, t) => {
1310
+ e && (i.border ||= {}, i.border[e] = t);
1311
+ };
1312
+ a.border && a.border !== "none" && (d("top", a.border), d("left", a.border), d("right", a.border), d("bottom", a.border)), a.borderTop && d("top", a.borderTop), a.borderLeft && d("left", a.borderLeft), a.borderRight && d("right", a.borderRight), a.borderBottom && d("bottom", a.borderBottom), a.msoDiagonalUp && d("diagonalUp", a.msoDiagonalUp), a.msoDiagonalDown && d("diagonalDown", a.msoDiagonalDown);
1313
+ let f = i.numberFormat;
1314
+ a.msoNumberFormat && (f = y(a.msoNumberFormat), f.includes("\\") ? f = null : f === "Fixed" ? f = E.Styles.lookupStyle(i.numberFormat).formatType === E.Type.Number ? null : E.Type.Number : f === "Percent" && (f = E.Styles.lookupStyle(i.numberFormat).formatType === E.Type.Percentage ? null : E.Type.Percentage)), f && (i.numberFormat = f), e.style = this._styles.normalize(i), r && Object.keys(e.style).length === 0 && delete e.style;
1315
+ }
1316
+ onCell(e, t, n, r, i) {
1317
+ 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") {
1319
+ 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 = A.VerticalAlignment.Sub), i.querySelectorAll("sup").length > 0 && (t.verticalAlign = A.VerticalAlignment.Super), (i.querySelectorAll("b").length > 0 || i.querySelectorAll("strong").length > 0) && (t.weight = 700), i.querySelectorAll("i").length > 0 && (t.style = A.Style.Italic), i.querySelectorAll("u").length > 0 && (t.underline = A.UnderlineStyle.Single), Object.keys(t).length > 0 && (e || (e = {}, o.style = e), e.font ||= t);
1321
+ let n = i.querySelectorAll("a");
1322
+ if (n.length > 0) {
1323
+ let e = n[0].getAttribute("href");
1324
+ e && (o.hyperlink = e);
1325
+ }
1326
+ }
1327
+ if (!L.isSingleCell(e)) {
1328
+ let t = {
1329
+ rowStart: this._topLeft.rowIndex + e.rowStart,
1330
+ colStart: this._topLeft.colIndex + e.colStart,
1331
+ rowEnd: this._topLeft.rowIndex + e.rowEnd,
1332
+ colEnd: this._topLeft.colIndex + e.colEnd
1333
+ };
1334
+ this._mergedReading.push(t);
1335
+ }
1336
+ if (o.value === void 0 && !o.style && Object.keys(o).length <= 1) return;
1337
+ 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) {
1339
+ if (a.msoIgnore.includes("colspan")) {
1340
+ let t = {};
1341
+ a && this.applyCSSStyle(t, a);
1342
+ let n = e.colEnd - e.colStart, r = c.rowIndex + e.rowStart;
1343
+ for (let i = 1; i <= n; i++) s.pushAt(r, c.colIndex + e.colStart + i, t);
1344
+ e = {
1345
+ ...e,
1346
+ colEnd: e.colStart
1347
+ };
1348
+ }
1349
+ a.msoIgnore.includes("rowspan") && (e = {
1350
+ ...e,
1351
+ rowEnd: e.rowStart
1352
+ });
1353
+ }
1354
+ }
1355
+ onNoTable(e, t, n) {
1356
+ this.onCell({
1357
+ rowStart: this._topLeft.rowIndex,
1358
+ colStart: this._topLeft.colIndex,
1359
+ rowEnd: this._topLeft.rowIndex,
1360
+ colEnd: this._topLeft.colIndex
1361
+ }, e, null, t, n);
1362
+ }
1363
+ onRowStart(e, t, n, r) {
1364
+ let i = n(r);
1365
+ if (i.msoHeightSource !== "userset" || !r) return;
1366
+ let a = r.getAttribute("height") ?? i.height, o = null;
1367
+ if (a && (o = D(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 = D(t.getAttribute("height") ?? n(t).height, this._styles.getNormal().getFont().getSize(), "px");
1369
+ i !== null && (o = Math.max(i, o ?? 0));
1370
+ }
1371
+ o !== null && this._rowsReading.push({
1372
+ address: {
1373
+ min: this._topLeft.rowIndex + e,
1374
+ max: this._topLeft.rowIndex + e + t - 1
1375
+ },
1376
+ update: { size: o * A.getDeviceScale() }
1377
+ });
1378
+ }
1379
+ onColumn(e, t, n, r) {
1380
+ let i = n(r);
1381
+ if (i.msoWidthSource !== "userset" || !r) return;
1382
+ let a = r.getAttribute("width") ?? i.width, o = null;
1383
+ a && (o = D(a, this._styles.getNormal().getFont().getSize(), "px")), o !== null && this._colsReading.push({
1384
+ address: {
1385
+ min: this._topLeft.colIndex + e,
1386
+ max: this._topLeft.colIndex + e + t - 1
1387
+ },
1388
+ update: { size: o * A.getDeviceScale() }
1389
+ });
1390
+ }
1391
+ onDone() {
1392
+ this._colsReading.length > 0 && this._sheet.getColumnHeaders().updateHeaderPairs(this._colsReading), this._rowsReading.length > 0 && this._sheet.getRowHeaders().updateHeaderPairs(this._rowsReading), this._sheet.doBatch(() => {
1393
+ this._builder.apply();
1394
+ }), this._mergedReading.length > 0 && this._sheet.getRanges(this._mergedReading).merge();
1395
+ }
1396
+ sheet() {
1397
+ return this._sheet;
1398
+ }
1399
+ }, hn = class {
1400
+ constructor(e) {
1401
+ if (!e) throw new _t("snapshot is required.");
1402
+ this._snapshot = e;
1403
+ }
1404
+ getItemType() {
1405
+ return "range";
1406
+ }
1407
+ getItem() {
1408
+ return this._snapshot;
1409
+ }
1410
+ editMode() {
1411
+ return this._snapshot?.getMarkOptions().editMode ?? null;
1412
+ }
1413
+ isCut() {
1414
+ return this._snapshot?.getMarkOptions().isCut ?? !1;
1415
+ }
1416
+ getName() {
1417
+ return this._snapshot.getName();
1418
+ }
1419
+ toText() {
1420
+ return this._snapshot.toText();
1421
+ }
1422
+ toHtml() {
1423
+ return this._snapshot.toHtml();
1424
+ }
1425
+ toImage() {
1426
+ return this._snapshot.toImage();
1427
+ }
1428
+ get isClipboardItem() {
1429
+ return !0;
1430
+ }
1431
+ }, gn = class {
1432
+ 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;
1435
+ }
1436
+ getItemType() {
1437
+ return "range";
1438
+ }
1439
+ isCut() {
1440
+ return !1;
1441
+ }
1442
+ toText() {
1443
+ return this._native?.text;
1444
+ }
1445
+ toHtml() {
1446
+ return this._native?.html?.documentElement.outerHTML || null;
1447
+ }
1448
+ toImage() {
1449
+ return this._native?.image;
1450
+ }
1451
+ getItem() {
1452
+ let e = this._parsed;
1453
+ if (e === void 0) throw Error("Must call 'parse()' before getItem().");
1454
+ if (e === null) return null;
1455
+ if (this._snapshot) return this._snapshot;
1456
+ let t = this;
1457
+ return this._snapshot = {
1458
+ copyTo: (n, r) => e.copyTo(n, {
1459
+ ...t._markOptions,
1460
+ ...r
1461
+ }),
1462
+ getMarkOptions: () => t._markOptions,
1463
+ getName: () => e?.getName() ?? "Clipboard Data",
1464
+ getCoords: () => e?.getCoords?.() ?? null,
1465
+ toText: () => t.toText(),
1466
+ toHtml: () => t.toHtml(),
1467
+ toImage: () => t.toImage(),
1468
+ getSource: () => e?.getSource?.() ?? null,
1469
+ isISnapshot: !0
1470
+ }, this._snapshot;
1471
+ }
1472
+ async parse() {
1473
+ let e, t = this._native?.text, n = this._native.html;
1474
+ 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);
1477
+ n = e, t = null;
1478
+ } catch {
1479
+ console.warn("Discovered text as html table but could could not parse.");
1480
+ }
1481
+ 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 (We(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;
1491
+ } catch (e) {
1492
+ throw e;
1493
+ }
1494
+ if (!t && !n && this._native.image) {
1495
+ let e = this;
1496
+ 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;
1503
+ },
1504
+ getName: () => "Image"
1505
+ }, !0;
1506
+ }
1507
+ return !1;
1508
+ }
1509
+ get isClipboardItem() {
1510
+ return !0;
1511
+ }
1512
+ }, Z = {
1513
+ showFormulaBar: !0,
1514
+ showTabs: !0,
1515
+ tabRatio: 600,
1516
+ showHorizontalScrollbar: !0,
1517
+ showVerticalScrollbar: !0,
1518
+ showStatusBar: !0,
1519
+ activeSheetId: 0
1520
+ }, Q = class {
1521
+ constructor(e) {
1522
+ this._emitter = new j(this), this._state = { ...Z }, e?.json && this._fromJSON(e?.json);
1523
+ }
1524
+ isShowFormulaBar() {
1525
+ return this._state.showFormulaBar;
1526
+ }
1527
+ setShowFormulaBar(e) {
1528
+ return this._state.showFormulaBar = e, this._emitter.notify("onViewChange"), this;
1529
+ }
1530
+ isShowTabs() {
1531
+ return this._state.showTabs;
1532
+ }
1533
+ setShowTabs(e) {
1534
+ return this._state.showTabs = e, this._emitter.notify("onViewChange"), this;
1535
+ }
1536
+ getTabRatio() {
1537
+ return this._state.tabRatio;
1538
+ }
1539
+ setTabRatio(e) {
1540
+ return this._state.tabRatio = e, this._emitter.notify("onViewChange"), this;
1541
+ }
1542
+ isShowHorizontalScrollbar() {
1543
+ return this._state.showHorizontalScrollbar;
1544
+ }
1545
+ setShowHorizontalScrollbar(e) {
1546
+ return this._state.showHorizontalScrollbar = e, this._emitter.notify("onViewChange"), this;
1547
+ }
1548
+ isShowVerticalScrollbar() {
1549
+ return this._state.showVerticalScrollbar;
1550
+ }
1551
+ setShowVerticalScrollbar(e) {
1552
+ return this._state.showVerticalScrollbar = e, this._emitter.notify("onViewChange"), this;
1553
+ }
1554
+ isShowStatusBar() {
1555
+ return this._state.showStatusBar;
1556
+ }
1557
+ setShowStatusBar(e) {
1558
+ return this._state.showStatusBar = e, this._emitter.notify("onViewChange"), this;
1559
+ }
1560
+ getActiveSheetId() {
1561
+ return this._state.activeSheetId;
1562
+ }
1563
+ setActiveSheetId(e) {
1564
+ let t = this._state, n = t.activeSheetId;
1565
+ return t.activeSheetId = e, n !== e && this._emitter.notify("onViewChange"), this;
1566
+ }
1567
+ addListeners(e, t) {
1568
+ return this._emitter.addListeners(e, t);
1569
+ }
1570
+ toJSON() {
1571
+ let e = {}, t = Object.keys(this._state), n = t.length;
1572
+ for (let r = 0; r < n; r++) {
1573
+ let n = t[r], i = this._state[n];
1574
+ i != null && i !== Z[n] && (e[n] = i);
1575
+ }
1576
+ return Object.keys(e).length === 0 && (e = null), e;
1577
+ }
1578
+ _fromJSON(e, t = !0) {
1579
+ let n = e || {};
1580
+ this.update(n, t);
1581
+ }
1582
+ update(e, t = !0) {
1583
+ this._state = {
1584
+ ...Z,
1585
+ ...this._state,
1586
+ ...e
1587
+ }, t && this._emitter.notify("onViewChange");
1588
+ }
1589
+ get [Symbol.toStringTag]() {
1590
+ return "[WorkbookView]";
1591
+ }
1592
+ toString() {
1593
+ let e = this.toJSON();
1594
+ return e ? JSON.stringify(e) : "DefaultWorkbookView";
1595
+ }
1596
+ }, _n = Object.freeze({
1597
+ structure: !1,
1598
+ windows: !1,
1599
+ revision: !1,
1600
+ password: null,
1601
+ revisionsPassword: null
1602
+ }), vn = class extends a {
1603
+ isWindowsAllowed() {
1604
+ return this._isPropertyAllowed("windows");
1605
+ }
1606
+ isRevisionAllowed() {
1607
+ return this._isPropertyAllowed("revision");
1608
+ }
1609
+ isStructureAllowed() {
1610
+ return this._isPropertyAllowed("structure");
1611
+ }
1612
+ _fromJSON(e) {
1613
+ this._properties = e;
1614
+ }
1615
+ _toJSON(e) {
1616
+ let t = this._properties;
1617
+ if (t) {
1618
+ e = {
1619
+ ...e,
1620
+ ...t
1621
+ };
1622
+ let n = Object.keys(t), r = n.length;
1623
+ for (let i = 0; i < r; i++) {
1624
+ let r = n[i], a = t[r];
1625
+ a != null && a !== _n[r] && (e[r] = a);
1626
+ }
1627
+ }
1628
+ return super._toJSON(e);
1629
+ }
1630
+ get [Symbol.toStringTag]() {
1631
+ return "[WorkbookProtection]";
1632
+ }
65
1633
  };
1634
+ function yn(e) {
1635
+ return H("error.workbook.invalidSheetKey", { key: e });
1636
+ }
1637
+ var bn = class {
1638
+ constructor(e, t) {
1639
+ this._add = e, this._get = t;
1640
+ }
1641
+ add(e) {
1642
+ return this._add(e);
1643
+ }
1644
+ *[Symbol.iterator]() {
1645
+ yield* this.getItems();
1646
+ }
1647
+ getItems(e) {
1648
+ return this._get(e?.name, e?.visibility);
1649
+ }
1650
+ getByName(e) {
1651
+ return this._get(e)?.[0] ?? null;
1652
+ }
1653
+ getCount() {
1654
+ return this._get().length;
1655
+ }
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 });
1659
+ return t === "workbook.defaultSheetName" ? `Sheet${e + 1}` : t;
1660
+ }
1661
+ function wn(e, t) {
1662
+ return {
1663
+ ...Xe,
1664
+ getSheet: () => null,
1665
+ toString: () => C(e, t)
1666
+ };
1667
+ }
1668
+ function Tn(e, t = !1) {
1669
+ if (!e) throw Error(H("error.workbook.sheetNameBlank"));
1670
+ if (xn.test(e)) {
1671
+ if (!t) throw Error(function(e) {
1672
+ return e ? H("error.workbook.sheetNameInvalidCharsNamed", { sheetName: e }) : H("error.workbook.sheetNameInvalidChars");
1673
+ }(e));
1674
+ e = e.replace(xn, "");
1675
+ }
1676
+ if (e.length === 0) throw Error(H("error.workbook.sheetNameBlank"));
1677
+ let n = e.length;
1678
+ if (n > 31) {
1679
+ if (!t) throw Error(H("error.workbook.sheetNameTooLong"));
1680
+ e = e.substring(0, 31);
1681
+ }
1682
+ if (e.charAt(0) === "'" || e.charAt(n - 1) === "'") {
1683
+ if (!t) throw Error(H("error.workbook.sheetNameQuotes"));
1684
+ e = e.replace(/^'|'$/g, "");
1685
+ }
1686
+ return e;
1687
+ }
1688
+ var En, Dn, $ = class e extends he {
1689
+ constructor(e, t, n, r) {
1690
+ super(e, t, r), this._workbook = n;
1691
+ }
1692
+ getSource() {
1693
+ return this._workbook;
1694
+ }
1695
+ _createRanges(t, n) {
1696
+ let r = this._options;
1697
+ return n && (r = {
1698
+ ...this._options,
1699
+ getOptions: k(this._options?.getOptions, n)
1700
+ }), new e(t, this._internal, this._workbook, r);
1701
+ }
1702
+ _createRange(e, n) {
1703
+ let r = e ? { ...e } : null, i = r ? this._workbook._getSheetRef(r.scope, t.Visibility.VeryHidden) : null;
1704
+ if (!i) {
1705
+ let e = this._workbook.getSelectedSheet();
1706
+ return delete r?.scope, wn(r, r ? {
1707
+ scope: qe,
1708
+ ...e.getEntireRange().getCoords()
1709
+ } : null);
1710
+ }
1711
+ let a = this._options;
1712
+ return n && (a = {
1713
+ ...this._options,
1714
+ getOptions: k(this._options.getOptions, n)
1715
+ }), new On(e, w(i.sheet), this._workbook, a);
1716
+ }
1717
+ async select(e) {
1718
+ let t = [], n = null, r = this.getCoords();
1719
+ for (let e = 0; e < r.length; e++) {
1720
+ let i = r[e];
1721
+ i && (n ||= i.scope, i && i.scope === n && t.push(i));
1722
+ }
1723
+ n ||= this._workbook.getSelectedSheet().getName();
1724
+ let i = this._workbook.getSheets().getByName(n);
1725
+ if (!i) return;
1726
+ let a = await i.getRanges(t).select(e), o = this._workbook._rangesAddressToCoords(a.getCoords());
1727
+ return this._createRanges(o);
1728
+ }
1729
+ addListener(e, t) {
1730
+ if (!this.getCoords()) return () => {};
1731
+ let n = this._workbook._sheetToWBEvent(e);
1732
+ return super.addListener(n, t);
1733
+ }
1734
+ get [Symbol.toStringTag]() {
1735
+ return "[WorkbookRanges]";
1736
+ }
1737
+ getAddress(e) {
1738
+ let t = this._internal.getSheet(), n = t.getEntireRange().getCoords();
1739
+ return h(this.getCoords(), {
1740
+ ...n,
1741
+ scope: t.getName()
1742
+ }, C, le, e);
1743
+ }
1744
+ toString() {
1745
+ return this.getAddress();
1746
+ }
1747
+ }, On = class e extends je {
1748
+ constructor(e, t, n, r) {
1749
+ super(e, t, r), this._workbook = n;
1750
+ }
1751
+ _createRanges(e, t) {
1752
+ let n = this._options;
1753
+ return t && (n = {
1754
+ ...this._options,
1755
+ getOptions: k(this._options?.getOptions, t)
1756
+ }), new $(e, this._internal, this._workbook, n);
1757
+ }
1758
+ _createRange(t, n) {
1759
+ let r = this._internal;
1760
+ if (!t) return ke(r.getSheet(), r.getSheet().getEntireCoords());
1761
+ if (r.validateCoords(t), r.getSheet().isClosed()) return ke(null, r.getSheet().getEntireCoords(), t);
1762
+ let i = this._options;
1763
+ return n && (i = {
1764
+ ...this._options,
1765
+ getOptions: k(this._options?.getOptions, n)
1766
+ }), new e(t, this._internal, this._workbook, i);
1767
+ }
1768
+ addListener(e, t) {
1769
+ if (!this.getCoords()) return () => {};
1770
+ let n = this._workbook._sheetToWBEvent(e);
1771
+ return super.addListener(n, t);
1772
+ }
1773
+ get [Symbol.toStringTag]() {
1774
+ return "[WorkbookRange]";
1775
+ }
1776
+ getAddress(e) {
1777
+ let t = this._internal.getSheet(), n = t?.getEntireRange().getCoords() ?? null;
1778
+ return C(this.getCoords(), {
1779
+ ...n,
1780
+ scope: t.getName()
1781
+ });
1782
+ }
1783
+ toString() {
1784
+ return this.getAddress();
1785
+ }
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 n = typeof e == "string" ? { origin: e } : { ...e }, r = n.origin;
1790
+ this._origin = typeof r == "string" ? new U(null, { name: r }) : r ?? new U(null), delete n.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 i = n.json;
1796
+ delete n.json, this._transactions = n.transactions ?? new c(), this._id = this._transactions.create(), this._ownTransactions = !n.transactions, this._emitter = new j(this, this._transactions), this._runtime = n.runtime ?? new Se("Workbook Runtime", {
1797
+ isDate1904: () => this._isDate1904,
1798
+ getLocale: () => this._locale ?? Le() ?? Ge(),
1799
+ getLocaleOverrides: () => this._localeOverrides
1800
+ }), this._listenerLanguage = mt.addChangeListener(() => {
1801
+ this._locale !== null || this._closed || this._notifyAllChange();
1802
+ });
1803
+ let a = this, o = this._beginCommit({ description: V(i ? "op.openWorkbook" : "op.newWorkbook") });
1804
+ try {
1805
+ this._strings = n.strings ?? new lt(), this._ownStrings = !n.strings, this._externalBooks = new un({ json: i?.externalBooks }), this._resources = n.resources ?? new me(), this._ownResources = !n.resources, this._createSheetName = n.createSheetNameCallback ?? Cn;
1806
+ let e = n.createSheetCallback;
1807
+ e ||= (e) => new O(e), this._sheetOnNameChange = /* @__PURE__ */ new Map(), this._sheetOnVisibilityChange = /* @__PURE__ */ new Map(), this._sheetOnIndexChange = /* @__PURE__ */ new Map(), this._createSheet = (n, r, i, o, s) => {
1808
+ let c = null, l = {
1809
+ runtime: a._runtime,
1810
+ readonly: a._options.readonly ?? !1,
1811
+ disableLoadAutoFit: a._options.disableLoadAutoFit ?? !1,
1812
+ formulaTransform: a._options.formulaTransform,
1813
+ opener: a._options.opener,
1814
+ transactions: a._transactions,
1815
+ styles: a._styles,
1816
+ strings: a._strings,
1817
+ resources: a._resources,
1818
+ names: a._names,
1819
+ workbook: a,
1820
+ calculation: a._calculation,
1821
+ resolveRange: (e) => a._options.resolveRange?.(e) ?? a.getRange(e),
1822
+ container: {
1823
+ beforeFromJSON: (e) => {
1824
+ c = e, a._addSheetRef({
1825
+ name: r,
1826
+ id: n,
1827
+ visibility: i ?? t.Visibility.Visible,
1828
+ sheet: e
1829
+ }, o);
1830
+ },
1831
+ getName: () => {
1832
+ let e = a._getSheetRef(c);
1833
+ return e ? e.name : r;
1834
+ },
1835
+ setName: (e, t) => {
1836
+ a._getSheetRef(c) && a._setSheetName(c, e, t);
1837
+ },
1838
+ setNameChangeCallback: (e) => {
1839
+ a._sheetOnNameChange.set(n, e);
1840
+ },
1841
+ getVisibility: () => {
1842
+ let e = a._getSheetRef(c);
1843
+ return e ? e.visibility : t.Visibility.Visible;
1844
+ },
1845
+ setVisibility: (e, t) => {
1846
+ a._setSheetVisibility(c, e, t);
1847
+ },
1848
+ setVisibilityCallback: (e) => {
1849
+ a._sheetOnVisibilityChange.set(n, e);
1850
+ },
1851
+ duplicate: () => a._duplicateSheet(c),
1852
+ getIndex: () => {
1853
+ let e = a._getSheetRef(c);
1854
+ return e ? a._getOffsetForId(e.id, a._getSheetRefs(t.Visibility.VeryHidden)) : o;
1855
+ },
1856
+ setIndex: (e, n) => {
1857
+ let r = a._getSheetRef(c, t.Visibility.VeryHidden);
1858
+ return !!r && (a._moveSheet(r, e, n), !0);
1859
+ },
1860
+ setIndexCallback: (e) => {
1861
+ a._sheetOnIndexChange.set(n, e);
1862
+ },
1863
+ requestSelect: async () => (a._setSelectedSheet(c), await this._emitter.notify("onRequestSelect", {
1864
+ source: a,
1865
+ params: c,
1866
+ async: !0
1867
+ }), a.getSelectedSheet() === c)
1868
+ }
1869
+ };
1870
+ return s && (l.json = s), c = e(l, r, o, i), c;
1871
+ }, this._namedTableSource = new de({
1872
+ getSheets: () => a._sheets ? a.getSheets().getItems() : I.EmptyArray,
1873
+ addSheetsListener: (e, t) => a.addListeners({ onSheetsChange: e }, t)
1874
+ }), this._names = n.names ?? new be({
1875
+ addressToRanges: (e) => a.getRanges(e),
1876
+ getCurrentScope: () => a.getSelectedSheet().getName(),
1877
+ isReadOnly: () => a._options.readonly ?? !1,
1878
+ transactions: a._transactions,
1879
+ getSources: () => a._calculation ? [a._calculation.getNamedFormulas(), a._namedTableSource] : I.EmptyArray
1880
+ }), this._ownNames = !n.names, this._calculation = n.calculation ?? new ve({
1881
+ runtime: a._runtime,
1882
+ functions: n.functions,
1883
+ getActiveCell: () => {
1884
+ let e = a.getSelectedSheet(), t = e?.getSelectedRange()?.getCoords();
1885
+ return t ? {
1886
+ rowIndex: t.rowStart,
1887
+ colIndex: t.colStart,
1888
+ scope: e.getId()
1889
+ } : null;
1890
+ },
1891
+ getRange: a.getRange.bind(a),
1892
+ getRanges: a.getRanges.bind(a),
1893
+ createGraphRanges: (e, t) => a._createGraphRanges(e, t),
1894
+ getSheetIndex: (e) => {
1895
+ if (e === void 0) {
1896
+ let e = a.getSelectedSheet();
1897
+ return e ? this._getSheetRefs(t.Visibility.VeryHidden).findIndex((t) => t.sheet === e) : -1;
1898
+ }
1899
+ let n = this._getSheetRefs(t.Visibility.VeryHidden);
1900
+ e = e.toLowerCase();
1901
+ let r = n.length;
1902
+ for (let t = 0; t < r; t++) if (n[t].name.toLowerCase() === e) return t;
1903
+ try {
1904
+ An.address = e;
1905
+ let n = this._names.getItems(An);
1906
+ if (!n || n.length === 0) return -1;
1907
+ let r = n[0].getRanges?.()?.getCoords()?.[0]?.scope;
1908
+ if (!r) return -1;
1909
+ let i = this._getSheetRefs(t.Visibility.VeryHidden);
1910
+ r = r.toLowerCase();
1911
+ let a = i.length;
1912
+ for (let e = 0; e < a; e++) if (i[e].name.toLowerCase() === r) return e;
1913
+ } catch {
1914
+ return -1;
1915
+ }
1916
+ return -1;
1917
+ },
1918
+ getSheetCount: () => a.getSheets().getItems({ visibility: t.Visibility.VeryHidden }).length,
1919
+ getSheetById: (e) => {
1920
+ let n = a.getSheets().getItems({ visibility: t.Visibility.VeryHidden }), r = n.length;
1921
+ for (let t = 0; t < r; t++) if (n[t].getId() === e) return n[t];
1922
+ return null;
1923
+ },
1924
+ getSheetByName: (e) => {
1925
+ try {
1926
+ return a.getSheets().getByName(e) ?? null;
1927
+ } catch {
1928
+ return null;
1929
+ }
1930
+ },
1931
+ namedCollection: a._names,
1932
+ strings: a._strings,
1933
+ transactions: a._transactions,
1934
+ names: i?.names,
1935
+ formulaTransform: n.formulaTransform
1936
+ }), this._ownCalculation = !n.calculation, this._scripts = this._createScripts(), this._ownNames = !n.names, this._options = Object.freeze({ ...n });
1937
+ let r = async () => {
1938
+ this._ownCalculation && await this._calculation.start(), await this._scripts.start(), this._starting = null;
1939
+ };
1940
+ this._starting = r(), this._starting?.catch(() => {}), i ? this._fromJSON(i) : (this._initState(), this._addSheet(!1)), this._sheets = new bn((e) => a._addSheetOptions(e), (e, t) => {
1941
+ if (e) {
1942
+ let n = this._getSheetRef(e, t);
1943
+ return n ? [n.sheet] : I.EmptyArray;
1944
+ }
1945
+ return this._getSheets(t);
1946
+ }), this._ownCalculation && this._calculation.hydrateNames(), this._emitter.notify("onLoad"), o.commit({ forceAmend: this._ownTransactions });
1947
+ } catch (e) {
1948
+ throw o.rollback(), e;
1949
+ }
1950
+ this._initializing = !1;
1951
+ }
1952
+ _initState() {
1953
+ let e = this._getSheetRefs();
1954
+ for (let t = (e ? e.length : 0) - 1; t >= 0; t--);
1955
+ let t = this._options;
1956
+ this._isDate1904 = t.runtime?.isDate1904() ?? !1, this._locale = null, this._localeOverrides = null, this._theme = t.theme ?? new p().getDefaultTheme(), this._styles = t?.styles ?? new ot(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) => {
1957
+ n._emitter.notify("onProtectionChange");
1958
+ } });
1959
+ let n = this;
1960
+ this._transactionsRemoveListener = this._transactions.addStateListener(this._id, {
1961
+ async onAfterStateChange(e, t, r) {
1962
+ 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) {
1963
+ let r = n.getView().getActiveSheetId();
1964
+ t.view === n.getView() && (r = t.activeSheetId);
1965
+ let i = 0;
1966
+ try {
1967
+ i = n._getOffsetForId(r, e.sheetRefsVisible);
1968
+ } catch {}
1969
+ n._adjustRemoveSelectionIfRequired(i, r);
1970
+ }
1971
+ n._lastTransactionUUID = r.getId(), n._notifyAllChange();
1972
+ },
1973
+ onRestoreOrRevert() {
1974
+ n._ownCalculation, n._emitter.notify("onInvalidated");
1975
+ }
1976
+ });
1977
+ let r = this._getState();
1978
+ r?.listenersSheets && (r?.listenersSheets.forEach((e) => {
1979
+ e();
1980
+ }), r?.listenersSheets.clear()), this._updateState({
1981
+ sheetRefsAll: [],
1982
+ sheetRefsVisibleAndHidden: [],
1983
+ sheetRefsVisible: [],
1984
+ refsById: /* @__PURE__ */ new Map(),
1985
+ sheetsById: /* @__PURE__ */ new Map(),
1986
+ refsByLowerCaseName: /* @__PURE__ */ new Map(),
1987
+ sheetsByLowerCaseName: /* @__PURE__ */ new Map(),
1988
+ refsByInstance: /* @__PURE__ */ new Map(),
1989
+ lastId: -1,
1990
+ sheetsCreated: /* @__PURE__ */ new Set(),
1991
+ listenersSheets: /* @__PURE__ */ new Map()
1992
+ });
1993
+ }
1994
+ getId() {
1995
+ return this._id;
1996
+ }
1997
+ getVersionId() {
1998
+ return this._transactions.getVersionId(this._id);
1999
+ }
2000
+ getName() {
2001
+ return this._closed ? null : this._origin.getName();
2002
+ }
2003
+ getOrigin() {
2004
+ return this._origin;
2005
+ }
2006
+ getView() {
2007
+ return this._view;
2008
+ }
2009
+ setView(e) {
2010
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2011
+ if (!e) throw new R(H("error.sheet.emptyView"));
2012
+ this._listenerWorkbookView?.();
2013
+ let t = this, n = -1;
2014
+ return this._listenerWorkbookView = e.addListeners({ onViewChange: (e) => {
2015
+ let r = t._getState(), i = this._view.getActiveSheetId(), a = r.sheetRefsVisible, o = this._getOffsetForId(i, a);
2016
+ this._activeSheetOffset = o, t._emitter.notify("onViewChange"), n !== i && (t._emitter.notify("onSelectionChange"), t._emitter.notify("onSelectedSheetChange")), n = i;
2017
+ } }), this._view = e, t._emitter.notify("onViewChange"), this;
2018
+ }
2019
+ getRuntime() {
2020
+ return this._runtime;
2021
+ }
2022
+ setDate1904(e) {
2023
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2024
+ return this._isDate1904 = e, this._notifyAllChange(), this;
2025
+ }
2026
+ getLocale() {
2027
+ return this._runtime.getLocale();
2028
+ }
2029
+ getPinnedLocale() {
2030
+ return this._locale;
2031
+ }
2032
+ setLocale(e) {
2033
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2034
+ if (e) try {
2035
+ new Intl.Locale(e);
2036
+ } catch {
2037
+ throw Error(H("error.workbook.invalidLocale", { locale: e }));
2038
+ }
2039
+ return this._locale === e || (this._locale = e, this._notifyAllChange()), this;
2040
+ }
2041
+ getLocaleOverrides() {
2042
+ return this._localeOverrides;
2043
+ }
2044
+ setLocaleOverrides(e) {
2045
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2046
+ let t = e && Object.keys(e).length > 0 ? e : null;
2047
+ return this._localeOverrides = t, this._notifyAllChange(), this;
2048
+ }
2049
+ getStyles() {
2050
+ return this._styles;
2051
+ }
2052
+ getResources() {
2053
+ return this._resources;
2054
+ }
2055
+ getTransactions() {
2056
+ return this._transactions;
2057
+ }
2058
+ getStrings() {
2059
+ return this._strings;
2060
+ }
2061
+ getExternalBooks() {
2062
+ return this._externalBooks;
2063
+ }
2064
+ getTheme() {
2065
+ return this._theme;
2066
+ }
2067
+ setTheme(e) {
2068
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2069
+ if (!e) throw new R(H("error.workbook.notSetValue"));
2070
+ let t = this._theme;
2071
+ return this._theme = e, this.getStyles().setTheme(e), this._emitter.notify("onThemeChange"), t;
2072
+ }
2073
+ getSelectedSheetIndex() {
2074
+ return this._activeSheetOffset;
2075
+ }
2076
+ getSelectedSheet() {
2077
+ let e = this._getSheetRef(this.getSelectedSheetIndex());
2078
+ return e ? e?.sheet : null;
2079
+ }
2080
+ getSheet(e, n = t.Visibility.Visible) {
2081
+ if (e === void 0) return this.getSelectedSheet();
2082
+ if (!e) throw Error(H("error.workbook.sheetNameNotProvided"));
2083
+ let r = this._getSheetRef(e, n);
2084
+ if (!r) throw new B(H("error.workbook.sheetNameNotFound", { sheetName: e }));
2085
+ return r.sheet;
2086
+ }
2087
+ getSheetAt(e, n = t.Visibility.Visible) {
2088
+ let r = this._getSheetRef(e, n);
2089
+ if (!r) throw new B(function(e) {
2090
+ return H("error.workbook.sheetIndexNotFound", { index: e });
2091
+ }(e));
2092
+ return r.sheet;
2093
+ }
2094
+ getSheets() {
2095
+ return this._sheets;
2096
+ }
2097
+ addSheet(e) {
2098
+ return this.getSheets().add(e);
2099
+ }
2100
+ _getSheets(e = t.Visibility.Visible) {
2101
+ let n = this._getSheetRefs(e), r = [], i = n.length;
2102
+ for (let e = 0; e < i; e++) r.push(n[e].sheet);
2103
+ return r;
2104
+ }
2105
+ _getSheetRefs(e = t.Visibility.Visible) {
2106
+ let n = this._getState();
2107
+ return n ? e === t.Visibility.Visible ? n.sheetRefsVisible : e === t.Visibility.Hidden ? n.sheetRefsVisibleAndHidden : e === t.Visibility.VeryHidden ? n.sheetRefsAll : I.EmptyArray : [];
2108
+ }
2109
+ _getSheetRef(e, n = t.Visibility.Visible) {
2110
+ let r = null;
2111
+ return typeof e == "number" ? this._getSheetRefs(n)[e] : (typeof e == "string" ? r = this._getState().refsByLowerCaseName.get(e.toLowerCase()) : e instanceof O ? r = this._getState().refsByInstance.get(e) : e?.id !== void 0 && (r = this._getState().refsById.get(e.id)), r);
2112
+ }
2113
+ _validateNewSheetName(e, t = !0) {
2114
+ if (e == null) return e;
2115
+ if (Tn(e), t && this._getState().sheetsByLowerCaseName.has(e.toLowerCase())) throw new R(H("error.workbook.nameTaken"));
2116
+ return e.substring(0, 31);
2117
+ }
2118
+ findValidSheetName(e) {
2119
+ e &&= Tn(e, !0);
2120
+ try {
2121
+ return function(e, t) {
2122
+ try {
2123
+ if (t(e)) return e;
2124
+ } catch {}
2125
+ let n, r, i = Sn.exec(e);
2126
+ for (i === null ? (n = e + " ", r = 1) : (n = e.substring(0, i.index), r = parseFloat(i[1])); r < 256;) {
2127
+ r++;
2128
+ let e = "(" + r + ")", i = n.substring(0, 31 - e.length) + e;
2129
+ try {
2130
+ if (t(i)) return i;
2131
+ } catch {}
2132
+ }
2133
+ throw Error(e + " is not a valid sheet name");
2134
+ }(e, (e) => this._validateNewSheetName(e));
2135
+ } catch {
2136
+ return this._nextSheetName();
2137
+ }
2138
+ }
2139
+ isValidSheetNameCharacter(e) {
2140
+ return !xn.test(e);
2141
+ }
2142
+ _addSheetOptions(e) {
2143
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2144
+ if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2145
+ let t, n = null;
2146
+ t = typeof e == "string" ? { name: e } : typeof e == "number" ? { index: e } : e, t = {
2147
+ ...t,
2148
+ description: t?.description ?? V("op.addSheet")
2149
+ };
2150
+ let r = this.beginCommit(t);
2151
+ try {
2152
+ let e = t?.autoSelect ?? !1;
2153
+ n = this._addSheet(!0, t.name, t.index ?? null);
2154
+ let i = this.getView().getActiveSheetId(), a, o;
2155
+ if (!1 !== e) {
2156
+ let t = this.getView().getActiveSheetId();
2157
+ t = this._getSheetRef(n).id, e && (a = {
2158
+ view: this.getView(),
2159
+ activeSheetId: i
2160
+ }, o = {
2161
+ view: this.getView(),
2162
+ activeSheetId: t
2163
+ });
2164
+ }
2165
+ if (r.commit({
2166
+ description: H("op.addSheetNamed", { name: n.getName() }),
2167
+ viewBefore: a,
2168
+ viewAfter: o
2169
+ }), !1 !== e) {
2170
+ let t = typeof e == "boolean" ? void 0 : e;
2171
+ n.select(t);
2172
+ }
2173
+ } catch (e) {
2174
+ throw r.rollback(), e;
2175
+ }
2176
+ return n;
2177
+ }
2178
+ _nextSheetName(e = null) {
2179
+ let t = e ? e.toLowerCase() : null, n = this._getState(), r = n.sheetsByLowerCaseName;
2180
+ if (e && r.has(t)) throw new R(function(e) {
2181
+ return H("error.workbook.nameDuplicate", { sheetName: e });
2182
+ }(e));
2183
+ t = (e = this._validateNewSheetName(e)) ? e.toLowerCase() : null;
2184
+ let i = n.lastId + 1;
2185
+ for (; !e;) {
2186
+ let t = this._createSheetName(i), n = t.toLowerCase();
2187
+ r.has(n) ? i++ : e = t;
2188
+ }
2189
+ return this._updateState({ lastId: i }), e;
2190
+ }
2191
+ _addSheet(e, n = null, r = null) {
2192
+ n = this._nextSheetName(n);
2193
+ let i = this._getState(), a = this._createSheet(i.lastId, n, t.Visibility.Visible, r, null);
2194
+ if (!a) throw new R(H("error.workbook.sheetNameBlank"));
2195
+ return e && this._emitter.notify("onSheetsChange"), a;
2196
+ }
2197
+ _updateSheetRefStates(e) {
2198
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2199
+ if (!this._initializing && !this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2200
+ let n = e, r = [], i = [], a = n.length;
2201
+ for (let e = 0; e < a; e++) n[e].visibility === t.Visibility.Visible ? (r.push(n[e]), i.push(n[e])) : n[e].visibility === t.Visibility.Hidden && i.push(n[e]);
2202
+ this._updateState({
2203
+ sheetRefsAll: n,
2204
+ sheetRefsVisible: r,
2205
+ sheetRefsVisibleAndHidden: i
2206
+ });
2207
+ }
2208
+ _addSheetRef(e, n = null) {
2209
+ let r = this._getState(), i = r.sheetRefsAll, a = Math.max(0, Math.min(i.length, n ?? i.length)), o = [
2210
+ ...i.slice(0, a),
2211
+ e,
2212
+ ...i.slice(a)
2213
+ ];
2214
+ this._updateSheetRefStates(o);
2215
+ let s = e.sheet, c = e.name.toLowerCase(), l = new Map(r.refsById);
2216
+ l.set(e.id, e);
2217
+ let u = new Map(r.refsByLowerCaseName);
2218
+ u.set(c, e);
2219
+ let d = new Map(r.refsByInstance);
2220
+ d.set(s, e);
2221
+ let f = new Map(r.sheetsById);
2222
+ f.set(e.id, s);
2223
+ let p = new Map(r.sheetsByLowerCaseName);
2224
+ p.set(c, s);
2225
+ let m = this, h = r.listenersSheets;
2226
+ if (s !== void 0) {
2227
+ let n = s.addListeners({
2228
+ onBeforeDelete: (e) => {
2229
+ m._validateDeleteSheet(e);
2230
+ },
2231
+ onDelete(e) {
2232
+ let n = m._getSheetRef(e, t.Visibility.VeryHidden);
2233
+ if (!n) return;
2234
+ let r = m._beginCommit({ description: H("op.deleteSheet", { name: n.name }) });
2235
+ try {
2236
+ let t = m._getState(), i = t.sheetRefsAll, a = m._getOffsetForId(n.id, i), o = [...i];
2237
+ o.splice(a, 1), m._updateSheetRefStates(o);
2238
+ let c = new Map(t.refsById);
2239
+ c.delete(n.id);
2240
+ let l = new Map(t.sheetsById);
2241
+ l.delete(n.id);
2242
+ let u = n.name.toLowerCase(), d = new Map(t.refsByLowerCaseName);
2243
+ d.delete(u);
2244
+ let f = new Map(t.sheetsByLowerCaseName);
2245
+ f.delete(u);
2246
+ let p = new Map(t.refsByInstance);
2247
+ p.delete(e), t.listenersSheets.get(n.id)();
2248
+ let h = new Map(t.listenersSheets);
2249
+ h.delete(n.id), m._adjustRemoveSelectionIfRequired(a, n.id), m._adjustSheetNamesIfRequired(), m._sheetOnNameChange.delete(n.id), m._sheetOnVisibilityChange.delete(n.id), m._sheetOnIndexChange.delete(n.id), m._emitter.notify("onSheetsChange");
2250
+ let g = new Set(t.sheetsCreated);
2251
+ g.has(s) && g.delete(s), m._updateState({
2252
+ refsById: c,
2253
+ sheetsById: l,
2254
+ refsByLowerCaseName: d,
2255
+ sheetsByLowerCaseName: f,
2256
+ refsByInstance: p,
2257
+ sheetsCreated: g,
2258
+ listenersSheets: h
2259
+ }), r.commit();
2260
+ } catch (e) {
2261
+ throw r.rollback(), e;
2262
+ }
2263
+ }
2264
+ }), i = s.addListeners({ onSelectionChange: (e) => {
2265
+ m.getView().getActiveSheetId() === m._getSheetRef(e)?.id && m._emitter.notify("onSelectionChange", {
2266
+ source: m,
2267
+ params: e
2268
+ });
2269
+ } }, { transactional: !1 });
2270
+ h = new Map(r.listenersSheets), h.set(e.id, () => {
2271
+ n(), i();
2272
+ });
2273
+ }
2274
+ let g = r.lastId;
2275
+ g !== -1 && (g = Math.max(g, e.id)), this._updateState({ lastId: g }), this._updateState({
2276
+ refsById: l,
2277
+ refsByLowerCaseName: u,
2278
+ refsByInstance: d,
2279
+ sheetsById: f,
2280
+ sheetsByLowerCaseName: p,
2281
+ listenersSheets: h
2282
+ }), this._adjustSheetNamesIfRequired();
2283
+ let _ = new Set(this._getState().sheetsCreated);
2284
+ return _.add(e.sheet), this._updateState({ sheetsCreated: _ }), e;
2285
+ }
2286
+ _adjustRemoveSelectionIfRequired(e, t) {
2287
+ if (this._view.getActiveSheetId() === t) {
2288
+ let t, n = this._getState().sheetRefsVisible;
2289
+ t = e < n.length ? n[e].id : n[e - 1].id, this._view.setActiveSheetId(t);
2290
+ }
2291
+ }
2292
+ _adjustSheetNamesIfRequired() {
2293
+ let e = this._getState(), n = e.lastId;
2294
+ if (n === -1) return;
2295
+ let r = this._view.getActiveSheetId();
2296
+ r ??= (this._view.setActiveSheetId(n), n);
2297
+ let i = e.refsById.get(r);
2298
+ i || (this._view.setActiveSheetId(n), i = e.refsById.get(n), r = n), i.visibility === t.Visibility.Visible && (this._activeSheetOffset = this._getOffsetForId(r, e.sheetRefsVisible));
2299
+ }
2300
+ _validateDeleteSheet(e) {
2301
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2302
+ if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2303
+ let t = this._getSheetRef(e);
2304
+ if (!t) throw new R(function(e) {
2305
+ return H("error.workbook.deleteKey", { key: e });
2306
+ }(e));
2307
+ let n = this._getState().sheetRefsVisible;
2308
+ if (n.length === 1 && n[0].id === t.id) throw new R(H("error.workbook.sheetOne"));
2309
+ }
2310
+ _getOffsetForId(e, t) {
2311
+ let n = t.length;
2312
+ for (let r = 0; r < n; r++) if (t[r].id === e) return r;
2313
+ throw new R(H("error.workbook.noVisibleRefs"));
2314
+ }
2315
+ find(e) {
2316
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2317
+ let t = this._getSheets();
2318
+ if (t.length === 1) return t[0].find(e);
2319
+ typeof e == "string" && (e = { text: e });
2320
+ let n = !e?.reverse, r = e?.disableWrap ?? !1, i = this.getSelectedSheetIndex(), a = i, o = t[a], s = !1;
2321
+ e = {
2322
+ ...e,
2323
+ disableWrap: !0
2324
+ };
2325
+ let c, l = o.find(e), u = l.next(), d = !1;
2326
+ if (e?.from) {
2327
+ let t = this._rangesAddressToCoords(e?.from);
2328
+ c = {
2329
+ colIndex: t[0].colStart,
2330
+ rowIndex: t[0].rowStart
2331
+ };
2332
+ }
2333
+ let f = L.createCellComparator(e?.axis, e?.reverse);
2334
+ delete (e = { ...e }).from;
2335
+ let p = () => {
2336
+ 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)) {
2337
+ o = t[a], l = o.find(e);
2338
+ let n = u;
2339
+ return u = l.next(), n;
2340
+ }
2341
+ if (!d && s && a === i && (u.done || !c || !u.done && f(u.value.getCoords(), c) >= 0) && (d = !0), d) {
2342
+ let e = u;
2343
+ return u = ye, e;
2344
+ }
2345
+ let p = u;
2346
+ return u = l.next(), p;
2347
+ };
2348
+ return { next: () => {
2349
+ let e = p();
2350
+ for (; !d && e.done;) e = p();
2351
+ return e;
2352
+ } };
2353
+ }
2354
+ replace(e, t, n) {
2355
+ let r = 0, i = null, a = typeof t == "function", o = n?.maxCount ?? 2 ** 53 - 1, s = !n?.maxCount, c = "", l = typeof t == "string" ? ct(t) : null, u = n?.description ?? V("op.replace"), d = this._transactions.beginCommit({ description: u });
2356
+ try {
2357
+ let u = null, f = null, p = e.next();
2358
+ for (; !p.done && r < o;) {
2359
+ let o = p.value, s = o.getSheet();
2360
+ s !== u && (u = s, f !== null && f.apply(), f = u.getEntireRange().createSparseBuilder({
2361
+ axis: n?.axis,
2362
+ allowUnorderedWrites: !0
2363
+ }));
2364
+ let c = a ? t(o) : t;
2365
+ c !== void 0 && c !== o && (f.push(o, c), r++, i = o), p = e.next();
2366
+ }
2367
+ f?.apply(), r === 1 && o === 1 && i && (c = i.getAddress()), r === 0 ? d.rollback() : d.commit({
2368
+ 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", {
2369
+ address: c,
2370
+ value: l
2371
+ }) : l === null ? V("op.replace") : H("op.replaceWith", { value: l })),
2372
+ viewAfter: { selection: null }
2373
+ });
2374
+ } catch (e) {
2375
+ throw d.rollback(), e;
2376
+ }
2377
+ return {
2378
+ count: r,
2379
+ last: i
2380
+ };
2381
+ }
2382
+ _nextSheetIndex(e, t = this._getSheetRefs()) {
2383
+ let n = t.length;
2384
+ return n === 1 ? 0 : (e === void 0 && (e = this.getSelectedSheetIndex()), (e = Math.max(0, Math.min(e, n - 1))) >= n - 1 ? 0 : e + 1);
2385
+ }
2386
+ _prevSheetIndex(e, t = this._getSheetRefs()) {
2387
+ let n = t.length;
2388
+ return n === 1 ? 0 : (e === void 0 && (e = this.getSelectedSheetIndex()), (e = Math.max(0, Math.min(e, n - 1))) <= 0 ? n - 1 : e - 1);
2389
+ }
2390
+ getNextSheet(e) {
2391
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2392
+ let t = this._getSheetRefs();
2393
+ return t[this._nextSheetIndex(e, t)]?.sheet ?? null;
2394
+ }
2395
+ getPreviousSheet(e) {
2396
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2397
+ let t = this._getSheetRefs();
2398
+ return t[this._prevSheetIndex(e, t)]?.sheet ?? null;
2399
+ }
2400
+ async _duplicateSheet(e) {
2401
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2402
+ if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2403
+ let t = this._getSheetRefs(), n = this.getSelectedSheetIndex(), r = null;
2404
+ if (e) {
2405
+ if (r = this._getSheetRef(e), !r) throw new R(yn(r));
2406
+ } else r = t[n];
2407
+ if (!r) return null;
2408
+ 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() }));
2409
+ try {
2410
+ 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);
2411
+ this._emitter.notify("onSheetsChange"), c = s, l.commit();
2412
+ } catch (e) {
2413
+ throw l.rollback(), e;
2414
+ } finally {
2415
+ s.endPersist(), o.endPersist(), a.endPersist();
2416
+ }
2417
+ return c;
2418
+ }
2419
+ _createRange(e, n) {
2420
+ let r = e ? { ...e } : null, i = r ? this._getSheetRef(r.scope, t.Visibility.VeryHidden) : null;
2421
+ if (!i) {
2422
+ let e = this.getSelectedSheet();
2423
+ return e ? (delete r?.scope, wn(r, r ? {
2424
+ scope: qe,
2425
+ ...e.getEntireRange().getCoords()
2426
+ } : null)) : void console.warn(H("error.workbook.noVisibleRefs"));
2427
+ }
2428
+ let a = i.sheet, o = null;
2429
+ return n && (o = { getOptions: n }), new On(e, w(a), this, o);
2430
+ }
2431
+ _createRanges(e, t) {
2432
+ let n = this.getSelectedSheet(), r = null;
2433
+ return t && (r = { getOptions: t }), new $(e, w(n), this, r);
2434
+ }
2435
+ getRange(e, t) {
2436
+ if (e === void 0) return this.getSelectedRange(t);
2437
+ try {
2438
+ let n = this._rangesAddressToCoords(e);
2439
+ if (n.length !== 1) throw new R(H("error.address.singleRangeOnlyAlt"));
2440
+ return this._createRange(n[0], t);
2441
+ } catch (t) {
2442
+ throw t instanceof B ? new B(t.message) : new R(t.message ?? re(e));
2443
+ }
2444
+ }
2445
+ getCell(e) {
2446
+ if (e === void 0) return this.getSelectedCell();
2447
+ let t = this.getRange(e);
2448
+ if (t.size > 1) throw new R(H("error.address.singleCellOnly"));
2449
+ return t.getCell();
2450
+ }
2451
+ getRanges(e, t) {
2452
+ let n = this._rangesAddressToCoords(e);
2453
+ if (n.length === 0) throw new R(re(e));
2454
+ return this._createRanges(n, t);
2455
+ }
2456
+ _createGraphRanges(e, n) {
2457
+ let r = [];
2458
+ for (let e = 0; e < n.length; e++) {
2459
+ let i = n[e], a = (i.sheetName ? this._getSheetRef(i.sheetName, t.Visibility.VeryHidden) : null)?.sheet ?? this.getSelectedSheet();
2460
+ a && r.push(new Ye(i, w(a), null));
2461
+ }
2462
+ for (let t = 0; t < e.length; t++) r.push(e[t]);
2463
+ return r.length === 0 ? null : new $(r, w(this.getSelectedSheet()), this, null);
2464
+ }
2465
+ getStats(e) {
2466
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2467
+ let n = this._getSheets(t.Visibility.VeryHidden), r = n.length;
2468
+ if (r === 1) return n[0].getStats(e);
2469
+ let i = Array(r);
2470
+ for (let t = 0; t < r; t++) i[t] = n[t].getStats(e);
2471
+ return new on(i);
2472
+ }
2473
+ _activeRangeCoords() {
2474
+ let e = this.getSelectedSheet(), t = e.getSelection().getRanges().getCoords(), n = e.getName(), r = t.length, i = Array(r);
2475
+ for (let e = 0; e < r; e++) {
2476
+ let r = t[e];
2477
+ i[e] = {
2478
+ colStart: r.colStart,
2479
+ colEnd: r.colEnd,
2480
+ rowStart: r.rowStart,
2481
+ rowEnd: r.rowEnd,
2482
+ scope: n
2483
+ };
2484
+ }
2485
+ return i;
2486
+ }
2487
+ getSelectedRange(e) {
2488
+ return this.getRange(this._activeRangeCoords()[0], e);
2489
+ }
2490
+ getSelectedRanges(e) {
2491
+ return this.getRanges(this._activeRangeCoords(), e);
2492
+ }
2493
+ getSelectedCell() {
2494
+ return this.getSelectedSheet().getSelectedCell();
2495
+ }
2496
+ _rangesAddressToCoords(e, n = !0, r = t.Visibility.Hidden) {
2497
+ if (!e) throw new R(H("error.address.noAddress"));
2498
+ let i = this.getSelectedSheet(), a = { ...i?.getEntireRange().getCoords() }, o = i?.getName();
2499
+ if (o && (a.scope = o), typeof e == "string") {
2500
+ let t = e.trim().toLowerCase();
2501
+ if (t === "r" || t === "c") {
2502
+ let n = this.getSelectedCell().getCoords(), r = {};
2503
+ t === "r" ? r.rowStart = r.rowEnd = n.rowIndex : r.colStart = r.colEnd = n.colIndex, e = r;
2504
+ }
2505
+ }
2506
+ let s = this, c = ce(e, a, te, (e) => {
2507
+ if (!n) return null;
2508
+ if (typeof e == "string") {
2509
+ let t = s.getNames().getByName(e)?.getRanges?.();
2510
+ if (t) return t.getCoords();
2511
+ }
2512
+ throw new R(`Invalid sheet reference '${e}'.`);
2513
+ }), l = c.length;
2514
+ for (let e = 0; e < l; e++) this._validateCoords(c[e], r);
2515
+ return c;
2516
+ }
2517
+ _validateCoords(e, n = t.Visibility.Visible, r = H("error.sheet.oobRange")) {
2518
+ if (e === null) return;
2519
+ let i = this.getSheet(e.scope, n).getEntireRange().getCoords();
2520
+ if (!L.isRangeWithinRange(e, i)) throw new B(r);
2521
+ if (e.rowEnd < e.rowStart || e.colEnd < e.colStart) throw new R(H("error.address.invalidRangeInverted"));
2522
+ }
2523
+ _updateSheetRef(e, t) {
2524
+ let n = this._getState(), r = [...n.sheetRefsAll];
2525
+ r[this._getOffsetForId(e.id, n.sheetRefsAll)] = t, this._updateSheetRefStates(r);
2526
+ let i = new Map(n.refsById);
2527
+ i.set(e.id, t);
2528
+ let a = e.name.toLowerCase(), o = t.name.toLowerCase(), s = new Map(n.refsByLowerCaseName);
2529
+ s.delete(a), s.set(o, t);
2530
+ let c = new Map(n.sheetsByLowerCaseName), l = c.get(a);
2531
+ c.delete(a), c.set(o, l);
2532
+ let u = new Map(n.refsByInstance);
2533
+ return u.set(l, t), this._updateState({
2534
+ refsById: i,
2535
+ refsByLowerCaseName: s,
2536
+ sheetsByLowerCaseName: c,
2537
+ refsByInstance: u
2538
+ }), t;
2539
+ }
2540
+ _setSheetName(e, t, n) {
2541
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2542
+ if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2543
+ let r = this._getSheetRef(e);
2544
+ if (!r) throw new R(yn(e));
2545
+ if (t === r.name) return r.sheet;
2546
+ if ((t = this._validateNewSheetName(t)) == null) throw new R(H("error.workbook.sheetNameNotProvided"));
2547
+ let i = Object.freeze({
2548
+ ...r,
2549
+ name: t
2550
+ }), a = null, o = this.beginCommit(V("op.renameSheet"));
2551
+ try {
2552
+ let e = this._updateSheetRef(r, i);
2553
+ this._adjustSheetNamesIfRequired(), this._sheetOnNameChange.forEach((e, t) => {
2554
+ r.id === t && e();
2555
+ }), this._emitter.notify("onSheetsChange"), r.id === this.getView().getActiveSheetId() && this._emitter.notify("onSelectionChange"), a = e.sheet, o.commit(n);
2556
+ } catch (e) {
2557
+ throw o.rollback(), e;
2558
+ }
2559
+ return a;
2560
+ }
2561
+ _setSheetVisibility(e, n = t.Visibility.Visible, r) {
2562
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2563
+ if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2564
+ let i = this._getSheetRef(e, t.Visibility.VeryHidden);
2565
+ if (!i) return null;
2566
+ if (n === i.visibility) return;
2567
+ let a = null, o = "";
2568
+ n === t.Visibility.Visible ? o = V("op.unhideSheet") : n === t.Visibility.Hidden ? o = V("op.hideSheet") : n === t.Visibility.VeryHidden && (o = V("op.veryHideSheet"));
2569
+ let s = this.beginCommit(o);
2570
+ try {
2571
+ let e = this._getState().sheetRefsVisible;
2572
+ if (n !== t.Visibility.Visible && e.length === 1 && e[0].id === i.id) throw new R(H("error.workbook.sheetOne"));
2573
+ let o = {
2574
+ ...i,
2575
+ visibility: n
2576
+ }, c = -1;
2577
+ n !== t.Visibility.Visible && (c = this._getOffsetForId(i.id, e)), a = this._updateSheetRef(i, o).sheet, n !== t.Visibility.Visible && this._adjustRemoveSelectionIfRequired(c, i.id), this._adjustSheetNamesIfRequired(), s.commit(r);
2578
+ } catch (e) {
2579
+ throw s.rollback(), e;
2580
+ }
2581
+ return this._sheetOnVisibilityChange.forEach((e, t) => {
2582
+ i.id === t && e();
2583
+ }), this._emitter.notify("onSheetsChange"), a;
2584
+ }
2585
+ _moveSheet(e, t, n) {
2586
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2587
+ if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2588
+ let r = null, i = this.beginCommit(H("op.moveSheetNamed", { name: e.name }));
2589
+ try {
2590
+ let a = this._getState(), o = a.sheetRefsVisible;
2591
+ if (t < 0 || t > o.length - 1) throw new R(`Invalid to index: ${t}`);
2592
+ let s = {
2593
+ view: this.getView(),
2594
+ activeSheetId: this.getView().getActiveSheetId()
2595
+ }, c = a.sheetRefsAll, l = this._getOffsetForId(e.id, c), u = this._getOffsetForId(o[t].id, c);
2596
+ if (l === u) return;
2597
+ let d = c[l], f = [...c];
2598
+ f.splice(l, 1), f.splice(u, 0, d), this._updateSheetRefStates(f), this._adjustSheetNamesIfRequired(), this._sheetOnIndexChange.forEach((e, t) => {
2599
+ t >= l && t <= u && e();
2600
+ }), this._emitter.notify("onSheetsChange"), r = d.sheet, i.commit({
2601
+ ...n,
2602
+ viewBefore: s,
2603
+ viewAfter: {
2604
+ view: this.getView(),
2605
+ activeSheetId: this.getView().getActiveSheetId()
2606
+ }
2607
+ });
2608
+ } catch (e) {
2609
+ throw i.rollback(), e;
2610
+ }
2611
+ return r;
2612
+ }
2613
+ _setSelectedSheet(e) {
2614
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2615
+ let n = this._getSheetRef(e);
2616
+ if (!n) throw new R(yn(e));
2617
+ let r = null;
2618
+ return n.visibility !== t.Visibility.Visible && this._setSheetVisibility(n, t.Visibility.Visible), this._view.setActiveSheetId(n.id), r = n.sheet, r;
2619
+ }
2620
+ getProtection() {
2621
+ return this._protection;
2622
+ }
2623
+ getNames() {
2624
+ return this._names;
2625
+ }
2626
+ getCalculation() {
2627
+ return this._calculation;
2628
+ }
2629
+ createFormula(e, t) {
2630
+ return this.getCalculation().createFormula(e, t);
2631
+ }
2632
+ evaluate(e, t) {
2633
+ return this.getCalculation().evaluate(e, t);
2634
+ }
2635
+ whenCalculationReady() {
2636
+ return this.getCalculation().ready();
2637
+ }
2638
+ getScripts() {
2639
+ return this._scripts ||= this._createScripts(), this._scripts;
2640
+ }
2641
+ _notifyAllChange() {
2642
+ this._emitter.notify("onSheetsChange"), this._emitter.notify("onSelectedSheetChange"), this._emitter.notify("onViewChange");
2643
+ }
2644
+ addListeners(e, t) {
2645
+ return this._emitter.addListeners(e, t);
2646
+ }
2647
+ _sheetToWBEvent(e) {
2648
+ let t = this;
2649
+ return (n) => {
2650
+ let r = () => {
2651
+ let e = n.getSource();
2652
+ if (e.isICellRanges) {
2653
+ let n = [...e.getCoords()], r = n.length;
2654
+ for (let t = 0; t < r; t++) {
2655
+ let r = n[t];
2656
+ !r.scope && e.getSheet().getName() && (n[t] = {
2657
+ ...r,
2658
+ scope: e.getSheet().getName()
2659
+ });
2660
+ }
2661
+ return t.getRanges(n);
2662
+ }
2663
+ if (e.isICellRange) {
2664
+ let n = e.getCoords(), r = e.getSheet().getName();
2665
+ return t.getRange({
2666
+ ...n,
2667
+ scope: r
2668
+ });
2669
+ }
2670
+ };
2671
+ e({
2672
+ getSource: r,
2673
+ trigger: n.trigger,
2674
+ getFrom: () => t.getRanges(n.getFrom()),
2675
+ getTo: () => t.getRange(n.getTo()),
2676
+ isDataChange: n.isDataChange,
2677
+ getTransactionId: n.getTransactionId,
2678
+ isUndo: n.isUndo,
2679
+ toString: () => `WorkbookRangeEvent: ('${n.trigger}', ${r().toString()})`,
2680
+ timeStamp: Date.now()
2681
+ });
2682
+ };
2683
+ }
2684
+ _fromJSON(e) {
2685
+ if (this._emitter.notify("onBeforeLoad", { params: e }), this._initState(), !e.sheets || e.sheets.length === 0) throw new R(H("error.workbook.sheetOne"));
2686
+ e.theme && (this._theme = new u(e.theme), this._styles.setTheme(this._theme));
2687
+ let n = this._strings.beginPersist(), r = this._resources.beginPersist(), i = this._styles.beginPersist();
2688
+ try {
2689
+ n.fromJSON(e.strings), r.fromJSON(e.resources), i.fromJSON(e.styles), e.date1904 && (this._isDate1904 = !0), e.locale && (this._locale = e.locale), e.localeOverrides && (this._localeOverrides = e.localeOverrides), e.view ||= {};
2690
+ let a = e.sheets, o = a.length, s = e.view.activeSheetId ?? null;
2691
+ s !== null && (s = Math.min(Math.max(0, s), o - 1));
2692
+ let c = null, l = null, u = -1;
2693
+ for (let e = 0; e < o; e++) {
2694
+ let n = a[e], r = n.visibility || t.Visibility.Visible, i = e;
2695
+ l = i, r === t.Visibility.Visible ? (u++, c === null && (c = i)) : s !== null && s === i && (s = null), this._createSheet(i, n.name, r, u, n.sheet);
2696
+ }
2697
+ this._updateState({ lastId: l }), e.view.activeSheetId = s ?? c, this.setView(new Q({ json: e.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
2698
+ let d = this;
2699
+ this._protection = new vn(e?.protection, this._options?.readonly), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
2700
+ d._emitter.notify("onProtectionChange", { source: e });
2701
+ } }), e.scripts && (this._scripts = this._createScripts(e.scripts)), this._emitter.notify("onLoad");
2702
+ } finally {
2703
+ i.endPersist(), r.endPersist(), n.endPersist();
2704
+ }
2705
+ }
2706
+ _createScripts(e) {
2707
+ let t = this;
2708
+ return new pn({
2709
+ transactions: this._transactions,
2710
+ json: e,
2711
+ workbook: t,
2712
+ getBuiltInFunctions: () => t._calculation?.getFunctions(),
2713
+ onAdd: (e, n) => {
2714
+ let r = t._calculation;
2715
+ r.getStatus() !== Ve.Status.Off && r.start().then(async () => {
2716
+ let e = n.getFunctions().getItems({ type: "formula" }), t = e.length;
2717
+ for (let n = 0; n < t; n++) {
2718
+ let t = e[n];
2719
+ try {
2720
+ await this._calculation.getFunctions().add(t);
2721
+ } catch (e) {
2722
+ z.error(e?.message ?? String(e), e);
2723
+ }
2724
+ }
2725
+ }).catch(() => {});
2726
+ },
2727
+ onRemove: (e, t) => {}
2728
+ });
2729
+ }
2730
+ async toJSON(e) {
2731
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2732
+ await Promise.resolve(this._starting), await this._emitter.notify("onBeforeSave", { async: !0 });
2733
+ let n = { sheets: [] }, r = e?.ignoreStyles ?? !1;
2734
+ if (!r) {
2735
+ let e = this._theme.toJSON();
2736
+ (e ? Object.keys(e).length : 0) > 0 && (n.theme = e);
2737
+ }
2738
+ if (this._scripts) {
2739
+ let e = this._scripts.toJSON();
2740
+ e && Object.keys(e).length > 0 && (n.scripts = e);
2741
+ }
2742
+ this._isDate1904 && (n.date1904 = !0), this._locale && (n.locale = this._locale), this._localeOverrides && (n.localeOverrides = this._localeOverrides);
2743
+ let i = e?.ignoreResources ?? !1, a = this._strings.beginPersist(), o = i ? null : this._resources.beginPersist(), s = this._styles.beginPersist();
2744
+ try {
2745
+ let c = this._getSheetRef(this.getSelectedSheetIndex()).id, l = c, u = null, d = this._getState(), f = d.sheetRefsAll, p = d.sheetsById, m = f.length;
2746
+ for (let r = 0; r < m; r++) {
2747
+ let i = f[r], a = r + 1, o = await p.get(i.id).toJSON(e), s = {
2748
+ name: i.name,
2749
+ sheet: o
2750
+ };
2751
+ i.visibility === t.Visibility.Visible ? u === null && (u = a) : s.visibility = i.visibility, i.id === c && (l = a), n.sheets.push(s);
2752
+ }
2753
+ if (!r) {
2754
+ let e = s.toJSON();
2755
+ e && Object.keys(e).length > 0 && (n.styles = e);
2756
+ }
2757
+ let h = this.getProtection().toJSON();
2758
+ h && (n.protection = h);
2759
+ let g = await a.toJSONAsync();
2760
+ g && g.length > 0 && (n.strings = g);
2761
+ let _ = this._externalBooks.toJSON();
2762
+ if (_ && (n.externalBooks = _), !i) {
2763
+ let e = await o.toJSONAsync();
2764
+ e && e.length > 0 && (n.resources = e);
2765
+ }
2766
+ let v = this._calculation.getNamedFormulas().toJSON();
2767
+ v && v.length > 0 && (n.names = v);
2768
+ let y = this._view.toJSON();
2769
+ y && (l === u ? delete y.activeSheetId : y.activeSheetId = l, Object.keys(y).length > 0 && (n.view = y));
2770
+ } finally {
2771
+ s.endPersist(), i || o.endPersist(), a.endPersist();
2772
+ }
2773
+ return this._emitter.notify("onSave", { params: n }), n;
2774
+ }
2775
+ isClosed() {
2776
+ return this._closed;
2777
+ }
2778
+ close() {
2779
+ if (this._closed) return;
2780
+ this._emitter.notify("onClose");
2781
+ let e = this._getState();
2782
+ e.listenersSheets.forEach((e) => {
2783
+ e();
2784
+ }), e.listenersSheets.clear();
2785
+ let t = e.sheetRefsAll;
2786
+ for (let e = t.length - 1; e >= 0; e--) try {
2787
+ t[e].sheet.close();
2788
+ } catch (e) {
2789
+ console.warn("error on close", e);
2790
+ }
2791
+ this._ownResources, this._ownNames && this._names.close(), this._ownCalculation && this._calculation.close(), this._ownStyles, this._transactionsRemoveListener?.(), this._listenerLanguage?.(), this._listenerOrigin?.(), this._closed = !0;
2792
+ }
2793
+ beginCommit(e) {
2794
+ if (this._closed) throw Error(H("error.workbook.modelClosed"));
2795
+ return this._beginCommit(typeof e == "string" ? { description: e } : e);
2796
+ }
2797
+ doBatch(e, t) {
2798
+ let n = this;
2799
+ return t = typeof t == "string" ? { description: t } : {
2800
+ description: V("op.updateWorkbook"),
2801
+ ...t
2802
+ }, this._transactions.doBatch(e, t, (e, t) => {
2803
+ e.getDepth() === 0 && (n._lastTransactionUUID = e.getId());
2804
+ });
2805
+ }
2806
+ _beginCommit(e) {
2807
+ let t = this;
2808
+ return this._transactions.beginCommit(typeof e == "string" ? { description: e } : e, (e) => {
2809
+ e.getDepth() === 0 && (t._lastTransactionUUID = e.getId());
2810
+ });
2811
+ }
2812
+ _getState() {
2813
+ return this._transactions.getState(this._id);
2814
+ }
2815
+ _updateState(e, t = V("op.updateWorkbook"), n) {
2816
+ if (!e) return;
2817
+ let r = this._beginCommit(t);
2818
+ try {
2819
+ r.updateState(this._id, e), r.commit(n);
2820
+ } catch (e) {
2821
+ throw r.rollback(), e;
2822
+ }
2823
+ }
2824
+ get options() {
2825
+ return this._options;
2826
+ }
2827
+ get [Symbol.toStringTag]() {
2828
+ return "[Workbook]";
2829
+ }
2830
+ toString() {
2831
+ return `[${this.getName() ?? "(untitled)"}]`;
2832
+ }
2833
+ get isIWorkbook() {
2834
+ return !0;
2835
+ }
2836
+ }, An = { address: null }, jn = class {
2837
+ constructor() {
2838
+ this._readFormats = [], this._writeFormats = [], this._encryptions = [];
2839
+ }
2840
+ async registerReadFormat(e) {
2841
+ this._readFormats = await this._registerFormatType(e, this._readFormats);
2842
+ }
2843
+ async registerWriteFormat(e) {
2844
+ this._writeFormats = await this._registerFormatType(e, this._writeFormats);
2845
+ }
2846
+ async registerEncryption(e) {
2847
+ if (!e) throw Error("encryption must be provided.");
2848
+ if (!e.key) throw Error("encryption.key must be provided.");
2849
+ let t = e.key.toLowerCase(), n = this._encryptions.findIndex((e) => e.key.toLowerCase() === t);
2850
+ if (n !== -1) {
2851
+ let t = [...this._encryptions];
2852
+ t[n] = e, this._encryptions = Object.freeze(t);
2853
+ return;
2854
+ }
2855
+ this._encryptions = Object.freeze([...this._encryptions, e]);
2856
+ }
2857
+ async getEncryption(e) {
2858
+ return this.peekEncryption(e);
2859
+ }
2860
+ peekEncryption(e) {
2861
+ if (!e) return this._encryptions[0] ?? null;
2862
+ let t = e.toLowerCase();
2863
+ return this._encryptions.find((e) => e.key.toLowerCase() === t) ?? null;
2864
+ }
2865
+ async detectEncryption(e) {
2866
+ for (let t of this._encryptions) if (await t.detect(e)) return t;
2867
+ return null;
2868
+ }
2869
+ async getReadFormats(e) {
2870
+ return e ? this._filterFormats(e, this._readFormats) : [...this._readFormats];
2871
+ }
2872
+ async getWriteFormats(e) {
2873
+ return this._writeFormats ? e ? this._filterFormats(e, this._writeFormats) : [...this._writeFormats] : [];
2874
+ }
2875
+ async _registerFormatType(e, t) {
2876
+ return this._registerFormatTypeSync(e, t);
2877
+ }
2878
+ _registerFormatTypeSync(e, t) {
2879
+ if (!e) throw Error("format must be provided.");
2880
+ if (!e.key) throw Error("format.key must be provided.");
2881
+ let n = e.key.toLowerCase(), r = t.findIndex((e) => e.key.toLowerCase() === n);
2882
+ if (r !== -1) {
2883
+ let n = [...t];
2884
+ return n[r] = e, Object.freeze(n);
2885
+ }
2886
+ return Object.freeze([...t, e]);
2887
+ }
2888
+ _filterFormats(e, t, n) {
2889
+ if (!e || Object.keys(e).length === 0) {
2890
+ if (!n) return [...t];
2891
+ e = { ext: n };
2892
+ }
2893
+ let r = e.search?.toLocaleLowerCase();
2894
+ return t.filter((t) => {
2895
+ if (r) {
2896
+ let e = t.key.toLocaleLowerCase().includes(r), n = !!t.exts && t.exts.some((e) => e.toLocaleLowerCase().includes(r)), i = !!t.mimeType && t.mimeType.toLocaleLowerCase().includes(r), a = !!t.tags && t.tags.some((e) => e.toLocaleLowerCase().includes(r)), o = !!t.description && t.description.toLocaleLowerCase().includes(r);
2897
+ if (!(e || n || i || a || o)) return !1;
2898
+ }
2899
+ let i = e.ext || n;
2900
+ if (i) {
2901
+ let e = i.toLocaleLowerCase();
2902
+ if (!t.exts.some((t) => t.toLocaleLowerCase() === e)) return !1;
2903
+ }
2904
+ if (e.mimeType && t.mimeType !== e.mimeType || e.key && t.key.toLocaleLowerCase() !== e.key.toLocaleLowerCase()) return !1;
2905
+ if (e.tags) {
2906
+ let n = t.tags || [];
2907
+ if (!(typeof e.tags == "string" ? [e.tags] : e.tags).every((e) => n.includes(e))) return !1;
2908
+ }
2909
+ return !0;
2910
+ });
2911
+ }
2912
+ }, Mn = (e) => !!e && typeof e == "object" && typeof e.getPath == "function" && typeof e.canWrite == "function", Nn = class {
2913
+ constructor() {
2914
+ this._setInstalled = /* @__PURE__ */ new WeakSet(), this._backingStore = null, this._emitter = new j(this), this._registry = new jn(), this._defaultStore = new wt(() => this.getWriteFormats(), () => this.getReadFormats());
2915
+ }
2916
+ getBackingStore() {
2917
+ return this._backingStore ?? this._defaultStore;
2918
+ }
2919
+ setBackingStore(e) {
2920
+ this._backingStore = e ?? null;
2921
+ }
2922
+ canWrite() {
2923
+ return typeof this.getBackingStore().write == "function";
2924
+ }
2925
+ canRead() {
2926
+ return typeof this.getBackingStore().read == "function";
2927
+ }
2928
+ async install(e) {
2929
+ this._setInstalled.has(e) || (await e.register(this._registry), this._setInstalled.add(e));
2930
+ }
2931
+ addListeners(e, t) {
2932
+ return this._emitter.addListeners(e, t);
2933
+ }
2934
+ addCommitListener(e) {
2935
+ return this._emitter.addListeners({ onWrite: (t, n) => {
2936
+ n.save && e.onCommit?.({
2937
+ store: n.workbook.getTransactions(),
2938
+ commitId: n.commitId
2939
+ });
2940
+ } });
2941
+ }
2942
+ async getReadFormats(e) {
2943
+ return this._registry.getReadFormats(e);
2944
+ }
2945
+ async getWriteFormats(e) {
2946
+ return this._registry.getWriteFormats(e);
2947
+ }
2948
+ getOrigin(e) {
2949
+ return new U(e);
2950
+ }
2951
+ async read(e) {
2952
+ let t = null;
2953
+ if (typeof e == "string") e = { source: e };
2954
+ else if (Mn(e)) {
2955
+ let n = e.getPath();
2956
+ if (!n) throw Error("Cannot read from an unbound origin (no path).");
2957
+ t = e, e = { source: n };
2958
+ }
2959
+ let n = e ?? {}, { source: r = null, ...i } = n, a = this.getBackingStore();
2960
+ return (a.read ? a : this._defaultStore).read({
2961
+ source: r,
2962
+ options: i,
2963
+ decode: (e, r) => this._decodeBuffer(e, r, n, t)
2964
+ });
2965
+ }
2966
+ async _decodeBuffer(e, t = {}, n, r = null) {
2967
+ let i = t.format, a = t.ext;
2968
+ if (!i && !a) throw Error("Either format or file extension must be provided to determine read type.");
2969
+ let o = (await this._registry.getReadFormats({
2970
+ search: i,
2971
+ ext: a
2972
+ }))[0];
2973
+ if (!o) throw Error(`No read format available for '${i ?? a}' input.`);
2974
+ let s = n?.typedCreateWorkbookOptions, c = s ? Object.keys(s).find((e) => e.toLowerCase() === o.key.toLowerCase()) : void 0, l = {
2975
+ ...n,
2976
+ ...c === void 0 ? void 0 : s[c]
2977
+ };
2978
+ delete l.typedCreateWorkbookOptions, delete l.source;
2979
+ let u = r ?? new U(t.absolutePath ?? null, {
2980
+ name: t.name ?? null,
2981
+ format: o.key,
2982
+ size: t.size ?? null,
2983
+ canWrite: t.canWrite ?? !1
2984
+ });
2985
+ r instanceof U && r.update({
2986
+ format: o.key,
2987
+ size: t.size ?? null
2988
+ }), l.createWorkbookOptions = {
2989
+ ...l.createWorkbookOptions || {},
2990
+ origin: u
2991
+ }, l.readonly !== void 0 && (l.createWorkbookOptions = {
2992
+ readonly: l.readonly,
2993
+ ...l.createWorkbookOptions
2994
+ }, delete l.readonly), l.calcOnly && (l.createWorkbookOptions = {
2995
+ disableLoadAutoFit: !0,
2996
+ ...l.createWorkbookOptions
2997
+ });
2998
+ let d = await this._decrypt(e, u, l);
2999
+ if (d === null) return null;
3000
+ e = d.bytes;
3001
+ let f = l?.progress?.onStart?.bind(l.progress);
3002
+ f && await Promise.resolve(f(u, t.size));
3003
+ try {
3004
+ let t = await this._readArrayBuffer(e, o, l);
3005
+ return d.password !== null && u.setPassword(d.password), l?.progress?.onComplete?.(u), this._emitter.notify("onRead", {
3006
+ params: {
3007
+ workbook: t,
3008
+ origin: u
3009
+ },
3010
+ transactional: !1
3011
+ }), t;
3012
+ } catch (e) {
3013
+ throw l?.progress?.onError?.(e), l?.progress?.onComplete?.(null), e;
3014
+ }
3015
+ }
3016
+ async _decrypt(e, t, n) {
3017
+ let r = await this._registry.detectEncryption(e);
3018
+ if (t instanceof U && t.update({ encryption: r ? r.key : null }), !r) return {
3019
+ bytes: e,
3020
+ password: null
3021
+ };
3022
+ let i = null, a = async (t) => {
3023
+ try {
3024
+ return i = await r.decode(e, t), !0;
3025
+ } catch (e) {
3026
+ if (!(e instanceof ht)) throw e;
3027
+ return !1;
3028
+ }
3029
+ };
3030
+ if (n?.password && await a(n.password)) return {
3031
+ bytes: i,
3032
+ password: n.password
3033
+ };
3034
+ if (!n?.onPassword) throw new vt(`'${t.getName() ?? "This file"}' is encrypted. Supply options.password or options.onPassword to open it.`);
3035
+ let o = await Promise.resolve(n.onPassword({
3036
+ origin: t,
3037
+ encryption: r.key,
3038
+ validate: a
3039
+ }));
3040
+ if (o == null) return null;
3041
+ if (i !== null || await a(o)) return {
3042
+ bytes: i,
3043
+ password: o
3044
+ };
3045
+ throw new ht();
3046
+ }
3047
+ async writeArrayBuffer(e, t) {
3048
+ if (!t?.format) throw Error("A format must be specified to write to an ArrayBuffer (e.g. { format: 'xlsx' }).");
3049
+ let n = (await this._registry.getWriteFormats({ search: t.format }))[0];
3050
+ if (!n) throw Error(`No write format available for '${t.format}'.`);
3051
+ return this._writeArrayBuffer(e, n, t);
3052
+ }
3053
+ async write(e, t, n) {
3054
+ if (!e) throw Error("Workbook must be provided.");
3055
+ if (!e.isIWorkbook) throw Error("Invalid workbook model provided. Must be an instance of IWorkbook.");
3056
+ let r = n, i = null;
3057
+ typeof t == "string" ? i = this.getOrigin(t) : Mn(t) ? i = t : t && (r = t);
3058
+ let a = !i, o = i ?? e.getOrigin(), s = o.getFormat(), c;
3059
+ 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 Error("Unable to determine a write format. Specify options.format, or a destination with a known extension.");
3060
+ if (i && typeof t == "string") {
3061
+ let e = i.getPath();
3062
+ e && !M(e) && i.update?.({ path: `${e}.${c.exts[0]}` });
3063
+ }
3064
+ 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;
3065
+ if (p === void 0) {
3066
+ if (f) throw new vt(`'${o.getName() ?? "This file"}' is encrypted. Supply options.password to re-encrypt it, or options.password = null to write it without a password.`);
3067
+ } else if (p !== null && (m = await this._registry.getEncryption(l), !m)) throw Error("No encryption support is installed, so this workbook cannot be password protected.");
3068
+ let h = `${o.getName() ?? "workbook"}.${c.exts[0]}`, g = r?.progress, _ = !1, v = this, y = null, ee = {
3069
+ workbook: e,
3070
+ format: c,
3071
+ origin: o,
3072
+ suggestedName: h,
3073
+ prompt: r?.prompt,
3074
+ async encode(t) {
3075
+ await (async () => {
3076
+ _ || (_ = !0, g?.onStart && await Promise.resolve(g.onStart(o)));
3077
+ })(), y = e.getTransactions?.()?.getCurrentCommit() ?? y;
3078
+ let n = t ? (await v._registry.getWriteFormats({ search: t }))[0] ?? c : c, i = await v._writeArrayBuffer(e, n, r);
3079
+ return m ? m.encode(i, p) : i;
3080
+ }
3081
+ }, b = null;
3082
+ try {
3083
+ let t = this.getBackingStore();
3084
+ if (!t.write) throw Error("The active backing store is read-only (no write implementation).");
3085
+ if (b = await t.write(ee), b) {
3086
+ p !== void 0 && b instanceof U && (b.setPassword(p), b.update({ encryption: m ? m.key : null }));
3087
+ let t = y ?? e.getTransactions?.()?.getCurrentCommit() ?? null;
3088
+ this._emitter.notify("onWrite", {
3089
+ params: {
3090
+ workbook: e,
3091
+ origin: b,
3092
+ commitId: t?.getId() ?? null,
3093
+ save: a
3094
+ },
3095
+ transactional: !1
3096
+ });
3097
+ }
3098
+ g?.onComplete && await Promise.resolve(g.onComplete(b));
3099
+ } catch (e) {
3100
+ let t = e instanceof Error ? e : Error(String(e));
3101
+ throw g?.onError && await Promise.resolve(g.onError(t)), g?.onComplete && await Promise.resolve(g.onComplete(null)), Error("Unable to write workbook.", { cause: e });
3102
+ }
3103
+ return b;
3104
+ }
3105
+ async writeAs(e, t, n) {
3106
+ if (!t) throw Error("A target must be provided for writeAs (use write(workbook) for a plain save).");
3107
+ let r = e?.getOrigin?.();
3108
+ if (!(r instanceof U)) return this.write(e, t, n);
3109
+ let i = typeof t == "string" ? t : t.getPath(), a = i && M(i)?.toLowerCase() || null, o = a ? (await this._registry.getWriteFormats({ search: a }))[0]?.key ?? a : null, s = {
3110
+ path: r.getPath(),
3111
+ name: r.getName(),
3112
+ format: r.getFormat(),
3113
+ canWrite: r.canWrite()
3114
+ };
3115
+ r.update({
3116
+ path: i,
3117
+ name: typeof t == "string" ? null : t.getName(),
3118
+ format: o,
3119
+ canWrite: i != null
3120
+ });
3121
+ let c = null;
3122
+ try {
3123
+ c = await this.write(e, void 0, n);
3124
+ } finally {
3125
+ c || r.update(s);
3126
+ }
3127
+ return c;
3128
+ }
3129
+ _stripExtension(e) {
3130
+ let t = M(e);
3131
+ return t ? e.slice(0, e.length - t.length - 1) : e;
3132
+ }
3133
+ _baseName(e) {
3134
+ if (!e) return null;
3135
+ let t = e.split(/[?#]/)[0], n = t.split(/[/\\]/).pop() ?? t;
3136
+ return this._stripExtension(n) || null;
3137
+ }
3138
+ async _writeArrayBuffer(e, t, n) {
3139
+ if (!t) throw Error(`Invalid write type for '${t}'.`);
3140
+ try {
3141
+ let r = t.handler;
3142
+ if (!r) throw Error(`Unable to resolve handler for type: ${t.description ?? t}.`);
3143
+ return r(e, {
3144
+ ...n,
3145
+ format: t.key
3146
+ });
3147
+ } catch (e) {
3148
+ throw Error(`Unable to load handler for '${t}.'`, { cause: e });
3149
+ }
3150
+ }
3151
+ async _readArrayBuffer(e, t, n) {
3152
+ if (!e) throw Error("ArrayBuffer must be specified.");
3153
+ if (!t) throw Error("format must be specified.");
3154
+ if (e.byteLength === 0) return new kn(n?.createWorkbookOptions);
3155
+ let r = t.handler;
3156
+ if (!r) throw Error(`Unable to resolve handler for format type: ${t?.description ?? t}.`);
3157
+ let i;
3158
+ try {
3159
+ i = await r(e, n);
3160
+ } catch (e) {
3161
+ throw Error(`Unable to read ${t.description ?? t.key} — ${e?.message ?? String(e)}`, { cause: e });
3162
+ }
3163
+ return i;
3164
+ }
3165
+ }, Pn = new Nn(), Fn = class {
3166
+ constructor() {
3167
+ this._buffer = null, this._formatKey = null;
3168
+ }
3169
+ get buffer() {
3170
+ return this._buffer;
3171
+ }
3172
+ async write(e) {
3173
+ let t = await e.encode();
3174
+ return this._buffer = t, this._formatKey = e.format.key, e.origin;
3175
+ }
3176
+ async read(e) {
3177
+ return this._buffer ? e.decode(this._buffer, { format: this._formatKey ?? void 0 }) : null;
3178
+ }
3179
+ }, In = "locales", Ln = "fonts", Rn = [{
3180
+ kind: In,
3181
+ files: [{
3182
+ suffix: ".msg.json",
3183
+ async extract(e) {
3184
+ let t = e.relPath.split("/");
3185
+ return t.length === 2 ? {
3186
+ locale: t[0],
3187
+ role: "messages"
3188
+ } : null;
3189
+ },
3190
+ place: (e, t) => t ? `${t}/${e}` : null
3191
+ }]
3192
+ }, {
3193
+ kind: Ln,
3194
+ files: [
3195
+ ".woff2",
3196
+ ".woff",
3197
+ ".ttf",
3198
+ ".otf",
3199
+ ".ttc"
3200
+ ].map((e) => ({
3201
+ suffix: e,
3202
+ place: (e, t) => t ? `${t}/${e}` : e
3203
+ }))
3204
+ }];
3205
+ En ||= {}, Dn ||= {};
3206
+ var zn, Bn = e({ nowWithPrecision: () => Vn });
3207
+ function Vn(e = 6e4) {
3208
+ return new Date(Math.floor(Date.now() / e) * e);
3209
+ }
3210
+ zn ||= {};
3211
+ var Hn = class extends Ce {
3212
+ constructor(e) {
3213
+ super(e);
3214
+ }
3215
+ _initializeOptions(e) {
3216
+ return e = {
3217
+ ...e,
3218
+ coords: {
3219
+ colStart: 0,
3220
+ rowStart: 0,
3221
+ colEnd: (e?.size?.width ?? 5) - 1,
3222
+ rowEnd: (e?.size?.height ?? 5) - 1
3223
+ },
3224
+ getRanges: (e) => null
3225
+ }, super._initializeOptions(e);
3226
+ }
3227
+ }, Un = "0.7.28-beta.1", Wn = "Mon Aug 24 2026";
3228
+ export { _e as AddressUtils, Fn as ArrayBackingStore, xe as AutoFill, Wn as BUILD_DATE, r as Color, Ke as Condition, Bn as DateUtils, Nn as DefaultWorkbookIO, gn as ExternalRangeClipboardItem, Ln as FONTS_KIND, Rt as FontUtils, Ee as GeomUtils, at as IAnchored, Be as IBorder, Ve as ICalculation, rt as ICell, Qt as ICellHeaderRange, Fe as ICellRange, Zt as ICellRanges, f as IColor, Te as ICondition, Qe as IConditionalFormat, Ue as IDataValidation, Lt as IEffect, N as IFill, A as IFont, kt as IFontCollection, zn as IMovable, Dn as IPicture, En as IPrint, Xt as IResource, t as ISheet, pe as ISheetView, Ft as ISort, It as IStroke, ne as IStyle, b as ITableStyle, i as IText, x as ITextFrame, Yt as ITheme, _ as IThemeCollection, bt as IWorkbookIO, In as LOCALES_KIND, g as LicenseManager, E as NumberFormat, hn as RangeClipboardItem, o as Registry, st as Resource, me as ResourceCollection, Rn as SHEETXL_RESOURCE_KINDS, oe as SYSTEM_COLOR_CSS_PREFIX, O as Sheet, Ot as SimpleFontFace, et as Sort, lt as StringCollection, ot as StyleCollection, Hn as Table, ue as TextRotation, it as TextUtils, u as Theme, p as ThemeCollection, ie as TransactionConflictError, St as TransactionSaveStateManager, c as TransactionStore, xt as TransactionUndoManager, nt as Tuple, Un as VERSION, kn as Workbook, Pn as WorkbookIO, U as WorkbookOrigin, Q as WorkbookView, Jt as builtInStyleNameDisplay, tt as createCellRangeCounts, tn as getBuiltInFunctionNames, fe as getLanguagePack, De as getLocaleProfile, He as localizeBoolean, Ze as localizeErrorLabel, we as makeLocaleProfile, ge as parseBooleanLocal, Pe as parseErrorLocal, nn as parseFormulaLiteral, Ae as registerSdkLocales };