ooxml-core 1.8.3 → 1.9.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 (308) hide show
  1. package/dist/PptxHandler-AT7FVG5Q.mjs +2 -0
  2. package/dist/{PptxHandler-BL4B7CZO.mjs → PptxHandler-EX4WBIQQ.mjs} +2 -2
  3. package/dist/PptxHandler-VFSCECPL.cjs +11 -0
  4. package/dist/automation/index.cjs +7380 -4682
  5. package/dist/automation/index.mjs +7380 -4682
  6. package/dist/chunk-AT66SA5M.cjs +44423 -0
  7. package/dist/{chunk-TTPZITQN.mjs → chunk-FIELY5PI.mjs} +1 -1
  8. package/dist/{chunk-ZAP5WLEN.mjs → chunk-IGOA57LE.mjs} +1 -1
  9. package/dist/chunk-LCS3J3QI.mjs +87604 -0
  10. package/dist/{chunk-NIHPA63A.mjs → chunk-M76PHYRR.mjs} +54 -37
  11. package/dist/chunk-OB277ZGE.mjs +44107 -0
  12. package/dist/{chunk-GAGSCAR3.mjs → chunk-OXHMZS7B.mjs} +552 -178
  13. package/dist/chunk-SWF7KVL5.cjs +87610 -0
  14. package/dist/{chunk-Z7IQR4S4.mjs → chunk-WSO4T2LJ.mjs} +246 -21
  15. package/dist/docx/block-parser.d.ts.map +1 -1
  16. package/dist/docx/cell-blocks.d.ts +4 -0
  17. package/dist/docx/cell-blocks.d.ts.map +1 -0
  18. package/dist/docx/document-paragraphs.d.ts.map +1 -1
  19. package/dist/docx/document-parts.d.ts +2 -0
  20. package/dist/docx/document-parts.d.ts.map +1 -1
  21. package/dist/docx/embedded.cjs +189 -20
  22. package/dist/docx/embedded.mjs +189 -20
  23. package/dist/docx/index.cjs +219 -24
  24. package/dist/docx/index.mjs +219 -24
  25. package/dist/docx/layout/adapt-table.d.ts.map +1 -1
  26. package/dist/docx/layout/adapter.d.ts.map +1 -1
  27. package/dist/docx/layout/flow-paragraph.d.ts +5 -0
  28. package/dist/docx/layout/flow-paragraph.d.ts.map +1 -1
  29. package/dist/docx/layout/flow-table.d.ts +2 -1
  30. package/dist/docx/layout/flow-table.d.ts.map +1 -1
  31. package/dist/docx/layout/footnote-columns.d.ts +22 -0
  32. package/dist/docx/layout/footnote-columns.d.ts.map +1 -0
  33. package/dist/docx/layout/footnote-flow.d.ts +27 -0
  34. package/dist/docx/layout/footnote-flow.d.ts.map +1 -0
  35. package/dist/docx/layout/footnote-split.d.ts +7 -0
  36. package/dist/docx/layout/footnote-split.d.ts.map +1 -0
  37. package/dist/docx/layout/index.cjs +1099 -92
  38. package/dist/docx/layout/index.mjs +1099 -92
  39. package/dist/docx/layout/input.d.ts +17 -1
  40. package/dist/docx/layout/input.d.ts.map +1 -1
  41. package/dist/docx/layout/legacy-footnote-flow.d.ts +18 -0
  42. package/dist/docx/layout/legacy-footnote-flow.d.ts.map +1 -0
  43. package/dist/docx/layout/line-metrics.d.ts.map +1 -1
  44. package/dist/docx/layout/page-cursor.d.ts +13 -8
  45. package/dist/docx/layout/page-cursor.d.ts.map +1 -1
  46. package/dist/docx/layout/page-flow.d.ts.map +1 -1
  47. package/dist/docx/layout/paragraph-layout.d.ts.map +1 -1
  48. package/dist/docx/layout/paragraph-tokens.d.ts +2 -0
  49. package/dist/docx/layout/paragraph-tokens.d.ts.map +1 -1
  50. package/dist/docx/layout/reference-footnotes.d.ts +7 -0
  51. package/dist/docx/layout/reference-footnotes.d.ts.map +1 -0
  52. package/dist/docx/layout/result.d.ts +31 -0
  53. package/dist/docx/layout/result.d.ts.map +1 -1
  54. package/dist/docx/layout/section-flow.d.ts +2 -0
  55. package/dist/docx/layout/section-flow.d.ts.map +1 -1
  56. package/dist/docx/layout/table-cell-layout.d.ts +11 -0
  57. package/dist/docx/layout/table-cell-layout.d.ts.map +1 -0
  58. package/dist/docx/layout/table-footnotes.d.ts +27 -0
  59. package/dist/docx/layout/table-footnotes.d.ts.map +1 -0
  60. package/dist/docx/layout/table-layout.d.ts +10 -4
  61. package/dist/docx/layout/table-layout.d.ts.map +1 -1
  62. package/dist/docx/load/index.cjs +194 -25
  63. package/dist/docx/load/index.mjs +194 -25
  64. package/dist/docx/model-run.d.ts +2 -0
  65. package/dist/docx/model-run.d.ts.map +1 -1
  66. package/dist/docx/model.d.ts +7 -0
  67. package/dist/docx/model.d.ts.map +1 -1
  68. package/dist/docx/notes.d.ts +5 -0
  69. package/dist/docx/notes.d.ts.map +1 -1
  70. package/dist/docx/parse-table.d.ts.map +1 -1
  71. package/dist/docx/parse.d.ts.map +1 -1
  72. package/dist/docx/save.d.ts.map +1 -1
  73. package/dist/docx/section-model.d.ts +2 -0
  74. package/dist/docx/section-model.d.ts.map +1 -1
  75. package/dist/docx/sections.d.ts.map +1 -1
  76. package/dist/docx/settings.d.ts +2 -0
  77. package/dist/docx/settings.d.ts.map +1 -1
  78. package/dist/docx/table-model.d.ts +3 -1
  79. package/dist/docx/table-model.d.ts.map +1 -1
  80. package/dist/docx/ui/index.cjs +55 -0
  81. package/dist/docx/ui/index.d.ts +1 -0
  82. package/dist/docx/ui/index.d.ts.map +1 -1
  83. package/dist/docx/ui/index.mjs +55 -1
  84. package/dist/docx/ui/table-structure-guard.d.ts +4 -0
  85. package/dist/docx/ui/table-structure-guard.d.ts.map +1 -0
  86. package/dist/docx/write-footnote-columns.d.ts +3 -0
  87. package/dist/docx/write-footnote-columns.d.ts.map +1 -0
  88. package/dist/docx/write-notes.d.ts.map +1 -1
  89. package/dist/docx/write-run.d.ts.map +1 -1
  90. package/dist/docx/write-sections.d.ts.map +1 -1
  91. package/dist/index.cjs +8 -5
  92. package/dist/index.mjs +8 -5
  93. package/dist/opc/clone-part-graph.d.ts +4 -0
  94. package/dist/opc/clone-part-graph.d.ts.map +1 -1
  95. package/dist/opc/index.cjs +8 -5
  96. package/dist/opc/index.mjs +8 -5
  97. package/dist/pptx/automation/index.cjs +621 -207
  98. package/dist/pptx/automation/index.d.ts +3 -3
  99. package/dist/pptx/automation/index.mjs +5 -5
  100. package/dist/pptx/chunks/{index-Cn-GzYGp.d.ts → index-B4cnSPNz.d.ts} +33 -4
  101. package/dist/pptx/chunks/index-B4cnSPNz.d.ts.map +1 -0
  102. package/dist/pptx/chunks/{index-CKIUurnd.d.ts → index-BZh-IMkN.d.ts} +14 -9
  103. package/dist/pptx/chunks/{index-CKIUurnd.d.ts.map → index-BZh-IMkN.d.ts.map} +1 -1
  104. package/dist/pptx/chunks/{text-operations-BHfAm5K9.d.ts → text-operations-BLodkuXE.d.ts} +29 -12
  105. package/dist/pptx/chunks/text-operations-BLodkuXE.d.ts.map +1 -0
  106. package/dist/pptx/cli/index.cjs +622 -213
  107. package/dist/pptx/cli/index.d.ts +1 -1
  108. package/dist/pptx/cli/index.mjs +4 -4
  109. package/dist/pptx/converter/index.cjs +53 -36
  110. package/dist/pptx/converter/index.d.ts +1 -1
  111. package/dist/pptx/converter/index.mjs +2 -2
  112. package/dist/pptx/editor/render/find-replace.cjs +416 -45
  113. package/dist/pptx/editor/render/find-replace.d.ts +35 -4
  114. package/dist/pptx/editor/render/find-replace.d.ts.map +1 -1
  115. package/dist/pptx/editor/render/find-replace.mjs +416 -46
  116. package/dist/pptx/editor/render/slide-operations.cjs +87 -0
  117. package/dist/pptx/editor/render/slide-operations.d.ts +17 -1
  118. package/dist/pptx/editor/render/slide-operations.d.ts.map +1 -1
  119. package/dist/pptx/editor/render/slide-operations.mjs +83 -1
  120. package/dist/pptx/editor/render/slide-search.cjs +6 -10
  121. package/dist/pptx/editor/render/slide-search.d.ts +1 -1
  122. package/dist/pptx/editor/render/slide-search.mjs +6 -10
  123. package/dist/pptx/editor/render/template-editing.d.ts +1 -1
  124. package/dist/pptx/editor/render/template-editing.d.ts.map +1 -1
  125. package/dist/pptx/index.cjs +889 -237
  126. package/dist/pptx/index.d.ts +4 -4
  127. package/dist/pptx/index.mjs +5 -5
  128. package/dist/teams/index.cjs +672 -37
  129. package/dist/teams/index.mjs +672 -37
  130. package/dist/visio/accessibility.d.ts +10 -0
  131. package/dist/visio/accessibility.d.ts.map +1 -0
  132. package/dist/visio/cell-formula.d.ts +2 -0
  133. package/dist/visio/cell-formula.d.ts.map +1 -1
  134. package/dist/visio/connector-curve-aligned.d.ts +5 -0
  135. package/dist/visio/connector-curve-aligned.d.ts.map +1 -0
  136. package/dist/visio/connector-curve-spans.d.ts +14 -0
  137. package/dist/visio/connector-curve-spans.d.ts.map +1 -0
  138. package/dist/visio/connector-jumps.d.ts +5 -0
  139. package/dist/visio/connector-jumps.d.ts.map +1 -0
  140. package/dist/visio/connector-route-walk.d.ts +2 -1
  141. package/dist/visio/connector-route-walk.d.ts.map +1 -1
  142. package/dist/visio/edit-alt-text-scope.d.ts +5 -0
  143. package/dist/visio/edit-alt-text-scope.d.ts.map +1 -0
  144. package/dist/visio/edit-alt-text.d.ts +3 -0
  145. package/dist/visio/edit-alt-text.d.ts.map +1 -0
  146. package/dist/visio/edit-commands.d.ts +7 -2
  147. package/dist/visio/edit-commands.d.ts.map +1 -1
  148. package/dist/visio/edit-formatting-commands.d.ts +5 -0
  149. package/dist/visio/edit-formatting-commands.d.ts.map +1 -1
  150. package/dist/visio/edit-formatting-paint.d.ts.map +1 -1
  151. package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
  152. package/dist/visio/edit-line-jump-cache.d.ts +4 -0
  153. package/dist/visio/edit-line-jump-cache.d.ts.map +1 -0
  154. package/dist/visio/edit-master-index.d.ts.map +1 -1
  155. package/dist/visio/edit-metadata-commands.d.ts +10 -2
  156. package/dist/visio/edit-metadata-commands.d.ts.map +1 -1
  157. package/dist/visio/edit-metadata.d.ts +3 -1
  158. package/dist/visio/edit-metadata.d.ts.map +1 -1
  159. package/dist/visio/edit-page-alt-text.d.ts +4 -0
  160. package/dist/visio/edit-page-alt-text.d.ts.map +1 -0
  161. package/dist/visio/edit-page-layout.d.ts.map +1 -1
  162. package/dist/visio/edit-page-rename.d.ts.map +1 -1
  163. package/dist/visio/edit-page-setup-commands.d.ts +7 -1
  164. package/dist/visio/edit-page-setup-commands.d.ts.map +1 -1
  165. package/dist/visio/edit-page-size.d.ts.map +1 -1
  166. package/dist/visio/edit-pages.d.ts.map +1 -1
  167. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  168. package/dist/visio/edit-scope.d.ts.map +1 -1
  169. package/dist/visio/edit-shape-create.d.ts.map +1 -1
  170. package/dist/visio/edit-stencil-connector-write.d.ts.map +1 -1
  171. package/dist/visio/edit-style-admission.d.ts.map +1 -1
  172. package/dist/visio/edit-text.d.ts.map +1 -1
  173. package/dist/visio/edit.d.ts +1 -1
  174. package/dist/visio/edit.d.ts.map +1 -1
  175. package/dist/visio/index.cjs +1091 -233
  176. package/dist/visio/index.d.ts +2 -1
  177. package/dist/visio/index.d.ts.map +1 -1
  178. package/dist/visio/index.mjs +1091 -234
  179. package/dist/visio/line-jumps.d.ts +1 -5
  180. package/dist/visio/line-jumps.d.ts.map +1 -1
  181. package/dist/visio/model.d.ts +13 -0
  182. package/dist/visio/model.d.ts.map +1 -1
  183. package/dist/visio/page-layout.d.ts +11 -2
  184. package/dist/visio/page-layout.d.ts.map +1 -1
  185. package/dist/visio/parser.d.ts.map +1 -1
  186. package/dist/visio/shape-metadata.d.ts +6 -0
  187. package/dist/visio/shape-metadata.d.ts.map +1 -1
  188. package/dist/visio/shapes.d.ts.map +1 -1
  189. package/dist/visio/text-field-case.d.ts +2 -0
  190. package/dist/visio/text-field-case.d.ts.map +1 -0
  191. package/dist/visio/text-field-display.d.ts.map +1 -1
  192. package/dist/visio/text-field-numeric.d.ts +4 -0
  193. package/dist/visio/text-field-numeric.d.ts.map +1 -0
  194. package/dist/visio/ui/connector-preview.d.ts +1 -1
  195. package/dist/visio/ui/connector-preview.d.ts.map +1 -1
  196. package/dist/visio/ui/data-graphic-rules.d.ts +2 -0
  197. package/dist/visio/ui/data-graphic-rules.d.ts.map +1 -1
  198. package/dist/visio/ui/data-graphics.d.ts +3 -2
  199. package/dist/visio/ui/data-graphics.d.ts.map +1 -1
  200. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  201. package/dist/visio/ui/index.cjs +16898 -15855
  202. package/dist/visio/ui/index.mjs +16898 -15856
  203. package/dist/visio/ui/scene-details.d.ts.map +1 -1
  204. package/dist/visio/ui/scene-validation.d.ts.map +1 -1
  205. package/dist/visio/ui/snapshot-scene.d.ts +2 -1
  206. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  207. package/dist/visio/xml-attribute-whitespace.d.ts +5 -0
  208. package/dist/visio/xml-attribute-whitespace.d.ts.map +1 -0
  209. package/dist/xlsx/edit/index.d.ts +1 -0
  210. package/dist/xlsx/edit/index.d.ts.map +1 -1
  211. package/dist/xlsx/edit/insert-guard.d.ts.map +1 -1
  212. package/dist/xlsx/edit/merge.d.ts.map +1 -1
  213. package/dist/xlsx/edit/page-breaks.d.ts +5 -0
  214. package/dist/xlsx/edit/page-breaks.d.ts.map +1 -0
  215. package/dist/xlsx/edit/pivots.d.ts +8 -0
  216. package/dist/xlsx/edit/pivots.d.ts.map +1 -0
  217. package/dist/xlsx/edit/print-titles.d.ts +7 -0
  218. package/dist/xlsx/edit/print-titles.d.ts.map +1 -0
  219. package/dist/xlsx/edit/session.d.ts.map +1 -1
  220. package/dist/xlsx/edit/sheets.d.ts.map +1 -1
  221. package/dist/xlsx/edit/shift-formulas.d.ts.map +1 -1
  222. package/dist/xlsx/edit/shift-sheet.d.ts.map +1 -1
  223. package/dist/xlsx/edit/sparkline-ranges.d.ts +11 -0
  224. package/dist/xlsx/edit/sparkline-ranges.d.ts.map +1 -0
  225. package/dist/xlsx/edit/sparkline-xml.d.ts +13 -0
  226. package/dist/xlsx/edit/sparkline-xml.d.ts.map +1 -0
  227. package/dist/xlsx/edit/sparklines.d.ts +16 -0
  228. package/dist/xlsx/edit/sparklines.d.ts.map +1 -0
  229. package/dist/xlsx/edit/table-edits.d.ts.map +1 -1
  230. package/dist/xlsx/edit/tables.d.ts.map +1 -1
  231. package/dist/xlsx/edit/types.d.ts +22 -1
  232. package/dist/xlsx/edit/types.d.ts.map +1 -1
  233. package/dist/xlsx/formula/functions/text-regex.d.ts.map +1 -1
  234. package/dist/xlsx/index.cjs +3415 -1374
  235. package/dist/xlsx/index.d.ts +1 -0
  236. package/dist/xlsx/index.d.ts.map +1 -1
  237. package/dist/xlsx/index.mjs +3396 -1375
  238. package/dist/xlsx/layout/cell-view.d.ts +2 -0
  239. package/dist/xlsx/layout/cell-view.d.ts.map +1 -1
  240. package/dist/xlsx/layout/header-footer.d.ts +58 -0
  241. package/dist/xlsx/layout/header-footer.d.ts.map +1 -0
  242. package/dist/xlsx/layout/index.d.ts +5 -0
  243. package/dist/xlsx/layout/index.d.ts.map +1 -1
  244. package/dist/xlsx/layout/print-breaks.d.ts +11 -0
  245. package/dist/xlsx/layout/print-breaks.d.ts.map +1 -0
  246. package/dist/xlsx/layout/print-layout.d.ts +34 -0
  247. package/dist/xlsx/layout/print-layout.d.ts.map +1 -0
  248. package/dist/xlsx/layout/print-merges.d.ts +18 -0
  249. package/dist/xlsx/layout/print-merges.d.ts.map +1 -0
  250. package/dist/xlsx/layout/print-repeat.d.ts +12 -0
  251. package/dist/xlsx/layout/print-repeat.d.ts.map +1 -0
  252. package/dist/xlsx/layout/print-titles.d.ts +20 -0
  253. package/dist/xlsx/layout/print-titles.d.ts.map +1 -0
  254. package/dist/xlsx/layout/sparkline-data.d.ts.map +1 -1
  255. package/dist/xlsx/layout/sparkline-view.d.ts.map +1 -1
  256. package/dist/xlsx/load/index.cjs +7831 -6961
  257. package/dist/xlsx/load/index.mjs +7831 -6961
  258. package/dist/xlsx/model-pivots.d.ts +46 -0
  259. package/dist/xlsx/model-pivots.d.ts.map +1 -0
  260. package/dist/xlsx/model.d.ts +5 -0
  261. package/dist/xlsx/model.d.ts.map +1 -1
  262. package/dist/xlsx/pivot/admission.d.ts +5 -0
  263. package/dist/xlsx/pivot/admission.d.ts.map +1 -0
  264. package/dist/xlsx/pivot/aggregate.d.ts +19 -0
  265. package/dist/xlsx/pivot/aggregate.d.ts.map +1 -0
  266. package/dist/xlsx/pivot/cache-xml.d.ts +9 -0
  267. package/dist/xlsx/pivot/cache-xml.d.ts.map +1 -0
  268. package/dist/xlsx/pivot/data.d.ts +12 -0
  269. package/dist/xlsx/pivot/data.d.ts.map +1 -0
  270. package/dist/xlsx/pivot/hierarchy.d.ts +7 -0
  271. package/dist/xlsx/pivot/hierarchy.d.ts.map +1 -0
  272. package/dist/xlsx/pivot/index.d.ts +3 -0
  273. package/dist/xlsx/pivot/index.d.ts.map +1 -0
  274. package/dist/xlsx/pivot/read.d.ts +5 -0
  275. package/dist/xlsx/pivot/read.d.ts.map +1 -0
  276. package/dist/xlsx/pivot/table-xml.d.ts +5 -0
  277. package/dist/xlsx/pivot/table-xml.d.ts.map +1 -0
  278. package/dist/xlsx/pivot/write.d.ts +11 -0
  279. package/dist/xlsx/pivot/write.d.ts.map +1 -0
  280. package/dist/xlsx/read/load.d.ts.map +1 -1
  281. package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
  282. package/dist/xlsx/ui/commands/i18n/index.d.ts.map +1 -1
  283. package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
  284. package/dist/xlsx/ui/commands/i18n/pivots.d.ts +3 -0
  285. package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -0
  286. package/dist/xlsx/ui/commands/i18n/print-layout.d.ts +3 -0
  287. package/dist/xlsx/ui/commands/i18n/print-layout.d.ts.map +1 -0
  288. package/dist/xlsx/ui/commands/i18n/sparklines.d.ts +3 -0
  289. package/dist/xlsx/ui/commands/i18n/sparklines.d.ts.map +1 -0
  290. package/dist/xlsx/ui/commands/i18n/tools.d.ts.map +1 -1
  291. package/dist/xlsx/ui/commands/page-breaks.d.ts +3 -0
  292. package/dist/xlsx/ui/commands/page-breaks.d.ts.map +1 -0
  293. package/dist/xlsx/ui/index.cjs +2451 -737
  294. package/dist/xlsx/ui/index.d.ts +1 -0
  295. package/dist/xlsx/ui/index.d.ts.map +1 -1
  296. package/dist/xlsx/ui/index.mjs +2451 -738
  297. package/dist/xlsx/write/chart-cache.d.ts +8 -0
  298. package/dist/xlsx/write/chart-cache.d.ts.map +1 -0
  299. package/dist/xlsx/write/page-setup.d.ts.map +1 -1
  300. package/dist/xlsx/write/save.d.ts.map +1 -1
  301. package/dist/xlsx/write/sheet-parts.d.ts +1 -0
  302. package/dist/xlsx/write/sheet-parts.d.ts.map +1 -1
  303. package/dist/xlsx/write/workbook-part.d.ts +1 -1
  304. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  305. package/dist/xlsx/write/worksheet.d.ts.map +1 -1
  306. package/package.json +1 -1
  307. package/dist/pptx/chunks/index-Cn-GzYGp.d.ts.map +0 -1
  308. package/dist/pptx/chunks/text-operations-BHfAm5K9.d.ts.map +0 -1
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var JSZip3 = require('jszip');
3
+ var JSZip17 = require('jszip');
4
4
  var fastXmlParser = require('fast-xml-parser');
5
5
  var xmldom = require('@xmldom/xmldom');
6
6
  var mtxDecompressor = require('mtx-decompressor');
7
7
 
8
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
 
10
- var JSZip3__default = /*#__PURE__*/_interopDefault(JSZip3);
10
+ var JSZip17__default = /*#__PURE__*/_interopDefault(JSZip17);
11
11
 
12
12
  var __defProp = Object.defineProperty;
13
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -5178,7 +5178,7 @@ async function buildBlankPresentationArchive(options) {
5178
5178
  const layoutCount = STANDARD_LAYOUTS.length;
5179
5179
  const initialSlideCount = Math.max(0, options?.initialSlideCount ?? 0);
5180
5180
  const blankLayoutIdx = STANDARD_LAYOUTS.findIndex((l) => l.type === "blank") + 1 || 7;
5181
- const zip = new JSZip3__default.default();
5181
+ const zip = new JSZip17__default.default();
5182
5182
  zip.file("[Content_Types].xml", contentTypesXml(layoutCount, initialSlideCount));
5183
5183
  zip.file("_rels/.rels", rootRelsXml());
5184
5184
  zip.file("ppt/presentation.xml", presentationXml(width, height, initialSlideCount));
@@ -22836,7 +22836,7 @@ async function detectOlePayloadEditorKind(bytes) {
22836
22836
  }
22837
22837
  if (isZipMagic(bytes)) {
22838
22838
  try {
22839
- const zip = await JSZip3__default.default.loadAsync(bytes);
22839
+ const zip = await JSZip17__default.default.loadAsync(bytes);
22840
22840
  if (zip.file("xl/workbook.xml")) {
22841
22841
  return "sheet-xlsx";
22842
22842
  }
@@ -23326,7 +23326,7 @@ function cellDisplayValue(cell, sharedStrings) {
23326
23326
  }
23327
23327
  async function readOleSheetGrid(xlsxBytes, maxRows = DEFAULT_MAX_ROWS, maxCols = DEFAULT_MAX_COLS) {
23328
23328
  try {
23329
- const zip = await JSZip3__default.default.loadAsync(xlsxBytes);
23329
+ const zip = await JSZip17__default.default.loadAsync(xlsxBytes);
23330
23330
  const sheetFile = zip.file(FIRST_SHEET_PATH);
23331
23331
  if (!sheetFile) {
23332
23332
  return void 0;
@@ -23385,7 +23385,7 @@ function markFullCalcOnLoad(workbookXml, parser, builder3) {
23385
23385
  }
23386
23386
  async function writeOleSheetCellEdit(xlsxBytes, edit) {
23387
23387
  try {
23388
- const zip = await JSZip3__default.default.loadAsync(xlsxBytes);
23388
+ const zip = await JSZip17__default.default.loadAsync(xlsxBytes);
23389
23389
  const sheetFile = zip.file(FIRST_SHEET_PATH);
23390
23390
  if (!sheetFile) {
23391
23391
  return xlsxBytes;
@@ -24543,7 +24543,7 @@ function paragraphText(paragraph) {
24543
24543
  }
24544
24544
  async function readOleDocumentParagraphs(docxBytes) {
24545
24545
  try {
24546
- const zip = await JSZip3__default.default.loadAsync(docxBytes);
24546
+ const zip = await JSZip17__default.default.loadAsync(docxBytes);
24547
24547
  const documentFile = zip.file(DOCUMENT_PART_PATH);
24548
24548
  if (!documentFile) {
24549
24549
  return void 0;
@@ -24561,7 +24561,7 @@ async function readOleDocumentParagraphs(docxBytes) {
24561
24561
  }
24562
24562
  async function writeOleDocumentParagraphEdit(docxBytes, paragraphIndex, text2) {
24563
24563
  try {
24564
- const zip = await JSZip3__default.default.loadAsync(docxBytes);
24564
+ const zip = await JSZip17__default.default.loadAsync(docxBytes);
24565
24565
  const documentFile = zip.file(DOCUMENT_PART_PATH);
24566
24566
  if (!documentFile) {
24567
24567
  return docxBytes;
@@ -45038,6 +45038,11 @@ function relationshipsPartFor(partName) {
45038
45038
  const slash = partName.lastIndexOf("/");
45039
45039
  return `${partName.slice(0, slash + 1)}_rels/${partName.slice(slash + 1)}.rels`;
45040
45040
  }
45041
+ function nextRelationshipId(used) {
45042
+ let index = 1;
45043
+ while (used.has(`rId${index}`)) index++;
45044
+ return `rId${index}`;
45045
+ }
45041
45046
  var escapeAttr;
45042
45047
  var init_relationships = __esm({
45043
45048
  "opc/relationships.ts"() {
@@ -45064,6 +45069,13 @@ function parseContentTypes(xml) {
45064
45069
  }
45065
45070
  return { defaults, overrides: overrides28 };
45066
45071
  }
45072
+ function contentTypeForPart(types, partName) {
45073
+ const overridePath = partName.startsWith("/") ? partName : `/${partName}`;
45074
+ const override = types.overrides.get(overridePath);
45075
+ if (override) return override;
45076
+ const extension = partName.split(".").pop()?.toLowerCase();
45077
+ return extension ? types.defaults.get(extension) : void 0;
45078
+ }
45067
45079
  var init_content_types = __esm({
45068
45080
  "opc/content-types.ts"() {
45069
45081
  init_xml2();
@@ -45103,10 +45115,13 @@ function relativePartTarget(basePart, targetPart) {
45103
45115
  }
45104
45116
  async function clonePartGraph(options) {
45105
45117
  const { zip, sourcePart, targetPart, shouldClone } = options;
45106
- const copies = /* @__PURE__ */ new Map([[sourcePart, targetPart]]);
45107
- const types = parseContentTypes(await zip.file("[Content_Types].xml")?.async("string"));
45118
+ const sourceZip = options.sourceZip ?? zip;
45119
+ const copies = options.copies ?? /* @__PURE__ */ new Map();
45120
+ copies.set(sourcePart, targetPart);
45121
+ const types = parseContentTypes(await sourceZip.file("[Content_Types].xml")?.async("string"));
45108
45122
  const reserved = new Set(Object.keys(zip.files));
45109
45123
  reserved.add(targetPart);
45124
+ for (const target of copies.values()) reserved.add(target);
45110
45125
  const allocate = (source) => {
45111
45126
  const match = /^(?<stem>.*?)(?:\d+)?(?<extension>\.[^/.]+)$/u.exec(source);
45112
45127
  const stem = match?.groups?.stem ?? source;
@@ -45118,9 +45133,9 @@ async function clonePartGraph(options) {
45118
45133
  return path2;
45119
45134
  };
45120
45135
  const copyRelationships = async (source, destination) => {
45121
- const contentType = types.overrides.get(`/${source}`);
45136
+ const contentType = contentTypeForPart(types, source);
45122
45137
  if (contentType) await ensureContentTypeOverride(zip, destination, contentType);
45123
- const xml = await zip.file(relationshipsPartFor(source))?.async("string");
45138
+ const xml = await sourceZip.file(relationshipsPartFor(source))?.async("string");
45124
45139
  if (!xml) return;
45125
45140
  const relationships2 = parseRelationships(xml);
45126
45141
  for (const relationship of relationships2.values()) {
@@ -45128,7 +45143,7 @@ async function clonePartGraph(options) {
45128
45143
  const originalTarget = resolvePartPath(source, relationship.target);
45129
45144
  let newTarget = copies.get(originalTarget);
45130
45145
  if (!newTarget && shouldClone(relationship, originalTarget)) {
45131
- const file = zip.file(originalTarget);
45146
+ const file = sourceZip.file(originalTarget);
45132
45147
  if (!file) throw new Error(`Cannot clone missing package part: ${originalTarget}`);
45133
45148
  newTarget = allocate(originalTarget);
45134
45149
  copies.set(originalTarget, newTarget);
@@ -55448,7 +55463,7 @@ function resolveCellValue(cell, sharedStrings) {
55448
55463
  }
55449
55464
  async function parseEmbeddedXlsx(xlsxData) {
55450
55465
  try {
55451
- const xlsxZip = await JSZip3__default.default.loadAsync(xlsxData);
55466
+ const xlsxZip = await JSZip17__default.default.loadAsync(xlsxData);
55452
55467
  const xmlParser = new fastXmlParser.XMLParser({
55453
55468
  ignoreAttributes: false,
55454
55469
  attributeNamePrefix: "@_",
@@ -59553,7 +59568,7 @@ function normalisePath(p) {
59553
59568
  }
59554
59569
  async function tryOpenZip(buffer) {
59555
59570
  try {
59556
- const zip = await JSZip3__default.default.loadAsync(buffer);
59571
+ const zip = await JSZip17__default.default.loadAsync(buffer);
59557
59572
  return { zip };
59558
59573
  } catch {
59559
59574
  return { error: "Buffer is not a valid ZIP file" };
@@ -72772,7 +72787,7 @@ var init_PptxPresentationSlidesReconciler = __esm({
72772
72787
  }
72773
72788
  staticRelationships.push(relationship);
72774
72789
  }
72775
- const nextRelationshipId4 = () => {
72790
+ const nextRelationshipId5 = () => {
72776
72791
  let index = 1;
72777
72792
  while (usedRIds.has(`rId${index}`)) {
72778
72793
  index += 1;
@@ -72816,7 +72831,7 @@ var init_PptxPresentationSlidesReconciler = __esm({
72816
72831
  const existingSlideXml = input.slideMap.get(slide.id);
72817
72832
  if (existingSlideXml) {
72818
72833
  if (!slide.rId || slide.rId.length === 0 || !slideTargetByRid.has(slide.rId)) {
72819
- slide.rId = nextRelationshipId4();
72834
+ slide.rId = nextRelationshipId5();
72820
72835
  } else {
72821
72836
  usedRIds.add(slide.rId);
72822
72837
  }
@@ -72835,7 +72850,7 @@ var init_PptxPresentationSlidesReconciler = __esm({
72835
72850
  sourceSlidePath,
72836
72851
  usedRIds,
72837
72852
  slideTargetByRid,
72838
- nextRelationshipId: nextRelationshipId4
72853
+ nextRelationshipId: nextRelationshipId5
72839
72854
  });
72840
72855
  attachedPaths.set(originalId, slide.id);
72841
72856
  }
@@ -73858,7 +73873,13 @@ var init_PptxSlideNotesPartUpdater = __esm({
73858
73873
  init.slideNotesRelationshipType,
73859
73874
  `../notesSlides/${fileName}`
73860
73875
  );
73861
- init.zip.file(notesPath, init.xmlBuilder.build(this.buildNotesSlide(init.slide, strict)));
73876
+ const notesXmlObject = this.buildNotesSlide(init.slide, strict);
73877
+ init.updateNotesXmlText(
73878
+ notesXmlObject,
73879
+ init.slide.notes ?? init.slide.notesSegments?.map((segment) => segment.text).join("") ?? "",
73880
+ init.slide.notesSegments
73881
+ );
73882
+ init.zip.file(notesPath, init.xmlBuilder.build(notesXmlObject));
73862
73883
  init.zip.file(
73863
73884
  `ppt/notesSlides/_rels/${fileName}.rels`,
73864
73885
  init.xmlBuilder.build({
@@ -106659,6 +106680,341 @@ var init_header_footer_parts = __esm({
106659
106680
  }
106660
106681
  });
106661
106682
 
106683
+ // pptx/core/utils/chart-xlsx-write-validation.ts
106684
+ function unsupported(reason) {
106685
+ throw new Error(`Chart label replacement requires direct literal workbook cells: ${reason}.`);
106686
+ }
106687
+ async function validateAtomicChartWorkbookWrites(zip, parser, paths, writes, requireCurrentValues = false) {
106688
+ const relationships2 = xmlChild(
106689
+ parser.parse(
106690
+ await zip.file("xl/_rels/workbook.xml.rels")?.async("string") ?? ""
106691
+ ),
106692
+ "Relationships"
106693
+ );
106694
+ for (const rel of xmlChildren(relationships2, "Relationship")) {
106695
+ if (xmlAttr(rel, "TargetMode") === "External") {
106696
+ unsupported("external worksheet relationships are not supported");
106697
+ }
106698
+ }
106699
+ const sheets = /* @__PURE__ */ new Map();
106700
+ const cellsByPath = /* @__PURE__ */ new Map();
106701
+ for (const path2 of new Set(paths.values())) {
106702
+ const file = zip.file(path2);
106703
+ if (!file) {
106704
+ unsupported("a referenced worksheet is missing");
106705
+ }
106706
+ let tree;
106707
+ try {
106708
+ tree = parser.parse(await file.async("string"));
106709
+ } catch {
106710
+ unsupported("a worksheet cannot be parsed");
106711
+ }
106712
+ const data = xmlChild(xmlChild(tree, "worksheet"), "sheetData");
106713
+ if (!data) {
106714
+ unsupported("a worksheet has no cell data");
106715
+ }
106716
+ if (Object.keys(data).some((key2) => key2.includes(":"))) {
106717
+ unsupported("prefixed worksheet cell nodes are not supported");
106718
+ }
106719
+ const cells2 = /* @__PURE__ */ new Map();
106720
+ for (const row of xmlChildren(data, "row")) {
106721
+ if (Object.keys(row).some((key2) => key2.includes(":"))) {
106722
+ unsupported("prefixed worksheet cell nodes are not supported");
106723
+ }
106724
+ for (const cell of xmlChildren(row, "c")) {
106725
+ const ref = xmlAttr(cell, "r");
106726
+ if (!ref || cells2.has(ref)) {
106727
+ unsupported("duplicate or unidentified worksheet cells are not supported");
106728
+ }
106729
+ cells2.set(ref, cell);
106730
+ if (Object.keys(cell).some((key2) => key2 === "f" || key2.endsWith(":f"))) {
106731
+ unsupported("formula-dependent workbooks are not supported");
106732
+ }
106733
+ }
106734
+ }
106735
+ sheets.set(path2, data);
106736
+ cellsByPath.set(path2, cells2);
106737
+ }
106738
+ const sharedFile = zip.file("xl/sharedStrings.xml");
106739
+ const shared = sharedFile ? xmlChildren(
106740
+ xmlChild(parser.parse(await sharedFile.async("string")), "sst"),
106741
+ "si"
106742
+ ) : [];
106743
+ const destinations = /* @__PURE__ */ new Map();
106744
+ for (const write of writes) {
106745
+ const range = parseChartFormulaRange(write.formula);
106746
+ if (!range || /[\[\]:!]/u.test(range.sheetName)) {
106747
+ unsupported("a range is not a direct local reference");
106748
+ }
106749
+ if ([range.start, range.end].some(
106750
+ (cell) => cell.row < 0 || cell.row >= 1048576 || cell.col < 0 || cell.col >= 16384
106751
+ )) {
106752
+ unsupported("a source cell lies outside the worksheet limits");
106753
+ }
106754
+ const addresses = expandRangeAddresses(range, write.values.length);
106755
+ const path2 = paths.get(range.sheetName.toLowerCase());
106756
+ const data = path2 ? sheets.get(path2) : void 0;
106757
+ if (!addresses || !path2 || !data) {
106758
+ unsupported("a source range cannot be resolved");
106759
+ }
106760
+ for (const [index, address] of addresses.entries()) {
106761
+ const value = write.values[index];
106762
+ const key2 = `${path2}!${address}`;
106763
+ const prior = destinations.get(key2);
106764
+ if (prior && (prior.value !== value || prior.numeric !== write.isNumeric)) {
106765
+ unsupported("overlapping source ranges request conflicting values");
106766
+ }
106767
+ destinations.set(key2, { value, numeric: write.isNumeric });
106768
+ const cell = cellsByPath.get(path2)?.get(address);
106769
+ if (!cell) {
106770
+ unsupported("a source cell is missing");
106771
+ }
106772
+ const type = xmlAttr(cell, "t") ?? "n";
106773
+ const text2 = type === "s" ? shared[Number(xmlText(cell.v))] : xmlChild(cell, "is");
106774
+ if (text2 && Object.keys(text2).some((node) => !node.startsWith("@_") && node !== "t" && node !== "#text")) {
106775
+ unsupported("rich worksheet strings require source-workbook editing");
106776
+ }
106777
+ if (requireCurrentValues) {
106778
+ const current = text2 ? xmlText(text2.t) : xmlText(cell.v);
106779
+ const equal = write.isNumeric ? current !== void 0 && Number(current) === Number(value) : current === value;
106780
+ if (!equal) {
106781
+ unsupported("the workbook and chart caches disagree");
106782
+ }
106783
+ }
106784
+ if (write.isNumeric && !Number.isFinite(Number(value))) {
106785
+ unsupported("a numeric cache value is not finite");
106786
+ }
106787
+ if (!["n", "s", "inlineStr", "str"].includes(type)) {
106788
+ unsupported("a source cell has an unsupported value type");
106789
+ }
106790
+ }
106791
+ }
106792
+ }
106793
+ var init_chart_xlsx_write_validation = __esm({
106794
+ "pptx/core/utils/chart-xlsx-write-validation.ts"() {
106795
+ init_chart_xlsx_cellref();
106796
+ init_xml_access();
106797
+ }
106798
+ });
106799
+ function collectChartWorkbookWrite(xmlLookupService, container2, isNumeric2, values) {
106800
+ if (!container2) {
106801
+ return void 0;
106802
+ }
106803
+ const refNode = xmlLookupService.getChildByLocalName(container2, isNumeric2 ? "numRef" : "strRef");
106804
+ const formula = refNode ? xmlLookupService.getScalarChildByLocalName(refNode, "f") : void 0;
106805
+ return formula ? { formula, isNumeric: isNumeric2, values } : void 0;
106806
+ }
106807
+ function createSpreadsheetXmlParser2() {
106808
+ return new fastXmlParser.XMLParser({
106809
+ ignoreAttributes: false,
106810
+ attributeNamePrefix: "@_",
106811
+ trimValues: false,
106812
+ parseTagValue: false,
106813
+ tagValueProcessor: (tagName, tagValue) => preservesSpreadsheetXmlWhitespace(tagName) ? tagValue : tagValue.trim()
106814
+ });
106815
+ }
106816
+ function createSpreadsheetXmlBuilder2() {
106817
+ return new fastXmlParser.XMLBuilder({
106818
+ ignoreAttributes: false,
106819
+ attributeNamePrefix: "@_",
106820
+ suppressBooleanAttributes: false,
106821
+ format: false
106822
+ });
106823
+ }
106824
+ async function resolveWorksheetPathsByName(xlsxZip, parser) {
106825
+ const result = /* @__PURE__ */ new Map();
106826
+ const workbookFile = xlsxZip.file("xl/workbook.xml");
106827
+ const relsFile = xlsxZip.file("xl/_rels/workbook.xml.rels");
106828
+ if (!workbookFile || !relsFile) {
106829
+ return result;
106830
+ }
106831
+ try {
106832
+ const workbookTree = parser.parse(await workbookFile.async("string"));
106833
+ const relsTree = parser.parse(await relsFile.async("string"));
106834
+ const targetByRelId = /* @__PURE__ */ new Map();
106835
+ const relationships2 = xmlChild(relsTree, "Relationships");
106836
+ for (const rel of xmlChildren(relationships2, "Relationship")) {
106837
+ const id = xmlAttr(rel, "Id");
106838
+ const target = xmlAttr(rel, "Target");
106839
+ if (id && target) {
106840
+ targetByRelId.set(id, target);
106841
+ }
106842
+ }
106843
+ const workbookRoot = xmlChild(workbookTree, "workbook");
106844
+ const sheets = xmlChild(workbookRoot, "sheets");
106845
+ for (const sheet of xmlChildren(sheets, "sheet")) {
106846
+ const name = xmlAttr(sheet, "name");
106847
+ const relId = xmlAttr(sheet, "r:id") ?? xmlAttr(sheet, "id");
106848
+ const target = relId ? targetByRelId.get(relId) : void 0;
106849
+ if (name && target) {
106850
+ result.set(name.toLowerCase(), resolveWorkbookPartPath(target));
106851
+ }
106852
+ }
106853
+ } catch {
106854
+ }
106855
+ return result;
106856
+ }
106857
+ function resolveWorkbookPartPath(target) {
106858
+ return target.startsWith("/") ? target.slice(1) : `xl/${target}`;
106859
+ }
106860
+ async function writeChartWorkbookUpdates(xlsxBytes, writes, options = {}) {
106861
+ if (writes.length === 0) {
106862
+ return { unresolved: 0 };
106863
+ }
106864
+ let xlsxZip;
106865
+ try {
106866
+ xlsxZip = await JSZip17__default.default.loadAsync(xlsxBytes);
106867
+ } catch {
106868
+ if (options.atomic) {
106869
+ throw new Error("Chart label replacement requires a readable embedded workbook.");
106870
+ }
106871
+ return { unresolved: writes.length };
106872
+ }
106873
+ const parser = createSpreadsheetXmlParser2();
106874
+ const sheetPathByName = await resolveWorksheetPathsByName(xlsxZip, parser);
106875
+ if (options.atomic) {
106876
+ await validateAtomicChartWorkbookWrites(
106877
+ xlsxZip,
106878
+ parser,
106879
+ sheetPathByName,
106880
+ writes,
106881
+ options.requireCurrentValues ?? false
106882
+ );
106883
+ }
106884
+ const writesBySheetPath = /* @__PURE__ */ new Map();
106885
+ let unresolved = 0;
106886
+ for (const write of writes) {
106887
+ const range = parseChartFormulaRange(write.formula);
106888
+ const sheetPath = range ? sheetPathByName.get(range.sheetName.toLowerCase()) : void 0;
106889
+ const refs = range ? expandRangeAddresses(range, write.values.length) : void 0;
106890
+ if (!range || !sheetPath || !refs) {
106891
+ unresolved += 1;
106892
+ continue;
106893
+ }
106894
+ const bucket = writesBySheetPath.get(sheetPath) ?? [];
106895
+ bucket.push({ refs, values: write.values, isNumeric: write.isNumeric });
106896
+ writesBySheetPath.set(sheetPath, bucket);
106897
+ }
106898
+ const builder3 = createSpreadsheetXmlBuilder2();
106899
+ let changedAny = false;
106900
+ for (const [sheetPath, resolvedWrites] of writesBySheetPath) {
106901
+ const sheetFile = xlsxZip.file(sheetPath);
106902
+ if (!sheetFile) {
106903
+ unresolved += resolvedWrites.length;
106904
+ continue;
106905
+ }
106906
+ try {
106907
+ const sheetTree = parser.parse(await sheetFile.async("string"));
106908
+ const cellWrites = resolvedWrites.flatMap(
106909
+ ({ refs, values, isNumeric: isNumeric2 }) => refs.map((ref, i2) => ({ ref, isNumeric: isNumeric2, value: values[i2] }))
106910
+ );
106911
+ if (applyCellWritesToWorksheet(sheetTree, cellWrites)) {
106912
+ xlsxZip.file(sheetPath, builder3.build(sheetTree));
106913
+ changedAny = true;
106914
+ }
106915
+ } catch {
106916
+ unresolved += resolvedWrites.length;
106917
+ }
106918
+ }
106919
+ if (options.atomic && unresolved > 0) {
106920
+ throw new Error("Chart label replacement could not update every source range.");
106921
+ }
106922
+ if (!changedAny) {
106923
+ return { unresolved };
106924
+ }
106925
+ const bytes = await xlsxZip.generateAsync({
106926
+ type: "uint8array",
106927
+ compression: "DEFLATE",
106928
+ compressionOptions: { level: 6 }
106929
+ });
106930
+ return { bytes, unresolved };
106931
+ }
106932
+ var init_chart_xlsx_writer = __esm({
106933
+ "pptx/core/utils/chart-xlsx-writer.ts"() {
106934
+ init_chart_xlsx_cellref();
106935
+ init_chart_xlsx_write_validation();
106936
+ init_chart_xlsx_sheet_cells();
106937
+ init_xml_access();
106938
+ init_xml_whitespace();
106939
+ }
106940
+ });
106941
+ function formulaCount(value) {
106942
+ if (!value || typeof value !== "object") return 0;
106943
+ if (Array.isArray(value)) return value.reduce((total, item) => total + formulaCount(item), 0);
106944
+ return Object.entries(value).reduce(
106945
+ (total, [key2, child30]) => total + (key2 === "f" || key2.endsWith(":f") ? 1 : formulaCount(child30)),
106946
+ 0
106947
+ );
106948
+ }
106949
+ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes, series, categories, external, chartPartPath, resolve) {
106950
+ if (!chartSpace || seriesNodes.length !== series.length || !categories.length || external?.isExternal)
106951
+ return false;
106952
+ if (formulaCount(chartSpace) !== seriesNodes.reduce((sum, node) => sum + formulaCount(node), 0))
106953
+ return false;
106954
+ const writes = [];
106955
+ const labelOwners = /* @__PURE__ */ new Map();
106956
+ for (const [index, node] of seriesNodes.entries()) {
106957
+ const entry2 = series[index];
106958
+ for (const [name, numeric, values] of [
106959
+ ["tx", false, [entry2.name]],
106960
+ ["cat", false, [...categories]],
106961
+ ["val", true, entry2.values.map(String)]
106962
+ ]) {
106963
+ const container2 = xml.getChildByLocalName(node, name);
106964
+ if (!container2) return false;
106965
+ const write = collectChartWorkbookWrite(xml, container2, numeric, [...values]);
106966
+ if (write) {
106967
+ writes.push(write);
106968
+ if (!numeric) {
106969
+ const range = parseChartFormulaRange(write.formula);
106970
+ const addresses = range ? expandRangeAddresses(range, values.length) : void 0;
106971
+ if (!range || !addresses) return false;
106972
+ for (const [point2, address] of addresses.entries()) {
106973
+ const key2 = `${range.sheetName.toLowerCase()}!${address}`;
106974
+ const owner = name === "tx" ? `series:${index}` : `category:${point2}`;
106975
+ if (labelOwners.has(key2) && labelOwners.get(key2) !== owner) return false;
106976
+ labelOwners.set(key2, owner);
106977
+ }
106978
+ }
106979
+ } else if (external || !xml.getChildByLocalName(container2, numeric ? "numLit" : "strLit") && !(name === "tx" && xml.getScalarChildByLocalName(container2, "v") !== void 0))
106980
+ return false;
106981
+ }
106982
+ }
106983
+ if (formulaCount(chartSpace) !== writes.length) return false;
106984
+ if (!external) return writes.length === 0;
106985
+ if (!external.targetPath || !external.embeddedWorkbookData) return false;
106986
+ const target = resolve(chartPartPath, external.targetPath);
106987
+ let references = 0;
106988
+ const parser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
106989
+ try {
106990
+ for (const path2 of Object.keys(zip.files)) {
106991
+ if (!path2.endsWith(".rels") || !path2.includes("/_rels/")) continue;
106992
+ const source = path2.replace("/_rels/", "/").slice(0, -5);
106993
+ const tree = parser.parse(await zip.file(path2).async("string"));
106994
+ for (const rel of xmlChildren(xmlChild(tree, "Relationships"), "Relationship")) {
106995
+ const relationshipTarget2 = xmlAttr(rel, "Target");
106996
+ if (relationshipTarget2 && xmlAttr(rel, "TargetMode") !== "External" && resolve(source, relationshipTarget2) === target)
106997
+ references++;
106998
+ }
106999
+ }
107000
+ if (references !== 1) return false;
107001
+ await writeChartWorkbookUpdates(external.embeddedWorkbookData, writes, {
107002
+ atomic: true,
107003
+ requireCurrentValues: true
107004
+ });
107005
+ return true;
107006
+ } catch {
107007
+ return false;
107008
+ }
107009
+ }
107010
+ var init_chart_label_source = __esm({
107011
+ "pptx/core/utils/chart-label-source.ts"() {
107012
+ init_chart_xlsx_writer();
107013
+ init_xml_access();
107014
+ init_chart_xlsx_cellref();
107015
+ }
107016
+ });
107017
+
106662
107018
  // pptx/core/utils/chart-band-fmts.ts
106663
107019
  function safeUnsignedInt2(val) {
106664
107020
  const n = Number(val);
@@ -112581,7 +112937,7 @@ async function persistModernCommentPackage(init) {
112581
112937
  authorPath,
112582
112938
  init.xmlBuilder.build(buildModernAuthorPart(init.authors, init.authorRoot))
112583
112939
  );
112584
- relationshipId2 = init.authorRelationshipId || String(existing?.["@_Id"] || "") || nextRelationshipId(retained);
112940
+ relationshipId2 = init.authorRelationshipId || String(existing?.["@_Id"] || "") || nextRelationshipId2(retained);
112585
112941
  retained.push({
112586
112942
  ...existing || {},
112587
112943
  "@_Id": relationshipId2,
@@ -112612,7 +112968,7 @@ async function persistModernCommentPackage(init) {
112612
112968
  }
112613
112969
  return hasComments ? { authorPartPath: authorPath, authorRelationshipId: relationshipId2 } : {};
112614
112970
  }
112615
- var RELATIONSHIPS_NS, ensureArray13, resolvePartPath3, relationshipTarget, modernComments, nextRelationshipId, updateOverride;
112971
+ var RELATIONSHIPS_NS, ensureArray13, resolvePartPath3, relationshipTarget, modernComments, nextRelationshipId2, updateOverride;
112616
112972
  var init_modern_comment_package = __esm({
112617
112973
  "pptx/core/utils/modern-comment-package.ts"() {
112618
112974
  init_comment_thread_format();
@@ -112645,7 +113001,7 @@ var init_modern_comment_package = __esm({
112645
113001
  return `${"../".repeat(source.length)}${target.join("/")}`;
112646
113002
  };
112647
113003
  modernComments = (slide) => (slide.comments || []).filter(usesModernCommentFormat).map(promoteCommentToModern);
112648
- nextRelationshipId = (relationships2) => {
113004
+ nextRelationshipId2 = (relationships2) => {
112649
113005
  const used = new Set(relationships2.map((entry2) => String(entry2["@_Id"] || "")));
112650
113006
  let index = 1;
112651
113007
  while (used.has(`rId${index}`)) {
@@ -114157,7 +114513,7 @@ function buildContentTypesXml(overrides28) {
114157
114513
  }
114158
114514
  async function buildMetroBlobPackage(input) {
114159
114515
  const root = ROOT[input.kind];
114160
- const zip = new JSZip3__default.default();
114516
+ const zip = new JSZip17__default.default();
114161
114517
  const overrides28 = new Map([
114162
114518
  [root.path, root.contentType],
114163
114519
  ...input.parts.contentTypes,
@@ -114473,7 +114829,7 @@ async function buildOne(zip, slidePath, slideXml3, element) {
114473
114829
  });
114474
114830
  }
114475
114831
  async function buildMetroBlobs(pptxBytes, slides) {
114476
- const zip = await JSZip3__default.default.loadAsync(pptxBytes);
114832
+ const zip = await JSZip17__default.default.loadAsync(pptxBytes);
114477
114833
  const slidePaths = await orderedSlidePaths(zip);
114478
114834
  const out = /* @__PURE__ */ new Map();
114479
114835
  for (let i2 = 0; i2 < slides.length; i2++) {
@@ -117465,7 +117821,7 @@ function withDeclaration(xml) {
117465
117821
  ${body}`;
117466
117822
  }
117467
117823
  async function zipParts(parts) {
117468
- const zip = new JSZip3__default.default();
117824
+ const zip = new JSZip17__default.default();
117469
117825
  for (const [name, text2] of parts) {
117470
117826
  zip.file(name, text2);
117471
117827
  }
@@ -117512,7 +117868,7 @@ async function buildMasterRoundTrip(source) {
117512
117868
  };
117513
117869
  }
117514
117870
  async function buildDeckMasterRoundTripsFromPptx(pptxBytes) {
117515
- const zip = await JSZip3__default.default.loadAsync(pptxBytes);
117871
+ const zip = await JSZip17__default.default.loadAsync(pptxBytes);
117516
117872
  const slidePaths = await readSlideMasterPaths(zip);
117517
117873
  const masterPaths = [...new Set(slidePaths)];
117518
117874
  if (masterPaths.length === 0) {
@@ -120348,7 +120704,7 @@ function upsertRelationship(relationships2, entry2, target) {
120348
120704
  (item) => String(item["@_Id"] ?? "") === entry2.relId && isCustomXmlRelationship(item["@_Type"])
120349
120705
  );
120350
120706
  if (!relationship) {
120351
- entry2.relId = nextRelationshipId2(relationships2);
120707
+ entry2.relId = nextRelationshipId3(relationships2);
120352
120708
  relationship = {};
120353
120709
  relationships2.push(relationship);
120354
120710
  }
@@ -120416,7 +120772,7 @@ function relativeTarget2(source, target) {
120416
120772
  }
120417
120773
  return [...from.map(() => ".."), ...to].join("/");
120418
120774
  }
120419
- function nextRelationshipId2(relationships2) {
120775
+ function nextRelationshipId3(relationships2) {
120420
120776
  const used = new Set(relationships2.map((entry2) => String(entry2["@_Id"] ?? "")));
120421
120777
  let index = 1;
120422
120778
  while (used.has(`rId${index}`)) {
@@ -120673,7 +121029,7 @@ async function upsertTagRelationship(zip, codec, collection) {
120673
121029
  (entry2) => String(entry2["@_Id"] ?? "") === collection.relationshipId && String(entry2["@_Type"] ?? "") === TAG_RELATIONSHIP_TYPE
120674
121030
  );
120675
121031
  if (!relationship) {
120676
- collection.relationshipId = nextRelationshipId3(relationships2);
121032
+ collection.relationshipId = nextRelationshipId4(relationships2);
120677
121033
  relationship = {};
120678
121034
  relationships2.push(relationship);
120679
121035
  }
@@ -120732,7 +121088,7 @@ function relativeTarget3(source, target) {
120732
121088
  }
120733
121089
  return [...from.map(() => ".."), ...to].join("/");
120734
121090
  }
120735
- function nextRelationshipId3(relationships2) {
121091
+ function nextRelationshipId4(relationships2) {
120736
121092
  const used = new Set(relationships2.map((entry2) => String(entry2["@_Id"] ?? "")));
120737
121093
  let index = 1;
120738
121094
  while (used.has(`rId${index}`)) {
@@ -120759,6 +121115,18 @@ var init_tag_package = __esm({
120759
121115
  }
120760
121116
  });
120761
121117
 
121118
+ // pptx/core/utils/chart-workbook-data-signature.ts
121119
+ function chartWorkbookDataSignature(data) {
121120
+ return JSON.stringify({
121121
+ categories: data.dateCategories?.values ?? data.categories,
121122
+ series: data.series.map((series) => ({ name: series.name, values: series.values }))
121123
+ });
121124
+ }
121125
+ var init_chart_workbook_data_signature = __esm({
121126
+ "pptx/core/utils/chart-workbook-data-signature.ts"() {
121127
+ }
121128
+ });
121129
+
120762
121130
  // pptx/core/utils/chart-axis-deleted.ts
120763
121131
  function authoredDeleted(node) {
120764
121132
  if (node === void 0) {
@@ -121846,6 +122214,33 @@ var init_chart_title_run_alignment = __esm({
121846
122214
  }
121847
122215
  });
121848
122216
 
122217
+ // pptx/core/utils/chart-title-text-edit.ts
122218
+ function patchChartTitleRunText(title, runs, local) {
122219
+ const tx = title[findKey7(title, "tx", local) ?? ""];
122220
+ const rich = tx?.[findKey7(tx, "rich", local) ?? ""];
122221
+ const raw = rich?.[findKey7(rich, "p", local) ?? ""];
122222
+ const paragraphs = Array.isArray(raw) ? raw : raw ? [raw] : [];
122223
+ if (paragraphs.length !== 1) return false;
122224
+ const paragraph = paragraphs[0];
122225
+ if (findKey7(paragraph, "br", local) || findKey7(paragraph, "fld", local)) return false;
122226
+ const rawRuns = paragraph[findKey7(paragraph, "r", local) ?? ""];
122227
+ const original = Array.isArray(rawRuns) ? rawRuns : rawRuns ? [rawRuns] : [];
122228
+ if (original.length !== runs.length) return false;
122229
+ const keys = original.map((run) => findKey7(run, "t", local));
122230
+ if (keys.some((key2) => !key2)) return false;
122231
+ for (const [index, value] of original.entries()) {
122232
+ const run = value, key2 = keys[index];
122233
+ const text2 = run[key2];
122234
+ run[key2] = text2 && typeof text2 === "object" && !Array.isArray(text2) ? { ...text2, "#text": runs[index].text } : runs[index].text;
122235
+ }
122236
+ return true;
122237
+ }
122238
+ var init_chart_title_text_edit = __esm({
122239
+ "pptx/core/utils/chart-title-text-edit.ts"() {
122240
+ init_chart_title_xml_ops();
122241
+ }
122242
+ });
122243
+
121849
122244
  // pptx/core/utils/chart-title-serializer.ts
121850
122245
  function applyChartTitleToXml(chartRoot, model, getLocalName2, options = { prefix: "c" }) {
121851
122246
  const { prefix } = options;
@@ -121871,11 +122266,18 @@ function applyChartTitleToXml(chartRoot, model, getLocalName2, options = { prefi
121871
122266
  runs = realignOrCollapseTitleRuns(staleRuns, model.title);
121872
122267
  }
121873
122268
  let titleNode = existingKey ? chartRoot[existingKey] : void 0;
122269
+ const textOnlyStylesMatch = Boolean(
122270
+ runs && model.titleTextOnlyStyles?.length === runs.length && runs.every(
122271
+ (run, index) => ["bold", "italic", "fontSize", "color"].every(
122272
+ (key2) => run[key2] === model.titleTextOnlyStyles[index][key2]
122273
+ )
122274
+ )
122275
+ );
121874
122276
  if (runs && titleNode && typeof titleNode === "object") {
121875
122277
  const existingTexts = [];
121876
122278
  collectAllText(titleNode, getLocalName2, existingTexts);
121877
122279
  const newTexts = runs.map((run) => run.text);
121878
- if (existingTexts.length === newTexts.length && existingTexts.every((text2, index) => text2 === newTexts[index])) {
122280
+ if ((!model.titleTextOnly || textOnlyStylesMatch) && existingTexts.length === newTexts.length && existingTexts.every((text2, index) => text2 === newTexts[index])) {
121879
122281
  runs = void 0;
121880
122282
  }
121881
122283
  }
@@ -121887,6 +122289,12 @@ function applyChartTitleToXml(chartRoot, model, getLocalName2, options = { prefi
121887
122289
  insertAt2(chartRoot, 0, `${prefix}:title`, titleNode);
121888
122290
  }
121889
122291
  } else if (runs) {
122292
+ if (model.titleTextOnly && textOnlyStylesMatch) {
122293
+ if (!patchChartTitleRunText(titleNode, runs, getLocalName2))
122294
+ throw new Error("This chart title cannot be replaced without changing its text source");
122295
+ if (prefix === "c") setAutoTitleDeleted(chartRoot, false, getLocalName2);
122296
+ return true;
122297
+ }
121890
122298
  const txKey = findKey7(titleNode, "tx", getLocalName2);
121891
122299
  if (txKey) {
121892
122300
  titleNode[txKey] = buildTitleTextFromRuns(prefix, runs);
@@ -121910,6 +122318,7 @@ var init_chart_title_serializer = __esm({
121910
122318
  "pptx/core/utils/chart-title-serializer.ts"() {
121911
122319
  init_chart_title_node_builder();
121912
122320
  init_chart_title_run_alignment();
122321
+ init_chart_title_text_edit();
121913
122322
  init_chart_title_xml_ops();
121914
122323
  }
121915
122324
  });
@@ -122071,131 +122480,6 @@ var init_chart_title_style_serializer = __esm({
122071
122480
  };
122072
122481
  }
122073
122482
  });
122074
- function collectChartWorkbookWrite(xmlLookupService, container2, isNumeric2, values) {
122075
- if (!container2) {
122076
- return void 0;
122077
- }
122078
- const refNode = xmlLookupService.getChildByLocalName(container2, isNumeric2 ? "numRef" : "strRef");
122079
- const formula = refNode ? xmlLookupService.getScalarChildByLocalName(refNode, "f") : void 0;
122080
- return formula ? { formula, isNumeric: isNumeric2, values } : void 0;
122081
- }
122082
- function createSpreadsheetXmlParser2() {
122083
- return new fastXmlParser.XMLParser({
122084
- ignoreAttributes: false,
122085
- attributeNamePrefix: "@_",
122086
- trimValues: false,
122087
- tagValueProcessor: (tagName, tagValue) => preservesSpreadsheetXmlWhitespace(tagName) ? tagValue : tagValue.trim()
122088
- });
122089
- }
122090
- function createSpreadsheetXmlBuilder2() {
122091
- return new fastXmlParser.XMLBuilder({
122092
- ignoreAttributes: false,
122093
- attributeNamePrefix: "@_",
122094
- suppressBooleanAttributes: false,
122095
- format: false
122096
- });
122097
- }
122098
- async function resolveWorksheetPathsByName(xlsxZip, parser) {
122099
- const result = /* @__PURE__ */ new Map();
122100
- const workbookFile = xlsxZip.file("xl/workbook.xml");
122101
- const relsFile = xlsxZip.file("xl/_rels/workbook.xml.rels");
122102
- if (!workbookFile || !relsFile) {
122103
- return result;
122104
- }
122105
- try {
122106
- const workbookTree = parser.parse(await workbookFile.async("string"));
122107
- const relsTree = parser.parse(await relsFile.async("string"));
122108
- const targetByRelId = /* @__PURE__ */ new Map();
122109
- const relationships2 = xmlChild(relsTree, "Relationships");
122110
- for (const rel of xmlChildren(relationships2, "Relationship")) {
122111
- const id = xmlAttr(rel, "Id");
122112
- const target = xmlAttr(rel, "Target");
122113
- if (id && target) {
122114
- targetByRelId.set(id, target);
122115
- }
122116
- }
122117
- const workbookRoot = xmlChild(workbookTree, "workbook");
122118
- const sheets = xmlChild(workbookRoot, "sheets");
122119
- for (const sheet of xmlChildren(sheets, "sheet")) {
122120
- const name = xmlAttr(sheet, "name");
122121
- const relId = xmlAttr(sheet, "r:id") ?? xmlAttr(sheet, "id");
122122
- const target = relId ? targetByRelId.get(relId) : void 0;
122123
- if (name && target) {
122124
- result.set(name.toLowerCase(), resolveWorkbookPartPath(target));
122125
- }
122126
- }
122127
- } catch {
122128
- }
122129
- return result;
122130
- }
122131
- function resolveWorkbookPartPath(target) {
122132
- return target.startsWith("/") ? target.slice(1) : `xl/${target}`;
122133
- }
122134
- async function writeChartWorkbookUpdates(xlsxBytes, writes) {
122135
- if (writes.length === 0) {
122136
- return { unresolved: 0 };
122137
- }
122138
- let xlsxZip;
122139
- try {
122140
- xlsxZip = await JSZip3__default.default.loadAsync(xlsxBytes);
122141
- } catch {
122142
- return { unresolved: writes.length };
122143
- }
122144
- const parser = createSpreadsheetXmlParser2();
122145
- const sheetPathByName = await resolveWorksheetPathsByName(xlsxZip, parser);
122146
- const writesBySheetPath = /* @__PURE__ */ new Map();
122147
- let unresolved = 0;
122148
- for (const write of writes) {
122149
- const range = parseChartFormulaRange(write.formula);
122150
- const sheetPath = range ? sheetPathByName.get(range.sheetName.toLowerCase()) : void 0;
122151
- const refs = range ? expandRangeAddresses(range, write.values.length) : void 0;
122152
- if (!range || !sheetPath || !refs) {
122153
- unresolved += 1;
122154
- continue;
122155
- }
122156
- const bucket = writesBySheetPath.get(sheetPath) ?? [];
122157
- bucket.push({ refs, values: write.values, isNumeric: write.isNumeric });
122158
- writesBySheetPath.set(sheetPath, bucket);
122159
- }
122160
- const builder3 = createSpreadsheetXmlBuilder2();
122161
- let changedAny = false;
122162
- for (const [sheetPath, resolvedWrites] of writesBySheetPath) {
122163
- const sheetFile = xlsxZip.file(sheetPath);
122164
- if (!sheetFile) {
122165
- unresolved += resolvedWrites.length;
122166
- continue;
122167
- }
122168
- try {
122169
- const sheetTree = parser.parse(await sheetFile.async("string"));
122170
- const cellWrites = resolvedWrites.flatMap(
122171
- ({ refs, values, isNumeric: isNumeric2 }) => refs.map((ref, i2) => ({ ref, isNumeric: isNumeric2, value: values[i2] }))
122172
- );
122173
- if (applyCellWritesToWorksheet(sheetTree, cellWrites)) {
122174
- xlsxZip.file(sheetPath, builder3.build(sheetTree));
122175
- changedAny = true;
122176
- }
122177
- } catch {
122178
- unresolved += resolvedWrites.length;
122179
- }
122180
- }
122181
- if (!changedAny) {
122182
- return { unresolved };
122183
- }
122184
- const bytes = await xlsxZip.generateAsync({
122185
- type: "uint8array",
122186
- compression: "DEFLATE",
122187
- compressionOptions: { level: 6 }
122188
- });
122189
- return { bytes, unresolved };
122190
- }
122191
- var init_chart_xlsx_writer = __esm({
122192
- "pptx/core/utils/chart-xlsx-writer.ts"() {
122193
- init_chart_xlsx_cellref();
122194
- init_chart_xlsx_sheet_cells();
122195
- init_xml_access();
122196
- init_xml_whitespace();
122197
- }
122198
- });
122199
122483
 
122200
122484
  // pptx/core/core/runtime/chart-cx-update-data.ts
122201
122485
  function findKey31(node, localName29, getLocalName2) {
@@ -122531,13 +122815,19 @@ var init_chart_cx_update = __esm({
122531
122815
  });
122532
122816
 
122533
122817
  // pptx/core/core/runtime/chart-external-workbook-save.ts
122534
- async function saveChartExternalWorkbookUpdates(deps, chartPartPath, slidePath, externalData, writes) {
122818
+ async function saveChartExternalWorkbookUpdates(deps, chartPartPath, slidePath, externalData, writes, atomic = false) {
122819
+ if (atomic && externalData && (!externalData.targetPath || externalData.isExternal)) {
122820
+ throw new Error("Chart label replacement cannot update an external or missing workbook.");
122821
+ }
122535
122822
  if (writes.length === 0 || !externalData?.targetPath) {
122536
- return;
122823
+ return writes.length === 0;
122537
122824
  }
122538
122825
  const embeddingPath = deps.resolveImagePath(chartPartPath, externalData.targetPath);
122539
122826
  const looksEmbedded = embeddingPath.includes("embeddings/") && /\.xlsx$/iu.test(embeddingPath);
122540
- if (!looksEmbedded) {
122827
+ if (!looksEmbedded || externalData.isExternal) {
122828
+ if (atomic) {
122829
+ throw new Error("Chart label replacement requires an embedded .xlsx workbook.");
122830
+ }
122541
122831
  deps.reportWarning({
122542
122832
  code: "CHART_EXTERNAL_DATA_WRITEBACK_UNSUPPORTED",
122543
122833
  message: "Chart data changes were saved to the cached values only: the linked data source is external or not an embedded .xlsx workbook, so it was not updated.",
@@ -122546,10 +122836,13 @@ async function saveChartExternalWorkbookUpdates(deps, chartPartPath, slidePath,
122546
122836
  slideId: slidePath,
122547
122837
  xmlPath: chartPartPath
122548
122838
  });
122549
- return;
122839
+ return false;
122550
122840
  }
122551
122841
  const xlsxFile = deps.zip.file(embeddingPath);
122552
122842
  if (!xlsxFile) {
122843
+ if (atomic) {
122844
+ throw new Error("Chart label replacement workbook is missing.");
122845
+ }
122553
122846
  deps.reportWarning({
122554
122847
  code: "CHART_EMBEDDED_WORKBOOK_MISSING",
122555
122848
  message: "Chart data changes were saved to the cached values only: the referenced embedded workbook was not found in the package.",
@@ -122558,12 +122851,15 @@ async function saveChartExternalWorkbookUpdates(deps, chartPartPath, slidePath,
122558
122851
  slideId: slidePath,
122559
122852
  xmlPath: embeddingPath
122560
122853
  });
122561
- return;
122854
+ return false;
122562
122855
  }
122563
122856
  let xlsxBytes;
122564
122857
  try {
122565
122858
  xlsxBytes = await xlsxFile.async("uint8array");
122566
122859
  } catch {
122860
+ if (atomic) {
122861
+ throw new Error("Chart label replacement workbook cannot be read.");
122862
+ }
122567
122863
  deps.reportWarning({
122568
122864
  code: "CHART_EMBEDDED_WORKBOOK_UNREADABLE",
122569
122865
  message: "Chart data changes were saved to the cached values only: the referenced embedded workbook could not be read.",
@@ -122572,9 +122868,9 @@ async function saveChartExternalWorkbookUpdates(deps, chartPartPath, slidePath,
122572
122868
  slideId: slidePath,
122573
122869
  xmlPath: embeddingPath
122574
122870
  });
122575
- return;
122871
+ return false;
122576
122872
  }
122577
- const result = await writeChartWorkbookUpdates(xlsxBytes, writes);
122873
+ const result = await writeChartWorkbookUpdates(xlsxBytes, writes, { atomic });
122578
122874
  if (result.bytes) {
122579
122875
  deps.zip.file(embeddingPath, result.bytes);
122580
122876
  }
@@ -122588,6 +122884,7 @@ async function saveChartExternalWorkbookUpdates(deps, chartPartPath, slidePath,
122588
122884
  xmlPath: embeddingPath
122589
122885
  });
122590
122886
  }
122887
+ return result.unresolved === 0;
122591
122888
  }
122592
122889
  var init_chart_external_workbook_save = __esm({
122593
122890
  "pptx/core/core/runtime/chart-external-workbook-save.ts"() {
@@ -126042,7 +126339,7 @@ var init_PptxHandlerRuntimeState = __esm({
126042
126339
  */
126043
126340
  savedSlideFingerprints = /* @__PURE__ */ new Map();
126044
126341
  /**
126045
- * `chartData` exactly as it stood right after `enrichChartData` parsed it,
126342
+ * `chartData` as parsed or last serialized into the current ZIP,
126046
126343
  * serialized to JSON and keyed by `chartPartPath`. The save pipeline used
126047
126344
  * to re-serialize EVERY chart part on any slide rewrite regardless of
126048
126345
  * whether the chart itself was touched, which materializes the load-time
@@ -126055,6 +126352,10 @@ var init_PptxHandlerRuntimeState = __esm({
126055
126352
  * untouched chart part pass through byte-for-byte instead.
126056
126353
  */
126057
126354
  chartDataBaselines = /* @__PURE__ */ new Map();
126355
+ /** Pending chart requests also retain warned workbook writes for later retry. */
126356
+ pendingChartUpdates;
126357
+ /** Last fully reconciled workbook data plus whether a write-back needs retry. */
126358
+ chartWorkbookDataBaselines = /* @__PURE__ */ new Map();
126058
126359
  /** Per-slide relationship maps: slide path -> (rId -> target path). */
126059
126360
  slideRelsMap = /* @__PURE__ */ new Map();
126060
126361
  /** Tracks relationship IDs with TargetMode="External" per slide/part path. */
@@ -134402,6 +134703,7 @@ var init_table_tblpr_save = __esm({
134402
134703
  var CHART_DATA_DISPLAY_OPTIONS_EXT_URI, PptxHandlerRuntime24;
134403
134704
  var init_PptxHandlerRuntimeSaveDataSerialization = __esm({
134404
134705
  "pptx/core/core/runtime/PptxHandlerRuntimeSaveDataSerialization.ts"() {
134706
+ init_chart_workbook_data_signature();
134405
134707
  init_chart_axis_dispunits_serializer();
134406
134708
  init_chart_axis_gridlines_serializer();
134407
134709
  init_chart_axis_label_formatting();
@@ -134539,8 +134841,6 @@ var init_PptxHandlerRuntimeSaveDataSerialization = __esm({
134539
134841
  console.warn("Failed to serialize table data:", e);
134540
134842
  }
134541
134843
  }
134542
- /** Pending chart data updates to process in the async save method. */
134543
- pendingChartUpdates;
134544
134844
  /**
134545
134845
  * Record `chartData` as parsed, straight off `enrichChartData`, as this
134546
134846
  * chart's load-time baseline. See {@link chartDataBaselines}.
@@ -134550,6 +134850,10 @@ var init_PptxHandlerRuntimeSaveDataSerialization = __esm({
134550
134850
  return;
134551
134851
  }
134552
134852
  this.chartDataBaselines.set(chartData.chartPartPath, JSON.stringify(chartData));
134853
+ this.chartWorkbookDataBaselines.set(chartData.chartPartPath, {
134854
+ signature: chartWorkbookDataSignature(chartData),
134855
+ pending: false
134856
+ });
134553
134857
  }
134554
134858
  /**
134555
134859
  * Collect chart data for deferred async processing during save.
@@ -134566,12 +134870,28 @@ var init_PptxHandlerRuntimeSaveDataSerialization = __esm({
134566
134870
  /**
134567
134871
  * Process all pending chart data updates (called from the async save method).
134568
134872
  */
134569
- async processPendingChartUpdates() {
134873
+ async processPendingChartUpdates(slides) {
134570
134874
  if (!this.pendingChartUpdates || this.pendingChartUpdates.length === 0) {
134571
134875
  return;
134572
134876
  }
134877
+ if (slides) {
134878
+ const current = /* @__PURE__ */ new Map();
134879
+ const visit = (elements3, slidePath) => {
134880
+ for (const element of elements3) {
134881
+ if (element.type === "group") visit(element.children, slidePath);
134882
+ else if (element.type === "chart" && element.chartData?.chartPartPath) {
134883
+ current.set(element.chartData.chartPartPath, {
134884
+ chartData: element.chartData,
134885
+ slidePath
134886
+ });
134887
+ }
134888
+ }
134889
+ };
134890
+ for (const slide of slides) visit(slide.elements, slide.id);
134891
+ this.pendingChartUpdates = [...current.values()];
134892
+ }
134573
134893
  for (const { chartData, slidePath } of this.pendingChartUpdates) {
134574
- if (chartData.chartPartPath && this.chartDataBaselines.get(chartData.chartPartPath) === JSON.stringify(chartData)) {
134894
+ if (chartData.chartPartPath && !this.chartWorkbookDataBaselines.get(chartData.chartPartPath)?.pending && this.chartDataBaselines.get(chartData.chartPartPath) === JSON.stringify(chartData)) {
134575
134895
  continue;
134576
134896
  }
134577
134897
  if (chartData.colorPalette && chartData.colorStylePartPath) {
@@ -134990,7 +135310,9 @@ var init_PptxHandlerRuntimeSaveDataSerialization = __esm({
134990
135310
  {
134991
135311
  title: chartData.title,
134992
135312
  hasTitle: chartData.style?.hasTitle,
134993
- titleRuns: chartData.titleRuns
135313
+ titleRuns: chartData.titleRuns,
135314
+ titleTextOnly: chartData.titleTextOnly,
135315
+ titleTextOnlyStyles: chartData.titleTextOnlyStyles
134994
135316
  },
134995
135317
  (key2) => this.compatibilityService.getXmlLocalName(key2)
134996
135318
  );
@@ -135182,23 +135504,41 @@ var init_PptxHandlerRuntimeSaveDataSerialization = __esm({
135182
135504
  }
135183
135505
  }
135184
135506
  await this.syncChartUserShapesToXml(chartSpace, chartData, chartPartPath);
135507
+ const serializedBaseline = this.chartDataBaselines.get(chartPartPath);
135508
+ const signature = chartWorkbookDataSignature(chartData);
135509
+ const workbookBaseline = this.chartWorkbookDataBaselines.get(chartPartPath);
135510
+ const previousSignature = workbookBaseline?.signature ?? (serializedBaseline ? chartWorkbookDataSignature(JSON.parse(serializedBaseline)) : void 0);
135511
+ const workbookDataChanged = workbookBaseline?.pending || signature !== previousSignature;
135512
+ if (workbookDataChanged) {
135513
+ const complete = await saveChartExternalWorkbookUpdates(
135514
+ {
135515
+ zip: this.zip,
135516
+ resolveImagePath: (basePath, target) => this.resolveImagePath(basePath, target),
135517
+ reportWarning: (warning) => this.compatibilityService.reportWarning(warning)
135518
+ },
135519
+ chartPartPath,
135520
+ slidePath,
135521
+ chartData.externalData,
135522
+ workbookWrites,
135523
+ chartData.dataLabelTextOnly ?? false
135524
+ );
135525
+ this.chartWorkbookDataBaselines.set(chartPartPath, {
135526
+ signature: complete ? signature : previousSignature ?? signature,
135527
+ pending: !complete
135528
+ });
135529
+ }
135185
135530
  this.zip.file(chartPartPath, this.builder.build(chartXmlData));
135186
- await saveChartExternalWorkbookUpdates(
135187
- {
135188
- zip: this.zip,
135189
- resolveImagePath: (basePath, target) => this.resolveImagePath(basePath, target),
135190
- reportWarning: (warning) => this.compatibilityService.reportWarning(warning)
135191
- },
135192
- chartPartPath,
135193
- slidePath,
135194
- chartData.externalData,
135195
- workbookWrites
135196
- );
135531
+ this.chartDataBaselines.set(chartPartPath, JSON.stringify(chartData));
135197
135532
  } catch (e) {
135533
+ if (chartData.dataLabelTextOnly) {
135534
+ throw e;
135535
+ }
135198
135536
  console.warn(`[pptx-save] Failed to serialize chart data for ${chartPartPath}:`, e);
135199
135537
  }
135200
135538
  }
135201
- this.pendingChartUpdates = void 0;
135539
+ this.pendingChartUpdates = this.pendingChartUpdates.filter(
135540
+ ({ chartData }) => chartData.chartPartPath && this.chartWorkbookDataBaselines.get(chartData.chartPartPath)?.pending
135541
+ );
135202
135542
  }
135203
135543
  /**
135204
135544
  * Route a chart save that the 2006 `c:*Chart` update loop cannot handle:
@@ -143402,22 +143742,44 @@ function drawingNamespace(strict) {
143402
143742
  var NOTES_MASTER_CONTENT_TYPE, PptxHandlerRuntime50;
143403
143743
  var init_PptxHandlerRuntimeSaveNotesInfrastructure = __esm({
143404
143744
  "pptx/core/core/runtime/PptxHandlerRuntimeSaveNotesInfrastructure.ts"() {
143745
+ init_relationships();
143405
143746
  init_PptxHandlerRuntimeSaveViewProperties();
143406
143747
  NOTES_MASTER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml";
143407
143748
  PptxHandlerRuntime50 = class extends PptxHandlerRuntime49 {
143408
143749
  /** Ensure authored notes have the global notes-master OPC infrastructure. */
143409
143750
  async ensureNotesMasterForAuthoredNotes(slides, constants) {
143410
143751
  const needsNotes = slides.some(
143411
- (slide) => slide.notes !== void 0 || Boolean(slide.notesSegments?.length)
143752
+ (slide) => Boolean(slide.notes) || Boolean(slide.notesSegments?.some((segment) => segment.text))
143412
143753
  );
143413
143754
  if (!needsNotes || Object.keys(this.zip.files).some(
143414
143755
  (path2) => /^ppt\/notesMasters\/notesMaster\d+\.xml$/u.test(path2)
143415
143756
  )) {
143416
143757
  return;
143417
143758
  }
143759
+ const relsPath2 = "ppt/_rels/presentation.xml.rels";
143760
+ const relsXml = await this.zip.file(relsPath2)?.async("string");
143761
+ if (!relsXml || !this.presentationData) return;
143762
+ if (Array.from(parseRelationships(relsXml).values()).some(
143763
+ (relationship) => relationship.type.endsWith("/notesMaster") && relationship.mode !== "External" && this.zip.file(resolvePartPath("ppt/presentation.xml", relationship.target))
143764
+ ))
143765
+ return;
143418
143766
  const strict = constants.conformance === "strict";
143419
143767
  const masterPath = "ppt/notesMasters/notesMaster1.xml";
143420
- const themePath = Object.keys(this.zip.files).find((path2) => /^ppt\/theme\/theme\d+\.xml$/u.test(path2)) ?? "ppt/theme/theme1.xml";
143768
+ const sourceThemePath = Object.keys(this.zip.files).find((path2) => /^ppt\/theme\/theme\d+\.xml$/u.test(path2)) ?? "ppt/theme/theme1.xml";
143769
+ let themeIndex = 1;
143770
+ while (this.zip.file(`ppt/theme/theme${themeIndex}.xml`)) themeIndex += 1;
143771
+ const themePath = `ppt/theme/theme${themeIndex}.xml`;
143772
+ const themeBytes = await this.zip.file(sourceThemePath)?.async("uint8array");
143773
+ const theme = themeBytes ?? this.buildThemeXml(themePath, void 0);
143774
+ if (!theme) throw new Error("Cannot create a notes theme from the presentation state");
143775
+ this.zip.file(themePath, theme);
143776
+ const themeRelationships = await this.zip.file(`ppt/theme/_rels/${sourceThemePath.slice(sourceThemePath.lastIndexOf("/") + 1)}.rels`)?.async("uint8array");
143777
+ if (themeRelationships)
143778
+ this.zip.file(`ppt/theme/_rels/theme${themeIndex}.xml.rels`, themeRelationships);
143779
+ await this.addContentTypeOverride(
143780
+ `/${themePath}`,
143781
+ "application/vnd.openxmlformats-officedocument.theme+xml"
143782
+ );
143421
143783
  this.zip.file(masterPath, this.builder.build(this.buildDefaultNotesMaster(strict)));
143422
143784
  this.zip.file(
143423
143785
  "ppt/notesMasters/_rels/notesMaster1.xml.rels",
@@ -143432,11 +143794,6 @@ var init_PptxHandlerRuntimeSaveNotesInfrastructure = __esm({
143432
143794
  }
143433
143795
  })
143434
143796
  );
143435
- const relsPath2 = "ppt/_rels/presentation.xml.rels";
143436
- const relsXml = await this.zip.file(relsPath2)?.async("string");
143437
- if (!relsXml || !this.presentationData) {
143438
- return;
143439
- }
143440
143797
  const relsData = this.parser.parse(relsXml);
143441
143798
  const relsRoot = relsData["Relationships"] ?? {};
143442
143799
  const relationships2 = asArray7(relsRoot["Relationship"]);
@@ -144171,7 +144528,7 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
144171
144528
  saveSession,
144172
144529
  saveConstants
144173
144530
  );
144174
- await this.processPendingChartUpdates();
144531
+ await this.processPendingChartUpdates(slides);
144175
144532
  await this.ensureChartPartContentTypes();
144176
144533
  await this.ensureOleEmbeddingContentTypes();
144177
144534
  await this.processPendingOleContentUpdates();
@@ -154182,6 +154539,7 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
154182
154539
  );
154183
154540
  const autoUpdateAttr = externalDataNode["@_autoUpdate"];
154184
154541
  const autoUpdate = autoUpdateNode?.["@_val"] === "1" || autoUpdateNode?.["@_val"] === "true" || autoUpdateAttr === "1" || autoUpdateAttr === "true" || false;
154542
+ let isExternal = false;
154185
154543
  let targetPath;
154186
154544
  try {
154187
154545
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
@@ -154196,6 +154554,7 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
154196
154554
  for (const rel of rels) {
154197
154555
  if (String(rel?.["@_Id"] || "") === relId) {
154198
154556
  targetPath = String(rel?.["@_Target"] || "").trim() || void 0;
154557
+ isExternal = String(rel?.["@_TargetMode"] || "") === "External";
154199
154558
  break;
154200
154559
  }
154201
154560
  }
@@ -154204,7 +154563,7 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
154204
154563
  } catch {
154205
154564
  }
154206
154565
  let embeddedWorkbookData;
154207
- if (targetPath) {
154566
+ if (targetPath && !isExternal) {
154208
154567
  try {
154209
154568
  const embeddingPath = this.resolveImagePath(chartPartPath, targetPath);
154210
154569
  if (embeddingPath.includes("embeddings/") && embeddingPath.endsWith(".xlsx")) {
@@ -154218,6 +154577,7 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
154218
154577
  }
154219
154578
  return {
154220
154579
  relId,
154580
+ ...isExternal ? { isExternal: true } : {},
154221
154581
  targetPath,
154222
154582
  autoUpdate,
154223
154583
  ...embeddedWorkbookData ? { embeddedWorkbookData } : {}
@@ -154588,6 +154948,8 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
154588
154948
  ...result.categoryLevels ? { categoryLevels: result.categoryLevels } : {},
154589
154949
  series: result.series,
154590
154950
  title: cxTitleText,
154951
+ titleTextEditable: false,
154952
+ dataLabelTextEditable: false,
154591
154953
  style: chartStyle2,
154592
154954
  chartPartPath,
154593
154955
  chartRelationshipId,
@@ -154611,6 +154973,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
154611
154973
  var PptxHandlerRuntime95;
154612
154974
  var init_PptxHandlerRuntimeChartParsing = __esm({
154613
154975
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts"() {
154976
+ init_chart_label_source();
154614
154977
  init_chart_advanced_parser();
154615
154978
  init_chart_axis_parser();
154616
154979
  init_chart_band_fmts();
@@ -154801,12 +155164,34 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
154801
155164
  colorAdapter
154802
155165
  );
154803
155166
  const style = chartStyleFromNeutral(neutral, this.extractChartStyle(chartSpace, chartRoot));
155167
+ const titleTx = reader2.xml.getChildByLocalName(
155168
+ reader2.xml.getChildByLocalName(chartRoot, "title"),
155169
+ "tx"
155170
+ );
155171
+ const titleRich = reader2.xml.getChildByLocalName(titleTx, "rich");
155172
+ const titleParagraphs = reader2.xml.getChildrenArrayByLocalName(titleRich, "p");
155173
+ const titleTextEditable = Boolean(
155174
+ titleRuns?.length && titleParagraphs.length === 1 && !Object.keys(titleParagraphs[0] ?? {}).some(
155175
+ (key2) => ["br", "fld"].includes(reader2.localName(key2))
155176
+ )
155177
+ );
154804
155178
  const groupOptions = groupOptionsFromNeutral(groups[0]?.group, chartType);
154805
155179
  const linesAndChrome = this.readChartLinesAndChrome(neutral, tree, groups, reader2);
154806
155180
  const facts = await this.readChartPartFacts(chartSpace, chartRoot, chartPartPath);
154807
155181
  const workbook = facts.embeddedWorkbookData;
154808
155182
  const dateCategories = rawDateCategories ? { ...rawDateCategories, date1904: neutral.date1904 ?? workbook?.date1904 ?? false } : void 0;
154809
155183
  const filled = applyEmbeddedWorkbookFallback(chartType, categories, built.series, workbook);
155184
+ const dataLabelTextEditable = !categoryLevels && !dateCategories && await chartLabelsHaveEditableSources(
155185
+ reader2.xml,
155186
+ this.zip,
155187
+ chartSpace,
155188
+ built.seriesNodes,
155189
+ filled.series,
155190
+ filled.categories,
155191
+ facts.externalData,
155192
+ chartPartPath,
155193
+ this.resolveImagePath.bind(this)
155194
+ );
154810
155195
  const hasPicture = filled.series.some(
154811
155196
  (entry2) => entry2.picture || entry2.impliedPicture || entry2.dataPoints?.some((point2) => point2.picture || point2.impliedPicture)
154812
155197
  );
@@ -154839,6 +155224,14 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
154839
155224
  ...built.filtered,
154840
155225
  title: neutralTitleText(neutral.title),
154841
155226
  ...titleRuns ? { titleRuns } : {},
155227
+ titleTextEditable,
155228
+ dataLabelTextEditable,
155229
+ ...dataLabelTextEditable ? {
155230
+ dataLabelSourceShape: {
155231
+ categoryCount: filled.categories.length,
155232
+ seriesValueCounts: filled.series.map((series) => series.values.length)
155233
+ }
155234
+ } : {},
154842
155235
  style,
154843
155236
  grouping: groupOptions.grouping,
154844
155237
  ...groupOptions,
@@ -155298,7 +155691,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
155298
155691
  );
155299
155692
  }
155300
155693
  try {
155301
- this.zip = await JSZip3__default.default.loadAsync(data);
155694
+ this.zip = await JSZip17__default.default.loadAsync(data);
155302
155695
  this.documentPropertiesUpdater = this.dependencyFactory.createDocumentPropertiesUpdater(
155303
155696
  this.zip,
155304
155697
  this.parser,
@@ -155336,6 +155729,8 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
155336
155729
  this.slideMap.clear();
155337
155730
  this.savedSlideFingerprints.clear();
155338
155731
  this.chartDataBaselines.clear();
155732
+ this.chartWorkbookDataBaselines.clear();
155733
+ this.pendingChartUpdates = void 0;
155339
155734
  this.layoutCache.clear();
155340
155735
  this.masterCache.clear();
155341
155736
  this.templateElementBaselines.reset();
@@ -155825,6 +156220,8 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
155825
156220
  this.slideMap.clear();
155826
156221
  this.savedSlideFingerprints.clear();
155827
156222
  this.chartDataBaselines.clear();
156223
+ this.chartWorkbookDataBaselines.clear();
156224
+ this.pendingChartUpdates = void 0;
155828
156225
  this.slideRelsMap.clear();
155829
156226
  this.externalRelsMap.clear();
155830
156227
  this.layoutCache.clear();
@@ -156223,7 +156620,7 @@ var init_PptxHandlerRuntimeImplementation = __esm({
156223
156620
  constructor(dependencyFactory = new exports.PptxRuntimeDependencyFactory()) {
156224
156621
  super();
156225
156622
  this.dependencyFactory = dependencyFactory;
156226
- this.zip = new JSZip3__default.default();
156623
+ this.zip = new JSZip17__default.default();
156227
156624
  this.parser = this.dependencyFactory.createParser();
156228
156625
  this.builder = this.dependencyFactory.createBuilder();
156229
156626
  this.elementXmlBuilder = new exports.PptxElementXmlBuilder({
@@ -159295,7 +159692,7 @@ function collectPictureIndexes(slide) {
159295
159692
  return indexes;
159296
159693
  }
159297
159694
  async function buildPptxPackage(deck) {
159298
- const zip = new JSZip3__default.default();
159695
+ const zip = new JSZip17__default.default();
159299
159696
  const usage = { fileNumbers: /* @__PURE__ */ new Map() };
159300
159697
  let mediaCounter = 0;
159301
159698
  for (const slide of deck.slides) {
@@ -161472,11 +161869,16 @@ function duplicateSlide(slide, newSlideNumber) {
161472
161869
  cloned.elements = cloned.elements.map(reassignElementId);
161473
161870
  if (cloned.animations && cloned.animations.length > 0) {
161474
161871
  const idMap = /* @__PURE__ */ new Map();
161475
- slide.elements.forEach((originalEl, idx) => {
161476
- if (idx < cloned.elements.length) {
161477
- idMap.set(originalEl.id, cloned.elements[idx].id);
161478
- }
161479
- });
161872
+ const mapElements = (originals, copies) => {
161873
+ originals.forEach((original, index) => {
161874
+ const copy2 = copies[index];
161875
+ if (!copy2) return;
161876
+ idMap.set(original.id, copy2.id);
161877
+ if (original.type === "group" && copy2.type === "group")
161878
+ mapElements(original.children, copy2.children);
161879
+ });
161880
+ };
161881
+ mapElements(slide.elements, cloned.elements);
161480
161882
  cloned.animations = cloned.animations.map((anim) => ({
161481
161883
  ...anim,
161482
161884
  elementId: idMap.get(anim.elementId) ?? anim.elementId
@@ -162101,7 +162503,7 @@ async function addLayoutContentType(zip, layoutIndex2) {
162101
162503
  }
162102
162504
  async function createLayout(handler, data, definition, masterIndex = 1) {
162103
162505
  const bytes = await handler.save(data.slides);
162104
- const zip = await JSZip3__default.default.loadAsync(bytes);
162506
+ const zip = await JSZip17__default.default.loadAsync(bytes);
162105
162507
  const existingCount = countExistingLayouts(zip);
162106
162508
  const newIndex = existingCount + 1;
162107
162509
  const layoutPath = `ppt/slideLayouts/slideLayout${newIndex}.xml`;
@@ -162124,7 +162526,7 @@ async function createLayouts(handler, data, definitions, masterIndex = 1) {
162124
162526
  return { layoutPaths: [], handler, data };
162125
162527
  }
162126
162528
  const bytes = await handler.save(data.slides);
162127
- const zip = await JSZip3__default.default.loadAsync(bytes);
162529
+ const zip = await JSZip17__default.default.loadAsync(bytes);
162128
162530
  const existingCount = countExistingLayouts(zip);
162129
162531
  const layoutPaths = [];
162130
162532
  for (let i2 = 0; i2 < definitions.length; i2++) {
@@ -162230,7 +162632,7 @@ init_xml_utils();
162230
162632
  init_PptxHandler();
162231
162633
  async function saveToZip(handler, data) {
162232
162634
  const bytes = await handler.save(data.slides);
162233
- return JSZip3__default.default.loadAsync(bytes);
162635
+ return JSZip17__default.default.loadAsync(bytes);
162234
162636
  }
162235
162637
  async function reload(zip) {
162236
162638
  const buffer = await zip.generateAsync({ type: "arraybuffer" });
@@ -164461,6 +164863,234 @@ function getThemePreset(name) {
164461
164863
  return ThemePresets[name];
164462
164864
  }
164463
164865
 
164866
+ // pptx/core/builders/sdk/import-slide-package.ts
164867
+ init_PresentationBuilder();
164868
+ init_PptxHandler();
164869
+ init_clone_part_graph();
164870
+ init_relationships();
164871
+ init_xml2();
164872
+ async function importSlidePackage(destination, source, options = {}) {
164873
+ if (options.insertAt !== void 0 && (!Number.isInteger(options.insertAt) || !Number.isFinite(options.insertAt)))
164874
+ throw new Error("Insertion point must be a finite integer");
164875
+ const [zip, sourceZip] = await Promise.all([
164876
+ JSZip17__default.default.loadAsync(destination),
164877
+ JSZip17__default.default.loadAsync(source)
164878
+ ]);
164879
+ const presentationPath = "ppt/presentation.xml";
164880
+ const sourceDoc = parseXml(await requiredXml(sourceZip, presentationPath));
164881
+ const destinationDoc = parseXml(await requiredXml(zip, presentationPath));
164882
+ const sourceRoot = sourceDoc.documentElement, root = destinationDoc.documentElement;
164883
+ const ns = root.namespaceURI ?? "";
164884
+ if (sourceRoot.namespaceURI !== ns)
164885
+ throw new Error("Cannot import slides between Strict and Transitional packages");
164886
+ const sourceSize = first(sourceRoot, "sldSz", ns), size = first(root, "sldSz", ns);
164887
+ if (sourceSize?.getAttribute("cx") !== size?.getAttribute("cx") || sourceSize?.getAttribute("cy") !== size?.getAttribute("cy"))
164888
+ throw new Error("Cannot import slides with a different slide size");
164889
+ if (first(sourceRoot, "embeddedFontLst", ns))
164890
+ throw new Error("Cross-deck embedded fonts are not supported");
164891
+ const relationshipNs = ns === "http://purl.oclc.org/ooxml/presentationml/main" ? "http://purl.oclc.org/ooxml/officeDocument/relationships" : "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
164892
+ const presentationRels = relationshipsPartFor(presentationPath);
164893
+ const sourceRels = parseRelationships(await requiredXml(sourceZip, presentationRels));
164894
+ for (const relationship of sourceRels.values()) {
164895
+ if (!relationship.type.endsWith("/tableStyles") || relationship.mode === "External") continue;
164896
+ const styles = parseXml(
164897
+ await requiredXml(sourceZip, resolvePartPath(presentationPath, relationship.target))
164898
+ );
164899
+ if (elements(styles.documentElement).some((node) => node.localName === "tblStyle"))
164900
+ throw new Error("Cross-deck custom table styles are not supported");
164901
+ }
164902
+ const destinationRels = parseRelationships(await requiredXml(zip, presentationRels));
164903
+ const masterIds = Array.from(root.getElementsByTagNameNS(ns, "sldMasterId")).map(
164904
+ (entry2) => entry2.getAttribute("id")
164905
+ );
164906
+ for (const relationship of destinationRels.values()) {
164907
+ if (!relationship.type.endsWith("/slideMaster") || relationship.mode === "External") continue;
164908
+ const master = parseXml(
164909
+ await requiredXml(zip, resolvePartPath(presentationPath, relationship.target))
164910
+ );
164911
+ for (const entry2 of Array.from(master.getElementsByTagNameNS(ns, "sldLayoutId")))
164912
+ masterIds.push(entry2.getAttribute("id"));
164913
+ }
164914
+ const allocateMasterId = nativeIdAllocator(masterIds, 2147483648, 4294967295, "master/layout");
164915
+ const masterParts = /* @__PURE__ */ new Map();
164916
+ for (const relationship of sourceRels.values()) {
164917
+ const type = relationship.type.slice(relationship.type.lastIndexOf("/") + 1);
164918
+ if ((type === "slideMaster" || type === "notesMaster") && relationship.mode !== "External")
164919
+ masterParts.set(resolvePartPath(presentationPath, relationship.target), type);
164920
+ }
164921
+ const sourceSlides = elements(first(sourceRoot, "sldIdLst", ns) ?? sourceRoot).filter(
164922
+ (node) => node.localName === "sldId"
164923
+ );
164924
+ const indexes = options.slideIndices ?? sourceSlides.map((_, index) => index);
164925
+ if (indexes.some(
164926
+ (index) => !Number.isInteger(index) || index < 0 || index >= sourceSlides.length
164927
+ ) || new Set(indexes).size !== indexes.length)
164928
+ throw new Error("Source slide indexes must be unique valid integers");
164929
+ if (!indexes.length) return { bytes: new Uint8Array(destination), slidePaths: [] };
164930
+ const selected = indexes.map((index) => {
164931
+ const rel = sourceRels.get(
164932
+ sourceSlides[index].getAttributeNS(relationshipNs, "id") ?? sourceSlides[index].getAttribute("r:id") ?? ""
164933
+ );
164934
+ if (!rel || rel.mode === "External") throw new Error("Source slide relationship is missing");
164935
+ return resolvePartPath(presentationPath, rel.target);
164936
+ });
164937
+ const selectedSet = new Set(selected), copies = /* @__PURE__ */ new Map();
164938
+ const reserved = new Set(Object.keys(zip.files));
164939
+ for (const path2 of selected) {
164940
+ let index = 1;
164941
+ while (reserved.has(`ppt/slides/slide${index}.xml`)) index++;
164942
+ const newPath = `ppt/slides/slide${index}.xml`;
164943
+ reserved.add(newPath);
164944
+ copies.set(path2, newPath);
164945
+ const bytes = await sourceZip.file(path2)?.async("uint8array");
164946
+ if (!bytes) throw new Error(`Source slide is missing: ${path2}`);
164947
+ zip.file(newPath, bytes);
164948
+ }
164949
+ for (const path2 of selected) {
164950
+ await clonePartGraph({
164951
+ zip,
164952
+ sourceZip,
164953
+ copies,
164954
+ sourcePart: path2,
164955
+ targetPart: copies.get(path2),
164956
+ shouldClone: (rel, part) => {
164957
+ const type = rel.type.slice(rel.type.lastIndexOf("/") + 1);
164958
+ if (type === "slideMaster" || type === "notesMaster") masterParts.set(part, type);
164959
+ if (/comment/iu.test(type)) throw new Error("Cross-deck comments are not supported");
164960
+ if (type === "slide" && !selectedSet.has(part))
164961
+ throw new Error("An imported slide links to a slide outside the selected set");
164962
+ return true;
164963
+ }
164964
+ });
164965
+ }
164966
+ const slideList = first(root, "sldIdLst", ns) ?? destinationDoc.createElementNS(ns, "p:sldIdLst");
164967
+ if (!slideList.parentNode) root.insertBefore(slideList, first(root, "sldSz", ns) ?? null);
164968
+ const existingSlides = elements(slideList);
164969
+ const insertAt3 = Math.min(
164970
+ Math.max(0, options.insertAt ?? existingSlides.length),
164971
+ existingSlides.length
164972
+ );
164973
+ const allocateSlideId = nativeIdAllocator(
164974
+ existingSlides.map((node) => node.getAttribute("id")),
164975
+ 256,
164976
+ 2147483647,
164977
+ "slide"
164978
+ );
164979
+ const used = new Set(destinationRels.keys());
164980
+ const register = (part, type) => {
164981
+ const id = nextRelationshipId(used);
164982
+ used.add(id);
164983
+ destinationRels.set(id, {
164984
+ id,
164985
+ type: `${relationshipNs}/${type}`,
164986
+ target: relativePartTarget(presentationPath, part),
164987
+ mode: "Internal"
164988
+ });
164989
+ return id;
164990
+ };
164991
+ const appendEntry = (list2, localName29, relationshipId2, id) => {
164992
+ const entry2 = destinationDoc.createElementNS(ns, `p:${localName29}`);
164993
+ if (id !== void 0) entry2.setAttribute("id", String(id));
164994
+ entry2.setAttributeNS(relationshipNs, "r:id", relationshipId2);
164995
+ list2.appendChild(entry2);
164996
+ return entry2;
164997
+ };
164998
+ for (const path2 of selected) {
164999
+ const entry2 = appendEntry(
165000
+ slideList,
165001
+ "sldId",
165002
+ register(copies.get(path2), "slide"),
165003
+ allocateSlideId()
165004
+ );
165005
+ slideList.insertBefore(entry2, existingSlides[insertAt3] ?? null);
165006
+ }
165007
+ let masterList = first(root, "sldMasterIdLst", ns);
165008
+ for (const [original, copied] of copies) {
165009
+ if (masterParts.get(original) !== "slideMaster") continue;
165010
+ if (!masterList) {
165011
+ masterList = destinationDoc.createElementNS(ns, "p:sldMasterIdLst");
165012
+ root.insertBefore(masterList, root.firstChild);
165013
+ }
165014
+ appendEntry(masterList, "sldMasterId", register(copied, "slideMaster"), allocateMasterId());
165015
+ const master = parseXml(await requiredXml(zip, copied));
165016
+ for (const entry2 of Array.from(master.getElementsByTagNameNS(ns, "sldLayoutId")))
165017
+ entry2.setAttribute("id", String(allocateMasterId()));
165018
+ zip.file(copied, buildXml(master));
165019
+ }
165020
+ let notesMasterList = first(root, "notesMasterIdLst", ns);
165021
+ for (const [original, copied] of copies) {
165022
+ if (masterParts.get(original) !== "notesMaster") continue;
165023
+ if (!notesMasterList) {
165024
+ notesMasterList = destinationDoc.createElementNS(ns, "p:notesMasterIdLst");
165025
+ root.insertBefore(notesMasterList, first(root, "handoutMasterIdLst", ns) ?? slideList);
165026
+ }
165027
+ appendEntry(notesMasterList, "notesMasterId", register(copied, "notesMaster"));
165028
+ }
165029
+ zip.file(presentationPath, buildXml(destinationDoc));
165030
+ zip.file(presentationRels, buildRelationshipsXml(destinationRels));
165031
+ return {
165032
+ bytes: await zip.generateAsync({ type: "uint8array" }),
165033
+ slidePaths: selected.map((path2) => copies.get(path2))
165034
+ };
165035
+ }
165036
+ async function requiredXml(zip, path2) {
165037
+ const text2 = await zip.file(path2)?.async("string");
165038
+ if (!text2) throw new Error(`Required package part is missing: ${path2}`);
165039
+ return text2;
165040
+ }
165041
+ function nativeIdAllocator(values, min, max, kind) {
165042
+ const used = /* @__PURE__ */ new Set();
165043
+ for (const value of values) {
165044
+ const id = Number(value);
165045
+ if (!Number.isInteger(id) || id < min || id > max || used.has(id))
165046
+ throw new Error(`Destination ${kind} IDs must be unique integers between ${min} and ${max}`);
165047
+ used.add(id);
165048
+ }
165049
+ let next = min;
165050
+ return () => {
165051
+ while (used.has(next) && next <= max) next++;
165052
+ if (next > max) throw new Error(`No available ${kind} IDs remain`);
165053
+ used.add(next);
165054
+ return next++;
165055
+ };
165056
+ }
165057
+ async function createSlideClipboardPackage(source, slideIndices) {
165058
+ const sourceZip = await JSZip17__default.default.loadAsync(source);
165059
+ const root = parseXml(await requiredXml(sourceZip, "ppt/presentation.xml")).documentElement;
165060
+ const size = first(root, "sldSz", root.namespaceURI ?? "");
165061
+ const width = Number(size?.getAttribute("cx")), height = Number(size?.getAttribute("cy"));
165062
+ if (!width || !height) throw new Error("Source slide dimensions are missing");
165063
+ let blank = new Uint8Array(await buildBlankPresentationArchive({ width, height }));
165064
+ if (root.namespaceURI === "http://purl.oclc.org/ooxml/presentationml/main") {
165065
+ const handler = new exports.PptxHandler();
165066
+ try {
165067
+ await handler.load(blank.buffer);
165068
+ blank = await handler.save([], { conformance: "strict" });
165069
+ } finally {
165070
+ handler.dispose();
165071
+ }
165072
+ }
165073
+ return (await importSlidePackage(blank, source, { slideIndices })).bytes;
165074
+ }
165075
+
165076
+ // pptx/core/builders/sdk/slide-package-clipboard-codec.ts
165077
+ init_json_binary_codec();
165078
+ var SLIDE_PACKAGE_CLIPBOARD_MIME = "web application/vnd.ooxml.pptx-slide-package";
165079
+ var MARKER2 = "ooxml.pptx.slide-package.v1\n";
165080
+ function serializeSlidePackageClipboard(bytes) {
165081
+ return MARKER2 + bytesToBase64(bytes);
165082
+ }
165083
+ function deserializeSlidePackageClipboard(text2) {
165084
+ if (!text2.startsWith(MARKER2)) return null;
165085
+ const payload = text2.slice(MARKER2.length);
165086
+ if (!payload || payload.length % 4 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u.test(payload))
165087
+ throw new Error("Copied slide package is malformed");
165088
+ const bytes = base64ToBytes(payload);
165089
+ if (bytes[0] !== 80 || bytes[1] !== 75)
165090
+ throw new Error("Copied slides do not contain an OOXML archive");
165091
+ return bytes;
165092
+ }
165093
+
164464
165094
  // pptx/core/index.ts
164465
165095
  init_core2();
164466
165096
  init_services();
@@ -175639,15 +176269,26 @@ init_font_substitution();
175639
176269
  var DEFAULT_FONT_SIZE = 18;
175640
176270
  var FALLBACK_PAD_FACTOR = 0.06;
175641
176271
  function drawTextSegments(ctx, segments, bodyStyle, w, h2, scaleFactor = 1) {
175642
- const padL = bodyStyle?.bodyInsetLeft ? bodyStyle.bodyInsetLeft * scaleFactor : Math.round(w * FALLBACK_PAD_FACTOR);
175643
- const padR = bodyStyle?.bodyInsetRight ? bodyStyle.bodyInsetRight * scaleFactor : Math.round(w * FALLBACK_PAD_FACTOR);
175644
- const padT = bodyStyle?.bodyInsetTop ? bodyStyle.bodyInsetTop * scaleFactor : Math.round(h2 * FALLBACK_PAD_FACTOR);
175645
- const padB = bodyStyle?.bodyInsetBottom ? bodyStyle.bodyInsetBottom * scaleFactor : Math.round(h2 * FALLBACK_PAD_FACTOR);
176272
+ const padL = bodyStyle?.bodyInsetLeft !== void 0 ? bodyStyle.bodyInsetLeft * scaleFactor : Math.round(w * FALLBACK_PAD_FACTOR);
176273
+ const padR = bodyStyle?.bodyInsetRight !== void 0 ? bodyStyle.bodyInsetRight * scaleFactor : Math.round(w * FALLBACK_PAD_FACTOR);
176274
+ const padT = bodyStyle?.bodyInsetTop !== void 0 ? bodyStyle.bodyInsetTop * scaleFactor : Math.round(h2 * FALLBACK_PAD_FACTOR);
176275
+ const padB = bodyStyle?.bodyInsetBottom !== void 0 ? bodyStyle.bodyInsetBottom * scaleFactor : Math.round(h2 * FALLBACK_PAD_FACTOR);
175646
176276
  const maxWidth = w - padL - padR;
175647
176277
  if (maxWidth <= 0) {
175648
176278
  return;
175649
176279
  }
175650
- const paragraphs = splitIntoParagraphs(segments);
176280
+ const paragraphs = splitIntoParagraphs(
176281
+ segments.map((segment) => ({
176282
+ ...segment,
176283
+ style: {
176284
+ ...bodyStyle,
176285
+ ...Object.fromEntries(
176286
+ Object.entries(segment.style).filter(([, value]) => value !== void 0)
176287
+ )
176288
+ }
176289
+ })),
176290
+ bodyStyle
176291
+ );
175651
176292
  const lines = layoutParagraphs(ctx, paragraphs, maxWidth, scaleFactor);
175652
176293
  if (lines.length === 0) {
175653
176294
  return;
@@ -175683,33 +176324,58 @@ function drawTextSegments(ctx, segments, bodyStyle, w, h2, scaleFactor = 1) {
175683
176324
  y += line2.height * 0.3;
175684
176325
  }
175685
176326
  }
175686
- function splitIntoParagraphs(segments) {
175687
- const paragraphs = [[]];
176327
+ function splitIntoParagraphs(segments, bodyStyle) {
176328
+ const paragraphs = [{ segments: [], style: bodyStyle ?? {} }];
175688
176329
  for (const seg of segments) {
175689
- if (seg.isParagraphBreak) {
175690
- paragraphs.push([]);
175691
- } else if (seg.text) {
175692
- paragraphs[paragraphs.length - 1].push(seg);
176330
+ if (seg.isParagraphBreak || seg.text === "\n" && !seg.isLineBreak) {
176331
+ paragraphs.push({ segments: [], style: seg.style });
176332
+ } else if (seg.text || seg.isLineBreak) {
176333
+ paragraphs[paragraphs.length - 1].segments.push(seg);
175693
176334
  }
175694
176335
  }
175695
- return paragraphs.filter((p) => p.length > 0);
176336
+ return paragraphs;
175696
176337
  }
175697
176338
  function layoutParagraphs(ctx, paragraphs, maxWidth, scaleFactor) {
175698
176339
  const lines = [];
175699
- for (const para of paragraphs) {
175700
- const paraAlign = para[0]?.style?.align;
176340
+ for (const paragraph of paragraphs) {
176341
+ const para = paragraph.segments;
176342
+ const paraAlign = para[0]?.style.align ?? paragraph.style.align;
175701
176343
  let currentLine = [];
175702
176344
  let lineWidth = 0;
175703
176345
  let lineHeight = 0;
176346
+ let fallbackHeight = (para[0]?.style.fontSize ?? paragraph.style.fontSize ?? DEFAULT_FONT_SIZE) * scaleFactor * 1.2;
176347
+ const flushLine = () => {
176348
+ while (currentLine.length > 0 && /^\s+$/.test(currentLine[currentLine.length - 1].text)) {
176349
+ lineWidth -= currentLine.pop().measuredWidth;
176350
+ }
176351
+ lines.push({
176352
+ runs: currentLine,
176353
+ width: lineWidth,
176354
+ height: lineHeight || fallbackHeight,
176355
+ align: paraAlign
176356
+ });
176357
+ currentLine = [];
176358
+ lineWidth = 0;
176359
+ lineHeight = 0;
176360
+ };
175704
176361
  for (const seg of para) {
175705
176362
  ctx.font = buildFont(seg.style, scaleFactor);
175706
176363
  const fontSize = (seg.style.fontSize ?? DEFAULT_FONT_SIZE) * scaleFactor;
175707
176364
  const segHeight = fontSize * 1.2;
175708
- const tokens = seg.text.split(/(?<=\s)(?=\S)|(?<=\S)(?=\s)/);
176365
+ fallbackHeight = segHeight;
176366
+ if (seg.isLineBreak) {
176367
+ flushLine();
176368
+ continue;
176369
+ }
176370
+ const tokens = seg.text.split(/(\r\n|\r|\n)|(?<=\s)(?=\S)|(?<=\S)(?=\s)/);
175709
176371
  for (const raw of tokens) {
175710
176372
  if (!raw) {
175711
176373
  continue;
175712
176374
  }
176375
+ if (/^(\r\n|\r|\n)$/.test(raw)) {
176376
+ flushLine();
176377
+ continue;
176378
+ }
175713
176379
  if (/^\s+$/.test(raw)) {
175714
176380
  if (currentLine.length > 0) {
175715
176381
  const spaceW = ctx.measureText(raw).width;
@@ -175725,19 +176391,7 @@ function layoutParagraphs(ctx, paragraphs, maxWidth, scaleFactor) {
175725
176391
  const word = raw;
175726
176392
  const wordW = ctx.measureText(word).width;
175727
176393
  if (lineWidth + wordW > maxWidth && currentLine.length > 0) {
175728
- while (currentLine.length > 0 && /^\s+$/.test(currentLine[currentLine.length - 1].text)) {
175729
- const removed = currentLine.pop();
175730
- lineWidth -= removed.measuredWidth;
175731
- }
175732
- lines.push({
175733
- runs: currentLine,
175734
- width: lineWidth,
175735
- height: lineHeight,
175736
- align: paraAlign
175737
- });
175738
- currentLine = [];
175739
- lineWidth = 0;
175740
- lineHeight = 0;
176394
+ flushLine();
175741
176395
  }
175742
176396
  currentLine.push({
175743
176397
  text: word,
@@ -175748,14 +176402,7 @@ function layoutParagraphs(ctx, paragraphs, maxWidth, scaleFactor) {
175748
176402
  lineHeight = Math.max(lineHeight, segHeight);
175749
176403
  }
175750
176404
  }
175751
- if (currentLine.length > 0) {
175752
- lines.push({
175753
- runs: currentLine,
175754
- width: lineWidth,
175755
- height: lineHeight,
175756
- align: paraAlign
175757
- });
175758
- }
176405
+ flushLine();
175759
176406
  }
175760
176407
  return lines;
175761
176408
  }
@@ -177691,6 +178338,7 @@ exports.PptxMarkdownConverter = PptxMarkdownConverter;
177691
178338
  exports.PptxSaveSession = exports.PptxSaveState;
177692
178339
  exports.PptxSaveSessionBuilder = exports.PptxSaveStateBuilder;
177693
178340
  exports.Presentation = Presentation;
178341
+ exports.SLIDE_PACKAGE_CLIPBOARD_MIME = SLIDE_PACKAGE_CLIPBOARD_MIME;
177694
178342
  exports.ShapeBuilder = ShapeBuilder;
177695
178343
  exports.SlideProcessor = SlideProcessor;
177696
178344
  exports.SlideSizes = SlideSizes;
@@ -177836,6 +178484,7 @@ exports.createMediaElement = createMediaElement;
177836
178484
  exports.createModifyVerifier = createModifyVerifier;
177837
178485
  exports.createSaltlessModifyVerifierForTesting = createSaltlessModifyVerifierForTesting;
177838
178486
  exports.createShapeElement = createShapeElement;
178487
+ exports.createSlideClipboardPackage = createSlideClipboardPackage;
177839
178488
  exports.createTableCellXml = createTableCellXml;
177840
178489
  exports.createTableElement = createTableElement;
177841
178490
  exports.createTableGraphicFrameRawXml = createTableGraphicFrameRawXml;
@@ -177864,6 +178513,7 @@ exports.deriveOutputPath = deriveOutputPath;
177864
178513
  exports.deriveSlideTitle = deriveSlideTitle;
177865
178514
  exports.deriveSlideTitles = deriveSlideTitles;
177866
178515
  exports.deserializePptxFromJson = deserializePptxFromJson;
178516
+ exports.deserializeSlidePackageClipboard = deserializeSlidePackageClipboard;
177867
178517
  exports.detectDigitalSignatures = detectDigitalSignatures;
177868
178518
  exports.detectFileFormat = detectFileFormat;
177869
178519
  exports.detectFontFormat = detectFontFormat;
@@ -177994,6 +178644,7 @@ exports.hasTextProperties = hasTextProperties;
177994
178644
  exports.hebrewAlphaLabel = hebrewAlphaLabel;
177995
178645
  exports.hexToRgbChannels = hexToRgbChannels;
177996
178646
  exports.hslToRgb = hslToRgb;
178647
+ exports.importSlidePackage = importSlidePackage;
177997
178648
  exports.inches = inches;
177998
178649
  exports.inchesToEmu = inchesToEmu;
177999
178650
  exports.inferOleExtensionFromTarget = inferOleExtensionFromTarget;
@@ -178247,6 +178898,7 @@ exports.serializeCondition = serializeCondition;
178247
178898
  exports.serializeConditionList = serializeConditionList;
178248
178899
  exports.serializeGraphicBuild = serializeGraphicBuild;
178249
178900
  exports.serializePptxToJson = serializePptxToJson;
178901
+ exports.serializeSlidePackageClipboard = serializeSlidePackageClipboard;
178250
178902
  exports.serializeSmartArtDefinitionHeaderList = serializeSmartArtDefinitionHeaderList;
178251
178903
  exports.serializeSvgPath = serializeSvgPath;
178252
178904
  exports.serializeTimeTargetElement = serializeTimeTargetElement;