@allyhub/sdk 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/dist/define.d.ts +4 -0
  2. package/dist/define.js +1 -1
  3. package/dist/node_modules/@allyhub-next/audio/dist/node/index.d.ts +1 -1
  4. package/dist/node_modules/@allyhub-next/audio/dist/node/index.js +1 -1
  5. package/dist/node_modules/@allyhub-next/audio/dist/node/master.d.ts +4 -0
  6. package/dist/node_modules/@allyhub-next/audio/dist/node/master.js +1 -1
  7. package/dist/node_modules/@allyhub-next/audio/package.json +1 -1
  8. package/dist/node_modules/@allyhub-next/chart/dist/chart-xml.js +2 -2
  9. package/dist/node_modules/@allyhub-next/chart/dist/chart.d.ts +14 -5
  10. package/dist/node_modules/@allyhub-next/chart/dist/chart.js +1 -1
  11. package/dist/node_modules/@allyhub-next/chart/package.json +1 -1
  12. package/dist/node_modules/@allyhub-next/formats/dist/data/deck-code.d.ts +205 -0
  13. package/dist/node_modules/@allyhub-next/formats/dist/data/deck-code.js +2 -0
  14. package/dist/node_modules/@allyhub-next/formats/dist/data/script.d.ts +4 -1
  15. package/dist/node_modules/@allyhub-next/formats/dist/data/script.js +1 -1
  16. package/dist/node_modules/@allyhub-next/formats/dist/data/sheet.d.ts +69 -18
  17. package/dist/node_modules/@allyhub-next/formats/dist/data/sheet.js +1 -1
  18. package/dist/node_modules/@allyhub-next/formats/dist/data/slides.d.ts +847 -116
  19. package/dist/node_modules/@allyhub-next/formats/dist/data/slides.js +1 -1
  20. package/dist/node_modules/@allyhub-next/formats/dist/data/website.d.ts +20 -0
  21. package/dist/node_modules/@allyhub-next/formats/dist/data/website.js +2 -0
  22. package/dist/node_modules/@allyhub-next/formats/dist/index.d.ts +3 -0
  23. package/dist/node_modules/@allyhub-next/formats/dist/index.js +1 -1
  24. package/dist/node_modules/@allyhub-next/formats/dist/items.d.ts +1 -1
  25. package/dist/node_modules/@allyhub-next/formats/dist/items.js +1 -1
  26. package/dist/node_modules/@allyhub-next/formats/dist/media-type.d.ts +3 -0
  27. package/dist/node_modules/@allyhub-next/formats/dist/media-type.js +2 -0
  28. package/dist/node_modules/@allyhub-next/formats/dist/schemas.d.ts +501 -38
  29. package/dist/node_modules/@allyhub-next/formats/dist/schemas.js +1 -1
  30. package/dist/node_modules/@allyhub-next/formats/dist/strict.d.ts +2 -0
  31. package/dist/node_modules/@allyhub-next/formats/dist/strict.js +1 -1
  32. package/dist/node_modules/@allyhub-next/formats/package.json +2 -1
  33. package/dist/node_modules/@allyhub-next/ooxml/LICENSE +241 -0
  34. package/dist/node_modules/@allyhub-next/ooxml/dist/brightness.d.ts +31 -0
  35. package/dist/node_modules/@allyhub-next/ooxml/dist/brightness.js +2 -0
  36. package/dist/node_modules/@allyhub-next/ooxml/dist/color.d.ts +33 -0
  37. package/dist/node_modules/@allyhub-next/ooxml/dist/color.js +2 -0
  38. package/dist/node_modules/@allyhub-next/ooxml/dist/enums.d.ts +13 -0
  39. package/dist/node_modules/@allyhub-next/ooxml/dist/enums.js +2 -0
  40. package/dist/node_modules/@allyhub-next/ooxml/dist/ext.d.ts +79 -0
  41. package/dist/node_modules/@allyhub-next/ooxml/dist/ext.js +2 -0
  42. package/dist/node_modules/@allyhub-next/ooxml/dist/generated/enums.d.ts +132 -0
  43. package/dist/node_modules/@allyhub-next/ooxml/dist/generated/enums.js +2 -0
  44. package/dist/node_modules/@allyhub-next/ooxml/dist/generated/presets.d.ts +28 -0
  45. package/dist/node_modules/@allyhub-next/ooxml/dist/generated/presets.js +2 -0
  46. package/dist/node_modules/@allyhub-next/ooxml/dist/generated/spec.d.ts +4708 -0
  47. package/dist/node_modules/@allyhub-next/ooxml/dist/generated/spec.js +2 -0
  48. package/dist/node_modules/@allyhub-next/ooxml/dist/geometry/index.d.ts +57 -0
  49. package/dist/node_modules/@allyhub-next/ooxml/dist/geometry/index.js +2 -0
  50. package/dist/node_modules/@allyhub-next/ooxml/dist/index.d.ts +10 -0
  51. package/dist/node_modules/@allyhub-next/ooxml/dist/index.js +2 -0
  52. package/dist/node_modules/@allyhub-next/ooxml/dist/mce.d.ts +12 -0
  53. package/dist/node_modules/@allyhub-next/ooxml/dist/mce.js +2 -0
  54. package/dist/node_modules/@allyhub-next/ooxml/dist/node.d.ts +111 -0
  55. package/dist/node_modules/@allyhub-next/ooxml/dist/node.js +2 -0
  56. package/dist/node_modules/@allyhub-next/ooxml/dist/ns.d.ts +45 -0
  57. package/dist/node_modules/@allyhub-next/ooxml/dist/ns.js +2 -0
  58. package/dist/node_modules/@allyhub-next/ooxml/dist/opc.d.ts +48 -0
  59. package/dist/node_modules/@allyhub-next/ooxml/dist/opc.js +2 -0
  60. package/dist/node_modules/@allyhub-next/ooxml/dist/report.d.ts +45 -0
  61. package/dist/node_modules/@allyhub-next/ooxml/dist/report.js +2 -0
  62. package/dist/node_modules/@allyhub-next/ooxml/dist/xml.d.ts +28 -0
  63. package/dist/node_modules/@allyhub-next/ooxml/dist/xml.js +2 -0
  64. package/dist/node_modules/@allyhub-next/ooxml/package.json +26 -0
  65. package/dist/node_modules/@allyhub-next/protocol/dist/account.d.ts +338 -0
  66. package/dist/node_modules/@allyhub-next/protocol/dist/account.js +2 -0
  67. package/dist/node_modules/@allyhub-next/protocol/dist/auth.d.ts +12 -13
  68. package/dist/node_modules/@allyhub-next/protocol/dist/auth.js +1 -1
  69. package/dist/node_modules/@allyhub-next/protocol/dist/blobs.d.ts +35 -0
  70. package/dist/node_modules/@allyhub-next/protocol/dist/blobs.js +2 -0
  71. package/dist/node_modules/@allyhub-next/protocol/dist/cloud.d.ts +101 -32
  72. package/dist/node_modules/@allyhub-next/protocol/dist/cloud.js +1 -1
  73. package/dist/node_modules/@allyhub-next/protocol/dist/editor.d.ts +79 -5
  74. package/dist/node_modules/@allyhub-next/protocol/dist/editor.js +1 -1
  75. package/dist/node_modules/@allyhub-next/protocol/dist/files.d.ts +2 -2
  76. package/dist/node_modules/@allyhub-next/protocol/dist/index.d.ts +6 -0
  77. package/dist/node_modules/@allyhub-next/protocol/dist/index.js +1 -1
  78. package/dist/node_modules/@allyhub-next/protocol/dist/notes.d.ts +21 -0
  79. package/dist/node_modules/@allyhub-next/protocol/dist/notes.js +1 -1
  80. package/dist/node_modules/@allyhub-next/protocol/dist/open.d.ts +13 -0
  81. package/dist/node_modules/@allyhub-next/protocol/dist/open.js +2 -0
  82. package/dist/node_modules/@allyhub-next/protocol/dist/registry.d.ts +73 -59
  83. package/dist/node_modules/@allyhub-next/protocol/dist/registry.js +1 -1
  84. package/dist/node_modules/@allyhub-next/protocol/dist/routes.d.ts +1 -1
  85. package/dist/node_modules/@allyhub-next/protocol/dist/routes.js +1 -1
  86. package/dist/node_modules/@allyhub-next/protocol/dist/shares.d.ts +115 -0
  87. package/dist/node_modules/@allyhub-next/protocol/dist/shares.js +2 -0
  88. package/dist/node_modules/@allyhub-next/protocol/dist/sites.d.ts +293 -0
  89. package/dist/node_modules/@allyhub-next/protocol/dist/sites.js +2 -0
  90. package/dist/node_modules/@allyhub-next/protocol/dist/snapshots.d.ts +377 -0
  91. package/dist/node_modules/@allyhub-next/protocol/dist/snapshots.js +2 -0
  92. package/dist/node_modules/@allyhub-next/protocol/dist/teams.d.ts +27 -9
  93. package/dist/node_modules/@allyhub-next/protocol/dist/teams.js +1 -1
  94. package/dist/node_modules/@allyhub-next/protocol/dist/tools.d.ts +53 -14
  95. package/dist/node_modules/@allyhub-next/protocol/dist/tools.js +1 -1
  96. package/dist/node_modules/@allyhub-next/protocol/package.json +2 -1
  97. package/dist/node_modules/@allyhub-next/runtimes/package.json +1 -1
  98. package/dist/node_modules/@allyhub-next/runtimes/schemas/runtimes.schema.json +25 -5
  99. package/dist/node_modules/@allyhub-next/scenery/package.json +1 -1
  100. package/dist/node_modules/@allyhub-next/sheet/dist/calc/analyse.d.ts +9 -3
  101. package/dist/node_modules/@allyhub-next/sheet/dist/calc/analyse.js +1 -1
  102. package/dist/node_modules/@allyhub-next/sheet/dist/calc/coerce.d.ts +5 -1
  103. package/dist/node_modules/@allyhub-next/sheet/dist/calc/coerce.js +1 -1
  104. package/dist/node_modules/@allyhub-next/sheet/dist/calc/engine.d.ts +60 -13
  105. package/dist/node_modules/@allyhub-next/sheet/dist/calc/engine.js +1 -1
  106. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/aggregate.js +1 -1
  107. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/convert.d.ts +4 -0
  108. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/convert.js +2 -0
  109. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/criteria.js +1 -1
  110. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/database.js +1 -1
  111. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/date.js +1 -1
  112. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/define.d.ts +27 -1
  113. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/define.js +1 -1
  114. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/delimiters.d.ts +16 -0
  115. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/delimiters.js +2 -0
  116. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/dynamic.d.ts +18 -1
  117. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/dynamic.js +1 -1
  118. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/finance.js +1 -1
  119. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/index.d.ts +2 -0
  120. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/index.js +1 -1
  121. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/info.js +1 -1
  122. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/kernels.js +1 -1
  123. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/logical.js +1 -1
  124. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/lookup.js +1 -1
  125. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/maths.js +1 -1
  126. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/modern.d.ts +2 -0
  127. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/modern.js +2 -0
  128. package/dist/node_modules/@allyhub-next/sheet/dist/calc/functions/text.js +1 -1
  129. package/dist/node_modules/@allyhub-next/sheet/dist/calc/graph.d.ts +38 -0
  130. package/dist/node_modules/@allyhub-next/sheet/dist/calc/graph.js +2 -0
  131. package/dist/node_modules/@allyhub-next/sheet/dist/calc/indexes.d.ts +19 -0
  132. package/dist/node_modules/@allyhub-next/sheet/dist/calc/indexes.js +2 -0
  133. package/dist/node_modules/@allyhub-next/sheet/dist/calc/remote.d.ts +49 -0
  134. package/dist/node_modules/@allyhub-next/sheet/dist/calc/remote.js +2 -0
  135. package/dist/node_modules/@allyhub-next/sheet/dist/calc/server.d.ts +82 -0
  136. package/dist/node_modules/@allyhub-next/sheet/dist/calc/server.js +2 -0
  137. package/dist/node_modules/@allyhub-next/sheet/dist/calc/types.d.ts +6 -1
  138. package/dist/node_modules/@allyhub-next/sheet/dist/calc/types.js +1 -1
  139. package/dist/node_modules/@allyhub-next/sheet/dist/chart.js +1 -1
  140. package/dist/node_modules/@allyhub-next/sheet/dist/check.js +1 -1
  141. package/dist/node_modules/@allyhub-next/sheet/dist/diff.d.ts +15 -0
  142. package/dist/node_modules/@allyhub-next/sheet/dist/diff.js +1 -1
  143. package/dist/node_modules/@allyhub-next/sheet/dist/export.d.ts +29 -8
  144. package/dist/node_modules/@allyhub-next/sheet/dist/export.js +3 -4
  145. package/dist/node_modules/@allyhub-next/sheet/dist/file.js +2 -2
  146. package/dist/node_modules/@allyhub-next/sheet/dist/format.d.ts +8 -2
  147. package/dist/node_modules/@allyhub-next/sheet/dist/format.js +1 -1
  148. package/dist/node_modules/@allyhub-next/sheet/dist/html.d.ts +52 -4
  149. package/dist/node_modules/@allyhub-next/sheet/dist/html.js +43 -11
  150. package/dist/node_modules/@allyhub-next/sheet/dist/index.d.ts +7 -3
  151. package/dist/node_modules/@allyhub-next/sheet/dist/index.js +1 -1
  152. package/dist/node_modules/@allyhub-next/sheet/dist/inspect.js +1 -1
  153. package/dist/node_modules/@allyhub-next/sheet/dist/paginate.d.ts +98 -0
  154. package/dist/node_modules/@allyhub-next/sheet/dist/paginate.js +2 -0
  155. package/dist/node_modules/@allyhub-next/sheet/dist/structure.js +1 -1
  156. package/dist/node_modules/@allyhub-next/sheet/dist/table-style.d.ts +32 -0
  157. package/dist/node_modules/@allyhub-next/sheet/dist/table-style.js +2 -0
  158. package/dist/node_modules/@allyhub-next/sheet/dist/table-styles.d.ts +3 -0
  159. package/dist/node_modules/@allyhub-next/sheet/dist/table-styles.js +2 -0
  160. package/dist/node_modules/@allyhub-next/sheet/dist/values.js +1 -1
  161. package/dist/node_modules/@allyhub-next/sheet/dist/workbook.d.ts +10 -1
  162. package/dist/node_modules/@allyhub-next/sheet/dist/workbook.js +1 -1
  163. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/charts.d.ts +10 -1
  164. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/charts.js +1 -1
  165. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/formula.d.ts +14 -4
  166. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/formula.js +2 -2
  167. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/functions.d.ts +11 -1
  168. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/functions.js +36 -16
  169. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/import.d.ts +3 -1
  170. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/import.js +1 -1
  171. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/read.d.ts +42 -1
  172. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/read.js +2 -1
  173. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/sax.d.ts +23 -0
  174. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/sax.js +2 -0
  175. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/styles.d.ts +2 -0
  176. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/styles.js +1 -1
  177. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/write.d.ts +6 -0
  178. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/write.js +1 -1
  179. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/zip.d.ts +40 -0
  180. package/dist/node_modules/@allyhub-next/sheet/dist/xlsx/zip.js +2 -0
  181. package/dist/node_modules/@allyhub-next/sheet/package.json +1 -1
  182. package/dist/node_modules/@allyhub-next/slides-core/dist/animation.js +1 -1
  183. package/dist/node_modules/@allyhub-next/slides-core/dist/api.d.ts +59 -39
  184. package/dist/node_modules/@allyhub-next/slides-core/dist/api.js +2 -2
  185. package/dist/node_modules/@allyhub-next/slides-core/dist/capabilities.js +1 -1
  186. package/dist/node_modules/@allyhub-next/slides-core/dist/chart-api.d.ts +27 -13
  187. package/dist/node_modules/@allyhub-next/slides-core/dist/chart-api.js +1 -1
  188. package/dist/node_modules/@allyhub-next/slides-core/dist/check.js +1 -1
  189. package/dist/node_modules/@allyhub-next/slides-core/dist/code.d.ts +33 -0
  190. package/dist/node_modules/@allyhub-next/slides-core/dist/code.js +2 -0
  191. package/dist/node_modules/@allyhub-next/slides-core/dist/components.d.ts +31 -0
  192. package/dist/node_modules/@allyhub-next/slides-core/dist/components.js +2 -0
  193. package/dist/node_modules/@allyhub-next/slides-core/dist/enums.d.ts +179 -16
  194. package/dist/node_modules/@allyhub-next/slides-core/dist/enums.js +1 -1
  195. package/dist/node_modules/@allyhub-next/slides-core/dist/file.d.ts +43 -21
  196. package/dist/node_modules/@allyhub-next/slides-core/dist/file.js +3 -3
  197. package/dist/node_modules/@allyhub-next/slides-core/dist/identity.d.ts +17 -0
  198. package/dist/node_modules/@allyhub-next/slides-core/dist/identity.js +2 -0
  199. package/dist/node_modules/@allyhub-next/slides-core/dist/index.d.ts +5 -1
  200. package/dist/node_modules/@allyhub-next/slides-core/dist/index.js +1 -1
  201. package/dist/node_modules/@allyhub-next/slides-core/dist/lang.d.ts +6 -0
  202. package/dist/node_modules/@allyhub-next/slides-core/dist/lang.js +2 -0
  203. package/dist/node_modules/@allyhub-next/slides-core/dist/measure.js +1 -1
  204. package/dist/node_modules/@allyhub-next/slides-core/dist/merge.d.ts +58 -0
  205. package/dist/node_modules/@allyhub-next/slides-core/dist/merge.js +2 -0
  206. package/dist/node_modules/@allyhub-next/slides-core/dist/model.d.ts +2 -4
  207. package/dist/node_modules/@allyhub-next/slides-core/dist/office.d.ts +17 -1
  208. package/dist/node_modules/@allyhub-next/slides-core/dist/office.js +1 -1
  209. package/dist/node_modules/@allyhub-next/slides-core/dist/resolve.d.ts +21 -5
  210. package/dist/node_modules/@allyhub-next/slides-core/dist/resolve.js +1 -1
  211. package/dist/node_modules/@allyhub-next/slides-core/dist/script.d.ts +18 -16
  212. package/dist/node_modules/@allyhub-next/slides-core/dist/script.js +2 -2
  213. package/dist/node_modules/@allyhub-next/slides-core/dist/stage.d.ts +51 -53
  214. package/dist/node_modules/@allyhub-next/slides-core/dist/strict.js +1 -1
  215. package/dist/node_modules/@allyhub-next/slides-core/dist/units.d.ts +27 -0
  216. package/dist/node_modules/@allyhub-next/slides-core/dist/units.js +1 -1
  217. package/dist/node_modules/@allyhub-next/slides-core/dist/values.d.ts +7 -0
  218. package/dist/node_modules/@allyhub-next/slides-core/dist/values.js +2 -0
  219. package/dist/node_modules/@allyhub-next/slides-core/package.json +1 -1
  220. package/dist/node_modules/@allyhub-next/video-core/dist/captions.js +6 -6
  221. package/dist/node_modules/@allyhub-next/video-core/dist/fact.d.ts +47 -8
  222. package/dist/node_modules/@allyhub-next/video-core/dist/fact.js +1 -1
  223. package/dist/node_modules/@allyhub-next/video-core/dist/index.d.ts +1 -0
  224. package/dist/node_modules/@allyhub-next/video-core/dist/index.js +1 -1
  225. package/dist/node_modules/@allyhub-next/video-core/dist/marks.d.ts +14 -0
  226. package/dist/node_modules/@allyhub-next/video-core/dist/marks.js +1 -1
  227. package/dist/node_modules/@allyhub-next/video-core/dist/music.d.ts +2 -1
  228. package/dist/node_modules/@allyhub-next/video-core/dist/piece.d.ts +11 -2
  229. package/dist/node_modules/@allyhub-next/video-core/dist/problem.d.ts +4 -0
  230. package/dist/node_modules/@allyhub-next/video-core/dist/problem.js +1 -1
  231. package/dist/node_modules/@allyhub-next/video-core/dist/schema.d.ts +2 -2
  232. package/dist/node_modules/@allyhub-next/video-core/dist/schema.js +1 -1
  233. package/dist/node_modules/@allyhub-next/video-core/dist/script.d.ts +2 -1
  234. package/dist/node_modules/@allyhub-next/video-core/dist/script.js +1 -1
  235. package/dist/node_modules/@allyhub-next/video-core/dist/source.d.ts +7 -0
  236. package/dist/node_modules/@allyhub-next/video-core/dist/source.js +2 -0
  237. package/dist/node_modules/@allyhub-next/video-core/dist/timeline.d.ts +10 -33
  238. package/dist/node_modules/@allyhub-next/video-core/package.json +1 -1
  239. package/dist/slides.d.ts +3 -1
  240. package/dist/slides.js +1 -1
  241. package/docs/README.md +1 -0
  242. package/docs/contract.md +1 -1
  243. package/docs/defaults.md +2 -2
  244. package/docs/layers.md +1 -1
  245. package/docs/project.md +3 -1
  246. package/docs/sheets.md +7 -6
  247. package/docs/slides.md +16 -12
  248. package/docs/sound.md +1 -1
  249. package/docs/websites.md +57 -0
  250. package/package.json +3 -1
  251. package/dist/node_modules/@allyhub-next/slides-core/dist/preset.d.ts +0 -5
  252. package/dist/node_modules/@allyhub-next/slides-core/dist/preset.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{zipSync as me}from"fflate";import{SHEET_PAPERS as fe}from"@allyhub-next/formats";import{cellName as j,columnIndex as ue,columnLetter as K,rangeName as L,readAddress as J,readArea as pe}from"../address.js";import{parseFormula as xe}from"../formula/parse.js";import{sheetPrefix as Q}from"../formula/print.js";import{fileCells as ge,isPicture as $e,pictureHeight as we,pictureSize as ee}from"../files.js";import{scenariosByCell as ye}from"../scenario.js";import{CellError as z,readTyped as be}from"../values.js";import{FormulaCell as ve}from"../workbook.js";import{chartPart as Se,drawingPart as ke}from"./charts.js";import{fileFormula as H,needsArray as X}from"./formula.js";import{Styles as Te}from"./styles.js";import{THEME_XML as Ce}from"./theme.js";import{HEAD as v,NS as A,el as s,xstring as x}from"./xml.js";const S={comments:"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",worksheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",strings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",theme:"application/vnd.openxmlformats-officedocument.theme+xml",table:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",metadata:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",core:"application/vnd.openxmlformats-package.core-properties+xml",app:"application/vnd.openxmlformats-officedocument.extended-properties+xml"},$=`${A.rel}/`,te=new Date(1980,0,1),Ae=191029;export const DEFAULT_TABLE_STYLE="TableStyleMedium2";const Ee=64,Me=7,_e=l=>Math.min(255,Math.floor(l/Me*256)/256),Re=l=>Math.min(409.5,l*3/4),B=32767,q=255,Le=2e5,Ie=s("metadata",{xmlns:A.main,"xmlns:xda":"http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray"},s("metadataTypes",{count:1},s("metadataType",{name:"XLDAPR",minSupportedVersion:12e4,copy:1,pasteAll:1,pasteValues:1,merge:1,splitFirst:1,rowColShift:1,clearFormats:1,clearComments:1,assign:1,coerce:1,cellMeta:1})),s("futureMetadata",{name:"XLDAPR",count:1},s("bk",{},s("extLst",{},s("ext",{uri:"{bdbb8cdc-fa1e-496e-a857-3c3f30c029c3}"},s("xda:dynamicArrayProperties",{fDynamic:1,fCollapsed:0}))))),s("cellMetadata",{count:1},s("bk",{},s("rc",{t:1,v:0}))));class Oe{index=new Map;count=0;of(n){this.count+=1;let e=this.index.get(n);return e===void 0&&(e=this.index.size,this.index.set(n,e)),e}xml(){const n=[...this.index.keys()].map(e=>`<si><t${/^\s|\s$|\n/u.test(e)?' xml:space="preserve"':""}>${x(e)}</t></si>`);return s("sst",{xmlns:A.main,count:this.count,uniqueCount:this.index.size},...n)}}const G=l=>x(l),Pe="Base case";function Fe(l){const n=new Map;for(const o of l.scenarios)for(const r of o.cells)n.set(j(r),r);const e=(o,r)=>s("inputCells",{r:j(o),val:r===null||r instanceof z?"":typeof r=="boolean"?r?"1":"0":String(r)}),t=(o,r)=>s("scenario",{name:o,locked:!0,count:r.length,user:"AllyHub"},...r);return s("scenarios",{current:0,show:0,sqref:[...n.keys()].join(" ")},t(Pe,[...n.values()].map(o=>e(o,o.base))),...l.scenarios.map(o=>t(o.name,o.cells.map(r=>e(r,r.value)))))}function De(l,n,e,t){const o=[];let r=0;for(const{row:d,col:h,paths:i,column:a}of ge(l,n)){let c=0;const u=we(a);for(const T of i){const w=$e(T)?e?.(T):void 0,E=w&&ee(w);if(!w||!E){r+=1;continue}const g=Math.round(E.width/E.height*u);o.push({row:d,col:h,x:c,width:g,height:u,name:T.split("/").pop()??T,file:`.${E.type==="jpeg"?"jpg":E.type}`,bytes:w}),c+=g+4}}for(const d of l.spec.pictures??[]){const h=J(d.at),i=e?.(d.file),a=i&&ee(i);if(!h||!i||!a)continue;const c=a.width/a.height,u=d.width??(d.height===void 0?a.width:d.height*c);o.push({row:h.row,col:h.col,x:d.x??0,y:d.y??0,width:Math.round(u),height:Math.round(d.height??u/c),name:d.file.split("/").pop()??d.file,file:`.${a.type==="jpeg"?"jpg":a.type}`,bytes:i})}return r>0&&t.push(`${l.name}: ${String(r)} file${r===1?"":"s"} in a cell, which stay${r===1?"s":""} a name`),o}class je{arrays=!1;places=new Map;sheet;calc;styles;strings;wb;cached;left;isTable;isRangeName;hiddenRows;tall;scenarios;drawn;constructor(n,e,t,o,r,d,h=[],i){this.sheet=n,this.calc=e,this.wb=e.wb,this.styles=t,this.strings=o,this.cached=r,this.left=d,this.isTable=c=>this.wb.table(c)!==void 0,this.isRangeName=c=>{const u=this.wb.name(c)?.formula?.node;return this.isTable(c)||u!==void 0&&X({kind:"unary",op:"-",arg:u})},this.hiddenRows=e.filtered(n),this.scenarios=i,this.drawn=n.charts.length>0||h.length>0;const a=new Map;for(const c of h)c.y===void 0&&a.set(c.row,Math.max(a.get(c.row)??0,c.height));this.tall=a}add(n,e){let t=this.places.get(n);t||(t=new Set,this.places.set(n,t)),t.add(e)}gather(){const{sheet:n}=this;for(let e=0;e<n.columnsUsed;e++){const[t,o]=n.span(e,0,Number.MAX_SAFE_INTEGER);for(let r=t;r<=o;r++)(n.at(r,e)!==void 0||n.spillAt(r,e))&&this.add(r,e)}for(const{area:e}of n.styledAreas()){const t=(e.bottom-e.top+1)*(e.right-e.left+1);if(t>Le){this.left.push(`${n.name}!${L(e)}: its look on the cells that hold something, ${String(t)} cells being too many to write empty`);continue}for(let o=e.top;o<=e.bottom;o++)for(let r=e.left;r<=e.right;r++)this.add(o,r)}for(const e of n.keys.keys())this.add(Math.floor(e/16384),e%16384)}styleOf(n,e){const t=this.sheet.lookAt(n,e);return Object.keys(t).length===0?void 0:this.styles.xf(t)}held(n,e){return e.length<=B?e:(this.left.push(`${this.sheet.name}!${n} past Excel's ${String(B)} characters, of its ${String(e.length)}`),e.slice(0,B))}value(n,e,t){return t===null?s("c",{r:n,s:e}):typeof t=="number"?`<c r="${n}"${k(e)}><v>${String(t)}</v></c>`:typeof t=="boolean"?`<c r="${n}"${k(e)} t="b"><v>${t?"1":"0"}</v></c>`:t instanceof z?ie(t)?`<c r="${n}"${k(e)} t="e"><v>${t.code}</v></c>`:`<c r="${n}"${k(e)} t="s"><v>${String(this.strings.of(t.code))}</v></c>`:`<c r="${n}"${k(e)} t="s"><v>${String(this.strings.of(this.held(n,t)))}</v></c>`}table(n){return this.sheet.tableAt(n.row,n.col)?.name}formula(n,e,t){const o=this.calc.value(t.sheet,t.row,t.col),{node:r}=t.shared;if(!r)return`<c r="${n}"${k(e)} t="e"><v>#NAME?</v></c>`;const d=t.moved,h=t.array!==void 0||t.blocked!==void 0||X(d,this.isRangeName),i=H(d,{table:this.table(t),isTable:this.isTable,array:h});let a=`<f>${G(i)}</f>`,c="";if(h){this.arrays=!0;const u=t.spill??{top:t.row,left:t.col,bottom:t.row,right:t.col};a=`<f t="array" ref="${L(u)}">${G(i)}</f>`,c=' cm="1"'}return this.cached?o===null||typeof o=="number"?`<c r="${n}"${k(e)}${c}>${a}<v>${String(o??0)}</v></c>`:typeof o=="boolean"?`<c r="${n}"${k(e)} t="b"${c}>${a}<v>${o?"1":"0"}</v></c>`:o instanceof z?ie(o)?`<c r="${n}"${k(e)} t="e"${c}>${a}<v>${o.code}</v></c>`:`<c r="${n}"${k(e)}${c}>${a}<v>0</v></c>`:`<c r="${n}"${k(e)} t="str"${c}>${a}<v>${x(this.held(n,o))}</v></c>`:`<c r="${n}"${k(e)}${c}>${a}</c>`}cell(n,e){const t=j({row:n,col:e}),o=this.styleOf(n,e),r=this.sheet.at(n,e);return r instanceof ve?this.formula(t,o,r):r===void 0&&this.sheet.spillAt(n,e)&&this.cached?this.value(t,o,this.calc.value(this.sheet,n,e)):this.value(t,o,r??null)}columns(){const{sheet:n}=this,{spec:e}=n,t=new Map,o=new Map;for(const i of n.tables)for(const a of i.columns)a.spec?.width!==void 0&&o.set(i.at.col+a.index,a.spec.width);const r=new Set(o.keys()),d=new Map;for(const[i,a]of Object.entries(e.columns??{})){const c=ue(i);c!==void 0&&(d.set(c,a),r.add(c))}for(const i of r){const a=d.get(i),c=a?.width??o.get(i),u=ae(a);t.set(i,s("col",{min:i+1,max:i+1,width:_e(c??Ee),style:u===void 0?void 0:this.styles.xf(u),hidden:a?.hidden===!0?!0:void 0,customWidth:c===void 0?void 0:!0,outlineLevel:a?.level}))}const h=[...t.keys()].sort((i,a)=>i-a).map(i=>t.get(i)??"");return h.length===0?"":s("cols",{},...h)}rowAttrs(n){const e=this.sheet.spec.rows?.[String(n+1)],t=ae(e),o=e?.height??this.tall.get(n);return{r:n+1,s:t===void 0?void 0:this.styles.xf(t),customFormat:t===void 0?void 0:!0,ht:o===void 0?void 0:Re(o),customHeight:o===void 0?void 0:!0,hidden:e?.hidden===!0||this.hiddenRows.has(n)?!0:void 0,outlineLevel:e?.level}}rows(){const{sheet:n}=this,e=new Set(this.places.keys());for(const o of Object.keys(n.spec.rows??{}))e.add(Number(o)-1);for(const o of this.hiddenRows)e.add(o);const t=[];for(const o of[...e].sort((r,d)=>r-d)){const r=[...this.places.get(o)??[]].sort((i,a)=>i-a),d=s("row",this.rowAttrs(o)).slice(4,-2);if(r.length===0){t.push(`<row${d}/>`);continue}let h=`<row${d}>`;for(const i of r)h+=this.cell(o,i);t.push(`${h}</row>`)}return t.join("")}view(n){const{freeze:e}=this.sheet;let t="";if(e&&(e.row>0||e.col>0)){const o=e.row>0&&e.col>0?"bottomRight":e.row>0?"bottomLeft":"topRight";t=s("pane",{xSplit:e.col>0?e.col:void 0,ySplit:e.row>0?e.row:void 0,topLeftCell:j(e),activePane:o,state:"frozen"})}return s("sheetViews",{},s("sheetView",{showGridLines:this.sheet.spec.gridlines===!1?!1:void 0,tabSelected:n?!0:void 0,workbookViewId:0},t))}write(n,e){const{sheet:t}=this;this.gather();const o=Xe(this.places),r=this.rows(),d=t.merges.map(g=>s("mergeCell",{ref:L(g)})),h=t.tables.map((g,y)=>s("tablePart",{"r:id":`rId${String(y+1)}`})),{print:i}=t.spec,a=i?.fit,c=Object.keys(t.spec.notes??{}).length>0,u=h.length+1+(this.drawn?1:0)+(c?2:0);let T=0;const w=Object.entries(t.spec.links??{}).map(([g,y])=>y.startsWith("#")?s("hyperlink",{ref:g,location:y.slice(1)}):s("hyperlink",{ref:g,"r:id":`rId${String(u+T++)}`}));return{xml:v+s("worksheet",{xmlns:A.main,"xmlns:r":A.rel},t.spec.tab===void 0&&a===void 0?"":s("sheetPr",{},t.spec.tab===void 0?"":s("tabColor",{rgb:`FF${t.spec.tab.slice(1).toUpperCase()}`}),a===void 0?"":s("pageSetUpPr",{fitToPage:!0})),s("dimension",{ref:o?L(o):"A1"}),this.view(n),s("sheetFormatPr",{defaultRowHeight:15,outlineLevelRow:ne(t.spec.rows),outlineLevelCol:ne(t.spec.columns)}),this.columns(),r===""?s("sheetData"):`<sheetData>${r}</sheetData>`,t.spec.protect===!0?s("sheetProtection",{sheet:!0,objects:!0,scenarios:!0}):"",this.scenarios?Fe(this.scenarios):"",this.sheetFilter(),d.length>0?s("mergeCells",{count:d.length},...d):"",...t.conditions.map((g,y)=>this.condition(g,y+1)),this.validations(),w.length>0?s("hyperlinks",{},...w):"",s("pageMargins",{...Ne,...i?.margins}),i?.orientation!==void 0||i?.paper!==void 0||a!==void 0?s("pageSetup",{paperSize:i?.paper===void 0?void 0:fe[i.paper],fitToWidth:a?.width,fitToHeight:a?.height,orientation:i?.orientation}):"",i?.header||i?.footer?s("headerFooter",{},i.header?s("oddHeader",{},x(se(i.header))):"",i.footer?s("oddFooter",{},x(se(i.footer))):""):"",this.drawn?s("drawing",{"r:id":`rId${String(h.length+1)}`}):"",c?s("legacyDrawing",{"r:id":`rId${String(h.length+(this.drawn?2:1))}`}):"",h.length>0?s("tableParts",{count:h.length},...h):""),tables:t.tables.map((g,y)=>this.tableXml(g,e+y))}}bound(n){if(n===void 0)return"";if(typeof n=="number")return String(n);if(!n.startsWith("=")){const t=be(n);return typeof t.value=="number"&&t.formula===void 0?String(t.value):`"${n.replaceAll('"','""')}"`}const e=xe(n);return e.ok?H(e.node,{isTable:this.isTable,array:!0}):n.slice(1)}cfvo(n){return s("cfvo",{type:n.at,val:n.value===void 0?void 0:typeof n.value=="number"?n.value:this.bound(n.value)})}condition(n,e){const{spec:t}=n,o=t.range,r=(a,...c)=>s("conditionalFormatting",{sqref:o},s("cfRule",{...a,priority:e,stopIfTrue:t.stop===!0?!0:void 0},...c)),d=()=>{const a=Ue(t);return Object.keys(a).length===0?void 0:this.styles.dxf(a)},h=n.areas[0],i=h?j({row:h.top,col:h.left}):"A1";switch(t.type){case"cellIs":return r({type:"cellIs",dxfId:d(),operator:t.operator},...t.formula.map(a=>s("formula",{},x(this.bound(a)))));case"containsText":{const a=t.operator??"contains",c=`"${t.text.replaceAll('"','""')}"`,u=a==="contains"?`NOT(ISERROR(SEARCH(${c},${i})))`:a==="notContains"?`ISERROR(SEARCH(${c},${i}))`:a==="beginsWith"?`LEFT(${i},LEN(${c}))=${c}`:`RIGHT(${i},LEN(${c}))=${c}`;return r({type:a==="contains"?"containsText":a==="notContains"?"notContainsText":a,dxfId:d(),operator:a==="contains"?"containsText":a,text:t.text},s("formula",{},x(u)))}case"duplicateValues":case"uniqueValues":return r({type:t.type,dxfId:d()});case"top10":return r({type:"top10",dxfId:d(),percent:t.percent===!0?!0:void 0,bottom:t.bottom===!0?!0:void 0,rank:t.rank});case"aboveAverage":return r({type:"aboveAverage",dxfId:d(),aboveAverage:t.below===!0?!1:void 0,equalAverage:t.equal===!0?!0:void 0});case"expression":return r({type:"expression",dxfId:d()},s("formula",{},x(this.bound(t.formula.startsWith("=")?t.formula:`=${t.formula}`))));case"dataBar":return r({type:"dataBar"},s("dataBar",{showValue:t.show===!1?!1:void 0},this.cfvo(t.min??{at:"min"}),this.cfvo(t.max??{at:"max"}),s("color",{rgb:re(t.color)})));case"colorScale":return r({type:"colorScale"},s("colorScale",{},...t.stops.map(a=>this.cfvo(a)),...t.stops.map(a=>s("color",{rgb:re(a.color)}))));case"iconSet":{const a=Number.parseInt(t.icons,10),c=t.stops??Array.from({length:a},(u,T)=>({at:"percent",value:Math.round(T*100/a)}));return r({type:"iconSet"},s("iconSet",{iconSet:t.icons,showValue:t.show===!1?!1:void 0,reverse:t.reverse===!0?!0:void 0},...c.map(u=>this.cfvo(u))))}}}validation(n){const{spec:e}=n;let t="";if(e.values){const h=e.values.join(",");(h.length>q||e.values.some(i=>i.includes(",")))&&this.left.push(`${this.sheet.name}!${e.range}: a list a file's cell cannot spell out, its values longer than ${String(q)} characters or holding a comma`),t=`"${h.slice(0,q)}"`}else t=this.bound(e.formula?.[0]);const o=this.bound(e.formula?.[1]),{error:r,prompt:d}=e;return e.multiple===!0&&this.left.push(`${this.sheet.name}!${e.range}: several choices in a cell: its text stays, and Excel's list offers one at a time`),s("dataValidation",{type:e.type,errorStyle:r?.style===void 0||r.style==="stop"?void 0:r.style,operator:e.operator===void 0||e.operator==="between"?void 0:e.operator,allowBlank:e.blank===!1?void 0:!0,showDropDown:e.dropdown===!1?!0:void 0,showInputMessage:d?.show===!1?void 0:!0,showErrorMessage:r?.show===!1||e.multiple===!0?void 0:!0,errorTitle:r?.title,error:r?.message,promptTitle:d?.title,prompt:d?.message,sqref:e.range},t===""?"":s("formula1",{},x(t)),o===""?"":s("formula2",{},x(o)))}validations(){const n=this.sheet.validations;return n.length===0?"":s("dataValidations",{count:n.length},...n.map(e=>this.validation(e)))}filterColumns(n){return[...n.columns.entries()].sort(([e],[t])=>e-t).map(([e,t])=>We(e-n.area.left,t))}sheetFilter(){const n=this.sheet.filters.find(e=>!e.table);return n?s("autoFilter",{ref:L(n.area)},...this.filterColumns(n)):""}columnFormula(n,e){if(!e?.node)return"";const t=X(e.node,this.isRangeName),o=H(e.node,{table:n.name,isTable:this.isTable,array:t});return s("calculatedColumnFormula",{array:t?!0:void 0},G(o))}tableXml(n,e){const t=n.area,o=L({...t,bottom:Math.max(t.bottom,t.top+1)}),r=n.spec.style??DEFAULT_TABLE_STYLE,d=this.sheet.filters.find(h=>h.table===n);return v+s("table",{xmlns:A.main,id:e,name:n.name,displayName:n.name,ref:o,totalsRowShown:0},d?s("autoFilter",{ref:o},...this.filterColumns(d)):"",s("tableColumns",{count:n.columns.length},...n.columns.map((h,i)=>s("tableColumn",{id:i+1,name:h.name},this.columnFormula(n,h.formula)))),r==="none"?s("tableStyleInfo",{showFirstColumn:0,showLastColumn:0,showRowStripes:1,showColumnStripes:0}):s("tableStyleInfo",{name:r,showFirstColumn:0,showLastColumn:0,showRowStripes:1,showColumnStripes:0}))}}const Ne={left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},ne=l=>{const n=Object.values(l??{}).flatMap(e=>e.level===void 0?[]:[e.level]);return n.length>0?Math.max(...n):void 0},se=l=>[l.left===void 0?"":`&L${l.left}`,l.center===void 0?"":`&C${l.center}`,l.right===void 0?"":`&R${l.right}`].join(""),ze=l=>typeof l=="string"?{text:l,author:oe}:{text:l.text,author:l.author??oe},oe="AllyHub";function He(l){const n=l.map(([t,o])=>({ref:t,...ze(o)})),e=[...new Set(n.map(t=>t.author))];return v+s("comments",{xmlns:A.main},s("authors",{},...e.map(t=>s("author",{},x(t)))),s("commentList",{},...n.map(t=>s("comment",{ref:t.ref,authorId:e.indexOf(t.author)},s("text",{},s("r",{},s("t",{},x(t.text))))))))}function Ve(l){return`<xml xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1"/></o:shapelayout><v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter"/><v:path gradientshapeok="t" o:connecttype="rect"/></v:shapetype>${l.flatMap(([e],t)=>{const o=J(e);return o?[`<v:shape id="_x0000_s${String(1025+t)}" type="#_x0000_t202" style="position:absolute;margin-left:80pt;margin-top:5pt;width:120pt;height:60pt;z-index:${String(t+1)};visibility:hidden" fillcolor="#ffffe1" o:insetmode="auto"><v:fill color2="#ffffe1"/><v:shadow on="t" color="black" obscured="t"/><v:path o:connecttype="none"/><v:textbox style="mso-direction-alt:auto"><div style="text-align:left"></div></v:textbox><x:ClientData ObjectType="Note"><x:MoveWithCells/><x:SizeWithCells/><x:Anchor>${String(o.col+1)}, 15, ${String(o.row)}, 2, ${String(o.col+3)}, 15, ${String(o.row+4)}, 4</x:Anchor><x:AutoFill>False</x:AutoFill><x:Row>${String(o.row)}</x:Row><x:Column>${String(o.col)}</x:Column></x:ClientData></v:shape>`]:[]}).join("")}</xml>`}const re=l=>`FF${l.slice(1).toUpperCase()}`;function Ue(l){if(l.type==="dataBar"||l.type==="colorScale"||l.type==="iconSet")return{};const n={};for(const e of["bold","italic","underline","strike","color","fill","border"])l[e]!==void 0&&(n[e]=l[e]);return n}function We(l,n){return s("filterColumn",{colId:l},s("filters",{blank:n.blanks===!0?!0:void 0},...(n.values??[]).map(e=>s("filter",{val:e}))))}const k=l=>l===void 0?"":` s="${String(l)}"`,ie=l=>l.code!=="#CYCLE!";function Xe(l){let n;for(const[e,t]of l)for(const o of t)n?(n.top=Math.min(n.top,e),n.bottom=Math.max(n.bottom,e),n.left=Math.min(n.left,o),n.right=Math.max(n.right,o)):n={top:e,bottom:e,left:o,right:o};return n}const Be=new Set(["width","height","hidden"]);function ae(l){if(!l)return;const n=Object.fromEntries(Object.entries(l).filter(([e])=>!Be.has(e)));return Object.keys(n).length===0?void 0:n}const V=l=>v+s("Relationships",{xmlns:A.pkg},...l.map(([n,e,t],o)=>s("Relationship",{Id:`rId${String(o+1)}`,Type:n,Target:e,TargetMode:t})));function qe(l,n){const e=l.name(n);if(!e)return;const t=e.formula?.node;if(t)return H(t,{isTable:r=>l.table(r)!==void 0,array:!0});const{value:o}=e;return o==null?'""':typeof o=="string"?`"${o.replaceAll('"','""')}"`:typeof o=="boolean"?o?"TRUE":"FALSE":o instanceof z?o.code:String(o)}const Ge=(l,n)=>l.length===n.length&&l.every((e,t)=>e===n[t]),le=l=>`$${K(l.left)}$${String(l.top+1)}:$${K(l.right)}$${String(l.bottom+1)}`;export function writeXlsx(l,n={}){const e=l.wb,t=[];e.checks.length>0&&t.push(`${String(e.checks.length)} check${e.checks.length===1?"":"s"}: a file has no such thing`);const o=ye(l);t.push(...o.left);const r=new Te,d=new Oe,h=new TextEncoder,i={},a=[["/xl/workbook.xml",S.sheet]],c=Math.max(0,e.sheets.findIndex(m=>m.spec.hidden!==!0));let u=1,T=!1;const w=new Map;let E=0,g=0,y=0;for(const[m,f]of e.sheets.entries()){const R=String(m+1),M=De(f,l,n.file,t),_=f.charts.filter(({spec:p})=>[p.categories,...p.series.flatMap(C=>[C.values,C.x])].some(C=>C?.endsWith("#"))).length;_>0&&t.push(`${f.name}: ${String(_)} chart${_===1?"":"s"} on a spill: ${_===1?"it reads":"they read"} the cells the spill covers now, and will not grow with it`);const P=new je(f,l,r,d,n.cached!==!1,t,M,o.sheets.find(p=>p.sheet===f)),F=P.write(m===c,u);T||=P.arrays,i[`xl/worksheets/sheet${R}.xml`]=F.xml,a.push([`/xl/worksheets/sheet${R}.xml`,S.worksheet]);const b=[];for(const p of F.tables){const C=`table${String(u)}.xml`;u+=1,i[`xl/tables/${C}`]=p,a.push([`/xl/tables/${C}`,S.table]),b.push([`${$}table`,`../tables/${C}`])}if(f.charts.length>0||M.length>0){E+=1;const p=`drawing${String(E)}.xml`;i[`xl/drawings/${p}`]=ke(f.charts,M),a.push([`/xl/drawings/${p}`,S.drawing]),b.push([`${$}drawing`,`../drawings/${p}`]);const C=f.charts.map(D=>{g+=1;const N=`chart${String(g)}.xml`;return i[`xl/charts/${N}`]=Se(l,f,D),a.push([`/xl/charts/${N}`,S.chart]),[`${$}chart`,`../charts/${N}`]});for(const D of M){const Z=[...w].find(([,he])=>Ge(he,D.bytes))?.[0]??`image${String(w.size+1)}${D.file}`;w.set(Z,D.bytes),C.push([`${$}image`,`../media/${Z}`])}i[`xl/drawings/_rels/${p}.rels`]=V(C)}const W=Object.entries(f.spec.notes??{});if(W.length>0){y+=1;const p=String(y);i[`xl/comments${p}.xml`]=He(W),a.push([`/xl/comments${p}.xml`,S.comments]),i[`xl/drawings/vmlDrawing${p}.vml`]=Ve(W),b.push([`${$}vmlDrawing`,`../drawings/vmlDrawing${p}.vml`]),b.push([`${$}comments`,`../comments${p}.xml`])}for(const p of Object.values(f.spec.links??{}))p.startsWith("#")||b.push([`${$}hyperlink`,p,"External"]);b.length>0&&(i[`xl/worksheets/_rels/sheet${R}.xml.rels`]=V(b))}const ce=e.sheets.length,I=e.sheets.map((m,f)=>[`${$}worksheet`,`worksheets/sheet${String(f+1)}.xml`]);I.push([`${$}theme`,"theme/theme1.xml"]),I.push([`${$}styles`,"styles.xml"]),I.push([`${$}sharedStrings`,"sharedStrings.xml"]),T&&(I.push([`${$}sheetMetadata`,"metadata.xml"]),i["xl/metadata.xml"]=v+Ie,a.push(["/xl/metadata.xml",S.metadata]));const O=[...e.names.values()].flatMap(m=>{const f=qe(e,m.name);return f===void 0?[]:[s("definedName",{name:m.name},x(f))]});e.sheets.forEach((m,f)=>{const R=m.filters.find(b=>!b.table);R&&O.push(s("definedName",{name:"_xlnm._FilterDatabase",localSheetId:f,hidden:!0},x(`${Q(m.name)}${le(R.area)}`)));const M=Q(m.name),_=m.spec.print,P=_?.area===void 0?void 0:pe(_.area);P&&O.push(s("definedName",{name:"_xlnm.Print_Area",localSheetId:f},x(`${M}${le(P)}`)));const F=[_?.title_cols?.toUpperCase().replace(/([A-Z]+):([A-Z]+)/u,"$$$1:$$$2"),_?.title_rows?.replace(/(\d+):(\d+)/u,"$$$1:$$$2")].flatMap(b=>b===void 0?[]:[`${M}${b}`]);F.length>0&&O.push(s("definedName",{name:"_xlnm.Print_Titles",localSheetId:f},x(F.join(","))))}),i["xl/workbook.xml"]=v+s("workbook",{xmlns:A.main,"xmlns:r":A.rel},s("workbookPr",{}),s("bookViews",{},s("workbookView",{activeTab:c===0?void 0:c})),s("sheets",{},...e.sheets.map((m,f)=>s("sheet",{name:m.name,sheetId:f+1,state:m.spec.hidden===!0?"hidden":void 0,"r:id":`rId${String(f+1)}`}))),O.length>0?s("definedNames",{},...O):"",s("calcPr",{calcId:Ae,fullCalcOnLoad:!0})),i["xl/_rels/workbook.xml.rels"]=V(I),i["xl/styles.xml"]=v+r.xml(),i["xl/sharedStrings.xml"]=v+d.xml(),i["xl/theme/theme1.xml"]=v+Ce,i["docProps/core.xml"]=v+s("cp:coreProperties",{"xmlns:cp":"http://schemas.openxmlformats.org/package/2006/metadata/core-properties","xmlns:dc":"http://purl.org/dc/elements/1.1/"},e.title===void 0?"":s("dc:title",{},x(e.title))),i["docProps/app.xml"]=v+s("Properties",{xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"},s("Application",{},"AllyHub")),i["_rels/.rels"]=V([[`${$}officeDocument`,"xl/workbook.xml"],["http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties","docProps/core.xml"],[`${$}extended-properties`,"docProps/app.xml"]]),a.push(["/xl/styles.xml",S.styles],["/xl/sharedStrings.xml",S.strings],["/xl/theme/theme1.xml",S.theme],["/docProps/core.xml",S.core],["/docProps/app.xml",S.app]),i["[Content_Types].xml"]=v+s("Types",{xmlns:A.types},s("Default",{Extension:"rels",ContentType:"application/vnd.openxmlformats-package.relationships+xml"}),s("Default",{Extension:"xml",ContentType:"application/xml"}),y>0?s("Default",{Extension:"vml",ContentType:"application/vnd.openxmlformats-officedocument.vmlDrawing"}):"",...[...new Set([...w.keys()].map(m=>m.split(".").pop()??""))].sort().map(m=>s("Default",{Extension:m,ContentType:`image/${m==="jpg"?"jpeg":m}`})),...a.map(([m,f])=>s("Override",{PartName:m,ContentType:f})));const Y=["[Content_Types].xml","_rels/.rels","docProps/app.xml","docProps/core.xml","xl/workbook.xml","xl/_rels/workbook.xml.rels",...Array.from({length:ce},(m,f)=>`xl/worksheets/sheet${String(f+1)}.xml`)],de=[...Y,...Object.keys(i).filter(m=>!Y.includes(m)).sort()],U={};for(const m of de)U[m]=[h.encode(i[m]??""),{mtime:te}];for(const[m,f]of[...w].sort(([R],[M])=>R.localeCompare(M)))U[`xl/media/${m}`]=[f,{mtime:te}];return{bytes:me(U),left:t}}
2
+ import{SHEET_MARGINS as pe,SHEET_NOTE_AUTHOR as K,SHEET_PAPERS as we}from"@allyhub-next/formats";import{MAX_COLUMNS as Q,MAX_ROWS as ee,cellName as _,columnIndex as xe,columnLetter as D,rangeName as M,readAddress as te,readArea as ge}from"../address.js";import{parseFormula as $e}from"../formula/parse.js";import{sheetPrefix as X}from"../formula/print.js";import{walk as ye}from"../formula/walk.js";import{fileCells as be,isPicture as ve,pictureHeight as Se,pictureSize as se}from"../files.js";import{scenariosByCell as ke}from"../scenario.js";import{CellError as P,readTyped as Ae}from"../values.js";import{FormulaCell as Ce}from"../workbook.js";import{chartPart as Ee,drawingPart as Te}from"./charts.js";import{fileFormula as N,needsArray as B}from"./formula.js";import{GRID_END as W}from"./read.js";import{Styles as Me}from"./styles.js";import{THEME_XML as Re}from"./theme.js";import{HEAD as S,NS as k,el as o,xstring as x}from"./xml.js";import{ZipOut as _e}from"./zip.js";const A={comments:"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",worksheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",strings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",theme:"application/vnd.openxmlformats-officedocument.theme+xml",table:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",metadata:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",core:"application/vnd.openxmlformats-package.core-properties+xml",app:"application/vnd.openxmlformats-officedocument.extended-properties+xml"},v=`${k.rel}/`,ne="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",oe="http://schemas.microsoft.com/office/excel/2006/main",re={conditional:"{78C0D931-6437-407d-A8EE-F0AAD7539E65}",validations:"{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}"},je=191029;export const DEFAULT_TABLE_STYLE="TableStyleMedium2",LISTS_SHEET="AllyHub lists";const Le=64,Oe=7,Fe=a=>Math.min(255,Math.floor(a/Oe*256)/256),Ie=a=>Math.min(409.5,a*3/4),q=32767,De=255,Pe=2e5,Ne=o("metadata",{xmlns:k.main,"xmlns:xda":"http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray"},o("metadataTypes",{count:1},o("metadataType",{name:"XLDAPR",minSupportedVersion:12e4,copy:1,pasteAll:1,pasteValues:1,merge:1,splitFirst:1,rowColShift:1,clearFormats:1,clearComments:1,assign:1,coerce:1,cellMeta:1})),o("futureMetadata",{name:"XLDAPR",count:1},o("bk",{},o("extLst",{},o("ext",{uri:"{bdbb8cdc-fa1e-496e-a857-3c3f30c029c3}"},o("xda:dynamicArrayProperties",{fDynamic:1,fCollapsed:0}))))),o("cellMetadata",{count:1},o("bk",{},o("rc",{t:1,v:0}))));class Ve{index=new Map;count=0;of(t){this.count+=1;let s=this.index.get(t);return s===void 0&&(s=this.index.size,this.index.set(t,s)),s}write(t){t.write(`${S}<sst xmlns="${k.main}" count="${String(this.count)}" uniqueCount="${String(this.index.size)}">`);for(const s of this.index.keys()){const e=/^\s|\s$|\n/u.test(s);t.write(`<si><t${e?' xml:space="preserve"':""}>${x(s)}</t></si>`)}t.write("</sst>"),t.end()}}function ze(a){for(const t in a)if(Object.hasOwn(a,t))return!1;return!0}const He=a=>o("x",a).slice(2,-2),Ue="Base case";function Xe(a){const t=new Map;for(const n of a.scenarios)for(const r of n.cells)t.set(_(r),r);const s=(n,r)=>o("inputCells",{r:_(n),val:r===null||r instanceof P?"":typeof r=="boolean"?r?"1":"0":String(r)}),e=(n,r)=>o("scenario",{name:n,locked:!0,count:r.length,user:"AllyHub"},r.join(""));return o("scenarios",{current:0,show:0,sqref:[...t.keys()].join(" ")},e(Ue,[...t.values()].map(n=>s(n,n.base))),...a.scenarios.map(n=>e(n.name,n.cells.map(r=>s(r,r.value)))))}function Be(a,t,s,e){const n=[];let r=0;for(const{row:l,col:h,paths:c,column:i}of be(a,t)){let d=0;const f=Se(i);for(const m of c){const u=ve(m)?s?.(m):void 0,$=u&&se(u);if(!u||!$){r+=1;continue}const T=Math.round($.width/$.height*f);n.push({row:l,col:h,x:d,width:T,height:f,name:m.split("/").pop()??m,path:m,file:`.${$.type==="jpeg"?"jpg":$.type}`,bytes:u}),d+=T+4}}for(const l of a.spec.pictures??[]){const h=te(l.at),c=s?.(l.file),i=c&&se(c);if(!h||!c||!i)continue;const d=i.width/i.height,f=l.width??(l.height===void 0?i.width:l.height*d);n.push({row:h.row,col:h.col,x:l.x??0,y:l.y??0,width:Math.round(f),height:Math.round(l.height??f/d),name:l.file.split("/").pop()??l.file,path:l.file,file:`.${i.type==="jpeg"?"jpg":i.type}`,bytes:c})}return r>0&&e.push(`${a.name}: ${String(r)} file${r===1?"":"s"} in a cell, which stay${r===1?"s":""} a name`),n}class We{name;columns=[];known=new Map;constructor(t){let s=LISTS_SHEET;for(let e=2;t.sheet(s);e++)s=`${LISTS_SHEET} (${String(e)})`;this.name=s}place(t){const s=JSON.stringify(t);let e=this.known.get(s);e===void 0&&(e=this.columns.length,this.columns.push(t),this.known.set(s,e));const n=D(e);return`${X(this.name)}$${n}$1:$${n}$${String(Math.max(1,t.length))}`}xml(t){const s=[],e=Math.max(0,...this.columns.map(n=>n.length));for(let n=0;n<e;n++){let r=`<row r="${String(n+1)}">`;this.columns.forEach((l,h)=>{const c=l[n];c!==void 0&&(r+=`<c r="${_({row:n,col:h})}" t="s"><v>${String(t.of(c))}</v></c>`)}),s.push(`${r}</row>`)}return`${S}<worksheet xmlns="${k.main}" xmlns:r="${k.rel}"><dimension ref="${M({top:0,left:0,bottom:Math.max(0,e-1),right:Math.max(0,this.columns.length-1)})}"/><sheetViews><sheetView workbookViewId="0"/></sheetViews><sheetFormatPr defaultRowHeight="15"/><sheetData>${s.join("")}</sheetData><pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/></worksheet>`}}class qe{rows=new Int32Array(1024);cols=new Int32Array(1024);size=0;add(t,s){if(this.size===this.rows.length){const e=new Int32Array(this.size*2);e.set(this.rows),this.rows=e;const n=new Int32Array(this.size*2);n.set(this.cols),this.cols=n}this.rows[this.size]=t,this.cols[this.size]=s,this.size+=1}byRow(){const{size:t}=this;if(t===0)return{start:new Uint32Array(1),cols:new Int32Array(0),top:0,used:void 0};let s=1/0,e=-1,n=1/0,r=-1;for(let i=0;i<t;i++){const d=this.rows[i]??0,f=this.cols[i]??0;d<s&&(s=d),d>e&&(e=d),f<n&&(n=f),f>r&&(r=f)}const l=new Uint32Array(e-s+2);for(let i=0;i<t;i++){const d=(this.rows[i]??0)-s+1;l[d]=(l[d]??0)+1}for(let i=1;i<l.length;i++)l[i]=(l[i]??0)+(l[i-1]??0);const h=l.slice(0,-1),c=new Int32Array(t);for(let i=0;i<t;i++){const d=(this.rows[i]??0)-s,f=h[d]??0;c[f]=this.cols[i]??0,h[d]=f+1}return{start:l,cols:c,top:s,used:{top:s,bottom:e,left:n,right:r}}}}function Ge(a,t){if(!a)return!1;let s=!1;const e=t.toLowerCase();return ye(a,n=>{(n.kind==="ref"||n.kind==="name")&&n.sheet!==void 0&&n.sheet.toLowerCase()!==e&&(s=!0)}),s}const Ye=(a,t)=>`{00000000-0000-4000-8000-${(a*65536+t).toString(16).toUpperCase().padStart(12,"0")}}`;class Ze{arrays=!1;sheet;calc;styles;strings;wb;cached;left;lists;index;isTable;isRangeName;hiddenRows;tall;scenarios;drawn;newerRules=[];newerValidations=[];shapes=new Map;groups=new Map;constructor(t,s,e,n,r,l,h,c,i=[],d){this.sheet=t,this.calc=s,this.wb=s.wb,this.styles=e,this.strings=n,this.cached=r,this.left=l,this.lists=h,this.index=c,this.isTable=m=>this.wb.table(m)!==void 0,this.isRangeName=m=>{const u=this.wb.name(m,t)?.formula?.node;return this.isTable(m)||u!==void 0&&B({kind:"unary",op:"-",arg:u})},this.hiddenRows=s.filtered(t),this.scenarios=d,this.drawn=t.charts.length>0||i.length>0;const f=new Map;for(const m of i)m.y===void 0&&f.set(m.row,Math.max(f.get(m.row)??0,m.height));this.tall=f}grid(){const{sheet:t}=this;if(t.lastRow>=ee)throw new Error(`${t.name} reaches row ${(t.lastRow+1).toLocaleString("en-US")}, and ${W}: an Excel file cannot hold it.`);if(t.columnsUsed>Q)throw new Error(`${t.name} reaches past column ${D(Q-1)}, and ${W}: an Excel file cannot hold it.`);for(const s of Object.keys(t.spec.rows??{}))if(Number(s)>ee)throw new Error(`${t.name} sets row ${s}, and ${W}: an Excel file cannot hold it.`)}gather(){const{sheet:t}=this,s=new qe;for(let e=0;e<t.columnsUsed;e++){const[n,r]=t.span(e,0,Number.MAX_SAFE_INTEGER);for(let l=n;l<=r;l++)(t.at(l,e)!==void 0||t.spillAt(l,e))&&s.add(l,e)}for(const{area:e}of t.styledAreas()){const n=(e.bottom-e.top+1)*(e.right-e.left+1);if(n>Pe){this.left.push(`${t.name}!${M(e)}: its look on the cells that hold something, ${String(n)} cells being too many to write empty`);continue}for(let r=e.top;r<=e.bottom;r++)for(let l=e.left;l<=e.right;l++)s.add(r,l)}for(const e of t.keys.keys())s.add(Math.floor(e/16384),e%16384);return s.byRow()}styleOf(t,s){const e=this.sheet.lookAt(t,s);return ze(e)?void 0:this.styles.xf(e)}held(t,s){return s.length<=q?s:(this.left.push(`${this.sheet.name}!${t} past Excel's ${String(q)} characters, of its ${String(s.length)}`),s.slice(0,q))}value(t,s,e){return e===null?`<c r="${t}"${C(s)}/>`:typeof e=="number"?`<c r="${t}"${C(s)}><v>${String(e)}</v></c>`:typeof e=="boolean"?`<c r="${t}"${C(s)} t="b"><v>${e?"1":"0"}</v></c>`:e instanceof P?ce(e)?`<c r="${t}"${C(s)} t="e"><v>${e.code}</v></c>`:`<c r="${t}"${C(s)} t="s"><v>${String(this.strings.of(e.code))}</v></c>`:`<c r="${t}"${C(s)} t="s"><v>${String(this.strings.of(this.held(t,e)))}</v></c>`}table(t){return this.sheet.tableAt(t.row,t.col)?.name}formula(t,s,e){const n=this.calc.value(e.sheet,e.row,e.col),{shared:r}=e,{node:l}=r;if(!l)return`<c r="${t}"${C(s)} t="e"><v>#NAME?</v></c>`;let h=this.shapes.get(r);h===void 0&&(h=B(l,this.isRangeName),this.shapes.set(r,h));const c=e.array!==void 0||e.blocked!==void 0||h;let i=c?void 0:this.groups.get(r);i?.written===!1&&(e.row!==i.ref.top||e.col!==i.ref.left)&&(i=void 0);let d,f="";if(i?.written===!0)d=`<f t="shared" si="${String(i.si)}"/>`;else{const m=N(e.moved,{table:this.table(e),isTable:this.isTable,array:c});d=i?`<f t="shared" ref="${M(i.ref)}" si="${String(i.si)}">${x(m)}</f>`:`<f>${x(m)}</f>`,i&&(i.written=!0),c&&(d=this.arrayFormula(e,m))}return c&&(this.arrays=!0,f=' cm="1"'),this.cached?n===null||typeof n=="number"?`<c r="${t}"${C(s)}${f}>${d}<v>${String(n??0)}</v></c>`:typeof n=="boolean"?`<c r="${t}"${C(s)} t="b"${f}>${d}<v>${n?"1":"0"}</v></c>`:n instanceof P?ce(n)?`<c r="${t}"${C(s)} t="e"${f}>${d}<v>${n.code}</v></c>`:`<c r="${t}"${C(s)}${f}>${d}<v>0</v></c>`:`<c r="${t}"${C(s)} t="str"${f}>${d}<v>${x(this.held(t,n))}</v></c>`:`<c r="${t}"${C(s)}${f}>${d}</c>`}arrayFormula(t,s){const e=t.spill??{top:t.row,left:t.col,bottom:t.row,right:t.col};return`<f t="array" ref="${M(e)}">${x(s)}</f>`}shareFormulas(){const t=new Map;for(const e of this.sheet.formulas){const n=t.get(e.shared);if(!n)t.set(e.shared,{area:{top:e.row,bottom:e.row,left:e.col,right:e.col},first:e,n:1});else{const{area:r}=n;e.row<r.top&&(r.top=e.row),e.row>r.bottom&&(r.bottom=e.row),e.col<r.left&&(r.left=e.col),e.col>r.right&&(r.right=e.col),(e.row<n.first.row||e.row===n.first.row&&e.col<n.first.col)&&(n.first=e),n.n+=1}}let s=0;for(const[e,{area:n,first:r,n:l}]of t)l>1&&r.row===n.top&&r.col===n.left&&(this.groups.set(e,{si:s,ref:n,written:!1}),s+=1)}cell(t,s){const e=_({row:t,col:s}),n=this.styleOf(t,s),r=this.sheet.at(t,s);return r instanceof Ce?this.formula(e,n,r):r===void 0&&this.cached&&this.sheet.spillAt(t,s)?this.value(e,n,this.calc.value(this.sheet,t,s)):this.value(e,n,r??null)}columns(){const{sheet:t}=this,{spec:s}=t,e=new Map,n=new Map;for(const c of t.tables)for(const i of c.columns)i.spec?.width!==void 0&&n.set(c.at.col+i.index,i.spec.width);const r=new Set(n.keys()),l=new Map;for(const[c,i]of Object.entries(s.columns??{})){const d=xe(c);d!==void 0&&(l.set(d,i),r.add(d))}for(const c of r){const i=l.get(c),d=i?.width??n.get(c),f=de(i);e.set(c,o("col",{min:c+1,max:c+1,width:Fe(d??Le),style:f===void 0?void 0:this.styles.xf(f),hidden:i?.hidden===!0?!0:void 0,customWidth:d===void 0?void 0:!0,outlineLevel:i?.level}))}const h=[...e.keys()].sort((c,i)=>c-i).map(c=>e.get(c)??"");return h.length===0?"":`<cols>${h.join("")}</cols>`}rowAttrs(t){const s=this.sheet.spec.rows?.[String(t+1)],e=de(s),n=s?.height??this.tall.get(t);return He({r:t+1,s:e===void 0?void 0:this.styles.xf(e),customFormat:e===void 0?void 0:!0,ht:n===void 0?void 0:Ie(n),customHeight:n===void 0?void 0:!0,hidden:s?.hidden===!0||this.hiddenRows.has(t)?!0:void 0,outlineLevel:s?.level})}rows(t,s){const{sheet:e}=this,n=new Set(this.hiddenRows);for(const d of Object.keys(e.spec.rows??{}))n.add(Number(d)-1);const{start:r,cols:l,top:h}=s;let c=s.used?h:1/0,i=s.used?s.used.bottom:-1;for(const d of n)d<c&&(c=d),d>i&&(i=d);for(let d=Math.max(0,c);d<=i;d++){const f=d-h,m=f>=0&&f<r.length-1?r[f]??0:0,u=f>=0&&f<r.length-1?r[f+1]??0:0;if(m===u&&!n.has(d))continue;if(m===u){t.write(`<row${this.rowAttrs(d)}/>`);continue}const $=l.subarray(m,u).sort();let T=`<row${this.rowAttrs(d)}>`,y=-1;for(const b of $)b!==y&&(y=b,T+=this.cell(d,b));t.write(`${T}</row>`)}}view(t){const{freeze:s}=this.sheet;let e="";if(s&&(s.row>0||s.col>0)){const n=s.row>0&&s.col>0?"bottomRight":s.row>0?"bottomLeft":"topRight";e=o("pane",{xSplit:s.col>0?s.col:void 0,ySplit:s.row>0?s.row:void 0,topLeftCell:_(s),activePane:n,state:"frozen"})}return o("sheetViews",{},o("sheetView",{showGridLines:this.sheet.spec.gridlines===!1?!1:void 0,tabSelected:t?!0:void 0,workbookViewId:0},e))}write(t,s,e){const{sheet:n}=this;this.grid();const r=this.gather();this.shareFormulas();const l=n.tables.map((y,b)=>o("tablePart",{"r:id":`rId${String(b+1)}`})),{print:h}=n.spec,c=h?.fit,i=Object.keys(n.spec.notes??{}).length>0;t.write(`${S}<worksheet xmlns="${k.main}" xmlns:r="${k.rel}">`+(n.spec.tab===void 0&&c===void 0?"":o("sheetPr",{},n.spec.tab===void 0?"":o("tabColor",{rgb:`FF${n.spec.tab.slice(1).toUpperCase()}`}),c===void 0?"":o("pageSetUpPr",{fitToPage:!0})))+o("dimension",{ref:r.used?M(r.used):"A1"})+this.view(s)+o("sheetFormatPr",{defaultRowHeight:15,outlineLevelRow:ie(n.spec.rows),outlineLevelCol:ie(n.spec.columns)})+this.columns()+"<sheetData>"),this.rows(t,r);const d=l.length+1+(this.drawn?1:0)+(i?2:0);let f=0;const m=Object.entries(n.spec.links??{}).map(([y,b])=>b.startsWith("#")?o("hyperlink",{ref:y,location:b.slice(1)}):o("hyperlink",{ref:y,"r:id":`rId${String(d+f++)}`})),u=n.merges.map(y=>o("mergeCell",{ref:M(y)})),$=n.conditions.map((y,b)=>this.condition(y,b+1)).join(""),T=this.validations();return t.write("</sheetData>"+(n.spec.protect===!0?o("sheetProtection",{sheet:!0,objects:!0,scenarios:!0}):"")+(this.scenarios?Xe(this.scenarios):"")+this.sheetFilter()+(u.length>0?o("mergeCells",{count:u.length},u.join("")):"")+$+T+(m.length>0?o("hyperlinks",{},m.join("")):"")+o("pageMargins",{...pe,...h?.margins})+(h?.orientation!==void 0||h?.paper!==void 0||c!==void 0?o("pageSetup",{paperSize:h?.paper===void 0?void 0:we[h.paper],fitToWidth:c?.width,fitToHeight:c?.height,orientation:h?.orientation}):"")+(h?.header||h?.footer?o("headerFooter",{},h.header?o("oddHeader",{},x(ae(h.header))):"",h.footer?o("oddFooter",{},x(ae(h.footer))):""):"")+(this.drawn?o("drawing",{"r:id":`rId${String(l.length+1)}`}):"")+(i?o("legacyDrawing",{"r:id":`rId${String(l.length+(this.drawn?2:1))}`}):"")+(l.length>0?o("tableParts",{count:l.length},l.join("")):"")+this.extensions()+"</worksheet>"),t.end(),n.tables.map((y,b)=>this.tableXml(y,e+b))}extensions(){const t=[];return this.newerRules.length>0&&t.push(o("ext",{uri:re.conditional,"xmlns:x14":ne},o("x14:conditionalFormattings",{},this.newerRules.join("")))),this.newerValidations.length>0&&t.push(o("ext",{uri:re.validations,"xmlns:x14":ne},o("x14:dataValidations",{count:this.newerValidations.length,"xmlns:xm":oe},this.newerValidations.join("")))),t.length===0?"":o("extLst",{},t.join(""))}bound(t){if(t===void 0)return"";if(typeof t=="number")return String(t);if(!t.startsWith("=")){const e=Ae(t);return typeof e.value=="number"&&e.formula===void 0?String(e.value):`"${t.replaceAll('"','""')}"`}const s=$e(t);return s.ok?N(s.node,{isTable:this.isTable,array:!0}):t.slice(1)}cfvo(t,s){const e=t.value===void 0?void 0:typeof t.value=="number"?String(t.value):this.bound(t.value);return s?o("x14:cfvo",{type:t.at},e===void 0?"":o("xm:f",{},x(e))):o("cfvo",{type:t.at,val:e})}crosses(t){return t.some(s=>Ge(s?.node,this.sheet.name))}condition(t,s){const{spec:e}=t,n=e.range,r=e.type!=="dataBar"&&this.crosses(t.formulas),l=(f,m,...u)=>{if(!r){const $=Object.keys(m).length===0?void 0:this.styles.dxf(m);return o("conditionalFormatting",{sqref:n},o("cfRule",{...f,dxfId:$,priority:s,stopIfTrue:e.stop===!0?!0:void 0},...u))}return this.newerRules.push(o("x14:conditionalFormatting",{"xmlns:xm":oe},o("x14:cfRule",{...f,priority:s,stopIfTrue:e.stop===!0?!0:void 0,id:Ye(this.index,s)},...u.map($=>$.replace(/^<formula>(.*)<\/formula>$/su,"<xm:f>$1</xm:f>")),Object.keys(m).length===0?"":this.styles.dxfXml(m,"x14:dxf")),o("xm:sqref",{},n))),""},h=et(e),c=t.areas[0],i=c?_({row:c.top,col:c.left}):"A1",d=f=>o("formula",{},x(f));switch(e.type){case"cellIs":return l({type:"cellIs",operator:e.operator},h,...e.formula.map(f=>d(this.bound(f))));case"containsText":{const f=e.operator??"contains",m=`"${e.text.replaceAll('"','""')}"`,u=f==="contains"?`NOT(ISERROR(SEARCH(${m},${i})))`:f==="notContains"?`ISERROR(SEARCH(${m},${i}))`:f==="beginsWith"?`LEFT(${i},LEN(${m}))=${m}`:`RIGHT(${i},LEN(${m}))=${m}`;return l({type:f==="contains"?"containsText":f==="notContains"?"notContainsText":f,operator:f==="contains"?"containsText":f,text:e.text},h,d(u))}case"duplicateValues":case"uniqueValues":return l({type:e.type},h);case"top10":return l({type:"top10",percent:e.percent===!0?!0:void 0,bottom:e.bottom===!0?!0:void 0,rank:e.rank},h);case"aboveAverage":return l({type:"aboveAverage",aboveAverage:e.below===!0?!1:void 0,equalAverage:e.equal===!0?!0:void 0},h);case"expression":return l({type:"expression"},h,d(this.bound(e.formula.startsWith("=")?e.formula:`=${e.formula}`)));case"dataBar":return l({type:"dataBar"},{},o("dataBar",{showValue:e.show===!1?!1:void 0},this.cfvo(e.min??{at:"min"},!1),this.cfvo(e.max??{at:"max"},!1),o("color",{rgb:le(e.color)})));case"colorScale":{const f=r?"x14:":"";return l({type:"colorScale"},{},o(`${f}colorScale`,{},...e.stops.map(m=>this.cfvo(m,r)),...e.stops.map(m=>o(`${f}color`,{rgb:le(m.color)}))))}case"iconSet":{const f=Number.parseInt(e.icons,10),m=e.stops??Array.from({length:f},(u,$)=>({at:"percent",value:Math.round($*100/f)}));return l({type:"iconSet"},{},o(r?"x14:iconSet":"iconSet",{iconSet:e.icons,showValue:e.show===!1?!1:void 0,reverse:e.reverse===!0?!0:void 0},...m.map(u=>this.cfvo(u,r))))}}}validation(t){const{spec:s}=t;let e="",n=this.crosses(t.formulas);if(s.values){const i=s.values.join(",");i.length>De||s.values.some(d=>d.includes(",")||d.includes('"'))?(e=this.lists.place(s.values),n=!0):e=`"${i}"`}else e=this.bound(s.formula?.[0]);const r=this.bound(s.formula?.[1]),{error:l,prompt:h}=s;s.multiple===!0&&this.left.push(`${this.sheet.name}!${s.range}: several choices in a cell: its text stays, and Excel's list offers one at a time`);const c={type:s.type,errorStyle:l?.style===void 0||l.style==="stop"?void 0:l.style,operator:s.operator===void 0||s.operator==="between"?void 0:s.operator,allowBlank:s.blank===!1?void 0:!0,showDropDown:s.dropdown===!1?!0:void 0,showInputMessage:h?.show===!1?void 0:!0,showErrorMessage:l?.show===!1||s.multiple===!0?void 0:!0,errorTitle:l?.title,error:l?.message,promptTitle:h?.title,prompt:h?.message};return n?(this.newerValidations.push(o("x14:dataValidation",c,e===""?"":o("x14:formula1",{},o("xm:f",{},x(e))),r===""?"":o("x14:formula2",{},o("xm:f",{},x(r))),o("xm:sqref",{},s.range))),""):o("dataValidation",{...c,sqref:s.range},e===""?"":o("formula1",{},x(e)),r===""?"":o("formula2",{},x(r)))}validations(){const t=this.sheet.validations.map(s=>this.validation(s)).filter(s=>s!=="");return t.length===0?"":o("dataValidations",{count:t.length},t.join(""))}filterColumns(t){return[...t.columns.entries()].sort(([s],[e])=>s-e).map(([s,e])=>tt(s-t.area.left,e))}sheetFilter(){const t=this.sheet.filters.find(s=>!s.table);return t?o("autoFilter",{ref:M(t.area)},...this.filterColumns(t)):""}columnFormula(t,s){if(!s?.node)return"";const e=B(s.node,this.isRangeName),n=N(s.node,{table:t.name,isTable:this.isTable,array:e});return o("calculatedColumnFormula",{array:e?!0:void 0},x(n))}tableXml(t,s){const e=t.area,n=M({...e,bottom:Math.max(e.bottom,e.top+1)}),r=t.spec.style??DEFAULT_TABLE_STYLE,l=this.sheet.filters.find(h=>h.table===t);return S+o("table",{xmlns:k.main,id:s,name:t.name,displayName:t.name,ref:n,totalsRowShown:0},l?o("autoFilter",{ref:n},...this.filterColumns(l)):"",o("tableColumns",{count:t.columns.length},t.columns.map((h,c)=>o("tableColumn",{id:c+1,name:h.name},this.columnFormula(t,h.formula))).join("")),r==="none"?o("tableStyleInfo",{showFirstColumn:0,showLastColumn:0,showRowStripes:1,showColumnStripes:0}):o("tableStyleInfo",{name:r,showFirstColumn:0,showLastColumn:0,showRowStripes:1,showColumnStripes:0}))}}const ie=a=>{let t;for(const s of Object.values(a??{}))s.level!==void 0&&(t=Math.max(t??0,s.level));return t},ae=a=>[a.left===void 0?"":`&L${a.left}`,a.center===void 0?"":`&C${a.center}`,a.right===void 0?"":`&R${a.right}`].join(""),Je=a=>typeof a=="string"?{text:a,author:K}:{text:a.text,author:a.author??K};function Ke(a){const t=a.map(([e,n])=>({ref:e,...Je(n)})),s=[...new Set(t.map(e=>e.author))];return S+o("comments",{xmlns:k.main},o("authors",{},s.map(e=>o("author",{},x(e))).join("")),o("commentList",{},t.map(e=>o("comment",{ref:e.ref,authorId:s.indexOf(e.author)},o("text",{},o("r",{},o("t",/^\s|\s$|\n/u.test(e.text)?{"xml:space":"preserve"}:{},x(e.text)))))).join("")))}function Qe(a){return`<xml xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1"/></o:shapelayout><v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter"/><v:path gradientshapeok="t" o:connecttype="rect"/></v:shapetype>${a.flatMap(([s],e)=>{const n=te(s);return n?[`<v:shape id="_x0000_s${String(1025+e)}" type="#_x0000_t202" style="position:absolute;margin-left:80pt;margin-top:5pt;width:120pt;height:60pt;z-index:${String(e+1)};visibility:hidden" fillcolor="#ffffe1" o:insetmode="auto"><v:fill color2="#ffffe1"/><v:shadow on="t" color="black" obscured="t"/><v:path o:connecttype="none"/><v:textbox style="mso-direction-alt:auto"><div style="text-align:left"></div></v:textbox><x:ClientData ObjectType="Note"><x:MoveWithCells/><x:SizeWithCells/><x:Anchor>${String(n.col+1)}, 15, ${String(n.row)}, 2, ${String(n.col+3)}, 15, ${String(n.row+4)}, 4</x:Anchor><x:AutoFill>False</x:AutoFill><x:Row>${String(n.row)}</x:Row><x:Column>${String(n.col)}</x:Column></x:ClientData></v:shape>`]:[]}).join("")}</xml>`}const le=a=>`FF${a.slice(1).toUpperCase()}`;function et(a){if(a.type==="dataBar"||a.type==="colorScale"||a.type==="iconSet")return{};const t={};for(const s of["bold","italic","underline","strike","color","fill","border"])a[s]!==void 0&&(t[s]=a[s]);return t}function tt(a,t){return o("filterColumn",{colId:a},o("filters",{blank:t.blanks===!0?!0:void 0},(t.values??[]).map(s=>o("filter",{val:s})).join("")))}const C=a=>a===void 0?"":` s="${String(a)}"`,ce=a=>a.code!=="#CYCLE!",st=new Set(["width","height","hidden"]);function de(a){if(!a)return;const t=Object.fromEntries(Object.entries(a).filter(([s])=>!st.has(s)));return Object.keys(t).length===0?void 0:t}const V=a=>S+o("Relationships",{xmlns:k.pkg},a.map(([t,s,e],n)=>o("Relationship",{Id:`rId${String(n+1)}`,Type:t,Target:s,TargetMode:e})).join(""));function nt(a,t){const s=t.formula?.node;if(s)return N(s,{isTable:n=>a.table(n)!==void 0,array:!0});const{value:e}=t;return e==null?'""':typeof e=="string"?`"${e.replaceAll('"','""')}"`:typeof e=="boolean"?e?"TRUE":"FALSE":e instanceof P?e.code:String(e)}const ot=(a,t)=>a.length===t.length&&a.every((s,e)=>s===t[e]),he=a=>`$${D(a.left)}$${String(a.top+1)}:$${D(a.right)}$${String(a.bottom+1)}`;function rt(a){const t=[],s=(e,n)=>o("definedName",{name:e.name,localSheetId:n,hidden:e.hidden===!0?!0:void 0},x(nt(a,e)));for(const e of a.names.values())t.push(s(e));return a.sheets.forEach((e,n)=>{for(const d of e.names.values())t.push(s(d,n));const r=e.filters.find(d=>!d.table);r&&t.push(o("definedName",{name:"_xlnm._FilterDatabase",localSheetId:n,hidden:!0},x(`${X(e.name)}${he(r.area)}`)));const l=X(e.name),h=e.spec.print,c=h?.area===void 0?void 0:ge(h.area);c&&t.push(o("definedName",{name:"_xlnm.Print_Area",localSheetId:n},x(`${l}${he(c)}`)));const i=[h?.title_cols?.toUpperCase().replace(/([A-Z]+):([A-Z]+)/u,"$$$1:$$$2"),h?.title_rows?.replace(/(\d+):(\d+)/u,"$$$1:$$$2")].flatMap(d=>d===void 0?[]:[`${l}${d}`]);i.length>0&&t.push(o("definedName",{name:"_xlnm.Print_Titles",localSheetId:n},x(i.join(","))))}),t}export function writeXlsx(a,t={}){const s=a.wb,e=[];s.checks.length>0&&e.push(`${String(s.checks.length)} check${s.checks.length===1?"":"s"}: a file has no such thing`);const n=ke(a);e.push(...n.left);const r=new Me,l=new Ve,h=new We(s),c=new _e,i=[["/xl/workbook.xml",A.sheet]],d=Math.max(0,s.sheets.findIndex(p=>p.spec.hidden!==!0));let f=1,m=!1;const u=new Map;let $=0,T=0,y=0;for(const[p,w]of s.sheets.entries()){const H=String(p+1),O=Be(w,a,t.file,e),F=w.charts.filter(({spec:g})=>[g.categories,...g.series.flatMap(E=>[E.values,E.x])].some(E=>E?.endsWith("#"))).length;F>0&&e.push(`${w.name}: ${String(F)} chart${F===1?"":"s"} on a spill: ${F===1?"it reads":"they read"} the cells the spill covers now, and will not grow with it`);const Z=new Ze(w,a,r,l,t.cached!==!1,e,h,p,O,n.sheets.find(g=>g.sheet===w)),me=Z.write(c.part(`xl/worksheets/sheet${H}.xml`),p===d,f);m||=Z.arrays,i.push([`/xl/worksheets/sheet${H}.xml`,A.worksheet]);const R=[];for(const g of me){const E=`table${String(f)}.xml`;f+=1,c.add(`xl/tables/${E}`,g),i.push([`/xl/tables/${E}`,A.table]),R.push([`${v}table`,`../tables/${E}`])}if(w.charts.length>0||O.length>0){$+=1;const g=`drawing${String($)}.xml`;c.add(`xl/drawings/${g}`,Te(w.charts,O)),i.push([`/xl/drawings/${g}`,A.drawing]),R.push([`${v}drawing`,`../drawings/${g}`]);const E=w.charts.map(L=>{T+=1;const I=`chart${String(T)}.xml`;return c.add(`xl/charts/${I}`,Ee(a,w,L)),i.push([`/xl/charts/${I}`,A.chart]),[`${v}chart`,`../charts/${I}`]});for(const L of O){const J=[...u].find(([,ue])=>ot(ue,L.bytes))?.[0]??`image${String(u.size+1)}${L.file}`;u.set(J,L.bytes),E.push([`${v}image`,`../media/${J}`])}c.add(`xl/drawings/_rels/${g}.rels`,V(E))}const U=Object.entries(w.spec.notes??{});if(U.length>0){y+=1;const g=String(y);c.add(`xl/comments${g}.xml`,Ke(U)),i.push([`/xl/comments${g}.xml`,A.comments]),c.add(`xl/drawings/vmlDrawing${g}.vml`,Qe(U)),R.push([`${v}vmlDrawing`,`../drawings/vmlDrawing${g}.vml`]),R.push([`${v}comments`,`../comments${g}.xml`])}for(const g of Object.values(w.spec.links??{}))g.startsWith("#")||R.push([`${v}hyperlink`,g,"External"]);R.length>0&&c.add(`xl/worksheets/_rels/sheet${H}.xml.rels`,V(R))}const b=s.sheets.length,z=h.columns.length>0;if(z){const p=`xl/worksheets/sheet${String(b+1)}.xml`;c.add(p,h.xml(l)),i.push([`/${p}`,A.worksheet])}const j=[...s.sheets,...z?[void 0]:[]].map((p,w)=>[`${v}worksheet`,`worksheets/sheet${String(w+1)}.xml`]);j.push([`${v}theme`,"theme/theme1.xml"]),j.push([`${v}styles`,"styles.xml"]),j.push([`${v}sharedStrings`,"sharedStrings.xml"]),m&&(j.push([`${v}sheetMetadata`,"metadata.xml"]),i.push(["/xl/metadata.xml",A.metadata]));const G=rt(s),Y=s.sheets.map((p,w)=>o("sheet",{name:p.name,sheetId:w+1,state:p.spec.hidden===!0?"hidden":void 0,"r:id":`rId${String(w+1)}`}));z&&Y.push(o("sheet",{name:h.name,sheetId:b+1,state:"veryHidden","r:id":`rId${String(b+1)}`})),c.add("xl/workbook.xml",S+o("workbook",{xmlns:k.main,"xmlns:r":k.rel},o("workbookPr",{}),o("bookViews",{},o("workbookView",{activeTab:d===0?void 0:d})),o("sheets",{},Y.join("")),G.length>0?o("definedNames",{},G.join("")):"",o("calcPr",{calcId:je,fullCalcOnLoad:!0}))),c.add("xl/_rels/workbook.xml.rels",V(j)),c.add("xl/styles.xml",S+r.xml()),l.write(c.part("xl/sharedStrings.xml")),c.add("xl/theme/theme1.xml",S+Re),m&&c.add("xl/metadata.xml",S+Ne),c.add("docProps/core.xml",S+o("cp:coreProperties",{"xmlns:cp":"http://schemas.openxmlformats.org/package/2006/metadata/core-properties","xmlns:dc":"http://purl.org/dc/elements/1.1/"},s.title===void 0?"":o("dc:title",{},x(s.title)))),c.add("docProps/app.xml",S+o("Properties",{xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"},o("Application",{},"AllyHub"))),c.add("_rels/.rels",V([[`${v}officeDocument`,"xl/workbook.xml"],["http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties","docProps/core.xml"],[`${v}extended-properties`,"docProps/app.xml"]])),i.push(["/xl/styles.xml",A.styles],["/xl/sharedStrings.xml",A.strings],["/xl/theme/theme1.xml",A.theme],["/docProps/core.xml",A.core],["/docProps/app.xml",A.app]);const fe=[...u].sort(([p],[w])=>p.localeCompare(w));for(const[p,w]of fe)c.add(`xl/media/${p}`,w);return c.add("[Content_Types].xml",S+o("Types",{xmlns:k.types},o("Default",{Extension:"rels",ContentType:"application/vnd.openxmlformats-package.relationships+xml"}),o("Default",{Extension:"xml",ContentType:"application/xml"}),y>0?o("Default",{Extension:"vml",ContentType:"application/vnd.openxmlformats-officedocument.vmlDrawing"}):"",[...new Set([...u.keys()].map(p=>p.split(".").pop()??""))].sort().map(p=>o("Default",{Extension:p,ContentType:`image/${p==="jpg"?"jpeg":p}`})).join(""),i.map(([p,w])=>o("Override",{PartName:p,ContentType:w})).join(""))),{bytes:c.finish(),left:e}}
@@ -0,0 +1,40 @@
1
+ import { type ZipLimits } from "@allyhub-next/formats";
2
+ /** A part being written: text in order, then its end. */
3
+ export interface PartWriter {
4
+ write(text: string): void;
5
+ end(): void;
6
+ }
7
+ /** A zip written a part at a time, one part after another. */
8
+ export declare class ZipOut {
9
+ private readonly chunks;
10
+ private readonly zip;
11
+ private readonly encoder;
12
+ private open;
13
+ constructor();
14
+ private entry;
15
+ /** A part written in pieces. */
16
+ part(path: string): PartWriter;
17
+ /** A whole part at once. */
18
+ add(path: string, content: string | Uint8Array): void;
19
+ /** The zip's bytes; nothing can be added after. */
20
+ finish(): Uint8Array;
21
+ }
22
+ /** A zip read through its central directory: any part, when it is asked for. */
23
+ export declare class ZipIn {
24
+ private readonly bytes;
25
+ private readonly entries;
26
+ private readonly lower;
27
+ constructor(bytes: Uint8Array, limits?: Partial<ZipLimits>);
28
+ get names(): string[];
29
+ private find;
30
+ has(path: string): boolean;
31
+ /** Its parts as the central directory lists them. */
32
+ private directory;
33
+ /** A part's bytes, a piece at a time; never more than the directory says it holds. */
34
+ stream(path: string, onBytes: (chunk: Uint8Array) => void): boolean;
35
+ /** A part's text, a piece at a time. */
36
+ streamText(path: string, onText: (text: string) => void): boolean;
37
+ bytesOf(path: string): Uint8Array | undefined;
38
+ text(path: string): string | undefined;
39
+ }
40
+ //# sourceMappingURL=zip.d.ts.map
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{Inflate as C,Zip as D,ZipDeflate as M}from"fflate";import{withinZip as U,ZipLimitError as E}from"@allyhub-next/formats";const O=new Date(1980,0,1),_=1<<20;export class ZipOut{chunks=[];zip;encoder=new TextEncoder;open=!1;constructor(){this.zip=new D((t,e)=>{if(t)throw t;this.chunks.push(e)})}entry(t){if(this.open)throw new Error(`${t} is written while a part is open.`);const e=new M(t,{level:6});return e.mtime=O,this.zip.add(e),e}part(t){const e=this.entry(t);this.open=!0;let n=[],s=0;const i=o=>{const r=n.length===1?n[0]??"":n.join("");n=[],s=0,e.push(this.encoder.encode(r),o)};return{write:o=>{n.push(o),s+=o.length,s>=_&&i(!1)},end:()=>{i(!0),this.open=!1}}}add(t,e){this.entry(t).push(typeof e=="string"?this.encoder.encode(e):e,!0)}finish(){this.zip.end();let t=0;for(const s of this.chunks)t+=s.length;const e=new Uint8Array(t);let n=0;for(const s of this.chunks)e.set(s,n),n+=s.length;return e}}const g=65536,h=(f,t)=>(f[t]??0)|(f[t+1]??0)<<8,a=(f,t)=>(h(f,t)|h(f,t+2)<<16)>>>0,d=(f,t)=>a(f,t)+a(f,t+4)*4294967296,A=f=>{let t="";for(const e of f)t+=String.fromCharCode(e);return t};export class ZipIn{bytes;entries=new Map;lower=new Map;constructor(t,e){this.bytes=t;const n=U(e);for(const s of this.directory())n({name:s.name,originalSize:s.size}),this.entries.set(s.name,s),this.lower.set(s.name.toLowerCase(),s)}get names(){return[...this.entries.keys()]}find(t){return this.entries.get(t)??this.lower.get(t.toLowerCase())}has(t){return this.find(t)!==void 0}*directory(){const t=this.bytes;let e=-1;for(let r=t.length-22;r>=Math.max(0,t.length-22-65535);r--)if(a(t,r)===101010256){e=r;break}if(e<0)throw new Error("It has no zip directory.");let n=h(t,e+10),s=a(t,e+16);if((n===65535||s===4294967295)&&a(t,e-20)===117853008){const r=d(t,e-12);if(a(t,r)!==101075792)throw new Error("Its zip64 end is lost.");n=d(t,r+32),s=d(t,r+48)}const i=new TextDecoder;let o=s;for(let r=0;r<n;r++){if(a(t,o)!==33639248)throw new Error("Its zip directory is damaged.");const I=h(t,o+8),Z=h(t,o+10);let w=a(t,o+20),m=a(t,o+24);const y=h(t,o+28),L=h(t,o+30),T=h(t,o+32);let c=a(t,o+42);const x=t.subarray(o+46,o+46+y),p=I&2048?i.decode(x):A(x);let l=o+46+y;const z=l+L;for(;l+4<=z;){const $=h(t,l),k=h(t,l+2);if($===1){let u=l+4;m===4294967295&&(m=d(t,u),u+=8),w===4294967295&&(w=d(t,u),u+=8),c===4294967295&&(c=d(t,u))}l+=4+k}if(o=z+T,a(t,c)!==67324752)throw new Error(`Its part ${p} is lost.`);const b=c+30+h(t,c+26)+h(t,c+28);if(b+w>t.length)throw new Error(`Its part ${p} is cut short.`);p.endsWith("/")||(yield{name:p,method:Z,start:b,compressed:w,size:m})}}stream(t,e){const n=this.find(t);if(!n)return!1;const s=this.bytes.subarray(n.start,n.start+n.compressed);if(n.method===0){if(s.length>n.size)throw new E(`${n.name} holds more than it says.`);return e(s),!0}if(n.method!==8)throw new Error(`${n.name} is compressed in a way a zip reader here does not know.`);let i=0;const o=new C(r=>{if(i+=r.length,i>n.size)throw new E(`${n.name} unzips to more than it says.`);e(r)});for(let r=0;r<s.length;r+=g)o.push(s.subarray(r,r+g),r+g>=s.length);return s.length===0&&o.push(s,!0),!0}streamText(t,e){const n=new TextDecoder;if(!this.stream(t,o=>{const r=n.decode(o,{stream:!0});r!==""&&e(r)}))return!1;const i=n.decode();return i!==""&&e(i),!0}bytesOf(t){const e=this.find(t);if(!e)return;const n=new Uint8Array(e.size);let s=0;return this.stream(t,i=>{n.set(i,s),s+=i.length}),s===n.length?n:n.subarray(0,s)}text(t){const e=this.bytesOf(t);return e===void 0?void 0:new TextDecoder().decode(e)}}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub-next/sheet",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{pathSteps as g}from"./path.js";import{EMU_PER_PT as h}from"./units.js";export const ANIMATION_DURATIONS={appear:0,fade:.5,wipe:.5,"fly-in":.5,zoom:.5,disappear:0,"fade-out":.5,"wipe-out":.5,"fly-out":.5,"zoom-out":.5,pulse:.5,path:2};const S=new Set(["disappear","fade-out","wipe-out","fly-out","zoom-out"]),M=new Set(["appear","fade","wipe","fly-in","zoom"]);export const isExit=t=>S.has(t),isEntrance=t=>M.has(t),TRANSITION_DURATIONS={fade:.7,push:1,wipe:1,morph:2},resolveTransition=t=>({type:t.type,direction:t.direction??"from-right",duration:t.duration??TRANSITION_DURATIONS[t.type]});const w={"from-left":{x:-1,y:0},"from-right":{x:1,y:0},"from-top":{x:0,y:-1},"from-bottom":{x:0,y:1}};export function transitionAt(t,o){const e={opacity:1,x:0,y:0};if(t.type==="fade")return{incoming:{...e,opacity:o},outgoing:{x:0,y:0}};if(t.type==="push"){const n=w[t.direction];return{incoming:{...e,x:n.x*(1-o),y:n.y*(1-o)},outgoing:{x:-n.x*o,y:-n.y*o}}}return t.type==="wipe"?{incoming:{...e,clip:d(t.direction,1-o)},outgoing:{x:0,y:0}}:{incoming:e,outgoing:{x:0,y:0}}}export function morphFrame(t,o,e){const n=e*e*(3-2*e),i=(p,f)=>p+(f-p)*n;return{left:i(t.left,o.left),top:i(t.top,o.top),width:i(t.width,o.width),height:i(t.height,o.height)}}export function resolveAnimation(t){const o=t.path===void 0?void 0:g(t.path);if(!(t.path!==void 0&&!o)&&!(t.effect==="path"&&!o))return{shape:t.shape,...t.paragraph===void 0?{}:{paragraph:t.paragraph},effect:t.effect,direction:t.direction??"from-bottom",start:t.start??"on-click",duration:t.duration??ANIMATION_DURATIONS[t.effect],delay:t.delay??0,...o?{path:o.map(e=>e.op==="close"?e:e.op!=="curve"?{...e,x:e.x*h,y:e.y*h}:{op:"curve",x1:e.x1*h,y1:e.y1*h,x2:e.x2*h,y2:e.y2*h,x:e.x*h,y:e.y*h})}:{}}}export function slideClock(t,o,e,n=0,i=0){const p=new Set(t.filter(s=>isEntrance(s.effect)).map(s=>s.shape));let f=i+(o.some(s=>!p.has(s))?e:0);if(t.length===0)return{timed:[],rests:[Math.max(e,i)]};const r=[],c=[];let a=0,u=i;for(const s of t){s.start==="on-click"?(r.push(f),a++,f+=n,u=f):s.start==="after-previous"&&(u=f);const y=u+s.delay,l=y+s.duration;c.push({...s,step:a,from:y,to:l}),f=Math.max(f,l),o.includes(s.shape)&&isEntrance(s.effect)&&(f=Math.max(f,y+e))}return r.push(f),{timed:c,rests:r}}export const SLIDE_SECONDS=4,DECK_FPS=30;const E=t=>Math.ceil(t*DECK_FPS-1e-6)/DECK_FPS;export function clockOf(t,o){const e=o?0:t.transition?.duration??0,n=slideClock(t.animations,t.shapes.flatMap(i=>i.component?[i.name]:[]),SLIDE_SECONDS-1/DECK_FPS,1/DECK_FPS,e);return{timed:n.timed,rests:n.rests.map(E),lead:e,comesOn:i=>n.timed.find(p=>p.shape===i&&isEntrance(p.effect))?.from??e,goesOff:i=>n.timed.find(p=>p.shape===i&&isExit(p.effect))?.to}}const T=1e-6,x={hidden:!1,opacity:1,x:0,y:0,scale:1},N=t=>1-(1-t)*(1-t);function A(t){const o=[];let e={x:0,y:0};for(const n of t){if(n.op==="close")continue;if(n.op!=="curve"){e={x:n.x,y:n.y},o.push(e);continue}const i=e;for(let p=1;p<=24;p++){const f=p/24,r=1-f,c=(a,u,s,y)=>r*r*r*a+3*r*r*f*u+3*r*f*f*s+f*f*f*y;o.push({x:c(i.x,n.x1,n.x2,n.x),y:c(i.y,n.y1,n.y2,n.y)})}e={x:n.x,y:n.y}}return o}export function pathPoint(t,o){const e=A(t),[n]=e;if(!n)return{x:0,y:0};let i=0;for(let f=1;f<e.length;f++){const[r,c]=[e[f-1]??n,e[f]??n];i+=Math.hypot(c.x-r.x,c.y-r.y)}let p=i*o;for(let f=1;f<e.length;f++){const[r,c]=[e[f-1]??n,e[f]??n],a=Math.hypot(c.x-r.x,c.y-r.y);if(p<=a&&a>0){const u=p/a;return{x:r.x+(c.x-r.x)*u,y:r.y+(c.y-r.y)*u}}p-=a}return e.at(-1)??n}function I(t,o,e){return t==="from-left"?{x:-(o.left+o.width),y:0}:t==="from-right"?{x:e.width-o.left,y:0}:t==="from-top"?{x:0,y:-(o.top+o.height)}:{x:0,y:e.height-o.top}}function d(t,o){const e={top:0,right:0,bottom:0,left:0};return t==="from-left"?e.right=o:t==="from-right"?e.left=o:t==="from-top"?e.bottom=o:e.top=o,e}function m(t,o,e,n){if(t.effect==="fade"||t.effect==="fade-out")return{opacity:o};if(t.effect==="zoom"||t.effect==="zoom-out")return{scale:o,opacity:o};if(t.effect==="wipe"||t.effect==="wipe-out")return{clip:d(t.direction,1-o)};if(t.effect==="fly-in"||t.effect==="fly-out"){const i=I(t.direction,e,n);return{x:i.x*(1-o),y:i.y*(1-o)}}return{}}export function drawnAt(t,o,e,n){let i={...x};const[p]=t,f=r=>o<r-T;if(p&&isEntrance(p.effect)&&f(p.from))return{...x,hidden:!0};for(const r of t){if(f(r.from))break;const c=r.to>r.from?Math.min(1,(o-r.from)/(r.to-r.from)):1;if(r.effect==="path"&&r.path){const a=pathPoint(r.path,c);i={...i,x:a.x,y:a.y}}else r.effect==="pulse"?i={...i,scale:1+.05*Math.sin(c*Math.PI)}:isExit(r.effect)?i=c>=1?{...x,hidden:!0}:{...i,...m(r,1-(r.effect==="fly-out"?c*c:c),e,n)}:i={...x,...c<1?m(r,r.effect==="fly-in"?N(c):c,e,n):{}}}return i}export function animationTargets(t){const o=new Map;for(const e of t){const n=JSON.stringify([e.shape,e.paragraph??null]),i=o.get(n);i?i.animations.push(e):o.set(n,{shape:e.shape,...e.paragraph===void 0?{}:{paragraph:e.paragraph},animations:[e]})}return[...o.values()]}
2
+ import{pathSteps as S}from"./path.js";import{EMU_PER_PT as h}from"./units.js";export const ANIMATION_DURATIONS={appear:0,fade:.5,wipe:.5,"fly-in":.5,zoom:.5,disappear:0,"fade-out":.5,"wipe-out":.5,"fly-out":.5,"zoom-out":.5,pulse:.5,path:2};const M=new Set(["disappear","fade-out","wipe-out","fly-out","zoom-out"]),w=new Set(["appear","fade","wipe","fly-in","zoom"]);export const isExit=t=>M.has(t),isEntrance=t=>w.has(t),TRANSITION_DURATIONS={fade:.7,push:1,wipe:1,morph:2},resolveTransition=t=>({type:t.type,direction:t.direction??"from-right",duration:t.duration??TRANSITION_DURATIONS[t.type]});const E={"from-left":{x:-1,y:0},"from-right":{x:1,y:0},"from-top":{x:0,y:-1},"from-bottom":{x:0,y:1}};export function transitionAt(t,o){const e={opacity:1,x:0,y:0};if(t.type==="fade")return{incoming:{...e,opacity:o},outgoing:{x:0,y:0}};if(t.type==="push"){const n=E[t.direction];return{incoming:{...e,x:n.x*(1-o),y:n.y*(1-o)},outgoing:{x:-n.x*o,y:-n.y*o}}}return t.type==="wipe"?{incoming:{...e,clip:m(t.direction,1-o)},outgoing:{x:0,y:0}}:{incoming:e,outgoing:{x:0,y:0}}}export function morphFrame(t,o,e){const n=e*e*(3-2*e),i=(p,f)=>p+(f-p)*n;return{left:i(t.left,o.left),top:i(t.top,o.top),width:i(t.width,o.width),height:i(t.height,o.height)}}export function resolveAnimation(t){const o=t.path===void 0?void 0:S(t.path);if(!(t.path!==void 0&&!o)&&!(t.effect==="path"&&!o))return{shape:t.shape,...t.paragraph===void 0?{}:{paragraph:t.paragraph},effect:t.effect,direction:t.direction??"from-bottom",start:t.start??"on-click",duration:t.duration??ANIMATION_DURATIONS[t.effect],delay:t.delay??0,...o?{path:o.map(e=>e.op==="close"?e:e.op!=="curve"?{...e,x:e.x*h,y:e.y*h}:{op:"curve",x1:e.x1*h,y1:e.y1*h,x2:e.x2*h,y2:e.y2*h,x:e.x*h,y:e.y*h})}:{}}}export function slideClock(t,o,e,n=0,i=0){const p=new Set(t.filter(s=>isEntrance(s.effect)).map(s=>s.shape));let f=i+(o.some(s=>!p.has(s))?e:0);if(t.length===0)return{timed:[],rests:[Math.max(e,i)]};const r=[],c=[];let a=0,u=i;for(const s of t){s.start==="on-click"?(r.push(f),a++,f+=n,u=f):s.start==="after-previous"&&(u=f);const y=u+s.delay,l=y+s.duration;c.push({...s,step:a,from:y,to:l}),f=Math.max(f,l),o.includes(s.shape)&&isEntrance(s.effect)&&(f=Math.max(f,y+e))}return r.push(f),{timed:c,rests:r}}export const SLIDE_SECONDS=4,DECK_FPS=30;const T=t=>Math.ceil(t*DECK_FPS-1e-6)/DECK_FPS;export function clockOf(t,o){const e=o?0:t.transition?.duration??0,n=slideClock(t.animations,t.shapes.flatMap(i=>i.component?[i.name]:[]),SLIDE_SECONDS-1/DECK_FPS,1/DECK_FPS,e);return{timed:n.timed,rests:n.rests.map(T),lead:e,comesOn:i=>n.timed.find(p=>p.shape===i&&isEntrance(p.effect))?.from??e,goesOff:i=>n.timed.find(p=>p.shape===i&&isExit(p.effect))?.to}}const d=1e-6,x={hidden:!1,opacity:1,x:0,y:0,scale:1},N=t=>1-(1-t)*(1-t);function A(t){const o=[];let e={x:0,y:0};for(const n of t){if(n.op==="close")continue;if(n.op!=="curve"){e={x:n.x,y:n.y},o.push(e);continue}const i=e;for(let p=1;p<=24;p++){const f=p/24,r=1-f,c=(a,u,s,y)=>r*r*r*a+3*r*r*f*u+3*r*f*f*s+f*f*f*y;o.push({x:c(i.x,n.x1,n.x2,n.x),y:c(i.y,n.y1,n.y2,n.y)})}e={x:n.x,y:n.y}}return o}export function pathPoint(t,o){const e=A(t),[n]=e;if(!n)return{x:0,y:0};let i=0;for(let f=1;f<e.length;f++){const[r,c]=[e[f-1]??n,e[f]??n];i+=Math.hypot(c.x-r.x,c.y-r.y)}let p=i*o;for(let f=1;f<e.length;f++){const[r,c]=[e[f-1]??n,e[f]??n],a=Math.hypot(c.x-r.x,c.y-r.y);if(p<=a&&a>0){const u=p/a;return{x:r.x+(c.x-r.x)*u,y:r.y+(c.y-r.y)*u}}p-=a}return e.at(-1)??n}function I(t,o,e){return t==="from-left"?{x:-(o.left+o.width),y:0}:t==="from-right"?{x:e.width-o.left,y:0}:t==="from-top"?{x:0,y:-(o.top+o.height)}:{x:0,y:e.height-o.top}}function m(t,o){const e={top:0,right:0,bottom:0,left:0};return t==="from-left"?e.right=o:t==="from-right"?e.left=o:t==="from-top"?e.bottom=o:e.top=o,e}function g(t,o,e,n){if(t.effect==="fade"||t.effect==="fade-out")return{opacity:o};if(t.effect==="zoom"||t.effect==="zoom-out")return{scale:o,opacity:o};if(t.effect==="wipe"||t.effect==="wipe-out")return{clip:m(t.direction,1-o)};if(t.effect==="fly-in"||t.effect==="fly-out"){const i=I(t.direction,e,n);return{x:i.x*(1-o),y:i.y*(1-o)}}return{}}export function drawnAt(t,o,e,n){let i={...x};const[p]=t,f=r=>o<r-d;if(p&&isEntrance(p.effect)&&f(p.from))return{...x,hidden:!0};for(const r of t){if(f(r.from))break;const c=r.to>r.from&&o<r.to-d?Math.min(1,(o-r.from)/(r.to-r.from)):1;if(r.effect==="path"&&r.path){const a=pathPoint(r.path,c);i={...i,x:a.x,y:a.y}}else r.effect==="pulse"?i={...i,scale:1+.05*Math.sin(c*Math.PI)}:isExit(r.effect)?i=c>=1?{...x,hidden:!0}:{...i,...g(r,1-(r.effect==="fly-out"?c*c:c),e,n)}:i={...x,...c<1?g(r,r.effect==="fly-in"?N(c):c,e,n):{}}}return i}export function animationTargets(t){const o=new Map;for(const e of t){const n=JSON.stringify([e.shape,e.paragraph??null]),i=o.get(n);i?i.animations.push(e):o.set(n,{shape:e.shape,...e.paragraph===void 0?{}:{paragraph:e.paragraph},animations:[e]})}return[...o.values()]}
@@ -4,18 +4,34 @@ import type { Color, ComponentContext, DeckDef, FontDef, Frame, GradientDef, Fre
4
4
  import type { SheetChartType } from "@allyhub-next/formats";
5
5
  import { Chart, type CategoryChartData, type XyChartData } from "./chart-api.js";
6
6
  import type { ThemeInput } from "./theme.js";
7
- import { type Length, type SlideSizeName } from "./units.js";
8
- /** python-pptx's `RGBColor(r, g, b)` and `RGBColor.from_string("3C2F80")`: a colour as `#RRGGBB`. */
9
- export declare const RGBColor: ((r: number, g: number, b: number) => string) & {
10
- from_string: (s: string) => string;
11
- };
12
- /** A colour (python-pptx's `ColorFormat`): the theme's, or RGB. */
7
+ import { type Length, type LengthValue, type SlideSizeName } from "./units.js";
8
+ /** python-pptx's `RGBColor`: called or made with `new`, a colour as `#RRGGBB`. */
9
+ export interface RGBColorMaker {
10
+ (r: number, g: number, b: number): string;
11
+ new (r: number, g: number, b: number): string;
12
+ from_string(s: string): string;
13
+ }
14
+ /**
15
+ * python-pptx's `RGBColor(r, g, b)` and `RGBColor.from_string("3C2F80")`:
16
+ * a colour as `#RRGGBB`; `new RGBColor(r, g, b)` makes the same (a String
17
+ * object, which the API takes as its text).
18
+ */
19
+ export declare const RGBColor: RGBColorMaker;
20
+ /** A colour (python-pptx's `ColorFormat`): the theme's, lighter or darker by its brightness, or RGB. */
13
21
  export declare class ColorFormat {
14
22
  private readonly read;
15
23
  private readonly write;
16
24
  constructor(read: () => Color | undefined, write: (c: Color | undefined) => void);
17
25
  get theme_color(): ThemeColor | undefined;
26
+ /** As python-pptx's: a theme colour changed to another keeps its brightness. */
18
27
  set theme_color(c: ThemeColor | undefined);
28
+ /**
29
+ * Lighter (up to 1, white) or darker (down to -1, black), 0 for neither:
30
+ * PowerPoint's "Lighter 40%" is 0.4, "Darker 25%" -0.25 (`a:lumMod` and
31
+ * `a:lumOff`). A theme colour's; setting `rgb` takes it away.
32
+ */
33
+ get brightness(): number;
34
+ set brightness(v: number);
19
35
  /** `#RRGGBB`; python-pptx's `RGBColor`, here a string (RGBColor(…) makes one). */
20
36
  get rgb(): string | undefined;
21
37
  set rgb(v: string | undefined);
@@ -36,7 +52,7 @@ export declare class Font {
36
52
  set highlight(v: string | undefined);
37
53
  get name(): string | undefined;
38
54
  set name(v: string | undefined);
39
- get size(): Length | undefined;
55
+ get size(): LengthValue | undefined;
40
56
  set size(v: Length | undefined);
41
57
  get bold(): boolean | undefined;
42
58
  set bold(v: boolean | undefined);
@@ -46,7 +62,7 @@ export declare class Font {
46
62
  get underline(): boolean | undefined;
47
63
  set underline(v: boolean | undefined);
48
64
  /** Space added between letters, a Length (negative tightens): PowerPoint's Character Spacing, which python-pptx has no name for. */
49
- get spacing(): Length | undefined;
65
+ get spacing(): LengthValue | undefined;
50
66
  set spacing(v: Length | undefined);
51
67
  get color(): ColorFormat;
52
68
  }
@@ -73,11 +89,11 @@ declare abstract class Format {
73
89
  get alignment(): TextAlign | undefined;
74
90
  set alignment(v: TextAlign | undefined);
75
91
  /** A number of lines (1.5), or a Length (Pt(18)) for a fixed height. */
76
- get line_spacing(): number | undefined;
92
+ get line_spacing(): number | LengthValue | undefined;
77
93
  set line_spacing(v: number | undefined);
78
- get space_before(): Length | undefined;
94
+ get space_before(): LengthValue | undefined;
79
95
  set space_before(v: Length | undefined);
80
- get space_after(): Length | undefined;
96
+ get space_after(): LengthValue | undefined;
81
97
  set space_after(v: Length | undefined);
82
98
  /** Its runs' default character properties (`a:defRPr`). */
83
99
  get font(): Font;
@@ -115,10 +131,10 @@ export declare class ListLevel extends Format {
115
131
  get bullet_font(): string | undefined;
116
132
  set bullet_font(v: string | undefined);
117
133
  /** Where its lines start (`@marL`). */
118
- get margin_left(): Length | undefined;
134
+ get margin_left(): LengthValue | undefined;
119
135
  set margin_left(v: Length | undefined);
120
136
  /** Its first line from margin_left (`@indent`; negative hangs it, for a bullet). */
121
- get indent(): Length | undefined;
137
+ get indent(): LengthValue | undefined;
122
138
  set indent(v: Length | undefined);
123
139
  }
124
140
  /** A list style's nine levels, level 0 first. */
@@ -160,13 +176,13 @@ export declare class TextFrame {
160
176
  set auto_size(v: AutoSize | undefined);
161
177
  get word_wrap(): boolean | undefined;
162
178
  set word_wrap(v: boolean | undefined);
163
- get margin_left(): Length;
179
+ get margin_left(): LengthValue;
164
180
  set margin_left(v: Length);
165
- get margin_top(): Length;
181
+ get margin_top(): LengthValue;
166
182
  set margin_top(v: Length);
167
- get margin_right(): Length;
183
+ get margin_right(): LengthValue;
168
184
  set margin_right(v: Length);
169
- get margin_bottom(): Length;
185
+ get margin_bottom(): LengthValue;
170
186
  set margin_bottom(v: Length);
171
187
  }
172
188
  /** python-pptx's `FillFormat`, for a solid fill and none. */
@@ -210,9 +226,9 @@ export declare class ShadowFormat {
210
226
  /** Whether it has none of its own; false gives it SHADOW_DEFAULTS. */
211
227
  get inherit(): boolean;
212
228
  set inherit(v: boolean);
213
- get blur_radius(): Length;
229
+ get blur_radius(): LengthValue;
214
230
  set blur_radius(v: Length);
215
- get distance(): Length;
231
+ get distance(): LengthValue;
216
232
  set distance(v: Length);
217
233
  get angle(): number;
218
234
  set angle(v: number);
@@ -227,7 +243,7 @@ export declare class LineFormat {
227
243
  /** Its colour; setting one makes the line solid. */
228
244
  get color(): ColorFormat;
229
245
  get fill(): FillFormat;
230
- get width(): Length;
246
+ get width(): LengthValue;
231
247
  set width(v: Length);
232
248
  /** Its dashes (MSO_LINE), or null for its theme's. */
233
249
  get dash_style(): LineDash | null;
@@ -247,8 +263,8 @@ export declare class Background {
247
263
  });
248
264
  get fill(): FillFormat;
249
265
  }
250
- /** A geometry's adjustments and what each is when not set (PresentationML's presets). */
251
- export declare const ADJUSTMENT_DEFAULTS: Partial<Record<ShapeGeometry, number[]>>;
266
+ /** A geometry's adjustments when none is set: its preset's own (ECMA-376's definitions), python-pptx's shares. */
267
+ export declare const adjustmentDefaults: (geometry: string) => number[];
252
268
  /** python-pptx's `Adjustments`: `shape.adjustments[0] = 0.1`. */
253
269
  export declare class Adjustments {
254
270
  [i: number]: number;
@@ -283,13 +299,13 @@ export declare class Shape {
283
299
  type: PlaceholderType;
284
300
  idx: number;
285
301
  };
286
- get left(): Length;
302
+ get left(): LengthValue;
287
303
  set left(v: Length);
288
- get top(): Length;
304
+ get top(): LengthValue;
289
305
  set top(v: Length);
290
- get width(): Length;
306
+ get width(): LengthValue;
291
307
  set width(v: Length);
292
- get height(): Length;
308
+ get height(): LengthValue;
293
309
  set height(v: Length);
294
310
  /** Degrees clockwise about its centre; python-pptx's, kept from 0 up to 360. */
295
311
  get rotation(): number;
@@ -343,14 +359,14 @@ export declare class GroupShape {
343
359
  get shape_type(): ShapeType;
344
360
  get name(): string;
345
361
  set name(v: string);
346
- get left(): Length;
362
+ get left(): LengthValue;
347
363
  /** Moves its shapes with it. */
348
364
  set left(v: Length);
349
- get top(): Length;
365
+ get top(): LengthValue;
350
366
  /** Moves its shapes with it. */
351
367
  set top(v: Length);
352
- get width(): Length;
353
- get height(): Length;
368
+ get width(): LengthValue;
369
+ get height(): LengthValue;
354
370
  }
355
371
  /** python-pptx's `_Cell`. */
356
372
  export declare class Cell {
@@ -366,13 +382,13 @@ export declare class Cell {
366
382
  /** Its edges, each a colour and a width; python-pptx has none (`a:lnL`…). */
367
383
  get borders(): NonNullable<TableCellDef["borders"]>;
368
384
  set borders(v: NonNullable<TableCellDef["borders"]>);
369
- get margin_left(): Length;
385
+ get margin_left(): LengthValue;
370
386
  set margin_left(v: Length);
371
- get margin_right(): Length;
387
+ get margin_right(): LengthValue;
372
388
  set margin_right(v: Length);
373
- get margin_top(): Length;
389
+ get margin_top(): LengthValue;
374
390
  set margin_top(v: Length);
375
- get margin_bottom(): Length;
391
+ get margin_bottom(): LengthValue;
376
392
  set margin_bottom(v: Length);
377
393
  get vertical_anchor(): Anchor | undefined;
378
394
  set vertical_anchor(v: Anchor | undefined);
@@ -390,7 +406,7 @@ export declare class Column {
390
406
  private readonly def;
391
407
  private readonly at;
392
408
  constructor(def: TableDef, at: number);
393
- get width(): Length;
409
+ get width(): LengthValue;
394
410
  set width(v: Length);
395
411
  }
396
412
  /** python-pptx's `_Row`. */
@@ -399,7 +415,7 @@ export declare class Row {
399
415
  private readonly at;
400
416
  constructor(def: TableDef, at: number);
401
417
  private get row();
402
- get height(): Length;
418
+ get height(): LengthValue;
403
419
  set height(v: Length);
404
420
  }
405
421
  /** python-pptx's `Table`. */
@@ -468,7 +484,11 @@ export declare class ShapeCollection implements Iterable<Shape> {
468
484
  add_group_shape(): GroupShape;
469
485
  /** A freeform's builder (python-pptx's build_freeform): filled and outlined as an autoshape. */
470
486
  build_freeform(start_x?: number, start_y?: number, scale?: number | readonly [number, number]): FreeformBuilder;
471
- /** A straight line from one point to another (MSO_CONNECTOR.STRAIGHT). */
487
+ /**
488
+ * A connector from one point to another: MSO_CONNECTOR's straight line,
489
+ * elbow or curve, or a connector's preset by name where python-pptx has
490
+ * none (`straightConnector1`, `bentConnector2`…`5`, `curvedConnector2`…`5`).
491
+ */
472
492
  add_connector(connector_type: ShapeGeometry, begin_x: Length, begin_y: Length, end_x: Length, end_y: Length): Shape;
473
493
  /** A component of the presentation (`prs.components.add`), drawn by its code in the frame (an extension). */
474
494
  add_component(component: string, left: Length, top: Length, width: Length, height: Length, props?: Record<string, unknown>): Shape;
@@ -644,9 +664,9 @@ export declare class Presentation {
644
664
  readonly _ctx: Context;
645
665
  constructor(size: readonly [Length, Length], base: string);
646
666
  get _def(): DeckDef;
647
- get slide_width(): Length;
667
+ get slide_width(): LengthValue;
648
668
  set slide_width(v: Length);
649
- get slide_height(): Length;
669
+ get slide_height(): LengthValue;
650
670
  set slide_height(v: Length);
651
671
  get slide_masters(): SlideMasters;
652
672
  /** The first master (python-pptx's `slide_master`). */