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
@@ -152,28 +152,28 @@ var MARKUP_SKIPS = [
152
152
  ["<![CDATA[", "]]>"],
153
153
  ["<?", "?>"]
154
154
  ];
155
- function checkXmlLimits(xml, label, limits = {}) {
155
+ function checkXmlLimits(xml2, label, limits = {}) {
156
156
  const maxDepth = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
157
157
  const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
158
158
  let depth = 0;
159
159
  let nodes = 0;
160
- let at = xml.indexOf("<");
160
+ let at = xml2.indexOf("<");
161
161
  while (at !== -1) {
162
- const skip = MARKUP_SKIPS.find(([open]) => xml.startsWith(open, at));
162
+ const skip = MARKUP_SKIPS.find(([open]) => xml2.startsWith(open, at));
163
163
  if (skip) {
164
- const end = xml.indexOf(skip[1], at + skip[0].length);
164
+ const end = xml2.indexOf(skip[1], at + skip[0].length);
165
165
  if (end === -1) return;
166
- at = xml.indexOf("<", end + skip[1].length);
166
+ at = xml2.indexOf("<", end + skip[1].length);
167
167
  continue;
168
168
  }
169
169
  TAG_RE.lastIndex = at;
170
- const match = TAG_RE.exec(xml);
170
+ const match = TAG_RE.exec(xml2);
171
171
  if (!match) {
172
- at = xml.indexOf("<", at + 1);
172
+ at = xml2.indexOf("<", at + 1);
173
173
  continue;
174
174
  }
175
175
  const [, closing, , selfClosing] = match;
176
- at = xml.indexOf("<", at + match[0].length);
176
+ at = xml2.indexOf("<", at + match[0].length);
177
177
  if (closing) {
178
178
  depth--;
179
179
  continue;
@@ -195,11 +195,11 @@ function checkXmlLimits(xml, label, limits = {}) {
195
195
  }
196
196
  var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
197
197
  var crlfDeclarations = /* @__PURE__ */ new WeakSet();
198
- function parseXml(xml, options = {}) {
198
+ function parseXml(xml2, options = {}) {
199
199
  const label = options.label ?? "OOXML";
200
- if (/<!DOCTYPE|<!ENTITY/i.test(xml))
200
+ if (/<!DOCTYPE|<!ENTITY/i.test(xml2))
201
201
  throw new Error(`${label} XML with DTD or entity declarations is not supported`);
202
- checkXmlLimits(xml, label, options.limits);
202
+ checkXmlLimits(xml2, label, options.limits);
203
203
  let parseError = "";
204
204
  let parsed;
205
205
  try {
@@ -207,7 +207,7 @@ function parseXml(xml, options = {}) {
207
207
  onError: (level, message) => {
208
208
  if (level !== "warning" || options.warningsAsErrors) parseError = message;
209
209
  }
210
- }).parseFromString(xml, "application/xml");
210
+ }).parseFromString(xml2, "application/xml");
211
211
  } catch (error) {
212
212
  throw new Error(
213
213
  `Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
@@ -216,12 +216,12 @@ function parseXml(xml, options = {}) {
216
216
  }
217
217
  if (parseError || !parsed.documentElement)
218
218
  throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
219
- if (CRLF_DECLARATION.test(xml)) crlfDeclarations.add(parsed);
219
+ if (CRLF_DECLARATION.test(xml2)) crlfDeclarations.add(parsed);
220
220
  return parsed;
221
221
  }
222
222
  var buildXml = (node) => {
223
- const xml = new XMLSerializer().serializeToString(node);
224
- return crlfDeclarations.has(node) ? xml.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml;
223
+ const xml2 = new XMLSerializer().serializeToString(node);
224
+ return crlfDeclarations.has(node) ? xml2.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml2;
225
225
  };
226
226
  var isElement = (node) => node.nodeType === 1;
227
227
  var elements = (parent) => Array.from(parent.childNodes).filter(isElement);
@@ -236,11 +236,378 @@ function attr(element, local, ns, prefix) {
236
236
  }
237
237
  var relAttr = (element, local) => attr(element, local, NS.r, "r");
238
238
 
239
+ // text/text-diff.ts
240
+ var isLowSurrogate = (text, at) => {
241
+ const code = text.charCodeAt(at);
242
+ return code >= 56320 && code <= 57343;
243
+ };
244
+ function shortestEdit(n, m, same2, maxEdits) {
245
+ const max = Math.min(n + m, maxEdits);
246
+ const offset = max + 1;
247
+ const v = new Int32Array(2 * max + 3);
248
+ const trace = [];
249
+ for (let d = 0; d <= max; d++) {
250
+ for (let k = -d; k <= d; k += 2) {
251
+ const down = k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1];
252
+ let x = down ? v[offset + k + 1] : v[offset + k - 1] + 1;
253
+ let y = x - k;
254
+ while (x < n && y < m && same2(x, y)) {
255
+ x++;
256
+ y++;
257
+ }
258
+ v[offset + k] = x;
259
+ if (x >= n && y >= m) return backtrack(trace, n, m, d);
260
+ }
261
+ trace.push(v.slice(offset - d, offset + d + 1));
262
+ }
263
+ return void 0;
264
+ }
265
+ function backtrack(trace, n, m, d) {
266
+ const edits = [];
267
+ let x = n;
268
+ let y = m;
269
+ for (let step = d; step > 0; step--) {
270
+ const previous = trace[step - 1];
271
+ const at = (k2) => previous[k2 + step - 1];
272
+ const k = x - y;
273
+ const down = k === -step || k !== step && at(k - 1) < at(k + 1);
274
+ const before = down ? k + 1 : k - 1;
275
+ const startX = at(before);
276
+ const startY = startX - before;
277
+ edits.push(down ? [startX, startY, true] : [startX, startY, false]);
278
+ x = startX;
279
+ y = startY;
280
+ }
281
+ return edits.reverse();
282
+ }
283
+ function changesOf(edits) {
284
+ const changes = [];
285
+ for (const [x, y, inserts] of edits) {
286
+ const last = changes.at(-1);
287
+ if (last && last.fromEnd === x && last.toEnd === y) {
288
+ if (inserts) last.toEnd++;
289
+ else last.fromEnd++;
290
+ } else
291
+ changes.push({
292
+ fromStart: x,
293
+ fromEnd: inserts ? x : x + 1,
294
+ toStart: y,
295
+ toEnd: inserts ? y + 1 : y
296
+ });
297
+ }
298
+ return changes;
299
+ }
300
+ function characterChanges(a, b, maxEdits) {
301
+ const edits = shortestEdit(
302
+ a.length,
303
+ b.length,
304
+ (x, y) => a.charCodeAt(x) === b.charCodeAt(y),
305
+ maxEdits
306
+ );
307
+ return edits && changesOf(edits);
308
+ }
309
+ var TOKEN = /[\p{L}\p{N}\p{M}]+|\s+|[\s\S]/gu;
310
+ function tokensOf(text, ids) {
311
+ const tokens = [];
312
+ const starts = [];
313
+ for (const match of text.matchAll(TOKEN)) {
314
+ let id = ids.get(match[0]);
315
+ if (id === void 0) ids.set(match[0], id = ids.size);
316
+ tokens.push(id);
317
+ starts.push(match.index);
318
+ }
319
+ starts.push(text.length);
320
+ return { tokens, starts };
321
+ }
322
+ function tokenChanges(a, b, maxEdits) {
323
+ const ids = /* @__PURE__ */ new Map();
324
+ const from = tokensOf(a, ids);
325
+ const to = tokensOf(b, ids);
326
+ const edits = shortestEdit(
327
+ from.tokens.length,
328
+ to.tokens.length,
329
+ (x, y) => from.tokens[x] === to.tokens[y],
330
+ maxEdits
331
+ );
332
+ if (!edits) return void 0;
333
+ let budget = maxEdits;
334
+ return changesOf(edits).flatMap((stretch) => {
335
+ const change = {
336
+ fromStart: from.starts[stretch.fromStart],
337
+ fromEnd: from.starts[stretch.fromEnd],
338
+ toStart: to.starts[stretch.toStart],
339
+ toEnd: to.starts[stretch.toEnd]
340
+ };
341
+ const inner = change.fromEnd > change.fromStart && change.toEnd > change.toStart ? characterChanges(
342
+ a.slice(change.fromStart, change.fromEnd),
343
+ b.slice(change.toStart, change.toEnd),
344
+ budget
345
+ ) : void 0;
346
+ if (!inner) return [change];
347
+ for (const found of inner)
348
+ budget -= found.fromEnd - found.fromStart + found.toEnd - found.toStart;
349
+ return inner.map((found) => ({
350
+ fromStart: found.fromStart + change.fromStart,
351
+ fromEnd: found.fromEnd + change.fromStart,
352
+ toStart: found.toStart + change.toStart,
353
+ toEnd: found.toEnd + change.toStart
354
+ }));
355
+ });
356
+ }
357
+ function diffText(from, to, maxEdits = 500) {
358
+ let start = 0;
359
+ while (start < from.length && start < to.length && from.charCodeAt(start) === to.charCodeAt(start))
360
+ start++;
361
+ let end = 0;
362
+ while (end < from.length - start && end < to.length - start && from.charCodeAt(from.length - 1 - end) === to.charCodeAt(to.length - 1 - end))
363
+ end++;
364
+ const a = from.slice(start, from.length - end);
365
+ const b = to.slice(start, to.length - end);
366
+ if (!a.length && !b.length) return [];
367
+ const found = a.length && b.length ? characterChanges(a, b, maxEdits) ?? tokenChanges(a, b, maxEdits) : void 0;
368
+ const changes = found ?? [{ fromStart: 0, fromEnd: a.length, toStart: 0, toEnd: b.length }];
369
+ const result = [];
370
+ for (const change of changes) {
371
+ const placed = {
372
+ fromStart: change.fromStart + start,
373
+ fromEnd: change.fromEnd + start,
374
+ toStart: change.toStart + start,
375
+ toEnd: change.toEnd + start
376
+ };
377
+ if (placed.fromStart > 0 && placed.toStart > 0 && (isLowSurrogate(from, placed.fromStart) || isLowSurrogate(to, placed.toStart))) {
378
+ placed.fromStart--;
379
+ placed.toStart--;
380
+ }
381
+ if (isLowSurrogate(from, placed.fromEnd) || isLowSurrogate(to, placed.toEnd)) {
382
+ placed.fromEnd++;
383
+ placed.toEnd++;
384
+ }
385
+ const last = result.at(-1);
386
+ if (last && placed.fromStart <= last.fromEnd) {
387
+ last.fromEnd = Math.max(last.fromEnd, placed.fromEnd);
388
+ last.toEnd = Math.max(last.toEnd, placed.toEnd);
389
+ } else result.push(placed);
390
+ }
391
+ return result;
392
+ }
393
+
394
+ // text/merge-three-way.ts
395
+ function mergeTextThreeWay(base, local, remote) {
396
+ if (local === remote || base === remote) return { status: "merged", text: local };
397
+ if (base === local) return { status: "merged", text: remote };
398
+ if (Math.max(base.length, local.length, remote.length) > 1e6)
399
+ return { status: "unresolved" };
400
+ const changes = (value) => diffText(base, value).map((change) => ({
401
+ start: change.fromStart,
402
+ end: change.fromEnd,
403
+ text: value.slice(change.toStart, change.toEnd)
404
+ }));
405
+ const edits = changes(local);
406
+ for (const next of changes(remote)) {
407
+ if (edits.some(
408
+ (edit) => edit.start === next.start && edit.end === next.end && edit.text === next.text
409
+ ))
410
+ continue;
411
+ if (edits.some((edit) => {
412
+ if (edit.start === edit.end && next.start === next.end) return false;
413
+ if (edit.start === edit.end) return edit.start > next.start && edit.start < next.end;
414
+ if (next.start === next.end) return next.start > edit.start && next.start < edit.end;
415
+ return edit.start < next.end && next.start < edit.end;
416
+ }))
417
+ return { status: "unresolved" };
418
+ edits.push(next);
419
+ }
420
+ edits.sort(
421
+ (a, b) => a.start - b.start || a.end - b.end || (a.text < b.text ? -1 : a.text > b.text ? 1 : 0)
422
+ );
423
+ let text = "", cursor = 0;
424
+ for (const edit of edits) {
425
+ text += base.slice(cursor, edit.start) + edit.text;
426
+ cursor = edit.end;
427
+ }
428
+ return { status: "merged", text: text + base.slice(cursor) };
429
+ }
430
+
431
+ // xml/merge-three-way.ts
432
+ var tag = (node) => `${node.namespaceURI ?? ""}|${node.localName ?? node.tagName}`;
433
+ var xml = (node) => node ? buildXml(node) : void 0;
434
+ function childrenByKey(parent, options, repeated) {
435
+ const result = /* @__PURE__ */ new Map();
436
+ const counts = /* @__PURE__ */ new Map();
437
+ for (const child of elements(parent)) {
438
+ const name = tag(child), explicit = options.keyElement?.(child, parent);
439
+ const index = counts.get(name) ?? 0;
440
+ counts.set(name, index + 1);
441
+ if (!explicit && repeated.has(name) && !options.allowPositional?.(parent))
442
+ throw new Error("Ambiguous repeated elements");
443
+ const key = explicit ? `${name}@${explicit}` : `${name}#${index}`;
444
+ if (result.has(key)) throw new Error("Duplicate element identity");
445
+ result.set(key, child);
446
+ }
447
+ return result;
448
+ }
449
+ function orderKeys(base, local, remote) {
450
+ const same2 = (a, b) => a.length === b.length && a.every((key, index) => key === b[index]);
451
+ if (same2(base, local)) return [...remote];
452
+ if (same2(base, remote) || same2(local, remote)) return [...local];
453
+ const keys = [.../* @__PURE__ */ new Set([...remote, ...local])].sort();
454
+ const edges = new Map(keys.map((key) => [key, /* @__PURE__ */ new Set()]));
455
+ const degree = new Map(keys.map((key) => [key, 0]));
456
+ for (const sequence of [local, remote])
457
+ for (let i = 1; i < sequence.length; i++) {
458
+ const previous = sequence[i - 1], next = sequence[i];
459
+ if (!edges.get(previous).has(next)) {
460
+ edges.get(previous).add(next);
461
+ degree.set(next, degree.get(next) + 1);
462
+ }
463
+ }
464
+ const out = [];
465
+ const ready = keys.filter((key) => degree.get(key) === 0);
466
+ while (ready.length) {
467
+ const next = ready.sort().shift();
468
+ out.push(next);
469
+ for (const key of edges.get(next)) {
470
+ degree.set(key, degree.get(key) - 1);
471
+ if (degree.get(key) === 0) ready.push(key);
472
+ }
473
+ }
474
+ return out.length === keys.length ? out : void 0;
475
+ }
476
+ function mergeXmlThreeWay(baseXml, localXml, remoteXml, options = {}) {
477
+ if (localXml === remoteXml || baseXml === remoteXml) return { status: "merged", xml: localXml };
478
+ if (baseXml === localXml) return { status: "merged", xml: remoteXml };
479
+ const issues = [];
480
+ try {
481
+ let merge2 = function(b, l, r, path) {
482
+ const bx = xml(b), lx = xml(l), rx = xml(r);
483
+ if (lx === rx || bx === rx) return l ? copy(l) : void 0;
484
+ if (bx === lx) return r ? copy(r) : void 0;
485
+ if (!b && l && r && tag(l) === tag(r) && !elements(l).length && !elements(r).length) {
486
+ const resolved = options.resolveText?.(r, l, r);
487
+ if (resolved !== void 0) {
488
+ const node = copy(r);
489
+ node.textContent = resolved;
490
+ return node;
491
+ }
492
+ }
493
+ if (!b || !l || !r || tag(b) !== tag(l) || tag(b) !== tag(r)) {
494
+ issues.push(`${path}: overlapping structural changes`);
495
+ return void 0;
496
+ }
497
+ const out = remote.createElementNS(r.namespaceURI, r.tagName);
498
+ const attrs = (node) => new Map(
499
+ Array.from(node.attributes).map((a) => [
500
+ `${a.namespaceURI ?? ""}|${a.localName ?? a.name}`,
501
+ a
502
+ ])
503
+ );
504
+ const ba = attrs(b), la = attrs(l), ra = attrs(r);
505
+ for (const key of /* @__PURE__ */ new Set([...ba.keys(), ...la.keys(), ...ra.keys()])) {
506
+ const old = ba.get(key)?.value, left = la.get(key)?.value, right = ra.get(key)?.value;
507
+ const value = left === right || right === old ? left : left === old ? right : void 0;
508
+ if (left !== right && left !== old && right !== old) {
509
+ issues.push(`${path}: overlapping attribute ${key}`);
510
+ continue;
511
+ }
512
+ const source = ra.get(key) ?? la.get(key) ?? ba.get(key);
513
+ if (value !== void 0) out.setAttributeNS(source.namespaceURI, source.name, value);
514
+ }
515
+ const lists = [b, l, r].map(elements);
516
+ if (lists.every((list) => list.length === 0)) {
517
+ if ([b, l, r].some(
518
+ (node) => Array.from(node.childNodes).some(
519
+ (child) => child.nodeType !== 3 && child.nodeType !== 4
520
+ )
521
+ )) {
522
+ issues.push(`${path}: non-text leaf content requires explicit preservation`);
523
+ return void 0;
524
+ }
525
+ const texts = [b, l, r].map((node) => node.textContent ?? "");
526
+ const override = options.resolveText?.(b, l, r);
527
+ 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] } : options.allowText?.(b) ? mergeTextThreeWay(texts[0], texts[1], texts[2]) : { status: "unresolved" };
528
+ if (value.status !== "merged") issues.push(`${path}: overlapping text changes`);
529
+ else if (value.text) out.appendChild(remote.createTextNode(value.text));
530
+ return out;
531
+ }
532
+ if ([b, l, r].some(
533
+ (node) => Array.from(node.childNodes).some(
534
+ (child) => child.nodeType !== 1 && (child.nodeType !== 3 || Boolean(child.textContent?.trim()))
535
+ )
536
+ )) {
537
+ issues.push(`${path}: mixed content cannot be matched safely`);
538
+ return void 0;
539
+ }
540
+ const repeated = /* @__PURE__ */ new Set();
541
+ const groups = lists.map((list) => {
542
+ const grouped = /* @__PURE__ */ new Map();
543
+ for (const child of list) {
544
+ const name = tag(child), group = grouped.get(name) ?? [];
545
+ group.push(child);
546
+ grouped.set(name, group);
547
+ if (group.length > 1) repeated.add(name);
548
+ }
549
+ return grouped;
550
+ });
551
+ for (const name of repeated) {
552
+ const rows = groups.map((group) => group.get(name) ?? []);
553
+ if (rows.some((row) => row.some((child) => options.keyElement?.(child, b) !== void 0)))
554
+ continue;
555
+ if (rows.some((row) => row.length !== rows[0].length)) {
556
+ issues.push(`${path}: unkeyed structural changes`);
557
+ return void 0;
558
+ }
559
+ const before = rows[0].map((child) => buildXml(child));
560
+ const known = new Set(before);
561
+ for (const row of rows.slice(1))
562
+ if (row.some((child, i) => {
563
+ const value = buildXml(child);
564
+ return before[i] !== value && known.has(value);
565
+ })) {
566
+ issues.push(`${path}: reordered unkeyed elements`);
567
+ return void 0;
568
+ }
569
+ }
570
+ let maps;
571
+ try {
572
+ maps = [b, l, r].map((parent) => childrenByKey(parent, options, repeated));
573
+ } catch {
574
+ issues.push(`${path}: ambiguous element identities`);
575
+ return void 0;
576
+ }
577
+ const [bm, lm, rm] = maps;
578
+ const merged = /* @__PURE__ */ new Map();
579
+ for (const key of /* @__PURE__ */ new Set([...bm.keys(), ...lm.keys(), ...rm.keys()])) {
580
+ const node = merge2(bm.get(key), lm.get(key), rm.get(key), `${path}/${key}`);
581
+ if (node) merged.set(key, node);
582
+ }
583
+ const surviving = (map) => [...map.keys()].filter((key) => merged.has(key));
584
+ const order = orderKeys(surviving(bm), surviving(lm), surviving(rm));
585
+ if (!order) {
586
+ issues.push(`${path}: incompatible element order`);
587
+ return void 0;
588
+ }
589
+ for (const key of order) out.appendChild(merged.get(key));
590
+ return out;
591
+ };
592
+ var merge = merge2;
593
+ const base = parseXml(baseXml, { warningsAsErrors: true });
594
+ const local = parseXml(localXml, { warningsAsErrors: true });
595
+ const remote = parseXml(remoteXml, { warningsAsErrors: true });
596
+ const copy = (node) => remote.importNode(node, true);
597
+ const root = merge2(base.documentElement, local.documentElement, remote.documentElement, "root");
598
+ if (!root || issues.length) return { status: "unresolved", issues };
599
+ remote.replaceChild(root, remote.documentElement);
600
+ return { status: "merged", xml: buildXml(remote) };
601
+ } catch {
602
+ return { status: "unresolved", issues: ["Invalid or unsupported XML input"] };
603
+ }
604
+ }
605
+
239
606
  // opc/relationships.ts
240
- function parseRelationships(xml) {
607
+ function parseRelationships(xml2) {
241
608
  const map = /* @__PURE__ */ new Map();
242
- if (!xml) return map;
243
- const root = parseXml(xml).documentElement;
609
+ if (!xml2) return map;
610
+ const root = parseXml(xml2).documentElement;
244
611
  for (const node of elements(root)) {
245
612
  if (node.localName !== "Relationship") continue;
246
613
  const id = node.getAttribute("Id");
@@ -287,11 +654,11 @@ var getRelationshipId = (element) => relAttr(element, "id") || void 0;
287
654
 
288
655
  // opc/content-types.ts
289
656
  var escapeAttr2 = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
290
- function parseContentTypes(xml) {
657
+ function parseContentTypes(xml2) {
291
658
  const defaults = /* @__PURE__ */ new Map();
292
659
  const overrides = /* @__PURE__ */ new Map();
293
- if (!xml) return { defaults, overrides };
294
- for (const node of elements(parseXml(xml).documentElement)) {
660
+ if (!xml2) return { defaults, overrides };
661
+ for (const node of elements(parseXml(xml2).documentElement)) {
295
662
  const contentType = node.getAttribute("ContentType");
296
663
  if (!contentType) continue;
297
664
  if (node.localName === "Default") {
@@ -320,9 +687,9 @@ function buildContentTypesXml(types) {
320
687
  ).join("");
321
688
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="${NS.contentTypes}">${defaults}${overrides}</Types>`;
322
689
  }
323
- function ensureContentTypeDefault(xml, extension, contentType) {
324
- const types = parseContentTypes(xml);
325
- if (types.defaults.has(extension.toLowerCase())) return xml ?? buildContentTypesXml(types);
690
+ function ensureContentTypeDefault(xml2, extension, contentType) {
691
+ const types = parseContentTypes(xml2);
692
+ if (types.defaults.has(extension.toLowerCase())) return xml2 ?? buildContentTypesXml(types);
326
693
  types.defaults.set(extension.toLowerCase(), contentType);
327
694
  return buildContentTypesXml(types);
328
695
  }
@@ -332,35 +699,35 @@ var CONTENT_TYPES_PATH = "[Content_Types].xml";
332
699
  var XML_DECLARATION = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
333
700
  var EMPTY_TYPES = `${XML_DECLARATION}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>`;
334
701
  var EMPTY_RELS = `${XML_DECLARATION}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>`;
335
- function attr2(tag, name) {
702
+ function attr2(tag2, name) {
336
703
  const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
337
- const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(tag);
704
+ const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(tag2);
338
705
  return match ? match[1] ?? match[2] : void 0;
339
706
  }
340
707
  async function ensureContentTypeOverride(zip, partName, contentType) {
341
- const xml = await zip.file(CONTENT_TYPES_PATH)?.async("string") ?? EMPTY_TYPES;
708
+ const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string") ?? EMPTY_TYPES;
342
709
  const target = `/${partName}`;
343
- for (const tag of xml.match(/<Override\b[^>]*\/>/g) ?? [])
344
- if (attr2(tag, "PartName") === target) return;
710
+ for (const tag2 of xml2.match(/<Override\b[^>]*\/>/g) ?? [])
711
+ if (attr2(tag2, "PartName") === target) return;
345
712
  const insertion = `<Override PartName="${target}" ContentType="${contentType}"/>`;
346
- zip.file(CONTENT_TYPES_PATH, xml.replace("</Types>", `${insertion}</Types>`));
713
+ zip.file(CONTENT_TYPES_PATH, xml2.replace("</Types>", `${insertion}</Types>`));
347
714
  }
348
715
  async function removeContentTypeOverride(zip, partName) {
349
- const xml = await zip.file(CONTENT_TYPES_PATH)?.async("string");
350
- if (!xml) return;
716
+ const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string");
717
+ if (!xml2) return;
351
718
  const target = `/${partName}`;
352
- const tag = (xml.match(/<Override\b[^>]*\/>/g) ?? []).find(
719
+ const tag2 = (xml2.match(/<Override\b[^>]*\/>/g) ?? []).find(
353
720
  (candidate) => attr2(candidate, "PartName") === target
354
721
  );
355
- if (tag) zip.file(CONTENT_TYPES_PATH, xml.replace(tag, ""));
722
+ if (tag2) zip.file(CONTENT_TYPES_PATH, xml2.replace(tag2, ""));
356
723
  }
357
724
  async function ensureRelationship(zip, relsPath, type, target) {
358
- const xml = await zip.file(relsPath)?.async("string") ?? EMPTY_RELS;
725
+ const xml2 = await zip.file(relsPath)?.async("string") ?? EMPTY_RELS;
359
726
  const used = /* @__PURE__ */ new Set();
360
- for (const tag of xml.match(/<Relationship\b[^>]*\/>/g) ?? []) {
361
- const id2 = attr2(tag, "Id");
727
+ for (const tag2 of xml2.match(/<Relationship\b[^>]*\/>/g) ?? []) {
728
+ const id2 = attr2(tag2, "Id");
362
729
  if (id2) used.add(id2);
363
- if (id2 && attr2(tag, "Type") === type && attr2(tag, "Target") === target) return id2;
730
+ if (id2 && attr2(tag2, "Type") === type && attr2(tag2, "Target") === target) return id2;
364
731
  }
365
732
  const highest = Math.max(
366
733
  0,
@@ -369,128 +736,15 @@ async function ensureRelationship(zip, relsPath, type, target) {
369
736
  let id = `rId${highest + 1}`;
370
737
  if (used.has(id)) id = nextRelationshipId(used);
371
738
  const insertion = `<Relationship Id="${id}" Type="${type}" Target="${target}"/>`;
372
- zip.file(relsPath, xml.replace("</Relationships>", `${insertion}</Relationships>`));
739
+ zip.file(relsPath, xml2.replace("</Relationships>", `${insertion}</Relationships>`));
373
740
  return id;
374
741
  }
375
742
  async function findOfficeDocumentPart(zip) {
376
- const xml = await zip.file("_rels/.rels")?.async("string");
377
- for (const tag of xml?.match(/<Relationship\b[^>]*\/>/g) ?? [])
378
- if (attr2(tag, "Type") === RELATIONSHIP_TYPES.officeDocument) return attr2(tag, "Target");
743
+ const xml2 = await zip.file("_rels/.rels")?.async("string");
744
+ for (const tag2 of xml2?.match(/<Relationship\b[^>]*\/>/g) ?? [])
745
+ if (attr2(tag2, "Type") === RELATIONSHIP_TYPES.officeDocument) return attr2(tag2, "Target");
379
746
  return void 0;
380
747
  }
381
-
382
- // opc/clone-part-graph.ts
383
- function relativePartTarget(basePart, targetPart) {
384
- const base = basePart.split("/").slice(0, -1);
385
- const target = targetPart.split("/");
386
- while (base.length > 0 && base[0] === target[0]) {
387
- base.shift();
388
- target.shift();
389
- }
390
- return [...base.map(() => ".."), ...target].join("/");
391
- }
392
- async function clonePartGraph(options) {
393
- const { zip, sourcePart, targetPart, shouldClone } = options;
394
- const sourceZip = options.sourceZip ?? zip;
395
- const copies = options.copies ?? /* @__PURE__ */ new Map();
396
- copies.set(sourcePart, targetPart);
397
- const types = parseContentTypes(await sourceZip.file("[Content_Types].xml")?.async("string"));
398
- const reserved = new Set(Object.keys(zip.files));
399
- reserved.add(targetPart);
400
- for (const target of copies.values()) reserved.add(target);
401
- const allocate = (source) => {
402
- const match = /^(?<stem>.*?)(?:\d+)?(?<extension>\.[^/.]+)$/u.exec(source);
403
- const stem = match?.groups?.stem ?? source;
404
- const extension = match?.groups?.extension ?? "";
405
- let index = 1;
406
- while (reserved.has(`${stem}${index}${extension}`)) index += 1;
407
- const path = `${stem}${index}${extension}`;
408
- reserved.add(path);
409
- return path;
410
- };
411
- const copyRelationships = async (source, destination) => {
412
- const contentType = contentTypeForPart(types, source);
413
- if (contentType) await ensureContentTypeOverride(zip, destination, contentType);
414
- const xml = await sourceZip.file(relationshipsPartFor(source))?.async("string");
415
- if (!xml) return;
416
- const relationships = parseRelationships(xml);
417
- for (const relationship of relationships.values()) {
418
- if (relationship.mode === "External") continue;
419
- const originalTarget = resolvePartPath(source, relationship.target);
420
- let newTarget = copies.get(originalTarget);
421
- if (!newTarget && shouldClone(relationship, originalTarget)) {
422
- const file = sourceZip.file(originalTarget);
423
- if (!file) throw new Error(`Cannot clone missing package part: ${originalTarget}`);
424
- newTarget = allocate(originalTarget);
425
- copies.set(originalTarget, newTarget);
426
- zip.file(newTarget, await file.async("uint8array"));
427
- await copyRelationships(originalTarget, newTarget);
428
- }
429
- relationship.target = relativePartTarget(destination, newTarget ?? originalTarget);
430
- }
431
- zip.file(relationshipsPartFor(destination), buildRelationshipsXml(relationships));
432
- };
433
- await copyRelationships(sourcePart, targetPart);
434
- return copies;
435
- }
436
-
437
- // opc/safe-href.ts
438
- var SAFE_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]);
439
- function isSafeHyperlinkHref(href) {
440
- const scheme = /^([a-z][a-z0-9+.-]*:)/i.exec(href.trim())?.[1];
441
- return scheme !== void 0 && SAFE_SCHEMES.has(scheme.toLowerCase());
442
- }
443
- var OPEN_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto"]);
444
- var STORE_SCHEMES = /* @__PURE__ */ new Set([...OPEN_SCHEMES, "ftp", "file"]);
445
- var SCRIPT_SCHEMES = /* @__PURE__ */ new Set([
446
- "javascript",
447
- "vbscript",
448
- "livescript",
449
- "jscript",
450
- "mocha",
451
- "data",
452
- "mhtml",
453
- "ms-its",
454
- "mk",
455
- "x-javascript",
456
- "blob"
457
- ]);
458
- var IGNORABLE = new RegExp(
459
- "[\\u0000-\\u0020\\u007f\\u00ad\\u200b-\\u200f\\u202a-\\u202e\\u2060-\\u2064\\ufeff]",
460
- "gu"
461
- );
462
- var CONTROL = new RegExp("[\\u0000-\\u001f\\u007f]", "u");
463
- var SCHEME = /^([a-z][a-z0-9+.-]*):/;
464
- var STORE_ONLY = { store: true, open: false, reason: "not-openable" };
465
- var reject = (reason) => ({
466
- store: false,
467
- open: false,
468
- reason
469
- });
470
- function hyperlinkPolicy(href, options = {}) {
471
- if (typeof href !== "string") return reject("empty");
472
- const trimmed = href.trim();
473
- const normalized = trimmed.replace(IGNORABLE, "").toLowerCase();
474
- if (normalized.length === 0) return reject("empty");
475
- const scheme = SCHEME.exec(normalized)?.[1];
476
- if (scheme !== void 0 && SCRIPT_SCHEMES.has(scheme)) return reject("script-scheme");
477
- if (scheme !== void 0 && !trimmed.toLowerCase().startsWith(`${scheme}:`))
478
- return reject("obfuscated-scheme");
479
- if (CONTROL.test(trimmed)) return reject("control-characters");
480
- if (scheme === void 0) return options.openRelative ? { store: true, open: true } : STORE_ONLY;
481
- if (scheme.length === 1) return STORE_ONLY;
482
- if (OPEN_SCHEMES.has(scheme)) return { store: true, open: true };
483
- if (options.additionalOpenSchemes?.some((allowed) => allowed.toLowerCase() === scheme))
484
- return { store: true, open: true };
485
- if (STORE_SCHEMES.has(scheme)) return STORE_ONLY;
486
- return reject("unsupported-scheme");
487
- }
488
- function isStorableHyperlinkHref(href, options) {
489
- return hyperlinkPolicy(href, options).store;
490
- }
491
- function isOpenableHyperlinkHref(href, options) {
492
- return hyperlinkPolicy(href, options).open;
493
- }
494
748
  var DEFAULT_ZIP_LIMITS = {
495
749
  maxInputBytes: 100 * 1024 * 1024,
496
750
  maxEntries: 1e4,
@@ -713,6 +967,215 @@ async function openZip(input, limits = {}) {
713
967
  return guardZip(await JSZip.loadAsync(bytes), limits);
714
968
  }
715
969
 
970
+ // opc/merge-snapshots.ts
971
+ var equal = (a, b) => a === b || Boolean(a && b && a.length === b.length && a.every((value, index) => value === b[index]));
972
+ var decoder = new TextDecoder("utf-8", { fatal: true });
973
+ var encoder = new TextEncoder();
974
+ function mergeManifest(input) {
975
+ const { path, base, local, remote } = input;
976
+ if (!base || !local || !remote) return void 0;
977
+ if (!path.endsWith(".rels") && path !== "[Content_Types].xml" && path !== "docProps/core.xml")
978
+ return void 0;
979
+ try {
980
+ const result = mergeXmlThreeWay(
981
+ decoder.decode(base),
982
+ decoder.decode(local),
983
+ decoder.decode(remote),
984
+ {
985
+ keyElement: (element) => {
986
+ const attribute = element.localName === "Relationship" ? "Id" : element.localName === "Override" ? "PartName" : element.localName === "Default" ? "Extension" : void 0;
987
+ return attribute ? element.getAttribute(attribute) ?? void 0 : void 0;
988
+ },
989
+ resolveText: (_b, _l, r) => path === "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
990
+ }
991
+ );
992
+ return result.status === "merged" ? { status: "merged", bytes: encoder.encode(result.xml) } : result;
993
+ } catch {
994
+ return { status: "unresolved", issues: [`${path}: invalid metadata XML`] };
995
+ }
996
+ }
997
+ async function mergeOpcSnapshots(baseBytes, localBytes, remoteBytes, options = {}) {
998
+ if (equal(localBytes, remoteBytes) || equal(baseBytes, remoteBytes))
999
+ return { status: "merged", bytes: localBytes.slice() };
1000
+ if (equal(baseBytes, localBytes)) return { status: "merged", bytes: remoteBytes.slice() };
1001
+ try {
1002
+ const [base, local, remote] = await Promise.all([
1003
+ openZip(baseBytes, { label: "Merge" }),
1004
+ openZip(localBytes, { label: "Merge" }),
1005
+ openZip(remoteBytes, { label: "Merge" })
1006
+ ]);
1007
+ const paths = [
1008
+ ...new Set(
1009
+ [base, local, remote].flatMap(
1010
+ (zip) => Object.keys(zip.files).filter((path) => !zip.files[path].dir)
1011
+ )
1012
+ )
1013
+ ].sort();
1014
+ if (paths.some((path) => path.startsWith("_xmlsignatures/")))
1015
+ return {
1016
+ status: "unresolved",
1017
+ issues: ["Signed packages require explicit signature handling before merging"]
1018
+ };
1019
+ const issues = [];
1020
+ for (const path of paths) {
1021
+ const [b, l, r] = await Promise.all(
1022
+ [base, local, remote].map((zip) => zip.file(path)?.async("uint8array"))
1023
+ );
1024
+ let chosen;
1025
+ if (equal(l, r) || equal(b, r)) chosen = l;
1026
+ else if (equal(b, l)) chosen = r;
1027
+ else {
1028
+ const input = {
1029
+ path,
1030
+ ...b ? { base: b } : {},
1031
+ ...l ? { local: l } : {},
1032
+ ...r ? { remote: r } : {}
1033
+ };
1034
+ const result = mergeManifest(input) ?? await options.mergePart?.(input);
1035
+ if (!result || result.status === "unresolved") {
1036
+ issues.push(...result?.issues ?? [`${path}: both versions changed the same part`]);
1037
+ continue;
1038
+ }
1039
+ chosen = result.bytes;
1040
+ }
1041
+ if (chosen) remote.file(path, chosen);
1042
+ else remote.remove(path);
1043
+ }
1044
+ if (issues.length) return { status: "unresolved", issues };
1045
+ for (const path of Object.keys(remote.files).filter((name) => name.endsWith(".rels"))) {
1046
+ const source = path === "_rels/.rels" ? "" : path.replace(/(^|\/)_rels\/([^/]+)\.rels$/u, "$1$2");
1047
+ for (const relation of parseRelationships(
1048
+ await remote.file(path).async("string")
1049
+ ).values()) {
1050
+ if (relation.mode === "External") continue;
1051
+ const target = resolvePartPath(source, relation.target.split("#")[0] ?? "");
1052
+ if (!remote.file(target) && !remote.file(decodeURIComponent(target)))
1053
+ issues.push(`${path}: merged relationship target is missing`);
1054
+ }
1055
+ }
1056
+ if (issues.length) return { status: "unresolved", issues };
1057
+ return {
1058
+ status: "merged",
1059
+ bytes: await remote.generateAsync({ type: "uint8array", compression: "DEFLATE" })
1060
+ };
1061
+ } catch {
1062
+ return { status: "unresolved", issues: ["Invalid or oversized Office package"] };
1063
+ }
1064
+ }
1065
+
1066
+ // opc/clone-part-graph.ts
1067
+ function relativePartTarget(basePart, targetPart) {
1068
+ const base = basePart.split("/").slice(0, -1);
1069
+ const target = targetPart.split("/");
1070
+ while (base.length > 0 && base[0] === target[0]) {
1071
+ base.shift();
1072
+ target.shift();
1073
+ }
1074
+ return [...base.map(() => ".."), ...target].join("/");
1075
+ }
1076
+ async function clonePartGraph(options) {
1077
+ const { zip, sourcePart, targetPart, shouldClone } = options;
1078
+ const sourceZip = options.sourceZip ?? zip;
1079
+ const copies = options.copies ?? /* @__PURE__ */ new Map();
1080
+ copies.set(sourcePart, targetPart);
1081
+ const types = parseContentTypes(await sourceZip.file("[Content_Types].xml")?.async("string"));
1082
+ const reserved = new Set(Object.keys(zip.files));
1083
+ reserved.add(targetPart);
1084
+ for (const target of copies.values()) reserved.add(target);
1085
+ const allocate = (source) => {
1086
+ const match = /^(?<stem>.*?)(?:\d+)?(?<extension>\.[^/.]+)$/u.exec(source);
1087
+ const stem = match?.groups?.stem ?? source;
1088
+ const extension = match?.groups?.extension ?? "";
1089
+ let index = 1;
1090
+ while (reserved.has(`${stem}${index}${extension}`)) index += 1;
1091
+ const path = `${stem}${index}${extension}`;
1092
+ reserved.add(path);
1093
+ return path;
1094
+ };
1095
+ const copyRelationships = async (source, destination) => {
1096
+ const contentType = contentTypeForPart(types, source);
1097
+ if (contentType) await ensureContentTypeOverride(zip, destination, contentType);
1098
+ const xml2 = await sourceZip.file(relationshipsPartFor(source))?.async("string");
1099
+ if (!xml2) return;
1100
+ const relationships = parseRelationships(xml2);
1101
+ for (const relationship of relationships.values()) {
1102
+ if (relationship.mode === "External") continue;
1103
+ const originalTarget = resolvePartPath(source, relationship.target);
1104
+ let newTarget = copies.get(originalTarget);
1105
+ if (!newTarget && shouldClone(relationship, originalTarget)) {
1106
+ const file = sourceZip.file(originalTarget);
1107
+ if (!file) throw new Error(`Cannot clone missing package part: ${originalTarget}`);
1108
+ newTarget = allocate(originalTarget);
1109
+ copies.set(originalTarget, newTarget);
1110
+ zip.file(newTarget, await file.async("uint8array"));
1111
+ await copyRelationships(originalTarget, newTarget);
1112
+ }
1113
+ relationship.target = relativePartTarget(destination, newTarget ?? originalTarget);
1114
+ }
1115
+ zip.file(relationshipsPartFor(destination), buildRelationshipsXml(relationships));
1116
+ };
1117
+ await copyRelationships(sourcePart, targetPart);
1118
+ return copies;
1119
+ }
1120
+
1121
+ // opc/safe-href.ts
1122
+ var SAFE_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]);
1123
+ function isSafeHyperlinkHref(href) {
1124
+ const scheme = /^([a-z][a-z0-9+.-]*:)/i.exec(href.trim())?.[1];
1125
+ return scheme !== void 0 && SAFE_SCHEMES.has(scheme.toLowerCase());
1126
+ }
1127
+ var OPEN_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto"]);
1128
+ var STORE_SCHEMES = /* @__PURE__ */ new Set([...OPEN_SCHEMES, "ftp", "file"]);
1129
+ var SCRIPT_SCHEMES = /* @__PURE__ */ new Set([
1130
+ "javascript",
1131
+ "vbscript",
1132
+ "livescript",
1133
+ "jscript",
1134
+ "mocha",
1135
+ "data",
1136
+ "mhtml",
1137
+ "ms-its",
1138
+ "mk",
1139
+ "x-javascript",
1140
+ "blob"
1141
+ ]);
1142
+ var IGNORABLE = new RegExp(
1143
+ "[\\u0000-\\u0020\\u007f\\u00ad\\u200b-\\u200f\\u202a-\\u202e\\u2060-\\u2064\\ufeff]",
1144
+ "gu"
1145
+ );
1146
+ var CONTROL = new RegExp("[\\u0000-\\u001f\\u007f]", "u");
1147
+ var SCHEME = /^([a-z][a-z0-9+.-]*):/;
1148
+ var STORE_ONLY = { store: true, open: false, reason: "not-openable" };
1149
+ var reject = (reason) => ({
1150
+ store: false,
1151
+ open: false,
1152
+ reason
1153
+ });
1154
+ function hyperlinkPolicy(href, options = {}) {
1155
+ if (typeof href !== "string") return reject("empty");
1156
+ const trimmed = href.trim();
1157
+ const normalized = trimmed.replace(IGNORABLE, "").toLowerCase();
1158
+ if (normalized.length === 0) return reject("empty");
1159
+ const scheme = SCHEME.exec(normalized)?.[1];
1160
+ if (scheme !== void 0 && SCRIPT_SCHEMES.has(scheme)) return reject("script-scheme");
1161
+ if (scheme !== void 0 && !trimmed.toLowerCase().startsWith(`${scheme}:`))
1162
+ return reject("obfuscated-scheme");
1163
+ if (CONTROL.test(trimmed)) return reject("control-characters");
1164
+ if (scheme === void 0) return options.openRelative ? { store: true, open: true } : STORE_ONLY;
1165
+ if (scheme.length === 1) return STORE_ONLY;
1166
+ if (OPEN_SCHEMES.has(scheme)) return { store: true, open: true };
1167
+ if (options.additionalOpenSchemes?.some((allowed) => allowed.toLowerCase() === scheme))
1168
+ return { store: true, open: true };
1169
+ if (STORE_SCHEMES.has(scheme)) return STORE_ONLY;
1170
+ return reject("unsupported-scheme");
1171
+ }
1172
+ function isStorableHyperlinkHref(href, options) {
1173
+ return hyperlinkPolicy(href, options).store;
1174
+ }
1175
+ function isOpenableHyperlinkHref(href, options) {
1176
+ return hyperlinkPolicy(href, options).open;
1177
+ }
1178
+
716
1179
  // opc/embedded-packages.ts
717
1180
  var EMBEDDED_ZIP_LIMITS = {
718
1181
  label: "Embedded",
@@ -765,10 +1228,10 @@ var PROPERTY_CONTENT_TYPES = {
765
1228
 
766
1229
  // opc/properties/patch.ts
767
1230
  var XMLNS = "http://www.w3.org/2000/xmlns/";
768
- function tagEnd(xml, from) {
1231
+ function tagEnd(xml2, from) {
769
1232
  let quote = "";
770
- for (let i = from + 1; i < xml.length; i++) {
771
- const ch = xml[i];
1233
+ for (let i = from + 1; i < xml2.length; i++) {
1234
+ const ch = xml2[i];
772
1235
  if (quote) {
773
1236
  if (ch === quote) quote = "";
774
1237
  } else if (ch === '"' || ch === "'") quote = ch;
@@ -776,24 +1239,24 @@ function tagEnd(xml, from) {
776
1239
  }
777
1240
  throw new Error("Unterminated tag in property part");
778
1241
  }
779
- function skipMarkup(xml, at) {
780
- if (xml.startsWith("<!--", at)) return xml.indexOf("-->", at) + 3;
781
- if (xml.startsWith("<![CDATA[", at)) return xml.indexOf("]]>", at) + 3;
782
- if (xml.startsWith("<?", at)) return xml.indexOf("?>", at) + 2;
1242
+ function skipMarkup(xml2, at) {
1243
+ if (xml2.startsWith("<!--", at)) return xml2.indexOf("-->", at) + 3;
1244
+ if (xml2.startsWith("<![CDATA[", at)) return xml2.indexOf("]]>", at) + 3;
1245
+ if (xml2.startsWith("<?", at)) return xml2.indexOf("?>", at) + 2;
783
1246
  return void 0;
784
1247
  }
785
- function scan(xml) {
1248
+ function scan(xml2) {
786
1249
  let i = 0;
787
1250
  let rootStart = -1;
788
1251
  while (rootStart < 0) {
789
- const lt = xml.indexOf("<", i);
1252
+ const lt = xml2.indexOf("<", i);
790
1253
  if (lt < 0) throw new Error("Property part has no root element");
791
- const skipped = skipMarkup(xml, lt);
1254
+ const skipped = skipMarkup(xml2, lt);
792
1255
  if (skipped !== void 0) i = skipped;
793
1256
  else rootStart = lt;
794
1257
  }
795
- const openEnd = tagEnd(xml, rootStart);
796
- if (xml[openEnd - 2] === "/") {
1258
+ const openEnd = tagEnd(xml2, rootStart);
1259
+ if (xml2[openEnd - 2] === "/") {
797
1260
  const root = {
798
1261
  start: rootStart,
799
1262
  openEnd,
@@ -808,16 +1271,16 @@ function scan(xml) {
808
1271
  let child;
809
1272
  i = openEnd;
810
1273
  for (; ; ) {
811
- const lt = xml.indexOf("<", i);
1274
+ const lt = xml2.indexOf("<", i);
812
1275
  if (lt < 0) throw new Error("Property part root is not closed");
813
- const skipped = skipMarkup(xml, lt);
1276
+ const skipped = skipMarkup(xml2, lt);
814
1277
  if (skipped !== void 0) {
815
1278
  i = skipped;
816
1279
  continue;
817
1280
  }
818
- const end = tagEnd(xml, lt);
1281
+ const end = tagEnd(xml2, lt);
819
1282
  i = end;
820
- if (xml[lt + 1] === "/") {
1283
+ if (xml2[lt + 1] === "/") {
821
1284
  if (depth === 0) {
822
1285
  const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
823
1286
  return { root, children: children2 };
@@ -825,7 +1288,7 @@ function scan(xml) {
825
1288
  depth--;
826
1289
  if (depth === 0 && child)
827
1290
  children2.push({ ...child, closeStart: lt, end, selfClosing: false });
828
- } else if (xml[end - 2] === "/") {
1291
+ } else if (xml2[end - 2] === "/") {
829
1292
  if (depth === 0)
830
1293
  children2.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
831
1294
  } else {
@@ -835,11 +1298,11 @@ function scan(xml) {
835
1298
  }
836
1299
  }
837
1300
  var escapeText = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\r/g, "&#xD;");
838
- var qualifiedName = (xml, span) => /^<([^\s/>]+)/.exec(xml.slice(span.start, span.openEnd))?.[1] ?? "";
1301
+ var qualifiedName = (xml2, span) => /^<([^\s/>]+)/.exec(xml2.slice(span.start, span.openEnd))?.[1] ?? "";
839
1302
  var PartPatch = class {
840
- constructor(xml, rootElement) {
841
- this.xml = xml;
842
- const { root, children: children2 } = scan(xml);
1303
+ constructor(xml2, rootElement) {
1304
+ this.xml = xml2;
1305
+ const { root, children: children2 } = scan(xml2);
843
1306
  const kids = elements(rootElement);
844
1307
  if (kids.length !== children2.length) throw new Error("Property part markup is not supported");
845
1308
  kids.forEach((kid, index) => this.spans.set(kid, children2[index]));
@@ -954,10 +1417,10 @@ var FIELDS = [
954
1417
  var CORE_PROPERTY_FIELDS = FIELDS.map(([field]) => field);
955
1418
  var EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
956
1419
  <cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
957
- function parseCoreProperties(xml) {
1420
+ function parseCoreProperties(xml2) {
958
1421
  const out = {};
959
- if (!xml) return out;
960
- const root = parseXml(xml, { label: "core properties" }).documentElement;
1422
+ if (!xml2) return out;
1423
+ const root = parseXml(xml2, { label: "core properties" }).documentElement;
961
1424
  for (const [field, prefix] of FIELDS) {
962
1425
  const text = first(root, field, NS[prefix])?.textContent ?? "";
963
1426
  if (text !== "") out[field] = text;
@@ -966,9 +1429,9 @@ function parseCoreProperties(xml) {
966
1429
  }
967
1430
  var formatW3cdtf = (date) => date.toISOString().replace(/\.\d{3}Z$/, "Z");
968
1431
  function writeCoreProperties(props, sourceXml) {
969
- const xml = sourceXml ?? EMPTY_CORE;
970
- const root = parseXml(xml, { label: "core properties" }).documentElement;
971
- const patch = new PartPatch(xml, root);
1432
+ const xml2 = sourceXml ?? EMPTY_CORE;
1433
+ const root = parseXml(xml2, { label: "core properties" }).documentElement;
1434
+ const patch = new PartPatch(xml2, root);
972
1435
  for (const [field, prefix, isDate] of FIELDS) {
973
1436
  const ns = NS[prefix];
974
1437
  const value = props[field];
@@ -1066,9 +1529,9 @@ function readKnown(root, ns) {
1066
1529
  }
1067
1530
  return out;
1068
1531
  }
1069
- function parseAppProperties(xml) {
1070
- if (!xml) return {};
1071
- const root = parseXml(xml, { label: "app properties" }).documentElement;
1532
+ function parseAppProperties(xml2) {
1533
+ if (!xml2) return {};
1534
+ const root = parseXml(xml2, { label: "app properties" }).documentElement;
1072
1535
  const ns = namespacesOf(root);
1073
1536
  return ns ? readKnown(root, ns) : {};
1074
1537
  }
@@ -1086,11 +1549,11 @@ function content(kind, value, vt) {
1086
1549
  return `<${vt}:vector size="${items.length}" baseType="${baseType}">${items.join("")}</${vt}:vector>`;
1087
1550
  }
1088
1551
  function writeAppProperties(props, sourceXml) {
1089
- const xml = sourceXml ?? EMPTY_APP;
1090
- const root = parseXml(xml, { label: "app properties" }).documentElement;
1552
+ const xml2 = sourceXml ?? EMPTY_APP;
1553
+ const root = parseXml(xml2, { label: "app properties" }).documentElement;
1091
1554
  const ns = namespacesOf(root);
1092
1555
  if (!ns) throw new Error("app properties root is not an extended-properties element");
1093
- const patch = new PartPatch(xml, root);
1556
+ const patch = new PartPatch(xml2, root);
1094
1557
  const prior = readKnown(root, ns);
1095
1558
  const ownPrefix = root.prefix ? `${root.prefix}:` : "";
1096
1559
  FIELDS2.forEach(([field, local, kind], index) => {
@@ -1141,9 +1604,9 @@ function readValue(variant) {
1141
1604
  return void 0;
1142
1605
  }
1143
1606
  }
1144
- function parseCustomProperties(xml) {
1145
- if (!xml) return [];
1146
- const root = parseXml(xml, { label: "custom properties" }).documentElement;
1607
+ function parseCustomProperties(xml2) {
1608
+ if (!xml2) return [];
1609
+ const root = parseXml(xml2, { label: "custom properties" }).documentElement;
1147
1610
  const out = [];
1148
1611
  for (const property of children(root, "property", NS.customProperties)) {
1149
1612
  const name = property.getAttribute("name") ?? "";
@@ -1209,9 +1672,9 @@ function writeCustomProperties(properties) {
1209
1672
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1210
1673
  <Properties xmlns="${NS.customProperties}" xmlns:vt="${NS.vt}">${body}</Properties>`;
1211
1674
  }
1212
- function parseCustomPropertyTexts(xml) {
1213
- if (!xml) return [];
1214
- const root = parseXml(xml, { label: "custom properties" }).documentElement;
1675
+ function parseCustomPropertyTexts(xml2) {
1676
+ if (!xml2) return [];
1677
+ const root = parseXml(xml2, { label: "custom properties" }).documentElement;
1215
1678
  const out = [];
1216
1679
  for (const property of children(root, "property", NS.customProperties)) {
1217
1680
  const name = property.getAttribute("name") ?? "";
@@ -1549,63 +2012,63 @@ function escapeXmlText(value) {
1549
2012
  function isValidBase64(value) {
1550
2013
  return typeof value === "string" && value.length > 0 && /^[A-Za-z0-9+/=\s]+$/.test(value);
1551
2014
  }
1552
- function extractTagAttribute(xml, tagName, attributeName) {
2015
+ function extractTagAttribute(xml2, tagName, attributeName) {
1553
2016
  const pattern = new RegExp(
1554
2017
  `<${tagName}\\b[^>]*\\b${attributeName}="(?<attributeValue>[^"]+)"`,
1555
2018
  "i"
1556
2019
  );
1557
- const match = xml.match(pattern);
2020
+ const match = xml2.match(pattern);
1558
2021
  return match?.groups?.["attributeValue"]?.trim();
1559
2022
  }
1560
2023
  var isNameChar = (c) => c !== void 0 && /[\w.-]/.test(c);
1561
2024
  var isWordChar = (c) => c !== void 0 && /\w/.test(c);
1562
- function matchName(xml, lowerXml, from, lname) {
2025
+ function matchName(xml2, lowerXml, from, lname) {
1563
2026
  let pos = from;
1564
2027
  if (!lowerXml.startsWith(lname, pos)) {
1565
2028
  let end = pos;
1566
- while (isNameChar(xml[end])) end++;
1567
- if (end === pos || xml[end] !== ":") return -1;
2029
+ while (isNameChar(xml2[end])) end++;
2030
+ if (end === pos || xml2[end] !== ":") return -1;
1568
2031
  pos = end + 1;
1569
2032
  if (!lowerXml.startsWith(lname, pos)) return -1;
1570
2033
  }
1571
2034
  return pos + lname.length;
1572
2035
  }
1573
- function findTagText(xml, lowerXml, lname, from) {
1574
- let lt = xml.indexOf("<", from);
2036
+ function findTagText(xml2, lowerXml, lname, from) {
2037
+ let lt = xml2.indexOf("<", from);
1575
2038
  while (lt !== -1) {
1576
- const afterName = matchName(xml, lowerXml, lt + 1, lname);
1577
- if (afterName !== -1 && !isWordChar(xml[afterName])) {
1578
- const gt = xml.indexOf(">", afterName);
2039
+ const afterName = matchName(xml2, lowerXml, lt + 1, lname);
2040
+ if (afterName !== -1 && !isWordChar(xml2[afterName])) {
2041
+ const gt = xml2.indexOf(">", afterName);
1579
2042
  if (gt === -1) return null;
1580
- let close = xml.indexOf("</", gt + 1);
2043
+ let close = xml2.indexOf("</", gt + 1);
1581
2044
  while (close !== -1) {
1582
- const closeEnd = matchName(xml, lowerXml, close + 2, lname);
1583
- if (closeEnd !== -1 && xml[closeEnd] === ">") {
1584
- return { text: xml.slice(gt + 1, close), end: closeEnd + 1 };
2045
+ const closeEnd = matchName(xml2, lowerXml, close + 2, lname);
2046
+ if (closeEnd !== -1 && xml2[closeEnd] === ">") {
2047
+ return { text: xml2.slice(gt + 1, close), end: closeEnd + 1 };
1585
2048
  }
1586
- close = xml.indexOf("</", close + 2);
2049
+ close = xml2.indexOf("</", close + 2);
1587
2050
  }
1588
2051
  return null;
1589
2052
  }
1590
- lt = xml.indexOf("<", lt + 1);
2053
+ lt = xml2.indexOf("<", lt + 1);
1591
2054
  }
1592
2055
  return null;
1593
2056
  }
1594
- function extractFirstTagText(xml, localName) {
1595
- const found = findTagText(xml, xml.toLowerCase(), localName.toLowerCase(), 0);
2057
+ function extractFirstTagText(xml2, localName) {
2058
+ const found = findTagText(xml2, xml2.toLowerCase(), localName.toLowerCase(), 0);
1596
2059
  return found?.text.replace(/\s+/g, "").trim() || void 0;
1597
2060
  }
1598
- function extractAllTagText(xml, localName) {
2061
+ function extractAllTagText(xml2, localName) {
1599
2062
  const result = [];
1600
- const lowerXml = xml.toLowerCase();
2063
+ const lowerXml = xml2.toLowerCase();
1601
2064
  const lname = localName.toLowerCase();
1602
- let found = findTagText(xml, lowerXml, lname, 0);
2065
+ let found = findTagText(xml2, lowerXml, lname, 0);
1603
2066
  while (found) {
1604
2067
  const value = found.text.replace(/\s+/g, "").trim();
1605
2068
  if (value) {
1606
2069
  result.push(value);
1607
2070
  }
1608
- found = findTagText(xml, lowerXml, lname, found.end);
2071
+ found = findTagText(xml2, lowerXml, lname, found.end);
1609
2072
  }
1610
2073
  return result;
1611
2074
  }
@@ -1776,4 +2239,4 @@ function zlibCompress(data) {
1776
2239
  return zlibSync(data);
1777
2240
  }
1778
2241
 
1779
- export { CORE_PROPERTY_FIELDS, CUSTOM_PROPERTIES_FMTID, DEFAULT_ZIP_LIMITS, PROPERTY_CONTENT_TYPES, PROPERTY_PART_NAMES, RELATIONSHIP_TYPES, STRICT_APP_NAMESPACES, ZipLimitError, allocateCustomPropertyIds, buildContentTypesXml, buildRelationshipsXml, clonePartGraph, contentTypeForPart, customPropertyFromText, declaredEntrySize, ensureContentTypeDefault, ensureContentTypeOverride, ensureRelationship, findOfficeDocumentPart, formatW3cdtf, fromTitleGroups, getRelationshipId, guardZip, hyperlinkPolicy, inflateEntryGuarded, isOpenableHyperlinkHref, isSafeHyperlinkHref, isSafePartName, isStorableHyperlinkHref, listEmbeddedPackages, nextRelationshipId, openZip, parseAppProperties, parseContentTypes, parseCoreProperties, parseCustomProperties, parseCustomPropertyTexts, parseRelationships, relationshipsPartFor, relativePartTarget, removeContentTypeOverride, replaceEmbeddedPackage, replaceTitleGroup, resolvePartPath, signature_exports as signature, streamEntryGuarded, titleGroups, writeAppProperties, writeCoreProperties, writeCustomProperties, zlibCompress };
2242
+ export { CORE_PROPERTY_FIELDS, CUSTOM_PROPERTIES_FMTID, DEFAULT_ZIP_LIMITS, PROPERTY_CONTENT_TYPES, PROPERTY_PART_NAMES, RELATIONSHIP_TYPES, STRICT_APP_NAMESPACES, ZipLimitError, allocateCustomPropertyIds, buildContentTypesXml, buildRelationshipsXml, clonePartGraph, contentTypeForPart, customPropertyFromText, declaredEntrySize, ensureContentTypeDefault, ensureContentTypeOverride, ensureRelationship, findOfficeDocumentPart, formatW3cdtf, fromTitleGroups, getRelationshipId, guardZip, hyperlinkPolicy, inflateEntryGuarded, isOpenableHyperlinkHref, isSafeHyperlinkHref, isSafePartName, isStorableHyperlinkHref, listEmbeddedPackages, mergeOpcSnapshots, nextRelationshipId, openZip, parseAppProperties, parseContentTypes, parseCoreProperties, parseCustomProperties, parseCustomPropertyTexts, parseRelationships, relationshipsPartFor, relativePartTarget, removeContentTypeOverride, replaceEmbeddedPackage, replaceTitleGroup, resolvePartPath, signature_exports as signature, streamEntryGuarded, titleGroups, writeAppProperties, writeCoreProperties, writeCustomProperties, zlibCompress };