@sheetxl/mcp 0.0.0-stage → 0.8.0-beta.15

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 (509) hide show
  1. package/LICENSE.md +11 -0
  2. package/README.md +72 -2
  3. package/agent/instructions.md +66 -0
  4. package/assets/9U9XCqqdn-q3i2fj.js +123 -0
  5. package/assets/B-MqXm_7luDLwazY.js +596 -0
  6. package/assets/B2Ek-DWpZMGJ0V1Z.js +18 -0
  7. package/assets/B2udpZ-uIaql3AUh.js +104 -0
  8. package/assets/B4VnJacrzr1x4PHR.js +402 -0
  9. package/assets/B5lHOOQ_rkP4Mi2r.js +638 -0
  10. package/assets/B7gUyrfLln3TiyKM.js +14 -0
  11. package/assets/B9US2ZrF93KOjmAx.js +22 -0
  12. package/assets/BBb_3gEGzmEzbTIk.js +359 -0
  13. package/assets/BCy1zP97fsiIcvj6.js +18 -0
  14. package/assets/BFXeoFUbuc4IKTz9.js +28 -0
  15. package/assets/BFdeov2e_xUQPEY_.js +202 -0
  16. package/assets/BG5kgbDRXMc0re6W.js +242 -0
  17. package/assets/BJxfinOazQqqByc-.js +105 -0
  18. package/assets/BOPsJmq7v7HOKUkO.js +32 -0
  19. package/assets/BPwmBu_aouERJjiW.js +45 -0
  20. package/assets/BQMDOjNBMjAx9WiW.js +3011 -0
  21. package/assets/BQbF1RkUH8WyXqSD.js +780 -0
  22. package/assets/BRzp6DEIYUgM3NkN.js +369 -0
  23. package/assets/BSxTn2BhkEEeF9x_.js +2346 -0
  24. package/assets/BTQhJQ3e0hsiousD.js +28 -0
  25. package/assets/BZPTaa0WjpoUAbgZ.js +35 -0
  26. package/assets/BbAmA46MhQSu3ZF_.js +119 -0
  27. package/assets/BbcUxIZe3YXywsQR.js +28 -0
  28. package/assets/BeLr36oL3jmeXFFi.js +58 -0
  29. package/assets/Bg95xYj5siqhHVEz.js +594 -0
  30. package/assets/Bh0PNKlrR4VAqnP8.js +60500 -0
  31. package/assets/BjqQjxBuoXza8oqg.js +362 -0
  32. package/assets/BlPubAFi7DY7VrAo.js +33 -0
  33. package/assets/BleMG0hAQgjE8fTa.js +7 -0
  34. package/assets/Bn8D2bebQ2tFfwQt.js +310 -0
  35. package/assets/BrcQmHcE7Hcr1erJ.js +24 -0
  36. package/assets/BsQZI1vXTRE63Zy-.js +2368 -0
  37. package/assets/BtjqpAKczftx91BQ.js +96 -0
  38. package/assets/Btys7KwtvV3hz2F6.js +656 -0
  39. package/assets/BuUEsifnQALe49uk.js +857 -0
  40. package/assets/By-7OWXShMlFFejV.js +119 -0
  41. package/assets/C0CiMKC3lWK1z9p5.js +449 -0
  42. package/assets/C2OrZ8LZ-TI6eYG0.js +22 -0
  43. package/assets/C4z2IilWTuu2TWXw.js +3917 -0
  44. package/assets/C7ONfuYIWRmDu_vs.js +319 -0
  45. package/assets/C7Z1li2XjWi6bkrp.js +1556 -0
  46. package/assets/C97xDe_wBbLZh_uW.js +35 -0
  47. package/assets/CGBGyaCGdlZFQYK0.js +447 -0
  48. package/assets/CJ5WQnaoCsdr5gf4.js +1783 -0
  49. package/assets/CMK6tIDVqYYvK4GZ.js +55 -0
  50. package/assets/CMWAsUQ66V8fYrME.js +223 -0
  51. package/assets/CNz3LdmvsOEJoLO9.js +12 -0
  52. package/assets/CWVWdbY1B1-WLl9k.js +199 -0
  53. package/assets/CWl6oHiJxkNKRixk.js +17 -0
  54. package/assets/CXHslDxkWCuEcCSQ.js +13 -0
  55. package/assets/CZTSZL3T_f-vSXqM.js +7 -0
  56. package/assets/CduNzsdbTigxH-ZK.js +5220 -0
  57. package/assets/CecTe22WURiXbVdY.js +2260 -0
  58. package/assets/Cf2dcwmmmf13Rywg.js +146 -0
  59. package/assets/Cf9LpgZz-W5blzy_.js +27 -0
  60. package/assets/Cfhv_Yw_LT8VzAMt.js +255 -0
  61. package/assets/Cg51xaLRUkVOMdCZ.js +144 -0
  62. package/assets/ChWpsFGl-BYOnX_A.js +142 -0
  63. package/assets/ClNQN3vEg5b5qUDp.js +10289 -0
  64. package/assets/Crt2kLdGIlBHANgg.js +28 -0
  65. package/assets/CudNpUD78SrtJIiy.js +610 -0
  66. package/assets/CvngwB17_ve4W49b.js +639 -0
  67. package/assets/CwPBmcY6xSP8dNlh.js +51 -0
  68. package/assets/CxjchwpiqxPM1XKd.js +304 -0
  69. package/assets/D-ffk16w8c5w0mxI.js +71 -0
  70. package/assets/D0CHDsemn0S31ltt.js +32 -0
  71. package/assets/D7oUtYjetuykGhQ5.js +18 -0
  72. package/assets/D8J14MLlN2HRXdXB.js +20 -0
  73. package/assets/DA_ar3QKLKtJ9fJD.js +37 -0
  74. package/assets/DB-tkqI6wFXDKEfB.js +118 -0
  75. package/assets/DD8HNAUFroTCuD-b.js +7514 -0
  76. package/assets/DDnwKPJSznyfYDZS.js +49 -0
  77. package/assets/DEW2GxfGYqVFvrfg.js +23 -0
  78. package/assets/DH7sGHzxUqIQkDnd.js +16 -0
  79. package/assets/DJiLWtmPR2OQNjzi.js +19 -0
  80. package/assets/DKLm4nWzynGw1Kr9.js +15 -0
  81. package/assets/DPCKMM7sgWbrtB8z.js +81 -0
  82. package/assets/DTfl-4Iboi6TQU5m.js +37 -0
  83. package/assets/DVchxwp6w6lu2Ihu.js +7 -0
  84. package/assets/DaoSWy3EFlqpZaLr.js +4437 -0
  85. package/assets/DcWTBOi_iBFc6U4J.js +8338 -0
  86. package/assets/Dht2mcOSyYlPY32b.js +14 -0
  87. package/assets/Diee6f_qAmcZBd2_.js +52 -0
  88. package/assets/DkibD_CEVePaoj_y.js +7 -0
  89. package/assets/DlBdhv6NHgrNp5Yo.js +7 -0
  90. package/assets/DoILAmhKUOlKWRVw.js +12 -0
  91. package/assets/DpdHDTFOeuzDVNEe.js +405 -0
  92. package/assets/DsCI_ZYm_jDjXF3J.js +12996 -0
  93. package/assets/DvUUArnZwoYOKOuk.js +12 -0
  94. package/assets/DwLZpYUp85UHBE3H.js +63 -0
  95. package/assets/DwWngYJTgC0KLbih.js +184 -0
  96. package/assets/Dz8UUJ7Xc2oN5PBG.js +45 -0
  97. package/assets/FS9NbEKgQvz5wqvZ.js +1135 -0
  98. package/assets/F_f0jJqM5MrXGbwC.js +86 -0
  99. package/assets/FzNG48GE_wso6RII.js +173 -0
  100. package/assets/JO3zH9hupFSV6vj2.js +15 -0
  101. package/assets/LEJp05fjmflKgyqF.js +1760 -0
  102. package/assets/LyLlBk--VJD2V-f8.js +351 -0
  103. package/assets/OVRdpPUzR0-ueTxE.js +1860 -0
  104. package/assets/PpFbmF0DFeUdpb9I.js +145 -0
  105. package/assets/S16s2h9qoYVBlVEa.js +9137 -0
  106. package/assets/SHZe9VOU1prGs1F9.js +19 -0
  107. package/assets/U1XXGEPuuqIAzYl1.js +8 -0
  108. package/assets/ZuYfVKlp41IJnrOS.js +540 -0
  109. package/assets/_d5XJ7dn1CKKYrep.js +1131 -0
  110. package/assets/_fUXIv6nKvgZkhxn.js +23 -0
  111. package/assets/fDMpDhXp36CatF-G.js +23 -0
  112. package/assets/hulrR0PldUxMJm_F.js +504 -0
  113. package/assets/iujMYIEPx_v3sdPf.js +9109 -0
  114. package/assets/jPUOH4FHF4b-rapv.js +171 -0
  115. package/assets/jadLBUNBVR9mbZ35.js +4036 -0
  116. package/assets/jiEe5eKV3BFPBWfi.js +6294 -0
  117. package/assets/oxjm7Yr7u7MeaO5P.js +37 -0
  118. package/assets/vZZi_iKYHm05gAye.js +30 -0
  119. package/assets/wfVh0olISLRWdv9Q.js +47 -0
  120. package/assets/xmTQJJVyCrcq77WR.js +63 -0
  121. package/assets/xnhBSX6lAcmBM65y.js +32 -0
  122. package/index.js +8070 -0
  123. package/lib.js +7 -0
  124. package/licenses/dependencies.txt +1552 -0
  125. package/package.json +44 -3
  126. package/resources/contents.json +333 -0
  127. package/resources/fonts/@sheetxl/sdk/aptos-bold-italic.hinted.json +125 -0
  128. package/resources/fonts/@sheetxl/sdk/aptos-bold-italic.metrics.json +221 -0
  129. package/resources/fonts/@sheetxl/sdk/aptos-bold-italic.rows.json +8 -0
  130. package/resources/fonts/@sheetxl/sdk/aptos-bold.hinted.json +125 -0
  131. package/resources/fonts/@sheetxl/sdk/aptos-bold.metrics.json +221 -0
  132. package/resources/fonts/@sheetxl/sdk/aptos-bold.rows.json +8 -0
  133. package/resources/fonts/@sheetxl/sdk/aptos-display-bold-italic.hinted.json +125 -0
  134. package/resources/fonts/@sheetxl/sdk/aptos-display-bold-italic.metrics.json +221 -0
  135. package/resources/fonts/@sheetxl/sdk/aptos-display-bold-italic.rows.json +8 -0
  136. package/resources/fonts/@sheetxl/sdk/aptos-display-bold.hinted.json +125 -0
  137. package/resources/fonts/@sheetxl/sdk/aptos-display-bold.metrics.json +221 -0
  138. package/resources/fonts/@sheetxl/sdk/aptos-display-bold.rows.json +8 -0
  139. package/resources/fonts/@sheetxl/sdk/aptos-display-italic.hinted.json +124 -0
  140. package/resources/fonts/@sheetxl/sdk/aptos-display-italic.metrics.json +221 -0
  141. package/resources/fonts/@sheetxl/sdk/aptos-display-italic.rows.json +8 -0
  142. package/resources/fonts/@sheetxl/sdk/aptos-display-regular.hinted.json +125 -0
  143. package/resources/fonts/@sheetxl/sdk/aptos-display-regular.metrics.json +221 -0
  144. package/resources/fonts/@sheetxl/sdk/aptos-display-regular.rows.json +8 -0
  145. package/resources/fonts/@sheetxl/sdk/aptos-italic.hinted.json +125 -0
  146. package/resources/fonts/@sheetxl/sdk/aptos-italic.metrics.json +221 -0
  147. package/resources/fonts/@sheetxl/sdk/aptos-italic.rows.json +8 -0
  148. package/resources/fonts/@sheetxl/sdk/aptos-narrow-bold-italic.hinted.json +125 -0
  149. package/resources/fonts/@sheetxl/sdk/aptos-narrow-bold-italic.metrics.json +221 -0
  150. package/resources/fonts/@sheetxl/sdk/aptos-narrow-bold-italic.rows.json +8 -0
  151. package/resources/fonts/@sheetxl/sdk/aptos-narrow-bold.hinted.json +125 -0
  152. package/resources/fonts/@sheetxl/sdk/aptos-narrow-bold.metrics.json +221 -0
  153. package/resources/fonts/@sheetxl/sdk/aptos-narrow-bold.rows.json +8 -0
  154. package/resources/fonts/@sheetxl/sdk/aptos-narrow-italic.hinted.json +125 -0
  155. package/resources/fonts/@sheetxl/sdk/aptos-narrow-italic.metrics.json +221 -0
  156. package/resources/fonts/@sheetxl/sdk/aptos-narrow-italic.rows.json +8 -0
  157. package/resources/fonts/@sheetxl/sdk/aptos-narrow-regular.hinted.json +125 -0
  158. package/resources/fonts/@sheetxl/sdk/aptos-narrow-regular.metrics.json +221 -0
  159. package/resources/fonts/@sheetxl/sdk/aptos-narrow-regular.rows.json +8 -0
  160. package/resources/fonts/@sheetxl/sdk/aptos-regular.hinted.json +125 -0
  161. package/resources/fonts/@sheetxl/sdk/aptos-regular.metrics.json +221 -0
  162. package/resources/fonts/@sheetxl/sdk/aptos-regular.rows.json +8 -0
  163. package/resources/fonts/@sheetxl/sdk/arial-bold-italic.hinted.json +125 -0
  164. package/resources/fonts/@sheetxl/sdk/arial-bold-italic.metrics.json +139 -0
  165. package/resources/fonts/@sheetxl/sdk/arial-bold-italic.rows.json +8 -0
  166. package/resources/fonts/@sheetxl/sdk/arial-bold.hinted.json +125 -0
  167. package/resources/fonts/@sheetxl/sdk/arial-bold.metrics.json +139 -0
  168. package/resources/fonts/@sheetxl/sdk/arial-bold.rows.json +8 -0
  169. package/resources/fonts/@sheetxl/sdk/arial-italic.hinted.json +125 -0
  170. package/resources/fonts/@sheetxl/sdk/arial-italic.metrics.json +139 -0
  171. package/resources/fonts/@sheetxl/sdk/arial-italic.rows.json +8 -0
  172. package/resources/fonts/@sheetxl/sdk/arial-regular.hinted.json +125 -0
  173. package/resources/fonts/@sheetxl/sdk/arial-regular.metrics.json +139 -0
  174. package/resources/fonts/@sheetxl/sdk/arial-regular.rows.json +8 -0
  175. package/resources/fonts/@sheetxl/sdk/calibri-bold-italic.hinted.json +122 -0
  176. package/resources/fonts/@sheetxl/sdk/calibri-bold-italic.metrics.json +137 -0
  177. package/resources/fonts/@sheetxl/sdk/calibri-bold-italic.rows.json +8 -0
  178. package/resources/fonts/@sheetxl/sdk/calibri-bold.hinted.json +122 -0
  179. package/resources/fonts/@sheetxl/sdk/calibri-bold.metrics.json +137 -0
  180. package/resources/fonts/@sheetxl/sdk/calibri-bold.rows.json +8 -0
  181. package/resources/fonts/@sheetxl/sdk/calibri-italic.hinted.json +121 -0
  182. package/resources/fonts/@sheetxl/sdk/calibri-italic.metrics.json +137 -0
  183. package/resources/fonts/@sheetxl/sdk/calibri-italic.rows.json +8 -0
  184. package/resources/fonts/@sheetxl/sdk/calibri-regular.hinted.json +121 -0
  185. package/resources/fonts/@sheetxl/sdk/calibri-regular.metrics.json +137 -0
  186. package/resources/fonts/@sheetxl/sdk/calibri-regular.rows.json +8 -0
  187. package/resources/fonts/@sheetxl/sdk/cambria-bold-italic.hinted.json +105 -0
  188. package/resources/fonts/@sheetxl/sdk/cambria-bold-italic.metrics.json +66 -0
  189. package/resources/fonts/@sheetxl/sdk/cambria-bold-italic.rows.json +8 -0
  190. package/resources/fonts/@sheetxl/sdk/cambria-bold.hinted.json +108 -0
  191. package/resources/fonts/@sheetxl/sdk/cambria-bold.metrics.json +66 -0
  192. package/resources/fonts/@sheetxl/sdk/cambria-bold.rows.json +8 -0
  193. package/resources/fonts/@sheetxl/sdk/cambria-italic.hinted.json +102 -0
  194. package/resources/fonts/@sheetxl/sdk/cambria-italic.metrics.json +66 -0
  195. package/resources/fonts/@sheetxl/sdk/cambria-italic.rows.json +8 -0
  196. package/resources/fonts/@sheetxl/sdk/cambria-regular.hinted.json +110 -0
  197. package/resources/fonts/@sheetxl/sdk/cambria-regular.metrics.json +66 -0
  198. package/resources/fonts/@sheetxl/sdk/cambria-regular.rows.json +8 -0
  199. package/resources/fonts/@sheetxl/sdk/contents.json +646 -0
  200. package/resources/fonts/@sheetxl/sdk/courier-new-bold-italic.hinted.json +11 -0
  201. package/resources/fonts/@sheetxl/sdk/courier-new-bold-italic.metrics.json +143 -0
  202. package/resources/fonts/@sheetxl/sdk/courier-new-bold-italic.rows.json +8 -0
  203. package/resources/fonts/@sheetxl/sdk/courier-new-bold.hinted.json +11 -0
  204. package/resources/fonts/@sheetxl/sdk/courier-new-bold.metrics.json +143 -0
  205. package/resources/fonts/@sheetxl/sdk/courier-new-bold.rows.json +8 -0
  206. package/resources/fonts/@sheetxl/sdk/courier-new-italic.hinted.json +11 -0
  207. package/resources/fonts/@sheetxl/sdk/courier-new-italic.metrics.json +143 -0
  208. package/resources/fonts/@sheetxl/sdk/courier-new-italic.rows.json +8 -0
  209. package/resources/fonts/@sheetxl/sdk/courier-new-regular.hinted.json +11 -0
  210. package/resources/fonts/@sheetxl/sdk/courier-new-regular.metrics.json +143 -0
  211. package/resources/fonts/@sheetxl/sdk/courier-new-regular.rows.json +8 -0
  212. package/resources/fonts/@sheetxl/sdk/times-new-roman-bold-italic.hinted.json +125 -0
  213. package/resources/fonts/@sheetxl/sdk/times-new-roman-bold-italic.metrics.json +141 -0
  214. package/resources/fonts/@sheetxl/sdk/times-new-roman-bold-italic.rows.json +8 -0
  215. package/resources/fonts/@sheetxl/sdk/times-new-roman-bold.hinted.json +125 -0
  216. package/resources/fonts/@sheetxl/sdk/times-new-roman-bold.metrics.json +141 -0
  217. package/resources/fonts/@sheetxl/sdk/times-new-roman-bold.rows.json +8 -0
  218. package/resources/fonts/@sheetxl/sdk/times-new-roman-italic.hinted.json +125 -0
  219. package/resources/fonts/@sheetxl/sdk/times-new-roman-italic.metrics.json +143 -0
  220. package/resources/fonts/@sheetxl/sdk/times-new-roman-italic.rows.json +8 -0
  221. package/resources/fonts/@sheetxl/sdk/times-new-roman-regular.hinted.json +125 -0
  222. package/resources/fonts/@sheetxl/sdk/times-new-roman-regular.metrics.json +141 -0
  223. package/resources/fonts/@sheetxl/sdk/times-new-roman-regular.rows.json +8 -0
  224. package/resources/locales/@sheetxl/formulas/contents.json +9 -0
  225. package/resources/locales/@sheetxl/formulas/de/functions.json +298 -0
  226. package/resources/locales/@sheetxl/formulas-extended/contents.json +9 -0
  227. package/resources/locales/@sheetxl/formulas-extended/de/functions.json +59 -0
  228. package/resources/locales/@sheetxl/sdk/contents.json +19 -0
  229. package/resources/locales/@sheetxl/sdk/de/grammar.json +16 -0
  230. package/resources/locales/@sheetxl/sdk/de/model.msg.json +710 -0
  231. package/resources/locales/@sheetxl/sdk/en/model.msg.json +732 -0
  232. package/screenshot-page/assets/-cpi3yOZYn6GsYN4.js +9 -0
  233. package/screenshot-page/assets/-i_fTASJeu9NdNH_.js +7 -0
  234. package/screenshot-page/assets/0MTaPYjKud2Q9QG9.js +1 -0
  235. package/screenshot-page/assets/21oAESJyBGXeHegm.js +2 -0
  236. package/screenshot-page/assets/3Ls_kOvlQseMV8Q0.js +1 -0
  237. package/screenshot-page/assets/4qZpl2QCzneWdmJO.js +1 -0
  238. package/screenshot-page/assets/6IEV7KeOEbBdrthj.js +1 -0
  239. package/screenshot-page/assets/8QrkTrKHDnMBb7q4.js +1 -0
  240. package/screenshot-page/assets/9w0ECZmzGUyk3F_O.js +1 -0
  241. package/screenshot-page/assets/AjS2PipZDIH3BXB2.js +1 -0
  242. package/screenshot-page/assets/B-KIwD5F_5S-NsPg.js +1 -0
  243. package/screenshot-page/assets/B-sAzW5ROrhvMGM4.js +1 -0
  244. package/screenshot-page/assets/B0FQypGas6gbGT_U.js +1 -0
  245. package/screenshot-page/assets/B2IQMVqTZT1rUnib.js +1 -0
  246. package/screenshot-page/assets/B2MJPcMcsuv6FekC.js +1 -0
  247. package/screenshot-page/assets/B2g3jiFIQ4Qjh5gG.js +1 -0
  248. package/screenshot-page/assets/B4PbXdzBe9BsoZ0e.js +2 -0
  249. package/screenshot-page/assets/B5GO9v4p9L70Xb9i.js +1 -0
  250. package/screenshot-page/assets/B8y_eLNCGnXLEIaE.js +1 -0
  251. package/screenshot-page/assets/BEuMvXYIa9A1JacY.js +1 -0
  252. package/screenshot-page/assets/BEwl-ucV9Jfr0RoC.js +1 -0
  253. package/screenshot-page/assets/BFaiQZKle44Rhyou.js +1 -0
  254. package/screenshot-page/assets/BHqg55S-4_OoAu3P.js +2 -0
  255. package/screenshot-page/assets/BNgLvS2bLOYKRguv.js +1 -0
  256. package/screenshot-page/assets/BQAN82ftWBiLJT3r.js +1 -0
  257. package/screenshot-page/assets/BQfe-XTIOGeUnD9B.js +1 -0
  258. package/screenshot-page/assets/BQnELVV0uR4T4ItQ.js +1 -0
  259. package/screenshot-page/assets/BRVZJ0OGJg9XJro6.js +1 -0
  260. package/screenshot-page/assets/BSdFVGZNhU6YHbMI.js +2 -0
  261. package/screenshot-page/assets/BTMW3ukmc44U2fy7.js +1 -0
  262. package/screenshot-page/assets/BTOQaSn9DDyJPUlX.js +1 -0
  263. package/screenshot-page/assets/BTboCICZ-951XWsi.js +1 -0
  264. package/screenshot-page/assets/BUGXf2DEBog16Slb.js +2 -0
  265. package/screenshot-page/assets/BUjI304IvdJnFXH3.js +1 -0
  266. package/screenshot-page/assets/B_W2QroTKADz3ABp.js +2 -0
  267. package/screenshot-page/assets/Baz0SC2AgGyxMX72.js +1 -0
  268. package/screenshot-page/assets/BbP9KThfrodyosvn.js +1 -0
  269. package/screenshot-page/assets/BcOdl17EeFSxnAiq.js +1 -0
  270. package/screenshot-page/assets/BclKeOKIOBjijhsu.js +1 -0
  271. package/screenshot-page/assets/Bf7xq8PyF4ohjMzP.js +2 -0
  272. package/screenshot-page/assets/BimyzECCZl-NESff.js +1 -0
  273. package/screenshot-page/assets/Bj-vfAT28PK-tWWa.js +2 -0
  274. package/screenshot-page/assets/BkLH7JH3A93TXFJi.js +1 -0
  275. package/screenshot-page/assets/BksaQEoZr5OWq-_d.js +3 -0
  276. package/screenshot-page/assets/BnoVwUBEor8NgQNs.js +4 -0
  277. package/screenshot-page/assets/BowRIybLgENunTOT.js +1 -0
  278. package/screenshot-page/assets/Bp7se0JaDGrzfSA_.js +1 -0
  279. package/screenshot-page/assets/Bx61vmiWY0Xvx9qs.js +1 -0
  280. package/screenshot-page/assets/ByY3fmwyDPAyOLdo.js +1 -0
  281. package/screenshot-page/assets/Bz5V1tmiy5gbT9ys.js +1 -0
  282. package/screenshot-page/assets/Bz9v1lgjvbu4QnOs.js +2 -0
  283. package/screenshot-page/assets/BzQ5GyiXq8gTz-H-.js +1 -0
  284. package/screenshot-page/assets/C1k_VrZqlpiUigCP.js +1 -0
  285. package/screenshot-page/assets/C2Wh2h27c7FUb8Yk.js +1 -0
  286. package/screenshot-page/assets/C6oLDVnuCS9LGkkH.js +1 -0
  287. package/screenshot-page/assets/C81mK8aZKZAAS-AB.js +1 -0
  288. package/screenshot-page/assets/C9SC-cEIt6gdhZRw.js +1 -0
  289. package/screenshot-page/assets/CE8MCCIiwjOVwBBW.js +1 -0
  290. package/screenshot-page/assets/CG3ynup87FmG-kkX.js +1 -0
  291. package/screenshot-page/assets/CHlWgOAlcRCjVuhg.js +1 -0
  292. package/screenshot-page/assets/CIged53b3hHKxa-o.js +1 -0
  293. package/screenshot-page/assets/CNQczIR5xcE5u5fT.js +1 -0
  294. package/screenshot-page/assets/CSUd8n1H0VBfREnk.js +2 -0
  295. package/screenshot-page/assets/CSlBTkRDITCC8JRB.js +1 -0
  296. package/screenshot-page/assets/CV2jr9hpQOG2OG0C.js +1 -0
  297. package/screenshot-page/assets/CXGgKVbVXjWzE0p6.js +1 -0
  298. package/screenshot-page/assets/CXKCmZ_TRyGaB9Ob.js +1 -0
  299. package/screenshot-page/assets/CXUO3vYip3JPSJ7A.js +1 -0
  300. package/screenshot-page/assets/CXwbGzavyvYgDbWU.js +1 -0
  301. package/screenshot-page/assets/CZf9s6otzzoaBlSs.js +1 -0
  302. package/screenshot-page/assets/CZvwQEeVhBilgKLG.js +1 -0
  303. package/screenshot-page/assets/Ca6nxdhEuLLty3d7.js +2 -0
  304. package/screenshot-page/assets/CbUDukmvDZmVfhJH.js +1 -0
  305. package/screenshot-page/assets/CbXtAM7H-Jg_J0dk.js +1 -0
  306. package/screenshot-page/assets/CctIRGMFmARVi2KT.js +1 -0
  307. package/screenshot-page/assets/Cenh1POxiGMxIQlv.js +1 -0
  308. package/screenshot-page/assets/ChSvXfVMLxZsP9zG.js +8 -0
  309. package/screenshot-page/assets/Ci5NtzhJLll1kxGf.js +10 -0
  310. package/screenshot-page/assets/CjngjJNheGaVRvZp.js +1 -0
  311. package/screenshot-page/assets/ClzdIJrFdInttVJA.js +1 -0
  312. package/screenshot-page/assets/CnPgk3HcIziOcskY.js +10 -0
  313. package/screenshot-page/assets/CnXLpFE_vFrJ5Jbf.js +1 -0
  314. package/screenshot-page/assets/CpbohdgEaEsVDi9J.js +1 -0
  315. package/screenshot-page/assets/CqR3hGrC956TkCMj.js +20 -0
  316. package/screenshot-page/assets/Cr1tQKUBVKOQl3QC.js +1 -0
  317. package/screenshot-page/assets/CwqNb7JYzC03lCj0.js +1 -0
  318. package/screenshot-page/assets/CykecBozGGFl26KA.js +3940 -0
  319. package/screenshot-page/assets/CzTizxHhb-CI_ajE.js +1 -0
  320. package/screenshot-page/assets/CzhH7lTYQrYGHct6.js +1 -0
  321. package/screenshot-page/assets/CzzEl3lAkZopkwhC.js +1 -0
  322. package/screenshot-page/assets/D-LgRj0s-PAVqY-L.js +1 -0
  323. package/screenshot-page/assets/D-XR1MGhwn7Jqj60.js +1 -0
  324. package/screenshot-page/assets/D47ePD4x1lVazNdl.js +7 -0
  325. package/screenshot-page/assets/D66vSE1ConAuENmB.js +586 -0
  326. package/screenshot-page/assets/D6Jpaz2YkhOfzxDB.js +1 -0
  327. package/screenshot-page/assets/D9zCVZpnJBfNSNO2.js +1 -0
  328. package/screenshot-page/assets/DCVUZ_ayOXFwV2d_.js +3 -0
  329. package/screenshot-page/assets/DDQWM8rNYCYzKa9R.js +1 -0
  330. package/screenshot-page/assets/DFE-fKq5NV7_O8V6.js +1 -0
  331. package/screenshot-page/assets/DGXDfjkGZjMRAXPg.js +5 -0
  332. package/screenshot-page/assets/DHa5_U58lSwCnpmG.js +1 -0
  333. package/screenshot-page/assets/DKVB6ddRfDJatYid.js +1 -0
  334. package/screenshot-page/assets/DK_QSosKV62NDcuT.js +42 -0
  335. package/screenshot-page/assets/DM9U7u7FQK0jcwh4.js +1 -0
  336. package/screenshot-page/assets/DNDaHmkQrQTaCHhV.js +1 -0
  337. package/screenshot-page/assets/DQ0kGd99-fXxuNYk.js +1 -0
  338. package/screenshot-page/assets/DQWHkaQeNXft9j8b.js +2 -0
  339. package/screenshot-page/assets/DRVfGdmVBvktrZ1t.js +1 -0
  340. package/screenshot-page/assets/DRrM-dY9nM7nDRpV.js +1 -0
  341. package/screenshot-page/assets/DT2x1gO3f2G5NfeB.js +1 -0
  342. package/screenshot-page/assets/DTFRGj188QuLKEXw.js +1 -0
  343. package/screenshot-page/assets/DU3FmyUH0RjPIBd-.js +1 -0
  344. package/screenshot-page/assets/DVueE--eOrZPrqrm.js +1 -0
  345. package/screenshot-page/assets/DXQLzGmxoyN3kfQi.js +27 -0
  346. package/screenshot-page/assets/DXWWyJlMSWgDFxs1.js +10 -0
  347. package/screenshot-page/assets/DYJSIlNxrNw8qk-w.js +1 -0
  348. package/screenshot-page/assets/DYRbCudWTaiE_Sjc.js +1 -0
  349. package/screenshot-page/assets/DZDRRw-62D6Zw7qs.js +1 -0
  350. package/screenshot-page/assets/DaKZ4-Li_ULIIwnK.js +1 -0
  351. package/screenshot-page/assets/DadZXeaVK5UXSHIi.js +1 -0
  352. package/screenshot-page/assets/Db_VGqQo2G2JgXWW.js +1 -0
  353. package/screenshot-page/assets/DceNHPrRLok2At-X.js +1 -0
  354. package/screenshot-page/assets/DcrVJCyDwGKeil2U.js +1 -0
  355. package/screenshot-page/assets/DeAKjatTVaZ0u_FY.js +1 -0
  356. package/screenshot-page/assets/DmMZ4pd492HPw_3_.js +1 -0
  357. package/screenshot-page/assets/DmbuCapSSCYIa3yk.js +1 -0
  358. package/screenshot-page/assets/Dpepompn_NhpSncR.js +1 -0
  359. package/screenshot-page/assets/DqYhS4mcQfOe96hU.js +1 -0
  360. package/screenshot-page/assets/Dsx0NUmGIxS7SvZ8.js +1 -0
  361. package/screenshot-page/assets/DyGpT6t96jrvgJes.js +1 -0
  362. package/screenshot-page/assets/DyLWQxXXTw5uwPVy.js +30 -0
  363. package/screenshot-page/assets/DyYVf8O1rhg3YmjW.js +1 -0
  364. package/screenshot-page/assets/DyxJBLjUkeDuu96F.js +1 -0
  365. package/screenshot-page/assets/HclGiUj8dZXDFmoM.js +1 -0
  366. package/screenshot-page/assets/IRtoU5oVgBWu9rnK.js +2 -0
  367. package/screenshot-page/assets/J73KTOmdZGNmnq-z.js +1 -0
  368. package/screenshot-page/assets/J_xJVgE7YlmeU-ZO.js +6 -0
  369. package/screenshot-page/assets/KoxRo2J_cwB_yOd5.js +2 -0
  370. package/screenshot-page/assets/LVtV_IPhPQroHRui.js +1 -0
  371. package/screenshot-page/assets/MNoPOsydrUv1UGU8.js +2 -0
  372. package/screenshot-page/assets/Q5EKmzoJZCE81Om-.js +2 -0
  373. package/screenshot-page/assets/TfhknTx8vxQkw4zV.js +2 -0
  374. package/screenshot-page/assets/VvqAh6BWzaD5OUPF.js +1 -0
  375. package/screenshot-page/assets/fGlPAximvsxzPzGA.js +1 -0
  376. package/screenshot-page/assets/gG0AFZ45VxS_moMw.js +2 -0
  377. package/screenshot-page/assets/hp_-JA1DMK4Yoztn.js +57 -0
  378. package/screenshot-page/assets/l32n8O_A78Qqduv3.js +1 -0
  379. package/screenshot-page/assets/nHThFXCAZFOM_npq.js +1 -0
  380. package/screenshot-page/assets/pRykm05ElquZBk_a.js +1 -0
  381. package/screenshot-page/assets/rPOkVKdPbFpTG6AY.js +1 -0
  382. package/screenshot-page/assets/sHBomL5R4-_px8rD.js +1 -0
  383. package/screenshot-page/assets/skRJ2qjA7kcmnOsh.js +39 -0
  384. package/screenshot-page/assets/w3bV7wggRayUYTd-.js +1 -0
  385. package/screenshot-page/assets/zFbb8ESzwR_bE7IQ.js +1 -0
  386. package/screenshot-page/index.html +44 -0
  387. package/screenshot-page/resources/contents.json +333 -0
  388. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-bold-italic.hinted.json +125 -0
  389. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-bold-italic.metrics.json +221 -0
  390. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-bold-italic.rows.json +8 -0
  391. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-bold.hinted.json +125 -0
  392. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-bold.metrics.json +221 -0
  393. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-bold.rows.json +8 -0
  394. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-bold-italic.hinted.json +125 -0
  395. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-bold-italic.metrics.json +221 -0
  396. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-bold-italic.rows.json +8 -0
  397. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-bold.hinted.json +125 -0
  398. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-bold.metrics.json +221 -0
  399. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-bold.rows.json +8 -0
  400. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-italic.hinted.json +124 -0
  401. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-italic.metrics.json +221 -0
  402. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-italic.rows.json +8 -0
  403. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-regular.hinted.json +125 -0
  404. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-regular.metrics.json +221 -0
  405. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-display-regular.rows.json +8 -0
  406. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-italic.hinted.json +125 -0
  407. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-italic.metrics.json +221 -0
  408. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-italic.rows.json +8 -0
  409. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-bold-italic.hinted.json +125 -0
  410. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-bold-italic.metrics.json +221 -0
  411. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-bold-italic.rows.json +8 -0
  412. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-bold.hinted.json +125 -0
  413. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-bold.metrics.json +221 -0
  414. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-bold.rows.json +8 -0
  415. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-italic.hinted.json +125 -0
  416. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-italic.metrics.json +221 -0
  417. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-italic.rows.json +8 -0
  418. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-regular.hinted.json +125 -0
  419. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-regular.metrics.json +221 -0
  420. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-narrow-regular.rows.json +8 -0
  421. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-regular.hinted.json +125 -0
  422. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-regular.metrics.json +221 -0
  423. package/screenshot-page/resources/fonts/@sheetxl/sdk/aptos-regular.rows.json +8 -0
  424. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-bold-italic.hinted.json +125 -0
  425. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-bold-italic.metrics.json +139 -0
  426. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-bold-italic.rows.json +8 -0
  427. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-bold.hinted.json +125 -0
  428. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-bold.metrics.json +139 -0
  429. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-bold.rows.json +8 -0
  430. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-italic.hinted.json +125 -0
  431. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-italic.metrics.json +139 -0
  432. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-italic.rows.json +8 -0
  433. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-regular.hinted.json +125 -0
  434. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-regular.metrics.json +139 -0
  435. package/screenshot-page/resources/fonts/@sheetxl/sdk/arial-regular.rows.json +8 -0
  436. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-bold-italic.hinted.json +122 -0
  437. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-bold-italic.metrics.json +137 -0
  438. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-bold-italic.rows.json +8 -0
  439. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-bold.hinted.json +122 -0
  440. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-bold.metrics.json +137 -0
  441. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-bold.rows.json +8 -0
  442. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-italic.hinted.json +121 -0
  443. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-italic.metrics.json +137 -0
  444. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-italic.rows.json +8 -0
  445. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-regular.hinted.json +121 -0
  446. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-regular.metrics.json +137 -0
  447. package/screenshot-page/resources/fonts/@sheetxl/sdk/calibri-regular.rows.json +8 -0
  448. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-bold-italic.hinted.json +105 -0
  449. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-bold-italic.metrics.json +66 -0
  450. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-bold-italic.rows.json +8 -0
  451. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-bold.hinted.json +108 -0
  452. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-bold.metrics.json +66 -0
  453. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-bold.rows.json +8 -0
  454. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-italic.hinted.json +102 -0
  455. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-italic.metrics.json +66 -0
  456. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-italic.rows.json +8 -0
  457. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-regular.hinted.json +110 -0
  458. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-regular.metrics.json +66 -0
  459. package/screenshot-page/resources/fonts/@sheetxl/sdk/cambria-regular.rows.json +8 -0
  460. package/screenshot-page/resources/fonts/@sheetxl/sdk/contents.json +646 -0
  461. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-bold-italic.hinted.json +11 -0
  462. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-bold-italic.metrics.json +143 -0
  463. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-bold-italic.rows.json +8 -0
  464. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-bold.hinted.json +11 -0
  465. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-bold.metrics.json +143 -0
  466. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-bold.rows.json +8 -0
  467. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-italic.hinted.json +11 -0
  468. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-italic.metrics.json +143 -0
  469. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-italic.rows.json +8 -0
  470. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-regular.hinted.json +11 -0
  471. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-regular.metrics.json +143 -0
  472. package/screenshot-page/resources/fonts/@sheetxl/sdk/courier-new-regular.rows.json +8 -0
  473. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-bold-italic.hinted.json +125 -0
  474. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-bold-italic.metrics.json +141 -0
  475. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-bold-italic.rows.json +8 -0
  476. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-bold.hinted.json +125 -0
  477. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-bold.metrics.json +141 -0
  478. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-bold.rows.json +8 -0
  479. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-italic.hinted.json +125 -0
  480. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-italic.metrics.json +143 -0
  481. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-italic.rows.json +8 -0
  482. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-regular.hinted.json +125 -0
  483. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-regular.metrics.json +141 -0
  484. package/screenshot-page/resources/fonts/@sheetxl/sdk/times-new-roman-regular.rows.json +8 -0
  485. package/screenshot-page/resources/locales/@sheetxl/formulas/contents.json +9 -0
  486. package/screenshot-page/resources/locales/@sheetxl/formulas/de/functions.json +298 -0
  487. package/screenshot-page/resources/locales/@sheetxl/formulas-extended/contents.json +9 -0
  488. package/screenshot-page/resources/locales/@sheetxl/formulas-extended/de/functions.json +59 -0
  489. package/screenshot-page/resources/locales/@sheetxl/sdk/contents.json +19 -0
  490. package/screenshot-page/resources/locales/@sheetxl/sdk/de/grammar.json +16 -0
  491. package/screenshot-page/resources/locales/@sheetxl/sdk/de/model.msg.json +710 -0
  492. package/screenshot-page/resources/locales/@sheetxl/sdk/en/model.msg.json +732 -0
  493. package/types/index.d.ts +1 -0
  494. package/types/lib.d.ts +2 -0
  495. package/types/scripting-api.json +10855 -0
  496. package/types/scripting-enums.json +1339 -0
  497. package/types/scripting.d.ts +49295 -0
  498. package/types/src/SessionRegistry.d.ts +630 -0
  499. package/types/src/index.d.ts +3 -0
  500. package/types/src/instances.d.ts +104 -0
  501. package/types/src/lib/Types.d.ts +17 -0
  502. package/types/src/lib/index.d.ts +2 -0
  503. package/types/src/lib/runReport.d.ts +158 -0
  504. package/types/src/lib.d.ts +2 -0
  505. package/types/src/prepareRun.d.ts +56 -0
  506. package/types/src/relay.d.ts +102 -0
  507. package/types/src/screenshot.d.ts +23 -0
  508. package/types/src/server.d.ts +37 -0
  509. package/types/src/taskStore.d.ts +28 -0
@@ -0,0 +1,4036 @@
1
+ /**
2
+ * @license @sheetxl/mcp - MCP server exposing SheetXL spreadsheet operations as tools and resources. - v0.8.0-beta.15
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 { r as e } from "./BCy1zP97fsiIcvj6.js";
8
+ import { B as t, D as s, I as r, J as i, S as o, T as n, Z as a, bt as l, ct as h, ht as c, i as u, ot as d, p as g, tt as m, u as _, xt as f } from "./BQMDOjNBMjAx9WiW.js";
9
+ import { a as p, c as w, s as y } from "./_d5XJ7dn1CKKYrep.js";
10
+ import { Ct as b, K as S, Kt as k, L as C, M as v, Nt as I, Q as N, R as O, S as R, U as x, Ut as E, ct as L, dt as A, ft as V, gt as T, i as P, st as F, yt as W, zt as B } from "./iujMYIEPx_v3sdPf.js";
11
+ import { d as j, p as M } from "./BQbF1RkUH8WyXqSD.js";
12
+ import { An as D, At as z, D as H, Di as J, Dn as U, Ei as q, En as $, Er as K, Ft as G, Hi as X, Jr as Z, Kr as Q, Lr as Y, Lt as ee, Nt as te, Or as se, R as re, Ri as ie, Rt as oe, Sn as ne, St as ae, T as le, V as he, Vn as ce, Vr as ue, W as de, Wi as ge, Yt as me, Zn as _e, Zr as fe, Zt as pe, _a as we, _n as ye, _t as be, an as Se, ar as ke, ca as Ce, cr as ve, ct as Ie, di as Ne, dt as Oe, fa as Re, hn as xe, ht as Ee, ii as Le, ki as Ae, la as Ve, mn as Te, n as Pe, o as Fe, oa as We, ot as Be, pt as je, q as Me, qr as De, ri as ze, rt as He, sn as Je, sr as Ue, st as qe, tr as $e, tt as Ke, ui as Ge, v as Xe, wi as Ze, yr as Qe, zr as Ye } from "./Bh0PNKlrR4VAqnP8.js";
13
+ var et, tt, st = class extends r {
14
+ constructor(e, t = 50) {
15
+ super(t), this._transactions = e, this._floorId = e ? e.getCurrentCommit(!1).getId() : null, this._removeListener = e?.addListener({ onCommitChange: () => this._notifyOnStackChange() });
16
+ }
17
+ _undoCommits(e = this.maxStack) {
18
+ const t = this._transactions;
19
+ if (!t) return [];
20
+ const s = t.getLog(t.getCurrentCommit(!1).getId(), Number.MAX_SAFE_INTEGER), r = [];
21
+ for (let t = 0; t < s.length && r.length < e; t++) {
22
+ const e = s[t];
23
+ if (e.getId() === this._floorId) break;
24
+ if (t === s.length - 1) break;
25
+ e.getDescription() && r.push(e);
26
+ }
27
+ return r;
28
+ }
29
+ _redoCommits(e = this.maxStack) {
30
+ const t = this._transactions;
31
+ if (!t) return [];
32
+ const s = t.getCurrentCommit(!1).getId(), r = t.getTipCommit().getId();
33
+ if (r === s) return [];
34
+ const i = t.getLog(r, Number.MAX_SAFE_INTEGER), o = [];
35
+ let n = !1;
36
+ for (const e of i) {
37
+ if (e.getId() === s) {
38
+ n = !0;
39
+ break;
40
+ }
41
+ o.push(e);
42
+ }
43
+ if (!n) return [];
44
+ o.reverse();
45
+ const a = [];
46
+ for (const t of o) if (t.getDescription() && a.push(t), a.length >= e) break;
47
+ return a;
48
+ }
49
+ undo(e = 1) {
50
+ const t = this._transactions;
51
+ if (!t) return;
52
+ let s = !1;
53
+ try {
54
+ for (let r = 0; r < e; r++) {
55
+ const [e] = this._undoCommits(1);
56
+ if (!e) break;
57
+ t.revert(e.getId()), s = !0;
58
+ }
59
+ } finally {
60
+ s && this._notifyOnStackChange();
61
+ }
62
+ }
63
+ redo(e = 1) {
64
+ const t = this._transactions;
65
+ if (!t) return;
66
+ let s = !1;
67
+ try {
68
+ for (let r = 0; r < e; r++) {
69
+ const [e] = this._redoCommits(1);
70
+ if (!e) {
71
+ 0 === r && this._repeatOperation?.repeat();
72
+ break;
73
+ }
74
+ t.restore(e.getId()), s = !0;
75
+ }
76
+ } finally {
77
+ s && this._notifyOnStackChange();
78
+ }
79
+ }
80
+ hasUndo() {
81
+ return this._undoCommits(1).length > 0;
82
+ }
83
+ hasRedo() {
84
+ return this._redoCommits(1).length > 0 || null !== this._repeatOperation;
85
+ }
86
+ getTopUndoDescription() {
87
+ return this._undoCommits(1)[0]?.getDescription() ?? null;
88
+ }
89
+ getTopRedoDescription() {
90
+ return null !== this._repeatOperation ? this._repeatOperation.description : this._redoCommits(1)[0]?.getDescription() ?? null;
91
+ }
92
+ getUndoDescriptions() {
93
+ return this._undoCommits().map((e) => e.getDescription());
94
+ }
95
+ getRedoDescriptions() {
96
+ const e = this._redoCommits().map((e) => e.getDescription());
97
+ return 0 === e.length && null !== this._repeatOperation && e.push(this._repeatOperation.description), Object.freeze(e);
98
+ }
99
+ getUndoEntries() {
100
+ return this._undoCommits().map(it);
101
+ }
102
+ getRedoEntries() {
103
+ const e = this._redoCommits().map(it);
104
+ return 0 === e.length && null !== this._repeatOperation && e.push({
105
+ description: this._repeatOperation.description,
106
+ author: null,
107
+ meta: rt
108
+ }), Object.freeze(e);
109
+ }
110
+ addUndoOperation() {
111
+ throw new Error("TransactionUndoManager derives its stack from the commit log; commit a described transaction instead.");
112
+ }
113
+ clear(e = !0) {
114
+ this._transactions && (this._floorId = this._transactions.getCurrentCommit(!1).getId()), super.clear(e);
115
+ }
116
+ close() {
117
+ this._removeListener?.();
118
+ }
119
+ }, rt = Object.freeze({}), it = (e) => ({
120
+ description: e.getDescription(),
121
+ author: e.getAuthor(),
122
+ meta: e.getMeta() ?? rt
123
+ }), ot = class {
124
+ constructor(e, t) {
125
+ this._dirty = !1, this._store = e, this._savedCommitId = e.getCurrentCommit()?.getId() ?? null, this._emitter = new y(this);
126
+ const s = this;
127
+ this._removeStoreListener = e.addListener({
128
+ onCommitEnd() {
129
+ s._recompute();
130
+ },
131
+ onCommitChange() {
132
+ s._recompute();
133
+ }
134
+ }), this._removeCommitListener = t?.addCommitListener({ onCommit(e) {
135
+ e.store === s._store && s.markSaved(e.commitId);
136
+ } });
137
+ }
138
+ getStore() {
139
+ return this._store;
140
+ }
141
+ isDirty() {
142
+ return (this._store.getCurrentCommit()?.getId() ?? null) !== this._savedCommitId;
143
+ }
144
+ getSavedCommitId() {
145
+ return this._savedCommitId;
146
+ }
147
+ markSaved(e = this._store.getCurrentCommit()?.getId() ?? null) {
148
+ e !== this._savedCommitId && (this._savedCommitId = e ?? null, this._recompute());
149
+ }
150
+ addListeners(e, t) {
151
+ return this._emitter.addListeners(e, t);
152
+ }
153
+ _recompute() {
154
+ const e = this.isDirty();
155
+ e !== this._dirty && (this._dirty = e, this._emitter.notify(e ? "onDirty" : "onClean", { transactional: !1 }));
156
+ }
157
+ close() {
158
+ this._removeStoreListener?.(), this._removeCommitListener?.(), this._emitter.close();
159
+ }
160
+ };
161
+ et || (et = {});
162
+ var nt = class e {
163
+ constructor(t, s = {}) {
164
+ this._password = null, this._emitter = new y(this), this._path = t ?? null, this._name = s.name ?? null, this._format = s.format ?? null, this._size = s.size ?? null, this._lastModified = s.lastModified ?? null, this._canWrite = s.canWrite ?? e._defaultCanWrite(this._path), this._encryption = s.encryption ?? null;
165
+ }
166
+ static _defaultCanWrite(e) {
167
+ return !!e && !/^(https?:|data:|blob:)/i.test(e);
168
+ }
169
+ _cleanPath() {
170
+ return this._path ? this._path.split(/[?#]/)[0] : null;
171
+ }
172
+ getName() {
173
+ if (null !== this._name && void 0 !== this._name) return this._name;
174
+ const e = this._cleanPath();
175
+ return e && He(e) || null;
176
+ }
177
+ getPath() {
178
+ return this._path;
179
+ }
180
+ getFormat() {
181
+ return this._format ? this._format : this.getExtension();
182
+ }
183
+ getExtension() {
184
+ const e = this._cleanPath();
185
+ if (!e) return null;
186
+ const t = Ke(e);
187
+ return t ? t.toLowerCase() : null;
188
+ }
189
+ getEncryption() {
190
+ return this._encryption;
191
+ }
192
+ isEncrypted() {
193
+ return null !== this._encryption || null !== this._password;
194
+ }
195
+ setPassword(e) {
196
+ this._password !== (e ?? null) && (this._password = e ?? null, null === this._password && (this._encryption = null), this._emitter.notify("onChange"));
197
+ }
198
+ getPassword() {
199
+ return this._password;
200
+ }
201
+ getSize() {
202
+ return this._size;
203
+ }
204
+ getLastModified() {
205
+ return this._lastModified;
206
+ }
207
+ canWrite() {
208
+ return this._canWrite;
209
+ }
210
+ setName(e) {
211
+ this.update({ name: e });
212
+ }
213
+ update(e) {
214
+ let t = !1;
215
+ return void 0 !== e.lastModified && e.lastModified !== this._lastModified && (this._lastModified = e.lastModified, t = !0), void 0 !== e.name && e.name !== this._name && (this._name = e.name, t = !0), void 0 !== e.format && e.format !== this._format && (this._format = e.format, t = !0), void 0 !== e.size && e.size !== this._size && (this._size = e.size, t = !0), void 0 !== e.canWrite && e.canWrite !== this._canWrite && (this._canWrite = e.canWrite, t = !0), void 0 !== e.encryption && e.encryption !== this._encryption && (this._encryption = e.encryption, t = !0), t && this._emitter.notify("onChange"), this;
216
+ }
217
+ addListeners(e, t) {
218
+ return this._emitter.addListeners(e, t);
219
+ }
220
+ get [Symbol.toStringTag]() {
221
+ return "[Origin]";
222
+ }
223
+ toString() {
224
+ const e = this._cleanPath(), t = e ? e.split(/[/\\]/).pop() || e : this._name ?? "(unbound)", s = this._size;
225
+ if (null == s) return t;
226
+ if (s < 1024) return `${t} ${s}B`;
227
+ const r = Math.floor(Math.log(s) / Math.log(1024)), i = [
228
+ "B",
229
+ "KB",
230
+ "MB",
231
+ "GB",
232
+ "TB"
233
+ ];
234
+ return `${t} ${(s / Math.pow(1024, r)).toFixed(2)}${i[Math.min(r, i.length - 1)]}`;
235
+ }
236
+ }, at = /* @__PURE__ */ new WeakMap(), lt = /* @__PURE__ */ new Set(), ht = (e) => at.get(e) ?? null, ct = class e {
237
+ constructor(t) {
238
+ this._released = !1, e._assertFree(t), this._emitter = new y(this), this._origin = t, at.set(t, this), lt.add(this);
239
+ }
240
+ getOrigin() {
241
+ return this._origin;
242
+ }
243
+ setOrigin(t) {
244
+ t !== this._origin && (e._assertFree(t), this._released || (at.delete(this._origin), at.set(t, this)), this._origin = t, this._emitter.notify("onOriginChange"));
245
+ }
246
+ release() {
247
+ this._released || (this._released = !0, at.get(this._origin) === this && at.delete(this._origin), lt.delete(this));
248
+ }
249
+ addListeners(e, t) {
250
+ return this._emitter.addListeners(e, t);
251
+ }
252
+ static _assertFree(e) {
253
+ if (at.has(e)) throw new Error("This origin already backs an open workbook; an origin backs one workbook at a time.");
254
+ }
255
+ }, ut = class {
256
+ constructor() {
257
+ this._defaultStringSourceType = "filepath";
258
+ }
259
+ async read(e) {
260
+ const t = e.options ?? {};
261
+ let s = e.source;
262
+ if ("function" == typeof s && (s = s()), s && "object" == typeof s && "function" == typeof s.then && (s = await Promise.resolve(s)), null == s && (s = await this.resolveSource(e), null == s)) return null;
263
+ const r = s, i = await this.fileFromHandle(s);
264
+ i && (s = i);
265
+ const o = t.format;
266
+ let n = this._detectSourceType(s);
267
+ if (!n) throw new Error("Unable to detect source type from provided input.");
268
+ let a, l, h = !1;
269
+ if ("filepath" === n) {
270
+ const e = "string" == typeof s && s.startsWith("file://") ? s.slice(7) : s;
271
+ s = await this.filePathToFile(e), n = "file", h = !0;
272
+ }
273
+ switch (n) {
274
+ case "file": {
275
+ const e = s, r = e?.name, n = r ? `${He(r)}` : "";
276
+ a = await e.arrayBuffer(), l = {
277
+ format: o,
278
+ ext: Ke(r),
279
+ name: n,
280
+ absolutePath: r,
281
+ size: e.size,
282
+ lastModified: e.lastModified,
283
+ canWrite: !t.asCopy && (!!i || h && this._canWriteLocalPath())
284
+ };
285
+ break;
286
+ }
287
+ case "blob": {
288
+ const e = s;
289
+ a = await e.arrayBuffer(), l = {
290
+ format: o,
291
+ size: e.size
292
+ };
293
+ break;
294
+ }
295
+ case "base64": {
296
+ let e;
297
+ if (s && "object" == typeof s && "base64" in s) e = s.base64;
298
+ else if ("string" == typeof s && s.startsWith("data:")) {
299
+ const [, t] = s.split(",");
300
+ e = t;
301
+ } else e = s;
302
+ a = f.base64ToArrayBuffer(e), l = {
303
+ format: o,
304
+ size: e.length
305
+ };
306
+ break;
307
+ }
308
+ case "fetch": {
309
+ let t, r, i;
310
+ if ("string" == typeof s) t = s;
311
+ else {
312
+ if (!s || "object" != typeof s || !("input" in s)) throw new Error("Invalid fetch source provided.");
313
+ {
314
+ const e = s;
315
+ t = e.input, r = e.init, i = e.timeout;
316
+ }
317
+ }
318
+ const n = i || 3e4, h = new AbortController(), c = setTimeout(() => h.abort(), n), u = "string" == typeof t ? t : t.toString(), d = Ke(u);
319
+ try {
320
+ const e = await fetch(t, {
321
+ ...r,
322
+ signal: h.signal
323
+ });
324
+ if (clearTimeout(c), !e.ok) throw new Error(`Failed to fetch: ${e.status} ${e.statusText}`);
325
+ const s = await e.arrayBuffer();
326
+ if (!s) throw new Error(`Unable to fetched content: ${u}`);
327
+ a = s, l = {
328
+ format: o,
329
+ ext: d,
330
+ name: He(u, !0),
331
+ absolutePath: u
332
+ };
333
+ } catch (e) {
334
+ if (clearTimeout(c), "AbortError" === e.name) throw new Error(`Fetch timeout after ${n}ms: ${u}`);
335
+ throw e;
336
+ }
337
+ break;
338
+ }
339
+ case "buffer":
340
+ a = s, l = { format: o };
341
+ break;
342
+ case "stream": {
343
+ const e = s.getReader(), t = [];
344
+ let r = 0;
345
+ try {
346
+ for (;;) {
347
+ const { done: s, value: i } = await e.read();
348
+ if (s) break;
349
+ t.push(i), r += i.length;
350
+ }
351
+ } finally {
352
+ e.releaseLock();
353
+ }
354
+ const i = new ArrayBuffer(r), n = new Uint8Array(i);
355
+ let h = 0;
356
+ for (const e of t) n.set(e, h), h += e.length;
357
+ a = i, l = { format: o };
358
+ break;
359
+ }
360
+ default: throw new Error(`Unsupported source type: ${n}`);
361
+ }
362
+ l.canWrite && await this.findOpenOrigin(r, l) && (l.canWrite = !1);
363
+ const c = await e.decode(a, {
364
+ sourceType: n,
365
+ ...l
366
+ });
367
+ return c ? (await this.onWorkbookRead(c, r), c) : null;
368
+ }
369
+ async findOpenOrigin(e, t) {
370
+ return t.absolutePath ? this.findOpenPath(t.absolutePath) : null;
371
+ }
372
+ findOpenPath(e, t) {
373
+ return Array.from(lt, (e) => e.getOrigin()).find((s) => {
374
+ if (s === t || !s.canWrite()) return !1;
375
+ const r = s.getPath();
376
+ return !!r && this.isSamePath(r, e);
377
+ }) ?? null;
378
+ }
379
+ isSamePath(e, t) {
380
+ return e === t;
381
+ }
382
+ async fileFromHandle(e) {
383
+ return null;
384
+ }
385
+ async resolveSource(e) {
386
+ return null;
387
+ }
388
+ async onWorkbookRead(e, t) {}
389
+ _canWriteLocalPath() {
390
+ return !1;
391
+ }
392
+ _detectSourceType(e) {
393
+ if (e && "object" == typeof e && "base64" in e) return "base64";
394
+ if (e && "object" == typeof e && "input" in e) return "fetch";
395
+ if ("string" == typeof e) {
396
+ if (e.startsWith("data:")) return "base64";
397
+ if (e.startsWith("http://") || e.startsWith("https://")) return "fetch";
398
+ if (e.startsWith("file://")) return "filepath";
399
+ const t = this._defaultStringSourceType;
400
+ return e.startsWith("./") || e.startsWith("../") || e.startsWith("/") || /^[a-zA-Z]:[/\\]/.test(e), t;
401
+ }
402
+ if ("undefined" != typeof File && e instanceof File) return "file";
403
+ if ("undefined" != typeof Blob && e instanceof Blob) return "blob";
404
+ const t = e instanceof ArrayBuffer || "[object ArrayBuffer]" === Object.prototype.toString.call(e), s = ArrayBuffer.isView(e), r = f.isNodeBuffer(e);
405
+ return t || s || r ? "buffer" : "undefined" != typeof ReadableStream && e instanceof ReadableStream || "[object ReadableStream]" === Object.prototype.toString.call(e) || e && "function" == typeof e.getReader && void 0 !== e.locked ? "stream" : null;
406
+ }
407
+ }, dt = class extends ut {
408
+ constructor(e, t) {
409
+ super();
410
+ }
411
+ filePathToFile(e) {
412
+ return async function(e) {
413
+ const t = await import(
414
+ /* @vite-ignore */
415
+ /* webpackIgnore: true */
416
+ "fs/promises"
417
+ ), s = (await import(
418
+ /* @vite-ignore */
419
+ /* webpackIgnore: true */
420
+ "path"
421
+ )).resolve(e.replace(/\\/g, "/")), [r, i] = await Promise.all([t.readFile(s), t.stat(s)]), o = new Uint8Array(r);
422
+ return new File([o], s, { lastModified: i.mtimeMs });
423
+ }(e);
424
+ }
425
+ _canWriteLocalPath() {
426
+ return !0;
427
+ }
428
+ isSamePath(e, t) {
429
+ const s = (e) => {
430
+ const t = e.replace(/\\/g, "/");
431
+ return "win32" === process.platform ? t.toLowerCase() : t;
432
+ };
433
+ return s(e) === s(t);
434
+ }
435
+ async write(e) {
436
+ const t = await import(
437
+ /* @vite-ignore */
438
+ /* webpackIgnore: true */
439
+ "fs/promises"
440
+ ), s = await import(
441
+ /* @vite-ignore */
442
+ /* webpackIgnore: true */
443
+ "path"
444
+ ), r = e.origin.getPath(), i = !(!r || !e.origin.canWrite()), o = i ? r : e.origin.getName() ? e.suggestedName : null;
445
+ if (!o) throw new Error("No file name provided to write to.");
446
+ const n = s.resolve(o.replace(/\\/g, "/")), a = this.findOpenPath(n, e.workbook?.getOrigin?.());
447
+ if (a) throw new m(g("error.io.openElsewhere", { name: a.getName() ?? n }));
448
+ const l = i ? e.origin : new nt(n, {
449
+ format: e.format.key,
450
+ canWrite: !0
451
+ }), h = await e.encode(e.format.key, l);
452
+ if (!h) return null;
453
+ const c = Buffer.from(h), u = s.dirname(n);
454
+ try {
455
+ await t.mkdir(u, { recursive: !0 });
456
+ } catch (e) {
457
+ if ("EEXIST" !== e.code) throw new Error(`Cannot create directory '${u}': ${e.message}`);
458
+ }
459
+ try {
460
+ await t.writeFile(n, c);
461
+ } catch (e) {
462
+ throw new Error(`Failed to write file '${n}': ${e.message}`);
463
+ }
464
+ if (l instanceof nt) {
465
+ const e = await t.stat(n).catch(() => null);
466
+ l.update({
467
+ size: c.byteLength,
468
+ lastModified: e?.mtimeMs ?? null
469
+ });
470
+ }
471
+ return l;
472
+ }
473
+ };
474
+ (tt || (tt = {})).SortOn = {
475
+ Value: "value",
476
+ FillColor: "fillColor",
477
+ FontColor: "fontColor",
478
+ Icon: "icon"
479
+ };
480
+ var gt, mt, _t, ft, pt = {
481
+ TopLeft: "tl",
482
+ Top: "t",
483
+ TopRight: "tr",
484
+ Left: "l",
485
+ Center: "ctr",
486
+ Right: "r",
487
+ BottomLeft: "bl",
488
+ Bottom: "b",
489
+ BottomRight: "br"
490
+ }, wt = W.BuiltInName, yt = {
491
+ [wt.Normal]: _("style.builtin.normal"),
492
+ [wt.Comma]: _("style.builtin.comma"),
493
+ [wt.Currency]: _("style.builtin.currency"),
494
+ [wt.Percent]: _("style.builtin.percent"),
495
+ [wt.Comma0]: _("style.builtin.comma0"),
496
+ [wt.Currency0]: _("style.builtin.currency0"),
497
+ [wt.Hyperlink]: _("style.builtin.hyperlink"),
498
+ [wt.FollowedHyperlink]: _("style.builtin.followedHyperlink"),
499
+ [wt.Note]: _("style.builtin.note"),
500
+ [wt.WarningText]: _("style.builtin.warningText"),
501
+ [wt.Title]: _("style.builtin.title"),
502
+ [wt.Input]: _("style.builtin.input"),
503
+ [wt.Output]: _("style.builtin.output"),
504
+ [wt.Calculation]: _("style.builtin.calculation"),
505
+ [wt.CheckCell]: _("style.builtin.checkCell"),
506
+ [wt.LinkedCell]: _("style.builtin.linkedCell"),
507
+ [wt.Total]: _("style.builtin.total"),
508
+ [wt.Good]: _("style.builtin.good"),
509
+ [wt.Bad]: _("style.builtin.bad"),
510
+ [wt.Neutral]: _("style.builtin.neutral"),
511
+ [wt.ExplanatoryText]: _("style.builtin.explanatoryText")
512
+ }, bt = _("style.builtin.heading"), St = _("style.builtin.accent"), kt = _("style.builtin.accentTint"), Ct = /^Heading ([1-4])$/, vt = /^Accent([1-6])$/, It = /^(20|40|60)% - Accent([1-6])$/;
513
+ function Nt(e) {
514
+ const t = yt[e];
515
+ if (t) return { key: t };
516
+ let s = Ct.exec(e);
517
+ return s ? {
518
+ key: bt,
519
+ params: { n: +s[1] }
520
+ } : (s = vt.exec(e), s ? {
521
+ key: St,
522
+ params: { n: +s[1] }
523
+ } : (s = It.exec(e), s ? {
524
+ key: kt,
525
+ params: {
526
+ pct: +s[1],
527
+ n: +s[2]
528
+ }
529
+ } : null));
530
+ }
531
+ var Ot, Rt = (e, t, s, r, i) => {
532
+ const o = JSON.parse(JSON.stringify(e.definition));
533
+ o.adjs || (o.adjs = []);
534
+ let n = "", a = 0, l = 0;
535
+ t > 0 ? (l = t, a = 100 - t, n = g("op.lighterPercent", { percent: t })) : t < 0 && (a = 100 + t, n = g("op.darkerPercent", { percent: -t })), a && o.adjs.push({ [E.AdjustmentType.LumMod]: a }), l && o.adjs.push({ [E.AdjustmentType.LumOff]: l });
536
+ const h = new S({
537
+ val: o.val,
538
+ adjs: o.adjs
539
+ }, s), c = h.toString();
540
+ r?.set(c, h);
541
+ const u = h.toRGBA().toString();
542
+ return i?.set(u, h), {
543
+ description: e.description + ", " + n,
544
+ definition: o
545
+ };
546
+ };
547
+ (gt || (gt = {})).buildPalette = function(e, t, s, r) {
548
+ let i = [];
549
+ for (let o = 0; o < e.length; o++) {
550
+ let n = [];
551
+ i.push(n);
552
+ const a = (i) => {
553
+ for (let a = 0; a < i.length; a++) n.push(Rt(e[o], i[a], t, s, r));
554
+ };
555
+ let l = new S({
556
+ val: e[o].definition.val,
557
+ adjs: e[o].definition.adjs
558
+ }, t).toHSLA().lum;
559
+ a(0 === l ? [
560
+ 50,
561
+ 35,
562
+ 25,
563
+ 15,
564
+ 5
565
+ ] : 100 === l ? [
566
+ -5,
567
+ -15,
568
+ -25,
569
+ -35,
570
+ -50
571
+ ] : l <= 20 ? [
572
+ 90,
573
+ 75,
574
+ 50,
575
+ 25,
576
+ 10
577
+ ] : l >= 80 ? [
578
+ -10,
579
+ -25,
580
+ -50,
581
+ -75,
582
+ -90
583
+ ] : [
584
+ 80,
585
+ 60,
586
+ 40,
587
+ -25,
588
+ -50
589
+ ]);
590
+ }
591
+ return i;
592
+ }, mt || (mt = {}), _t || (_t = {}), ft || (ft = {});
593
+ var xt = null;
594
+ function Et() {
595
+ if (!xt) {
596
+ const e = import("./ClNQN3vEg5b5qUDp.js").then(({ initializeFunctions: e }) => {
597
+ const t = e(() => null);
598
+ return Object.freeze(Array.from(t.keys()));
599
+ });
600
+ e.catch(() => {
601
+ xt = null;
602
+ }), xt = e;
603
+ }
604
+ return xt;
605
+ }
606
+ function Lt(e) {
607
+ return We.peek()?.readFormulaLiteral(e);
608
+ }
609
+ function At(e, t) {
610
+ const s = Vt(e), r = Vt(t);
611
+ return s !== r ? s - r : e === t ? 0 : "number" == typeof e && "number" == typeof t ? e < t ? -1 : 1 : "string" == typeof e && "string" == typeof t ? e < t ? -1 : e > t ? 1 : 0 : "boolean" == typeof e ? e ? 1 : -1 : j.isError(e) && j.isError(t) ? e.getCode() - t.getCode() : 0;
612
+ }
613
+ function Vt(e) {
614
+ if (null === e) return 0;
615
+ switch (typeof e) {
616
+ case "number": return 1;
617
+ case "string": return 2;
618
+ case "boolean": return 3;
619
+ default: return j.isError(e) ? 4 : 5;
620
+ }
621
+ }
622
+ (function(e) {
623
+ function t(e) {
624
+ return We.peek()?.getFunctionDeclaration(e) ?? null;
625
+ }
626
+ e.get = t, e.has = function(e) {
627
+ return null !== t(e);
628
+ };
629
+ })(Ot || (Ot = {}));
630
+ var Tt, Pt = class {
631
+ constructor(e) {
632
+ this._children = e;
633
+ }
634
+ getCoords() {
635
+ const e = this._children;
636
+ let t = null;
637
+ for (let s = 0; s < e.length; s++) {
638
+ const r = e[s].getCoords();
639
+ r && (t = t ? {
640
+ rowStart: Math.min(t.rowStart, r.rowStart),
641
+ colStart: Math.min(t.colStart, r.colStart),
642
+ rowEnd: Math.max(t.rowEnd, r.rowEnd),
643
+ colEnd: Math.max(t.colEnd, r.colEnd)
644
+ } : r);
645
+ }
646
+ return t;
647
+ }
648
+ getSize() {
649
+ const e = this._children, t = e.length;
650
+ let s = 0;
651
+ for (let r = 0; r < t; r++) s += e[r].getSize();
652
+ return s;
653
+ }
654
+ getCount() {
655
+ const e = this._children, t = e.length;
656
+ let s = 0;
657
+ for (let r = 0; r < t; r++) s += e[r].getCount();
658
+ return s;
659
+ }
660
+ getAggregates(e) {
661
+ if (e) return this._mergeAggregates(e);
662
+ let t = this._aggregates;
663
+ return t || (t = this._mergeAggregates(), this._aggregates = t), t;
664
+ }
665
+ getSnappedSum(e) {
666
+ const t = e ?? this.getAggregates().sum ?? 0, s = this._children;
667
+ for (let e = s.length - 1; e >= 0; e--) if (s[e].getAggregates().numericalCount > 0) return s[e].getSnappedSum(t);
668
+ return t;
669
+ }
670
+ getSortedNumbers() {
671
+ let e = this._sortedNumbers;
672
+ if (!e) {
673
+ const t = this._children, s = t.length, r = [];
674
+ for (let e = 0; e < s; e++) {
675
+ const s = t[e].getSortedNumbers().getValues();
676
+ s.length > 0 && r.push(s);
677
+ }
678
+ e = new se(function(e) {
679
+ const t = e.length;
680
+ if (0 === t) return Ft;
681
+ if (1 === t) return e[0];
682
+ let s = e[0];
683
+ for (let r = 1; r < t; r++) s = Wt(s, e[r]);
684
+ return Object.freeze(s);
685
+ }(r)), this._sortedNumbers = e;
686
+ }
687
+ return e;
688
+ }
689
+ getRanked(e) {
690
+ return J(this._children, e, At)[Symbol.iterator]();
691
+ }
692
+ getFrequencies(e) {
693
+ if (e) return this._mergeFrequencies(e);
694
+ let t = this._frequencies;
695
+ return t || (t = this._mergeFrequencies(), this._frequencies = t), t;
696
+ }
697
+ _mergeFrequencies(e) {
698
+ const t = e?.keyFn ?? Ve, s = e?.limit, r = /* @__PURE__ */ new Map(), i = this._children, o = i.length;
699
+ let n = 0, a = 0, l = !1;
700
+ for (let h = 0; h < o; h++) {
701
+ const o = i[h].getFrequencies(e);
702
+ n += o.getVisitedCount(), a += o.getTotalCount(), l = l || o.isTruncated();
703
+ const c = o.getValueCounts();
704
+ let u = c.next();
705
+ for (; !u.done;) {
706
+ const [e, i] = u.value, o = t(e), n = r.get(o);
707
+ n ? n.count += i : void 0 === s || r.size < s ? r.set(o, {
708
+ value: e,
709
+ count: i
710
+ }) : l = !0, u = c.next();
711
+ }
712
+ }
713
+ return le.fromGroups(r, t, e, At, n, a, l);
714
+ }
715
+ getTypedCounts(e) {
716
+ let t = this._typedCounts;
717
+ if (!t) {
718
+ const e = {
719
+ [M.Number]: 0,
720
+ [M.String]: 0,
721
+ [M.Boolean]: 0,
722
+ [M.Error]: 0,
723
+ [M.RichData]: 0,
724
+ [M.Null]: 0
725
+ }, s = this._children, r = s.length;
726
+ for (let t = 0; t < r; t++) {
727
+ const r = s[t].getTypedCounts();
728
+ e[M.Number] += r[M.Number] ?? 0, e[M.String] += r[M.String] ?? 0, e[M.Boolean] += r[M.Boolean] ?? 0, e[M.Error] += r[M.Error] ?? 0, e[M.RichData] += r[M.RichData] ?? 0, e[M.Null] += r[M.Null] ?? 0;
729
+ }
730
+ t = Object.freeze(e), this._typedCounts = t;
731
+ }
732
+ if (void 0 === e) return t;
733
+ const s = {}, r = e.length;
734
+ for (let i = 0; i < r; i++) s[e[i]] = t[e[i]] ?? 0;
735
+ return s;
736
+ }
737
+ get isIRangeStats() {
738
+ return !0;
739
+ }
740
+ _mergeAggregates(e) {
741
+ const t = this._children, s = t.length, r = {
742
+ count: 0,
743
+ min: void 0,
744
+ max: void 0,
745
+ numericalCount: 0,
746
+ sum: 0,
747
+ sumSq: 0,
748
+ typed: {
749
+ [M.Number]: 0,
750
+ [M.String]: 0,
751
+ [M.Boolean]: 0,
752
+ [M.Error]: 0,
753
+ [M.RichData]: 0,
754
+ [M.Null]: 0
755
+ }
756
+ };
757
+ for (let i = 0; i < s; i++) {
758
+ const s = t[i].getAggregates(e);
759
+ r.count += s.count;
760
+ const o = s.numericalCount;
761
+ o <= 0 || (r.numericalCount += o, r.sum += s.sum, r.sumSq += s.varP * o + s.sum * s.sum / o, (void 0 === r.min || s.min < r.min) && (r.min = s.min), (void 0 === r.max || s.max > r.max) && (r.max = s.max));
762
+ }
763
+ return Be(r);
764
+ }
765
+ }, Ft = Object.freeze([]);
766
+ function Wt(e, t) {
767
+ const s = e.length, r = t.length, i = new Array(s + r);
768
+ let o = 0, n = 0, a = 0;
769
+ for (; o < s && n < r;) i[a++] = e[o] <= t[n] ? e[o++] : t[n++];
770
+ for (; o < s;) i[a++] = e[o++];
771
+ for (; n < r;) i[a++] = t[n++];
772
+ return i;
773
+ }
774
+ var Bt, jt = class {
775
+ constructor(e, t) {
776
+ this._source = null, this.cacheId = e, this.part = t;
777
+ }
778
+ _hold(e) {
779
+ const t = this.part?.xml;
780
+ if (!t || this._source) return;
781
+ const s = ke(t, "worksheetSource", "ref"), r = ke(t, "worksheetSource", "sheet");
782
+ if (!s || !r || s.includes("#REF!")) return;
783
+ const i = e(r);
784
+ if (!i) return;
785
+ const o = {
786
+ formula: null,
787
+ wired: null,
788
+ last: null
789
+ };
790
+ this._source = o, i(`${me(r)}!${Fe(s)}`, (e) => {
791
+ o.formula = e.formula;
792
+ const t = e.formula.getExpression();
793
+ o.wired ??= t, e.formula.hasRefError() || (o.last = t);
794
+ });
795
+ }
796
+ getXML() {
797
+ const e = this.part?.xml ?? null, t = this._source;
798
+ if (!e || !t?.formula) return e;
799
+ const s = t.formula.hasRefError() ? t.last : t.formula.getExpression();
800
+ if (null === s || s === t.wired) return e;
801
+ const r = $(s);
802
+ return r ? Le(Le(e, "worksheetSource", "ref", ne(r.reference)), "worksheetSource", "sheet", r.sheet) : Le(e, "worksheetSource", "ref", ne(s));
803
+ }
804
+ toJSON(e) {
805
+ const t = { cacheId: this.cacheId }, s = Oe.toJSON(this.part, e);
806
+ if (s) {
807
+ const e = this.getXML();
808
+ null !== e && (s.xml = e), t.part = s;
809
+ }
810
+ return t;
811
+ }
812
+ }, Mt = class {
813
+ constructor(e, t) {
814
+ this._deleted = !1, this._json = { ...e }, this._deleteFromCollection = t ?? null;
815
+ }
816
+ getId() {
817
+ return this._json.id;
818
+ }
819
+ getDisplayName() {
820
+ return this._json.displayName;
821
+ }
822
+ getUserId() {
823
+ return this._json.userId ?? null;
824
+ }
825
+ getProviderId() {
826
+ return this._json.providerId ?? null;
827
+ }
828
+ delete() {
829
+ this._deleted || (this._deleted = !0, this._deleteFromCollection?.(this));
830
+ }
831
+ isDeleted() {
832
+ return this._deleted;
833
+ }
834
+ toJSON() {
835
+ return { ...this._json };
836
+ }
837
+ get [Symbol.toStringTag]() {
838
+ return "[Person]";
839
+ }
840
+ toString() {
841
+ return `Person:${this.getDisplayName()}`;
842
+ }
843
+ get isIPerson() {
844
+ return !0;
845
+ }
846
+ }, Dt = class extends pe {
847
+ constructor(e) {
848
+ super(), this._byId = /* @__PURE__ */ new Map(), this._byDisplayName = /* @__PURE__ */ new Map(), this._items = null, this._current = null, e && this.fromJSON(e);
849
+ }
850
+ _getItems() {
851
+ return this._items ??= Array.from(this._byId.values());
852
+ }
853
+ getCount() {
854
+ return this._byId.size;
855
+ }
856
+ add(e) {
857
+ const t = "string" == typeof e ? { displayName: e } : e, s = t.id;
858
+ if (s) {
859
+ const e = this._byId.get(s);
860
+ if (e) return e;
861
+ }
862
+ const r = t.displayName ?? "";
863
+ if (!s) {
864
+ const e = this._byDisplayName.get(r);
865
+ if (e) return e;
866
+ }
867
+ const i = new Mt({
868
+ ...t,
869
+ displayName: r,
870
+ id: s ?? c.uuidV4().toUpperCase()
871
+ }, (e) => this._remove(e));
872
+ return this._byId.set(i.getId(), i), r && !this._byDisplayName.has(r) && this._byDisplayName.set(r, i), this._items = null, this._notifyCollectionChange(), i;
873
+ }
874
+ getById(e) {
875
+ return "string" != typeof e ? null : this._byId.get(e) ?? null;
876
+ }
877
+ getByDisplayName(e) {
878
+ return "string" != typeof e ? null : this._byDisplayName.get(e) ?? null;
879
+ }
880
+ getCurrent() {
881
+ return this._current ??= this.add("Author");
882
+ }
883
+ setCurrent(e) {
884
+ if (null !== e) {
885
+ if ("object" == typeof e && e.isIPerson) {
886
+ const t = e;
887
+ this._current = this.getById(t.getId()) ?? this.add(t.toJSON());
888
+ return;
889
+ }
890
+ this._current = this.add(e);
891
+ } else this._current = null;
892
+ }
893
+ _remove(e) {
894
+ this._byId.get(e.getId()) === e && (this._byId.delete(e.getId()), this._byDisplayName.get(e.getDisplayName()) === e && this._byDisplayName.delete(e.getDisplayName()), this._current === e && (this._current = null), this._items = null, this._notifyCollectionChange());
895
+ }
896
+ toJSON() {
897
+ return 0 === this._byId.size ? null : this._getItems().map((e) => e.toJSON());
898
+ }
899
+ fromJSON(e) {
900
+ if (!e) return;
901
+ const t = e.length;
902
+ for (let s = 0; s < t; s++) {
903
+ const t = e[s];
904
+ t && "string" == typeof t.id && this.add(t);
905
+ }
906
+ }
907
+ get isIPersonCollection() {
908
+ return !0;
909
+ }
910
+ }, zt = class {
911
+ constructor(e) {
912
+ this._options = e, this._emitter = new y(this), this._initState();
913
+ }
914
+ _initState() {}
915
+ getModules() {
916
+ return this._modules;
917
+ }
918
+ _builtInNames() {
919
+ try {
920
+ const e = this._options.getBuiltInFunctions?.();
921
+ if (!e) return c.EmptyArray;
922
+ const t = [];
923
+ for (const s of e.getItems({ includeHidden: !0 })) s.isBuiltIn() && t.push(s.getName());
924
+ return t;
925
+ } catch {
926
+ return c.EmptyArray;
927
+ }
928
+ }
929
+ async createModule(e) {
930
+ const t = await (await import("./DlBdhv6NHgrNp5Yo.js")).ScriptCompiler.compile({
931
+ builtInNames: this._builtInNames(),
932
+ minify: !0,
933
+ ...e
934
+ });
935
+ return t.module ? await ce(X.DEFAULT_MODULE, t.module, e?.declarationsOnly ?? !1, t.diagnostics) : null;
936
+ }
937
+ addModule(e, t, s) {
938
+ this._modules.add(e, t, s);
939
+ }
940
+ async addModuleFromJSON(e, t, s) {
941
+ const r = await ce(e, t);
942
+ return this.addModule(e, r, s), r;
943
+ }
944
+ executeMacro(e, t, s) {
945
+ const r = this._modules.getItems({ name: t }), i = r.length;
946
+ for (let t = 0; t < i; t++) {
947
+ const i = r[t].getFunctions().getByName(e);
948
+ if (i) return i.execute(this._options.workbook, {
949
+ applyResult: !0,
950
+ ...s
951
+ });
952
+ }
953
+ throw new Error(`No macro ${e} found.`);
954
+ }
955
+ async run(e, t) {
956
+ try {
957
+ const s = "string" == typeof e ? await this.createModule({ source: e }) : await ce(X.DEFAULT_MODULE, e), r = "string" == typeof e ? e : e?.source ?? "";
958
+ return await this._runModule(s, r, t);
959
+ } catch (e) {
960
+ return {
961
+ ok: !1,
962
+ error: e
963
+ };
964
+ }
965
+ }
966
+ async _runModule(e, t, s) {
967
+ const r = this._options?.workbook;
968
+ if (!e) return {
969
+ ok: !1,
970
+ error: /* @__PURE__ */ new Error("The script did not compile to a module.")
971
+ };
972
+ const i = e.getDiagnostics(), o = i.filter((e) => "error" === e.severity);
973
+ if (o.length > 0) {
974
+ const e = new Error(((e, t) => {
975
+ const s = [0];
976
+ for (let t = 0; t < e.length; t++) "\n" === e[t] && s.push(t + 1);
977
+ const r = t.map((e) => ` ${((e) => {
978
+ let t = 0, r = s.length - 1;
979
+ for (; t < r;) {
980
+ const i = t + r + 1 >> 1;
981
+ s[i] <= e ? t = i : r = i - 1;
982
+ }
983
+ return `${t + 1}:${e - s[t] + 1}`;
984
+ })(e.start)} ${e.code}: ${e.message}`), i = t.length;
985
+ return `Script has ${i} compile error${1 === i ? "" : "s"}:\n${r.join("\n")}`;
986
+ })(t, o));
987
+ return e.diagnostics = o, {
988
+ ok: !1,
989
+ error: e,
990
+ diagnostics: i
991
+ };
992
+ }
993
+ const n = e.getFunctions(), a = n.getItems({
994
+ type: "autoRun",
995
+ includeHidden: !0
996
+ })[0] ?? n.getItems({
997
+ type: "macro",
998
+ includeHidden: !0
999
+ })[0] ?? null;
1000
+ if (!a) return {
1001
+ ok: !1,
1002
+ error: /* @__PURE__ */ new Error("The script has no runnable entry. Export a default function taking the script context, e.g. `export default function run(ctx: IScript.ScriptContext) { ... }` (the workbook is `ctx.wb`; a macro may instead take its target first, e.g. `(sheet: IWorksheet, ctx)`).")
1003
+ };
1004
+ const l = await a.execute(r, s);
1005
+ return {
1006
+ ok: !0,
1007
+ result: l?.results,
1008
+ commitId: l?.commitId,
1009
+ diagnostics: i
1010
+ };
1011
+ }
1012
+ _searchable(e) {
1013
+ const t = this._modules;
1014
+ return t && 0 !== t.getCount() ? (e ? t.getItems({ name: e }) : t.getItems()).map((e) => e.getFunctions()) : c.EmptyArray;
1015
+ }
1016
+ async searchFunctions(e) {
1017
+ await this._emitter.notify("onBeforeSearch", { async: !0 });
1018
+ const t = this._searchable(e?.moduleName);
1019
+ if (0 === t.length) return c.EmptyArray;
1020
+ if (1 === t.length) return t[0].search(e);
1021
+ const s = e?.limit, r = void 0 === s ? e : {
1022
+ ...e,
1023
+ limit: void 0
1024
+ };
1025
+ let i;
1026
+ const o = /* @__PURE__ */ new Set();
1027
+ for (let e = 0; e < t.length; e++) {
1028
+ const s = await t[e].search(r);
1029
+ if (0 !== s.length) {
1030
+ i || (i = []);
1031
+ for (let e = 0; e < s.length; e++) {
1032
+ const t = s[e], r = t.getName().toUpperCase();
1033
+ o.has(r) || (o.add(r), i.push(t));
1034
+ }
1035
+ }
1036
+ }
1037
+ if (!i || 0 === i.length) return c.EmptyArray;
1038
+ const n = e?.text ? e.text.trim().toUpperCase() : null;
1039
+ return n ? fe(i, n) : i.sort((e, t) => {
1040
+ const s = e.getName().toUpperCase(), r = t.getName().toUpperCase();
1041
+ return s < r ? -1 : s > r ? 1 : 0;
1042
+ }), void 0 !== s && i.length > s ? i.slice(0, s) : i;
1043
+ }
1044
+ async start() {
1045
+ return this._startPromise || (this._startPromise = this._doStart(), this._startPromise.catch(() => {
1046
+ this._startPromise = void 0;
1047
+ })), this._startPromise;
1048
+ }
1049
+ _load() {
1050
+ return this._loadPromise || (this._loadPromise = this._doLoad(), this._loadPromise.catch(() => {
1051
+ this._loadPromise = void 0;
1052
+ })), this._loadPromise;
1053
+ }
1054
+ async _doStart() {
1055
+ await this._load();
1056
+ const e = this._options?.workbook, t = this._modules.getItems(), s = t.length;
1057
+ for (let r = 0; r < s; r++) {
1058
+ const s = t[r];
1059
+ try {
1060
+ const t = s.getFunctions().getItems({
1061
+ type: "autoRun",
1062
+ includeHidden: !0
1063
+ }), r = t.length;
1064
+ for (let s = 0; s < r; s++) await t[s].execute(e);
1065
+ } catch (e) {
1066
+ i.error("Error executing autoRun script:", e);
1067
+ }
1068
+ }
1069
+ }
1070
+ async _doLoad() {
1071
+ const e = this._options?.workbook, t = this._options?.json;
1072
+ let s = {};
1073
+ if (t) {
1074
+ const r = Object.keys(t);
1075
+ for (let o = 0; o < r.length; o++) {
1076
+ const n = r[o], a = t[n];
1077
+ try {
1078
+ s[n] = await ce(n, a, !1, [], "workbook" === a?.scope ? e : null);
1079
+ } catch (e) {
1080
+ i.error(`Could not load script '${n}'; it will be unavailable.`, e);
1081
+ }
1082
+ }
1083
+ }
1084
+ const r = this, o = new Je({
1085
+ transactions: this._options?.transactions,
1086
+ initial: s,
1087
+ isReadOnly: () => r.isReadOnly(),
1088
+ onRemove: (e, t) => {
1089
+ r._options?.onRemove?.(e, t);
1090
+ },
1091
+ onAdd: (e, t) => {
1092
+ r._emitter.notify("onChange"), r._options?.onAdd?.(e, t);
1093
+ }
1094
+ });
1095
+ this._modules = o;
1096
+ }
1097
+ addListeners(e, t) {
1098
+ return this._emitter.addListeners(e, t);
1099
+ }
1100
+ isReadOnly() {
1101
+ return this._options.workbook?._isStructureProtected?.() ?? !1;
1102
+ }
1103
+ toJSON() {
1104
+ this._emitter.notify("onBeforeSave");
1105
+ const e = this._modules;
1106
+ if (!e) throw new Error("Scripts is initializing.");
1107
+ return e.toJSON();
1108
+ }
1109
+ get isIScript() {
1110
+ return !0;
1111
+ }
1112
+ }, Ht = /^([a-z][a-z0-9+.-]*):/i, Jt = (e) => {
1113
+ const t = e.toLowerCase();
1114
+ return t.endsWith(":") ? t : t + ":";
1115
+ }, Ut = async (e, t) => {
1116
+ try {
1117
+ return await globalThis.fetch(e, t);
1118
+ } catch (s) {
1119
+ if (s instanceof TypeError && await (async (e, t) => {
1120
+ const s = globalThis.location;
1121
+ if (!s || t?.method && "GET" !== t.method.toUpperCase()) return !1;
1122
+ const r = new AbortController(), i = setTimeout(() => r.abort(), 5e3);
1123
+ try {
1124
+ return new URL(e, s.href).origin !== s.origin && (await globalThis.fetch(e, {
1125
+ mode: "no-cors",
1126
+ credentials: "omit",
1127
+ signal: r.signal
1128
+ }), !0);
1129
+ } catch {
1130
+ return !1;
1131
+ } finally {
1132
+ clearTimeout(i), r.abort();
1133
+ }
1134
+ })(e, t)) throw new j.Blocked("This site is restricted: it doesn't allow web apps to read its data, so the browser blocked the request for security.", { cause: s });
1135
+ throw s;
1136
+ }
1137
+ }, qt = class {
1138
+ constructor() {
1139
+ this._handlers = /* @__PURE__ */ new Map([["http:", Ut], ["https:", Ut]]);
1140
+ }
1141
+ fetch(e, t) {
1142
+ const s = Ht.exec(e)?.[1], r = this._handlers.get(s ? Jt(s) : "https:");
1143
+ if (!r) return Promise.reject(/* @__PURE__ */ new TypeError(`No fetcher serves '${s}:'.`));
1144
+ try {
1145
+ return r(e, t);
1146
+ } catch (e) {
1147
+ return Promise.reject(e);
1148
+ }
1149
+ }
1150
+ register(e, t) {
1151
+ const s = Jt(e), r = this._handlers.get(s);
1152
+ return this._handlers.set(s, t), () => {
1153
+ this._handlers.get(s) === t && (r ? this._handlers.set(s, r) : this._handlers.delete(s));
1154
+ };
1155
+ }
1156
+ get isIFetcher() {
1157
+ return !0;
1158
+ }
1159
+ }, $t = /* @__PURE__ */ new Set([
1160
+ 101,
1161
+ 103,
1162
+ 204,
1163
+ 205,
1164
+ 304
1165
+ ]), Kt = (e) => new Response($t.has(e.status) ? null : e.body, {
1166
+ status: e.status,
1167
+ statusText: e.statusText,
1168
+ headers: e.headers
1169
+ }), Gt = class {
1170
+ constructor(e, t) {
1171
+ this._kept = /* @__PURE__ */ new Map(), this._cached = /* @__PURE__ */ new Map(), this._inFlight = /* @__PURE__ */ new Map(), this._resources = e, this._fetcher = t;
1172
+ }
1173
+ getFetcher() {
1174
+ return this._fetcher;
1175
+ }
1176
+ async fetch(e, t) {
1177
+ if (((e) => !e || (!e.method || "GET" === e.method.toUpperCase()) && !e.body)(t) && "reload" !== t?.cache) {
1178
+ const s = this._kept.get(e) ?? this._findHeld(e);
1179
+ if (s && !s.isClosed()) return this._fromKept(s);
1180
+ const r = this._cached.get(e);
1181
+ if (r) return Kt(r);
1182
+ let i = this._inFlight.get(e);
1183
+ return i || (i = this._request(e, {
1184
+ ...t,
1185
+ signal: void 0
1186
+ }).finally(() => {
1187
+ this._inFlight.delete(e);
1188
+ }), this._inFlight.set(e, i)), Kt(await ((e, t) => t ? t.aborted ? Promise.reject(t.reason) : new Promise((s, r) => {
1189
+ const i = () => r(t.reason);
1190
+ t.addEventListener("abort", i, { once: !0 }), e.then(s, r).finally(() => t.removeEventListener("abort", i));
1191
+ }) : e)(i, t?.signal));
1192
+ }
1193
+ return Kt(await this._request(e, t));
1194
+ }
1195
+ adopt(e) {
1196
+ for (const t of e) {
1197
+ const e = t.getFetchedFrom();
1198
+ e && !t.isClosed() && this.keep(e, t);
1199
+ }
1200
+ }
1201
+ keep(e, t) {
1202
+ const s = this._kept.get(e);
1203
+ s !== t && (t.addReference(this), this._kept.set(e, t), s && !s.isClosed() && s.deleteReference(this));
1204
+ }
1205
+ _findHeld(e) {
1206
+ for (const t of this._resources.getItems()) if (t.getFetchedFrom() === e && !t.isClosed()) return this.keep(e, t), t;
1207
+ return null;
1208
+ }
1209
+ async _fromKept(e) {
1210
+ const [t, s] = await Promise.all([e.toBuffer(), e.getType()]);
1211
+ return Kt({
1212
+ status: 200,
1213
+ statusText: "OK",
1214
+ headers: s ? [["content-type", s.mime]] : [],
1215
+ body: t
1216
+ });
1217
+ }
1218
+ async _request(e, t) {
1219
+ const s = await this._fetcher.fetch(e, t), r = $t.has(s.status) ? null : await s.arrayBuffer(), i = [];
1220
+ s.headers.forEach((e, t) => {
1221
+ i.push([t, e]);
1222
+ });
1223
+ const o = {
1224
+ status: s.status,
1225
+ statusText: s.statusText,
1226
+ headers: i,
1227
+ body: r
1228
+ };
1229
+ if (s.ok && r && r.byteLength > 0) {
1230
+ const t = await new de({ source: { buffer: r } }).getType();
1231
+ t?.mime.startsWith("image/") ? (o.headers = i.filter(([e]) => "content-type" !== e.toLowerCase()), o.headers.push(["content-type", t.mime])) : this._cached.set(e, o);
1232
+ }
1233
+ return o;
1234
+ }
1235
+ }, Xt = class {
1236
+ constructor(e, t, s, r) {
1237
+ this._mergedReading = [], this._colsReading = [], this._rowsReading = [], this._styles = s, this._topLeft = t ?? d.EmptyCell, this._sheet = new ge({
1238
+ runtime: e,
1239
+ styles: this._styles,
1240
+ calcOnLoad: "none",
1241
+ container: {
1242
+ getName: () => r,
1243
+ getIndex: () => 1
1244
+ }
1245
+ }), this._builder = this._sheet.getEntireRange().createSparseBuilder();
1246
+ }
1247
+ applyCSSStyle(e, t) {
1248
+ let s = !1;
1249
+ e.style || (e.style = {}, s = !0);
1250
+ let r = e.style, i = { ...t };
1251
+ if (t.msoIgnore) {
1252
+ const e = t.msoIgnore.split(",");
1253
+ let s = Object.keys(i);
1254
+ for (let t = 0; t < s.length; t++) {
1255
+ const r = s[t];
1256
+ e.includes(r) && delete i[r];
1257
+ }
1258
+ }
1259
+ const o = A(i.fontFamily);
1260
+ r.font = {}, o && (r.font.family = o.family, r.font.fallbacks = o.fallbacks, r.font.size = o.size), r.font.size = i.fontSize, r.font.weight = i.fontWeight, r.font.style = i.fontStyle, r.font.color = i.color;
1261
+ const n = T(i.textDecoration);
1262
+ r.font.underline = n.underline, r.font.strike = n.strike ? x.StrikeStyle.Single : x.StrikeStyle.None, i.textUnderlineStyle && (r.font.underline = B(i.textUnderlineStyle)), r.alignment = {}, i?.textAlign && (r.alignment.horizontal = P(i.textAlign)), i?.textAlign && !r.alignment.horizontal && "general" !== i?.textAlign && ("center-across" === i.textAlign ? r.alignment.horizontal = F.HorizontalAlignment.CenterContinuous : "fill" === i.textAlign ? r.alignment.horizontal = F.HorizontalAlignment.Fill : "121" === i.textAlign || "010" === i.textAlign ? (r.alignment.horizontal = F.HorizontalAlignment.Distributed, r.alignment.justifyLastLine = "121" === i.textAlign) : console.warn("unknown text-align", i.textAlign)), i.verticalAlign && ("super" === i.verticalAlign.toLowerCase() ? r.font.baseline = R.Baseline.Superscript : "sub" === i.verticalAlign.toLowerCase() ? r.font.baseline = R.Baseline.Subscript : r.alignment.vertical = O(i.verticalAlign), r.alignment.vertical || ("121" === i.verticalAlign ? r.alignment.vertical = F.VerticalAlignment.Distributed : console.warn("unknown vertical-align", i.verticalAlign))), i.msoCharIndentCount && (r.alignment.indent = i.msoCharIndentCount), i.whiteSpace && (r.alignment.overflow = "no-wrap" === i.whiteSpace || "nowrap" === i.whiteSpace ? F.Overflow.Visible : F.Overflow.Wrap), "shrinktofit" === i.msoTextControl && (r.alignment.overflow = F.Overflow.Shrink);
1263
+ let a = null;
1264
+ if (i.background ? a = i.background : i.backgroundColor && (a = i.backgroundColor), a && (r.fill = { color: a }), i.msoPattern) {
1265
+ let e = V(i.msoPattern);
1266
+ e && (e.patternType === C.BuiltInSheetPattern.Solid ? r.fill = { color: e.foreground } : e.patternType !== C.BuiltInSheetPattern.None && (a && (e.background = a), r.fill = e));
1267
+ }
1268
+ "vertical" === i.layoutFlow || "vertical-ideographic" === i.layoutFlow ? r.alignment.stacked = !0 : void 0 !== i.msoRotate && (r.alignment.rotation = N(i.msoRotate));
1269
+ const l = (e, t) => {
1270
+ e && (r.borders || (r.borders = {}), r.borders[e] = t);
1271
+ };
1272
+ i.border && "none" !== i.border && (l("top", i.border), l("left", i.border), l("right", i.border), l("bottom", i.border)), i.borderTop && l("top", i.borderTop), i.borderLeft && l("left", i.borderLeft), i.borderRight && l("right", i.borderRight), i.borderBottom && l("bottom", i.borderBottom), i.msoDiagonalUp && l("diagonalUp", i.msoDiagonalUp), i.msoDiagonalDown && l("diagonalDown", i.msoDiagonalDown);
1273
+ let h = r.numberFormat;
1274
+ i.msoNumberFormat && (h = b(i.msoNumberFormat), h.includes("\\") ? h = null : "Fixed" === h ? h = v.Styles.lookupStyle(r.numberFormat).formatType === v.Type.Number ? null : v.Type.Number : "Percent" === h && (h = v.Styles.lookupStyle(r.numberFormat).formatType === v.Type.Percentage ? null : v.Type.Percentage)), h && (r.numberFormat = h), e.style = this._styles.normalize(r), s && 0 === Object.keys(e.style).length && delete e.style;
1275
+ }
1276
+ onCell(e, t, s, r, i) {
1277
+ const o = r(i);
1278
+ let n = { value: void 0 !== t ? t : s ?? "" };
1279
+ if ("string" == typeof n.value && 0 === n.value.length && (n.value = void 0), o && this.applyCSSStyle(n, o), "string" == typeof n.value && /^#+$/.test(n.value)) {
1280
+ const e = n.style?.numberFormat;
1281
+ e && (k(e) || L(e)) && (n.value = j.BuiltIn.Num);
1282
+ }
1283
+ if ("TD" === i?.tagName.toUpperCase()) {
1284
+ let e = n.style, t = e?.font ?? {};
1285
+ (i.querySelectorAll("s").length > 0 || i.querySelectorAll("strike").length > 0) && (t.strike = x.StrikeStyle.Single), i.querySelectorAll("sub").length > 0 && (t.baseline = R.Baseline.Subscript), i.querySelectorAll("sup").length > 0 && (t.baseline = R.Baseline.Superscript), (i.querySelectorAll("b").length > 0 || i.querySelectorAll("strong").length > 0) && (t.weight = 700), i.querySelectorAll("i").length > 0 && (t.style = x.Style.Italic), i.querySelectorAll("u").length > 0 && (t.underline = x.UnderlineStyle.Single), Object.keys(t).length > 0 && (e || (e = {}, n.style = e), e.font || (e.font = t));
1286
+ const s = i.querySelectorAll("a");
1287
+ if (s.length > 0) {
1288
+ const e = s[0].getAttribute("href");
1289
+ e && (n.hyperlink = e);
1290
+ }
1291
+ }
1292
+ if (!d.isSingleCell(e)) {
1293
+ const t = {
1294
+ rowStart: this._topLeft.rowIndex + e.rowStart,
1295
+ colStart: this._topLeft.colIndex + e.colStart,
1296
+ rowEnd: this._topLeft.rowIndex + e.rowEnd,
1297
+ colEnd: this._topLeft.colIndex + e.colEnd
1298
+ };
1299
+ this._mergedReading.push(t);
1300
+ }
1301
+ if (void 0 === n.value && !n.style && Object.keys(n).length <= 1) return;
1302
+ const a = this._builder, l = this._topLeft;
1303
+ if (a.pushAt(l.rowIndex + e.rowStart, l.colIndex + e.colStart, n), !d.isSingleCell(e) && o.msoIgnore) {
1304
+ if (o.msoIgnore.includes("colspan")) {
1305
+ const t = {};
1306
+ o && this.applyCSSStyle(t, o);
1307
+ const s = e.colEnd - e.colStart, r = l.rowIndex + e.rowStart;
1308
+ for (let i = 1; i <= s; i++) a.pushAt(r, l.colIndex + e.colStart + i, t);
1309
+ e = {
1310
+ ...e,
1311
+ colEnd: e.colStart
1312
+ };
1313
+ }
1314
+ o.msoIgnore.includes("rowspan") && (e = {
1315
+ ...e,
1316
+ rowEnd: e.rowStart
1317
+ });
1318
+ }
1319
+ }
1320
+ onNoTable(e, t, s) {
1321
+ this.onCell({
1322
+ rowStart: this._topLeft.rowIndex,
1323
+ colStart: this._topLeft.colIndex,
1324
+ rowEnd: this._topLeft.rowIndex,
1325
+ colEnd: this._topLeft.colIndex
1326
+ }, e, null, t, s);
1327
+ }
1328
+ onRowStart(e, t, s, r) {
1329
+ const i = s(r);
1330
+ if ("userset" !== i.msoHeightSource) return;
1331
+ if (!r) return;
1332
+ let o = r.getAttribute("height") ?? i.height, n = null;
1333
+ if (o && (n = I(o, this._styles.getNormal().getFont().getSize(), "px")), null === n) for (let e = 0; e < r.cells.length; e++) {
1334
+ const t = r.cells[e], i = t.getAttribute("height") ?? s(t).height;
1335
+ let o = I(i, this._styles.getNormal().getFont().getSize(), "px");
1336
+ null !== o && (n = Math.max(o, n ?? 0));
1337
+ }
1338
+ null !== n && this._rowsReading.push({
1339
+ address: {
1340
+ min: this._topLeft.rowIndex + e,
1341
+ max: this._topLeft.rowIndex + e + t - 1
1342
+ },
1343
+ update: { size: n * x.getDeviceScale() }
1344
+ });
1345
+ }
1346
+ onColumn(e, t, s, r) {
1347
+ const i = s(r);
1348
+ if ("userset" !== i.msoWidthSource) return;
1349
+ if (!r) return;
1350
+ let o = r.getAttribute("width") ?? i.width, n = null;
1351
+ o && (n = I(o, this._styles.getNormal().getFont().getSize(), "px")), null !== n && this._colsReading.push({
1352
+ address: {
1353
+ min: this._topLeft.colIndex + e,
1354
+ max: this._topLeft.colIndex + e + t - 1
1355
+ },
1356
+ update: { size: n * x.getDeviceScale() }
1357
+ });
1358
+ }
1359
+ onDone() {
1360
+ this._colsReading.length > 0 && this._sheet.getColumnHeaders().updateHeaderPairs(this._colsReading), this._rowsReading.length > 0 && this._sheet.getRowHeaders().updateHeaderPairs(this._rowsReading), this._sheet.doBatch(() => {
1361
+ this._builder.apply();
1362
+ }), this._mergedReading.length > 0 && this._sheet.getRanges(this._mergedReading).merge();
1363
+ }
1364
+ sheet() {
1365
+ return this._sheet;
1366
+ }
1367
+ }, Zt = class {
1368
+ constructor(e) {
1369
+ if (!e) throw new u("snapshot is required.");
1370
+ this._snapshot = e;
1371
+ }
1372
+ getItemType() {
1373
+ return "range";
1374
+ }
1375
+ getItem() {
1376
+ return this._snapshot;
1377
+ }
1378
+ editMode() {
1379
+ return this._snapshot?.getMarkOptions().editMode ?? null;
1380
+ }
1381
+ isCut() {
1382
+ return this._snapshot?.getMarkOptions().isCut ?? !1;
1383
+ }
1384
+ getName() {
1385
+ return this._snapshot.getName();
1386
+ }
1387
+ toText() {
1388
+ return this._snapshot.toText();
1389
+ }
1390
+ toHtml() {
1391
+ return this._snapshot.toHtml();
1392
+ }
1393
+ toImage() {
1394
+ return this._snapshot.toImage();
1395
+ }
1396
+ get isClipboardItem() {
1397
+ return !0;
1398
+ }
1399
+ }, Qt = class {
1400
+ constructor(e, t, s, r, i) {
1401
+ if (this._parsed = void 0, this._runtime = e, !t) throw new u("nativeItems are required.");
1402
+ this._topLeft = s ?? d.EmptyCell, this._native = t, this._markOptions = Object.freeze(r ?? {}), this._styles = i;
1403
+ }
1404
+ getItemType() {
1405
+ return "range";
1406
+ }
1407
+ isCut() {
1408
+ return !1;
1409
+ }
1410
+ toText() {
1411
+ return this._native?.text;
1412
+ }
1413
+ toHtml() {
1414
+ return this._native?.html?.documentElement.outerHTML || null;
1415
+ }
1416
+ toImage() {
1417
+ return this._native?.image;
1418
+ }
1419
+ getItem() {
1420
+ const e = this._parsed;
1421
+ if (void 0 === e) throw new Error("Must call 'parse()' before getItem().");
1422
+ if (null === e) return null;
1423
+ if (this._snapshot) return this._snapshot;
1424
+ const t = this;
1425
+ return this._snapshot = {
1426
+ prepare: (s, r) => e.prepare?.(s, {
1427
+ ...t._markOptions,
1428
+ ...r
1429
+ }),
1430
+ copyTo: (s, r) => e.copyTo(s, {
1431
+ ...t._markOptions,
1432
+ ...r
1433
+ }),
1434
+ getMarkOptions: () => t._markOptions,
1435
+ getName: () => e?.getName() ?? "Clipboard Data",
1436
+ getCoords: () => e?.getCoords?.() ?? null,
1437
+ toText: () => t.toText(),
1438
+ toHtml: () => t.toHtml(),
1439
+ toImage: () => t.toImage(),
1440
+ getSource: () => e?.getSource?.() ?? null,
1441
+ isISnapshot: !0
1442
+ }, this._snapshot;
1443
+ }
1444
+ async parse() {
1445
+ let e, t = this._native?.text, s = this._native.html;
1446
+ if (null === s && t && t.includes("<table")) try {
1447
+ const e = new DOMParser().parseFromString(t, n.Html), r = e.querySelector("parsererror");
1448
+ if (r) throw new m("Unable to parse: " + r);
1449
+ s = e, t = null;
1450
+ } catch (e) {
1451
+ console.warn("Discovered text as html table but could could not parse.");
1452
+ }
1453
+ try {
1454
+ const r = new Xt(this._runtime, this._topLeft, this._styles, s ? "HTML" : "Text"), i = await Promise.resolve(t ? ae(t) : [[]]);
1455
+ let o;
1456
+ if (he(s, i, r) ? (e = r.sheet(), o = e.getUsedRange()) : s = null, o) {
1457
+ const t = o.getSnapshot();
1458
+ return this._parsed = {
1459
+ prepare: (e, s) => t.prepare?.(e, s),
1460
+ copyTo: (e, s) => t.copyTo(e, s),
1461
+ getCoords: () => o.getCoords(),
1462
+ getSource: () => e,
1463
+ getName: () => e.getName()
1464
+ }, !0;
1465
+ }
1466
+ } catch (e) {
1467
+ throw e;
1468
+ }
1469
+ if (!t && !s && this._native.image) {
1470
+ const e = await this._native.image.arrayBuffer(), t = h.getPngStatedSize(e);
1471
+ let s = null;
1472
+ return this._parsed = {
1473
+ async prepare(r) {
1474
+ const i = r.getWorksheet();
1475
+ s = {
1476
+ sheet: i,
1477
+ options: await i.getMovables()._preparePicture({ source: { buffer: e } }, {
1478
+ type: "picture",
1479
+ description: _("op.copyImageFromClipboard"),
1480
+ autoSelect: !0,
1481
+ ...t && { bounds: t }
1482
+ })
1483
+ };
1484
+ },
1485
+ copyTo(e, t) {
1486
+ const r = e.getWorksheet();
1487
+ if (s?.sheet !== r) throw new Error("The image was not prepared for this sheet.");
1488
+ return r.getMovables()._insertNow(s.options), null;
1489
+ },
1490
+ getName: () => "Image"
1491
+ }, !0;
1492
+ }
1493
+ return this._parsed = null, !1;
1494
+ }
1495
+ get isClipboardItem() {
1496
+ return !0;
1497
+ }
1498
+ }, Yt = class {
1499
+ constructor(e) {
1500
+ this._closed = !1, this._kind = e.kind, this._id = e.id, this._part = e.part, this._styles = e.styles, this._tabColor = e.tabColor ? this._styles.parseColor(e.tabColor) : null, this._transactions = e.transactions, this._workbook = e.workbook ?? null, this._container = e.container, this._emitter = new y(this, this._transactions);
1501
+ }
1502
+ getKind() {
1503
+ return this._kind;
1504
+ }
1505
+ getId() {
1506
+ return this._id;
1507
+ }
1508
+ getName() {
1509
+ return this._container.getName();
1510
+ }
1511
+ setName(e, t) {
1512
+ return this._assertOpen(), this._container.setName(e, t), this;
1513
+ }
1514
+ getVisibility() {
1515
+ return this._closed ? Ge.Visibility.VeryHidden : this._container.getVisibility();
1516
+ }
1517
+ setVisibility(e = !0, t) {
1518
+ let s;
1519
+ return this._assertOpen(), s = !0 === e ? Ge.Visibility.Visible : !1 === e ? Ge.Visibility.Hidden : e, this._container.setVisibility(s, t), this;
1520
+ }
1521
+ getIndex() {
1522
+ return this._container.getIndex();
1523
+ }
1524
+ setIndex(e, t) {
1525
+ return this._assertOpen(), this._container.setIndex(e, t), this;
1526
+ }
1527
+ getTabColor() {
1528
+ return this._tabColor;
1529
+ }
1530
+ setTabColor(e) {
1531
+ return this._assertOpen(), this._tabColor = "string" == typeof e ? this._styles.parseColor(e) : e ?? null, this._notify("onTabColorChange"), this;
1532
+ }
1533
+ getWorkbook() {
1534
+ return this._workbook;
1535
+ }
1536
+ async select(e) {
1537
+ return await this._container.requestSelect(e), this;
1538
+ }
1539
+ delete() {
1540
+ if (this._closed) return;
1541
+ const e = this._transactions.beginCommit({ description: g("op.deleteSheet", { name: this.getName() }) });
1542
+ try {
1543
+ try {
1544
+ this._notify("onBeforeDelete");
1545
+ } catch (e) {
1546
+ throw e instanceof Error ? e : new m(e?.message ?? g("error.sheet.modelDelete"));
1547
+ }
1548
+ this._notify("onDelete"), e.commit();
1549
+ } catch (t) {
1550
+ throw e.rollback(), t;
1551
+ }
1552
+ }
1553
+ isDeleted() {
1554
+ return !this._container.isAttached();
1555
+ }
1556
+ addListeners(e, t) {
1557
+ return this._emitter.addListeners(e, t);
1558
+ }
1559
+ close() {
1560
+ this._closed || (this._notify("onClose"), this._emitter.close(), this._closed = !0);
1561
+ }
1562
+ isClosed() {
1563
+ return this._closed;
1564
+ }
1565
+ _getPart() {
1566
+ return this._part;
1567
+ }
1568
+ _notify(e) {
1569
+ this._emitter.notify(e);
1570
+ }
1571
+ _assertOpen() {
1572
+ if (this._closed) throw new Error(g("error.sheet.modelClosed"));
1573
+ }
1574
+ get [Symbol.toStringTag]() {
1575
+ return "[OpaqueSheet]";
1576
+ }
1577
+ toString() {
1578
+ return `[${this.getName() ?? "(untitled)"}]`;
1579
+ }
1580
+ get isISheet() {
1581
+ return !0;
1582
+ }
1583
+ get isIOpaqueSheet() {
1584
+ return !0;
1585
+ }
1586
+ };
1587
+ (Tt || (Tt = {})).Visibility = {
1588
+ Visible: "visible",
1589
+ Hidden: "hidden",
1590
+ VeryHidden: "veryHidden"
1591
+ };
1592
+ var es = {
1593
+ showFormulaBar: !0,
1594
+ showTabs: !0,
1595
+ tabRatio: 600,
1596
+ showHorizontalScrollbar: !0,
1597
+ showVerticalScrollbar: !0,
1598
+ showStatusBar: !0,
1599
+ activeSheetId: 0,
1600
+ firstTab: 0,
1601
+ windowBounds: null,
1602
+ minimized: !1,
1603
+ visibility: Tt.Visibility.Visible,
1604
+ autoFilterDateGrouping: !0
1605
+ }, ts = class {
1606
+ constructor(e) {
1607
+ this._id = c.uuidV4(), this._emitter = new y(this), this._state = { ...es }, e?.json && this._fromJSON(e?.json);
1608
+ }
1609
+ getId() {
1610
+ return this._id;
1611
+ }
1612
+ isShowFormulaBar() {
1613
+ return this._state.showFormulaBar;
1614
+ }
1615
+ setShowFormulaBar(e) {
1616
+ return this._state.showFormulaBar = e, this._emitter.notify("onViewChange"), this;
1617
+ }
1618
+ isShowTabs() {
1619
+ return this._state.showTabs;
1620
+ }
1621
+ setShowTabs(e) {
1622
+ return this._state.showTabs = e, this._emitter.notify("onViewChange"), this;
1623
+ }
1624
+ getTabRatio() {
1625
+ return this._state.tabRatio;
1626
+ }
1627
+ setTabRatio(e) {
1628
+ return this._state.tabRatio = e, this._emitter.notify("onViewChange"), this;
1629
+ }
1630
+ isShowHorizontalScrollbar() {
1631
+ return this._state.showHorizontalScrollbar;
1632
+ }
1633
+ setShowHorizontalScrollbar(e) {
1634
+ return this._state.showHorizontalScrollbar = e, this._emitter.notify("onViewChange"), this;
1635
+ }
1636
+ isShowVerticalScrollbar() {
1637
+ return this._state.showVerticalScrollbar;
1638
+ }
1639
+ setShowVerticalScrollbar(e) {
1640
+ return this._state.showVerticalScrollbar = e, this._emitter.notify("onViewChange"), this;
1641
+ }
1642
+ isShowStatusBar() {
1643
+ return this._state.showStatusBar;
1644
+ }
1645
+ setShowStatusBar(e) {
1646
+ return this._state.showStatusBar = e, this._emitter.notify("onViewChange"), this;
1647
+ }
1648
+ getActiveSheetId() {
1649
+ return this._state.activeSheetId;
1650
+ }
1651
+ setActiveSheetId(e) {
1652
+ const t = this._state, s = t.activeSheetId;
1653
+ return t.activeSheetId = e, s !== e && this._emitter.notify("onViewChange"), this;
1654
+ }
1655
+ getFirstTab() {
1656
+ return this._state.firstTab;
1657
+ }
1658
+ setFirstTab(e) {
1659
+ return this._set("firstTab", Math.max(0, Math.trunc(e)));
1660
+ }
1661
+ getWindowBounds() {
1662
+ return this._state.windowBounds;
1663
+ }
1664
+ setWindowBounds(e) {
1665
+ return this._set("windowBounds", e ? Object.freeze({ ...e }) : null);
1666
+ }
1667
+ isMinimized() {
1668
+ return this._state.minimized;
1669
+ }
1670
+ setMinimized(e) {
1671
+ return this._set("minimized", e);
1672
+ }
1673
+ getVisibility() {
1674
+ return this._state.visibility;
1675
+ }
1676
+ setVisibility(e) {
1677
+ return this._set("visibility", e);
1678
+ }
1679
+ isAutoFilterDateGrouping() {
1680
+ return this._state.autoFilterDateGrouping;
1681
+ }
1682
+ setAutoFilterDateGrouping(e) {
1683
+ return this._set("autoFilterDateGrouping", e);
1684
+ }
1685
+ _set(e, t) {
1686
+ return this._state[e] === t || (this._state[e] = t, this._emitter.notify("onViewChange")), this;
1687
+ }
1688
+ addListeners(e, t) {
1689
+ return this._emitter.addListeners(e, t);
1690
+ }
1691
+ toJSON() {
1692
+ let e = {};
1693
+ const t = Object.keys(this._state), s = t.length;
1694
+ for (let r = 0; r < s; r++) {
1695
+ const s = t[r], i = this._state[s];
1696
+ null != i && i !== es[s] && (e[s] = i);
1697
+ }
1698
+ return 0 === Object.keys(e).length && (e = null), e;
1699
+ }
1700
+ _fromJSON(e, t = !0) {
1701
+ const s = e || {};
1702
+ this.update(s, t);
1703
+ }
1704
+ update(e, t = !0) {
1705
+ this._state = {
1706
+ ...es,
1707
+ ...this._state,
1708
+ ...e
1709
+ }, t && this._emitter.notify("onViewChange");
1710
+ }
1711
+ get [Symbol.toStringTag]() {
1712
+ return "[WorkbookView]";
1713
+ }
1714
+ toString() {
1715
+ const e = this.toJSON();
1716
+ return e ? JSON.stringify(e) : "DefaultWorkbookView";
1717
+ }
1718
+ get isIWorkbookView() {
1719
+ return !0;
1720
+ }
1721
+ }, ss = Object.freeze({
1722
+ structure: !1,
1723
+ windows: !1,
1724
+ revision: !0,
1725
+ password: null,
1726
+ revisionsPassword: null
1727
+ }), rs = class extends Qe {
1728
+ isWindowsAllowed() {
1729
+ return this._isPropertyAllowed("windows");
1730
+ }
1731
+ isRevisionAllowed() {
1732
+ return this.isLocked() && void 0 === this._properties?.revision ? !this._isReadOnly : this._isPropertyAllowed("revision");
1733
+ }
1734
+ isStructureAllowed() {
1735
+ return this._isPropertyAllowed("structure");
1736
+ }
1737
+ _getAllowedKey() {
1738
+ return "workbook";
1739
+ }
1740
+ _fromJSON(e) {
1741
+ this._properties = e;
1742
+ }
1743
+ _toJSON(e) {
1744
+ const t = this._properties;
1745
+ if (t) {
1746
+ const s = Object.keys(t), r = s.length;
1747
+ for (let i = 0; i < r; i++) {
1748
+ const r = s[i], o = t[r];
1749
+ null != o && o !== ss[r] && (e[r] = o);
1750
+ }
1751
+ }
1752
+ return super._toJSON(e);
1753
+ }
1754
+ get [Symbol.toStringTag]() {
1755
+ return "[WorkbookProtection]";
1756
+ }
1757
+ get isIWorkbookProtection() {
1758
+ return !0;
1759
+ }
1760
+ };
1761
+ (Bt || (Bt = {})).Type = {
1762
+ Number: "number",
1763
+ Boolean: "boolean",
1764
+ Date: "date",
1765
+ String: "string",
1766
+ Float: "float"
1767
+ };
1768
+ var is = (e) => {
1769
+ if ("string" == typeof e) return {
1770
+ type: Bt.Type.String,
1771
+ value: e
1772
+ };
1773
+ if ("boolean" == typeof e) return {
1774
+ type: Bt.Type.Boolean,
1775
+ value: e
1776
+ };
1777
+ if ("number" == typeof e) {
1778
+ if (!Number.isFinite(e)) throw new Error("A custom property value must be a finite number.");
1779
+ return {
1780
+ type: Number.isInteger(e) && e >= -2147483648 && e <= 2147483647 ? Bt.Type.Number : Bt.Type.Float,
1781
+ value: e
1782
+ };
1783
+ }
1784
+ if (e instanceof Date) {
1785
+ if (isNaN(e.getTime())) throw new Error("A custom property value must be a valid date.");
1786
+ return {
1787
+ type: Bt.Type.Date,
1788
+ value: e.toISOString()
1789
+ };
1790
+ }
1791
+ throw new Error("A custom property value must be a string, number, boolean or Date.");
1792
+ }, os = class {
1793
+ constructor(e, t) {
1794
+ this._json = e, this._owner = t;
1795
+ }
1796
+ getKey() {
1797
+ return this._json.key;
1798
+ }
1799
+ getType() {
1800
+ return this._json.type;
1801
+ }
1802
+ getLinkTarget() {
1803
+ return this._json.linkTarget ?? null;
1804
+ }
1805
+ getValue() {
1806
+ const { type: e, value: t } = this._json;
1807
+ return e === Bt.Type.Date ? new Date(t) : t;
1808
+ }
1809
+ setValue(e) {
1810
+ this._owner._assertCustomEditable(this), this._json = {
1811
+ ...this._json,
1812
+ ...is(e)
1813
+ };
1814
+ }
1815
+ delete() {
1816
+ this._owner._removeCustom(this);
1817
+ }
1818
+ toJSON() {
1819
+ return { ...this._json };
1820
+ }
1821
+ }, ns = class {
1822
+ constructor(e) {
1823
+ this._json = {}, this._custom = [], this._assertOpen = e;
1824
+ }
1825
+ _text(e) {
1826
+ return this._json[e] ?? null;
1827
+ }
1828
+ _setText(e, t) {
1829
+ return this._assertOpen(), null == t || "" === t ? delete this._json[e] : this._json[e] = t, this;
1830
+ }
1831
+ getAuthor() {
1832
+ return this._text("author");
1833
+ }
1834
+ setAuthor(e) {
1835
+ return this._setText("author", e);
1836
+ }
1837
+ getCategory() {
1838
+ return this._text("category");
1839
+ }
1840
+ setCategory(e) {
1841
+ return this._setText("category", e);
1842
+ }
1843
+ getComments() {
1844
+ return this._text("comments");
1845
+ }
1846
+ setComments(e) {
1847
+ return this._setText("comments", e);
1848
+ }
1849
+ getCompany() {
1850
+ return this._text("company");
1851
+ }
1852
+ setCompany(e) {
1853
+ return this._setText("company", e);
1854
+ }
1855
+ getContentStatus() {
1856
+ return this._text("contentStatus");
1857
+ }
1858
+ setContentStatus(e) {
1859
+ return this._setText("contentStatus", e);
1860
+ }
1861
+ getCreationDate() {
1862
+ const e = this._json.creationDate;
1863
+ if (!e) return null;
1864
+ const t = new Date(e);
1865
+ return isNaN(t.getTime()) ? null : t;
1866
+ }
1867
+ getKeywords() {
1868
+ return this._text("keywords");
1869
+ }
1870
+ setKeywords(e) {
1871
+ return this._setText("keywords", e);
1872
+ }
1873
+ getLastAuthor() {
1874
+ return this._json.lastAuthor ?? null;
1875
+ }
1876
+ getManager() {
1877
+ return this._text("manager");
1878
+ }
1879
+ setManager(e) {
1880
+ return this._setText("manager", e);
1881
+ }
1882
+ getRevisionNumber() {
1883
+ return this._json.revisionNumber ?? null;
1884
+ }
1885
+ setRevisionNumber(e) {
1886
+ return this._assertOpen(), null != e && Number.isFinite(e) ? this._json.revisionNumber = e : delete this._json.revisionNumber, this;
1887
+ }
1888
+ getSubject() {
1889
+ return this._text("subject");
1890
+ }
1891
+ setSubject(e) {
1892
+ return this._setText("subject", e);
1893
+ }
1894
+ getTitle() {
1895
+ return this._text("title");
1896
+ }
1897
+ setTitle(e) {
1898
+ return this._setText("title", e);
1899
+ }
1900
+ getCustom() {
1901
+ return this._custom.slice();
1902
+ }
1903
+ getCustomProperty(e) {
1904
+ const t = e.toLowerCase();
1905
+ return this._custom.find((e) => e.getKey().toLowerCase() === t);
1906
+ }
1907
+ addCustomProperty(e, t) {
1908
+ if (this._assertOpen(), "string" != typeof e || "" === e) throw new Error("A custom property needs a name.");
1909
+ const s = this.getCustomProperty(e);
1910
+ if (s) return s.setValue(t), s;
1911
+ const r = new os({
1912
+ key: e,
1913
+ ...is(t)
1914
+ }, this);
1915
+ return this._custom.push(r), r;
1916
+ }
1917
+ deleteAllCustomProperties() {
1918
+ this._assertOpen(), this._custom = [];
1919
+ }
1920
+ _assertCustomEditable(e) {
1921
+ if (this._assertOpen(), !this._custom.includes(e)) throw new Error("The custom property has been deleted.");
1922
+ }
1923
+ _removeCustom(e) {
1924
+ this._assertCustomEditable(e), this._custom = this._custom.filter((t) => t !== e);
1925
+ }
1926
+ fromJSON(e) {
1927
+ const { custom: t, ...s } = e ?? {};
1928
+ this._json = s, this._custom = (t ?? []).map((e) => new os({ ...e }, this));
1929
+ }
1930
+ toJSON() {
1931
+ const e = { ...this._json };
1932
+ return this._custom.length > 0 && (e.custom = this._custom.map((e) => e.toJSON())), e;
1933
+ }
1934
+ };
1935
+ function as(e) {
1936
+ return g("error.workbook.invalidSheetKey", { key: e });
1937
+ }
1938
+ function ls(e) {
1939
+ return g("error.workbook.sheetNameNotFound", { sheetName: e });
1940
+ }
1941
+ function hs(e, t) {
1942
+ return g("chart" === t ? "error.workbook.sheetIsChart" : "macro" === t ? "error.workbook.sheetIsMacro" : "error.workbook.sheetIsDialog", { sheetName: e });
1943
+ }
1944
+ function cs(e, t) {
1945
+ return "chart" === t ? g("error.workbook.selectedIsChart", { sheetName: e }) : "macro" === t ? g("error.workbook.selectedIsMacro", { sheetName: e }) : "dialog" === t ? g("error.workbook.selectedIsDialog", { sheetName: e }) : g("error.workbook.noWorksheet");
1946
+ }
1947
+ var us, ds = class extends pe {
1948
+ constructor(e, t, s, r) {
1949
+ super(), this._add = e, this._get = t, this._addListeners = s, this._getSelected = r;
1950
+ }
1951
+ getActive() {
1952
+ return this._getSelected();
1953
+ }
1954
+ getAt(e) {
1955
+ return this.getItems()[e] ?? null;
1956
+ }
1957
+ getByIndex(e) {
1958
+ return this.getItems()[e] ?? null;
1959
+ }
1960
+ getAll() {
1961
+ return this.getItems();
1962
+ }
1963
+ add(e) {
1964
+ return this._add(e);
1965
+ }
1966
+ _getItems(e) {
1967
+ return this._get(e?.name, e?.visibility);
1968
+ }
1969
+ getByName(e) {
1970
+ return this._get(e)?.[0] ?? null;
1971
+ }
1972
+ addListeners(e, t) {
1973
+ return this._addListeners(e, t);
1974
+ }
1975
+ get isIWorksheetCollection() {
1976
+ return !0;
1977
+ }
1978
+ }, gs = /* @__PURE__ */ new RegExp(/[\\/\\*?:[\]]+/), ms = /* @__PURE__ */ new RegExp(/\(((\d+)(?!.*\d))\)$/, "g");
1979
+ function _s(e) {
1980
+ const t = g(_("workbook.defaultSheetName"), { n: e + 1 });
1981
+ return "workbook.defaultSheetName" === t ? `Sheet${e + 1}` : t;
1982
+ }
1983
+ function fs(e, t) {
1984
+ return {
1985
+ ...xe,
1986
+ getWorksheet: () => null,
1987
+ toString: () => Pe(e, t)
1988
+ };
1989
+ }
1990
+ function ps(e, t = !1) {
1991
+ if (!e) throw new Error(g("error.workbook.sheetNameBlank"));
1992
+ if (gs.test(e)) {
1993
+ if (!t) throw new Error(function(e) {
1994
+ return e ? g("error.workbook.sheetNameInvalidCharsNamed", { sheetName: e }) : g("error.workbook.sheetNameInvalidChars");
1995
+ }(e));
1996
+ e = e.replace(gs, "");
1997
+ }
1998
+ if (0 === e.length) throw new Error(g("error.workbook.sheetNameBlank"));
1999
+ const s = e.length;
2000
+ if (s > 31) {
2001
+ if (!t) throw new Error(g("error.workbook.sheetNameTooLong"));
2002
+ e = e.substring(0, 31);
2003
+ }
2004
+ if ("'" === e.charAt(0) || "'" === e.charAt(s - 1)) {
2005
+ if (!t) throw new Error(g("error.workbook.sheetNameQuotes"));
2006
+ e = e.replace(/^'|'$/g, "");
2007
+ }
2008
+ return e;
2009
+ }
2010
+ var ws = "workbook.activeSheet", ys = class e extends Ie {
2011
+ constructor(e, t, s, r) {
2012
+ super(e, t, r), this._workbook = s;
2013
+ }
2014
+ getSource() {
2015
+ return this._workbook;
2016
+ }
2017
+ _createRanges(t, s) {
2018
+ let r = this._options;
2019
+ return s && (r = {
2020
+ ...this._options,
2021
+ getOptions: je(this._options?.getOptions, s)
2022
+ }), new e(t, this._internal, this._workbook, r);
2023
+ }
2024
+ _createRange(e, t) {
2025
+ const s = e ? { ...e } : null, r = this._workbook, i = s ? r._getSheetRef(s.scope, Ge.Visibility.VeryHidden) : null;
2026
+ if (i && !i.sheet.isIWorksheet) throw new m(hs(i.name, i.sheet.getKind()));
2027
+ if (!i) {
2028
+ const e = r._anchorWorksheet();
2029
+ return delete s?.scope, fs(s, s ? {
2030
+ scope: H,
2031
+ ...e.getEntireRange().getCoords()
2032
+ } : null);
2033
+ }
2034
+ let o = this._options;
2035
+ return t && (o = {
2036
+ ...this._options,
2037
+ getOptions: je(this._options.getOptions, t)
2038
+ }), new bs(e, q(i.sheet), this._workbook, o);
2039
+ }
2040
+ async select(e) {
2041
+ const t = [];
2042
+ let s = null;
2043
+ const r = this.getCoords();
2044
+ for (let e = 0; e < r.length; e++) {
2045
+ const i = r[e];
2046
+ i && (s || (s = i.scope), i && i.scope === s && t.push(i));
2047
+ }
2048
+ s || (s = this._workbook.getWorksheet().getName());
2049
+ const i = this._workbook.getWorksheets().getByName(s);
2050
+ if (!i) return;
2051
+ const o = await i.getRanges(t).select(e), n = this._workbook._rangesAddressToCoords(o.getCoords());
2052
+ return this._createRanges(n);
2053
+ }
2054
+ addListener(e, t) {
2055
+ if (!this.getCoords()) return () => {};
2056
+ const s = this._workbook._sheetToWBEvent(e);
2057
+ return super.addListener(s, t);
2058
+ }
2059
+ get [Symbol.toStringTag]() {
2060
+ return "[WorkbookRanges]";
2061
+ }
2062
+ getAddress(e) {
2063
+ const t = this._internal.getSheet(), s = t.getEntireRange().getCoords();
2064
+ return Ne(this.getCoords(), {
2065
+ ...s,
2066
+ scope: t.getName()
2067
+ }, Pe, we, e);
2068
+ }
2069
+ toString() {
2070
+ return this.getAddress();
2071
+ }
2072
+ }, bs = class e extends Ae {
2073
+ constructor(e, t, s, r) {
2074
+ super(e, t, r), this._workbook = s;
2075
+ }
2076
+ _createRanges(e, t) {
2077
+ let s = this._options;
2078
+ return t && (s = {
2079
+ ...this._options,
2080
+ getOptions: je(this._options?.getOptions, t)
2081
+ }), new ys(e, this._internal, this._workbook, s);
2082
+ }
2083
+ _createRange(t, s) {
2084
+ const r = this._internal;
2085
+ if (!t) return Q(r.getSheet(), r.getSheet().getEntireCoords());
2086
+ if (r.validateCoords(t), r.getSheet().isClosed()) return Q(null, r.getSheet().getEntireCoords(), t);
2087
+ let i = this._options;
2088
+ return s && (i = {
2089
+ ...this._options,
2090
+ getOptions: je(this._options?.getOptions, s)
2091
+ }), new e(t, this._internal, this._workbook, i);
2092
+ }
2093
+ addListener(e, t) {
2094
+ if (!this.getCoords()) return () => {};
2095
+ const s = this._workbook._sheetToWBEvent(e);
2096
+ return super.addListener(s, t);
2097
+ }
2098
+ get [Symbol.toStringTag]() {
2099
+ return "[WorkbookRange]";
2100
+ }
2101
+ getAddress(e) {
2102
+ const t = this._internal.getSheet(), s = t?.getEntireRange().getCoords() ?? null;
2103
+ return Pe(this.getCoords(), {
2104
+ ...s,
2105
+ scope: t.getName()
2106
+ });
2107
+ }
2108
+ toString() {
2109
+ return this.getAddress();
2110
+ }
2111
+ }, Ss = (e) => !!e && "object" == typeof e && "function" == typeof e.getOrigin, ks = class {
2112
+ constructor(t) {
2113
+ this._isLoadingSheets = !1, this._lastTransactionUUID = null, this._starting = null, this._closed = !1, this._listenerOriginProvider = null, this._listenerOrigin = null, this._lastOriginName = null, this._initializing = !0, this._pivotCaches = [], this._pivotTableCollection = new K(() => {
2114
+ const e = [];
2115
+ for (const t of this.getWorksheets()) e.push(...t.getPivotTables());
2116
+ return e;
2117
+ }), this._people = new Dt(), this._commentCollection = new G(null, (e, t, s) => {
2118
+ const r = [];
2119
+ for (const i of this.getWorksheets()) r.push(...i.getComments().getItems(e ? {
2120
+ address: e,
2121
+ ignoreHidden: t,
2122
+ fullyContained: s
2123
+ } : {
2124
+ ignoreHidden: t,
2125
+ fullyContained: s
2126
+ }));
2127
+ return r;
2128
+ }, (e, t) => this.addListeners({ onSheetsChange: e.onCollectionChange ? () => {
2129
+ e.onCollectionChange(this._commentCollection);
2130
+ } : void 0 }, t)), this._isDate1904 = !1, this._codeName = null, this._updateLinks = null, this._documentProperties = new ns(() => {
2131
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2132
+ }), this._locale = null, this._localeOverrides = null, this._startModules = /* @__PURE__ */ new WeakSet();
2133
+ const s = "string" == typeof t ? { origin: t } : { ...t }, r = s.origin;
2134
+ this._ownOriginProvider = !Ss(r), this._originProvider = Ss(r) ? r : new ct("string" == typeof r ? new nt(null, { name: r }) : r ?? new nt(null)), delete s.origin, this._bindOrigin(this._originProvider.getOrigin()), this._listenerOriginProvider = this._originProvider.addListeners({ onOriginChange: () => this._onOriginChange() });
2135
+ const i = s.json;
2136
+ delete s.json, this._transactions = s.transactions ?? new p(), this._id = this._transactions.create(), this._ownTransactions = !s.transactions, this._emitter = new y(this, this._transactions), this._runtime = s.runtime ?? new te("Workbook Runtime", {
2137
+ isDate1904: () => this._isDate1904,
2138
+ getNow: () => this._transactions.getCurrentCommit().getTimestamp(),
2139
+ getLocale: () => this._locale ?? Ee() ?? ue(),
2140
+ getLocaleOverrides: () => this._localeOverrides
2141
+ }), this._listenerLanguage = o.addChangeListener(() => {
2142
+ this._closed || this._notifyAllChange();
2143
+ });
2144
+ const n = this, a = this._beginCommit({ description: _(i ? "op.openWorkbook" : "op.newWorkbook") });
2145
+ try {
2146
+ this._strings = s.strings ?? new Y(), this._ownStrings = !s.strings, this._richValues = s.richData ?? new Te(), this._resources = s.resources ?? new Se(), this._ownResources = !s.resources, this._fetch = new Gt(this._resources, s.fetcher ?? new qt()), this._createSheetName = s.createSheetNameCallback ?? _s;
2147
+ let t = s.createWorksheetCallback;
2148
+ t || (t = (e) => new ge(e)), this._sheetOnNameChange = /* @__PURE__ */ new Map(), this._sheetOnVisibilityChange = /* @__PURE__ */ new Map(), this._sheetOnIndexChange = /* @__PURE__ */ new Map(), this._createSheet = (e, s, r, i, o, a, l) => {
2149
+ let h = null;
2150
+ const c = {
2151
+ runtime: n._runtime,
2152
+ readonly: n._options.readonly ?? !1,
2153
+ disableLoadAutoFit: n._options.disableLoadAutoFit ?? !1,
2154
+ opener: n._options.opener,
2155
+ transactions: n._transactions,
2156
+ styles: n._styles,
2157
+ strings: n._strings,
2158
+ richData: n._richValues,
2159
+ resources: n._resources,
2160
+ names: n._names,
2161
+ workbook: n,
2162
+ calculation: n._calculation,
2163
+ resolveRange: (e) => n._options.resolveRange?.(e) ?? n.getRange(e),
2164
+ container: {
2165
+ beforeFromJSON: (t) => {
2166
+ h = t, n._addSheetRef({
2167
+ name: s,
2168
+ id: e,
2169
+ visibility: r ?? Ge.Visibility.Visible,
2170
+ sheetId: o,
2171
+ sheet: t
2172
+ }, i);
2173
+ },
2174
+ getName: () => {
2175
+ const e = n._getSheetRef(h);
2176
+ return e ? e.name : s;
2177
+ },
2178
+ setName: (e, t) => {
2179
+ n._getSheetRef(h) && n._setSheetName(h, e, t);
2180
+ },
2181
+ setNameChangeCallback: (t) => {
2182
+ n._sheetOnNameChange.set(e, t);
2183
+ },
2184
+ getVisibility: () => {
2185
+ const e = n._getSheetRef(h);
2186
+ return e ? e.visibility : Ge.Visibility.Visible;
2187
+ },
2188
+ setVisibility: (e, t) => {
2189
+ n._setSheetVisibility(h, e, t);
2190
+ },
2191
+ setVisibilityCallback: (t) => {
2192
+ n._sheetOnVisibilityChange.set(e, t);
2193
+ },
2194
+ duplicate: () => n._duplicateSheet(h),
2195
+ getIndex: () => {
2196
+ const e = n._getSheetRef(h);
2197
+ return e ? n._getOffsetForId(e.id, n._getSheetRefs(Ge.Visibility.VeryHidden)) : i;
2198
+ },
2199
+ setIndex: (e, t) => {
2200
+ const s = n._getSheetRef(h, Ge.Visibility.VeryHidden);
2201
+ return !!s && (n._moveSheet(s, e, t), !0);
2202
+ },
2203
+ setIndexCallback: (t) => {
2204
+ n._sheetOnIndexChange.set(e, t);
2205
+ },
2206
+ requestSelect: () => n._requestSelect(h)
2207
+ }
2208
+ };
2209
+ return a && (c.json = a), void 0 !== l && (c.uid = () => l), h = t(c, s, i, r), h;
2210
+ }, this._namedTableSource = new $e({
2211
+ getSheets: () => n._sheets ? n.getWorksheets().getItems() : c.EmptyArray,
2212
+ addSheetsListener: (e, t) => n.addListeners({ onSheetsChange: e }, t)
2213
+ }), this._names = s.names ?? new Ze({
2214
+ addressToRanges: (e) => n.getRanges(e),
2215
+ getCurrentScope: () => n.getSelectedWorksheet()?.getName() ?? null,
2216
+ isReadOnly: () => (n._options.readonly ?? !1) || n._isStructureProtected(),
2217
+ transactions: n._transactions,
2218
+ getSources: () => n._calculation ? [n._calculation.getNamedFormulas(), n._namedTableSource] : c.EmptyArray
2219
+ }), this._ownNames = !s.names, this._calculation = s.calculation ?? new qe({
2220
+ runtime: n._runtime,
2221
+ functions: s.functions,
2222
+ json: i?.calc,
2223
+ isNamesReadOnly: () => n._isStructureProtected(),
2224
+ getActiveCell: () => {
2225
+ const e = n.getSelectedWorksheet(), t = e?.getSelectedRange()?.getCoords();
2226
+ return e && t ? {
2227
+ rowIndex: t.rowStart,
2228
+ colIndex: t.colStart,
2229
+ scope: e.getId()
2230
+ } : null;
2231
+ },
2232
+ getRange: n.getRange.bind(n),
2233
+ getRanges: n.getRanges.bind(n),
2234
+ createGraphRanges: (e, t) => n._createGraphRanges(e, t),
2235
+ getSheetIndex: (e) => {
2236
+ if (void 0 === e) {
2237
+ const e = n.getSelectedSheet();
2238
+ return e ? this._getSheetRefs(Ge.Visibility.VeryHidden).findIndex((t) => t.sheet === e) : -1;
2239
+ }
2240
+ const t = this._getSheetRefs(Ge.Visibility.VeryHidden);
2241
+ e = e.toLowerCase();
2242
+ const s = t.length;
2243
+ for (let r = 0; r < s; r++) if (t[r].name.toLowerCase() === e) return r;
2244
+ try {
2245
+ Cs.address = e;
2246
+ const t = this._names.getItems(Cs);
2247
+ if (!t || 0 === t.length) return -1;
2248
+ let s = (t[0].getRanges?.()?.getCoords()?.[0])?.scope;
2249
+ if (!s) return -1;
2250
+ const r = this._getSheetRefs(Ge.Visibility.VeryHidden);
2251
+ s = s.toLowerCase();
2252
+ const i = r.length;
2253
+ for (let e = 0; e < i; e++) if (r[e].name.toLowerCase() === s) return e;
2254
+ } catch (e) {
2255
+ return -1;
2256
+ }
2257
+ return -1;
2258
+ },
2259
+ getSheetCount: () => n._getSheetRefs(Ge.Visibility.VeryHidden).length,
2260
+ externalBooks: i?.externalBooks,
2261
+ externalBookResolver: s.externalBookResolver,
2262
+ namedCollection: n._names,
2263
+ strings: n._strings,
2264
+ get resources() {
2265
+ return n._resources;
2266
+ },
2267
+ fetch: (e, t) => n._fetch.fetch(e, t),
2268
+ parseText: (t, s) => (async (t, s, r) => {
2269
+ const i = await import("./Bg95xYj5siqhHVEz.js").then((t) => e(t.default, 1)), o = (i.default ?? i).parse(s, {
2270
+ delimiter: r?.delimiter ?? ",",
2271
+ skipEmptyLines: !1
2272
+ }).data;
2273
+ let n = o.length;
2274
+ const a = o[n - 1];
2275
+ a && 1 === a.length && "" === a[0] && n--;
2276
+ let l = 0;
2277
+ for (let e = 0; e < n; e++) o[e].length > l && (l = o[e].length);
2278
+ const h = new Array(n);
2279
+ for (let e = 0; e < n; e++) {
2280
+ const s = o[e], r = new Array(l);
2281
+ for (let e = 0; e < l; e++) {
2282
+ const i = s[e];
2283
+ r[e] = void 0 === i || "" === i ? null : Xe(t, i).value;
2284
+ }
2285
+ h[e] = r;
2286
+ }
2287
+ return h;
2288
+ })(n._runtime, t, s),
2289
+ startFunctions: () => n._startFunctions(),
2290
+ transactions: n._transactions,
2291
+ names: i?.names
2292
+ }), this._ownCalculation = !s.calculation, this._scripts = this._createScripts(i?.modules), this._ownNames = !s.names, this._options = Object.freeze({ ...s });
2293
+ const r = i?.sheets?.length ? i.sheets.map((e) => e.name) : [this._createSheetName(0)], o = r.map((e) => e + "-" + c.uuidV4()), l = (e) => {
2294
+ const t = i?.sheets?.[e]?.kind;
2295
+ return !!t && t !== Ge.Kind.Worksheet;
2296
+ };
2297
+ this._calculation._setSheets(r.map((e, t) => l(t) ? [
2298
+ o[t],
2299
+ e,
2300
+ !0
2301
+ ] : [o[t], e]));
2302
+ const h = s.calcOnLoad ?? "auto";
2303
+ let u = !1;
2304
+ const d = (async () => {
2305
+ try {
2306
+ if (this._ownCalculation && "none" !== h && ("full" === h || "auto" === h && !0 === i?.calc?.fullCalcOnLoad ? await this._calculation._calculateForLoad() : await this._calculation.start(), this._closed)) return;
2307
+ await this._scripts.start();
2308
+ } finally {
2309
+ u = !0, this._starting = null;
2310
+ }
2311
+ })();
2312
+ u || (this._starting = d), this._starting?.catch(() => {}), i ? this._fromJSON(i, o) : (this._initState(), this._addSheet(!1, r[0], null, o[0])), this._sheets = new ds((e) => n._addSheetOptions(e), (e, t) => {
2313
+ if (e) {
2314
+ const s = this._getSheetRef(e, t);
2315
+ return s && vs(s) ? [s.sheet] : c.EmptyArray;
2316
+ }
2317
+ return this._getWorksheets(t);
2318
+ }, (e, t) => {
2319
+ const s = e.onCollectionChange, r = e.onInvalidated;
2320
+ return n._emitter.addListeners({
2321
+ onSheetsChange: s ? () => {
2322
+ s(n._sheets);
2323
+ } : void 0,
2324
+ onInvalidated: r ? () => {
2325
+ r(n._sheets);
2326
+ } : void 0
2327
+ }, t);
2328
+ }, () => n.getSelectedWorksheet()), this._ownCalculation && "none" !== (s.calcOnLoad ?? "auto") && this._calculation.hydrateNames(), this._emitter.notify("onLoad"), this._ownTransactions ? a.amend() : a.commit();
2329
+ } catch (e) {
2330
+ throw a.rollback(), e;
2331
+ }
2332
+ this._initializing = !1;
2333
+ }
2334
+ _initState() {
2335
+ let e = this._getSheetRefs();
2336
+ for (let t = (e ? e.length : 0) - 1; t >= 0; t--);
2337
+ const t = this._options;
2338
+ this._isDate1904 = t.runtime?.isDate1904() ?? !1, this._locale = null, this._localeOverrides = null, this._theme = t.theme ?? new ee().getDefaultTheme(), this._styles = t?.styles ?? new Ye(this._theme), this._ownStyles = !t.styles, this._styles.getTheme() || this._styles.setTheme(this.getTheme()), this._activeSheetOffset = 0, this.setView(new ts()), this._listenerProtection?.(), this._protection = new rs(void 0, this._options.readonly ?? !1), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
2339
+ s._emitter.notify("onProtectionChange");
2340
+ } });
2341
+ const s = this;
2342
+ this._transactionsRemoveListener = this._transactions.addStateListener(this._id, {
2343
+ async onAfterStateChange(e, t, r, i, o) {
2344
+ const n = s._view, a = o?.[ws], l = r ? a?.before : a?.after, h = a?.viewId === n.getId() && null != l, c = h ? l : n.getActiveSheetId(), u = h && t.getId() === s._lastTransactionUUID ? s._getSheetRef({ id: c }) : null;
2345
+ u ? await u.sheet.select() : s._resyncActiveSheet(c, e), s._lastTransactionUUID = t.getId(), (r || i) && s._emitter.notify("onSheetsChange"), s._emitter.notify("onSelectedSheetChange"), s._emitter.notify("onViewChange");
2346
+ },
2347
+ onRestoreOrRevert() {
2348
+ s._ownCalculation, s._emitter.notify("onInvalidated");
2349
+ }
2350
+ });
2351
+ const r = this._getState();
2352
+ r?.listenersSheets && (r?.listenersSheets.forEach((e) => {
2353
+ e();
2354
+ }), r?.listenersSheets.clear()), this._updateState({
2355
+ sheetRefsAll: [],
2356
+ sheetRefsVisibleAndHidden: [],
2357
+ sheetRefsVisible: [],
2358
+ refsById: /* @__PURE__ */ new Map(),
2359
+ sheetsById: /* @__PURE__ */ new Map(),
2360
+ refsByLowerCaseName: /* @__PURE__ */ new Map(),
2361
+ sheetsByLowerCaseName: /* @__PURE__ */ new Map(),
2362
+ refsByInstance: /* @__PURE__ */ new Map(),
2363
+ lastId: -1,
2364
+ sheetsCreated: /* @__PURE__ */ new Set(),
2365
+ listenersSheets: /* @__PURE__ */ new Map()
2366
+ });
2367
+ }
2368
+ getId() {
2369
+ return this._id;
2370
+ }
2371
+ getVersionId() {
2372
+ return this._transactions.getVersionId(this._id);
2373
+ }
2374
+ getName() {
2375
+ return this._closed ? null : this._origin.getName();
2376
+ }
2377
+ getOrigin() {
2378
+ return this._originProvider.getOrigin();
2379
+ }
2380
+ _onOriginChange() {
2381
+ if (this._closed) return;
2382
+ const e = this._originProvider.getOrigin();
2383
+ if (e === this._origin) return;
2384
+ this._listenerOrigin?.();
2385
+ const t = this._lastOriginName;
2386
+ this._bindOrigin(e), this._emitter.notify("onOriginChange"), this._lastOriginName !== t && this._emitter.notify("onNameChange");
2387
+ }
2388
+ _bindOrigin(e) {
2389
+ this._origin = e, this._lastOriginName = e.getName(), this._listenerOrigin = e.addListeners({ onChange: () => {
2390
+ if (this._closed) return;
2391
+ const t = e.getName();
2392
+ t !== this._lastOriginName && (this._lastOriginName = t, this._emitter.notify("onNameChange"));
2393
+ } });
2394
+ }
2395
+ getView() {
2396
+ return this._view;
2397
+ }
2398
+ setView(e) {
2399
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2400
+ if (!e) throw new m(g("error.sheet.emptyView"));
2401
+ this._listenerWorkbookView?.();
2402
+ const t = this;
2403
+ let s = -1;
2404
+ return this._listenerWorkbookView = e.addListeners({ onViewChange: (e) => {
2405
+ const r = t._getState(), i = this._view.getActiveSheetId(), o = r.sheetRefsVisible, n = this._getOffsetForId(i, o);
2406
+ this._activeSheetOffset = n, t._emitter.notify("onViewChange"), s !== i && (t._emitter.notify("onSelectionChange"), t._emitter.notify("onSelectedSheetChange")), s = i;
2407
+ } }), this._view = e, t._emitter.notify("onViewChange"), this;
2408
+ }
2409
+ getRuntime() {
2410
+ return this._runtime;
2411
+ }
2412
+ setDate1904(e) {
2413
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2414
+ return this._isDate1904 === e || (this._isDate1904 = e, this._emitter.notify("onRegionalChange")), this;
2415
+ }
2416
+ getLocale() {
2417
+ return this._runtime.getLocale();
2418
+ }
2419
+ getPinnedLocale() {
2420
+ return this._locale;
2421
+ }
2422
+ setLocale(e) {
2423
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2424
+ if (e) try {
2425
+ new Intl.Locale(e);
2426
+ } catch {
2427
+ throw new Error(g("error.workbook.invalidLocale", { locale: e }));
2428
+ }
2429
+ return this._locale === e || (this._locale = e, this._emitter.notify("onRegionalChange")), this;
2430
+ }
2431
+ getLocaleOverrides() {
2432
+ return this._localeOverrides;
2433
+ }
2434
+ setLocaleOverrides(e) {
2435
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2436
+ const t = e && Object.keys(e).length > 0 ? e : null;
2437
+ return this._localeOverrides = t, this._emitter.notify("onRegionalChange"), this;
2438
+ }
2439
+ getStyles() {
2440
+ return this._styles;
2441
+ }
2442
+ getResources() {
2443
+ return this._resources;
2444
+ }
2445
+ getFetcher() {
2446
+ return this._fetch.getFetcher();
2447
+ }
2448
+ fetch(e, t) {
2449
+ return this._fetch.fetch(e, t);
2450
+ }
2451
+ getTransactions() {
2452
+ return this._transactions;
2453
+ }
2454
+ getChanges(e) {
2455
+ const t = this._transactions, [s, r] = t.getLog(e ?? t.getCurrentCommit(!1).getId(), 2), i = [], o = this.getWorksheets().getItems({ visibility: Ge.Visibility.VeryHidden });
2456
+ for (let e = 0; e < o.length; e++) {
2457
+ const t = o[e];
2458
+ t instanceof ge && i.push(...t._changeEventsOf(s, r ?? null));
2459
+ }
2460
+ return i;
2461
+ }
2462
+ getStrings() {
2463
+ return this._strings;
2464
+ }
2465
+ getExternalBooks() {
2466
+ return this._calculation.getExternalBooks();
2467
+ }
2468
+ getUpdateLinks() {
2469
+ return this._updateLinks;
2470
+ }
2471
+ setUpdateLinks(e) {
2472
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2473
+ return this._updateLinks = e, this;
2474
+ }
2475
+ getPivotTables() {
2476
+ return this._pivotTableCollection;
2477
+ }
2478
+ getComments() {
2479
+ return this._commentCollection;
2480
+ }
2481
+ getPeople() {
2482
+ return this._people;
2483
+ }
2484
+ getTheme() {
2485
+ return this._theme;
2486
+ }
2487
+ setTheme(e) {
2488
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2489
+ if (!e) throw new m(g("error.workbook.notSetValue"));
2490
+ const t = this._theme;
2491
+ return this._theme = e, this.getStyles().setTheme(e), this._emitter.notify("onThemeChange"), t;
2492
+ }
2493
+ getSelectedSheetIndex() {
2494
+ return this._activeSheetOffset;
2495
+ }
2496
+ getSelectedSheet() {
2497
+ const e = this._getSheetRef(this.getSelectedSheetIndex());
2498
+ return e ? e.sheet : null;
2499
+ }
2500
+ getSelectedWorksheet() {
2501
+ const e = this._getSheetRef(this.getSelectedSheetIndex());
2502
+ return e && vs(e) ? e.sheet : null;
2503
+ }
2504
+ getActiveSheet() {
2505
+ return this.getSelectedWorksheet();
2506
+ }
2507
+ getActiveWorksheet() {
2508
+ return this.getSelectedWorksheet();
2509
+ }
2510
+ getSheets(e) {
2511
+ const t = this._getSheetRefs(e?.visibility ?? Ge.Visibility.Visible), s = new Array(t.length);
2512
+ for (let e = 0; e < t.length; e++) s[e] = t[e].sheet;
2513
+ return s;
2514
+ }
2515
+ getSheet(e) {
2516
+ if (void 0 === e) return this.getSelectedSheet();
2517
+ if (!e) throw new Error(g("error.workbook.sheetNameNotProvided"));
2518
+ const t = this._getSheetRef(e);
2519
+ if (!t) throw new a(ls(e));
2520
+ return t.sheet;
2521
+ }
2522
+ getWorksheet(e, t = Ge.Visibility.Visible) {
2523
+ if ("number" == typeof e) return this.getWorksheetAt(e, t);
2524
+ if (void 0 === e) return this._requireSelectedWorksheet();
2525
+ if (!e) throw new Error(g("error.workbook.sheetNameNotProvided"));
2526
+ const s = this._getSheetRef(e, t);
2527
+ if (!s) throw new a(ls(e));
2528
+ if (!vs(s)) throw new a(hs(s.name, s.sheet.getKind()));
2529
+ return s.sheet;
2530
+ }
2531
+ getWorksheetAt(e, t = Ge.Visibility.Visible) {
2532
+ const s = this._getWorksheets(t)[e];
2533
+ if (!s) throw new a(function(e) {
2534
+ return g("error.workbook.sheetIndexNotFound", { index: e });
2535
+ }(e));
2536
+ return s;
2537
+ }
2538
+ _requireSelectedWorksheet() {
2539
+ const e = this.getSelectedWorksheet();
2540
+ if (e) return e;
2541
+ const t = this.getSelectedSheet();
2542
+ throw new m(cs(t?.getName() ?? "", t?.getKind() ?? Ge.Kind.Worksheet));
2543
+ }
2544
+ _anchorWorksheet() {
2545
+ return this.getSelectedWorksheet() || (this._getWorksheets(Ge.Visibility.VeryHidden)[0] ?? null);
2546
+ }
2547
+ getWorksheets() {
2548
+ return this._sheets;
2549
+ }
2550
+ addWorksheet(e) {
2551
+ return this.getWorksheets().add(e);
2552
+ }
2553
+ _getWorksheets(e = Ge.Visibility.Visible) {
2554
+ const t = this._getSheetRefs(e), s = [], r = t.length;
2555
+ for (let e = 0; e < r; e++) {
2556
+ const r = t[e];
2557
+ vs(r) && s.push(r.sheet);
2558
+ }
2559
+ return s;
2560
+ }
2561
+ _getSheetRefs(e = Ge.Visibility.Visible) {
2562
+ const t = this._getState();
2563
+ return t ? e === Ge.Visibility.Visible ? t.sheetRefsVisible : e === Ge.Visibility.Hidden ? t.sheetRefsVisibleAndHidden : e === Ge.Visibility.VeryHidden ? t.sheetRefsAll : c.EmptyArray : [];
2564
+ }
2565
+ _getSheetRef(e, t = Ge.Visibility.Visible) {
2566
+ let s = null;
2567
+ return "number" == typeof e ? this._getSheetRefs(t)[e] : ("string" == typeof e ? s = this._getState().refsByLowerCaseName.get(e.toLowerCase()) : !0 === e?.isISheet ? s = this._getState().refsByInstance.get(e) : void 0 !== e?.id && (s = this._getState().refsById.get(e.id)), s);
2568
+ }
2569
+ _validateNewSheetName(e, t = !0) {
2570
+ if (null == e) return e;
2571
+ if (ps(e), t && this._getState().sheetsByLowerCaseName.has(e.toLowerCase())) throw new m(g("error.workbook.nameTaken"));
2572
+ return e.substring(0, 31);
2573
+ }
2574
+ findValidSheetName(e) {
2575
+ e && (e = ps(e, !0));
2576
+ try {
2577
+ return function(e, t) {
2578
+ try {
2579
+ if (t(e)) return e;
2580
+ } catch (e) {}
2581
+ let s, r, i = ms.exec(e);
2582
+ for (null !== i ? (s = e.substring(0, i.index), r = parseFloat(i[1])) : (s = e + " ", r = 1); r < 256;) {
2583
+ r++;
2584
+ const i = "(" + r + ")", o = s.substring(0, 31 - i.length) + i;
2585
+ try {
2586
+ if (t(o)) return o;
2587
+ } catch (e) {}
2588
+ }
2589
+ throw new Error(e + " is not a valid sheet name");
2590
+ }(e, (e) => this._validateNewSheetName(e));
2591
+ } catch (e) {
2592
+ return this._nextSheetName();
2593
+ }
2594
+ }
2595
+ isValidSheetNameCharacter(e) {
2596
+ return !gs.test(e);
2597
+ }
2598
+ _isStructureProtected() {
2599
+ return !this._initializing && !this.getProtection().isStructureAllowed();
2600
+ }
2601
+ _addSheetOptions(e) {
2602
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2603
+ if (!this.getProtection().isStructureAllowed()) throw new t(g("error.workbook.protection"));
2604
+ let s, r = null;
2605
+ s = "string" == typeof e ? { name: e } : "number" == typeof e ? { index: e } : e, s = {
2606
+ ...s,
2607
+ description: s?.description ?? _("op.addSheet")
2608
+ };
2609
+ const i = this.beginCommit(s);
2610
+ try {
2611
+ const e = s?.autoSelect ?? !1;
2612
+ r = this._addSheet(!0, s.name, s.index ?? null);
2613
+ const t = this.getView().getActiveSheetId();
2614
+ if (e && this._recordActiveSheet(i, t, this._getSheetRef(r).id), i.commit({ description: g("op.addSheetNamed", { name: r.getName() }) }), !1 !== e) {
2615
+ const t = "boolean" == typeof e ? void 0 : e;
2616
+ r.select(t);
2617
+ }
2618
+ } catch (e) {
2619
+ throw i.rollback(), e;
2620
+ }
2621
+ return r;
2622
+ }
2623
+ _nextSheetName(e = null) {
2624
+ let t = e ? e.toLowerCase() : null;
2625
+ const s = this._getState(), r = s.sheetsByLowerCaseName;
2626
+ if (e && r.has(t)) throw new m(function(e) {
2627
+ return g("error.workbook.nameDuplicate", { sheetName: e });
2628
+ }(e));
2629
+ t = (e = this._validateNewSheetName(e)) ? e.toLowerCase() : null;
2630
+ let i = s.lastId + 1;
2631
+ for (; !e;) {
2632
+ const t = this._createSheetName(i), s = t.toLowerCase();
2633
+ r.has(s) ? i++ : e = t;
2634
+ }
2635
+ return this._updateState({ lastId: i }), e;
2636
+ }
2637
+ _addSheet(e, t = null, s = null, r) {
2638
+ t = this._nextSheetName(t);
2639
+ const i = this._getState(), o = this._createSheet(i.lastId, t, Ge.Visibility.Visible, s, void 0, null, r);
2640
+ if (!o) throw new m(g("error.workbook.sheetNameBlank"));
2641
+ return e && (this._tellSheets(), this._emitter.notify("onSheetsChange")), o;
2642
+ }
2643
+ _createOpaqueSheet(e, t, s, r, i, o, n, a, l) {
2644
+ const h = this;
2645
+ let u = null;
2646
+ return u = new Yt({
2647
+ kind: o,
2648
+ id: l ?? t + "-" + c.uuidV4(),
2649
+ part: n,
2650
+ tabColor: a,
2651
+ styles: this._styles,
2652
+ transactions: this._transactions,
2653
+ workbook: this,
2654
+ container: {
2655
+ getName: () => h._getSheetRef(u)?.name ?? t,
2656
+ setName: (e, t) => {
2657
+ h._setSheetName(u, e, t);
2658
+ },
2659
+ getVisibility: () => h._getSheetRef(u, Ge.Visibility.VeryHidden)?.visibility ?? Ge.Visibility.Visible,
2660
+ setVisibility: (e, t) => {
2661
+ h._setSheetVisibility(u, e, t);
2662
+ },
2663
+ getIndex: () => {
2664
+ const e = h._getSheetRef(u, Ge.Visibility.VeryHidden);
2665
+ return e ? h._getOffsetForId(e.id, h._getSheetRefs(Ge.Visibility.VeryHidden)) : -1;
2666
+ },
2667
+ setIndex: (e, t) => {
2668
+ const s = h._getSheetRef(u, Ge.Visibility.VeryHidden);
2669
+ s && h._moveSheet(s, e, t);
2670
+ },
2671
+ requestSelect: () => h._requestSelect(u),
2672
+ isAttached: () => !!h._getSheetRef(u, Ge.Visibility.VeryHidden)
2673
+ }
2674
+ }), this._sheetOnNameChange.set(e, () => u._notify("onNameChange")), this._sheetOnVisibilityChange.set(e, () => u._notify("onVisibilityChange")), this._sheetOnIndexChange.set(e, () => u._notify("onIndexChange")), this._addSheetRef({
2675
+ name: t,
2676
+ id: e,
2677
+ visibility: s ?? Ge.Visibility.Visible,
2678
+ sheetId: i,
2679
+ sheet: u
2680
+ }, r), u;
2681
+ }
2682
+ async _requestSelect(e) {
2683
+ return this._setSelectedSheet(e), await this._emitter.notify("onRequestSelect", {
2684
+ source: this,
2685
+ params: e,
2686
+ async: !0
2687
+ }), this.getSelectedSheet() === e;
2688
+ }
2689
+ _updateSheetRefStates(e) {
2690
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2691
+ if (!this._initializing && !this.getProtection().isStructureAllowed()) throw new t(g("error.workbook.protection"));
2692
+ const s = e, r = [], i = [], o = s.length;
2693
+ for (let e = 0; e < o; e++) s[e].visibility === Ge.Visibility.Visible ? (r.push(s[e]), i.push(s[e])) : s[e].visibility === Ge.Visibility.Hidden && i.push(s[e]);
2694
+ this._updateState({
2695
+ sheetRefsAll: s,
2696
+ sheetRefsVisible: r,
2697
+ sheetRefsVisibleAndHidden: i
2698
+ });
2699
+ }
2700
+ _tellSheets() {
2701
+ if (this._isLoadingSheets) return;
2702
+ const e = this._getState().sheetRefsAll;
2703
+ this._calculation._setSheets(e.map((e) => vs(e) ? [e.sheet.getId(), e.name] : [
2704
+ e.sheet.getId(),
2705
+ e.name,
2706
+ !0
2707
+ ]));
2708
+ }
2709
+ _addSheetRef(e, t = null) {
2710
+ const s = this._getState(), r = s.sheetRefsAll, i = Math.max(0, Math.min(r.length, t ?? r.length));
2711
+ let o = [
2712
+ ...r.slice(0, i),
2713
+ e,
2714
+ ...r.slice(i)
2715
+ ];
2716
+ this._updateSheetRefStates(o);
2717
+ const n = e.sheet, a = e.name.toLowerCase(), l = new Map(s.refsById);
2718
+ l.set(e.id, e);
2719
+ const h = new Map(s.refsByLowerCaseName);
2720
+ h.set(a, e);
2721
+ const c = new Map(s.refsByInstance);
2722
+ c.set(n, e);
2723
+ const u = new Map(s.sheetsById);
2724
+ u.set(e.id, n);
2725
+ const d = new Map(s.sheetsByLowerCaseName);
2726
+ d.set(a, n);
2727
+ const m = this;
2728
+ let _ = s.listenersSheets;
2729
+ if (void 0 !== n) {
2730
+ const t = n.addListeners({
2731
+ onBeforeDelete: (e) => {
2732
+ m._validateDeleteSheet(e);
2733
+ },
2734
+ onDelete(e) {
2735
+ let t = m._getSheetRef(e, Ge.Visibility.VeryHidden);
2736
+ if (!t) return;
2737
+ const s = m._beginCommit({ description: g("op.deleteSheet", { name: t.name }) });
2738
+ try {
2739
+ const r = m._getState(), i = r.sheetRefsAll, o = m._getOffsetForId(t.id, i);
2740
+ let a = [...i];
2741
+ a.splice(o, 1), m._updateSheetRefStates(a);
2742
+ const l = new Map(r.refsById);
2743
+ l.delete(t.id);
2744
+ const h = new Map(r.sheetsById);
2745
+ h.delete(t.id);
2746
+ const c = t.name.toLowerCase(), u = new Map(r.refsByLowerCaseName);
2747
+ u.delete(c);
2748
+ const d = new Map(r.sheetsByLowerCaseName);
2749
+ d.delete(c);
2750
+ const g = new Map(r.refsByInstance);
2751
+ g.delete(e), r.listenersSheets.get(t.id)();
2752
+ const _ = new Map(r.listenersSheets);
2753
+ _.delete(t.id), m._adjustRemoveSelectionIfRequired(o, t.id), m._adjustSheetNamesIfRequired(), m._sheetOnNameChange.delete(t.id), m._sheetOnVisibilityChange.delete(t.id), m._sheetOnIndexChange.delete(t.id), m._tellSheets(), m._emitter.notify("onSheetsChange");
2754
+ const f = new Set(r.sheetsCreated);
2755
+ f.has(n) && f.delete(n), m._updateState({
2756
+ refsById: l,
2757
+ sheetsById: h,
2758
+ refsByLowerCaseName: u,
2759
+ sheetsByLowerCaseName: d,
2760
+ refsByInstance: g,
2761
+ sheetsCreated: f,
2762
+ listenersSheets: _
2763
+ }), s.commit();
2764
+ } catch (e) {
2765
+ throw s.rollback(), e;
2766
+ }
2767
+ }
2768
+ }, { transactional: !0 }), r = vs(e) ? e.sheet.addListeners({ onSelectionChange: (e) => {
2769
+ m.getView().getActiveSheetId() === m._getSheetRef(e)?.id && m._emitter.notify("onSelectionChange", {
2770
+ source: m,
2771
+ params: e
2772
+ });
2773
+ } }, { transactional: !1 }) : null, i = () => {
2774
+ t(), r?.();
2775
+ };
2776
+ _ = new Map(s.listenersSheets), _.set(e.id, i);
2777
+ }
2778
+ let f = s.lastId;
2779
+ -1 !== f && (f = Math.max(f, e.id)), this._updateState({ lastId: f }), this._updateState({
2780
+ refsById: l,
2781
+ refsByLowerCaseName: h,
2782
+ refsByInstance: c,
2783
+ sheetsById: u,
2784
+ sheetsByLowerCaseName: d,
2785
+ listenersSheets: _
2786
+ }), this._adjustSheetNamesIfRequired();
2787
+ const p = new Set(this._getState().sheetsCreated);
2788
+ return p.add(e.sheet), this._updateState({ sheetsCreated: p }), this._tellSheets(), e;
2789
+ }
2790
+ _recordActiveSheet(e, t, s) {
2791
+ const r = this.getView().getId();
2792
+ e.setIntent(ws, (e) => ({
2793
+ viewId: r,
2794
+ before: e?.before ?? t,
2795
+ after: s
2796
+ }));
2797
+ }
2798
+ _resyncActiveSheet(e, t) {
2799
+ const s = t?.sheetRefsVisible;
2800
+ if (!s?.length) return;
2801
+ let r = -1;
2802
+ const i = s.length;
2803
+ for (let t = 0; t < i; t++) if (s[t].id === e) {
2804
+ r = t;
2805
+ break;
2806
+ }
2807
+ -1 === r && (r = Math.min(Math.max(this._activeSheetOffset, 0), i - 1));
2808
+ const o = s[r].id;
2809
+ this._view.getActiveSheetId() !== o ? this._view.setActiveSheetId(o) : this._activeSheetOffset = r;
2810
+ }
2811
+ _adjustRemoveSelectionIfRequired(e, t) {
2812
+ if (this._view.getActiveSheetId() === t) {
2813
+ let t;
2814
+ const s = this._getState().sheetRefsVisible;
2815
+ t = e < s.length ? s[e].id : s[e - 1].id, this._view.setActiveSheetId(t);
2816
+ }
2817
+ }
2818
+ _adjustSheetNamesIfRequired() {
2819
+ const e = this._getState(), t = e.lastId;
2820
+ if (-1 === t) return;
2821
+ let s = this._view.getActiveSheetId();
2822
+ s ?? (this._view.setActiveSheetId(t), s = t);
2823
+ let r = e.refsById.get(s);
2824
+ r || (this._view.setActiveSheetId(t), r = e.refsById.get(t), s = t), r.visibility === Ge.Visibility.Visible && (this._activeSheetOffset = this._getOffsetForId(s, e.sheetRefsVisible));
2825
+ }
2826
+ _validateDeleteSheet(e) {
2827
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2828
+ if (!this.getProtection().isStructureAllowed()) throw new t(g("error.workbook.protection"));
2829
+ let s = this._getSheetRef(e);
2830
+ if (!s) throw new m(function(e) {
2831
+ return g("error.workbook.deleteKey", { key: e });
2832
+ }(e));
2833
+ const r = this._getState().sheetRefsVisible;
2834
+ if (1 === r.length && r[0].id === s.id) throw new m(g("error.workbook.sheetOne"));
2835
+ }
2836
+ _getOffsetForId(e, t) {
2837
+ const s = t.length;
2838
+ for (let r = 0; r < s; r++) if (t[r].id === e) return r;
2839
+ throw new m(g("error.workbook.noVisibleRefs"));
2840
+ }
2841
+ find(e) {
2842
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2843
+ const t = this._getWorksheets();
2844
+ if (0 === t.length) return { next: () => D };
2845
+ if (1 === t.length) return t[0].find(e);
2846
+ "string" == typeof e && (e = { text: e });
2847
+ const s = !e?.reverse;
2848
+ let r = e?.disableWrap ?? !1;
2849
+ const i = this._worksheetOffsetFrom(this.getSelectedSheetIndex(), t);
2850
+ let o = i, n = t[o], a = !1;
2851
+ e = {
2852
+ ...e,
2853
+ disableWrap: !0
2854
+ };
2855
+ let l, h = n.find(e), c = h.next(), u = !1;
2856
+ if (e?.from) {
2857
+ const t = this._rangesAddressToCoords(e?.from);
2858
+ l = {
2859
+ colIndex: t[0].colStart,
2860
+ rowIndex: t[0].rowStart
2861
+ };
2862
+ }
2863
+ const m = d.createCellComparator(e?.axis, e?.reverse);
2864
+ delete (e = { ...e }).from;
2865
+ const _ = () => {
2866
+ if (!u && c.done && (a && o === i ? u = !0 : s ? (o++, o > t.length - 1 && (o = 0, a = !0)) : (o--, o < 0 && (o = t.length - 1, a = !0)), r && a && (u = !0), u || l || !a || o !== i || (u = !0), !u)) {
2867
+ n = t[o], h = n.find(e);
2868
+ const s = c;
2869
+ return c = h.next(), s;
2870
+ }
2871
+ if (!u && a && o === i && (c.done || !l || !c.done && m(c.value.getCoords(), l) >= 0) && (u = !0), u) {
2872
+ const e = c;
2873
+ return c = D, e;
2874
+ }
2875
+ const d = c;
2876
+ return c = h.next(), d;
2877
+ };
2878
+ return { next: () => {
2879
+ let e = _();
2880
+ for (; !u && e.done;) e = _();
2881
+ return e;
2882
+ } };
2883
+ }
2884
+ replace(e, t, s) {
2885
+ let r = 0, i = null;
2886
+ const o = "function" == typeof t, n = s?.maxCount ?? Number.MAX_SAFE_INTEGER, a = !s?.maxCount;
2887
+ let l = "";
2888
+ const h = "string" == typeof t ? ye(t) : null;
2889
+ let c = s?.description ?? _("op.replace");
2890
+ const u = this._transactions.beginCommit({ description: c });
2891
+ try {
2892
+ let c = null, d = null, m = e.next();
2893
+ for (; !m.done && r < n;) {
2894
+ const n = m.value, a = n.getWorksheet();
2895
+ a !== c && (c = a, null !== d && d.apply(), d = c.getEntireRange().createSparseBuilder({
2896
+ axis: s?.axis,
2897
+ allowUnorderedWrites: !0
2898
+ }));
2899
+ const l = o ? t(n) : t;
2900
+ void 0 !== l && l !== n && (d.push(n, l), r++, i = n), m = e.next();
2901
+ }
2902
+ d?.apply(), 1 === r && 1 === n && i && (l = i.getAddress()), 0 === r ? u.rollback() : u.commit({ description: s?.description ?? (a ? null !== h ? g("op.replaceAllWith", { value: h }) : _("op.replaceAll") : l ? null !== h ? g("op.replaceAtWith", {
2903
+ address: l,
2904
+ value: h
2905
+ }) : g("op.replaceAt", { address: l }) : null !== h ? g("op.replaceWith", { value: h }) : _("op.replace")) });
2906
+ } catch (e) {
2907
+ throw u.rollback(), e;
2908
+ }
2909
+ return {
2910
+ count: r,
2911
+ last: i
2912
+ };
2913
+ }
2914
+ _nextSheetIndex(e, t = this._getSheetRefs()) {
2915
+ const s = t.length;
2916
+ return 1 === s ? 0 : (void 0 === e && (e = this.getSelectedSheetIndex()), (e = Math.max(0, Math.min(e, s - 1))) >= s - 1 ? 0 : e + 1);
2917
+ }
2918
+ _prevSheetIndex(e, t = this._getSheetRefs()) {
2919
+ const s = t.length;
2920
+ return 1 === s ? 0 : (void 0 === e && (e = this.getSelectedSheetIndex()), (e = Math.max(0, Math.min(e, s - 1))) <= 0 ? s - 1 : e - 1);
2921
+ }
2922
+ _worksheetOffsetFrom(e, t) {
2923
+ const s = this._getSheetRefs(), r = s.length;
2924
+ for (let i = 0; i < r; i++) {
2925
+ const o = s[(e + i) % r];
2926
+ if (!vs(o)) continue;
2927
+ const n = t.indexOf(o.sheet);
2928
+ if (-1 !== n) return n;
2929
+ }
2930
+ return 0;
2931
+ }
2932
+ getNextSheet(e) {
2933
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2934
+ const t = this._getSheetRefs();
2935
+ return t[this._nextSheetIndex(e, t)]?.sheet ?? null;
2936
+ }
2937
+ getPreviousSheet(e) {
2938
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2939
+ const t = this._getSheetRefs();
2940
+ return t[this._prevSheetIndex(e, t)]?.sheet ?? null;
2941
+ }
2942
+ async _duplicateSheet(e) {
2943
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
2944
+ if (!this.getProtection().isStructureAllowed()) throw new t(g("error.workbook.protection"));
2945
+ const s = this._getSheetRefs(), r = this.getSelectedSheetIndex();
2946
+ let i = null;
2947
+ if (e) {
2948
+ if (i = this._getSheetRef(e), !i) throw new m(as(i));
2949
+ } else i = s[r];
2950
+ if (!i) return null;
2951
+ if (!vs(i)) throw new m((o = i.name, g("error.workbook.sheetNotDuplicable", { sheetName: o })));
2952
+ var o;
2953
+ const n = i.sheet, a = this._strings.beginPersist(), l = this.getResources().beginPersist(), h = this.getStyles().beginPersist(), c = this._richValues.beginPersist();
2954
+ let u = null;
2955
+ const d = this.beginCommit(g("op.duplicateNamed", { name: n.getName() }));
2956
+ try {
2957
+ const e = this._getState().refsByInstance.get(n), t = await n.toJSON(), i = s.length + 1, o = this.findValidSheetName(e.name), a = this._createSheet(i, o, e.visibility, r, void 0, t);
2958
+ this._tellSheets(), this._emitter.notify("onSheetsChange"), u = a, d.commit();
2959
+ } catch (e) {
2960
+ throw d.rollback(), e;
2961
+ } finally {
2962
+ c.endPersist(), h.endPersist(), l.endPersist(), a.endPersist();
2963
+ }
2964
+ return u;
2965
+ }
2966
+ _createRange(e, t) {
2967
+ const s = e ? { ...e } : null, r = s ? this._getSheetRef(s.scope, Ge.Visibility.VeryHidden) : null;
2968
+ if (r && !vs(r)) throw new m(hs(r.name, r.sheet.getKind()));
2969
+ if (!r) {
2970
+ const e = this._anchorWorksheet();
2971
+ return e ? (delete s?.scope, fs(s, s ? {
2972
+ scope: H,
2973
+ ...e.getEntireRange().getCoords()
2974
+ } : null)) : void console.warn(g("error.workbook.noVisibleRefs"));
2975
+ }
2976
+ const i = r.sheet;
2977
+ let o = null;
2978
+ return t && (o = { getOptions: t }), new bs(e, q(i), this, o);
2979
+ }
2980
+ _createRanges(e, t) {
2981
+ const s = this._anchorWorksheet();
2982
+ if (!s) throw new m(cs("", Ge.Kind.Worksheet));
2983
+ let r = null;
2984
+ return t && (r = { getOptions: t }), new ys(e, q(s), this, r);
2985
+ }
2986
+ getRange(e, t) {
2987
+ if (void 0 === e) return this.getSelectedRange(t);
2988
+ "number" == typeof e && (e = Z(arguments), t = void 0);
2989
+ try {
2990
+ const s = this._rangesAddressToCoords(e);
2991
+ if (1 !== s.length) throw new m(g("error.address.singleRangeOnlyAlt"));
2992
+ return this._createRange(s[0], t);
2993
+ } catch (t) {
2994
+ if (t instanceof a) throw new a(t.message);
2995
+ throw new m(t.message ?? ze(e));
2996
+ }
2997
+ }
2998
+ getCell(e) {
2999
+ if (void 0 === e) return this.getSelectedCell();
3000
+ const t = this.getRange(e);
3001
+ if (t.size > 1) throw new m(g("error.address.singleCellOnly"));
3002
+ return t.getCell();
3003
+ }
3004
+ getRanges(e, t) {
3005
+ const s = this._rangesAddressToCoords(e);
3006
+ if (0 === s.length) throw new m(ze(e));
3007
+ return this._createRanges(s, t);
3008
+ }
3009
+ _createGraphRanges(e, t) {
3010
+ const s = [], r = this.getCalculation()?.getNamedFormulas() ?? null;
3011
+ for (let e = 0; e < t.length; e++) {
3012
+ const i = t[e], o = i.sheetName ? this._getSheetRef(i.sheetName, Ge.Visibility.VeryHidden) : null, n = o && vs(o) ? o.sheet : this._anchorWorksheet();
3013
+ n && s.push(new De(i, r, q(n), null));
3014
+ }
3015
+ for (let t = 0; t < e.length; t++) s.push(e[t]);
3016
+ const i = this._anchorWorksheet();
3017
+ return 0 !== s.length && i ? new ys(s, q(i), this, null) : null;
3018
+ }
3019
+ getAnomalies(e) {
3020
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
3021
+ const t = ie(e), s = this._getWorksheets(Ge.Visibility.VeryHidden).map((e) => {
3022
+ const t = q(e);
3023
+ return {
3024
+ bounds: t.getSheet().getEntireCoords(),
3025
+ internal: t,
3026
+ qualified: !0
3027
+ };
3028
+ });
3029
+ return new Ue(s, () => (this.getSelectedWorksheet() ?? this._getWorksheets(Ge.Visibility.VeryHidden)[0]).getEntireRange(), t);
3030
+ }
3031
+ getStats(e) {
3032
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
3033
+ const t = this._getWorksheets(Ge.Visibility.VeryHidden), s = t.length;
3034
+ if (1 === s) return t[0].getStats(e);
3035
+ const r = new Array(s);
3036
+ for (let i = 0; i < s; i++) r[i] = t[i].getStats(e);
3037
+ return new Pt(r);
3038
+ }
3039
+ _activeRangeCoords() {
3040
+ const e = this._requireSelectedWorksheet(), t = e.getSelection().getRanges().getCoords(), s = e.getName(), r = t.length, i = new Array(r);
3041
+ for (let e = 0; e < r; e++) {
3042
+ const r = t[e];
3043
+ i[e] = {
3044
+ colStart: r.colStart,
3045
+ colEnd: r.colEnd,
3046
+ rowStart: r.rowStart,
3047
+ rowEnd: r.rowEnd,
3048
+ scope: s
3049
+ };
3050
+ }
3051
+ return i;
3052
+ }
3053
+ getSelectedRange(e) {
3054
+ return this.getRange(this._activeRangeCoords()[0], e);
3055
+ }
3056
+ getSelectedRanges(e) {
3057
+ return this.getRanges(this._activeRangeCoords(), e);
3058
+ }
3059
+ getSelectedCell() {
3060
+ return this._requireSelectedWorksheet().getSelectedCell();
3061
+ }
3062
+ _rangesAddressToCoords(e, t = !0, s = Ge.Visibility.Hidden) {
3063
+ if (!e) throw new m(g("error.address.noAddress"));
3064
+ const r = this.getSelectedWorksheet(), i = { ...(r ?? this._anchorWorksheet())?.getEntireRange().getCoords() }, o = r?.getName();
3065
+ if (o && (i.scope = o), "string" == typeof e) {
3066
+ const t = e.trim().toLowerCase();
3067
+ if ("r" === t || "c" === t) {
3068
+ const s = this.getSelectedCell().getCoords(), r = {};
3069
+ "r" === t ? r.rowStart = r.rowEnd = s.rowIndex : r.colStart = r.colEnd = s.colIndex, e = r;
3070
+ }
3071
+ }
3072
+ const n = this, a = _e(e, i, ve, (e) => {
3073
+ if (!t) return null;
3074
+ if ("string" == typeof e) {
3075
+ const t = be(e, {
3076
+ getTable: (e) => z(n.getNames().getByName(e)),
3077
+ getAnchor: () => r ? {
3078
+ sheet: r,
3079
+ coords: r.getSelectedCell().getCoords()
3080
+ } : null
3081
+ });
3082
+ if (t) return [t];
3083
+ const s = n.getNames().getByName(e)?.getRanges?.();
3084
+ if (s) return s.getCoords();
3085
+ }
3086
+ throw new m(`Invalid sheet reference '${e}'.`);
3087
+ }), l = a.length;
3088
+ for (let e = 0; e < l; e++) this._validateCoords(a[e], s);
3089
+ return a;
3090
+ }
3091
+ _validateCoords(e, t = Ge.Visibility.Visible, s = g("error.sheet.oobRange")) {
3092
+ if (null === e) return;
3093
+ const r = this.getWorksheet(e.scope ?? void 0, t).getEntireRange().getCoords();
3094
+ if (!d.isRangeWithinRange(e, r)) throw new a(s);
3095
+ if (e.rowEnd < e.rowStart || e.colEnd < e.colStart) throw new m(g("error.address.invalidRangeInverted"));
3096
+ }
3097
+ _updateSheetRef(e, t) {
3098
+ const s = this._getState();
3099
+ let r = [...s.sheetRefsAll];
3100
+ r[this._getOffsetForId(e.id, s.sheetRefsAll)] = t, this._updateSheetRefStates(r);
3101
+ const i = new Map(s.refsById);
3102
+ i.set(e.id, t);
3103
+ const o = e.name.toLowerCase(), n = t.name.toLowerCase(), a = new Map(s.refsByLowerCaseName);
3104
+ a.delete(o), a.set(n, t);
3105
+ const l = new Map(s.sheetsByLowerCaseName);
3106
+ let h = l.get(o);
3107
+ l.delete(o), l.set(n, h);
3108
+ const c = new Map(s.refsByInstance);
3109
+ return c.set(h, t), this._updateState({
3110
+ refsById: i,
3111
+ refsByLowerCaseName: a,
3112
+ sheetsByLowerCaseName: l,
3113
+ refsByInstance: c
3114
+ }), this._tellSheets(), t;
3115
+ }
3116
+ _setSheetName(e, s, r) {
3117
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
3118
+ if (!this.getProtection().isStructureAllowed()) throw new t(g("error.workbook.protection"));
3119
+ const i = this._getSheetRef(e);
3120
+ if (!i) throw new m(as(e));
3121
+ if (s === i.name) return i.sheet;
3122
+ if (null == (s = this._validateNewSheetName(s))) throw new m(g("error.workbook.sheetNameNotProvided"));
3123
+ const o = Object.freeze({
3124
+ ...i,
3125
+ name: s
3126
+ });
3127
+ let n = null;
3128
+ const a = this.beginCommit(_("op.renameSheet"));
3129
+ try {
3130
+ const e = this._updateSheetRef(i, o);
3131
+ this._adjustSheetNamesIfRequired(), this._sheetOnNameChange.forEach((e, t) => {
3132
+ i.id === t && e();
3133
+ }), this._emitter.notify("onSheetsChange"), i.id === this.getView().getActiveSheetId() && this._emitter.notify("onSelectionChange"), n = e.sheet, a.commit(r);
3134
+ } catch (e) {
3135
+ throw a.rollback(), e;
3136
+ }
3137
+ return n;
3138
+ }
3139
+ _setSheetVisibility(e, s = Ge.Visibility.Visible, r) {
3140
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
3141
+ if (!this.getProtection().isStructureAllowed()) throw new t(g("error.workbook.protection"));
3142
+ const i = this._getSheetRef(e, Ge.Visibility.VeryHidden);
3143
+ if (!i) return null;
3144
+ if (s === i.visibility) return;
3145
+ let o = null, n = "";
3146
+ s === Ge.Visibility.Visible ? n = _("op.unhideSheet") : s === Ge.Visibility.Hidden ? n = _("op.hideSheet") : s === Ge.Visibility.VeryHidden && (n = _("op.veryHideSheet"));
3147
+ const a = this.beginCommit(n);
3148
+ try {
3149
+ const e = this._getState().sheetRefsVisible;
3150
+ if (s !== Ge.Visibility.Visible && 1 === e.length && e[0].id === i.id) throw new m(g("error.workbook.sheetOne"));
3151
+ const t = {
3152
+ ...i,
3153
+ visibility: s
3154
+ };
3155
+ let n = -1;
3156
+ s !== Ge.Visibility.Visible && (n = this._getOffsetForId(i.id, e)), o = this._updateSheetRef(i, t).sheet, s !== Ge.Visibility.Visible && this._adjustRemoveSelectionIfRequired(n, i.id), this._adjustSheetNamesIfRequired(), a.commit(r);
3157
+ } catch (e) {
3158
+ throw a.rollback(), e;
3159
+ }
3160
+ return this._sheetOnVisibilityChange.forEach((e, t) => {
3161
+ i.id === t && e();
3162
+ }), this._emitter.notify("onSheetsChange"), o;
3163
+ }
3164
+ _moveSheet(e, s, r) {
3165
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
3166
+ if (!this.getProtection().isStructureAllowed()) throw new t(g("error.workbook.protection"));
3167
+ let i = null;
3168
+ const o = this.beginCommit(g("op.moveSheetNamed", { name: e.name }));
3169
+ try {
3170
+ const t = this._getState(), n = t.sheetRefsVisible;
3171
+ if (s < 0 || s > n.length - 1) throw new m(`Invalid to index: ${s}`);
3172
+ const a = this.getView().getActiveSheetId(), l = t.sheetRefsAll, h = this._getOffsetForId(e.id, l), c = this._getOffsetForId(n[s].id, l);
3173
+ if (h === c) return;
3174
+ const u = l[h];
3175
+ let d = [...l];
3176
+ d.splice(h, 1), d.splice(c, 0, u), this._updateSheetRefStates(d), this._calculation._replaceSheetSpans?.(l.map((e) => e.sheet.getId()), d.map((e) => e.sheet.getId()), u.sheet.getId()), this._adjustSheetNamesIfRequired(), this._sheetOnIndexChange.forEach((e, t) => {
3177
+ t >= h && t <= c && e();
3178
+ }), this._tellSheets(), this._emitter.notify("onSheetsChange"), i = u.sheet, this._recordActiveSheet(o, a, this.getView().getActiveSheetId()), o.commit(r);
3179
+ } catch (e) {
3180
+ throw o.rollback(), e;
3181
+ }
3182
+ return i;
3183
+ }
3184
+ _setSelectedSheet(e) {
3185
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
3186
+ const t = this._getSheetRef(e);
3187
+ if (!t) throw new m(as(e));
3188
+ let s = null;
3189
+ return t.visibility !== Ge.Visibility.Visible && this._setSheetVisibility(t, Ge.Visibility.Visible), this._view.setActiveSheetId(t.id), s = t.sheet, s;
3190
+ }
3191
+ getProtection() {
3192
+ return this._protection;
3193
+ }
3194
+ getProperties() {
3195
+ return this._documentProperties;
3196
+ }
3197
+ getCodeName() {
3198
+ return this._codeName;
3199
+ }
3200
+ getNames() {
3201
+ return this._names;
3202
+ }
3203
+ getCalculation() {
3204
+ return this._calculation;
3205
+ }
3206
+ getFonts() {
3207
+ return re.getShared();
3208
+ }
3209
+ createFormula(e, t, s) {
3210
+ return this.getCalculation().createFormula(e, t, s);
3211
+ }
3212
+ evaluate(e, t) {
3213
+ return this.getCalculation().evaluate(e, t);
3214
+ }
3215
+ async whenCalculationReady() {
3216
+ const e = this._starting;
3217
+ return e ? e.then(() => this.getCalculation().ready()) : this.getCalculation().ready();
3218
+ }
3219
+ whenFontsReady() {
3220
+ return this.getFonts().whenReady();
3221
+ }
3222
+ async whenReady() {
3223
+ await Promise.all([this.whenCalculationReady(), this.whenFontsReady()]);
3224
+ }
3225
+ getScripts() {
3226
+ return this._scripts || (this._scripts = this._createScripts()), this._scripts;
3227
+ }
3228
+ getModules() {
3229
+ return this.getScripts().getModules();
3230
+ }
3231
+ _notifyAllChange() {
3232
+ this._emitter.notify("onSheetsChange"), this._emitter.notify("onSelectedSheetChange"), this._emitter.notify("onViewChange");
3233
+ }
3234
+ addListeners(e, t) {
3235
+ return this._emitter.addListeners(e, t);
3236
+ }
3237
+ _sheetToWBEvent(e) {
3238
+ const t = this, s = (e) => {
3239
+ if (e.isInvalid()) return e;
3240
+ const s = e.getWorksheet().getName();
3241
+ if (e.isICellRanges) {
3242
+ const r = e.getCoords().map((e) => e.scope ? e : {
3243
+ ...e,
3244
+ scope: s
3245
+ });
3246
+ return t.getRanges(r);
3247
+ }
3248
+ const r = e.getCoords();
3249
+ return t.getRange(r.scope ? r : {
3250
+ ...r,
3251
+ scope: s
3252
+ });
3253
+ };
3254
+ return (t) => {
3255
+ e({
3256
+ getSource: () => s(t.getSource()),
3257
+ getRanges: () => {
3258
+ const e = t.getRanges();
3259
+ return e ? s(e) : null;
3260
+ },
3261
+ getPreviousAddress: () => t.getPreviousAddress(),
3262
+ getTrigger: () => t.getTrigger(),
3263
+ isUndo: () => t.isUndo(),
3264
+ getCommit: () => t.getCommit(),
3265
+ toString: () => `WorkbookRangeEvent: ('${t.getTrigger()}', ${s(t.getSource()).toString()})`,
3266
+ getTimeStamp: () => t.getTimeStamp()
3267
+ });
3268
+ };
3269
+ }
3270
+ _holdPivotCaches() {
3271
+ const e = this._pivotCaches;
3272
+ if (0 === e.length) return;
3273
+ const t = (e) => {
3274
+ const t = this._getSheetRef(e), s = t && vs(t) ? t.sheet : null;
3275
+ return s ? s._contentAddWatch(() => null) : null;
3276
+ };
3277
+ for (let s = 0; s < e.length; s++) e[s]._hold(t);
3278
+ }
3279
+ _fromJSON(e, t) {
3280
+ if (this._emitter.notify("onBeforeLoad", { params: e }), this._initState(), !e.sheets || 0 === e.sheets.length) throw new m(g("error.workbook.sheetOne"));
3281
+ e.theme && (this._theme = new Ce(e.theme), this._styles.setTheme(this._theme));
3282
+ const s = this._strings.beginPersist(), r = this._resources.beginPersist(), i = this._styles.beginPersist(), o = this._richValues.beginPersist();
3283
+ try {
3284
+ s.fromJSON(e.strings), r.fromJSON(e.resources), this._fetch.adopt(this._resources.getItems()), i.fromJSON(e.styles), o.fromJSON(e.richData, {
3285
+ resources: this._resources,
3286
+ strings: this._strings,
3287
+ fromResourceId: (e) => r.fromResourceId(e) ?? null
3288
+ }, e.richTypes), e.date1904 && (this._isDate1904 = !0), this._codeName = e.codeName ?? null, this._updateLinks = e.updateLinks ?? null, this._documentProperties.fromJSON(e.properties), e.locale && (this._locale = e.locale), e.localeOverrides && (this._localeOverrides = e.localeOverrides), e.view || (e.view = {});
3289
+ const n = [], a = e.pivotCaches;
3290
+ if (a) {
3291
+ const e = r.fromResourceId.bind(r);
3292
+ for (let t = 0; t < a.length; t++) {
3293
+ const s = a[t];
3294
+ s && "number" == typeof s.cacheId && n.push(new jt(s.cacheId, Oe.fromJSON(s.part, e)));
3295
+ }
3296
+ }
3297
+ this._pivotCaches = n, this._people.fromJSON(e.people);
3298
+ const l = e.sheets, h = l.length;
3299
+ let c = e.view.activeSheetId ?? null;
3300
+ null !== c && (c = Math.min(Math.max(0, c), h - 1));
3301
+ let u = null, d = null;
3302
+ this._isLoadingSheets = !0;
3303
+ for (let s = 0; s < h; s++) {
3304
+ const i = l[s], o = i.visibility || Ge.Visibility.Visible, n = s;
3305
+ d = n, o === Ge.Visibility.Visible ? null === u && (u = n) : null !== c && c === n && (c = null);
3306
+ try {
3307
+ const e = i.kind ?? Ge.Kind.Worksheet;
3308
+ if (e !== Ge.Kind.Worksheet) {
3309
+ const a = i.sheet, l = Oe.fromJSON(a?.part, r.fromResourceId.bind(r));
3310
+ if (!l) throw new m(g("error.workbook.sheetPartMissing", { sheetName: i.name }));
3311
+ this._createOpaqueSheet(n, i.name, o, s, i.sheetId, e, l, a?.tabColor ?? null, t?.[s]);
3312
+ } else this._createSheet(n, i.name, o, s, i.sheetId, i.sheet, t?.[s]);
3313
+ } catch (e) {
3314
+ throw this._isLoadingSheets = !1, e;
3315
+ }
3316
+ }
3317
+ this._isLoadingSheets = !1, this._tellSheets(), this._holdPivotCaches(), this._updateState({ lastId: d }), e.view.activeSheetId = c ?? u, this.setView(new ts({ json: e.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
3318
+ const _ = this;
3319
+ this._protection = new rs(e?.protection, this._options?.readonly), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
3320
+ _._emitter.notify("onProtectionChange", { source: e });
3321
+ } }), this._emitter.notify("onLoad");
3322
+ } finally {
3323
+ o.endPersist(), i.endPersist(), r.endPersist(), s.endPersist();
3324
+ }
3325
+ }
3326
+ async _startFunctions() {
3327
+ const e = this._scripts;
3328
+ if (!e) return c.EmptyArray;
3329
+ await e._load();
3330
+ const t = [];
3331
+ for (const s of e.getModules().getItems()) this._startModules.add(s), t.push(...s.getFunctions().getItems({
3332
+ type: "formula",
3333
+ includeHidden: !0
3334
+ }));
3335
+ return t;
3336
+ }
3337
+ _createScripts(e) {
3338
+ const t = this;
3339
+ return new zt({
3340
+ transactions: this._transactions,
3341
+ json: e,
3342
+ workbook: t,
3343
+ getBuiltInFunctions: () => t._calculation?.getFunctions(),
3344
+ onAdd: (e, s) => {
3345
+ const r = t._calculation;
3346
+ r.getStatus() !== Me.Status.Off && r.start().then(async () => {
3347
+ if (t._startModules.has(s)) return;
3348
+ const e = s.getFunctions().getItems({
3349
+ type: "formula",
3350
+ includeHidden: !0
3351
+ }), r = e.length;
3352
+ for (let t = 0; t < r; t++) {
3353
+ const s = e[t];
3354
+ try {
3355
+ await this._calculation.getFunctions().add(s);
3356
+ } catch (e) {
3357
+ i.error(e?.message ?? String(e), e);
3358
+ }
3359
+ }
3360
+ }).catch(() => {});
3361
+ },
3362
+ onRemove: (e, t) => {}
3363
+ });
3364
+ }
3365
+ async toJSON(e) {
3366
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
3367
+ await Promise.resolve(this._starting);
3368
+ const t = this.getCalculation();
3369
+ t.getStatus() !== Me.Status.Off && (await t.ready(), await t._whenRequestsSettled?.()), await this._emitter.notify("onBeforeSave", { async: !0 });
3370
+ const s = { sheets: [] }, r = e?.ignoreStyles ?? !1;
3371
+ if (!r) {
3372
+ const e = this._theme.toJSON();
3373
+ (e ? Object.keys(e).length : 0) > 0 && (s.theme = e);
3374
+ }
3375
+ if (this._scripts) {
3376
+ const e = this._scripts.toJSON();
3377
+ e && Object.keys(e).length > 0 && (s.modules = e);
3378
+ }
3379
+ this._isDate1904 && (s.date1904 = !0), this._codeName && (s.codeName = this._codeName), this._updateLinks && (s.updateLinks = this._updateLinks);
3380
+ const i = this._documentProperties.toJSON();
3381
+ Object.keys(i).length > 0 && (s.properties = i), this._locale && (s.locale = this._locale), this._localeOverrides && (s.localeOverrides = this._localeOverrides);
3382
+ const o = e?.resources ?? "embed", n = "ignore" === o, a = this._strings.beginPersist(), l = n ? null : this._resources.beginPersist(), h = this._styles.beginPersist(), c = this._richValues.beginPersist();
3383
+ try {
3384
+ const t = this._getSheetRef(this.getSelectedSheetIndex()).id;
3385
+ let i = t, u = null;
3386
+ const d = this._getState(), g = d.sheetRefsAll, m = d.sheetsById, _ = g.length;
3387
+ for (let r = 0; r < _; r++) {
3388
+ const o = g[r], n = r + 1;
3389
+ let a;
3390
+ const h = m.get(o.id);
3391
+ if (vs(o)) a = {
3392
+ name: o.name,
3393
+ sheet: await o.sheet.toJSON(e)
3394
+ };
3395
+ else {
3396
+ const e = h, t = l ? l.toResourceId.bind(l) : () => null, s = { part: Oe.toJSON(e._getPart(), t) }, r = e.getTabColor();
3397
+ r && (s.tabColor = r.toString()), a = {
3398
+ name: o.name,
3399
+ kind: e.getKind(),
3400
+ sheet: s
3401
+ };
3402
+ }
3403
+ void 0 !== o.sheetId && (a.sheetId = o.sheetId), o.visibility === Ge.Visibility.Visible ? null === u && (u = n) : a.visibility = o.visibility, o.id === t && (i = n), s.sheets.push(a);
3404
+ }
3405
+ if (!r) {
3406
+ const e = h.toJSON();
3407
+ e && Object.keys(e).length > 0 && (s.styles = e);
3408
+ }
3409
+ const f = this.getProtection().toJSON();
3410
+ f && (s.protection = f);
3411
+ const p = this._calculation.toJSON();
3412
+ Object.keys(p).length > 0 && (s.calc = p);
3413
+ const w = await a.toJSONAsync();
3414
+ w && w.length > 0 && (s.strings = w);
3415
+ const y = await c.toJSONAsync(l ? l.toResourceId.bind(l) : void 0);
3416
+ if (y.length > 0) {
3417
+ s.richData = y;
3418
+ const e = c.toKindsJSON();
3419
+ e.length > 0 && (s.richTypes = e);
3420
+ }
3421
+ const b = this._calculation.getExternalBooks().toJSON();
3422
+ b && (s.externalBooks = b);
3423
+ const S = this._pivotCaches;
3424
+ if (S.length > 0) {
3425
+ const e = l ? l.toResourceId.bind(l) : () => null, t = /* @__PURE__ */ new Set();
3426
+ for (const e of this.getPivotTables()) t.add(e.getCacheId());
3427
+ const r = [];
3428
+ for (let s = 0; s < S.length; s++) t.has(S[s].cacheId) && r.push(S[s].toJSON(e));
3429
+ r.length > 0 && (s.pivotCaches = r);
3430
+ }
3431
+ const k = this._people.toJSON();
3432
+ if (k && (s.people = k), !n) {
3433
+ const e = await l.toJSONAsync("function" == typeof o ? o : void 0);
3434
+ e && e.length > 0 && (s.resources = e);
3435
+ }
3436
+ const C = this._calculation.getNamedFormulas().toJSON();
3437
+ C && C.length > 0 && (s.names = C);
3438
+ const v = this._view.toJSON();
3439
+ v && (i !== u ? v.activeSheetId = i : delete v.activeSheetId, Object.keys(v).length > 0 && (s.view = v));
3440
+ } finally {
3441
+ c.endPersist(), h.endPersist(), n || l.endPersist(), a.endPersist();
3442
+ }
3443
+ return this._emitter.notify("onSave", { params: s }), s;
3444
+ }
3445
+ isClosed() {
3446
+ return this._closed;
3447
+ }
3448
+ close() {
3449
+ if (this._closed) return;
3450
+ this._emitter.notify("onClose");
3451
+ const e = this._getState();
3452
+ e.listenersSheets.forEach((e) => {
3453
+ e();
3454
+ }), e.listenersSheets.clear();
3455
+ const t = e.sheetRefsAll;
3456
+ for (let s = t.length - 1; s >= 0; s--) try {
3457
+ t[s].sheet.close();
3458
+ } catch (e) {
3459
+ console.warn("error on close", e);
3460
+ }
3461
+ this._ownResources, this._ownNames && this._names.close(), this._ownCalculation && this._calculation.close(), this._ownStyles, this._transactionsRemoveListener?.(), this._listenerLanguage?.(), this._listenerOrigin?.(), this._listenerOriginProvider?.(), this._ownOriginProvider && this._originProvider instanceof ct && this._originProvider.release(), this._closed = !0;
3462
+ }
3463
+ beginCommit(e) {
3464
+ if (this._closed) throw new Error(g("error.workbook.modelClosed"));
3465
+ return this._beginCommit("string" == typeof e ? { description: e } : e);
3466
+ }
3467
+ doBatch(e, t) {
3468
+ const s = this;
3469
+ t = "string" == typeof t ? { description: t } : {
3470
+ description: _("op.updateWorkbook"),
3471
+ ...t
3472
+ };
3473
+ const r = w.bind(this._transactions, this, e);
3474
+ return this._transactions.doBatch(r.callback, {
3475
+ ...t,
3476
+ onChildCommit: r.onChildCommit
3477
+ }, (e, t) => {
3478
+ r.close(), 0 === e.getDepth() && (s._lastTransactionUUID = e.getId());
3479
+ });
3480
+ }
3481
+ _beginCommit(e) {
3482
+ const t = this;
3483
+ return this._transactions.beginCommit("string" == typeof e ? { description: e } : e, (e) => {
3484
+ 0 === e.getDepth() && (t._lastTransactionUUID = e.getId());
3485
+ });
3486
+ }
3487
+ _getState() {
3488
+ return this._transactions.getState(this._id);
3489
+ }
3490
+ _updateState(e, t = _("op.updateWorkbook"), s) {
3491
+ if (!e) return;
3492
+ const r = this._beginCommit(t);
3493
+ try {
3494
+ r.updateState(this._id, e), r.commit(s);
3495
+ } catch (e) {
3496
+ throw r.rollback(), e;
3497
+ }
3498
+ }
3499
+ get options() {
3500
+ return this._options;
3501
+ }
3502
+ get [Symbol.toStringTag]() {
3503
+ return "[Workbook]";
3504
+ }
3505
+ toString() {
3506
+ return `[${this.getName() ?? "(untitled)"}]`;
3507
+ }
3508
+ get isIWorkbook() {
3509
+ return !0;
3510
+ }
3511
+ }, Cs = { address: null }, vs = (e) => e.sheet.getKind() === Ge.Kind.Worksheet, Is = class {
3512
+ constructor() {
3513
+ this._readFormats = [], this._writeFormats = [], this._encryptions = [];
3514
+ }
3515
+ async registerReadFormat(e) {
3516
+ this._readFormats = await this._registerFormatType(e, this._readFormats);
3517
+ }
3518
+ async registerWriteFormat(e) {
3519
+ this._writeFormats = await this._registerFormatType(e, this._writeFormats);
3520
+ }
3521
+ async registerEncryption(e) {
3522
+ if (!e) throw new Error("encryption must be provided.");
3523
+ if (!e.key) throw new Error("encryption.key must be provided.");
3524
+ const t = e.key.toLowerCase(), s = this._encryptions.findIndex((e) => e.key.toLowerCase() === t);
3525
+ if (-1 !== s) {
3526
+ const t = [...this._encryptions];
3527
+ t[s] = e, this._encryptions = Object.freeze(t);
3528
+ return;
3529
+ }
3530
+ this._encryptions = Object.freeze([...this._encryptions, e]);
3531
+ }
3532
+ async getEncryption(e) {
3533
+ return this.peekEncryption(e);
3534
+ }
3535
+ peekEncryption(e) {
3536
+ if (!e) return this._encryptions[0] ?? null;
3537
+ const t = e.toLowerCase();
3538
+ return this._encryptions.find((e) => e.key.toLowerCase() === t) ?? null;
3539
+ }
3540
+ async detectEncryption(e) {
3541
+ for (const t of this._encryptions) if (await t.detect(e)) return t;
3542
+ return null;
3543
+ }
3544
+ async getReadFormats(e) {
3545
+ return e ? this._filterFormats(e, this._readFormats) : [...this._readFormats];
3546
+ }
3547
+ async getWriteFormats(e) {
3548
+ return this._writeFormats ? e ? this._filterFormats(e, this._writeFormats) : [...this._writeFormats] : [];
3549
+ }
3550
+ async _registerFormatType(e, t) {
3551
+ return this._registerFormatTypeSync(e, t);
3552
+ }
3553
+ _registerFormatTypeSync(e, t) {
3554
+ if (!e) throw new Error("format must be provided.");
3555
+ if (!e.key) throw new Error("format.key must be provided.");
3556
+ const s = e.key.toLowerCase(), r = t.findIndex((e) => e.key.toLowerCase() === s);
3557
+ if (-1 !== r) {
3558
+ const s = [...t];
3559
+ return s[r] = e, Object.freeze(s);
3560
+ }
3561
+ return Object.freeze([...t, e]);
3562
+ }
3563
+ _filterFormats(e, t, s) {
3564
+ if (!e || 0 === Object.keys(e).length) {
3565
+ if (!s) return [...t];
3566
+ e = { ext: s };
3567
+ }
3568
+ const r = e.search?.toLocaleLowerCase();
3569
+ return t.filter((t) => {
3570
+ if (r) {
3571
+ const e = t.key.toLocaleLowerCase().includes(r), s = !!t.exts && t.exts.some((e) => e.toLocaleLowerCase().includes(r)), i = !!t.mimeType && t.mimeType.toLocaleLowerCase().includes(r), o = !!t.tags && t.tags.some((e) => e.toLocaleLowerCase().includes(r)), n = !!t.description && t.description.toLocaleLowerCase().includes(r);
3572
+ if (!(e || s || i || o || n)) return !1;
3573
+ }
3574
+ const i = e.ext || s;
3575
+ if (i) {
3576
+ const e = i.toLocaleLowerCase();
3577
+ if (!t.exts.some((t) => t.toLocaleLowerCase() === e)) return !1;
3578
+ }
3579
+ if (e.mimeType && t.mimeType !== e.mimeType) return !1;
3580
+ if (e.key && t.key.toLocaleLowerCase() !== e.key.toLocaleLowerCase()) return !1;
3581
+ if (e.tags) {
3582
+ const s = t.tags || [];
3583
+ if (!("string" == typeof e.tags ? [e.tags] : e.tags).every((e) => s.includes(e))) return !1;
3584
+ }
3585
+ return !0;
3586
+ });
3587
+ }
3588
+ }, Ns = /* @__PURE__ */ new WeakMap(), Os = (e) => !!e && "object" == typeof e && "function" == typeof e.getPath && "function" == typeof e.canWrite, Rs = class {
3589
+ constructor() {
3590
+ this._setInstalled = /* @__PURE__ */ new WeakSet(), this._backingStore = null, this._emitter = new y(this), this._registry = new Is(), this._defaultStore = new dt(() => this.getWriteFormats(), () => this.getReadFormats());
3591
+ }
3592
+ getBackingStore() {
3593
+ return this._backingStore ?? this._defaultStore;
3594
+ }
3595
+ setBackingStore(e) {
3596
+ this._backingStore = e ?? null;
3597
+ }
3598
+ canWrite() {
3599
+ return "function" == typeof this.getBackingStore().write;
3600
+ }
3601
+ canRead() {
3602
+ return "function" == typeof this.getBackingStore().read;
3603
+ }
3604
+ async install(e) {
3605
+ this._setInstalled.has(e) || (await e.register(this._registry), this._setInstalled.add(e));
3606
+ }
3607
+ addListeners(e, t) {
3608
+ return this._emitter.addListeners(e, t);
3609
+ }
3610
+ addCommitListener(e) {
3611
+ return this._emitter.addListeners({ onWrite: (t, s) => {
3612
+ s.save && e.onCommit?.({
3613
+ store: s.workbook.getTransactions(),
3614
+ commitId: s.commitId
3615
+ });
3616
+ } });
3617
+ }
3618
+ async getReadFormats(e) {
3619
+ return this._registry.getReadFormats(e);
3620
+ }
3621
+ async getWriteFormats(e) {
3622
+ return this._registry.getWriteFormats(e);
3623
+ }
3624
+ getOrigin(e) {
3625
+ return new nt(e);
3626
+ }
3627
+ async read(e) {
3628
+ let t = null;
3629
+ if ("string" == typeof e) e = { source: e };
3630
+ else if (Os(e)) {
3631
+ const s = e.getPath();
3632
+ if (!s) throw new Error("Cannot read from an unbound origin (no path).");
3633
+ ht(e) ? e = {
3634
+ source: s,
3635
+ asCopy: !0
3636
+ } : (t = e, e = { source: s });
3637
+ }
3638
+ const s = e ?? {}, { source: r = null, ...i } = s, o = this.getBackingStore();
3639
+ return (o.read ? o : this._defaultStore).read({
3640
+ source: r,
3641
+ options: i,
3642
+ decode: (e, r) => this._decodeBuffer(e, r, s, t)
3643
+ });
3644
+ }
3645
+ async _decodeBuffer(e, t = {}, s, r = null) {
3646
+ const i = t.format, o = t.ext;
3647
+ if (!i && !o) throw new Error("Either format or file extension must be provided to determine read type.");
3648
+ const n = (await this._registry.getReadFormats({
3649
+ search: i,
3650
+ ext: o
3651
+ }))[0];
3652
+ if (!n) throw new m(g("error.io.readFormatUnavailable", { format: i ?? o }));
3653
+ const a = s?.typedCreateWorkbookOptions, l = a ? Object.keys(a).find((e) => e.toLowerCase() === n.key.toLowerCase()) : void 0;
3654
+ let h = {
3655
+ ...s,
3656
+ ...void 0 !== l ? a[l] : void 0
3657
+ };
3658
+ delete h.typedCreateWorkbookOptions, delete h.source, delete h.asCopy;
3659
+ const c = r ?? new nt(t.absolutePath ?? null, {
3660
+ name: t.name ?? null,
3661
+ format: n.key,
3662
+ size: t.size ?? null,
3663
+ lastModified: t.lastModified ?? null,
3664
+ canWrite: t.canWrite ?? !1
3665
+ });
3666
+ r instanceof nt && r.update({
3667
+ format: n.key,
3668
+ size: t.size ?? null,
3669
+ lastModified: t.lastModified ?? null
3670
+ }), h.createWorkbookOptions = {
3671
+ ...h.createWorkbookOptions || {},
3672
+ origin: c
3673
+ }, void 0 !== h.readonly && (h.createWorkbookOptions = {
3674
+ readonly: h.readonly,
3675
+ ...h.createWorkbookOptions
3676
+ }, delete h.readonly), h.calcOnly && (h.createWorkbookOptions = {
3677
+ disableLoadAutoFit: !0,
3678
+ ...h.createWorkbookOptions
3679
+ });
3680
+ const u = await this._decrypt(e, c, h);
3681
+ if (null === u) return null;
3682
+ e = u.bytes;
3683
+ const d = h?.progress?.onStart?.bind(h.progress);
3684
+ d && await Promise.resolve(d(c, t.size));
3685
+ try {
3686
+ const t = await this._readArrayBuffer(e, n, h);
3687
+ return null !== u.password && c.setPassword(u.password), h?.progress?.onComplete?.(c), this._emitter.notify("onRead", {
3688
+ params: {
3689
+ workbook: t,
3690
+ origin: c
3691
+ },
3692
+ transactional: !1
3693
+ }), t;
3694
+ } catch (e) {
3695
+ throw h?.progress?.onError?.(e), h?.progress?.onComplete?.(null), e;
3696
+ }
3697
+ }
3698
+ async _decrypt(e, t, r) {
3699
+ const i = await this._registry.detectEncryption(e);
3700
+ if (t instanceof nt && t.update({ encryption: i ? i.key : null }), !i) return {
3701
+ bytes: e,
3702
+ password: null
3703
+ };
3704
+ let o = null;
3705
+ const n = async (t) => {
3706
+ try {
3707
+ return o = await i.decode(e, t), !0;
3708
+ } catch (e) {
3709
+ if (!(e instanceof s)) throw e;
3710
+ return !1;
3711
+ }
3712
+ };
3713
+ if (r?.password && await n(r.password)) return {
3714
+ bytes: o,
3715
+ password: r.password
3716
+ };
3717
+ if (!r?.onPassword) {
3718
+ const e = t.getName();
3719
+ throw new l(e ? g("error.io.passwordRequired", { name: e }) : g("error.io.passwordRequiredUnnamed"));
3720
+ }
3721
+ const a = await Promise.resolve(r.onPassword({
3722
+ origin: t,
3723
+ encryption: i.key,
3724
+ validate: n
3725
+ }));
3726
+ if (null == a) return null;
3727
+ if (null !== o) return {
3728
+ bytes: o,
3729
+ password: a
3730
+ };
3731
+ if (await n(a)) return {
3732
+ bytes: o,
3733
+ password: a
3734
+ };
3735
+ throw new s(g("error.io.passwordIncorrect"));
3736
+ }
3737
+ async writeArrayBuffer(e, t) {
3738
+ if (!t?.format) throw new Error("A format must be specified to write to an ArrayBuffer (e.g. { format: 'xlsx' }).");
3739
+ const s = (await this._registry.getWriteFormats({ search: t.format }))[0];
3740
+ if (!s) throw new m(g("error.io.writeFormatUnavailable", { format: t.format }));
3741
+ return this._writeArrayBuffer(e, s, t);
3742
+ }
3743
+ async write(e, t, s) {
3744
+ return "string" == typeof t || Os(t) ? this._write(e, t, !1, s) : this._write(e, e?.getOrigin?.(), !0, t ?? s);
3745
+ }
3746
+ async writeAs(e, t, s) {
3747
+ if (!t) throw new Error("A target must be provided for writeAs (use write(workbook) for a plain save).");
3748
+ return this._write(e, t, !0, s);
3749
+ }
3750
+ async _write(e, t, s, r) {
3751
+ if (!e) throw new Error("Workbook must be provided.");
3752
+ if (!e.isIWorkbook) throw new Error("Invalid workbook model provided. Must be an instance of IWorkbook.");
3753
+ let i = "string" == typeof t ? this.getOrigin(t) : t;
3754
+ const o = i.getFormat();
3755
+ let n;
3756
+ if ((r?.format || o) && (n = (await this._registry.getWriteFormats({ search: r?.format ?? o ?? void 0 }))[0]), n || i.getPath() && i.canWrite() && i.getExtension() || (n = (await this._registry.getWriteFormats({ ext: "sxl" }))[0] ?? (await this._registry.getWriteFormats())[0]), !n) throw new m(g("error.io.writeFormatUnresolved"));
3757
+ const a = i.getExtension();
3758
+ if (r?.format && a && i.getPath() && i.canWrite() && !n.exts.includes(a)) {
3759
+ const e = (await this._registry.getWriteFormats({ ext: a }))[0];
3760
+ if (e && e.key !== n.key) {
3761
+ const e = i.getPath().split(/[/\\]/).pop();
3762
+ throw new m(g("error.io.writeFormatMismatch", {
3763
+ format: r.format,
3764
+ file: e
3765
+ }));
3766
+ }
3767
+ }
3768
+ if ("string" == typeof t) {
3769
+ const e = i.getPath();
3770
+ i = new nt(Ke(e) ? e : `${e}.${n.exts[0]}`, { format: n.key });
3771
+ }
3772
+ const h = i.getEncryption(), c = e.getOrigin?.(), u = (i instanceof nt ? i.getPassword() : null) ?? (c instanceof nt ? c.getPassword() : null), d = i.isEncrypted() || (c?.isEncrypted() ?? !1), _ = void 0 !== r?.password ? r.password : u ?? (d ? void 0 : null);
3773
+ let f = null;
3774
+ if (void 0 === _) {
3775
+ if (d) {
3776
+ const e = i.getName();
3777
+ throw new l(e ? g("error.io.passwordRequiredSave", { name: e }) : g("error.io.passwordRequiredSaveUnnamed"));
3778
+ }
3779
+ } else if (null !== _ && (f = await this._registry.getEncryption(h), !f)) throw new m(g("error.io.encryptionUnavailable"));
3780
+ const p = `${i.getName() ?? g("workbook.defaultName")}.${n.exts[0]}`, w = r?.progress, y = !i.getPath() || !i.canWrite() || !!r?.prompt;
3781
+ let b = !1;
3782
+ const S = this;
3783
+ let k = null, C = [];
3784
+ const v = {
3785
+ workbook: e,
3786
+ format: n,
3787
+ origin: i,
3788
+ suggestedName: p,
3789
+ prompt: r?.prompt,
3790
+ async encode(t, o) {
3791
+ const a = o ?? i;
3792
+ await (async (e) => {
3793
+ b || (b = !0, w?.onStart && await Promise.resolve(w.onStart(e)));
3794
+ })(a), k = e.getTransactions?.()?.getCurrentCommit() ?? k;
3795
+ const l = t ? (await S._registry.getWriteFormats({ search: t }))[0] ?? n : n, h = [], c = ((e, t) => ({
3796
+ onStart: e?.onStart ? (t, s) => e.onStart(t, s) : void 0,
3797
+ onProgress: e?.onProgress ? (t, s) => e.onProgress(t, s) : void 0,
3798
+ onError: e?.onError ? (t) => e.onError(t) : void 0,
3799
+ onComplete: e?.onComplete ? (t) => e.onComplete(t) : void 0,
3800
+ onWarning: (s, r) => {
3801
+ t.push({
3802
+ message: s ?? "",
3803
+ context: r
3804
+ }), e?.onWarning?.(s, r);
3805
+ }
3806
+ }))(w, h), u = await S._writeArrayBuffer(e, l, {
3807
+ ...r,
3808
+ progress: c
3809
+ }), d = Ns.get(a);
3810
+ if (h.some((e) => !d?.has(e.message)) && r?.onWarnings) {
3811
+ const t = await Promise.resolve(r.onWarnings({
3812
+ workbook: e,
3813
+ origin: a,
3814
+ warnings: h,
3815
+ save: s,
3816
+ canCancel: !y
3817
+ }));
3818
+ if (!y && !1 === t) return null;
3819
+ }
3820
+ return C = h, f ? f.encode(u, _) : u;
3821
+ }
3822
+ };
3823
+ let I = null;
3824
+ try {
3825
+ const t = this.getBackingStore();
3826
+ if (!t.write) throw new Error("The active backing store is read-only (no write implementation).");
3827
+ if (I = await t.write(v), I) {
3828
+ if (void 0 !== _ && I instanceof nt && (I.setPassword(_), I.update({ encryption: f ? f.key : null })), C.length) {
3829
+ const e = Ns.get(I) ?? /* @__PURE__ */ new Set();
3830
+ for (const t of C) e.add(t.message);
3831
+ Ns.set(I, e);
3832
+ }
3833
+ s && I !== e.getOrigin() && ht(e.getOrigin())?.setOrigin(I);
3834
+ const t = k ?? e.getTransactions?.()?.getCurrentCommit() ?? null;
3835
+ this._emitter.notify("onWrite", {
3836
+ params: {
3837
+ workbook: e,
3838
+ origin: I,
3839
+ commitId: t?.getId() ?? null,
3840
+ save: s
3841
+ },
3842
+ transactional: !1
3843
+ });
3844
+ }
3845
+ w?.onComplete && await Promise.resolve(w.onComplete(I));
3846
+ } catch (e) {
3847
+ const t = e instanceof Error ? e : new Error(String(e));
3848
+ if (w?.onError && await Promise.resolve(w.onError(t)), w?.onComplete && await Promise.resolve(w.onComplete(null)), t instanceof m) throw t;
3849
+ throw new Error(g("error.io.writeFailed", { reason: t.message }), { cause: e });
3850
+ }
3851
+ return I;
3852
+ }
3853
+ _stripExtension(e) {
3854
+ const t = Ke(e);
3855
+ return t ? e.slice(0, e.length - t.length - 1) : e;
3856
+ }
3857
+ _baseName(e) {
3858
+ if (!e) return null;
3859
+ const t = e.split(/[?#]/)[0], s = t.split(/[/\\]/).pop() ?? t;
3860
+ return this._stripExtension(s) || null;
3861
+ }
3862
+ async _writeArrayBuffer(e, t, s) {
3863
+ if (!t) throw new Error("A write format must be provided.");
3864
+ const r = t.handler;
3865
+ if (!r) throw new Error(`Unable to resolve a write handler for '${t.key}'.`);
3866
+ return r(e, {
3867
+ ...s,
3868
+ format: t.key
3869
+ });
3870
+ }
3871
+ async _readArrayBuffer(e, t, s) {
3872
+ if (!e) throw new Error("ArrayBuffer must be specified.");
3873
+ if (!t) throw new Error("format must be specified.");
3874
+ if (0 === e.byteLength) return new ks(s?.createWorkbookOptions);
3875
+ const r = t.handler;
3876
+ if (!r) throw new Error(`Unable to resolve a read handler for '${t.key}'.`);
3877
+ let i;
3878
+ try {
3879
+ i = await r(e, s);
3880
+ } catch (e) {
3881
+ if (e instanceof m) throw e;
3882
+ throw new m(g("error.io.readFailed", {
3883
+ format: t.description ?? t.key,
3884
+ reason: e?.message ?? String(e)
3885
+ }), { cause: e });
3886
+ }
3887
+ return await oe(), i;
3888
+ }
3889
+ get isIWorkbookIO() {
3890
+ return !0;
3891
+ }
3892
+ }, xs = new Rs(), Es = class {
3893
+ constructor() {
3894
+ this._buffer = null, this._formatKey = null;
3895
+ }
3896
+ get buffer() {
3897
+ return this._buffer;
3898
+ }
3899
+ async write(e) {
3900
+ const t = await e.encode();
3901
+ return t ? (this._buffer = t, this._formatKey = e.format.key, e.origin) : null;
3902
+ }
3903
+ async read(e) {
3904
+ return this._buffer ? e.decode(this._buffer, { format: this._formatKey ?? void 0 }) : null;
3905
+ }
3906
+ }, Ls = "locales", As = "fonts", Vs = {
3907
+ suffix: ".msg.json",
3908
+ async extract(e) {
3909
+ const t = e.relPath.split("/");
3910
+ return 2 === t.length ? {
3911
+ locale: t[0],
3912
+ role: "messages"
3913
+ } : null;
3914
+ },
3915
+ place: (e, t) => t ? `${t}/${e}` : null
3916
+ }, Ts = [
3917
+ ".woff2",
3918
+ ".woff",
3919
+ ".ttf",
3920
+ ".otf",
3921
+ ".ttc",
3922
+ ".otc"
3923
+ ].map((e) => ({
3924
+ suffix: e,
3925
+ place: (e, t) => t ? `${t}/${e}` : e
3926
+ })), Ps = {
3927
+ suffix: ".metrics.json",
3928
+ async extract(e) {
3929
+ const t = await e.readJson();
3930
+ return "sheetxl-font-metrics/1" === t?.format ? {
3931
+ family: t.family,
3932
+ weight: t.weight,
3933
+ italic: t.italic
3934
+ } : null;
3935
+ },
3936
+ place: (e, t) => t ? `${t}/${e}` : e
3937
+ }, Fs = [{
3938
+ kind: Ls,
3939
+ files: [Vs]
3940
+ }, {
3941
+ kind: As,
3942
+ files: [
3943
+ Ps,
3944
+ {
3945
+ suffix: ".hinted.json",
3946
+ async extract(e) {
3947
+ const t = await e.readJson();
3948
+ return "sheetxl-font-hinting/1" === t?.format ? {
3949
+ family: t.family,
3950
+ weight: t.weight,
3951
+ italic: t.italic,
3952
+ hinted: !0
3953
+ } : null;
3954
+ },
3955
+ place: Ps.place
3956
+ },
3957
+ {
3958
+ suffix: ".rows.json",
3959
+ async extract(e) {
3960
+ const t = await e.readJson();
3961
+ return "sheetxl-font-rows/1" === t?.format ? {
3962
+ family: t.family,
3963
+ weight: t.weight,
3964
+ italic: t.italic,
3965
+ rows: !0
3966
+ } : null;
3967
+ },
3968
+ place: Ps.place
3969
+ },
3970
+ ...Ts
3971
+ ]
3972
+ }];
3973
+ async function Ws(e, t) {
3974
+ const { Chart: s } = await import("./DsCI_ZYm_jDjXF3J.js");
3975
+ return new s({
3976
+ json: e,
3977
+ getStyles: t?.getStyles
3978
+ });
3979
+ }
3980
+ us || (us = {});
3981
+ var Bs, js, Ms, Ds = null;
3982
+ function zs() {
3983
+ if (!Ds) {
3984
+ const e = import("./BbcUxIZe3YXywsQR.js").then((e) => e.loadScriptingDeclarations());
3985
+ e.catch(() => {
3986
+ Ds = null;
3987
+ }), Ds = e;
3988
+ }
3989
+ return Ds;
3990
+ }
3991
+ var Hs = null;
3992
+ function Js() {
3993
+ if (!Hs) {
3994
+ const e = import("./BbcUxIZe3YXywsQR.js").then((e) => e.loadScriptingApi()).then((e) => JSON.parse(e));
3995
+ e.catch(() => {
3996
+ Hs = null;
3997
+ }), Hs = e;
3998
+ }
3999
+ return Hs;
4000
+ }
4001
+ Bs || (Bs = {}), (js || (js = {})).Type = {
4002
+ Button: "button",
4003
+ CheckBox: "checkBox",
4004
+ OptionButton: "optionButton",
4005
+ ListBox: "listBox",
4006
+ DropDown: "dropDown",
4007
+ ScrollBar: "scrollBar",
4008
+ Spinner: "spinner",
4009
+ GroupBox: "groupBox",
4010
+ Label: "label",
4011
+ EditBox: "editBox",
4012
+ Dialog: "dialog",
4013
+ Unknown: "formControl"
4014
+ }, (Ms || (Ms = {})).DropStyle = {
4015
+ Combo: "combo",
4016
+ ComboEdit: "comboEdit",
4017
+ Simple: "simple"
4018
+ };
4019
+ var Us = class extends Re {
4020
+ constructor(e) {
4021
+ super(e);
4022
+ }
4023
+ _initializeOptions(e) {
4024
+ return e = {
4025
+ ...e,
4026
+ coords: {
4027
+ colStart: 0,
4028
+ rowStart: 0,
4029
+ colEnd: (e?.size?.width ?? 5) - 1,
4030
+ rowEnd: (e?.size?.height ?? 5) - 1
4031
+ },
4032
+ getRanges: (e) => new U(null)
4033
+ }, super._initializeOptions(e);
4034
+ }
4035
+ }, qs = "0.8.0-beta.15", $s = "2026-11-04T19:26:57.415Z";
4036
+ export { Js as A, Ms as C, zs as D, qs as E, mt as F, As as I, Ls as L, Tt as M, $s as N, Dt as O, ks as P, js as R, Bs as S, Lt as T, Rs as _, ts as a, Ws as b, ot as c, xs as d, Et as f, Ot as g, Nt as h, us as i, Fs as j, et as k, tt as l, Qt as m, Bt as n, gt as o, nt as p, st as r, ft as s, _t as t, pt as u, Us as v, Es as w, Zt as x, qt as y };