ooxml-core 1.32.1 → 1.34.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 (595) hide show
  1. package/dist/PptxHandler-5UDSMCBG.cjs +14 -0
  2. package/dist/PptxHandler-TTRTAQAR.mjs +5 -0
  3. package/dist/PptxHandler-XCYX5DVX.mjs +7 -0
  4. package/dist/{PresentationBuilder-5NFBUP7Y.cjs → PresentationBuilder-HA56ZY23.cjs} +6 -5
  5. package/dist/{PresentationBuilder-S6HXHKEJ.mjs → PresentationBuilder-IVLUEB4K.mjs} +4 -4
  6. package/dist/{PresentationBuilder-3CH5TR4W.mjs → PresentationBuilder-JBTNOIL7.mjs} +3 -2
  7. package/dist/automation/index.cjs +47133 -42384
  8. package/dist/automation/index.mjs +47133 -42384
  9. package/dist/chart/funnel-geometry.d.ts +1 -1
  10. package/dist/chart/funnel-geometry.d.ts.map +1 -1
  11. package/dist/chart/index.cjs +5743 -3820
  12. package/dist/chart/index.mjs +5736 -3821
  13. package/dist/chart/region-map/alias.d.ts +12 -0
  14. package/dist/chart/region-map/alias.d.ts.map +1 -0
  15. package/dist/chart/region-map/cache.d.ts +20 -0
  16. package/dist/chart/region-map/cache.d.ts.map +1 -0
  17. package/dist/chart/region-map/colors.d.ts +4 -0
  18. package/dist/chart/region-map/colors.d.ts.map +1 -0
  19. package/dist/chart/region-map/data.d.ts +45 -0
  20. package/dist/chart/region-map/data.d.ts.map +1 -0
  21. package/dist/chart/region-map/geographic-projection.d.ts +4 -0
  22. package/dist/chart/region-map/geographic-projection.d.ts.map +1 -0
  23. package/dist/chart/region-map/geometry.d.ts +10 -0
  24. package/dist/chart/region-map/geometry.d.ts.map +1 -0
  25. package/dist/chart/region-map/index.cjs +892 -0
  26. package/dist/chart/region-map/index.d.ts +12 -0
  27. package/dist/chart/region-map/index.d.ts.map +1 -0
  28. package/dist/chart/region-map/index.mjs +870 -0
  29. package/dist/chart/region-map/projection.d.ts +19 -0
  30. package/dist/chart/region-map/projection.d.ts.map +1 -0
  31. package/dist/chart/region-map/types.d.ts +39 -0
  32. package/dist/chart/region-map/types.d.ts.map +1 -0
  33. package/dist/chart/region-map/value-color-positions.d.ts +4 -0
  34. package/dist/chart/region-map/value-color-positions.d.ts.map +1 -0
  35. package/dist/chart/region-map/value-colors.d.ts +4 -0
  36. package/dist/chart/region-map/value-colors.d.ts.map +1 -0
  37. package/dist/chart/region-map/world-regions.d.ts +22 -0
  38. package/dist/chart/region-map/world-regions.d.ts.map +1 -0
  39. package/dist/chart/render/chart-3d-camera.d.ts +26 -0
  40. package/dist/chart/render/chart-3d-camera.d.ts.map +1 -0
  41. package/dist/chart/render/chart-3d-layout.d.ts +27 -0
  42. package/dist/chart/render/chart-3d-layout.d.ts.map +1 -0
  43. package/dist/chart/render/chart-3d-marks.d.ts +10 -0
  44. package/dist/chart/render/chart-3d-marks.d.ts.map +1 -0
  45. package/dist/chart/render/chart-3d-mesh.d.ts +32 -0
  46. package/dist/chart/render/chart-3d-mesh.d.ts.map +1 -0
  47. package/dist/chart/render/chart-3d-pie.d.ts +16 -0
  48. package/dist/chart/render/chart-3d-pie.d.ts.map +1 -0
  49. package/dist/chart/render/chart-3d-projection.d.ts +37 -0
  50. package/dist/chart/render/chart-3d-projection.d.ts.map +1 -0
  51. package/dist/chart/render/chart-3d-scene.d.ts +9 -0
  52. package/dist/chart/render/chart-3d-scene.d.ts.map +1 -0
  53. package/dist/chart/render/chart-3d-shading.d.ts +10 -0
  54. package/dist/chart/render/chart-3d-shading.d.ts.map +1 -0
  55. package/dist/chart/render/chart-3d-surface.d.ts +5 -0
  56. package/dist/chart/render/chart-3d-surface.d.ts.map +1 -0
  57. package/dist/chart/render/chart-3d-svg.d.ts +7 -0
  58. package/dist/chart/render/chart-3d-svg.d.ts.map +1 -0
  59. package/dist/chart/render/chart-3d-walls.d.ts +13 -0
  60. package/dist/chart/render/chart-3d-walls.d.ts.map +1 -0
  61. package/dist/chart/render/chart-svg-funnel.d.ts.map +1 -1
  62. package/dist/chart/render/chart-svg-region-map.d.ts +4 -0
  63. package/dist/chart/render/chart-svg-region-map.d.ts.map +1 -0
  64. package/dist/chart/render/chart-svg-text-metrics.d.ts +2 -0
  65. package/dist/chart/render/chart-svg-text-metrics.d.ts.map +1 -1
  66. package/dist/chart/render/chart-svg.d.ts.map +1 -1
  67. package/dist/chart/render/chart-view.d.ts +5 -1
  68. package/dist/chart/render/chart-view.d.ts.map +1 -1
  69. package/dist/chart/render/index.d.ts +5 -0
  70. package/dist/chart/render/index.d.ts.map +1 -1
  71. package/dist/chart/render/render-space.d.ts.map +1 -1
  72. package/dist/chart/render/summary-ex-formatting.d.ts +5 -0
  73. package/dist/chart/render/summary-ex-formatting.d.ts.map +1 -0
  74. package/dist/chart/render/summary-ex-series.d.ts.map +1 -1
  75. package/dist/chart/render/summary-from-chartex.d.ts.map +1 -1
  76. package/dist/chart/render/summary-from-space.d.ts.map +1 -1
  77. package/dist/chart/render/summary.d.ts +5 -1
  78. package/dist/chart/render/summary.d.ts.map +1 -1
  79. package/dist/chunk-2N7RZQLC.mjs +8 -0
  80. package/dist/{chunk-Q6NM64J2.cjs → chunk-A27O7M5X.cjs} +4938 -1083
  81. package/dist/{chunk-4R65YYAD.mjs → chunk-EGBNPVBA.mjs} +6256 -2277
  82. package/dist/{chunk-3H5UAJB3.mjs → chunk-GNGL4BO7.mjs} +935 -568
  83. package/dist/chunk-LSO5SSFX.mjs +112 -0
  84. package/dist/chunk-MB3TYNMV.mjs +28 -0
  85. package/dist/{chunk-N6424WKA.mjs → chunk-MK2IBZU6.mjs} +1 -1
  86. package/dist/{chunk-X6VNUBES.cjs → chunk-PA5ADSTX.cjs} +2124 -1791
  87. package/dist/{chunk-IOTGRLJH.mjs → chunk-RI56PFGL.mjs} +933 -600
  88. package/dist/{chunk-NAWLWKOJ.mjs → chunk-RPJHMPEL.mjs} +2 -2
  89. package/dist/{chunk-UYMSFJQZ.mjs → chunk-TJXK4D4U.mjs} +5 -5
  90. package/dist/{chunk-O7SVHLD7.mjs → chunk-UQMAPY6D.mjs} +4901 -1077
  91. package/dist/{chunk-54S5A5PZ.mjs → chunk-VDUNZTJC.mjs} +36 -1
  92. package/dist/chunk-XF6ZRA2D.cjs +120 -0
  93. package/dist/crypto/index.cjs +23 -15
  94. package/dist/crypto/index.mjs +23 -15
  95. package/dist/diagram/drawing-resolve.d.ts.map +1 -1
  96. package/dist/diagram/drawing-view.d.ts +6 -0
  97. package/dist/diagram/drawing-view.d.ts.map +1 -1
  98. package/dist/diagram/engine/engine-to-result.d.ts.map +1 -1
  99. package/dist/diagram/index.cjs +786 -145
  100. package/dist/diagram/index.d.ts +1 -0
  101. package/dist/diagram/index.d.ts.map +1 -1
  102. package/dist/diagram/index.mjs +783 -147
  103. package/dist/diagram/layout/smartart-layout-types.d.ts +7 -0
  104. package/dist/diagram/layout/smartart-layout-types.d.ts.map +1 -1
  105. package/dist/diagram/layout-preview.d.ts +4 -0
  106. package/dist/diagram/layout-preview.d.ts.map +1 -1
  107. package/dist/diagram/layout-role-style.d.ts +4 -0
  108. package/dist/diagram/layout-role-style.d.ts.map +1 -0
  109. package/dist/diagram/load.d.ts.map +1 -1
  110. package/dist/diagram/picture-layout.d.ts +23 -0
  111. package/dist/diagram/picture-layout.d.ts.map +1 -0
  112. package/dist/diagram/types.d.ts +6 -0
  113. package/dist/diagram/types.d.ts.map +1 -1
  114. package/dist/diagram/write/cache.d.ts +1 -0
  115. package/dist/diagram/write/cache.d.ts.map +1 -1
  116. package/dist/digest/crc32.d.ts +2 -0
  117. package/dist/digest/crc32.d.ts.map +1 -0
  118. package/dist/digest/index.cjs +11 -0
  119. package/dist/digest/index.d.ts +1 -0
  120. package/dist/digest/index.d.ts.map +1 -1
  121. package/dist/digest/index.mjs +11 -1
  122. package/dist/docx/block-parser.d.ts.map +1 -1
  123. package/dist/docx/diagram-cache.d.ts.map +1 -1
  124. package/dist/docx/diagram-save.d.ts.map +1 -1
  125. package/dist/docx/drawing.d.ts.map +1 -1
  126. package/dist/docx/embedded.cjs +1394 -366
  127. package/dist/docx/embedded.mjs +1394 -366
  128. package/dist/docx/find-pattern.d.ts +33 -0
  129. package/dist/docx/find-pattern.d.ts.map +1 -0
  130. package/dist/docx/find-replacement.d.ts +16 -0
  131. package/dist/docx/find-replacement.d.ts.map +1 -0
  132. package/dist/docx/find-syntax.d.ts +13 -0
  133. package/dist/docx/find-syntax.d.ts.map +1 -0
  134. package/dist/docx/find-wildcards.d.ts +8 -0
  135. package/dist/docx/find-wildcards.d.ts.map +1 -0
  136. package/dist/docx/form-field-model.d.ts +39 -0
  137. package/dist/docx/form-field-model.d.ts.map +1 -1
  138. package/dist/docx/index.cjs +6107 -1728
  139. package/dist/docx/index.d.ts +3 -1
  140. package/dist/docx/index.d.ts.map +1 -1
  141. package/dist/docx/index.mjs +6103 -1729
  142. package/dist/docx/inline-model.d.ts +4 -0
  143. package/dist/docx/inline-model.d.ts.map +1 -1
  144. package/dist/docx/layout/adapt-floats.d.ts.map +1 -1
  145. package/dist/docx/layout/adapter.d.ts.map +1 -1
  146. package/dist/docx/layout/floats.d.ts.map +1 -1
  147. package/dist/docx/layout/index.cjs +2338 -554
  148. package/dist/docx/layout/index.mjs +2338 -554
  149. package/dist/docx/layout/input.d.ts +5 -0
  150. package/dist/docx/layout/input.d.ts.map +1 -1
  151. package/dist/docx/layout/result.d.ts +3 -0
  152. package/dist/docx/layout/result.d.ts.map +1 -1
  153. package/dist/docx/load/index.cjs +7593 -1539
  154. package/dist/docx/load/index.mjs +7593 -1539
  155. package/dist/docx/load/legacy-doc/binary-save.d.ts +4 -0
  156. package/dist/docx/load/legacy-doc/binary-save.d.ts.map +1 -0
  157. package/dist/docx/load/legacy-doc/blocks.d.ts +19 -0
  158. package/dist/docx/load/legacy-doc/blocks.d.ts.map +1 -0
  159. package/dist/docx/load/legacy-doc/borders.d.ts +7 -0
  160. package/dist/docx/load/legacy-doc/borders.d.ts.map +1 -0
  161. package/dist/docx/load/legacy-doc/context.d.ts +65 -0
  162. package/dist/docx/load/legacy-doc/context.d.ts.map +1 -0
  163. package/dist/docx/load/legacy-doc/drawing.d.ts +15 -0
  164. package/dist/docx/load/legacy-doc/drawing.d.ts.map +1 -0
  165. package/dist/docx/load/legacy-doc/error.d.ts +5 -0
  166. package/dist/docx/load/legacy-doc/error.d.ts.map +1 -0
  167. package/dist/docx/load/legacy-doc/inline.d.ts +7 -0
  168. package/dist/docx/load/legacy-doc/inline.d.ts.map +1 -0
  169. package/dist/docx/load/legacy-doc/numbering-part.d.ts +3 -0
  170. package/dist/docx/load/legacy-doc/numbering-part.d.ts.map +1 -0
  171. package/dist/docx/load/legacy-doc/package.d.ts +8 -0
  172. package/dist/docx/load/legacy-doc/package.d.ts.map +1 -0
  173. package/dist/docx/load/legacy-doc/para-props.d.ts +6 -0
  174. package/dist/docx/load/legacy-doc/para-props.d.ts.map +1 -0
  175. package/dist/docx/load/legacy-doc/run-props.d.ts +8 -0
  176. package/dist/docx/load/legacy-doc/run-props.d.ts.map +1 -0
  177. package/dist/docx/load/legacy-doc/sections.d.ts +23 -0
  178. package/dist/docx/load/legacy-doc/sections.d.ts.map +1 -0
  179. package/dist/docx/load/legacy-doc/styles-part.d.ts +3 -0
  180. package/dist/docx/load/legacy-doc/styles-part.d.ts.map +1 -0
  181. package/dist/docx/load/legacy-doc/table.d.ts +6 -0
  182. package/dist/docx/load/legacy-doc/table.d.ts.map +1 -0
  183. package/dist/docx/load/legacy-doc/xml.d.ts +21 -0
  184. package/dist/docx/load/legacy-doc/xml.d.ts.map +1 -0
  185. package/dist/docx/load/legacy-doc.d.ts +5 -4
  186. package/dist/docx/load/legacy-doc.d.ts.map +1 -1
  187. package/dist/docx/model-paragraph.d.ts +5 -0
  188. package/dist/docx/model-paragraph.d.ts.map +1 -1
  189. package/dist/docx/model.d.ts +3 -0
  190. package/dist/docx/model.d.ts.map +1 -1
  191. package/dist/docx/numbering-editing.d.ts +11 -1
  192. package/dist/docx/numbering-editing.d.ts.map +1 -1
  193. package/dist/docx/numbering-format.d.ts.map +1 -1
  194. package/dist/docx/numbering-model.d.ts +17 -0
  195. package/dist/docx/numbering-model.d.ts.map +1 -1
  196. package/dist/docx/numbering-package.d.ts +2 -2
  197. package/dist/docx/numbering-package.d.ts.map +1 -1
  198. package/dist/docx/numbering-parse.d.ts +2 -1
  199. package/dist/docx/numbering-parse.d.ts.map +1 -1
  200. package/dist/docx/numbering-picture-save.d.ts +13 -0
  201. package/dist/docx/numbering-picture-save.d.ts.map +1 -0
  202. package/dist/docx/numbering-picture.d.ts +18 -0
  203. package/dist/docx/numbering-picture.d.ts.map +1 -0
  204. package/dist/docx/parse.d.ts.map +1 -1
  205. package/dist/docx/permission-markers.d.ts +19 -0
  206. package/dist/docx/permission-markers.d.ts.map +1 -0
  207. package/dist/docx/permissions.d.ts +11 -0
  208. package/dist/docx/permissions.d.ts.map +1 -0
  209. package/dist/docx/protection-legacy.d.ts +13 -0
  210. package/dist/docx/protection-legacy.d.ts.map +1 -0
  211. package/dist/docx/protection.d.ts +30 -0
  212. package/dist/docx/protection.d.ts.map +1 -0
  213. package/dist/docx/save.d.ts.map +1 -1
  214. package/dist/docx/settings.d.ts +6 -1
  215. package/dist/docx/settings.d.ts.map +1 -1
  216. package/dist/docx/ui/customization.d.ts.map +1 -1
  217. package/dist/docx/ui/edit-restriction.d.ts +53 -0
  218. package/dist/docx/ui/edit-restriction.d.ts.map +1 -0
  219. package/dist/docx/ui/index.cjs +3617 -1097
  220. package/dist/docx/ui/index.d.ts +4 -0
  221. package/dist/docx/ui/index.d.ts.map +1 -1
  222. package/dist/docx/ui/index.mjs +3597 -1098
  223. package/dist/docx/ui/inline-content-schema.d.ts.map +1 -1
  224. package/dist/docx/ui/paragraph-attributes.d.ts.map +1 -1
  225. package/dist/docx/ui/ribbon-action-ids.d.ts +1 -1
  226. package/dist/docx/ui/ribbon-action-ids.d.ts.map +1 -1
  227. package/dist/docx/ui/run-adapter.d.ts.map +1 -1
  228. package/dist/docx/write-drawing.d.ts.map +1 -1
  229. package/dist/docx/write-paragraph.d.ts.map +1 -1
  230. package/dist/drawingml/index.cjs +708 -111
  231. package/dist/drawingml/index.d.ts +7 -0
  232. package/dist/drawingml/index.d.ts.map +1 -1
  233. package/dist/drawingml/index.mjs +698 -113
  234. package/dist/drawingml/picture-artistic.d.ts +14 -0
  235. package/dist/drawingml/picture-artistic.d.ts.map +1 -0
  236. package/dist/drawingml/picture-effects.d.ts +4 -1
  237. package/dist/drawingml/picture-effects.d.ts.map +1 -1
  238. package/dist/drawingml/picture-fill.d.ts.map +1 -1
  239. package/dist/drawingml/picture-hsl-pixels.d.ts +4 -0
  240. package/dist/drawingml/picture-hsl-pixels.d.ts.map +1 -0
  241. package/dist/drawingml/picture-layout.d.ts +25 -0
  242. package/dist/drawingml/picture-layout.d.ts.map +1 -0
  243. package/dist/drawingml/picture-standard-effects.d.ts +15 -0
  244. package/dist/drawingml/picture-standard-effects.d.ts.map +1 -0
  245. package/dist/drawingml/picture-transfer.d.ts +11 -0
  246. package/dist/drawingml/picture-transfer.d.ts.map +1 -0
  247. package/dist/drawingml/raster-image.d.ts +29 -0
  248. package/dist/drawingml/raster-image.d.ts.map +1 -0
  249. package/dist/drawingml/types.d.ts +1 -0
  250. package/dist/drawingml/types.d.ts.map +1 -1
  251. package/dist/drawingml/write-pattern-picture.d.ts.map +1 -1
  252. package/dist/drawingml/write-theme.d.ts +2 -0
  253. package/dist/drawingml/write-theme.d.ts.map +1 -1
  254. package/dist/geometry/index.cjs +38 -0
  255. package/dist/geometry/index.d.ts +1 -0
  256. package/dist/geometry/index.d.ts.map +1 -1
  257. package/dist/geometry/index.mjs +36 -1
  258. package/dist/geometry/picture-tile.d.ts +29 -0
  259. package/dist/geometry/picture-tile.d.ts.map +1 -0
  260. package/dist/index.cjs +15671 -12934
  261. package/dist/index.mjs +15671 -12934
  262. package/dist/pptx/automation/index.cjs +9313 -3688
  263. package/dist/pptx/automation/index.d.ts +40 -6
  264. package/dist/pptx/automation/index.d.ts.map +1 -1
  265. package/dist/pptx/automation/index.mjs +254 -12
  266. package/dist/pptx/automation/schemas/index.cjs +26 -0
  267. package/dist/pptx/automation/schemas/index.d.ts +26 -1
  268. package/dist/pptx/automation/schemas/index.d.ts.map +1 -0
  269. package/dist/pptx/automation/schemas/index.mjs +1 -1
  270. package/dist/pptx/chunks/{elements-mSCZ84Tc.d.ts → elements-f3UbFph-.d.ts} +7 -2
  271. package/dist/pptx/chunks/elements-f3UbFph-.d.ts.map +1 -0
  272. package/dist/pptx/chunks/{index-DnWlmYCy.d.ts → index-BnH2QjYm.d.ts} +4 -4
  273. package/dist/pptx/chunks/{index-DnWlmYCy.d.ts.map → index-BnH2QjYm.d.ts.map} +1 -1
  274. package/dist/pptx/chunks/{index-D-FdgqrP.d.ts → index-Bp-1pGo1.d.ts} +4 -4
  275. package/dist/pptx/chunks/{index-D-FdgqrP.d.ts.map → index-Bp-1pGo1.d.ts.map} +1 -1
  276. package/dist/pptx/chunks/{index-DKybuHPT.d.ts → index-pLLN4OTz.d.ts} +62 -24
  277. package/dist/pptx/chunks/index-pLLN4OTz.d.ts.map +1 -0
  278. package/dist/pptx/chunks/{smart-art-DLumQo90.d.ts → smart-art-CmOrPLLQ.d.ts} +86 -2
  279. package/dist/pptx/chunks/smart-art-CmOrPLLQ.d.ts.map +1 -0
  280. package/dist/pptx/chunks/{text-operations-hyPODwIQ.d.ts → text-operations-D5sgspO6.d.ts} +2 -2
  281. package/dist/pptx/chunks/{text-operations-hyPODwIQ.d.ts.map → text-operations-D5sgspO6.d.ts.map} +1 -1
  282. package/dist/pptx/cli/index.cjs +7477 -2848
  283. package/dist/pptx/cli/index.d.ts +1 -1
  284. package/dist/pptx/cli/index.mjs +6 -6
  285. package/dist/pptx/converter/index.cjs +3895 -503
  286. package/dist/pptx/converter/index.d.ts +1 -1
  287. package/dist/pptx/converter/index.mjs +3 -3
  288. package/dist/pptx/editor/render/custom-show-operations.cjs +133 -0
  289. package/dist/pptx/editor/render/custom-show-operations.d.ts +42 -0
  290. package/dist/pptx/editor/render/custom-show-operations.d.ts.map +1 -0
  291. package/dist/pptx/editor/render/custom-show-operations.mjs +119 -0
  292. package/dist/pptx/editor/render/find-replace.cjs +15 -14
  293. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  294. package/dist/pptx/editor/render/find-replace.mjs +2 -1
  295. package/dist/pptx/editor/render/slide-operations.cjs +9 -8
  296. package/dist/pptx/editor/render/slide-operations.mjs +3 -2
  297. package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
  298. package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
  299. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
  300. package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
  301. package/dist/pptx/index.cjs +8447 -3693
  302. package/dist/pptx/index.d.ts +7 -7
  303. package/dist/pptx/index.mjs +7 -7
  304. package/dist/pptx/node/index.d.ts +1 -1
  305. package/dist/pptx/smartart-layouts/index.d.ts +1 -1
  306. package/dist/pptx/smartart-layouts/index.mjs +2 -2
  307. package/dist/teams/index.cjs +2176 -751
  308. package/dist/teams/index.mjs +2176 -751
  309. package/dist/text/index.cjs +241 -0
  310. package/dist/text/index.d.ts +2 -0
  311. package/dist/text/index.d.ts.map +1 -1
  312. package/dist/text/index.mjs +240 -1
  313. package/dist/text/truetype/parse.d.ts +36 -0
  314. package/dist/text/truetype/parse.d.ts.map +1 -0
  315. package/dist/text/truetype/subset.d.ts +16 -0
  316. package/dist/text/truetype/subset.d.ts.map +1 -0
  317. package/dist/visio/cell-formula.d.ts +5 -1
  318. package/dist/visio/cell-formula.d.ts.map +1 -1
  319. package/dist/visio/collab/index.cjs +3 -1
  320. package/dist/visio/collab/index.mjs +3 -1
  321. package/dist/visio/container-relationships.d.ts +53 -0
  322. package/dist/visio/container-relationships.d.ts.map +1 -0
  323. package/dist/visio/data-connections.d.ts +32 -0
  324. package/dist/visio/data-connections.d.ts.map +1 -0
  325. package/dist/visio/data-recordsets.d.ts +7 -0
  326. package/dist/visio/data-recordsets.d.ts.map +1 -1
  327. package/dist/visio/data-refresh.d.ts +33 -0
  328. package/dist/visio/data-refresh.d.ts.map +1 -0
  329. package/dist/visio/edit-commands.d.ts +6 -1
  330. package/dist/visio/edit-commands.d.ts.map +1 -1
  331. package/dist/visio/edit-connector.d.ts.map +1 -1
  332. package/dist/visio/edit-container-fit.d.ts +32 -0
  333. package/dist/visio/edit-container-fit.d.ts.map +1 -0
  334. package/dist/visio/edit-container-members.d.ts +33 -0
  335. package/dist/visio/edit-container-members.d.ts.map +1 -0
  336. package/dist/visio/edit-container-options.d.ts +33 -0
  337. package/dist/visio/edit-container-options.d.ts.map +1 -0
  338. package/dist/visio/edit-data-commands.d.ts +5 -0
  339. package/dist/visio/edit-data-commands.d.ts.map +1 -1
  340. package/dist/visio/edit-data-parts.d.ts +2 -0
  341. package/dist/visio/edit-data-parts.d.ts.map +1 -1
  342. package/dist/visio/edit-data.d.ts.map +1 -1
  343. package/dist/visio/edit-delete.d.ts.map +1 -1
  344. package/dist/visio/edit-diagram-parts-commands.d.ts +24 -1
  345. package/dist/visio/edit-diagram-parts-commands.d.ts.map +1 -1
  346. package/dist/visio/edit-diagram-parts.d.ts +11 -2
  347. package/dist/visio/edit-diagram-parts.d.ts.map +1 -1
  348. package/dist/visio/edit-geometry.d.ts +4 -1
  349. package/dist/visio/edit-geometry.d.ts.map +1 -1
  350. package/dist/visio/edit-group-resize.d.ts.map +1 -1
  351. package/dist/visio/edit-instance-checks.d.ts.map +1 -1
  352. package/dist/visio/edit-package.d.ts.map +1 -1
  353. package/dist/visio/edit-page-theme-commands.d.ts +26 -0
  354. package/dist/visio/edit-page-theme-commands.d.ts.map +1 -1
  355. package/dist/visio/edit-page-theme-part.d.ts +6 -0
  356. package/dist/visio/edit-page-theme-part.d.ts.map +1 -0
  357. package/dist/visio/edit-page-theme.d.ts +9 -1
  358. package/dist/visio/edit-page-theme.d.ts.map +1 -1
  359. package/dist/visio/edit-picture-adjust.d.ts +32 -0
  360. package/dist/visio/edit-picture-adjust.d.ts.map +1 -0
  361. package/dist/visio/edit-recalculate-index.d.ts +13 -0
  362. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  363. package/dist/visio/edit-recalculate-values.d.ts.map +1 -1
  364. package/dist/visio/edit-recalculate.d.ts.map +1 -1
  365. package/dist/visio/edit-resize-anchor.d.ts.map +1 -1
  366. package/dist/visio/edit-swimlane-commands.d.ts +91 -0
  367. package/dist/visio/edit-swimlane-commands.d.ts.map +1 -0
  368. package/dist/visio/edit-swimlane-layout.d.ts +64 -0
  369. package/dist/visio/edit-swimlane-layout.d.ts.map +1 -0
  370. package/dist/visio/edit-swimlane-ops.d.ts +11 -0
  371. package/dist/visio/edit-swimlane-ops.d.ts.map +1 -0
  372. package/dist/visio/edit-swimlane-shapes.d.ts +42 -0
  373. package/dist/visio/edit-swimlane-shapes.d.ts.map +1 -0
  374. package/dist/visio/edit-swimlane-turn.d.ts +9 -0
  375. package/dist/visio/edit-swimlane-turn.d.ts.map +1 -0
  376. package/dist/visio/edit.d.ts.map +1 -1
  377. package/dist/visio/effects.d.ts +3 -2
  378. package/dist/visio/effects.d.ts.map +1 -1
  379. package/dist/visio/formula-analyze.d.ts +2 -0
  380. package/dist/visio/formula-analyze.d.ts.map +1 -1
  381. package/dist/visio/formula-evaluate.d.ts.map +1 -1
  382. package/dist/visio/formula-master.d.ts +1 -0
  383. package/dist/visio/formula-master.d.ts.map +1 -1
  384. package/dist/visio/geometry.d.ts +2 -1
  385. package/dist/visio/geometry.d.ts.map +1 -1
  386. package/dist/visio/index.cjs +12207 -7779
  387. package/dist/visio/index.d.ts +8 -1
  388. package/dist/visio/index.d.ts.map +1 -1
  389. package/dist/visio/index.mjs +12201 -7780
  390. package/dist/visio/infinite-line.d.ts +17 -0
  391. package/dist/visio/infinite-line.d.ts.map +1 -0
  392. package/dist/visio/media.d.ts +4 -23
  393. package/dist/visio/media.d.ts.map +1 -1
  394. package/dist/visio/model.d.ts +46 -0
  395. package/dist/visio/model.d.ts.map +1 -1
  396. package/dist/visio/package-common.d.ts +1 -1
  397. package/dist/visio/package-common.d.ts.map +1 -1
  398. package/dist/visio/package-kind.d.ts +34 -0
  399. package/dist/visio/package-kind.d.ts.map +1 -0
  400. package/dist/visio/page-theme.d.ts +7 -0
  401. package/dist/visio/page-theme.d.ts.map +1 -1
  402. package/dist/visio/parser.d.ts +2 -2
  403. package/dist/visio/parser.d.ts.map +1 -1
  404. package/dist/visio/shadow.d.ts +2 -1
  405. package/dist/visio/shadow.d.ts.map +1 -1
  406. package/dist/visio/shape-structure.d.ts +19 -3
  407. package/dist/visio/shape-structure.d.ts.map +1 -1
  408. package/dist/visio/shapes.d.ts +7 -1
  409. package/dist/visio/shapes.d.ts.map +1 -1
  410. package/dist/visio/stencil-file.d.ts +2 -2
  411. package/dist/visio/style.d.ts.map +1 -1
  412. package/dist/visio/swimlane-stack.d.ts +65 -0
  413. package/dist/visio/swimlane-stack.d.ts.map +1 -0
  414. package/dist/visio/theme-builtins.d.ts +3 -0
  415. package/dist/visio/theme-builtins.d.ts.map +1 -1
  416. package/dist/visio/theme-effects.d.ts +19 -0
  417. package/dist/visio/theme-effects.d.ts.map +1 -0
  418. package/dist/visio/theme-font.d.ts +13 -0
  419. package/dist/visio/theme-font.d.ts.map +1 -0
  420. package/dist/visio/theme-line.d.ts.map +1 -1
  421. package/dist/visio/theme-write.d.ts.map +1 -1
  422. package/dist/visio/theme.d.ts +7 -0
  423. package/dist/visio/theme.d.ts.map +1 -1
  424. package/dist/visio/ui/data-graphic-config.d.ts +45 -0
  425. package/dist/visio/ui/data-graphic-config.d.ts.map +1 -0
  426. package/dist/visio/ui/data-graphic-rules.d.ts +7 -0
  427. package/dist/visio/ui/data-graphic-rules.d.ts.map +1 -1
  428. package/dist/visio/ui/data-graphics.d.ts +9 -0
  429. package/dist/visio/ui/data-graphics.d.ts.map +1 -1
  430. package/dist/visio/ui/diagram-parts.d.ts +20 -2
  431. package/dist/visio/ui/diagram-parts.d.ts.map +1 -1
  432. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  433. package/dist/visio/ui/guides.d.ts +9 -1
  434. package/dist/visio/ui/guides.d.ts.map +1 -1
  435. package/dist/visio/ui/index.cjs +14266 -10008
  436. package/dist/visio/ui/index.d.ts +4 -0
  437. package/dist/visio/ui/index.d.ts.map +1 -1
  438. package/dist/visio/ui/index.mjs +14231 -10009
  439. package/dist/visio/ui/org-chart.d.ts +75 -0
  440. package/dist/visio/ui/org-chart.d.ts.map +1 -0
  441. package/dist/visio/ui/resize-snap.d.ts +51 -0
  442. package/dist/visio/ui/resize-snap.d.ts.map +1 -0
  443. package/dist/visio/ui/sample-drawing.d.ts +26 -0
  444. package/dist/visio/ui/sample-drawing.d.ts.map +1 -1
  445. package/dist/visio/ui/scene-validation.d.ts.map +1 -1
  446. package/dist/visio/ui/selection-resize.d.ts +2 -2
  447. package/dist/visio/ui/selection-resize.d.ts.map +1 -1
  448. package/dist/visio/ui/shape-resize.d.ts +29 -1
  449. package/dist/visio/ui/shape-resize.d.ts.map +1 -1
  450. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  451. package/dist/visio/ui/swimlane.d.ts +37 -0
  452. package/dist/visio/ui/swimlane.d.ts.map +1 -0
  453. package/dist/visio/ui/templates.d.ts +26 -0
  454. package/dist/visio/ui/templates.d.ts.map +1 -0
  455. package/dist/xlsx/audit/ast-text.d.ts +12 -0
  456. package/dist/xlsx/audit/ast-text.d.ts.map +1 -0
  457. package/dist/xlsx/audit/error-check.d.ts +23 -0
  458. package/dist/xlsx/audit/error-check.d.ts.map +1 -0
  459. package/dist/xlsx/audit/evaluate-steps.d.ts +48 -0
  460. package/dist/xlsx/audit/evaluate-steps.d.ts.map +1 -0
  461. package/dist/xlsx/audit/index.d.ts +6 -0
  462. package/dist/xlsx/audit/index.d.ts.map +1 -0
  463. package/dist/xlsx/audit/trace.d.ts +59 -0
  464. package/dist/xlsx/audit/trace.d.ts.map +1 -0
  465. package/dist/xlsx/audit/watch.d.ts +17 -0
  466. package/dist/xlsx/audit/watch.d.ts.map +1 -0
  467. package/dist/xlsx/edit/cell-values.d.ts.map +1 -1
  468. package/dist/xlsx/edit/chart-ex.d.ts +1 -0
  469. package/dist/xlsx/edit/chart-ex.d.ts.map +1 -1
  470. package/dist/xlsx/edit/filter.d.ts +8 -1
  471. package/dist/xlsx/edit/filter.d.ts.map +1 -1
  472. package/dist/xlsx/edit/index.d.ts +5 -1
  473. package/dist/xlsx/edit/index.d.ts.map +1 -1
  474. package/dist/xlsx/edit/session-calc.d.ts +5 -0
  475. package/dist/xlsx/edit/session-calc.d.ts.map +1 -1
  476. package/dist/xlsx/edit/session.d.ts.map +1 -1
  477. package/dist/xlsx/edit/sort-choices.d.ts +23 -0
  478. package/dist/xlsx/edit/sort-choices.d.ts.map +1 -0
  479. package/dist/xlsx/edit/sort-keys.d.ts +49 -0
  480. package/dist/xlsx/edit/sort-keys.d.ts.map +1 -0
  481. package/dist/xlsx/edit/sort-reapply.d.ts +11 -0
  482. package/dist/xlsx/edit/sort-reapply.d.ts.map +1 -0
  483. package/dist/xlsx/edit/sort.d.ts +14 -12
  484. package/dist/xlsx/edit/sort.d.ts.map +1 -1
  485. package/dist/xlsx/edit/text-columns.d.ts +21 -0
  486. package/dist/xlsx/edit/text-columns.d.ts.map +1 -0
  487. package/dist/xlsx/edit/types.d.ts +10 -5
  488. package/dist/xlsx/edit/types.d.ts.map +1 -1
  489. package/dist/xlsx/edit/view.d.ts +9 -1
  490. package/dist/xlsx/edit/view.d.ts.map +1 -1
  491. package/dist/xlsx/embedded-chart-ex-space.d.ts +18 -0
  492. package/dist/xlsx/embedded-chart-ex-space.d.ts.map +1 -0
  493. package/dist/xlsx/filter-criteria.d.ts +23 -0
  494. package/dist/xlsx/filter-criteria.d.ts.map +1 -0
  495. package/dist/xlsx/filter-dynamic.d.ts +8 -0
  496. package/dist/xlsx/filter-dynamic.d.ts.map +1 -0
  497. package/dist/xlsx/filter-menu.d.ts +49 -0
  498. package/dist/xlsx/filter-menu.d.ts.map +1 -0
  499. package/dist/xlsx/filter-rows.d.ts +4 -4
  500. package/dist/xlsx/filter-rows.d.ts.map +1 -1
  501. package/dist/xlsx/formula/engine-types.d.ts +8 -0
  502. package/dist/xlsx/formula/engine-types.d.ts.map +1 -1
  503. package/dist/xlsx/formula/engine.d.ts.map +1 -1
  504. package/dist/xlsx/index.cjs +7259 -3079
  505. package/dist/xlsx/index.d.ts +5 -0
  506. package/dist/xlsx/index.d.ts.map +1 -1
  507. package/dist/xlsx/index.mjs +7213 -3079
  508. package/dist/xlsx/layout/index.d.ts +1 -0
  509. package/dist/xlsx/layout/index.d.ts.map +1 -1
  510. package/dist/xlsx/layout/split.d.ts +55 -0
  511. package/dist/xlsx/layout/split.d.ts.map +1 -0
  512. package/dist/xlsx/layout/viewport.d.ts +2 -0
  513. package/dist/xlsx/layout/viewport.d.ts.map +1 -1
  514. package/dist/xlsx/load/index.cjs +2170 -688
  515. package/dist/xlsx/load/index.mjs +2170 -688
  516. package/dist/xlsx/model-filter.d.ts +54 -0
  517. package/dist/xlsx/model-filter.d.ts.map +1 -0
  518. package/dist/xlsx/model-sort.d.ts +27 -0
  519. package/dist/xlsx/model-sort.d.ts.map +1 -0
  520. package/dist/xlsx/model.d.ts +81 -4
  521. package/dist/xlsx/model.d.ts.map +1 -1
  522. package/dist/xlsx/read/chart.d.ts.map +1 -1
  523. package/dist/xlsx/read/drawing.d.ts.map +1 -1
  524. package/dist/xlsx/read/filter-columns.d.ts +5 -0
  525. package/dist/xlsx/read/filter-columns.d.ts.map +1 -0
  526. package/dist/xlsx/read/ignored-errors.d.ts +4 -0
  527. package/dist/xlsx/read/ignored-errors.d.ts.map +1 -0
  528. package/dist/xlsx/read/shared-strings.d.ts +5 -3
  529. package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
  530. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  531. package/dist/xlsx/read/sheet-props.d.ts +2 -2
  532. package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
  533. package/dist/xlsx/read/sort-state.d.ts +5 -0
  534. package/dist/xlsx/read/sort-state.d.ts.map +1 -0
  535. package/dist/xlsx/read/tables.d.ts +2 -2
  536. package/dist/xlsx/read/tables.d.ts.map +1 -1
  537. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  538. package/dist/xlsx/sort-lists.d.ts +6 -0
  539. package/dist/xlsx/sort-lists.d.ts.map +1 -0
  540. package/dist/xlsx/ui/audit-state.d.ts +19 -0
  541. package/dist/xlsx/ui/audit-state.d.ts.map +1 -0
  542. package/dist/xlsx/ui/commands/audit.d.ts +3 -0
  543. package/dist/xlsx/ui/commands/audit.d.ts.map +1 -0
  544. package/dist/xlsx/ui/commands/formulas.d.ts.map +1 -1
  545. package/dist/xlsx/ui/commands/i18n/audit.d.ts +3 -0
  546. package/dist/xlsx/ui/commands/i18n/audit.d.ts.map +1 -0
  547. package/dist/xlsx/ui/commands/i18n/filters.d.ts +3 -0
  548. package/dist/xlsx/ui/commands/i18n/filters.d.ts.map +1 -0
  549. package/dist/xlsx/ui/commands/i18n/index.d.ts.map +1 -1
  550. package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
  551. package/dist/xlsx/ui/commands/i18n/ribbon-tabs.d.ts.map +1 -1
  552. package/dist/xlsx/ui/commands/i18n/rules.d.ts.map +1 -1
  553. package/dist/xlsx/ui/commands/i18n/tools.d.ts.map +1 -1
  554. package/dist/xlsx/ui/commands/icons.d.ts.map +1 -1
  555. package/dist/xlsx/ui/commands/sort-filter.d.ts.map +1 -1
  556. package/dist/xlsx/ui/context.d.ts +6 -1
  557. package/dist/xlsx/ui/context.d.ts.map +1 -1
  558. package/dist/xlsx/ui/dialogs/grid-chart.d.ts.map +1 -1
  559. package/dist/xlsx/ui/grid/geometry.d.ts +29 -1
  560. package/dist/xlsx/ui/grid/geometry.d.ts.map +1 -1
  561. package/dist/xlsx/ui/index.cjs +9454 -5323
  562. package/dist/xlsx/ui/index.d.ts +1 -0
  563. package/dist/xlsx/ui/index.d.ts.map +1 -1
  564. package/dist/xlsx/ui/index.mjs +9448 -5324
  565. package/dist/xlsx/ui/ribbon/icon-paths.d.ts.map +1 -1
  566. package/dist/xlsx/ui/ribbon/tabs/review-view.d.ts.map +1 -1
  567. package/dist/xlsx/write/drawing.d.ts.map +1 -1
  568. package/dist/xlsx/write/filter-columns.d.ts +53 -0
  569. package/dist/xlsx/write/filter-columns.d.ts.map +1 -0
  570. package/dist/xlsx/write/ignored-errors.d.ts +3 -0
  571. package/dist/xlsx/write/ignored-errors.d.ts.map +1 -0
  572. package/dist/xlsx/write/shared-strings.d.ts +4 -4
  573. package/dist/xlsx/write/shared-strings.d.ts.map +1 -1
  574. package/dist/xlsx/write/sheet-parts.d.ts.map +1 -1
  575. package/dist/xlsx/write/sheet-props.d.ts +2 -1
  576. package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
  577. package/dist/xlsx/write/smart-art-cache.d.ts.map +1 -1
  578. package/dist/xlsx/write/smart-art.d.ts.map +1 -1
  579. package/dist/xlsx/write/sort-state.d.ts +55 -0
  580. package/dist/xlsx/write/sort-state.d.ts.map +1 -0
  581. package/dist/xlsx/write/table-patch.d.ts +2 -1
  582. package/dist/xlsx/write/table-patch.d.ts.map +1 -1
  583. package/dist/xlsx/write/tables.d.ts +2 -1
  584. package/dist/xlsx/write/tables.d.ts.map +1 -1
  585. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  586. package/dist/xlsx/write/worksheet.d.ts.map +1 -1
  587. package/package.json +7 -2
  588. package/dist/PptxHandler-QY5VL3CY.mjs +0 -7
  589. package/dist/PptxHandler-SJ5ZUIUX.mjs +0 -4
  590. package/dist/PptxHandler-TESZUH66.cjs +0 -13
  591. package/dist/chunk-3GXV5MPC.mjs +0 -41
  592. package/dist/chunk-MHNETXQB.mjs +0 -1
  593. package/dist/pptx/chunks/elements-mSCZ84Tc.d.ts.map +0 -1
  594. package/dist/pptx/chunks/index-DKybuHPT.d.ts.map +0 -1
  595. package/dist/pptx/chunks/smart-art-DLumQo90.d.ts.map +0 -1
@@ -414,8 +414,8 @@ function parseHalfPoints(value) {
414
414
  function parseSignedHalfPoints(value) {
415
415
  if (value === null || value === void 0) return void 0;
416
416
  const text = value.trim();
417
- const integer4 = parseInteger(text);
418
- if (integer4 !== void 0) return halfPoints(integer4);
417
+ const integer5 = parseInteger(text);
418
+ if (integer5 !== void 0) return halfPoints(integer5);
419
419
  const twips3 = universalMeasureToTwips(text);
420
420
  return twips3 === void 0 ? void 0 : halfPoints(Math.sign(twips3) * Math.round(Math.abs(twips3) / 10));
421
421
  }
@@ -1555,37 +1555,271 @@ function resolveDrawingColor(color, theme, options) {
1555
1555
  };
1556
1556
  }
1557
1557
 
1558
- // drawingml/picture-crop.ts
1559
- var SIDES2 = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
1560
- function parsePictureCrop(blipFill) {
1561
- const rect2 = first(blipFill, "srcRect", NS.a);
1562
- if (!rect2) return void 0;
1563
- const result = {};
1564
- for (const [attr3, key] of Object.entries(SIDES2)) {
1565
- const raw2 = rect2.getAttribute(attr3);
1566
- if (raw2 === null || !raw2.trim()) continue;
1567
- const percent = raw2.endsWith("%");
1568
- const value = Number(percent ? raw2.slice(0, -1) : raw2) / (percent ? 100 : 1e5);
1569
- if (Number.isFinite(value)) result[key] = value;
1558
+ // drawingml/picture-artistic.ts
1559
+ var ARTISTIC_PRIMARY_ATTRIBUTE = {
1560
+ artisticBlur: "radius",
1561
+ artisticCement: "crackSpacing",
1562
+ artisticChalkSketch: "pressure",
1563
+ artisticCrisscrossEtching: "pressure",
1564
+ artisticCutout: "numberOfShades",
1565
+ artisticFilmGrain: "grainSize",
1566
+ artisticGlass: "scaling",
1567
+ artisticGlowDiffused: "intensity",
1568
+ artisticGlowEdges: "smoothness",
1569
+ artisticLightScreen: "gridSize",
1570
+ artisticLineDrawing: "pencilSize",
1571
+ artisticMarker: "size",
1572
+ // Spelled "Mosiaic" in the schema; Microsoft's typo is part of the format.
1573
+ artisticMosiaicBubbles: "pressure",
1574
+ artisticPaintBrush: "brushSize",
1575
+ artisticPaintStrokes: "intensity",
1576
+ artisticPastelsSmooth: "scaling",
1577
+ artisticPencilGrayscale: "pencilSize",
1578
+ artisticPencilSketch: "pressure",
1579
+ artisticPhotocopy: "detail",
1580
+ artisticPlasticWrap: "smoothness",
1581
+ artisticTexturizer: "scaling",
1582
+ artisticWatercolorSponge: "brushSize"
1583
+ };
1584
+ function parseArtisticPictureExtension(node) {
1585
+ if (node.namespaceURI !== NS.a || node.localName !== "extLst") return void 0;
1586
+ const found = [];
1587
+ const unhandled = [];
1588
+ const pending2 = [node];
1589
+ while (pending2.length) {
1590
+ const item2 = pending2.pop();
1591
+ if (item2 !== node && !(item2.namespaceURI === NS.a && item2.localName === "ext") && !(item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && (["imgProps", "imgLayer", "imgEffect", "useLocalDpi"].includes(item2.localName) || ARTISTIC_PRIMARY_ATTRIBUTE[item2.localName])))
1592
+ unhandled.push(item2.localName);
1593
+ if (item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && item2.localName.startsWith("artistic"))
1594
+ found.push(item2);
1595
+ pending2.push(...elements(item2));
1596
+ }
1597
+ if (found.length !== 1) return void 0;
1598
+ const effect = found[0];
1599
+ const key = ARTISTIC_PRIMARY_ATTRIBUTE[effect.localName];
1600
+ if (!key) return void 0;
1601
+ const raw2 = key ? effect.getAttribute(key) : null;
1602
+ const n = raw2 === null ? 0 : Number(raw2);
1603
+ if (!Number.isFinite(n)) return void 0;
1604
+ return {
1605
+ kind: "artistic",
1606
+ name: effect.localName,
1607
+ radius: effect.localName === "artisticBlur" ? n : n / 1e3,
1608
+ baked: true,
1609
+ ...unhandled.length ? { unhandled } : {}
1610
+ };
1611
+ }
1612
+
1613
+ // drawingml/write-color.ts
1614
+ var ELEMENTS = {
1615
+ srgb: "srgbClr",
1616
+ scheme: "schemeClr",
1617
+ system: "sysClr",
1618
+ preset: "prstClr",
1619
+ scrgb: "scrgbClr",
1620
+ hsl: "hslClr"
1621
+ };
1622
+ function drawingColorXml(color) {
1623
+ const local = ELEMENTS[color.kind];
1624
+ const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
1625
+ const root = doc.documentElement;
1626
+ if (color.kind === "scrgb" || color.kind === "hsl") {
1627
+ const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
1628
+ const values = color.value.split(",");
1629
+ keys.forEach((key, i) => root.setAttribute(key, values[i] ?? "0"));
1630
+ } else root.setAttribute("val", color.value);
1631
+ if (color.fallback !== void 0 && color.kind === "system")
1632
+ root.setAttribute("lastClr", color.fallback);
1633
+ for (const transform2 of color.transforms) {
1634
+ if (!/^[A-Za-z_][\w.-]*$/.test(transform2.name))
1635
+ throw new Error(`Invalid DrawingML transform ${transform2.name}`);
1636
+ const node = doc.createElementNS(NS.a, `a:${transform2.name}`);
1637
+ if (transform2.value !== "") node.setAttribute("val", transform2.value);
1638
+ root.appendChild(node);
1570
1639
  }
1571
- return result;
1640
+ return buildXml(doc);
1572
1641
  }
1573
- function applyPictureCrop(blipFill, crop) {
1574
- let rect2 = first(blipFill, "srcRect", NS.a);
1575
- if (!rect2 && crop && Object.values(crop).some((value) => value !== void 0)) {
1576
- rect2 = blipFill.ownerDocument.createElementNS(NS.a, "a:srcRect");
1577
- const blip = first(blipFill, "blip", NS.a);
1578
- blipFill.insertBefore(rect2, blip?.nextSibling ?? blipFill.firstChild);
1642
+
1643
+ // drawingml/patch-color.ts
1644
+ function patchDrawingColorIn(container, color) {
1645
+ const old = elements(container).find((node) => parseDrawingColor(node));
1646
+ const before = parseDrawingColorIn(container);
1647
+ if (!old || !before || before.kind !== color.kind) {
1648
+ const next = container.ownerDocument.importNode(
1649
+ parseXml(drawingColorXml(color)).documentElement,
1650
+ true
1651
+ );
1652
+ if (old) container.replaceChild(next, old);
1653
+ else container.insertBefore(next, container.firstChild);
1654
+ return;
1579
1655
  }
1580
- if (!rect2) return;
1581
- for (const [attr3, key] of Object.entries(SIDES2)) {
1582
- const value = crop?.[key];
1583
- if (value === void 0) rect2.removeAttribute(attr3);
1584
- else {
1585
- if (!Number.isFinite(value)) throw new RangeError("Picture crop must be finite");
1586
- rect2.setAttribute(attr3, String(Math.round(value * 1e5)));
1656
+ if (before.value !== color.value) {
1657
+ if (color.kind === "scrgb" || color.kind === "hsl") {
1658
+ const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
1659
+ const values = color.value.split(",");
1660
+ keys.forEach((key, index) => old.setAttribute(key, values[index] ?? "0"));
1661
+ } else old.setAttribute("val", color.value);
1662
+ }
1663
+ if (before.fallback !== color.fallback && color.kind === "system") {
1664
+ if (color.fallback === void 0) old.removeAttribute("lastClr");
1665
+ else old.setAttribute("lastClr", color.fallback);
1666
+ }
1667
+ const originals = elements(old);
1668
+ color.transforms.forEach((transform2, index) => {
1669
+ const source2 = originals[index];
1670
+ if (source2?.localName === transform2.name) {
1671
+ if (before.transforms[index]?.value !== transform2.value) {
1672
+ if (transform2.value === "") source2.removeAttribute("val");
1673
+ else source2.setAttribute("val", transform2.value);
1674
+ }
1675
+ return;
1587
1676
  }
1677
+ if (!/^[A-Za-z_][\w.-]*$/u.test(transform2.name))
1678
+ throw new Error("Invalid DrawingML colour transform");
1679
+ const next = old.ownerDocument.createElementNS(NS.a, `a:${transform2.name}`);
1680
+ if (transform2.value !== "") next.setAttribute("val", transform2.value);
1681
+ if (source2) old.replaceChild(next, source2);
1682
+ else old.appendChild(next);
1683
+ });
1684
+ for (const extra of originals.slice(color.transforms.length)) old.removeChild(extra);
1685
+ }
1686
+
1687
+ // drawingml/picture-standard-effects.ts
1688
+ var attrs = {
1689
+ biLevel: { threshold: "thresh" },
1690
+ alphaRepl: { amount: "a" },
1691
+ alphaBiLevel: { threshold: "thresh" },
1692
+ hsl: { hue: "hue", saturation: "sat", luminance: "lum" },
1693
+ tint: { hue: "hue", amount: "amt" },
1694
+ blur: { radiusEmu: "rad" }
1695
+ };
1696
+ function parseStandardPictureEffect(node) {
1697
+ const name = node.localName;
1698
+ if (![
1699
+ "biLevel",
1700
+ "alphaInv",
1701
+ "alphaCeiling",
1702
+ "alphaFloor",
1703
+ "alphaRepl",
1704
+ "alphaBiLevel",
1705
+ "alphaMod",
1706
+ "duotone",
1707
+ "clrRepl",
1708
+ "clrChange",
1709
+ "hsl",
1710
+ "tint",
1711
+ "blur"
1712
+ ].includes(name))
1713
+ return void 0;
1714
+ const values = {};
1715
+ for (const [key, attribute2] of Object.entries(attrs[name] ?? {})) {
1716
+ const raw2 = node.getAttribute(attribute2);
1717
+ if (raw2 === null) continue;
1718
+ const percent = raw2.endsWith("%");
1719
+ const n = Number(percent ? raw2.slice(0, -1) : raw2) / (key === "hue" ? 6e4 : key === "radiusEmu" ? 1 : percent ? 100 : 1e5);
1720
+ if (!Number.isFinite(n) || key === "hue" && (n < 0 || n >= 360) || key === "threshold" && (n < 0 || n > 1) || key === "radiusEmu" && (!Number.isSafeInteger(n) || n < 0) || ["saturation", "luminance", "amount"].includes(key) && name !== "alphaMod" && (n < (name === "alphaRepl" ? 0 : -1) || n > 1))
1721
+ return void 0;
1722
+ values[key] = n;
1723
+ }
1724
+ if (["biLevel", "alphaBiLevel"].includes(name) && values.threshold === void 0)
1725
+ return void 0;
1726
+ if (name === "alphaRepl" && values.amount === void 0) return void 0;
1727
+ if (name === "alphaMod") {
1728
+ const cont = first(node, "cont", NS.a);
1729
+ const nested = cont ? elements(cont) : [];
1730
+ if (nested.length !== 1 || nested[0]?.localName !== "alphaModFix") return void 0;
1731
+ const raw2 = nested[0].getAttribute("amt") ?? "100000";
1732
+ const n = Number(raw2.endsWith("%") ? raw2.slice(0, -1) : raw2) / (raw2.endsWith("%") ? 100 : 1e5);
1733
+ if (!Number.isFinite(n) || n < 0) return void 0;
1734
+ values.amount = n;
1735
+ }
1736
+ let colors = [];
1737
+ if (name === "duotone") {
1738
+ const candidates = elements(node).filter(
1739
+ (item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
1740
+ );
1741
+ colors = candidates.map((item2) => parseDrawingColor(item2)).filter((item2) => Boolean(item2));
1742
+ if (colors.length !== 2) return void 0;
1588
1743
  }
1744
+ if (name === "clrRepl") {
1745
+ const color = parseDrawingColorIn(node);
1746
+ if (!color) return void 0;
1747
+ colors = [color];
1748
+ }
1749
+ if (name === "clrChange") {
1750
+ const from = parseDrawingColorIn(first(node, "clrFrom", NS.a)), to = parseDrawingColorIn(first(node, "clrTo", NS.a));
1751
+ if (!from || !to) return void 0;
1752
+ colors = [from, to];
1753
+ }
1754
+ if (name === "alphaInv") {
1755
+ const color = parseDrawingColorIn(node);
1756
+ if (color) colors = [color];
1757
+ }
1758
+ return {
1759
+ kind: "standard",
1760
+ name,
1761
+ ...Object.keys(values).length ? { values } : {},
1762
+ ...colors.length ? { colors } : {},
1763
+ ...name === "clrChange" && node.hasAttribute("useA") ? { useAlpha: !["0", "false"].includes(node.getAttribute("useA") ?? "") } : {},
1764
+ ...name === "blur" && node.hasAttribute("grow") ? { grow: !["0", "false"].includes(node.getAttribute("grow") ?? "") } : {}
1765
+ };
1766
+ }
1767
+ function applyStandardPictureEffect(node, effect) {
1768
+ const doc = node.ownerDocument, before = parseStandardPictureEffect(node);
1769
+ for (const [key, value] of Object.entries(effect.values ?? {})) {
1770
+ if (!Number.isFinite(value) || key === "hue" && (value < 0 || value >= 360) || key === "threshold" && (value < 0 || value > 1) || key === "radiusEmu" && (!Number.isSafeInteger(value) || value < 0) || key === "amount" && effect.name === "alphaMod" && value < 0 || ["saturation", "luminance", "amount"].includes(key) && effect.name !== "alphaMod" && (value < (effect.name === "alphaRepl" ? 0 : -1) || value > 1))
1771
+ throw new RangeError("Invalid picture effect values");
1772
+ }
1773
+ const count = effect.colors?.length ?? 0;
1774
+ if (["duotone", "clrChange"].includes(effect.name) && count !== 2 || effect.name === "clrRepl" && count !== 1 || effect.name === "alphaInv" && count > 1)
1775
+ throw new RangeError("Invalid picture effect colours");
1776
+ for (const [key, attribute2] of Object.entries(attrs[effect.name] ?? {})) {
1777
+ const value = effect.values?.[key];
1778
+ if (value === before?.values?.[key]) continue;
1779
+ if (value === void 0) node.removeAttribute(attribute2);
1780
+ else
1781
+ node.setAttribute(
1782
+ attribute2,
1783
+ String(Math.round(value * (key === "hue" ? 6e4 : key === "radiusEmu" ? 1 : 1e5)))
1784
+ );
1785
+ }
1786
+ if (effect.name === "alphaMod" && effect.values?.amount !== before?.values?.amount) {
1787
+ const cont = first(node, "cont", NS.a) ?? doc.createElementNS(NS.a, "a:cont");
1788
+ const fix = first(cont, "alphaModFix", NS.a) ?? doc.createElementNS(NS.a, "a:alphaModFix");
1789
+ fix.setAttribute("amt", String(Math.round((effect.values?.amount ?? 1) * 1e5)));
1790
+ if (!fix.parentNode) cont.appendChild(fix);
1791
+ if (!cont.parentNode) node.appendChild(cont);
1792
+ }
1793
+ if (effect.useAlpha !== before?.useAlpha) {
1794
+ if (effect.useAlpha === void 0) node.removeAttribute("useA");
1795
+ else node.setAttribute("useA", effect.useAlpha ? "1" : "0");
1796
+ }
1797
+ if (effect.grow !== before?.grow) {
1798
+ if (effect.grow === void 0) node.removeAttribute("grow");
1799
+ else node.setAttribute("grow", effect.grow ? "1" : "0");
1800
+ }
1801
+ if (JSON.stringify(effect.colors) !== JSON.stringify(before?.colors)) {
1802
+ if (effect.name === "duotone") {
1803
+ const old = elements(node).filter(
1804
+ (item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
1805
+ );
1806
+ for (let i = 0; i < (effect.colors?.length ?? 0); i++) {
1807
+ const holder = doc.createElementNS(NS.a, "a:holder");
1808
+ if (old[i]) holder.appendChild(doc.importNode(old[i], true));
1809
+ patchDrawingColorIn(holder, effect.colors[i]);
1810
+ const next = elements(holder)[0];
1811
+ if (old[i]) node.replaceChild(next, old[i]);
1812
+ else node.insertBefore(next, first(node, "extLst", NS.a) ?? null);
1813
+ }
1814
+ } else if (effect.name === "clrChange") {
1815
+ for (const [i, name] of ["clrFrom", "clrTo"].entries()) {
1816
+ const holder = first(node, name, NS.a) ?? doc.createElementNS(NS.a, `a:${name}`);
1817
+ if (effect.colors?.[i]) patchDrawingColorIn(holder, effect.colors[i]);
1818
+ if (!holder.parentNode) node.insertBefore(holder, first(node, "extLst", NS.a) ?? null);
1819
+ }
1820
+ } else if (effect.colors?.[0]) patchDrawingColorIn(node, effect.colors[0]);
1821
+ }
1822
+ if (!parseStandardPictureEffect(node)) throw new RangeError("Invalid picture effect values");
1589
1823
  }
1590
1824
 
1591
1825
  // drawingml/picture-effects.ts
@@ -1625,14 +1859,19 @@ function readPictureEffect(name, attribute2) {
1625
1859
  function parsePictureEffects(blip) {
1626
1860
  if (!blip) return [];
1627
1861
  return elements(blip).map((node) => ({
1628
- ...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) : void 0) ?? { kind: "unsupported", name: node.localName },
1862
+ ...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) ?? parseStandardPictureEffect(node) ?? parseArtisticPictureExtension(node) : void 0) ?? { kind: "unsupported", name: node.localName },
1629
1863
  sourceXml: buildXml(node)
1630
1864
  }));
1631
1865
  }
1632
1866
  function applyPictureEffects(blip, effects) {
1633
1867
  if (JSON.stringify(parsePictureEffects(blip)) === JSON.stringify(effects)) return;
1634
1868
  const nodes = effects.map((effect) => {
1635
- const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind;
1869
+ const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind === "artistic" ? "extLst" : effect.kind === "standard" ? effect.name : effect.kind;
1870
+ if (effect.kind === "artistic") {
1871
+ const before = effect.sourceXml ? parseArtisticPictureExtension(parseXml(effect.sourceXml).documentElement) : void 0;
1872
+ if (!effect.baked || !before || before.name !== effect.name || before.radius !== effect.radius)
1873
+ throw new Error("Artistic authoring requires a host-generated baked picture cache");
1874
+ }
1636
1875
  const source2 = effect.sourceXml ? parseXml(effect.sourceXml).documentElement : void 0;
1637
1876
  if (effect.kind === "unsupported" && !source2)
1638
1877
  throw new Error("An unsupported picture effect needs source XML");
@@ -1659,12 +1898,157 @@ function applyPictureEffects(blip, effects) {
1659
1898
  if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
1660
1899
  set2("amt", effect.amount);
1661
1900
  }
1901
+ if (effect.kind === "standard") applyStandardPictureEffect(node, effect);
1662
1902
  return node;
1663
1903
  });
1664
1904
  for (const node of elements(blip)) blip.removeChild(node);
1665
1905
  for (const node of nodes) blip.appendChild(node);
1666
1906
  }
1667
1907
 
1908
+ // drawingml/picture-layout.ts
1909
+ function parsePictureLayout(fill) {
1910
+ const out = {};
1911
+ const rot = fill.getAttribute("rotWithShape");
1912
+ if (rot !== null) out.rotWithShape = rot !== "0" && rot !== "false";
1913
+ const dpi = Number(fill.getAttribute("dpi"));
1914
+ if (fill.hasAttribute("dpi") && Number.isFinite(dpi) && dpi > 0) out.dpi = dpi;
1915
+ const tile = first(fill, "tile", NS.a);
1916
+ if (tile) {
1917
+ const value = {};
1918
+ for (const [key, attr3] of [
1919
+ ["scaleX", "sx"],
1920
+ ["scaleY", "sy"]
1921
+ ]) {
1922
+ const n = picturePercentage(tile.getAttribute(attr3));
1923
+ if (n !== void 0) value[key] = n;
1924
+ }
1925
+ for (const [key, attr3] of [
1926
+ ["offsetXEmu", "tx"],
1927
+ ["offsetYEmu", "ty"]
1928
+ ]) {
1929
+ const raw2 = tile.getAttribute(attr3);
1930
+ const n = raw2 === null ? NaN : Number(raw2);
1931
+ if (Number.isSafeInteger(n)) value[key] = n;
1932
+ }
1933
+ const alignment = tile.getAttribute("algn");
1934
+ if (alignment) value.alignment = alignment;
1935
+ const flip = tile.getAttribute("flip");
1936
+ if (flip && ["none", "x", "y", "xy"].includes(flip))
1937
+ value.flip = flip;
1938
+ out.tile = value;
1939
+ }
1940
+ const rect2 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
1941
+ if (rect2)
1942
+ out.fillRect = {
1943
+ l: picturePercentage(rect2.getAttribute("l")) ?? 0,
1944
+ t: picturePercentage(rect2.getAttribute("t")) ?? 0,
1945
+ r: picturePercentage(rect2.getAttribute("r")) ?? 0,
1946
+ b: picturePercentage(rect2.getAttribute("b")) ?? 0
1947
+ };
1948
+ return out;
1949
+ }
1950
+ function applyPictureLayout(fill, layout2) {
1951
+ const before = parsePictureLayout(fill);
1952
+ const attr3 = (node, name, value, old) => {
1953
+ if (value === old) return;
1954
+ if (value === void 0) node.removeAttribute(name);
1955
+ else node.setAttribute(name, String(value));
1956
+ };
1957
+ if (layout2.rotWithShape !== before.rotWithShape)
1958
+ attr3(
1959
+ fill,
1960
+ "rotWithShape",
1961
+ layout2.rotWithShape === void 0 ? void 0 : layout2.rotWithShape ? "1" : "0",
1962
+ void 0
1963
+ );
1964
+ if (layout2.dpi !== before.dpi) {
1965
+ if (layout2.dpi !== void 0 && (!Number.isSafeInteger(layout2.dpi) || layout2.dpi <= 0))
1966
+ throw new RangeError("Invalid picture DPI");
1967
+ attr3(fill, "dpi", layout2.dpi, void 0);
1968
+ }
1969
+ const make = (parent, name) => {
1970
+ const old = first(parent, name, NS.a);
1971
+ if (old) return old;
1972
+ const node = fill.ownerDocument.createElementNS(NS.a, `a:${name}`);
1973
+ parent.insertBefore(node, first(parent, "extLst", NS.a) ?? null);
1974
+ return node;
1975
+ };
1976
+ if (layout2.tile) {
1977
+ const stretch = first(fill, "stretch", NS.a);
1978
+ if (stretch) fill.removeChild(stretch);
1979
+ const tile = make(fill, "tile");
1980
+ for (const [key, name] of [
1981
+ ["scaleX", "sx"],
1982
+ ["scaleY", "sy"],
1983
+ ["offsetXEmu", "tx"],
1984
+ ["offsetYEmu", "ty"]
1985
+ ]) {
1986
+ const n = layout2.tile[key];
1987
+ if (n !== void 0 && (!Number.isFinite(n) || (name === "sx" || name === "sy" ? n <= 0 : !Number.isSafeInteger(n))))
1988
+ throw new RangeError("Invalid picture tile");
1989
+ if (n !== before.tile?.[key])
1990
+ attr3(
1991
+ tile,
1992
+ name,
1993
+ n === void 0 ? void 0 : Math.round(n * (name === "sx" || name === "sy" ? 1e5 : 1)),
1994
+ void 0
1995
+ );
1996
+ }
1997
+ if (layout2.tile.alignment !== before.tile?.alignment) {
1998
+ if (layout2.tile.alignment && !["tl", "t", "tr", "l", "ctr", "r", "bl", "b", "br"].includes(layout2.tile.alignment))
1999
+ throw new RangeError("Invalid picture tile alignment");
2000
+ attr3(tile, "algn", layout2.tile.alignment, void 0);
2001
+ }
2002
+ if (layout2.tile.flip !== void 0 && !["none", "x", "y", "xy"].includes(layout2.tile.flip))
2003
+ throw new RangeError("Invalid picture tile flip");
2004
+ if (layout2.tile.flip !== before.tile?.flip) attr3(tile, "flip", layout2.tile.flip, void 0);
2005
+ } else if (before.tile || layout2.fillRect) {
2006
+ const tile = first(fill, "tile", NS.a);
2007
+ if (tile) fill.removeChild(tile);
2008
+ const rect2 = make(make(fill, "stretch"), "fillRect");
2009
+ for (const key of ["l", "t", "r", "b"]) {
2010
+ const n = layout2.fillRect?.[key];
2011
+ if (n !== void 0 && !Number.isFinite(n))
2012
+ throw new RangeError("Invalid picture fill rectangle");
2013
+ if (n !== before.fillRect?.[key])
2014
+ attr3(rect2, key, n === void 0 ? void 0 : Math.round(n * 1e5), void 0);
2015
+ }
2016
+ }
2017
+ }
2018
+
2019
+ // drawingml/picture-crop.ts
2020
+ var SIDES2 = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
2021
+ function parsePictureCrop(blipFill) {
2022
+ const rect2 = first(blipFill, "srcRect", NS.a);
2023
+ if (!rect2) return void 0;
2024
+ const result = {};
2025
+ for (const [attr3, key] of Object.entries(SIDES2)) {
2026
+ const raw2 = rect2.getAttribute(attr3);
2027
+ if (raw2 === null || !raw2.trim()) continue;
2028
+ const percent = raw2.endsWith("%");
2029
+ const value = Number(percent ? raw2.slice(0, -1) : raw2) / (percent ? 100 : 1e5);
2030
+ if (Number.isFinite(value)) result[key] = value;
2031
+ }
2032
+ return result;
2033
+ }
2034
+ function applyPictureCrop(blipFill, crop) {
2035
+ let rect2 = first(blipFill, "srcRect", NS.a);
2036
+ if (!rect2 && crop && Object.values(crop).some((value) => value !== void 0)) {
2037
+ rect2 = blipFill.ownerDocument.createElementNS(NS.a, "a:srcRect");
2038
+ const blip = first(blipFill, "blip", NS.a);
2039
+ blipFill.insertBefore(rect2, blip?.nextSibling ?? blipFill.firstChild);
2040
+ }
2041
+ if (!rect2) return;
2042
+ for (const [attr3, key] of Object.entries(SIDES2)) {
2043
+ const value = crop?.[key];
2044
+ if (value === void 0) rect2.removeAttribute(attr3);
2045
+ else {
2046
+ if (!Number.isFinite(value)) throw new RangeError("Picture crop must be finite");
2047
+ rect2.setAttribute(attr3, String(Math.round(value * 1e5)));
2048
+ }
2049
+ }
2050
+ }
2051
+
1668
2052
  // drawingml/picture-fill.ts
1669
2053
  function parseDrawingPictureFill(fill) {
1670
2054
  const blip = first(fill, "blip", NS.a);
@@ -1672,13 +2056,32 @@ function parseDrawingPictureFill(fill) {
1672
2056
  const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
1673
2057
  const crop = parsePictureCrop(fill);
1674
2058
  const effects = parsePictureEffects(blip);
1675
- const tile = first(fill, "tile", NS.a);
1676
- const rect2 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
1677
- const unsupported2 = [
1678
- ...tile ? ["tile"] : [],
1679
- ...rect2 && ["l", "t", "r", "b"].some((key) => Number(rect2.getAttribute(key) ?? 0) !== 0) ? ["fillRect"] : [],
1680
- ...fill.getAttribute("rotWithShape") === "0" || fill.getAttribute("rotWithShape") === "false" ? ["rotWithShape"] : []
1681
- ];
2059
+ const layout2 = parsePictureLayout(fill);
2060
+ const unsupported2 = [];
2061
+ const tile = first(fill, "tile", NS.a), stretch = first(fill, "stretch", NS.a);
2062
+ if (tile && stretch) unsupported2.push("tile/stretch-choice");
2063
+ if (tile) {
2064
+ for (const [attr3, key] of [
2065
+ ["sx", "scaleX"],
2066
+ ["sy", "scaleY"],
2067
+ ["tx", "offsetXEmu"],
2068
+ ["ty", "offsetYEmu"]
2069
+ ])
2070
+ if (tile.hasAttribute(attr3) && (layout2.tile?.[key] === void 0 || (attr3 === "sx" || attr3 === "sy") && layout2.tile[key] <= 0))
2071
+ unsupported2.push(`tile:${attr3}`);
2072
+ if (tile.hasAttribute("algn") && !["tl", "t", "tr", "l", "ctr", "r", "bl", "b", "br"].includes(tile.getAttribute("algn") ?? ""))
2073
+ unsupported2.push("tile:algn");
2074
+ if (tile.hasAttribute("flip") && !layout2.tile?.flip) unsupported2.push("tile:flip");
2075
+ }
2076
+ const rect2 = first(stretch, "fillRect", NS.a);
2077
+ if (rect2)
2078
+ for (const key of ["l", "t", "r", "b"]) {
2079
+ const raw2 = rect2.getAttribute(key);
2080
+ if (raw2 !== null && !/^[-+]?(?:\d+\.?\d*|\.\d+)%?$/.test(raw2))
2081
+ unsupported2.push(`fillRect:${key}`);
2082
+ }
2083
+ if (fill.hasAttribute("rotWithShape") && !["0", "1", "true", "false"].includes(fill.getAttribute("rotWithShape") ?? ""))
2084
+ unsupported2.push("rotWithShape");
1682
2085
  return {
1683
2086
  kind: "picture",
1684
2087
  sourceXml: buildXml(fill),
@@ -1686,6 +2089,7 @@ function parseDrawingPictureFill(fill) {
1686
2089
  ...linkRelId ? { linkRelId } : {},
1687
2090
  ...crop ? { crop } : {},
1688
2091
  ...effects.length ? { effects } : {},
2092
+ ...Object.keys(layout2).length ? { layout: layout2 } : {},
1689
2093
  ...unsupported2.length ? { unsupportedPicture: unsupported2 } : {}
1690
2094
  };
1691
2095
  }
@@ -1817,80 +2221,6 @@ function drawingDashLength(value) {
1817
2221
  return Number.isSafeInteger(number2) && number2 <= 2147483647 ? number2 : void 0;
1818
2222
  }
1819
2223
 
1820
- // drawingml/write-color.ts
1821
- var ELEMENTS = {
1822
- srgb: "srgbClr",
1823
- scheme: "schemeClr",
1824
- system: "sysClr",
1825
- preset: "prstClr",
1826
- scrgb: "scrgbClr",
1827
- hsl: "hslClr"
1828
- };
1829
- function drawingColorXml(color) {
1830
- const local = ELEMENTS[color.kind];
1831
- const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
1832
- const root = doc.documentElement;
1833
- if (color.kind === "scrgb" || color.kind === "hsl") {
1834
- const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
1835
- const values = color.value.split(",");
1836
- keys.forEach((key, i) => root.setAttribute(key, values[i] ?? "0"));
1837
- } else root.setAttribute("val", color.value);
1838
- if (color.fallback !== void 0 && color.kind === "system")
1839
- root.setAttribute("lastClr", color.fallback);
1840
- for (const transform2 of color.transforms) {
1841
- if (!/^[A-Za-z_][\w.-]*$/.test(transform2.name))
1842
- throw new Error(`Invalid DrawingML transform ${transform2.name}`);
1843
- const node = doc.createElementNS(NS.a, `a:${transform2.name}`);
1844
- if (transform2.value !== "") node.setAttribute("val", transform2.value);
1845
- root.appendChild(node);
1846
- }
1847
- return buildXml(doc);
1848
- }
1849
-
1850
- // drawingml/patch-color.ts
1851
- function patchDrawingColorIn(container, color) {
1852
- const old = elements(container).find((node) => parseDrawingColor(node));
1853
- const before = parseDrawingColorIn(container);
1854
- if (!old || !before || before.kind !== color.kind) {
1855
- const next = container.ownerDocument.importNode(
1856
- parseXml(drawingColorXml(color)).documentElement,
1857
- true
1858
- );
1859
- if (old) container.replaceChild(next, old);
1860
- else container.insertBefore(next, container.firstChild);
1861
- return;
1862
- }
1863
- if (before.value !== color.value) {
1864
- if (color.kind === "scrgb" || color.kind === "hsl") {
1865
- const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
1866
- const values = color.value.split(",");
1867
- keys.forEach((key, index) => old.setAttribute(key, values[index] ?? "0"));
1868
- } else old.setAttribute("val", color.value);
1869
- }
1870
- if (before.fallback !== color.fallback && color.kind === "system") {
1871
- if (color.fallback === void 0) old.removeAttribute("lastClr");
1872
- else old.setAttribute("lastClr", color.fallback);
1873
- }
1874
- const originals = elements(old);
1875
- color.transforms.forEach((transform2, index) => {
1876
- const source2 = originals[index];
1877
- if (source2?.localName === transform2.name) {
1878
- if (before.transforms[index]?.value !== transform2.value) {
1879
- if (transform2.value === "") source2.removeAttribute("val");
1880
- else source2.setAttribute("val", transform2.value);
1881
- }
1882
- return;
1883
- }
1884
- if (!/^[A-Za-z_][\w.-]*$/u.test(transform2.name))
1885
- throw new Error("Invalid DrawingML colour transform");
1886
- const next = old.ownerDocument.createElementNS(NS.a, `a:${transform2.name}`);
1887
- if (transform2.value !== "") next.setAttribute("val", transform2.value);
1888
- if (source2) old.replaceChild(next, source2);
1889
- else old.appendChild(next);
1890
- });
1891
- for (const extra of originals.slice(color.transforms.length)) old.removeChild(extra);
1892
- }
1893
-
1894
2224
  // drawingml/write-pattern-picture.ts
1895
2225
  function drawingPatternPictureXml(fill) {
1896
2226
  const name = fill.kind === "pattern" ? "pattFill" : "blipFill";
@@ -1952,7 +2282,8 @@ function drawingPatternPictureXml(fill) {
1952
2282
  applyPictureCrop(root, fill.crop);
1953
2283
  if (fill.effects !== void 0 && JSON.stringify(before?.kind === "picture" ? before.effects ?? [] : []) !== JSON.stringify(fill.effects ?? []))
1954
2284
  applyPictureEffects(blip, fill.effects ?? []);
1955
- if (!fill.sourceXml) {
2285
+ if (fill.layout !== void 0) applyPictureLayout(root, fill.layout);
2286
+ if (!fill.sourceXml && !fill.layout?.tile && !first(root, "stretch", NS.a)) {
1956
2287
  const stretch = doc.createElementNS(NS.a, "a:stretch");
1957
2288
  stretch.appendChild(doc.createElementNS(NS.a, "a:fillRect"));
1958
2289
  root.appendChild(stretch);
@@ -6700,8 +7031,33 @@ function reconcileBookmarks(doc, starts, ends, names, baseNames, nextId) {
6700
7031
  return { starts: keptStarts, ends: keptEnds };
6701
7032
  }
6702
7033
 
7034
+ // docx/permission-markers.ts
7035
+ var setAttribute4 = (element4, local, value) => element4.setAttributeNS(WORD_NS, `w:${local}`, value);
7036
+ var isPermission = (element4) => named2(element4, "permStart") || named2(element4, "permEnd");
7037
+ function changedPermissionMarkers(doc, paragraph2, base, source2, length) {
7038
+ if (!base || JSON.stringify(paragraph2.permissions ?? null) === JSON.stringify(base.permissions ?? null))
7039
+ return void 0;
7040
+ const spans = (list2) => list2?.some((r) => r.fromPrevious || r.toNext);
7041
+ if (spans(paragraph2.permissions) || spans(base.permissions)) return void 0;
7042
+ const drop = new Set(source2.filter(isPermission));
7043
+ const added = [];
7044
+ for (const range of paragraph2.permissions ?? []) {
7045
+ const start = makeW(doc, "permStart");
7046
+ setAttribute4(start, "id", range.id);
7047
+ if (range.group !== void 0) setAttribute4(start, "edGrp", range.group);
7048
+ if (range.user !== void 0) setAttribute4(start, "ed", range.user);
7049
+ const end = makeW(doc, "permEnd");
7050
+ setAttribute4(end, "id", range.id);
7051
+ added.push(
7052
+ { element: start, position: Math.min(range.from, length), source: range.from, opening: true },
7053
+ { element: end, position: Math.min(range.to, length), source: range.to, opening: false }
7054
+ );
7055
+ }
7056
+ return { drop, added };
7057
+ }
7058
+
6703
7059
  // docx/numbering-write.ts
6704
- function setAttribute4(element4, local, value) {
7060
+ function setAttribute5(element4, local, value) {
6705
7061
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
6706
7062
  }
6707
7063
  function sameNumbering(a2, b) {
@@ -6713,16 +7069,16 @@ function writeNumberingProperties(doc, props, paragraph2, base) {
6713
7069
  if (!paragraph2.numbering) return;
6714
7070
  const numPr = makeW(doc, "numPr");
6715
7071
  const ilvl = makeW(doc, "ilvl");
6716
- setAttribute4(ilvl, "val", String(paragraph2.numbering.level));
7072
+ setAttribute5(ilvl, "val", String(paragraph2.numbering.level));
6717
7073
  numPr.appendChild(ilvl);
6718
7074
  const numId = makeW(doc, "numId");
6719
- setAttribute4(numId, "val", String(paragraph2.numbering.numId));
7075
+ setAttribute5(numId, "val", String(paragraph2.numbering.numId));
6720
7076
  numPr.appendChild(numId);
6721
7077
  props.appendChild(numPr);
6722
7078
  }
6723
7079
 
6724
7080
  // docx/write-run-extra.ts
6725
- function setAttribute5(element4, local, value) {
7081
+ function setAttribute6(element4, local, value) {
6726
7082
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
6727
7083
  }
6728
7084
  function removeChildren2(element4, local) {
@@ -6732,7 +7088,7 @@ function setToggle(doc, props, local, value) {
6732
7088
  removeChildren2(props, local);
6733
7089
  if (value === void 0) return;
6734
7090
  const element4 = makeW(doc, local);
6735
- if (!value) setAttribute5(element4, "val", "0");
7091
+ if (!value) setAttribute6(element4, "val", "0");
6736
7092
  props.appendChild(element4);
6737
7093
  }
6738
7094
  function setExtendedRunProperties(doc, props, run2, base) {
@@ -6742,7 +7098,7 @@ function setExtendedRunProperties(doc, props, run2, base) {
6742
7098
  removeChildren2(props, "rStyle");
6743
7099
  if (run2.style) {
6744
7100
  const style = makeW(doc, "rStyle");
6745
- setAttribute5(style, "val", run2.style);
7101
+ setAttribute6(style, "val", run2.style);
6746
7102
  props.insertBefore(style, props.firstChild);
6747
7103
  }
6748
7104
  }
@@ -6759,14 +7115,14 @@ function setExtendedRunProperties(doc, props, run2, base) {
6759
7115
  removeChildren2(props, local);
6760
7116
  if (run2[key] === void 0) continue;
6761
7117
  const element4 = makeW(doc, local);
6762
- setAttribute5(element4, "val", String(run2[key]));
7118
+ setAttribute6(element4, "val", String(run2[key]));
6763
7119
  props.appendChild(element4);
6764
7120
  }
6765
7121
  if (changed("characterSpacingTwips")) {
6766
7122
  removeChildren2(props, "spacing");
6767
7123
  if (run2.characterSpacingTwips !== void 0) {
6768
7124
  const spacing2 = makeW(doc, "spacing");
6769
- setAttribute5(spacing2, "val", String(Math.round(run2.characterSpacingTwips)));
7125
+ setAttribute6(spacing2, "val", String(Math.round(run2.characterSpacingTwips)));
6770
7126
  props.appendChild(spacing2);
6771
7127
  }
6772
7128
  }
@@ -6774,14 +7130,14 @@ function setExtendedRunProperties(doc, props, run2, base) {
6774
7130
  removeChildren2(props, "shd");
6775
7131
  if (run2.shadingFill || run2.shadingThemeFill) {
6776
7132
  const shd = makeW(doc, "shd");
6777
- setAttribute5(shd, "val", "clear");
6778
- setAttribute5(shd, "fill", run2.shadingFill ? run2.shadingFill.replace(/^#/, "") : "auto");
7133
+ setAttribute6(shd, "val", "clear");
7134
+ setAttribute6(shd, "fill", run2.shadingFill ? run2.shadingFill.replace(/^#/, "") : "auto");
6779
7135
  if (run2.shadingThemeFill) {
6780
- setAttribute5(shd, "themeFill", run2.shadingThemeFill.token);
7136
+ setAttribute6(shd, "themeFill", run2.shadingThemeFill.token);
6781
7137
  if (run2.shadingThemeFill.tint !== void 0)
6782
- setAttribute5(shd, "themeFillTint", fractionToThemeByte(run2.shadingThemeFill.tint));
7138
+ setAttribute6(shd, "themeFillTint", fractionToThemeByte(run2.shadingThemeFill.tint));
6783
7139
  if (run2.shadingThemeFill.shade !== void 0)
6784
- setAttribute5(shd, "themeFillShade", fractionToThemeByte(run2.shadingThemeFill.shade));
7140
+ setAttribute6(shd, "themeFillShade", fractionToThemeByte(run2.shadingThemeFill.shade));
6785
7141
  }
6786
7142
  props.appendChild(shd);
6787
7143
  }
@@ -7420,25 +7776,25 @@ function parseCustomGeometry(custom, width, height) {
7420
7776
  const value = (node, name) => operand(node.getAttribute(name), vars);
7421
7777
  for (const node of elements(path3)) {
7422
7778
  if (node.namespaceURI !== NS.a) return void 0;
7423
- const points = children(node, "pt", NS.a).map((point) => ({
7779
+ const points2 = children(node, "pt", NS.a).map((point) => ({
7424
7780
  x: value(point, "x"),
7425
7781
  y: value(point, "y")
7426
7782
  }));
7427
- if (points.some((point) => !Number.isFinite(point.x) || !Number.isFinite(point.y)))
7783
+ if (points2.some((point) => !Number.isFinite(point.x) || !Number.isFinite(point.y)))
7428
7784
  return void 0;
7429
- const [p0, p1, p2] = points;
7785
+ const [p0, p1, p2] = points2;
7430
7786
  switch (node.localName) {
7431
7787
  case "moveTo":
7432
7788
  case "lnTo":
7433
- if (points.length !== 1 || !p0) return void 0;
7789
+ if (points2.length !== 1 || !p0) return void 0;
7434
7790
  commands.push({ op: node.localName === "moveTo" ? "M" : "L", ...p0 });
7435
7791
  break;
7436
7792
  case "quadBezTo":
7437
- if (points.length !== 2 || !p0 || !p1) return void 0;
7793
+ if (points2.length !== 2 || !p0 || !p1) return void 0;
7438
7794
  commands.push({ op: "Q", x1: p0.x, y1: p0.y, ...p1 });
7439
7795
  break;
7440
7796
  case "cubicBezTo":
7441
- if (points.length !== 3 || !p0 || !p1 || !p2) return void 0;
7797
+ if (points2.length !== 3 || !p0 || !p1 || !p2) return void 0;
7442
7798
  commands.push({ op: "C", x1: p0.x, y1: p0.y, x2: p1.x, y2: p1.y, ...p2 });
7443
7799
  break;
7444
7800
  case "arcTo": {
@@ -7684,8 +8040,8 @@ function parseDrawingRunProperties(element4) {
7684
8040
 
7685
8041
  // drawingml/read-paragraph-properties.ts
7686
8042
  function parseDrawingTextSpacing(element4) {
7687
- const points = integerAttribute(first(element4, "spcPts", NS.a), "val");
7688
- if (points !== void 0) return { unit: "points", value: points / 100 };
8043
+ const points2 = integerAttribute(first(element4, "spcPts", NS.a), "val");
8044
+ if (points2 !== void 0) return { unit: "points", value: points2 / 100 };
7689
8045
  const percent = parseOoxmlPercent(first(element4, "spcPct", NS.a)?.getAttribute("val"));
7690
8046
  if (percent !== void 0) return { unit: "percent", value: percent };
7691
8047
  return void 0;
@@ -13627,9 +13983,9 @@ var heart = {
13627
13983
  }
13628
13984
  ]
13629
13985
  };
13630
- function buildIrregularSeal(name, points) {
13986
+ function buildIrregularSeal(name, points2) {
13631
13987
  const commands = [];
13632
- const first3 = points[0];
13988
+ const first3 = points2[0];
13633
13989
  if (!first3) {
13634
13990
  return {
13635
13991
  name,
@@ -13638,8 +13994,8 @@ function buildIrregularSeal(name, points) {
13638
13994
  };
13639
13995
  }
13640
13996
  commands.push({ kind: "moveTo", x: String(first3[0]), y: String(first3[1]) });
13641
- for (let i = 1; i < points.length; i++) {
13642
- const p = points[i];
13997
+ for (let i = 1; i < points2.length; i++) {
13998
+ const p = points2[i];
13643
13999
  commands.push({ kind: "lnTo", x: String(p[0]), y: String(p[1]) });
13644
14000
  }
13645
14001
  commands.push({ kind: "close" });
@@ -18220,7 +18576,7 @@ function isSpace(ch) {
18220
18576
  return ch === " " || ch === " " || ch === "\n" || ch === "\r";
18221
18577
  }
18222
18578
  function parseAttributes(source2) {
18223
- const attrs2 = {};
18579
+ const attrs3 = {};
18224
18580
  let i = 0;
18225
18581
  const n = source2.length;
18226
18582
  while (i < n) {
@@ -18255,9 +18611,9 @@ function parseAttributes(source2) {
18255
18611
  if (name === "xmlns" || name.startsWith("xmlns:")) {
18256
18612
  continue;
18257
18613
  }
18258
- attrs2[localName(name)] = decodeEntities(value);
18614
+ attrs3[localName(name)] = decodeEntities(value);
18259
18615
  }
18260
- return attrs2;
18616
+ return attrs3;
18261
18617
  }
18262
18618
  function tagEnd2(xml, from) {
18263
18619
  let quote = "";
@@ -18383,14 +18739,14 @@ function numOrNaN(value) {
18383
18739
  function relation(value) {
18384
18740
  return value === "ch" || value === "des" ? value : "self";
18385
18741
  }
18386
- function parseIterator(attrs2) {
18742
+ function parseIterator(attrs3) {
18387
18743
  return {
18388
- axis: list(attrs2.axis),
18389
- ptType: list(attrs2.ptType),
18390
- hideLastTrans: list(attrs2.hideLastTrans).map((v) => v === "1" || v === "true"),
18391
- st: numberList(attrs2.st),
18392
- cnt: numberList(attrs2.cnt),
18393
- step: numberList(attrs2.step)
18744
+ axis: list(attrs3.axis),
18745
+ ptType: list(attrs3.ptType),
18746
+ hideLastTrans: list(attrs3.hideLastTrans).map((v) => v === "1" || v === "true"),
18747
+ st: numberList(attrs3.st),
18748
+ cnt: numberList(attrs3.cnt),
18749
+ step: numberList(attrs3.step)
18394
18750
  };
18395
18751
  }
18396
18752
  function parseAlgorithm(element4) {
@@ -18421,41 +18777,41 @@ function parseShape2(element4) {
18421
18777
  adj
18422
18778
  };
18423
18779
  }
18424
- function parseConstraint(attrs2) {
18425
- const op = attrs2.op;
18780
+ function parseConstraint(attrs3) {
18781
+ const op = attrs3.op;
18426
18782
  return {
18427
- type: attrs2.type ?? "none",
18428
- for: relation(attrs2.for),
18429
- forName: attrs2.forName || void 0,
18430
- ptType: attrs2.ptType ?? "all",
18431
- refType: attrs2.refType ?? "none",
18432
- refFor: relation(attrs2.refFor),
18433
- refForName: attrs2.refForName || void 0,
18434
- refPtType: attrs2.refPtType ?? "all",
18783
+ type: attrs3.type ?? "none",
18784
+ for: relation(attrs3.for),
18785
+ forName: attrs3.forName || void 0,
18786
+ ptType: attrs3.ptType ?? "all",
18787
+ refType: attrs3.refType ?? "none",
18788
+ refFor: relation(attrs3.refFor),
18789
+ refForName: attrs3.refForName || void 0,
18790
+ refPtType: attrs3.refPtType ?? "all",
18435
18791
  op: op === "equ" || op === "gte" || op === "lte" ? op : "none",
18436
- val: num(attrs2.val, 0),
18437
- hasVal: attrs2.val !== void 0,
18438
- fact: num(attrs2.fact, 1)
18792
+ val: num(attrs3.val, 0),
18793
+ hasVal: attrs3.val !== void 0,
18794
+ fact: num(attrs3.fact, 1)
18439
18795
  };
18440
18796
  }
18441
- function parseRule(attrs2) {
18797
+ function parseRule(attrs3) {
18442
18798
  return {
18443
- type: attrs2.type ?? "none",
18444
- for: relation(attrs2.for),
18445
- forName: attrs2.forName || void 0,
18446
- ptType: attrs2.ptType ?? "all",
18447
- val: numOrNaN(attrs2.val),
18448
- fact: numOrNaN(attrs2.fact),
18449
- max: numOrNaN(attrs2.max)
18799
+ type: attrs3.type ?? "none",
18800
+ for: relation(attrs3.for),
18801
+ forName: attrs3.forName || void 0,
18802
+ ptType: attrs3.ptType ?? "all",
18803
+ val: numOrNaN(attrs3.val),
18804
+ fact: numOrNaN(attrs3.fact),
18805
+ max: numOrNaN(attrs3.max)
18450
18806
  };
18451
18807
  }
18452
- function parseCondition(attrs2) {
18808
+ function parseCondition(attrs3) {
18453
18809
  return {
18454
- ...parseIterator(attrs2),
18455
- func: attrs2.func ?? "cnt",
18456
- arg: attrs2.arg,
18457
- op: attrs2.op ?? "equ",
18458
- val: attrs2.val ?? ""
18810
+ ...parseIterator(attrs3),
18811
+ func: attrs3.func ?? "cnt",
18812
+ arg: attrs3.arg,
18813
+ op: attrs3.op ?? "equ",
18814
+ val: attrs3.val ?? ""
18459
18815
  };
18460
18816
  }
18461
18817
  function parseBody(element4, state) {
@@ -18661,15 +19017,15 @@ function isLastSiblingTransition(point) {
18661
19017
  }
18662
19018
  return false;
18663
19019
  }
18664
- function windowPoints(points, st = 1, cnt = 0, step = 1) {
18665
- if (points.length === 0) {
19020
+ function windowPoints(points2, st = 1, cnt = 0, step = 1) {
19021
+ if (points2.length === 0) {
18666
19022
  return [];
18667
19023
  }
18668
19024
  const stride = step === 0 ? 1 : step;
18669
- let index = st > 0 ? st - 1 : st < 0 ? points.length + st : 0;
19025
+ let index = st > 0 ? st - 1 : st < 0 ? points2.length + st : 0;
18670
19026
  const out = [];
18671
- while (index >= 0 && index < points.length) {
18672
- out.push(points[index]);
19027
+ while (index >= 0 && index < points2.length) {
19028
+ out.push(points2[index]);
18673
19029
  if (cnt > 0 && out.length >= cnt) {
18674
19030
  break;
18675
19031
  }
@@ -18681,12 +19037,12 @@ function iterateStep(point, iterator, step) {
18681
19037
  const axis = iterator.axis[step] ?? "none";
18682
19038
  const ptType = iterator.ptType[step] ?? iterator.ptType[iterator.ptType.length - 1] ?? "all";
18683
19039
  const hideLast = (iterator.hideLastTrans[step] ?? true) && SIBLING_AXES.has(axis);
18684
- let points = axisPoints(point, axis).filter((candidate) => matchesPointType(candidate, ptType));
19040
+ let points2 = axisPoints(point, axis).filter((candidate) => matchesPointType(candidate, ptType));
18685
19041
  if (hideLast) {
18686
- points = points.filter((candidate) => !isLastSiblingTransition(candidate));
19042
+ points2 = points2.filter((candidate) => !isLastSiblingTransition(candidate));
18687
19043
  }
18688
19044
  return windowPoints(
18689
- points,
19045
+ points2,
18690
19046
  iterator.st[step] ?? 1,
18691
19047
  iterator.cnt[step] ?? 0,
18692
19048
  iterator.step[step] ?? 1
@@ -22556,7 +22912,13 @@ function buildRenderedNode(node, index, nodeById, palette, style, mergedSourceId
22556
22912
  fontSize: 0,
22557
22913
  textX: x + width / 2,
22558
22914
  textY: y + height / 2,
22559
- nodeId: primary?.id,
22915
+ // Picture roles often omit presOf: they present the current point's image, not its text.
22916
+ nodeId: primary?.id ?? (node.shape?.blipPhldr ? node.point.source?.id : void 0),
22917
+ picturePlaceholder: node.shape?.blipPhldr,
22918
+ layoutRole: node.name,
22919
+ contextNodeId: node.point.source?.id,
22920
+ textAlign: ["l", "ctr", "r"].includes(node.alg.params.parTxLTRAlign ?? "") ? node.alg.params.parTxLTRAlign : void 0,
22921
+ textVerticalAnchor: ["t", "ctr", "b"].includes(node.alg.params.txAnchorVert ?? "") ? node.alg.params.txAnchorVert : void 0,
22560
22922
  rotation: transform2.rotation === 0 ? void 0 : transform2.rotation,
22561
22923
  presetOverride: node.shape?.type ?? "roundRect",
22562
22924
  foldedNodeIds: foldedNodeIds.length > 0 ? foldedNodeIds : void 0,
@@ -22687,15 +23049,15 @@ function treeDepth(t, depth = 0) {
22687
23049
  }
22688
23050
 
22689
23051
  // diagram/layout/smartart-layout-interpreter-custom.ts
22690
- function parsePoints(points) {
22691
- return points.trim().split(/\s+/u).filter((pair) => pair.length > 0).map((pair) => {
23052
+ function parsePoints(points2) {
23053
+ return points2.trim().split(/\s+/u).filter((pair) => pair.length > 0).map((pair) => {
22692
23054
  const [x, y] = pair.split(",").map(Number);
22693
23055
  return [x, y];
22694
23056
  });
22695
23057
  }
22696
- function pointsBoundingBox(points) {
22697
- const xs = points.map(([x]) => x);
22698
- const ys = points.map(([, y]) => y);
23058
+ function pointsBoundingBox(points2) {
23059
+ const xs = points2.map(([x]) => x);
23060
+ const ys = points2.map(([, y]) => y);
22699
23061
  const minX = Math.min(...xs);
22700
23062
  const minY = Math.min(...ys);
22701
23063
  const maxX = Math.max(...xs);
@@ -22748,15 +23110,15 @@ function applyToCircle(node, custom, box) {
22748
23110
  };
22749
23111
  }
22750
23112
  function applyToPolygon(node, custom, box) {
22751
- const points = parsePoints(node.points);
22752
- const bbox = pointsBoundingBox(points);
23113
+ const points2 = parsePoints(node.points);
23114
+ const bbox = pointsBoundingBox(points2);
22753
23115
  const cx = bbox.x + bbox.width / 2;
22754
23116
  const cy = bbox.y + bbox.height / 2;
22755
23117
  const { x: scaleX, y: scaleY } = scaleRatios(custom);
22756
23118
  const flipX = custom.flipHorizontal ? -1 : 1;
22757
23119
  const flipY = custom.flipVertical ? -1 : 1;
22758
23120
  const { dx, dy } = positionNudge(custom, box);
22759
- const transformed = points.map(([x, y]) => {
23121
+ const transformed = points2.map(([x, y]) => {
22760
23122
  const relX = (x - cx) * scaleX * flipX;
22761
23123
  const relY = (y - cy) * scaleY * flipY;
22762
23124
  return `${cx + dx + relX},${cy + dy + relY}`;
@@ -23857,7 +24219,7 @@ function writeFabricatedDiagramData(data, ids, options = {}) {
23857
24219
  const docGuid = createModelId();
23858
24220
  const guidByNodeId = options.guidByNodeId ?? buildDiagramNodeGuidMap(data.nodes, createModelId);
23859
24221
  const presentationGuidByNodeId = options.presentationGuidByNodeId ?? buildDiagramPresentationGuidMap(data.nodes, createModelId);
23860
- const points = [docPointXml(docGuid, ids)];
24222
+ const points2 = [docPointXml(docGuid, ids)];
23861
24223
  const connections = [];
23862
24224
  const nextSrcOrd = /* @__PURE__ */ new Map();
23863
24225
  for (const node of data.nodes) {
@@ -23871,15 +24233,15 @@ function writeFabricatedDiagramData(data, ids, options = {}) {
23871
24233
  const cxnGuid = createModelId();
23872
24234
  const parTransGuid = createModelId();
23873
24235
  const sibTransGuid = createModelId();
23874
- points.push(contentPointXml(guid, node));
23875
- points.push(transPointXml(parTransGuid, "parTrans", cxnGuid));
23876
- points.push(transPointXml(sibTransGuid, "sibTrans", cxnGuid));
24236
+ points2.push(contentPointXml(guid, node));
24237
+ points2.push(transPointXml(parTransGuid, "parTrans", cxnGuid));
24238
+ points2.push(transPointXml(sibTransGuid, "sibTrans", cxnGuid));
23877
24239
  connections.push(
23878
24240
  `<dgm:cxn modelId="${cxnGuid}" srcId="${parentGuid}" destId="${guid}" srcOrd="${srcOrd}" destOrd="0" parTransId="${parTransGuid}" sibTransId="${sibTransGuid}"/>`
23879
24241
  );
23880
24242
  const presentationGuid = node.id ? presentationGuidByNodeId.get(node.id) : void 0;
23881
24243
  if (presentationGuid) {
23882
- points.push(
24244
+ points2.push(
23883
24245
  `<dgm:pt modelId="${presentationGuid}" type="pres"><dgm:prSet presAssocID="${guid}" presName="node" presStyleLbl="node1" presStyleIdx="${srcOrd}" presStyleCnt="${data.nodes.length}"/><dgm:spPr/></dgm:pt>`
23884
24246
  );
23885
24247
  connections.push(
@@ -23888,7 +24250,7 @@ function writeFabricatedDiagramData(data, ids, options = {}) {
23888
24250
  }
23889
24251
  }
23890
24252
  return `${DIAGRAM_XML_PROLOG}\r
23891
- <dgm:dataModel ${DIAGRAM_DATA_XMLNS}><dgm:ptLst>${points.join("")}</dgm:ptLst><dgm:cxnLst>${connections.join("")}</dgm:cxnLst><dgm:bg/><dgm:whole/>${dataModelExtXml(options.drawingRelId)}</dgm:dataModel>`;
24253
+ <dgm:dataModel ${DIAGRAM_DATA_XMLNS}><dgm:ptLst>${points2.join("")}</dgm:ptLst><dgm:cxnLst>${connections.join("")}</dgm:cxnLst><dgm:bg/><dgm:whole/>${dataModelExtXml(options.drawingRelId)}</dgm:dataModel>`;
23892
24254
  }
23893
24255
  function dataModelExtXml(drawingRelId) {
23894
24256
  if (!drawingRelId) {
@@ -24011,9 +24373,9 @@ function writeEditedDiagramData(xml, nodes, options = {}) {
24011
24373
  cxnLst = element2(doc, DGM, "dgm:cxnLst");
24012
24374
  ptLst.parentNode?.insertBefore(cxnLst, ptLst.nextSibling);
24013
24375
  }
24014
- const points = elements(ptLst).filter((el5) => el5.localName === "pt");
24015
- const pointById = new Map(points.map((pt) => [pt.getAttribute("modelId") ?? "", pt]));
24016
- const docPoint = points.find((pt) => pointType(pt) === "doc");
24376
+ const points2 = elements(ptLst).filter((el5) => el5.localName === "pt");
24377
+ const pointById = new Map(points2.map((pt) => [pt.getAttribute("modelId") ?? "", pt]));
24378
+ const docPoint = points2.find((pt) => pointType(pt) === "doc");
24017
24379
  const rootId = docPoint?.getAttribute("modelId");
24018
24380
  if (!rootId) throw new Error("The diagram data part has no document point.");
24019
24381
  const connections = () => elements(cxnLst).filter((el5) => el5.localName === "cxn");
@@ -24025,7 +24387,7 @@ function writeEditedDiagramData(xml, nodes, options = {}) {
24025
24387
  }
24026
24388
  const kept = new Set(idMap.values());
24027
24389
  const removed2 = /* @__PURE__ */ new Set();
24028
- for (const pt of points) {
24390
+ for (const pt of points2) {
24029
24391
  const id = pt.getAttribute("modelId") ?? "";
24030
24392
  if (CONTENT_TYPES.has(pointType(pt)) && !kept.has(id)) removed2.add(id);
24031
24393
  }
@@ -24039,14 +24401,14 @@ function writeEditedDiagramData(xml, nodes, options = {}) {
24039
24401
  if (id) removed2.add(id);
24040
24402
  }
24041
24403
  const cxnId = cxn2.getAttribute("modelId");
24042
- for (const pt of points)
24404
+ for (const pt of points2)
24043
24405
  if (cxnId && pt.getAttribute("cxnId") === cxnId)
24044
24406
  removed2.add(pt.getAttribute("modelId") ?? "");
24045
24407
  cxnLst.removeChild(cxn2);
24046
24408
  } else if (!parOfByDest.has(dest)) parOfByDest.set(dest, cxn2);
24047
24409
  }
24048
24410
  const removedPres = /* @__PURE__ */ new Set();
24049
- for (const pt of points)
24411
+ for (const pt of points2)
24050
24412
  if (pointType(pt) === "pres" && removed2.has(child5(pt, "prSet")?.getAttribute("presAssocID") ?? ""))
24051
24413
  removedPres.add(pt.getAttribute("modelId") ?? "");
24052
24414
  for (let grew = true; grew; ) {
@@ -24064,7 +24426,7 @@ function writeEditedDiagramData(xml, nodes, options = {}) {
24064
24426
  if (type === "presOf" && (removed2.has(src) || removedPres.has(dest)) || type === "presParOf" && (removedPres.has(src) || removedPres.has(dest)))
24065
24427
  cxnLst.removeChild(cxn2);
24066
24428
  }
24067
- for (const pt of points) {
24429
+ for (const pt of points2) {
24068
24430
  const id = pt.getAttribute("modelId") ?? "";
24069
24431
  if (removed2.has(id) || removedPres.has(id)) ptLst.removeChild(pt);
24070
24432
  }
@@ -24464,9 +24826,9 @@ var DEFAULT_GENERATED_DIAGRAM_SCHEME = {
24464
24826
  // diagram/data-model.ts
24465
24827
  var TRANSITION_TYPES = /* @__PURE__ */ new Set(["parTrans", "sibTrans"]);
24466
24828
  var STRUCTURAL_TYPES = /* @__PURE__ */ new Set(["doc", "pres", "parTrans", "sibTrans"]);
24467
- function collectTransitionText(points, describe, text) {
24829
+ function collectTransitionText(points2, describe, text) {
24468
24830
  const byId = /* @__PURE__ */ new Map();
24469
- for (const point of points) {
24831
+ for (const point of points2) {
24470
24832
  const { type, modelId } = describe(point);
24471
24833
  if (!TRANSITION_TYPES.has((type ?? "").trim())) continue;
24472
24834
  const id = (modelId ?? "").trim();
@@ -24528,7 +24890,7 @@ function parseDiagramDataModel(source2, part) {
24528
24890
  const root = (typeof source2 === "string" ? parseXml(source2, { label: "DiagramML" }) : source2).documentElement;
24529
24891
  const issues = [];
24530
24892
  const report = (code, message) => issues.push({ code, message, ...part ? { part } : {} });
24531
- const points = [];
24893
+ const points2 = [];
24532
24894
  const ids = /* @__PURE__ */ new Set();
24533
24895
  for (const element4 of children(first(root, "ptLst", NS.dgm) ?? root, "pt", NS.dgm)) {
24534
24896
  const point = parsePoint(element4);
@@ -24539,10 +24901,10 @@ function parseDiagramDataModel(source2, part) {
24539
24901
  if (ids.has(point.modelId))
24540
24902
  report("POINT_ID_DUPLICATE", `Duplicate dgm:pt modelId: ${point.modelId}.`);
24541
24903
  ids.add(point.modelId);
24542
- points.push(point);
24904
+ points2.push(point);
24543
24905
  }
24544
24906
  const transitionText = collectTransitionText(
24545
- points,
24907
+ points2,
24546
24908
  (point) => ({ type: point.type, modelId: point.modelId }),
24547
24909
  (point) => point.text
24548
24910
  );
@@ -24579,13 +24941,13 @@ function parseDiagramDataModel(source2, part) {
24579
24941
  );
24580
24942
  const generatedCacheDigest = generated2?.getAttribute("drawingSha256");
24581
24943
  return {
24582
- points,
24944
+ points: points2,
24583
24945
  ...descendants(root, "generatedCache").some(
24584
24946
  (node) => node.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
24585
24947
  ) ? { generatedCache: true } : {},
24586
24948
  ...generatedCacheDigest ? { generatedCacheDigest } : {},
24587
24949
  connections,
24588
- nodes: points.filter((point) => !STRUCTURAL_TYPES.has(point.type)),
24950
+ nodes: points2.filter((point) => !STRUCTURAL_TYPES.has(point.type)),
24589
24951
  parentById,
24590
24952
  ...drawingRelId ? { drawingRelId } : {},
24591
24953
  issues
@@ -24843,6 +25205,203 @@ function approximateDiagramDrawingFromNodes(input) {
24843
25205
  });
24844
25206
  }
24845
25207
 
25208
+ // diagram/picture-layout.ts
25209
+ var DIAGRAM_PICTURE_SOURCE_NS = "urn:ooxml-core:diagram-picture-sources:1";
25210
+ function remapFill(fill, id) {
25211
+ if (!fill.sourceXml) return { ...fill, relId: id };
25212
+ const node = parseXml(fill.sourceXml).documentElement;
25213
+ const blip = first(node, "blip", NS.a);
25214
+ if (blip) {
25215
+ blip.setAttributeNS(NS.r, "r:embed", id);
25216
+ blip.removeAttributeNS(NS.r, "link");
25217
+ }
25218
+ return { ...fill, relId: id, sourceXml: buildXml(node) };
25219
+ }
25220
+ function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
25221
+ const pictures = [];
25222
+ const parts = { ...dataParts };
25223
+ const add4 = (source2, owner) => {
25224
+ const part = source2.fill.relId ? owner[source2.fill.relId] : void 0;
25225
+ if (!part) return;
25226
+ let id = Object.keys(parts).find((key) => parts[key] === part);
25227
+ if (!id) {
25228
+ let index = 1;
25229
+ while (Object.hasOwn(parts, `ooxmlDiagramPicture${index}`)) index++;
25230
+ id = `ooxmlDiagramPicture${index}`;
25231
+ parts[id] = part;
25232
+ }
25233
+ const entry2 = { ...source2, fill: remapFill(source2.fill, id) };
25234
+ const existing = pictures.findIndex(
25235
+ (item2) => item2.nodeId === entry2.nodeId && (item2.role === entry2.role && item2.styleLabel === entry2.styleLabel || !item2.role && !item2.styleLabel && item2.fill.relId === entry2.fill.relId)
25236
+ );
25237
+ if (existing < 0) pictures.push(entry2);
25238
+ else pictures[existing] = entry2;
25239
+ };
25240
+ const root = parseXml(dataXml2).documentElement;
25241
+ const saved = root.getElementsByTagNameNS(DIAGRAM_PICTURE_SOURCE_NS, "picture");
25242
+ for (const element4 of saved) {
25243
+ const nodeId = element4.getAttribute("nodeId");
25244
+ const fill = first(element4, "blipFill", NS.a);
25245
+ if (nodeId && fill && model.nodes.some((node) => node.modelId === nodeId))
25246
+ add4(
25247
+ {
25248
+ nodeId,
25249
+ fill: parseDrawingPictureFill(fill),
25250
+ ...element4.getAttribute("role") ? { role: element4.getAttribute("role") } : {},
25251
+ ...element4.getAttribute("styleLabel") ? { styleLabel: element4.getAttribute("styleLabel") } : {}
25252
+ },
25253
+ dataParts
25254
+ );
25255
+ }
25256
+ for (const point of model.points) {
25257
+ if (point.fill?.kind !== "picture") continue;
25258
+ const nodeId = point.type === "pres" ? point.presAssocId : point.modelId;
25259
+ if (nodeId && model.nodes.some((node) => node.modelId === nodeId) && !pictures.some((item2) => item2.nodeId === nodeId))
25260
+ add4(
25261
+ {
25262
+ nodeId,
25263
+ fill: point.fill,
25264
+ ...point.presName ? { role: point.presName } : {},
25265
+ ...point.presStyleLabel ? { styleLabel: point.presStyleLabel } : {}
25266
+ },
25267
+ dataParts
25268
+ );
25269
+ }
25270
+ for (const shape of drawing?.shapes ?? []) {
25271
+ if (shape.fill?.kind !== "picture") continue;
25272
+ const point = model.points.find((point2) => point2.modelId === shape.modelId);
25273
+ const nodeId = shape.sourceNodeId ?? (point?.type === "pres" ? point.presAssocId : point?.modelId);
25274
+ const part = shape.fill.relId ? drawing?.pictureParts?.[shape.fill.relId] : void 0;
25275
+ if (saved.length && pictures.some(
25276
+ (item2) => item2.nodeId === nodeId && item2.fill.relId && parts[item2.fill.relId] === part && item2.role !== point?.presName && item2.styleLabel !== point?.presStyleLabel
25277
+ ))
25278
+ continue;
25279
+ if (nodeId && model.nodes.some((node) => node.modelId === nodeId))
25280
+ add4(
25281
+ {
25282
+ nodeId,
25283
+ fill: shape.fill,
25284
+ ...point?.presName ? { role: point.presName } : {},
25285
+ ...point?.presStyleLabel ? { styleLabel: point.presStyleLabel } : {}
25286
+ },
25287
+ drawing?.pictureParts ?? {}
25288
+ );
25289
+ }
25290
+ return pictures.length ? { pictures, pictureParts: parts } : {};
25291
+ }
25292
+ function applyDiagramPictureSources(drawing, nodes, source2, issues, liveNodeIds) {
25293
+ if (!source2?.pictures?.length) return;
25294
+ if (source2.pictureParts) drawing.pictureParts = { ...source2.pictureParts };
25295
+ const used = /* @__PURE__ */ new Set();
25296
+ nodes.forEach((node, index) => {
25297
+ if (!node.picturePlaceholder || !node.nodeId) return;
25298
+ const shape = drawing.shapes[index];
25299
+ if (!shape) return;
25300
+ const candidates = source2.pictures.filter((picture2) => picture2.nodeId === node.nodeId);
25301
+ const matching = candidates.filter(
25302
+ (picture2) => picture2.role === node.layoutRole || !!picture2.styleLabel && picture2.styleLabel === node.styleLabel
25303
+ );
25304
+ const picture = matching.length === 1 ? matching[0] : candidates.length === 1 ? candidates[0] : void 0;
25305
+ if (picture) {
25306
+ shape.fill = structuredClone(picture.fill);
25307
+ delete shape.text;
25308
+ delete shape.body;
25309
+ used.add(picture);
25310
+ } else if (candidates.length)
25311
+ issues.push({
25312
+ code: "DIAGRAM_PICTURE_AMBIGUOUS",
25313
+ message: `Picture role ${node.layoutRole ?? node.key} has multiple source pictures; no arbitrary assignment was made.`
25314
+ });
25315
+ });
25316
+ if (source2.pictures.some(
25317
+ (picture) => (!liveNodeIds || liveNodeIds.has(picture.nodeId)) && !used.has(picture)
25318
+ ))
25319
+ issues.push({
25320
+ code: "DIAGRAM_PICTURE_LAYOUT_UNSUPPORTED",
25321
+ message: "Some retained pictures have no matching image placeholder in this layout. Their source associations are preserved for a compatible layout."
25322
+ });
25323
+ }
25324
+ function withDiagramPictureSources(dataXml2, source2) {
25325
+ if (!source2?.pictures?.length) return dataXml2;
25326
+ const doc = parseXml(dataXml2);
25327
+ const root = doc.documentElement;
25328
+ const points2 = first(root, "ptLst", NS.dgm);
25329
+ const live = children(points2 ?? root, "pt", NS.dgm).filter(
25330
+ (point) => !["doc", "pres", "parTrans", "sibTrans"].includes(point.getAttribute("type") ?? "node")
25331
+ );
25332
+ for (const element4 of [...root.getElementsByTagNameNS(DIAGRAM_PICTURE_SOURCE_NS, "pictures")]) {
25333
+ const extension2 = element4.parentNode;
25334
+ if (extension2?.parentNode) extension2.parentNode.removeChild(extension2);
25335
+ }
25336
+ const retained = source2.pictures.filter(
25337
+ (picture) => live.some((point) => point.getAttribute("modelId") === picture.nodeId)
25338
+ );
25339
+ if (!retained.length) return buildXml(doc);
25340
+ const list2 = first(root, "extLst", NS.dgm) ?? doc.createElementNS(NS.dgm, "dgm:extLst");
25341
+ if (!list2.parentNode) root.appendChild(list2);
25342
+ const extension = doc.createElementNS(NS.a, "a:ext");
25343
+ extension.setAttribute("uri", DIAGRAM_PICTURE_SOURCE_NS);
25344
+ const payload = doc.createElementNS(DIAGRAM_PICTURE_SOURCE_NS, "op:pictures");
25345
+ extension.appendChild(payload);
25346
+ list2.appendChild(extension);
25347
+ for (const picture of retained) {
25348
+ if (!picture.fill.sourceXml)
25349
+ throw new Error("A retained SmartArt picture needs source fill XML");
25350
+ const element4 = doc.createElementNS(DIAGRAM_PICTURE_SOURCE_NS, "op:picture");
25351
+ element4.setAttribute("nodeId", picture.nodeId);
25352
+ if (picture.role) element4.setAttribute("role", picture.role);
25353
+ if (picture.styleLabel) element4.setAttribute("styleLabel", picture.styleLabel);
25354
+ const fill = parseXml(picture.fill.sourceXml).documentElement;
25355
+ element4.appendChild(doc.importNode(fill, true));
25356
+ payload.appendChild(element4);
25357
+ const presentations = children(points2 ?? root, "pt", NS.dgm).filter((point) => {
25358
+ const props = first(point, "prSet", NS.dgm);
25359
+ return point.getAttribute("type") === "pres" && props?.getAttribute("presAssocID") === picture.nodeId && (picture.role && props.getAttribute("presName") === picture.role || picture.styleLabel && props.getAttribute("presStyleLbl") === picture.styleLabel);
25360
+ });
25361
+ if (presentations.length === 1) {
25362
+ const point = presentations[0];
25363
+ const props = first(point, "spPr", NS.dgm) ?? doc.createElementNS(NS.dgm, "dgm:spPr");
25364
+ if (!props.parentNode) point.appendChild(props);
25365
+ for (const old of [...props.childNodes].filter((node) => node.nodeType === 1).filter(
25366
+ (node) => node.namespaceURI === NS.a && ["blipFill", "solidFill", "gradFill", "pattFill", "noFill", "grpFill"].includes(
25367
+ node.localName
25368
+ )
25369
+ ))
25370
+ props.removeChild(old);
25371
+ props.insertBefore(doc.importNode(fill, true), props.firstChild);
25372
+ }
25373
+ }
25374
+ return buildXml(doc);
25375
+ }
25376
+ function diagramPictureRelationships(owner, source2, existing) {
25377
+ if (!source2?.pictures?.length || !source2.pictureParts) return existing;
25378
+ const rels = parseRelationships(existing);
25379
+ for (const [id, part] of Object.entries(source2.pictureParts)) {
25380
+ const previous = rels.get(id);
25381
+ if (previous && (previous.mode === "External" || resolvePartPath(owner, previous.target) !== part))
25382
+ throw new Error(`Conflicting SmartArt picture relationship: ${id}`);
25383
+ rels.set(id, { id, type: RELATIONSHIP_TYPES.image, target: `/${part}`, mode: "Internal" });
25384
+ }
25385
+ return buildRelationshipsXml(rels);
25386
+ }
25387
+
25388
+ // diagram/layout-role-style.ts
25389
+ function applyDiagramRoleColors(shape, role, index, minorFont) {
25390
+ const at = (colors) => colors[index % colors.length];
25391
+ const fill = role && at(role.fill.colors);
25392
+ if (fill && shape.fill?.kind !== "none" && shape.fill?.kind !== "picture")
25393
+ shape.fill = { kind: "solid", color: structuredClone(fill) };
25394
+ const line2 = role && at(role.line.colors);
25395
+ if (line2 && shape.line) shape.line.fill = { kind: "solid", color: structuredClone(line2) };
25396
+ const text = role && at(role.textFill.colors);
25397
+ for (const paragraph2 of shape.text?.paragraphs ?? []) {
25398
+ for (const run2 of paragraph2.runs) {
25399
+ if (!run2.color && text) run2.color = structuredClone(text);
25400
+ if (!run2.typeface && minorFont) run2.typeface = minorFont;
25401
+ }
25402
+ }
25403
+ }
25404
+
24846
25405
  // diagram/layout-preview.ts
24847
25406
  function diagramLayoutData(input) {
24848
25407
  const original = input.source?.dataXml ? parseDiagramDataModel(input.source.dataXml) : void 0;
@@ -24988,6 +25547,8 @@ function previewDiagramLayout(input) {
24988
25547
  ];
24989
25548
  });
24990
25549
  const drawing2 = diagramDrawingFromViews(views);
25550
+ drawing2.extentEmu = { ...input.extentEmu };
25551
+ const colors = input.source?.colorsXml ? parseDiagramColors(input.source.colorsXml) : void 0;
24991
25552
  const quickStyle = input.source?.quickStyleXml ? parseDiagramQuickStyle(input.source.quickStyleXml) : void 0;
24992
25553
  const originalModel = input.source?.dataXml ? parseDiagramDataModel(input.source.dataXml) : void 0;
24993
25554
  result.nodes.forEach((node, index) => {
@@ -24998,7 +25559,9 @@ function previewDiagramLayout(input) {
24998
25559
  shape.style = label;
24999
25560
  shape.has3d = label.requires3d ?? label.hasShape3d;
25000
25561
  }
25001
- if (node.nodeId) shape.sourceNodeId = node.nodeId;
25562
+ const contextNodeId = node.nodeId ?? node.contextNodeId;
25563
+ if (contextNodeId) shape.sourceNodeId = contextNodeId;
25564
+ if (node.layoutRole) shape.sourceLayoutRole = node.layoutRole;
25002
25565
  if (node.styleLabel) shape.sourceStyleLabel = node.styleLabel;
25003
25566
  if (node.foldedNodeIds?.length) shape.foldedNodeIds = node.foldedNodeIds;
25004
25567
  const sourceNode = data.nodes.find((entry2) => entry2.id === node.nodeId);
@@ -25011,15 +25574,36 @@ function previewDiagramLayout(input) {
25011
25574
  if (fill) shape.fill = fill;
25012
25575
  }
25013
25576
  const direct = originalModel?.nodes.find((entry2) => entry2.modelId === node.nodeId);
25014
- if (direct?.fill) shape.fill = direct.fill;
25015
- if (direct?.line) shape.line = { ...shape.line, ...direct.line };
25016
25577
  const sourceIds = [node.nodeId, ...node.foldedNodeIds ?? []];
25017
25578
  const textNodes = sourceIds.flatMap((id) => {
25018
25579
  const source2 = input.nodes.find((entry2) => entry2.id === id);
25019
25580
  return source2 ? [source2] : [];
25020
25581
  });
25021
25582
  if (textNodes.length) shape.text = diagramPreviewText(textNodes, node.fontSize);
25583
+ if (shape.text) {
25584
+ if (node.textVerticalAnchor) shape.text.anchor = node.textVerticalAnchor;
25585
+ for (const paragraph2 of shape.text.paragraphs)
25586
+ if (!paragraph2.align && node.textAlign) paragraph2.align = node.textAlign;
25587
+ }
25588
+ applyDiagramRoleColors(
25589
+ shape,
25590
+ colors?.labels.find((label2) => label2.name === node.styleLabel),
25591
+ Math.max(
25592
+ 0,
25593
+ input.nodes.findIndex((entry2) => entry2.id === contextNodeId)
25594
+ ),
25595
+ input.minorFont
25596
+ );
25597
+ if (direct?.fill && direct.fill.kind !== "picture") shape.fill = direct.fill;
25598
+ if (direct?.line) shape.line = { ...shape.line, ...direct.line };
25022
25599
  });
25600
+ applyDiagramPictureSources(
25601
+ drawing2,
25602
+ result.nodes,
25603
+ input.source,
25604
+ issues,
25605
+ new Set(input.nodes.map((node) => node.id))
25606
+ );
25023
25607
  return { drawing: drawing2, mode: "interpreted", issues };
25024
25608
  }
25025
25609
  } catch (error) {
@@ -25060,9 +25644,9 @@ function resolveDiagramDrawingStyles(drawing, scheme2) {
25060
25644
 
25061
25645
  // diagram/write/cache.ts
25062
25646
  var DSP2 = "http://schemas.microsoft.com/office/drawing/2008/diagram";
25063
- function add2(parent, namespace, name, attrs2 = {}) {
25647
+ function add2(parent, namespace, name, attrs3 = {}) {
25064
25648
  const child7 = parent.ownerDocument.createElementNS(namespace, name);
25065
- for (const [key, value] of Object.entries(attrs2)) child7.setAttribute(key, value);
25649
+ for (const [key, value] of Object.entries(attrs3)) child7.setAttribute(key, value);
25066
25650
  parent.appendChild(child7);
25067
25651
  return child7;
25068
25652
  }
@@ -25080,6 +25664,7 @@ function withDiagramDrawingRelationship(xml, relationshipId) {
25080
25664
  return buildXml(doc);
25081
25665
  }
25082
25666
  function buildGeneratedDiagramCache(dataXml2, input) {
25667
+ dataXml2 = withDiagramPictureSources(dataXml2, input.source);
25083
25668
  const source2 = { ...input.source, dataXml: dataXml2 };
25084
25669
  const model = parseDiagramDataModel(dataXml2);
25085
25670
  const scheme2 = { ...DEFAULT_GENERATED_DIAGRAM_SCHEME, ...input.scheme };
@@ -25094,9 +25679,9 @@ function buildGeneratedDiagramCache(dataXml2, input) {
25094
25679
  const drawing = resolveDiagramDrawingStyles(preview.drawing, input.formatScheme);
25095
25680
  const doc = parseXml(dataXml2);
25096
25681
  const root = doc.documentElement;
25097
- const points = first(root, "ptLst", NS.dgm);
25682
+ const points2 = first(root, "ptLst", NS.dgm);
25098
25683
  const connections = first(root, "cxnLst", NS.dgm);
25099
- if (!points || !connections) return void 0;
25684
+ if (!points2 || !connections) return void 0;
25100
25685
  const colors = source2.colorsXml ? parseDiagramColors(source2.colorsXml).labels : [];
25101
25686
  const authoredColors = colors.flatMap((label) => [...label.fill.colors, ...label.line.colors]);
25102
25687
  const themed = /* @__PURE__ */ new Map();
@@ -25106,14 +25691,17 @@ function buildGeneratedDiagramCache(dataXml2, input) {
25106
25691
  }
25107
25692
  for (const shape of drawing.shapes) {
25108
25693
  if (shape.has3d || shape.foldedNodeIds?.length) return void 0;
25109
- if (shape.fill && !["none", "solid", "gradient"].includes(shape.fill.kind)) return void 0;
25694
+ if (shape.fill && !["none", "solid", "gradient", "picture"].includes(shape.fill.kind))
25695
+ return void 0;
25696
+ if (shape.fill?.kind === "picture" && (!shape.fill.relId || !drawing.pictureParts?.[shape.fill.relId]))
25697
+ return void 0;
25110
25698
  if (shape.fill?.kind === "gradient" && shape.fill.path && !["circle", "rect"].includes(shape.fill.path))
25111
25699
  return void 0;
25112
25700
  if (shape.effects?.effects.some(
25113
25701
  (effect) => effect.kind !== "outerShadow" || !resolveDrawingOuterShadow(effect, { scheme: (name) => scheme2[name] })
25114
25702
  ))
25115
25703
  return void 0;
25116
- const point = children(points, "pt", NS.dgm).find(
25704
+ const point = children(points2, "pt", NS.dgm).find(
25117
25705
  (point2) => point2.getAttribute("modelId") === shape.sourceNodeId
25118
25706
  );
25119
25707
  const direct = model.nodes.find((node) => node.modelId === shape.sourceNodeId);
@@ -25187,8 +25775,8 @@ function buildGeneratedDiagramCache(dataXml2, input) {
25187
25775
  (marker2) => descendants(marker2, "shape").map((node) => node.getAttribute("id"))
25188
25776
  )
25189
25777
  );
25190
- for (const point of children(points, "pt", NS.dgm))
25191
- if (oldIds.has(point.getAttribute("modelId"))) points.removeChild(point);
25778
+ for (const point of children(points2, "pt", NS.dgm))
25779
+ if (oldIds.has(point.getAttribute("modelId"))) points2.removeChild(point);
25192
25780
  for (const edge of children(connections, "cxn", NS.dgm))
25193
25781
  if (oldIds.has(edge.getAttribute("destId"))) connections.removeChild(edge);
25194
25782
  for (const marker2 of oldMarkers) {
@@ -25210,15 +25798,18 @@ function buildGeneratedDiagramCache(dataXml2, input) {
25210
25798
  );
25211
25799
  drawing.shapes.forEach((shape, index) => {
25212
25800
  const id = serialized.modelIds.get(shape.modelId);
25213
- const point = add2(points, NS.dgm, "dgm:pt", { modelId: id, type: "pres" });
25801
+ const point = add2(points2, NS.dgm, "dgm:pt", { modelId: id, type: "pres" });
25214
25802
  add2(point, NS.dgm, "dgm:prSet", {
25215
25803
  ...shape.sourceNodeId ? { presAssocID: shape.sourceNodeId } : {},
25216
- presName: "node",
25804
+ presName: shape.sourceLayoutRole ?? "node",
25217
25805
  presStyleLbl: shape.sourceStyleLabel ?? "node1",
25218
25806
  presStyleIdx: String(index),
25219
25807
  presStyleCnt: String(drawing.shapes.length)
25220
25808
  });
25221
- add2(point, NS.dgm, "dgm:spPr");
25809
+ const properties = add2(point, NS.dgm, "dgm:spPr");
25810
+ if (shape.fill?.kind === "picture" && shape.fill.sourceXml) {
25811
+ properties.appendChild(doc.importNode(parseXml(shape.fill.sourceXml).documentElement, true));
25812
+ }
25222
25813
  if (shape.sourceNodeId)
25223
25814
  add2(connections, NS.dgm, "dgm:cxn", {
25224
25815
  modelId: createOfficeGuid(),
@@ -25231,7 +25822,11 @@ function buildGeneratedDiagramCache(dataXml2, input) {
25231
25822
  });
25232
25823
  add2(marker, GENERATED_DIAGRAM_CACHE_NS, "oc:shape", { id });
25233
25824
  });
25234
- return { dataXml: buildXml(doc), drawingXml: serialized.xml };
25825
+ return {
25826
+ dataXml: buildXml(doc),
25827
+ drawingXml: serialized.xml,
25828
+ ...drawing.pictureParts ? { pictureParts: drawing.pictureParts } : {}
25829
+ };
25235
25830
  }
25236
25831
 
25237
25832
  // diagram/relationships.ts
@@ -25496,6 +26091,29 @@ async function loadDiagram(hostPart, relationshipIds, host) {
25496
26091
  code: "DIAGRAM_DRAWING_ABSENT",
25497
26092
  message: "The package has no cached drawing for this diagram; its layout can only be recomputed from the layout definition."
25498
26093
  });
26094
+ if (data && layoutSource.dataXml) {
26095
+ let pictureParts = {};
26096
+ if (paths.data) {
26097
+ const owner = paths.data;
26098
+ try {
26099
+ const entries = await host.readRelationshipEntries(diagramRelationshipsPart(owner));
26100
+ pictureParts = Object.fromEntries(
26101
+ (entries ?? []).filter(
26102
+ (entry2) => entry2.type.endsWith("/image") && entry2.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry2.target)
26103
+ ).map((entry2) => [entry2.id, host.resolvePath(owner, entry2.target)])
26104
+ );
26105
+ } catch {
26106
+ issues.push({
26107
+ code: "DIAGRAM_PICTURE_RELATIONSHIPS_UNREADABLE",
26108
+ message: "Picture relationships in the diagram data could not be read."
26109
+ });
26110
+ }
26111
+ }
26112
+ Object.assign(
26113
+ layoutSource,
26114
+ captureDiagramPictures(data, layoutSource.dataXml, pictureParts, drawing)
26115
+ );
26116
+ }
25499
26117
  return {
25500
26118
  layoutSource,
25501
26119
  ...generatedCache ? { generatedCache: true } : {},
@@ -27426,14 +28044,14 @@ function formula(parent, local) {
27426
28044
  var LEVEL = /* @__PURE__ */ new Set(["pt", "extLst"]);
27427
28045
  function parseLevel(context, element4) {
27428
28046
  reportUnmodelled2(context, element4, LEVEL);
27429
- const points = cxChildren(element4, "pt").map((pt) => {
28047
+ const points2 = cxChildren(element4, "pt").map((pt) => {
27430
28048
  const point = { value: pt.textContent ?? "" };
27431
28049
  const index = indexAttribute(context, pt, "idx");
27432
28050
  if (index !== void 0) point.index = index;
27433
28051
  return point;
27434
28052
  });
27435
28053
  return assignDefined(
27436
- { points },
28054
+ { points: points2 },
27437
28055
  {
27438
28056
  pointCount: indexAttribute(context, element4, "ptCount"),
27439
28057
  formatCode: attribute(element4, "formatCode"),
@@ -27867,8 +28485,8 @@ function attributes(entries) {
27867
28485
  return ` ${name}="${text}"`;
27868
28486
  }).join("");
27869
28487
  }
27870
- var cxElement = (local, content = "", attrs2 = "") => content ? `<cx:${local}${attrs2}>${content}</cx:${local}>` : `<cx:${local}${attrs2}/>`;
27871
- var cxText = (local, text, attrs2 = "") => text === void 0 ? "" : `<cx:${local}${attrs2}>${escapeText2(text)}</cx:${local}>`;
28488
+ var cxElement = (local, content = "", attrs3 = "") => content ? `<cx:${local}${attrs3}>${content}</cx:${local}>` : `<cx:${local}${attrs3}/>`;
28489
+ var cxText = (local, text, attrs3 = "") => text === void 0 ? "" : `<cx:${local}${attrs3}>${escapeText2(text)}</cx:${local}>`;
27872
28490
  var cxVal = (local, value) => value === void 0 ? "" : `<cx:${local}${attributes([["val", value]])}/>`;
27873
28491
  var formulaXml = (local, formula2) => formula2 ? cxText(local, formula2.formula, attributes([["dir", formula2.direction]])) : "";
27874
28492
  var shapeXml = (context, shape) => shape ? cxElement("spPr", shapePropertiesInnerXml(context, shape)) : "";
@@ -27953,7 +28571,7 @@ function labelBody(context, label) {
27953
28571
  }
27954
28572
  function dataLabelsXml2(context, labels) {
27955
28573
  if (!labels) return "";
27956
- const points = labels.labels.map(
28574
+ const points2 = labels.labels.map(
27957
28575
  (label) => cxElement(
27958
28576
  "dataLabel",
27959
28577
  labelBody(context, label) + raw(context, label.extLst),
@@ -27966,7 +28584,7 @@ function dataLabelsXml2(context, labels) {
27966
28584
  const hidden = labels.hidden.map((index) => cxElement("dataLabelHidden", "", attributes([["idx", index]]))).join("");
27967
28585
  return cxElement(
27968
28586
  "dataLabels",
27969
- labelBody(context, labels) + points + hidden + raw(context, labels.extLst),
28587
+ labelBody(context, labels) + points2 + hidden + raw(context, labels.extLst),
27970
28588
  attributes([["pos", labels.position]])
27971
28589
  );
27972
28590
  }
@@ -28013,7 +28631,7 @@ function layoutXml2(context, layout2) {
28013
28631
  );
28014
28632
  }
28015
28633
  function seriesXml2(context, series) {
28016
- const points = series.dataPoints.map(
28634
+ const points2 = series.dataPoints.map(
28017
28635
  (point) => cxElement(
28018
28636
  "dataPt",
28019
28637
  shapeXml(context, point.spPr) + raw(context, point.extLst),
@@ -28022,7 +28640,7 @@ function seriesXml2(context, series) {
28022
28640
  ).join("");
28023
28641
  return cxElement(
28024
28642
  "series",
28025
- textXml(context, series.tx) + shapeXml(context, series.spPr) + textBodyXml2(context, series.txPr) + raw(context, series.valueColorsXml) + raw(context, series.valueColorPositionsXml) + points + dataLabelsXml2(context, series.dataLabels) + (series.data ? dataXml(context, series.data) : "") + cxVal("dataId", series.dataId) + layoutXml2(context, series.layoutProperties) + series.axisIds.map((id) => cxVal("axisId", id)).join("") + raw(context, series.extLst),
28643
+ textXml(context, series.tx) + shapeXml(context, series.spPr) + textBodyXml2(context, series.txPr) + raw(context, series.valueColorsXml) + raw(context, series.valueColorPositionsXml) + points2 + dataLabelsXml2(context, series.dataLabels) + (series.data ? dataXml(context, series.data) : "") + cxVal("dataId", series.dataId) + layoutXml2(context, series.layoutProperties) + series.axisIds.map((id) => cxVal("axisId", id)).join("") + raw(context, series.extLst),
28026
28644
  attributes([
28027
28645
  ["layoutId", series.layoutId],
28028
28646
  ["hidden", series.hidden],
@@ -28919,6 +29537,54 @@ async function appendChartExWorkbookData(bytes, before, after) {
28919
29537
  return { bytes: result.bytes, space: layout2.space };
28920
29538
  }
28921
29539
 
29540
+ // chart/render/chart-title-text.ts
29541
+ function chartRunStyle(run2) {
29542
+ return {
29543
+ ...run2.sizePt === void 0 ? {} : { fontSize: run2.sizePt },
29544
+ ...run2.bold === void 0 ? {} : { bold: run2.bold },
29545
+ ...run2.italic === void 0 ? {} : { italic: run2.italic },
29546
+ ...run2.underline === void 0 ? {} : { underline: run2.underline },
29547
+ ...run2.typeface === void 0 ? {} : { typeface: run2.typeface },
29548
+ ...run2.color === void 0 ? {} : { textColor: run2.color }
29549
+ };
29550
+ }
29551
+
29552
+ // chart/render/summary-ex-formatting.ts
29553
+ function textStyle(body) {
29554
+ const paragraph2 = body?.paragraphs[0];
29555
+ return {
29556
+ ...chartRunStyle(paragraph2?.defaultProperties ?? {}),
29557
+ ...chartRunStyle(paragraph2?.runs[0] ?? {})
29558
+ };
29559
+ }
29560
+ function chartExFormatting(space) {
29561
+ return {
29562
+ builtInStyle: 2,
29563
+ sourceXml: "",
29564
+ entries: {
29565
+ title: {
29566
+ fontSize: 18,
29567
+ bold: false,
29568
+ textColor: {
29569
+ kind: "scheme",
29570
+ value: "tx1",
29571
+ transforms: []
29572
+ },
29573
+ ...textStyle(space.title?.txPr),
29574
+ ...textStyle(space.title?.tx?.rich),
29575
+ ...space.title?.tx?.rich ? { textBody: space.title.tx.rich } : {},
29576
+ sourceXml: ""
29577
+ },
29578
+ legend: { fontSize: 12, ...textStyle(space.legend?.txPr), sourceXml: "" },
29579
+ categoryAxis: {
29580
+ fontSize: 10,
29581
+ ...textStyle(space.plotArea.axes.find((a2) => a2.scaling?.kind === "cat")?.txPr),
29582
+ sourceXml: ""
29583
+ }
29584
+ }
29585
+ };
29586
+ }
29587
+
28922
29588
  // chart/render/summary-ex-series.ts
28923
29589
  var level2 = (source2) => ({
28924
29590
  ...source2.visibility?.value === void 0 ? {} : { showValue: source2.visibility.value },
@@ -28931,15 +29597,16 @@ var level2 = (source2) => ({
28931
29597
  function chartExSeriesPaint(source2, series, defaultValues = false) {
28932
29598
  const fill = source2.spPr?.fill;
28933
29599
  if (fill) series.fill = fill;
28934
- const points = {};
29600
+ if (source2.spPr?.line) series.line = source2.spPr.line;
29601
+ const points2 = {};
28935
29602
  const fills = {};
28936
29603
  for (const point of source2.dataPoints) {
28937
29604
  if (point.index === void 0) continue;
28938
29605
  const fill2 = point.spPr?.fill;
28939
- if (fill2?.kind === "solid") points[point.index] = fill2.color;
29606
+ if (fill2?.kind === "solid") points2[point.index] = fill2.color;
28940
29607
  else if (fill2) fills[point.index] = fill2;
28941
29608
  }
28942
- if (Object.keys(points).length) series.pointColors = points;
29609
+ if (Object.keys(points2).length) series.pointColors = points2;
28943
29610
  if (Object.keys(fills).length) series.pointFills = fills;
28944
29611
  const labels = source2.dataLabels;
28945
29612
  if (!labels && !defaultValues) return;
@@ -28962,10 +29629,10 @@ function seriesData(space, series) {
28962
29629
  }
28963
29630
  var findDimension = (data, kind, type) => data?.dimensions.find((d) => d.kind === kind && (d.type ?? "") === type);
28964
29631
  function levelPoints(level3) {
28965
- const points = [];
28966
- for (const point of level3.points) points[point.index ?? points.length] = point.value.trim();
28967
- for (let i = 0; i < Math.max(level3.pointCount ?? 0, points.length); i++) points[i] ??= "";
28968
- return points;
29632
+ const points2 = [];
29633
+ for (const point of level3.points) points2[point.index ?? points2.length] = point.value.trim();
29634
+ for (let i = 0; i < Math.max(level3.pointCount ?? 0, points2.length); i++) points2[i] ??= "";
29635
+ return points2;
28969
29636
  }
28970
29637
  function dimension(data, kind, type) {
28971
29638
  const element4 = findDimension(data, kind, type);
@@ -29014,34 +29681,13 @@ function chartExSummary(source2) {
29014
29681
  if (!isChartExRoot(root)) return void 0;
29015
29682
  return chartExSummaryFromModel(parseChartExSpace(root).chartExSpace);
29016
29683
  }
29017
- function chartExFormatting() {
29018
- return {
29019
- builtInStyle: 2,
29020
- sourceXml: "",
29021
- entries: {
29022
- title: {
29023
- fontSize: 14,
29024
- bold: false,
29025
- textColor: {
29026
- kind: "scheme",
29027
- value: "tx1",
29028
- transforms: [
29029
- { name: "lumMod", value: "65000" },
29030
- { name: "lumOff", value: "35000" }
29031
- ]
29032
- },
29033
- sourceXml: ""
29034
- }
29035
- }
29036
- };
29037
- }
29038
29684
  function summarySeries(space, source2, chartType) {
29039
29685
  const data = seriesData(space, source2);
29040
29686
  const categories = dimension(data, "strDim", "cat");
29041
29687
  const values = dimension(
29042
29688
  data,
29043
29689
  "numDim",
29044
- chartType === "treemap" || chartType === "sunburst" ? "size" : "val"
29690
+ chartType === "treemap" || chartType === "sunburst" ? "size" : chartType === "regionMap" ? "colorVal" : "val"
29045
29691
  );
29046
29692
  const series = {
29047
29693
  categories: categories?.points ?? [],
@@ -29050,11 +29696,24 @@ function summarySeries(space, source2, chartType) {
29050
29696
  ),
29051
29697
  ...seriesFill(source2)
29052
29698
  };
29053
- if (chartType === "funnel" || chartType === "boxWhisker") {
29699
+ if (chartType === "funnel" || chartType === "boxWhisker" || chartType === "regionMap") {
29054
29700
  chartExSeriesPaint(source2, series, chartType === "funnel" && source2.dataLabels !== void 0);
29055
29701
  if (source2.hidden !== void 0) series.hidden = source2.hidden;
29056
29702
  }
29057
29703
  if (chartType === "boxWhisker") series.boxWhisker = source2.layoutProperties ?? {};
29704
+ if (chartType === "regionMap") {
29705
+ const geo = source2.layoutProperties?.geography;
29706
+ series.regionMap = {
29707
+ ...geo,
29708
+ ...geo?.geoCacheXml ? { geographyCacheXml: geo.geoCacheXml } : {},
29709
+ ...dimension(data, "strDim", "entityId") ? { entityIds: dimension(data, "strDim", "entityId").points } : {},
29710
+ ...source2.layoutProperties?.regionLabelLayout ? {
29711
+ regionLabelLayout: source2.layoutProperties.regionLabelLayout
29712
+ } : {},
29713
+ ...source2.valueColorsXml ? { valueColorsXml: source2.valueColorsXml } : {},
29714
+ ...source2.valueColorPositionsXml ? { valueColorPositionsXml: source2.valueColorPositionsXml } : {}
29715
+ };
29716
+ }
29058
29717
  const name = source2.tx?.value?.trim();
29059
29718
  if (name) series.name = name;
29060
29719
  const nameRef = source2.tx?.formula?.formula.trim();
@@ -29067,7 +29726,7 @@ function chartExSummaryFromModel(space) {
29067
29726
  const all = space.plotArea.series;
29068
29727
  const primary = all.find((s) => s.layoutId !== "paretoLine") ?? all[0];
29069
29728
  const layoutId = primary?.layoutId ?? "";
29070
- const chartType = layoutId === "waterfall" ? "waterfall" : layoutId === "clusteredColumn" ? "histogram" : layoutId === "treemap" || layoutId === "sunburst" || layoutId === "funnel" || layoutId === "boxWhisker" ? layoutId : void 0;
29729
+ const chartType = layoutId === "waterfall" ? "waterfall" : layoutId === "clusteredColumn" ? "histogram" : layoutId === "treemap" || layoutId === "sunburst" || layoutId === "funnel" || layoutId === "boxWhisker" || layoutId === "regionMap" ? layoutId : void 0;
29071
29730
  if (!primary || !chartType) return { layoutId };
29072
29731
  const series = summarySeries(space, primary, chartType);
29073
29732
  const layout2 = primary.layoutProperties;
@@ -29105,7 +29764,12 @@ function chartExSummaryFromModel(space) {
29105
29764
  ];
29106
29765
  });
29107
29766
  }
29108
- summary.formatting = chartExFormatting();
29767
+ if (chartType === "funnel") {
29768
+ const cat = space.plotArea.axes.find((axis) => axis.scaling?.kind === "cat")?.scaling;
29769
+ if (cat?.kind === "cat" && typeof cat.gapWidth === "number")
29770
+ summary.funnelGapWidth = cat.gapWidth;
29771
+ }
29772
+ summary.formatting = chartExFormatting(space);
29109
29773
  const title = titleOf(space);
29110
29774
  if (title) summary.title = title;
29111
29775
  const position2 = legend?.position;
@@ -29302,11 +29966,11 @@ function warningsFor(document) {
29302
29966
  ],
29303
29967
  [
29304
29968
  ["rPrChange"],
29305
- "Formatting-change revisions retain their prior run-properties snapshots and support acceptance and rejection; recording new formatting changes and showing prior formatting in Original display are not supported yet."
29969
+ "Formatting-change revisions retain their prior run-properties snapshots and support acceptance, rejection and Original display; supported run-formatting changes are recorded as new revisions, other formatting edits are not."
29306
29970
  ],
29307
29971
  [
29308
29972
  ["pPrChange"],
29309
- "Paragraph-formatting-change revisions retain their prior properties snapshots and support acceptance and rejection; recording new paragraph formatting changes and showing prior formatting in Original display are not supported yet."
29973
+ "Paragraph-formatting-change revisions retain their prior properties snapshots and support acceptance, rejection and Original display; pure paragraph-formatting changes are recorded as new revisions, and revised paragraph-mark merging is not shown yet."
29310
29974
  ],
29311
29975
  [
29312
29976
  ["ffData"],
@@ -29601,6 +30265,7 @@ function parseModernDrawing(node, context) {
29601
30265
  if (picture)
29602
30266
  return {
29603
30267
  ...picture,
30268
+ ...blip?.parentNode ? { pictureFill: parseDrawingPictureFill(blip.parentNode) } : {},
29604
30269
  widthPx,
29605
30270
  heightPx,
29606
30271
  ...definedProps({ altText, title, anchored }),
@@ -29704,7 +30369,7 @@ var add3 = (parent, ...items) => {
29704
30369
  };
29705
30370
  var emu3 = (px2) => String(Math.max(1, Math.round(px2 * EMU_PER_PIXEL)));
29706
30371
  var emuOffset = (px2) => String(Math.round(px2 * EMU_PER_PIXEL));
29707
- var attrs = (element4, values) => {
30372
+ var attrs2 = (element4, values) => {
29708
30373
  for (const [name, value] of Object.entries(values)) element4.setAttribute(name, value);
29709
30374
  return element4;
29710
30375
  };
@@ -29757,9 +30422,9 @@ function textParagraphs(doc, lines2, color) {
29757
30422
  }
29758
30423
  function shapeStyle(doc) {
29759
30424
  const ref = (name, idx, scheme2, shade) => {
29760
- const node = attrs(el2(doc, A_NS2, `a:${name}`), { idx });
29761
- const color = attrs(el2(doc, A_NS2, "a:schemeClr"), { val: scheme2 });
29762
- if (shade) add3(color, attrs(el2(doc, A_NS2, "a:shade"), { val: shade }));
30425
+ const node = attrs2(el2(doc, A_NS2, `a:${name}`), { idx });
30426
+ const color = attrs2(el2(doc, A_NS2, "a:schemeClr"), { val: scheme2 });
30427
+ if (shade) add3(color, attrs2(el2(doc, A_NS2, "a:shade"), { val: shade }));
29763
30428
  return add3(node, color);
29764
30429
  };
29765
30430
  return add3(
@@ -29773,17 +30438,17 @@ function shapeStyle(doc) {
29773
30438
  function wrapElement(doc, placement) {
29774
30439
  switch (placement.wrap) {
29775
30440
  case "square":
29776
- return attrs(el2(doc, WP_NS3, "wp:wrapSquare"), { wrapText: "bothSides" });
30441
+ return attrs2(el2(doc, WP_NS3, "wp:wrapSquare"), { wrapText: "bothSides" });
29777
30442
  case "tight":
29778
30443
  case "through": {
29779
- const wrap2 = attrs(
30444
+ const wrap2 = attrs2(
29780
30445
  el2(doc, WP_NS3, `wp:wrap${placement.wrap === "tight" ? "Tight" : "Through"}`),
29781
30446
  {
29782
30447
  wrapText: "bothSides"
29783
30448
  }
29784
30449
  );
29785
- const polygon = attrs(el2(doc, WP_NS3, "wp:wrapPolygon"), { edited: "0" });
29786
- const point = (name, x, y) => attrs(el2(doc, WP_NS3, `wp:${name}`), { x, y });
30450
+ const polygon = attrs2(el2(doc, WP_NS3, "wp:wrapPolygon"), { edited: "0" });
30451
+ const point = (name, x, y) => attrs2(el2(doc, WP_NS3, `wp:${name}`), { x, y });
29787
30452
  return add3(
29788
30453
  wrap2,
29789
30454
  add3(
@@ -29803,7 +30468,7 @@ function wrapElement(doc, placement) {
29803
30468
  }
29804
30469
  }
29805
30470
  function position(doc, axis, relativeFrom, align, offsetPx) {
29806
- const node = attrs(el2(doc, WP_NS3, `wp:position${axis}`), { relativeFrom });
30471
+ const node = attrs2(el2(doc, WP_NS3, `wp:position${axis}`), { relativeFrom });
29807
30472
  if (align) {
29808
30473
  const a2 = el2(doc, WP_NS3, "wp:align");
29809
30474
  a2.textContent = align;
@@ -29814,10 +30479,10 @@ function position(doc, axis, relativeFrom, align, offsetPx) {
29814
30479
  return add3(node, offset);
29815
30480
  }
29816
30481
  function geometry(doc, spec) {
29817
- const prst = attrs(el2(doc, A_NS2, "a:prstGeom"), { prst: spec.preset });
30482
+ const prst = attrs2(el2(doc, A_NS2, "a:prstGeom"), { prst: spec.preset });
29818
30483
  const avLst = el2(doc, A_NS2, "a:avLst");
29819
30484
  for (const [name, value] of Object.entries(spec.adjustments ?? {}))
29820
- add3(avLst, attrs(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
30485
+ add3(avLst, attrs2(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
29821
30486
  const nodes = spec.customGeometryXml ? importFragment(doc, spec.customGeometryXml) : [add3(prst, avLst)];
29822
30487
  if (spec.fill) {
29823
30488
  const xml = drawingFillXml(spec.fill);
@@ -29833,7 +30498,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
29833
30498
  const anchored = Boolean(image.anchored);
29834
30499
  const holder = el2(doc, WP_NS3, anchored ? "wp:anchor" : "wp:inline");
29835
30500
  if (anchored) {
29836
- attrs(holder, {
30501
+ attrs2(holder, {
29837
30502
  distT: "0",
29838
30503
  distB: "0",
29839
30504
  distL: "114300",
@@ -29847,7 +30512,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
29847
30512
  });
29848
30513
  add3(
29849
30514
  holder,
29850
- attrs(el2(doc, WP_NS3, "wp:simplePos"), { x: "0", y: "0" }),
30515
+ attrs2(el2(doc, WP_NS3, "wp:simplePos"), { x: "0", y: "0" }),
29851
30516
  position(
29852
30517
  doc,
29853
30518
  "H",
@@ -29866,24 +30531,24 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
29866
30531
  } else for (const side of ["distT", "distB", "distL", "distR"]) holder.setAttribute(side, "0");
29867
30532
  add3(
29868
30533
  holder,
29869
- attrs(el2(doc, WP_NS3, "wp:extent"), { cx: emu3(image.widthPx), cy: emu3(image.heightPx) }),
29870
- attrs(el2(doc, WP_NS3, "wp:effectExtent"), { l: "0", t: "0", r: "0", b: "0" })
30534
+ attrs2(el2(doc, WP_NS3, "wp:extent"), { cx: emu3(image.widthPx), cy: emu3(image.heightPx) }),
30535
+ attrs2(el2(doc, WP_NS3, "wp:effectExtent"), { l: "0", t: "0", r: "0", b: "0" })
29871
30536
  );
29872
30537
  if (anchored) add3(holder, wrapElement(doc, placement ?? { wrap: "none" }));
29873
- const docPr = attrs(el2(doc, WP_NS3, "wp:docPr"), {
30538
+ const docPr = attrs2(el2(doc, WP_NS3, "wp:docPr"), {
29874
30539
  id: identity.id,
29875
30540
  name: identity.name ?? `Shape ${identity.id}`
29876
30541
  });
29877
30542
  if (identity.descr) docPr.setAttribute("descr", identity.descr);
29878
30543
  if (identity.title) docPr.setAttribute("title", identity.title);
29879
- const xfrm = attrs(el2(doc, A_NS2, "a:xfrm"), {});
30544
+ const xfrm = attrs2(el2(doc, A_NS2, "a:xfrm"), {});
29880
30545
  if (spec.rotation) xfrm.setAttribute("rot", String(Math.round(spec.rotation * 6e4)));
29881
30546
  if (spec.flipH) xfrm.setAttribute("flipH", "1");
29882
30547
  if (spec.flipV) xfrm.setAttribute("flipV", "1");
29883
30548
  add3(
29884
30549
  xfrm,
29885
- attrs(el2(doc, A_NS2, "a:off"), { x: "0", y: "0" }),
29886
- attrs(el2(doc, A_NS2, "a:ext"), { cx: emu3(image.widthPx), cy: emu3(image.heightPx) })
30550
+ attrs2(el2(doc, A_NS2, "a:off"), { x: "0", y: "0" }),
30551
+ attrs2(el2(doc, A_NS2, "a:ext"), { cx: emu3(image.widthPx), cy: emu3(image.heightPx) })
29887
30552
  );
29888
30553
  const spPr = add3(el2(doc, WPS_NS2, "wps:spPr"), xfrm, ...geometry(doc, spec));
29889
30554
  const wsp = add3(
@@ -29899,7 +30564,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
29899
30564
  );
29900
30565
  add3(wsp, add3(el2(doc, WPS_NS2, "wps:txbx"), content));
29901
30566
  }
29902
- const body = attrs(el2(doc, WPS_NS2, "wps:bodyPr"), {
30567
+ const body = attrs2(el2(doc, WPS_NS2, "wps:bodyPr"), {
29903
30568
  rot: "0",
29904
30569
  vert: "horz",
29905
30570
  wrap: "square",
@@ -29911,7 +30576,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
29911
30576
  anchorCtr: "0"
29912
30577
  });
29913
30578
  add3(wsp, add3(body, el2(doc, A_NS2, "a:noAutofit")));
29914
- const graphicData = attrs(el2(doc, A_NS2, "a:graphicData"), { uri: WPS_NS2 });
30579
+ const graphicData = attrs2(el2(doc, A_NS2, "a:graphicData"), { uri: WPS_NS2 });
29915
30580
  add3(
29916
30581
  holder,
29917
30582
  docPr,
@@ -30027,9 +30692,9 @@ function clearNonProperties(node, keep) {
30027
30692
  var A_NS5 = "http://schemas.openxmlformats.org/drawingml/2006/main";
30028
30693
  var WP_NS5 = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
30029
30694
  var C_NS = "http://schemas.openxmlformats.org/drawingml/2006/chart";
30030
- function child6(parent, ns, name, attrs2 = {}) {
30695
+ function child6(parent, ns, name, attrs3 = {}) {
30031
30696
  const node = makeNS(parent.ownerDocument, ns, name);
30032
- for (const [key, value] of Object.entries(attrs2)) node.setAttribute(key, value);
30697
+ for (const [key, value] of Object.entries(attrs3)) node.setAttribute(key, value);
30033
30698
  parent.appendChild(node);
30034
30699
  return node;
30035
30700
  }
@@ -30415,14 +31080,14 @@ async function writeNewRelationships(zip, partName, created, pendingMedia) {
30415
31080
  overrides.push(relationship2);
30416
31081
  continue;
30417
31082
  }
30418
- const pending = pendingMedia?.get(relationship2.partName);
30419
- if (!pending)
31083
+ const pending2 = pendingMedia?.get(relationship2.partName);
31084
+ if (!pending2)
30420
31085
  throw new Error(`Missing bytes for newly inserted media part: ${relationship2.partName}`);
30421
- zip.file(relationship2.partName, pending.bytes);
31086
+ zip.file(relationship2.partName, pending2.bytes);
30422
31087
  contentTypesXml = ensureContentTypeDefault(
30423
31088
  contentTypesXml,
30424
31089
  extensionOf(relationship2.partName),
30425
- pending.contentType
31090
+ pending2.contentType
30426
31091
  );
30427
31092
  }
30428
31093
  zip.file(relsPath, buildRelationshipsXml(relationships));
@@ -30513,6 +31178,19 @@ async function applyDiagramEdits(zip, blocks, baseBlocks, pendingMedia) {
30513
31178
  ...relaid && layoutId ? { layout: { uniqueId: layoutId, category: diagram.layout?.family } } : {}
30514
31179
  })
30515
31180
  );
31181
+ if (diagram.layoutSource?.pictures?.length) {
31182
+ zip.file(
31183
+ partName,
31184
+ withDiagramPictureSources(await zip.file(partName).async("string"), diagram.layoutSource)
31185
+ );
31186
+ const relsName = relationshipsPartFor2(partName);
31187
+ const rels = diagramPictureRelationships(
31188
+ partName,
31189
+ diagram.layoutSource,
31190
+ await zip.file(relsName)?.async("string")
31191
+ );
31192
+ if (rels) zip.file(relsName, rels);
31193
+ }
30516
31194
  if (drawing) await dropDrawingPart(zip, drawing.relId, drawing.partName, drawing.ownerPart);
30517
31195
  }
30518
31196
  }
@@ -30525,9 +31203,9 @@ var EMU_PER_PIXEL2 = 9525;
30525
31203
  function isSameDiagram(base, next) {
30526
31204
  return Boolean(base?.parts.data?.partName) && base?.parts.data?.partName === next.parts.data?.partName && !next.inserted;
30527
31205
  }
30528
- function el3(doc, ns, qualified, attrs2 = {}) {
31206
+ function el3(doc, ns, qualified, attrs3 = {}) {
30529
31207
  const node = makeNS(doc, ns, qualified);
30530
- for (const [name, value] of Object.entries(attrs2)) node.setAttribute(name, value);
31208
+ for (const [name, value] of Object.entries(attrs3)) node.setAttribute(name, value);
30531
31209
  return node;
30532
31210
  }
30533
31211
  function buildInsertedDiagramDrawing(doc, diagram, widthPx, heightPx, allocator) {
@@ -30677,6 +31355,9 @@ function buildInlineDrawing(doc, image, relId, docPrId, svgRelId) {
30677
31355
  stretch.appendChild(el4(doc, A_NS7, "a:fillRect"));
30678
31356
  const blipFill = el4(doc, PIC_NS, "pic:blipFill");
30679
31357
  appendAll(blipFill, blip, stretch);
31358
+ if (image.pictureFill?.crop) applyPictureCrop(blipFill, image.pictureFill.crop);
31359
+ if (image.pictureFill?.effects) applyPictureEffects(blip, image.pictureFill.effects);
31360
+ if (image.pictureFill?.layout) applyPictureLayout(blipFill, image.pictureFill.layout);
30680
31361
  const xfrm = el4(doc, A_NS7, "a:xfrm");
30681
31362
  const off = el4(doc, A_NS7, "a:off");
30682
31363
  off.setAttribute("x", "0");
@@ -30763,6 +31444,16 @@ function createImageRun(doc, image, base, old, allocator) {
30763
31444
  return node;
30764
31445
  }
30765
31446
  if (base && oldDrawing && sameUnderlyingImage(base, image)) {
31447
+ if (image.pictureFill && JSON.stringify(image.pictureFill) !== JSON.stringify(base.pictureFill)) {
31448
+ const fill = oldDrawing.getElementsByTagNameNS(PIC_NS, "blipFill")[0];
31449
+ const blip = fill?.getElementsByTagNameNS(A_NS7, "blip")[0];
31450
+ if (fill && image.pictureFill.crop !== void 0)
31451
+ applyPictureCrop(fill, image.pictureFill.crop);
31452
+ if (blip && image.pictureFill.effects !== void 0)
31453
+ applyPictureEffects(blip, image.pictureFill.effects);
31454
+ if (fill && image.pictureFill.layout !== void 0)
31455
+ applyPictureLayout(fill, image.pictureFill.layout);
31456
+ }
30766
31457
  if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
30767
31458
  updateExtent(oldDrawing, image.widthPx, image.heightPx);
30768
31459
  if (image.altText !== base.altText || image.title !== base.title)
@@ -31073,7 +31764,7 @@ function writeFormFieldData(doc, field, source2) {
31073
31764
  }
31074
31765
 
31075
31766
  // docx/write-run.ts
31076
- function setAttribute6(element4, local, value) {
31767
+ function setAttribute7(element4, local, value) {
31077
31768
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
31078
31769
  }
31079
31770
  function removeChildren3(element4, local) {
@@ -31083,7 +31774,7 @@ function setToggle2(doc, props, local, value) {
31083
31774
  removeChildren3(props, local);
31084
31775
  if (value === void 0) return;
31085
31776
  const element4 = makeW(doc, local);
31086
- if (!value) setAttribute6(element4, "val", "0");
31777
+ if (!value) setAttribute7(element4, "val", "0");
31087
31778
  props.appendChild(element4);
31088
31779
  }
31089
31780
  function setBooleanAttribute(doc, props, local, value) {
@@ -31096,7 +31787,7 @@ function setBooleanAttribute(doc, props, local, value) {
31096
31787
  element4 = makeW(doc, local);
31097
31788
  props.appendChild(element4);
31098
31789
  }
31099
- setAttribute6(element4, "val", value ? "1" : "0");
31790
+ setAttribute7(element4, "val", value ? "1" : "0");
31100
31791
  }
31101
31792
  function setLanguageAttribute(doc, props, attribute2, value) {
31102
31793
  let language = first2(props, "lang");
@@ -31108,7 +31799,7 @@ function setLanguageAttribute(doc, props, attribute2, value) {
31108
31799
  language = makeW(doc, "lang");
31109
31800
  props.appendChild(language);
31110
31801
  }
31111
- setAttribute6(language, attribute2, value);
31802
+ setAttribute7(language, attribute2, value);
31112
31803
  }
31113
31804
  if (language && !language.attributes.length && !language.childNodes.length)
31114
31805
  props.removeChild(language);
@@ -31139,7 +31830,7 @@ function setRunProperties(doc, runNode, run2, base) {
31139
31830
  removeChildren3(props, "szCs");
31140
31831
  if (run2.fontSizeComplexScript !== void 0) {
31141
31832
  const size = makeW(doc, "szCs");
31142
- setAttribute6(size, "val", String(Math.round(run2.fontSizeComplexScript * 2)));
31833
+ setAttribute7(size, "val", String(Math.round(run2.fontSizeComplexScript * 2)));
31143
31834
  props.appendChild(size);
31144
31835
  }
31145
31836
  }
@@ -31151,13 +31842,13 @@ function setRunProperties(doc, runNode, run2, base) {
31151
31842
  removeChildren3(props, "u");
31152
31843
  if (run2.underline === false) {
31153
31844
  const none = makeW(doc, "u");
31154
- setAttribute6(none, "val", "none");
31845
+ setAttribute7(none, "val", "none");
31155
31846
  props.appendChild(none);
31156
31847
  } else if (run2.underline) {
31157
31848
  const underline = makeW(doc, "u");
31158
- setAttribute6(underline, "val", run2.underlineStyle ?? "single");
31849
+ setAttribute7(underline, "val", run2.underlineStyle ?? "single");
31159
31850
  if (run2.underlineColor)
31160
- setAttribute6(underline, "color", run2.underlineColor.replace(/^#/, ""));
31851
+ setAttribute7(underline, "color", run2.underlineColor.replace(/^#/, ""));
31161
31852
  props.appendChild(underline);
31162
31853
  }
31163
31854
  }
@@ -31165,7 +31856,7 @@ function setRunProperties(doc, runNode, run2, base) {
31165
31856
  removeChildren3(props, "highlight");
31166
31857
  if (run2.highlight) {
31167
31858
  const highlight = makeW(doc, "highlight");
31168
- setAttribute6(highlight, "val", run2.highlight);
31859
+ setAttribute7(highlight, "val", run2.highlight);
31169
31860
  props.appendChild(highlight);
31170
31861
  }
31171
31862
  }
@@ -31173,7 +31864,7 @@ function setRunProperties(doc, runNode, run2, base) {
31173
31864
  removeChildren3(props, "vertAlign");
31174
31865
  if (run2.verticalAlign) {
31175
31866
  const verticalAlign = makeW(doc, "vertAlign");
31176
- setAttribute6(verticalAlign, "val", run2.verticalAlign);
31867
+ setAttribute7(verticalAlign, "val", run2.verticalAlign);
31177
31868
  props.appendChild(verticalAlign);
31178
31869
  }
31179
31870
  }
@@ -31186,7 +31877,7 @@ function setRunProperties(doc, runNode, run2, base) {
31186
31877
  removeChildren3(props, "sz");
31187
31878
  if (run2.fontSize !== void 0) {
31188
31879
  const size = makeW(doc, "sz");
31189
- setAttribute6(size, "val", String(Math.round(run2.fontSize * 2)));
31880
+ setAttribute7(size, "val", String(Math.round(run2.fontSize * 2)));
31190
31881
  props.appendChild(size);
31191
31882
  }
31192
31883
  }
@@ -31195,11 +31886,11 @@ function setRunProperties(doc, runNode, run2, base) {
31195
31886
  if (run2.fontFamily || run2.fontTheme || run2.fontFamilyEastAsia || run2.fontFamilyComplexScript) {
31196
31887
  const fonts = makeW(doc, "rFonts");
31197
31888
  if (run2.fontFamily) {
31198
- setAttribute6(fonts, "ascii", run2.fontFamily);
31199
- setAttribute6(fonts, "hAnsi", run2.fontFamily);
31889
+ setAttribute7(fonts, "ascii", run2.fontFamily);
31890
+ setAttribute7(fonts, "hAnsi", run2.fontFamily);
31200
31891
  }
31201
- if (run2.fontFamilyEastAsia) setAttribute6(fonts, "eastAsia", run2.fontFamilyEastAsia);
31202
- if (run2.fontFamilyComplexScript) setAttribute6(fonts, "cs", run2.fontFamilyComplexScript);
31892
+ if (run2.fontFamilyEastAsia) setAttribute7(fonts, "eastAsia", run2.fontFamilyEastAsia);
31893
+ if (run2.fontFamilyComplexScript) setAttribute7(fonts, "cs", run2.fontFamilyComplexScript);
31203
31894
  const themeAttribute = {
31204
31895
  ascii: ["asciiTheme", "Ascii"],
31205
31896
  hAnsi: ["hAnsiTheme", "HAnsi"],
@@ -31209,7 +31900,7 @@ function setRunProperties(doc, runNode, run2, base) {
31209
31900
  for (const script of ["ascii", "hAnsi", "eastAsia", "cs"]) {
31210
31901
  const role = run2.fontTheme?.[script];
31211
31902
  const [attribute2, suffix] = themeAttribute[script];
31212
- if (role) setAttribute6(fonts, attribute2, `${role}${suffix}`);
31903
+ if (role) setAttribute7(fonts, attribute2, `${role}${suffix}`);
31213
31904
  }
31214
31905
  props.appendChild(fonts);
31215
31906
  }
@@ -31219,13 +31910,13 @@ function setRunProperties(doc, runNode, run2, base) {
31219
31910
  const hex = run2.color && /^#?([0-9a-f]{6})$/i.exec(run2.color)?.[1];
31220
31911
  if (hex || run2.colorTheme) {
31221
31912
  const color = makeW(doc, "color");
31222
- setAttribute6(color, "val", hex || "auto");
31913
+ setAttribute7(color, "val", hex || "auto");
31223
31914
  if (run2.colorTheme) {
31224
- setAttribute6(color, "themeColor", run2.colorTheme.token);
31915
+ setAttribute7(color, "themeColor", run2.colorTheme.token);
31225
31916
  if (run2.colorTheme.tint !== void 0)
31226
- setAttribute6(color, "themeTint", fractionToThemeByte(run2.colorTheme.tint));
31917
+ setAttribute7(color, "themeTint", fractionToThemeByte(run2.colorTheme.tint));
31227
31918
  if (run2.colorTheme.shade !== void 0)
31228
- setAttribute6(color, "themeShade", fractionToThemeByte(run2.colorTheme.shade));
31919
+ setAttribute7(color, "themeShade", fractionToThemeByte(run2.colorTheme.shade));
31229
31920
  }
31230
31921
  props.appendChild(color);
31231
31922
  }
@@ -31274,13 +31965,13 @@ function createRun(doc, run2, base, old, allocator) {
31274
31965
  if (child7.nodeType !== 1 || child7.localName !== "rPr") node.removeChild(child7);
31275
31966
  if (run2.break) {
31276
31967
  const br = makeW(doc, "br");
31277
- setAttribute6(br, "type", run2.break);
31968
+ setAttribute7(br, "type", run2.break);
31278
31969
  node.appendChild(br);
31279
31970
  return node;
31280
31971
  }
31281
31972
  if (run2.fieldChar) {
31282
31973
  const marker = makeW(doc, "fldChar");
31283
- setAttribute6(marker, "fldCharType", run2.fieldChar);
31974
+ setAttribute7(marker, "fldCharType", run2.fieldChar);
31284
31975
  writeFieldFlags(marker, run2.fieldFlags);
31285
31976
  if (run2.fieldChar === "begin" && run2.formField)
31286
31977
  marker.appendChild(writeFormFieldData(doc, run2.formField, formData));
@@ -31307,7 +31998,7 @@ function createRun(doc, run2, base, old, allocator) {
31307
31998
  doc,
31308
31999
  run2.noteReference.kind === "footnote" ? "footnoteReference" : "endnoteReference"
31309
32000
  );
31310
- setAttribute6(reference, "id", run2.noteReference.id);
32001
+ setAttribute7(reference, "id", run2.noteReference.id);
31311
32002
  node.appendChild(reference);
31312
32003
  return node;
31313
32004
  }
@@ -32043,7 +32734,7 @@ function runsToWriteAnew(paragraph2, base, slots) {
32043
32734
  }
32044
32735
 
32045
32736
  // docx/write-paragraph.ts
32046
- function setAttribute7(element4, local, value) {
32737
+ function setAttribute8(element4, local, value) {
32047
32738
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
32048
32739
  }
32049
32740
  function removeChildren4(element4, local) {
@@ -32087,7 +32778,7 @@ function writeParagraphImpl(doc, paragraph2, node, base, allocator, spans) {
32087
32778
  const jc = paragraphJustification(paragraph2);
32088
32779
  if (jc) {
32089
32780
  const align = makeW(doc, "jc");
32090
- setAttribute7(align, "val", jc);
32781
+ setAttribute8(align, "val", jc);
32091
32782
  pPr.appendChild(align);
32092
32783
  }
32093
32784
  }
@@ -32095,7 +32786,7 @@ function writeParagraphImpl(doc, paragraph2, node, base, allocator, spans) {
32095
32786
  removeChildren4(pPr, "pStyle");
32096
32787
  if (paragraph2.style) {
32097
32788
  const style = makeW(doc, "pStyle");
32098
- setAttribute7(style, "val", paragraph2.style);
32789
+ setAttribute8(style, "val", paragraph2.style);
32099
32790
  pPr.appendChild(style);
32100
32791
  }
32101
32792
  }
@@ -32120,7 +32811,14 @@ function writeParagraphImpl(doc, paragraph2, node, base, allocator, spans) {
32120
32811
  const source2 = new Set(sourceBookmarks);
32121
32812
  const kept = /* @__PURE__ */ new Set([...starts, ...ends]);
32122
32813
  const sourcePositions = runPositions(base?.runs ?? []);
32123
- const read = markers.filter((marker) => !isBookmark(marker.element) || kept.has(marker.element)).map((marker) => {
32814
+ const permissions = changedPermissionMarkers(
32815
+ doc,
32816
+ paragraph2,
32817
+ base,
32818
+ markers.map((marker) => marker.element),
32819
+ runPositions(paragraph2.runs).at(-1)
32820
+ );
32821
+ const read = markers.filter((marker) => !isBookmark(marker.element) || kept.has(marker.element)).filter((marker) => !permissions?.drop.has(marker.element)).map((marker) => {
32124
32822
  const position2 = sourcePositions[marker.boundary] ?? 0;
32125
32823
  const annotation = marker.annotation;
32126
32824
  return {
@@ -32135,8 +32833,8 @@ function writeParagraphImpl(doc, paragraph2, node, base, allocator, spans) {
32135
32833
  });
32136
32834
  const end = runPositions(paragraph2.runs).at(-1);
32137
32835
  const sources = containerSources(paragraph2.runs, base?.runs, slots);
32138
- const carried = orderRangeEnds(
32139
- base ? followFormFieldBookmarks(
32836
+ const carried = orderRangeEnds([
32837
+ ...base ? followFormFieldBookmarks(
32140
32838
  followContainers(
32141
32839
  moveMarkers(base.runs, paragraph2.runs, read),
32142
32840
  sources,
@@ -32145,8 +32843,9 @@ function writeParagraphImpl(doc, paragraph2, node, base, allocator, spans) {
32145
32843
  ),
32146
32844
  base.runs,
32147
32845
  paragraph2.runs
32148
- ) : read.map((marker) => ({ ...marker, position: marker.opening ? 0 : end }))
32149
- );
32846
+ ) : read.map((marker) => ({ ...marker, position: marker.opening ? 0 : end })),
32847
+ ...permissions?.added ?? []
32848
+ ]);
32150
32849
  for (const marker of markers) marker.element.parentNode?.removeChild(marker.element);
32151
32850
  for (const oldNode of replaceableInlineChildren(node)) node.removeChild(oldNode);
32152
32851
  const { nodes, placed, containers } = buildInlineContent(
@@ -32295,21 +32994,21 @@ function applyModel(doc, model, original, reservedRelationshipIds = [], baseSect
32295
32994
  size = makeW(doc, "pgSz");
32296
32995
  section.appendChild(size);
32297
32996
  }
32298
- setAttribute7(size, "w", twips2(model.page.width));
32299
- setAttribute7(size, "h", twips2(model.page.height));
32997
+ setAttribute8(size, "w", twips2(model.page.width));
32998
+ setAttribute8(size, "h", twips2(model.page.height));
32300
32999
  let margins = first2(section, "pgMar");
32301
33000
  if (!margins) {
32302
33001
  margins = makeW(doc, "pgMar");
32303
33002
  section.appendChild(margins);
32304
33003
  }
32305
33004
  for (const side of ["Top", "Right", "Bottom", "Left"])
32306
- setAttribute7(margins, side.toLowerCase(), twips2(model.page[`margin${side}`]));
33005
+ setAttribute8(margins, side.toLowerCase(), twips2(model.page[`margin${side}`]));
32307
33006
  for (const [name, fallback] of [
32308
33007
  ["header", "720"],
32309
33008
  ["footer", "720"],
32310
33009
  ["gutter", "0"]
32311
33010
  ])
32312
- if (!margins.getAttributeNS(WORD_NS, name)) setAttribute7(margins, name, fallback);
33011
+ if (!margins.getAttributeNS(WORD_NS, name)) setAttribute8(margins, name, fallback);
32313
33012
  orderSectionProperties(section);
32314
33013
  if (model.sections)
32315
33014
  applySectionEdits(
@@ -32783,6 +33482,122 @@ function assertValidDocumentModel(model) {
32783
33482
  if (issues.length) throw new DocxModelValidationError(issues);
32784
33483
  }
32785
33484
 
33485
+ // docx/numbering-picture.ts
33486
+ var NUMBERING_PART = "word/numbering.xml";
33487
+ var descendants4 = (root, local) => Array.from(root.getElementsByTagName("*")).filter(
33488
+ (node) => node.nodeType === 1 && node.localName === local
33489
+ );
33490
+ var points = (style, property) => {
33491
+ const match = new RegExp(`(?:^|;)\\s*${property}:\\s*([\\d.]+)(pt|px|in|cm|mm)?`, "i").exec(
33492
+ style
33493
+ );
33494
+ if (!match) return void 0;
33495
+ const value = Number(match[1]);
33496
+ const unit = (match[2] ?? "pt").toLowerCase();
33497
+ const factor = { pt: 1, px: 0.75, in: 72, cm: 72 / 2.54, mm: 72 / 25.4 }[unit] ?? 1;
33498
+ return Number.isFinite(value) && value > 0 ? value * factor : void 0;
33499
+ };
33500
+ function parsePictureBullet(element4, rels) {
33501
+ const id = getW(element4, "numPicBulletId");
33502
+ if (id === void 0) return void 0;
33503
+ const imagedata = descendants4(element4, "imagedata")[0];
33504
+ const blip = descendants4(element4, "blip")[0];
33505
+ const relId = imagedata && getR(imagedata, "id") || blip && getR(blip, "embed") || void 0;
33506
+ const rel = relId ? rels.get(relId) : void 0;
33507
+ if (!rel || rel.mode === "External") return void 0;
33508
+ const partName = resolvePartPath(NUMBERING_PART, rel.target);
33509
+ const result = {
33510
+ id,
33511
+ partName,
33512
+ contentType: imageContentType(partName)
33513
+ };
33514
+ const style = descendants4(element4, "shape")[0]?.getAttribute("style") ?? "";
33515
+ let width = points(style, "width");
33516
+ let height = points(style, "height");
33517
+ const extent = descendants4(element4, "extent")[0];
33518
+ if (extent && width === void 0 && height === void 0) {
33519
+ const cx = Number(extent.getAttribute("cx"));
33520
+ const cy = Number(extent.getAttribute("cy"));
33521
+ if (cx > 0 && cy > 0) {
33522
+ width = cx / 12700;
33523
+ height = cy / 12700;
33524
+ }
33525
+ }
33526
+ if (width !== void 0) result.widthPt = width;
33527
+ if (height !== void 0) result.heightPt = height;
33528
+ return result;
33529
+ }
33530
+ function parseNumberingPictureBullets(root, rels) {
33531
+ const bullets = /* @__PURE__ */ Object.create(null);
33532
+ if (!rels) return bullets;
33533
+ for (const element4 of descendants4(root, "numPicBullet")) {
33534
+ const parsed = parsePictureBullet(element4, rels);
33535
+ if (parsed) bullets[parsed.id] = parsed;
33536
+ }
33537
+ return bullets;
33538
+ }
33539
+
33540
+ // docx/numbering-picture-save.ts
33541
+ var VML_NS3 = "urn:schemas-microsoft-com:vml";
33542
+ var OFFICE_NS2 = "urn:schemas-microsoft-com:office:office";
33543
+ var R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
33544
+ var IMAGE_REL = `${R_NS}/image`;
33545
+ function addedPictureBullets(prior, next) {
33546
+ for (const [id, bullet] of Object.entries(prior?.pictureBullets ?? {}))
33547
+ if (JSON.stringify(next.pictureBullets?.[id]) !== JSON.stringify(bullet))
33548
+ throw new Error(
33549
+ `Cannot edit picture bullet "${id}"; the original numbering.xml and its images are preserved unchanged.`
33550
+ );
33551
+ return Object.values(next.pictureBullets ?? {}).filter(
33552
+ (bullet) => !prior?.pictureBullets?.[bullet.id]
33553
+ );
33554
+ }
33555
+ function buildPictureBullet(doc, bullet, relId, serial) {
33556
+ const element4 = makeW(doc, "numPicBullet");
33557
+ element4.setAttributeNS(WORD_NS, "w:numPicBulletId", bullet.id);
33558
+ const pict = makeW(doc, "pict");
33559
+ const shape = makeNS(doc, VML_NS3, "v:shape");
33560
+ shape.setAttribute("id", `_x0000_i${1025 + serial}`);
33561
+ shape.setAttribute("type", "#_x0000_t75");
33562
+ const width = bullet.widthPt ?? bullet.heightPt ?? 9;
33563
+ const height = bullet.heightPt ?? width;
33564
+ shape.setAttribute("style", `width:${+width.toFixed(2)}pt;height:${+height.toFixed(2)}pt`);
33565
+ shape.setAttributeNS(OFFICE_NS2, "o:bullet", "t");
33566
+ const imagedata = makeNS(doc, VML_NS3, "v:imagedata");
33567
+ imagedata.setAttributeNS(R_NS, "r:id", relId);
33568
+ imagedata.setAttributeNS(OFFICE_NS2, "o:title", "");
33569
+ shape.appendChild(imagedata);
33570
+ pict.appendChild(shape);
33571
+ element4.appendChild(pict);
33572
+ return element4;
33573
+ }
33574
+ async function writePictureBullets(zip, doc, added, before, pendingMedia) {
33575
+ if (!added.length) return;
33576
+ const used = new Set(
33577
+ parseRelationships(
33578
+ await zip.file(relationshipsPartFor2(NUMBERING_PART))?.async("string")
33579
+ ).keys()
33580
+ );
33581
+ let serial = 1;
33582
+ const relationships = added.map((bullet, index) => {
33583
+ while (used.has(`rId${serial}`)) serial++;
33584
+ const id = `rId${serial}`;
33585
+ used.add(id);
33586
+ doc.documentElement.insertBefore(buildPictureBullet(doc, bullet, id, index), before);
33587
+ const stored = zip.file(bullet.partName) !== null;
33588
+ if (!stored && !pendingMedia?.get(bullet.partName))
33589
+ throw new Error(`Missing bytes for picture bullet image: ${bullet.partName}`);
33590
+ return {
33591
+ id,
33592
+ type: IMAGE_REL,
33593
+ target: bullet.partName.replace(/^word\//, ""),
33594
+ mode: "Internal",
33595
+ ...stored ? {} : { partName: bullet.partName }
33596
+ };
33597
+ });
33598
+ await writeNewRelationships(zip, NUMBERING_PART, relationships, pendingMedia);
33599
+ }
33600
+
32786
33601
  // docx/numbering-parts.ts
32787
33602
  var CT_NS = "http://schemas.openxmlformats.org/package/2006/content-types";
32788
33603
  var REL_NS2 = "http://schemas.openxmlformats.org/package/2006/relationships";
@@ -32874,6 +33689,8 @@ function parseNumberingLevel(lvl) {
32874
33689
  if (flag(first2(lvl, "isLgl"))) result.isLgl = true;
32875
33690
  const restart = getW(first2(lvl, "lvlRestart"), "val");
32876
33691
  if (restart !== void 0) result.lvlRestart = integer3(restart, 0);
33692
+ const pictureBulletId = getW(first2(lvl, "lvlPicBulletId"), "val");
33693
+ if (pictureBulletId !== void 0) result.pictureBulletId = pictureBulletId;
32877
33694
  const marker = parseMarkerFormat(first2(lvl, "rPr"));
32878
33695
  if (marker) result.markerFormat = marker;
32879
33696
  result.suffix = suffRaw === "space" ? "space" : suffRaw === "nothing" ? "none" : "tab";
@@ -32909,7 +33726,7 @@ function parseNum(element4) {
32909
33726
  ...Object.keys(levelOverrides).length ? { levelOverrides } : {}
32910
33727
  };
32911
33728
  }
32912
- function parseNumberingCatalog(xml) {
33729
+ function parseNumberingCatalog(xml, relationships) {
32913
33730
  const document = parseXml2(xml);
32914
33731
  const root = document.documentElement;
32915
33732
  const abstractNums = dictionary();
@@ -32923,17 +33740,30 @@ function parseNumberingCatalog(xml) {
32923
33740
  warnings.push(
32924
33741
  `Numbering definition abstractNum ${parsed.id} links to style "${link}"; style-linked numbering levels are not resolved.`
32925
33742
  );
32926
- if (byName(element4, "lvlPicBulletId").length)
32927
- warnings.push(
32928
- `Numbering definition abstractNum ${parsed.id} uses a picture bullet; picture bullets are not rendered.`
32929
- );
32930
33743
  }
33744
+ const pictureBullets = parseNumberingPictureBullets(
33745
+ root,
33746
+ relationships
33747
+ );
33748
+ for (const element4 of byName(root, "abstractNum"))
33749
+ for (const ref of byName(element4, "lvlPicBulletId")) {
33750
+ const id = getW(ref, "val");
33751
+ if (id !== void 0 && !own(pictureBullets, id))
33752
+ warnings.push(
33753
+ `Numbering definition abstractNum ${getW(element4, "abstractNumId")} uses picture bullet ${id}, whose image could not be resolved; the level falls back to its bullet glyph.`
33754
+ );
33755
+ }
32931
33756
  const nums = dictionary();
32932
33757
  for (const element4 of byName(root, "num")) {
32933
33758
  const parsed = parseNum(element4);
32934
33759
  if (parsed) nums[parsed.id] = parsed;
32935
33760
  }
32936
- return { abstractNums, nums, warnings: [...new Set(warnings)] };
33761
+ return {
33762
+ abstractNums,
33763
+ nums,
33764
+ ...Object.keys(pictureBullets).length ? { pictureBullets } : {},
33765
+ warnings: [...new Set(warnings)]
33766
+ };
32937
33767
  }
32938
33768
  function resolveNumberingLevel(catalog, numId, level3) {
32939
33769
  const num2 = own(catalog.nums, numId);
@@ -33039,17 +33869,18 @@ function patchNumberingStarts(doc, changes) {
33039
33869
  }
33040
33870
 
33041
33871
  // docx/numbering-package.ts
33042
- function setAttribute8(element4, local, value) {
33872
+ var addedAbstractIds = (prior, next) => Object.keys(next.abstractNums).filter((id) => !prior?.abstractNums[id]);
33873
+ function setAttribute9(element4, local, value) {
33043
33874
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
33044
33875
  }
33045
33876
  function valueElement(doc, local, value) {
33046
33877
  const element4 = makeW(doc, local);
33047
- setAttribute8(element4, "val", value);
33878
+ setAttribute9(element4, "val", value);
33048
33879
  return element4;
33049
33880
  }
33050
33881
  function buildLevelElement(doc, def) {
33051
33882
  const lvl = makeW(doc, "lvl");
33052
- setAttribute8(lvl, "ilvl", String(def.level));
33883
+ setAttribute9(lvl, "ilvl", String(def.level));
33053
33884
  if (!def.startWasOmitted || def.start !== 1)
33054
33885
  lvl.appendChild(valueElement(doc, "start", String(def.start)));
33055
33886
  lvl.appendChild(valueElement(doc, "numFmt", def.numFmt));
@@ -33065,22 +33896,24 @@ function buildLevelElement(doc, def) {
33065
33896
  )
33066
33897
  );
33067
33898
  lvl.appendChild(valueElement(doc, "lvlText", def.lvlText));
33899
+ if (def.pictureBulletId !== void 0)
33900
+ lvl.appendChild(valueElement(doc, "lvlPicBulletId", def.pictureBulletId));
33068
33901
  if (def.lvlJc) lvl.appendChild(valueElement(doc, "lvlJc", def.lvlJc));
33069
33902
  if (def.tabStopTwips !== void 0 || def.indentLeftTwips !== void 0 || def.hangingTwips !== void 0 || def.firstLineTwips !== void 0) {
33070
33903
  const pPr = makeW(doc, "pPr");
33071
33904
  if (def.tabStopTwips !== void 0) {
33072
33905
  const tabs = makeW(doc, "tabs");
33073
33906
  const tab = makeW(doc, "tab");
33074
- setAttribute8(tab, "val", "num");
33075
- setAttribute8(tab, "pos", String(def.tabStopTwips));
33907
+ setAttribute9(tab, "val", "num");
33908
+ setAttribute9(tab, "pos", String(def.tabStopTwips));
33076
33909
  tabs.appendChild(tab);
33077
33910
  pPr.appendChild(tabs);
33078
33911
  }
33079
33912
  const ind = makeW(doc, "ind");
33080
- if (def.indentLeftTwips !== void 0) setAttribute8(ind, "left", String(def.indentLeftTwips));
33081
- if (def.hangingTwips !== void 0) setAttribute8(ind, "hanging", String(def.hangingTwips));
33913
+ if (def.indentLeftTwips !== void 0) setAttribute9(ind, "left", String(def.indentLeftTwips));
33914
+ if (def.hangingTwips !== void 0) setAttribute9(ind, "hanging", String(def.hangingTwips));
33082
33915
  if (def.firstLineTwips !== void 0)
33083
- setAttribute8(ind, "firstLine", String(def.firstLineTwips));
33916
+ setAttribute9(ind, "firstLine", String(def.firstLineTwips));
33084
33917
  if (ind.attributes.length) pPr.appendChild(ind);
33085
33918
  lvl.appendChild(pPr);
33086
33919
  }
@@ -33089,8 +33922,8 @@ function buildLevelElement(doc, def) {
33089
33922
  const rPr = makeW(doc, "rPr");
33090
33923
  if (marker.fontFamily) {
33091
33924
  const fonts = makeW(doc, "rFonts");
33092
- setAttribute8(fonts, "ascii", marker.fontFamily);
33093
- setAttribute8(fonts, "hAnsi", marker.fontFamily);
33925
+ setAttribute9(fonts, "ascii", marker.fontFamily);
33926
+ setAttribute9(fonts, "hAnsi", marker.fontFamily);
33094
33927
  rPr.appendChild(fonts);
33095
33928
  }
33096
33929
  if (marker.bold) rPr.appendChild(makeW(doc, "b"));
@@ -33105,7 +33938,7 @@ function buildLevelElement(doc, def) {
33105
33938
  }
33106
33939
  function buildAbstractNumElement(doc, def) {
33107
33940
  const element4 = makeW(doc, "abstractNum");
33108
- setAttribute8(element4, "abstractNumId", def.id);
33941
+ setAttribute9(element4, "abstractNumId", def.id);
33109
33942
  element4.appendChild(valueElement(doc, "multiLevelType", "hybridMultilevel"));
33110
33943
  for (const level3 of Object.values(def.levels).sort((a2, b) => a2.level - b.level))
33111
33944
  element4.appendChild(buildLevelElement(doc, level3));
@@ -33113,11 +33946,11 @@ function buildAbstractNumElement(doc, def) {
33113
33946
  }
33114
33947
  function buildNumElement(doc, def) {
33115
33948
  const element4 = makeW(doc, "num");
33116
- setAttribute8(element4, "numId", def.id);
33949
+ setAttribute9(element4, "numId", def.id);
33117
33950
  element4.appendChild(valueElement(doc, "abstractNumId", def.abstractNumId));
33118
33951
  for (const [level3, override] of Object.entries(def.levelOverrides ?? {})) {
33119
33952
  const lvlOverride = makeW(doc, "lvlOverride");
33120
- setAttribute8(lvlOverride, "ilvl", level3);
33953
+ setAttribute9(lvlOverride, "ilvl", level3);
33121
33954
  if (override.startOverride !== void 0)
33122
33955
  lvlOverride.appendChild(valueElement(doc, "startOverride", String(override.startOverride)));
33123
33956
  if (override.lvl) lvlOverride.appendChild(buildLevelElement(doc, override.lvl));
@@ -33125,7 +33958,7 @@ function buildNumElement(doc, def) {
33125
33958
  }
33126
33959
  return element4;
33127
33960
  }
33128
- async function applyNumberingCatalog(zip, model, binding) {
33961
+ async function applyNumberingCatalog(zip, model, binding, pendingMedia) {
33129
33962
  const next = model.numberingCatalog;
33130
33963
  const prior = binding?.base.numberingCatalog;
33131
33964
  if (JSON.stringify(next ?? null) === JSON.stringify(prior ?? null)) return;
@@ -33137,6 +33970,14 @@ async function applyNumberingCatalog(zip, model, binding) {
33137
33970
  throw new Error(
33138
33971
  "Removing the numbering catalog is not supported; the source numbering.xml is preserved unchanged."
33139
33972
  );
33973
+ const addedPictures = addedPictureBullets(prior, next);
33974
+ for (const level3 of addedAbstractIds(prior, next).flatMap(
33975
+ (id) => Object.values(next.abstractNums[id]?.levels ?? {})
33976
+ ))
33977
+ if (level3.pictureBulletId !== void 0 && !next.pictureBullets?.[level3.pictureBulletId])
33978
+ throw new Error(
33979
+ `Level ${level3.level} references picture bullet "${level3.pictureBulletId}", which the numbering part does not define.`
33980
+ );
33140
33981
  for (const id of Object.keys(prior?.abstractNums ?? {}))
33141
33982
  if (JSON.stringify(next.abstractNums[id]) !== JSON.stringify(prior?.abstractNums[id]))
33142
33983
  throw new Error(
@@ -33145,12 +33986,20 @@ async function applyNumberingCatalog(zip, model, binding) {
33145
33986
  const startChanges = numberingStartChanges(prior, next);
33146
33987
  const newAbstractIds = Object.keys(next.abstractNums).filter((id) => !prior?.abstractNums[id]);
33147
33988
  const newNumIds = Object.keys(next.nums).filter((id) => !prior?.nums[id]);
33148
- if (!newAbstractIds.length && !newNumIds.length && !startChanges.length) return;
33989
+ if (!newAbstractIds.length && !newNumIds.length && !startChanges.length && !addedPictures.length)
33990
+ return;
33149
33991
  const existingFile = zip.file("word/numbering.xml");
33150
33992
  const doc = existingFile ? parseXml2(await existingFile.async("string")) : parseXml2(`<w:numbering xmlns:w="${WORD_NS}"/>`);
33151
33993
  const root = doc.documentElement;
33152
33994
  patchNumberingStarts(doc, startChanges);
33153
33995
  const cleanup = children2(root, "numIdMacAtCleanup")[0] ?? null;
33996
+ await writePictureBullets(
33997
+ zip,
33998
+ doc,
33999
+ addedPictures,
34000
+ children2(root, "abstractNum")[0] ?? children2(root, "num")[0] ?? cleanup,
34001
+ pendingMedia
34002
+ );
33154
34003
  const firstNum = children2(root, "num")[0] ?? cleanup;
33155
34004
  for (const id of newAbstractIds) {
33156
34005
  const abstractNum = next.abstractNums[id];
@@ -33429,6 +34278,55 @@ async function applyNoteEdits(zip, model, base, pendingMedia, docPrIds) {
33429
34278
  }
33430
34279
  }
33431
34280
 
34281
+ // docx/protection.ts
34282
+ var DIGEST_BY_SID = {
34283
+ 1: "MD2",
34284
+ 2: "MD4",
34285
+ 3: "MD5",
34286
+ 4: "SHA-1",
34287
+ 7: "RIPEMD-128",
34288
+ 8: "RIPEMD-160",
34289
+ 12: "SHA-256",
34290
+ 13: "SHA-384",
34291
+ 14: "SHA-512"
34292
+ };
34293
+ var integer4 = (value) => {
34294
+ const number2 = value === void 0 ? NaN : Number(value);
34295
+ return Number.isInteger(number2) ? number2 : void 0;
34296
+ };
34297
+ function readProtectionPassword(element4) {
34298
+ const hashValue = getW(element4, "hashValue");
34299
+ const saltValue = getW(element4, "saltValue");
34300
+ const algorithmName = getW(element4, "algorithmName");
34301
+ if (hashValue && saltValue && algorithmName) {
34302
+ const spinCount2 = integer4(getW(element4, "spinCount"));
34303
+ return {
34304
+ password: {
34305
+ algorithmName,
34306
+ hashValue,
34307
+ saltValue,
34308
+ ...spinCount2 !== void 0 && { spinCount: spinCount2 }
34309
+ }
34310
+ };
34311
+ }
34312
+ const hash = getW(element4, "hash");
34313
+ if (!hash) return {};
34314
+ const sid = integer4(getW(element4, "cryptAlgorithmSid"));
34315
+ const salt = getW(element4, "salt");
34316
+ const digest = sid === void 0 ? void 0 : DIGEST_BY_SID[sid];
34317
+ if (sid === void 0 || !digest || !salt) return { unverifiable: true };
34318
+ const spinCount = integer4(getW(element4, "cryptSpinCount"));
34319
+ return {
34320
+ password: {
34321
+ algorithmName: digest,
34322
+ hashValue: hash,
34323
+ saltValue: salt,
34324
+ ...spinCount !== void 0 && { spinCount },
34325
+ word: { algorithmSid: sid }
34326
+ }
34327
+ };
34328
+ }
34329
+
33432
34330
  // docx/settings.ts
33433
34331
  var SETTINGS_PATH = "word/settings.xml";
33434
34332
  var SETTINGS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml";
@@ -33543,10 +34441,14 @@ function parseFormSettings(xml) {
33543
34441
  if (!root) return {};
33544
34442
  const protect = children2(root, "documentProtection")[0];
33545
34443
  const edit = protect && getW(protect, "edit");
34444
+ const secret = protect && readProtectionPassword(protect);
33546
34445
  return {
33547
34446
  ...protect && {
33548
34447
  protection: {
33549
34448
  edit: isStDocProtect(edit) ? edit : "none",
34449
+ ...parseOnOff(getW(protect, "formatting")) === true && { formatting: true },
34450
+ ...secret?.password && { password: secret.password },
34451
+ ...secret?.unverifiable && { unverifiablePassword: true },
33550
34452
  // Word enforces the protection unless `w:enforcement` turns it off ([MS-OE376]
33551
34453
  // 2.1.410), where ECMA-376 would ignore it when the attribute is missing.
33552
34454
  enforced: parseOnOff(getW(protect, "enforcement")) !== false
@@ -33635,6 +34537,51 @@ async function applyCompatibilityMode(zip, mode) {
33635
34537
  await ensureDocumentRelationship(zip, SETTINGS_RELATIONSHIP_TYPE, "settings.xml");
33636
34538
  }
33637
34539
  }
34540
+ function protectionElement(doc, protection) {
34541
+ const element4 = makeW(doc, "documentProtection");
34542
+ const set2 = (name, value) => element4.setAttributeNS(WORD_NS, `w:${name}`, String(value));
34543
+ set2("edit", protection.edit);
34544
+ if (protection.formatting) set2("formatting", 1);
34545
+ set2("enforcement", protection.enforced ? 1 : 0);
34546
+ const secret = protection.password;
34547
+ if (secret?.word) {
34548
+ set2("cryptProviderType", "rsaAES");
34549
+ set2("cryptAlgorithmClass", "hash");
34550
+ set2("cryptAlgorithmType", "typeAny");
34551
+ set2("cryptAlgorithmSid", secret.word.algorithmSid);
34552
+ if (secret.spinCount !== void 0) set2("cryptSpinCount", secret.spinCount);
34553
+ set2("hash", secret.hashValue);
34554
+ set2("salt", secret.saltValue);
34555
+ } else if (secret) {
34556
+ set2("algorithmName", secret.algorithmName);
34557
+ set2("hashValue", secret.hashValue);
34558
+ set2("saltValue", secret.saltValue);
34559
+ if (secret.spinCount !== void 0) set2("spinCount", secret.spinCount);
34560
+ }
34561
+ return element4;
34562
+ }
34563
+ async function applyDocumentProtection(zip, protection) {
34564
+ const file = zip.file(SETTINGS_PATH);
34565
+ if (!file && !protection) return;
34566
+ const doc = parseXml2(
34567
+ await file?.async("string") ?? `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:settings xmlns:w="${WORD_NS}"></w:settings>`
34568
+ );
34569
+ const root = doc.documentElement;
34570
+ for (const element4 of children2(root, "documentProtection")) root.removeChild(element4);
34571
+ if (protection) {
34572
+ const rank2 = SETTINGS_ORDER.indexOf("documentProtection");
34573
+ const after = Array.from(root.childNodes).find((node) => {
34574
+ const index = SETTINGS_ORDER.indexOf(node.localName ?? "");
34575
+ return node.nodeType === 1 && index > rank2;
34576
+ });
34577
+ root.insertBefore(protectionElement(doc, protection), after ?? null);
34578
+ }
34579
+ zip.file(SETTINGS_PATH, buildXml(doc));
34580
+ if (!file) {
34581
+ await ensureContentTypeOverride(zip, SETTINGS_PATH, SETTINGS_CONTENT_TYPE);
34582
+ await ensureDocumentRelationship(zip, SETTINGS_RELATIONSHIP_TYPE, "settings.xml");
34583
+ }
34584
+ }
33638
34585
 
33639
34586
  // docx/page-background.ts
33640
34587
  var HEX = /^[0-9a-fA-F]{6}$/;
@@ -33987,6 +34934,7 @@ function computeListLabels(model) {
33987
34934
  if (def.numFmt === "none") continue;
33988
34935
  counters.advance(numId, level3, def, catalog);
33989
34936
  const text = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId, level3, catalog, counters, Boolean(def.isLgl));
34937
+ const picture = def.pictureBulletId !== void 0 ? catalog.pictureBullets?.[def.pictureBulletId] : void 0;
33990
34938
  labels.set(paragraph2.id, {
33991
34939
  numId,
33992
34940
  level: level3,
@@ -33998,7 +34946,8 @@ function computeListLabels(model) {
33998
34946
  hangingTwips: def.hangingTwips,
33999
34947
  firstLineTwips: def.firstLineTwips,
34000
34948
  markerFormat: def.markerFormat,
34001
- tabStopTwips: def.tabStopTwips
34949
+ tabStopTwips: def.tabStopTwips,
34950
+ picture
34002
34951
  })
34003
34952
  });
34004
34953
  }
@@ -34431,6 +35380,7 @@ async function applyGeneratedDiagramCaches(zip, blocks, baseBlocks, theme) {
34431
35380
  const colorsXml = await read("colors");
34432
35381
  const quickStyleXml = await read("quickStyle");
34433
35382
  const source2 = {
35383
+ ...diagram.layoutSource,
34434
35384
  ...layoutXml3 ? { layoutXml: layoutXml3 } : {},
34435
35385
  ...colorsXml ? { colorsXml } : {},
34436
35386
  ...quickStyleXml ? { quickStyleXml } : {}
@@ -34455,6 +35405,8 @@ async function applyGeneratedDiagramCaches(zip, blocks, baseBlocks, theme) {
34455
35405
  );
34456
35406
  zip.file(name, withDiagramDrawingRelationship(cache.dataXml, relationship2));
34457
35407
  zip.file(drawingName, cache.drawingXml);
35408
+ const pictureRels = diagramPictureRelationships(drawingName, diagram.layoutSource);
35409
+ if (pictureRels) zip.file(drawingName.replace(/([^/]+)$/, "_rels/$1.rels"), pictureRels);
34458
35410
  await ensureContentTypeOverride(zip, drawingName, DIAGRAM_CONTENT_TYPES.drawing);
34459
35411
  }
34460
35412
  }
@@ -34701,7 +35653,7 @@ async function saveDocx(model, pendingMedia, options) {
34701
35653
  docPrIds
34702
35654
  );
34703
35655
  await applyChartPartEdits(zip, model, binding?.base);
34704
- await applyNumberingCatalog(zip, model, binding);
35656
+ await applyNumberingCatalog(zip, model, binding, pendingMedia);
34705
35657
  await applyCoreProperties(zip, model.properties, binding?.base.properties);
34706
35658
  if (binding) await applyStyleNumbering(zip, model, binding.base);
34707
35659
  if (binding) await applyStyleFormatting(zip, model, binding.base);
@@ -34715,6 +35667,8 @@ async function saveDocx(model, pendingMedia, options) {
34715
35667
  await applySettingsFlag(zip, "autoHyphenation", Boolean(model.autoHyphenation));
34716
35668
  if (model.trackChanges !== binding?.base.trackChanges)
34717
35669
  await applyTrackChangesSetting(zip, model.trackChanges === true);
35670
+ if (JSON.stringify(model.protection) !== JSON.stringify(binding?.base.protection))
35671
+ await applyDocumentProtection(zip, model.protection);
34718
35672
  for (const [key, flag2] of [
34719
35673
  ["trackFormatting", "doNotTrackFormatting"],
34720
35674
  ["trackMoves", "doNotTrackMoves"]
@@ -34923,6 +35877,71 @@ function parseSimpleHyperlinkField(instr) {
34923
35877
  return void 0;
34924
35878
  }
34925
35879
 
35880
+ // docx/permissions.ts
35881
+ var pending = /* @__PURE__ */ new WeakMap();
35882
+ function readParagraphPermissionMarkers(node, paragraph2) {
35883
+ if (!node.getElementsByTagNameNS("*", "permStart").length && !node.getElementsByTagNameNS("*", "permEnd").length)
35884
+ return;
35885
+ const found = collectInlineSlots(node);
35886
+ if (!found || found.slots.length !== paragraph2.runs.length) return;
35887
+ const positions = runPositions(paragraph2.runs);
35888
+ const events = [];
35889
+ for (const { element: element4, boundary } of found.markers) {
35890
+ const start = named2(element4, "permStart");
35891
+ if (!start && !named2(element4, "permEnd")) continue;
35892
+ const id = getW(element4, "id");
35893
+ if (id === void 0) continue;
35894
+ const group = getW(element4, "edGrp");
35895
+ const user = getW(element4, "ed");
35896
+ events.push({
35897
+ start,
35898
+ id,
35899
+ position: positions[boundary] ?? 0,
35900
+ ...group !== void 0 && { group },
35901
+ ...user !== void 0 && { user }
35902
+ });
35903
+ }
35904
+ if (events.length) pending.set(paragraph2, events);
35905
+ }
35906
+ function resolvePermissions(blocks) {
35907
+ const open = /* @__PURE__ */ new Map();
35908
+ forEachParagraph2(blocks, (paragraph2) => {
35909
+ const events = pending.get(paragraph2) ?? [];
35910
+ const end = runPositions(paragraph2.runs).at(-1) ?? 0;
35911
+ const ranges = [];
35912
+ const begun = new Map(
35913
+ [...open].map(([id, who]) => [id, { ...who, from: 0, previous: true }])
35914
+ );
35915
+ const add4 = (id, begin, to, next) => ranges.push({
35916
+ id,
35917
+ ...begin.group !== void 0 && { group: begin.group },
35918
+ ...begin.user !== void 0 && { user: begin.user },
35919
+ from: begin.from,
35920
+ to,
35921
+ ...begin.previous && { fromPrevious: true },
35922
+ ...next && { toNext: true }
35923
+ });
35924
+ for (const event of events) {
35925
+ if (event.start) {
35926
+ const who = {
35927
+ ...event.group !== void 0 && { group: event.group },
35928
+ ...event.user !== void 0 && { user: event.user }
35929
+ };
35930
+ begun.set(event.id, { ...who, from: event.position });
35931
+ open.set(event.id, who);
35932
+ continue;
35933
+ }
35934
+ const begin = begun.get(event.id);
35935
+ if (begin) add4(event.id, begin, event.position);
35936
+ begun.delete(event.id);
35937
+ open.delete(event.id);
35938
+ }
35939
+ for (const [id, begin] of begun) add4(id, begin, end, true);
35940
+ if (ranges.length) paragraph2.permissions = ranges;
35941
+ pending.delete(paragraph2);
35942
+ });
35943
+ }
35944
+
34926
35945
  // docx/field-runs.ts
34927
35946
  function createFieldTracker() {
34928
35947
  const stack = [];
@@ -35180,6 +36199,7 @@ function parseParagraph2(node, id, fields) {
35180
36199
  if (props) paragraph2.sourceParagraphPropertiesXml = buildXml(props);
35181
36200
  const bookmarks = paragraphBookmarkNames(node);
35182
36201
  if (bookmarks.length) paragraph2.bookmarks = bookmarks;
36202
+ readParagraphPermissionMarkers(node, paragraph2);
35183
36203
  const markRevision = paragraphMarkRevision(props);
35184
36204
  if (markRevision) paragraph2.markRevision = markRevision;
35185
36205
  const formatRevision = paragraphFormatRevision(props);
@@ -35218,6 +36238,7 @@ function parseContainer(container, idPrefix) {
35218
36238
  if (control) block.contentControl = control;
35219
36239
  blocks.push(block);
35220
36240
  }
36241
+ resolvePermissions(blocks);
35221
36242
  return blocks;
35222
36243
  }
35223
36244
 
@@ -35624,16 +36645,16 @@ async function readPlaceholderTexts(zip, relationships, model) {
35624
36645
 
35625
36646
  // docx/parse.ts
35626
36647
  var px = (twips3, fallback) => twips3 === void 0 ? fallback : Number(twips3) * 96 / 1440;
35627
- var RESTRICTED_TO = {
35628
- readOnly: "reading",
35629
- comments: "comments",
35630
- trackedChanges: "tracked changes"
35631
- };
35632
36648
  function protectionWarning(edit) {
35633
36649
  if (edit === "forms")
35634
- return "The document is protected for filling in forms: the editor lets only form fields, content controls and sections left unprotected change. The protection password is not checked.";
35635
- const allowed = RESTRICTED_TO[edit];
35636
- return allowed ? `The document limits editing to ${allowed}; the restriction is kept but not enforced while editing.` : void 0;
36650
+ return "The document is protected for filling in forms: the editor lets only form fields, content controls and sections left unprotected change. The protection password is checked only when you stop the protection.";
36651
+ if (edit === "readOnly")
36652
+ return "The document is protected against changes: the editor lets only its editable regions change. Stop protection (Review > Restrict Editing) to edit the rest.";
36653
+ if (edit === "comments")
36654
+ return "The document is protected for comments: the editor lets you add comments and change its editable regions. Stop protection (Review > Restrict Editing) to edit the rest.";
36655
+ if (edit === "trackedChanges")
36656
+ return "The document is protected for tracked changes: every change is recorded and cannot be accepted or rejected until the protection is stopped (Review > Restrict Editing).";
36657
+ return void 0;
35637
36658
  }
35638
36659
  async function readPackage(input) {
35639
36660
  const original = input instanceof Uint8Array ? new Uint8Array(input) : new Uint8Array(input.slice(0));
@@ -35714,12 +36735,16 @@ async function readPackage(input) {
35714
36735
  const numberingFile = zip.file("word/numbering.xml");
35715
36736
  if (numberingFile) {
35716
36737
  const numberingXml = await numberingFile.async("string");
36738
+ const numberingRels = zip.file("word/_rels/numbering.xml.rels");
36739
+ const numberingRelationships = parseRelationships(
36740
+ numberingRels ? await numberingRels.async("string") : void 0
36741
+ );
35717
36742
  model.numberingCatalog = withParseWarnings(
35718
36743
  schemaWarnings,
35719
- () => parseNumberingCatalog(numberingXml)
36744
+ () => parseNumberingCatalog(numberingXml, numberingRelationships)
35720
36745
  );
35721
36746
  model.warnings.push(
35722
- "Numbering is resolved for decimal, Roman numeral, letter, ordinal, cardinal/ordinal text and bullet formats, including multilevel lvlText and legal numbering. Picture bullets, style-linked numbering and other custom formats fall back to Decimal Number and are not rendered as Word would.",
36747
+ "Numbering is resolved for decimal, Roman numeral, letter, ordinal, cardinal/ordinal text and bullet formats, including multilevel lvlText and legal numbering. Style-linked numbering and other custom formats fall back to Decimal Number and are not rendered as Word would.",
35723
36748
  ...model.numberingCatalog.warnings
35724
36749
  );
35725
36750
  } else if (document.getElementsByTagNameNS(WORD_NS, "numPr").length > 0) {
@@ -35799,10 +36824,13 @@ async function readPackage(input) {
35799
36824
  for (const part of [
35800
36825
  run2.image?.partName,
35801
36826
  run2.image?.svgPartName,
35802
- ...Object.values(run2.image?.diagram?.drawing?.pictureParts ?? {})
36827
+ ...Object.values(run2.image?.diagram?.drawing?.pictureParts ?? {}),
36828
+ ...Object.values(run2.image?.diagram?.layoutSource?.pictureParts ?? {})
35803
36829
  ])
35804
36830
  if (part) imagePartNames.add(part);
35805
36831
  });
36832
+ for (const bullet of Object.values(model.numberingCatalog?.pictureBullets ?? {}))
36833
+ imagePartNames.add(bullet.partName);
35806
36834
  const media = /* @__PURE__ */ new Map();
35807
36835
  for (const partName of imagePartNames) {
35808
36836
  const part = zip.file(partName);