ooxml-core 1.37.0 → 1.38.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 (335) hide show
  1. package/README.md +7 -0
  2. package/dist/automation/index.cjs +207 -207
  3. package/dist/automation/index.mjs +207 -207
  4. package/dist/{chunk-M2DFN3SP.mjs → chunk-XBIZIBTJ.mjs} +507 -10
  5. package/dist/collab/merge-values.d.ts +14 -0
  6. package/dist/collab/merge-values.d.ts.map +1 -0
  7. package/dist/docx/embedded.cjs +476 -474
  8. package/dist/docx/embedded.mjs +476 -474
  9. package/dist/docx/index.cjs +1075 -719
  10. package/dist/docx/index.d.ts +1 -0
  11. package/dist/docx/index.d.ts.map +1 -1
  12. package/dist/docx/index.mjs +1075 -720
  13. package/dist/docx/layout/index.cjs +4 -0
  14. package/dist/docx/layout/index.mjs +4 -0
  15. package/dist/docx/load/index.cjs +164 -164
  16. package/dist/docx/load/index.mjs +164 -164
  17. package/dist/docx/merge-snapshots.d.ts +9 -0
  18. package/dist/docx/merge-snapshots.d.ts.map +1 -0
  19. package/dist/docx/ui/index.cjs +155 -155
  20. package/dist/docx/ui/index.mjs +155 -155
  21. package/dist/embedding/index.cjs +207 -0
  22. package/dist/embedding/index.d.ts +3 -0
  23. package/dist/embedding/index.d.ts.map +1 -1
  24. package/dist/embedding/index.mjs +205 -1
  25. package/dist/embedding/onedrive/client.d.ts +4 -0
  26. package/dist/embedding/onedrive/client.d.ts.map +1 -0
  27. package/dist/embedding/onedrive/index.cjs +617 -0
  28. package/dist/embedding/onedrive/index.d.ts +6 -0
  29. package/dist/embedding/onedrive/index.d.ts.map +1 -0
  30. package/dist/embedding/onedrive/index.mjs +611 -0
  31. package/dist/embedding/onedrive/metadata.d.ts +6 -0
  32. package/dist/embedding/onedrive/metadata.d.ts.map +1 -0
  33. package/dist/embedding/onedrive/requests.d.ts +8 -0
  34. package/dist/embedding/onedrive/requests.d.ts.map +1 -0
  35. package/dist/embedding/onedrive/session.d.ts +4 -0
  36. package/dist/embedding/onedrive/session.d.ts.map +1 -0
  37. package/dist/embedding/onedrive/transport.d.ts +9 -0
  38. package/dist/embedding/onedrive/transport.d.ts.map +1 -0
  39. package/dist/embedding/onedrive/types.d.ts +86 -0
  40. package/dist/embedding/onedrive/types.d.ts.map +1 -0
  41. package/dist/embedding/onedrive/upload.d.ts +3 -0
  42. package/dist/embedding/onedrive/upload.d.ts.map +1 -0
  43. package/dist/embedding/storage-merge.d.ts +8 -0
  44. package/dist/embedding/storage-merge.d.ts.map +1 -0
  45. package/dist/embedding/storage-session.d.ts +7 -0
  46. package/dist/embedding/storage-session.d.ts.map +1 -0
  47. package/dist/embedding/versioned-storage.d.ts +67 -0
  48. package/dist/embedding/versioned-storage.d.ts.map +1 -0
  49. package/dist/index.cjs +1013 -340
  50. package/dist/index.mjs +1013 -340
  51. package/dist/opc/index.cjs +680 -216
  52. package/dist/opc/index.d.ts +1 -0
  53. package/dist/opc/index.d.ts.map +1 -1
  54. package/dist/opc/index.mjs +680 -217
  55. package/dist/opc/merge-snapshots.d.ts +26 -0
  56. package/dist/opc/merge-snapshots.d.ts.map +1 -0
  57. package/dist/pptx/automation/index.cjs +20 -6
  58. package/dist/pptx/automation/index.d.ts +8 -17
  59. package/dist/pptx/automation/index.d.ts.map +1 -1
  60. package/dist/pptx/automation/index.mjs +1 -1
  61. package/dist/pptx/automation/schemas/chart-formatting-schemas.d.ts +1 -3
  62. package/dist/pptx/automation/schemas/chart-formatting-schemas.d.ts.map +1 -1
  63. package/dist/pptx/automation/schemas/chart-schemas.d.ts +1 -3
  64. package/dist/pptx/automation/schemas/chart-schemas.d.ts.map +1 -1
  65. package/dist/pptx/automation/schemas/chart-user-shape-schemas.d.ts +1 -3
  66. package/dist/pptx/automation/schemas/chart-user-shape-schemas.d.ts.map +1 -1
  67. package/dist/pptx/automation/schemas/element-schemas.d.ts +1 -3
  68. package/dist/pptx/automation/schemas/element-schemas.d.ts.map +1 -1
  69. package/dist/pptx/automation/schemas/export-schemas.d.ts +1 -3
  70. package/dist/pptx/automation/schemas/export-schemas.d.ts.map +1 -1
  71. package/dist/pptx/automation/schemas/geometry-schemas.d.ts +1 -3
  72. package/dist/pptx/automation/schemas/geometry-schemas.d.ts.map +1 -1
  73. package/dist/pptx/automation/schemas/hyperlink-schemas.d.ts +1 -3
  74. package/dist/pptx/automation/schemas/hyperlink-schemas.d.ts.map +1 -1
  75. package/dist/pptx/automation/schemas/index.d.ts +1 -3
  76. package/dist/pptx/automation/schemas/index.d.ts.map +1 -1
  77. package/dist/pptx/automation/schemas/json-schemas.d.ts +1 -3
  78. package/dist/pptx/automation/schemas/json-schemas.d.ts.map +1 -1
  79. package/dist/pptx/automation/schemas/layout-schemas.d.ts +1 -3
  80. package/dist/pptx/automation/schemas/layout-schemas.d.ts.map +1 -1
  81. package/dist/pptx/automation/schemas/lock-schemas.d.ts +1 -3
  82. package/dist/pptx/automation/schemas/lock-schemas.d.ts.map +1 -1
  83. package/dist/pptx/automation/schemas/metadata-schemas.d.ts +1 -3
  84. package/dist/pptx/automation/schemas/metadata-schemas.d.ts.map +1 -1
  85. package/dist/pptx/automation/schemas/ole-schemas.d.ts +1 -3
  86. package/dist/pptx/automation/schemas/ole-schemas.d.ts.map +1 -1
  87. package/dist/pptx/automation/schemas/presentation-schemas.d.ts +1 -3
  88. package/dist/pptx/automation/schemas/presentation-schemas.d.ts.map +1 -1
  89. package/dist/pptx/automation/schemas/section-schemas.d.ts +1 -3
  90. package/dist/pptx/automation/schemas/section-schemas.d.ts.map +1 -1
  91. package/dist/pptx/automation/schemas/slide-schemas.d.ts +1 -3
  92. package/dist/pptx/automation/schemas/slide-schemas.d.ts.map +1 -1
  93. package/dist/pptx/automation/schemas/smartart-schemas.d.ts +1 -3
  94. package/dist/pptx/automation/schemas/smartart-schemas.d.ts.map +1 -1
  95. package/dist/pptx/automation/schemas/table-style-schemas.d.ts +1 -3
  96. package/dist/pptx/automation/schemas/table-style-schemas.d.ts.map +1 -1
  97. package/dist/pptx/automation/schemas/template-schemas.d.ts +1 -3
  98. package/dist/pptx/automation/schemas/template-schemas.d.ts.map +1 -1
  99. package/dist/pptx/automation/schemas/theme-schemas.d.ts +1 -3
  100. package/dist/pptx/automation/schemas/theme-schemas.d.ts.map +1 -1
  101. package/dist/pptx/automation/schemas/validation-schemas.d.ts +1 -3
  102. package/dist/pptx/automation/schemas/validation-schemas.d.ts.map +1 -1
  103. package/dist/pptx/chunks/{collaboration-text-codec-Du_XeE_i.d.ts → collaboration-text-codec-1VmwD3yq.d.ts} +1 -3
  104. package/dist/pptx/chunks/collaboration-text-codec-1VmwD3yq.d.ts.map +1 -0
  105. package/dist/pptx/chunks/{collaboration-text-merge-DWWWdT_t.d.ts → collaboration-text-merge-B-tth-0W.d.ts} +2 -4
  106. package/dist/pptx/chunks/collaboration-text-merge-B-tth-0W.d.ts.map +1 -0
  107. package/dist/pptx/chunks/{collaboration-text-positions-MMT3GkZi.d.ts → collaboration-text-positions-D-1Jo1Fz.d.ts} +1 -3
  108. package/dist/pptx/chunks/collaboration-text-positions-D-1Jo1Fz.d.ts.map +1 -0
  109. package/dist/pptx/chunks/{collaboration-text-session-D0NOLQk7.d.ts → collaboration-text-session-CWHTaWF4.d.ts} +4 -6
  110. package/dist/pptx/chunks/collaboration-text-session-CWHTaWF4.d.ts.map +1 -0
  111. package/dist/pptx/chunks/{collaboration-text-session-delta-CzJGrTKJ.d.ts → collaboration-text-session-delta-Dxzybssp.d.ts} +2 -4
  112. package/dist/pptx/chunks/collaboration-text-session-delta-Dxzybssp.d.ts.map +1 -0
  113. package/dist/pptx/chunks/{color-ref-DT599vEx.d.ts → color-ref-CwUQoKPJ.d.ts} +1 -3
  114. package/dist/pptx/chunks/color-ref-CwUQoKPJ.d.ts.map +1 -0
  115. package/dist/pptx/chunks/{elements-f3UbFph-.d.ts → elements-DheCTwi0.d.ts} +4 -54
  116. package/dist/pptx/chunks/elements-DheCTwi0.d.ts.map +1 -0
  117. package/dist/pptx/chunks/{index-Bp-1pGo1.d.ts → index-B4ofjG6_.d.ts} +6 -384
  118. package/dist/pptx/chunks/index-B4ofjG6_.d.ts.map +1 -0
  119. package/dist/pptx/chunks/{index-BnH2QjYm.d.ts → index-Jcce8TlI.d.ts} +5 -37
  120. package/dist/pptx/chunks/index-Jcce8TlI.d.ts.map +1 -0
  121. package/dist/pptx/chunks/{index-pLLN4OTz.d.ts → index-bgj0Ztnq.d.ts} +23 -543
  122. package/dist/pptx/chunks/index-bgj0Ztnq.d.ts.map +1 -0
  123. package/dist/pptx/chunks/{inspection-status-DjiWd_Aa.d.ts → inspection-status-TKac7eqb.d.ts} +1 -13
  124. package/dist/pptx/chunks/inspection-status-TKac7eqb.d.ts.map +1 -0
  125. package/dist/pptx/chunks/{schemas-fuDGetRe.d.ts → schemas-LHsDbVOw.d.ts} +1 -29
  126. package/dist/pptx/chunks/schemas-LHsDbVOw.d.ts.map +1 -0
  127. package/dist/pptx/chunks/{smart-art-CmOrPLLQ.d.ts → smart-art-DB37AsFP.d.ts} +2 -46
  128. package/dist/pptx/chunks/smart-art-DB37AsFP.d.ts.map +1 -0
  129. package/dist/pptx/chunks/{text-operations-D5sgspO6.d.ts → text-operations-CdgEnFuK.d.ts} +4 -32
  130. package/dist/pptx/chunks/text-operations-CdgEnFuK.d.ts.map +1 -0
  131. package/dist/pptx/chunks/{text-P9xVnXXf.d.ts → text-t_wJ2OwM.d.ts} +2 -12
  132. package/dist/pptx/chunks/text-t_wJ2OwM.d.ts.map +1 -0
  133. package/dist/pptx/cli/index.cjs +20 -6
  134. package/dist/pptx/cli/index.d.ts +1 -3
  135. package/dist/pptx/cli/index.d.ts.map +1 -1
  136. package/dist/pptx/converter/index.cjs +7 -0
  137. package/dist/pptx/converter/index.d.ts +1 -1
  138. package/dist/pptx/editor/ai/table-merge.d.ts +0 -2
  139. package/dist/pptx/editor/ai/table-merge.d.ts.map +1 -1
  140. package/dist/pptx/editor/loader/element-patch-walker.d.ts +0 -2
  141. package/dist/pptx/editor/loader/element-patch-walker.d.ts.map +1 -1
  142. package/dist/pptx/editor/loader/is-external-url.d.ts +0 -2
  143. package/dist/pptx/editor/loader/is-external-url.d.ts.map +1 -1
  144. package/dist/pptx/editor/loader/lazy-image-resolution.d.ts +0 -2
  145. package/dist/pptx/editor/loader/lazy-image-resolution.d.ts.map +1 -1
  146. package/dist/pptx/editor/loader/load-content-helpers.d.ts +0 -2
  147. package/dist/pptx/editor/loader/load-content-helpers.d.ts.map +1 -1
  148. package/dist/pptx/editor/loader/table-style-image-paths.d.ts +0 -2
  149. package/dist/pptx/editor/loader/table-style-image-paths.d.ts.map +1 -1
  150. package/dist/pptx/editor/loader/text-fill-image-paths.d.ts +0 -2
  151. package/dist/pptx/editor/loader/text-fill-image-paths.d.ts.map +1 -1
  152. package/dist/pptx/editor/render/bullet-list.d.ts +0 -2
  153. package/dist/pptx/editor/render/bullet-list.d.ts.map +1 -1
  154. package/dist/pptx/editor/render/bullet-toggle.d.ts +0 -2
  155. package/dist/pptx/editor/render/bullet-toggle.d.ts.map +1 -1
  156. package/dist/pptx/editor/render/chart-user-shape-edit.d.ts +0 -2
  157. package/dist/pptx/editor/render/chart-user-shape-edit.d.ts.map +1 -1
  158. package/dist/pptx/editor/render/clone.d.ts +0 -2
  159. package/dist/pptx/editor/render/clone.d.ts.map +1 -1
  160. package/dist/pptx/editor/render/collaboration-active-session.d.ts +0 -2
  161. package/dist/pptx/editor/render/collaboration-active-session.d.ts.map +1 -1
  162. package/dist/pptx/editor/render/collaboration-departure.d.ts +0 -2
  163. package/dist/pptx/editor/render/collaboration-departure.d.ts.map +1 -1
  164. package/dist/pptx/editor/render/collaboration-live-patch-target.d.ts +0 -2
  165. package/dist/pptx/editor/render/collaboration-live-patch-target.d.ts.map +1 -1
  166. package/dist/pptx/editor/render/collaboration-load-origin.d.ts +0 -2
  167. package/dist/pptx/editor/render/collaboration-load-origin.d.ts.map +1 -1
  168. package/dist/pptx/editor/render/collaboration-reconcile.d.ts +0 -2
  169. package/dist/pptx/editor/render/collaboration-reconcile.d.ts.map +1 -1
  170. package/dist/pptx/editor/render/collaboration-sync.d.ts +4 -8
  171. package/dist/pptx/editor/render/collaboration-sync.d.ts.map +1 -1
  172. package/dist/pptx/editor/render/collaboration-text-codec.d.ts +1 -1
  173. package/dist/pptx/editor/render/collaboration-text-lease.d.ts +0 -2
  174. package/dist/pptx/editor/render/collaboration-text-lease.d.ts.map +1 -1
  175. package/dist/pptx/editor/render/collaboration-text-merge.d.ts +1 -1
  176. package/dist/pptx/editor/render/collaboration-text-native-edit.d.ts +2 -4
  177. package/dist/pptx/editor/render/collaboration-text-native-edit.d.ts.map +1 -1
  178. package/dist/pptx/editor/render/collaboration-text-positions.d.ts +1 -1
  179. package/dist/pptx/editor/render/collaboration-text-projection.d.ts +1 -3
  180. package/dist/pptx/editor/render/collaboration-text-projection.d.ts.map +1 -1
  181. package/dist/pptx/editor/render/collaboration-text-session-apply.d.ts +3 -5
  182. package/dist/pptx/editor/render/collaboration-text-session-apply.d.ts.map +1 -1
  183. package/dist/pptx/editor/render/collaboration-text-session-delta.d.ts +1 -1
  184. package/dist/pptx/editor/render/collaboration-text-session-paragraph.d.ts +1 -3
  185. package/dist/pptx/editor/render/collaboration-text-session-paragraph.d.ts.map +1 -1
  186. package/dist/pptx/editor/render/collaboration-text-session.d.ts +1 -1
  187. package/dist/pptx/editor/render/collaboration-text-snapshot-positions.d.ts +2 -4
  188. package/dist/pptx/editor/render/collaboration-text-snapshot-positions.d.ts.map +1 -1
  189. package/dist/pptx/editor/render/custom-show-operations.d.ts +0 -2
  190. package/dist/pptx/editor/render/custom-show-operations.d.ts.map +1 -1
  191. package/dist/pptx/editor/render/deck-save-encryption.d.ts +0 -2
  192. package/dist/pptx/editor/render/deck-save-encryption.d.ts.map +1 -1
  193. package/dist/pptx/editor/render/editor-history.d.ts +0 -2
  194. package/dist/pptx/editor/render/editor-history.d.ts.map +1 -1
  195. package/dist/pptx/editor/render/editor-mutations.d.ts +0 -2
  196. package/dist/pptx/editor/render/editor-mutations.d.ts.map +1 -1
  197. package/dist/pptx/editor/render/element-locks.d.ts +0 -2
  198. package/dist/pptx/editor/render/element-locks.d.ts.map +1 -1
  199. package/dist/pptx/editor/render/element-operations.d.ts +0 -2
  200. package/dist/pptx/editor/render/element-operations.d.ts.map +1 -1
  201. package/dist/pptx/editor/render/element.d.ts +0 -2
  202. package/dist/pptx/editor/render/element.d.ts.map +1 -1
  203. package/dist/pptx/editor/render/find-replace.d.ts +2 -4
  204. package/dist/pptx/editor/render/find-replace.d.ts.map +1 -1
  205. package/dist/pptx/editor/render/font-family-update.d.ts +1 -3
  206. package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -1
  207. package/dist/pptx/editor/render/group-drill.d.ts +0 -2
  208. package/dist/pptx/editor/render/group-drill.d.ts.map +1 -1
  209. package/dist/pptx/editor/render/inline-list-body.d.ts +0 -2
  210. package/dist/pptx/editor/render/inline-list-body.d.ts.map +1 -1
  211. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +1 -3
  212. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -1
  213. package/dist/pptx/editor/render/remap-empty-paragraph.d.ts +0 -2
  214. package/dist/pptx/editor/render/remap-empty-paragraph.d.ts.map +1 -1
  215. package/dist/pptx/editor/render/remap-paragraph-sources.d.ts +0 -2
  216. package/dist/pptx/editor/render/remap-paragraph-sources.d.ts.map +1 -1
  217. package/dist/pptx/editor/render/remap-text-bullets.d.ts +0 -2
  218. package/dist/pptx/editor/render/remap-text-bullets.d.ts.map +1 -1
  219. package/dist/pptx/editor/render/remap-text.d.ts +0 -2
  220. package/dist/pptx/editor/render/remap-text.d.ts.map +1 -1
  221. package/dist/pptx/editor/render/schema-label-keys.d.ts +0 -2
  222. package/dist/pptx/editor/render/schema-label-keys.d.ts.map +1 -1
  223. package/dist/pptx/editor/render/section-operations.d.ts +0 -2
  224. package/dist/pptx/editor/render/section-operations.d.ts.map +1 -1
  225. package/dist/pptx/editor/render/slide-background-patch.d.ts +0 -2
  226. package/dist/pptx/editor/render/slide-background-patch.d.ts.map +1 -1
  227. package/dist/pptx/editor/render/slide-operations.d.ts +0 -2
  228. package/dist/pptx/editor/render/slide-operations.d.ts.map +1 -1
  229. package/dist/pptx/editor/render/slide-search.d.ts +0 -2
  230. package/dist/pptx/editor/render/slide-search.d.ts.map +1 -1
  231. package/dist/pptx/editor/render/slide-size-rescale.d.ts +0 -2
  232. package/dist/pptx/editor/render/slide-size-rescale.d.ts.map +1 -1
  233. package/dist/pptx/editor/render/slide-transition-edits.d.ts +0 -2
  234. package/dist/pptx/editor/render/slide-transition-edits.d.ts.map +1 -1
  235. package/dist/pptx/editor/render/table-cell-edit.d.ts +0 -2
  236. package/dist/pptx/editor/render/table-cell-edit.d.ts.map +1 -1
  237. package/dist/pptx/editor/render/table-cell-merge.d.ts +0 -2
  238. package/dist/pptx/editor/render/table-cell-merge.d.ts.map +1 -1
  239. package/dist/pptx/editor/render/table-data-grid-ops.d.ts +0 -2
  240. package/dist/pptx/editor/render/table-data-grid-ops.d.ts.map +1 -1
  241. package/dist/pptx/editor/render/table-layout.d.ts +0 -2
  242. package/dist/pptx/editor/render/table-layout.d.ts.map +1 -1
  243. package/dist/pptx/editor/render/table-merge.d.ts +0 -2
  244. package/dist/pptx/editor/render/table-merge.d.ts.map +1 -1
  245. package/dist/pptx/editor/render/table-style-editor-descriptor.d.ts +0 -2
  246. package/dist/pptx/editor/render/table-style-editor-descriptor.d.ts.map +1 -1
  247. package/dist/pptx/editor/render/table-style-editor-edit.d.ts +0 -2
  248. package/dist/pptx/editor/render/table-style-editor-edit.d.ts.map +1 -1
  249. package/dist/pptx/editor/render/table-style-editor-parts.d.ts +0 -2
  250. package/dist/pptx/editor/render/table-style-editor-parts.d.ts.map +1 -1
  251. package/dist/pptx/editor/render/table-style-map-edits.d.ts +0 -2
  252. package/dist/pptx/editor/render/table-style-map-edits.d.ts.map +1 -1
  253. package/dist/pptx/editor/render/template-editing.d.ts +0 -2
  254. package/dist/pptx/editor/render/template-editing.d.ts.map +1 -1
  255. package/dist/pptx/editor/render/text-content-style.d.ts +1 -3
  256. package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -1
  257. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +2 -4
  258. package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -1
  259. package/dist/pptx/editor/render/text-segment-paragraph-break.d.ts +0 -2
  260. package/dist/pptx/editor/render/text-segment-paragraph-break.d.ts.map +1 -1
  261. package/dist/pptx/editor/render/text-style-scope.d.ts +2 -4
  262. package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -1
  263. package/dist/pptx/editor/render/text-theme.d.ts +0 -2
  264. package/dist/pptx/editor/render/text-theme.d.ts.map +1 -1
  265. package/dist/pptx/editor/render/theme-editor-model.d.ts +0 -2
  266. package/dist/pptx/editor/render/theme-editor-model.d.ts.map +1 -1
  267. package/dist/pptx/editor/render/theme-editor-presets.d.ts +0 -2
  268. package/dist/pptx/editor/render/theme-editor-presets.d.ts.map +1 -1
  269. package/dist/pptx/editor/render/update-text-segment-style.d.ts +1 -3
  270. package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -1
  271. package/dist/pptx/index.cjs +1687 -1159
  272. package/dist/pptx/index.d.ts +10 -10
  273. package/dist/pptx/index.mjs +1 -1
  274. package/dist/pptx/node/index.d.ts +1 -3
  275. package/dist/pptx/node/index.d.ts.map +1 -1
  276. package/dist/pptx/signature-node/index.d.ts +1 -21
  277. package/dist/pptx/signature-node/index.d.ts.map +1 -1
  278. package/dist/pptx/smartart-layouts/index.d.ts +1 -7
  279. package/dist/pptx/smartart-layouts/index.d.ts.map +1 -1
  280. package/dist/pptx/ui/index.d.ts +1 -9
  281. package/dist/pptx/ui/index.d.ts.map +1 -1
  282. package/dist/teams/index.cjs +215 -201
  283. package/dist/teams/index.mjs +215 -201
  284. package/dist/text/index.cjs +193 -0
  285. package/dist/text/index.d.ts +1 -0
  286. package/dist/text/index.d.ts.map +1 -1
  287. package/dist/text/index.mjs +193 -1
  288. package/dist/text/merge-three-way.d.ts +9 -0
  289. package/dist/text/merge-three-way.d.ts.map +1 -0
  290. package/dist/visio/collab/index.cjs +226 -7
  291. package/dist/visio/collab/index.d.ts +1 -0
  292. package/dist/visio/collab/index.d.ts.map +1 -1
  293. package/dist/visio/collab/index.mjs +225 -7
  294. package/dist/visio/collab/merge-snapshots.d.ts +14 -0
  295. package/dist/visio/collab/merge-snapshots.d.ts.map +1 -0
  296. package/dist/visio/index.cjs +9 -9
  297. package/dist/visio/index.mjs +9 -9
  298. package/dist/visio/ui/index.cjs +9 -9
  299. package/dist/visio/ui/index.mjs +9 -9
  300. package/dist/xlsx/collab/index.cjs +49966 -507
  301. package/dist/xlsx/collab/index.d.ts +1 -0
  302. package/dist/xlsx/collab/index.d.ts.map +1 -1
  303. package/dist/xlsx/collab/index.mjs +49961 -507
  304. package/dist/xlsx/collab/merge-residual.d.ts +16 -0
  305. package/dist/xlsx/collab/merge-residual.d.ts.map +1 -0
  306. package/dist/xlsx/collab/merge-snapshots.d.ts +8 -0
  307. package/dist/xlsx/collab/merge-snapshots.d.ts.map +1 -0
  308. package/dist/xlsx/index.cjs +202 -202
  309. package/dist/xlsx/index.mjs +202 -202
  310. package/dist/xlsx/load/index.cjs +155 -155
  311. package/dist/xlsx/load/index.mjs +155 -155
  312. package/dist/xlsx/ui/index.cjs +202 -202
  313. package/dist/xlsx/ui/index.mjs +202 -202
  314. package/dist/xml/index.cjs +390 -22
  315. package/dist/xml/index.d.ts +1 -0
  316. package/dist/xml/index.d.ts.map +1 -1
  317. package/dist/xml/index.mjs +390 -23
  318. package/dist/xml/merge-three-way.d.ts +16 -0
  319. package/dist/xml/merge-three-way.d.ts.map +1 -0
  320. package/package.json +13 -8
  321. package/dist/pptx/chunks/collaboration-text-codec-Du_XeE_i.d.ts.map +0 -1
  322. package/dist/pptx/chunks/collaboration-text-merge-DWWWdT_t.d.ts.map +0 -1
  323. package/dist/pptx/chunks/collaboration-text-positions-MMT3GkZi.d.ts.map +0 -1
  324. package/dist/pptx/chunks/collaboration-text-session-D0NOLQk7.d.ts.map +0 -1
  325. package/dist/pptx/chunks/collaboration-text-session-delta-CzJGrTKJ.d.ts.map +0 -1
  326. package/dist/pptx/chunks/color-ref-DT599vEx.d.ts.map +0 -1
  327. package/dist/pptx/chunks/elements-f3UbFph-.d.ts.map +0 -1
  328. package/dist/pptx/chunks/index-BnH2QjYm.d.ts.map +0 -1
  329. package/dist/pptx/chunks/index-Bp-1pGo1.d.ts.map +0 -1
  330. package/dist/pptx/chunks/index-pLLN4OTz.d.ts.map +0 -1
  331. package/dist/pptx/chunks/inspection-status-DjiWd_Aa.d.ts.map +0 -1
  332. package/dist/pptx/chunks/schemas-fuDGetRe.d.ts.map +0 -1
  333. package/dist/pptx/chunks/smart-art-CmOrPLLQ.d.ts.map +0 -1
  334. package/dist/pptx/chunks/text-P9xVnXXf.d.ts.map +0 -1
  335. package/dist/pptx/chunks/text-operations-D5sgspO6.d.ts.map +0 -1
@@ -8,6 +8,198 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
9
9
  var JSZip__default = /*#__PURE__*/_interopDefault(JSZip);
10
10
 
11
+ // text/text-diff.ts
12
+ var isLowSurrogate = (text2, at) => {
13
+ const code = text2.charCodeAt(at);
14
+ return code >= 56320 && code <= 57343;
15
+ };
16
+ function shortestEdit(n2, m, same6, maxEdits) {
17
+ const max = Math.min(n2 + m, maxEdits);
18
+ const offset = max + 1;
19
+ const v = new Int32Array(2 * max + 3);
20
+ const trace = [];
21
+ for (let d = 0; d <= max; d++) {
22
+ for (let k = -d; k <= d; k += 2) {
23
+ const down = k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1];
24
+ let x = down ? v[offset + k + 1] : v[offset + k - 1] + 1;
25
+ let y = x - k;
26
+ while (x < n2 && y < m && same6(x, y)) {
27
+ x++;
28
+ y++;
29
+ }
30
+ v[offset + k] = x;
31
+ if (x >= n2 && y >= m) return backtrack(trace, n2, m, d);
32
+ }
33
+ trace.push(v.slice(offset - d, offset + d + 1));
34
+ }
35
+ return void 0;
36
+ }
37
+ function backtrack(trace, n2, m, d) {
38
+ const edits = [];
39
+ let x = n2;
40
+ let y = m;
41
+ for (let step = d; step > 0; step--) {
42
+ const previous = trace[step - 1];
43
+ const at = (k2) => previous[k2 + step - 1];
44
+ const k = x - y;
45
+ const down = k === -step || k !== step && at(k - 1) < at(k + 1);
46
+ const before = down ? k + 1 : k - 1;
47
+ const startX = at(before);
48
+ const startY = startX - before;
49
+ edits.push(down ? [startX, startY, true] : [startX, startY, false]);
50
+ x = startX;
51
+ y = startY;
52
+ }
53
+ return edits.reverse();
54
+ }
55
+ function changesOf(edits) {
56
+ const changes = [];
57
+ for (const [x, y, inserts] of edits) {
58
+ const last = changes.at(-1);
59
+ if (last && last.fromEnd === x && last.toEnd === y) {
60
+ if (inserts) last.toEnd++;
61
+ else last.fromEnd++;
62
+ } else
63
+ changes.push({
64
+ fromStart: x,
65
+ fromEnd: inserts ? x : x + 1,
66
+ toStart: y,
67
+ toEnd: inserts ? y + 1 : y
68
+ });
69
+ }
70
+ return changes;
71
+ }
72
+ function characterChanges(a2, b, maxEdits) {
73
+ const edits = shortestEdit(
74
+ a2.length,
75
+ b.length,
76
+ (x, y) => a2.charCodeAt(x) === b.charCodeAt(y),
77
+ maxEdits
78
+ );
79
+ return edits && changesOf(edits);
80
+ }
81
+ var TOKEN = /[\p{L}\p{N}\p{M}]+|\s+|[\s\S]/gu;
82
+ function tokensOf(text2, ids) {
83
+ const tokens = [];
84
+ const starts = [];
85
+ for (const match of text2.matchAll(TOKEN)) {
86
+ let id = ids.get(match[0]);
87
+ if (id === void 0) ids.set(match[0], id = ids.size);
88
+ tokens.push(id);
89
+ starts.push(match.index);
90
+ }
91
+ starts.push(text2.length);
92
+ return { tokens, starts };
93
+ }
94
+ function tokenChanges(a2, b, maxEdits) {
95
+ const ids = /* @__PURE__ */ new Map();
96
+ const from = tokensOf(a2, ids);
97
+ const to = tokensOf(b, ids);
98
+ const edits = shortestEdit(
99
+ from.tokens.length,
100
+ to.tokens.length,
101
+ (x, y) => from.tokens[x] === to.tokens[y],
102
+ maxEdits
103
+ );
104
+ if (!edits) return void 0;
105
+ let budget = maxEdits;
106
+ return changesOf(edits).flatMap((stretch) => {
107
+ const change = {
108
+ fromStart: from.starts[stretch.fromStart],
109
+ fromEnd: from.starts[stretch.fromEnd],
110
+ toStart: to.starts[stretch.toStart],
111
+ toEnd: to.starts[stretch.toEnd]
112
+ };
113
+ const inner = change.fromEnd > change.fromStart && change.toEnd > change.toStart ? characterChanges(
114
+ a2.slice(change.fromStart, change.fromEnd),
115
+ b.slice(change.toStart, change.toEnd),
116
+ budget
117
+ ) : void 0;
118
+ if (!inner) return [change];
119
+ for (const found of inner)
120
+ budget -= found.fromEnd - found.fromStart + found.toEnd - found.toStart;
121
+ return inner.map((found) => ({
122
+ fromStart: found.fromStart + change.fromStart,
123
+ fromEnd: found.fromEnd + change.fromStart,
124
+ toStart: found.toStart + change.toStart,
125
+ toEnd: found.toEnd + change.toStart
126
+ }));
127
+ });
128
+ }
129
+ function diffText(from, to, maxEdits = 500) {
130
+ let start = 0;
131
+ while (start < from.length && start < to.length && from.charCodeAt(start) === to.charCodeAt(start))
132
+ start++;
133
+ let end = 0;
134
+ while (end < from.length - start && end < to.length - start && from.charCodeAt(from.length - 1 - end) === to.charCodeAt(to.length - 1 - end))
135
+ end++;
136
+ const a2 = from.slice(start, from.length - end);
137
+ const b = to.slice(start, to.length - end);
138
+ if (!a2.length && !b.length) return [];
139
+ const found = a2.length && b.length ? characterChanges(a2, b, maxEdits) ?? tokenChanges(a2, b, maxEdits) : void 0;
140
+ const changes = found ?? [{ fromStart: 0, fromEnd: a2.length, toStart: 0, toEnd: b.length }];
141
+ const result = [];
142
+ for (const change of changes) {
143
+ const placed = {
144
+ fromStart: change.fromStart + start,
145
+ fromEnd: change.fromEnd + start,
146
+ toStart: change.toStart + start,
147
+ toEnd: change.toEnd + start
148
+ };
149
+ if (placed.fromStart > 0 && placed.toStart > 0 && (isLowSurrogate(from, placed.fromStart) || isLowSurrogate(to, placed.toStart))) {
150
+ placed.fromStart--;
151
+ placed.toStart--;
152
+ }
153
+ if (isLowSurrogate(from, placed.fromEnd) || isLowSurrogate(to, placed.toEnd)) {
154
+ placed.fromEnd++;
155
+ placed.toEnd++;
156
+ }
157
+ const last = result.at(-1);
158
+ if (last && placed.fromStart <= last.fromEnd) {
159
+ last.fromEnd = Math.max(last.fromEnd, placed.fromEnd);
160
+ last.toEnd = Math.max(last.toEnd, placed.toEnd);
161
+ } else result.push(placed);
162
+ }
163
+ return result;
164
+ }
165
+
166
+ // text/merge-three-way.ts
167
+ function mergeTextThreeWay(base, local, remote) {
168
+ if (local === remote || base === remote) return { status: "merged", text: local };
169
+ if (base === local) return { status: "merged", text: remote };
170
+ if (Math.max(base.length, local.length, remote.length) > 1e6)
171
+ return { status: "unresolved" };
172
+ const changes = (value) => diffText(base, value).map((change) => ({
173
+ start: change.fromStart,
174
+ end: change.fromEnd,
175
+ text: value.slice(change.toStart, change.toEnd)
176
+ }));
177
+ const edits = changes(local);
178
+ for (const next of changes(remote)) {
179
+ if (edits.some(
180
+ (edit) => edit.start === next.start && edit.end === next.end && edit.text === next.text
181
+ ))
182
+ continue;
183
+ if (edits.some((edit) => {
184
+ if (edit.start === edit.end && next.start === next.end) return false;
185
+ if (edit.start === edit.end) return edit.start > next.start && edit.start < next.end;
186
+ if (next.start === next.end) return next.start > edit.start && next.start < edit.end;
187
+ return edit.start < next.end && next.start < edit.end;
188
+ }))
189
+ return { status: "unresolved" };
190
+ edits.push(next);
191
+ }
192
+ edits.sort(
193
+ (a2, b) => a2.start - b.start || a2.end - b.end || (a2.text < b.text ? -1 : a2.text > b.text ? 1 : 0)
194
+ );
195
+ let text2 = "", cursor = 0;
196
+ for (const edit of edits) {
197
+ text2 += base.slice(cursor, edit.start) + edit.text;
198
+ cursor = edit.end;
199
+ }
200
+ return { status: "merged", text: text2 + base.slice(cursor) };
201
+ }
202
+
11
203
  // xml/namespaces.ts
12
204
  var NS = {
13
205
  /** WordprocessingML main. */
@@ -77,6 +269,8 @@ var NS = {
77
269
  /** XML itself (`xml:space`). */
78
270
  xml: "http://www.w3.org/XML/1998/namespace"
79
271
  };
272
+
273
+ // xml/xml.ts
80
274
  var DEFAULT_XML_LIMITS = {
81
275
  maxDepth: 512,
82
276
  maxNodes: 5e6
@@ -100,28 +294,28 @@ var MARKUP_SKIPS = [
100
294
  ["<![CDATA[", "]]>"],
101
295
  ["<?", "?>"]
102
296
  ];
103
- function checkXmlLimits(xml, label, limits = {}) {
297
+ function checkXmlLimits(xml2, label, limits = {}) {
104
298
  const maxDepth2 = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
105
299
  const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
106
300
  let depth = 0;
107
301
  let nodes = 0;
108
- let at = xml.indexOf("<");
302
+ let at = xml2.indexOf("<");
109
303
  while (at !== -1) {
110
- const skip = MARKUP_SKIPS.find(([open]) => xml.startsWith(open, at));
304
+ const skip = MARKUP_SKIPS.find(([open]) => xml2.startsWith(open, at));
111
305
  if (skip) {
112
- const end = xml.indexOf(skip[1], at + skip[0].length);
306
+ const end = xml2.indexOf(skip[1], at + skip[0].length);
113
307
  if (end === -1) return;
114
- at = xml.indexOf("<", end + skip[1].length);
308
+ at = xml2.indexOf("<", end + skip[1].length);
115
309
  continue;
116
310
  }
117
311
  TAG_RE.lastIndex = at;
118
- const match = TAG_RE.exec(xml);
312
+ const match = TAG_RE.exec(xml2);
119
313
  if (!match) {
120
- at = xml.indexOf("<", at + 1);
314
+ at = xml2.indexOf("<", at + 1);
121
315
  continue;
122
316
  }
123
317
  const [, closing, , selfClosing] = match;
124
- at = xml.indexOf("<", at + match[0].length);
318
+ at = xml2.indexOf("<", at + match[0].length);
125
319
  if (closing) {
126
320
  depth--;
127
321
  continue;
@@ -143,11 +337,11 @@ function checkXmlLimits(xml, label, limits = {}) {
143
337
  }
144
338
  var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
145
339
  var crlfDeclarations = /* @__PURE__ */ new WeakSet();
146
- function parseXml(xml, options2 = {}) {
340
+ function parseXml(xml2, options2 = {}) {
147
341
  const label = options2.label ?? "OOXML";
148
- if (/<!DOCTYPE|<!ENTITY/i.test(xml))
342
+ if (/<!DOCTYPE|<!ENTITY/i.test(xml2))
149
343
  throw new Error(`${label} XML with DTD or entity declarations is not supported`);
150
- checkXmlLimits(xml, label, options2.limits);
344
+ checkXmlLimits(xml2, label, options2.limits);
151
345
  let parseError = "";
152
346
  let parsed;
153
347
  try {
@@ -155,7 +349,7 @@ function parseXml(xml, options2 = {}) {
155
349
  onError: (level4, message) => {
156
350
  if (level4 !== "warning" || options2.warningsAsErrors) parseError = message;
157
351
  }
158
- }).parseFromString(xml, "application/xml");
352
+ }).parseFromString(xml2, "application/xml");
159
353
  } catch (error) {
160
354
  throw new Error(
161
355
  `Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
@@ -164,12 +358,12 @@ function parseXml(xml, options2 = {}) {
164
358
  }
165
359
  if (parseError || !parsed.documentElement)
166
360
  throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
167
- if (CRLF_DECLARATION.test(xml)) crlfDeclarations.add(parsed);
361
+ if (CRLF_DECLARATION.test(xml2)) crlfDeclarations.add(parsed);
168
362
  return parsed;
169
363
  }
170
364
  var buildXml = (node) => {
171
- const xml = new xmldom.XMLSerializer().serializeToString(node);
172
- return crlfDeclarations.has(node) ? xml.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml;
365
+ const xml2 = new xmldom.XMLSerializer().serializeToString(node);
366
+ return crlfDeclarations.has(node) ? xml2.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml2;
173
367
  };
174
368
  var isElement = (node) => node.nodeType === 1;
175
369
  var elements = (parent) => Array.from(parent.childNodes).filter(isElement);
@@ -186,11 +380,597 @@ function attr(element4, local, ns, prefix2) {
186
380
  }
187
381
  var relAttr = (element4, local) => attr(element4, local, NS.r, "r");
188
382
 
383
+ // xml/merge-three-way.ts
384
+ var tag = (node) => `${node.namespaceURI ?? ""}|${node.localName ?? node.tagName}`;
385
+ var xml = (node) => node ? buildXml(node) : void 0;
386
+ function childrenByKey(parent, options2, repeated) {
387
+ const result = /* @__PURE__ */ new Map();
388
+ const counts = /* @__PURE__ */ new Map();
389
+ for (const child7 of elements(parent)) {
390
+ const name = tag(child7), explicit = options2.keyElement?.(child7, parent);
391
+ const index = counts.get(name) ?? 0;
392
+ counts.set(name, index + 1);
393
+ if (!explicit && repeated.has(name) && !options2.allowPositional?.(parent))
394
+ throw new Error("Ambiguous repeated elements");
395
+ const key = explicit ? `${name}@${explicit}` : `${name}#${index}`;
396
+ if (result.has(key)) throw new Error("Duplicate element identity");
397
+ result.set(key, child7);
398
+ }
399
+ return result;
400
+ }
401
+ function orderKeys(base, local, remote) {
402
+ const same6 = (a2, b) => a2.length === b.length && a2.every((key, index) => key === b[index]);
403
+ if (same6(base, local)) return [...remote];
404
+ if (same6(base, remote) || same6(local, remote)) return [...local];
405
+ const keys = [.../* @__PURE__ */ new Set([...remote, ...local])].sort();
406
+ const edges = new Map(keys.map((key) => [key, /* @__PURE__ */ new Set()]));
407
+ const degree = new Map(keys.map((key) => [key, 0]));
408
+ for (const sequence of [local, remote])
409
+ for (let i2 = 1; i2 < sequence.length; i2++) {
410
+ const previous = sequence[i2 - 1], next = sequence[i2];
411
+ if (!edges.get(previous).has(next)) {
412
+ edges.get(previous).add(next);
413
+ degree.set(next, degree.get(next) + 1);
414
+ }
415
+ }
416
+ const out = [];
417
+ const ready = keys.filter((key) => degree.get(key) === 0);
418
+ while (ready.length) {
419
+ const next = ready.sort().shift();
420
+ out.push(next);
421
+ for (const key of edges.get(next)) {
422
+ degree.set(key, degree.get(key) - 1);
423
+ if (degree.get(key) === 0) ready.push(key);
424
+ }
425
+ }
426
+ return out.length === keys.length ? out : void 0;
427
+ }
428
+ function mergeXmlThreeWay(baseXml, localXml, remoteXml, options2 = {}) {
429
+ if (localXml === remoteXml || baseXml === remoteXml) return { status: "merged", xml: localXml };
430
+ if (baseXml === localXml) return { status: "merged", xml: remoteXml };
431
+ const issues = [];
432
+ try {
433
+ let merge2 = function(b, l, r, path3) {
434
+ const bx = xml(b), lx = xml(l), rx = xml(r);
435
+ if (lx === rx || bx === rx) return l ? copy(l) : void 0;
436
+ if (bx === lx) return r ? copy(r) : void 0;
437
+ if (!b && l && r && tag(l) === tag(r) && !elements(l).length && !elements(r).length) {
438
+ const resolved = options2.resolveText?.(r, l, r);
439
+ if (resolved !== void 0) {
440
+ const node = copy(r);
441
+ node.textContent = resolved;
442
+ return node;
443
+ }
444
+ }
445
+ if (!b || !l || !r || tag(b) !== tag(l) || tag(b) !== tag(r)) {
446
+ issues.push(`${path3}: overlapping structural changes`);
447
+ return void 0;
448
+ }
449
+ const out = remote.createElementNS(r.namespaceURI, r.tagName);
450
+ const attrs3 = (node) => new Map(
451
+ Array.from(node.attributes).map((a2) => [
452
+ `${a2.namespaceURI ?? ""}|${a2.localName ?? a2.name}`,
453
+ a2
454
+ ])
455
+ );
456
+ const ba = attrs3(b), la = attrs3(l), ra = attrs3(r);
457
+ for (const key of /* @__PURE__ */ new Set([...ba.keys(), ...la.keys(), ...ra.keys()])) {
458
+ const old = ba.get(key)?.value, left = la.get(key)?.value, right = ra.get(key)?.value;
459
+ const value = left === right || right === old ? left : left === old ? right : void 0;
460
+ if (left !== right && left !== old && right !== old) {
461
+ issues.push(`${path3}: overlapping attribute ${key}`);
462
+ continue;
463
+ }
464
+ const source2 = ra.get(key) ?? la.get(key) ?? ba.get(key);
465
+ if (value !== void 0) out.setAttributeNS(source2.namespaceURI, source2.name, value);
466
+ }
467
+ const lists = [b, l, r].map(elements);
468
+ if (lists.every((list2) => list2.length === 0)) {
469
+ if ([b, l, r].some(
470
+ (node) => Array.from(node.childNodes).some(
471
+ (child7) => child7.nodeType !== 3 && child7.nodeType !== 4
472
+ )
473
+ )) {
474
+ issues.push(`${path3}: non-text leaf content requires explicit preservation`);
475
+ return void 0;
476
+ }
477
+ const texts = [b, l, r].map((node) => node.textContent ?? "");
478
+ const override = options2.resolveText?.(b, l, r);
479
+ const value = override !== void 0 ? { status: "merged", text: override } : texts[1] === texts[2] || texts[0] === texts[2] ? { status: "merged", text: texts[1] } : texts[0] === texts[1] ? { status: "merged", text: texts[2] } : options2.allowText?.(b) ? mergeTextThreeWay(texts[0], texts[1], texts[2]) : { status: "unresolved" };
480
+ if (value.status !== "merged") issues.push(`${path3}: overlapping text changes`);
481
+ else if (value.text) out.appendChild(remote.createTextNode(value.text));
482
+ return out;
483
+ }
484
+ if ([b, l, r].some(
485
+ (node) => Array.from(node.childNodes).some(
486
+ (child7) => child7.nodeType !== 1 && (child7.nodeType !== 3 || Boolean(child7.textContent?.trim()))
487
+ )
488
+ )) {
489
+ issues.push(`${path3}: mixed content cannot be matched safely`);
490
+ return void 0;
491
+ }
492
+ const repeated = /* @__PURE__ */ new Set();
493
+ const groups = lists.map((list2) => {
494
+ const grouped = /* @__PURE__ */ new Map();
495
+ for (const child7 of list2) {
496
+ const name = tag(child7), group3 = grouped.get(name) ?? [];
497
+ group3.push(child7);
498
+ grouped.set(name, group3);
499
+ if (group3.length > 1) repeated.add(name);
500
+ }
501
+ return grouped;
502
+ });
503
+ for (const name of repeated) {
504
+ const rows2 = groups.map((group3) => group3.get(name) ?? []);
505
+ if (rows2.some((row) => row.some((child7) => options2.keyElement?.(child7, b) !== void 0)))
506
+ continue;
507
+ if (rows2.some((row) => row.length !== rows2[0].length)) {
508
+ issues.push(`${path3}: unkeyed structural changes`);
509
+ return void 0;
510
+ }
511
+ const before = rows2[0].map((child7) => buildXml(child7));
512
+ const known = new Set(before);
513
+ for (const row of rows2.slice(1))
514
+ if (row.some((child7, i2) => {
515
+ const value = buildXml(child7);
516
+ return before[i2] !== value && known.has(value);
517
+ })) {
518
+ issues.push(`${path3}: reordered unkeyed elements`);
519
+ return void 0;
520
+ }
521
+ }
522
+ let maps;
523
+ try {
524
+ maps = [b, l, r].map((parent) => childrenByKey(parent, options2, repeated));
525
+ } catch {
526
+ issues.push(`${path3}: ambiguous element identities`);
527
+ return void 0;
528
+ }
529
+ const [bm, lm, rm] = maps;
530
+ const merged = /* @__PURE__ */ new Map();
531
+ for (const key of /* @__PURE__ */ new Set([...bm.keys(), ...lm.keys(), ...rm.keys()])) {
532
+ const node = merge2(bm.get(key), lm.get(key), rm.get(key), `${path3}/${key}`);
533
+ if (node) merged.set(key, node);
534
+ }
535
+ const surviving = (map) => [...map.keys()].filter((key) => merged.has(key));
536
+ const order = orderKeys(surviving(bm), surviving(lm), surviving(rm));
537
+ if (!order) {
538
+ issues.push(`${path3}: incompatible element order`);
539
+ return void 0;
540
+ }
541
+ for (const key of order) out.appendChild(merged.get(key));
542
+ return out;
543
+ };
544
+ var merge = merge2;
545
+ const base = parseXml(baseXml, { warningsAsErrors: true });
546
+ const local = parseXml(localXml, { warningsAsErrors: true });
547
+ const remote = parseXml(remoteXml, { warningsAsErrors: true });
548
+ const copy = (node) => remote.importNode(node, true);
549
+ const root = merge2(base.documentElement, local.documentElement, remote.documentElement, "root");
550
+ if (!root || issues.length) return { status: "unresolved", issues };
551
+ remote.replaceChild(root, remote.documentElement);
552
+ return { status: "merged", xml: buildXml(remote) };
553
+ } catch {
554
+ return { status: "unresolved", issues: ["Invalid or unsupported XML input"] };
555
+ }
556
+ }
557
+ var DEFAULT_ZIP_LIMITS = {
558
+ maxInputBytes: 100 * 1024 * 1024,
559
+ maxEntries: 1e4,
560
+ maxEntryBytes: 100 * 1024 * 1024,
561
+ maxTotalBytes: 100 * 1024 * 1024
562
+ };
563
+ var ZipLimitError = class extends Error {
564
+ code = "ZIP_BOMB";
565
+ limit;
566
+ /** The check that failed (absent when the error was built without one). */
567
+ kind;
568
+ /** The observed value, when known (a lower bound for a size found while inflating). */
569
+ actual;
570
+ constructor(message, details) {
571
+ super(message);
572
+ this.name = "ZipLimitError";
573
+ this.limit = details.limit;
574
+ this.kind = details.kind;
575
+ this.actual = details.actual;
576
+ }
577
+ };
578
+ var mib = (bytes) => Math.round(bytes / 1048576);
579
+ function isSafePartName(name) {
580
+ if (name.includes("\0") || name.includes("\\")) return false;
581
+ if (/^[A-Za-z]:/u.test(name)) return false;
582
+ const body = name.startsWith("/") ? name.slice(1) : name;
583
+ if (body.startsWith("/")) return false;
584
+ return !body.split("/").some((segment2) => segment2 === "..");
585
+ }
586
+ function declaredEntrySize(entry2) {
587
+ const data = entry2._data;
588
+ const size = Number(data?.uncompressedSize ?? 0);
589
+ return Number.isFinite(size) && size > 0 ? size : 0;
590
+ }
591
+ function resolveLimits(limits) {
592
+ const create2 = limits.createError;
593
+ return {
594
+ maxEntries: limits.maxEntries ?? DEFAULT_ZIP_LIMITS.maxEntries,
595
+ maxEntryBytes: limits.maxEntryBytes ?? DEFAULT_ZIP_LIMITS.maxEntryBytes,
596
+ maxTotalBytes: limits.maxTotalBytes ?? DEFAULT_ZIP_LIMITS.maxTotalBytes,
597
+ label: limits.label ?? "ZIP",
598
+ fail: (message, limit, kind, actual) => create2 ? create2(message, { limit, kind, actual }) : new ZipLimitError(message, { limit, kind, actual })
599
+ };
600
+ }
601
+ async function inflateEntryGuarded(entry2, alreadyRead, limits) {
602
+ const chunks = [];
603
+ let size = 0;
604
+ for await (const chunk of streamEntryGuarded(entry2, alreadyRead, limits)) {
605
+ chunks.push(chunk);
606
+ size += chunk.byteLength;
607
+ }
608
+ if (chunks.length === 1 && chunks[0]) return chunks[0];
609
+ const out = new Uint8Array(size);
610
+ let offset = 0;
611
+ for (const chunk of chunks) {
612
+ out.set(chunk, offset);
613
+ offset += chunk.byteLength;
614
+ }
615
+ return out;
616
+ }
617
+ var AHEAD = 8;
618
+ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
619
+ const r = resolveLimits(limits);
620
+ const declared = declaredEntrySize(entry2);
621
+ const stream = entry2.internalStream("uint8array");
622
+ const queue = [];
623
+ let size = 0;
624
+ let ended = false;
625
+ let stopped = false;
626
+ let failure;
627
+ let paused = false;
628
+ let wake;
629
+ const pause = () => {
630
+ paused = true;
631
+ stream.pause();
632
+ };
633
+ const resume = () => {
634
+ if (!paused || stopped) return;
635
+ paused = false;
636
+ stream.resume();
637
+ };
638
+ const fail = (error) => {
639
+ failure ??= error;
640
+ stopped = true;
641
+ queue.length = 0;
642
+ pause();
643
+ wake?.();
644
+ };
645
+ stream.on("data", (chunk) => {
646
+ if (stopped) return pause();
647
+ size += chunk.byteLength;
648
+ if (size > declared || size > r.maxEntryBytes)
649
+ return fail(
650
+ r.fail(
651
+ `${r.label} part ${entry2.name} inflates past its declared size`,
652
+ r.maxEntryBytes,
653
+ size > declared ? "declaredSize" : "maxEntryBytes",
654
+ size
655
+ )
656
+ );
657
+ if (alreadyRead + size > r.maxTotalBytes)
658
+ return fail(
659
+ r.fail(
660
+ `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
661
+ r.maxTotalBytes,
662
+ "maxTotalBytes",
663
+ alreadyRead + size
664
+ )
665
+ );
666
+ queue.push(chunk);
667
+ if (queue.length >= AHEAD) pause();
668
+ wake?.();
669
+ });
670
+ stream.on("error", (error) => fail(error));
671
+ stream.on("end", () => {
672
+ ended = true;
673
+ wake?.();
674
+ });
675
+ stream.resume();
676
+ try {
677
+ for (; ; ) {
678
+ if (failure) throw failure;
679
+ const chunk = queue.shift();
680
+ if (chunk) {
681
+ if (queue.length < AHEAD / 2) resume();
682
+ yield chunk;
683
+ continue;
684
+ }
685
+ if (ended) return;
686
+ await new Promise((resolve) => {
687
+ wake = resolve;
688
+ resume();
689
+ });
690
+ wake = void 0;
691
+ }
692
+ } finally {
693
+ stopped = true;
694
+ if (!ended) pause();
695
+ }
696
+ }
697
+ function toBase64(bytes) {
698
+ let binary = "";
699
+ for (let i2 = 0; i2 < bytes.length; i2 += 32768)
700
+ binary += String.fromCharCode(...bytes.subarray(i2, i2 + 32768));
701
+ return btoa(binary);
702
+ }
703
+ function guardZip(zip, limits = {}) {
704
+ const r = resolveLimits(limits);
705
+ const entries = Object.values(zip.files);
706
+ if (entries.length > r.maxEntries)
707
+ throw r.fail(
708
+ `${r.label} package exceeds the ${r.maxEntries.toLocaleString("en-US")} part limit`,
709
+ r.maxEntries,
710
+ "maxEntries",
711
+ entries.length
712
+ );
713
+ let declared = 0;
714
+ for (const entry2 of entries) {
715
+ const original = entry2.unsafeOriginalName;
716
+ if (!isSafePartName(entry2.name) || original !== void 0 && !isSafePartName(original))
717
+ throw r.fail(`${r.label} package has an unsafe part name`, r.maxEntries, "partName");
718
+ if (entry2.dir) continue;
719
+ const size = declaredEntrySize(entry2);
720
+ if (size > r.maxEntryBytes)
721
+ throw r.fail(
722
+ `${r.label} part ${entry2.name} exceeds the uncompressed part size limit`,
723
+ r.maxEntryBytes,
724
+ "maxEntryBytes",
725
+ size
726
+ );
727
+ declared += size;
728
+ }
729
+ if (declared > r.maxTotalBytes)
730
+ throw r.fail(
731
+ `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
732
+ r.maxTotalBytes,
733
+ "maxTotalBytes",
734
+ declared
735
+ );
736
+ const produced = /* @__PURE__ */ new Map();
737
+ let total = 0;
738
+ for (const entry2 of entries) {
739
+ if (entry2.dir) continue;
740
+ const inflateOriginal = entry2.async.bind(entry2);
741
+ entry2.async = async (type, onUpdate) => {
742
+ const previous = produced.get(entry2.name) ?? 0;
743
+ const bytes = await inflateEntryGuarded(entry2, total - previous, limits);
744
+ if (bytes.byteLength > previous) {
745
+ total += bytes.byteLength - previous;
746
+ produced.set(entry2.name, bytes.byteLength);
747
+ }
748
+ switch (type) {
749
+ case "uint8array":
750
+ return bytes;
751
+ case "string":
752
+ case "text":
753
+ return new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes);
754
+ case "arraybuffer":
755
+ return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
756
+ case "base64":
757
+ return toBase64(bytes);
758
+ default:
759
+ return inflateOriginal(type, onUpdate);
760
+ }
761
+ };
762
+ }
763
+ return zip;
764
+ }
765
+ async function openZip(input, limits = {}) {
766
+ const r = resolveLimits(limits);
767
+ const maxInput = limits.maxInputBytes ?? DEFAULT_ZIP_LIMITS.maxInputBytes;
768
+ const bytes = input instanceof Uint8Array ? input : new Uint8Array(input);
769
+ if (bytes.byteLength > maxInput)
770
+ throw r.fail(
771
+ `${r.label} package exceeds the ${mib(maxInput)} MiB compressed input limit`,
772
+ maxInput,
773
+ "maxInputBytes",
774
+ bytes.byteLength
775
+ );
776
+ return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
777
+ }
778
+
779
+ // opc/relationships.ts
780
+ function parseRelationships(xml2) {
781
+ const map = /* @__PURE__ */ new Map();
782
+ if (!xml2) return map;
783
+ const root = parseXml(xml2).documentElement;
784
+ for (const node of elements(root)) {
785
+ if (node.localName !== "Relationship") continue;
786
+ const id = node.getAttribute("Id");
787
+ const target = node.getAttribute("Target");
788
+ if (!id || target == null) continue;
789
+ map.set(id, {
790
+ id,
791
+ type: node.getAttribute("Type") ?? "",
792
+ target,
793
+ mode: node.getAttribute("TargetMode") === "External" ? "External" : "Internal"
794
+ });
795
+ }
796
+ return map;
797
+ }
798
+ var escapeAttr = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
799
+ function buildRelationshipsXml(relationships) {
800
+ const items = Array.from(relationships).map(([id, rel]) => {
801
+ const mode = rel.mode === "External" ? ' TargetMode="External"' : "";
802
+ return `<Relationship Id="${escapeAttr(id)}" Type="${escapeAttr(rel.type)}" Target="${escapeAttr(rel.target)}"${mode}/>`;
803
+ }).join("");
804
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${NS.rels}">${items}</Relationships>`;
805
+ }
806
+ function resolvePartPath(basePart, target) {
807
+ if (target.startsWith("/")) return target.slice(1);
808
+ const baseDir = basePart.slice(0, basePart.lastIndexOf("/") + 1);
809
+ const resolved = [];
810
+ for (const segment2 of `${baseDir}${target}`.split("/")) {
811
+ if (segment2 === "." || segment2 === "") continue;
812
+ if (segment2 === "..") resolved.pop();
813
+ else resolved.push(segment2);
814
+ }
815
+ return resolved.join("/");
816
+ }
817
+ function relationshipsPartFor(partName) {
818
+ const slash = partName.lastIndexOf("/");
819
+ return `${partName.slice(0, slash + 1)}_rels/${partName.slice(slash + 1)}.rels`;
820
+ }
821
+ function nextRelationshipId(used) {
822
+ let index = 1;
823
+ while (used.has(`rId${index}`)) index++;
824
+ return `rId${index}`;
825
+ }
826
+ var getRelationshipId = (element4) => relAttr(element4, "id") || void 0;
827
+
828
+ // opc/merge-snapshots.ts
829
+ var equal = (a2, b) => a2 === b || Boolean(a2 && b && a2.length === b.length && a2.every((value, index) => value === b[index]));
830
+ var decoder = new TextDecoder("utf-8", { fatal: true });
831
+ var encoder = new TextEncoder();
832
+ function mergeManifest(input) {
833
+ const { path: path3, base, local, remote } = input;
834
+ if (!base || !local || !remote) return void 0;
835
+ if (!path3.endsWith(".rels") && path3 !== "[Content_Types].xml" && path3 !== "docProps/core.xml")
836
+ return void 0;
837
+ try {
838
+ const result = mergeXmlThreeWay(
839
+ decoder.decode(base),
840
+ decoder.decode(local),
841
+ decoder.decode(remote),
842
+ {
843
+ keyElement: (element4) => {
844
+ const attribute2 = element4.localName === "Relationship" ? "Id" : element4.localName === "Override" ? "PartName" : element4.localName === "Default" ? "Extension" : void 0;
845
+ return attribute2 ? element4.getAttribute(attribute2) ?? void 0 : void 0;
846
+ },
847
+ resolveText: (_b, _l, r) => path3 === "docProps/core.xml" && (r.namespaceURI === "http://purl.org/dc/terms/" && r.localName === "modified" || r.namespaceURI === "http://schemas.openxmlformats.org/package/2006/metadata/core-properties" && r.localName === "lastModifiedBy") ? r.textContent ?? "" : void 0
848
+ }
849
+ );
850
+ return result.status === "merged" ? { status: "merged", bytes: encoder.encode(result.xml) } : result;
851
+ } catch {
852
+ return { status: "unresolved", issues: [`${path3}: invalid metadata XML`] };
853
+ }
854
+ }
855
+ async function mergeOpcSnapshots(baseBytes, localBytes, remoteBytes, options2 = {}) {
856
+ if (equal(localBytes, remoteBytes) || equal(baseBytes, remoteBytes))
857
+ return { status: "merged", bytes: localBytes.slice() };
858
+ if (equal(baseBytes, localBytes)) return { status: "merged", bytes: remoteBytes.slice() };
859
+ try {
860
+ const [base, local, remote] = await Promise.all([
861
+ openZip(baseBytes, { label: "Merge" }),
862
+ openZip(localBytes, { label: "Merge" }),
863
+ openZip(remoteBytes, { label: "Merge" })
864
+ ]);
865
+ const paths = [
866
+ ...new Set(
867
+ [base, local, remote].flatMap(
868
+ (zip) => Object.keys(zip.files).filter((path3) => !zip.files[path3].dir)
869
+ )
870
+ )
871
+ ].sort();
872
+ if (paths.some((path3) => path3.startsWith("_xmlsignatures/")))
873
+ return {
874
+ status: "unresolved",
875
+ issues: ["Signed packages require explicit signature handling before merging"]
876
+ };
877
+ const issues = [];
878
+ for (const path3 of paths) {
879
+ const [b, l, r] = await Promise.all(
880
+ [base, local, remote].map((zip) => zip.file(path3)?.async("uint8array"))
881
+ );
882
+ let chosen;
883
+ if (equal(l, r) || equal(b, r)) chosen = l;
884
+ else if (equal(b, l)) chosen = r;
885
+ else {
886
+ const input = {
887
+ path: path3,
888
+ ...b ? { base: b } : {},
889
+ ...l ? { local: l } : {},
890
+ ...r ? { remote: r } : {}
891
+ };
892
+ const result = mergeManifest(input) ?? await options2.mergePart?.(input);
893
+ if (!result || result.status === "unresolved") {
894
+ issues.push(...result?.issues ?? [`${path3}: both versions changed the same part`]);
895
+ continue;
896
+ }
897
+ chosen = result.bytes;
898
+ }
899
+ if (chosen) remote.file(path3, chosen);
900
+ else remote.remove(path3);
901
+ }
902
+ if (issues.length) return { status: "unresolved", issues };
903
+ for (const path3 of Object.keys(remote.files).filter((name) => name.endsWith(".rels"))) {
904
+ const source2 = path3 === "_rels/.rels" ? "" : path3.replace(/(^|\/)_rels\/([^/]+)\.rels$/u, "$1$2");
905
+ for (const relation2 of parseRelationships(
906
+ await remote.file(path3).async("string")
907
+ ).values()) {
908
+ if (relation2.mode === "External") continue;
909
+ const target = resolvePartPath(source2, relation2.target.split("#")[0] ?? "");
910
+ if (!remote.file(target) && !remote.file(decodeURIComponent(target)))
911
+ issues.push(`${path3}: merged relationship target is missing`);
912
+ }
913
+ }
914
+ if (issues.length) return { status: "unresolved", issues };
915
+ return {
916
+ status: "merged",
917
+ bytes: await remote.generateAsync({ type: "uint8array", compression: "DEFLATE" })
918
+ };
919
+ } catch {
920
+ return { status: "unresolved", issues: ["Invalid or oversized Office package"] };
921
+ }
922
+ }
923
+
924
+ // docx/merge-snapshots.ts
925
+ var WORD_2010 = "http://schemas.microsoft.com/office/word/2010/wordml";
926
+ var TEXT_PART = /^word\/(?:document|header\d*|footer\d*|footnotes|endnotes|comments|styles)\.xml$/u;
927
+ var POSITIONAL = /* @__PURE__ */ new Set(["body", "p", "r", "hyperlink", "sdtContent", "tbl", "tr", "tc"]);
928
+ var IDS = {
929
+ comment: "id",
930
+ footnote: "id",
931
+ endnote: "id",
932
+ style: "styleId"
933
+ };
934
+ function keyElement(element4) {
935
+ if (element4.namespaceURI !== NS.w) return void 0;
936
+ if (element4.localName === "p") {
937
+ const id2 = element4.getAttributeNS(WORD_2010, "paraId");
938
+ return id2 ? `paragraph:${id2}` : void 0;
939
+ }
940
+ const attribute2 = IDS[element4.localName];
941
+ if (!attribute2) return void 0;
942
+ const id = element4.getAttributeNS(NS.w, attribute2);
943
+ return id ? `${element4.localName}:${id}` : void 0;
944
+ }
945
+ function mergeDocxSnapshots(base, local, remote) {
946
+ return mergeOpcSnapshots(base, local, remote, {
947
+ async mergePart(input) {
948
+ if (!TEXT_PART.test(input.path) || !input.base || !input.local || !input.remote)
949
+ return {
950
+ status: "unresolved",
951
+ issues: [`Concurrent unsupported DOCX part: ${input.path}`]
952
+ };
953
+ const decoder2 = new TextDecoder();
954
+ const result = mergeXmlThreeWay(
955
+ decoder2.decode(input.base),
956
+ decoder2.decode(input.local),
957
+ decoder2.decode(input.remote),
958
+ {
959
+ keyElement,
960
+ allowPositional: (parent) => parent.namespaceURI === NS.w && POSITIONAL.has(parent.localName),
961
+ allowText: (element4) => (element4.namespaceURI === NS.w || element4.namespaceURI === NS.a) && element4.localName === "t"
962
+ }
963
+ );
964
+ return result.status === "merged" ? { status: "merged", bytes: new TextEncoder().encode(result.xml) } : { status: "unresolved", issues: result.issues.map((issue) => `${input.path}: ${issue}`) };
965
+ }
966
+ });
967
+ }
968
+
189
969
  // docx/xml.ts
190
970
  var WORD_NS = NS.w;
191
971
  var WORD_DATE_UTC_NS = "http://schemas.microsoft.com/office/word/2023/wordml/word16du";
192
972
  var REL_NS = NS.r;
193
- var parseXml2 = (xml) => parseXml(xml, { label: "DOCX" });
973
+ var parseXml2 = (xml2) => parseXml(xml2, { label: "DOCX" });
194
974
  var named2 = (element4, local) => named(element4, local, WORD_NS);
195
975
  var children2 = (parent, local) => children(parent, local, WORD_NS);
196
976
  var first2 = (parent, local) => first(parent, local, WORD_NS);
@@ -974,8 +1754,8 @@ function styleElements(document) {
974
1754
  (element4) => named2(element4, "style") && (getW(element4, "type") === "character" || getW(element4, "type") === "paragraph")
975
1755
  );
976
1756
  }
977
- function parseRunStyleCatalog(xml) {
978
- const document = parseXml2(xml);
1757
+ function parseRunStyleCatalog(xml2) {
1758
+ const document = parseXml2(xml2);
979
1759
  const defaults = first2(first2(document.documentElement, "docDefaults"), "rPrDefault");
980
1760
  const styles = /* @__PURE__ */ Object.create(null);
981
1761
  for (const element4 of styleElements(document)) {
@@ -1168,20 +1948,20 @@ function parseFormatting(pPr) {
1168
1948
  if (rule === "auto" || rule === "exact" || rule === "atLeast") result.lineSpacingRule = rule;
1169
1949
  else if (line4 !== void 0) result.lineSpacingRule = "auto";
1170
1950
  const ind = first2(pPr, "ind");
1171
- for (const [xml, key] of [
1951
+ for (const [xml2, key] of [
1172
1952
  ["left", "indentLeftTwips"],
1173
1953
  ["right", "indentRightTwips"],
1174
1954
  ["start", "indentStartTwips"],
1175
1955
  ["end", "indentEndTwips"]
1176
1956
  ]) {
1177
- const value = signedTwipValue(getW(ind, xml));
1957
+ const value = signedTwipValue(getW(ind, xml2));
1178
1958
  if (value !== void 0) result[key] = value;
1179
1959
  }
1180
- for (const [xml, key] of [
1960
+ for (const [xml2, key] of [
1181
1961
  ["firstLine", "firstLineTwips"],
1182
1962
  ["hanging", "hangingTwips"]
1183
1963
  ]) {
1184
- const value = twipValue(getW(ind, xml));
1964
+ const value = twipValue(getW(ind, xml2));
1185
1965
  if (value !== void 0) result[key] = value;
1186
1966
  }
1187
1967
  return result;
@@ -1198,8 +1978,8 @@ function styleElements2(document) {
1198
1978
  (element4) => named2(element4, "style") && getW(element4, "type") === "paragraph"
1199
1979
  );
1200
1980
  }
1201
- function parseParagraphStyleCatalog(xml) {
1202
- const document = parseXml2(xml);
1981
+ function parseParagraphStyleCatalog(xml2) {
1982
+ const document = parseXml2(xml2);
1203
1983
  const defaults = first2(first2(document.documentElement, "docDefaults"), "pPrDefault");
1204
1984
  const pDefaults = first2(defaults, "pPr");
1205
1985
  const styles = /* @__PURE__ */ Object.create(null);
@@ -1336,8 +2116,8 @@ function conditionalFormatting(block) {
1336
2116
  if (Object.keys(run2).length) result.run = run2;
1337
2117
  return result;
1338
2118
  }
1339
- function parseTableStyleCatalog(xml) {
1340
- const document = parseXml2(xml);
2119
+ function parseTableStyleCatalog(xml2) {
2120
+ const document = parseXml2(xml2);
1341
2121
  const styles = /* @__PURE__ */ Object.create(null);
1342
2122
  for (const element4 of tableStyleElements(document)) {
1343
2123
  const id = getW(element4, "styleId");
@@ -2977,24 +3757,24 @@ function drawingPatternPictureXml(fill) {
2977
3757
  if (!fill.preset && !fill.sourceXml) throw new Error("A DrawingML pattern needs a preset");
2978
3758
  if (before?.kind !== "pattern" || before.preset !== fill.preset)
2979
3759
  root.setAttribute("prst", fill.preset);
2980
- for (const [key, tag] of [
3760
+ for (const [key, tag2] of [
2981
3761
  ["foreground", "fgClr"],
2982
3762
  ["background", "bgClr"]
2983
3763
  ]) {
2984
3764
  const color = fill[key];
2985
3765
  if (before?.kind === "pattern" && JSON.stringify(before[key]) === JSON.stringify(color))
2986
3766
  continue;
2987
- const old = first(root, tag, NS.a);
3767
+ const old = first(root, tag2, NS.a);
2988
3768
  if (!color) {
2989
3769
  if (old) root.removeChild(old);
2990
3770
  continue;
2991
3771
  }
2992
- const node = old ?? doc.createElementNS(NS.a, `a:${tag}`);
3772
+ const node = old ?? doc.createElementNS(NS.a, `a:${tag2}`);
2993
3773
  patchDrawingColorIn(node, color);
2994
3774
  if (!old)
2995
3775
  root.insertBefore(
2996
3776
  node,
2997
- tag === "fgClr" ? first(root, "bgClr", NS.a) ?? root.firstChild : first(root, "extLst", NS.a) ?? null
3777
+ tag2 === "fgClr" ? first(root, "bgClr", NS.a) ?? root.firstChild : first(root, "extLst", NS.a) ?? null
2998
3778
  );
2999
3779
  }
3000
3780
  } else {
@@ -3033,9 +3813,9 @@ function drawingPatternPictureXml(fill) {
3033
3813
  }
3034
3814
 
3035
3815
  // drawingml/write-fill.ts
3036
- function setDrawingFillXml(properties, xml) {
3816
+ function setDrawingFillXml(properties, xml2) {
3037
3817
  const doc = properties.ownerDocument;
3038
- const wrapper = parseXml(`<w xmlns:a="${NS.a}">${xml}</w>`);
3818
+ const wrapper = parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`);
3039
3819
  const fill = elements(wrapper.documentElement)[0];
3040
3820
  const names = ["solidFill", "gradFill", "pattFill", "blipFill", "grpFill", "noFill"];
3041
3821
  if (elements(wrapper.documentElement).length !== 1 || !fill || fill.namespaceURI !== NS.a || !names.includes(fill.localName))
@@ -3063,7 +3843,7 @@ function drawingFillXml(fill) {
3063
3843
  const root = doc.documentElement;
3064
3844
  if (root.namespaceURI !== NS.a || root.localName !== "gradFill")
3065
3845
  throw new Error("Invalid gradient source XML");
3066
- const fragment2 = (xml) => doc.importNode(elements(parseXml(`<w xmlns:a="${NS.a}">${xml}</w>`).documentElement)[0], true);
3846
+ const fragment2 = (xml2) => doc.importNode(elements(parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`).documentElement)[0], true);
3067
3847
  let list2 = first(root, "gsLst", NS.a);
3068
3848
  if (!list2) {
3069
3849
  list2 = doc.createElementNS(NS.a, "a:gsLst");
@@ -3142,8 +3922,8 @@ var ORDER = [
3142
3922
  "extLst"
3143
3923
  ];
3144
3924
  var same = (a2, b) => JSON.stringify(a2) === JSON.stringify(b);
3145
- function importXml(host, xml) {
3146
- const wrapper = parseXml(`<w xmlns:a="${NS.a}">${xml}</w>`);
3925
+ function importXml(host, xml2) {
3926
+ const wrapper = parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`);
3147
3927
  return host.ownerDocument.importNode(elements(wrapper.documentElement)[0], true);
3148
3928
  }
3149
3929
  function dropDrawingDeclarations(node) {
@@ -3184,10 +3964,10 @@ function patchDrawingLine(ln, line4) {
3184
3964
  const solid = first(ln, "solidFill", NS.a);
3185
3965
  if (solid && line4.fill?.kind === "solid") patchDrawingColorIn(solid, line4.fill.color);
3186
3966
  else {
3187
- const xml = line4.fill && drawingFillXml(line4.fill);
3188
- if (xml || !line4.fill) remove(ln, FILLS);
3189
- if (xml) {
3190
- const child7 = importXml(ln, xml);
3967
+ const xml2 = line4.fill && drawingFillXml(line4.fill);
3968
+ if (xml2 || !line4.fill) remove(ln, FILLS);
3969
+ if (xml2) {
3970
+ const child7 = importXml(ln, xml2);
3191
3971
  dropDrawingDeclarations(child7);
3192
3972
  insert(ln, child7);
3193
3973
  }
@@ -3275,7 +4055,7 @@ var KINDS = {
3275
4055
  reflection: "reflection",
3276
4056
  fillOverlay: "fillOverlay"
3277
4057
  };
3278
- var TAGS = Object.fromEntries(Object.entries(KINDS).map(([tag, kind]) => [kind, tag]));
4058
+ var TAGS = Object.fromEntries(Object.entries(KINDS).map(([tag2, kind]) => [kind, tag2]));
3279
4059
  var GEOMETRY = { blurRadiusEmu: "blurRad", distanceEmu: "dist", directionAngle: "dir" };
3280
4060
  var TRANSFORM = { scaleX: "sx", scaleY: "sy", skewXAngle: "kx", skewYAngle: "ky" };
3281
4061
  var NUMBERS = {
@@ -3309,8 +4089,8 @@ var BOOLEANS = {
3309
4089
  };
3310
4090
  var COLORED = /* @__PURE__ */ new Set(["outerShadow", "innerShadow", "presetShadow", "glow"]);
3311
4091
  var same2 = (a2, b) => JSON.stringify(a2) === JSON.stringify(b);
3312
- function fragment(xml) {
3313
- return elements(parseXml(`<w xmlns:a="${NS.a}">${xml}</w>`).documentElement)[0];
4092
+ function fragment(xml2) {
4093
+ return elements(parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`).documentElement)[0];
3314
4094
  }
3315
4095
  function parseDrawingEffect(node) {
3316
4096
  const sourceXml = buildXml(node);
@@ -3384,12 +4164,12 @@ function drawingEffectXml(effect) {
3384
4164
  }
3385
4165
  }
3386
4166
  if (effect.kind === "fillOverlay" && changed("fill")) {
3387
- const xml = effect.fill && drawingFillXml(effect.fill);
3388
- if (effect.fill && !xml) throw new Error("Cannot author this DrawingML effect fill");
3389
- if (xml || !effect.fill) {
4167
+ const xml2 = effect.fill && drawingFillXml(effect.fill);
4168
+ if (effect.fill && !xml2) throw new Error("Cannot author this DrawingML effect fill");
4169
+ if (xml2 || !effect.fill) {
3390
4170
  const fill = fillElementOf(root);
3391
4171
  if (fill) root.removeChild(fill);
3392
- if (xml) root.insertBefore(doc.importNode(fragment(xml), true), root.firstChild);
4172
+ if (xml2) root.insertBefore(doc.importNode(fragment(xml2), true), root.firstChild);
3393
4173
  }
3394
4174
  }
3395
4175
  return buildXml(doc);
@@ -3609,8 +4389,8 @@ function fontSetOf(collection) {
3609
4389
  ...complexScript ? { complexScript } : {}
3610
4390
  };
3611
4391
  }
3612
- function parseTheme2(xml) {
3613
- const theme = parseTheme(parseXml2(xml));
4392
+ function parseTheme2(xml2) {
4393
+ const theme = parseTheme(parseXml2(xml2));
3614
4394
  const colors = {};
3615
4395
  for (const slot2 of THEME_COLOR_SLOTS) {
3616
4396
  const value = themeSlotHex(theme.colorScheme.colors[slot2]);
@@ -3639,8 +4419,8 @@ var TOKEN_TO_SLOT = {
3639
4419
  hyperlink: "hlink",
3640
4420
  followedHyperlink: "folHlink"
3641
4421
  };
3642
- function parseColorSchemeMapping(xml) {
3643
- const document = parseXml2(xml);
4422
+ function parseColorSchemeMapping(xml2) {
4423
+ const document = parseXml2(xml2);
3644
4424
  const mapping = Array.from(document.getElementsByTagNameNS(WORD_NS, "clrSchemeMapping"))[0];
3645
4425
  const result = {};
3646
4426
  if (!mapping) return result;
@@ -3729,62 +4509,13 @@ var RELATIONSHIP_TYPES = {
3729
4509
  diagramColors: `${BASE}/diagramColors`,
3730
4510
  diagramDrawing: "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing"};
3731
4511
 
3732
- // opc/relationships.ts
3733
- function parseRelationships(xml) {
3734
- const map = /* @__PURE__ */ new Map();
3735
- if (!xml) return map;
3736
- const root = parseXml(xml).documentElement;
3737
- for (const node of elements(root)) {
3738
- if (node.localName !== "Relationship") continue;
3739
- const id = node.getAttribute("Id");
3740
- const target = node.getAttribute("Target");
3741
- if (!id || target == null) continue;
3742
- map.set(id, {
3743
- id,
3744
- type: node.getAttribute("Type") ?? "",
3745
- target,
3746
- mode: node.getAttribute("TargetMode") === "External" ? "External" : "Internal"
3747
- });
3748
- }
3749
- return map;
3750
- }
3751
- var escapeAttr = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
3752
- function buildRelationshipsXml(relationships) {
3753
- const items = Array.from(relationships).map(([id, rel]) => {
3754
- const mode = rel.mode === "External" ? ' TargetMode="External"' : "";
3755
- return `<Relationship Id="${escapeAttr(id)}" Type="${escapeAttr(rel.type)}" Target="${escapeAttr(rel.target)}"${mode}/>`;
3756
- }).join("");
3757
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${NS.rels}">${items}</Relationships>`;
3758
- }
3759
- function resolvePartPath(basePart, target) {
3760
- if (target.startsWith("/")) return target.slice(1);
3761
- const baseDir = basePart.slice(0, basePart.lastIndexOf("/") + 1);
3762
- const resolved = [];
3763
- for (const segment2 of `${baseDir}${target}`.split("/")) {
3764
- if (segment2 === "." || segment2 === "") continue;
3765
- if (segment2 === "..") resolved.pop();
3766
- else resolved.push(segment2);
3767
- }
3768
- return resolved.join("/");
3769
- }
3770
- function relationshipsPartFor(partName) {
3771
- const slash = partName.lastIndexOf("/");
3772
- return `${partName.slice(0, slash + 1)}_rels/${partName.slice(slash + 1)}.rels`;
3773
- }
3774
- function nextRelationshipId(used) {
3775
- let index = 1;
3776
- while (used.has(`rId${index}`)) index++;
3777
- return `rId${index}`;
3778
- }
3779
- var getRelationshipId = (element4) => relAttr(element4, "id") || void 0;
3780
-
3781
4512
  // opc/content-types.ts
3782
4513
  var escapeAttr2 = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
3783
- function parseContentTypes(xml) {
4514
+ function parseContentTypes(xml2) {
3784
4515
  const defaults = /* @__PURE__ */ new Map();
3785
4516
  const overrides = /* @__PURE__ */ new Map();
3786
- if (!xml) return { defaults, overrides };
3787
- for (const node of elements(parseXml(xml).documentElement)) {
4517
+ if (!xml2) return { defaults, overrides };
4518
+ for (const node of elements(parseXml(xml2).documentElement)) {
3788
4519
  const contentType = node.getAttribute("ContentType");
3789
4520
  if (!contentType) continue;
3790
4521
  if (node.localName === "Default") {
@@ -3813,9 +4544,9 @@ function buildContentTypesXml(types) {
3813
4544
  ).join("");
3814
4545
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="${NS.contentTypes}">${defaults}${overrides}</Types>`;
3815
4546
  }
3816
- function ensureContentTypeDefault(xml, extension, contentType) {
3817
- const types = parseContentTypes(xml);
3818
- if (types.defaults.has(extension.toLowerCase())) return xml ?? buildContentTypesXml(types);
4547
+ function ensureContentTypeDefault(xml2, extension, contentType) {
4548
+ const types = parseContentTypes(xml2);
4549
+ if (types.defaults.has(extension.toLowerCase())) return xml2 ?? buildContentTypesXml(types);
3819
4550
  types.defaults.set(extension.toLowerCase(), contentType);
3820
4551
  return buildContentTypesXml(types);
3821
4552
  }
@@ -3825,35 +4556,35 @@ var CONTENT_TYPES_PATH = "[Content_Types].xml";
3825
4556
  var XML_DECLARATION = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
3826
4557
  var EMPTY_TYPES = `${XML_DECLARATION}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>`;
3827
4558
  var EMPTY_RELS = `${XML_DECLARATION}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>`;
3828
- function attr2(tag, name) {
4559
+ function attr2(tag2, name) {
3829
4560
  const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3830
- const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(tag);
4561
+ const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(tag2);
3831
4562
  return match ? match[1] ?? match[2] : void 0;
3832
4563
  }
3833
4564
  async function ensureContentTypeOverride(zip, partName, contentType) {
3834
- const xml = await zip.file(CONTENT_TYPES_PATH)?.async("string") ?? EMPTY_TYPES;
4565
+ const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string") ?? EMPTY_TYPES;
3835
4566
  const target = `/${partName}`;
3836
- for (const tag of xml.match(/<Override\b[^>]*\/>/g) ?? [])
3837
- if (attr2(tag, "PartName") === target) return;
4567
+ for (const tag2 of xml2.match(/<Override\b[^>]*\/>/g) ?? [])
4568
+ if (attr2(tag2, "PartName") === target) return;
3838
4569
  const insertion = `<Override PartName="${target}" ContentType="${contentType}"/>`;
3839
- zip.file(CONTENT_TYPES_PATH, xml.replace("</Types>", `${insertion}</Types>`));
4570
+ zip.file(CONTENT_TYPES_PATH, xml2.replace("</Types>", `${insertion}</Types>`));
3840
4571
  }
3841
4572
  async function removeContentTypeOverride(zip, partName) {
3842
- const xml = await zip.file(CONTENT_TYPES_PATH)?.async("string");
3843
- if (!xml) return;
4573
+ const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string");
4574
+ if (!xml2) return;
3844
4575
  const target = `/${partName}`;
3845
- const tag = (xml.match(/<Override\b[^>]*\/>/g) ?? []).find(
4576
+ const tag2 = (xml2.match(/<Override\b[^>]*\/>/g) ?? []).find(
3846
4577
  (candidate) => attr2(candidate, "PartName") === target
3847
4578
  );
3848
- if (tag) zip.file(CONTENT_TYPES_PATH, xml.replace(tag, ""));
4579
+ if (tag2) zip.file(CONTENT_TYPES_PATH, xml2.replace(tag2, ""));
3849
4580
  }
3850
4581
  async function ensureRelationship(zip, relsPath, type, target) {
3851
- const xml = await zip.file(relsPath)?.async("string") ?? EMPTY_RELS;
4582
+ const xml2 = await zip.file(relsPath)?.async("string") ?? EMPTY_RELS;
3852
4583
  const used = /* @__PURE__ */ new Set();
3853
- for (const tag of xml.match(/<Relationship\b[^>]*\/>/g) ?? []) {
3854
- const id2 = attr2(tag, "Id");
4584
+ for (const tag2 of xml2.match(/<Relationship\b[^>]*\/>/g) ?? []) {
4585
+ const id2 = attr2(tag2, "Id");
3855
4586
  if (id2) used.add(id2);
3856
- if (id2 && attr2(tag, "Type") === type && attr2(tag, "Target") === target) return id2;
4587
+ if (id2 && attr2(tag2, "Type") === type && attr2(tag2, "Target") === target) return id2;
3857
4588
  }
3858
4589
  const highest = Math.max(
3859
4590
  0,
@@ -3862,7 +4593,7 @@ async function ensureRelationship(zip, relsPath, type, target) {
3862
4593
  let id = `rId${highest + 1}`;
3863
4594
  if (used.has(id)) id = nextRelationshipId(used);
3864
4595
  const insertion = `<Relationship Id="${id}" Type="${type}" Target="${target}"/>`;
3865
- zip.file(relsPath, xml.replace("</Relationships>", `${insertion}</Relationships>`));
4596
+ zip.file(relsPath, xml2.replace("</Relationships>", `${insertion}</Relationships>`));
3866
4597
  return id;
3867
4598
  }
3868
4599
 
@@ -3874,234 +4605,13 @@ function isSafeHyperlinkHref(href) {
3874
4605
  }
3875
4606
  var OPEN_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto"]);
3876
4607
  /* @__PURE__ */ new Set([...OPEN_SCHEMES, "ftp", "file"]);
3877
- var DEFAULT_ZIP_LIMITS = {
3878
- maxInputBytes: 100 * 1024 * 1024,
3879
- maxEntries: 1e4,
3880
- maxEntryBytes: 100 * 1024 * 1024,
3881
- maxTotalBytes: 100 * 1024 * 1024
3882
- };
3883
- var ZipLimitError = class extends Error {
3884
- code = "ZIP_BOMB";
3885
- limit;
3886
- /** The check that failed (absent when the error was built without one). */
3887
- kind;
3888
- /** The observed value, when known (a lower bound for a size found while inflating). */
3889
- actual;
3890
- constructor(message, details) {
3891
- super(message);
3892
- this.name = "ZipLimitError";
3893
- this.limit = details.limit;
3894
- this.kind = details.kind;
3895
- this.actual = details.actual;
3896
- }
3897
- };
3898
- var mib = (bytes) => Math.round(bytes / 1048576);
3899
- function isSafePartName(name) {
3900
- if (name.includes("\0") || name.includes("\\")) return false;
3901
- if (/^[A-Za-z]:/u.test(name)) return false;
3902
- const body = name.startsWith("/") ? name.slice(1) : name;
3903
- if (body.startsWith("/")) return false;
3904
- return !body.split("/").some((segment2) => segment2 === "..");
3905
- }
3906
- function declaredEntrySize(entry2) {
3907
- const data = entry2._data;
3908
- const size = Number(data?.uncompressedSize ?? 0);
3909
- return Number.isFinite(size) && size > 0 ? size : 0;
3910
- }
3911
- function resolveLimits(limits) {
3912
- const create2 = limits.createError;
3913
- return {
3914
- maxEntries: limits.maxEntries ?? DEFAULT_ZIP_LIMITS.maxEntries,
3915
- maxEntryBytes: limits.maxEntryBytes ?? DEFAULT_ZIP_LIMITS.maxEntryBytes,
3916
- maxTotalBytes: limits.maxTotalBytes ?? DEFAULT_ZIP_LIMITS.maxTotalBytes,
3917
- label: limits.label ?? "ZIP",
3918
- fail: (message, limit, kind, actual) => create2 ? create2(message, { limit, kind, actual }) : new ZipLimitError(message, { limit, kind, actual })
3919
- };
3920
- }
3921
- async function inflateEntryGuarded(entry2, alreadyRead, limits) {
3922
- const chunks = [];
3923
- let size = 0;
3924
- for await (const chunk of streamEntryGuarded(entry2, alreadyRead, limits)) {
3925
- chunks.push(chunk);
3926
- size += chunk.byteLength;
3927
- }
3928
- if (chunks.length === 1 && chunks[0]) return chunks[0];
3929
- const out = new Uint8Array(size);
3930
- let offset = 0;
3931
- for (const chunk of chunks) {
3932
- out.set(chunk, offset);
3933
- offset += chunk.byteLength;
3934
- }
3935
- return out;
3936
- }
3937
- var AHEAD = 8;
3938
- async function* streamEntryGuarded(entry2, alreadyRead, limits) {
3939
- const r = resolveLimits(limits);
3940
- const declared = declaredEntrySize(entry2);
3941
- const stream = entry2.internalStream("uint8array");
3942
- const queue = [];
3943
- let size = 0;
3944
- let ended = false;
3945
- let stopped = false;
3946
- let failure;
3947
- let paused = false;
3948
- let wake;
3949
- const pause = () => {
3950
- paused = true;
3951
- stream.pause();
3952
- };
3953
- const resume = () => {
3954
- if (!paused || stopped) return;
3955
- paused = false;
3956
- stream.resume();
3957
- };
3958
- const fail = (error) => {
3959
- failure ??= error;
3960
- stopped = true;
3961
- queue.length = 0;
3962
- pause();
3963
- wake?.();
3964
- };
3965
- stream.on("data", (chunk) => {
3966
- if (stopped) return pause();
3967
- size += chunk.byteLength;
3968
- if (size > declared || size > r.maxEntryBytes)
3969
- return fail(
3970
- r.fail(
3971
- `${r.label} part ${entry2.name} inflates past its declared size`,
3972
- r.maxEntryBytes,
3973
- size > declared ? "declaredSize" : "maxEntryBytes",
3974
- size
3975
- )
3976
- );
3977
- if (alreadyRead + size > r.maxTotalBytes)
3978
- return fail(
3979
- r.fail(
3980
- `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
3981
- r.maxTotalBytes,
3982
- "maxTotalBytes",
3983
- alreadyRead + size
3984
- )
3985
- );
3986
- queue.push(chunk);
3987
- if (queue.length >= AHEAD) pause();
3988
- wake?.();
3989
- });
3990
- stream.on("error", (error) => fail(error));
3991
- stream.on("end", () => {
3992
- ended = true;
3993
- wake?.();
3994
- });
3995
- stream.resume();
3996
- try {
3997
- for (; ; ) {
3998
- if (failure) throw failure;
3999
- const chunk = queue.shift();
4000
- if (chunk) {
4001
- if (queue.length < AHEAD / 2) resume();
4002
- yield chunk;
4003
- continue;
4004
- }
4005
- if (ended) return;
4006
- await new Promise((resolve) => {
4007
- wake = resolve;
4008
- resume();
4009
- });
4010
- wake = void 0;
4011
- }
4012
- } finally {
4013
- stopped = true;
4014
- if (!ended) pause();
4015
- }
4016
- }
4017
- function toBase64(bytes) {
4018
- let binary = "";
4019
- for (let i2 = 0; i2 < bytes.length; i2 += 32768)
4020
- binary += String.fromCharCode(...bytes.subarray(i2, i2 + 32768));
4021
- return btoa(binary);
4022
- }
4023
- function guardZip(zip, limits = {}) {
4024
- const r = resolveLimits(limits);
4025
- const entries = Object.values(zip.files);
4026
- if (entries.length > r.maxEntries)
4027
- throw r.fail(
4028
- `${r.label} package exceeds the ${r.maxEntries.toLocaleString("en-US")} part limit`,
4029
- r.maxEntries,
4030
- "maxEntries",
4031
- entries.length
4032
- );
4033
- let declared = 0;
4034
- for (const entry2 of entries) {
4035
- const original = entry2.unsafeOriginalName;
4036
- if (!isSafePartName(entry2.name) || original !== void 0 && !isSafePartName(original))
4037
- throw r.fail(`${r.label} package has an unsafe part name`, r.maxEntries, "partName");
4038
- if (entry2.dir) continue;
4039
- const size = declaredEntrySize(entry2);
4040
- if (size > r.maxEntryBytes)
4041
- throw r.fail(
4042
- `${r.label} part ${entry2.name} exceeds the uncompressed part size limit`,
4043
- r.maxEntryBytes,
4044
- "maxEntryBytes",
4045
- size
4046
- );
4047
- declared += size;
4048
- }
4049
- if (declared > r.maxTotalBytes)
4050
- throw r.fail(
4051
- `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
4052
- r.maxTotalBytes,
4053
- "maxTotalBytes",
4054
- declared
4055
- );
4056
- const produced = /* @__PURE__ */ new Map();
4057
- let total = 0;
4058
- for (const entry2 of entries) {
4059
- if (entry2.dir) continue;
4060
- const inflateOriginal = entry2.async.bind(entry2);
4061
- entry2.async = async (type, onUpdate) => {
4062
- const previous = produced.get(entry2.name) ?? 0;
4063
- const bytes = await inflateEntryGuarded(entry2, total - previous, limits);
4064
- if (bytes.byteLength > previous) {
4065
- total += bytes.byteLength - previous;
4066
- produced.set(entry2.name, bytes.byteLength);
4067
- }
4068
- switch (type) {
4069
- case "uint8array":
4070
- return bytes;
4071
- case "string":
4072
- case "text":
4073
- return new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes);
4074
- case "arraybuffer":
4075
- return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
4076
- case "base64":
4077
- return toBase64(bytes);
4078
- default:
4079
- return inflateOriginal(type, onUpdate);
4080
- }
4081
- };
4082
- }
4083
- return zip;
4084
- }
4085
- async function openZip(input, limits = {}) {
4086
- const r = resolveLimits(limits);
4087
- const maxInput = limits.maxInputBytes ?? DEFAULT_ZIP_LIMITS.maxInputBytes;
4088
- const bytes = input instanceof Uint8Array ? input : new Uint8Array(input);
4089
- if (bytes.byteLength > maxInput)
4090
- throw r.fail(
4091
- `${r.label} package exceeds the ${mib(maxInput)} MiB compressed input limit`,
4092
- maxInput,
4093
- "maxInputBytes",
4094
- bytes.byteLength
4095
- );
4096
- return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
4097
- }
4098
4608
 
4099
4609
  // opc/properties/patch.ts
4100
4610
  var XMLNS3 = "http://www.w3.org/2000/xmlns/";
4101
- function tagEnd(xml, from) {
4611
+ function tagEnd(xml2, from) {
4102
4612
  let quote = "";
4103
- for (let i2 = from + 1; i2 < xml.length; i2++) {
4104
- const ch = xml[i2];
4613
+ for (let i2 = from + 1; i2 < xml2.length; i2++) {
4614
+ const ch = xml2[i2];
4105
4615
  if (quote) {
4106
4616
  if (ch === quote) quote = "";
4107
4617
  } else if (ch === '"' || ch === "'") quote = ch;
@@ -4109,24 +4619,24 @@ function tagEnd(xml, from) {
4109
4619
  }
4110
4620
  throw new Error("Unterminated tag in property part");
4111
4621
  }
4112
- function skipMarkup(xml, at) {
4113
- if (xml.startsWith("<!--", at)) return xml.indexOf("-->", at) + 3;
4114
- if (xml.startsWith("<![CDATA[", at)) return xml.indexOf("]]>", at) + 3;
4115
- if (xml.startsWith("<?", at)) return xml.indexOf("?>", at) + 2;
4622
+ function skipMarkup(xml2, at) {
4623
+ if (xml2.startsWith("<!--", at)) return xml2.indexOf("-->", at) + 3;
4624
+ if (xml2.startsWith("<![CDATA[", at)) return xml2.indexOf("]]>", at) + 3;
4625
+ if (xml2.startsWith("<?", at)) return xml2.indexOf("?>", at) + 2;
4116
4626
  return void 0;
4117
4627
  }
4118
- function scan(xml) {
4628
+ function scan(xml2) {
4119
4629
  let i2 = 0;
4120
4630
  let rootStart = -1;
4121
4631
  while (rootStart < 0) {
4122
- const lt = xml.indexOf("<", i2);
4632
+ const lt = xml2.indexOf("<", i2);
4123
4633
  if (lt < 0) throw new Error("Property part has no root element");
4124
- const skipped = skipMarkup(xml, lt);
4634
+ const skipped = skipMarkup(xml2, lt);
4125
4635
  if (skipped !== void 0) i2 = skipped;
4126
4636
  else rootStart = lt;
4127
4637
  }
4128
- const openEnd = tagEnd(xml, rootStart);
4129
- if (xml[openEnd - 2] === "/") {
4638
+ const openEnd = tagEnd(xml2, rootStart);
4639
+ if (xml2[openEnd - 2] === "/") {
4130
4640
  const root = {
4131
4641
  start: rootStart,
4132
4642
  openEnd,
@@ -4141,16 +4651,16 @@ function scan(xml) {
4141
4651
  let child7;
4142
4652
  i2 = openEnd;
4143
4653
  for (; ; ) {
4144
- const lt = xml.indexOf("<", i2);
4654
+ const lt = xml2.indexOf("<", i2);
4145
4655
  if (lt < 0) throw new Error("Property part root is not closed");
4146
- const skipped = skipMarkup(xml, lt);
4656
+ const skipped = skipMarkup(xml2, lt);
4147
4657
  if (skipped !== void 0) {
4148
4658
  i2 = skipped;
4149
4659
  continue;
4150
4660
  }
4151
- const end = tagEnd(xml, lt);
4661
+ const end = tagEnd(xml2, lt);
4152
4662
  i2 = end;
4153
- if (xml[lt + 1] === "/") {
4663
+ if (xml2[lt + 1] === "/") {
4154
4664
  if (depth === 0) {
4155
4665
  const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
4156
4666
  return { root, children: children3 };
@@ -4158,7 +4668,7 @@ function scan(xml) {
4158
4668
  depth--;
4159
4669
  if (depth === 0 && child7)
4160
4670
  children3.push({ ...child7, closeStart: lt, end, selfClosing: false });
4161
- } else if (xml[end - 2] === "/") {
4671
+ } else if (xml2[end - 2] === "/") {
4162
4672
  if (depth === 0)
4163
4673
  children3.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
4164
4674
  } else {
@@ -4168,11 +4678,11 @@ function scan(xml) {
4168
4678
  }
4169
4679
  }
4170
4680
  var escapeText = (text2) => text2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\r/g, "&#xD;");
4171
- var qualifiedName = (xml, span) => /^<([^\s/>]+)/.exec(xml.slice(span.start, span.openEnd))?.[1] ?? "";
4681
+ var qualifiedName = (xml2, span) => /^<([^\s/>]+)/.exec(xml2.slice(span.start, span.openEnd))?.[1] ?? "";
4172
4682
  var PartPatch = class {
4173
- constructor(xml, rootElement) {
4174
- this.xml = xml;
4175
- const { root, children: children3 } = scan(xml);
4683
+ constructor(xml2, rootElement) {
4684
+ this.xml = xml2;
4685
+ const { root, children: children3 } = scan(xml2);
4176
4686
  const kids = elements(rootElement);
4177
4687
  if (kids.length !== children3.length) throw new Error("Property part markup is not supported");
4178
4688
  kids.forEach((kid, index) => this.spans.set(kid, children3[index]));
@@ -4287,10 +4797,10 @@ var FIELDS = [
4287
4797
  FIELDS.map(([field]) => field);
4288
4798
  var EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
4289
4799
  <cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
4290
- function parseCoreProperties(xml) {
4800
+ function parseCoreProperties(xml2) {
4291
4801
  const out = {};
4292
- if (!xml) return out;
4293
- const root = parseXml(xml, { label: "core properties" }).documentElement;
4802
+ if (!xml2) return out;
4803
+ const root = parseXml(xml2, { label: "core properties" }).documentElement;
4294
4804
  for (const [field, prefix2] of FIELDS) {
4295
4805
  const text2 = first(root, field, NS[prefix2])?.textContent ?? "";
4296
4806
  if (text2 !== "") out[field] = text2;
@@ -4299,9 +4809,9 @@ function parseCoreProperties(xml) {
4299
4809
  }
4300
4810
  var formatW3cdtf = (date) => date.toISOString().replace(/\.\d{3}Z$/, "Z");
4301
4811
  function writeCoreProperties(props, sourceXml) {
4302
- const xml = sourceXml ?? EMPTY_CORE;
4303
- const root = parseXml(xml, { label: "core properties" }).documentElement;
4304
- const patch = new PartPatch(xml, root);
4812
+ const xml2 = sourceXml ?? EMPTY_CORE;
4813
+ const root = parseXml(xml2, { label: "core properties" }).documentElement;
4814
+ const patch = new PartPatch(xml2, root);
4305
4815
  for (const [field, prefix2, isDate] of FIELDS) {
4306
4816
  const ns = NS[prefix2];
4307
4817
  const value = props[field];
@@ -4438,8 +4948,8 @@ var PREFIX = {
4438
4948
  };
4439
4949
  var CORE_TYPE = "application/vnd.openxmlformats-package.core-properties+xml";
4440
4950
  var CORE_REL = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
4441
- function parseCoreProperties2(xml) {
4442
- const root = parseXml2(xml).documentElement;
4951
+ function parseCoreProperties2(xml2) {
4952
+ const root = parseXml2(xml2).documentElement;
4443
4953
  const result = {};
4444
4954
  for (const field of PROPERTY_FIELDS) {
4445
4955
  const element4 = child(root, field);
@@ -5113,8 +5623,8 @@ function parseContentControl(sdt, level4) {
5113
5623
  };
5114
5624
  const alias = getW(first2(sdtPr, "alias"), "val");
5115
5625
  if (alias !== void 0) control.alias = alias;
5116
- const tag = getW(first2(sdtPr, "tag"), "val");
5117
- if (tag !== void 0) control.tag = tag;
5626
+ const tag2 = getW(first2(sdtPr, "tag"), "val");
5627
+ if (tag2 !== void 0) control.tag = tag2;
5118
5628
  const lock = getW(first2(sdtPr, "lock"), "val");
5119
5629
  if (lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked")
5120
5630
  control.lock = lock;
@@ -5417,21 +5927,21 @@ function onlyProperties(sdtPr) {
5417
5927
  const value = (local) => children2(sdtPr, local).map((child7) => getW(child7, "val"));
5418
5928
  return value("id").every((id) => validId(id) !== void 0) && value("lock").every((lock) => lock === "unlocked" || validLock(lock) !== void 0);
5419
5929
  }
5420
- function verbatimProperties(doc, xml) {
5421
- if (!xml) return void 0;
5930
+ function verbatimProperties(doc, xml2) {
5931
+ if (!xml2) return void 0;
5422
5932
  let root;
5423
5933
  try {
5424
- root = parseXml2(xml).documentElement;
5934
+ root = parseXml2(xml2).documentElement;
5425
5935
  } catch {
5426
5936
  return void 0;
5427
5937
  }
5428
5938
  return root?.localName === "sdtPr" && root.namespaceURI === WORD_NS && onlyProperties(root) ? importElement(doc, root) : void 0;
5429
5939
  }
5430
- function verbatimEndProperties(doc, xml) {
5431
- if (!xml) return void 0;
5940
+ function verbatimEndProperties(doc, xml2) {
5941
+ if (!xml2) return void 0;
5432
5942
  let root;
5433
5943
  try {
5434
- root = parseXml2(xml).documentElement;
5944
+ root = parseXml2(xml2).documentElement;
5435
5945
  } catch {
5436
5946
  return void 0;
5437
5947
  }
@@ -6000,8 +6510,8 @@ async function commentHexIds(zip) {
6000
6510
  const used = /* @__PURE__ */ new Set();
6001
6511
  for (const file of Object.values(zip.files)) {
6002
6512
  if (!file.name.startsWith("word/") || !file.name.endsWith(".xml")) continue;
6003
- const xml = await file.async("string");
6004
- for (const match of xml.matchAll(
6513
+ const xml2 = await file.async("string");
6514
+ for (const match of xml2.matchAll(
6005
6515
  /\b(?:[\w.-]+:)?(?:paraId|durableId)\s*=\s*["']([\dA-Fa-f]{8})["']/g
6006
6516
  ))
6007
6517
  used.add(match[1].toUpperCase());
@@ -6033,9 +6543,9 @@ async function patchCommentAnchors(zip, ids, comments) {
6033
6543
  const byId = new Map(comments.map((comment) => [ids.get(comment.id), comment]));
6034
6544
  for (const file of Object.values(zip.files)) {
6035
6545
  if (!file.name.startsWith("word/") || !file.name.endsWith(".xml")) continue;
6036
- const xml = await file.async("string");
6037
- if (!/commentRangeStart|commentRangeEnd|commentReference/.test(xml)) continue;
6038
- const doc = parseXml2(xml);
6546
+ const xml2 = await file.async("string");
6547
+ if (!/commentRangeStart|commentRangeEnd|commentReference/.test(xml2)) continue;
6548
+ const doc = parseXml2(xml2);
6039
6549
  let changed = false;
6040
6550
  const anchors = /* @__PURE__ */ new Map();
6041
6551
  for (const name of ["commentRangeStart", "commentRangeEnd", "commentReference"]) {
@@ -6154,161 +6664,6 @@ function patchCommentMetadata(parts, identities) {
6154
6664
  return result;
6155
6665
  }
6156
6666
 
6157
- // text/text-diff.ts
6158
- var isLowSurrogate = (text2, at) => {
6159
- const code = text2.charCodeAt(at);
6160
- return code >= 56320 && code <= 57343;
6161
- };
6162
- function shortestEdit(n2, m, same6, maxEdits) {
6163
- const max = Math.min(n2 + m, maxEdits);
6164
- const offset = max + 1;
6165
- const v = new Int32Array(2 * max + 3);
6166
- const trace = [];
6167
- for (let d = 0; d <= max; d++) {
6168
- for (let k = -d; k <= d; k += 2) {
6169
- const down = k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1];
6170
- let x = down ? v[offset + k + 1] : v[offset + k - 1] + 1;
6171
- let y = x - k;
6172
- while (x < n2 && y < m && same6(x, y)) {
6173
- x++;
6174
- y++;
6175
- }
6176
- v[offset + k] = x;
6177
- if (x >= n2 && y >= m) return backtrack(trace, n2, m, d);
6178
- }
6179
- trace.push(v.slice(offset - d, offset + d + 1));
6180
- }
6181
- return void 0;
6182
- }
6183
- function backtrack(trace, n2, m, d) {
6184
- const edits = [];
6185
- let x = n2;
6186
- let y = m;
6187
- for (let step = d; step > 0; step--) {
6188
- const previous = trace[step - 1];
6189
- const at = (k2) => previous[k2 + step - 1];
6190
- const k = x - y;
6191
- const down = k === -step || k !== step && at(k - 1) < at(k + 1);
6192
- const before = down ? k + 1 : k - 1;
6193
- const startX = at(before);
6194
- const startY = startX - before;
6195
- edits.push(down ? [startX, startY, true] : [startX, startY, false]);
6196
- x = startX;
6197
- y = startY;
6198
- }
6199
- return edits.reverse();
6200
- }
6201
- function changesOf(edits) {
6202
- const changes = [];
6203
- for (const [x, y, inserts] of edits) {
6204
- const last = changes.at(-1);
6205
- if (last && last.fromEnd === x && last.toEnd === y) {
6206
- if (inserts) last.toEnd++;
6207
- else last.fromEnd++;
6208
- } else
6209
- changes.push({
6210
- fromStart: x,
6211
- fromEnd: inserts ? x : x + 1,
6212
- toStart: y,
6213
- toEnd: inserts ? y + 1 : y
6214
- });
6215
- }
6216
- return changes;
6217
- }
6218
- function characterChanges(a2, b, maxEdits) {
6219
- const edits = shortestEdit(
6220
- a2.length,
6221
- b.length,
6222
- (x, y) => a2.charCodeAt(x) === b.charCodeAt(y),
6223
- maxEdits
6224
- );
6225
- return edits && changesOf(edits);
6226
- }
6227
- var TOKEN = /[\p{L}\p{N}\p{M}]+|\s+|[\s\S]/gu;
6228
- function tokensOf(text2, ids) {
6229
- const tokens = [];
6230
- const starts = [];
6231
- for (const match of text2.matchAll(TOKEN)) {
6232
- let id = ids.get(match[0]);
6233
- if (id === void 0) ids.set(match[0], id = ids.size);
6234
- tokens.push(id);
6235
- starts.push(match.index);
6236
- }
6237
- starts.push(text2.length);
6238
- return { tokens, starts };
6239
- }
6240
- function tokenChanges(a2, b, maxEdits) {
6241
- const ids = /* @__PURE__ */ new Map();
6242
- const from = tokensOf(a2, ids);
6243
- const to = tokensOf(b, ids);
6244
- const edits = shortestEdit(
6245
- from.tokens.length,
6246
- to.tokens.length,
6247
- (x, y) => from.tokens[x] === to.tokens[y],
6248
- maxEdits
6249
- );
6250
- if (!edits) return void 0;
6251
- let budget = maxEdits;
6252
- return changesOf(edits).flatMap((stretch) => {
6253
- const change = {
6254
- fromStart: from.starts[stretch.fromStart],
6255
- fromEnd: from.starts[stretch.fromEnd],
6256
- toStart: to.starts[stretch.toStart],
6257
- toEnd: to.starts[stretch.toEnd]
6258
- };
6259
- const inner = change.fromEnd > change.fromStart && change.toEnd > change.toStart ? characterChanges(
6260
- a2.slice(change.fromStart, change.fromEnd),
6261
- b.slice(change.toStart, change.toEnd),
6262
- budget
6263
- ) : void 0;
6264
- if (!inner) return [change];
6265
- for (const found of inner)
6266
- budget -= found.fromEnd - found.fromStart + found.toEnd - found.toStart;
6267
- return inner.map((found) => ({
6268
- fromStart: found.fromStart + change.fromStart,
6269
- fromEnd: found.fromEnd + change.fromStart,
6270
- toStart: found.toStart + change.toStart,
6271
- toEnd: found.toEnd + change.toStart
6272
- }));
6273
- });
6274
- }
6275
- function diffText(from, to, maxEdits = 500) {
6276
- let start = 0;
6277
- while (start < from.length && start < to.length && from.charCodeAt(start) === to.charCodeAt(start))
6278
- start++;
6279
- let end = 0;
6280
- while (end < from.length - start && end < to.length - start && from.charCodeAt(from.length - 1 - end) === to.charCodeAt(to.length - 1 - end))
6281
- end++;
6282
- const a2 = from.slice(start, from.length - end);
6283
- const b = to.slice(start, to.length - end);
6284
- if (!a2.length && !b.length) return [];
6285
- const found = a2.length && b.length ? characterChanges(a2, b, maxEdits) ?? tokenChanges(a2, b, maxEdits) : void 0;
6286
- const changes = found ?? [{ fromStart: 0, fromEnd: a2.length, toStart: 0, toEnd: b.length }];
6287
- const result = [];
6288
- for (const change of changes) {
6289
- const placed = {
6290
- fromStart: change.fromStart + start,
6291
- fromEnd: change.fromEnd + start,
6292
- toStart: change.toStart + start,
6293
- toEnd: change.toEnd + start
6294
- };
6295
- if (placed.fromStart > 0 && placed.toStart > 0 && (isLowSurrogate(from, placed.fromStart) || isLowSurrogate(to, placed.toStart))) {
6296
- placed.fromStart--;
6297
- placed.toStart--;
6298
- }
6299
- if (isLowSurrogate(from, placed.fromEnd) || isLowSurrogate(to, placed.toEnd)) {
6300
- placed.fromEnd++;
6301
- placed.toEnd++;
6302
- }
6303
- const last = result.at(-1);
6304
- if (last && placed.fromStart <= last.fromEnd) {
6305
- last.fromEnd = Math.max(last.fromEnd, placed.fromEnd);
6306
- last.toEnd = Math.max(last.toEnd, placed.toEnd);
6307
- } else result.push(placed);
6308
- }
6309
- return result;
6310
- }
6311
-
6312
6667
  // docx/write-run-extra.ts
6313
6668
  function setAttribute2(element4, local, value) {
6314
6669
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
@@ -7144,8 +7499,8 @@ function resolveDrawingOuterShadow(effect, theme) {
7144
7499
  dy: Math.sin(angle) * distance
7145
7500
  };
7146
7501
  }
7147
- function resolveDrawingShadowXml(xml, theme) {
7148
- return xml ? resolveDrawingShadow(parseXml(xml).documentElement, theme) : void 0;
7502
+ function resolveDrawingShadowXml(xml2, theme) {
7503
+ return xml2 ? resolveDrawingShadow(parseXml(xml2).documentElement, theme) : void 0;
7149
7504
  }
7150
7505
  function svgDropShadowElement(s, format) {
7151
7506
  const num2 = format.number;
@@ -7866,20 +8221,20 @@ function dropRedundantDeclarations(element4) {
7866
8221
  if (element4.getAttribute("xmlns:r") === NS.r) element4.removeAttribute("xmlns:r");
7867
8222
  for (const child7 of elements(element4)) dropRedundantDeclarations(child7);
7868
8223
  }
7869
- function importDrawingXml(doc, xml) {
7870
- const wrapper = parseXml(`<w xmlns:a="${NS.a}" xmlns:r="${NS.r}">${xml}</w>`).documentElement;
8224
+ function importDrawingXml(doc, xml2) {
8225
+ const wrapper = parseXml(`<w xmlns:a="${NS.a}" xmlns:r="${NS.r}">${xml2}</w>`).documentElement;
7871
8226
  const node = elements(wrapper)[0];
7872
8227
  if (!node) throw new Error("Empty DrawingML fragment");
7873
8228
  const imported = doc.importNode(node, true);
7874
8229
  dropRedundantDeclarations(imported);
7875
8230
  return imported;
7876
8231
  }
7877
- function keptChildName(xml) {
7878
- const match = /^\s*<(?:[\w.-]+:)?([\w.-]+)/u.exec(xml);
8232
+ function keptChildName(xml2) {
8233
+ const match = /^\s*<(?:[\w.-]+:)?([\w.-]+)/u.exec(xml2);
7879
8234
  return match?.[1] ?? "";
7880
8235
  }
7881
- function keptChildren(doc, xml) {
7882
- return (xml ?? []).map((value) => ({
8236
+ function keptChildren(doc, xml2) {
8237
+ return (xml2 ?? []).map((value) => ({
7883
8238
  name: keptChildName(value),
7884
8239
  node: importDrawingXml(doc, value)
7885
8240
  }));
@@ -7946,7 +8301,7 @@ function writeHyperlink(doc, local, link) {
7946
8301
  setBoolean(element4, "history", link.history);
7947
8302
  setBoolean(element4, "highlightClick", link.highlightClick);
7948
8303
  setBoolean(element4, "endSnd", link.endSound);
7949
- for (const xml of link.extraXml ?? []) element4.appendChild(importDrawingXml(doc, xml));
8304
+ for (const xml2 of link.extraXml ?? []) element4.appendChild(importDrawingXml(doc, xml2));
7950
8305
  return element4;
7951
8306
  }
7952
8307
  function setAttributes(element4, value) {
@@ -7971,9 +8326,9 @@ function setAttributes(element4, value) {
7971
8326
  setValue(element4, "bmk", value.bookmark);
7972
8327
  }
7973
8328
  function fillChild(doc, fill) {
7974
- const xml = fill ? drawingFillXml(fill) : void 0;
7975
- if (!xml) return void 0;
7976
- const node = importDrawingXml(doc, xml);
8329
+ const xml2 = fill ? drawingFillXml(fill) : void 0;
8330
+ if (!xml2) return void 0;
8331
+ const node = importDrawingXml(doc, xml2);
7977
8332
  return { name: node.localName, node };
7978
8333
  }
7979
8334
  function modelledChildren(doc, value) {
@@ -8194,9 +8549,9 @@ function semantics(value) {
8194
8549
  Object.fromEntries(Object.entries(value).filter(([key]) => key !== "sourceXml"))
8195
8550
  );
8196
8551
  }
8197
- function source(doc, name, xml) {
8198
- if (!xml) return doc.createElementNS(NS.a, `a:${name}`);
8199
- const element4 = parseXml(xml).documentElement;
8552
+ function source(doc, name, xml2) {
8553
+ if (!xml2) return doc.createElementNS(NS.a, `a:${name}`);
8554
+ const element4 = parseXml(xml2).documentElement;
8200
8555
  if (element4.namespaceURI !== NS.a || element4.localName !== name)
8201
8556
  throw new Error(`Invalid ${name} source`);
8202
8557
  return doc.importNode(element4, true);
@@ -18013,10 +18368,10 @@ function parseAttributes(source2) {
18013
18368
  }
18014
18369
  return attrs3;
18015
18370
  }
18016
- function tagEnd2(xml, from) {
18371
+ function tagEnd2(xml2, from) {
18017
18372
  let quote = "";
18018
- for (let i2 = from; i2 < xml.length; i2++) {
18019
- const ch = xml[i2];
18373
+ for (let i2 = from; i2 < xml2.length; i2++) {
18374
+ const ch = xml2[i2];
18020
18375
  if (quote) {
18021
18376
  if (ch === quote) {
18022
18377
  quote = "";
@@ -18029,27 +18384,27 @@ function tagEnd2(xml, from) {
18029
18384
  }
18030
18385
  return -1;
18031
18386
  }
18032
- function parseOrderedXml(xml) {
18387
+ function parseOrderedXml(xml2) {
18033
18388
  const root = { name: "#document", attrs: {}, children: [] };
18034
18389
  const stack = [root];
18035
- let i2 = xml.indexOf("<");
18036
- while (i2 >= 0 && i2 < xml.length) {
18037
- if (xml.startsWith("<!--", i2)) {
18038
- const close = xml.indexOf("-->", i2 + 4);
18039
- i2 = close < 0 ? -1 : xml.indexOf("<", close + 3);
18390
+ let i2 = xml2.indexOf("<");
18391
+ while (i2 >= 0 && i2 < xml2.length) {
18392
+ if (xml2.startsWith("<!--", i2)) {
18393
+ const close = xml2.indexOf("-->", i2 + 4);
18394
+ i2 = close < 0 ? -1 : xml2.indexOf("<", close + 3);
18040
18395
  continue;
18041
18396
  }
18042
- if (xml.startsWith("<![CDATA[", i2)) {
18043
- const close = xml.indexOf("]]>", i2 + 9);
18044
- i2 = close < 0 ? -1 : xml.indexOf("<", close + 3);
18397
+ if (xml2.startsWith("<![CDATA[", i2)) {
18398
+ const close = xml2.indexOf("]]>", i2 + 9);
18399
+ i2 = close < 0 ? -1 : xml2.indexOf("<", close + 3);
18045
18400
  continue;
18046
18401
  }
18047
- const end = tagEnd2(xml, i2 + 1);
18402
+ const end = tagEnd2(xml2, i2 + 1);
18048
18403
  if (end < 0) {
18049
18404
  break;
18050
18405
  }
18051
- const next = xml.indexOf("<", end + 1);
18052
- const first3 = xml[i2 + 1];
18406
+ const next = xml2.indexOf("<", end + 1);
18407
+ const first3 = xml2[i2 + 1];
18053
18408
  if (first3 === "?" || first3 === "!") {
18054
18409
  i2 = next;
18055
18410
  continue;
@@ -18057,11 +18412,11 @@ function parseOrderedXml(xml) {
18057
18412
  const closing = first3 === "/";
18058
18413
  let cursor = closing ? i2 + 2 : i2 + 1;
18059
18414
  const nameStart = cursor;
18060
- while (cursor < end && isNameChar(xml[cursor])) {
18415
+ while (cursor < end && isNameChar(xml2[cursor])) {
18061
18416
  cursor++;
18062
18417
  }
18063
- const tag = xml.slice(nameStart, cursor);
18064
- if (!tag) {
18418
+ const tag2 = xml2.slice(nameStart, cursor);
18419
+ if (!tag2) {
18065
18420
  i2 = next;
18066
18421
  continue;
18067
18422
  }
@@ -18072,10 +18427,10 @@ function parseOrderedXml(xml) {
18072
18427
  i2 = next;
18073
18428
  continue;
18074
18429
  }
18075
- const selfClosing = xml[end - 1] === "/";
18430
+ const selfClosing = xml2[end - 1] === "/";
18076
18431
  const element4 = {
18077
- name: localName(tag),
18078
- attrs: parseAttributes(xml.slice(cursor, selfClosing ? end - 1 : end)),
18432
+ name: localName(tag2),
18433
+ attrs: parseAttributes(xml2.slice(cursor, selfClosing ? end - 1 : end)),
18079
18434
  children: []
18080
18435
  };
18081
18436
  stack[stack.length - 1].children.push(element4);
@@ -18285,8 +18640,8 @@ function parseStatement(element4, state) {
18285
18640
  return void 0;
18286
18641
  }
18287
18642
  }
18288
- function parseLayoutDefinitionXml(xml) {
18289
- const document = parseOrderedXml(xml);
18643
+ function parseLayoutDefinitionXml(xml2) {
18644
+ const document = parseOrderedXml(xml2);
18290
18645
  const layoutDef = document?.name === "layoutDef" ? document : findOrderedDescendant(document, "layoutDef");
18291
18646
  const rootElement = layoutDef?.children.find((child7) => child7.name === "layoutNode");
18292
18647
  if (!layoutDef || !rootElement) {
@@ -24158,12 +24513,12 @@ function writeDiagramFormatDefinition(source2, change) {
24158
24513
  return buildXml(doc);
24159
24514
  }
24160
24515
  function formatDiagramSource(source2, change) {
24161
- const xml = writeDiagramFormatDefinition(
24516
+ const xml2 = writeDiagramFormatDefinition(
24162
24517
  change.kind === "colors" ? source2?.colorsXml : source2?.quickStyleXml,
24163
24518
  change
24164
24519
  );
24165
24520
  const id = `urn:ooxml-core/${change.kind}/${change.value}`;
24166
- return change.kind === "colors" ? { source: { ...source2, colorsXml: xml }, colorsId: id } : { source: { ...source2, quickStyleXml: xml }, quickStyleId: id };
24521
+ return change.kind === "colors" ? { source: { ...source2, colorsXml: xml2 }, colorsId: id } : { source: { ...source2, quickStyleXml: xml2 }, quickStyleId: id };
24167
24522
  }
24168
24523
 
24169
24524
  // diagram/write/data-edit.ts
@@ -24269,9 +24624,9 @@ function dropDrawingExtension(model) {
24269
24624
  if (ext.getAttribute("uri") === DSP_EXT_URI) extLst.removeChild(ext);
24270
24625
  if (elements(extLst).length === 0) model.removeChild(extLst);
24271
24626
  }
24272
- function writeEditedDiagramData(xml, nodes, options2 = {}) {
24627
+ function writeEditedDiagramData(xml2, nodes, options2 = {}) {
24273
24628
  const createModelId = options2.createModelId ?? createOfficeGuid;
24274
- const doc = parseXml(xml, { label: "diagram data" });
24629
+ const doc = parseXml(xml2, { label: "diagram data" });
24275
24630
  const model = doc.documentElement;
24276
24631
  const ptLst = child4(model, "ptLst");
24277
24632
  if (!ptLst) throw new Error("The diagram data part has no point list.");
@@ -24709,8 +25064,8 @@ function sha256(data) {
24709
25064
  // diagram/cache-metadata.ts
24710
25065
  var GENERATED_DIAGRAM_CACHE_NS = "urn:ooxml-core:diagram:generated-cache";
24711
25066
  var GENERATED_DIAGRAM_CACHE_NOTICE = "Generated SmartArt preview; not native Office layout.";
24712
- var generatedDrawingDigest = (xml) => Array.from(
24713
- sha256(new TextEncoder().encode(xml)),
25067
+ var generatedDrawingDigest = (xml2) => Array.from(
25068
+ sha256(new TextEncoder().encode(xml2)),
24714
25069
  (byte) => byte.toString(16).padStart(2, "0")
24715
25070
  ).join("");
24716
25071
  var DEFAULT_GENERATED_DIAGRAM_SCHEME = {
@@ -25361,26 +25716,26 @@ function diagramLayoutData(input) {
25361
25716
  const branch = first(vars, "hierBranch", NS.dgm)?.getAttribute("val");
25362
25717
  if (branch === "std" || branch === "init" || branch === "l" || branch === "r" || branch === "hang")
25363
25718
  values.hierarchyBranch = branch;
25364
- for (const [tag, key] of [
25719
+ for (const [tag2, key] of [
25365
25720
  ["chMax", "childMax"],
25366
25721
  ["chPref", "childPreferred"]
25367
25722
  ]) {
25368
- const raw2 = first(vars, tag, NS.dgm)?.getAttribute("val");
25723
+ const raw2 = first(vars, tag2, NS.dgm)?.getAttribute("val");
25369
25724
  if (raw2 && Number.isFinite(Number(raw2))) values[key] = Number(raw2);
25370
25725
  }
25371
- for (const [tag, key] of [
25726
+ for (const [tag2, key] of [
25372
25727
  ["orgChart", "orgChart"],
25373
25728
  ["bulletEnabled", "bulletEnabled"]
25374
25729
  ]) {
25375
- const raw2 = first(vars, tag, NS.dgm)?.getAttribute("val");
25730
+ const raw2 = first(vars, tag2, NS.dgm)?.getAttribute("val");
25376
25731
  if (raw2) values[key] = raw2 === "1" || raw2 === "true";
25377
25732
  }
25378
- for (const [tag, key] of [
25733
+ for (const [tag2, key] of [
25379
25734
  ["animLvl", "animationLevel"],
25380
25735
  ["animOne", "animateOne"],
25381
25736
  ["resizeHandles", "resizeHandles"]
25382
25737
  ]) {
25383
- const raw2 = first(vars, tag, NS.dgm)?.getAttribute("val");
25738
+ const raw2 = first(vars, tag2, NS.dgm)?.getAttribute("val");
25384
25739
  if (raw2) values[key] = raw2;
25385
25740
  }
25386
25741
  data.presLayoutVars = values;
@@ -25557,8 +25912,8 @@ function add2(parent, namespace, name, attrs3 = {}) {
25557
25912
  parent.appendChild(child7);
25558
25913
  return child7;
25559
25914
  }
25560
- function withDiagramDrawingRelationship(xml, relationshipId) {
25561
- const doc = parseXml(xml);
25915
+ function withDiagramDrawingRelationship(xml2, relationshipId) {
25916
+ const doc = parseXml(xml2);
25562
25917
  const model = doc.documentElement;
25563
25918
  let extension = descendants(model, "dataModelExt").find((node) => node.namespaceURI === DSP2);
25564
25919
  if (!extension) {
@@ -25918,8 +26273,8 @@ async function loadDiagram(hostPart, relationshipIds, host) {
25918
26273
  const part = paths[name];
25919
26274
  if (!part) return void 0;
25920
26275
  try {
25921
- const xml = await host.readText(part);
25922
- if (xml === void 0) {
26276
+ const xml2 = await host.readText(part);
26277
+ if (xml2 === void 0) {
25923
26278
  issues.push({
25924
26279
  code: "DIAGRAM_PART_MISSING",
25925
26280
  message: `Part ${part} is not in the package.`,
@@ -25927,11 +26282,11 @@ async function loadDiagram(hostPart, relationshipIds, host) {
25927
26282
  });
25928
26283
  return void 0;
25929
26284
  }
25930
- if (name === "layout") layoutSource.layoutXml = xml;
25931
- if (name === "data") layoutSource.dataXml = xml;
25932
- if (name === "colors") layoutSource.colorsXml = xml;
25933
- if (name === "quickStyle") layoutSource.quickStyleXml = xml;
25934
- return parse(xml, part);
26285
+ if (name === "layout") layoutSource.layoutXml = xml2;
26286
+ if (name === "data") layoutSource.dataXml = xml2;
26287
+ if (name === "colors") layoutSource.colorsXml = xml2;
26288
+ if (name === "quickStyle") layoutSource.quickStyleXml = xml2;
26289
+ return parse(xml2, part);
25935
26290
  } catch (error) {
25936
26291
  issues.push({
25937
26292
  code: "DIAGRAM_PART_UNREADABLE",
@@ -25941,11 +26296,11 @@ async function loadDiagram(hostPart, relationshipIds, host) {
25941
26296
  return void 0;
25942
26297
  }
25943
26298
  };
25944
- const data = await read("data", (xml, part) => parseDiagramDataModel(xml, part));
26299
+ const data = await read("data", (xml2, part) => parseDiagramDataModel(xml2, part));
25945
26300
  if (data) issues.push(...data.issues);
25946
- const layout2 = await read("layout", (xml) => parseDiagramLayoutSummary(xml));
25947
- const colors = await read("colors", (xml) => parseDiagramColors(xml));
25948
- const quickStyle = await read("quickStyle", (xml) => parseDiagramQuickStyle(xml));
26301
+ const layout2 = await read("layout", (xml2) => parseDiagramLayoutSummary(xml2));
26302
+ const colors = await read("colors", (xml2) => parseDiagramColors(xml2));
26303
+ const quickStyle = await read("quickStyle", (xml2) => parseDiagramQuickStyle(xml2));
25949
26304
  let drawingResolution;
25950
26305
  try {
25951
26306
  drawingResolution = await resolveDiagramDrawingPart(
@@ -25964,11 +26319,11 @@ async function loadDiagram(hostPart, relationshipIds, host) {
25964
26319
  let generatedCache = false;
25965
26320
  if (drawingResolution) {
25966
26321
  paths.drawing = drawingResolution.path;
25967
- drawing = await read("drawing", (xml, part) => {
26322
+ drawing = await read("drawing", (xml2, part) => {
25968
26323
  generatedCache = Boolean(
25969
- data?.generatedCacheDigest && data.generatedCacheDigest === generatedDrawingDigest(xml)
26324
+ data?.generatedCacheDigest && data.generatedCacheDigest === generatedDrawingDigest(xml2)
25970
26325
  );
25971
- return parseDiagramDrawing(xml, part);
26326
+ return parseDiagramDrawing(xml2, part);
25972
26327
  });
25973
26328
  if (drawing) {
25974
26329
  try {
@@ -26126,10 +26481,10 @@ async function resolveDiagramParts(diagram, readText) {
26126
26481
  resolvePath: resolvePartPath,
26127
26482
  readText,
26128
26483
  readRelationshipEntries: async (relsPart) => {
26129
- const xml = await readText(relsPart);
26130
- if (!xml) return void 0;
26484
+ const xml2 = await readText(relsPart);
26485
+ if (!xml2) return void 0;
26131
26486
  try {
26132
- return [...parseRelationships(xml).values()].map(({ id, type, target, mode }) => ({
26487
+ return [...parseRelationships(xml2).values()].map(({ id, type, target, mode }) => ({
26133
26488
  id,
26134
26489
  type,
26135
26490
  target,
@@ -27419,8 +27774,8 @@ function chartPaletteSeriesColor(palette, i2, n2, scheme2) {
27419
27774
 
27420
27775
  // chart/color-style.ts
27421
27776
  var CHART_COLOR_STYLE_NS = "http://schemas.microsoft.com/office/drawing/2012/chartStyle";
27422
- function chartColorStyleId(xml) {
27423
- const root = parseXml(xml).documentElement;
27777
+ function chartColorStyleId(xml2) {
27778
+ const root = parseXml(xml2).documentElement;
27424
27779
  if (root.localName !== "colorStyle" || root.namespaceURI !== CHART_COLOR_STYLE_NS)
27425
27780
  return void 0;
27426
27781
  const value = root.getAttribute("id");
@@ -27578,22 +27933,22 @@ function readChartManualLayoutValues(value) {
27578
27933
  };
27579
27934
  const target = enumeration("layoutTarget", ["inner", "outer"]);
27580
27935
  if (target) result.layoutTarget = target;
27581
- for (const [xml, key] of [
27936
+ for (const [xml2, key] of [
27582
27937
  ["xMode", "xMode"],
27583
27938
  ["yMode", "yMode"],
27584
27939
  ["wMode", "widthMode"],
27585
27940
  ["hMode", "heightMode"]
27586
27941
  ]) {
27587
- const mode = enumeration(xml, ["edge", "factor"]);
27942
+ const mode = enumeration(xml2, ["edge", "factor"]);
27588
27943
  if (mode) result[key] = mode;
27589
27944
  }
27590
- for (const [xml, key] of [
27945
+ for (const [xml2, key] of [
27591
27946
  ["x", "x"],
27592
27947
  ["y", "y"],
27593
27948
  ["w", "width"],
27594
27949
  ["h", "height"]
27595
27950
  ]) {
27596
- const raw2 = value(xml);
27951
+ const raw2 = value(xml2);
27597
27952
  if (typeof raw2 !== "string" && typeof raw2 !== "number" || typeof raw2 === "string" && !raw2.trim())
27598
27953
  continue;
27599
27954
  const number2 = Number(raw2);
@@ -27844,12 +28199,12 @@ var CHART_ROOT_BINDINGS = /* @__PURE__ */ new Map([
27844
28199
  ["r", NS.r]
27845
28200
  ]);
27846
28201
  var DECLARATION = / xmlns:([A-Za-z_][\w.-]*)="([^"]*)"/g;
27847
- function stripDeclarations(xml, bindings) {
28202
+ function stripDeclarations(xml2, bindings) {
27848
28203
  const conflicting = /* @__PURE__ */ new Set();
27849
- for (const [, prefix2, uri] of xml.matchAll(DECLARATION))
28204
+ for (const [, prefix2, uri] of xml2.matchAll(DECLARATION))
27850
28205
  if (prefix2 !== void 0 && bindings.has(prefix2) && bindings.get(prefix2) !== uri)
27851
28206
  conflicting.add(prefix2);
27852
- return xml.replace(
28207
+ return xml2.replace(
27853
28208
  DECLARATION,
27854
28209
  (match, prefix2, uri) => bindings.get(prefix2) === uri && !conflicting.has(prefix2) ? "" : match
27855
28210
  );
@@ -28203,7 +28558,7 @@ function valXml(local, value) {
28203
28558
  return `<c:${local} val="${text2}"/>`;
28204
28559
  }
28205
28560
  var elementXml = (local, content, attributes2 = "") => content ? `<c:${local}${attributes2}>${content}</c:${local}>` : `<c:${local}${attributes2}/>`;
28206
- var raw = (context, xml) => xml ? stripDeclarations(xml, context.bindings) : "";
28561
+ var raw = (context, xml2) => xml2 ? stripDeclarations(xml2, context.bindings) : "";
28207
28562
  function sameValue(left, right) {
28208
28563
  if (left === right) return true;
28209
28564
  if (typeof left !== "object" || typeof right !== "object" || !left || !right) return false;
@@ -28887,7 +29242,7 @@ function writeTextBody(body) {
28887
29242
 
28888
29243
  // chart/write-shape.ts
28889
29244
  var ROOT_DECLARATIONS = [...CHART_ROOT_BINDINGS].map(([prefix2, uri]) => ` xmlns:${prefix2}="${uri}"`).join("");
28890
- var wrap = (local, xml) => parseXml(`<c:${local}${ROOT_DECLARATIONS}>${xml}</c:${local}>`, { label: "Chart" }).documentElement;
29245
+ var wrap = (local, xml2) => parseXml(`<c:${local}${ROOT_DECLARATIONS}>${xml2}</c:${local}>`, { label: "Chart" }).documentElement;
28891
29246
  function chartFillXml(fill) {
28892
29247
  return drawingFillXml(fill);
28893
29248
  }
@@ -28897,8 +29252,8 @@ var firstOf = (parent, names) => elements(parent).find((node) => node.namespaceU
28897
29252
  function patchShape(root, shape2, read) {
28898
29253
  const doc = root.ownerDocument;
28899
29254
  if (!sameValue(read.fill, shape2.fill)) {
28900
- const xml = shape2.fill && chartFillXml(shape2.fill);
28901
- if (xml) setDrawingFillXml(root, xml);
29255
+ const xml2 = shape2.fill && chartFillXml(shape2.fill);
29256
+ if (xml2) setDrawingFillXml(root, xml2);
28902
29257
  else if (!shape2.fill)
28903
29258
  for (let fill = fillElementOf(root); fill; fill = fillElementOf(root)) root.removeChild(fill);
28904
29259
  }
@@ -28983,12 +29338,12 @@ function numberFormatXml(format) {
28983
29338
  const linked = format.sourceLinked === void 0 ? "" : ` sourceLinked="${format.sourceLinked ? 1 : 0}"`;
28984
29339
  return `<c:numFmt formatCode="${escapeAttribute(format.formatCode)}"${linked}/>`;
28985
29340
  }
28986
- function chartTextBodyFromXml(xml) {
28987
- const body = parseDrawingTextBody(wrap("rich", xml)) ?? {
29341
+ function chartTextBodyFromXml(xml2) {
29342
+ const body = parseDrawingTextBody(wrap("rich", xml2)) ?? {
28988
29343
  paragraphs: [],
28989
29344
  text: ""
28990
29345
  };
28991
- body.sourceXml = xml;
29346
+ body.sourceXml = xml2;
28992
29347
  return body;
28993
29348
  }
28994
29349
 
@@ -30072,9 +30427,9 @@ var CHART_EX_ROOT_DECLARATIONS = [
30072
30427
  { prefix: "a", uri: NS.a },
30073
30428
  { prefix: "r", uri: NS.r }
30074
30429
  ];
30075
- function chartExWriteOptionsOf(xml) {
30076
- const declarationBreak = /^<\?xml[^>]*\?>(\r\n|\n)?/.exec(xml)?.[1] ?? "";
30077
- return { declarationBreak, .../<[^<>]*\s\/>/.test(xml) ? { emptyElementSpace: true } : {} };
30430
+ function chartExWriteOptionsOf(xml2) {
30431
+ const declarationBreak = /^<\?xml[^>]*\?>(\r\n|\n)?/.exec(xml2)?.[1] ?? "";
30432
+ return { declarationBreak, .../<[^<>]*\s\/>/.test(xml2) ? { emptyElementSpace: true } : {} };
30078
30433
  }
30079
30434
  function writeChartExSpace(space, options2 = {}) {
30080
30435
  const bindings = /* @__PURE__ */ new Map();
@@ -30113,9 +30468,9 @@ function writeChartExSpace(space, options2 = {}) {
30113
30468
  );
30114
30469
  const userShapes = space.userShapesRelId === void 0 ? "" : `<c:userShapes${attributes([["r:id", space.userShapesRelId]])}/>`;
30115
30470
  const body = chartDataXml(context, space.chartData) + chart + shapeXml(context, space.spPr) + textBodyXml2(context, space.txPr) + raw(context, space.colorMapOverrideXml) + raw(context, space.formatOverridesXml) + raw(context, space.printSettingsXml) + userShapes + raw(context, space.extLst);
30116
- let xml = `${DECLARATION3}${options2.declarationBreak ?? ""}<cx:chartSpace${declarations}>${body}</cx:chartSpace>`;
30117
- if (options2.emptyElementSpace) xml = xml.replace(/\/>/g, " />");
30118
- return xml;
30471
+ let xml2 = `${DECLARATION3}${options2.declarationBreak ?? ""}<cx:chartSpace${declarations}>${body}</cx:chartSpace>`;
30472
+ if (options2.emptyElementSpace) xml2 = xml2.replace(/\/>/g, " />");
30473
+ return xml2;
30119
30474
  }
30120
30475
 
30121
30476
  // chart/data-sheet.ts
@@ -31089,17 +31444,17 @@ async function syncWorksheetTables(zip, sheetPath, doc, writes, shared) {
31089
31444
  for (const rel of rels.values()) {
31090
31445
  if (rel.mode === "External" || !rel.type.endsWith("/table")) continue;
31091
31446
  const path3 = resolvePartPath(sheetPath, rel.target);
31092
- const xml = await zip.file(path3)?.async("string");
31093
- if (!xml) continue;
31094
- const tableDoc = parseXml(xml, { label: "Table" });
31447
+ const xml2 = await zip.file(path3)?.async("string");
31448
+ if (!xml2) continue;
31449
+ const tableDoc = parseXml(xml2, { label: "Table" });
31095
31450
  const table = tableDoc.documentElement;
31096
31451
  if (table && syncTable(table, doc, values, shared)) zip.file(path3, buildXml(tableDoc));
31097
31452
  }
31098
31453
  }
31099
31454
  async function sharedStringTexts(zip) {
31100
- const xml = await zip.file("xl/sharedStrings.xml")?.async("string");
31101
- if (!xml) return [];
31102
- return childrenNamed(parseXml(xml).documentElement ?? void 0, "si").map((item2) => {
31455
+ const xml2 = await zip.file("xl/sharedStrings.xml")?.async("string");
31456
+ if (!xml2) return [];
31457
+ return childrenNamed(parseXml(xml2).documentElement ?? void 0, "si").map((item2) => {
31103
31458
  const direct = childNamed(item2, "t");
31104
31459
  if (direct) return direct.textContent ?? "";
31105
31460
  return childrenNamed(item2, "r").map((run2) => childNamed(run2, "t")?.textContent ?? "").join("");
@@ -31177,8 +31532,8 @@ async function validateAtomicChartWorkbookWrites(zip, paths, writes, requireCurr
31177
31532
  unsupported("rich worksheet strings require source-workbook editing");
31178
31533
  if (requireCurrentValues) {
31179
31534
  const current = text2 ? childNamed(text2, "t")?.textContent ?? void 0 : childNamed(cell2, "v")?.textContent ?? void 0;
31180
- const equal = write.isNumeric ? current !== void 0 && Number(current) === Number(value) : current === value;
31181
- if (!equal) unsupported("the workbook and chart caches disagree");
31535
+ const equal2 = write.isNumeric ? current !== void 0 && Number(current) === Number(value) : current === value;
31536
+ if (!equal2) unsupported("the workbook and chart caches disagree");
31182
31537
  }
31183
31538
  if (write.isNumeric && !Number.isFinite(Number(value)))
31184
31539
  unsupported("a numeric cache value is not finite");
@@ -31381,9 +31736,9 @@ async function appendChartWorkbookSheet(bytes, rowsForName, options2 = {}) {
31381
31736
  // chart/ex/workbook.ts
31382
31737
  async function appendChartExWorkbookData(bytes, before, after) {
31383
31738
  const zip = await openEmbeddedPackage(bytes);
31384
- const xml = await zip.file("xl/workbook.xml")?.async("string");
31385
- if (!xml) throw new Error("The chart workbook is missing.");
31386
- const root = parseXml(xml).documentElement;
31739
+ const xml2 = await zip.file("xl/workbook.xml")?.async("string");
31740
+ if (!xml2) throw new Error("The chart workbook is missing.");
31741
+ const root = parseXml(xml2).documentElement;
31387
31742
  const defined = first(root, "definedNames", NS.x);
31388
31743
  const names = defined ? children(defined, "definedName", NS.x) : [];
31389
31744
  const resolve = (name) => names.find(
@@ -33618,9 +33973,9 @@ function schemaPosition(node, end) {
33618
33973
  }
33619
33974
  return end === "mid" ? { kind: "percent", value: 50 } : { kind: end };
33620
33975
  }
33621
- function parseRegionValueColorPositions(xml) {
33622
- if (!xml) return void 0;
33623
- const root = parseXml(`<cx:root xmlns:cx="${NS.cx}">${xml}</cx:root>`).documentElement;
33976
+ function parseRegionValueColorPositions(xml2) {
33977
+ if (!xml2) return void 0;
33978
+ const root = parseXml(`<cx:root xmlns:cx="${NS.cx}">${xml2}</cx:root>`).documentElement;
33624
33979
  const positions = first(root, "valueColorPositions", NS.cx);
33625
33980
  if (!positions) return void 0;
33626
33981
  const count = positions.getAttribute("count");
@@ -33646,8 +34001,8 @@ function parseRegionValueColorPositions(xml) {
33646
34001
  // chart/region-map/value-colors.ts
33647
34002
  function resolveRegionValueColors(options2, color) {
33648
34003
  const result = { ...options2 };
33649
- const xml = `<cx:root xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">${options2.valueColorsXml ?? ""}${options2.valueColorPositionsXml ?? ""}</cx:root>`;
33650
- const root = parseXml(xml).documentElement;
34004
+ const xml2 = `<cx:root xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">${options2.valueColorsXml ?? ""}${options2.valueColorPositionsXml ?? ""}</cx:root>`;
34005
+ const root = parseXml(xml2).documentElement;
33651
34006
  if (options2.valueColorsXml) {
33652
34007
  const colors = Array.from(root.getElementsByTagName("*")).flatMap((node) => {
33653
34008
  const c2 = color(parseDrawingColorIn(node));
@@ -35387,14 +35742,14 @@ function inflateGeoCache(binary, maxOutputBytes = LIMIT) {
35387
35742
  }
35388
35743
  return new TextDecoder("utf-8", { fatal: true }).decode(out);
35389
35744
  }
35390
- function readGeographyCache(xml, pointLimit = 1e6) {
35745
+ function readGeographyCache(xml2, pointLimit = 1e6) {
35391
35746
  const result = { regions: [], issues: [] };
35392
- if (!xml) return result;
35747
+ if (!xml2) return result;
35393
35748
  try {
35394
35749
  if (!Number.isSafeInteger(pointLimit) || pointLimit < 1 || pointLimit > 1e6)
35395
35750
  throw new Error("Invalid geography point limit.");
35396
- if (xml.length > LIMIT) throw new Error("Geography cache input limit exceeded.");
35397
- let root = parseXml(`<cx:root xmlns:cx="${CX}">${xml}</cx:root>`).documentElement;
35751
+ if (xml2.length > LIMIT) throw new Error("Geography cache input limit exceeded.");
35752
+ let root = parseXml(`<cx:root xmlns:cx="${CX}">${xml2}</cx:root>`).documentElement;
35398
35753
  const binary = elements2(root, "binary")[0];
35399
35754
  if (binary) root = parseXml(inflateGeoCache(binary.textContent ?? "")).documentElement;
35400
35755
  let points3 = 0;
@@ -37756,15 +38111,15 @@ function parseChartGraphic(graphicData, docPr, rels, isAnchor) {
37756
38111
  async function resolveChartPart(chart, readText) {
37757
38112
  if (!chart.partName) return;
37758
38113
  try {
37759
- const xml = await readText(chart.partName);
37760
- if (xml === void 0) {
38114
+ const xml2 = await readText(chart.partName);
38115
+ if (xml2 === void 0) {
37761
38116
  chart.issues.push({
37762
38117
  code: "CHART_PART_MISSING",
37763
38118
  message: `The chart part ${chart.partName} is not in the package.`
37764
38119
  });
37765
38120
  return;
37766
38121
  }
37767
- const root = parseXml(xml, { label: "Chart part" }).documentElement;
38122
+ const root = parseXml(xml2, { label: "Chart part" }).documentElement;
37768
38123
  const extended = chartExSummary(root);
37769
38124
  if (extended) {
37770
38125
  const parsed = parseChartExSpace(root);
@@ -38041,8 +38396,8 @@ function dropDeclarations(element4) {
38041
38396
  for (const node of Array.from(element4.childNodes))
38042
38397
  if (node.nodeType === 1) dropDeclarations(node);
38043
38398
  }
38044
- function importFragment(doc, xml) {
38045
- const wrapper = parseXml(`<w xmlns:a="${A_NS2}">${xml}</w>`).documentElement;
38399
+ function importFragment(doc, xml2) {
38400
+ const wrapper = parseXml(`<w xmlns:a="${A_NS2}">${xml2}</w>`).documentElement;
38046
38401
  return Array.from(wrapper.childNodes).filter((node) => node.nodeType === 1).map((node) => {
38047
38402
  const imported = doc.importNode(node, true);
38048
38403
  dropDeclarations(imported);
@@ -38148,8 +38503,8 @@ function geometry(doc, spec) {
38148
38503
  add3(avLst, attrs2(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
38149
38504
  const nodes = spec.customGeometryXml ? importFragment(doc, spec.customGeometryXml) : [add3(prst, avLst)];
38150
38505
  if (spec.fill) {
38151
- const xml = drawingFillXml(spec.fill);
38152
- if (xml) nodes.push(...importFragment(doc, xml));
38506
+ const xml2 = drawingFillXml(spec.fill);
38507
+ if (xml2) nodes.push(...importFragment(doc, xml2));
38153
38508
  }
38154
38509
  if (spec.line) nodes.push(...importFragment(doc, drawingLineXml(spec.line)));
38155
38510
  return nodes;
@@ -38470,8 +38825,8 @@ var DocPrIdAllocator = class {
38470
38825
  this.reserve(Number(node.getAttribute("id")));
38471
38826
  }
38472
38827
  /** Reserves every `docPr` id found in serialized XML. */
38473
- reserveFromXml(xml) {
38474
- for (const match of xml.matchAll(DOC_PR_ID)) this.reserve(Number(match[1]));
38828
+ reserveFromXml(xml2) {
38829
+ for (const match of xml2.matchAll(DOC_PR_ID)) this.reserve(Number(match[1]));
38475
38830
  }
38476
38831
  /** Reserves the ids of every XML part in a package (document, headers, footers, notes...). */
38477
38832
  async reserveFromPackage(zip) {
@@ -38871,9 +39226,9 @@ function insertedDiagramDataXml(diagram, createModelId = createOfficeGuid) {
38871
39226
  }
38872
39227
  async function dropDrawingPart(zip, relId, partName, ownerPart = HOST_PART) {
38873
39228
  const relsPath = relationshipsPartFor2(ownerPart);
38874
- const xml = await zip.file(relsPath)?.async("string");
38875
- if (xml) {
38876
- const document = parseXml(xml);
39229
+ const xml2 = await zip.file(relsPath)?.async("string");
39230
+ if (xml2) {
39231
+ const document = parseXml(xml2);
38877
39232
  const entry2 = elements(document.documentElement).find(
38878
39233
  (node) => node.namespaceURI === NS.rels && node.getAttribute("Id") === relId && node.getAttribute("Type") === DIAGRAM_RELATIONSHIP_TYPES.drawing
38879
39234
  );
@@ -38909,8 +39264,8 @@ async function applyDiagramEdits(zip, blocks, baseBlocks, pendingMedia) {
38909
39264
  if (!relaid && !reformatted && JSON.stringify(nodesOf(diagram)) === JSON.stringify(nodesOf(original)))
38910
39265
  continue;
38911
39266
  done.add(partName);
38912
- const xml = await zip.file(partName)?.async("string");
38913
- if (xml === void 0) continue;
39267
+ const xml2 = await zip.file(partName)?.async("string");
39268
+ if (xml2 === void 0) continue;
38914
39269
  const drawing = original.parts.drawing;
38915
39270
  const layoutPart = diagram.parts.layout?.partName;
38916
39271
  const definition = layoutPart ? pendingMedia?.get(layoutPart) : void 0;
@@ -38919,16 +39274,16 @@ async function applyDiagramEdits(zip, blocks, baseBlocks, pendingMedia) {
38919
39274
  "The new SmartArt layout definition is missing; the layout cannot be changed."
38920
39275
  );
38921
39276
  if (relaid && layoutPart && definition) zip.file(layoutPart, definition.bytes);
38922
- for (const [key, xml2] of [
39277
+ for (const [key, xml3] of [
38923
39278
  ["colors", diagram.layoutSource?.colorsXml],
38924
39279
  ["quickStyle", diagram.layoutSource?.quickStyleXml]
38925
39280
  ]) {
38926
39281
  const name = diagram.parts[key]?.partName;
38927
- if (reformatted && name && xml2) zip.file(name, xml2);
39282
+ if (reformatted && name && xml3) zip.file(name, xml3);
38928
39283
  }
38929
39284
  zip.file(
38930
39285
  partName,
38931
- writeEditedDiagramData(xml, nodesOf(diagram), {
39286
+ writeEditedDiagramData(xml2, nodesOf(diagram), {
38932
39287
  dropDrawingLink: true,
38933
39288
  ...diagram.colorsId ? { colorsId: diagram.colorsId } : {},
38934
39289
  ...diagram.quickStyleId ? { quickStyleId: diagram.quickStyleId } : {},
@@ -39234,8 +39589,8 @@ function createImageRun(doc, image, base, old, allocator) {
39234
39589
  }
39235
39590
 
39236
39591
  // docx/revision-properties.ts
39237
- function parsePropertiesSnapshot(xml, local) {
39238
- const element4 = parseXml2(xml).documentElement;
39592
+ function parsePropertiesSnapshot(xml2, local) {
39593
+ const element4 = parseXml2(xml2).documentElement;
39239
39594
  if (!named2(element4, local))
39240
39595
  throw new Error(`A formatting revision snapshot must contain Word ${local} properties.`);
39241
39596
  return element4;
@@ -39289,10 +39644,10 @@ function writeFormatRevision(doc, props, revision, local) {
39289
39644
  const original = first2(props, `${local}Change`);
39290
39645
  removeChildren2(props, `${local}Change`);
39291
39646
  if (!revision) return;
39292
- const xml = local === "rPr" ? revision.previousRunPropertiesXml : revision.previousParagraphPropertiesXml;
39293
- if (!xml)
39647
+ const xml2 = local === "rPr" ? revision.previousRunPropertiesXml : revision.previousParagraphPropertiesXml;
39648
+ if (!xml2)
39294
39649
  throw new Error(`Cannot write a formatting revision without its prior ${local} snapshot.`);
39295
- const previous = parsePropertiesSnapshot(xml, local);
39650
+ const previous = parsePropertiesSnapshot(xml2, local);
39296
39651
  const change = original ?? makeW(doc, `${local}Change`);
39297
39652
  removeChildren2(change, local);
39298
39653
  writeRevisionMetadata(change, revision);
@@ -39475,21 +39830,21 @@ function runPropertiesHaveUnknownContent(properties) {
39475
39830
  }
39476
39831
 
39477
39832
  // docx/restore-run-format.ts
39478
- function parseRunPropertiesSnapshot(xml) {
39479
- return parsePropertiesSnapshot(xml, "rPr");
39833
+ function parseRunPropertiesSnapshot(xml2) {
39834
+ return parsePropertiesSnapshot(xml2, "rPr");
39480
39835
  }
39481
39836
  function restoreRunFormatting(run2) {
39482
39837
  const nested = run2.formatRevision;
39483
- const xml = (nested ?? run2.revision)?.previousRunPropertiesXml;
39484
- if (!xml)
39838
+ const xml2 = (nested ?? run2.revision)?.previousRunPropertiesXml;
39839
+ if (!xml2)
39485
39840
  throw new Error(
39486
39841
  "Cannot reject a formatting revision without its prior run-properties snapshot."
39487
39842
  );
39488
- const snapshot2 = parseRunPropertiesSnapshot(xml);
39843
+ const snapshot2 = parseRunPropertiesSnapshot(xml2);
39489
39844
  const previous = parseDirectRunProperties(snapshot2);
39490
39845
  for (const key of DIRECT_RUN_PROPERTY_KEYS) delete run2[key];
39491
39846
  Object.assign(run2, previous);
39492
- run2.restoredRunPropertiesXml = xml;
39847
+ run2.restoredRunPropertiesXml = xml2;
39493
39848
  if (runPropertiesHaveUnknownContent(snapshot2)) run2.sourceRunPropertiesXml = buildXml(snapshot2);
39494
39849
  else delete run2.sourceRunPropertiesXml;
39495
39850
  if (nested) delete run2.formatRevision;
@@ -40099,7 +40454,7 @@ async function applyComments(zip, comments) {
40099
40454
  parts.comments.xml && before === after ? parts.comments.xml : after
40100
40455
  );
40101
40456
  const metadata = patchCommentMetadata(parts, identities);
40102
- for (const [path3, xml] of metadata) zip.file(path3, xml);
40457
+ for (const [path3, xml2] of metadata) zip.file(path3, xml2);
40103
40458
  for (const kind of Object.keys(COMMENT_PARTS)) {
40104
40459
  const part = parts[kind];
40105
40460
  if (kind !== "comments" && !metadata.has(part.path)) continue;
@@ -40235,8 +40590,8 @@ var BORDER_ORDER = ["top", "left", "bottom", "right", "insideH", "insideV"];
40235
40590
  function setW2(element4, name, value) {
40236
40591
  element4.setAttributeNS(WORD_NS, `w:${name}`, value);
40237
40592
  }
40238
- function buildBorders(doc, borders, tag) {
40239
- const element4 = makeW(doc, tag);
40593
+ function buildBorders(doc, borders, tag2) {
40594
+ const element4 = makeW(doc, tag2);
40240
40595
  for (const side of BORDER_ORDER) {
40241
40596
  const value = borders[side];
40242
40597
  if (!value) continue;
@@ -40250,8 +40605,8 @@ function buildBorders(doc, borders, tag) {
40250
40605
  }
40251
40606
  return element4;
40252
40607
  }
40253
- function buildMargins(doc, margins, tag) {
40254
- const element4 = makeW(doc, tag);
40608
+ function buildMargins(doc, margins, tag2) {
40609
+ const element4 = makeW(doc, tag2);
40255
40610
  for (const side of ["top", "left", "bottom", "right"]) {
40256
40611
  const value = margins[side];
40257
40612
  if (value === void 0) continue;
@@ -43592,8 +43947,8 @@ function parseNum(element4) {
43592
43947
  ...Object.keys(levelOverrides).length ? { levelOverrides } : {}
43593
43948
  };
43594
43949
  }
43595
- function parseNumberingCatalog(xml, relationships) {
43596
- const document = parseXml2(xml);
43950
+ function parseNumberingCatalog(xml2, relationships) {
43951
+ const document = parseXml2(xml2);
43597
43952
  const root = document.documentElement;
43598
43953
  const abstractNums = dictionary();
43599
43954
  const warnings = [];
@@ -44013,13 +44368,13 @@ async function createHeaderFooterParts(zip, model, base, docPrIds) {
44013
44368
  const content = (model.sections ?? []).flatMap((section) => Object.values(section[kind] ?? {})).find((content2) => content2?.partName === partName);
44014
44369
  const source2 = content?.sourcePartName && zip.file(content.sourcePartName);
44015
44370
  if (source2) {
44016
- const xml = await source2.async("string");
44371
+ const xml2 = await source2.async("string");
44017
44372
  zip.file(
44018
44373
  partName,
44019
- docPrIds ? xml.replace(
44374
+ docPrIds ? xml2.replace(
44020
44375
  /(<(?:[\w.-]+:)?docPr\b[^>]*?\sid\s*=\s*["'])\d+(["'])/g,
44021
44376
  (_match, start, end) => `${start}${docPrIds.next()}${end}`
44022
- ) : xml
44377
+ ) : xml2
44023
44378
  );
44024
44379
  const rels = zip.file(relationshipsPartFor2(content.sourcePartName));
44025
44380
  if (rels) zip.file(relationshipsPartFor2(partName), await rels.async("uint8array"));
@@ -44091,8 +44446,8 @@ var PARTS = {
44091
44446
  var WORD_NS3 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
44092
44447
  var RELATIONSHIPS2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
44093
44448
  function emptyNotesPart(kind) {
44094
- const tag = `w:${kind}`;
44095
- const separator = (type, id, mark) => `<${tag} w:type="${type}" w:id="${id}"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:${mark}/></w:r></w:p></${tag}>`;
44449
+ const tag2 = `w:${kind}`;
44450
+ const separator = (type, id, mark) => `<${tag2} w:type="${type}" w:id="${id}"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:${mark}/></w:r></w:p></${tag2}>`;
44096
44451
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:${kind}s xmlns:w="${WORD_NS3}">${separator("separator", "-1", "separator")}${separator("continuationSeparator", "0", "continuationSeparator")}</w:${kind}s>`;
44097
44452
  }
44098
44453
  async function createNotesPart(zip, kind) {
@@ -46094,13 +46449,13 @@ var SETTINGS_ORDER = [
46094
46449
  "decimalSymbol",
46095
46450
  "listSeparator"
46096
46451
  ];
46097
- function parseTrackChangesSetting(xml) {
46098
- const root = parseXml2(xml).documentElement;
46452
+ function parseTrackChangesSetting(xml2) {
46453
+ const root = parseXml2(xml2).documentElement;
46099
46454
  if (!root) return false;
46100
46455
  return onOffElement(children2(root, "trackRevisions")[0] ?? children2(root, "trackChanges")[0]) === true;
46101
46456
  }
46102
- function parseFormSettings(xml) {
46103
- const root = parseXml2(xml).documentElement;
46457
+ function parseFormSettings(xml2) {
46458
+ const root = parseXml2(xml2).documentElement;
46104
46459
  if (!root) return {};
46105
46460
  const protect = children2(root, "documentProtection")[0];
46106
46461
  const edit = protect && getW(protect, "edit");
@@ -46122,8 +46477,8 @@ function parseFormSettings(xml) {
46122
46477
  }
46123
46478
  };
46124
46479
  }
46125
- function parseReviewPreferences(xml) {
46126
- const root = parseXml2(xml).documentElement;
46480
+ function parseReviewPreferences(xml2) {
46481
+ const root = parseXml2(xml2).documentElement;
46127
46482
  return {
46128
46483
  trackFormatting: onOffElement(children2(root, "doNotTrackFormatting")[0]) !== true,
46129
46484
  trackMoves: onOffElement(children2(root, "doNotTrackMoves")[0]) !== true
@@ -46132,8 +46487,8 @@ function parseReviewPreferences(xml) {
46132
46487
  async function applySettingsFlag(zip, name, enabled2) {
46133
46488
  const file = zip.file(SETTINGS_PATH);
46134
46489
  if (!file && !enabled2) return;
46135
- const xml = await file?.async("string") ?? `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:settings xmlns:w="${WORD_NS}"></w:settings>`;
46136
- const doc = parseXml2(xml);
46490
+ const xml2 = await file?.async("string") ?? `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:settings xmlns:w="${WORD_NS}"></w:settings>`;
46491
+ const doc = parseXml2(xml2);
46137
46492
  const root = doc.documentElement;
46138
46493
  for (const element4 of children2(root, name)) root.removeChild(element4);
46139
46494
  if (enabled2) {
@@ -47204,9 +47559,9 @@ function numberRevisionIds(model, reservedMax = -1) {
47204
47559
  });
47205
47560
  return mapDocumentParagraphs(model, paragraph2);
47206
47561
  }
47207
- function maxWordId(xml) {
47562
+ function maxWordId(xml2) {
47208
47563
  let max = -1;
47209
- for (const match of xml?.matchAll(/\bw:id="(\d{1,9})"/g) ?? [])
47564
+ for (const match of xml2?.matchAll(/\bw:id="(\d{1,9})"/g) ?? [])
47210
47565
  max = Math.max(max, Number(match[1]));
47211
47566
  return max;
47212
47567
  }
@@ -48054,12 +48409,12 @@ function parseRawSections(body, blocks) {
48054
48409
 
48055
48410
  // docx/notes.ts
48056
48411
  var skippedTypes = /* @__PURE__ */ new Set(["separator", "continuationSeparator"]);
48057
- function parseNotesPart(xml, kind, parseBlocks) {
48058
- const document = parseXml2(xml);
48059
- const tag = kind === "footnote" ? "footnote" : "endnote";
48412
+ function parseNotesPart(xml2, kind, parseBlocks) {
48413
+ const document = parseXml2(xml2);
48414
+ const tag2 = kind === "footnote" ? "footnote" : "endnote";
48060
48415
  const idPrefix = kind === "footnote" ? "fn" : "en";
48061
48416
  const notes = [];
48062
- for (const element4 of children2(document.documentElement, tag)) {
48417
+ for (const element4 of children2(document.documentElement, tag2)) {
48063
48418
  const type = getW(element4, "type");
48064
48419
  if (type && skippedTypes.has(type)) continue;
48065
48420
  const id = getW(element4, "id");
@@ -48068,8 +48423,8 @@ function parseNotesPart(xml, kind, parseBlocks) {
48068
48423
  }
48069
48424
  return notes;
48070
48425
  }
48071
- function parseFootnoteSeparators(xml, parseBlocks) {
48072
- const root = parseXml2(xml).documentElement;
48426
+ function parseFootnoteSeparators(xml2, parseBlocks) {
48427
+ const root = parseXml2(xml2).documentElement;
48073
48428
  const result = {};
48074
48429
  for (const element4 of children2(root, "footnote")) {
48075
48430
  const type = getW(element4, "type");
@@ -48174,9 +48529,9 @@ var FIELD_MARKUP = /<w:(?:fldSimple|instrText|fldChar)\b/;
48174
48529
  async function readPart(zip, path3) {
48175
48530
  return zip.file(path3)?.async("string");
48176
48531
  }
48177
- function parseSettings(xml) {
48178
- if (!xml) return { evenAndOddHeaders: false, autoHyphenation: false };
48179
- const root = parseXml2(xml).documentElement;
48532
+ function parseSettings(xml2) {
48533
+ if (!xml2) return { evenAndOddHeaders: false, autoHyphenation: false };
48534
+ const root = parseXml2(xml2).documentElement;
48180
48535
  const compatibility = (first2(root, "compat") ? children2(first2(root, "compat"), "compatSetting") : []).find(
48181
48536
  (setting) => getW(setting, "name") === "compatibilityMode" && getW(setting, "uri") === "http://schemas.microsoft.com/office/word"
48182
48537
  );
@@ -48209,11 +48564,11 @@ async function resolveSlots(zip, relationships, refs, cache, fieldMarkup, drawin
48209
48564
  const path3 = resolvePartPath("word/document.xml", relationship2.target);
48210
48565
  let blocks = cache.get(path3);
48211
48566
  if (!blocks) {
48212
- const xml = await readPart(zip, path3);
48213
- if (xml === void 0) continue;
48214
- if (FIELD_MARKUP.test(xml)) fieldMarkup.seen = true;
48567
+ const xml2 = await readPart(zip, path3);
48568
+ if (xml2 === void 0) continue;
48569
+ if (FIELD_MARKUP.test(xml2)) fieldMarkup.seen = true;
48215
48570
  const context = await partContext(zip, path3, drawings);
48216
- const root = parseXml2(xml).documentElement;
48571
+ const root = parseXml2(xml2).documentElement;
48217
48572
  blocks = withParseWarnings(
48218
48573
  sink2,
48219
48574
  () => parseBlocksFromContainer(root, `${path3.replace(/[^a-z0-9]+/gi, "")}-`, context)
@@ -48288,9 +48643,9 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
48288
48643
 
48289
48644
  // docx/glossary.ts
48290
48645
  var GLOSSARY_DOCUMENT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument";
48291
- function parseGlossaryTexts(xml) {
48646
+ function parseGlossaryTexts(xml2) {
48292
48647
  const texts = /* @__PURE__ */ new Map();
48293
- const parts = first2(parseXml2(xml).documentElement, "docParts");
48648
+ const parts = first2(parseXml2(xml2).documentElement, "docParts");
48294
48649
  for (const part of parts ? children2(parts, "docPart") : []) {
48295
48650
  const name = getW(first2(first2(part, "docPartPr"), "name"), "val");
48296
48651
  const paragraph2 = first2(first2(part, "docPartBody"), "p");
@@ -48884,12 +49239,12 @@ var PARAGRAPH_FORMAT_KEYS = [
48884
49239
  "shadingFill"
48885
49240
  ];
48886
49241
  function restoreParagraphFormatting(paragraph2) {
48887
- const xml = paragraph2.formatRevision?.previousParagraphPropertiesXml;
48888
- if (!xml)
49242
+ const xml2 = paragraph2.formatRevision?.previousParagraphPropertiesXml;
49243
+ if (!xml2)
48889
49244
  throw new Error(
48890
49245
  "Cannot reject a paragraph formatting revision without its prior properties snapshot."
48891
49246
  );
48892
- const properties = parsePropertiesSnapshot(xml, "pPr");
49247
+ const properties = parsePropertiesSnapshot(xml2, "pPr");
48893
49248
  if (paragraph2.sourceParagraphPropertiesXml) {
48894
49249
  const current = parsePropertiesSnapshot(paragraph2.sourceParagraphPropertiesXml, "pPr");
48895
49250
  for (const name of ["rPr", "sectPr"]) {
@@ -49608,9 +49963,9 @@ function siteIds(sites) {
49608
49963
  return uniqueName(name) ? `field:${name}` : `field#${legacy.indexOf(site) + 1}`;
49609
49964
  }
49610
49965
  const id = ownId(site);
49611
- const tag = site.control.tag;
49966
+ const tag2 = site.control.tag;
49612
49967
  if (uniqueId(id)) return `control:${id}`;
49613
- if (uniqueTag(tag)) return `tag:${tag}`;
49968
+ if (uniqueTag(tag2)) return `tag:${tag2}`;
49614
49969
  return `control#${controls.indexOf(site) + 1}`;
49615
49970
  });
49616
49971
  }
@@ -51152,6 +51507,7 @@ exports.linkStylesToList = linkStylesToList;
51152
51507
  exports.listFormFields = listFormFields;
51153
51508
  exports.listRevisions = listRevisions;
51154
51509
  exports.loadDocx = loadDocx;
51510
+ exports.mergeDocxSnapshots = mergeDocxSnapshots;
51155
51511
  exports.newChartImage = newChartImage;
51156
51512
  exports.newDocxChart = newDocxChart;
51157
51513
  exports.newShape = newShape;