@cj-tech-master/excelts 9.4.2 → 9.5.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 (618) hide show
  1. package/dist/browser/index.browser.d.ts +8 -5
  2. package/dist/browser/index.browser.js +19 -1
  3. package/dist/browser/index.d.ts +4 -2
  4. package/dist/browser/index.js +9 -1
  5. package/dist/browser/modules/excel/chart/cache-populator.d.ts +49 -0
  6. package/dist/browser/modules/excel/chart/cache-populator.js +1171 -0
  7. package/dist/browser/modules/excel/chart/chart-api.d.ts +92 -0
  8. package/dist/browser/modules/excel/chart/chart-api.js +364 -0
  9. package/dist/browser/modules/excel/chart/chart-builder.d.ts +48 -0
  10. package/dist/browser/modules/excel/chart/chart-builder.js +2432 -0
  11. package/dist/browser/modules/excel/chart/chart-ex-builder.d.ts +36 -0
  12. package/dist/browser/modules/excel/chart/chart-ex-builder.js +903 -0
  13. package/dist/browser/modules/excel/chart/chart-ex-parser.d.ts +8 -0
  14. package/dist/browser/modules/excel/chart/chart-ex-parser.js +1205 -0
  15. package/dist/browser/modules/excel/chart/chart-ex-renderer.d.ts +187 -0
  16. package/dist/browser/modules/excel/chart/chart-ex-renderer.js +5352 -0
  17. package/dist/browser/modules/excel/chart/chart-ex-types.d.ts +531 -0
  18. package/dist/browser/modules/excel/chart/chart-ex-types.js +11 -0
  19. package/dist/browser/modules/excel/chart/chart-images.d.ts +78 -0
  20. package/dist/browser/modules/excel/chart/chart-images.js +363 -0
  21. package/dist/browser/modules/excel/chart/chart-presets.d.ts +392 -0
  22. package/dist/browser/modules/excel/chart/chart-presets.js +179 -0
  23. package/dist/browser/modules/excel/chart/chart-renderer.d.ts +550 -0
  24. package/dist/browser/modules/excel/chart/chart-renderer.js +6440 -0
  25. package/dist/browser/modules/excel/chart/chart-sidecar.d.ts +21 -0
  26. package/dist/browser/modules/excel/chart/chart-sidecar.js +427 -0
  27. package/dist/browser/modules/excel/chart/chart-utils.d.ts +306 -0
  28. package/dist/browser/modules/excel/chart/chart-utils.js +821 -0
  29. package/dist/browser/modules/excel/chart/chart.d.ts +504 -0
  30. package/dist/browser/modules/excel/chart/chart.js +1320 -0
  31. package/dist/browser/modules/excel/chart/glyph-rasterizer.d.ts +62 -0
  32. package/dist/browser/modules/excel/chart/glyph-rasterizer.js +658 -0
  33. package/dist/browser/modules/excel/chart/index.d.ts +54 -0
  34. package/dist/browser/modules/excel/chart/index.js +46 -0
  35. package/dist/browser/modules/excel/chart/install.d.ts +44 -0
  36. package/dist/browser/modules/excel/chart/install.js +91 -0
  37. package/dist/browser/modules/excel/chart/shape-properties.d.ts +156 -0
  38. package/dist/browser/modules/excel/chart/shape-properties.js +1557 -0
  39. package/dist/browser/modules/excel/chart/stroke-font.d.ts +36 -0
  40. package/dist/browser/modules/excel/chart/stroke-font.js +1556 -0
  41. package/dist/browser/modules/excel/chart/topojson.d.ts +98 -0
  42. package/dist/browser/modules/excel/chart/topojson.js +236 -0
  43. package/dist/browser/modules/excel/chart/types.d.ts +2559 -0
  44. package/dist/browser/modules/excel/chart/types.js +8 -0
  45. package/dist/browser/modules/excel/chart-host-registry.d.ts +157 -0
  46. package/dist/browser/modules/excel/chart-host-registry.js +90 -0
  47. package/dist/browser/modules/excel/chartsheet.d.ts +102 -0
  48. package/dist/browser/modules/excel/chartsheet.js +196 -0
  49. package/dist/browser/modules/excel/defined-names.d.ts +35 -0
  50. package/dist/browser/modules/excel/defined-names.js +44 -4
  51. package/dist/browser/modules/excel/errors.d.ts +6 -0
  52. package/dist/browser/modules/excel/errors.js +9 -0
  53. package/dist/browser/modules/excel/form-control.d.ts +6 -0
  54. package/dist/browser/modules/excel/form-control.js +17 -0
  55. package/dist/browser/modules/excel/image.js +12 -2
  56. package/dist/browser/modules/excel/pivot-chart.d.ts +7 -0
  57. package/dist/browser/modules/excel/pivot-chart.js +53 -0
  58. package/dist/browser/modules/excel/pivot-table.d.ts +55 -0
  59. package/dist/browser/modules/excel/pivot-table.js +35 -0
  60. package/dist/browser/modules/excel/range.js +5 -1
  61. package/dist/browser/modules/excel/sparkline/index.d.ts +7 -0
  62. package/dist/browser/modules/excel/sparkline/index.js +7 -0
  63. package/dist/browser/modules/excel/sparkline/sparkline.d.ts +206 -0
  64. package/dist/browser/modules/excel/sparkline/sparkline.js +750 -0
  65. package/dist/browser/modules/excel/stream/worksheet-writer.js +3 -2
  66. package/dist/browser/modules/excel/table.js +42 -6
  67. package/dist/browser/modules/excel/types.d.ts +72 -0
  68. package/dist/browser/modules/excel/utils/address.d.ts +18 -0
  69. package/dist/browser/modules/excel/utils/address.js +28 -0
  70. package/dist/browser/modules/excel/utils/drawing-utils.js +11 -6
  71. package/dist/browser/modules/excel/utils/guid.d.ts +15 -0
  72. package/dist/browser/modules/excel/utils/guid.js +35 -0
  73. package/dist/browser/modules/excel/utils/ooxml-paths.d.ts +74 -0
  74. package/dist/browser/modules/excel/utils/ooxml-paths.js +206 -9
  75. package/dist/browser/modules/excel/utils/ooxml-validator/check-chart-sidecar.d.ts +35 -0
  76. package/dist/browser/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +101 -0
  77. package/dist/browser/modules/excel/utils/ooxml-validator/check-chart.d.ts +32 -0
  78. package/dist/browser/modules/excel/utils/ooxml-validator/check-chart.js +2125 -0
  79. package/dist/browser/modules/excel/utils/ooxml-validator/check-chartsheet.d.ts +9 -0
  80. package/dist/browser/modules/excel/utils/ooxml-validator/check-chartsheet.js +26 -0
  81. package/dist/browser/modules/excel/utils/ooxml-validator/check-content-types.d.ts +16 -0
  82. package/dist/browser/modules/excel/utils/ooxml-validator/check-content-types.js +181 -0
  83. package/dist/browser/modules/excel/utils/ooxml-validator/check-drawing.d.ts +34 -0
  84. package/dist/browser/modules/excel/utils/ooxml-validator/check-drawing.js +267 -0
  85. package/dist/browser/modules/excel/utils/ooxml-validator/check-pivot.d.ts +14 -0
  86. package/dist/browser/modules/excel/utils/ooxml-validator/check-pivot.js +104 -0
  87. package/dist/browser/modules/excel/utils/ooxml-validator/check-relationships.d.ts +18 -0
  88. package/dist/browser/modules/excel/utils/ooxml-validator/check-relationships.js +184 -0
  89. package/dist/browser/modules/excel/utils/ooxml-validator/check-structure.d.ts +21 -0
  90. package/dist/browser/modules/excel/utils/ooxml-validator/check-structure.js +56 -0
  91. package/dist/browser/modules/excel/utils/ooxml-validator/check-styles.d.ts +15 -0
  92. package/dist/browser/modules/excel/utils/ooxml-validator/check-styles.js +89 -0
  93. package/dist/browser/modules/excel/utils/ooxml-validator/check-table.d.ts +31 -0
  94. package/dist/browser/modules/excel/utils/ooxml-validator/check-table.js +177 -0
  95. package/dist/browser/modules/excel/utils/ooxml-validator/check-workbook.d.ts +19 -0
  96. package/dist/browser/modules/excel/utils/ooxml-validator/check-workbook.js +163 -0
  97. package/dist/browser/modules/excel/utils/ooxml-validator/check-worksheet.d.ts +25 -0
  98. package/dist/browser/modules/excel/utils/ooxml-validator/check-worksheet.js +569 -0
  99. package/dist/browser/modules/excel/utils/ooxml-validator/context.d.ts +85 -0
  100. package/dist/browser/modules/excel/utils/ooxml-validator/context.js +191 -0
  101. package/dist/browser/modules/excel/utils/ooxml-validator/index.d.ts +31 -0
  102. package/dist/browser/modules/excel/utils/ooxml-validator/index.js +102 -0
  103. package/dist/browser/modules/excel/utils/ooxml-validator/path-utils.d.ts +67 -0
  104. package/dist/browser/modules/excel/utils/ooxml-validator/path-utils.js +156 -0
  105. package/dist/browser/modules/excel/utils/ooxml-validator/reporter.d.ts +41 -0
  106. package/dist/browser/modules/excel/utils/ooxml-validator/reporter.js +61 -0
  107. package/dist/browser/modules/excel/utils/ooxml-validator/types.d.ts +109 -0
  108. package/dist/browser/modules/excel/utils/ooxml-validator/types.js +12 -0
  109. package/dist/browser/modules/excel/utils/ooxml-validator/xml-utils.d.ts +38 -0
  110. package/dist/browser/modules/excel/utils/ooxml-validator/xml-utils.js +100 -0
  111. package/dist/browser/modules/excel/workbook.browser.d.ts +248 -30
  112. package/dist/browser/modules/excel/workbook.browser.js +966 -31
  113. package/dist/browser/modules/excel/workbook.d.ts +43 -0
  114. package/dist/browser/modules/excel/workbook.js +48 -0
  115. package/dist/browser/modules/excel/worksheet.d.ts +157 -3
  116. package/dist/browser/modules/excel/worksheet.js +394 -35
  117. package/dist/browser/modules/excel/xlsx/rel-type.d.ts +40 -0
  118. package/dist/browser/modules/excel/xlsx/rel-type.js +41 -1
  119. package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +1 -0
  120. package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
  121. package/dist/browser/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
  122. package/dist/browser/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
  123. package/dist/browser/modules/excel/xlsx/xform/chart/chart-space-xform.d.ts +353 -0
  124. package/dist/browser/modules/excel/xlsx/xform/chart/chart-space-xform.js +6000 -0
  125. package/dist/browser/modules/excel/xlsx/xform/comment/threaded-comments-xform.d.ts +60 -0
  126. package/dist/browser/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +213 -0
  127. package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +150 -11
  128. package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
  129. package/dist/browser/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
  130. package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +30 -0
  131. package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
  132. package/dist/browser/modules/excel/xlsx/xform/drawing/graphic-frame-xform.d.ts +54 -0
  133. package/dist/browser/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +225 -0
  134. package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +3 -1
  135. package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
  136. package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +46 -0
  137. package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
  138. package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +13 -2
  139. package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
  140. package/dist/browser/modules/excel/xlsx/xform/sheet/chartsheet-xform.d.ts +185 -0
  141. package/dist/browser/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +441 -0
  142. package/dist/browser/modules/excel/xlsx/xform/sheet/ext-lst-xform.d.ts +1 -0
  143. package/dist/browser/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
  144. package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +196 -20
  145. package/dist/browser/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
  146. package/dist/browser/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
  147. package/dist/browser/modules/excel/xlsx/xform/xsd-values.d.ts +63 -0
  148. package/dist/browser/modules/excel/xlsx/xform/xsd-values.js +101 -0
  149. package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +115 -21
  150. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +4422 -78
  151. package/dist/browser/modules/pdf/builder/document-builder.d.ts +74 -0
  152. package/dist/browser/modules/pdf/builder/document-builder.js +507 -2
  153. package/dist/browser/modules/pdf/builder/pdf-editor.js +48 -3
  154. package/dist/browser/modules/pdf/excel-bridge.d.ts +69 -0
  155. package/dist/browser/modules/pdf/excel-bridge.js +683 -12
  156. package/dist/browser/modules/pdf/font/font-manager.d.ts +25 -0
  157. package/dist/browser/modules/pdf/font/font-manager.js +39 -0
  158. package/dist/browser/modules/pdf/index.d.ts +5 -2
  159. package/dist/browser/modules/pdf/index.js +3 -1
  160. package/dist/browser/modules/pdf/render/chart-surface.d.ts +33 -0
  161. package/dist/browser/modules/pdf/render/chart-surface.js +200 -0
  162. package/dist/browser/modules/pdf/render/layout-engine.d.ts +22 -1
  163. package/dist/browser/modules/pdf/render/layout-engine.js +436 -56
  164. package/dist/browser/modules/pdf/render/page-renderer.js +169 -28
  165. package/dist/browser/modules/pdf/render/pdf-exporter.js +117 -7
  166. package/dist/browser/modules/pdf/types.d.ts +227 -23
  167. package/dist/browser/modules/pdf/types.js +4 -0
  168. package/dist/browser/modules/pdf/word-bridge.d.ts +47 -0
  169. package/dist/browser/modules/pdf/word-bridge.js +304 -0
  170. package/dist/browser/modules/word/constants.d.ts +179 -0
  171. package/dist/browser/modules/word/constants.js +231 -0
  172. package/dist/browser/modules/word/content-types.d.ts +27 -0
  173. package/dist/browser/modules/word/content-types.js +53 -0
  174. package/dist/browser/modules/word/digital-signatures.d.ts +87 -0
  175. package/dist/browser/modules/word/digital-signatures.js +134 -0
  176. package/dist/browser/modules/word/document.d.ts +728 -0
  177. package/dist/browser/modules/word/document.js +1795 -0
  178. package/dist/browser/modules/word/docx-packager.d.ts +14 -0
  179. package/dist/browser/modules/word/docx-packager.js +822 -0
  180. package/dist/browser/modules/word/docx-reader.d.ts +11 -0
  181. package/dist/browser/modules/word/docx-reader.js +4929 -0
  182. package/dist/browser/modules/word/encryption.d.ts +102 -0
  183. package/dist/browser/modules/word/encryption.js +274 -0
  184. package/dist/browser/modules/word/errors.d.ts +49 -0
  185. package/dist/browser/modules/word/errors.js +68 -0
  186. package/dist/browser/modules/word/font-obfuscation.d.ts +31 -0
  187. package/dist/browser/modules/word/font-obfuscation.js +83 -0
  188. package/dist/browser/modules/word/html-renderer.d.ts +38 -0
  189. package/dist/browser/modules/word/html-renderer.js +782 -0
  190. package/dist/browser/modules/word/index.base.d.ts +19 -0
  191. package/dist/browser/modules/word/index.base.js +51 -0
  192. package/dist/browser/modules/word/index.browser.d.ts +4 -0
  193. package/dist/browser/modules/word/index.browser.js +4 -0
  194. package/dist/browser/modules/word/index.d.ts +4 -0
  195. package/dist/browser/modules/word/index.js +4 -0
  196. package/dist/browser/modules/word/internal-utils.d.ts +23 -0
  197. package/dist/browser/modules/word/internal-utils.js +54 -0
  198. package/dist/browser/modules/word/relationships.d.ts +31 -0
  199. package/dist/browser/modules/word/relationships.js +56 -0
  200. package/dist/browser/modules/word/types.d.ts +2325 -0
  201. package/dist/browser/modules/word/types.js +10 -0
  202. package/dist/browser/modules/word/units.d.ts +49 -0
  203. package/dist/browser/modules/word/units.js +111 -0
  204. package/dist/browser/modules/word/writers/chart-writer.d.ts +10 -0
  205. package/dist/browser/modules/word/writers/chart-writer.js +385 -0
  206. package/dist/browser/modules/word/writers/checkbox-writer.d.ts +9 -0
  207. package/dist/browser/modules/word/writers/checkbox-writer.js +42 -0
  208. package/dist/browser/modules/word/writers/comment-writer.d.ts +15 -0
  209. package/dist/browser/modules/word/writers/comment-writer.js +70 -0
  210. package/dist/browser/modules/word/writers/document-writer.d.ts +16 -0
  211. package/dist/browser/modules/word/writers/document-writer.js +461 -0
  212. package/dist/browser/modules/word/writers/footnote-writer.d.ts +11 -0
  213. package/dist/browser/modules/word/writers/footnote-writer.js +72 -0
  214. package/dist/browser/modules/word/writers/header-footer-writer.d.ts +13 -0
  215. package/dist/browser/modules/word/writers/header-footer-writer.js +129 -0
  216. package/dist/browser/modules/word/writers/image-writer.d.ts +10 -0
  217. package/dist/browser/modules/word/writers/image-writer.js +185 -0
  218. package/dist/browser/modules/word/writers/math-writer.d.ts +9 -0
  219. package/dist/browser/modules/word/writers/math-writer.js +428 -0
  220. package/dist/browser/modules/word/writers/numbering-writer.d.ts +10 -0
  221. package/dist/browser/modules/word/writers/numbering-writer.js +125 -0
  222. package/dist/browser/modules/word/writers/paragraph-writer.d.ts +13 -0
  223. package/dist/browser/modules/word/writers/paragraph-writer.js +516 -0
  224. package/dist/browser/modules/word/writers/parts-writer.d.ts +26 -0
  225. package/dist/browser/modules/word/writers/parts-writer.js +660 -0
  226. package/dist/browser/modules/word/writers/run-writer.d.ts +15 -0
  227. package/dist/browser/modules/word/writers/run-writer.js +649 -0
  228. package/dist/browser/modules/word/writers/section-writer.d.ts +10 -0
  229. package/dist/browser/modules/word/writers/section-writer.js +238 -0
  230. package/dist/browser/modules/word/writers/styles-writer.d.ts +10 -0
  231. package/dist/browser/modules/word/writers/styles-writer.js +242 -0
  232. package/dist/browser/modules/word/writers/table-writer.d.ts +10 -0
  233. package/dist/browser/modules/word/writers/table-writer.js +503 -0
  234. package/dist/browser/modules/word/writers/textbox-writer.d.ts +9 -0
  235. package/dist/browser/modules/word/writers/textbox-writer.js +53 -0
  236. package/dist/browser/modules/word/writers/toc-writer.d.ts +9 -0
  237. package/dist/browser/modules/word/writers/toc-writer.js +79 -0
  238. package/dist/browser/modules/xml/encode.d.ts +56 -7
  239. package/dist/browser/modules/xml/encode.js +157 -11
  240. package/dist/cjs/index.js +13 -2
  241. package/dist/cjs/modules/excel/chart/cache-populator.js +1178 -0
  242. package/dist/cjs/modules/excel/chart/chart-api.js +371 -0
  243. package/dist/cjs/modules/excel/chart/chart-builder.js +2440 -0
  244. package/dist/cjs/modules/excel/chart/chart-ex-builder.js +907 -0
  245. package/dist/cjs/modules/excel/chart/chart-ex-parser.js +1208 -0
  246. package/dist/cjs/modules/excel/chart/chart-ex-renderer.js +5364 -0
  247. package/dist/cjs/modules/excel/chart/chart-ex-types.js +12 -0
  248. package/dist/cjs/modules/excel/chart/chart-images.js +366 -0
  249. package/dist/cjs/modules/excel/chart/chart-presets.js +184 -0
  250. package/dist/cjs/modules/excel/chart/chart-renderer.js +6450 -0
  251. package/dist/cjs/modules/excel/chart/chart-sidecar.js +433 -0
  252. package/dist/cjs/modules/excel/chart/chart-utils.js +845 -0
  253. package/dist/cjs/modules/excel/chart/chart.js +1324 -0
  254. package/dist/cjs/modules/excel/chart/glyph-rasterizer.js +664 -0
  255. package/dist/cjs/modules/excel/chart/index.js +101 -0
  256. package/dist/cjs/modules/excel/chart/install.js +95 -0
  257. package/dist/cjs/modules/excel/chart/shape-properties.js +1577 -0
  258. package/dist/cjs/modules/excel/chart/stroke-font.js +1559 -0
  259. package/dist/cjs/modules/excel/chart/topojson.js +239 -0
  260. package/dist/cjs/modules/excel/chart/types.js +9 -0
  261. package/dist/cjs/modules/excel/chart-host-registry.js +96 -0
  262. package/dist/cjs/modules/excel/chartsheet.js +199 -0
  263. package/dist/cjs/modules/excel/defined-names.js +44 -4
  264. package/dist/cjs/modules/excel/errors.js +11 -1
  265. package/dist/cjs/modules/excel/form-control.js +17 -0
  266. package/dist/cjs/modules/excel/image.js +12 -2
  267. package/dist/cjs/modules/excel/pivot-chart.js +56 -0
  268. package/dist/cjs/modules/excel/pivot-table.js +35 -0
  269. package/dist/cjs/modules/excel/range.js +5 -1
  270. package/dist/cjs/modules/excel/sparkline/index.js +23 -0
  271. package/dist/cjs/modules/excel/sparkline/sparkline.js +756 -0
  272. package/dist/cjs/modules/excel/stream/worksheet-writer.js +3 -2
  273. package/dist/cjs/modules/excel/table.js +42 -6
  274. package/dist/cjs/modules/excel/utils/address.js +29 -0
  275. package/dist/cjs/modules/excel/utils/drawing-utils.js +11 -6
  276. package/dist/cjs/modules/excel/utils/guid.js +38 -0
  277. package/dist/cjs/modules/excel/utils/ooxml-paths.js +246 -9
  278. package/dist/cjs/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +103 -0
  279. package/dist/cjs/modules/excel/utils/ooxml-validator/check-chart.js +2128 -0
  280. package/dist/cjs/modules/excel/utils/ooxml-validator/check-chartsheet.js +29 -0
  281. package/dist/cjs/modules/excel/utils/ooxml-validator/check-content-types.js +184 -0
  282. package/dist/cjs/modules/excel/utils/ooxml-validator/check-drawing.js +270 -0
  283. package/dist/cjs/modules/excel/utils/ooxml-validator/check-pivot.js +107 -0
  284. package/dist/cjs/modules/excel/utils/ooxml-validator/check-relationships.js +188 -0
  285. package/dist/cjs/modules/excel/utils/ooxml-validator/check-structure.js +60 -0
  286. package/dist/cjs/modules/excel/utils/ooxml-validator/check-styles.js +92 -0
  287. package/dist/cjs/modules/excel/utils/ooxml-validator/check-table.js +180 -0
  288. package/dist/cjs/modules/excel/utils/ooxml-validator/check-workbook.js +166 -0
  289. package/dist/cjs/modules/excel/utils/ooxml-validator/check-worksheet.js +572 -0
  290. package/dist/cjs/modules/excel/utils/ooxml-validator/context.js +196 -0
  291. package/dist/cjs/modules/excel/utils/ooxml-validator/index.js +105 -0
  292. package/dist/cjs/modules/excel/utils/ooxml-validator/path-utils.js +168 -0
  293. package/dist/cjs/modules/excel/utils/ooxml-validator/reporter.js +66 -0
  294. package/dist/cjs/modules/excel/utils/ooxml-validator/types.js +13 -0
  295. package/dist/cjs/modules/excel/utils/ooxml-validator/xml-utils.js +110 -0
  296. package/dist/cjs/modules/excel/workbook.browser.js +973 -38
  297. package/dist/cjs/modules/excel/workbook.js +48 -0
  298. package/dist/cjs/modules/excel/worksheet.js +393 -34
  299. package/dist/cjs/modules/excel/xlsx/rel-type.js +41 -1
  300. package/dist/cjs/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
  301. package/dist/cjs/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
  302. package/dist/cjs/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
  303. package/dist/cjs/modules/excel/xlsx/xform/chart/chart-space-xform.js +6003 -0
  304. package/dist/cjs/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +219 -0
  305. package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +149 -10
  306. package/dist/cjs/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
  307. package/dist/cjs/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
  308. package/dist/cjs/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
  309. package/dist/cjs/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +228 -0
  310. package/dist/cjs/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
  311. package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
  312. package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
  313. package/dist/cjs/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +444 -0
  314. package/dist/cjs/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
  315. package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +195 -19
  316. package/dist/cjs/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
  317. package/dist/cjs/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
  318. package/dist/cjs/modules/excel/xlsx/xform/xsd-values.js +106 -0
  319. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +4420 -76
  320. package/dist/cjs/modules/pdf/builder/document-builder.js +506 -1
  321. package/dist/cjs/modules/pdf/builder/pdf-editor.js +48 -3
  322. package/dist/cjs/modules/pdf/excel-bridge.js +684 -12
  323. package/dist/cjs/modules/pdf/font/font-manager.js +39 -0
  324. package/dist/cjs/modules/pdf/index.js +5 -1
  325. package/dist/cjs/modules/pdf/render/chart-surface.js +203 -0
  326. package/dist/cjs/modules/pdf/render/layout-engine.js +437 -56
  327. package/dist/cjs/modules/pdf/render/page-renderer.js +169 -28
  328. package/dist/cjs/modules/pdf/render/pdf-exporter.js +115 -5
  329. package/dist/cjs/modules/pdf/types.js +5 -0
  330. package/dist/cjs/modules/pdf/word-bridge.js +307 -0
  331. package/dist/cjs/modules/word/constants.js +234 -0
  332. package/dist/cjs/modules/word/content-types.js +57 -0
  333. package/dist/cjs/modules/word/digital-signatures.js +140 -0
  334. package/dist/cjs/modules/word/document.js +1909 -0
  335. package/dist/cjs/modules/word/docx-packager.js +825 -0
  336. package/dist/cjs/modules/word/docx-reader.js +4932 -0
  337. package/dist/cjs/modules/word/encryption.js +282 -0
  338. package/dist/cjs/modules/word/errors.js +88 -0
  339. package/dist/cjs/modules/word/font-obfuscation.js +88 -0
  340. package/dist/cjs/modules/word/html-renderer.js +785 -0
  341. package/dist/cjs/modules/word/index.base.js +199 -0
  342. package/dist/cjs/modules/word/index.browser.js +20 -0
  343. package/dist/cjs/modules/word/index.js +20 -0
  344. package/dist/cjs/modules/word/internal-utils.js +59 -0
  345. package/dist/cjs/modules/word/relationships.js +60 -0
  346. package/dist/cjs/modules/word/types.js +11 -0
  347. package/dist/cjs/modules/word/units.js +135 -0
  348. package/dist/cjs/modules/word/writers/chart-writer.js +388 -0
  349. package/dist/cjs/modules/word/writers/checkbox-writer.js +45 -0
  350. package/dist/cjs/modules/word/writers/comment-writer.js +74 -0
  351. package/dist/cjs/modules/word/writers/document-writer.js +465 -0
  352. package/dist/cjs/modules/word/writers/footnote-writer.js +76 -0
  353. package/dist/cjs/modules/word/writers/header-footer-writer.js +134 -0
  354. package/dist/cjs/modules/word/writers/image-writer.js +188 -0
  355. package/dist/cjs/modules/word/writers/math-writer.js +431 -0
  356. package/dist/cjs/modules/word/writers/numbering-writer.js +128 -0
  357. package/dist/cjs/modules/word/writers/paragraph-writer.js +521 -0
  358. package/dist/cjs/modules/word/writers/parts-writer.js +671 -0
  359. package/dist/cjs/modules/word/writers/run-writer.js +655 -0
  360. package/dist/cjs/modules/word/writers/section-writer.js +241 -0
  361. package/dist/cjs/modules/word/writers/styles-writer.js +245 -0
  362. package/dist/cjs/modules/word/writers/table-writer.js +506 -0
  363. package/dist/cjs/modules/word/writers/textbox-writer.js +56 -0
  364. package/dist/cjs/modules/word/writers/toc-writer.js +82 -0
  365. package/dist/cjs/modules/xml/encode.js +158 -11
  366. package/dist/esm/index.browser.js +20 -2
  367. package/dist/esm/index.js +9 -1
  368. package/dist/esm/modules/excel/chart/cache-populator.js +1171 -0
  369. package/dist/esm/modules/excel/chart/chart-api.js +364 -0
  370. package/dist/esm/modules/excel/chart/chart-builder.js +2432 -0
  371. package/dist/esm/modules/excel/chart/chart-ex-builder.js +903 -0
  372. package/dist/esm/modules/excel/chart/chart-ex-parser.js +1205 -0
  373. package/dist/esm/modules/excel/chart/chart-ex-renderer.js +5352 -0
  374. package/dist/esm/modules/excel/chart/chart-ex-types.js +11 -0
  375. package/dist/esm/modules/excel/chart/chart-images.js +363 -0
  376. package/dist/esm/modules/excel/chart/chart-presets.js +179 -0
  377. package/dist/esm/modules/excel/chart/chart-renderer.js +6440 -0
  378. package/dist/esm/modules/excel/chart/chart-sidecar.js +427 -0
  379. package/dist/esm/modules/excel/chart/chart-utils.js +821 -0
  380. package/dist/esm/modules/excel/chart/chart.js +1320 -0
  381. package/dist/esm/modules/excel/chart/glyph-rasterizer.js +658 -0
  382. package/dist/esm/modules/excel/chart/index.js +46 -0
  383. package/dist/esm/modules/excel/chart/install.js +91 -0
  384. package/dist/esm/modules/excel/chart/shape-properties.js +1557 -0
  385. package/dist/esm/modules/excel/chart/stroke-font.js +1556 -0
  386. package/dist/esm/modules/excel/chart/topojson.js +236 -0
  387. package/dist/esm/modules/excel/chart/types.js +8 -0
  388. package/dist/esm/modules/excel/chart-host-registry.js +90 -0
  389. package/dist/esm/modules/excel/chartsheet.js +196 -0
  390. package/dist/esm/modules/excel/defined-names.js +44 -4
  391. package/dist/esm/modules/excel/errors.js +9 -0
  392. package/dist/esm/modules/excel/form-control.js +17 -0
  393. package/dist/esm/modules/excel/image.js +12 -2
  394. package/dist/esm/modules/excel/pivot-chart.js +53 -0
  395. package/dist/esm/modules/excel/pivot-table.js +35 -0
  396. package/dist/esm/modules/excel/range.js +5 -1
  397. package/dist/esm/modules/excel/sparkline/index.js +7 -0
  398. package/dist/esm/modules/excel/sparkline/sparkline.js +750 -0
  399. package/dist/esm/modules/excel/stream/worksheet-writer.js +3 -2
  400. package/dist/esm/modules/excel/table.js +42 -6
  401. package/dist/esm/modules/excel/utils/address.js +28 -0
  402. package/dist/esm/modules/excel/utils/drawing-utils.js +11 -6
  403. package/dist/esm/modules/excel/utils/guid.js +35 -0
  404. package/dist/esm/modules/excel/utils/ooxml-paths.js +206 -9
  405. package/dist/esm/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +101 -0
  406. package/dist/esm/modules/excel/utils/ooxml-validator/check-chart.js +2125 -0
  407. package/dist/esm/modules/excel/utils/ooxml-validator/check-chartsheet.js +26 -0
  408. package/dist/esm/modules/excel/utils/ooxml-validator/check-content-types.js +181 -0
  409. package/dist/esm/modules/excel/utils/ooxml-validator/check-drawing.js +267 -0
  410. package/dist/esm/modules/excel/utils/ooxml-validator/check-pivot.js +104 -0
  411. package/dist/esm/modules/excel/utils/ooxml-validator/check-relationships.js +184 -0
  412. package/dist/esm/modules/excel/utils/ooxml-validator/check-structure.js +56 -0
  413. package/dist/esm/modules/excel/utils/ooxml-validator/check-styles.js +89 -0
  414. package/dist/esm/modules/excel/utils/ooxml-validator/check-table.js +177 -0
  415. package/dist/esm/modules/excel/utils/ooxml-validator/check-workbook.js +163 -0
  416. package/dist/esm/modules/excel/utils/ooxml-validator/check-worksheet.js +569 -0
  417. package/dist/esm/modules/excel/utils/ooxml-validator/context.js +191 -0
  418. package/dist/esm/modules/excel/utils/ooxml-validator/index.js +102 -0
  419. package/dist/esm/modules/excel/utils/ooxml-validator/path-utils.js +156 -0
  420. package/dist/esm/modules/excel/utils/ooxml-validator/reporter.js +61 -0
  421. package/dist/esm/modules/excel/utils/ooxml-validator/types.js +12 -0
  422. package/dist/esm/modules/excel/utils/ooxml-validator/xml-utils.js +100 -0
  423. package/dist/esm/modules/excel/workbook.browser.js +969 -34
  424. package/dist/esm/modules/excel/workbook.js +48 -0
  425. package/dist/esm/modules/excel/worksheet.js +394 -35
  426. package/dist/esm/modules/excel/xlsx/rel-type.js +41 -1
  427. package/dist/esm/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
  428. package/dist/esm/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
  429. package/dist/esm/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
  430. package/dist/esm/modules/excel/xlsx/xform/chart/chart-space-xform.js +6000 -0
  431. package/dist/esm/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +213 -0
  432. package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +150 -11
  433. package/dist/esm/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
  434. package/dist/esm/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
  435. package/dist/esm/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
  436. package/dist/esm/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +225 -0
  437. package/dist/esm/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
  438. package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
  439. package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
  440. package/dist/esm/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +441 -0
  441. package/dist/esm/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
  442. package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +196 -20
  443. package/dist/esm/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
  444. package/dist/esm/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
  445. package/dist/esm/modules/excel/xlsx/xform/xsd-values.js +101 -0
  446. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +4422 -78
  447. package/dist/esm/modules/pdf/builder/document-builder.js +507 -2
  448. package/dist/esm/modules/pdf/builder/pdf-editor.js +48 -3
  449. package/dist/esm/modules/pdf/excel-bridge.js +683 -12
  450. package/dist/esm/modules/pdf/font/font-manager.js +39 -0
  451. package/dist/esm/modules/pdf/index.js +3 -1
  452. package/dist/esm/modules/pdf/render/chart-surface.js +200 -0
  453. package/dist/esm/modules/pdf/render/layout-engine.js +436 -56
  454. package/dist/esm/modules/pdf/render/page-renderer.js +169 -28
  455. package/dist/esm/modules/pdf/render/pdf-exporter.js +117 -7
  456. package/dist/esm/modules/pdf/types.js +4 -0
  457. package/dist/esm/modules/pdf/word-bridge.js +304 -0
  458. package/dist/esm/modules/word/constants.js +231 -0
  459. package/dist/esm/modules/word/content-types.js +53 -0
  460. package/dist/esm/modules/word/digital-signatures.js +134 -0
  461. package/dist/esm/modules/word/document.js +1795 -0
  462. package/dist/esm/modules/word/docx-packager.js +822 -0
  463. package/dist/esm/modules/word/docx-reader.js +4929 -0
  464. package/dist/esm/modules/word/encryption.js +274 -0
  465. package/dist/esm/modules/word/errors.js +68 -0
  466. package/dist/esm/modules/word/font-obfuscation.js +83 -0
  467. package/dist/esm/modules/word/html-renderer.js +782 -0
  468. package/dist/esm/modules/word/index.base.js +51 -0
  469. package/dist/esm/modules/word/index.browser.js +4 -0
  470. package/dist/esm/modules/word/index.js +4 -0
  471. package/dist/esm/modules/word/internal-utils.js +54 -0
  472. package/dist/esm/modules/word/relationships.js +56 -0
  473. package/dist/esm/modules/word/types.js +10 -0
  474. package/dist/esm/modules/word/units.js +111 -0
  475. package/dist/esm/modules/word/writers/chart-writer.js +385 -0
  476. package/dist/esm/modules/word/writers/checkbox-writer.js +42 -0
  477. package/dist/esm/modules/word/writers/comment-writer.js +70 -0
  478. package/dist/esm/modules/word/writers/document-writer.js +461 -0
  479. package/dist/esm/modules/word/writers/footnote-writer.js +72 -0
  480. package/dist/esm/modules/word/writers/header-footer-writer.js +129 -0
  481. package/dist/esm/modules/word/writers/image-writer.js +185 -0
  482. package/dist/esm/modules/word/writers/math-writer.js +428 -0
  483. package/dist/esm/modules/word/writers/numbering-writer.js +125 -0
  484. package/dist/esm/modules/word/writers/paragraph-writer.js +516 -0
  485. package/dist/esm/modules/word/writers/parts-writer.js +660 -0
  486. package/dist/esm/modules/word/writers/run-writer.js +649 -0
  487. package/dist/esm/modules/word/writers/section-writer.js +238 -0
  488. package/dist/esm/modules/word/writers/styles-writer.js +242 -0
  489. package/dist/esm/modules/word/writers/table-writer.js +503 -0
  490. package/dist/esm/modules/word/writers/textbox-writer.js +53 -0
  491. package/dist/esm/modules/word/writers/toc-writer.js +79 -0
  492. package/dist/esm/modules/xml/encode.js +157 -11
  493. package/dist/iife/excelts.iife.js +11789 -687
  494. package/dist/iife/excelts.iife.js.map +1 -1
  495. package/dist/iife/excelts.iife.min.js +52 -44
  496. package/dist/types/index.browser.d.ts +8 -5
  497. package/dist/types/index.d.ts +4 -2
  498. package/dist/types/modules/excel/chart/cache-populator.d.ts +49 -0
  499. package/dist/types/modules/excel/chart/chart-api.d.ts +92 -0
  500. package/dist/types/modules/excel/chart/chart-builder.d.ts +48 -0
  501. package/dist/types/modules/excel/chart/chart-ex-builder.d.ts +36 -0
  502. package/dist/types/modules/excel/chart/chart-ex-parser.d.ts +8 -0
  503. package/dist/types/modules/excel/chart/chart-ex-renderer.d.ts +187 -0
  504. package/dist/types/modules/excel/chart/chart-ex-types.d.ts +531 -0
  505. package/dist/types/modules/excel/chart/chart-images.d.ts +78 -0
  506. package/dist/types/modules/excel/chart/chart-presets.d.ts +392 -0
  507. package/dist/types/modules/excel/chart/chart-renderer.d.ts +550 -0
  508. package/dist/types/modules/excel/chart/chart-sidecar.d.ts +21 -0
  509. package/dist/types/modules/excel/chart/chart-utils.d.ts +306 -0
  510. package/dist/types/modules/excel/chart/chart.d.ts +504 -0
  511. package/dist/types/modules/excel/chart/glyph-rasterizer.d.ts +62 -0
  512. package/dist/types/modules/excel/chart/index.d.ts +54 -0
  513. package/dist/types/modules/excel/chart/install.d.ts +44 -0
  514. package/dist/types/modules/excel/chart/shape-properties.d.ts +156 -0
  515. package/dist/types/modules/excel/chart/stroke-font.d.ts +36 -0
  516. package/dist/types/modules/excel/chart/topojson.d.ts +98 -0
  517. package/dist/types/modules/excel/chart/types.d.ts +2559 -0
  518. package/dist/types/modules/excel/chart-host-registry.d.ts +157 -0
  519. package/dist/types/modules/excel/chartsheet.d.ts +102 -0
  520. package/dist/types/modules/excel/defined-names.d.ts +35 -0
  521. package/dist/types/modules/excel/errors.d.ts +6 -0
  522. package/dist/types/modules/excel/form-control.d.ts +6 -0
  523. package/dist/types/modules/excel/pivot-chart.d.ts +7 -0
  524. package/dist/types/modules/excel/pivot-table.d.ts +55 -0
  525. package/dist/types/modules/excel/sparkline/index.d.ts +7 -0
  526. package/dist/types/modules/excel/sparkline/sparkline.d.ts +206 -0
  527. package/dist/types/modules/excel/types.d.ts +72 -0
  528. package/dist/types/modules/excel/utils/address.d.ts +18 -0
  529. package/dist/types/modules/excel/utils/guid.d.ts +15 -0
  530. package/dist/types/modules/excel/utils/ooxml-paths.d.ts +74 -0
  531. package/dist/types/modules/excel/utils/ooxml-validator/check-chart-sidecar.d.ts +35 -0
  532. package/dist/types/modules/excel/utils/ooxml-validator/check-chart.d.ts +32 -0
  533. package/dist/types/modules/excel/utils/ooxml-validator/check-chartsheet.d.ts +9 -0
  534. package/dist/types/modules/excel/utils/ooxml-validator/check-content-types.d.ts +16 -0
  535. package/dist/types/modules/excel/utils/ooxml-validator/check-drawing.d.ts +34 -0
  536. package/dist/types/modules/excel/utils/ooxml-validator/check-pivot.d.ts +14 -0
  537. package/dist/types/modules/excel/utils/ooxml-validator/check-relationships.d.ts +18 -0
  538. package/dist/types/modules/excel/utils/ooxml-validator/check-structure.d.ts +21 -0
  539. package/dist/types/modules/excel/utils/ooxml-validator/check-styles.d.ts +15 -0
  540. package/dist/types/modules/excel/utils/ooxml-validator/check-table.d.ts +31 -0
  541. package/dist/types/modules/excel/utils/ooxml-validator/check-workbook.d.ts +19 -0
  542. package/dist/types/modules/excel/utils/ooxml-validator/check-worksheet.d.ts +25 -0
  543. package/dist/types/modules/excel/utils/ooxml-validator/context.d.ts +85 -0
  544. package/dist/types/modules/excel/utils/ooxml-validator/index.d.ts +31 -0
  545. package/dist/types/modules/excel/utils/ooxml-validator/path-utils.d.ts +67 -0
  546. package/dist/types/modules/excel/utils/ooxml-validator/reporter.d.ts +41 -0
  547. package/dist/types/modules/excel/utils/ooxml-validator/types.d.ts +109 -0
  548. package/dist/types/modules/excel/utils/ooxml-validator/xml-utils.d.ts +38 -0
  549. package/dist/types/modules/excel/workbook.browser.d.ts +248 -30
  550. package/dist/types/modules/excel/workbook.d.ts +43 -0
  551. package/dist/types/modules/excel/worksheet.d.ts +157 -3
  552. package/dist/types/modules/excel/xlsx/rel-type.d.ts +40 -0
  553. package/dist/types/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +1 -0
  554. package/dist/types/modules/excel/xlsx/xform/chart/chart-space-xform.d.ts +353 -0
  555. package/dist/types/modules/excel/xlsx/xform/comment/threaded-comments-xform.d.ts +60 -0
  556. package/dist/types/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +30 -0
  557. package/dist/types/modules/excel/xlsx/xform/drawing/graphic-frame-xform.d.ts +54 -0
  558. package/dist/types/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +3 -1
  559. package/dist/types/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +46 -0
  560. package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +13 -2
  561. package/dist/types/modules/excel/xlsx/xform/sheet/chartsheet-xform.d.ts +185 -0
  562. package/dist/types/modules/excel/xlsx/xform/sheet/ext-lst-xform.d.ts +1 -0
  563. package/dist/types/modules/excel/xlsx/xform/xsd-values.d.ts +63 -0
  564. package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +115 -21
  565. package/dist/types/modules/pdf/builder/document-builder.d.ts +74 -0
  566. package/dist/types/modules/pdf/excel-bridge.d.ts +69 -0
  567. package/dist/types/modules/pdf/font/font-manager.d.ts +25 -0
  568. package/dist/types/modules/pdf/index.d.ts +5 -2
  569. package/dist/types/modules/pdf/render/chart-surface.d.ts +33 -0
  570. package/dist/types/modules/pdf/render/layout-engine.d.ts +22 -1
  571. package/dist/types/modules/pdf/types.d.ts +227 -23
  572. package/dist/types/modules/pdf/word-bridge.d.ts +47 -0
  573. package/dist/types/modules/word/constants.d.ts +179 -0
  574. package/dist/types/modules/word/content-types.d.ts +27 -0
  575. package/dist/types/modules/word/digital-signatures.d.ts +87 -0
  576. package/dist/types/modules/word/document.d.ts +728 -0
  577. package/dist/types/modules/word/docx-packager.d.ts +14 -0
  578. package/dist/types/modules/word/docx-reader.d.ts +11 -0
  579. package/dist/types/modules/word/encryption.d.ts +102 -0
  580. package/dist/types/modules/word/errors.d.ts +49 -0
  581. package/dist/types/modules/word/font-obfuscation.d.ts +31 -0
  582. package/dist/types/modules/word/html-renderer.d.ts +38 -0
  583. package/dist/types/modules/word/index.base.d.ts +19 -0
  584. package/dist/types/modules/word/index.browser.d.ts +4 -0
  585. package/dist/types/modules/word/index.d.ts +4 -0
  586. package/dist/types/modules/word/internal-utils.d.ts +23 -0
  587. package/dist/types/modules/word/relationships.d.ts +31 -0
  588. package/dist/types/modules/word/types.d.ts +2325 -0
  589. package/dist/types/modules/word/units.d.ts +49 -0
  590. package/dist/types/modules/word/writers/chart-writer.d.ts +10 -0
  591. package/dist/types/modules/word/writers/checkbox-writer.d.ts +9 -0
  592. package/dist/types/modules/word/writers/comment-writer.d.ts +15 -0
  593. package/dist/types/modules/word/writers/document-writer.d.ts +16 -0
  594. package/dist/types/modules/word/writers/footnote-writer.d.ts +11 -0
  595. package/dist/types/modules/word/writers/header-footer-writer.d.ts +13 -0
  596. package/dist/types/modules/word/writers/image-writer.d.ts +10 -0
  597. package/dist/types/modules/word/writers/math-writer.d.ts +9 -0
  598. package/dist/types/modules/word/writers/numbering-writer.d.ts +10 -0
  599. package/dist/types/modules/word/writers/paragraph-writer.d.ts +13 -0
  600. package/dist/types/modules/word/writers/parts-writer.d.ts +26 -0
  601. package/dist/types/modules/word/writers/run-writer.d.ts +15 -0
  602. package/dist/types/modules/word/writers/section-writer.d.ts +10 -0
  603. package/dist/types/modules/word/writers/styles-writer.d.ts +10 -0
  604. package/dist/types/modules/word/writers/table-writer.d.ts +10 -0
  605. package/dist/types/modules/word/writers/textbox-writer.d.ts +9 -0
  606. package/dist/types/modules/word/writers/toc-writer.d.ts +9 -0
  607. package/dist/types/modules/xml/encode.d.ts +56 -7
  608. package/package.json +29 -11
  609. package/dist/browser/modules/excel/utils/ooxml-validator.d.ts +0 -48
  610. package/dist/browser/modules/excel/utils/ooxml-validator.js +0 -493
  611. package/dist/browser/modules/excel/utils/passthrough-manager.d.ts +0 -77
  612. package/dist/browser/modules/excel/utils/passthrough-manager.js +0 -129
  613. package/dist/cjs/modules/excel/utils/ooxml-validator.js +0 -499
  614. package/dist/cjs/modules/excel/utils/passthrough-manager.js +0 -133
  615. package/dist/esm/modules/excel/utils/ooxml-validator.js +0 -493
  616. package/dist/esm/modules/excel/utils/passthrough-manager.js +0 -129
  617. package/dist/types/modules/excel/utils/ooxml-validator.d.ts +0 -48
  618. package/dist/types/modules/excel/utils/passthrough-manager.d.ts +0 -77
@@ -0,0 +1,1320 @@
1
+ /**
2
+ * Chart - High-level chart object for worksheet embedding.
3
+ *
4
+ * Similar to Image, a Chart belongs to a Worksheet and carries the
5
+ * structural data needed for both the DrawingML anchor and the
6
+ * standalone chart XML part.
7
+ */
8
+ import { Anchor } from "../anchor.js";
9
+ import { ChartOptionsError } from "../errors.js";
10
+ import { colCache } from "../utils/col-cache.js";
11
+ import { RelType } from "../xlsx/rel-type.js";
12
+ import { fillChartCaches, fillChartExCaches } from "./cache-populator.js";
13
+ import { applyChartSeriesOptionsPatch, buildChartModel, buildChartSeriesForType } from "./chart-builder.js";
14
+ import { renderChartExPng, renderChartExSvg } from "./chart-ex-renderer.js";
15
+ import { resolvePendingChartImages } from "./chart-images.js";
16
+ import { renderChartPng, renderChartSvg } from "./chart-renderer.js";
17
+ import { parseTxPr } from "./shape-properties.js";
18
+ /**
19
+ * Default chart extent when a caller passes a single-cell address. Matches
20
+ * Excel's behaviour on a fresh chart insertion (roughly 10 columns × 15
21
+ * rows). Shared between the initial anchor resolution and {@link Chart._cloneRange}
22
+ * so the two paths cannot drift.
23
+ */
24
+ const DEFAULT_CHART_WIDTH_COLS = 10;
25
+ const DEFAULT_CHART_HEIGHT_ROWS = 15;
26
+ // Pre-compiled regexes for _extractTextFromRawTx.
27
+ // NOTE: These patterns are consumed via `String.prototype.matchAll`, which
28
+ // returns a fresh iterator per call. They are intentionally NOT used with
29
+ // `RegExp.prototype.exec` + shared `lastIndex`, which would interleave state
30
+ // across concurrent callers (multiple titles extracted on the same chart in
31
+ // parallel promise chains).
32
+ //
33
+ // The `<a:t>` open tag may carry attributes — notably `xml:space="preserve"`
34
+ // when the run contains leading / trailing or internal whitespace. The
35
+ // original pattern (`<a:t>…`) missed those, causing the text extractor
36
+ // to skip every preserved-whitespace run. Allow a `>` or any attribute
37
+ // list (`[^>]*>`) to close the open tag.
38
+ const RAW_TX_AT_RE = /<a:t(?:\s[^>]*)?>([\s\S]*?)<\/a:t>/g;
39
+ const RAW_TX_CV_RE = /<c:v(?:\s[^>]*)?>([\s\S]*?)<\/c:v>/g;
40
+ /**
41
+ * A chart embedded in a worksheet.
42
+ *
43
+ * Charts come in two flavours:
44
+ *
45
+ * - **Classic** (`chartNumber` set): a fully-parsed `c:chart` with a
46
+ * {@link ChartModel}. All public accessors (`chartModel`,
47
+ * `chartTypes`, `axes`, series mutators, `style`, `mutate`, …) are
48
+ * backed by the structured model.
49
+ *
50
+ * - **ChartEx** (`chartExNumber` set): Office 2016+ `cx:chart`. The
51
+ * structured model (`chartExModel`) is populated; a parallel
52
+ * `rawXml` buffer is kept so byte-for-byte round-trip is the default
53
+ * when no mutation happens. The high-level accessors that make
54
+ * sense on both flavours (`title`, `legend`, `spPr`, `toSVG`,
55
+ * `toPNG`, `unknownElements`) work uniformly. ChartTypeGroup-level
56
+ * APIs (`chartTypes`, `axes`, `plotArea`, `getAxis`, `categoryAxis`,
57
+ * `valueAxis`, `addSeries`, `removeSeries`, `getSeries`,
58
+ * `updateSeries`, `addSeriesFromOptions`, `seriesCount`, `mutate`,
59
+ * `setStyle`) are classic-only — ChartEx has its own topology that
60
+ * doesn't map cleanly onto the classic group/series abstraction;
61
+ * use {@link Chart.mutateChartEx} for ChartEx mutations.
62
+ */
63
+ class Chart {
64
+ constructor(worksheet, ids, range) {
65
+ this.worksheet = worksheet;
66
+ this.chartNumber = ids.chartNumber ?? 0;
67
+ this.chartExNumber = ids.chartExNumber ?? 0;
68
+ this.range = Chart.parseRange(worksheet, range);
69
+ }
70
+ /** Whether this is an Office 2016+ extended chart (cx:chart) */
71
+ get isChartEx() {
72
+ return this.chartExNumber > 0;
73
+ }
74
+ static parseRange(worksheet, range) {
75
+ if (typeof range === "string") {
76
+ const decoded = colCache.decode(range);
77
+ if ("top" in decoded) {
78
+ return {
79
+ tl: new Anchor(worksheet, { col: decoded.left, row: decoded.top }, -1),
80
+ br: new Anchor(worksheet, { col: decoded.right, row: decoded.bottom }, 0),
81
+ editAs: "twoCell"
82
+ };
83
+ }
84
+ // Single cell — default to DEFAULT_CHART_WIDTH_COLS x DEFAULT_CHART_HEIGHT_ROWS.
85
+ const addr = colCache.decodeAddress(range);
86
+ return {
87
+ tl: new Anchor(worksheet, { col: addr.col, row: addr.row }, -1),
88
+ br: new Anchor(worksheet, {
89
+ col: addr.col + DEFAULT_CHART_WIDTH_COLS,
90
+ row: addr.row + DEFAULT_CHART_HEIGHT_ROWS
91
+ }, 0),
92
+ editAs: "twoCell"
93
+ };
94
+ }
95
+ const parseAnchor = (v) => {
96
+ if (typeof v === "string") {
97
+ return new Anchor(worksheet, v, -1);
98
+ }
99
+ return new Anchor(worksheet, v, 0);
100
+ };
101
+ // Absolute anchor: { pos, ext }. `ext` is mandatory — without it
102
+ // the drawing layer has no extent to emit and the writer would
103
+ // produce `<xdr:ext cx="undefined" cy="undefined"/>`. Reject
104
+ // early so callers see a clear error at the assignment site
105
+ // rather than an opaque serialization failure.
106
+ if ("pos" in range && range.pos !== undefined) {
107
+ if (!range.ext) {
108
+ throw new ChartOptionsError("Chart range with `pos` requires `ext` (absolute anchor needs an explicit EMU extent).");
109
+ }
110
+ return {
111
+ // Absolute anchors have no meaningful "tl" cell, but the drawing layer
112
+ // still requires one — default to (0, 0) with the provided offsets.
113
+ tl: new Anchor(worksheet, { col: 0, row: 0 }, 0),
114
+ pos: range.pos,
115
+ ext: range.ext,
116
+ editAs: range.editAs ?? "absolute"
117
+ };
118
+ }
119
+ // One-cell anchor: { tl, ext } with no bottom-right. We key on
120
+ // `range.br === undefined` (not `"br" in range`) so a caller that
121
+ // passes `{ tl, ext, br: undefined }` still lands here instead of
122
+ // falling through to the two-cell branch, which would then call
123
+ // `parseAnchor(undefined)` and throw from inside the Anchor
124
+ // constructor.
125
+ if ("tl" in range &&
126
+ "ext" in range &&
127
+ range.ext !== undefined &&
128
+ (!("br" in range) || range.br === undefined)) {
129
+ return {
130
+ tl: parseAnchor(range.tl),
131
+ ext: range.ext,
132
+ editAs: range.editAs ?? "oneCell"
133
+ };
134
+ }
135
+ // Two-cell anchor: { tl, br }
136
+ const twoCell = range;
137
+ return {
138
+ tl: parseAnchor(twoCell.tl),
139
+ br: parseAnchor(twoCell.br),
140
+ editAs: twoCell.editAs ?? "twoCell"
141
+ };
142
+ }
143
+ get model() {
144
+ const base = {
145
+ chartNumber: this.chartNumber,
146
+ chartExNumber: this.chartExNumber,
147
+ range: {
148
+ tl: this.range.tl.model,
149
+ br: this.range.br ? this.range.br.model : undefined,
150
+ editAs: this.range.editAs,
151
+ pos: this.range.pos,
152
+ ext: this.range.ext
153
+ }
154
+ };
155
+ return base;
156
+ }
157
+ // ===========================================================================
158
+ // Chart data access
159
+ // ===========================================================================
160
+ /** Get the full ChartModel from the workbook's chart entries (classic charts only) */
161
+ get chartModel() {
162
+ if (this.chartNumber <= 0) {
163
+ return undefined;
164
+ }
165
+ return this.worksheet.workbook.getChartEntry(this.chartNumber)?.model;
166
+ }
167
+ /** Get the structured ChartEx model, when this chart is an Office 2016+ chartEx. */
168
+ get chartExModel() {
169
+ if (this.chartExNumber <= 0) {
170
+ return undefined;
171
+ }
172
+ return this.worksheet.workbook.getChartExStructuredEntry(this.chartExNumber)?.model;
173
+ }
174
+ /**
175
+ * Vendor-extension elements the parser observed but could not map to a
176
+ * structured field. Populated when the chart was loaded from an existing
177
+ * `.xlsx` whose author emitted `c15:`/`cx14:` style extension tags (often
178
+ * MSO-internal; the OOXML spec treats them as implementation-specific).
179
+ *
180
+ * The array is **purely informational** in the default `preserve` writer
181
+ * mode — structural rebuilds keep the raw XML pass-through that contains
182
+ * those tags. In **`strictTemplateMode`** the writer surfaces this list
183
+ * in its failure message when a mutation cannot be expressed as a raw
184
+ * patch, so authors can decide between:
185
+ *
186
+ * 1. Relaxing `strictTemplateMode` and accepting that a rebuild will
187
+ * drop these vendor tags, or
188
+ * 2. Reshaping the mutation to land on a patch-friendly path (for
189
+ * example editing `title` text rather than replacing the whole
190
+ * `c:chart` subtree).
191
+ *
192
+ * Returns `undefined` if the chart was freshly created (no raw XML was
193
+ * ever parsed) or if every child was recognised. See
194
+ * {@link XlsxWriteOptions.strictTemplateMode} for the writer surface.
195
+ */
196
+ get unknownElements() {
197
+ const classic = this.chartModel?.unknownElements;
198
+ if (classic && classic.length > 0) {
199
+ return classic.slice();
200
+ }
201
+ const chartEx = this.chartExModel?.unknownElements;
202
+ if (chartEx && chartEx.length > 0) {
203
+ return chartEx.slice();
204
+ }
205
+ return undefined;
206
+ }
207
+ // ===========================================================================
208
+ // User-shape drawing part (c:userShapes)
209
+ // ===========================================================================
210
+ /**
211
+ * Raw XML bytes of the `c:userShapes` drawing part attached to this
212
+ * chart, or `undefined` when the chart has no user shapes. User
213
+ * shapes are annotation overlays (callouts, arrows, free text) that
214
+ * Excel stores in a separate `xl/drawings/drawingN.xml` part using
215
+ * relative anchors — the OOXML spec keeps their DrawingML schema
216
+ * distinct from worksheet drawings, so the library treats the part
217
+ * as opaque bytes for round-trip and programmatic replacement
218
+ * instead of exposing a full structural API.
219
+ *
220
+ * Classic charts only. Returns `undefined` on chartEx charts (they
221
+ * have their own extension mechanism and do not use `c:userShapes`).
222
+ */
223
+ get userShapesXml() {
224
+ if (this.chartNumber <= 0) {
225
+ return undefined;
226
+ }
227
+ return this.worksheet.workbook.getChartEntry(this.chartNumber)?.userShapesXml;
228
+ }
229
+ /**
230
+ * Replace the `c:userShapes` drawing part for this chart with the
231
+ * supplied raw XML bytes. Passing `undefined` or an empty byte
232
+ * array removes the user-shapes reference entirely (equivalent to
233
+ * {@link removeUserShapes}).
234
+ *
235
+ * The XML must be a complete DrawingML document whose root is a
236
+ * `c:userShapes` element containing `c:relSizeAnchor` /
237
+ * `c:absSizeAnchor` children. The library performs a shallow sanity
238
+ * check only — no schema validation.
239
+ *
240
+ * When a chart did not previously have user shapes, this allocates
241
+ * a new `r:id` and adds the drawing-part rel so the reference is
242
+ * discoverable in `chartN.xml.rels`. When a chart already had user
243
+ * shapes, the existing `r:id` is kept and only the bytes are
244
+ * updated.
245
+ *
246
+ * Classic charts only. Throws on chartEx charts.
247
+ */
248
+ setUserShapesXml(xml) {
249
+ if (this.chartNumber <= 0) {
250
+ throw new ChartOptionsError("Chart.setUserShapesXml is only supported on classic charts.");
251
+ }
252
+ const entry = this.worksheet.workbook.getChartEntry(this.chartNumber);
253
+ if (!entry) {
254
+ throw new ChartOptionsError(`Chart ${this.chartNumber} has no registered chart entry.`);
255
+ }
256
+ if (xml === undefined) {
257
+ this.removeUserShapes();
258
+ return;
259
+ }
260
+ const bytes = typeof xml === "string" ? new TextEncoder().encode(xml) : xml;
261
+ // Empty strings / empty byte arrays are treated the same as `undefined`
262
+ // — they remove the user-shapes reference entirely.
263
+ if (bytes.length === 0) {
264
+ this.removeUserShapes();
265
+ return;
266
+ }
267
+ // Minimal sanity check — full validation is left to downstream consumers.
268
+ const peek = new TextDecoder().decode(bytes.slice(0, 512));
269
+ if (!peek.includes("userShapes")) {
270
+ throw new ChartOptionsError("Chart.setUserShapesXml expects a DrawingML document whose root is c:userShapes.");
271
+ }
272
+ entry.userShapesXml = bytes;
273
+ entry.dirty = true;
274
+ // Reserve an r:id if we didn't have one, and pre-record a matching
275
+ // rel entry so that other allocators on this chart part
276
+ // (e.g. `chart-images.resolvePendingChartImages`) see the id as
277
+ // already taken and don't reuse it. The writer rewrites the
278
+ // `Target` to the final `chartUserShape{N}.xml` path at emission
279
+ // time (xlsx writer, `_writeChart`), so the placeholder Target here
280
+ // is advisory only.
281
+ //
282
+ // We seed the counter from `max(existing numeric suffix) + 1`
283
+ // instead of `rels.length + 1`, because rels can be sparse
284
+ // (e.g. rId1 / rId5 with rId2-4 removed) and `length + 1` would
285
+ // collide with live identifiers in that case.
286
+ if (!entry.model.userShapesRelId) {
287
+ const rels = (entry.rels ?? (entry.rels = []));
288
+ const existing = new Set(rels.map(r => r?.Id).filter((id) => Boolean(id)));
289
+ let maxSeen = 0;
290
+ for (const id of existing) {
291
+ const match = /^rId(\d+)$/.exec(id);
292
+ if (match) {
293
+ const n = parseInt(match[1], 10);
294
+ if (Number.isFinite(n) && n > maxSeen) {
295
+ maxSeen = n;
296
+ }
297
+ }
298
+ }
299
+ let counter = maxSeen + 1;
300
+ let rid = `rId${counter}`;
301
+ while (existing.has(rid)) {
302
+ counter += 1;
303
+ rid = `rId${counter}`;
304
+ }
305
+ entry.model.userShapesRelId = rid;
306
+ // Push a placeholder rel so downstream allocators see the id as
307
+ // taken. The xlsx writer resolves the Target to the actual
308
+ // drawing part path at emission time.
309
+ //
310
+ // CRITICAL: use `RelType.ChartUserShapes` (the canonical
311
+ // `chartUserShapes`, plural, ECMA-376 / Open XML SDK URI). An
312
+ // earlier version hardcoded the singular `chartUserShape` here,
313
+ // which drifted from `RelType.ChartUserShapes` used by the xlsx
314
+ // writer (see `xlsx.browser.ts`). The writer couldn't recognise
315
+ // this placeholder as the existing userShapes rel and would push
316
+ // a second rel on every write, producing a duplicate rel entry
317
+ // in the chart rels file.
318
+ const hasUserShapesRel = rels.some(r => r?.Type === RelType.ChartUserShapes);
319
+ if (!hasUserShapesRel) {
320
+ rels.push({
321
+ Id: rid,
322
+ Type: RelType.ChartUserShapes,
323
+ Target: ""
324
+ });
325
+ }
326
+ }
327
+ }
328
+ /**
329
+ * Drop the `c:userShapes` reference and its backing drawing part.
330
+ * Classic charts only. No-op when the chart has no user shapes.
331
+ */
332
+ removeUserShapes() {
333
+ if (this.chartNumber <= 0) {
334
+ return;
335
+ }
336
+ const entry = this.worksheet.workbook.getChartEntry(this.chartNumber);
337
+ if (!entry) {
338
+ return;
339
+ }
340
+ if (!entry.userShapesXml && !entry.model.userShapesRelId) {
341
+ return;
342
+ }
343
+ entry.userShapesXml = undefined;
344
+ entry.dirty = true;
345
+ const relId = entry.model.userShapesRelId;
346
+ entry.model.userShapesRelId = undefined;
347
+ if (relId && Array.isArray(entry.rels)) {
348
+ entry.rels = entry.rels.filter(r => r?.Id !== relId);
349
+ }
350
+ // Also purge the matching rel from the workbook-level `_chartRels`
351
+ // bag. The writer merges `model.chartRels[n]` (which is
352
+ // `_chartRels`) into the emitted .rels file BEFORE folding in
353
+ // `entry.rels`, so cleaning only `entry.rels` leaves the original
354
+ // userShapes rel in place — producing a chart whose XML has no
355
+ // `<c:userShapes>` reference but whose .rels still points at a
356
+ // drawing part that is never emitted.
357
+ const workbook = this.worksheet.workbook;
358
+ const workbookChartRels = workbook._chartRels;
359
+ if (workbookChartRels && Array.isArray(workbookChartRels[this.chartNumber])) {
360
+ workbookChartRels[this.chartNumber] = workbookChartRels[this.chartNumber].filter(r => {
361
+ // Match on the specific `Id` we just cleared — but also defensively
362
+ // drop any entry whose `Type` points at a userShapes drawing
363
+ // rel, covering the edge case where the model lost track of its
364
+ // authored `userShapesRelId` but the rel is still present.
365
+ if (relId && r?.Id === relId) {
366
+ return false;
367
+ }
368
+ if (r?.Type === RelType.ChartUserShapes) {
369
+ return false;
370
+ }
371
+ return true;
372
+ });
373
+ }
374
+ }
375
+ /**
376
+ * Render this chart as a **zero-dependency deterministic preview** SVG.
377
+ *
378
+ * The output is suitable for thumbnails, email attachments,
379
+ * server-side report generation, CI smoke tests, and README images.
380
+ * It is **not** an Excel-pixel-perfect compositor — text layout,
381
+ * font metrics, and 3D projection are approximated for a stable
382
+ * preview rather than reproduced from Excel's internal renderer.
383
+ *
384
+ * For production-grade rendering (Excel-identical layout, real 3D
385
+ * for non-bar types, exact font hinting), round-trip the `.xlsx`
386
+ * through headless LibreOffice (`soffice --convert-to pdf`) — the
387
+ * byte-preserving round-trip + `templateMode: "strict"` guarantees
388
+ * in this library make that a safe handoff.
389
+ *
390
+ * See `src/modules/excel/README.md` → "Rendering scope" for the
391
+ * complete boundary list.
392
+ */
393
+ toSVG(options = {}) {
394
+ const model = this.chartModel;
395
+ if (model) {
396
+ return renderChartSvg(model, options);
397
+ }
398
+ const chartEx = this.chartExModel;
399
+ if (chartEx) {
400
+ this._refreshChartExCaches();
401
+ return renderChartExSvg(chartEx, options);
402
+ }
403
+ throw new ChartOptionsError("Cannot render chart because no chart model is available.");
404
+ }
405
+ /**
406
+ * Render this chart as a **zero-dependency deterministic preview** PNG.
407
+ *
408
+ * Browsers use a `<canvas>` pipeline; Node.js uses the built-in
409
+ * `BasicRasterCanvas` rasteriser (a pure-JS SVG-subset rasteriser —
410
+ * no native canvas dependency). DrawingML effect filters
411
+ * (shadow/glow/soft-edge/blur/reflection) round-trip through XML and
412
+ * emit as SVG `<filter>`, but the Node PNG rasteriser silently drops
413
+ * them; the browser canvas path renders them natively.
414
+ *
415
+ * See {@link toSVG} for the full scope-boundary note. For pixel-perfect
416
+ * output, convert through LibreOffice.
417
+ */
418
+ async toPNG(options = {}) {
419
+ // `async` makes the "no model" branch reject the returned promise
420
+ // instead of throwing synchronously. The previous non-async form
421
+ // violated its `Promise<Uint8Array>` contract by throwing on the
422
+ // hot path — a caller using `.then().catch()` (e.g. a background
423
+ // job runner) would see an uncaught synchronous exception rather
424
+ // than a rejected promise.
425
+ const model = this.chartModel;
426
+ if (model) {
427
+ return renderChartPng(model, options);
428
+ }
429
+ const chartEx = this.chartExModel;
430
+ if (chartEx) {
431
+ this._refreshChartExCaches();
432
+ return renderChartExPng(chartEx, options);
433
+ }
434
+ throw new ChartOptionsError("Cannot render chart because no chart model is available.");
435
+ }
436
+ /** Get the chart title text. Returns undefined if no title. */
437
+ get title() {
438
+ const titleObj = this.chartModel?.chart?.title ?? this.chartExModel?.chartSpace?.chart?.title;
439
+ if (!titleObj) {
440
+ return undefined;
441
+ }
442
+ if (titleObj.text) {
443
+ return this._extractTextFromRichText(titleObj.text);
444
+ }
445
+ // Only consider the strRef cache resolved when it actually contains
446
+ // at least one point. Formula-bound titles are authored with
447
+ // `strRef: { formula, cache: { points: [] } }` (see
448
+ // `chart-builder.ts:makeTitle`), and without the explicit length
449
+ // check this getter returned `""` for every such title that hadn't
450
+ // yet gone through `fillChartCaches` — callers couldn't
451
+ // distinguish "title exists, not yet resolved" from an
452
+ // intentionally-empty title.
453
+ if (titleObj.strRef?.cache?.points && titleObj.strRef.cache.points.length > 0) {
454
+ return titleObj.strRef.cache.points.map(p => p.value).join("");
455
+ }
456
+ // Fall back to rawTx — extract text from <a:t> elements
457
+ if (titleObj.rawTx) {
458
+ return this._extractTextFromRawTx(titleObj.rawTx);
459
+ }
460
+ return undefined;
461
+ }
462
+ /**
463
+ * Set the chart title.
464
+ *
465
+ * Accepts:
466
+ * - `undefined` → removes title (sets autoTitleDeleted).
467
+ * - `string` → sets title text. If the existing title had rich-text formatting,
468
+ * the formatting of the first run is preserved and only the text is replaced.
469
+ * - `ChartRichText` → replaces the title with fully-structured rich text.
470
+ * - `{ formula: string }` → sets the title to a worksheet formula reference.
471
+ */
472
+ set title(value) {
473
+ const chart = this.chartModel?.chart ?? this.chartExModel?.chartSpace?.chart;
474
+ if (!chart) {
475
+ return;
476
+ }
477
+ if (value === undefined) {
478
+ this._markDirty(true);
479
+ chart.title = undefined;
480
+ chart.autoTitleDeleted = true;
481
+ return;
482
+ }
483
+ if (typeof value === "object" && "formula" in value && typeof value.formula === "string") {
484
+ this._markDirty();
485
+ chart.title = {
486
+ strRef: { formula: value.formula, cache: { points: [] } },
487
+ overlay: chart.title?.overlay ?? false
488
+ };
489
+ chart.autoTitleDeleted = false;
490
+ // Repopulate the title cache from the referenced cell(s) so
491
+ // preview callers (toSVG / toPNG) and headless converters can
492
+ // resolve the title text without waiting for a worksheet-side
493
+ // recalc. `fillChartCaches` no-ops for non-formula titles and
494
+ // already-populated caches, so calling it here is safe.
495
+ if (this.isChartEx) {
496
+ this._refreshChartExCaches();
497
+ }
498
+ else {
499
+ this._refreshCaches();
500
+ }
501
+ return;
502
+ }
503
+ if (typeof value === "object" && "paragraphs" in value) {
504
+ this._markDirty();
505
+ // Rich text — shallow-clone the paragraphs array so callers who
506
+ // reuse the same `ChartRichText` object across charts don't
507
+ // accidentally alias mutations. Runs remain shared by reference
508
+ // inside each paragraph — consumers generally treat them as
509
+ // immutable, and a deep clone here is cheap but hides the
510
+ // aliasing concern rather than documents it. Users who mutate
511
+ // a run after assignment should clone the object themselves.
512
+ chart.title = {
513
+ ...(chart.title ?? {}),
514
+ strRef: undefined,
515
+ rawTx: undefined,
516
+ text: { ...value, paragraphs: [...value.paragraphs] },
517
+ overlay: chart.title?.overlay ?? false
518
+ };
519
+ chart.autoTitleDeleted = false;
520
+ return;
521
+ }
522
+ // Plain string — try to preserve first-run formatting of existing title.
523
+ if (typeof value !== "string") {
524
+ // Reach here only when `value` is an object whose shape matches none of
525
+ // the branches above (e.g. `{ formula: 123 }`, `{ foo: 1 }`). Previously
526
+ // we silently returned, which quietly swallowed malformed input; throw
527
+ // instead so callers see the bug at the assignment site.
528
+ throw new ChartOptionsError("Chart.title accepts string | ChartRichText | { formula: string } | undefined. " +
529
+ `Got: ${JSON.stringify(value)}`);
530
+ }
531
+ this._markDirty(true);
532
+ const existing = chart.title;
533
+ const preservedProps = this._extractFirstRunProperties(existing);
534
+ chart.title = {
535
+ ...(existing ?? {}),
536
+ strRef: undefined,
537
+ rawTx: undefined,
538
+ text: {
539
+ paragraphs: [
540
+ {
541
+ runs: [{ text: value, properties: preservedProps }]
542
+ }
543
+ ]
544
+ },
545
+ overlay: existing?.overlay ?? false
546
+ };
547
+ chart.autoTitleDeleted = false;
548
+ }
549
+ /**
550
+ * Set the chart title using structured rich text.
551
+ * Convenience method equivalent to `chart.title = richText`.
552
+ */
553
+ setTitleRichText(richText) {
554
+ this.title = richText;
555
+ }
556
+ /**
557
+ * Get the structured rich text of the chart title.
558
+ * Returns undefined if the title is unset, formula-only, or captured as rawTx.
559
+ */
560
+ get titleRichText() {
561
+ return this.chartModel?.chart?.title?.text ?? this.chartExModel?.chartSpace?.chart?.title?.text;
562
+ }
563
+ /** Get the chart type groups in the plot area */
564
+ get chartTypes() {
565
+ return this.chartModel?.chart?.plotArea?.chartTypes ?? [];
566
+ }
567
+ /** Get the chart axes */
568
+ get axes() {
569
+ return this.chartModel?.chart?.plotArea?.axes ?? [];
570
+ }
571
+ /** Get the chart legend */
572
+ get legend() {
573
+ return this.chartModel?.chart?.legend ?? this.chartExModel?.chartSpace?.chart?.legend;
574
+ }
575
+ /** Set the chart legend */
576
+ set legend(value) {
577
+ const chart = this.chartModel?.chart ?? this.chartExModel?.chartSpace?.chart;
578
+ if (chart) {
579
+ this._markDirty(true);
580
+ chart.legend = value;
581
+ }
582
+ }
583
+ /**
584
+ * Get the chart-level shape properties. Works for both classic charts
585
+ * (`c:chartSpace/c:spPr`) and ChartEx (`cx:chartSpace/cx:spPr` — the
586
+ * Chart2014 schema puts `spPr` on `chartSpace`, not on `chart`).
587
+ */
588
+ get spPr() {
589
+ if (this.chartModel) {
590
+ return this.chartModel.spPr;
591
+ }
592
+ // ChartEx stores chart-frame shape properties on `CT_ChartSpace/spPr`.
593
+ // Legacy files that (incorrectly) placed `spPr` on `<cx:chart>`
594
+ // are migrated by the parser into `chartSpace.spPr` at load
595
+ // time — so this getter no longer needs a fallback path.
596
+ return this.chartExModel?.chartSpace?.spPr;
597
+ }
598
+ /**
599
+ * Set the chart-level shape properties. Routes to either
600
+ * `ChartModel.spPr` (classic) or `ChartExModel.chartSpace.spPr`
601
+ * (ChartEx); previously the ChartEx branch was a silent no-op, and
602
+ * the fix before that mis-targeted `chart.spPr` — which is not a
603
+ * valid child of `CT_Chart` in the Chart2014 schema (chart-frame
604
+ * styling belongs to `CT_ChartSpace/spPr`).
605
+ */
606
+ set spPr(value) {
607
+ const cm = this.chartModel;
608
+ if (cm) {
609
+ this._markDirty();
610
+ cm.spPr = value;
611
+ return;
612
+ }
613
+ const chartSpace = this.chartExModel?.chartSpace;
614
+ if (chartSpace) {
615
+ this._markDirty();
616
+ chartSpace.spPr = value;
617
+ }
618
+ }
619
+ /**
620
+ * Get an axis by its ID.
621
+ */
622
+ getAxis(axId) {
623
+ return this.axes.find(ax => ax.axId === axId);
624
+ }
625
+ /**
626
+ * Get the category (X) axis, if any.
627
+ */
628
+ get categoryAxis() {
629
+ return this.axes.find(ax => ax.axisType === "cat" || ax.axisType === "date");
630
+ }
631
+ /**
632
+ * Get the value (Y) axis, if any.
633
+ */
634
+ get valueAxis() {
635
+ return this.axes.find(ax => ax.axisType === "val");
636
+ }
637
+ /** Get the plot area for direct manipulation */
638
+ get plotArea() {
639
+ return this.chartModel?.chart?.plotArea;
640
+ }
641
+ mutate(mutator, options = {}) {
642
+ const model = this.chartModel;
643
+ if (!model) {
644
+ throw new ChartOptionsError("Cannot mutate a classic chart model because this chart is ChartEx or missing.");
645
+ }
646
+ mutator(model);
647
+ this._markDirty(options.preferRawPatch ?? false, options.requireRawPatch ?? false);
648
+ return this;
649
+ }
650
+ mutateChartEx(mutator, options = {}) {
651
+ const model = this.chartExModel;
652
+ if (!model) {
653
+ throw new ChartOptionsError("Cannot mutate a ChartEx model because this chart is classic or missing.");
654
+ }
655
+ mutator(model);
656
+ // Invalidate the model-level rawXml cache so subsequent calls to
657
+ // `renderChartEx(model)` (e.g. standalone preview, tests) honour the
658
+ // mutation instead of short-circuiting to the bytes captured at parse
659
+ // time. The xlsx writer path has its own change-detection (see
660
+ // `hasChartExEntryChanged` in xlsx.browser.ts) and does not depend on
661
+ // this flag, but direct consumers of `renderChartEx` do.
662
+ //
663
+ // `preferRawPatch` consumers explicitly opt in to surgical byte
664
+ // patching — they keep the rawXml so the patcher in xlsx.browser.ts
665
+ // can reuse it.
666
+ if (!options.preferRawPatch && !options.requireRawPatch) {
667
+ model.rawXml = undefined;
668
+ // Also clear title-level rawTx when the structured `text` was
669
+ // updated. Otherwise the writer's "structured path wins over
670
+ // raw" rule correctly routes the new text, but downstream
671
+ // snapshotters (change-detection / test helpers) still see the
672
+ // stale rawTx bytes and conclude the model hasn't been mutated.
673
+ // Clearing here unifies the invalidation model.
674
+ const title = model.chartSpace.chart.title;
675
+ if (title?.text && title.rawTx !== undefined) {
676
+ title.rawTx = undefined;
677
+ }
678
+ }
679
+ this._markDirty(options.preferRawPatch ?? false, options.requireRawPatch ?? false);
680
+ return this;
681
+ }
682
+ /**
683
+ * Set the built-in chart style by index.
684
+ *
685
+ * Writes `<c:style val="N"/>` on the classic chart (`chartN.xml`).
686
+ * Valid values are 1–48, matching the legacy Excel 2007/2010 style
687
+ * catalogue and `xlsxwriter`'s `set_style(N)`. This is the lightweight
688
+ * option — it does **not** emit a `styleN.xml` / `colorsN.xml` sidecar;
689
+ * for modern Office-2013-era styling use {@link setChartStyle} instead.
690
+ *
691
+ * ChartEx charts do not honour this field; calling `setStyle` on one
692
+ * throws, which matches OOXML: `c:style` only exists in the classic
693
+ * `c:` namespace.
694
+ *
695
+ * @param style - Integer in the range 1–48.
696
+ * @throws {ChartOptionsError} when `style` is outside 1–48 or the
697
+ * chart is a ChartEx.
698
+ */
699
+ setStyle(style) {
700
+ if (!Number.isInteger(style) || style < 1 || style > 48) {
701
+ throw new ChartOptionsError(`Chart.setStyle: built-in style must be an integer in 1..48, received ${style}`);
702
+ }
703
+ const model = this.chartModel;
704
+ if (!model) {
705
+ throw new ChartOptionsError("Chart.setStyle is only valid on classic charts; ChartEx does not honour `c:style`");
706
+ }
707
+ model.style = style;
708
+ this._markDirty();
709
+ return this;
710
+ }
711
+ /**
712
+ * Alias for {@link setStyle} that matches the `xlsxwriter` terminology
713
+ * used by Python/Rust users migrating their chart code. Equivalent in
714
+ * every way — both write the same `<c:style val>` attribute.
715
+ */
716
+ setBuiltInStyle(style) {
717
+ return this.setStyle(style);
718
+ }
719
+ /**
720
+ * Add a series to a chart type group.
721
+ *
722
+ * The series' `index` and `order` fields are rewritten to the next
723
+ * available slot in the target group so callers can safely push
724
+ * series that were built with a placeholder index (e.g. a reused
725
+ * result of `buildChartSeriesForType(..., 0)`). OOXML requires
726
+ * `c:ser/@idx` to be unique within the chart; leaving caller-provided
727
+ * values alone silently produces a chart with duplicate `<c:idx>`
728
+ * entries that Excel either rejects or collapses to a single series.
729
+ *
730
+ * @param series - The series object matching the expected series type for the chart.
731
+ * @param groupIndex - 0-based index of the chart type group (for combo charts). Defaults to 0.
732
+ */
733
+ addSeries(series, groupIndex = 0) {
734
+ const ctg = this.chartTypes[groupIndex];
735
+ if (ctg) {
736
+ this._markDirty();
737
+ const nextIdx = this._nextSeriesIndex();
738
+ series.index = nextIdx;
739
+ series.order = nextIdx;
740
+ // `ctg.series` is a discriminated union keyed on `ctg.type` — TS can't
741
+ // verify that `series` matches the expected variant from a generic
742
+ // `SeriesBase`. Callers are documented as responsible for passing a
743
+ // matching shape; we widen through `unknown` to avoid `as any` while
744
+ // keeping a single signature. Runtime validation lives in
745
+ // `buildChartModel`, which is invoked when the chart is serialised.
746
+ ctg.series.push(series);
747
+ // Refresh caches so the first preview render (and any
748
+ // change-detection snapshot taken before the next save cycle)
749
+ // sees the actual data rather than the blank shell the caller
750
+ // probably built via `buildChartSeriesForType`. `updateSeries`
751
+ // and `addSeriesFromOptions` already do this; the lower-level
752
+ // `addSeries` path previously skipped the refresh, so a chart
753
+ // authored via direct `ctg.series.push`-style flows displayed
754
+ // empty until the next save / reload cycle.
755
+ this._refreshCaches();
756
+ }
757
+ }
758
+ /**
759
+ * Remove a series from a chart type group by index.
760
+ *
761
+ * @param index - 0-based index of the series within the group.
762
+ * @param groupIndex - 0-based index of the chart type group (for combo charts). Defaults to 0.
763
+ * @returns The removed series, or undefined if out of range.
764
+ */
765
+ removeSeries(index, groupIndex = 0) {
766
+ const ctg = this.chartTypes[groupIndex];
767
+ if (!ctg || index < 0 || index >= ctg.series.length) {
768
+ return undefined;
769
+ }
770
+ this._markDirty();
771
+ return ctg.series.splice(index, 1)[0];
772
+ }
773
+ /**
774
+ * Get a series from a chart type group.
775
+ *
776
+ * @param index - 0-based index of the series within the group.
777
+ * @param groupIndex - 0-based index of the chart type group (for combo charts). Defaults to 0.
778
+ */
779
+ getSeries(index, groupIndex = 0) {
780
+ const ctg = this.chartTypes[groupIndex];
781
+ if (!ctg) {
782
+ return undefined;
783
+ }
784
+ return ctg.series[index];
785
+ }
786
+ /** Update common fields on an existing classic chart series. */
787
+ updateSeries(index, options, groupIndex = 0) {
788
+ const series = this.getSeries(index, groupIndex);
789
+ if (!series) {
790
+ return false;
791
+ }
792
+ // Apply the patch first so a malformed option (e.g. an unknown
793
+ // enum on `lineDash`) throws *before* we flip the dirty flag. The
794
+ // previous ordering left the chart entry marked dirty on failure,
795
+ // which then forced a full rebuild on the next write even though
796
+ // no mutation had actually landed on the model.
797
+ applyChartSeriesOptionsPatch(series, options, this.chartTypes[groupIndex]?.type);
798
+ // Resolve any staged `series.spPr.fill.blip._pendingImage` that the
799
+ // patch placed on the series. The initial `addChart` path does
800
+ // this in the worksheet's `addChart` hook (same for `addChartsheet`
801
+ // / `replaceChartsheetChart`), but post-registration mutations via
802
+ // `updateSeries` had no equivalent pass — the `_pendingImage`
803
+ // payload sat on the model and the xlsx writer emitted
804
+ // `<a:blipFill>` without a matching rel, leaving Excel with a
805
+ // broken picture reference. Match the registration paths so
806
+ // pictureFill works uniformly for create and update.
807
+ if (options.pictureFill?.image !== undefined) {
808
+ this._resolveSeriesPictureFills();
809
+ }
810
+ // Refresh numeric / string caches when the patch introduced a new
811
+ // formula reference. `applyChartSeriesOptionsPatch` always replaces
812
+ // `target.val` / `target.cat` / `target.xVal` / `target.bubbleSize`
813
+ // with a fresh `makeNumRef` / `makeStrRef` whose `cache.points` is
814
+ // empty, so preview readers and headless converters see blank
815
+ // values until the next `fillChartCaches` pass. Calling it here
816
+ // keeps parity with the worksheet's initial `addChart` step.
817
+ if (options.values !== undefined ||
818
+ options.categories !== undefined ||
819
+ options.xValues !== undefined ||
820
+ options.bubbleSize !== undefined) {
821
+ this._refreshCaches();
822
+ }
823
+ this._markDirty(true);
824
+ return true;
825
+ }
826
+ /** Add a series from high-level options, matching the target chart type group. */
827
+ addSeriesFromOptions(options, groupIndex = 0) {
828
+ const ctg = this.chartTypes[groupIndex];
829
+ if (!ctg) {
830
+ return false;
831
+ }
832
+ const index = this._nextSeriesIndex();
833
+ // `buildChartSeriesForType` can throw for invalid options (e.g. a
834
+ // `pie` chart given `scatter`-only fields). Build first, mark
835
+ // dirty only after the push lands — otherwise a failing build
836
+ // leaves the entry marked dirty without any change to serialise.
837
+ //
838
+ // `buildChartSeriesForType` returns the exact variant matching `ctg.type`,
839
+ // but TS sees `SeriesBase`. Widen via `unknown` (instead of `as any`) so
840
+ // the tighter typing of the union is preserved at the push site.
841
+ const built = buildChartSeriesForType(ctg.type, options, index);
842
+ ctg.series.push(built);
843
+ // Same rationale as `updateSeries`: if the new series carries a
844
+ // pictureFill image, resolve the pending payload into an actual
845
+ // media entry + chart rel so the writer emits valid XML.
846
+ if (options.pictureFill?.image !== undefined) {
847
+ this._resolveSeriesPictureFills();
848
+ }
849
+ // Newly added series always carry empty caches on their val /
850
+ // cat / xVal references — refresh so the first preview render
851
+ // sees the actual data rather than a blank shell.
852
+ this._refreshCaches();
853
+ this._markDirty();
854
+ return true;
855
+ }
856
+ /** Update the value range for a series. */
857
+ setSeriesValues(index, values, groupIndex = 0) {
858
+ return this.updateSeries(index, { values }, groupIndex);
859
+ }
860
+ /** Update the category range for a series. */
861
+ setSeriesCategories(index, categories, groupIndex = 0) {
862
+ return this.updateSeries(index, { categories }, groupIndex);
863
+ }
864
+ /** Update the series display name or formula reference. */
865
+ setSeriesName(index, name, groupIndex = 0) {
866
+ return this.updateSeries(index, { name }, groupIndex);
867
+ }
868
+ /** Get the total number of series across all chart type groups. */
869
+ get totalSeriesCount() {
870
+ return this.chartTypes.reduce((sum, ctg) => sum + (ctg.series?.length ?? 0), 0);
871
+ }
872
+ /**
873
+ * Get the number of series in a specific chart type group.
874
+ *
875
+ * @param groupIndex - 0-based index of the chart type group (defaults to 0).
876
+ */
877
+ getSeriesCount(groupIndex = 0) {
878
+ const ctg = this.chartTypes[groupIndex];
879
+ return ctg?.series?.length ?? 0;
880
+ }
881
+ /**
882
+ * @deprecated Use `getSeriesCount()` instead. Returns the count of series in the first chart type group.
883
+ */
884
+ get seriesCount() {
885
+ return this.getSeriesCount(0);
886
+ }
887
+ // ===========================================================================
888
+ // Chart cloning and duplication
889
+ // ===========================================================================
890
+ /**
891
+ * Create a deep copy of this chart and add it to a target worksheet.
892
+ * The new chart receives a fresh chartNumber; the original is untouched.
893
+ *
894
+ * @param targetWs - Worksheet to receive the clone. Defaults to this chart's worksheet.
895
+ * @param range - Anchor range for the clone. Defaults to the original range.
896
+ * @returns The new chartNumber in the target workbook.
897
+ */
898
+ copyTo(targetWs, range) {
899
+ const sourceModel = this.chartModel;
900
+ const sourceChartExModel = this.chartExModel;
901
+ if (!sourceModel && !sourceChartExModel) {
902
+ throw new ChartOptionsError("Cannot copy chart because no chart model is available.");
903
+ }
904
+ const targetRange = range ?? this._cloneRange();
905
+ // `Worksheet` declares `_registerChart` / `_registerChartEx` as
906
+ // `@internal private`, which TypeScript hides from external callers.
907
+ // Chart lives in the same compilation unit as Worksheet but the class
908
+ // boundary still enforces `private`, so we access the hooks through a
909
+ // narrowly-typed structural interface. Keep this cast co-located with
910
+ // the call sites so any rename of the Worksheet internals surfaces here.
911
+ const registrar = targetWs;
912
+ if (sourceChartExModel) {
913
+ const newChartExNumber = registrar._registerChartEx(deepClone(sourceChartExModel), targetRange);
914
+ // Copy chartEx-specific sidecars (the `_chartExRels` bag of
915
+ // authored relationship entries). Previously the copy dropped
916
+ // every rel, so a chartEx with `cx14:` extension references or
917
+ // embedded media ended up pointing at undefined rel ids on the
918
+ // clone.
919
+ this.worksheet.workbook.copyChartExSidecars?.(this.chartExNumber, newChartExNumber, targetWs.workbook);
920
+ return newChartExNumber;
921
+ }
922
+ const clonedModel = deepClone(sourceModel);
923
+ const chartNumber = registrar._registerChart(clonedModel, targetRange);
924
+ this.worksheet.workbook.copyChartSidecars?.(this.chartNumber, chartNumber, targetWs.workbook);
925
+ // `_registerChart` creates a minimal entry (model only). Carry
926
+ // the per-entry `userShapesXml` bytes across so annotation
927
+ // overlays (callouts, arrows, text boxes the user drew on top of
928
+ // the chart) survive the clone. Without this the duplicate loses
929
+ // every overlay — the drawing part is referenced via a per-entry
930
+ // rel that `copyChartSidecars` already copied, but the backing
931
+ // bytes live on the entry itself and were being dropped.
932
+ //
933
+ // Also carry over `entry.rels`. The workbook-level
934
+ // `copyChartSidecars` hook copies `_chartRels[n]` (style / colors /
935
+ // on-disk image rels), but rels generated programmatically by
936
+ // `resolvePendingChartImages` (for a `series.spPr.fill.blip`
937
+ // picture fill) and the user-shapes placeholder rel pushed by
938
+ // `setUserShapesXml` live on `entry.rels`. Without this copy,
939
+ // the clone's `spPr.fill.blip.relationshipId` / `model.userShapesRelId`
940
+ // referenced in the deep-cloned model point at rel IDs that
941
+ // only exist on the SOURCE entry — the target writes out a
942
+ // chart whose XML uses `r:embed="rId{N}"` but whose .rels has
943
+ // no matching entry, so Excel renders the picture-fill series
944
+ // as a broken / blank fill.
945
+ const srcEntry = this.worksheet.workbook.getChartEntry(this.chartNumber);
946
+ const dstEntry = targetWs.workbook.getChartEntry(chartNumber);
947
+ if (srcEntry && dstEntry) {
948
+ if (srcEntry.userShapesXml) {
949
+ dstEntry.userShapesXml = srcEntry.userShapesXml.slice();
950
+ }
951
+ if (Array.isArray(srcEntry.rels) && srcEntry.rels.length > 0) {
952
+ // Shallow-clone each rel so later mutations on the source
953
+ // don't leak into the clone. The writer only reads `Id`,
954
+ // `Type`, `Target`, and `TargetMode` off these entries, so
955
+ // a spread is sufficient.
956
+ dstEntry.rels = srcEntry.rels.map(rel => ({ ...rel }));
957
+ }
958
+ }
959
+ return chartNumber;
960
+ }
961
+ /**
962
+ * Create a deep copy of this chart in the same worksheet.
963
+ * @param range - Anchor for the clone (defaults to shifting right of original).
964
+ */
965
+ clone(range) {
966
+ return this.copyTo(this.worksheet, range ?? this._cloneRange());
967
+ }
968
+ _cloneRange() {
969
+ // Two-cell anchor: shift the clone right by the original's width.
970
+ if (this.range.br) {
971
+ const tl = this.range.tl.model;
972
+ const br = this.range.br.model;
973
+ const width = br.nativeCol - tl.nativeCol;
974
+ return {
975
+ tl: { col: br.nativeCol + 1, row: tl.nativeRow },
976
+ br: { col: br.nativeCol + 1 + width, row: br.nativeRow }
977
+ };
978
+ }
979
+ // Absolute anchor: shift horizontally by the extent so the clone
980
+ // sits alongside the original. Preserve `editAs: "absolute"` so
981
+ // the writer emits `<xdr:absoluteAnchor>` — the previous fallback
982
+ // degraded every non-two-cell anchor into a twoCell placed
983
+ // on top of the original, both changing the anchor kind and
984
+ // overlapping the source chart 100%.
985
+ if (this.range.pos && this.range.ext) {
986
+ return {
987
+ pos: {
988
+ x: this.range.pos.x + this.range.ext.cx,
989
+ y: this.range.pos.y
990
+ },
991
+ ext: { cx: this.range.ext.cx, cy: this.range.ext.cy },
992
+ editAs: "absolute"
993
+ };
994
+ }
995
+ // One-cell anchor: shift the `tl` column right by enough columns
996
+ // to clear the original's extent. Converting the EMU width back
997
+ // to a column count is approximate (Excel column widths vary per
998
+ // sheet), so estimate at `DEFAULT_CHART_WIDTH_COLS` for
999
+ // consistency with the two-cell fallback and keep `editAs:
1000
+ // "oneCell"` so the writer emits `<xdr:oneCellAnchor>`.
1001
+ if (this.range.ext) {
1002
+ return {
1003
+ tl: {
1004
+ col: this.range.tl.nativeCol + DEFAULT_CHART_WIDTH_COLS,
1005
+ row: this.range.tl.nativeRow
1006
+ },
1007
+ ext: { cx: this.range.ext.cx, cy: this.range.ext.cy },
1008
+ editAs: "oneCell"
1009
+ };
1010
+ }
1011
+ // No extent at all (should not happen in practice — `parseRange`
1012
+ // always populates at least `ext` for oneCell/absolute and `br` for
1013
+ // twoCell). Fall back to a two-cell shifted right by the default
1014
+ // chart extent.
1015
+ return {
1016
+ tl: {
1017
+ col: this.range.tl.nativeCol + DEFAULT_CHART_WIDTH_COLS,
1018
+ row: this.range.tl.nativeRow
1019
+ },
1020
+ br: {
1021
+ col: this.range.tl.nativeCol + 2 * DEFAULT_CHART_WIDTH_COLS,
1022
+ row: this.range.tl.nativeRow + DEFAULT_CHART_HEIGHT_ROWS
1023
+ }
1024
+ };
1025
+ }
1026
+ // ===========================================================================
1027
+ // Private helpers
1028
+ // ===========================================================================
1029
+ /**
1030
+ * Compute the next available series index across all chart type groups.
1031
+ * OOXML `c:ser/@idx` must be unique within the entire chart. Scans for
1032
+ * the maximum authored index (not the series count) so post-removeSeries
1033
+ * state and non-contiguous authored indices still produce a unique slot.
1034
+ */
1035
+ _nextSeriesIndex() {
1036
+ let maxIdx = -1;
1037
+ for (const g of this.chartTypes) {
1038
+ for (const s of g.series) {
1039
+ const idx = typeof s.index === "number" ? s.index : -1;
1040
+ if (Number.isFinite(idx) && idx > maxIdx) {
1041
+ maxIdx = idx;
1042
+ }
1043
+ }
1044
+ }
1045
+ return maxIdx + 1;
1046
+ }
1047
+ _markDirty(preferRawPatch = false, requireRawPatch = false) {
1048
+ if (this.chartNumber > 0) {
1049
+ const entry = this.worksheet.workbook.getChartEntry(this.chartNumber);
1050
+ if (entry) {
1051
+ entry.dirty = true;
1052
+ // Once any mutation drops `preferRawPatch`, a full rebuild is
1053
+ // required — a subsequent minor mutation must not re-enable
1054
+ // patching. Conversely, if the entry was already marked for
1055
+ // full rebuild, a minor mutation should not downgrade it back
1056
+ // to patch mode.
1057
+ if (!preferRawPatch) {
1058
+ entry.preferRawPatch = false;
1059
+ }
1060
+ else if (entry.preferRawPatch === undefined) {
1061
+ entry.preferRawPatch = true;
1062
+ }
1063
+ if (requireRawPatch) {
1064
+ entry.requireRawPatch = true;
1065
+ }
1066
+ }
1067
+ }
1068
+ if (this.chartExNumber > 0) {
1069
+ const entry = this.worksheet.workbook.getChartExStructuredEntry(this.chartExNumber);
1070
+ if (entry) {
1071
+ entry.dirty = true;
1072
+ if (!preferRawPatch) {
1073
+ entry.preferRawPatch = false;
1074
+ }
1075
+ else if (entry.preferRawPatch === undefined) {
1076
+ entry.preferRawPatch = true;
1077
+ }
1078
+ if (requireRawPatch) {
1079
+ entry.requireRawPatch = true;
1080
+ }
1081
+ // Invalidate the ChartExModel.rawXml cache on every structural
1082
+ // mutation (title / legend / spPr setters, addSeries etc.) —
1083
+ // direct consumers of `renderChartEx(model)` (standalone
1084
+ // preview, tests) short-circuit to `model.rawXml` when present
1085
+ // and would otherwise silently drop the mutation. The
1086
+ // `preferRawPatch` opt-in keeps the bytes so the xlsx writer
1087
+ // can still do surgical byte patching on them.
1088
+ if (!preferRawPatch && !requireRawPatch && entry.model) {
1089
+ entry.model.rawXml = undefined;
1090
+ }
1091
+ }
1092
+ }
1093
+ }
1094
+ /**
1095
+ * Resolve any `_pendingImage` payloads this chart's series carry into
1096
+ * workbook media entries + chart relationships. Used by
1097
+ * `updateSeries` / `addSeriesFromOptions` when a caller adds a
1098
+ * picture fill *after* registration — the initial `addChart` /
1099
+ * `addChartsheet` path already calls `resolvePendingChartImages`,
1100
+ * but post-registration mutations previously left `_pendingImage`
1101
+ * un-registered and the writer emitted `<a:blipFill>` pointing at a
1102
+ * missing rel.
1103
+ *
1104
+ * Uses the same resolver helper as the initial path, so rel id
1105
+ * allocation, collision checks against `_chartRels`, and media
1106
+ * naming stay centralised.
1107
+ */
1108
+ _resolveSeriesPictureFills() {
1109
+ if (this.chartNumber <= 0) {
1110
+ return;
1111
+ }
1112
+ const entry = this.worksheet.workbook.getChartEntry(this.chartNumber);
1113
+ if (!entry) {
1114
+ return;
1115
+ }
1116
+ try {
1117
+ resolvePendingChartImages(entry, this.worksheet.workbook, this.chartNumber);
1118
+ }
1119
+ catch {
1120
+ // Best-effort: a malformed image payload should not take down
1121
+ // the surrounding `updateSeries` / `addSeriesFromOptions` call.
1122
+ // The series keeps its `pictureOptions`; only the blip-fill
1123
+ // registration is skipped.
1124
+ }
1125
+ }
1126
+ /**
1127
+ * Rebuild numeric / string caches on this chart's model from the
1128
+ * current worksheet data. Callers mutating formula references after
1129
+ * registration (`updateSeries`, `addSeriesFromOptions`, title setter
1130
+ * with `{ formula }`) invoke this so preview renders and the
1131
+ * snapshot-based change detector see populated points instead of
1132
+ * the empty `{ points: [] }` shell the builders install.
1133
+ *
1134
+ * `fillChartCaches` short-circuits on already-populated caches, so
1135
+ * repeated calls across a burst of mutations are effectively O(N)
1136
+ * in the number of *new* references.
1137
+ */
1138
+ _refreshCaches() {
1139
+ const model = this.chartModel;
1140
+ if (!model) {
1141
+ return;
1142
+ }
1143
+ try {
1144
+ // Pass `this.worksheet` as the resolver context so sheet-scoped
1145
+ // defined names on this chart's owning sheet outrank workbook-
1146
+ // scoped names of the same bare name (matches Excel resolution
1147
+ // order and the `addChart` path in `Worksheet`).
1148
+ fillChartCaches(model, this.worksheet.workbook, this.worksheet);
1149
+ }
1150
+ catch {
1151
+ // Cache population is best-effort; a bad reference in one
1152
+ // series should not prevent the mutation from landing. The
1153
+ // writer still emits the new formula, and a later workbook-
1154
+ // wide pass can populate the cache when called explicitly.
1155
+ }
1156
+ }
1157
+ /**
1158
+ * Populate ChartEx data caches (`strDim.levels` / `numDim.levels`) from
1159
+ * the workbook's worksheet data so that preview renders see actual
1160
+ * values instead of empty arrays.
1161
+ *
1162
+ * The builder marks hierarchical dimensions with `_skipCache` to
1163
+ * prevent the XML writer from emitting flat cache levels (which
1164
+ * confuses Excel's hierarchy renderer). However, the in-memory
1165
+ * renderer still needs the data. We temporarily clear the flag,
1166
+ * fill, then restore it so the writer behaviour is unaffected.
1167
+ */
1168
+ _refreshChartExCaches() {
1169
+ const model = this.chartExModel;
1170
+ if (!model) {
1171
+ return;
1172
+ }
1173
+ // Temporarily lift _skipCache so fillChartExCaches actually populates
1174
+ const skipped = [];
1175
+ for (const entry of model.chartSpace.chartData.data) {
1176
+ const str = entry.strDim;
1177
+ if (str?.["_skipCache"]) {
1178
+ skipped.push({ dim: str, field: "_skipCache" });
1179
+ delete str["_skipCache"];
1180
+ }
1181
+ const num = entry.numDim;
1182
+ if (num?.["_skipCache"]) {
1183
+ skipped.push({ dim: num, field: "_skipCache" });
1184
+ delete num["_skipCache"];
1185
+ }
1186
+ }
1187
+ try {
1188
+ fillChartExCaches(model, this.worksheet.workbook, this.worksheet);
1189
+ }
1190
+ catch {
1191
+ // Best-effort — same rationale as _refreshCaches.
1192
+ }
1193
+ finally {
1194
+ // Restore _skipCache so the writer still suppresses cache output,
1195
+ // even if fillChartExCaches threw an error.
1196
+ for (const { dim } of skipped) {
1197
+ dim["_skipCache"] = true;
1198
+ }
1199
+ }
1200
+ }
1201
+ _extractTextFromRichText(rt) {
1202
+ return rt.paragraphs.map(p => (p.runs ?? []).map(r => r.text).join("")).join("\n");
1203
+ }
1204
+ _extractTextFromRawTx(rawTx) {
1205
+ // Extract all <a:t>…</a:t> text content from raw c:tx XML.
1206
+ // Also check <c:v>…</c:v> for strRef-based titles.
1207
+ //
1208
+ // Uses `matchAll` rather than `RegExp.exec` + shared `lastIndex` so
1209
+ // concurrent calls (extracting multiple titles in parallel promise
1210
+ // chains) cannot interleave each other's iterator state.
1211
+ const parts = [];
1212
+ for (const match of rawTx.matchAll(RAW_TX_AT_RE)) {
1213
+ parts.push(this._decodeXmlEntities(match[1]));
1214
+ }
1215
+ if (parts.length > 0) {
1216
+ return parts.join("");
1217
+ }
1218
+ for (const match of rawTx.matchAll(RAW_TX_CV_RE)) {
1219
+ parts.push(this._decodeXmlEntities(match[1]));
1220
+ }
1221
+ return parts.length > 0 ? parts.join("") : undefined;
1222
+ }
1223
+ _decodeXmlEntities(text) {
1224
+ // Single-pass decoder so sequences like `&amp;lt;` (the XML-encoded
1225
+ // form of a literal `&lt;`) decode to `&lt;` — NOT to `<`. Chaining
1226
+ // `.replace(/&amp;/g,"&").replace(/&lt;/g,"<")` produced the double-
1227
+ // decode by accident: the first replace turned `&amp;lt;` into
1228
+ // `&lt;`, which the second step then decoded as `<`. A title
1229
+ // authored as literal `&lt;tag&gt;` would round-trip as `<tag>`,
1230
+ // silently corrupting the user's text.
1231
+ return text.replace(/&(?:([A-Za-z]+)|#x([0-9A-Fa-f]+)|#(\d+));/g, (match, name, hex, dec) => {
1232
+ if (name !== undefined) {
1233
+ switch (name) {
1234
+ case "amp":
1235
+ return "&";
1236
+ case "lt":
1237
+ return "<";
1238
+ case "gt":
1239
+ return ">";
1240
+ case "quot":
1241
+ return '"';
1242
+ case "apos":
1243
+ return "'";
1244
+ default:
1245
+ return match;
1246
+ }
1247
+ }
1248
+ if (hex !== undefined) {
1249
+ const code = parseInt(hex, 16);
1250
+ return Number.isFinite(code) ? String.fromCodePoint(code) : match;
1251
+ }
1252
+ if (dec !== undefined) {
1253
+ const code = parseInt(dec, 10);
1254
+ return Number.isFinite(code) ? String.fromCodePoint(code) : match;
1255
+ }
1256
+ return match;
1257
+ });
1258
+ }
1259
+ /**
1260
+ * Extract the run properties of the first text run in an existing title,
1261
+ * if any. Used to preserve formatting when replacing plain-string title
1262
+ * text.
1263
+ *
1264
+ * We prefer the structured path (`title.text.paragraphs[0].runs[0]`) and
1265
+ * fall back to parsing the first `<a:rPr>...</a:rPr>` block out of
1266
+ * `rawTx`. The fallback used to only read *attributes* off the opening
1267
+ * tag (size / bold / italic / underline / strike / lang), which meant
1268
+ * the `<a:solidFill>` colour child and `<a:latin>` / `<a:cs>` typefaces
1269
+ * were silently stripped when a plain-string title replaced a
1270
+ * rich-text title. Now we delegate to `parseTxPr` (the same helper the
1271
+ * chart-space xform uses for the full txPr tree) so every supported
1272
+ * rPr field round-trips faithfully.
1273
+ */
1274
+ _extractFirstRunProperties(title) {
1275
+ if (!title) {
1276
+ return undefined;
1277
+ }
1278
+ // Structured path — cheapest and most complete.
1279
+ const firstRun = title.text?.paragraphs?.[0]?.runs?.[0];
1280
+ if (firstRun?.properties) {
1281
+ return { ...firstRun.properties };
1282
+ }
1283
+ // rawTx path — isolate the first `<a:rPr>…</a:rPr>` fragment (including
1284
+ // the self-closing variant) and delegate parsing to `parseTxPr`, which
1285
+ // understands colour, font family, east-asian / complex-script
1286
+ // typefaces and the run-level number format.
1287
+ if (title.rawTx) {
1288
+ const selfClosing = /<a:rPr\b[^>]*\/>/.exec(title.rawTx);
1289
+ const openClose = /<a:rPr\b[^>]*>[\s\S]*?<\/a:rPr>/.exec(title.rawTx);
1290
+ const rPrFragment = openClose && (!selfClosing || openClose.index <= selfClosing.index)
1291
+ ? openClose[0]
1292
+ : selfClosing?.[0];
1293
+ if (rPrFragment) {
1294
+ // `parseTxPr` looks for `<a:defRPr>` and `<a:rPr>` fragments inside
1295
+ // the passed-in raw XML; wrapping in a minimal `<c:txPr>` so it
1296
+ // finds exactly our fragment.
1297
+ const synthetic = `<c:txPr>${rPrFragment}</c:txPr>`;
1298
+ const parsed = parseTxPr({ _rawXml: synthetic });
1299
+ // `parsed` still contains `_rawXml`; strip it so the run properties
1300
+ // don't drag along a synthetic wrapper. Callers (setter for
1301
+ // `title`) only use the structured fields.
1302
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1303
+ const { _rawXml, ...structured } = parsed;
1304
+ return structured;
1305
+ }
1306
+ }
1307
+ return undefined;
1308
+ }
1309
+ }
1310
+ /**
1311
+ * Deep-clone a chart model. Uses `structuredClone` which is always available
1312
+ * in our supported environments (Node 22+, all modern browsers) and handles
1313
+ * the `Uint8Array` captured on {@link ChartExModel.rawXml} correctly — the
1314
+ * older `JSON.parse(JSON.stringify(...))` fallback stripped the typed-array
1315
+ * prototype and corrupted round-trip data.
1316
+ */
1317
+ function deepClone(obj) {
1318
+ return structuredClone(obj);
1319
+ }
1320
+ export { Chart, buildChartModel };