ooxml-core 1.32.0 → 1.33.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 (318) hide show
  1. package/dist/{PptxHandler-TESZUH66.cjs → PptxHandler-MGKMIK22.cjs} +3 -3
  2. package/dist/PptxHandler-Q7CFNKOU.mjs +7 -0
  3. package/dist/PptxHandler-TEC7SWBU.mjs +4 -0
  4. package/dist/{PresentationBuilder-3CH5TR4W.mjs → PresentationBuilder-PJMQRZI6.mjs} +2 -2
  5. package/dist/{PresentationBuilder-S6HXHKEJ.mjs → PresentationBuilder-SADKXDWC.mjs} +4 -4
  6. package/dist/{PresentationBuilder-5NFBUP7Y.cjs → PresentationBuilder-VP2637RH.cjs} +5 -5
  7. package/dist/automation/index.cjs +4398 -2262
  8. package/dist/automation/index.mjs +4398 -2262
  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-Q6NM64J2.cjs → chunk-2LTIDUXH.cjs} +4791 -950
  80. package/dist/chunk-2N7RZQLC.mjs +8 -0
  81. package/dist/{chunk-NAWLWKOJ.mjs → chunk-3LMHYL4W.mjs} +2 -2
  82. package/dist/{chunk-O7SVHLD7.mjs → chunk-6LJW76BZ.mjs} +4756 -951
  83. package/dist/{chunk-X6VNUBES.cjs → chunk-BDZR4DZ6.cjs} +2058 -1748
  84. package/dist/{chunk-IOTGRLJH.mjs → chunk-BQGLWC6N.mjs} +867 -557
  85. package/dist/{chunk-N6424WKA.mjs → chunk-EBBWRRSB.mjs} +1 -1
  86. package/dist/{chunk-UYMSFJQZ.mjs → chunk-JQVOUS6B.mjs} +5 -5
  87. package/dist/{chunk-3H5UAJB3.mjs → chunk-QRXMYOVN.mjs} +870 -525
  88. package/dist/{chunk-54S5A5PZ.mjs → chunk-VDUNZTJC.mjs} +36 -1
  89. package/dist/{chunk-4R65YYAD.mjs → chunk-Y2RH4QWG.mjs} +4228 -1070
  90. package/dist/diagram/drawing-resolve.d.ts.map +1 -1
  91. package/dist/diagram/drawing-view.d.ts +6 -0
  92. package/dist/diagram/drawing-view.d.ts.map +1 -1
  93. package/dist/diagram/engine/engine-to-result.d.ts.map +1 -1
  94. package/dist/diagram/index.cjs +786 -145
  95. package/dist/diagram/index.d.ts +1 -0
  96. package/dist/diagram/index.d.ts.map +1 -1
  97. package/dist/diagram/index.mjs +783 -147
  98. package/dist/diagram/layout/smartart-layout-types.d.ts +7 -0
  99. package/dist/diagram/layout/smartart-layout-types.d.ts.map +1 -1
  100. package/dist/diagram/layout-preview.d.ts +4 -0
  101. package/dist/diagram/layout-preview.d.ts.map +1 -1
  102. package/dist/diagram/layout-role-style.d.ts +4 -0
  103. package/dist/diagram/layout-role-style.d.ts.map +1 -0
  104. package/dist/diagram/load.d.ts.map +1 -1
  105. package/dist/diagram/picture-layout.d.ts +23 -0
  106. package/dist/diagram/picture-layout.d.ts.map +1 -0
  107. package/dist/diagram/types.d.ts +6 -0
  108. package/dist/diagram/types.d.ts.map +1 -1
  109. package/dist/diagram/write/cache.d.ts +1 -0
  110. package/dist/diagram/write/cache.d.ts.map +1 -1
  111. package/dist/digest/crc32.d.ts +2 -0
  112. package/dist/digest/crc32.d.ts.map +1 -0
  113. package/dist/digest/index.cjs +11 -0
  114. package/dist/digest/index.d.ts +1 -0
  115. package/dist/digest/index.d.ts.map +1 -1
  116. package/dist/digest/index.mjs +11 -1
  117. package/dist/docx/diagram-cache.d.ts.map +1 -1
  118. package/dist/docx/diagram-save.d.ts.map +1 -1
  119. package/dist/docx/drawing.d.ts.map +1 -1
  120. package/dist/docx/embedded.cjs +882 -212
  121. package/dist/docx/embedded.mjs +882 -212
  122. package/dist/docx/index.cjs +3082 -866
  123. package/dist/docx/index.mjs +3082 -866
  124. package/dist/docx/inline-model.d.ts +4 -0
  125. package/dist/docx/inline-model.d.ts.map +1 -1
  126. package/dist/docx/layout/adapt-floats.d.ts.map +1 -1
  127. package/dist/docx/layout/adapter.d.ts.map +1 -1
  128. package/dist/docx/layout/floats.d.ts.map +1 -1
  129. package/dist/docx/layout/index.cjs +2200 -438
  130. package/dist/docx/layout/index.mjs +2200 -438
  131. package/dist/docx/layout/input.d.ts +3 -0
  132. package/dist/docx/layout/input.d.ts.map +1 -1
  133. package/dist/docx/layout/result.d.ts +3 -0
  134. package/dist/docx/layout/result.d.ts.map +1 -1
  135. package/dist/docx/load/index.cjs +1311 -641
  136. package/dist/docx/load/index.mjs +1311 -641
  137. package/dist/docx/parse.d.ts.map +1 -1
  138. package/dist/docx/ui/index.cjs +2832 -842
  139. package/dist/docx/ui/index.mjs +2832 -842
  140. package/dist/docx/ui/inline-content-schema.d.ts.map +1 -1
  141. package/dist/docx/ui/run-adapter.d.ts.map +1 -1
  142. package/dist/docx/write-drawing.d.ts.map +1 -1
  143. package/dist/drawingml/index.cjs +707 -111
  144. package/dist/drawingml/index.d.ts +7 -0
  145. package/dist/drawingml/index.d.ts.map +1 -1
  146. package/dist/drawingml/index.mjs +697 -113
  147. package/dist/drawingml/picture-artistic.d.ts +14 -0
  148. package/dist/drawingml/picture-artistic.d.ts.map +1 -0
  149. package/dist/drawingml/picture-effects.d.ts +4 -1
  150. package/dist/drawingml/picture-effects.d.ts.map +1 -1
  151. package/dist/drawingml/picture-fill.d.ts.map +1 -1
  152. package/dist/drawingml/picture-hsl-pixels.d.ts +4 -0
  153. package/dist/drawingml/picture-hsl-pixels.d.ts.map +1 -0
  154. package/dist/drawingml/picture-layout.d.ts +25 -0
  155. package/dist/drawingml/picture-layout.d.ts.map +1 -0
  156. package/dist/drawingml/picture-standard-effects.d.ts +15 -0
  157. package/dist/drawingml/picture-standard-effects.d.ts.map +1 -0
  158. package/dist/drawingml/picture-transfer.d.ts +11 -0
  159. package/dist/drawingml/picture-transfer.d.ts.map +1 -0
  160. package/dist/drawingml/raster-image.d.ts +29 -0
  161. package/dist/drawingml/raster-image.d.ts.map +1 -0
  162. package/dist/drawingml/types.d.ts +1 -0
  163. package/dist/drawingml/types.d.ts.map +1 -1
  164. package/dist/drawingml/write-pattern-picture.d.ts.map +1 -1
  165. package/dist/geometry/index.cjs +38 -0
  166. package/dist/geometry/index.d.ts +1 -0
  167. package/dist/geometry/index.d.ts.map +1 -1
  168. package/dist/geometry/index.mjs +36 -1
  169. package/dist/geometry/picture-tile.d.ts +29 -0
  170. package/dist/geometry/picture-tile.d.ts.map +1 -0
  171. package/dist/index.cjs +15164 -12669
  172. package/dist/index.mjs +15164 -12669
  173. package/dist/pptx/automation/index.cjs +7431 -2967
  174. package/dist/pptx/automation/index.d.ts +5 -5
  175. package/dist/pptx/automation/index.mjs +7 -7
  176. package/dist/pptx/chunks/{elements-mSCZ84Tc.d.ts → elements-f3UbFph-.d.ts} +7 -2
  177. package/dist/pptx/chunks/elements-f3UbFph-.d.ts.map +1 -0
  178. package/dist/pptx/chunks/{index-DnWlmYCy.d.ts → index-BnH2QjYm.d.ts} +4 -4
  179. package/dist/pptx/chunks/{index-DnWlmYCy.d.ts.map → index-BnH2QjYm.d.ts.map} +1 -1
  180. package/dist/pptx/chunks/{index-D-FdgqrP.d.ts → index-Bp-1pGo1.d.ts} +4 -4
  181. package/dist/pptx/chunks/{index-D-FdgqrP.d.ts.map → index-Bp-1pGo1.d.ts.map} +1 -1
  182. package/dist/pptx/chunks/{index-DKybuHPT.d.ts → index-BuMPQDQb.d.ts} +27 -16
  183. package/dist/pptx/chunks/index-BuMPQDQb.d.ts.map +1 -0
  184. package/dist/pptx/chunks/{smart-art-DLumQo90.d.ts → smart-art-CmOrPLLQ.d.ts} +86 -2
  185. package/dist/pptx/chunks/smart-art-CmOrPLLQ.d.ts.map +1 -0
  186. package/dist/pptx/chunks/{text-operations-hyPODwIQ.d.ts → text-operations-D5sgspO6.d.ts} +2 -2
  187. package/dist/pptx/chunks/{text-operations-hyPODwIQ.d.ts.map → text-operations-D5sgspO6.d.ts.map} +1 -1
  188. package/dist/pptx/cli/index.cjs +7196 -2732
  189. package/dist/pptx/cli/index.d.ts +1 -1
  190. package/dist/pptx/cli/index.mjs +6 -6
  191. package/dist/pptx/converter/index.cjs +3895 -503
  192. package/dist/pptx/converter/index.d.ts +1 -1
  193. package/dist/pptx/converter/index.mjs +3 -3
  194. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  195. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  196. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  197. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  198. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  199. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
  200. package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
  201. package/dist/pptx/index.cjs +6828 -2969
  202. package/dist/pptx/index.d.ts +7 -7
  203. package/dist/pptx/index.mjs +7 -7
  204. package/dist/pptx/node/index.d.ts +1 -1
  205. package/dist/pptx/smartart-layouts/index.d.ts +1 -1
  206. package/dist/pptx/smartart-layouts/index.mjs +2 -2
  207. package/dist/teams/index.cjs +1964 -726
  208. package/dist/teams/index.mjs +1964 -726
  209. package/dist/visio/cell-formula.d.ts +5 -1
  210. package/dist/visio/cell-formula.d.ts.map +1 -1
  211. package/dist/visio/collab/index.cjs +3 -1
  212. package/dist/visio/collab/index.mjs +3 -1
  213. package/dist/visio/container-relationships.d.ts +19 -0
  214. package/dist/visio/container-relationships.d.ts.map +1 -0
  215. package/dist/visio/edit-container-fit.d.ts +19 -0
  216. package/dist/visio/edit-container-fit.d.ts.map +1 -0
  217. package/dist/visio/edit-container-members.d.ts +21 -0
  218. package/dist/visio/edit-container-members.d.ts.map +1 -0
  219. package/dist/visio/edit-delete.d.ts.map +1 -1
  220. package/dist/visio/edit-diagram-parts-commands.d.ts +23 -1
  221. package/dist/visio/edit-diagram-parts-commands.d.ts.map +1 -1
  222. package/dist/visio/edit-diagram-parts.d.ts +3 -2
  223. package/dist/visio/edit-diagram-parts.d.ts.map +1 -1
  224. package/dist/visio/edit-geometry.d.ts +4 -1
  225. package/dist/visio/edit-geometry.d.ts.map +1 -1
  226. package/dist/visio/edit-recalculate-index.d.ts +13 -0
  227. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  228. package/dist/visio/edit-recalculate-values.d.ts.map +1 -1
  229. package/dist/visio/edit-recalculate.d.ts.map +1 -1
  230. package/dist/visio/edit.d.ts.map +1 -1
  231. package/dist/visio/formula-analyze.d.ts +2 -0
  232. package/dist/visio/formula-analyze.d.ts.map +1 -1
  233. package/dist/visio/formula-evaluate.d.ts.map +1 -1
  234. package/dist/visio/formula-master.d.ts +1 -0
  235. package/dist/visio/formula-master.d.ts.map +1 -1
  236. package/dist/visio/index.cjs +2771 -1312
  237. package/dist/visio/index.d.ts +1 -1
  238. package/dist/visio/index.d.ts.map +1 -1
  239. package/dist/visio/index.mjs +2771 -1312
  240. package/dist/visio/media.d.ts +4 -23
  241. package/dist/visio/media.d.ts.map +1 -1
  242. package/dist/visio/package-common.d.ts +1 -1
  243. package/dist/visio/package-common.d.ts.map +1 -1
  244. package/dist/visio/shape-structure.d.ts +6 -3
  245. package/dist/visio/shape-structure.d.ts.map +1 -1
  246. package/dist/visio/ui/diagram-parts.d.ts +12 -1
  247. package/dist/visio/ui/diagram-parts.d.ts.map +1 -1
  248. package/dist/visio/ui/index.cjs +2679 -1201
  249. package/dist/visio/ui/index.mjs +2679 -1202
  250. package/dist/xlsx/edit/cell-values.d.ts.map +1 -1
  251. package/dist/xlsx/edit/chart-ex.d.ts +1 -0
  252. package/dist/xlsx/edit/chart-ex.d.ts.map +1 -1
  253. package/dist/xlsx/edit/filter.d.ts +5 -1
  254. package/dist/xlsx/edit/filter.d.ts.map +1 -1
  255. package/dist/xlsx/edit/index.d.ts +1 -0
  256. package/dist/xlsx/edit/index.d.ts.map +1 -1
  257. package/dist/xlsx/edit/session-calc.d.ts +5 -0
  258. package/dist/xlsx/edit/session-calc.d.ts.map +1 -1
  259. package/dist/xlsx/edit/session.d.ts.map +1 -1
  260. package/dist/xlsx/edit/text-columns.d.ts +21 -0
  261. package/dist/xlsx/edit/text-columns.d.ts.map +1 -0
  262. package/dist/xlsx/edit/types.d.ts +5 -1
  263. package/dist/xlsx/edit/types.d.ts.map +1 -1
  264. package/dist/xlsx/embedded-chart-ex-space.d.ts +18 -0
  265. package/dist/xlsx/embedded-chart-ex-space.d.ts.map +1 -0
  266. package/dist/xlsx/filter-criteria.d.ts +22 -0
  267. package/dist/xlsx/filter-criteria.d.ts.map +1 -0
  268. package/dist/xlsx/filter-dynamic.d.ts +8 -0
  269. package/dist/xlsx/filter-dynamic.d.ts.map +1 -0
  270. package/dist/xlsx/filter-menu.d.ts +49 -0
  271. package/dist/xlsx/filter-menu.d.ts.map +1 -0
  272. package/dist/xlsx/filter-rows.d.ts +4 -4
  273. package/dist/xlsx/filter-rows.d.ts.map +1 -1
  274. package/dist/xlsx/index.cjs +5861 -2939
  275. package/dist/xlsx/index.d.ts +4 -0
  276. package/dist/xlsx/index.d.ts.map +1 -1
  277. package/dist/xlsx/index.mjs +5844 -2939
  278. package/dist/xlsx/load/index.cjs +1871 -585
  279. package/dist/xlsx/load/index.mjs +1871 -585
  280. package/dist/xlsx/model-filter.d.ts +54 -0
  281. package/dist/xlsx/model-filter.d.ts.map +1 -0
  282. package/dist/xlsx/model.d.ts +42 -3
  283. package/dist/xlsx/model.d.ts.map +1 -1
  284. package/dist/xlsx/read/chart.d.ts.map +1 -1
  285. package/dist/xlsx/read/drawing.d.ts.map +1 -1
  286. package/dist/xlsx/read/filter-columns.d.ts +5 -0
  287. package/dist/xlsx/read/filter-columns.d.ts.map +1 -0
  288. package/dist/xlsx/read/shared-strings.d.ts +5 -3
  289. package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
  290. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  291. package/dist/xlsx/read/sheet-props.d.ts +2 -2
  292. package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
  293. package/dist/xlsx/ui/commands/i18n/filters.d.ts +3 -0
  294. package/dist/xlsx/ui/commands/i18n/filters.d.ts.map +1 -0
  295. package/dist/xlsx/ui/commands/i18n/index.d.ts.map +1 -1
  296. package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
  297. package/dist/xlsx/ui/commands/i18n/tools.d.ts.map +1 -1
  298. package/dist/xlsx/ui/commands/sort-filter.d.ts.map +1 -1
  299. package/dist/xlsx/ui/dialogs/grid-chart.d.ts.map +1 -1
  300. package/dist/xlsx/ui/index.cjs +7177 -4234
  301. package/dist/xlsx/ui/index.mjs +7177 -4234
  302. package/dist/xlsx/write/drawing.d.ts.map +1 -1
  303. package/dist/xlsx/write/filter-columns.d.ts +39 -0
  304. package/dist/xlsx/write/filter-columns.d.ts.map +1 -0
  305. package/dist/xlsx/write/shared-strings.d.ts +4 -4
  306. package/dist/xlsx/write/shared-strings.d.ts.map +1 -1
  307. package/dist/xlsx/write/sheet-props.d.ts +2 -1
  308. package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
  309. package/dist/xlsx/write/smart-art-cache.d.ts.map +1 -1
  310. package/dist/xlsx/write/smart-art.d.ts.map +1 -1
  311. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  312. package/package.json +6 -1
  313. package/dist/PptxHandler-QY5VL3CY.mjs +0 -7
  314. package/dist/PptxHandler-SJ5ZUIUX.mjs +0 -4
  315. package/dist/chunk-3GXV5MPC.mjs +0 -41
  316. package/dist/pptx/chunks/elements-mSCZ84Tc.d.ts.map +0 -1
  317. package/dist/pptx/chunks/index-DKybuHPT.d.ts.map +0 -1
  318. package/dist/pptx/chunks/smart-art-DLumQo90.d.ts.map +0 -1
@@ -3,6 +3,7 @@ import { isHistoryTransaction, closeHistory } from 'prosemirror-history';
3
3
  import { PluginKey, TextSelection, Plugin, NodeSelection } from 'prosemirror-state';
4
4
  import { ReplaceStep, Transform, Mapping, AttrStep, Step, DocAttrStep, StepMap, ReplaceAroundStep, AddMarkStep, RemoveMarkStep } from 'prosemirror-transform';
5
5
  import { Slice, Fragment, Mark } from 'prosemirror-model';
6
+ import { Inflate } from 'fflate';
6
7
  import { collab, sendableSteps, receiveTransaction, getVersion } from 'prosemirror-collab';
7
8
  import * as Y2 from 'yjs';
8
9
  import { ySyncPluginKey, prosemirrorToYXmlFragment, initProseMirrorDoc, defaultDeleteFilter, ySyncPlugin, getRelativeSelection, yCursorPlugin, yCursorPluginKey, relativePositionToAbsolutePosition, absolutePositionToRelativePosition } from 'y-prosemirror';
@@ -180,13 +181,13 @@ function updatedInlineRunAttributes(node, format) {
180
181
  if (Object.hasOwn(desired, key)) metadata[key] = desired[key];
181
182
  else delete metadata[key];
182
183
  }
183
- const attrs2 = {
184
+ const attrs3 = {
184
185
  ...node.attrs,
185
186
  format: Object.keys(metadata).length ? JSON.stringify(metadata) : null
186
187
  };
187
188
  for (const key of DIRECT_RUN_PROPERTY_KEYS)
188
- attrs2[attributeName(key)] = JSON.stringify(base[key]) === JSON.stringify(desired[key]) ? null : JSON.stringify(desired[key] ?? null);
189
- return attrs2;
189
+ attrs3[attributeName(key)] = JSON.stringify(base[key]) === JSON.stringify(desired[key]) ? null : JSON.stringify(desired[key] ?? null);
190
+ return attrs3;
190
191
  }
191
192
  function wordInlinePropertyCodec(schema) {
192
193
  return Object.values(schema.nodes).some((type) => type.spec.attrs?.[attributeName("bold")]) ? schema.marks.inlineCommentAnchors ? "word-yjs-v3" : "word-yjs-v2" : "word-yjs-v1";
@@ -272,6 +273,8 @@ var NS = {
272
273
  w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
273
274
  /** DrawingML main. */
274
275
  a: "http://schemas.openxmlformats.org/drawingml/2006/main",
276
+ /** Office 2016 extended charts (waterfall, histogram, funnel...; `cx:chartSpace`). */
277
+ cx: "http://schemas.microsoft.com/office/drawing/2014/chartex",
275
278
  /** DrawingML diagram (SmartArt) main. */
276
279
  dgm: "http://schemas.openxmlformats.org/drawingml/2006/diagram",
277
280
  /** Relationships (`r:id`, `r:embed`). */
@@ -973,8 +976,8 @@ function cellContent(state, cell, text2) {
973
976
  nodes.push(child3);
974
977
  return;
975
978
  }
976
- const attrs2 = child3.attrs.contentControl ? { ...child3.attrs, contentControl: null } : child3.attrs;
977
- nodes.push(child3.type.create(attrs2, placed ? null : text2));
979
+ const attrs3 = child3.attrs.contentControl ? { ...child3.attrs, contentControl: null } : child3.attrs;
980
+ nodes.push(child3.type.create(attrs3, placed ? null : text2));
978
981
  placed = true;
979
982
  });
980
983
  if (!placed) nodes.push(state.schema.nodes.paragraph.create(null, text2));
@@ -1660,16 +1663,16 @@ var RPR_ORDER = [
1660
1663
  "rPrChange"
1661
1664
  ];
1662
1665
  function orderChildren(parent, order) {
1663
- const elements2 = Array.from(parent.childNodes).filter(isElement);
1666
+ const elements3 = Array.from(parent.childNodes).filter(isElement);
1664
1667
  const rankOf = (name) => order.findIndex((entry) => typeof entry === "string" ? entry === name : entry.includes(name));
1665
1668
  let previousRank = -1;
1666
- const ranked = elements2.map((element3, index) => {
1669
+ const ranked = elements3.map((element3, index) => {
1667
1670
  const rank2 = element3.namespaceURI === WORD_NS ? rankOf(element3.localName ?? "") : -1;
1668
1671
  if (rank2 >= 0) previousRank = rank2;
1669
1672
  return { element: element3, index, rank: rank2 >= 0 ? rank2 : previousRank + 0.5 };
1670
1673
  });
1671
1674
  const sorted = [...ranked].sort((a, b) => a.rank - b.rank || a.index - b.index);
1672
- if (sorted.every((entry, index) => entry.element === elements2[index])) return;
1675
+ if (sorted.every((entry, index) => entry.element === elements3[index])) return;
1673
1676
  for (const { element: element3 } of sorted) parent.appendChild(element3);
1674
1677
  }
1675
1678
 
@@ -2296,9 +2299,9 @@ function parseRunProperties(props) {
2296
2299
  if (themeColor2) {
2297
2300
  result.colorTheme = { token: themeColor2 };
2298
2301
  const tint = parseTintShade(getW(color, "themeTint"));
2299
- const shade = parseTintShade(getW(color, "themeShade"));
2302
+ const shade2 = parseTintShade(getW(color, "themeShade"));
2300
2303
  if (tint !== void 0) result.colorTheme.tint = tint;
2301
- if (shade !== void 0) result.colorTheme.shade = shade;
2304
+ if (shade2 !== void 0) result.colorTheme.shade = shade2;
2302
2305
  }
2303
2306
  const spacing2 = parseSignedTwips(getW(first2(props, "spacing"), "val"));
2304
2307
  if (spacing2 !== void 0) result.characterSpacingTwips = spacing2;
@@ -2316,9 +2319,9 @@ function parseRunProperties(props) {
2316
2319
  if (shdTheme) {
2317
2320
  result.shadingThemeFill = { token: shdTheme };
2318
2321
  const tint = parseTintShade(getW(shd, "themeFillTint"));
2319
- const shade = parseTintShade(getW(shd, "themeFillShade"));
2322
+ const shade2 = parseTintShade(getW(shd, "themeFillShade"));
2320
2323
  if (tint !== void 0) result.shadingThemeFill.tint = tint;
2321
- if (shade !== void 0) result.shadingThemeFill.shade = shade;
2324
+ if (shade2 !== void 0) result.shadingThemeFill.shade = shade2;
2322
2325
  }
2323
2326
  return result;
2324
2327
  }
@@ -2390,166 +2393,6 @@ function setExtendedRunProperties(doc, props, run, base) {
2390
2393
  }
2391
2394
  }
2392
2395
 
2393
- // opc/signature/xml-utils.ts
2394
- function escapeXmlAttr(value) {
2395
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
2396
- }
2397
-
2398
- // docx/watermark.ts
2399
- var VML_NS = "urn:schemas-microsoft-com:vml";
2400
- var OFFICE_NS = "urn:schemas-microsoft-com:office:office";
2401
- var WORD10_NS = "urn:schemas-microsoft-com:office:word";
2402
- var WATERMARK_PREFIX = "PowerPlusWaterMarkObject";
2403
- function watermarkSizePt(spec) {
2404
- const chars = Math.max(1, [...spec.text].length);
2405
- const width = Math.min(spec.layout === "diagonal" ? 527 : 468, Math.max(150, chars * 44));
2406
- return { width, height: Math.round(width / (chars * 0.55) * 100) / 100 };
2407
- }
2408
- var FORMULAS = [
2409
- "sum #0 0 10800",
2410
- "prod #0 2 1",
2411
- "sum 21600 0 @1",
2412
- "sum 0 0 @2",
2413
- "sum 21600 0 @3",
2414
- "if @0 @3 0",
2415
- "if @0 21600 @1",
2416
- "if @0 0 @2",
2417
- "if @0 @4 21600",
2418
- "mid @5 @6",
2419
- "mid @8 @5",
2420
- "mid @7 @8",
2421
- "mid @6 @7",
2422
- "sum @6 0 @5"
2423
- ];
2424
- function buildWatermarkRun(doc, spec, uniqueId) {
2425
- const v = (name) => makeNS(doc, VML_NS, `v:${name}`);
2426
- const run = makeW(doc, "r");
2427
- const props = makeW(doc, "rPr");
2428
- props.appendChild(makeW(doc, "noProof"));
2429
- run.appendChild(props);
2430
- const pict = makeW(doc, "pict");
2431
- const type = v("shapetype");
2432
- type.setAttribute("id", "_x0000_t136");
2433
- type.setAttribute("coordsize", "21600,21600");
2434
- type.setAttributeNS(OFFICE_NS, "o:spt", "136");
2435
- type.setAttribute("adj", "10800");
2436
- type.setAttribute("path", "m@7,l@8,m@5,21600l@6,21600e");
2437
- const formulas = v("formulas");
2438
- for (const eqn of FORMULAS) {
2439
- const f = v("f");
2440
- f.setAttribute("eqn", eqn);
2441
- formulas.appendChild(f);
2442
- }
2443
- const path = v("path");
2444
- path.setAttribute("textpathok", "t");
2445
- path.setAttributeNS(OFFICE_NS, "o:connecttype", "custom");
2446
- path.setAttributeNS(OFFICE_NS, "o:connectlocs", "@9,0;@10,10800;@11,21600;@12,10800");
2447
- path.setAttributeNS(OFFICE_NS, "o:connectangles", "270,180,90,0");
2448
- const typePath = v("textpath");
2449
- typePath.setAttribute("on", "t");
2450
- typePath.setAttribute("fitshape", "t");
2451
- const handles = v("handles");
2452
- const handle = v("h");
2453
- handle.setAttribute("position", "#0,bottomRight");
2454
- handle.setAttribute("xrange", "6629,14971");
2455
- handles.appendChild(handle);
2456
- const lock = makeNS(doc, OFFICE_NS, "o:lock");
2457
- lock.setAttributeNS(VML_NS, "v:ext", "edit");
2458
- lock.setAttribute("text", "t");
2459
- lock.setAttribute("shapetype", "t");
2460
- for (const child3 of [formulas, path, typePath, handles, lock]) type.appendChild(child3);
2461
- const size = watermarkSizePt(spec);
2462
- const shape = v("shape");
2463
- shape.setAttribute("id", `${WATERMARK_PREFIX}${uniqueId}`);
2464
- shape.setAttributeNS(OFFICE_NS, "o:spid", `_x0000_s${2048 + (Number(uniqueId) || 1)}`);
2465
- shape.setAttribute("type", "#_x0000_t136");
2466
- shape.setAttribute(
2467
- "style",
2468
- `position:absolute;margin-left:0;margin-top:0;width:${size.width}pt;height:${size.height}pt;${spec.layout === "diagonal" ? "rotation:315;" : ""}z-index:-251658752;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin`
2469
- );
2470
- shape.setAttributeNS(OFFICE_NS, "o:allowincell", "f");
2471
- shape.setAttribute("fillcolor", spec.color.replace(/^#/, "").toLowerCase());
2472
- shape.setAttribute("stroked", "f");
2473
- const fill = v("fill");
2474
- fill.setAttribute("opacity", spec.semitransparent ? ".5" : "1");
2475
- const text2 = v("textpath");
2476
- text2.setAttribute("style", `font-family:"${spec.fontFamily ?? "Calibri"}";font-size:1pt`);
2477
- text2.setAttribute("string", spec.text);
2478
- const wrap = makeNS(doc, WORD10_NS, "w10:wrap");
2479
- wrap.setAttribute("anchorx", "margin");
2480
- wrap.setAttribute("anchory", "margin");
2481
- for (const child3 of [fill, text2, wrap]) shape.appendChild(child3);
2482
- pict.appendChild(type);
2483
- pict.appendChild(shape);
2484
- run.appendChild(pict);
2485
- return run;
2486
- }
2487
-
2488
- // docx/write-text-box.ts
2489
- var A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
2490
- var WP_NS = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
2491
- var WPS_NS = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
2492
- var W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
2493
- var el = (doc, ns, name) => makeNS(doc, ns, name);
2494
- var add = (parent, ...items) => {
2495
- for (const item2 of items) parent.appendChild(item2);
2496
- return parent;
2497
- };
2498
- var emu = (px) => String(Math.max(1, Math.round(px * EMU_PER_PIXEL)));
2499
- var descendants = (root, ns, local) => Array.from(root.getElementsByTagNameNS(ns, local));
2500
- function paragraphsFor(doc, lines) {
2501
- return (lines.length ? lines : [""]).map((line3) => {
2502
- const paragraph = makeW(doc, "p");
2503
- if (line3) {
2504
- const run = makeW(doc, "r");
2505
- const text2 = makeW(doc, "t");
2506
- if (/^\s|\s$/.test(line3))
2507
- text2.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
2508
- text2.textContent = line3;
2509
- add(run, text2);
2510
- add(paragraph, run);
2511
- }
2512
- return paragraph;
2513
- });
2514
- }
2515
- function outline(doc, border) {
2516
- const ln = el(doc, A_NS, "a:ln");
2517
- if (!border) return add(ln, el(doc, A_NS, "a:noFill"));
2518
- ln.setAttribute("w", "9525");
2519
- const color = el(doc, A_NS, "a:srgbClr");
2520
- color.setAttribute("val", "000000");
2521
- return add(ln, add(el(doc, A_NS, "a:solidFill"), color));
2522
- }
2523
- function patchTextBox(doc, drawing, image, base) {
2524
- if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
2525
- for (const node of [
2526
- ...descendants(drawing, WP_NS, "extent"),
2527
- ...descendants(drawing, A_NS, "ext").filter(
2528
- (ext) => ext.parentNode?.localName === "xfrm"
2529
- )
2530
- ]) {
2531
- node.setAttribute("cx", emu(image.widthPx));
2532
- node.setAttribute("cy", emu(image.heightPx));
2533
- }
2534
- if (JSON.stringify(image.textBoxText) !== JSON.stringify(base.textBoxText)) {
2535
- const content = descendants(drawing, W_NS, "txbxContent")[0];
2536
- if (content) {
2537
- for (const child3 of Array.from(content.childNodes)) content.removeChild(child3);
2538
- add(content, ...paragraphsFor(doc, image.textBoxText ?? []));
2539
- }
2540
- }
2541
- if (image.textBoxBorder !== false !== (base.textBoxBorder !== false)) {
2542
- const spPr = descendants(drawing, WPS_NS, "spPr")[0];
2543
- if (spPr) {
2544
- for (const old of Array.from(spPr.childNodes).filter(
2545
- (node) => isElement(node) && node.localName === "ln"
2546
- ))
2547
- spPr.removeChild(old);
2548
- spPr.appendChild(outline(doc, image.textBoxBorder !== false));
2549
- }
2550
- }
2551
- }
2552
-
2553
2396
  // drawingml/dom.ts
2554
2397
  function attributeReader(element3) {
2555
2398
  return (name) => {
@@ -2578,7 +2421,7 @@ function booleanAttribute(element3, name) {
2578
2421
  if (value === "0" || value === "false") return false;
2579
2422
  return void 0;
2580
2423
  }
2581
- function descendants2(root, local) {
2424
+ function descendants(root, local) {
2582
2425
  const result = [];
2583
2426
  const visit = (node) => {
2584
2427
  for (const child3 of Array.from(node.childNodes)) {
@@ -2591,6 +2434,94 @@ function descendants2(root, local) {
2591
2434
  return result;
2592
2435
  }
2593
2436
 
2437
+ // drawingml/picture-crop.ts
2438
+ var SIDES = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
2439
+ function parsePictureCrop(blipFill) {
2440
+ const rect3 = first(blipFill, "srcRect", NS.a);
2441
+ if (!rect3) return void 0;
2442
+ const result = {};
2443
+ for (const [attr2, key] of Object.entries(SIDES)) {
2444
+ const raw = rect3.getAttribute(attr2);
2445
+ if (raw === null || !raw.trim()) continue;
2446
+ const percent = raw.endsWith("%");
2447
+ const value = Number(percent ? raw.slice(0, -1) : raw) / (percent ? 100 : 1e5);
2448
+ if (Number.isFinite(value)) result[key] = value;
2449
+ }
2450
+ return result;
2451
+ }
2452
+ function applyPictureCrop(blipFill, crop) {
2453
+ let rect3 = first(blipFill, "srcRect", NS.a);
2454
+ if (!rect3 && crop && Object.values(crop).some((value) => value !== void 0)) {
2455
+ rect3 = blipFill.ownerDocument.createElementNS(NS.a, "a:srcRect");
2456
+ const blip = first(blipFill, "blip", NS.a);
2457
+ blipFill.insertBefore(rect3, blip?.nextSibling ?? blipFill.firstChild);
2458
+ }
2459
+ if (!rect3) return;
2460
+ for (const [attr2, key] of Object.entries(SIDES)) {
2461
+ const value = crop?.[key];
2462
+ if (value === void 0) rect3.removeAttribute(attr2);
2463
+ else {
2464
+ if (!Number.isFinite(value)) throw new RangeError("Picture crop must be finite");
2465
+ rect3.setAttribute(attr2, String(Math.round(value * 1e5)));
2466
+ }
2467
+ }
2468
+ }
2469
+
2470
+ // drawingml/picture-artistic.ts
2471
+ var ARTISTIC_PRIMARY_ATTRIBUTE = {
2472
+ artisticBlur: "radius",
2473
+ artisticCement: "crackSpacing",
2474
+ artisticChalkSketch: "pressure",
2475
+ artisticCrisscrossEtching: "pressure",
2476
+ artisticCutout: "numberOfShades",
2477
+ artisticFilmGrain: "grainSize",
2478
+ artisticGlass: "scaling",
2479
+ artisticGlowDiffused: "intensity",
2480
+ artisticGlowEdges: "smoothness",
2481
+ artisticLightScreen: "gridSize",
2482
+ artisticLineDrawing: "pencilSize",
2483
+ artisticMarker: "size",
2484
+ // Spelled "Mosiaic" in the schema; Microsoft's typo is part of the format.
2485
+ artisticMosiaicBubbles: "pressure",
2486
+ artisticPaintBrush: "brushSize",
2487
+ artisticPaintStrokes: "intensity",
2488
+ artisticPastelsSmooth: "scaling",
2489
+ artisticPencilGrayscale: "pencilSize",
2490
+ artisticPencilSketch: "pressure",
2491
+ artisticPhotocopy: "detail",
2492
+ artisticPlasticWrap: "smoothness",
2493
+ artisticTexturizer: "scaling",
2494
+ artisticWatercolorSponge: "brushSize"
2495
+ };
2496
+ function parseArtisticPictureExtension(node) {
2497
+ if (node.namespaceURI !== NS.a || node.localName !== "extLst") return void 0;
2498
+ const found = [];
2499
+ const unhandled = [];
2500
+ const pending = [node];
2501
+ while (pending.length) {
2502
+ const item2 = pending.pop();
2503
+ 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])))
2504
+ unhandled.push(item2.localName);
2505
+ if (item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && item2.localName.startsWith("artistic"))
2506
+ found.push(item2);
2507
+ pending.push(...elements(item2));
2508
+ }
2509
+ if (found.length !== 1) return void 0;
2510
+ const effect = found[0];
2511
+ const key = ARTISTIC_PRIMARY_ATTRIBUTE[effect.localName];
2512
+ if (!key) return void 0;
2513
+ const raw = key ? effect.getAttribute(key) : null;
2514
+ const n2 = raw === null ? 0 : Number(raw);
2515
+ if (!Number.isFinite(n2)) return void 0;
2516
+ return {
2517
+ kind: "artistic",
2518
+ name: effect.localName,
2519
+ radius: effect.localName === "artisticBlur" ? n2 : n2 / 1e3,
2520
+ baked: true,
2521
+ ...unhandled.length ? { unhandled } : {}
2522
+ };
2523
+ }
2524
+
2594
2525
  // drawingml/ordered-color-transforms.ts
2595
2526
  function orderedColorTransforms(channels, transforms) {
2596
2527
  let { r, g, b } = channels;
@@ -2764,11 +2695,11 @@ function resolveDrawingColor(color, theme, options2) {
2764
2695
  }
2765
2696
  if (has("inv")) [r, g, b] = [255 - r, 255 - g, 255 - b];
2766
2697
  if (has("gray")) r = g = b = Math.round(0.299 * r + 0.587 * g + 0.114 * b);
2767
- const shade = parseDrawingPercent(find("shade"));
2768
- if (shade !== void 0) {
2769
- r = linearToSrgb255(srgb255ToLinear(r) * shade);
2770
- g = linearToSrgb255(srgb255ToLinear(g) * shade);
2771
- b = linearToSrgb255(srgb255ToLinear(b) * shade);
2698
+ const shade2 = parseDrawingPercent(find("shade"));
2699
+ if (shade2 !== void 0) {
2700
+ r = linearToSrgb255(srgb255ToLinear(r) * shade2);
2701
+ g = linearToSrgb255(srgb255ToLinear(g) * shade2);
2702
+ b = linearToSrgb255(srgb255ToLinear(b) * shade2);
2772
2703
  }
2773
2704
  const tint = parseDrawingPercent(find("tint"));
2774
2705
  if (tint !== void 0) {
@@ -2814,46 +2745,216 @@ function resolveDrawingColor(color, theme, options2) {
2814
2745
  };
2815
2746
  }
2816
2747
 
2817
- // drawingml/drawing-color-css.ts
2818
- function drawingColorCss(value) {
2819
- if (!value || value.alpha === 1) return value?.hex;
2820
- const channels = [1, 3, 5].map(
2821
- (offset) => Number.parseInt(value.hex.slice(offset, offset + 2), 16)
2822
- );
2823
- return `rgba(${channels.join(",")},${value.alpha})`;
2748
+ // drawingml/write-color.ts
2749
+ var ELEMENTS = {
2750
+ srgb: "srgbClr",
2751
+ scheme: "schemeClr",
2752
+ system: "sysClr",
2753
+ preset: "prstClr",
2754
+ scrgb: "scrgbClr",
2755
+ hsl: "hslClr"
2756
+ };
2757
+ function drawingColorXml(color) {
2758
+ const local = ELEMENTS[color.kind];
2759
+ const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
2760
+ const root = doc.documentElement;
2761
+ if (color.kind === "scrgb" || color.kind === "hsl") {
2762
+ const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
2763
+ const values = color.value.split(",");
2764
+ keys.forEach((key, i) => root.setAttribute(key, values[i] ?? "0"));
2765
+ } else root.setAttribute("val", color.value);
2766
+ if (color.fallback !== void 0 && color.kind === "system")
2767
+ root.setAttribute("lastClr", color.fallback);
2768
+ for (const transform of color.transforms) {
2769
+ if (!/^[A-Za-z_][\w.-]*$/.test(transform.name))
2770
+ throw new Error(`Invalid DrawingML transform ${transform.name}`);
2771
+ const node = doc.createElementNS(NS.a, `a:${transform.name}`);
2772
+ if (transform.value !== "") node.setAttribute("val", transform.value);
2773
+ root.appendChild(node);
2774
+ }
2775
+ return buildXml(doc);
2824
2776
  }
2825
2777
 
2826
- // drawingml/picture-crop.ts
2827
- var SIDES = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
2828
- function parsePictureCrop(blipFill) {
2829
- const rect3 = first(blipFill, "srcRect", NS.a);
2830
- if (!rect3) return void 0;
2831
- const result = {};
2832
- for (const [attr2, key] of Object.entries(SIDES)) {
2833
- const raw = rect3.getAttribute(attr2);
2834
- if (raw === null || !raw.trim()) continue;
2778
+ // drawingml/patch-color.ts
2779
+ function patchDrawingColorIn(container, color) {
2780
+ const old = elements(container).find((node) => parseDrawingColor(node));
2781
+ const before = parseDrawingColorIn(container);
2782
+ if (!old || !before || before.kind !== color.kind) {
2783
+ const next = container.ownerDocument.importNode(
2784
+ parseXml(drawingColorXml(color)).documentElement,
2785
+ true
2786
+ );
2787
+ if (old) container.replaceChild(next, old);
2788
+ else container.insertBefore(next, container.firstChild);
2789
+ return;
2790
+ }
2791
+ if (before.value !== color.value) {
2792
+ if (color.kind === "scrgb" || color.kind === "hsl") {
2793
+ const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
2794
+ const values = color.value.split(",");
2795
+ keys.forEach((key, index) => old.setAttribute(key, values[index] ?? "0"));
2796
+ } else old.setAttribute("val", color.value);
2797
+ }
2798
+ if (before.fallback !== color.fallback && color.kind === "system") {
2799
+ if (color.fallback === void 0) old.removeAttribute("lastClr");
2800
+ else old.setAttribute("lastClr", color.fallback);
2801
+ }
2802
+ const originals = elements(old);
2803
+ color.transforms.forEach((transform, index) => {
2804
+ const source = originals[index];
2805
+ if (source?.localName === transform.name) {
2806
+ if (before.transforms[index]?.value !== transform.value) {
2807
+ if (transform.value === "") source.removeAttribute("val");
2808
+ else source.setAttribute("val", transform.value);
2809
+ }
2810
+ return;
2811
+ }
2812
+ if (!/^[A-Za-z_][\w.-]*$/u.test(transform.name))
2813
+ throw new Error("Invalid DrawingML colour transform");
2814
+ const next = old.ownerDocument.createElementNS(NS.a, `a:${transform.name}`);
2815
+ if (transform.value !== "") next.setAttribute("val", transform.value);
2816
+ if (source) old.replaceChild(next, source);
2817
+ else old.appendChild(next);
2818
+ });
2819
+ for (const extra of originals.slice(color.transforms.length)) old.removeChild(extra);
2820
+ }
2821
+
2822
+ // drawingml/picture-standard-effects.ts
2823
+ var attrs = {
2824
+ biLevel: { threshold: "thresh" },
2825
+ alphaRepl: { amount: "a" },
2826
+ alphaBiLevel: { threshold: "thresh" },
2827
+ hsl: { hue: "hue", saturation: "sat", luminance: "lum" },
2828
+ tint: { hue: "hue", amount: "amt" },
2829
+ blur: { radiusEmu: "rad" }
2830
+ };
2831
+ function parseStandardPictureEffect(node) {
2832
+ const name = node.localName;
2833
+ if (![
2834
+ "biLevel",
2835
+ "alphaInv",
2836
+ "alphaCeiling",
2837
+ "alphaFloor",
2838
+ "alphaRepl",
2839
+ "alphaBiLevel",
2840
+ "alphaMod",
2841
+ "duotone",
2842
+ "clrRepl",
2843
+ "clrChange",
2844
+ "hsl",
2845
+ "tint",
2846
+ "blur"
2847
+ ].includes(name))
2848
+ return void 0;
2849
+ const values = {};
2850
+ for (const [key, attribute] of Object.entries(attrs[name] ?? {})) {
2851
+ const raw = node.getAttribute(attribute);
2852
+ if (raw === null) continue;
2835
2853
  const percent = raw.endsWith("%");
2836
- const value = Number(percent ? raw.slice(0, -1) : raw) / (percent ? 100 : 1e5);
2837
- if (Number.isFinite(value)) result[key] = value;
2854
+ const n2 = Number(percent ? raw.slice(0, -1) : raw) / (key === "hue" ? 6e4 : key === "radiusEmu" ? 1 : percent ? 100 : 1e5);
2855
+ if (!Number.isFinite(n2) || key === "hue" && (n2 < 0 || n2 >= 360) || key === "threshold" && (n2 < 0 || n2 > 1) || key === "radiusEmu" && (!Number.isSafeInteger(n2) || n2 < 0) || ["saturation", "luminance", "amount"].includes(key) && name !== "alphaMod" && (n2 < (name === "alphaRepl" ? 0 : -1) || n2 > 1))
2856
+ return void 0;
2857
+ values[key] = n2;
2838
2858
  }
2839
- return result;
2859
+ if (["biLevel", "alphaBiLevel"].includes(name) && values.threshold === void 0)
2860
+ return void 0;
2861
+ if (name === "alphaRepl" && values.amount === void 0) return void 0;
2862
+ if (name === "alphaMod") {
2863
+ const cont = first(node, "cont", NS.a);
2864
+ const nested = cont ? elements(cont) : [];
2865
+ if (nested.length !== 1 || nested[0]?.localName !== "alphaModFix") return void 0;
2866
+ const raw = nested[0].getAttribute("amt") ?? "100000";
2867
+ const n2 = Number(raw.endsWith("%") ? raw.slice(0, -1) : raw) / (raw.endsWith("%") ? 100 : 1e5);
2868
+ if (!Number.isFinite(n2) || n2 < 0) return void 0;
2869
+ values.amount = n2;
2870
+ }
2871
+ let colors = [];
2872
+ if (name === "duotone") {
2873
+ const candidates = elements(node).filter(
2874
+ (item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
2875
+ );
2876
+ colors = candidates.map((item2) => parseDrawingColor(item2)).filter((item2) => Boolean(item2));
2877
+ if (colors.length !== 2) return void 0;
2878
+ }
2879
+ if (name === "clrRepl") {
2880
+ const color = parseDrawingColorIn(node);
2881
+ if (!color) return void 0;
2882
+ colors = [color];
2883
+ }
2884
+ if (name === "clrChange") {
2885
+ const from = parseDrawingColorIn(first(node, "clrFrom", NS.a)), to = parseDrawingColorIn(first(node, "clrTo", NS.a));
2886
+ if (!from || !to) return void 0;
2887
+ colors = [from, to];
2888
+ }
2889
+ if (name === "alphaInv") {
2890
+ const color = parseDrawingColorIn(node);
2891
+ if (color) colors = [color];
2892
+ }
2893
+ return {
2894
+ kind: "standard",
2895
+ name,
2896
+ ...Object.keys(values).length ? { values } : {},
2897
+ ...colors.length ? { colors } : {},
2898
+ ...name === "clrChange" && node.hasAttribute("useA") ? { useAlpha: !["0", "false"].includes(node.getAttribute("useA") ?? "") } : {},
2899
+ ...name === "blur" && node.hasAttribute("grow") ? { grow: !["0", "false"].includes(node.getAttribute("grow") ?? "") } : {}
2900
+ };
2840
2901
  }
2841
- function applyPictureCrop(blipFill, crop) {
2842
- let rect3 = first(blipFill, "srcRect", NS.a);
2843
- if (!rect3 && crop && Object.values(crop).some((value) => value !== void 0)) {
2844
- rect3 = blipFill.ownerDocument.createElementNS(NS.a, "a:srcRect");
2845
- const blip = first(blipFill, "blip", NS.a);
2846
- blipFill.insertBefore(rect3, blip?.nextSibling ?? blipFill.firstChild);
2902
+ function applyStandardPictureEffect(node, effect) {
2903
+ const doc = node.ownerDocument, before = parseStandardPictureEffect(node);
2904
+ for (const [key, value] of Object.entries(effect.values ?? {})) {
2905
+ 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))
2906
+ throw new RangeError("Invalid picture effect values");
2907
+ }
2908
+ const count = effect.colors?.length ?? 0;
2909
+ if (["duotone", "clrChange"].includes(effect.name) && count !== 2 || effect.name === "clrRepl" && count !== 1 || effect.name === "alphaInv" && count > 1)
2910
+ throw new RangeError("Invalid picture effect colours");
2911
+ for (const [key, attribute] of Object.entries(attrs[effect.name] ?? {})) {
2912
+ const value = effect.values?.[key];
2913
+ if (value === before?.values?.[key]) continue;
2914
+ if (value === void 0) node.removeAttribute(attribute);
2915
+ else
2916
+ node.setAttribute(
2917
+ attribute,
2918
+ String(Math.round(value * (key === "hue" ? 6e4 : key === "radiusEmu" ? 1 : 1e5)))
2919
+ );
2847
2920
  }
2848
- if (!rect3) return;
2849
- for (const [attr2, key] of Object.entries(SIDES)) {
2850
- const value = crop?.[key];
2851
- if (value === void 0) rect3.removeAttribute(attr2);
2852
- else {
2853
- if (!Number.isFinite(value)) throw new RangeError("Picture crop must be finite");
2854
- rect3.setAttribute(attr2, String(Math.round(value * 1e5)));
2855
- }
2921
+ if (effect.name === "alphaMod" && effect.values?.amount !== before?.values?.amount) {
2922
+ const cont = first(node, "cont", NS.a) ?? doc.createElementNS(NS.a, "a:cont");
2923
+ const fix = first(cont, "alphaModFix", NS.a) ?? doc.createElementNS(NS.a, "a:alphaModFix");
2924
+ fix.setAttribute("amt", String(Math.round((effect.values?.amount ?? 1) * 1e5)));
2925
+ if (!fix.parentNode) cont.appendChild(fix);
2926
+ if (!cont.parentNode) node.appendChild(cont);
2927
+ }
2928
+ if (effect.useAlpha !== before?.useAlpha) {
2929
+ if (effect.useAlpha === void 0) node.removeAttribute("useA");
2930
+ else node.setAttribute("useA", effect.useAlpha ? "1" : "0");
2931
+ }
2932
+ if (effect.grow !== before?.grow) {
2933
+ if (effect.grow === void 0) node.removeAttribute("grow");
2934
+ else node.setAttribute("grow", effect.grow ? "1" : "0");
2935
+ }
2936
+ if (JSON.stringify(effect.colors) !== JSON.stringify(before?.colors)) {
2937
+ if (effect.name === "duotone") {
2938
+ const old = elements(node).filter(
2939
+ (item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
2940
+ );
2941
+ for (let i = 0; i < (effect.colors?.length ?? 0); i++) {
2942
+ const holder = doc.createElementNS(NS.a, "a:holder");
2943
+ if (old[i]) holder.appendChild(doc.importNode(old[i], true));
2944
+ patchDrawingColorIn(holder, effect.colors[i]);
2945
+ const next = elements(holder)[0];
2946
+ if (old[i]) node.replaceChild(next, old[i]);
2947
+ else node.insertBefore(next, first(node, "extLst", NS.a) ?? null);
2948
+ }
2949
+ } else if (effect.name === "clrChange") {
2950
+ for (const [i, name] of ["clrFrom", "clrTo"].entries()) {
2951
+ const holder = first(node, name, NS.a) ?? doc.createElementNS(NS.a, `a:${name}`);
2952
+ if (effect.colors?.[i]) patchDrawingColorIn(holder, effect.colors[i]);
2953
+ if (!holder.parentNode) node.insertBefore(holder, first(node, "extLst", NS.a) ?? null);
2954
+ }
2955
+ } else if (effect.colors?.[0]) patchDrawingColorIn(node, effect.colors[0]);
2856
2956
  }
2957
+ if (!parseStandardPictureEffect(node)) throw new RangeError("Invalid picture effect values");
2857
2958
  }
2858
2959
 
2859
2960
  // drawingml/picture-effects.ts
@@ -2893,14 +2994,19 @@ function readPictureEffect(name, attribute) {
2893
2994
  function parsePictureEffects(blip) {
2894
2995
  if (!blip) return [];
2895
2996
  return elements(blip).map((node) => ({
2896
- ...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) : void 0) ?? { kind: "unsupported", name: node.localName },
2997
+ ...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) ?? parseStandardPictureEffect(node) ?? parseArtisticPictureExtension(node) : void 0) ?? { kind: "unsupported", name: node.localName },
2897
2998
  sourceXml: buildXml(node)
2898
2999
  }));
2899
3000
  }
2900
3001
  function applyPictureEffects(blip, effects) {
2901
3002
  if (JSON.stringify(parsePictureEffects(blip)) === JSON.stringify(effects)) return;
2902
3003
  const nodes = effects.map((effect) => {
2903
- const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind;
3004
+ 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;
3005
+ if (effect.kind === "artistic") {
3006
+ const before = effect.sourceXml ? parseArtisticPictureExtension(parseXml(effect.sourceXml).documentElement) : void 0;
3007
+ if (!effect.baked || !before || before.name !== effect.name || before.radius !== effect.radius)
3008
+ throw new Error("Artistic authoring requires a host-generated baked picture cache");
3009
+ }
2904
3010
  const source = effect.sourceXml ? parseXml(effect.sourceXml).documentElement : void 0;
2905
3011
  if (effect.kind === "unsupported" && !source)
2906
3012
  throw new Error("An unsupported picture effect needs source XML");
@@ -2927,12 +3033,124 @@ function applyPictureEffects(blip, effects) {
2927
3033
  if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
2928
3034
  set("amt", effect.amount);
2929
3035
  }
3036
+ if (effect.kind === "standard") applyStandardPictureEffect(node, effect);
2930
3037
  return node;
2931
3038
  });
2932
3039
  for (const node of elements(blip)) blip.removeChild(node);
2933
3040
  for (const node of nodes) blip.appendChild(node);
2934
3041
  }
2935
3042
 
3043
+ // drawingml/picture-layout.ts
3044
+ function parsePictureLayout(fill) {
3045
+ const out = {};
3046
+ const rot = fill.getAttribute("rotWithShape");
3047
+ if (rot !== null) out.rotWithShape = rot !== "0" && rot !== "false";
3048
+ const dpi = Number(fill.getAttribute("dpi"));
3049
+ if (fill.hasAttribute("dpi") && Number.isFinite(dpi) && dpi > 0) out.dpi = dpi;
3050
+ const tile = first(fill, "tile", NS.a);
3051
+ if (tile) {
3052
+ const value = {};
3053
+ for (const [key, attr2] of [
3054
+ ["scaleX", "sx"],
3055
+ ["scaleY", "sy"]
3056
+ ]) {
3057
+ const n2 = picturePercentage(tile.getAttribute(attr2));
3058
+ if (n2 !== void 0) value[key] = n2;
3059
+ }
3060
+ for (const [key, attr2] of [
3061
+ ["offsetXEmu", "tx"],
3062
+ ["offsetYEmu", "ty"]
3063
+ ]) {
3064
+ const raw = tile.getAttribute(attr2);
3065
+ const n2 = raw === null ? NaN : Number(raw);
3066
+ if (Number.isSafeInteger(n2)) value[key] = n2;
3067
+ }
3068
+ const alignment = tile.getAttribute("algn");
3069
+ if (alignment) value.alignment = alignment;
3070
+ const flip = tile.getAttribute("flip");
3071
+ if (flip && ["none", "x", "y", "xy"].includes(flip))
3072
+ value.flip = flip;
3073
+ out.tile = value;
3074
+ }
3075
+ const rect3 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
3076
+ if (rect3)
3077
+ out.fillRect = {
3078
+ l: picturePercentage(rect3.getAttribute("l")) ?? 0,
3079
+ t: picturePercentage(rect3.getAttribute("t")) ?? 0,
3080
+ r: picturePercentage(rect3.getAttribute("r")) ?? 0,
3081
+ b: picturePercentage(rect3.getAttribute("b")) ?? 0
3082
+ };
3083
+ return out;
3084
+ }
3085
+ function applyPictureLayout(fill, layout) {
3086
+ const before = parsePictureLayout(fill);
3087
+ const attr2 = (node, name, value, old) => {
3088
+ if (value === old) return;
3089
+ if (value === void 0) node.removeAttribute(name);
3090
+ else node.setAttribute(name, String(value));
3091
+ };
3092
+ if (layout.rotWithShape !== before.rotWithShape)
3093
+ attr2(
3094
+ fill,
3095
+ "rotWithShape",
3096
+ layout.rotWithShape === void 0 ? void 0 : layout.rotWithShape ? "1" : "0",
3097
+ void 0
3098
+ );
3099
+ if (layout.dpi !== before.dpi) {
3100
+ if (layout.dpi !== void 0 && (!Number.isSafeInteger(layout.dpi) || layout.dpi <= 0))
3101
+ throw new RangeError("Invalid picture DPI");
3102
+ attr2(fill, "dpi", layout.dpi, void 0);
3103
+ }
3104
+ const make = (parent, name) => {
3105
+ const old = first(parent, name, NS.a);
3106
+ if (old) return old;
3107
+ const node = fill.ownerDocument.createElementNS(NS.a, `a:${name}`);
3108
+ parent.insertBefore(node, first(parent, "extLst", NS.a) ?? null);
3109
+ return node;
3110
+ };
3111
+ if (layout.tile) {
3112
+ const stretch = first(fill, "stretch", NS.a);
3113
+ if (stretch) fill.removeChild(stretch);
3114
+ const tile = make(fill, "tile");
3115
+ for (const [key, name] of [
3116
+ ["scaleX", "sx"],
3117
+ ["scaleY", "sy"],
3118
+ ["offsetXEmu", "tx"],
3119
+ ["offsetYEmu", "ty"]
3120
+ ]) {
3121
+ const n2 = layout.tile[key];
3122
+ if (n2 !== void 0 && (!Number.isFinite(n2) || (name === "sx" || name === "sy" ? n2 <= 0 : !Number.isSafeInteger(n2))))
3123
+ throw new RangeError("Invalid picture tile");
3124
+ if (n2 !== before.tile?.[key])
3125
+ attr2(
3126
+ tile,
3127
+ name,
3128
+ n2 === void 0 ? void 0 : Math.round(n2 * (name === "sx" || name === "sy" ? 1e5 : 1)),
3129
+ void 0
3130
+ );
3131
+ }
3132
+ if (layout.tile.alignment !== before.tile?.alignment) {
3133
+ if (layout.tile.alignment && !["tl", "t", "tr", "l", "ctr", "r", "bl", "b", "br"].includes(layout.tile.alignment))
3134
+ throw new RangeError("Invalid picture tile alignment");
3135
+ attr2(tile, "algn", layout.tile.alignment, void 0);
3136
+ }
3137
+ if (layout.tile.flip !== void 0 && !["none", "x", "y", "xy"].includes(layout.tile.flip))
3138
+ throw new RangeError("Invalid picture tile flip");
3139
+ if (layout.tile.flip !== before.tile?.flip) attr2(tile, "flip", layout.tile.flip, void 0);
3140
+ } else if (before.tile || layout.fillRect) {
3141
+ const tile = first(fill, "tile", NS.a);
3142
+ if (tile) fill.removeChild(tile);
3143
+ const rect3 = make(make(fill, "stretch"), "fillRect");
3144
+ for (const key of ["l", "t", "r", "b"]) {
3145
+ const n2 = layout.fillRect?.[key];
3146
+ if (n2 !== void 0 && !Number.isFinite(n2))
3147
+ throw new RangeError("Invalid picture fill rectangle");
3148
+ if (n2 !== before.fillRect?.[key])
3149
+ attr2(rect3, key, n2 === void 0 ? void 0 : Math.round(n2 * 1e5), void 0);
3150
+ }
3151
+ }
3152
+ }
3153
+
2936
3154
  // drawingml/picture-fill.ts
2937
3155
  function parseDrawingPictureFill(fill) {
2938
3156
  const blip = first(fill, "blip", NS.a);
@@ -2940,13 +3158,32 @@ function parseDrawingPictureFill(fill) {
2940
3158
  const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
2941
3159
  const crop = parsePictureCrop(fill);
2942
3160
  const effects = parsePictureEffects(blip);
2943
- const tile = first(fill, "tile", NS.a);
2944
- const rect3 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
2945
- const unsupported = [
2946
- ...tile ? ["tile"] : [],
2947
- ...rect3 && ["l", "t", "r", "b"].some((key) => Number(rect3.getAttribute(key) ?? 0) !== 0) ? ["fillRect"] : [],
2948
- ...fill.getAttribute("rotWithShape") === "0" || fill.getAttribute("rotWithShape") === "false" ? ["rotWithShape"] : []
2949
- ];
3161
+ const layout = parsePictureLayout(fill);
3162
+ const unsupported = [];
3163
+ const tile = first(fill, "tile", NS.a), stretch = first(fill, "stretch", NS.a);
3164
+ if (tile && stretch) unsupported.push("tile/stretch-choice");
3165
+ if (tile) {
3166
+ for (const [attr2, key] of [
3167
+ ["sx", "scaleX"],
3168
+ ["sy", "scaleY"],
3169
+ ["tx", "offsetXEmu"],
3170
+ ["ty", "offsetYEmu"]
3171
+ ])
3172
+ if (tile.hasAttribute(attr2) && (layout.tile?.[key] === void 0 || (attr2 === "sx" || attr2 === "sy") && layout.tile[key] <= 0))
3173
+ unsupported.push(`tile:${attr2}`);
3174
+ if (tile.hasAttribute("algn") && !["tl", "t", "tr", "l", "ctr", "r", "bl", "b", "br"].includes(tile.getAttribute("algn") ?? ""))
3175
+ unsupported.push("tile:algn");
3176
+ if (tile.hasAttribute("flip") && !layout.tile?.flip) unsupported.push("tile:flip");
3177
+ }
3178
+ const rect3 = first(stretch, "fillRect", NS.a);
3179
+ if (rect3)
3180
+ for (const key of ["l", "t", "r", "b"]) {
3181
+ const raw = rect3.getAttribute(key);
3182
+ if (raw !== null && !/^[-+]?(?:\d+\.?\d*|\.\d+)%?$/.test(raw))
3183
+ unsupported.push(`fillRect:${key}`);
3184
+ }
3185
+ if (fill.hasAttribute("rotWithShape") && !["0", "1", "true", "false"].includes(fill.getAttribute("rotWithShape") ?? ""))
3186
+ unsupported.push("rotWithShape");
2950
3187
  return {
2951
3188
  kind: "picture",
2952
3189
  sourceXml: buildXml(fill),
@@ -2954,10 +3191,180 @@ function parseDrawingPictureFill(fill) {
2954
3191
  ...linkRelId ? { linkRelId } : {},
2955
3192
  ...crop ? { crop } : {},
2956
3193
  ...effects.length ? { effects } : {},
3194
+ ...Object.keys(layout).length ? { layout } : {},
2957
3195
  ...unsupported.length ? { unsupportedPicture: unsupported } : {}
2958
3196
  };
2959
3197
  }
2960
3198
 
3199
+ // opc/signature/xml-utils.ts
3200
+ function escapeXmlAttr(value) {
3201
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
3202
+ }
3203
+
3204
+ // docx/watermark.ts
3205
+ var VML_NS = "urn:schemas-microsoft-com:vml";
3206
+ var OFFICE_NS = "urn:schemas-microsoft-com:office:office";
3207
+ var WORD10_NS = "urn:schemas-microsoft-com:office:word";
3208
+ var WATERMARK_PREFIX = "PowerPlusWaterMarkObject";
3209
+ function watermarkSizePt(spec) {
3210
+ const chars = Math.max(1, [...spec.text].length);
3211
+ const width = Math.min(spec.layout === "diagonal" ? 527 : 468, Math.max(150, chars * 44));
3212
+ return { width, height: Math.round(width / (chars * 0.55) * 100) / 100 };
3213
+ }
3214
+ var FORMULAS = [
3215
+ "sum #0 0 10800",
3216
+ "prod #0 2 1",
3217
+ "sum 21600 0 @1",
3218
+ "sum 0 0 @2",
3219
+ "sum 21600 0 @3",
3220
+ "if @0 @3 0",
3221
+ "if @0 21600 @1",
3222
+ "if @0 0 @2",
3223
+ "if @0 @4 21600",
3224
+ "mid @5 @6",
3225
+ "mid @8 @5",
3226
+ "mid @7 @8",
3227
+ "mid @6 @7",
3228
+ "sum @6 0 @5"
3229
+ ];
3230
+ function buildWatermarkRun(doc, spec, uniqueId) {
3231
+ const v = (name) => makeNS(doc, VML_NS, `v:${name}`);
3232
+ const run = makeW(doc, "r");
3233
+ const props = makeW(doc, "rPr");
3234
+ props.appendChild(makeW(doc, "noProof"));
3235
+ run.appendChild(props);
3236
+ const pict = makeW(doc, "pict");
3237
+ const type = v("shapetype");
3238
+ type.setAttribute("id", "_x0000_t136");
3239
+ type.setAttribute("coordsize", "21600,21600");
3240
+ type.setAttributeNS(OFFICE_NS, "o:spt", "136");
3241
+ type.setAttribute("adj", "10800");
3242
+ type.setAttribute("path", "m@7,l@8,m@5,21600l@6,21600e");
3243
+ const formulas = v("formulas");
3244
+ for (const eqn of FORMULAS) {
3245
+ const f = v("f");
3246
+ f.setAttribute("eqn", eqn);
3247
+ formulas.appendChild(f);
3248
+ }
3249
+ const path = v("path");
3250
+ path.setAttribute("textpathok", "t");
3251
+ path.setAttributeNS(OFFICE_NS, "o:connecttype", "custom");
3252
+ path.setAttributeNS(OFFICE_NS, "o:connectlocs", "@9,0;@10,10800;@11,21600;@12,10800");
3253
+ path.setAttributeNS(OFFICE_NS, "o:connectangles", "270,180,90,0");
3254
+ const typePath = v("textpath");
3255
+ typePath.setAttribute("on", "t");
3256
+ typePath.setAttribute("fitshape", "t");
3257
+ const handles = v("handles");
3258
+ const handle = v("h");
3259
+ handle.setAttribute("position", "#0,bottomRight");
3260
+ handle.setAttribute("xrange", "6629,14971");
3261
+ handles.appendChild(handle);
3262
+ const lock = makeNS(doc, OFFICE_NS, "o:lock");
3263
+ lock.setAttributeNS(VML_NS, "v:ext", "edit");
3264
+ lock.setAttribute("text", "t");
3265
+ lock.setAttribute("shapetype", "t");
3266
+ for (const child3 of [formulas, path, typePath, handles, lock]) type.appendChild(child3);
3267
+ const size = watermarkSizePt(spec);
3268
+ const shape = v("shape");
3269
+ shape.setAttribute("id", `${WATERMARK_PREFIX}${uniqueId}`);
3270
+ shape.setAttributeNS(OFFICE_NS, "o:spid", `_x0000_s${2048 + (Number(uniqueId) || 1)}`);
3271
+ shape.setAttribute("type", "#_x0000_t136");
3272
+ shape.setAttribute(
3273
+ "style",
3274
+ `position:absolute;margin-left:0;margin-top:0;width:${size.width}pt;height:${size.height}pt;${spec.layout === "diagonal" ? "rotation:315;" : ""}z-index:-251658752;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin`
3275
+ );
3276
+ shape.setAttributeNS(OFFICE_NS, "o:allowincell", "f");
3277
+ shape.setAttribute("fillcolor", spec.color.replace(/^#/, "").toLowerCase());
3278
+ shape.setAttribute("stroked", "f");
3279
+ const fill = v("fill");
3280
+ fill.setAttribute("opacity", spec.semitransparent ? ".5" : "1");
3281
+ const text2 = v("textpath");
3282
+ text2.setAttribute("style", `font-family:"${spec.fontFamily ?? "Calibri"}";font-size:1pt`);
3283
+ text2.setAttribute("string", spec.text);
3284
+ const wrap = makeNS(doc, WORD10_NS, "w10:wrap");
3285
+ wrap.setAttribute("anchorx", "margin");
3286
+ wrap.setAttribute("anchory", "margin");
3287
+ for (const child3 of [fill, text2, wrap]) shape.appendChild(child3);
3288
+ pict.appendChild(type);
3289
+ pict.appendChild(shape);
3290
+ run.appendChild(pict);
3291
+ return run;
3292
+ }
3293
+
3294
+ // docx/write-text-box.ts
3295
+ var A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
3296
+ var WP_NS = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
3297
+ var WPS_NS = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
3298
+ var W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
3299
+ var el = (doc, ns, name) => makeNS(doc, ns, name);
3300
+ var add = (parent, ...items) => {
3301
+ for (const item2 of items) parent.appendChild(item2);
3302
+ return parent;
3303
+ };
3304
+ var emu = (px) => String(Math.max(1, Math.round(px * EMU_PER_PIXEL)));
3305
+ var descendants2 = (root, ns, local) => Array.from(root.getElementsByTagNameNS(ns, local));
3306
+ function paragraphsFor(doc, lines) {
3307
+ return (lines.length ? lines : [""]).map((line4) => {
3308
+ const paragraph = makeW(doc, "p");
3309
+ if (line4) {
3310
+ const run = makeW(doc, "r");
3311
+ const text2 = makeW(doc, "t");
3312
+ if (/^\s|\s$/.test(line4))
3313
+ text2.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
3314
+ text2.textContent = line4;
3315
+ add(run, text2);
3316
+ add(paragraph, run);
3317
+ }
3318
+ return paragraph;
3319
+ });
3320
+ }
3321
+ function outline(doc, border) {
3322
+ const ln = el(doc, A_NS, "a:ln");
3323
+ if (!border) return add(ln, el(doc, A_NS, "a:noFill"));
3324
+ ln.setAttribute("w", "9525");
3325
+ const color = el(doc, A_NS, "a:srgbClr");
3326
+ color.setAttribute("val", "000000");
3327
+ return add(ln, add(el(doc, A_NS, "a:solidFill"), color));
3328
+ }
3329
+ function patchTextBox(doc, drawing, image, base) {
3330
+ if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
3331
+ for (const node of [
3332
+ ...descendants2(drawing, WP_NS, "extent"),
3333
+ ...descendants2(drawing, A_NS, "ext").filter(
3334
+ (ext) => ext.parentNode?.localName === "xfrm"
3335
+ )
3336
+ ]) {
3337
+ node.setAttribute("cx", emu(image.widthPx));
3338
+ node.setAttribute("cy", emu(image.heightPx));
3339
+ }
3340
+ if (JSON.stringify(image.textBoxText) !== JSON.stringify(base.textBoxText)) {
3341
+ const content = descendants2(drawing, W_NS, "txbxContent")[0];
3342
+ if (content) {
3343
+ for (const child3 of Array.from(content.childNodes)) content.removeChild(child3);
3344
+ add(content, ...paragraphsFor(doc, image.textBoxText ?? []));
3345
+ }
3346
+ }
3347
+ if (image.textBoxBorder !== false !== (base.textBoxBorder !== false)) {
3348
+ const spPr = descendants2(drawing, WPS_NS, "spPr")[0];
3349
+ if (spPr) {
3350
+ for (const old of Array.from(spPr.childNodes).filter(
3351
+ (node) => isElement(node) && node.localName === "ln"
3352
+ ))
3353
+ spPr.removeChild(old);
3354
+ spPr.appendChild(outline(doc, image.textBoxBorder !== false));
3355
+ }
3356
+ }
3357
+ }
3358
+
3359
+ // drawingml/drawing-color-css.ts
3360
+ function drawingColorCss(value) {
3361
+ if (!value || value.alpha === 1) return value?.hex;
3362
+ const channels = [1, 3, 5].map(
3363
+ (offset) => Number.parseInt(value.hex.slice(offset, offset + 2), 16)
3364
+ );
3365
+ return `rgba(${channels.join(",")},${value.alpha})`;
3366
+ }
3367
+
2961
3368
  // drawingml/drawing-fill.ts
2962
3369
  var FILL_ELEMENTS = /* @__PURE__ */ new Set([
2963
3370
  "noFill",
@@ -3036,22 +3443,22 @@ function parseDrawingFill(properties3) {
3036
3443
  }
3037
3444
  function parseDrawingLine(ln) {
3038
3445
  if (!ln) return void 0;
3039
- const line3 = { sourceXml: buildXml(ln) };
3446
+ const line4 = { sourceXml: buildXml(ln) };
3040
3447
  const width = Number.parseInt(ln.getAttribute("w") ?? "", 10);
3041
- if (Number.isFinite(width)) line3.widthEmu = width;
3448
+ if (Number.isFinite(width)) line4.widthEmu = width;
3042
3449
  const fill = parseDrawingFill(ln);
3043
- if (fill) line3.fill = fill;
3450
+ if (fill) line4.fill = fill;
3044
3451
  const dash = first(ln, "prstDash", NS.a)?.getAttribute("val");
3045
- if (dash) line3.dash = dash;
3452
+ if (dash) line4.dash = dash;
3046
3453
  const cap = ln.getAttribute("cap");
3047
- if (cap) line3.cap = cap;
3454
+ if (cap) line4.cap = cap;
3048
3455
  const compound = ln.getAttribute("cmpd");
3049
- if (compound !== null) line3.compound = compound;
3456
+ if (compound !== null) line4.compound = compound;
3050
3457
  const alignment = ln.getAttribute("algn");
3051
- if (alignment !== null) line3.alignment = alignment;
3458
+ if (alignment !== null) line4.alignment = alignment;
3052
3459
  const custom = first(ln, "custDash", NS.a);
3053
3460
  if (custom && !dash) {
3054
- line3.customDash = children(custom, "ds", NS.a).flatMap((node) => {
3461
+ line4.customDash = children(custom, "ds", NS.a).flatMap((node) => {
3055
3462
  const dash2 = drawingDashLength(node.getAttribute("d"));
3056
3463
  const space = drawingDashLength(node.getAttribute("sp"));
3057
3464
  return dash2 !== void 0 && space !== void 0 ? [{ dash: dash2, space, sourceXml: buildXml(node) }] : [];
@@ -3061,23 +3468,23 @@ function parseDrawingLine(ln) {
3061
3468
  const join = first(ln, kind, NS.a);
3062
3469
  if (!join) continue;
3063
3470
  const limit = Number(join.getAttribute("lim"));
3064
- line3.join = { kind, ...join.hasAttribute("lim") && Number.isFinite(limit) ? { limit } : {} };
3471
+ line4.join = { kind, ...join.hasAttribute("lim") && Number.isFinite(limit) ? { limit } : {} };
3065
3472
  break;
3066
3473
  }
3067
3474
  for (const end of ["headEnd", "tailEnd"]) {
3068
3475
  const node = first(ln, end, NS.a);
3069
3476
  if (!node) continue;
3070
- line3[end] = {};
3477
+ line4[end] = {};
3071
3478
  for (const [attribute, key] of [
3072
3479
  ["type", "type"],
3073
3480
  ["w", "width"],
3074
3481
  ["len", "length"]
3075
3482
  ]) {
3076
3483
  const value = node.getAttribute(attribute);
3077
- if (value !== null) line3[end][key] = value;
3484
+ if (value !== null) line4[end][key] = value;
3078
3485
  }
3079
3486
  }
3080
- return line3;
3487
+ return line4;
3081
3488
  }
3082
3489
  function drawingDashLength(value) {
3083
3490
  if (!/^\d+$/u.test(value ?? "")) return void 0;
@@ -3273,80 +3680,6 @@ function evaluateGuides(guides, ctx, adjustments) {
3273
3680
  return vars;
3274
3681
  }
3275
3682
 
3276
- // drawingml/write-color.ts
3277
- var ELEMENTS = {
3278
- srgb: "srgbClr",
3279
- scheme: "schemeClr",
3280
- system: "sysClr",
3281
- preset: "prstClr",
3282
- scrgb: "scrgbClr",
3283
- hsl: "hslClr"
3284
- };
3285
- function drawingColorXml(color) {
3286
- const local = ELEMENTS[color.kind];
3287
- const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
3288
- const root = doc.documentElement;
3289
- if (color.kind === "scrgb" || color.kind === "hsl") {
3290
- const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
3291
- const values = color.value.split(",");
3292
- keys.forEach((key, i) => root.setAttribute(key, values[i] ?? "0"));
3293
- } else root.setAttribute("val", color.value);
3294
- if (color.fallback !== void 0 && color.kind === "system")
3295
- root.setAttribute("lastClr", color.fallback);
3296
- for (const transform of color.transforms) {
3297
- if (!/^[A-Za-z_][\w.-]*$/.test(transform.name))
3298
- throw new Error(`Invalid DrawingML transform ${transform.name}`);
3299
- const node = doc.createElementNS(NS.a, `a:${transform.name}`);
3300
- if (transform.value !== "") node.setAttribute("val", transform.value);
3301
- root.appendChild(node);
3302
- }
3303
- return buildXml(doc);
3304
- }
3305
-
3306
- // drawingml/patch-color.ts
3307
- function patchDrawingColorIn(container, color) {
3308
- const old = elements(container).find((node) => parseDrawingColor(node));
3309
- const before = parseDrawingColorIn(container);
3310
- if (!old || !before || before.kind !== color.kind) {
3311
- const next = container.ownerDocument.importNode(
3312
- parseXml(drawingColorXml(color)).documentElement,
3313
- true
3314
- );
3315
- if (old) container.replaceChild(next, old);
3316
- else container.insertBefore(next, container.firstChild);
3317
- return;
3318
- }
3319
- if (before.value !== color.value) {
3320
- if (color.kind === "scrgb" || color.kind === "hsl") {
3321
- const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
3322
- const values = color.value.split(",");
3323
- keys.forEach((key, index) => old.setAttribute(key, values[index] ?? "0"));
3324
- } else old.setAttribute("val", color.value);
3325
- }
3326
- if (before.fallback !== color.fallback && color.kind === "system") {
3327
- if (color.fallback === void 0) old.removeAttribute("lastClr");
3328
- else old.setAttribute("lastClr", color.fallback);
3329
- }
3330
- const originals = elements(old);
3331
- color.transforms.forEach((transform, index) => {
3332
- const source = originals[index];
3333
- if (source?.localName === transform.name) {
3334
- if (before.transforms[index]?.value !== transform.value) {
3335
- if (transform.value === "") source.removeAttribute("val");
3336
- else source.setAttribute("val", transform.value);
3337
- }
3338
- return;
3339
- }
3340
- if (!/^[A-Za-z_][\w.-]*$/u.test(transform.name))
3341
- throw new Error("Invalid DrawingML colour transform");
3342
- const next = old.ownerDocument.createElementNS(NS.a, `a:${transform.name}`);
3343
- if (transform.value !== "") next.setAttribute("val", transform.value);
3344
- if (source) old.replaceChild(next, source);
3345
- else old.appendChild(next);
3346
- });
3347
- for (const extra of originals.slice(color.transforms.length)) old.removeChild(extra);
3348
- }
3349
-
3350
3683
  // drawingml/write-pattern-picture.ts
3351
3684
  function drawingPatternPictureXml(fill) {
3352
3685
  const name = fill.kind === "pattern" ? "pattFill" : "blipFill";
@@ -3408,7 +3741,8 @@ function drawingPatternPictureXml(fill) {
3408
3741
  applyPictureCrop(root, fill.crop);
3409
3742
  if (fill.effects !== void 0 && JSON.stringify(before?.kind === "picture" ? before.effects ?? [] : []) !== JSON.stringify(fill.effects ?? []))
3410
3743
  applyPictureEffects(blip, fill.effects ?? []);
3411
- if (!fill.sourceXml) {
3744
+ if (fill.layout !== void 0) applyPictureLayout(root, fill.layout);
3745
+ if (!fill.sourceXml && !fill.layout?.tile && !first(root, "stretch", NS.a)) {
3412
3746
  const stretch = doc.createElementNS(NS.a, "a:stretch");
3413
3747
  stretch.appendChild(doc.createElementNS(NS.a, "a:fillRect"));
3414
3748
  root.appendChild(stretch);
@@ -3645,29 +3979,29 @@ function remove(host, names) {
3645
3979
  for (const child3 of elements(host))
3646
3980
  if (child3.namespaceURI === NS.a && names.includes(child3.localName)) host.removeChild(child3);
3647
3981
  }
3648
- function patchDrawingLine(ln, line3) {
3649
- const before = line3.sourceXml ? parseDrawingLine(ln) : void 0;
3650
- const changed = (key) => !before || !same(before[key], line3[key]);
3982
+ function patchDrawingLine(ln, line4) {
3983
+ const before = line4.sourceXml ? parseDrawingLine(ln) : void 0;
3984
+ const changed = (key) => !before || !same(before[key], line4[key]);
3651
3985
  for (const [key, attribute] of [
3652
3986
  ["widthEmu", "w"],
3653
3987
  ["cap", "cap"],
3654
3988
  ["compound", "cmpd"],
3655
3989
  ["alignment", "algn"]
3656
3990
  ]) {
3657
- if (!changed(key) || (key === "compound" || key === "alignment") && !line3.sourceXml && !(key in line3))
3991
+ if (!changed(key) || (key === "compound" || key === "alignment") && !line4.sourceXml && !(key in line4))
3658
3992
  continue;
3659
- const value = line3[key];
3993
+ const value = line4[key];
3660
3994
  if (value === void 0) ln.removeAttribute(attribute);
3661
3995
  else ln.setAttribute(attribute, String(typeof value === "number" ? Math.round(value) : value));
3662
3996
  }
3663
3997
  if (changed("fill")) {
3664
- if (line3.fill?.kind === "picture")
3998
+ if (line4.fill?.kind === "picture")
3665
3999
  throw new Error("Picture fills are not supported on DrawingML outlines");
3666
4000
  const solid = first(ln, "solidFill", NS.a);
3667
- if (solid && line3.fill?.kind === "solid") patchDrawingColorIn(solid, line3.fill.color);
4001
+ if (solid && line4.fill?.kind === "solid") patchDrawingColorIn(solid, line4.fill.color);
3668
4002
  else {
3669
- const xml = line3.fill && drawingFillXml(line3.fill);
3670
- if (xml || !line3.fill) remove(ln, FILLS);
4003
+ const xml = line4.fill && drawingFillXml(line4.fill);
4004
+ if (xml || !line4.fill) remove(ln, FILLS);
3671
4005
  if (xml) {
3672
4006
  const child3 = importXml(ln, xml);
3673
4007
  dropDrawingDeclarations(child3);
@@ -3675,21 +4009,21 @@ function patchDrawingLine(ln, line3) {
3675
4009
  }
3676
4010
  }
3677
4011
  }
3678
- if (changed("dash") || changed("customDash")) patchDash(ln, line3);
3679
- if ((line3.sourceXml || "join" in line3) && changed("join")) {
3680
- const original = line3.join && first(ln, line3.join.kind, NS.a);
4012
+ if (changed("dash") || changed("customDash")) patchDash(ln, line4);
4013
+ if ((line4.sourceXml || "join" in line4) && changed("join")) {
4014
+ const original = line4.join && first(ln, line4.join.kind, NS.a);
3681
4015
  const node = original?.cloneNode(true);
3682
4016
  remove(ln, ["round", "bevel", "miter"]);
3683
- if (line3.join) {
3684
- const next = node ?? ln.ownerDocument.createElementNS(NS.a, `a:${line3.join.kind}`);
3685
- if (line3.join.limit === void 0) next.removeAttribute("lim");
3686
- else next.setAttribute("lim", String(line3.join.limit));
4017
+ if (line4.join) {
4018
+ const next = node ?? ln.ownerDocument.createElementNS(NS.a, `a:${line4.join.kind}`);
4019
+ if (line4.join.limit === void 0) next.removeAttribute("lim");
4020
+ else next.setAttribute("lim", String(line4.join.limit));
3687
4021
  insert(ln, next);
3688
4022
  }
3689
4023
  }
3690
4024
  for (const key of ["headEnd", "tailEnd"]) {
3691
- if (!line3.sourceXml && !(key in line3) || !changed(key)) continue;
3692
- const end = line3[key];
4025
+ if (!line4.sourceXml && !(key in line4) || !changed(key)) continue;
4026
+ const end = line4[key];
3693
4027
  const old = first(ln, key, NS.a);
3694
4028
  if (!end) {
3695
4029
  if (old) ln.removeChild(old);
@@ -3708,15 +4042,15 @@ function patchDrawingLine(ln, line3) {
3708
4042
  if (!old) insert(ln, node);
3709
4043
  }
3710
4044
  }
3711
- function patchDash(ln, line3) {
3712
- if (line3.dash === void 0 && line3.customDash === void 0) {
3713
- remove(ln, line3.sourceXml ? ["prstDash", "custDash"] : ["prstDash"]);
4045
+ function patchDash(ln, line4) {
4046
+ if (line4.dash === void 0 && line4.customDash === void 0) {
4047
+ remove(ln, line4.sourceXml ? ["prstDash", "custDash"] : ["prstDash"]);
3714
4048
  return;
3715
4049
  }
3716
- if (line3.dash !== void 0) {
4050
+ if (line4.dash !== void 0) {
3717
4051
  remove(ln, ["prstDash", "custDash"]);
3718
4052
  const node2 = ln.ownerDocument.createElementNS(NS.a, "a:prstDash");
3719
- node2.setAttribute("val", line3.dash);
4053
+ node2.setAttribute("val", line4.dash);
3720
4054
  insert(ln, node2);
3721
4055
  return;
3722
4056
  }
@@ -3726,7 +4060,7 @@ function patchDash(ln, line3) {
3726
4060
  const stops = elements(node).filter(
3727
4061
  (stop) => stop.namespaceURI === NS.a && stop.localName === "ds" && drawingDashLength(stop.getAttribute("d")) !== void 0 && drawingDashLength(stop.getAttribute("sp")) !== void 0
3728
4062
  );
3729
- line3.customDash?.forEach((stop, index) => {
4063
+ line4.customDash?.forEach((stop, index) => {
3730
4064
  if (drawingDashLength(String(stop.dash)) === void 0 || drawingDashLength(String(stop.space)) === void 0)
3731
4065
  throw new Error("Invalid DrawingML custom dash length");
3732
4066
  const next = stops[index] ?? (stop.sourceXml ? importXml(ln, stop.sourceXml) : ln.ownerDocument.createElementNS(NS.a, "a:ds"));
@@ -3734,15 +4068,15 @@ function patchDash(ln, line3) {
3734
4068
  next.setAttribute("sp", String(stop.space));
3735
4069
  if (!next.parentNode) node.appendChild(next);
3736
4070
  });
3737
- for (const stop of stops.slice(line3.customDash?.length ?? 0)) node.removeChild(stop);
4071
+ for (const stop of stops.slice(line4.customDash?.length ?? 0)) node.removeChild(stop);
3738
4072
  remove(ln, ["prstDash", "custDash"]);
3739
4073
  insert(ln, node);
3740
4074
  }
3741
- function drawingLineXml(line3) {
3742
- const doc = parseXml(line3.sourceXml ?? `<a:ln xmlns:a="${NS.a}"/>`);
4075
+ function drawingLineXml(line4) {
4076
+ const doc = parseXml(line4.sourceXml ?? `<a:ln xmlns:a="${NS.a}"/>`);
3743
4077
  if (doc.documentElement.namespaceURI !== NS.a || doc.documentElement.localName !== "ln")
3744
4078
  throw new Error("Invalid DrawingML outline source XML");
3745
- patchDrawingLine(doc.documentElement, line3);
4079
+ patchDrawingLine(doc.documentElement, line4);
3746
4080
  return buildXml(doc);
3747
4081
  }
3748
4082
 
@@ -4016,8 +4350,8 @@ function readChild(child3, out, extra) {
4016
4350
  return;
4017
4351
  }
4018
4352
  if (name === "ln") {
4019
- const line3 = parseDrawingLine(child3);
4020
- if (line3) out.line = line3;
4353
+ const line4 = parseDrawingLine(child3);
4354
+ if (line4) out.line = line4;
4021
4355
  out.lineSourceXml = outerXml(child3);
4022
4356
  } else if (name in FONT_SLOTS) {
4023
4357
  const font = parseDrawingFont(child3);
@@ -13907,7 +14241,7 @@ function isSpace(ch) {
13907
14241
  return ch === " " || ch === " " || ch === "\n" || ch === "\r";
13908
14242
  }
13909
14243
  function parseAttributes(source) {
13910
- const attrs2 = {};
14244
+ const attrs3 = {};
13911
14245
  let i = 0;
13912
14246
  const n2 = source.length;
13913
14247
  while (i < n2) {
@@ -13942,9 +14276,9 @@ function parseAttributes(source) {
13942
14276
  if (name === "xmlns" || name.startsWith("xmlns:")) {
13943
14277
  continue;
13944
14278
  }
13945
- attrs2[localName(name)] = decodeEntities(value);
14279
+ attrs3[localName(name)] = decodeEntities(value);
13946
14280
  }
13947
- return attrs2;
14281
+ return attrs3;
13948
14282
  }
13949
14283
  function tagEnd(xml, from) {
13950
14284
  let quote = "";
@@ -14070,14 +14404,14 @@ function numOrNaN(value) {
14070
14404
  function relation(value) {
14071
14405
  return value === "ch" || value === "des" ? value : "self";
14072
14406
  }
14073
- function parseIterator(attrs2) {
14407
+ function parseIterator(attrs3) {
14074
14408
  return {
14075
- axis: list(attrs2.axis),
14076
- ptType: list(attrs2.ptType),
14077
- hideLastTrans: list(attrs2.hideLastTrans).map((v) => v === "1" || v === "true"),
14078
- st: numberList(attrs2.st),
14079
- cnt: numberList(attrs2.cnt),
14080
- step: numberList(attrs2.step)
14409
+ axis: list(attrs3.axis),
14410
+ ptType: list(attrs3.ptType),
14411
+ hideLastTrans: list(attrs3.hideLastTrans).map((v) => v === "1" || v === "true"),
14412
+ st: numberList(attrs3.st),
14413
+ cnt: numberList(attrs3.cnt),
14414
+ step: numberList(attrs3.step)
14081
14415
  };
14082
14416
  }
14083
14417
  function parseAlgorithm(element3) {
@@ -14108,41 +14442,41 @@ function parseShape(element3) {
14108
14442
  adj
14109
14443
  };
14110
14444
  }
14111
- function parseConstraint(attrs2) {
14112
- const op = attrs2.op;
14445
+ function parseConstraint(attrs3) {
14446
+ const op = attrs3.op;
14113
14447
  return {
14114
- type: attrs2.type ?? "none",
14115
- for: relation(attrs2.for),
14116
- forName: attrs2.forName || void 0,
14117
- ptType: attrs2.ptType ?? "all",
14118
- refType: attrs2.refType ?? "none",
14119
- refFor: relation(attrs2.refFor),
14120
- refForName: attrs2.refForName || void 0,
14121
- refPtType: attrs2.refPtType ?? "all",
14448
+ type: attrs3.type ?? "none",
14449
+ for: relation(attrs3.for),
14450
+ forName: attrs3.forName || void 0,
14451
+ ptType: attrs3.ptType ?? "all",
14452
+ refType: attrs3.refType ?? "none",
14453
+ refFor: relation(attrs3.refFor),
14454
+ refForName: attrs3.refForName || void 0,
14455
+ refPtType: attrs3.refPtType ?? "all",
14122
14456
  op: op === "equ" || op === "gte" || op === "lte" ? op : "none",
14123
- val: num(attrs2.val, 0),
14124
- hasVal: attrs2.val !== void 0,
14125
- fact: num(attrs2.fact, 1)
14457
+ val: num(attrs3.val, 0),
14458
+ hasVal: attrs3.val !== void 0,
14459
+ fact: num(attrs3.fact, 1)
14126
14460
  };
14127
14461
  }
14128
- function parseRule(attrs2) {
14462
+ function parseRule(attrs3) {
14129
14463
  return {
14130
- type: attrs2.type ?? "none",
14131
- for: relation(attrs2.for),
14132
- forName: attrs2.forName || void 0,
14133
- ptType: attrs2.ptType ?? "all",
14134
- val: numOrNaN(attrs2.val),
14135
- fact: numOrNaN(attrs2.fact),
14136
- max: numOrNaN(attrs2.max)
14464
+ type: attrs3.type ?? "none",
14465
+ for: relation(attrs3.for),
14466
+ forName: attrs3.forName || void 0,
14467
+ ptType: attrs3.ptType ?? "all",
14468
+ val: numOrNaN(attrs3.val),
14469
+ fact: numOrNaN(attrs3.fact),
14470
+ max: numOrNaN(attrs3.max)
14137
14471
  };
14138
14472
  }
14139
- function parseCondition(attrs2) {
14473
+ function parseCondition(attrs3) {
14140
14474
  return {
14141
- ...parseIterator(attrs2),
14142
- func: attrs2.func ?? "cnt",
14143
- arg: attrs2.arg,
14144
- op: attrs2.op ?? "equ",
14145
- val: attrs2.val ?? ""
14475
+ ...parseIterator(attrs3),
14476
+ func: attrs3.func ?? "cnt",
14477
+ arg: attrs3.arg,
14478
+ op: attrs3.op ?? "equ",
14479
+ val: attrs3.val ?? ""
14146
14480
  };
14147
14481
  }
14148
14482
  function parseBody(element3, state) {
@@ -15755,10 +16089,10 @@ function paragraphsHeight(text2, sizePt, availW, metrics) {
15755
16089
  if (wrappedWidestLineWidth(p.text, widthPx, sizePx, table) > widthPx) {
15756
16090
  return void 0;
15757
16091
  }
15758
- const line3 = p.size * lineEm;
15759
- height += wrappedLineCount(p.text, widthPx, sizePx, table) * line3 * SMARTART_LINE_SPACING_FACTOR;
16092
+ const line4 = p.size * lineEm;
16093
+ height += wrappedLineCount(p.text, widthPx, sizePx, table) * line4 * SMARTART_LINE_SPACING_FACTOR;
15760
16094
  if (i < paragraphs.length - 1) {
15761
- height += p.spcAft * line3;
16095
+ height += p.spcAft * line4;
15762
16096
  }
15763
16097
  }
15764
16098
  return height + SMARTART_TEXT_BLOCK_EXTRA_EM * sizePt;
@@ -17645,14 +17979,14 @@ function arrangeSnake(node) {
17645
17979
  const fromBottom = grDir === "bL" || grDir === "bR";
17646
17980
  const reverseAlternate = params.contDir === "revDir";
17647
17981
  cells.forEach((cell, i) => {
17648
- const line3 = Math.floor(i / lineLen);
17649
- const inLine = Math.min(lineLen, n2 - line3 * lineLen);
17650
- const reversedLine = reverseAlternate && line3 % 2 === 1;
17982
+ const line4 = Math.floor(i / lineLen);
17983
+ const inLine = Math.min(lineLen, n2 - line4 * lineLen);
17984
+ const reversedLine = reverseAlternate && line4 % 2 === 1;
17651
17985
  const pos = reversedLine ? lineLen - 1 - i % lineLen : i % lineLen;
17652
17986
  const centre = params.off === "ctr" ? (lineLen - inLine) / 2 : 0;
17653
17987
  const shortShift = reversedLine ? -centre : centre;
17654
- let col = row ? pos + shortShift : line3;
17655
- let rowIdx = row ? line3 : pos + shortShift;
17988
+ let col = row ? pos + shortShift : line4;
17989
+ let rowIdx = row ? line4 : pos + shortShift;
17656
17990
  if (fromRight) {
17657
17991
  col = dims.cols - 1 - col;
17658
17992
  }
@@ -18143,9 +18477,9 @@ function applyEngineFonts(collected, nodeById, fontName) {
18143
18477
  };
18144
18478
  for (const { node: renderedNode, rendered, textNode } of collected) {
18145
18479
  const node = textNode ?? renderedNode;
18146
- const pt = sizes.get(node) ?? 18;
18480
+ const pt2 = sizes.get(node) ?? 18;
18147
18481
  const text2 = texts.get(node);
18148
- const { first: first3, secondary } = text2 ? paragraphSizesPt(text2, pt) : { first: pt, secondary: Math.round(pt * DESCENDANT_FONT_SCALE) };
18482
+ const { first: first3, secondary } = text2 ? paragraphSizesPt(text2, pt2) : { first: pt2, secondary: Math.round(pt2 * DESCENDANT_FONT_SCALE) };
18149
18483
  rendered.fontSize = first3 * PX_PER_PT4;
18150
18484
  rendered.descendantFontSize = hasDescendants(node) ? secondary * PX_PER_PT4 : void 0;
18151
18485
  }
@@ -18243,7 +18577,13 @@ function buildRenderedNode(node, index, nodeById, palette, style, mergedSourceId
18243
18577
  fontSize: 0,
18244
18578
  textX: x + width / 2,
18245
18579
  textY: y + height / 2,
18246
- nodeId: primary?.id,
18580
+ // Picture roles often omit presOf: they present the current point's image, not its text.
18581
+ nodeId: primary?.id ?? (node.shape?.blipPhldr ? node.point.source?.id : void 0),
18582
+ picturePlaceholder: node.shape?.blipPhldr,
18583
+ layoutRole: node.name,
18584
+ contextNodeId: node.point.source?.id,
18585
+ textAlign: ["l", "ctr", "r"].includes(node.alg.params.parTxLTRAlign ?? "") ? node.alg.params.parTxLTRAlign : void 0,
18586
+ textVerticalAnchor: ["t", "ctr", "b"].includes(node.alg.params.txAnchorVert ?? "") ? node.alg.params.txAnchorVert : void 0,
18247
18587
  rotation: transform.rotation === 0 ? void 0 : transform.rotation,
18248
18588
  presetOverride: node.shape?.type ?? "roundRect",
18249
18589
  foldedNodeIds: foldedNodeIds.length > 0 ? foldedNodeIds : void 0,
@@ -19518,7 +19858,7 @@ function connectionLabel(connection, transitionText) {
19518
19858
  function textBodyParagraphs(body) {
19519
19859
  if (!body) return [];
19520
19860
  return children(body, "p", NS.a).map(
19521
- (paragraph) => descendants2(paragraph, "t").map((run) => run.textContent ?? "").join("")
19861
+ (paragraph) => descendants(paragraph, "t").map((run) => run.textContent ?? "").join("")
19522
19862
  );
19523
19863
  }
19524
19864
  function parsePoint(element3) {
@@ -19537,9 +19877,9 @@ function parsePoint(element3) {
19537
19877
  };
19538
19878
  const properties3 = first(element3, "spPr", NS.dgm);
19539
19879
  const fill = parseDrawingFill(properties3);
19540
- const line3 = parseDrawingLine(first(properties3, "ln", NS.a));
19880
+ const line4 = parseDrawingLine(first(properties3, "ln", NS.a));
19541
19881
  if (fill) point.fill = fill;
19542
- if (line3) point.line = line3;
19882
+ if (line4) point.line = line4;
19543
19883
  const optional = [
19544
19884
  ["connectionId", stringAttribute(element3, "cxnId")],
19545
19885
  ["presAssocId", stringAttribute(prSet, "presAssocID")],
@@ -19606,15 +19946,15 @@ function parseDiagramDataModel(source, part) {
19606
19946
  if ((!connection.type || connection.type === "parOf") && !parentById.has(connection.destId))
19607
19947
  parentById.set(connection.destId, connection.sourceId);
19608
19948
  }
19609
- const ext = descendants2(root, "dataModelExt")[0];
19949
+ const ext = descendants(root, "dataModelExt")[0];
19610
19950
  const drawingRelId = stringAttribute(ext, "relId");
19611
- const generated2 = descendants2(root, "generatedCache").find(
19951
+ const generated2 = descendants(root, "generatedCache").find(
19612
19952
  (node) => node.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
19613
19953
  );
19614
19954
  const generatedCacheDigest = generated2?.getAttribute("drawingSha256");
19615
19955
  return {
19616
19956
  points,
19617
- ...descendants2(root, "generatedCache").some(
19957
+ ...descendants(root, "generatedCache").some(
19618
19958
  (node) => node.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
19619
19959
  ) ? { generatedCache: true } : {},
19620
19960
  ...generatedCacheDigest ? { generatedCacheDigest } : {},
@@ -19676,11 +20016,11 @@ function styleRef(element3) {
19676
20016
  }
19677
20017
  function parseStyleReferences(style) {
19678
20018
  const refs = {};
19679
- const line3 = styleRef(first(style, "lnRef", NS.a));
20019
+ const line4 = styleRef(first(style, "lnRef", NS.a));
19680
20020
  const fill = styleRef(first(style, "fillRef", NS.a));
19681
20021
  const effect = styleRef(first(style, "effectRef", NS.a));
19682
20022
  const font = styleRef(first(style, "fontRef", NS.a));
19683
- if (line3) refs.line = line3;
20023
+ if (line4) refs.line = line4;
19684
20024
  if (fill) refs.fill = fill;
19685
20025
  if (effect) refs.effect = effect;
19686
20026
  if (font) refs.font = font;
@@ -19749,10 +20089,10 @@ function diagramDrawingFromViews(views, options2 = {}) {
19749
20089
  text: {
19750
20090
  anchor: "ctr",
19751
20091
  text: text2,
19752
- paragraphs: text2.split("\n").map((line3) => ({
20092
+ paragraphs: text2.split("\n").map((line4) => ({
19753
20093
  runs: [
19754
20094
  {
19755
- text: line3,
20095
+ text: line4,
19756
20096
  sizePt: Math.round((view.fontSize ?? 12) * 0.75 * 10) / 10,
19757
20097
  color: textColor
19758
20098
  }
@@ -19826,6 +20166,57 @@ function approximateDiagramDrawingFromNodes(input) {
19826
20166
  });
19827
20167
  }
19828
20168
 
20169
+ // diagram/picture-layout.ts
20170
+ function applyDiagramPictureSources(drawing, nodes, source, issues, liveNodeIds) {
20171
+ if (!source?.pictures?.length) return;
20172
+ if (source.pictureParts) drawing.pictureParts = { ...source.pictureParts };
20173
+ const used = /* @__PURE__ */ new Set();
20174
+ nodes.forEach((node, index) => {
20175
+ if (!node.picturePlaceholder || !node.nodeId) return;
20176
+ const shape = drawing.shapes[index];
20177
+ if (!shape) return;
20178
+ const candidates = source.pictures.filter((picture2) => picture2.nodeId === node.nodeId);
20179
+ const matching = candidates.filter(
20180
+ (picture2) => picture2.role === node.layoutRole || !!picture2.styleLabel && picture2.styleLabel === node.styleLabel
20181
+ );
20182
+ const picture = matching.length === 1 ? matching[0] : candidates.length === 1 ? candidates[0] : void 0;
20183
+ if (picture) {
20184
+ shape.fill = structuredClone(picture.fill);
20185
+ delete shape.text;
20186
+ delete shape.body;
20187
+ used.add(picture);
20188
+ } else if (candidates.length)
20189
+ issues.push({
20190
+ code: "DIAGRAM_PICTURE_AMBIGUOUS",
20191
+ message: `Picture role ${node.layoutRole ?? node.key} has multiple source pictures; no arbitrary assignment was made.`
20192
+ });
20193
+ });
20194
+ if (source.pictures.some(
20195
+ (picture) => (!liveNodeIds || liveNodeIds.has(picture.nodeId)) && !used.has(picture)
20196
+ ))
20197
+ issues.push({
20198
+ code: "DIAGRAM_PICTURE_LAYOUT_UNSUPPORTED",
20199
+ message: "Some retained pictures have no matching image placeholder in this layout. Their source associations are preserved for a compatible layout."
20200
+ });
20201
+ }
20202
+
20203
+ // diagram/layout-role-style.ts
20204
+ function applyDiagramRoleColors(shape, role, index, minorFont) {
20205
+ const at = (colors) => colors[index % colors.length];
20206
+ const fill = role && at(role.fill.colors);
20207
+ if (fill && shape.fill?.kind !== "none" && shape.fill?.kind !== "picture")
20208
+ shape.fill = { kind: "solid", color: structuredClone(fill) };
20209
+ const line4 = role && at(role.line.colors);
20210
+ if (line4 && shape.line) shape.line.fill = { kind: "solid", color: structuredClone(line4) };
20211
+ const text2 = role && at(role.textFill.colors);
20212
+ for (const paragraph of shape.text?.paragraphs ?? []) {
20213
+ for (const run of paragraph.runs) {
20214
+ if (!run.color && text2) run.color = structuredClone(text2);
20215
+ if (!run.typeface && minorFont) run.typeface = minorFont;
20216
+ }
20217
+ }
20218
+ }
20219
+
19829
20220
  // diagram/layout-preview.ts
19830
20221
  function diagramLayoutData(input) {
19831
20222
  const original = input.source?.dataXml ? parseDiagramDataModel(input.source.dataXml) : void 0;
@@ -19871,7 +20262,7 @@ function diagramLayoutData(input) {
19871
20262
  data.layoutDefinition = { rootNode: {}, rawXmlText: input.source.layoutXml };
19872
20263
  if (input.source?.dataXml) {
19873
20264
  const root = parseXml(input.source.dataXml).documentElement;
19874
- const vars = descendants2(root, "presLayoutVars")[0];
20265
+ const vars = descendants(root, "presLayoutVars")[0];
19875
20266
  const direction = first(vars, "dir", NS.dgm)?.getAttribute("val");
19876
20267
  const values = {};
19877
20268
  if (direction === "norm" || direction === "rev") values.direction = direction;
@@ -19929,7 +20320,7 @@ function previewDiagramLayout(input) {
19929
20320
  const computed = runEngineLayout(data, box, data.nodes, palette, intensity);
19930
20321
  if (computed) {
19931
20322
  const result = applyCustomLayoutOverrides(computed, data.nodes, box);
19932
- const declaresConnectors = input.source?.layoutXml && descendants2(parseXml(input.source.layoutXml).documentElement, "alg").some(
20323
+ const declaresConnectors = input.source?.layoutXml && descendants(parseXml(input.source.layoutXml).documentElement, "alg").some(
19933
20324
  (algorithm) => algorithm.getAttribute("type") === "conn"
19934
20325
  );
19935
20326
  if (declaresConnectors && data.nodes.some((node) => node.parentId) && !result.nodes.some((node) => /connector|^line(?:Inv)?$/i.test(node.presetOverride ?? "")))
@@ -19971,6 +20362,8 @@ function previewDiagramLayout(input) {
19971
20362
  ];
19972
20363
  });
19973
20364
  const drawing2 = diagramDrawingFromViews(views);
20365
+ drawing2.extentEmu = { ...input.extentEmu };
20366
+ const colors = input.source?.colorsXml ? parseDiagramColors(input.source.colorsXml) : void 0;
19974
20367
  const quickStyle = input.source?.quickStyleXml ? parseDiagramQuickStyle(input.source.quickStyleXml) : void 0;
19975
20368
  const originalModel = input.source?.dataXml ? parseDiagramDataModel(input.source.dataXml) : void 0;
19976
20369
  result.nodes.forEach((node, index) => {
@@ -19981,7 +20374,9 @@ function previewDiagramLayout(input) {
19981
20374
  shape.style = label;
19982
20375
  shape.has3d = label.requires3d ?? label.hasShape3d;
19983
20376
  }
19984
- if (node.nodeId) shape.sourceNodeId = node.nodeId;
20377
+ const contextNodeId = node.nodeId ?? node.contextNodeId;
20378
+ if (contextNodeId) shape.sourceNodeId = contextNodeId;
20379
+ if (node.layoutRole) shape.sourceLayoutRole = node.layoutRole;
19985
20380
  if (node.styleLabel) shape.sourceStyleLabel = node.styleLabel;
19986
20381
  if (node.foldedNodeIds?.length) shape.foldedNodeIds = node.foldedNodeIds;
19987
20382
  const sourceNode = data.nodes.find((entry) => entry.id === node.nodeId);
@@ -19994,15 +20389,36 @@ function previewDiagramLayout(input) {
19994
20389
  if (fill) shape.fill = fill;
19995
20390
  }
19996
20391
  const direct = originalModel?.nodes.find((entry) => entry.modelId === node.nodeId);
19997
- if (direct?.fill) shape.fill = direct.fill;
19998
- if (direct?.line) shape.line = { ...shape.line, ...direct.line };
19999
20392
  const sourceIds = [node.nodeId, ...node.foldedNodeIds ?? []];
20000
20393
  const textNodes = sourceIds.flatMap((id) => {
20001
20394
  const source = input.nodes.find((entry) => entry.id === id);
20002
20395
  return source ? [source] : [];
20003
20396
  });
20004
20397
  if (textNodes.length) shape.text = diagramPreviewText(textNodes, node.fontSize);
20398
+ if (shape.text) {
20399
+ if (node.textVerticalAnchor) shape.text.anchor = node.textVerticalAnchor;
20400
+ for (const paragraph of shape.text.paragraphs)
20401
+ if (!paragraph.align && node.textAlign) paragraph.align = node.textAlign;
20402
+ }
20403
+ applyDiagramRoleColors(
20404
+ shape,
20405
+ colors?.labels.find((label2) => label2.name === node.styleLabel),
20406
+ Math.max(
20407
+ 0,
20408
+ input.nodes.findIndex((entry) => entry.id === contextNodeId)
20409
+ ),
20410
+ input.minorFont
20411
+ );
20412
+ if (direct?.fill && direct.fill.kind !== "picture") shape.fill = direct.fill;
20413
+ if (direct?.line) shape.line = { ...shape.line, ...direct.line };
20005
20414
  });
20415
+ applyDiagramPictureSources(
20416
+ drawing2,
20417
+ result.nodes,
20418
+ input.source,
20419
+ issues,
20420
+ new Set(input.nodes.map((node) => node.id))
20421
+ );
20006
20422
  return { drawing: drawing2, mode: "interpreted", issues };
20007
20423
  }
20008
20424
  } catch (error) {
@@ -20029,12 +20445,12 @@ function resolveDiagramDrawingStyles(drawing, scheme2) {
20029
20445
  if (!refs) return shape;
20030
20446
  const fill = !shape.fill && refs.fill?.index !== void 0 ? refs.fill.index === 0 ? { kind: "none" } : resolveThemeFillStyle(scheme2, refs.fill.index, refs.fill.color) : void 0;
20031
20447
  const inheritedLine = refs.line?.index !== void 0 ? refs.line.index === 0 ? { fill: { kind: "none" } } : resolveThemeLineStyle(scheme2, refs.line.index, refs.line.color) : void 0;
20032
- const line3 = inheritedLine ? { ...inheritedLine, ...shape.line } : void 0;
20448
+ const line4 = inheritedLine ? { ...inheritedLine, ...shape.line } : void 0;
20033
20449
  const effects = !shape.effects && refs.effect?.index !== void 0 ? resolveThemeEffectStyle(scheme2, refs.effect.index, refs.effect.color) : void 0;
20034
20450
  return {
20035
20451
  ...shape,
20036
20452
  ...fill ? { fill } : {},
20037
- ...line3 ? { line: line3 } : {},
20453
+ ...line4 ? { line: line4 } : {},
20038
20454
  ...effects ? { effects } : {}
20039
20455
  };
20040
20456
  })
@@ -20788,6 +21204,24 @@ function computeHierarchicalSunburstArcs(categoryLevels, values, cx, cy, maxR) {
20788
21204
  return out;
20789
21205
  }
20790
21206
 
21207
+ // chart/style-palette.ts
21208
+ function hexToRgb2(hex) {
21209
+ const h = hex.replace("#", "");
21210
+ return [
21211
+ parseInt(h.substring(0, 2), 16),
21212
+ parseInt(h.substring(2, 4), 16),
21213
+ parseInt(h.substring(4, 6), 16)
21214
+ ];
21215
+ }
21216
+ function rgbToHex(r, g, b) {
21217
+ const clamp4 = (v) => Math.max(0, Math.min(255, Math.round(v)));
21218
+ return `#${clamp4(r).toString(16).padStart(2, "0")}${clamp4(g).toString(16).padStart(2, "0")}${clamp4(b).toString(16).padStart(2, "0")}`;
21219
+ }
21220
+ function shade(hex, amount) {
21221
+ const [r, g, b] = hexToRgb2(hex);
21222
+ return rgbToHex(r * (1 - amount), g * (1 - amount), b * (1 - amount));
21223
+ }
21224
+
20791
21225
  // chart/histogram-binning.ts
20792
21226
  function binLabel(lower, upper, closed, format) {
20793
21227
  return closed === "r" ? `(${format(lower)}, ${format(upper)}]` : `[${format(lower)}, ${format(upper)})`;
@@ -21294,11 +21728,11 @@ function resolveChartStyleDefinition(style, resolve) {
21294
21728
  const value = source[key];
21295
21729
  if (value !== void 0) Object.assign(entry, { [key]: value });
21296
21730
  }
21297
- const line3 = fillColor(source.line?.fill) ?? (source.lineRef?.color && resolve(source.lineRef.color));
21731
+ const line4 = fillColor(source.line?.fill) ?? (source.lineRef?.color && resolve(source.lineRef.color));
21298
21732
  const fill = fillColor(source.fill) ?? (source.fillRef?.color && resolve(source.fillRef.color));
21299
21733
  const color = (source.textColor && resolve(source.textColor)) ?? (source.fontRef?.color && resolve(source.fontRef.color));
21300
21734
  if (color !== void 0) entry.color = color;
21301
- if (line3 !== void 0) entry.lineColor = line3;
21735
+ if (line4 !== void 0) entry.lineColor = line4;
21302
21736
  if (fill !== void 0) entry.fillColor = fill;
21303
21737
  if (source.line?.widthEmu !== void 0 && source.line.widthEmu > 0)
21304
21738
  entry.lineWidth = source.line.widthEmu / 12700;
@@ -21444,10 +21878,10 @@ function buildChartGradientDef(id, fill, bounds) {
21444
21878
  stops
21445
21879
  };
21446
21880
  }
21447
- const rad = (fill.angle ?? 0) * Math.PI / 180;
21448
- const span = fill.scaled ? Math.abs(Math.cos(rad)) + Math.abs(Math.sin(rad)) : 1;
21449
- const dx = Math.cos(rad) * span / 2;
21450
- const dy = Math.sin(rad) * span / 2;
21881
+ const rad2 = (fill.angle ?? 0) * Math.PI / 180;
21882
+ const span = fill.scaled ? Math.abs(Math.cos(rad2)) + Math.abs(Math.sin(rad2)) : 1;
21883
+ const dx = Math.cos(rad2) * span / 2;
21884
+ const dy = Math.sin(rad2) * span / 2;
21451
21885
  const round = (value) => Math.round(value * 1e4) / 1e4;
21452
21886
  return {
21453
21887
  kind: "linearGradient",
@@ -21575,23 +22009,23 @@ function buildMarkerPrimitive(input) {
21575
22009
  return null;
21576
22010
  }
21577
22011
  const r = markerRadius(input.size, input.defaultRadius);
21578
- const outline2 = input.stroke ? {
22012
+ const outline3 = input.stroke ? {
21579
22013
  stroke: input.stroke,
21580
22014
  strokeWidth: input.strokeWidth ?? DEFAULT_MARKER_OUTLINE_PT * CHART_PX_PER_PT
21581
22015
  } : void 0;
21582
- const polygonStroke = outline2 ?? { stroke: fill, strokeWidth: 0 };
22016
+ const polygonStroke = outline3 ?? { stroke: fill, strokeWidth: 0 };
21583
22017
  const lineStroke = input.stroke ?? fill;
21584
22018
  switch (symbol) {
21585
22019
  case "square":
21586
22020
  case "dash": {
21587
22021
  const h = symbol === "dash" ? r * 0.64 : r * 2;
21588
22022
  const y = cy - h / 2;
21589
- if (outline2) {
22023
+ if (outline3) {
21590
22024
  return {
21591
22025
  kind: "polygon",
21592
22026
  points: rectPolygon(cx - r, y, r * 2, h),
21593
22027
  fill,
21594
- ...outline2,
22028
+ ...outline3,
21595
22029
  ...part
21596
22030
  };
21597
22031
  }
@@ -21649,9 +22083,9 @@ function buildMarkerPrimitive(input) {
21649
22083
  ...part
21650
22084
  };
21651
22085
  case "dot":
21652
- return { kind: "circle", cx, cy, r: Math.max(r * 0.6, 1), fill, ...part, ...outline2 };
22086
+ return { kind: "circle", cx, cy, r: Math.max(r * 0.6, 1), fill, ...part, ...outline3 };
21653
22087
  default:
21654
- return { kind: "circle", cx, cy, r, fill, ...part, ...outline2 };
22088
+ return { kind: "circle", cx, cy, r, fill, ...part, ...outline3 };
21655
22089
  }
21656
22090
  }
21657
22091
 
@@ -21928,6 +22362,18 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
21928
22362
  showNegativeBubbles: group2.showNegativeBubbles === true
21929
22363
  };
21930
22364
  }
22365
+ if (group2?.is3D) {
22366
+ const v = chartSpace.view3D;
22367
+ summary.view3D = {
22368
+ ...v?.rotX === void 0 ? {} : { rotX: v.rotX },
22369
+ ...v?.rotY === void 0 ? {} : { rotY: v.rotY },
22370
+ ...v?.perspective === void 0 ? {} : { perspective: v.perspective },
22371
+ ...v?.rightAngleAxes === void 0 ? {} : { rAngAx: v.rightAngleAxes },
22372
+ ...v?.depthPercent === void 0 ? {} : { depthPercent: v.depthPercent },
22373
+ ...v?.heightPercent === void 0 ? {} : { hPercent: v.heightPercent },
22374
+ ...group2.gapDepth === void 0 ? {} : { gapDepth: group2.gapDepth }
22375
+ };
22376
+ }
21931
22377
  const grouping = group2?.grouping;
21932
22378
  if (grouping && GROUPINGS.has(grouping))
21933
22379
  summary.grouping = grouping;
@@ -21955,17 +22401,6 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
21955
22401
  return summary;
21956
22402
  }
21957
22403
 
21958
- // chart/funnel-geometry.ts
21959
- function computeFunnelGeometry(values, plot) {
21960
- const max = Math.max(...values.map((v) => Math.abs(v)), 1);
21961
- const height = plot.height / Math.max(1, values.length);
21962
- const center = plot.x + plot.width / 2;
21963
- return values.map((value, index) => {
21964
- const width = Math.abs(value) / max * plot.width;
21965
- return { index, x: center - width / 2, y: plot.y + index * height, width, height, center };
21966
- });
21967
- }
21968
-
21969
22404
  // chart/render/theme-palette.ts
21970
22405
  var THEME_SLOTS = [
21971
22406
  "lt1",
@@ -22106,6 +22541,266 @@ function chartAppearance(chart, theme) {
22106
22541
  return out;
22107
22542
  }
22108
22543
 
22544
+ // chart/render/chart-title-text.ts
22545
+ function chartRunStyle(run) {
22546
+ return {
22547
+ ...run.sizePt === void 0 ? {} : { fontSize: run.sizePt },
22548
+ ...run.bold === void 0 ? {} : { bold: run.bold },
22549
+ ...run.italic === void 0 ? {} : { italic: run.italic },
22550
+ ...run.underline === void 0 ? {} : { underline: run.underline },
22551
+ ...run.typeface === void 0 ? {} : { typeface: run.typeface },
22552
+ ...run.color === void 0 ? {} : { textColor: run.color }
22553
+ };
22554
+ }
22555
+ function chartTitleText(chart, theme) {
22556
+ const formatting2 = chart.formatting;
22557
+ const entry = formatting2?.entries.title;
22558
+ const body = entry?.textBody;
22559
+ if (!formatting2 || !body || body.text !== chart.title) return void 0;
22560
+ if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
22561
+ return void 0;
22562
+ return {
22563
+ paragraphs: body.paragraphs.map((paragraph) => ({
22564
+ ...paragraph.align ? { align: paragraph.align } : {},
22565
+ ...paragraph.lineSpacing ? { lineSpacing: paragraph.lineSpacing } : {},
22566
+ ...paragraph.spaceBefore ? { spaceBefore: paragraph.spaceBefore } : {},
22567
+ ...paragraph.spaceAfter ? { spaceAfter: paragraph.spaceAfter } : {},
22568
+ runs: paragraph.runs.map((run) => {
22569
+ const direct = {
22570
+ sourceXml: "",
22571
+ ...entry.textBodyStyle,
22572
+ ...chartRunStyle(paragraph.defaultProperties ?? {}),
22573
+ ...chartRunStyle(run)
22574
+ };
22575
+ const appearance = chartAppearance(
22576
+ {
22577
+ ...chart,
22578
+ formatting: { ...formatting2, entries: { ...formatting2.entries, title: direct } }
22579
+ },
22580
+ theme
22581
+ )?.title ?? {};
22582
+ return { text: run.text, appearance };
22583
+ })
22584
+ }))
22585
+ };
22586
+ }
22587
+
22588
+ // chart/render/chart-3d-camera.ts
22589
+ var OBLIQUE_DEPTH_SCALE = 0.5;
22590
+ var rad = (deg) => deg * Math.PI / 180;
22591
+ function fitTransform(raw, size, fit2) {
22592
+ const xs = [];
22593
+ const ys = [];
22594
+ for (const x of [0, size.w])
22595
+ for (const y of [0, size.h])
22596
+ for (const z of [0, size.d]) {
22597
+ const q = raw([x, y, z]);
22598
+ xs.push(q.x);
22599
+ ys.push(q.y);
22600
+ }
22601
+ const minX = Math.min(...xs);
22602
+ const maxX = Math.max(...xs);
22603
+ const minY = Math.min(...ys);
22604
+ const maxY = Math.max(...ys);
22605
+ const scale = Math.min(fit2.w / Math.max(1e-6, maxX - minX), fit2.h / Math.max(1e-6, maxY - minY));
22606
+ return {
22607
+ scale,
22608
+ ox: fit2.x + (fit2.w - (maxX - minX) * scale) / 2 - minX * scale,
22609
+ oy: fit2.y + (fit2.h - (maxY - minY) * scale) / 2 + maxY * scale
22610
+ };
22611
+ }
22612
+ function createChart3DCamera(projection, size, fit2) {
22613
+ if (projection.mode === "oblique") {
22614
+ const kx = projection.shearX * OBLIQUE_DEPTH_SCALE;
22615
+ const ky = projection.shearY * OBLIQUE_DEPTH_SCALE;
22616
+ const raw2 = (p) => ({ x: p[0] + p[2] * kx, y: p[1] - p[2] * ky });
22617
+ const t2 = fitTransform(raw2, size, fit2);
22618
+ return {
22619
+ project: (p) => {
22620
+ const q = raw2(p);
22621
+ return { x: t2.ox + q.x * t2.scale, y: t2.oy - q.y * t2.scale, depth: p[2] };
22622
+ },
22623
+ viewDir: () => [-kx, ky, 1],
22624
+ eye: void 0,
22625
+ order: (a, b) => b[2] - a[2] || (projection.shearX >= 0 ? a[0] - b[0] : b[0] - a[0]) || (projection.shearY <= 0 ? a[1] - b[1] : b[1] - a[1]),
22626
+ sideWallAtZero: projection.shearX >= 0
22627
+ };
22628
+ }
22629
+ const cx = size.w / 2;
22630
+ const cy = size.h / 2;
22631
+ const cz = size.d / 2;
22632
+ const [cosY, sinY] = [Math.cos(rad(projection.rotYDeg)), Math.sin(rad(projection.rotYDeg))];
22633
+ const [cosX, sinX] = [Math.cos(rad(projection.rotXDeg)), Math.sin(rad(projection.rotXDeg))];
22634
+ const radius = Math.hypot(size.w, size.h, size.d) / 2;
22635
+ const dist = radius / Math.tan(rad(projection.fovDeg) / 2);
22636
+ const rotate = (p) => {
22637
+ const x = p[0] - cx;
22638
+ const y = p[1] - cy;
22639
+ const z = p[2] - cz;
22640
+ const x1 = x * cosY + z * sinY;
22641
+ const z1 = -x * sinY + z * cosY;
22642
+ return [x1, y * cosX + z1 * sinX, -y * sinX + z1 * cosX];
22643
+ };
22644
+ const raw = (p) => {
22645
+ const r = rotate(p);
22646
+ const s = dist / (dist + r[2]);
22647
+ return { x: r[0] * s, y: r[1] * s, depth: r[2] };
22648
+ };
22649
+ const t = fitTransform(raw, size, fit2);
22650
+ const ey = dist * sinX;
22651
+ const ez1 = -dist * cosX;
22652
+ const eyeX = cx - ez1 * sinY;
22653
+ const eye = [eyeX, cy + ey, cz + ez1 * cosY];
22654
+ return {
22655
+ project: (p) => {
22656
+ const q = raw(p);
22657
+ return { x: t.ox + q.x * t.scale, y: t.oy - q.y * t.scale, depth: q.depth };
22658
+ },
22659
+ viewDir: (p) => [p[0] - eye[0], p[1] - eye[1], p[2] - eye[2]],
22660
+ eye,
22661
+ order: (a, b) => {
22662
+ const da = (a[0] - eyeX) ** 2 + (a[1] - eye[1]) ** 2 + (a[2] - eye[2]) ** 2;
22663
+ const db = (b[0] - eyeX) ** 2 + (b[1] - eye[1]) ** 2 + (b[2] - eye[2]) ** 2;
22664
+ return db - da;
22665
+ },
22666
+ sideWallAtZero: eyeX > cx
22667
+ };
22668
+ }
22669
+
22670
+ // chart/render/chart-spacing.ts
22671
+ function chartBarSpacing(chart) {
22672
+ const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
22673
+ return {
22674
+ barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
22675
+ barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
22676
+ };
22677
+ }
22678
+
22679
+ // chart/render/chart-3d-layout.ts
22680
+ var DEFAULT_GAP_DEPTH = 150;
22681
+ var clamp2 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
22682
+ function chart3DSeriesInDepth(model) {
22683
+ return model.type === "surface" || model.grouping === "standard";
22684
+ }
22685
+ function chart3DLayout(model, inner, view) {
22686
+ const horizontal = model.horizontal;
22687
+ const w = Math.max(1, inner.w);
22688
+ const h = Math.max(
22689
+ 1,
22690
+ inner.h * (view.hPercent !== void 0 ? clamp2(view.hPercent, 5, 500) / 100 : 1)
22691
+ );
22692
+ const catLength = horizontal ? h : w;
22693
+ const valueLength = horizontal ? w : h;
22694
+ const cats = Math.max(1, model.categories.length);
22695
+ const band = catLength / cats;
22696
+ const rows2 = chart3DSeriesInDepth(model) ? Math.max(1, model.series.length) : 1;
22697
+ const isBar = model.type === "bar" || model.type === "column";
22698
+ const clustered = isBar && model.grouping === "clustered";
22699
+ const bars2 = isBar ? clusteredBarGeometry(
22700
+ band,
22701
+ clustered ? Math.max(1, model.series.length) : 1,
22702
+ chartBarSpacing(model)
22703
+ ) : void 0;
22704
+ const depthScale = clamp2(view.depthPercent ?? 100, 20, 2e3) / 100;
22705
+ const gap = clamp2(view.gapDepth ?? DEFAULT_GAP_DEPTH, 0, 500) / 100;
22706
+ const wanted = (bars2?.singleBarWidth ?? band * 0.5) * depthScale;
22707
+ const wantedCell = rows2 === 1 ? wanted * 1.5 : wanted * (1 + gap);
22708
+ const depth = Math.min(rows2 * wantedCell, Math.max(w, h) * 0.9);
22709
+ const cell = depth / rows2;
22710
+ const scale = model.valueAxis;
22711
+ const span = scale ? scale.max - scale.min || 1 : 1;
22712
+ return {
22713
+ size: { w, h, d: depth },
22714
+ horizontal,
22715
+ catLength,
22716
+ valueLength,
22717
+ band,
22718
+ rows: rows2,
22719
+ cell,
22720
+ markDepth: rows2 === 1 ? cell / 1.5 : cell / (1 + gap),
22721
+ bars: bars2,
22722
+ value: (v) => (v - (scale?.min ?? 0)) / span * valueLength || 0,
22723
+ rowZ: (r) => {
22724
+ const mark = rows2 === 1 ? cell / 1.5 : cell / (1 + gap);
22725
+ const z0 = r * cell + (cell - mark) / 2;
22726
+ return [z0, z0 + mark];
22727
+ }
22728
+ };
22729
+ }
22730
+
22731
+ // chart/render/chart-3d-mesh.ts
22732
+ function faceKind(n2) {
22733
+ const [x, y, z] = n2;
22734
+ if (Math.abs(y) >= Math.abs(x) && Math.abs(y) >= Math.abs(z)) return y >= 0 ? "top" : "bottom";
22735
+ if (Math.abs(x) >= Math.abs(z)) return x >= 0 ? "right" : "left";
22736
+ return z < 0 ? "front" : "back";
22737
+ }
22738
+ function signedArea(outline3) {
22739
+ let sum = 0;
22740
+ for (let i = 0; i < outline3.length; i++) {
22741
+ const [x0, y0] = outline3[i];
22742
+ const [x1, y1] = outline3[(i + 1) % outline3.length];
22743
+ sum += x0 * y1 - x1 * y0;
22744
+ }
22745
+ return sum / 2;
22746
+ }
22747
+ function extrudeMesh(outline3, z0, z1, meta) {
22748
+ if (outline3.length < 3 || Math.abs(signedArea(outline3)) < 1e-6) return void 0;
22749
+ const ccw = signedArea(outline3) > 0 ? [...outline3] : [...outline3].reverse();
22750
+ const faces = [
22751
+ { pts: ccw.map(([x, y]) => [x, y, z0]), normal: [0, 0, -1], kind: "front" },
22752
+ { pts: ccw.map(([x, y]) => [x, y, z1]), normal: [0, 0, 1], kind: "back" }
22753
+ ];
22754
+ for (let i = 0; i < ccw.length; i++) {
22755
+ const [ax, ay] = ccw[i];
22756
+ const [bx, by] = ccw[(i + 1) % ccw.length];
22757
+ const dx = bx - ax;
22758
+ const dy = by - ay;
22759
+ const len = Math.hypot(dx, dy);
22760
+ if (len < 1e-9) continue;
22761
+ const normal = [dy / len, -dx / len, 0];
22762
+ faces.push({
22763
+ pts: [
22764
+ [ax, ay, z0],
22765
+ [bx, by, z0],
22766
+ [bx, by, z1],
22767
+ [ax, ay, z1]
22768
+ ],
22769
+ normal,
22770
+ kind: faceKind(normal)
22771
+ });
22772
+ }
22773
+ const xs = ccw.map((p) => p[0]);
22774
+ const ys = ccw.map((p) => p[1]);
22775
+ const center = [
22776
+ (Math.min(...xs) + Math.max(...xs)) / 2,
22777
+ (Math.min(...ys) + Math.max(...ys)) / 2,
22778
+ (z0 + z1) / 2
22779
+ ];
22780
+ return { ...meta, center, faces };
22781
+ }
22782
+ function boxMesh(x0, x1, y0, y1, z0, z1, meta) {
22783
+ return extrudeMesh(
22784
+ [
22785
+ [Math.min(x0, x1), Math.min(y0, y1)],
22786
+ [Math.max(x0, x1), Math.min(y0, y1)],
22787
+ [Math.max(x0, x1), Math.max(y0, y1)],
22788
+ [Math.min(x0, x1), Math.max(y0, y1)]
22789
+ ],
22790
+ Math.min(z0, z1),
22791
+ Math.max(z0, z1),
22792
+ meta
22793
+ );
22794
+ }
22795
+
22796
+ // chart/data-table-layout.ts
22797
+ function chartDataTableMetrics(fontSize, names, showKeys = true) {
22798
+ const rowH = Math.max(14, Math.round(fontSize * 1.45));
22799
+ const longestName = names.reduce((m, name) => Math.max(m, name.length), 0);
22800
+ const keyW = Math.min(160, Math.max(40, longestName * fontSize * 0.55 + (showKeys ? 24 : 8)));
22801
+ return { fontSize, rowH, keyW, height: rowH * (1 + names.length) };
22802
+ }
22803
+
22109
22804
  // chart/render/chart-svg-util.ts
22110
22805
  var TEXT_COLOR = "#595959";
22111
22806
  var GRID_COLOR = "#D9D9D9";
@@ -22116,18 +22811,18 @@ function esc(text2) {
22116
22811
  }
22117
22812
  var n = (value) => String(Math.round(value * 100) / 100);
22118
22813
  var textWidth = (text2, size = FONT_SIZE) => text2.length * size * 0.55;
22119
- function text(x, y, content, attrs2 = {}) {
22814
+ function text(x, y, content, attrs3 = {}) {
22120
22815
  const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
22121
- parts.push(`font-size="${attrs2.size ?? FONT_SIZE}"`);
22122
- parts.push(`fill="${esc(attrs2.fill ?? TEXT_COLOR)}"`);
22123
- if (attrs2.anchor && attrs2.anchor !== "start") parts.push(`text-anchor="${attrs2.anchor}"`);
22124
- if (attrs2.weight) parts.push(`font-weight="${attrs2.weight}"`);
22125
- if (attrs2.baseline) parts.push(`dominant-baseline="${attrs2.baseline}"`);
22126
- if (attrs2.family) parts.push(`font-family="${esc(attrs2.family)}"`);
22127
- if (attrs2.filter) parts.push(`filter="${esc(attrs2.filter)}"`);
22128
- if (attrs2.italic !== void 0) parts.push(`font-style="${attrs2.italic ? "italic" : "normal"}"`);
22129
- if (attrs2.underline !== void 0)
22130
- parts.push(`text-decoration="${attrs2.underline ? "underline" : "none"}"`);
22816
+ parts.push(`font-size="${attrs3.size ?? FONT_SIZE}"`);
22817
+ parts.push(`fill="${esc(attrs3.fill ?? TEXT_COLOR)}"`);
22818
+ if (attrs3.anchor && attrs3.anchor !== "start") parts.push(`text-anchor="${attrs3.anchor}"`);
22819
+ if (attrs3.weight) parts.push(`font-weight="${attrs3.weight}"`);
22820
+ if (attrs3.baseline) parts.push(`dominant-baseline="${attrs3.baseline}"`);
22821
+ if (attrs3.family) parts.push(`font-family="${esc(attrs3.family)}"`);
22822
+ if (attrs3.filter) parts.push(`filter="${esc(attrs3.filter)}"`);
22823
+ if (attrs3.italic !== void 0) parts.push(`font-style="${attrs3.italic ? "italic" : "normal"}"`);
22824
+ if (attrs3.underline !== void 0)
22825
+ parts.push(`text-decoration="${attrs3.underline ? "underline" : "none"}"`);
22131
22826
  return `<text ${parts.join(" ")}>${esc(content)}</text>`;
22132
22827
  }
22133
22828
  var line2 = (x1, y1, x2, y2, stroke, width = 1) => `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" stroke="${stroke}" stroke-width="${width}"/>`;
@@ -22243,162 +22938,13 @@ function chartAreaRect(model, part, area) {
22243
22938
  return `${defs}<rect x="${n(area.x)}" y="${n(area.y)}" width="${n(area.w)}" height="${n(area.h)}" fill="${esc(fill)}" stroke="${esc(stroke)}" stroke-width="${n(width)}" data-chart-part="${part}"/>`;
22244
22939
  }
22245
22940
 
22246
- // chart/render/chart-svg-funnel.ts
22247
- function funnelSvg(model, area) {
22248
- const series = model.series[0];
22249
- if (!series || series.hidden) return "";
22250
- const attrs2 = chartTextAttributes(model, "categoryAxis", 10);
22251
- const width = Math.min(
22252
- area.w * 0.3,
22253
- Math.max(32, ...model.categories.map((s) => s.length * (attrs2.size ?? 10) * 0.55 + 8))
22254
- );
22255
- const plot = { x: area.x + width, y: area.y, width: Math.max(1, area.w - width), height: area.h };
22256
- const out = [
22257
- chartAreaRect(model, "plotArea", { x: plot.x, y: plot.y, w: plot.width, h: plot.height })
22258
- ];
22259
- for (const bar of computeFunnelGeometry(
22260
- series.values.map((v) => v ?? 0),
22261
- plot
22262
- )) {
22263
- const value = series.values[bar.index];
22264
- if (value === null || value === void 0) continue;
22265
- out.push(`<g data-chart-series="${series.sourceIndex ?? 0}" data-chart-point="${bar.index}">`);
22266
- out.push(
22267
- rect2(bar.x, bar.y, bar.width, bar.height, series.pointColors?.[bar.index] ?? series.color)
22268
- );
22269
- const size = Math.min(10, bar.height * 0.4);
22270
- const label = series.labels?.[bar.index];
22271
- if (label)
22272
- out.push(
22273
- text(bar.center, bar.y + bar.height / 2 + size * 0.35, label.text, {
22274
- ...chartTextAttributes(model, "dataLabel", size),
22275
- size,
22276
- anchor: "middle"
22277
- })
22278
- );
22279
- out.push(
22280
- text(
22281
- plot.x - 8,
22282
- bar.y + bar.height / 2 + (attrs2.size ?? 10) * 0.35,
22283
- fit(model.categories[bar.index] ?? "", width - 8, attrs2.size ?? 10),
22284
- { ...attrs2, anchor: "end" }
22285
- )
22286
- );
22287
- out.push("</g>");
22288
- }
22289
- return out.join("");
22290
- }
22291
-
22292
- // chart/box-distribution.ts
22293
- function boxWhiskerDistribution(values, method = "exclusive", trimOutliers = false) {
22294
- const stats = computeBoxStats(values, method);
22295
- if (!stats) return void 0;
22296
- const iqr = stats.q3 - stats.q1;
22297
- const lowerFence = stats.q1 - 1.5 * iqr;
22298
- const upperFence = stats.q3 + 1.5 * iqr;
22299
- const inliers = values.filter((v) => !trimOutliers || v >= lowerFence && v <= upperFence);
22300
- return {
22301
- stats,
22302
- whiskerMin: inliers.length ? Math.min(...inliers) : stats.min,
22303
- whiskerMax: inliers.length ? Math.max(...inliers) : stats.max,
22304
- mean: values.reduce((a, b) => a + b, 0) / values.length
22305
- };
22306
- }
22307
- function boxMeanMarkerPath(x, y, radius = 3) {
22308
- return `M${x - radius},${y - radius} L${x + radius},${y + radius} M${x - radius},${y + radius} L${x + radius},${y - radius}`;
22309
- }
22310
-
22311
- // chart/render/chart-svg-box.ts
22312
- function boxWhiskerSvg(model, frame2, out) {
22313
- const visible = model.series.filter((s) => !s.hidden);
22314
- const slot = frame2.bandSize / Math.max(1, visible.length);
22315
- const width = slot * 0.7;
22316
- visible.forEach((series, si) => {
22317
- if (series.hidden) return;
22318
- const groups = groupRowsByCategory(series.boxCategories ?? []);
22319
- model.categories.forEach((category, ci) => {
22320
- const observations = (groups.rowIndexesByCategory.get(category) ?? []).flatMap((row) => {
22321
- const value = series.values[row];
22322
- return value === null || value === void 0 ? [] : [{ row, value }];
22323
- });
22324
- const options2 = series.boxWhisker;
22325
- const rawMethod = options2?.statistics?.quartileMethod;
22326
- const method = rawMethod === "inclusive" ? "inclusive" : "exclusive";
22327
- const visibility = options2?.visibility;
22328
- const trim = rawMethod === "inclusive" || rawMethod === "exclusive" || !!visibility && Object.values(visibility).some((v) => v !== void 0);
22329
- const distribution = boxWhiskerDistribution(
22330
- observations.map((p) => p.value),
22331
- method,
22332
- trim
22333
- );
22334
- if (!distribution) return;
22335
- const { stats, whiskerMin, whiskerMax, mean } = distribution;
22336
- const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot + (slot - width) / 2;
22337
- const mid = x + width / 2;
22338
- const y = frame2.value;
22339
- out.push(
22340
- `<g data-chart-part="box" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${ci}">`
22341
- );
22342
- out.push(line2(mid, y(whiskerMax), mid, y(stats.q3), "#64748b", 1));
22343
- out.push(line2(mid, y(stats.q1), mid, y(whiskerMin), "#64748b", 1));
22344
- out.push(
22345
- line2(x + width * 0.25, y(whiskerMin), x + width * 0.75, y(whiskerMin), "#64748b", 1)
22346
- );
22347
- out.push(
22348
- line2(x + width * 0.25, y(whiskerMax), x + width * 0.75, y(whiskerMax), "#64748b", 1)
22349
- );
22350
- out.push(
22351
- rect2(
22352
- x,
22353
- Math.min(y(stats.q1), y(stats.q3)),
22354
- width,
22355
- Math.abs(y(stats.q1) - y(stats.q3)),
22356
- series.pointColors?.[ci] ?? series.color
22357
- )
22358
- );
22359
- out.push(line2(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
22360
- if (visibility?.meanLine) out.push(line2(x, y(mean), x + width, y(mean), "#0f766e", 1.5));
22361
- if (visibility?.meanMarker !== false)
22362
- out.push(
22363
- `<path d="${boxMeanMarkerPath(mid, y(mean))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
22364
- );
22365
- observations.forEach((point, index) => {
22366
- const outlier = point.value < whiskerMin || point.value > whiskerMax;
22367
- if (outlier ? !visibility?.outliers : !visibility?.nonoutliers) return;
22368
- const px = x + width * (0.2 + 0.6 * (index + 1) / (observations.length + 1));
22369
- out.push(
22370
- `<circle cx="${n(px)}" cy="${n(y(point.value))}" r="2.25" fill="${outlier ? "#dc2626" : "#1e293b"}" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${point.row}" data-chart-part="${outlier ? "outlier" : "observation"}"/>`
22371
- );
22372
- });
22373
- out.push("</g>");
22374
- });
22375
- });
22376
- }
22377
-
22378
- // chart/data-table-layout.ts
22379
- function chartDataTableMetrics(fontSize, names, showKeys = true) {
22380
- const rowH = Math.max(14, Math.round(fontSize * 1.45));
22381
- const longestName = names.reduce((m, name) => Math.max(m, name.length), 0);
22382
- const keyW = Math.min(160, Math.max(40, longestName * fontSize * 0.55 + (showKeys ? 24 : 8)));
22383
- return { fontSize, rowH, keyW, height: rowH * (1 + names.length) };
22384
- }
22385
-
22386
- // chart/render/chart-spacing.ts
22387
- function chartBarSpacing(chart) {
22388
- const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
22389
- return {
22390
- barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
22391
- barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
22392
- };
22393
- }
22394
-
22395
22941
  // chart/render/chart-svg-labels.ts
22396
22942
  var GAP = 3;
22397
22943
  var LINE = 1.2;
22398
22944
  var NAMED_COLORS = /^(black|blue|cyan|green|magenta|red|white|yellow)$/iu;
22399
22945
  function measure3(model, label) {
22400
- const attrs2 = chartTextAttributes(model, "dataLabel", 10);
22401
- const size = attrs2.size ?? 10;
22946
+ const attrs3 = chartTextAttributes(model, "dataLabel", 10);
22947
+ const size = attrs3.size ?? 10;
22402
22948
  const lines = label.text.split("\n");
22403
22949
  return {
22404
22950
  ...model.frameSize ? { frame: model.frameSize } : {},
@@ -22406,15 +22952,15 @@ function measure3(model, label) {
22406
22952
  size,
22407
22953
  w: Math.max(...lines.map((l) => textWidth(l, size))),
22408
22954
  h: lines.length * size * LINE,
22409
- attrs: attrs2
22955
+ attrs: attrs3
22410
22956
  };
22411
22957
  }
22412
22958
  function draw(m, label, x, y, anchor, out) {
22413
22959
  if (m.frame) ({ x, y } = applyLabelManualLayout(label.layout, m.frame, { x, y }));
22414
22960
  const fill = label.color && NAMED_COLORS.test(label.color) ? label.color.toLowerCase() : void 0;
22415
- m.lines.forEach((line3, k) => {
22961
+ m.lines.forEach((line4, k) => {
22416
22962
  const lineY = y - m.h / 2 + (k + 0.5) * m.size * LINE + m.size * 0.35;
22417
- out.push(text(x, lineY, line3, { ...m.attrs, ...fill ? { fill } : {}, anchor }));
22963
+ out.push(text(x, lineY, line4, { ...m.attrs, ...fill ? { fill } : {}, anchor }));
22418
22964
  });
22419
22965
  }
22420
22966
  function barLabels(model, marks, out) {
@@ -22715,13 +23261,13 @@ function chartDataTableSvg(model, plot) {
22715
23261
  const bottom = top + height;
22716
23262
  const cellW = plot.w / Math.max(1, model.categories.length);
22717
23263
  const styled = { ...model, appearance: { ...model.appearance, dataLabel: table.text ?? {} } };
22718
- const attrs2 = chartTextAttributes(styled, "dataLabel", fontSize);
23264
+ const attrs3 = chartTextAttributes(styled, "dataLabel", fontSize);
22719
23265
  const out = ['<g data-chart-part="dataTable">'];
22720
23266
  const border = (x1, y1, x2, y2) => out.push(
22721
23267
  `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" ${strokeAttributes(table.stroke)}/>`
22722
23268
  );
22723
23269
  const label = (x, y, value, width, anchor = "middle") => out.push(
22724
- text(x, y + fontSize * 0.35, fit(value, Math.max(1, width), fontSize), { ...attrs2, anchor })
23270
+ text(x, y + fontSize * 0.35, fit(value, Math.max(1, width), fontSize), { ...attrs3, anchor })
22725
23271
  );
22726
23272
  if (table.fill) out.push(rect2(left, top, right - left, height, table.fill));
22727
23273
  if (source.showOutline !== false) {
@@ -22973,8 +23519,8 @@ function chartDateAxis(model, plot, out) {
22973
23519
  unit,
22974
23520
  Math.max(1, axis.majorUnit ?? 1)
22975
23521
  );
22976
- const attrs2 = chartTextAttributes(model, "categoryAxis");
22977
- const size = attrs2.size ?? 10;
23522
+ const attrs3 = chartTextAttributes(model, "categoryAxis");
23523
+ const size = attrs3.size ?? 10;
22978
23524
  const y = axis.position === "t" ? plot.y : plot.y + plot.h;
22979
23525
  const paint2 = model.axes?.category?.line;
22980
23526
  const stroke = { color: paint2?.color ?? "#BFBFBF", width: paint2?.width ?? 1 };
@@ -23006,13 +23552,13 @@ function chartDateAxis(model, plot, out) {
23006
23552
  axis.numberFormat?.formatCode
23007
23553
  );
23008
23554
  if (model.horizontal)
23009
- out.push(text(plot.x - 4, position2(serial) + size * 0.3, label, { ...attrs2, anchor: "end" }));
23555
+ out.push(text(plot.x - 4, position2(serial) + size * 0.3, label, { ...attrs3, anchor: "end" }));
23010
23556
  else {
23011
23557
  const above = axis.tickLabelPosition === "high" || axis.tickLabelPosition !== "low" && axis.position === "t";
23012
23558
  const baseline = axis.tickLabelPosition === "high" ? plot.y : axis.tickLabelPosition === "low" ? plot.y + plot.h : y;
23013
23559
  out.push(
23014
23560
  text(position2(serial), baseline + (above ? -4 : size + 3), label, {
23015
- ...attrs2,
23561
+ ...attrs3,
23016
23562
  anchor: "middle"
23017
23563
  })
23018
23564
  );
@@ -23068,11 +23614,11 @@ function smoothSegment(points, i) {
23068
23614
  function chartLineSvg(points, series) {
23069
23615
  if (points.length < 2) return "";
23070
23616
  const stroke = series.stroke;
23071
- const attrs2 = strokeAttributes(
23617
+ const attrs3 = strokeAttributes(
23072
23618
  stroke ? { ...stroke, color: stroke.color === "none" ? "none" : series.color } : { color: series.color, width: 2.25 }
23073
23619
  );
23074
23620
  const filter = series.shadowFilter ? ` filter="${series.shadowFilter}"` : "";
23075
- return series.smooth ? `<path d="${smoothLinePath(points)}" fill="none" ${attrs2} stroke-linejoin="round"${filter}/>` : `<polyline points="${points.map((p) => `${n(p.x)},${n(p.y)}`).join(" ")}" fill="none" ${attrs2} stroke-linejoin="round"${filter}/>`;
23621
+ return series.smooth ? `<path d="${smoothLinePath(points)}" fill="none" ${attrs3} stroke-linejoin="round"${filter}/>` : `<polyline points="${points.map((p) => `${n(p.x)},${n(p.y)}`).join(" ")}" fill="none" ${attrs3} stroke-linejoin="round"${filter}/>`;
23076
23622
  }
23077
23623
 
23078
23624
  // chart/render/chart-svg-plot-layout.ts
@@ -23126,9 +23672,9 @@ function chartSeriesMarkerSvg(series, index, cx, cy, defaultRadius = 3) {
23126
23672
  geometry2 = `points="${esc(primitive.points)}"`;
23127
23673
  break;
23128
23674
  }
23129
- const outline2 = primitive.stroke ? ` stroke="${esc(primitive.stroke)}" stroke-width="${n(primitive.strokeWidth ?? 1)}"` : "";
23675
+ const outline3 = primitive.stroke ? ` stroke="${esc(primitive.stroke)}" stroke-width="${n(primitive.strokeWidth ?? 1)}"` : "";
23130
23676
  const filter = series.shadowFilter ? ` filter="${esc(series.shadowFilter)}"` : "";
23131
- return `<${primitive.kind} ${geometry2} fill="${esc(primitive.fill)}"${outline2}${filter}/>`;
23677
+ return `<${primitive.kind} ${geometry2} fill="${esc(primitive.fill)}"${outline3}${filter}/>`;
23132
23678
  }
23133
23679
 
23134
23680
  // chart/line-dash.ts
@@ -23372,69 +23918,76 @@ function applyChartAxes(model, chart, color) {
23372
23918
  model.axes = out;
23373
23919
  }
23374
23920
 
23375
- // chart/render/chart-title-text.ts
23376
- function chartRunStyle(run) {
23377
- return {
23378
- ...run.sizePt === void 0 ? {} : { fontSize: run.sizePt },
23379
- ...run.bold === void 0 ? {} : { bold: run.bold },
23380
- ...run.italic === void 0 ? {} : { italic: run.italic },
23381
- ...run.underline === void 0 ? {} : { underline: run.underline },
23382
- ...run.typeface === void 0 ? {} : { typeface: run.typeface },
23383
- ...run.color === void 0 ? {} : { textColor: run.color }
23384
- };
23921
+ // chart/region-map/value-color-positions.ts
23922
+ function schemaPosition(node, end) {
23923
+ for (const kind of ["number", "percent"]) {
23924
+ const element3 = first(node, kind, NS.cx), raw = element3?.getAttribute("val");
23925
+ const value = raw === null || raw === void 0 || raw === "" ? NaN : Number(raw);
23926
+ if (Number.isFinite(value)) return { kind, value };
23927
+ }
23928
+ return end === "mid" ? { kind: "percent", value: 50 } : { kind: end };
23385
23929
  }
23386
- function chartTitleText(chart, theme) {
23387
- const formatting2 = chart.formatting;
23388
- const entry = formatting2?.entries.title;
23389
- const body = entry?.textBody;
23390
- if (!formatting2 || !body || body.text !== chart.title) return void 0;
23391
- if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
23392
- return void 0;
23393
- return {
23394
- paragraphs: body.paragraphs.map((paragraph) => ({
23395
- ...paragraph.align ? { align: paragraph.align } : {},
23396
- ...paragraph.lineSpacing ? { lineSpacing: paragraph.lineSpacing } : {},
23397
- ...paragraph.spaceBefore ? { spaceBefore: paragraph.spaceBefore } : {},
23398
- ...paragraph.spaceAfter ? { spaceAfter: paragraph.spaceAfter } : {},
23399
- runs: paragraph.runs.map((run) => {
23400
- const direct = {
23401
- sourceXml: "",
23402
- ...entry.textBodyStyle,
23403
- ...chartRunStyle(paragraph.defaultProperties ?? {}),
23404
- ...chartRunStyle(run)
23405
- };
23406
- const appearance = chartAppearance(
23407
- {
23408
- ...chart,
23409
- formatting: { ...formatting2, entries: { ...formatting2.entries, title: direct } }
23410
- },
23411
- theme
23412
- )?.title ?? {};
23413
- return { text: run.text, appearance };
23414
- })
23415
- }))
23416
- };
23930
+ function parseRegionValueColorPositions(xml) {
23931
+ if (!xml) return void 0;
23932
+ const root = parseXml(`<cx:root xmlns:cx="${NS.cx}">${xml}</cx:root>`).documentElement;
23933
+ const positions = first(root, "valueColorPositions", NS.cx);
23934
+ if (!positions) return void 0;
23935
+ const count = positions.getAttribute("count");
23936
+ const native = ["min", "mid", "max"].some((key) => first(positions, key, NS.cx));
23937
+ if (native || count !== null && children(positions, "pos", NS.cx).length === 0) {
23938
+ const keys = count === "3" || first(positions, "mid", NS.cx) ? ["min", "mid", "max"] : ["min", "max"];
23939
+ return keys.map((key) => schemaPosition(first(positions, key, NS.cx), key));
23940
+ }
23941
+ const legacy = children(positions, "pos", NS.cx).flatMap(
23942
+ (element3) => {
23943
+ const type = element3.getAttribute("type");
23944
+ if (type === "min" || type === "max") return [{ kind: type }];
23945
+ if (type !== "num" && type !== "percent") return [];
23946
+ const raw = element3.getAttribute("val"), value = raw === null || raw === "" ? NaN : Number(raw);
23947
+ return [
23948
+ { kind: type === "num" ? "number" : type, ...Number.isFinite(value) ? { value } : {} }
23949
+ ];
23950
+ }
23951
+ );
23952
+ return legacy.length ? legacy : void 0;
23953
+ }
23954
+
23955
+ // chart/region-map/value-colors.ts
23956
+ function resolveRegionValueColors(options2, color) {
23957
+ const result = { ...options2 };
23958
+ const xml = `<cx:root xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">${options2.valueColorsXml ?? ""}${options2.valueColorPositionsXml ?? ""}</cx:root>`;
23959
+ const root = parseXml(xml).documentElement;
23960
+ if (options2.valueColorsXml) {
23961
+ const colors = Array.from(root.getElementsByTagName("*")).flatMap((node) => {
23962
+ const c = color(parseDrawingColorIn(node));
23963
+ return c ? [c] : [];
23964
+ });
23965
+ if (colors.length) result.valueColors = colors;
23966
+ }
23967
+ const positions = parseRegionValueColorPositions(options2.valueColorPositionsXml);
23968
+ if (positions) result.valueColorPositions = positions;
23969
+ return result;
23417
23970
  }
23418
23971
 
23419
23972
  // chart/render/chart-view-analysis.ts
23420
- function strokeOf(line3, fallback, resolve) {
23421
- if (line3?.fill?.kind === "none") return void 0;
23422
- const color = (line3?.fill?.kind === "solid" ? resolve(line3.fill.color) : void 0) ?? fallback.color;
23423
- const width = line3?.widthEmu === void 0 ? fallback.width : chartPointsToPixels(line3.widthEmu / 12700);
23424
- const dash = line3?.dash ?? fallback.dash;
23973
+ function strokeOf(line4, fallback, resolve) {
23974
+ if (line4?.fill?.kind === "none") return void 0;
23975
+ const color = (line4?.fill?.kind === "solid" ? resolve(line4.fill.color) : void 0) ?? fallback.color;
23976
+ const width = line4?.widthEmu === void 0 ? fallback.width : chartPointsToPixels(line4.widthEmu / 12700);
23977
+ const dash = line4?.dash ?? fallback.dash;
23425
23978
  return { color, width, ...dash && dash !== "solid" ? { dash } : {} };
23426
23979
  }
23427
23980
  function analysisView(source, seriesColor, resolve) {
23428
23981
  const plain = seriesColor === "none" || seriesColor.startsWith("url(") ? TEXT_COLOR : seriesColor;
23429
23982
  const trendlines2 = (source.trendlines ?? []).flatMap((entry) => {
23430
- const { name: _name, line: line3, ...fit2 } = entry;
23983
+ const { name: _name, line: line4, ...fit2 } = entry;
23431
23984
  const fallback = { color: plain, width: chartPointsToPixels(1.5), dash: "sysDot" };
23432
- const stroke = strokeOf(line3, fallback, resolve);
23985
+ const stroke = strokeOf(line4, fallback, resolve);
23433
23986
  return stroke ? [{ fit: fit2, stroke }] : [];
23434
23987
  });
23435
23988
  const errorBars = (source.errorBars ?? []).flatMap((entry) => {
23436
- const { direction, barType, noEndCap, line: line3, ...amount } = entry;
23437
- const stroke = strokeOf(line3, { color: TEXT_COLOR, width: chartPointsToPixels(0.75) }, resolve);
23989
+ const { direction, barType, noEndCap, line: line4, ...amount } = entry;
23990
+ const stroke = strokeOf(line4, { color: TEXT_COLOR, width: chartPointsToPixels(0.75) }, resolve);
23438
23991
  return stroke ? [{ direction, barType, amount, endCap: noEndCap !== true, stroke }] : [];
23439
23992
  });
23440
23993
  return {
@@ -23618,10 +24171,10 @@ function paintOf(fill, ctx) {
23618
24171
  return fill?.kind === "solid" ? ctx.drawingColor(fill.color) : void 0;
23619
24172
  }
23620
24173
  function lineOf(shape, ctx, color) {
23621
- const line3 = shape?.line;
24174
+ const line4 = shape?.line;
23622
24175
  return {
23623
- color: paintOf(line3?.fill, ctx) ?? color,
23624
- width: line3?.widthEmu === void 0 ? 1 : Math.max(0.5, line3.widthEmu / EMU_PER_PX2)
24176
+ color: paintOf(line4?.fill, ctx) ?? color,
24177
+ width: line4?.widthEmu === void 0 ? 1 : Math.max(0.5, line4.widthEmu / EMU_PER_PX2)
23625
24178
  };
23626
24179
  }
23627
24180
  function barOf(shape, ctx, fallback) {
@@ -23857,6 +24410,7 @@ var SUPPORTED = /* @__PURE__ */ new Set([
23857
24410
  "treemap",
23858
24411
  "sunburst",
23859
24412
  "funnel",
24413
+ "regionMap",
23860
24414
  "boxWhisker"
23861
24415
  ]);
23862
24416
  function chartSummaryView(chart, theme, options2 = {}) {
@@ -23917,8 +24471,14 @@ function chartSummaryView(chart, theme, options2 = {}) {
23917
24471
  categories,
23918
24472
  series: type === "boxWhisker" ? series.filter((s) => !s.hidden) : series,
23919
24473
  horizontal: type === "bar",
23920
- supported: SUPPORTED.has(type)
24474
+ supported: SUPPORTED.has(type) || type === "surface" && chart.view3D !== void 0
23921
24475
  };
24476
+ if (chart.view3D) model.view3D = chart.view3D;
24477
+ if (chart.funnelGapWidth !== void 0) model.funnelGapWidth = chart.funnelGapWidth;
24478
+ if (chart.series[0]?.regionMap)
24479
+ model.regionMap = resolveRegionValueColors(chart.series[0].regionMap, ctx.drawingColor);
24480
+ if (model.regionMap && chart.series[0]?.fill?.kind === "solid" && series[0])
24481
+ model.regionMap.fixedColor = series[0].color;
23922
24482
  const table = chartDataTableView(chart, theme, ctx.drawingColor);
23923
24483
  if (table) model.dataTable = table;
23924
24484
  if (chart.date1904 !== void 0) model.date1904 = chart.date1904;
@@ -24171,6 +24731,1414 @@ function linesAndAreas(model, frame2, out) {
24171
24731
  pointLabels(model, marks, out);
24172
24732
  }
24173
24733
 
24734
+ // chart/render/chart-3d-marks.ts
24735
+ var RIBBON_THICKNESS = 0.025;
24736
+ var stackedOf = (model) => model.grouping === "stacked" || model.grouping === "percentStacked";
24737
+ function chart3DBarMeshes(model, layout) {
24738
+ const bars2 = layout.bars;
24739
+ if (!bars2) return [];
24740
+ const values = plotted(model);
24741
+ const stacked = stackedOf(model);
24742
+ const clustered = model.grouping === "clustered";
24743
+ const inDepth = chart3DSeriesInDepth(model);
24744
+ const pos = new Array(model.categories.length).fill(0);
24745
+ const neg = new Array(model.categories.length).fill(0);
24746
+ const base = layout.value(0);
24747
+ const meshes = [];
24748
+ model.series.forEach((s, si) => {
24749
+ const slot = clustered ? si : 0;
24750
+ const [z0, z1] = layout.rowZ(inDepth ? si : 0);
24751
+ values[si]?.forEach((v, i) => {
24752
+ if (v === null || i >= model.categories.length) return;
24753
+ let from = 0;
24754
+ let to = v;
24755
+ if (stacked) {
24756
+ const acc = v >= 0 ? pos : neg;
24757
+ from = acc[i] ?? 0;
24758
+ to = from + v;
24759
+ acc[i] = to;
24760
+ }
24761
+ const a = stacked ? layout.value(from) : base;
24762
+ const b = layout.value(to);
24763
+ const centre = (i + 0.5) * layout.band;
24764
+ const meta = {
24765
+ series: s.sourceIndex ?? si,
24766
+ point: i,
24767
+ color: s.pointColors?.[i] ?? s.color
24768
+ };
24769
+ const mesh = layout.horizontal ? boxMesh(
24770
+ a,
24771
+ b,
24772
+ centre - (bars2.clusterWidth / 2 - bars2.singleBarWidth - slot * bars2.step) - bars2.singleBarWidth,
24773
+ centre - (bars2.clusterWidth / 2 - bars2.singleBarWidth - slot * bars2.step),
24774
+ z0,
24775
+ z1,
24776
+ meta
24777
+ ) : boxMesh(
24778
+ centre - bars2.clusterWidth / 2 + slot * bars2.step,
24779
+ centre - bars2.clusterWidth / 2 + slot * bars2.step + bars2.singleBarWidth,
24780
+ a,
24781
+ b,
24782
+ z0,
24783
+ z1,
24784
+ meta
24785
+ );
24786
+ if (mesh) meshes.push(mesh);
24787
+ });
24788
+ });
24789
+ return meshes;
24790
+ }
24791
+ function chart3DLineMeshes(model, layout) {
24792
+ const values = plotted(model);
24793
+ const stacked = stackedOf(model);
24794
+ const inDepth = chart3DSeriesInDepth(model);
24795
+ const thick = layout.valueLength * RIBBON_THICKNESS;
24796
+ const acc = new Array(model.categories.length).fill(0);
24797
+ const meshes = [];
24798
+ model.series.forEach((s, si) => {
24799
+ const [z0, z1] = layout.rowZ(inDepth ? si : 0);
24800
+ const pts = (values[si] ?? []).map((v, i) => {
24801
+ if (v === null || i >= model.categories.length) return null;
24802
+ const top = stacked ? acc[i] = (acc[i] ?? 0) + v : v;
24803
+ return [(i + 0.5) * layout.band, layout.value(top)];
24804
+ });
24805
+ for (let i = 0; i + 1 < pts.length; i++) {
24806
+ const p = pts[i];
24807
+ const q = pts[i + 1];
24808
+ if (!p || !q) continue;
24809
+ const mesh = extrudeMesh([p, q, [q[0], q[1] - thick], [p[0], p[1] - thick]], z0, z1, {
24810
+ series: s.sourceIndex ?? si,
24811
+ point: i,
24812
+ color: s.color
24813
+ });
24814
+ if (mesh) meshes.push(mesh);
24815
+ }
24816
+ });
24817
+ return meshes;
24818
+ }
24819
+ function chart3DAreaMeshes(model, layout) {
24820
+ const values = plotted(model);
24821
+ const stacked = stackedOf(model);
24822
+ const inDepth = chart3DSeriesInDepth(model);
24823
+ const cats = model.categories.length;
24824
+ const x = (i) => cats > 1 ? i / (cats - 1) * layout.catLength : layout.catLength / 2;
24825
+ const base = layout.value(0);
24826
+ const acc = new Array(cats).fill(0);
24827
+ const meshes = [];
24828
+ model.series.forEach((s, si) => {
24829
+ const [z0, z1] = layout.rowZ(inDepth ? si : 0);
24830
+ const upper = [];
24831
+ const lower = [];
24832
+ for (let i = 0; i < cats; i++) {
24833
+ const v = values[si]?.[i] ?? 0;
24834
+ const below = stacked ? acc[i] ?? 0 : 0;
24835
+ if (stacked) acc[i] = below + v;
24836
+ upper.push([x(i), layout.value(below + v)]);
24837
+ lower.push([x(i), stacked ? layout.value(below) : base]);
24838
+ }
24839
+ const mesh = extrudeMesh([...upper, ...lower.reverse()], z0, z1, {
24840
+ series: s.sourceIndex ?? si,
24841
+ point: 0,
24842
+ color: s.color
24843
+ });
24844
+ if (mesh) meshes.push(mesh);
24845
+ });
24846
+ return meshes;
24847
+ }
24848
+
24849
+ // chart/render/chart-3d-projection.ts
24850
+ var DEFAULT_ROT_X = 15;
24851
+ var DEFAULT_ROT_Y = 20;
24852
+ var DEFAULT_PIE_ROT_X = 30;
24853
+ var DEFAULT_PIE_ROT_Y = 0;
24854
+ var DEFAULT_PERSPECTIVE_DEG = 30;
24855
+ var PERSPECTIVE_MAX_DEG = 120;
24856
+ var FOV_MIN = 15;
24857
+ var FOV_MAX = 75;
24858
+ var clamp3 = (value, min, max) => Math.min(Math.max(value, min), max);
24859
+ function resolvePerspectiveFov(perspectiveDeg) {
24860
+ const perspective = clamp3(perspectiveDeg ?? DEFAULT_PERSPECTIVE_DEG, 0, PERSPECTIVE_MAX_DEG);
24861
+ return FOV_MIN + perspective / PERSPECTIVE_MAX_DEG * (FOV_MAX - FOV_MIN);
24862
+ }
24863
+ function resolveChart3DProjection(chartType, view3D) {
24864
+ const isPie = chartType === "pie3D";
24865
+ const rotXDeg = view3D?.rotX ?? (isPie ? DEFAULT_PIE_ROT_X : DEFAULT_ROT_X);
24866
+ const rotYDeg = view3D?.rotY ?? (isPie ? DEFAULT_PIE_ROT_Y : DEFAULT_ROT_Y);
24867
+ const rAngAx = view3D?.rAngAx ?? chartType === "bar3D";
24868
+ if (rAngAx) {
24869
+ const rx = rotXDeg * Math.PI / 180;
24870
+ const ry = rotYDeg * Math.PI / 180;
24871
+ return { mode: "oblique", shearX: Math.sin(ry), shearY: -Math.sin(rx), rotXDeg, rotYDeg };
24872
+ }
24873
+ return {
24874
+ mode: "perspective",
24875
+ rotXDeg,
24876
+ rotYDeg,
24877
+ fovDeg: resolvePerspectiveFov(view3D?.perspective)
24878
+ };
24879
+ }
24880
+
24881
+ // chart/render/chart-3d-shading.ts
24882
+ var FACE_SHADE_AMOUNT = {
24883
+ front: 0,
24884
+ top: 0.25,
24885
+ right: 0.36,
24886
+ left: 0.36,
24887
+ back: 0.36,
24888
+ bottom: 0.5
24889
+ };
24890
+ var HEX = /^#[0-9a-f]{6}$/i;
24891
+ function shadeChart3DFace(baseColor, face) {
24892
+ const amount = FACE_SHADE_AMOUNT[face];
24893
+ return amount === 0 || !HEX.test(baseColor) ? baseColor : shade(baseColor, amount);
24894
+ }
24895
+
24896
+ // chart/render/chart-3d-pie.ts
24897
+ var STEP = Math.PI / 45;
24898
+ function chart3DPieGeometry(area, view) {
24899
+ const tilt = resolveChart3DProjection("pie3D", view).rotXDeg;
24900
+ const sin = Math.min(1, Math.max(0.08, Math.sin(Math.abs(tilt) * Math.PI / 180)));
24901
+ const cos = Math.cos(Math.min(90, Math.abs(tilt)) * Math.PI / 180);
24902
+ const depth = Math.min(2e3, Math.max(20, view.depthPercent ?? 100)) / 100;
24903
+ const rx0 = Math.max(1, Math.min(area.w / 2, area.h / 2 / sin) - 4);
24904
+ const thickness = rx0 * 0.35 * cos * depth;
24905
+ const rx = Math.min(rx0, Math.max(1, (area.h - thickness) / 2 / sin));
24906
+ const ry = rx * sin;
24907
+ const thick = Math.min(thickness, Math.max(0, area.h - ry * 2));
24908
+ return {
24909
+ cx: area.x + area.w / 2,
24910
+ cy: area.y + (area.h - thick) / 2 + ry,
24911
+ rx,
24912
+ ry,
24913
+ thickness: thick
24914
+ };
24915
+ }
24916
+ var pt = (g, a, dy) => `${n(g.cx + g.rx * Math.cos(a))},${n(g.cy + g.ry * Math.sin(a) + dy)}`;
24917
+ function frontRanges(a0, a1) {
24918
+ const out = [];
24919
+ for (let k = Math.floor(a0 / (2 * Math.PI)) - 1; k <= Math.ceil(a1 / (2 * Math.PI)); k++) {
24920
+ const lo = Math.max(a0, k * 2 * Math.PI);
24921
+ const hi = Math.min(a1, k * 2 * Math.PI + Math.PI);
24922
+ if (hi - lo > 1e-6) out.push([lo, hi]);
24923
+ }
24924
+ return out;
24925
+ }
24926
+ function chart3DPieSvg(model, area, view) {
24927
+ const series = model.series[0];
24928
+ if (!series) return "";
24929
+ const total = series.values.reduce((sum, v) => sum + (v !== null && v > 0 ? v : 0), 0);
24930
+ if (total <= 0) return "";
24931
+ const g = chart3DPieGeometry(area, view);
24932
+ const walls = [];
24933
+ const tops = [];
24934
+ let angle = -Math.PI / 2;
24935
+ series.values.forEach((v, i) => {
24936
+ if (v === null || v <= 0) return;
24937
+ const sweep = v / total * Math.PI * 2;
24938
+ const a0 = angle;
24939
+ const a1 = angle + sweep;
24940
+ angle = a1;
24941
+ const color = series.pointColors?.[i] ?? series.color;
24942
+ const wall = shadeChart3DFace(color, "right");
24943
+ const top = color;
24944
+ const filter = series.shadowFilter ? ` filter="${series.shadowFilter}"` : "";
24945
+ for (const [lo, hi] of frontRanges(a0, a1)) {
24946
+ const steps = Math.max(2, Math.ceil((hi - lo) / STEP));
24947
+ const upper = [];
24948
+ const lower = [];
24949
+ for (let s = 0; s <= steps; s++) {
24950
+ const a = lo + (hi - lo) * s / steps;
24951
+ upper.push(pt(g, a, 0));
24952
+ lower.push(pt(g, a, g.thickness));
24953
+ }
24954
+ walls.push(
24955
+ `<polygon points="${[...upper, ...lower.reverse()].join(" ")}" fill="${wall}" stroke="${wall}" stroke-width="0.5" data-chart-series="0" data-chart-point="${i}"${filter}/>`
24956
+ );
24957
+ }
24958
+ const full = sweep >= Math.PI * 2 - 1e-6;
24959
+ const start = pt(g, a0, 0);
24960
+ const end = pt(g, a1, 0);
24961
+ const d = full ? `M${pt(g, a0, 0)} A${n(g.rx)},${n(g.ry)} 0 1 1 ${pt(g, a0 + Math.PI, 0)} A${n(g.rx)},${n(g.ry)} 0 1 1 ${start} Z` : `M${n(g.cx)},${n(g.cy)} L${start} A${n(g.rx)},${n(g.ry)} 0 ${sweep > Math.PI ? 1 : 0} 1 ${end} Z`;
24962
+ tops.push(
24963
+ `<path d="${d}" fill="${top}" stroke="#FFFFFF" stroke-width="1" data-chart-series="0" data-chart-point="${i}"${filter}/>`
24964
+ );
24965
+ });
24966
+ return walls.join("") + tops.join("");
24967
+ }
24968
+
24969
+ // chart/render/chart-3d-scene.ts
24970
+ var centroid = (pts) => {
24971
+ const sum = pts.reduce(
24972
+ (acc, p) => [acc[0] + p[0], acc[1] + p[1], acc[2] + p[2]],
24973
+ [0, 0, 0]
24974
+ );
24975
+ return [sum[0] / pts.length, sum[1] / pts.length, sum[2] / pts.length];
24976
+ };
24977
+ function chart3DFaceVisible(camera, face) {
24978
+ if (!face.normal) return true;
24979
+ const d = camera.viewDir(centroid(face.pts));
24980
+ return face.normal[0] * d[0] + face.normal[1] * d[1] + face.normal[2] * d[2] < 0;
24981
+ }
24982
+ function chart3DPolygon(camera, pts, fill, extra = "") {
24983
+ const points = pts.map((p) => {
24984
+ const q = camera.project(p);
24985
+ return `${n(q.x)},${n(q.y)}`;
24986
+ }).join(" ");
24987
+ return `<polygon points="${points}" fill="${fill}" stroke="${fill}" stroke-width="0.5" stroke-linejoin="round"${extra}/>`;
24988
+ }
24989
+ function chart3DMeshesSvg(camera, meshes) {
24990
+ const out = [];
24991
+ const ordered = [...meshes].sort((a, b) => camera.order(a.center, b.center));
24992
+ for (const mesh of ordered) {
24993
+ const faces = mesh.faces.filter((face) => chart3DFaceVisible(camera, face)).map((face) => ({ face, depth: camera.project(centroid(face.pts)).depth })).sort((a, b) => b.depth - a.depth);
24994
+ if (!faces.length) continue;
24995
+ out.push(`<g data-chart-series="${mesh.series}" data-chart-point="${mesh.point}">`);
24996
+ for (const { face } of faces)
24997
+ out.push(
24998
+ chart3DPolygon(camera, face.pts, face.fill ?? shadeChart3DFace(mesh.color, face.kind))
24999
+ );
25000
+ out.push("</g>");
25001
+ }
25002
+ return out.join("");
25003
+ }
25004
+
25005
+ // chart/render/chart-3d-surface.ts
25006
+ var LIGHT = (() => {
25007
+ const v = [-0.3, 0.8, -0.5];
25008
+ const len = Math.hypot(...v);
25009
+ return [v[0] / len, v[1] / len, v[2] / len];
25010
+ })();
25011
+ var HEX2 = /^#[0-9a-f]{6}$/i;
25012
+ var BAND_FALLBACK = ["#4472C4", "#ED7D31", "#A5A5A5", "#FFC000", "#5B9BD5", "#70AD47"];
25013
+ function chart3DSurfaceMeshes(model, layout) {
25014
+ const cols = model.categories.length;
25015
+ const rows2 = model.series.length;
25016
+ const scale = model.valueAxis;
25017
+ if (cols < 2 || rows2 < 1 || !scale) return [];
25018
+ const zRows = rows2 === 1 ? 2 : rows2;
25019
+ const height = (r, c) => layout.value(model.series[Math.min(r, rows2 - 1)]?.values[c] ?? 0);
25020
+ const x = (c) => c / (cols - 1) * layout.catLength;
25021
+ const z = (r) => r / (zRows - 1) * layout.size.d;
25022
+ const meshes = [];
25023
+ for (let r = 0; r + 1 < zRows; r++)
25024
+ for (let c = 0; c + 1 < cols; c++) {
25025
+ const pts = [
25026
+ [x(c), height(r, c), z(r)],
25027
+ [x(c + 1), height(r, c + 1), z(r)],
25028
+ [x(c + 1), height(r + 1, c + 1), z(r + 1)],
25029
+ [x(c), height(r + 1, c), z(r + 1)]
25030
+ ];
25031
+ const avg = pts.reduce((sum, p) => sum + p[1], 0) / 4;
25032
+ const band = Math.max(
25033
+ 0,
25034
+ Math.min(
25035
+ Math.max(0, scale.ticks.length - 2),
25036
+ Math.floor(avg / layout.valueLength * Math.max(1, scale.ticks.length - 1))
25037
+ )
25038
+ );
25039
+ const color = model.series[band % rows2]?.color && HEX2.test(model.series[band % rows2].color) ? model.series[band % rows2].color : BAND_FALLBACK[band % BAND_FALLBACK.length] ?? "#4472C4";
25040
+ const [a, b, , d] = pts;
25041
+ const e1 = [b[0] - a[0], b[1] - a[1], b[2] - a[2]];
25042
+ const e2 = [d[0] - a[0], d[1] - a[1], d[2] - a[2]];
25043
+ const nx = e1[1] * e2[2] - e1[2] * e2[1];
25044
+ const ny = e1[2] * e2[0] - e1[0] * e2[2];
25045
+ const nz = e1[0] * e2[1] - e1[1] * e2[0];
25046
+ const len = Math.hypot(nx, ny, nz) || 1;
25047
+ const lit = Math.abs((nx * LIGHT[0] + ny * LIGHT[1] + nz * LIGHT[2]) / len);
25048
+ meshes.push({
25049
+ series: Math.min(r, rows2 - 1),
25050
+ point: c,
25051
+ color,
25052
+ center: [(a[0] + b[0]) / 2, avg, (a[2] + d[2]) / 2],
25053
+ faces: [{ pts, normal: void 0, kind: "top", fill: shade(color, 0.35 * (1 - lit)) }]
25054
+ });
25055
+ }
25056
+ return meshes;
25057
+ }
25058
+
25059
+ // chart/render/chart-3d-walls.ts
25060
+ var LABEL_SIZE = 10;
25061
+ function line3(camera, a, b, color) {
25062
+ const p = camera.project(a);
25063
+ const q = camera.project(b);
25064
+ return `<line x1="${n(p.x)}" y1="${n(p.y)}" x2="${n(q.x)}" y2="${n(q.y)}" stroke="${color}" stroke-width="1"/>`;
25065
+ }
25066
+ function outline2(camera, pts, fill) {
25067
+ const points = pts.map((p) => {
25068
+ const q = camera.project(p);
25069
+ return `${n(q.x)},${n(q.y)}`;
25070
+ }).join(" ");
25071
+ return `<polygon points="${points}" fill="${fill}" stroke="${AXIS_COLOR}" stroke-width="1"/>`;
25072
+ }
25073
+ function chart3DLabelMargins(model) {
25074
+ const scale = model.valueAxis;
25075
+ const value = scale ? Math.max(
25076
+ ...scale.ticks.map(
25077
+ (t) => textWidth(axisTickText(t, model.axes?.value, scale.percent), LABEL_SIZE)
25078
+ ),
25079
+ 8
25080
+ ) + 6 : 8;
25081
+ const category = Math.max(...model.categories.map((c) => textWidth(c, LABEL_SIZE)), 8) + 6;
25082
+ return model.horizontal ? { left: Math.min(category, 120), bottom: LABEL_SIZE + 8 } : { left: Math.min(value, 80), bottom: LABEL_SIZE + 8 };
25083
+ }
25084
+ function chart3DWallsSvg(model, layout, camera) {
25085
+ const { w, h, d } = layout.size;
25086
+ const sx = camera.sideWallAtZero ? 0 : w;
25087
+ const out = [];
25088
+ out.push(
25089
+ outline2(
25090
+ camera,
25091
+ [
25092
+ [0, 0, 0],
25093
+ [w, 0, 0],
25094
+ [w, 0, d],
25095
+ [0, 0, d]
25096
+ ],
25097
+ "#F2F2F2"
25098
+ )
25099
+ );
25100
+ out.push(
25101
+ outline2(
25102
+ camera,
25103
+ [
25104
+ [0, 0, d],
25105
+ [w, 0, d],
25106
+ [w, h, d],
25107
+ [0, h, d]
25108
+ ],
25109
+ "none"
25110
+ )
25111
+ );
25112
+ out.push(
25113
+ outline2(
25114
+ camera,
25115
+ [
25116
+ [sx, 0, 0],
25117
+ [sx, 0, d],
25118
+ [sx, h, d],
25119
+ [sx, h, 0]
25120
+ ],
25121
+ "none"
25122
+ )
25123
+ );
25124
+ for (const tick of model.valueAxis?.ticks ?? []) {
25125
+ const p = layout.value(tick);
25126
+ if (layout.horizontal) {
25127
+ out.push(line3(camera, [p, 0, d], [p, h, d], GRID_COLOR));
25128
+ out.push(line3(camera, [p, 0, 0], [p, 0, d], GRID_COLOR));
25129
+ } else {
25130
+ out.push(line3(camera, [0, p, d], [w, p, d], GRID_COLOR));
25131
+ out.push(line3(camera, [sx, p, 0], [sx, p, d], GRID_COLOR));
25132
+ }
25133
+ }
25134
+ return out.join("");
25135
+ }
25136
+ function chart3DLabelsSvg(model, layout, camera, catPos) {
25137
+ const { w } = layout.size;
25138
+ const sx = camera.sideWallAtZero ? 0 : w;
25139
+ const scale = model.valueAxis;
25140
+ const out = [];
25141
+ const anchor = sx === 0 ? "end" : "start";
25142
+ const dx = sx === 0 ? -4 : 4;
25143
+ for (const tick of scale?.ticks ?? []) {
25144
+ const label = axisTickText(tick, model.axes?.value, scale?.percent ?? false);
25145
+ const p = layout.value(tick);
25146
+ if (layout.horizontal) {
25147
+ const q = camera.project([p, 0, 0]);
25148
+ out.push(text(q.x, q.y + LABEL_SIZE + 3, label, { anchor: "middle", size: LABEL_SIZE }));
25149
+ } else {
25150
+ const q = camera.project([sx, p, 0]);
25151
+ out.push(text(q.x + dx, q.y + 3, label, { anchor, size: LABEL_SIZE }));
25152
+ }
25153
+ }
25154
+ const a = camera.project([0, 0, 0]);
25155
+ const b = camera.project(layout.horizontal ? [0, layout.band, 0] : [layout.band, 0, 0]);
25156
+ const bandPx = Math.max(1, layout.horizontal ? Math.abs(b.y - a.y) : Math.abs(b.x - a.x));
25157
+ const extent = layout.horizontal ? LABEL_SIZE + 2 : Math.max(...model.categories.map((c) => textWidth(c, LABEL_SIZE)), 1);
25158
+ const stride = Math.max(1, Math.ceil(extent / bandPx));
25159
+ model.categories.forEach((label, i) => {
25160
+ if (i % stride) return;
25161
+ if (layout.horizontal) {
25162
+ const q = camera.project([sx, catPos(i), 0]);
25163
+ out.push(text(q.x + dx, q.y + 3, label, { anchor, size: LABEL_SIZE }));
25164
+ } else {
25165
+ const q = camera.project([catPos(i), 0, 0]);
25166
+ out.push(text(q.x, q.y + LABEL_SIZE + 3, label, { anchor: "middle", size: LABEL_SIZE }));
25167
+ }
25168
+ });
25169
+ return out.join("");
25170
+ }
25171
+
25172
+ // chart/render/chart-3d-svg.ts
25173
+ var PROJECTION_TYPE = {
25174
+ bar: "bar3D",
25175
+ column: "bar3D",
25176
+ line: "line3D",
25177
+ area: "area3D",
25178
+ pie: "pie3D",
25179
+ surface: "surface"
25180
+ };
25181
+ function chart3DApplies(model) {
25182
+ return model.view3D !== void 0 && PROJECTION_TYPE[model.type] !== void 0;
25183
+ }
25184
+ function chart3DSvg(model, area) {
25185
+ const view = model.view3D ?? {};
25186
+ if (model.type === "pie")
25187
+ return chartAreaRect(model, "plotArea", area) + chart3DPieSvg(model, area, view);
25188
+ const projection = resolveChart3DProjection(PROJECTION_TYPE[model.type] ?? "bar3D", view);
25189
+ const margins = chart3DLabelMargins(model);
25190
+ const inner = {
25191
+ x: area.x + margins.left,
25192
+ y: area.y + 6,
25193
+ w: Math.max(1, area.w - margins.left - 8),
25194
+ h: Math.max(1, area.h - margins.bottom - 10)
25195
+ };
25196
+ const layout = chart3DLayout(model, inner, view);
25197
+ const camera = createChart3DCamera(projection, layout.size, inner);
25198
+ let meshes;
25199
+ if (model.type === "surface") meshes = chart3DSurfaceMeshes(model, layout);
25200
+ else if (model.type === "line") meshes = chart3DLineMeshes(model, layout);
25201
+ else if (model.type === "area") meshes = chart3DAreaMeshes(model, layout);
25202
+ else meshes = chart3DBarMeshes(model, layout);
25203
+ const edge = model.type === "area" || model.type === "surface";
25204
+ const cats = model.categories.length;
25205
+ const catPos = edge ? (i) => cats > 1 ? i / (cats - 1) * layout.catLength : layout.catLength / 2 : (i) => (i + 0.5) * layout.band;
25206
+ return [
25207
+ chartAreaRect(model, "plotArea", area),
25208
+ chart3DWallsSvg(model, layout, camera),
25209
+ chart3DMeshesSvg(camera, meshes),
25210
+ chart3DLabelsSvg(model, layout, camera, catPos)
25211
+ ].join("");
25212
+ }
25213
+
25214
+ // chart/region-map/alias.ts
25215
+ var REGION_ALIAS_MAP = {
25216
+ us: "US",
25217
+ usa: "US",
25218
+ "united states": "US",
25219
+ "united states of america": "US",
25220
+ ca: "CA",
25221
+ can: "CA",
25222
+ canada: "CA",
25223
+ br: "BR",
25224
+ bra: "BR",
25225
+ brazil: "BR",
25226
+ gb: "GB",
25227
+ gbr: "GB",
25228
+ uk: "GB",
25229
+ "united kingdom": "GB",
25230
+ fr: "FR",
25231
+ fra: "FR",
25232
+ france: "FR",
25233
+ de: "DE",
25234
+ deu: "DE",
25235
+ germany: "DE",
25236
+ it: "IT",
25237
+ ita: "IT",
25238
+ italy: "IT",
25239
+ es: "ES",
25240
+ esp: "ES",
25241
+ spain: "ES",
25242
+ ru: "RU",
25243
+ rus: "RU",
25244
+ russia: "RU",
25245
+ cn: "CN",
25246
+ chn: "CN",
25247
+ china: "CN",
25248
+ in: "IN",
25249
+ ind: "IN",
25250
+ india: "IN",
25251
+ jp: "JP",
25252
+ jpn: "JP",
25253
+ japan: "JP",
25254
+ kr: "KR",
25255
+ kor: "KR",
25256
+ "south korea": "KR",
25257
+ korea: "KR",
25258
+ au: "AU",
25259
+ aus: "AU",
25260
+ australia: "AU",
25261
+ mx: "MX",
25262
+ mex: "MX",
25263
+ mexico: "MX",
25264
+ id: "ID",
25265
+ idn: "ID",
25266
+ indonesia: "ID",
25267
+ tr: "TR",
25268
+ tur: "TR",
25269
+ turkey: "TR",
25270
+ sa: "SA",
25271
+ sau: "SA",
25272
+ "saudi arabia": "SA",
25273
+ za: "ZA",
25274
+ zaf: "ZA",
25275
+ "south africa": "ZA",
25276
+ ar: "AR",
25277
+ arg: "AR",
25278
+ argentina: "AR",
25279
+ ng: "NG",
25280
+ nga: "NG",
25281
+ nigeria: "NG",
25282
+ eg: "EG",
25283
+ egy: "EG",
25284
+ egypt: "EG"
25285
+ };
25286
+ function resolveRegionCode(label) {
25287
+ const normalized = label.trim().toLowerCase();
25288
+ return REGION_ALIAS_MAP[normalized];
25289
+ }
25290
+
25291
+ // chart/region-map/data.ts
25292
+ function sourceIndices(indices, length) {
25293
+ return Array.from({ length }, (_, position2) => indices?.[position2] ?? position2);
25294
+ }
25295
+ function valueAtSource(values, indices, sourceIndex) {
25296
+ const position2 = indices.indexOf(sourceIndex);
25297
+ return position2 >= 0 ? values[position2] : void 0;
25298
+ }
25299
+ function cachedEntityName(cache, entityId) {
25300
+ if (!cache || typeof cache !== "object") {
25301
+ return void 0;
25302
+ }
25303
+ const record = cache;
25304
+ if (String(record["@_entityId"] ?? "") === entityId && record["@_entityName"] !== void 0) {
25305
+ return String(record["@_entityName"]);
25306
+ }
25307
+ for (const value of Object.values(record)) {
25308
+ if (Array.isArray(value)) {
25309
+ for (const item2 of value) {
25310
+ const name = cachedEntityName(item2, entityId);
25311
+ if (name) {
25312
+ return name;
25313
+ }
25314
+ }
25315
+ } else {
25316
+ const name = cachedEntityName(value, entityId);
25317
+ if (name) {
25318
+ return name;
25319
+ }
25320
+ }
25321
+ }
25322
+ return void 0;
25323
+ }
25324
+ function resolveRegionEntityCode(entityId, options2, resolveCode) {
25325
+ if (!entityId) {
25326
+ return void 0;
25327
+ }
25328
+ const direct = resolveCode(entityId);
25329
+ if (direct) {
25330
+ return direct;
25331
+ }
25332
+ const tokens = entityId.split(/[:/|._-]+/u).filter(Boolean);
25333
+ for (let index = tokens.length - 1; index >= 0; index--) {
25334
+ const resolved = resolveCode(tokens[index] ?? "");
25335
+ if (resolved) {
25336
+ return resolved;
25337
+ }
25338
+ }
25339
+ const cachedName = cachedEntityName(options2?.geographyCache, entityId);
25340
+ return cachedName ? resolveCode(cachedName) : void 0;
25341
+ }
25342
+ function buildRegionMapEntries(categories, values, options2, resolveCode) {
25343
+ const entityIds = options2?.entityIds ?? [];
25344
+ const categoryIndices = sourceIndices(options2?.categorySourceIndices, categories.length);
25345
+ const valueIndices = sourceIndices(options2?.valueSourceIndices, values.length);
25346
+ const entityIndices = sourceIndices(options2?.entityIdSourceIndices, entityIds.length);
25347
+ const indices = [.../* @__PURE__ */ new Set([...categoryIndices, ...valueIndices, ...entityIndices])].sort(
25348
+ (a, b) => a - b
25349
+ );
25350
+ return indices.flatMap((sourceIndex) => {
25351
+ const category = valueAtSource(categories, categoryIndices, sourceIndex) ?? "";
25352
+ const value = valueAtSource(values, valueIndices, sourceIndex);
25353
+ if (value === null || value === void 0 || !Number.isFinite(value)) return [];
25354
+ const entityId = valueAtSource(entityIds, entityIndices, sourceIndex);
25355
+ const code = resolveRegionEntityCode(entityId, options2, resolveCode) ?? resolveCode(category);
25356
+ return {
25357
+ sourceIndex,
25358
+ label: category || entityId || `Region ${sourceIndex + 1}`,
25359
+ value,
25360
+ ...entityId ? { entityId } : {},
25361
+ ...code ? { code } : {}
25362
+ };
25363
+ });
25364
+ }
25365
+ function shouldRenderRegionLabel(layout, projectedWidth, projectedHeight) {
25366
+ if (!layout || layout === "none") {
25367
+ return false;
25368
+ }
25369
+ if (layout === "bestFitOnly") {
25370
+ return projectedWidth >= 18 && projectedHeight >= 10;
25371
+ }
25372
+ return true;
25373
+ }
25374
+ function formatRegionMapValue(value, cultureLanguage) {
25375
+ if (!cultureLanguage) {
25376
+ return String(value);
25377
+ }
25378
+ try {
25379
+ return new Intl.NumberFormat(cultureLanguage, { maximumFractionDigits: 2 }).format(value);
25380
+ } catch {
25381
+ return String(value);
25382
+ }
25383
+ }
25384
+ function lerpColor(a, b, t) {
25385
+ const clamp4 = (v) => Math.max(0, Math.min(255, Math.round(v))), ha = a.replace("#", ""), hb = b.replace("#", ""), r1 = parseInt(ha.substring(0, 2), 16), g1 = parseInt(ha.substring(2, 4), 16), b1 = parseInt(ha.substring(4, 6), 16), r2 = parseInt(hb.substring(0, 2), 16), g2 = parseInt(hb.substring(2, 4), 16), b2 = parseInt(hb.substring(4, 6), 16), r = clamp4(r1 + (r2 - r1) * t), g = clamp4(g1 + (g2 - g1) * t), bl = clamp4(b1 + (b2 - b1) * t), toHex2 = (n2) => n2.toString(16).padStart(2, "0");
25386
+ return `#${toHex2(r)}${toHex2(g)}${toHex2(bl)}`;
25387
+ }
25388
+ function resolveValueColorStops(valueColors, valueColorPositions, minVal, maxVal) {
25389
+ if (!valueColors || valueColors.length < 2) {
25390
+ return void 0;
25391
+ }
25392
+ const span = maxVal - minVal || 1, count = valueColors.length, resolvePosition = (position2, index) => {
25393
+ if (position2?.kind === "min") {
25394
+ return 0;
25395
+ }
25396
+ if (position2?.kind === "max") {
25397
+ return 1;
25398
+ }
25399
+ if (position2?.kind === "number" && position2.value !== void 0) {
25400
+ return Math.min(1, Math.max(0, (position2.value - minVal) / span));
25401
+ }
25402
+ if (position2?.kind === "percent" && position2.value !== void 0) {
25403
+ return Math.min(1, Math.max(0, position2.value / 100));
25404
+ }
25405
+ return count === 1 ? 0 : index / (count - 1);
25406
+ };
25407
+ return valueColors.map((color, index) => ({
25408
+ color,
25409
+ position: resolvePosition(valueColorPositions?.[index], index)
25410
+ }));
25411
+ }
25412
+ function buildValueColorScale(stops) {
25413
+ const sorted = [...stops].sort((a, b) => a.position - b.position);
25414
+ return (t) => {
25415
+ const clamped = Math.max(0, Math.min(1, t)), first3 = sorted[0];
25416
+ if (!first3) {
25417
+ return "#94a3b8";
25418
+ }
25419
+ if (sorted.length === 1) {
25420
+ return first3.color;
25421
+ }
25422
+ for (let i = 0; i < sorted.length - 1; i++) {
25423
+ const a = sorted[i], b = sorted[i + 1];
25424
+ if (clamped >= a.position && clamped <= b.position) {
25425
+ return lerpColor(
25426
+ a.color,
25427
+ b.color,
25428
+ (clamped - a.position) / (b.position - a.position || 1)
25429
+ );
25430
+ }
25431
+ }
25432
+ const last = sorted[sorted.length - 1] ?? first3;
25433
+ return clamped <= first3.position ? first3.color : last.color;
25434
+ };
25435
+ }
25436
+
25437
+ // chart/region-map/colors.ts
25438
+ function sequentialColorScale(t, accent) {
25439
+ const clamped = Math.max(0, Math.min(1, t));
25440
+ if (accent && /^#[0-9a-f]{6}$/iu.test(accent))
25441
+ return lerpColor(lerpColor("#ffffff", accent, 0.2), accent, clamped);
25442
+ if (clamped <= 0.5) {
25443
+ return lerpColor("#dbeafe", "#3b82f6", clamped * 2);
25444
+ }
25445
+ return lerpColor("#3b82f6", "#1e3a5f", (clamped - 0.5) * 2);
25446
+ }
25447
+ function normalizeValue(value, min, max) {
25448
+ if (max === min) {
25449
+ return 0.5;
25450
+ }
25451
+ return (value - min) / (max - min);
25452
+ }
25453
+
25454
+ // chart/region-map/world-regions.ts
25455
+ var WORLD_REGIONS = [
25456
+ {
25457
+ code: "US",
25458
+ name: "United States",
25459
+ path: "M130,160 L250,155 265,170 270,190 260,210 230,215 200,220 170,215 145,205 130,195Z M280,175 L295,165 310,170 310,185 295,195 280,190Z",
25460
+ labelXY: [200, 190]
25461
+ },
25462
+ {
25463
+ code: "CA",
25464
+ name: "Canada",
25465
+ path: "M120,90 L280,85 290,100 295,130 280,150 250,155 200,155 160,155 130,155 115,140 110,115Z",
25466
+ labelXY: [200, 125]
25467
+ },
25468
+ {
25469
+ code: "MX",
25470
+ name: "Mexico",
25471
+ path: "M145,215 L200,220 210,235 200,255 185,265 165,260 150,245 140,230Z",
25472
+ labelXY: [175, 240]
25473
+ },
25474
+ {
25475
+ code: "BR",
25476
+ name: "Brazil",
25477
+ path: "M270,300 L310,280 335,290 340,320 330,355 310,370 285,365 265,345 260,320Z",
25478
+ labelXY: [300, 330]
25479
+ },
25480
+ {
25481
+ code: "AR",
25482
+ name: "Argentina",
25483
+ path: "M260,370 L280,365 290,380 285,410 275,435 260,445 250,425 248,395Z",
25484
+ labelXY: [268, 410]
25485
+ },
25486
+ {
25487
+ code: "GB",
25488
+ name: "United Kingdom",
25489
+ path: "M440,120 L448,110 455,115 455,135 448,142 440,138Z",
25490
+ labelXY: [448, 128]
25491
+ },
25492
+ {
25493
+ code: "FR",
25494
+ name: "France",
25495
+ path: "M450,145 L470,140 480,150 478,168 465,175 450,170 445,158Z",
25496
+ labelXY: [463, 158]
25497
+ },
25498
+ {
25499
+ code: "DE",
25500
+ name: "Germany",
25501
+ path: "M478,125 L498,120 505,130 502,148 490,152 478,148 475,138Z",
25502
+ labelXY: [490, 138]
25503
+ },
25504
+ {
25505
+ code: "IT",
25506
+ name: "Italy",
25507
+ path: "M490,155 L498,152 505,162 500,180 492,190 488,178 486,165Z",
25508
+ labelXY: [495, 172]
25509
+ },
25510
+ {
25511
+ code: "ES",
25512
+ name: "Spain",
25513
+ path: "M432,168 L460,165 465,175 460,188 442,192 430,185 428,175Z",
25514
+ labelXY: [448, 180]
25515
+ },
25516
+ {
25517
+ code: "RU",
25518
+ name: "Russia",
25519
+ path: "M510,60 L780,50 830,70 840,100 820,120 750,115 700,105 650,100 580,105 530,110 510,100 505,80Z",
25520
+ labelXY: [670, 85]
25521
+ },
25522
+ {
25523
+ code: "TR",
25524
+ name: "Turkey",
25525
+ path: "M530,165 L570,160 585,170 580,182 555,185 530,180Z",
25526
+ labelXY: [558, 175]
25527
+ },
25528
+ {
25529
+ code: "EG",
25530
+ name: "Egypt",
25531
+ path: "M530,200 L555,195 565,205 560,225 545,230 530,222Z",
25532
+ labelXY: [548, 215]
25533
+ },
25534
+ {
25535
+ code: "NG",
25536
+ name: "Nigeria",
25537
+ path: "M475,275 L500,270 510,280 505,298 490,302 475,295Z",
25538
+ labelXY: [492, 288]
25539
+ },
25540
+ {
25541
+ code: "ZA",
25542
+ name: "South Africa",
25543
+ path: "M520,380 L545,370 560,380 555,400 540,410 520,405 515,392Z",
25544
+ labelXY: [538, 392]
25545
+ },
25546
+ {
25547
+ code: "SA",
25548
+ name: "Saudi Arabia",
25549
+ path: "M565,220 L600,210 615,225 610,250 590,258 570,250 560,238Z",
25550
+ labelXY: [590, 238]
25551
+ },
25552
+ {
25553
+ code: "IN",
25554
+ name: "India",
25555
+ path: "M640,210 L665,195 685,210 688,240 678,268 660,278 645,265 635,240Z",
25556
+ labelXY: [662, 240]
25557
+ },
25558
+ {
25559
+ code: "CN",
25560
+ name: "China",
25561
+ path: "M700,120 L775,115 800,130 805,160 790,180 760,185 730,180 710,168 695,150 690,135Z",
25562
+ labelXY: [750, 155]
25563
+ },
25564
+ {
25565
+ code: "JP",
25566
+ name: "Japan",
25567
+ path: "M835,145 L845,135 852,140 850,158 842,165 835,160Z",
25568
+ labelXY: [843, 152]
25569
+ },
25570
+ {
25571
+ code: "KR",
25572
+ name: "South Korea",
25573
+ path: "M815,158 L825,152 830,160 827,170 818,172 813,165Z",
25574
+ labelXY: [822, 163]
25575
+ },
25576
+ {
25577
+ code: "ID",
25578
+ name: "Indonesia",
25579
+ path: "M740,295 L780,288 810,292 830,298 825,310 790,312 755,308 740,305Z",
25580
+ labelXY: [785, 302]
25581
+ },
25582
+ {
25583
+ code: "AU",
25584
+ name: "Australia",
25585
+ path: "M790,350 L850,340 880,355 885,385 870,405 840,410 810,400 790,380Z",
25586
+ labelXY: [838, 378]
25587
+ }
25588
+ ];
25589
+
25590
+ // chart/region-map/projection.ts
25591
+ function regionBounds(region) {
25592
+ const coordinates = region.path.match(/-?\d+(?:\.\d+)?/gu)?.map(Number) ?? [];
25593
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
25594
+ for (let index = 0; index < coordinates.length; index += 2) {
25595
+ const x = coordinates[index] ?? 0, y = coordinates[index + 1] ?? 0;
25596
+ minX = Math.min(minX, x);
25597
+ maxX = Math.max(maxX, x);
25598
+ minY = Math.min(minY, y);
25599
+ maxY = Math.max(maxY, y);
25600
+ }
25601
+ return { minX, minY, maxX, maxY };
25602
+ }
25603
+ function regionViewBounds(viewedRegionType, regionValues, regions = WORLD_REGIONS) {
25604
+ if (!viewedRegionType || viewedRegionType === "world" || regionValues.size === 0) {
25605
+ return { minX: 0, minY: 0, maxX: 1e3, maxY: 500 };
25606
+ }
25607
+ const matched = regions.filter((region) => regionValues.has(region.code));
25608
+ const targets = viewedRegionType === "countryRegion" ? matched.slice(0, 1) : matched;
25609
+ if (targets.length === 0) {
25610
+ return { minX: 0, minY: 0, maxX: 1e3, maxY: 500 };
25611
+ }
25612
+ const bounds = targets.map(regionBounds);
25613
+ const padding = 10;
25614
+ return {
25615
+ minX: Math.max(0, Math.min(...bounds.map((item2) => item2.minX)) - padding),
25616
+ minY: Math.max(0, Math.min(...bounds.map((item2) => item2.minY)) - padding),
25617
+ maxX: Math.min(1e3, Math.max(...bounds.map((item2) => item2.maxX)) + padding),
25618
+ maxY: Math.min(500, Math.max(...bounds.map((item2) => item2.maxY)) + padding)
25619
+ };
25620
+ }
25621
+ function scalePathD(d, scale, dx, dy) {
25622
+ const tokens = d.match(/[A-Za-z]|-?\d+(?:\.\d+)?/gu) ?? [];
25623
+ const out = [];
25624
+ let i = 0;
25625
+ while (i < tokens.length) {
25626
+ const tok = tokens[i];
25627
+ if (tok === void 0) {
25628
+ i++;
25629
+ continue;
25630
+ }
25631
+ if (/^[A-Za-z]$/u.test(tok)) {
25632
+ out.push(tok);
25633
+ i++;
25634
+ continue;
25635
+ }
25636
+ const xRaw = parseFloat(tok);
25637
+ const yRaw = parseFloat(tokens[i + 1] ?? "");
25638
+ if (!Number.isNaN(xRaw) && !Number.isNaN(yRaw)) {
25639
+ out.push(`${(xRaw * scale + dx).toFixed(2)},${(yRaw * scale + dy).toFixed(2)}`);
25640
+ i += 2;
25641
+ } else {
25642
+ out.push(tok);
25643
+ i++;
25644
+ }
25645
+ }
25646
+ return out.join(" ");
25647
+ }
25648
+ var CX = "http://schemas.microsoft.com/office/drawing/2014/chartex";
25649
+ var LIMIT = 16 * 1024 * 1024;
25650
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
25651
+ function decodeGeoRing(encoded, limit = 1e6) {
25652
+ const out = [];
25653
+ let lat = 0, lon = 0, number = 0, shift = 0;
25654
+ for (const ch of encoded) {
25655
+ const value = ALPHABET.indexOf(ch);
25656
+ if (value < 0 || shift > 50) return void 0;
25657
+ number += (value & 31) * 2 ** shift;
25658
+ if (!Number.isSafeInteger(number)) return void 0;
25659
+ if (value >= 32) {
25660
+ shift += 5;
25661
+ continue;
25662
+ }
25663
+ const diagonal = Math.floor((Math.sqrt(8 * number + 1) - 1) / 2);
25664
+ const a = number - diagonal * (diagonal + 1) / 2, b = diagonal - a;
25665
+ lat += a % 2 ? -(a + 1) / 2 : a / 2;
25666
+ lon += b % 2 ? -(b + 1) / 2 : b / 2;
25667
+ if (Math.abs(lat) > 9e6 || Math.abs(lon) > 54e6 || out.length >= limit) return void 0;
25668
+ out.push({ latitude: lat / 1e5, longitude: lon / 1e5 });
25669
+ number = 0;
25670
+ shift = 0;
25671
+ }
25672
+ return shift || out.length < 3 ? void 0 : out;
25673
+ }
25674
+ function elements2(root, name) {
25675
+ return Array.from(root.getElementsByTagNameNS(CX, name));
25676
+ }
25677
+ function inflateGeoCache(binary, maxOutputBytes = LIMIT) {
25678
+ if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 1 || maxOutputBytes > LIMIT)
25679
+ throw new Error("Invalid geography cache output limit.");
25680
+ if (binary.length > 12 * 1024 * 1024) throw new Error("Geography cache input limit exceeded.");
25681
+ const bytes = Uint8Array.from(atob(binary.replace(/\s/gu, "")), (c) => c.charCodeAt(0));
25682
+ const chunks = [];
25683
+ let size = 0;
25684
+ const stream = new Inflate((chunk) => {
25685
+ size += chunk.length;
25686
+ if (size > maxOutputBytes) throw new Error("Geography cache output limit exceeded.");
25687
+ chunks.push(chunk);
25688
+ });
25689
+ for (let i = 0; i < bytes.length; i += 256)
25690
+ stream.push(bytes.subarray(i, i + 256), false);
25691
+ const out = new Uint8Array(size);
25692
+ let offset = 0;
25693
+ for (const chunk of chunks) {
25694
+ out.set(chunk, offset);
25695
+ offset += chunk.length;
25696
+ }
25697
+ return new TextDecoder("utf-8", { fatal: true }).decode(out);
25698
+ }
25699
+ function readGeographyCache(xml, pointLimit = 1e6) {
25700
+ const result = { regions: [], issues: [] };
25701
+ if (!xml) return result;
25702
+ try {
25703
+ if (!Number.isSafeInteger(pointLimit) || pointLimit < 1 || pointLimit > 1e6)
25704
+ throw new Error("Invalid geography point limit.");
25705
+ if (xml.length > LIMIT) throw new Error("Geography cache input limit exceeded.");
25706
+ let root = parseXml(`<cx:root xmlns:cx="${CX}">${xml}</cx:root>`).documentElement;
25707
+ const binary = elements2(root, "binary")[0];
25708
+ if (binary) root = parseXml(inflateGeoCache(binary.textContent ?? "")).documentElement;
25709
+ let points = 0;
25710
+ for (const data of elements2(root, "geoData")) {
25711
+ const rings = [];
25712
+ for (const polygon of elements2(data, "geoPolygon")) {
25713
+ const parts = (polygon.getAttribute("pcaRings") ?? "").split(",");
25714
+ const version = Number(parts.shift());
25715
+ const expected = Number(polygon.getAttribute("numPoints"));
25716
+ if (version !== 1 || parts.length < 1 || !Number.isInteger(expected) || expected < 3) {
25717
+ result.issues.push("Invalid geography ring count.");
25718
+ continue;
25719
+ }
25720
+ const decoded = [];
25721
+ let polygonPoints2 = 0;
25722
+ for (const part of parts) {
25723
+ const ring = decodeGeoRing(
25724
+ part,
25725
+ Math.min(expected - polygonPoints2, pointLimit - points - polygonPoints2)
25726
+ );
25727
+ if (!ring) break;
25728
+ decoded.push(ring);
25729
+ polygonPoints2 += ring.length;
25730
+ }
25731
+ if (decoded.length !== parts.length) {
25732
+ result.issues.push("Invalid compressed geography polygon.");
25733
+ continue;
25734
+ }
25735
+ for (const ring of decoded) {
25736
+ rings.push(ring);
25737
+ points += ring.length;
25738
+ }
25739
+ }
25740
+ if (rings.length)
25741
+ result.regions.push({
25742
+ entityId: data.getAttribute("entityId") ?? "",
25743
+ name: data.getAttribute("entityName") ?? "",
25744
+ rings,
25745
+ copyright: elements2(data, "copyright").map((c) => c.textContent ?? "")
25746
+ });
25747
+ }
25748
+ } catch (error) {
25749
+ result.issues.push(error instanceof Error ? error.message : String(error));
25750
+ }
25751
+ return result;
25752
+ }
25753
+
25754
+ // chart/region-map/geographic-projection.ts
25755
+ var RAD = Math.PI / 180;
25756
+ var RX = [
25757
+ 1,
25758
+ 0.9986,
25759
+ 0.9954,
25760
+ 0.99,
25761
+ 0.9822,
25762
+ 0.973,
25763
+ 0.96,
25764
+ 0.9427,
25765
+ 0.9216,
25766
+ 0.8962,
25767
+ 0.8679,
25768
+ 0.835,
25769
+ 0.7986,
25770
+ 0.7597,
25771
+ 0.7186,
25772
+ 0.6732,
25773
+ 0.6213,
25774
+ 0.5722,
25775
+ 0.5322
25776
+ ];
25777
+ var RY = [
25778
+ 0,
25779
+ 0.062,
25780
+ 0.124,
25781
+ 0.186,
25782
+ 0.248,
25783
+ 0.31,
25784
+ 0.372,
25785
+ 0.434,
25786
+ 0.4958,
25787
+ 0.5571,
25788
+ 0.6176,
25789
+ 0.6769,
25790
+ 0.7346,
25791
+ 0.7903,
25792
+ 0.8435,
25793
+ 0.8936,
25794
+ 0.9394,
25795
+ 0.9761,
25796
+ 1
25797
+ ];
25798
+ function projectGeoPoint(point, projection = "mercator") {
25799
+ const lon = point.longitude * RAD, lat = Math.max(-89.999, Math.min(89.999, point.latitude)) * RAD;
25800
+ if (projection === "mercator")
25801
+ return [
25802
+ lon,
25803
+ -Math.log(
25804
+ Math.tan(Math.PI / 4 + Math.max(-85.05112878 * RAD, Math.min(85.05112878 * RAD, lat)) / 2)
25805
+ )
25806
+ ];
25807
+ if (projection === "miller") return [lon, -1.25 * Math.log(Math.tan(Math.PI / 4 + 0.4 * lat))];
25808
+ if (projection === "robinson") {
25809
+ const index = Math.min(17, Math.floor(Math.abs(point.latitude) / 5)), t = Math.min(1, Math.abs(point.latitude) / 5 - index);
25810
+ return [
25811
+ 0.8487 * lon * (RX[index] + (RX[index + 1] - RX[index]) * t),
25812
+ -1.3523 * Math.sign(lat) * (RY[index] + (RY[index + 1] - RY[index]) * t)
25813
+ ];
25814
+ }
25815
+ if (projection === "albers") {
25816
+ const n2 = (Math.sin(20 * RAD) + Math.sin(50 * RAD)) / 2;
25817
+ const c = Math.cos(20 * RAD) ** 2 + 2 * n2 * Math.sin(20 * RAD);
25818
+ const rho = Math.sqrt(Math.max(0, c - 2 * n2 * Math.sin(lat))) / n2;
25819
+ return [rho * Math.sin(n2 * lon), rho * Math.cos(n2 * lon) - Math.sqrt(c) / n2];
25820
+ }
25821
+ return void 0;
25822
+ }
25823
+
25824
+ // chart/region-map/geometry.ts
25825
+ function regionMapGeometry(options2) {
25826
+ const cache = readGeographyCache(options2?.geographyCacheXml);
25827
+ if (!cache.regions.length)
25828
+ return { regions: WORLD_REGIONS, approximate: true, issues: cache.issues, copyright: [] };
25829
+ const projection = options2?.projectionType ?? "robinson";
25830
+ const projected = cache.regions.map((region) => ({
25831
+ region,
25832
+ rings: region.rings.map((ring) => ring.map((p) => projectGeoPoint(p, projection)))
25833
+ }));
25834
+ if (projected.some((r) => r.rings.some((ring) => ring.some((p) => !p))))
25835
+ return {
25836
+ regions: [],
25837
+ approximate: false,
25838
+ issues: [...cache.issues, "Unsupported geographic projection."],
25839
+ copyright: []
25840
+ };
25841
+ const all = projected.flatMap((r) => r.rings.flatMap((ring) => ring));
25842
+ let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
25843
+ for (const [x, y] of all) {
25844
+ minX = Math.min(minX, x);
25845
+ maxX = Math.max(maxX, x);
25846
+ minY = Math.min(minY, y);
25847
+ maxY = Math.max(maxY, y);
25848
+ }
25849
+ const factor = Math.min(1e3 / Math.max(maxX - minX, 1e-12), 500 / Math.max(maxY - minY, 1e-12));
25850
+ const sx = factor, sy = factor, ox = (1e3 - (maxX - minX) * factor) / 2, oy = (500 - (maxY - minY) * factor) / 2;
25851
+ const regions = projected.map(({ region, rings }) => {
25852
+ const paths = rings.map(
25853
+ (ring) => ring.map((p) => {
25854
+ const [x2, y2] = p;
25855
+ return [(x2 - minX) * sx + ox, (y2 - minY) * sy + oy];
25856
+ })
25857
+ );
25858
+ const coords = paths.flat();
25859
+ let x = 0, y = 0;
25860
+ for (const p of coords) {
25861
+ x += p[0];
25862
+ y += p[1];
25863
+ }
25864
+ return {
25865
+ code: resolveRegionCode(region.name) ?? region.entityId,
25866
+ entityId: region.entityId,
25867
+ name: region.name,
25868
+ labelXY: [x / coords.length, y / coords.length],
25869
+ path: paths.map(
25870
+ (r) => r.map((p, i) => `${i ? "L" : "M"}${p[0].toFixed(3)},${p[1].toFixed(3)}`).join(" ") + "Z"
25871
+ ).join(" ")
25872
+ };
25873
+ });
25874
+ return {
25875
+ regions,
25876
+ approximate: false,
25877
+ issues: cache.issues,
25878
+ copyright: [...new Set(cache.regions.flatMap((r) => r.copyright))]
25879
+ };
25880
+ }
25881
+
25882
+ // chart/render/chart-svg-region-map.ts
25883
+ function regionMapSvg(model, area, approximationLabel) {
25884
+ const series = model.series[0];
25885
+ if (!series || series.hidden) return "";
25886
+ const options2 = model.regionMap;
25887
+ const geometry2 = regionMapGeometry(options2);
25888
+ const resolve = (label) => geometry2.regions.find(
25889
+ (r) => r.entityId === label || r.code === label || r.name.toLowerCase() === label.toLowerCase()
25890
+ )?.code ?? resolveRegionCode(label);
25891
+ const entries = buildRegionMapEntries(model.categories, series.values, options2, resolve);
25892
+ const min = entries.length ? Math.min(...entries.map((e) => e.value)) : 0, max = entries.length ? Math.max(...entries.map((e) => e.value)) : 1;
25893
+ const stops = resolveValueColorStops(
25894
+ options2?.valueColors,
25895
+ options2?.valueColorPositions,
25896
+ min,
25897
+ max
25898
+ );
25899
+ const colors = stops ? buildValueColorScale(stops) : (t) => sequentialColorScale(t, series.color);
25900
+ const matched = new Map(entries.filter((e) => e.code).map((e) => [e.code, e]));
25901
+ const missing = entries.filter(
25902
+ (e) => !e.code || !geometry2.regions.some((r) => r.code === e.code)
25903
+ );
25904
+ const bounds = regionViewBounds(options2?.viewedRegionType, matched, geometry2.regions);
25905
+ const width = bounds.maxX - bounds.minX || 1, height = bounds.maxY - bounds.minY || 1;
25906
+ const reserve = (model.showLegend ? 46 : 12) + Math.min(missing.length, 5) * 14 + (geometry2.approximate && approximationLabel ? 14 : 0);
25907
+ const scale = Math.max(
25908
+ 1e-5,
25909
+ Math.min(Math.max(1, area.w - 8) / width, Math.max(1, area.h - reserve) / height)
25910
+ );
25911
+ const dx = area.x + (area.w - width * scale) / 2 - bounds.minX * scale, dy = area.y - bounds.minY * scale;
25912
+ const out = [
25913
+ `<g data-chart-part="regionMap" data-map-geometry="${geometry2.approximate ? "approximate" : "cached"}"${geometry2.approximate ? ' data-map-report="approximate-country-outlines"' : ""}${geometry2.issues.length ? ' data-map-partial="true"' : ""}>`
25914
+ ];
25915
+ out.push(
25916
+ `<svg x="${area.x}" y="${area.y}" width="${area.w}" height="${Math.max(1, area.h - reserve)}" viewBox="${area.x} ${area.y} ${area.w} ${Math.max(1, area.h - reserve)}" overflow="hidden">`
25917
+ );
25918
+ for (const region of geometry2.regions) {
25919
+ const entry = matched.get(region.code);
25920
+ out.push(
25921
+ `<path d="${scalePathD(region.path, scale, dx, dy)}" fill="${esc(options2?.fixedColor ?? (entry ? colors(normalizeValue(entry.value, min, max)) : "#e2e8f0"))}" stroke="${esc(series.stroke?.color ?? "none")}" stroke-width="${series.stroke?.width ?? 0}" fill-rule="evenodd"${entry ? ` data-chart-series="0" data-chart-point="${entry.sourceIndex}"` : ""}><title>${esc(region.name)}${entry ? ": " + esc(formatRegionMapValue(entry.value, options2?.cultureLanguage)) : ""}</title></path>`
25922
+ );
25923
+ const b = regionBounds(region);
25924
+ if (entry && shouldRenderRegionLabel(
25925
+ options2?.regionLabelLayout,
25926
+ (b.maxX - b.minX) * scale,
25927
+ (b.maxY - b.minY) * scale
25928
+ ))
25929
+ out.push(
25930
+ text(region.labelXY[0] * scale + dx, region.labelXY[1] * scale + dy, region.name, {
25931
+ size: 8,
25932
+ anchor: "middle"
25933
+ })
25934
+ );
25935
+ const label = entry && series.labels?.[entry.sourceIndex];
25936
+ if (label)
25937
+ draw(
25938
+ measure3(model, label),
25939
+ label,
25940
+ region.labelXY[0] * scale + dx,
25941
+ region.labelXY[1] * scale + dy,
25942
+ "middle",
25943
+ out
25944
+ );
25945
+ }
25946
+ out.push("</svg>");
25947
+ const y = area.y + height * scale + 5, bar = Math.min(160, area.w * 0.4), left = area.x + (area.w - bar) / 2;
25948
+ if (model.showLegend) {
25949
+ const attrs3 = chartTextAttributes(model, "legend", 16), size = attrs3.size ?? 16;
25950
+ out.push(text(left - 8, y + size * 0.4, series.name, { ...attrs3, anchor: "end" }));
25951
+ for (let i = 0; i < 32; i++)
25952
+ out.push(rect2(left + i * bar / 32, y, bar / 32 + 0.1, 7, colors((i + 0.5) / 32)));
25953
+ out.push(
25954
+ text(left, y + 8 + size, String(min), attrs3),
25955
+ text(left + bar, y + 8 + size, String(max), { ...attrs3, anchor: "end" })
25956
+ );
25957
+ }
25958
+ let row = y + (model.showLegend ? 32 : 0);
25959
+ if (geometry2.approximate && approximationLabel) {
25960
+ out.push(text(area.x, row, approximationLabel, { size: 8 }));
25961
+ row += 14;
25962
+ }
25963
+ for (const entry of missing.slice(0, 5)) {
25964
+ out.push(
25965
+ text(
25966
+ area.x,
25967
+ row,
25968
+ `${entry.label}: ${formatRegionMapValue(entry.value, options2?.cultureLanguage)}`,
25969
+ { size: 9 }
25970
+ )
25971
+ );
25972
+ row += 14;
25973
+ }
25974
+ const credits = [options2?.attribution, ...geometry2.copyright].filter(Boolean).join("; ");
25975
+ if (credits)
25976
+ out.push(
25977
+ `<title>${esc(credits)}</title>`,
25978
+ text(
25979
+ area.x,
25980
+ area.y + area.h - 1,
25981
+ credits.length > 180 ? credits.slice(0, 177) + "..." : credits,
25982
+ { size: 6 }
25983
+ )
25984
+ );
25985
+ return out.join("") + "</g>";
25986
+ }
25987
+
25988
+ // chart/funnel-geometry.ts
25989
+ function computeFunnelGeometry(values, plot, gapWidth = 33) {
25990
+ const max = Math.max(...values.map((v) => Math.abs(v)), 1);
25991
+ const band = plot.height / Math.max(1, values.length);
25992
+ const gap = Number.isFinite(gapWidth) && gapWidth >= 0 ? gapWidth : 33;
25993
+ const height = band / (1 + gap / 100);
25994
+ const inset = (band - height) / 2;
25995
+ const center = plot.x + plot.width / 2;
25996
+ return values.map((value, index) => {
25997
+ const width = Math.abs(value) / max * plot.width;
25998
+ return {
25999
+ index,
26000
+ x: center - width / 2,
26001
+ y: plot.y + index * band + inset,
26002
+ width,
26003
+ height,
26004
+ center
26005
+ };
26006
+ });
26007
+ }
26008
+
26009
+ // chart/render/chart-svg-funnel.ts
26010
+ function funnelSvg(model, area) {
26011
+ const series = model.series[0];
26012
+ if (!series || series.hidden) return "";
26013
+ const attrs3 = chartTextAttributes(model, "categoryAxis", 10);
26014
+ const width = Math.min(
26015
+ area.w * 0.3,
26016
+ Math.max(32, ...model.categories.map((s) => s.length * (attrs3.size ?? 10) * 0.55 + 8))
26017
+ );
26018
+ const plot = { x: area.x + width, y: area.y, width: Math.max(1, area.w - width), height: area.h };
26019
+ const out = [
26020
+ chartAreaRect(model, "plotArea", { x: plot.x, y: plot.y, w: plot.width, h: plot.height })
26021
+ ];
26022
+ for (const bar of computeFunnelGeometry(
26023
+ series.values.map((v) => v ?? 0),
26024
+ plot,
26025
+ model.funnelGapWidth
26026
+ )) {
26027
+ const value = series.values[bar.index];
26028
+ if (value === null || value === void 0) continue;
26029
+ out.push(`<g data-chart-series="${series.sourceIndex ?? 0}" data-chart-point="${bar.index}">`);
26030
+ out.push(
26031
+ rect2(bar.x, bar.y, bar.width, bar.height, series.pointColors?.[bar.index] ?? series.color)
26032
+ );
26033
+ const size = Math.min(10, bar.height * 0.4);
26034
+ const label = series.labels?.[bar.index];
26035
+ if (label)
26036
+ out.push(
26037
+ text(bar.center, bar.y + bar.height / 2 + size * 0.35, label.text, {
26038
+ ...chartTextAttributes(model, "dataLabel", size),
26039
+ size,
26040
+ anchor: "middle"
26041
+ })
26042
+ );
26043
+ out.push(
26044
+ text(
26045
+ plot.x - 8,
26046
+ bar.y + bar.height / 2 + (attrs3.size ?? 10) * 0.35,
26047
+ fit(model.categories[bar.index] ?? "", width - 8, attrs3.size ?? 10),
26048
+ { ...attrs3, anchor: "end" }
26049
+ )
26050
+ );
26051
+ out.push("</g>");
26052
+ }
26053
+ return out.join("");
26054
+ }
26055
+
26056
+ // chart/box-distribution.ts
26057
+ function boxWhiskerDistribution(values, method = "exclusive", trimOutliers = false) {
26058
+ const stats = computeBoxStats(values, method);
26059
+ if (!stats) return void 0;
26060
+ const iqr = stats.q3 - stats.q1;
26061
+ const lowerFence = stats.q1 - 1.5 * iqr;
26062
+ const upperFence = stats.q3 + 1.5 * iqr;
26063
+ const inliers = values.filter((v) => !trimOutliers || v >= lowerFence && v <= upperFence);
26064
+ return {
26065
+ stats,
26066
+ whiskerMin: inliers.length ? Math.min(...inliers) : stats.min,
26067
+ whiskerMax: inliers.length ? Math.max(...inliers) : stats.max,
26068
+ mean: values.reduce((a, b) => a + b, 0) / values.length
26069
+ };
26070
+ }
26071
+ function boxMeanMarkerPath(x, y, radius = 3) {
26072
+ return `M${x - radius},${y - radius} L${x + radius},${y + radius} M${x - radius},${y + radius} L${x + radius},${y - radius}`;
26073
+ }
26074
+
26075
+ // chart/render/chart-svg-box.ts
26076
+ function boxWhiskerSvg(model, frame2, out) {
26077
+ const visible = model.series.filter((s) => !s.hidden);
26078
+ const slot = frame2.bandSize / Math.max(1, visible.length);
26079
+ const width = slot * 0.7;
26080
+ visible.forEach((series, si) => {
26081
+ if (series.hidden) return;
26082
+ const groups = groupRowsByCategory(series.boxCategories ?? []);
26083
+ model.categories.forEach((category, ci) => {
26084
+ const observations = (groups.rowIndexesByCategory.get(category) ?? []).flatMap((row) => {
26085
+ const value = series.values[row];
26086
+ return value === null || value === void 0 ? [] : [{ row, value }];
26087
+ });
26088
+ const options2 = series.boxWhisker;
26089
+ const rawMethod = options2?.statistics?.quartileMethod;
26090
+ const method = rawMethod === "inclusive" ? "inclusive" : "exclusive";
26091
+ const visibility = options2?.visibility;
26092
+ const trim = rawMethod === "inclusive" || rawMethod === "exclusive" || !!visibility && Object.values(visibility).some((v) => v !== void 0);
26093
+ const distribution = boxWhiskerDistribution(
26094
+ observations.map((p) => p.value),
26095
+ method,
26096
+ trim
26097
+ );
26098
+ if (!distribution) return;
26099
+ const { stats, whiskerMin, whiskerMax, mean } = distribution;
26100
+ const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot + (slot - width) / 2;
26101
+ const mid = x + width / 2;
26102
+ const y = frame2.value;
26103
+ out.push(
26104
+ `<g data-chart-part="box" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${ci}">`
26105
+ );
26106
+ out.push(line2(mid, y(whiskerMax), mid, y(stats.q3), "#64748b", 1));
26107
+ out.push(line2(mid, y(stats.q1), mid, y(whiskerMin), "#64748b", 1));
26108
+ out.push(
26109
+ line2(x + width * 0.25, y(whiskerMin), x + width * 0.75, y(whiskerMin), "#64748b", 1)
26110
+ );
26111
+ out.push(
26112
+ line2(x + width * 0.25, y(whiskerMax), x + width * 0.75, y(whiskerMax), "#64748b", 1)
26113
+ );
26114
+ out.push(
26115
+ rect2(
26116
+ x,
26117
+ Math.min(y(stats.q1), y(stats.q3)),
26118
+ width,
26119
+ Math.abs(y(stats.q1) - y(stats.q3)),
26120
+ series.pointColors?.[ci] ?? series.color
26121
+ )
26122
+ );
26123
+ out.push(line2(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
26124
+ if (visibility?.meanLine) out.push(line2(x, y(mean), x + width, y(mean), "#0f766e", 1.5));
26125
+ if (visibility?.meanMarker !== false)
26126
+ out.push(
26127
+ `<path d="${boxMeanMarkerPath(mid, y(mean))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
26128
+ );
26129
+ observations.forEach((point, index) => {
26130
+ const outlier = point.value < whiskerMin || point.value > whiskerMax;
26131
+ if (outlier ? !visibility?.outliers : !visibility?.nonoutliers) return;
26132
+ const px = x + width * (0.2 + 0.6 * (index + 1) / (observations.length + 1));
26133
+ out.push(
26134
+ `<circle cx="${n(px)}" cy="${n(y(point.value))}" r="2.25" fill="${outlier ? "#dc2626" : "#1e293b"}" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${point.row}" data-chart-part="${outlier ? "outlier" : "observation"}"/>`
26135
+ );
26136
+ });
26137
+ out.push("</g>");
26138
+ });
26139
+ });
26140
+ }
26141
+
24174
26142
  // chart/render/chart-svg-xy.ts
24175
26143
  function scatter(model, area, out, size) {
24176
26144
  const ys = model.valueAxis;
@@ -24733,26 +26701,26 @@ function sunburstSvg(model, area) {
24733
26701
 
24734
26702
  // chart/render/chart-svg-text-metrics.ts
24735
26703
  var CHART_FONT_FAMILY = "Calibri, Carlito, Arial, sans-serif";
24736
- function cssFont(attrs2) {
24737
- return `${attrs2.italic ? "italic" : "normal"} ${attrs2.weight ?? "normal"} ${attrs2.size ?? 10}px ${attrs2.family ?? CHART_FONT_FAMILY}`;
26704
+ function cssFont(attrs3) {
26705
+ return `${attrs3.italic ? "italic" : "normal"} ${attrs3.weight ?? "normal"} ${attrs3.size ?? 10}px ${attrs3.family ?? CHART_FONT_FAMILY}`;
24738
26706
  }
24739
- function chartFontMetrics(attrs2, options2) {
24740
- const metrics = options2.measureFont?.(cssFont(attrs2));
26707
+ function chartFontMetrics(attrs3, options2) {
26708
+ const metrics = options2.measureFont?.(cssFont(attrs3));
24741
26709
  return metrics && Number.isFinite(metrics.ascent) && Number.isFinite(metrics.descent) && metrics.ascent >= 0 && metrics.descent >= 0 && metrics.ascent + metrics.descent > 0 ? metrics : void 0;
24742
26710
  }
24743
- function chartTextWidth(content, attrs2, options2) {
24744
- const width = options2.measureText?.(content, cssFont(attrs2));
24745
- return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content, attrs2.size);
26711
+ function chartTextWidth(content, attrs3, options2) {
26712
+ const width = options2.measureText?.(content, cssFont(attrs3));
26713
+ return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content, attrs3.size);
24746
26714
  }
24747
- function fitChartText(content, maxWidth, attrs2, options2) {
24748
- if (!options2.measureText) return fit(content, maxWidth, attrs2.size);
24749
- if (chartTextWidth(content, attrs2, options2) <= maxWidth) return content;
26715
+ function fitChartText(content, maxWidth, attrs3, options2) {
26716
+ if (!options2.measureText) return fit(content, maxWidth, attrs3.size);
26717
+ if (chartTextWidth(content, attrs3, options2) <= maxWidth) return content;
24750
26718
  const points = [...content];
24751
26719
  let low = 0;
24752
26720
  let high = points.length;
24753
26721
  while (low < high) {
24754
26722
  const mid = Math.ceil((low + high) / 2);
24755
- if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs2, options2) <= maxWidth) low = mid;
26723
+ if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs3, options2) <= maxWidth) low = mid;
24756
26724
  else high = mid - 1;
24757
26725
  }
24758
26726
  return `${points.slice(0, low).join("")}\u2026`;
@@ -24774,13 +26742,13 @@ function chartLegendSvg(model, area, frame2, options2) {
24774
26742
  });
24775
26743
  if (!manual) return { plot, markup: automatic.join(""), foreground: !!model.legendOverlay };
24776
26744
  const entries = legendEntries(model);
24777
- const attrs2 = chartTextAttributes(model, "legend");
24778
- const size = attrs2.size ?? 10;
24779
- const font = chartFontMetrics(attrs2, options2);
26745
+ const attrs3 = chartTextAttributes(model, "legend");
26746
+ const size = attrs3.size ?? 10;
26747
+ const font = chartFontMetrics(attrs3, options2);
24780
26748
  const keySize = size / 2;
24781
26749
  const keyGap = size / 4;
24782
26750
  const widths = entries.map(
24783
- (entry) => chartTextWidth(entry.label, attrs2, options2) + keySize + keyGap
26751
+ (entry) => chartTextWidth(entry.label, attrs3, options2) + keySize + keyGap
24784
26752
  );
24785
26753
  const horizontal = manual.width > manual.height && widths.reduce((sum, width) => sum + width, 0) + size <= manual.width;
24786
26754
  const rowWidth = horizontal ? manual.width / entries.length : manual.width;
@@ -24796,13 +26764,13 @@ function chartLegendSvg(model, area, frame2, options2) {
24796
26764
  const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
24797
26765
  const widest = extentOf(widths).max;
24798
26766
  entries.forEach((entry, i) => {
24799
- const available = horizontal ? chartTextWidth(entry.label, attrs2, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
24800
- const label = fitChartText(entry.label, available, attrs2, options2);
26767
+ const available = horizontal ? chartTextWidth(entry.label, attrs3, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
26768
+ const label = fitChartText(entry.label, available, attrs3, options2);
24801
26769
  const contentWidth = Math.min(horizontal ? widths[i] ?? 0 : widest, rowWidth - size / 2);
24802
26770
  const x = horizontal ? horizontalX : manual.x + Math.max(size / 4, (rowWidth - contentWidth) / 2);
24803
26771
  const centerY = manual.y + (horizontal ? 0 : i * rowHeight) + rowHeight / 2;
24804
26772
  markup.push(rect2(x, centerY - keySize / 2, keySize, keySize, entry.color));
24805
- markup.push(text(x + keySize + keyGap, centerY + baselineOffset, label, attrs2));
26773
+ markup.push(text(x + keySize + keyGap, centerY + baselineOffset, label, attrs3));
24806
26774
  if (horizontal) horizontalX += (widths[i] ?? 0) + horizontalGap;
24807
26775
  });
24808
26776
  return {
@@ -24841,12 +26809,12 @@ function automaticLegend(model, area, out, options2, bounds) {
24841
26809
  const entries = legendEntries(model);
24842
26810
  if (!model.showLegend || entries.length === 0) return area;
24843
26811
  const pos = model.legendPosition;
24844
- const attrs2 = chartTextAttributes(model, "legend");
24845
- const size = attrs2.size ?? 10;
26812
+ const attrs3 = chartTextAttributes(model, "legend");
26813
+ const size = attrs3.size ?? 10;
24846
26814
  const rowH = Math.max(16, size * 1.4);
24847
26815
  if (pos === "t" || pos === "b") {
24848
26816
  const widths = entries.map(
24849
- (e) => Math.min(chartTextWidth(e.label, attrs2, options2) + 20, area.w / 2)
26817
+ (e) => Math.min(chartTextWidth(e.label, attrs3, options2) + 20, area.w / 2)
24850
26818
  );
24851
26819
  const total = widths.reduce((a, b) => a + b, 0);
24852
26820
  let x2 = area.x + Math.max(0, (area.w - total) / 2);
@@ -24863,14 +26831,14 @@ function automaticLegend(model, area, out, options2, bounds) {
24863
26831
  entries.forEach((e, i) => {
24864
26832
  const w = widths[i] ?? 0;
24865
26833
  out.push(rect2(x2, y, 8, 8, e.color));
24866
- out.push(text(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs2, options2), attrs2));
26834
+ out.push(text(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs3, options2), attrs3));
24867
26835
  x2 += w;
24868
26836
  });
24869
26837
  return pos === "t" ? { x: area.x, y: area.y + rowH + 4, w: area.w, h: area.h - rowH - 4 } : { x: area.x, y: area.y, w: area.w, h: area.h - rowH - 4 };
24870
26838
  }
24871
26839
  const width = Math.min(
24872
26840
  area.w * 0.35,
24873
- extentOf(entries.map((e) => chartTextWidth(e.label, attrs2, options2))).max + 22
26841
+ extentOf(entries.map((e) => chartTextWidth(e.label, attrs3, options2))).max + 22
24874
26842
  );
24875
26843
  const height = entries.length * rowH;
24876
26844
  const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
@@ -24888,7 +26856,7 @@ function automaticLegend(model, area, out, options2, bounds) {
24888
26856
  const y = y0 + i * rowH;
24889
26857
  if (y + rowH > area.y + area.h + 2) return;
24890
26858
  out.push(rect2(x, y + 3, 8, 8, e.color));
24891
- out.push(text(x + 12, y + 11, fitChartText(e.label, width - 16, attrs2, options2), attrs2));
26859
+ out.push(text(x + 12, y + 11, fitChartText(e.label, width - 16, attrs3, options2), attrs3));
24892
26860
  });
24893
26861
  return pos === "l" ? { x: area.x + width + 8, y: area.y, w: area.w - width - 8, h: area.h } : { x: area.x, y: area.y, w: area.w - width - 8, h: area.h };
24894
26862
  }
@@ -24922,11 +26890,11 @@ function wrapStyledRuns(runs, maxWidth, measure4, options2 = {}) {
24922
26890
  return sum + (Number.isFinite(advance) && advance >= 0 ? advance : 0);
24923
26891
  }, 0);
24924
26892
  const result = [];
24925
- let line3 = [];
26893
+ let line4 = [];
24926
26894
  let spaces = [];
24927
26895
  const flush = () => {
24928
- result.push(line3.map((piece) => ({ ...piece.run, text: piece.text })));
24929
- line3 = [];
26896
+ result.push(line4.map((piece) => ({ ...piece.run, text: piece.text })));
26897
+ line4 = [];
24930
26898
  spaces = [];
24931
26899
  };
24932
26900
  for (const group2 of groups) {
@@ -24938,20 +26906,20 @@ function wrapStyledRuns(runs, maxWidth, measure4, options2 = {}) {
24938
26906
  spaces = group2.pieces;
24939
26907
  continue;
24940
26908
  }
24941
- const separator = line3.length ? spaces : [];
26909
+ const separator = line4.length ? spaces : [];
24942
26910
  const wordWidth = width(group2.pieces);
24943
- if (line3.length && width(merged(line3, [...separator, ...group2.pieces])) > maxWidth) flush();
24944
- else line3 = merged(line3, separator);
26911
+ if (line4.length && width(merged(line4, [...separator, ...group2.pieces])) > maxWidth) flush();
26912
+ else line4 = merged(line4, separator);
24945
26913
  spaces = [];
24946
26914
  if (options2.breakWords && wordWidth > maxWidth) {
24947
26915
  for (const piece of group2.pieces) {
24948
26916
  for (const { segment: segment2 } of graphemes.segment(piece.text)) {
24949
26917
  const next = { ...piece, text: segment2 };
24950
- if (line3.length && width(merged(line3, [next])) > maxWidth) flush();
24951
- line3 = merged(line3, [next]);
26918
+ if (line4.length && width(merged(line4, [next])) > maxWidth) flush();
26919
+ line4 = merged(line4, [next]);
24952
26920
  }
24953
26921
  }
24954
- } else line3 = merged(line3, group2.pieces);
26922
+ } else line4 = merged(line4, group2.pieces);
24955
26923
  }
24956
26924
  flush();
24957
26925
  return result;
@@ -24974,25 +26942,25 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
24974
26942
  ];
24975
26943
  const hardLines = [];
24976
26944
  for (const paragraph of paragraphs) {
24977
- let line3 = {
26945
+ let line4 = {
24978
26946
  ...paragraph,
24979
26947
  runs: []
24980
26948
  };
24981
- hardLines.push(line3);
26949
+ hardLines.push(line4);
24982
26950
  for (const run of paragraph.runs) {
24983
26951
  const pieces = run.text.split("\n");
24984
26952
  for (const [index, piece] of pieces.entries()) {
24985
26953
  if (index) {
24986
- line3 = { ...paragraph, runs: [] };
24987
- hardLines.push(line3);
26954
+ line4 = { ...paragraph, runs: [] };
26955
+ hardLines.push(line4);
24988
26956
  }
24989
- if (piece) line3.runs.push({ ...run, text: piece });
26957
+ if (piece) line4.runs.push({ ...run, text: piece });
24990
26958
  }
24991
26959
  }
24992
26960
  }
24993
- const lines = hardLines.flatMap((line3) => {
26961
+ const lines = hardLines.flatMap((line4) => {
24994
26962
  const wrapped = wrapStyledRuns(
24995
- line3.runs,
26963
+ line4.runs,
24996
26964
  capacity,
24997
26965
  (content, run) => chartTextWidth(
24998
26966
  content,
@@ -25005,7 +26973,7 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
25005
26973
  ),
25006
26974
  { breakWords: true }
25007
26975
  );
25008
- const { spaceBefore, spaceAfter, ...properties3 } = line3;
26976
+ const { spaceBefore, spaceAfter, ...properties3 } = line4;
25009
26977
  return wrapped.map((runs, index) => ({
25010
26978
  ...properties3,
25011
26979
  runs,
@@ -25013,8 +26981,8 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
25013
26981
  ...index === wrapped.length - 1 && spaceAfter ? { spaceAfter } : {}
25014
26982
  }));
25015
26983
  });
25016
- const metrics = lines.map((line3) => {
25017
- const runs = line3.runs.map((run) => ({
26984
+ const metrics = lines.map((line4) => {
26985
+ const runs = line4.runs.map((run) => ({
25018
26986
  ...run,
25019
26987
  attrs: chartTextAttributes(
25020
26988
  { ...model, appearance: { title: run.appearance } },
@@ -25023,43 +26991,43 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
25023
26991
  )
25024
26992
  }));
25025
26993
  return {
25026
- ...line3,
26994
+ ...line4,
25027
26995
  runs,
25028
26996
  width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs, options2), 0),
25029
26997
  size: runs.length ? Math.max(...runs.map((run) => run.attrs.size ?? 14)) : base.size ?? 14,
25030
26998
  fontMetrics: (runs.length ? runs.map((run) => run.attrs) : [base]).map(
25031
- (attrs2) => chartFontMetrics(attrs2, options2)
26999
+ (attrs3) => chartFontMetrics(attrs3, options2)
25032
27000
  )
25033
27001
  };
25034
27002
  });
25035
- const measured = metrics.every((line3) => line3.fontMetrics.every((font) => font !== void 0));
25036
- const vertical = metrics.map((line3) => {
25037
- const ascent = measured ? Math.max(...line3.fontMetrics.map((font) => font.ascent)) : line3.size;
25038
- const descent = measured ? Math.max(...line3.fontMetrics.map((font) => font.descent)) : line3.size * 0.4 + 4;
27003
+ const measured = metrics.every((line4) => line4.fontMetrics.every((font) => font !== void 0));
27004
+ const vertical = metrics.map((line4) => {
27005
+ const ascent = measured ? Math.max(...line4.fontMetrics.map((font) => font.ascent)) : line4.size;
27006
+ const descent = measured ? Math.max(...line4.fontMetrics.map((font) => font.descent)) : line4.size * 0.4 + 4;
25039
27007
  const natural = ascent + descent;
25040
- const height2 = spacing(line3.lineSpacing, natural, natural);
27008
+ const height2 = spacing(line4.lineSpacing, natural, natural);
25041
27009
  const leading = (height2 - natural) / 2;
25042
27010
  return {
25043
27011
  ascent: ascent + leading,
25044
27012
  descent: descent + leading,
25045
27013
  height: height2,
25046
- before: spacing(line3.spaceBefore, natural, 0),
25047
- after: spacing(line3.spaceAfter, natural, 0),
27014
+ before: spacing(line4.spaceBefore, natural, 0),
27015
+ after: spacing(line4.spaceAfter, natural, 0),
25048
27016
  leading
25049
27017
  };
25050
27018
  });
25051
- const boxWidth = Math.min(width - 16, Math.max(0, ...metrics.map((line3) => line3.width)) + 8);
27019
+ const boxWidth = Math.min(width - 16, Math.max(0, ...metrics.map((line4) => line4.width)) + 8);
25052
27020
  const height = vertical.reduce(
25053
- (sum, line3) => sum + line3.height + line3.before + line3.after,
27021
+ (sum, line4) => sum + line4.height + line4.before + line4.after,
25054
27022
  measured ? 4 : 0
25055
27023
  );
25056
27024
  let baseline = 8 + (metrics[0]?.size ?? base.size ?? 14) + (vertical[0]?.before ?? 0) + (vertical[0]?.leading ?? 0);
25057
27025
  const spans = [];
25058
- for (const [index, line3] of metrics.entries()) {
27026
+ for (const [index, line4] of metrics.entries()) {
25059
27027
  if (index)
25060
27028
  baseline += vertical[index - 1].descent + vertical[index - 1].after + vertical[index].before + vertical[index].ascent;
25061
- let x = line3.align === "l" ? (width - boxWidth) / 2 + 4 : line3.align === "r" ? (width + boxWidth) / 2 - 4 - line3.width : (width - line3.width) / 2;
25062
- for (const run of line3.runs) {
27029
+ let x = line4.align === "l" ? (width - boxWidth) / 2 + 4 : line4.align === "r" ? (width + boxWidth) / 2 - 4 - line4.width : (width - line4.width) / 2;
27030
+ for (const run of line4.runs) {
25063
27031
  spans.push(
25064
27032
  text(x, baseline, run.text, {
25065
27033
  ...run.attrs,
@@ -25113,11 +27081,11 @@ function renderChartSvg(model, width, height, options2 = {}) {
25113
27081
  if (!model.titleOverlay)
25114
27082
  area = { ...area, y: area.y + richTitle.height, h: area.h - richTitle.height };
25115
27083
  } else if (model.title) {
25116
- const attrs2 = chartTextAttributes(model, "title", 14);
25117
- const size = attrs2.size ?? 14;
25118
- const label = fitChartText(model.title, w - 16, attrs2, options2);
25119
- const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs2, options2) + 8);
25120
- const font = chartFontMetrics(attrs2, options2);
27084
+ const attrs3 = chartTextAttributes(model, "title", 14);
27085
+ const size = attrs3.size ?? 14;
27086
+ const label = fitChartText(model.title, w - 16, attrs3, options2);
27087
+ const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs3, options2) + 8);
27088
+ const font = chartFontMetrics(attrs3, options2);
25121
27089
  const titleHeight = Math.max(24, font ? font.ascent + font.descent + 4 : size * 1.4 + 4);
25122
27090
  out.push(
25123
27091
  chartAreaRect(model, "title", {
@@ -25131,7 +27099,7 @@ function renderChartSvg(model, width, height, options2 = {}) {
25131
27099
  text(w / 2, 8 + size, label, {
25132
27100
  anchor: "middle",
25133
27101
  fill: "#404040",
25134
- ...attrs2
27102
+ ...attrs3
25135
27103
  })
25136
27104
  );
25137
27105
  if (!model.titleOverlay)
@@ -25145,11 +27113,14 @@ function renderChartSvg(model, width, height, options2 = {}) {
25145
27113
  out.push("</svg>");
25146
27114
  return out.join("");
25147
27115
  }
25148
- const legend = chartLegendSvg(model, area, { width: w, height: h }, options2);
27116
+ const legend = model.type === "regionMap" ? { plot: area, foreground: false, markup: "" } : chartLegendSvg(model, area, { width: w, height: h }, options2);
25149
27117
  area = legend.plot;
25150
27118
  if (!legend.foreground) out.push(legend.markup);
25151
27119
  if (area.w > 4 && area.h > 4) {
25152
- if (model.type === "pie" || model.type === "doughnut") out.push(pieSvg(model, area));
27120
+ if (chart3DApplies(model)) out.push(chart3DSvg(model, area));
27121
+ else if (model.type === "regionMap")
27122
+ out.push(regionMapSvg(model, area, options2.mapApproximationLabel));
27123
+ else if (model.type === "pie" || model.type === "doughnut") out.push(pieSvg(model, area));
25153
27124
  else if (model.type === "funnel") out.push(funnelSvg(model, area));
25154
27125
  else if (model.type === "radar") out.push(radarSvg(model, area));
25155
27126
  else if (model.type === "treemap") out.push(treemapSvg(model, area));
@@ -25179,6 +27150,7 @@ var DRAWN_CHART_TYPES = /* @__PURE__ */ new Set([
25179
27150
  "treemap",
25180
27151
  "sunburst",
25181
27152
  "funnel",
27153
+ "regionMap",
25182
27154
  "boxWhisker"
25183
27155
  ]);
25184
27156
  function chartThemePalette(theme, fonts = {}) {
@@ -25193,7 +27165,8 @@ function chartThemePalette(theme, fonts = {}) {
25193
27165
  function chartSpaceKind(space) {
25194
27166
  if (!space.plotArea.groups.length) return { drawn: false };
25195
27167
  const type = chartSummaryFromSpace(space).chartType;
25196
- return { type, drawn: DRAWN_CHART_TYPES.has(type) };
27168
+ const summary3D = type === "surface" && chartSummaryFromSpace(space).view3D !== void 0;
27169
+ return { type, drawn: DRAWN_CHART_TYPES.has(type) || summary3D };
25197
27170
  }
25198
27171
  function renderChartSpaceSvg(space, options2) {
25199
27172
  const { width, height, theme, fonts, formatting: formatting2, colorPalette, styleDefinition, ...svg } = options2;
@@ -25252,7 +27225,7 @@ var add2 = (parent, ...items) => {
25252
27225
  };
25253
27226
  var emu2 = (px) => String(Math.max(1, Math.round(px * EMU_PER_PIXEL)));
25254
27227
  var emuOffset = (px) => String(Math.round(px * EMU_PER_PIXEL));
25255
- var attrs = (element3, values) => {
27228
+ var attrs2 = (element3, values) => {
25256
27229
  for (const [name, value] of Object.entries(values)) element3.setAttribute(name, value);
25257
27230
  return element3;
25258
27231
  };
@@ -25280,13 +27253,13 @@ function explicitTextColor(spec) {
25280
27253
  return light ? "000000" : void 0;
25281
27254
  }
25282
27255
  function textParagraphs(doc, lines, color) {
25283
- return lines.map((line3) => {
27256
+ return lines.map((line4) => {
25284
27257
  const paragraph = makeW(doc, "p");
25285
27258
  const props = makeW(doc, "pPr");
25286
27259
  const jc = makeW(doc, "jc");
25287
27260
  jc.setAttributeNS(W_NS2, "w:val", "center");
25288
27261
  add2(paragraph, add2(props, jc));
25289
- if (line3) {
27262
+ if (line4) {
25290
27263
  const run = makeW(doc, "r");
25291
27264
  if (color) {
25292
27265
  const rPr = makeW(doc, "rPr");
@@ -25295,19 +27268,19 @@ function textParagraphs(doc, lines, color) {
25295
27268
  add2(run, add2(rPr, c));
25296
27269
  }
25297
27270
  const t = makeW(doc, "t");
25298
- if (/^\s|\s$/.test(line3))
27271
+ if (/^\s|\s$/.test(line4))
25299
27272
  t.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
25300
- t.textContent = line3;
27273
+ t.textContent = line4;
25301
27274
  add2(paragraph, add2(run, t));
25302
27275
  }
25303
27276
  return paragraph;
25304
27277
  });
25305
27278
  }
25306
27279
  function shapeStyle(doc) {
25307
- const ref = (name, idx, scheme2, shade) => {
25308
- const node = attrs(el2(doc, A_NS2, `a:${name}`), { idx });
25309
- const color = attrs(el2(doc, A_NS2, "a:schemeClr"), { val: scheme2 });
25310
- if (shade) add2(color, attrs(el2(doc, A_NS2, "a:shade"), { val: shade }));
27280
+ const ref = (name, idx, scheme2, shade2) => {
27281
+ const node = attrs2(el2(doc, A_NS2, `a:${name}`), { idx });
27282
+ const color = attrs2(el2(doc, A_NS2, "a:schemeClr"), { val: scheme2 });
27283
+ if (shade2) add2(color, attrs2(el2(doc, A_NS2, "a:shade"), { val: shade2 }));
25311
27284
  return add2(node, color);
25312
27285
  };
25313
27286
  return add2(
@@ -25321,17 +27294,17 @@ function shapeStyle(doc) {
25321
27294
  function wrapElement(doc, placement) {
25322
27295
  switch (placement.wrap) {
25323
27296
  case "square":
25324
- return attrs(el2(doc, WP_NS2, "wp:wrapSquare"), { wrapText: "bothSides" });
27297
+ return attrs2(el2(doc, WP_NS2, "wp:wrapSquare"), { wrapText: "bothSides" });
25325
27298
  case "tight":
25326
27299
  case "through": {
25327
- const wrap = attrs(
27300
+ const wrap = attrs2(
25328
27301
  el2(doc, WP_NS2, `wp:wrap${placement.wrap === "tight" ? "Tight" : "Through"}`),
25329
27302
  {
25330
27303
  wrapText: "bothSides"
25331
27304
  }
25332
27305
  );
25333
- const polygon = attrs(el2(doc, WP_NS2, "wp:wrapPolygon"), { edited: "0" });
25334
- const point = (name, x, y) => attrs(el2(doc, WP_NS2, `wp:${name}`), { x, y });
27306
+ const polygon = attrs2(el2(doc, WP_NS2, "wp:wrapPolygon"), { edited: "0" });
27307
+ const point = (name, x, y) => attrs2(el2(doc, WP_NS2, `wp:${name}`), { x, y });
25335
27308
  return add2(
25336
27309
  wrap,
25337
27310
  add2(
@@ -25351,7 +27324,7 @@ function wrapElement(doc, placement) {
25351
27324
  }
25352
27325
  }
25353
27326
  function position(doc, axis, relativeFrom, align, offsetPx) {
25354
- const node = attrs(el2(doc, WP_NS2, `wp:position${axis}`), { relativeFrom });
27327
+ const node = attrs2(el2(doc, WP_NS2, `wp:position${axis}`), { relativeFrom });
25355
27328
  if (align) {
25356
27329
  const a = el2(doc, WP_NS2, "wp:align");
25357
27330
  a.textContent = align;
@@ -25362,10 +27335,10 @@ function position(doc, axis, relativeFrom, align, offsetPx) {
25362
27335
  return add2(node, offset);
25363
27336
  }
25364
27337
  function geometry(doc, spec) {
25365
- const prst = attrs(el2(doc, A_NS2, "a:prstGeom"), { prst: spec.preset });
27338
+ const prst = attrs2(el2(doc, A_NS2, "a:prstGeom"), { prst: spec.preset });
25366
27339
  const avLst = el2(doc, A_NS2, "a:avLst");
25367
27340
  for (const [name, value] of Object.entries(spec.adjustments ?? {}))
25368
- add2(avLst, attrs(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
27341
+ add2(avLst, attrs2(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
25369
27342
  const nodes = spec.customGeometryXml ? importFragment(doc, spec.customGeometryXml) : [add2(prst, avLst)];
25370
27343
  if (spec.fill) {
25371
27344
  const xml = drawingFillXml(spec.fill);
@@ -25381,7 +27354,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
25381
27354
  const anchored = Boolean(image.anchored);
25382
27355
  const holder = el2(doc, WP_NS2, anchored ? "wp:anchor" : "wp:inline");
25383
27356
  if (anchored) {
25384
- attrs(holder, {
27357
+ attrs2(holder, {
25385
27358
  distT: "0",
25386
27359
  distB: "0",
25387
27360
  distL: "114300",
@@ -25395,7 +27368,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
25395
27368
  });
25396
27369
  add2(
25397
27370
  holder,
25398
- attrs(el2(doc, WP_NS2, "wp:simplePos"), { x: "0", y: "0" }),
27371
+ attrs2(el2(doc, WP_NS2, "wp:simplePos"), { x: "0", y: "0" }),
25399
27372
  position(
25400
27373
  doc,
25401
27374
  "H",
@@ -25414,24 +27387,24 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
25414
27387
  } else for (const side of ["distT", "distB", "distL", "distR"]) holder.setAttribute(side, "0");
25415
27388
  add2(
25416
27389
  holder,
25417
- attrs(el2(doc, WP_NS2, "wp:extent"), { cx: emu2(image.widthPx), cy: emu2(image.heightPx) }),
25418
- attrs(el2(doc, WP_NS2, "wp:effectExtent"), { l: "0", t: "0", r: "0", b: "0" })
27390
+ attrs2(el2(doc, WP_NS2, "wp:extent"), { cx: emu2(image.widthPx), cy: emu2(image.heightPx) }),
27391
+ attrs2(el2(doc, WP_NS2, "wp:effectExtent"), { l: "0", t: "0", r: "0", b: "0" })
25419
27392
  );
25420
27393
  if (anchored) add2(holder, wrapElement(doc, placement ?? { wrap: "none" }));
25421
- const docPr = attrs(el2(doc, WP_NS2, "wp:docPr"), {
27394
+ const docPr = attrs2(el2(doc, WP_NS2, "wp:docPr"), {
25422
27395
  id: identity.id,
25423
27396
  name: identity.name ?? `Shape ${identity.id}`
25424
27397
  });
25425
27398
  if (identity.descr) docPr.setAttribute("descr", identity.descr);
25426
27399
  if (identity.title) docPr.setAttribute("title", identity.title);
25427
- const xfrm = attrs(el2(doc, A_NS2, "a:xfrm"), {});
27400
+ const xfrm = attrs2(el2(doc, A_NS2, "a:xfrm"), {});
25428
27401
  if (spec.rotation) xfrm.setAttribute("rot", String(Math.round(spec.rotation * 6e4)));
25429
27402
  if (spec.flipH) xfrm.setAttribute("flipH", "1");
25430
27403
  if (spec.flipV) xfrm.setAttribute("flipV", "1");
25431
27404
  add2(
25432
27405
  xfrm,
25433
- attrs(el2(doc, A_NS2, "a:off"), { x: "0", y: "0" }),
25434
- attrs(el2(doc, A_NS2, "a:ext"), { cx: emu2(image.widthPx), cy: emu2(image.heightPx) })
27406
+ attrs2(el2(doc, A_NS2, "a:off"), { x: "0", y: "0" }),
27407
+ attrs2(el2(doc, A_NS2, "a:ext"), { cx: emu2(image.widthPx), cy: emu2(image.heightPx) })
25435
27408
  );
25436
27409
  const spPr = add2(el2(doc, WPS_NS2, "wps:spPr"), xfrm, ...geometry(doc, spec));
25437
27410
  const wsp = add2(
@@ -25447,7 +27420,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
25447
27420
  );
25448
27421
  add2(wsp, add2(el2(doc, WPS_NS2, "wps:txbx"), content));
25449
27422
  }
25450
- const body = attrs(el2(doc, WPS_NS2, "wps:bodyPr"), {
27423
+ const body = attrs2(el2(doc, WPS_NS2, "wps:bodyPr"), {
25451
27424
  rot: "0",
25452
27425
  vert: "horz",
25453
27426
  wrap: "square",
@@ -25459,7 +27432,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
25459
27432
  anchorCtr: "0"
25460
27433
  });
25461
27434
  add2(wsp, add2(body, el2(doc, A_NS2, "a:noAutofit")));
25462
- const graphicData = attrs(el2(doc, A_NS2, "a:graphicData"), { uri: WPS_NS2 });
27435
+ const graphicData = attrs2(el2(doc, A_NS2, "a:graphicData"), { uri: WPS_NS2 });
25463
27436
  add2(
25464
27437
  holder,
25465
27438
  docPr,
@@ -25585,8 +27558,8 @@ function chartRun(doc, node, image, base, oldDrawing, oldContainer, allocator) {
25585
27558
 
25586
27559
  // docx/write-fallback.ts
25587
27560
  var PT_PER_PX2 = 0.75;
25588
- function setStyleSize(style, name, pt) {
25589
- const value = `${Math.round(pt * 100) / 100}pt`;
27561
+ function setStyleSize(style, name, pt2) {
27562
+ const value = `${Math.round(pt2 * 100) / 100}pt`;
25590
27563
  const pattern = new RegExp(`(^|;)\\s*${name}\\s*:\\s*[^;]*`, "i");
25591
27564
  return pattern.test(style) ? style.replace(pattern, (_all, lead) => `${lead}${name}:${value}`) : style;
25592
27565
  }
@@ -25644,6 +27617,10 @@ function diagramRun(doc, node, image, base, oldDrawing, oldContainer, allocator)
25644
27617
  }
25645
27618
  return void 0;
25646
27619
  }
27620
+
27621
+ // docx/write-drawing.ts
27622
+ var A_NS6 = "http://schemas.openxmlformats.org/drawingml/2006/main";
27623
+ var PIC_NS = "http://schemas.openxmlformats.org/drawingml/2006/picture";
25647
27624
  function alternateContentDrawing(content) {
25648
27625
  const choice = Array.from(content.childNodes).filter(isElement).find((node) => node.localName === "Choice");
25649
27626
  return choice && findDrawingChild(choice);
@@ -25720,6 +27697,16 @@ function createImageRun(doc, image, base, old, allocator) {
25720
27697
  throw new Error("Cannot insert a text box without an id allocator.");
25721
27698
  }
25722
27699
  if (base && oldDrawing && sameUnderlyingImage(base, image)) {
27700
+ if (image.pictureFill && JSON.stringify(image.pictureFill) !== JSON.stringify(base.pictureFill)) {
27701
+ const fill = oldDrawing.getElementsByTagNameNS(PIC_NS, "blipFill")[0];
27702
+ const blip = fill?.getElementsByTagNameNS(A_NS6, "blip")[0];
27703
+ if (fill && image.pictureFill.crop !== void 0)
27704
+ applyPictureCrop(fill, image.pictureFill.crop);
27705
+ if (blip && image.pictureFill.effects !== void 0)
27706
+ applyPictureEffects(blip, image.pictureFill.effects);
27707
+ if (fill && image.pictureFill.layout !== void 0)
27708
+ applyPictureLayout(fill, image.pictureFill.layout);
27709
+ }
25723
27710
  if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
25724
27711
  updateExtent(oldDrawing, image.widthPx, image.heightPx);
25725
27712
  if (image.altText !== base.altText || image.title !== base.title)
@@ -26437,9 +28424,9 @@ function parseShadingThemeFill(shd) {
26437
28424
  if (!theme) return void 0;
26438
28425
  const ref = { token: theme };
26439
28426
  const tint = parseTintShade(getW(shd, "themeFillTint"));
26440
- const shade = parseTintShade(getW(shd, "themeFillShade"));
28427
+ const shade2 = parseTintShade(getW(shd, "themeFillShade"));
26441
28428
  if (tint !== void 0) ref.tint = tint;
26442
- if (shade !== void 0) ref.shade = shade;
28429
+ if (shade2 !== void 0) ref.shade = shade2;
26443
28430
  return ref;
26444
28431
  }
26445
28432
  function parseParagraphBorders(pBdr) {
@@ -26522,8 +28509,8 @@ function parseFormatting(pPr) {
26522
28509
  const value = enabled(first2(pPr, key));
26523
28510
  if (value !== void 0) result[key] = value;
26524
28511
  }
26525
- const outline2 = parseOutlineLevel(first2(pPr, "outlineLvl"));
26526
- if (outline2 !== void 0) result.outlineLevel = outline2;
28512
+ const outline3 = parseOutlineLevel(first2(pPr, "outlineLvl"));
28513
+ if (outline3 !== void 0) result.outlineLevel = outline3;
26527
28514
  const borders = parseParagraphBorders(first2(pPr, "pBdr"));
26528
28515
  if (borders) result.borders = borders;
26529
28516
  const shading = parseShadingFill(first2(pPr, "shd"));
@@ -26531,17 +28518,17 @@ function parseFormatting(pPr) {
26531
28518
  const spacing2 = first2(pPr, "spacing");
26532
28519
  const before = twipValue(getW(spacing2, "before"));
26533
28520
  const after = twipValue(getW(spacing2, "after"));
26534
- const line3 = signedTwipValue(getW(spacing2, "line"));
28521
+ const line4 = signedTwipValue(getW(spacing2, "line"));
26535
28522
  if (before !== void 0) result.spacingBeforeTwips = before;
26536
28523
  if (after !== void 0) result.spacingAfterTwips = after;
26537
28524
  const beforeAuto = parseOnOff(getW(spacing2, "beforeAutospacing"));
26538
28525
  const afterAuto = parseOnOff(getW(spacing2, "afterAutospacing"));
26539
28526
  if (beforeAuto !== void 0) result.spacingBeforeAuto = beforeAuto;
26540
28527
  if (afterAuto !== void 0) result.spacingAfterAuto = afterAuto;
26541
- if (line3 !== void 0) result.lineSpacingTwips = line3;
28528
+ if (line4 !== void 0) result.lineSpacingTwips = line4;
26542
28529
  const rule = getW(spacing2, "lineRule");
26543
28530
  if (rule === "auto" || rule === "exact" || rule === "atLeast") result.lineSpacingRule = rule;
26544
- else if (line3 !== void 0) result.lineSpacingRule = "auto";
28531
+ else if (line4 !== void 0) result.lineSpacingRule = "auto";
26545
28532
  const ind = first2(pPr, "ind");
26546
28533
  for (const [xml, key] of [
26547
28534
  ["left", "indentLeftTwips"],
@@ -27563,16 +29550,16 @@ function tableGrid(table) {
27563
29550
  const cells = table.rows[row] ?? [];
27564
29551
  if (!cells.length || sumSpans(cells) !== columns) return void 0;
27565
29552
  const placed = [];
27566
- const line3 = new Array(columns);
29553
+ const line4 = new Array(columns);
27567
29554
  let col = 0;
27568
29555
  cells.forEach((cell, index) => {
27569
29556
  const entry = { cell, row, index, col, span: spanOf(cell) };
27570
- for (let k = 0; k < entry.span; k++) line3[col + k] = entry;
29557
+ for (let k = 0; k < entry.span; k++) line4[col + k] = entry;
27571
29558
  col += entry.span;
27572
29559
  placed.push(entry);
27573
29560
  });
27574
29561
  rows2.push(placed);
27575
- cover.push(line3);
29562
+ cover.push(line4);
27576
29563
  }
27577
29564
  const grid = { columns, rows: rows2, cover };
27578
29565
  for (const entry of rows2.flat())
@@ -28614,8 +30601,8 @@ function parseDirectParagraphProperties(props) {
28614
30601
  const value = onOffElement(first2(props, key));
28615
30602
  if (value !== void 0) paragraph[key] = value;
28616
30603
  }
28617
- const outline2 = parseOutlineLevel(first2(props, "outlineLvl"));
28618
- if (outline2 !== void 0) paragraph.outlineLevel = outline2;
30604
+ const outline3 = parseOutlineLevel(first2(props, "outlineLvl"));
30605
+ if (outline3 !== void 0) paragraph.outlineLevel = outline3;
28619
30606
  const frame2 = first2(props, "framePr");
28620
30607
  const dropCap = getW(frame2, "dropCap");
28621
30608
  if (dropCap === "drop" || dropCap === "margin") {
@@ -28635,19 +30622,19 @@ function parseDirectParagraphProperties(props) {
28635
30622
  const spacing2 = first2(props, "spacing");
28636
30623
  const before = twipValue2(getW(spacing2, "before"));
28637
30624
  const after = twipValue2(getW(spacing2, "after"));
28638
- const line3 = signedTwipValue2(getW(spacing2, "line"));
30625
+ const line4 = signedTwipValue2(getW(spacing2, "line"));
28639
30626
  if (before !== void 0) paragraph.spacingBeforeTwips = before;
28640
30627
  if (after !== void 0) paragraph.spacingAfterTwips = after;
28641
30628
  const beforeAuto = parseOnOff(getW(spacing2, "beforeAutospacing"));
28642
30629
  const afterAuto = parseOnOff(getW(spacing2, "afterAutospacing"));
28643
30630
  if (beforeAuto !== void 0) paragraph.spacingBeforeAuto = beforeAuto;
28644
30631
  if (afterAuto !== void 0) paragraph.spacingAfterAuto = afterAuto;
28645
- if (line3 !== void 0) {
28646
- paragraph.lineSpacingTwips = line3;
30632
+ if (line4 !== void 0) {
30633
+ paragraph.lineSpacingTwips = line4;
28647
30634
  }
28648
30635
  const rule = getW(spacing2, "lineRule");
28649
30636
  if (rule === "auto" || rule === "exact" || rule === "atLeast") paragraph.lineSpacingRule = rule;
28650
- else if (line3 !== void 0) paragraph.lineSpacingRule = "auto";
30637
+ else if (line4 !== void 0) paragraph.lineSpacingRule = "auto";
28651
30638
  const indent = first2(props, "ind");
28652
30639
  const indentLeft = signedTwipValue2(getW(indent, "left"));
28653
30640
  const indentRight = signedTwipValue2(getW(indent, "right"));
@@ -29224,17 +31211,17 @@ function twipsAttr(value) {
29224
31211
  function signedTwipsAttr(value) {
29225
31212
  return typeof value === "number" && Number.isFinite(value) ? roundSignedTwips(value) : void 0;
29226
31213
  }
29227
- function paragraphTwipsFromAttrs(attrs2) {
31214
+ function paragraphTwipsFromAttrs(attrs3) {
29228
31215
  const result = {};
29229
- const spacingBefore = twipsAttr(attrs2.spacingBeforeTwips);
29230
- const spacingAfter = twipsAttr(attrs2.spacingAfterTwips);
29231
- const lineSpacing = signedTwipsAttr(attrs2.lineSpacingTwips);
29232
- const left = signedTwipsAttr(attrs2.indentLeftTwips);
29233
- const right = signedTwipsAttr(attrs2.indentRightTwips);
29234
- const start = signedTwipsAttr(attrs2.indentStartTwips);
29235
- const end = signedTwipsAttr(attrs2.indentEndTwips);
29236
- const firstLine = twipsAttr(attrs2.firstLineTwips);
29237
- const hanging = twipsAttr(attrs2.hangingTwips);
31216
+ const spacingBefore = twipsAttr(attrs3.spacingBeforeTwips);
31217
+ const spacingAfter = twipsAttr(attrs3.spacingAfterTwips);
31218
+ const lineSpacing = signedTwipsAttr(attrs3.lineSpacingTwips);
31219
+ const left = signedTwipsAttr(attrs3.indentLeftTwips);
31220
+ const right = signedTwipsAttr(attrs3.indentRightTwips);
31221
+ const start = signedTwipsAttr(attrs3.indentStartTwips);
31222
+ const end = signedTwipsAttr(attrs3.indentEndTwips);
31223
+ const firstLine = twipsAttr(attrs3.firstLineTwips);
31224
+ const hanging = twipsAttr(attrs3.hangingTwips);
29238
31225
  if (spacingBefore !== void 0) result.spacingBeforeTwips = spacingBefore;
29239
31226
  if (spacingAfter !== void 0) result.spacingAfterTwips = spacingAfter;
29240
31227
  if (lineSpacing !== void 0) result.lineSpacingTwips = lineSpacing;
@@ -29617,6 +31604,7 @@ function runToInlineNodes(run, schema, noteNumber) {
29617
31604
  anchored: Boolean(run.image.anchored),
29618
31605
  placement: run.image.placement ? JSON.stringify(run.image.placement) : null,
29619
31606
  svgPartName: run.image.svgPartName ?? null,
31607
+ pictureFill: run.image.pictureFill ? JSON.stringify(run.image.pictureFill) : null,
29620
31608
  unsupported: run.image.unsupported ?? null,
29621
31609
  textBoxText: run.image.textBoxText ? JSON.stringify(run.image.textBoxText) : null,
29622
31610
  textBoxEditable: run.image.textBoxEditable ?? null,
@@ -29704,6 +31692,7 @@ function appendInlineNode(runs, child3) {
29704
31692
  ...child3.attrs.title ? { title: child3.attrs.title } : {},
29705
31693
  ...child3.attrs.anchored ? { anchored: true } : {},
29706
31694
  ...child3.attrs.svgPartName ? { svgPartName: child3.attrs.svgPartName } : {},
31695
+ ...typeof child3.attrs.pictureFill === "string" ? { pictureFill: JSON.parse(child3.attrs.pictureFill) } : {},
29707
31696
  // Same key order as the parser's run: the writer compares an unchanged placeholder run by JSON.
29708
31697
  ...child3.attrs.unsupported ? { unsupported: child3.attrs.unsupported } : {},
29709
31698
  ...typeof child3.attrs.diagram === "string" ? { diagram: JSON.parse(child3.attrs.diagram) } : {},
@@ -29769,8 +31758,8 @@ var RUN_FORMAT_MARKS = /* @__PURE__ */ new Set([
29769
31758
  function setInlineRunFormatting(tr, pos, run) {
29770
31759
  const node = tr.doc.nodeAt(pos);
29771
31760
  const projected = runToInlineNodes(run, tr.doc.type.schema)[0];
29772
- const attrs2 = updatedInlineRunAttributes(node, projected.attrs.format);
29773
- for (const [key, value] of Object.entries(attrs2))
31761
+ const attrs3 = updatedInlineRunAttributes(node, projected.attrs.format);
31762
+ for (const [key, value] of Object.entries(attrs3))
29774
31763
  if (node.attrs[key] !== value) tr.setNodeAttribute(pos, key, value);
29775
31764
  for (const mark of node.marks)
29776
31765
  if (RUN_FORMAT_MARKS.has(mark.type.name)) tr.removeMark(pos, pos + node.nodeSize, mark.type);
@@ -29903,33 +31892,33 @@ var PARAGRAPH_KEEP_KEYS = [
29903
31892
  "contextualSpacing",
29904
31893
  "suppressLineNumbers"
29905
31894
  ];
29906
- function paragraphFromAttrs(attrs2, id, runs) {
31895
+ function paragraphFromAttrs(attrs3, id, runs) {
29907
31896
  return {
29908
31897
  type: "paragraph",
29909
31898
  id,
29910
31899
  runs,
29911
- ...attrs2.restoredParagraphPropertiesXml ? { restoredParagraphPropertiesXml: String(attrs2.restoredParagraphPropertiesXml) } : {},
29912
- ...attrs2.sourceParagraphPropertiesXml ? { sourceParagraphPropertiesXml: String(attrs2.sourceParagraphPropertiesXml) } : {},
29913
- ...attrs2.markRevision ? { markRevision: structuredClone(attrs2.markRevision) } : {},
29914
- ...attrs2.formatRevision ? { formatRevision: structuredClone(attrs2.formatRevision) } : {},
29915
- ...attrs2.align != null ? { align: attrs2.align } : {},
29916
- ...attrs2.justification != null ? { justification: attrs2.justification } : {},
29917
- ...attrs2.outlineLevel != null ? { outlineLevel: Number(attrs2.outlineLevel) } : {},
29918
- ...attrs2.direction != null ? { direction: attrs2.direction } : {},
29919
- ...attrs2.style ? { style: attrs2.style } : {},
29920
- ...paragraphTwipsFromAttrs(attrs2),
29921
- ...attrs2.lineSpacingRule != null ? { lineSpacingRule: attrs2.lineSpacingRule } : {},
29922
- ...attrs2.numId != null ? { numbering: { numId: attrs2.numId, level: attrs2.ilvl ?? 0 } } : {},
29923
- ...attrs2.pageBreakBefore != null ? { pageBreakBefore: Boolean(attrs2.pageBreakBefore) } : {},
29924
- ...attrs2.tabStops?.length ? { tabStops: structuredClone(attrs2.tabStops) } : {},
31900
+ ...attrs3.restoredParagraphPropertiesXml ? { restoredParagraphPropertiesXml: String(attrs3.restoredParagraphPropertiesXml) } : {},
31901
+ ...attrs3.sourceParagraphPropertiesXml ? { sourceParagraphPropertiesXml: String(attrs3.sourceParagraphPropertiesXml) } : {},
31902
+ ...attrs3.markRevision ? { markRevision: structuredClone(attrs3.markRevision) } : {},
31903
+ ...attrs3.formatRevision ? { formatRevision: structuredClone(attrs3.formatRevision) } : {},
31904
+ ...attrs3.align != null ? { align: attrs3.align } : {},
31905
+ ...attrs3.justification != null ? { justification: attrs3.justification } : {},
31906
+ ...attrs3.outlineLevel != null ? { outlineLevel: Number(attrs3.outlineLevel) } : {},
31907
+ ...attrs3.direction != null ? { direction: attrs3.direction } : {},
31908
+ ...attrs3.style ? { style: attrs3.style } : {},
31909
+ ...paragraphTwipsFromAttrs(attrs3),
31910
+ ...attrs3.lineSpacingRule != null ? { lineSpacingRule: attrs3.lineSpacingRule } : {},
31911
+ ...attrs3.numId != null ? { numbering: { numId: attrs3.numId, level: attrs3.ilvl ?? 0 } } : {},
31912
+ ...attrs3.pageBreakBefore != null ? { pageBreakBefore: Boolean(attrs3.pageBreakBefore) } : {},
31913
+ ...attrs3.tabStops?.length ? { tabStops: structuredClone(attrs3.tabStops) } : {},
29925
31914
  ...Object.fromEntries(
29926
- PARAGRAPH_KEEP_KEYS.filter((key) => attrs2[key] != null).map((key) => [key, attrs2[key]])
31915
+ PARAGRAPH_KEEP_KEYS.filter((key) => attrs3[key] != null).map((key) => [key, attrs3[key]])
29927
31916
  ),
29928
- ...attrs2.dropCap ? { dropCap: { ...attrs2.dropCap } } : {},
29929
- ...attrs2.borders ? { borders: structuredClone(attrs2.borders) } : {},
29930
- ...attrs2.shadingFill ? { shadingFill: attrs2.shadingFill } : {},
29931
- ...attrs2.bookmarks?.length ? { bookmarks: [...attrs2.bookmarks] } : {},
29932
- ...attrs2.contentControl ? { contentControl: structuredClone(attrs2.contentControl) } : {}
31917
+ ...attrs3.dropCap ? { dropCap: { ...attrs3.dropCap } } : {},
31918
+ ...attrs3.borders ? { borders: structuredClone(attrs3.borders) } : {},
31919
+ ...attrs3.shadingFill ? { shadingFill: attrs3.shadingFill } : {},
31920
+ ...attrs3.bookmarks?.length ? { bookmarks: [...attrs3.bookmarks] } : {},
31921
+ ...attrs3.contentControl ? { contentControl: structuredClone(attrs3.contentControl) } : {}
29933
31922
  };
29934
31923
  }
29935
31924
  function paragraphAttrs(paragraph) {
@@ -29981,7 +31970,7 @@ function resolveParagraphFormatting(tr, pos, mode) {
29981
31970
  if (!node) return;
29982
31971
  const revision = paragraphFormattingRevision(node);
29983
31972
  if (!revision) return;
29984
- const attrs2 = { ...node.attrs, formatRevision: null };
31973
+ const attrs3 = { ...node.attrs, formatRevision: null };
29985
31974
  if (mode === "reject") {
29986
31975
  const paragraph = {
29987
31976
  type: "paragraph",
@@ -29993,14 +31982,14 @@ function resolveParagraphFormatting(tr, pos, mode) {
29993
31982
  restoreParagraphFormatting(paragraph);
29994
31983
  for (const key of PARAGRAPH_FORMAT_KEYS)
29995
31984
  if (Object.hasOwn(node.attrs, key))
29996
- attrs2[key] = paragraph[key] ?? node.type.spec.attrs?.[key]?.default ?? null;
29997
- attrs2.numId = paragraph.numbering?.numId ?? null;
29998
- attrs2.ilvl = paragraph.numbering?.level ?? null;
29999
- attrs2.restoredParagraphPropertiesXml = paragraph.restoredParagraphPropertiesXml;
31985
+ attrs3[key] = paragraph[key] ?? node.type.spec.attrs?.[key]?.default ?? null;
31986
+ attrs3.numId = paragraph.numbering?.numId ?? null;
31987
+ attrs3.ilvl = paragraph.numbering?.level ?? null;
31988
+ attrs3.restoredParagraphPropertiesXml = paragraph.restoredParagraphPropertiesXml;
30000
31989
  if (paragraph.sourceParagraphPropertiesXml)
30001
- attrs2.sourceParagraphPropertiesXml = paragraph.sourceParagraphPropertiesXml;
31990
+ attrs3.sourceParagraphPropertiesXml = paragraph.sourceParagraphPropertiesXml;
30002
31991
  }
30003
- tr.setNodeMarkup(pos, void 0, attrs2);
31992
+ tr.setNodeMarkup(pos, void 0, attrs3);
30004
31993
  }
30005
31994
 
30006
31995
  // docx/ui/track-paragraph-formatting.ts
@@ -31935,9 +33924,9 @@ var WordYjsComments = class {
31935
33924
  if (!id || this.records.has(id)) return null;
31936
33925
  let added = null;
31937
33926
  this.change(() => {
31938
- const elements2 = this.inlineEnabled() && this.inlineAnchors.add(view.state, id);
33927
+ const elements3 = this.inlineEnabled() && this.inlineAnchors.add(view.state, id);
31939
33928
  added = addComment(view, author, text2, () => id, false);
31940
- if (!added && elements2) added = { id, author, text: text2, resolved: false };
33929
+ if (!added && elements3) added = { id, author, text: text2, resolved: false };
31941
33930
  if (added) this.records.set(id, added);
31942
33931
  });
31943
33932
  return added;
@@ -31970,8 +33959,8 @@ function removeSharedAnchor(fragment, id) {
31970
33959
  let offset = 0;
31971
33960
  for (const part of child3.toDelta()) {
31972
33961
  const length = typeof part.insert === "string" ? part.insert.length : 1;
31973
- for (const [key, attrs2] of Object.entries(part.attributes ?? {})) {
31974
- if (key.startsWith("comment--") && Array.isArray(attrs2.ids) && attrs2.ids.includes(id))
33962
+ for (const [key, attrs3] of Object.entries(part.attributes ?? {})) {
33963
+ if (key.startsWith("comment--") && Array.isArray(attrs3.ids) && attrs3.ids.includes(id))
31975
33964
  child3.format(offset, length, { [key]: null });
31976
33965
  }
31977
33966
  offset += length;
@@ -32028,10 +34017,10 @@ function guardDeletedNodeSelection(doc, view, binding) {
32028
34017
  doc.on("beforeObserverCalls", guard);
32029
34018
  return () => doc.off("beforeObserverCalls", guard);
32030
34019
  }
32031
- function wordYjsDocumentAttributes(attrs2, canWrite) {
34020
+ function wordYjsDocumentAttributes(attrs3, canWrite) {
32032
34021
  const patch = (state) => {
32033
34022
  const tr = state.tr;
32034
- for (const [key, value] of attrs2.entries()) {
34023
+ for (const [key, value] of attrs3.entries()) {
32035
34024
  if (key !== "commentThreads" && key in (state.doc.type.spec.attrs ?? {}) && JSON.stringify(state.doc.attrs[key]) !== JSON.stringify(value))
32036
34025
  tr.setDocAttribute(key, value);
32037
34026
  }
@@ -32048,18 +34037,18 @@ function wordYjsDocumentAttributes(attrs2, canWrite) {
32048
34037
  binding?.mux(() => view.dispatch(tr));
32049
34038
  }
32050
34039
  };
32051
- attrs2.observe(changed);
34040
+ attrs3.observe(changed);
32052
34041
  return {
32053
34042
  update: (next, previous) => {
32054
34043
  if (previous.doc.attrs === next.state.doc.attrs || !canWrite()) return;
32055
- attrs2.doc.transact((transaction) => {
34044
+ attrs3.doc.transact((transaction) => {
32056
34045
  transaction.meta.set("addToHistory", thisPlugin.getState(next.state));
32057
34046
  for (const [key, value] of Object.entries(next.state.doc.attrs))
32058
- if (key !== "commentThreads" && JSON.stringify(attrs2.get(key)) !== JSON.stringify(value))
32059
- attrs2.set(key, value);
34047
+ if (key !== "commentThreads" && JSON.stringify(attrs3.get(key)) !== JSON.stringify(value))
34048
+ attrs3.set(key, value);
32060
34049
  }, ySyncPluginKey);
32061
34050
  },
32062
- destroy: () => attrs2.unobserve(changed)
34051
+ destroy: () => attrs3.unobserve(changed)
32063
34052
  };
32064
34053
  }
32065
34054
  });
@@ -32720,10 +34709,10 @@ var insertWordHardBreak = (state, dispatch, view) => {
32720
34709
  // docx/ui/chart-spec.ts
32721
34710
  var SVG_NS2 = "http://www.w3.org/2000/svg";
32722
34711
  function elementSpec(element3, root) {
32723
- const attrs2 = {};
34712
+ const attrs3 = {};
32724
34713
  for (const attr2 of Array.from(element3.attributes)) {
32725
34714
  if (attr2.name === "xmlns" || attr2.name.startsWith("xmlns:") || /^on/i.test(attr2.name)) continue;
32726
- attrs2[attr2.name] = attr2.value;
34715
+ attrs3[attr2.name] = attr2.value;
32727
34716
  }
32728
34717
  const children3 = [];
32729
34718
  for (const child3 of Array.from(element3.childNodes)) {
@@ -32731,7 +34720,7 @@ function elementSpec(element3, root) {
32731
34720
  else if (child3.nodeType === 3 && child3.nodeValue) children3.push(child3.nodeValue);
32732
34721
  }
32733
34722
  const tag = root ? `${SVG_NS2} ${element3.localName}` : element3.localName;
32734
- return [tag, attrs2, ...children3];
34723
+ return [tag, attrs3, ...children3];
32735
34724
  }
32736
34725
  function svgMarkupSpec(svg) {
32737
34726
  return elementSpec(parseXml(svg, { label: "Chart SVG" }).documentElement, true);
@@ -32795,7 +34784,7 @@ function textBoxLines(value) {
32795
34784
  if (typeof value !== "string") return [];
32796
34785
  try {
32797
34786
  const lines = JSON.parse(value);
32798
- return Array.isArray(lines) ? lines.map((line3) => ["span", { class: "dve-textbox-line" }, String(line3)]) : [];
34787
+ return Array.isArray(lines) ? lines.map((line4) => ["span", { class: "dve-textbox-line" }, String(line4)]) : [];
32799
34788
  } catch {
32800
34789
  return [];
32801
34790
  }
@@ -32820,6 +34809,7 @@ var imageNodeSpec = {
32820
34809
  placement: { default: null },
32821
34810
  /** SVG original shown instead of the PNG fallback in `partName`. */
32822
34811
  svgPartName: { default: null },
34812
+ pictureFill: { default: null },
32823
34813
  unsupported: { default: null },
32824
34814
  /** A text box's paragraphs as a JSON string array; shown read-only inside its placeholder. */
32825
34815
  textBoxText: { default: null },
@@ -34353,12 +36343,12 @@ var markSpecs = {
34353
36343
  }
34354
36344
  ],
34355
36345
  toDOM: (mark) => {
34356
- const attrs2 = {};
34357
- if (mark.attrs.language) attrs2.lang = mark.attrs.language;
36346
+ const attrs3 = {};
36347
+ if (mark.attrs.language) attrs3.lang = mark.attrs.language;
34358
36348
  if (mark.attrs.eastAsiaLanguage)
34359
- attrs2["data-docx-east-asia-language"] = mark.attrs.eastAsiaLanguage;
34360
- if (mark.attrs.bidiLanguage) attrs2["data-docx-bidi-language"] = mark.attrs.bidiLanguage;
34361
- return ["span", attrs2, 0];
36349
+ attrs3["data-docx-east-asia-language"] = mark.attrs.eastAsiaLanguage;
36350
+ if (mark.attrs.bidiLanguage) attrs3["data-docx-bidi-language"] = mark.attrs.bidiLanguage;
36351
+ return ["span", attrs3, 0];
34362
36352
  }
34363
36353
  },
34364
36354
  runRtl: {
@@ -34380,12 +36370,12 @@ var markSpecs = {
34380
36370
  tag: "span",
34381
36371
  getAttrs: (el5) => {
34382
36372
  const style = el5.style;
34383
- const attrs2 = {
36373
+ const attrs3 = {
34384
36374
  family: pastedFontFamily(style.fontFamily),
34385
36375
  size: style.fontSize ? parseFontSize(style.fontSize) : null,
34386
36376
  color: pastedColor(style.color)
34387
36377
  };
34388
- return attrs2.family || attrs2.size || attrs2.color ? attrs2 : false;
36378
+ return attrs3.family || attrs3.size || attrs3.color ? attrs3 : false;
34389
36379
  }
34390
36380
  }
34391
36381
  ],
@@ -34546,15 +36536,15 @@ function parseBordersJson(value) {
34546
36536
  }
34547
36537
  }
34548
36538
  var twipsPx = (value) => Number.isSafeInteger(value) ? `${Number(value) / 15}px` : null;
34549
- function tableStyle(attrs2) {
34550
- const borders = parseBordersJson(attrs2.borders);
34551
- const margins = marginValues(attrs2.cellMargins);
36539
+ function tableStyle(attrs3) {
36540
+ const borders = parseBordersJson(attrs3.borders);
36541
+ const margins = marginValues(attrs3.cellMargins);
34552
36542
  const declarations = [
34553
36543
  "border-collapse:collapse",
34554
- twipsPx(attrs2.widthTwips) && `width:${twipsPx(attrs2.widthTwips)}`,
34555
- attrs2.alignment === "center" && "margin-left:auto;margin-right:auto",
34556
- attrs2.alignment === "right" && "margin-left:auto",
34557
- twipsPx(attrs2.indentTwips) && attrs2.alignment !== "center" && `margin-left:${twipsPx(attrs2.indentTwips)}`,
36544
+ twipsPx(attrs3.widthTwips) && `width:${twipsPx(attrs3.widthTwips)}`,
36545
+ attrs3.alignment === "center" && "margin-left:auto;margin-right:auto",
36546
+ attrs3.alignment === "right" && "margin-left:auto",
36547
+ twipsPx(attrs3.indentTwips) && attrs3.alignment !== "center" && `margin-left:${twipsPx(attrs3.indentTwips)}`,
34558
36548
  // Cells without their own resolved borders (e.g. a table inserted in the editor) draw the
34559
36549
  // table's inside line; tables with no border information fall back to dashed gridlines.
34560
36550
  borders && `--dve-cell-border:${cssBorderSide(borders.insideH ?? borders.top) ?? "none"}`,
@@ -34584,14 +36574,14 @@ function cellPadding(value) {
34584
36574
  (side) => margins[side] === void 0 ? `var(--dve-cell-padding-${side}, ${DEFAULT_CELL_MARGINS[side] / 15}px)` : `${margins[side]}px`
34585
36575
  ).join(" ")}`;
34586
36576
  }
34587
- function tableCellStyle(attrs2) {
34588
- const borders = parseBordersJson(attrs2.borders);
34589
- const verticalAlign = attrs2.verticalAlign === "center" ? "middle" : attrs2.verticalAlign === "bottom" ? "bottom" : "top";
36577
+ function tableCellStyle(attrs3) {
36578
+ const borders = parseBordersJson(attrs3.borders);
36579
+ const verticalAlign = attrs3.verticalAlign === "center" ? "middle" : attrs3.verticalAlign === "bottom" ? "bottom" : "top";
34590
36580
  const declarations = [
34591
- cellPadding(attrs2.margins),
36581
+ cellPadding(attrs3.margins),
34592
36582
  `vertical-align:${verticalAlign}`,
34593
- twipsPx(attrs2.widthTwips) && `width:${twipsPx(attrs2.widthTwips)}`,
34594
- typeof attrs2.shadingFill === "string" && `background-color:${attrs2.shadingFill}`,
36583
+ twipsPx(attrs3.widthTwips) && `width:${twipsPx(attrs3.widthTwips)}`,
36584
+ typeof attrs3.shadingFill === "string" && `background-color:${attrs3.shadingFill}`,
34595
36585
  ...["top", "bottom", "left", "right"].map(
34596
36586
  (side) => borders && (cssBorderSide(borders[side]) ? `border-${side}:${cssBorderSide(borders[side])}` : `border-${side}-style:none`)
34597
36587
  )
@@ -34602,10 +36592,10 @@ function paragraphBoxCss(borders, shadingFill) {
34602
36592
  const parsed = typeof borders === "string" ? parseBordersJson(borders) : borders;
34603
36593
  const css = [];
34604
36594
  for (const side of ["top", "bottom", "left", "right"]) {
34605
- const line3 = cssBorderSide(parsed?.[side]);
34606
- if (!line3) continue;
36595
+ const line4 = cssBorderSide(parsed?.[side]);
36596
+ if (!line4) continue;
34607
36597
  css.push(
34608
- `border-${side}:${line3}`,
36598
+ `border-${side}:${line4}`,
34609
36599
  `padding-${side}:${(parsed[side].spacePoints ?? 0) * 4 / 3}px`
34610
36600
  );
34611
36601
  }