pptx-ts 4.0.1 → 4.1.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 (95) hide show
  1. package/README.md +147 -114
  2. package/dist/{autopage-odPz7zZO.js → autopage-D4kyVp11.js} +5 -5
  3. package/dist/{autopage-odPz7zZO.js.map → autopage-D4kyVp11.js.map} +1 -1
  4. package/dist/{body-insets-Dw_BeWD_.js → body-insets-kVHmjGc6.js} +2 -2
  5. package/dist/{body-insets-Dw_BeWD_.js.map → body-insets-kVHmjGc6.js.map} +1 -1
  6. package/dist/browser.d.ts +7 -7
  7. package/dist/browser.js +5 -5
  8. package/dist/{clip-Bl01BPcN.d.ts → clip-DHDlnHUq.d.ts} +2 -2
  9. package/dist/{clip-Bl01BPcN.d.ts.map → clip-DHDlnHUq.d.ts.map} +1 -1
  10. package/dist/{diagnostics-D8ot4Ei7.d.ts → diagnostics-DiMmBU8P.d.ts} +6 -6
  11. package/dist/{diagnostics-D8ot4Ei7.d.ts.map → diagnostics-DiMmBU8P.d.ts.map} +1 -1
  12. package/dist/{embedded-fonts-DarT9aoa.d.ts → embedded-fonts-CI_YGW2d.d.ts} +2 -2
  13. package/dist/{embedded-fonts-DarT9aoa.d.ts.map → embedded-fonts-CI_YGW2d.d.ts.map} +1 -1
  14. package/dist/{entry-compose-DCnvBZz2.d.ts → entry-compose-6hF9aTmT.d.ts} +19 -17
  15. package/dist/{entry-compose-DCnvBZz2.d.ts.map → entry-compose-6hF9aTmT.d.ts.map} +1 -1
  16. package/dist/{enums-BUKTUB6V.d.ts → enums-DQRpVOLh.d.ts} +3 -3
  17. package/dist/{enums-BUKTUB6V.d.ts.map → enums-DQRpVOLh.d.ts.map} +1 -1
  18. package/dist/{errors-C4oENPcu.js → errors-Da2nXCJm.js} +6 -6
  19. package/dist/{errors-C4oENPcu.js.map → errors-Da2nXCJm.js.map} +1 -1
  20. package/dist/families.d.ts +6 -6
  21. package/dist/families.js +2 -2
  22. package/dist/{fit-Cb7naFj6.js → fit-CcXbg__l.js} +10 -10
  23. package/dist/{fit-Cb7naFj6.js.map → fit-CcXbg__l.js.map} +1 -1
  24. package/dist/{font-metrics-v5fn7s7e.d.ts → font-metrics-CBGmhLo0.d.ts} +6 -6
  25. package/dist/{font-metrics-v5fn7s7e.d.ts.map → font-metrics-CBGmhLo0.d.ts.map} +1 -1
  26. package/dist/{grid-DikTjFey.js → grid-9B2w5EaY.js} +2 -2
  27. package/dist/{grid-DikTjFey.js.map → grid-9B2w5EaY.js.map} +1 -1
  28. package/dist/{html-dom-Iuog2wdK.js → html-dom-DvJmuHt2.js} +10 -10
  29. package/dist/html-dom-DvJmuHt2.js.map +1 -0
  30. package/dist/html.d.ts +3 -3
  31. package/dist/html.js +2 -2
  32. package/dist/{image-size-CvN2iCA4.js → image-size-DwDbakcl.js} +64 -5
  33. package/dist/image-size-DwDbakcl.js.map +1 -0
  34. package/dist/index.d.ts +7 -7
  35. package/dist/index.js +3 -3
  36. package/dist/inspect.d.ts +4 -4
  37. package/dist/inspect.js +4 -4
  38. package/dist/inspect.js.map +1 -1
  39. package/dist/math.d.ts +1 -1
  40. package/dist/math.js +1 -1
  41. package/dist/measure.d.ts +3 -3
  42. package/dist/measure.js +2 -2
  43. package/dist/node.d.ts +7 -7
  44. package/dist/node.js +3 -3
  45. package/dist/{notes-Dh12JAbn.js → notes-BcT571R4.js} +19 -18
  46. package/dist/notes-BcT571R4.js.map +1 -0
  47. package/dist/options-internal-WqgMf720.js.map +1 -1
  48. package/dist/{package-J49Ck6S2.d.ts → package-KoEgVwII.d.ts} +6 -2
  49. package/dist/{package-J49Ck6S2.d.ts.map → package-KoEgVwII.d.ts.map} +1 -1
  50. package/dist/{pres-C6qgOFAa.d.ts → pres-BA9_lJbY.d.ts} +32 -12
  51. package/dist/pres-BA9_lJbY.d.ts.map +1 -0
  52. package/dist/{presentation-DGYlAWhl.js → presentation-Cyl74rq2.js} +70 -35
  53. package/dist/presentation-Cyl74rq2.js.map +1 -0
  54. package/dist/{presentation-types-8jLQHI4M.d.ts → presentation-types-B3VQH4Bz.d.ts} +19 -15
  55. package/dist/presentation-types-B3VQH4Bz.d.ts.map +1 -0
  56. package/dist/read.d.ts +6 -6
  57. package/dist/read.js +3 -3
  58. package/dist/script.d.ts +2 -2
  59. package/dist/script.d.ts.map +1 -1
  60. package/dist/script.js +11 -11
  61. package/dist/script.js.map +1 -1
  62. package/dist/{shapes-re0KyQk_.js → shapes-BcyFdZpp.js} +14 -10
  63. package/dist/shapes-BcyFdZpp.js.map +1 -0
  64. package/dist/{slide-Dx2ZeVZ6.d.ts → slide-BqPtyKmb.d.ts} +12 -7
  65. package/dist/slide-BqPtyKmb.d.ts.map +1 -0
  66. package/dist/{table-cell-margins-EVg0EwxT.js → table-cell-margins-PDshga8T.js} +4 -4
  67. package/dist/{table-cell-margins-EVg0EwxT.js.map → table-cell-margins-PDshga8T.js.map} +1 -1
  68. package/dist/{table-dom-BTDP3lEP.js → table-dom-CVbvUfgh.js} +3 -3
  69. package/dist/{table-dom-BTDP3lEP.js.map → table-dom-CVbvUfgh.js.map} +1 -1
  70. package/dist/{text-sN64Otf_.js → text-BvFFMMFQ.js} +38 -36
  71. package/dist/{text-sN64Otf_.js.map → text-BvFFMMFQ.js.map} +1 -1
  72. package/dist/{text-anchor-CrYXAfUu.js → text-anchor-BgLPbwbL.js} +2 -2
  73. package/dist/{text-anchor-CrYXAfUu.js.map → text-anchor-BgLPbwbL.js.map} +1 -1
  74. package/dist/{units-internal-XJlf-hOl.js → units-internal-DFcUYjh3.js} +11 -6
  75. package/dist/units-internal-DFcUYjh3.js.map +1 -0
  76. package/dist/{zip-C0leZZMj.d.ts → zip-CTll_dr0.d.ts} +2 -2
  77. package/dist/{zip-C0leZZMj.d.ts.map → zip-CTll_dr0.d.ts.map} +1 -1
  78. package/dist/{zip-CKd8ihcf.js → zip-CYZ0F6BV.js} +2 -2
  79. package/dist/{zip-CKd8ihcf.js.map → zip-CYZ0F6BV.js.map} +1 -1
  80. package/dist/zip.d.ts +2 -2
  81. package/dist/zip.js +2 -2
  82. package/dist/{zoom-DPUHh85d.js → zoom-BoNyOlPm.js} +65 -51
  83. package/dist/zoom-BoNyOlPm.js.map +1 -0
  84. package/package.json +39 -31
  85. package/skills/ts-pptx-upstream/SKILL.md +18 -18
  86. package/dist/html-dom-Iuog2wdK.js.map +0 -1
  87. package/dist/image-size-CvN2iCA4.js.map +0 -1
  88. package/dist/notes-Dh12JAbn.js.map +0 -1
  89. package/dist/pres-C6qgOFAa.d.ts.map +0 -1
  90. package/dist/presentation-DGYlAWhl.js.map +0 -1
  91. package/dist/presentation-types-8jLQHI4M.d.ts.map +0 -1
  92. package/dist/shapes-re0KyQk_.js.map +0 -1
  93. package/dist/slide-Dx2ZeVZ6.d.ts.map +0 -1
  94. package/dist/units-internal-XJlf-hOl.js.map +0 -1
  95. package/dist/zoom-DPUHh85d.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"zoom-DPUHh85d.js","names":[],"sources":["../src/gen/define/image-rel.ts","../src/gen/define/object-name.ts","../src/families/shared.ts","../src/gen/define/group.ts","../src/gen/slide/shape-ids.ts","../src/gen/drawingml/text-body.ts","../src/gen/define/frame.ts","../src/gen/define/layout-placeholder.ts","../src/gen/define/image.ts","../src/gen/define/text.ts","../src/gen/define/object-options.ts","../src/gen/define/media.ts","../src/gen/oxml/alternate-content.ts","../src/gen/drawingml/locks.ts","../src/gen/slide/objects/image-extent.ts","../src/gen/oxml/fmt-scheme.ts","../src/gen/chart/part-names.ts","../src/gen/opc/core.ts","../src/families/group.ts","../src/gen/drawingml/image.ts","../src/gen/slide/objects/image.ts","../src/families/image.ts","../src/package/parts/notes.ts","../src/gen/define/notes.ts","../src/families/notes.ts","../src/gen/define/shape.ts","../src/families/shape.ts","../src/gen/slide/objects/text.ts","../src/families/text.ts","../src/families/animations.ts","../src/gen/chart/chart-kind.ts","../src/gen/chart/data-refs.ts","../src/gen/chart/chart-stroke.ts","../src/gen/chart/chart-parts.ts","../src/gen/chart/chart-axes.ts","../src/gen/chart/plot-cat-axis.ts","../src/gen/chart/plot-scatter.ts","../src/gen/chart/plot-bubble.ts","../src/gen/chart/plot-pie.ts","../src/gen/chart/plot-stock.ts","../src/gen/chart/plot-surface.ts","../src/gen/chart/chart-xml.ts","../src/gen/chart/chartex-data.ts","../src/gen/chart/chartex-xml.ts","../src/gen/chart/chartex-style.ts","../src/gen/chart/embed-xlsx.ts","../src/gen/extract-charts.ts","../src/package/parts/chart.ts","../src/gen/slide/objects/chart.ts","../src/gen/define/chart.ts","../src/families/chart.ts","../src/gen/slide/comments.ts","../src/package/parts/comments.ts","../src/gen/define/comment.ts","../src/families/comments.ts","../src/gen/slide/objects/connector.ts","../src/gen/define/connector.ts","../src/families/connector.ts","../src/families/measure.ts","../src/gen/slide/objects/media.ts","../src/families/media.ts","../src/gen/slide/objects/model3d.ts","../src/gen/define/preview-image.ts","../src/gen/define/model3d.ts","../src/families/model3d.ts","../src/gen/slide/objects/ole.ts","../src/gen/define/ole.ts","../src/families/ole.ts","../src/gen/drawingml/table-border.ts","../src/gen/drawingml/table-cell3d.ts","../src/gen/slide/objects/table.ts","../src/gen/define/table.ts","../src/families/table.ts","../src/gen/slide/objects/zoom.ts","../src/gen/define/zoom.ts","../src/families/zoom.ts"],"sourcesContent":["/**\n * ts-pptx: the one place a media relationship is registered on a slide, layout or master.\n *\n * Every definer that embeds bytes pushes a media rel — images, image fills, previews, picture\n * bullets, backgrounds, audio and video, OLE payloads, 3D models, and the transition sound the\n * packager adds. They pushed the record by hand, each spelled slightly differently: two copies of\n * the dedupe match below, three spellings of the placeholder path, and one that put a base64\n * payload in the `path` field. {@link pushMediaRel} is the record, spelled once.\n */\nimport type { PresSlideInternal, SlideRelMedia } from '../../types/internal.js'\nimport { getNewRelId, nextMediaTarget, preencodedPath } from '../utils.js'\nimport { imageContentType, imageExtensionForSource } from '../../media/content-type.js'\nimport { hasBase64Header } from '../../media/base64.js'\n\n/** An image source a media rel is registered from: the caller's `path` and `data`, and the extension its part is named with. */\nexport interface ImageSource {\n\treadonly path: string\n\treadonly data: string\n\treadonly extn: string\n}\n\n/** Why a caller's image source cannot be registered. */\nexport type ImageSourceProblem = 'missing-source' | 'missing-base64-header'\n\n/**\n * Resolve a caller's `{ path, data }` to the source an image media rel is registered from, or say\n * why there is none.\n *\n * Every definer that embeds an image reads its source here: `addImage`, image fills, picture\n * bullets, backgrounds, and the covers and previews Zoom, OLE and 3D model objects are drawn from.\n * Each used to check its own subset, and three checked no header at all, so a cover of\n * `{ data: 'hello world' }` wrote a 7-byte `.png` part with nothing said.\n *\n * What a problem costs is the caller's to decide, because it depends on what the image is for: a\n * picture with nothing to degrade to throws, a cover falls back to a placeholder, and a fill, a\n * bullet or a background is dropped. This only reports it.\n * @param source - the caller's `path` and `data`, either of which may be absent\n */\nexport function resolveImageSource(\n\tsource: { path?: string | undefined; data?: string | undefined } | undefined\n): ImageSource | ImageSourceProblem {\n\tconst path = source?.path || ''\n\tconst data = source?.data || ''\n\tif (!path && !data) return 'missing-source'\n\tif (data && !hasBase64Header(data)) return 'missing-base64-header'\n\treturn { path, data, extn: imageExtensionForSource(path, data) }\n}\n\n/** One media source, as {@link pushMediaRel} registers it. */\nexport interface MediaRelSource {\n\t/** The part name's leading segment: `image`, `media`, `audio`, `model3d`, `oleObject`. */\n\tkind: string\n\t/** The part's file extension, without the dot. */\n\textn: string\n\t/** The part's content type — or `online` for an external video link, which writes no part. */\n\ttype: string\n\t/** A file or URL the media pass loads the bytes from, when the source is one. */\n\tpath?: string | undefined\n\t/** The bytes, as base64 or a `data:` URI, when they came inline. */\n\tdata?: string | undefined\n\t/** The relationship id, already allocated. */\n\trId: number\n\t/** The sibling directory the part lands in. */\n\tdir?: 'media' | 'embeddings'\n\t/**\n\t * Point at the part an identical earlier source already has, rather than naming a new one.\n\t *\n\t * De-dup is per target and by source, not by bytes: a file-path source matches on `path`,\n\t * while inline `data` sources have no real path — they all share the {@link preencodedPath}\n\t * placeholder — so they match on their payload instead, which is what stops the same inline\n\t * image being embedded once per use. A rel already marked `isDuplicate` is never matched\n\t * against, so every duplicate points at the one original rather than at a chain.\n\t *\n\t * This is a *slide-local* optimization. `package/assemble.ts` runs a second, deck-wide collapse\n\t * keyed on extension + bytes once every rel's data is loaded, which subsumes this one for reuse\n\t * across slides and for sources that only turn out identical after loading.\n\t */\n\tdedupe?: boolean\n\t/**\n\t * Name no new part. `sameAs` points at the part another rel of this source already named, for\n\t * the second of two rels one part needs (a video's ECMA and MS-2007 rels). `external` is the\n\t * link an online video's rel carries as its Target, with no part behind it.\n\t */\n\ttarget?: { sameAs: SlideRelMedia } | { external: string }\n\t/** Flags a few kinds carry for the passes after this one, copied onto the record as given. */\n\textra?: Pick<SlideRelMedia, 'isSvgPng' | 'svgSize' | 'isDefaultCover' | 'oleRelType' | 'model3dRelType'>\n}\n\n/**\n * Register one media rel on `target` and return the record.\n *\n * The part name is read before the push: {@link nextMediaTarget} counts the media rels already on\n * the target, so the first one lands on `image-<key>-1`, and computing it after the push would\n * rename every part.\n * @param target - slide, layout or master the rel is registered on\n * @param source - what the rel points at, and how\n */\nexport function pushMediaRel(target: PresSlideInternal, source: MediaRelSource): SlideRelMedia {\n\tconst path = source.path || ''\n\tconst data = source.data ?? ''\n\tconst linked = source.target && 'external' in source.target ? source.target.external : undefined\n\tconst shared = source.target && 'sameAs' in source.target ? source.target.sameAs : undefined\n\tconst dupe = source.dedupe\n\t\t? target._relsMedia.find((item) => {\n\t\t\t\tif (item.isDuplicate || !item.Target || item.type !== source.type) return false\n\t\t\t\treturn path ? item.path === path : !!data && item.data === data\n\t\t\t})\n\t\t: undefined\n\n\tconst rel: SlideRelMedia = {\n\t\tpath: path || preencodedPath(source.extn),\n\t\ttype: source.type,\n\t\textn: source.extn,\n\t\tdata,\n\t\trId: source.rId,\n\t\t...(source.dedupe ? { isDuplicate: !!dupe?.Target } : shared ? { isDuplicate: !!shared.isDuplicate } : {}),\n\t\tTarget:\n\t\t\tlinked ??\n\t\t\tshared?.Target ??\n\t\t\t(dupe?.Target ? dupe.Target : nextMediaTarget(target, source.kind, source.extn, source.dir)),\n\t\t...source.extra,\n\t}\n\ttarget._relsMedia.push(rel)\n\treturn rel\n}\n\n/**\n * Push an image media rel onto `target`, reusing an identical source's package part.\n *\n * Three definers need it — an image *fill* on a shape or text box (`registerImageFillMedia`), an\n * `addImage()` raster (`addImageDefinition`), and the cached preview raster a Zoom tile, an OLE\n * object or a 3D model is drawn from (`registerPreviewImage`). See {@link MediaRelSource.dedupe} for the match.\n * @param target - slide (or layout/master) the rel is registered on\n * @param source - the resolved image source: a `path`, a base64 `data` payload, or both\n * @param relId - the relationship id already allocated for this use\n */\nexport function registerImageMediaRel(\n\ttarget: PresSlideInternal,\n\tsource: { path?: string; data?: string; extn: string },\n\trelId: number\n): void {\n\tpushMediaRel(target, {\n\t\tkind: 'image',\n\t\textn: source.extn,\n\t\ttype: imageContentType(source.extn),\n\t\tpath: source.path || '',\n\t\tdata: source.data || '',\n\t\trId: relId,\n\t\tdedupe: true,\n\t})\n}\n\n/**\n * Push the *pair* of media rels an SVG source consumes: a rasterized PNG fallback (what a\n * renderer without SVG support paints, and what `<a:blip r:embed>` points at) and the SVG\n * itself (`asvg:svgBlip`).\n *\n * `addImage` and the picture-bullet definer both need this, and both used to take the SVG's\n * id as `pngRid + 1` on faith. That held only while nothing else allocated in between, and\n * `addImage`'s own hyperlink then took the same number a third time. Both ids now come from\n * {@link getNewRelId}, which skips every id the slide already holds.\n *\n * Neither push dedupes and neither needs to. The PNG fallback is rasterized per call from a\n * per-call `svgSize`, so two uses at different sizes are genuinely two different images; the SVG\n * source has no such excuse, but the deck-wide collapse in `package/assemble.ts` keys on\n * extension + bytes and merges them, so the same SVG placed twice measures as a single\n * `ppt/media/*.svg` part.\n *\n * @param target - slide (or layout/master) the rels are registered on\n * @param source - the resolved SVG source: a `path`, a base64 `data` payload, or both, plus\n * the display size the PNG fallback is rasterized at when the caller knows it\n * @param pinned - ids to reuse rather than allocate. Auto-paging re-registers the same bullet\n * on each overflow slide while sharing one options object by reference, so the pair has to\n * keep the ids that object already carries.\n * @returns the two allocated relationship ids\n */\nexport function registerSvgImageRels(\n\ttarget: PresSlideInternal,\n\tsource: { path: string; data: string; svgSize?: { w: number; h: number } },\n\tpinned?: { pngRid: number; svgRid: number }\n): { pngRid: number; svgRid: number } {\n\tconst { path, data } = source\n\n\t// The PNG fallback's name is read before the SVG's push, so the pair lands on consecutive names.\n\tconst pngRid = pinned ? pinned.pngRid : getNewRelId(target)\n\tpushMediaRel(target, {\n\t\tkind: 'image',\n\t\textn: 'png',\n\t\ttype: 'image/png',\n\t\tpath,\n\t\tdata,\n\t\trId: pngRid,\n\t\textra: { isSvgPng: true, ...(source.svgSize ? { svgSize: source.svgSize } : {}) },\n\t})\n\n\tconst svgRid = pinned ? pinned.svgRid : getNewRelId(target)\n\tpushMediaRel(target, { kind: 'image', extn: 'svg', type: 'image/svg+xml', path, data, rId: svgRid })\n\n\treturn { pngRid, svgRid }\n}\n","/**\n * ts-pptx: Slide-Object Name Indexing\n *\n * The per-slide default-name counter shared by every `add*Definition`. Kept in one place so a\n * grouped child and a later top-level object never collide on the same Selection Pane name\n * (see the note on {@link nextObjectNameIdx}).\n */\nimport { SlideObjectType } from '../../enums.js'\nimport type { PresSlideInternal } from '../../types/internal.js'\nimport { validateObjectName } from '../utils.js'\n\n/**\n * Take the next slide-wide index for `type`'s default Selection Pane name — 0-based here, and\n * offset to the 1-based name by {@link resolveObjectName}.\n *\n * Default names used to be derived by counting the matching objects already in\n * `target._slideObjects`. `buildGroupObject` splices group children back out of that array, so the\n * count never advanced past them and a later top-level object reused a grouped child's name. This\n * counter is immune to the splice: every object of a kind consumes an index when it is added,\n * whether it stays top-level or moves into a group — at any nesting depth, since `target` stays the\n * slide all the way down.\n *\n * Shapes and text boxes deliberately share the `text` bucket (both are `_type === text`), which is\n * what keeps `Shape 1` and `Text 1` from colliding on one slide. Callers take an index\n * unconditionally, including when the caller supplied an explicit `objectName`, so an object's\n * index is its ordinal among its kind rather than a count of the defaulted ones.\n * @param target - slide (or master) the object is being added to\n * @param type - the object's `_type`\n * @returns the index this object takes\n */\nexport function nextObjectNameIdx(target: PresSlideInternal, type: SlideObjectType): number {\n\tconst counts = (target._objectNameCounts ??= {})\n\tconst idx = counts[type] ?? 0\n\tcounts[type] = idx + 1\n\treturn idx\n}\n\n/**\n * The Selection Pane name an object takes: the caller's, validated and kept as they wrote it, or the\n * next default for its kind — `Shape 1`, `Image 1`, `Group 1`, `Slide Zoom 1`, …\n *\n * The name is stored raw and escaped once, when `cNvPrOpen` writes it. It used to be escaped here,\n * so any path that handed a stored name back in as a supplied one escaped it a second time: a layout\n * placeholder named `Q&A` was written `Q&amp;amp;A` on every slide that took its name.\n *\n * Eleven definers wrote this out, and the index base they appended used to disagree: six counted\n * from 0 (`Shape 0`, `Text 0`, `Image 0`, `Connector 0`, `Media 0`, `Table 0`), four from 1\n * (`Group 1`, `Object 1`, `3D Model 1`, and the zoom tiles), and `addChart` neither — it derived\n * `Chart 0` by counting the chart objects already on the slide, which is the numbering this\n * counter exists to replace ({@link nextObjectNameIdx}).\n *\n * They are all 1-based now, which is the base PowerPoint itself uses: it names an inserted\n * rectangle `Rectangle 1`, and nothing it authors is ever suffixed `0`. There is no base\n * parameter left to pass, so a new definer cannot pick the other convention by accident. The one\n * name outside this counter is the slide-number placeholder, which the slide emitter writes as\n * `Slide Number Placeholder 0`.\n *\n * The index is taken unconditionally — including when the caller supplied a name — so an object's\n * index is its ordinal among its kind. See {@link nextObjectNameIdx}.\n *\n * @param target - slide (or master) the object is being added to\n * @param type - the object's `_type`, which selects the counter bucket\n * @param spec - `label` opens the default name, `kind` names the API in a validation warning, and\n * `supplied` is the caller's own name when they gave one. `fallback` replaces the `label N`\n * default for a kind that has a better one to offer — a placeholder is named after the\n * placeholder it fills — and is used as given, since it is the library's own string rather than\n * the caller's and has nothing to validate.\n */\nexport function resolveObjectName(\n\ttarget: PresSlideInternal,\n\ttype: SlideObjectType,\n\tspec: { label: string; kind: string; supplied: string | undefined; fallback?: string }\n): string {\n\tconst idx = nextObjectNameIdx(target, type)\n\tif (spec.supplied) return validateObjectName(spec.supplied, spec.kind)\n\treturn spec.fallback ?? `${spec.label} ${idx + 1}`\n}\n","/**\n * ts-pptx: the construct-family seam\n *\n * A construct family is one value: everything the library knows about charts, or tables, or\n * speaker notes, reachable through a single name. What that value carries is what the write path\n * needs handed to it rather than imported — today the methods a family adds to a slide and the\n * child descriptors it recognises inside a slide master or a group.\n *\n * It has to be a value rather than a set of imports for the same reason the shape walk is handed\n * its renderers (`gen/slide/objects/shared.ts`) and the packager its part contributors\n * (`package/parts/shared.ts`): a named import inside a reachable function body is retained\n * unconditionally, and a class method body is never shaken at all, so a `SlideBuilder` that calls\n * `addChartDefinition` itself links every chart emitter into every program that writes a slide.\n * Those two seams say what a family emits; this one says what a family *is*, and a presentation is\n * composed with a list of them.\n *\n * Composed per presentation, never registered at import time. A module-level registry populated by\n * import side effects is how the same input came to produce different bytes once already (the\n * chart-part-id counter, `package/assemble.ts`), it would stop two presentations composed\n * differently in one process from each getting their own families, and it would make\n * `\"sideEffects\": false` a lie.\n */\n\nimport type { CHART_NAME } from '../enums.js'\nimport type {\n\tChartMulti,\n\tChartOpts,\n\tMeasureTextOptions,\n\tOptsChartData,\n\tOverflowBoxOptions,\n\tSlideMasterObject,\n\tTableLayoutResult,\n\tTableProps,\n\tTableRow,\n\tTableToSlidesProps,\n\tTextMeasurement,\n\tTextProps,\n} from '../types/index.js'\nimport type { Slide } from '../types/slide.js'\nimport type { PresSlideInternal } from '../types/internal.js'\nimport type { RendererTable } from '../gen/slide/objects/shared.js'\nimport type { PartContributor } from '../package/parts/shared.js'\nimport type { ExtractedSlide } from '../read/api/presentation-types.js'\nimport type SlideBuilder from '../slide.js'\nimport type PresentationCore from '../presentation.js'\nimport type { FontMetricsRegistry } from '../measure/font-metrics.js'\nimport { UnsupportedFeatureError } from '../errors.js'\n\n/**\n * Every construct family, by name. A name is what a diagnostic can say about a family that is not\n * composed, so it exists even for the families every tier carries.\n */\nexport type FamilyName =\n\t| 'animations'\n\t| 'chart'\n\t| 'comments'\n\t| 'connector'\n\t| 'group'\n\t| 'image'\n\t| 'measure'\n\t| 'media'\n\t| 'model3d'\n\t| 'notes'\n\t| 'ole'\n\t| 'shape'\n\t| 'table'\n\t| 'text'\n\t| 'zoom'\n\n/** The `Slide` methods that come from a family rather than from the slide itself. */\nexport type SlideAuthorMethod =\n\t| 'addAnimation'\n\t| 'addChart'\n\t| 'addComment'\n\t| 'addConnector'\n\t| 'addGroup'\n\t| 'addImage'\n\t| 'addMedia'\n\t| 'addModel3d'\n\t| 'addNotes'\n\t| 'addOleObject'\n\t| 'addSectionZoom'\n\t| 'addShape'\n\t| 'addSlideZoom'\n\t| 'addSummaryZoom'\n\t| 'addTable'\n\t| 'addText'\n\t| 'groupObjects'\n\n/**\n * One family method's author: the public signature, with the slide it authors onto in front and\n * the return dropped. Chaining is not the author's business — `SlideBuilder` returns the slide\n * from every bound method, so an author that returned one could only return the same one.\n */\ntype Author<M extends SlideAuthorMethod> = (slide: SlideBuilder, ...args: Parameters<Slide[M]>) => void\n\n/**\n * The slide methods a list of families supplies between them, each optional because a program\n * composed without a family does not have its methods.\n *\n * Derived from {@link Slide} rather than restated, so an author cannot drift from the method it\n * backs. `addChart` is written out because it is the one overloaded member: `Parameters` reads the\n * last overload only, which would let a family that handles just the combo form type-check while\n * the public method promises both.\n */\nexport type SlideAuthors = { [M in Exclude<SlideAuthorMethod, 'addChart'>]?: Author<M> } & {\n\taddChart?: (\n\t\tslide: SlideBuilder,\n\t\targ1: OptsChartData[] | ChartMulti[],\n\t\targ2?: ChartOpts & { type?: CHART_NAME }\n\t) => void\n}\n\n/** Which family supplies each slide method, as data, so a program can name a family it never linked. */\nexport const SLIDE_METHOD_FAMILIES: Readonly<Record<SlideAuthorMethod, FamilyName>> = Object.freeze({\n\taddAnimation: 'animations',\n\taddChart: 'chart',\n\taddComment: 'comments',\n\taddConnector: 'connector',\n\taddGroup: 'group',\n\taddImage: 'image',\n\taddMedia: 'media',\n\taddModel3d: 'model3d',\n\taddNotes: 'notes',\n\taddOleObject: 'ole',\n\taddSectionZoom: 'zoom',\n\taddShape: 'shape',\n\taddSlideZoom: 'zoom',\n\taddSummaryZoom: 'zoom',\n\taddTable: 'table',\n\taddText: 'text',\n\tgroupObjects: 'group',\n})\n\n/**\n * What a presentation-level author is given: the deck it is authoring onto, and the write-side\n * font metrics, which the presentation keeps private and a family cannot reach through the class.\n */\nexport interface PresentationAuthorContext {\n\treadonly pres: PresentationCore\n\treadonly fontMetrics: FontMetricsRegistry\n}\n\n/**\n * The presentation methods that come from a family rather than from the presentation itself.\n *\n * Written out with their signatures rather than derived from the class, because the class is what\n * they are being lifted out of. Each returns its own answer, so unlike a slide author there is\n * nothing generic to apply on the way back.\n */\nexport interface PresentationAuthors {\n\tmeasureText?: (\n\t\tctx: PresentationAuthorContext,\n\t\ttext: string | TextProps[],\n\t\topts: MeasureTextOptions\n\t) => TextMeasurement\n\toverflowsBox?: (ctx: PresentationAuthorContext, text: string | TextProps[], opts: OverflowBoxOptions) => boolean\n\ttableLayout?: (ctx: PresentationAuthorContext, rows: TableRow[], opts: TableProps) => TableLayoutResult\n\ttableToSlides?: (ctx: PresentationAuthorContext, eleId: string, options: TableToSlidesProps) => void\n}\n\n/** Which family supplies each presentation method. */\nexport const PRESENTATION_METHOD_FAMILIES: Readonly<Record<keyof PresentationAuthors, FamilyName>> = Object.freeze({\n\tmeasureText: 'measure',\n\toverflowsBox: 'measure',\n\ttableLayout: 'measure',\n\ttableToSlides: 'table',\n})\n\n/**\n * The key-tagged child descriptors a slide master's `objects` and a group's `children` are written\n * with (`{ text: … }`, `{ rect: … }`, …). `placeholder` is not one: it is master-specific and needs\n * the object's index, so `createSlideMaster` handles it itself.\n */\nexport type ChildDescriptorKey = 'chart' | 'image' | 'line' | 'rect' | 'roundRect' | 'shape' | 'text'\n\n/**\n * Which family supplies each child descriptor, as data — the counterpart to\n * {@link SLIDE_METHOD_FAMILIES}, and for the same reason: a descriptor key that reaches a\n * presentation composed without its family has to be able to name the family it is missing.\n *\n * Four of the seven keys are the shape family's, because `line`, `rect` and `roundRect` are the\n * shorthands `shape` spells out.\n */\nexport const CHILD_DESCRIPTOR_FAMILIES: Readonly<Record<ChildDescriptorKey, FamilyName>> = Object.freeze({\n\tchart: 'chart',\n\timage: 'image',\n\tline: 'shape',\n\trect: 'shape',\n\troundRect: 'shape',\n\tshape: 'shape',\n\ttext: 'text',\n})\n\n/** The payload behind one descriptor key, taken from the descriptor union so it cannot drift. */\ntype ChildDescriptor<K extends ChildDescriptorKey> = Extract<SlideMasterObject, Record<K, unknown>>[K]\n\n/**\n * The child descriptors a list of families recognises. A descriptor whose key is missing is one\n * nothing composed can author, and both walks warn — naming the family behind the key when\n * {@link CHILD_DESCRIPTOR_FAMILIES} has one, so a `{ chart: … }` in a master's `objects` on a\n * chartless presentation says what to compose rather than disappearing from the deck.\n */\nexport type ChildAuthors = {\n\t[K in ChildDescriptorKey]?: (target: PresSlideInternal, child: ChildDescriptor<K>) => void\n}\n\n/**\n * What a family contributes to an *extraction* -- the second emission path, which serializes a\n * slide for injection into a deck read from bytes rather than for a package of its own.\n *\n * One slot so far. Extraction re-emits a slide's shapes through the same renderer table a write\n * uses, so a family with only shapes to draw needs nothing here; charts are the exception because\n * an extracted chart carries its part XML and its workbook alongside the slide body.\n */\nexport interface SlideExtractors {\n\treadonly charts?: (slide: PresSlideInternal) => ExtractedSlide['charts']\n}\n\n/** One construct family. Every slot is optional; a family fills the ones it has something to say about. */\nexport interface ConstructFamily {\n\t/** This family's name, for the diagnostic a program without it raises. */\n\treadonly name: FamilyName\n\t/** Methods this family adds to a slide. */\n\treadonly authors?: SlideAuthors\n\t/** Child descriptors this family recognises inside a slide master or a group. */\n\treadonly children?: ChildAuthors\n\t/** The shape kinds this family emits XML for, keyed by `SlideObjectType`. */\n\treadonly renderers?: RendererTable\n\t/** The parts this family puts in the written package. */\n\treadonly parts?: PartContributor\n\t/** Methods this family adds to the presentation itself. */\n\treadonly presentationAuthors?: PresentationAuthors\n\t/** What this family adds to an extracted slide, beyond the shape XML its renderer emits. */\n\treadonly extract?: SlideExtractors\n}\n\n/** What a presentation was composed with: every family's contribution, flattened per seam. */\nexport interface Composition {\n\treadonly authors: SlideAuthors\n\treadonly children: ChildAuthors\n\treadonly renderers: RendererTable\n\treadonly partContributors: readonly PartContributor[]\n\treadonly presentationAuthors: PresentationAuthors\n\treadonly extract: SlideExtractors\n}\n\n/**\n * Flatten a family list into the tables the write path reads.\n *\n * A family listed twice is composed once. The list's order does not reach the output. Authors, child descriptors and renderers are all\n * addressed by name, so two families can only collide by claiming the same one, and none do; the\n * part contributors come out in list order and the packager sorts them by the rank each one\n * declares, which is the ordering that is byte-significant.\n */\nexport function composeFamilies(families: readonly ConstructFamily[]): Composition {\n\tconst authors: SlideAuthors = {}\n\tconst children: ChildAuthors = {}\n\tconst renderers: RendererTable = {}\n\tconst partContributors: PartContributor[] = []\n\tconst presentationAuthors: PresentationAuthors = {}\n\tconst extract: SlideExtractors = {}\n\t// By identity, because a family is a singleton value: listing one twice is a thing a caller will\n\t// do (`use: [tables]` on a tier that already has tables), and a part contributor collected twice\n\t// would write its parts twice -- a deck PowerPoint reports as corrupt, from a harmless spelling.\n\tfor (const family of new Set(families)) {\n\t\tObject.assign(authors, family.authors)\n\t\tObject.assign(children, family.children)\n\t\tObject.assign(renderers, family.renderers)\n\t\tObject.assign(presentationAuthors, family.presentationAuthors)\n\t\tObject.assign(extract, family.extract)\n\t\tif (family.parts) partContributors.push(family.parts)\n\t}\n\treturn { authors, children, renderers, partContributors, presentationAuthors, extract }\n}\n\n/**\n * The failure a method raises when its family was not composed.\n *\n * A method that is not composed still exists, and says which family it needs. Leaving it off\n * instead would report the same condition as `TypeError: slide.addChart is not a function`, which\n * names neither the family nor the fix; the family list this program was built with is not\n * something a missing property could point at.\n * @param call - how the method is called, e.g. `slide.addChart`\n * @param family - the family that supplies it\n */\nexport function familyMethodUnavailable(call: string, family: FamilyName): never {\n\tthrow new UnsupportedFeatureError(\n\t\t'family/not-composed',\n\t\t`${call}() needs the \"${family}\" construct family, and this presentation was composed without it. ` +\n\t\t\t`Add the \"${family}\" family to the list the presentation is composed with.`\n\t)\n}\n\n/**\n * A presentation author with its context already supplied — what a method on the presentation\n * calls, having nothing left to pass but its own arguments.\n */\nexport type BoundPresentationAuthor<F> = F extends (ctx: PresentationAuthorContext, ...args: infer A) => infer R\n\t? (...args: A) => R\n\t: never\n\n/** One presentation method's author, or the failure that names the family it came from. */\nexport function requirePresentationAuthor<M extends keyof PresentationAuthors>(\n\tauthors: PresentationAuthors,\n\tmethod: M\n): NonNullable<PresentationAuthors[M]> {\n\tconst author = authors[method]\n\tif (!author) familyMethodUnavailable(`pptx.${method}`, PRESENTATION_METHOD_FAMILIES[method])\n\treturn author\n}\n","/**\n * ts-pptx: Group Definition\n *\n * The group (`<p:grpSp>`) definition layer: `addGroupDefinition` builds a group from child\n * descriptors (recursing for nested groups), `groupObjectsDefinition` lifts already-authored\n * top-level objects into a group, and `addChildDefinition` is the shared child-descriptor\n * dispatch (also used by the slide-master definition).\n */\nimport { SlideObjectType } from '../../enums.js'\nimport { warn } from '../../diagnostics.js'\nimport type { GroupChildProps, GroupProps, SlideMasterObject } from '../../types/index.js'\nimport type { PresSlideInternal, SlideObject } from '../../types/internal.js'\nimport { resolveObjectName } from './object-name.js'\nimport { CHILD_DESCRIPTOR_FAMILIES, type ChildAuthors, type ChildDescriptorKey } from '../../families/shared.js'\nimport { InvalidOptionError, UnsupportedFeatureError } from '../../errors.js'\nimport { pickDefined } from '../../options-internal.js'\n\n/**\n * Dispatch a key-tagged child-object descriptor (`{ text }`, `{ image }`, `{ shape }`, …) to the\n * family that recognizes it. Shared by `createSlideMaster` (slide master `objects`) and\n * `addGroupDefinition` (group children) so the descriptor mapping lives in one place.\n *\n * The mapping is handed in rather than spelled here. It used to be an `if` chain naming four\n * `add*Definition` functions, which put the chart definer — and every plot module under it — in the\n * graph of any program that can define a slide master, which is all of them.\n *\n * `placeholder` is intentionally not handled here — it is master-specific and needs the object's\n * index for `_placeholderIdx`, so `createSlideMaster` handles that case itself.\n * @param target - slide (or master) the object is appended to\n * @param object - the child descriptor\n * @param children - the child-descriptor authors this presentation was composed with\n * @returns `true` if the descriptor was recognized and added, else `false`\n */\nexport function addChildDefinition(\n\ttarget: PresSlideInternal,\n\tobject: SlideMasterObject | GroupChildProps,\n\tchildren: ChildAuthors\n): boolean {\n\t// A descriptor carries exactly one key, so this reads it rather than testing the table's keys in\n\t// whatever order the family list produced them: which family was composed first is not allowed to\n\t// decide anything.\n\tfor (const key of Object.keys(object) as ChildDescriptorKey[]) {\n\t\tconst author = children[key] as ((t: PresSlideInternal, child: unknown) => void) | undefined\n\t\tif (!author) continue\n\t\tauthor(target, (object as Record<string, unknown>)[key])\n\t\treturn true\n\t}\n\treturn false\n}\n\n/**\n * Warn about a child descriptor {@link addChildDefinition} did not author, from `call`.\n *\n * Two conditions arrive here and they have different fixes, so they get different codes. A key\n * {@link CHILD_DESCRIPTOR_FAMILIES} claims is valid and typed and was simply left uncomposed —\n * the family that would have drawn it is not in this presentation's list, so the message names it\n * the way `familyMethodUnavailable` names the family behind a missing method. Any other key is a\n * typo, which is all this walk used to be able to say, because before the split a descriptor that\n * matched nothing could not type-check in the first place.\n * @param object - the descriptor nothing authored\n * @param call - the public call the descriptor was written for, e.g. `addGroup()`\n */\nexport function warnUnauthoredChild(object: SlideMasterObject | GroupChildProps, call: string): void {\n\tconst keys = Object.keys(object)\n\tconst uncomposed = (keys as ChildDescriptorKey[]).find((key) => CHILD_DESCRIPTOR_FAMILIES[key])\n\tif (uncomposed) {\n\t\tconst family = CHILD_DESCRIPTOR_FAMILIES[uncomposed]\n\t\twarn(\n\t\t\t'family/child-not-composed',\n\t\t\t`${call}: the '${uncomposed}' child descriptor needs the \"${family}\" construct family, and this presentation ` +\n\t\t\t\t`was composed without it; skipping. Add the \"${family}\" family to the list the presentation is composed with.`\n\t\t)\n\t} else {\n\t\twarn(\n\t\t\t'group/unrecognized-child',\n\t\t\t`${call} received an unrecognized child descriptor (${keys.join(', ')}); skipping.`\n\t\t)\n\t}\n}\n\n/**\n * Build a group (`<p:grpSp>`) render-object from its child descriptors, without appending the\n * group itself to the slide. Nested `group` children recurse, so a group can contain other groups.\n *\n * An identity child coordinate space is kept at every depth (emitted in `gen/slide/object.ts` as\n * `chOff/chExt == off/ext`), so children — including descendants of nested groups — keep their\n * slide-absolute coordinates and grouping is visually a no-op while making the objects one\n * selectable PowerPoint group. Charts, media, tables, and placeholders are not supported as group\n * children yet; each is skipped with a warning. When `opts.x/y/w/h` are omitted the group's bounds\n * are auto-computed (in `gen/slide/object.ts`) as the bounding box of its children.\n *\n * `target` stays the slide at every depth so leaf descendants register their image/chart rels and\n * unique ids slide-level, even when nested inside child groups.\n * @param target - slide the group's leaf children register rels against\n * @param children - the child-object descriptors\n * @param opts - group position/size/name options\n * @param childAuthors - the child-descriptor authors this presentation was composed with\n */\nfunction buildGroupObject(\n\ttarget: PresSlideInternal,\n\tchildren: GroupChildProps[],\n\topts: GroupProps,\n\tchildAuthors: ChildAuthors\n): SlideObject {\n\tconst groupObjects: SlideObject[] = []\n\n\t;(children || []).forEach((child) => {\n\t\t// Nested group: recurse and embed the child group object directly (no slide splice — its own\n\t\t// leaf descendants still register against `target` inside the recursive call).\n\t\tif ('group' in child) {\n\t\t\tgroupObjects.push(buildGroupObject(target, child.group.children, child.group.options || {}, childAuthors))\n\t\t\treturn\n\t\t}\n\t\t// Reject object types grouping does not support yet (rels/ID/transform work pending).\n\t\tif ('chart' in child || 'placeholder' in child || 'table' in child || 'media' in child) {\n\t\t\twarn('group/unsupported-child', `addGroup() does not support '${Object.keys(child)[0]}' children yet; skipping.`)\n\t\t\treturn\n\t\t}\n\t\t// Reuse the existing add*Definition logic (which registers any image/chart rels on the slide,\n\t\t// correctly — grouped children still reference slide-level relationships), then move the\n\t\t// just-appended object(s) off the slide's top-level list into this group's child list.\n\t\tconst before = target._slideObjects.length\n\t\tif (!addChildDefinition(target, child, childAuthors)) {\n\t\t\twarnUnauthoredChild(child, 'addGroup()')\n\t\t\treturn\n\t\t}\n\t\tgroupObjects.push(...target._slideObjects.splice(before))\n\t})\n\n\t// A group with no renderable children resolves to a zero-size <p:grpSp> (auto-bounds over an empty\n\t// bbox is 0×0). That is the degenerate result AGENTS.md says to warn on rather than emit silently —\n\t// the same class as the partial-frame fallback. Warn once here, at the group that is actually empty:\n\t// a nested empty group has already warned in its own recursion, and its non-empty parent has not.\n\tif (groupObjects.length === 0) {\n\t\twarn(\n\t\t\t'group/no-children',\n\t\t\t`addGroup(): group \"${opts.objectName ?? ''}\" has no renderable children; emitting an empty, zero-size group. ` +\n\t\t\t\t'Pass at least one supported child (text/shape, image, or a nested group).'\n\t\t)\n\t}\n\n\t// Called after the children above so nested groups number inside-out (see `makeGroupObject`).\n\treturn makeGroupObject(target, groupObjects, opts)\n}\n\n/**\n * Wrap already-built child render-objects in a group (`<p:grpSp>`) render-object, without appending\n * the group anywhere. Shared by `buildGroupObject` (children built from descriptors) and\n * `groupObjectsDefinition` (children lifted off the slide) so both entry points name and frame a\n * group identically — including the all-or-nothing frame, which is left to `gen/slide/object.ts` to resolve:\n * passing `x/y/w/h` through unset is what makes the bounds auto-compute to the children's bounding\n * box, so neither caller needs bounds math of its own.\n *\n * Call this *after* the children exist, so nested groups number inside-out: the name index is taken\n * here, and a child group that was built first has already taken a lower one.\n * @param target - slide the group belongs to (owns the name counter)\n * @param groupObjects - the group's child render-objects, in z-order\n * @param opts - group position/size/name options\n */\nfunction makeGroupObject(target: PresSlideInternal, groupObjects: SlideObject[], opts: GroupProps): SlideObject {\n\t// Per slide rather than per process: a module-global counter made two identical presentations\n\t// built in one process disagree on their group names.\n\tconst objectName = resolveObjectName(target, SlideObjectType.group, {\n\t\tlabel: 'Group',\n\t\tkind: 'group',\n\t\tsupplied: opts.objectName,\n\t})\n\n\treturn {\n\t\t_type: SlideObjectType.group,\n\t\t_groupObjects: groupObjects,\n\t\t// `pickDefined`, not a key-by-key literal: a group that states no `rotate` carries no\n\t\t// `rotate` key, where the literal wrote one holding `undefined` — and the group emitter\n\t\t// decides on key presence for the geometry it derives from its children.\n\t\toptions: {\n\t\t\t...pickDefined(opts, ['x', 'y', 'w', 'h', 'rotate', 'flipH', 'flipV', 'altText', 'objectLock']),\n\t\t\tobjectName,\n\t\t},\n\t}\n}\n\n/**\n * Add a group (`<p:grpSp>`) of child objects to a slide. Children may include nested groups.\n * @param target - slide the group is added to\n * @param children - the child-object descriptors\n * @param opts - group position/size/name options\n * @param childAuthors - the child-descriptor authors this presentation was composed with\n */\nexport function addGroupDefinition(\n\ttarget: PresSlideInternal,\n\tchildren: GroupChildProps[],\n\topts: GroupProps,\n\tchildAuthors: ChildAuthors\n): void {\n\ttarget._slideObjects.push(buildGroupObject(target, children, opts, childAuthors))\n}\n\n/**\n * Object kinds `groupObjects()` accepts. Text (which shapes and text boxes both are), images,\n * connectors, and groups — the last so consumers can build nested logical groups out of groups they\n * already made. Charts, media, tables, and placeholders are excluded for the same reason\n * `addGroup()` excludes them (rels/id/transform work pending); a placeholder is excluded on top of\n * that because grouping it would sever the layout inheritance that makes it a placeholder.\n */\nconst GROUPABLE_TYPES: readonly SlideObjectType[] = [\n\tSlideObjectType.text,\n\tSlideObjectType.image,\n\tSlideObjectType.connector,\n\tSlideObjectType.group,\n]\n\n/**\n * Whether `groupObjects()` would accept this object, given only what it is. The remaining reasons a\n * call can still fail are about the *selection* rather than the object — an unresolved, duplicated\n * or ambiguous name — so a consumer cannot decide those from one object either way.\n *\n * Exported because `Slide.objects` reports it as `canGroup`, and a consumer that had to re-state the\n * rule would be pinning a copy of the list above: it would keep refusing the day grouping learns a\n * new kind, and go on offering the day one is withdrawn, with nothing failing in either direction.\n * @param {SlideObject} obj - a top-level authored object\n * @returns {boolean} true when its kind is groupable and it is not a placeholder\n */\nexport function isGroupableObject(obj: SlideObject): boolean {\n\treturn GROUPABLE_TYPES.includes(obj._type) && !obj.options?.placeholder\n}\n\n/**\n * Depth-first search for an object named `name` among group children. Used only to explain a failed\n * lookup (see `groupObjectsDefinition`).\n */\nfunction findNameInGroups(objects: SlideObject[], name: string): boolean {\n\treturn objects.some((obj) => {\n\t\tif (obj._type !== SlideObjectType.group) return false\n\t\treturn (obj._groupObjects || []).some(\n\t\t\t(child) => child.options?.objectName === name || findNameInGroups([child], name)\n\t\t)\n\t})\n}\n\n/**\n * Move already-authored, top-level slide objects into one group (`<p:grpSp>`), addressed by\n * `objectName`. The counterpart to `addGroup()` for consumers that compose a slide from independent\n * renderers: the objects already exist, so replaying their descriptors just to group them would mean\n * every renderer exposing its internals.\n *\n * Grouping is visually a no-op — children keep their slide-absolute geometry, their ids, their rels,\n * and their relative z-order, exactly as with `addGroup()`. Two ordering rules make that true:\n * children are ordered by their existing slide z-order (**not** by the order they are named, which\n * would silently restack the slide), and the group itself takes the topmost member's former slot, so\n * it lands where the selection's top edge already was.\n *\n * Every failure here throws rather than warns. An unmatched name is not a degenerate deck the author\n * might still want — it means the intended object is silently still loose on the slide, which is the\n * footgun the group was meant to remove.\n * @param target - slide holding the objects\n * @param objectNames - `objectName`s of the top-level objects to group\n * @param opts - group position/size/name options (same semantics as `addGroup()`)\n */\nexport function groupObjectsDefinition(target: PresSlideInternal, objectNames: string[], opts: GroupProps): void {\n\tif (!Array.isArray(objectNames) || objectNames.length === 0) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'group/missing-object-names',\n\t\t\t\"groupObjects() requires a non-empty array of objectNames. Ex: `slide.groupObjects(['Title', 'Logo'])`\"\n\t\t)\n\t}\n\n\tconst requested = new Set<string>()\n\tobjectNames.forEach((name) => {\n\t\tif (typeof name !== 'string' || name.trim().length === 0) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'group/invalid-object-name',\n\t\t\t\t`groupObjects(): every objectName must be a non-empty string (got ${JSON.stringify(name)}).`\n\t\t\t)\n\t\t}\n\t\tif (requested.has(name))\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'group/duplicate-object-name',\n\t\t\t\t`groupObjects(): objectName \"${name}\" was named more than once.`\n\t\t\t)\n\t\trequested.add(name)\n\t})\n\n\t// Resolve every name before moving anything, so a bad name leaves the slide untouched instead of\n\t// half-grouped.\n\tconst members: SlideObject[] = []\n\tobjectNames.forEach((name) => {\n\t\t// Stored names are the caller's own spelling (only `cNvPrOpen` escapes them), so the lookup\n\t\t// and every message below compare and quote the name as given.\n\t\tconst matches = target._slideObjects.filter((obj) => obj.options?.objectName === name)\n\t\tconst [obj, ambiguous] = matches\n\t\tif (!obj) {\n\t\t\t// Distinguish \"no such object\" from \"already grouped\": both leave the caller's name\n\t\t\t// unresolved, but only one of them is a typo.\n\t\t\tconst hint = findNameInGroups(target._slideObjects, name)\n\t\t\t\t? 'it is already inside a group (an object can only belong to one group)'\n\t\t\t\t: 'no top-level object on this slide has that objectName'\n\t\t\tthrow new InvalidOptionError('group/unresolved-object-name', `groupObjects(): cannot group \"${name}\" — ${hint}.`)\n\t\t}\n\t\tif (ambiguous) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'group/ambiguous-object-name',\n\t\t\t\t`groupObjects(): objectName \"${name}\" is ambiguous — ${matches.length} objects on this slide share it. Give them unique objectNames.`\n\t\t\t)\n\t\t}\n\t\tif (!isGroupableObject(obj)) {\n\t\t\tconst kind = obj.options?.placeholder ? 'placeholder' : obj._type\n\t\t\tthrow new UnsupportedFeatureError(\n\t\t\t\t'group/kind-not-groupable',\n\t\t\t\t`groupObjects(): cannot group \"${name}\" — grouping a ${String(kind)} is not supported yet.`\n\t\t\t)\n\t\t}\n\t\tmembers.push(obj)\n\t})\n\n\t// Order children by existing z-order, not by the order named: grouping must not restack the slide.\n\tconst memberSet = new Set(members)\n\tconst children = target._slideObjects.filter((obj) => memberSet.has(obj))\n\n\t// The wrapper takes the topmost member's former slot — i.e. it sits above everything the selection\n\t// sat above, and below everything it sat below. Counting the *survivors* ahead of that slot gives\n\t// the post-removal index directly, so the removal below cannot shift it.\n\tconst topmostIdx = Math.max(...members.map((obj) => target._slideObjects.indexOf(obj)))\n\tconst insertAt = target._slideObjects.slice(0, topmostIdx).filter((obj) => !memberSet.has(obj)).length\n\n\tconst regrouped = target._slideObjects.filter((obj) => !memberSet.has(obj))\n\tregrouped.splice(insertAt, 0, makeGroupObject(target, children, opts))\n\t// Rewrite in place (rather than reassigning `_slideObjects`) so any held reference stays live.\n\ttarget._slideObjects.splice(0, target._slideObjects.length, ...regrouped)\n}\n","/**\n * ts-pptx: slide shape-id allocation\n *\n * Compute the `<p:cNvPr>` id every slide shape (including group children) is\n * rendered with, and resolve an `objectName` back to that id. References that\n * must name a shape before the render walk reaches it — a connector's\n * `<a:stCxn>`, an animation's `<p:spTgt spid>` — go through these helpers, so\n * they are shared by both the slide-object renderer and the animation builder.\n */\n\nimport { SlideObjectType } from '../../enums.js'\nimport type { SlideObject } from '../../types/internal.js'\n\n/**\n * The four `SlideObjectType` members that live in `_slideObjects` without drawing anything on the\n * slide: speaker notes belong to the notes part, a table cell is rendered by its owning table, a\n * hyperlink is a relationship carried by whatever shape owns it, and `online` is unreachable.\n * `slideObjectToXml` spells the same four out as the arms that emit nothing.\n */\nconst NON_RENDERING_TYPES: ReadonlySet<SlideObjectType> = new Set([\n\tSlideObjectType.notes,\n\tSlideObjectType.tablecell,\n\tSlideObjectType.hyperlink,\n\tSlideObjectType.online,\n])\n\n/**\n * The slide's top-level objects that actually reach the shape tree, in add order.\n *\n * This is the sequence a `shapeIndex` addresses and the sequence ids are handed out along. Both\n * used to run over `_slideObjects` itself, which counts the four non-rendering members: a slide\n * whose first entry was `addNotes` gave every later shape an id one higher than it emitted, so\n * `shapeIndex: 0` produced a `<p:spTgt spid>` naming nothing on the slide.\n * @param slideObjects - the slide's top-level objects\n * @returns the subset that renders a shape\n */\nexport function renderedSlideObjects(slideObjects: SlideObject[]): SlideObject[] {\n\treturn slideObjects.filter((obj) => !NON_RENDERING_TYPES.has(obj._type))\n}\n\n/**\n * How many `<p:cNvPr>` ids an object's render uses, starting at the one the allocator gives it.\n *\n * One for everything but a Summary Zoom. Its `mc:Fallback` is a group holding one picture per tile,\n * numbered from the zoom's own id plus one (`gen/slide/objects/zoom.ts`). The pictures are the\n * fallback's rendering of the zoom rather than shapes of their own, but a consumer reading the\n * fallback sees them beside every other shape on the slide, so their ids are held back from the\n * shapes that follow.\n * @param obj - a slide object that renders\n * @returns the number of ids it uses\n */\nexport function shapeIdCount(obj: SlideObject): number {\n\treturn obj._type === SlideObjectType.zoom && obj.zoom?.variant === 'summary' ? 1 + obj.zoom.tiles.length : 1\n}\n\n/**\n * Every object a slide renders, paired with the `<p:cNvPr>` id it is rendered with: top-level\n * objects first (from 2, in add order), then group children, seeded past the last top-level id\n * and allocated pre-order (a nested group takes an id before its own children do). Each object\n * holds {@link shapeIdCount} ids, so the next object starts past all of them.\n *\n * Only the objects that render take an id, so the emitted ids run without gaps and every id in the\n * map names a shape that exists.\n *\n * This **mirrors** the allocation in `slideObjectToXml`, which hands out ids as it walks the tree.\n * A reference that must name an id *before* the walk reaches it — a connector's `<a:stCxn>`, an\n * animation's `<p:spTgt spid>` — cannot wait for that, so it resolves through this map instead.\n * The two must stay in step: `test/regression/shape/group-shapes.test.js` parses the emitted `cNvPr` ids\n * back out and asserts each reference points at the shape it names, so drift fails there.\n * @param slideObjects - the slide's top-level objects\n * @returns each object's `<p:cNvPr>` id, keyed by object identity, in id order\n */\nexport function collectSlideShapeIds(slideObjects: SlideObject[]): Map<SlideObject, number> {\n\tconst shapeIds = new Map<SlideObject, number>()\n\tconst rendered = renderedSlideObjects(slideObjects)\n\tlet nextId = 2\n\tconst allocate = (obj: SlideObject): void => {\n\t\tshapeIds.set(obj, nextId)\n\t\tnextId += shapeIdCount(obj)\n\t}\n\trendered.forEach(allocate)\n\n\tconst allocGroupChildren = (children: SlideObject[]): void => {\n\t\tchildren.forEach((child) => {\n\t\t\tallocate(child)\n\t\t\tif (child._type === SlideObjectType.group) allocGroupChildren(child._groupObjects || [])\n\t\t})\n\t}\n\trendered.forEach((obj) => {\n\t\tif (obj._type === SlideObjectType.group) allocGroupChildren(obj._groupObjects || [])\n\t})\n\n\treturn shapeIds\n}\n\n/**\n * The `<p:cNvPr>` id of the object named `objectName`, or `null` when the slide has no such object.\n *\n * `objectName` is the **raw**, caller-supplied name, and it is compared as it is: every\n * `add*Definition` stores the name as the caller wrote it, and only `cNvPrOpen` escapes it. Connector\n * bindings and animation targets both resolve through here, so they cannot disagree about a name\n * containing `&`, `<`, `>`, `\"`, `'`, a tab or a newline.\n *\n * Group children are searched too: `buildGroupObject` splices them out of `_slideObjects` and into\n * their group's `_groupObjects`, but they are still `<p:cNvPr>`-named on this same slide and so are\n * legitimate targets for a connector binding or an animation. Searching only `_slideObjects` is what\n * silently dropped both.\n *\n * A top-level object wins over a group child of the same name (`slideObjectToXml` warns separately\n * about the duplicate), which leaves resolution unchanged for every deck without groups.\n * @param shapeIds - the slide's shape ids, from `collectSlideShapeIds` (iterated in id order)\n * @param objectName - the raw `objectName` to resolve, as the caller spelled it\n * @returns the object's `<p:cNvPr>` id, or `null` when unresolved\n */\nexport function resolveObjectNameToId(shapeIds: ReadonlyMap<SlideObject, number>, objectName: string): number | null {\n\tfor (const [obj, id] of shapeIds) {\n\t\tif (obj.options?.objectName === objectName) return id\n\t}\n\treturn null\n}\n","/**\n * ts-pptx: DrawingML text body\n *\n * The container layer over `text-run.ts`: body properties (`<a:bodyPr>`), the\n * full `<p:txBody>`/`<a:txBody>` builder (`genXmlTextBody`), the native-equation\n * predicate, and the placeholder `<p:ph>` element.\n */\n\nimport { PlaceholderType, SlideObjectType } from '../../enums.js'\nimport { CRLF } from '../../constants-internal.js'\nimport { warn } from '../../diagnostics.js'\nimport { checkEnumOrWarn } from '../../ooxml/check-enum.js'\nimport { TEXT_SHAPE_TYPES, TEXT_VERTICAL } from '../../ooxml/st-enums.js'\nimport type { ObjectOptions, TextProps, TextPropsOptions } from '../../types/index.js'\nimport type { SlideObject, TableCellInternal } from '../../types/internal.js'\nimport { el, raw, voidEl, type XmlAttrs } from '../oxml/el.js'\nimport { TEXT_ANCHOR_BY_VALIGN, type TextAnchorToken } from '../../ooxml/text-anchor.js'\nimport {\n\tgenXmlNormAutofit,\n\tgenXmlParagraphProperties,\n\tgroupRunsIntoLines,\n\trenderTextParagraphsXml,\n\ttype RunProps,\n} from './text-run.js'\n\nconst PLACEHOLDER_TYPE_MAP = PlaceholderType as Record<string, string>\n\n/**\n * Builds `<a:bodyPr></a:bodyPr>` tag for \"genXmlTextBody()\"\n * @param {SlideObject | TableCellInternal} slideObject - various options\n * @return {string} XML string\n */\nfunction genXmlBodyProperties(slideObject: SlideObject | TableCellInternal): string {\n\t// A table cell always emits bare body properties, whatever else is configured. (This used to be\n\t// a ternary on the return, which built the full element first and then threw it away.)\n\tif (slideObject._type === SlideObjectType.tablecell) return voidEl('a:bodyPr')\n\n\t// Placeholders (incl. master/layout placeholders) carry their margin/valign in `_bodyProp` just\n\t// like text boxes, so they must emit the same configured `<a:bodyPr>` — otherwise a placeholder\n\t// authored with insets or a vertical anchor silently degrades to the default.\n\t// `_bodyProp`/`options` are optional on the type but present on text/placeholder objects that reach\n\t// this branch; bind them once so the body reads a narrowed, non-undefined value.\n\tif (\n\t\t!slideObject ||\n\t\t(slideObject._type !== SlideObjectType.text && slideObject._type !== SlideObjectType.placeholder)\n\t) {\n\t\t// DEFAULT: paired, not self-closing — `<a:bodyPr .../>` would be a byte change.\n\t\treturn el('a:bodyPr', { wrap: 'square', rtlCol: '0' })\n\t}\n\t// A text/placeholder object with no `_bodyProp` still takes the full builder below, and its\n\t// defaults. It reached that arm by way of the text serializer creating an empty bag on the\n\t// authored object, which is the kind of write a serializer does not get to make; the empty\n\t// bag is spelled here instead.\n\t//\n\t// `addShape` is who arrives here that way — it builds a `_type === text` object and never\n\t// writes `_bodyProp`, where `addTextDefinition` always does. So every shape's `wrap` is\n\t// decided by what an *absent* key means, which is why it is stated rather than read off a\n\t// truthiness test below.\n\tconst options = slideObject.options\n\tconst bodyProp = options?._bodyProp ?? {}\n\n\t// PPT-2019 EX: <a:bodyPr wrap=\"square\" lIns=\"1270\" tIns=\"1270\" rIns=\"1270\" bIns=\"1270\" rtlCol=\"0\" anchor=\"ctr\"/>\n\t// NOTE: attribute ORDER is byte-significant; `rtlCol` sits after the margins and columns but\n\t// before the anchor points, which is why this is one ordered literal rather than grouped writes.\n\tconst attrs: XmlAttrs = {\n\t\t// A: Enable or disable textwrapping none or square. Only an explicit `false` turns wrapping\n\t\t// off: `square` is PowerPoint's own default and what `addTextDefinition` writes whenever it\n\t\t// runs, so an object that carries no `wrap` at all is one nobody made a decision about —\n\t\t// and the un-decided case is the default, not the opposite of it.\n\t\twrap: bodyProp.wrap === false ? 'none' : 'square',\n\t\t// B: Textbox margins [padding] — an explicit zero is meaningful, so test for it separately\n\t\tlIns: bodyProp.lIns || bodyProp.lIns === 0 ? bodyProp.lIns : null,\n\t\ttIns: bodyProp.tIns || bodyProp.tIns === 0 ? bodyProp.tIns : null,\n\t\trIns: bodyProp.rIns || bodyProp.rIns === 0 ? bodyProp.rIns : null,\n\t\tbIns: bodyProp.bIns || bodyProp.bIns === 0 ? bodyProp.bIns : null,\n\t\t// C.1: Text columns (numCol/spcCol). Spacing is only meaningful when there is more than one column.\n\t\tnumCol: bodyProp.numCol ? bodyProp.numCol : null,\n\t\tspcCol: bodyProp.spcCol ? bodyProp.spcCol : null,\n\t\t// C: Add rtl after margins\n\t\trtlCol: '0',\n\t\t// D: Add anchorPoints\n\t\tanchor: bodyProp.anchor ? bodyProp.anchor : null, // VALS: [t,ctr,b]\n\t\tvert: checkEnumOrWarn(bodyProp.vert, TEXT_VERTICAL, 'text/invalid-vertical', 'text: vert'),\n\t}\n\n\tconst children: string[] = []\n\n\t// E.1: Preset text warp (`<a:prstTxWarp>`). Per CT_TextBodyProperties this child\n\t// comes before the autofit group, so emit it immediately after the attributes.\n\t// NOTE: this `<a:avLst/>` has NO space before the slash, unlike the one `custGeom` writes.\n\tconst prstTxWarp = checkEnumOrWarn(bodyProp.prstTxWarp, TEXT_SHAPE_TYPES, 'text/invalid-warp', 'text: textWarp')\n\tif (prstTxWarp) {\n\t\tchildren.push(el('a:prstTxWarp', { prst: prstTxWarp }, raw(voidEl('a:avLst'))))\n\t}\n\n\t/**\n\t * F: Text Fit/AutoFit/Shrink option\n\t * @see: http://officeopenxml.com/drwSp-text-bodyPr-fit.php\n\t * @see: http://www.datypic.com/sc/ooxml/g-a_EG_TextAutofit.html\n\t */\n\tif (options?.fit) {\n\t\tconst fit = options.fit\n\t\t// NOTE: Use of '<a:noAutofit/>' instead of '' causes issues in PPT-2013! ('none' emits nothing.)\n\t\t// NOTE: Bare shrink does not work automatically - PowerPoint calculates fontScale/lnSpcReduction dynamically upon edit/resize.\n\t\t// The object form bakes explicit values into the file (MS-PPT > Format shape > Text Options: \"Shrink text on overflow\").\n\t\tif (fit === 'shrink') children.push(voidEl('a:normAutofit'))\n\t\telse if (fit === 'resize') children.push(voidEl('a:spAutoFit'))\n\t\telse if (typeof fit === 'object' && fit.type === 'shrink') children.push(genXmlNormAutofit(fit))\n\t}\n\n\treturn el('a:bodyPr', attrs, children.map(raw))\n}\n\n/**\n * Resolve a caller's `valign` to the `a:bodyPr/@anchor` token, or `null` when they stated\n * nothing usable.\n *\n * `null` means \"no answer here\", not \"omit the attribute\": each call site then applies its own\n * default — the text definer's is `ctr`, while a table cell and the slide-number placeholder\n * leave the attribute off and inherit.\n *\n * `ST_TextAnchoringType` is an enumeration, so a string outside it makes PowerPoint report the\n * package as needing repair. Typed callers are unaffected — `VAlign` is\n * `'top' | 'middle' | 'bottom'` — and a JavaScript caller passing something else now gets a\n * diagnostic instead of an attribute the schema rejects.\n * @param valign - the caller's `valign`, in any of the spellings above\n */\nexport function resolveTextAnchor(valign: string | null | undefined): TextAnchorToken | null {\n\tif (valign === null || valign === undefined || valign === '') return null\n\tconst anchor = TEXT_ANCHOR_BY_VALIGN[String(valign).trim().toLowerCase()]\n\tif (anchor) return anchor\n\twarn(\n\t\t'text/invalid-valign',\n\t\t`valign \"${String(valign)}\" is not one of top/middle/bottom; leaving the text anchor to inherit.`\n\t)\n\treturn null\n}\n\nexport function objectHasMath(slideObj: SlideObject): boolean {\n\tconst text = slideObj.text as TextProps | TextProps[] | string | number | undefined\n\tif (Array.isArray(text)) return text.some((item) => item && typeof item === 'object' && !!item.math)\n\tif (text && typeof text === 'object') return !!text.math\n\treturn false\n}\n\n/**\n * Generate the XML for text and its options (bold, bullet, etc) including text runs (word-level formatting)\n * @param {SlideObject|TableCellInternal} slideObj - slideObj or tableCell\n * @note PPT text lines [lines followed by line-breaks] are created using <p>-aragraph's\n * @note Bullets are a paragragh-level formatting device\n * @template\n * <p:txBody>\n * <a:bodyPr wrap=\"square\" rtlCol=\"0\">\n * <a:spAutoFit/>\n * </a:bodyPr>\n * <a:lstStyle/>\n * <a:p>\n * <a:pPr algn=\"ctr\"/>\n * <a:r>\n * <a:rPr lang=\"en-US\" dirty=\"0\" err=\"1\"/>\n * <a:t>textbox text</a:t>\n * </a:r>\n * <a:endParaRPr lang=\"en-US\" dirty=\"0\"/>\n * </a:p>\n * </p:txBody>\n * @returns XML containing the param object's text and formatting\n */\nexport function genXmlTextBody(slideObj: SlideObject | TableCellInternal): string {\n\tconst opts: ObjectOptions = slideObj.options || {}\n\tlet tmpTextObjects: TextProps[] = []\n\tconst arrTextObjects: RunProps[] = []\n\n\t// FIRST: Shapes without text reach this point with `slideObj.text` null/undefined.\n\t// We MUST still emit a `<p:txBody>` with at least an empty `<a:p>` paragraph;\n\t// the empty-txBody fallback below appends `<a:p><a:endParaRPr/></a:p>` when no\n\t// `<a:p>` was produced. Returning early here would emit `<p:sp>` without\n\t// `<p:txBody>`, which PowerPoint reports as a needs-repair error.\n\n\t// STEP 1: Accumulate the body's children; the `<p:txBody>`/`<a:txBody>` wrapper closes over\n\t// them in STEP 7.\n\tlet strSlideXml = ''\n\n\t// STEP 2: Add bodyProperties\n\t{\n\t\t// A: 'bodyPr'\n\t\tstrSlideXml += genXmlBodyProperties(slideObj)\n\n\t\t// B: 'lstStyle'\n\t\t// NOTE: shape type 'LINE' has different text align needs (a lstStyle.lvl1pPr between bodyPr and p)\n\t\t// KNOWN LIMITATION: horizontal align on a LINE does not work — text is always left-aligned inside the line.\n\t\tif (opts.h === 0 && opts.line && opts.align)\n\t\t\tstrSlideXml += el('a:lstStyle', null, raw(voidEl('a:lvl1pPr', { algn: 'l' })))\n\t\telse if (slideObj._type === SlideObjectType.placeholder)\n\t\t\tstrSlideXml += el('a:lstStyle', null, raw(genXmlParagraphProperties(slideObj, true)))\n\t\telse strSlideXml += voidEl('a:lstStyle')\n\t}\n\n\t/* STEP 3: Modify slideObj.text to array\n\t\tCASES:\n\t\taddText( 'string' ) // string\n\t\taddText( 'line1\\n line2' ) // string with lineBreak\n\t\taddText( ['barry','allen'] ) // array of strings\n\t\taddText( [{text:'word1'}, {text:'word2'}] ) // TextProps object array\n\t\taddText( [{text:'line1\\n line2'}, {text:'end word'}] ) // TextProps object array with lineBreak\n\t*/\n\tif (typeof slideObj.text === 'string' || typeof slideObj.text === 'number') {\n\t\t// Handle cases 1,2\n\t\ttmpTextObjects.push({ text: slideObj.text.toString(), options: opts || {} })\n\t} else if (Array.isArray(slideObj.text)) {\n\t\t// Handle cases 3,4,5\n\t\t// NOTE: use cast as text is TextProps[]|TableCellInternal[] and their `options` dont overlap (they share the same TextBaseProps though)\n\t\t// `math` carries raw OMML for native equation paragraphs — preserved here so STEP 5/6 can isolate it.\n\t\ttmpTextObjects = (slideObj.text as TextProps[]).map((item) => {\n\t\t\t// Projected key by key rather than spread: the array may really be `TableCellInternal[]` (see\n\t\t\t// the cast note above), and only these four belong on a `TextProps`. A key the item\n\t\t\t// does not have stays off the projection rather than arriving as an `undefined`.\n\t\t\tconst projected: TextProps = {}\n\t\t\tif (item.text !== undefined) projected.text = item.text\n\t\t\tif (item.options !== undefined) projected.options = item.options\n\t\t\tif (item.math !== undefined) projected.math = item.math\n\t\t\tif (item.inline !== undefined) projected.inline = item.inline\n\t\t\treturn projected\n\t\t})\n\t}\n\n\t// STEP 4: Iterate over text objects, set text/options, break into pieces if '\\n'/breakLine found\n\ttmpTextObjects.forEach((itext, idx) => {\n\t\tif (!itext.text) itext.text = ''\n\n\t\t// A: Set options\n\t\titext.options = itext.options || opts || {}\n\t\tif (idx === 0 && itext.options && !itext.options.bullet && opts.bullet) itext.options.bullet = opts.bullet\n\n\t\t// B: Cast to text-object and fix line-breaks (if needed)\n\t\tif (typeof itext.text === 'string' || typeof itext.text === 'number') {\n\t\t\t// 1: Convert \"\\n\" or any variation into CRLF\n\t\t\titext.text = itext.text.toString().replace(/\\r*\\n/g, CRLF)\n\t\t}\n\n\t\t// C: If text string has line-breaks, then create a separate text-object for each (much easier than dealing with split inside a loop below)\n\t\t// NOTE: Filter for trailing lineBreak prevents the creation of an empty textObj as the last item\n\t\tif (itext.text.includes(CRLF) && itext.text.match(/\\n$/g) === null) {\n\t\t\tconst lines = itext.text.split(CRLF)\n\t\t\tlines.forEach((line, lineIdx) => {\n\t\t\t\tconst isLast = lineIdx === lines.length - 1\n\t\t\t\t// Non-last pieces need a paragraph break after them (the \\n implies it).\n\t\t\t\t// The last piece inherits the caller's breakLine intent, *including* none — writing the\n\t\t\t\t// key as `undefined` would make an unstated intent look like a stated one to the next\n\t\t\t\t// spread. Copied rather than mutated, so the caller's own options are untouched.\n\t\t\t\tconst lineOptions: TextPropsOptions = { ...itext.options }\n\t\t\t\tif (!isLast) lineOptions.breakLine = true\n\t\t\t\tarrTextObjects.push({ text: line, options: lineOptions })\n\t\t\t})\n\t\t} else {\n\t\t\tarrTextObjects.push({ ...itext, options: itext.options ?? {} })\n\t\t}\n\t})\n\n\t// STEP 5: Group textObj into lines by checking for lineBreak, bullets, alignment change, etc.\n\tconst arrLines = groupRunsIntoLines(arrTextObjects, opts)\n\n\t// STEP 6: Loop over each line and create paragraph props, text run, etc.\n\tstrSlideXml += renderTextParagraphsXml(arrLines, slideObj, opts)\n\n\t// IMPORTANT: An empty txBody will cause \"needs repair\" error! Add <p> content if missing.\n\t// This fixes an issue with table auto-paging where some cells would be empty on subsequent pages.\n\t/*\n\t\t<a:txBody>\n\t\t\t<a:bodyPr/>\n\t\t\t<a:lstStyle/>\n\t\t</a:txBody>\n\t*/\n\t// NOTE: this scans the accumulated CHILDREN, which no longer include the opening `<p:txBody>`.\n\t// That does not change the result: neither `<a:bodyPr>` nor `<a:lstStyle>` can contain the\n\t// exact substring `<a:p>` (`<a:pPr`/`<a:lvl1pPr` do not match), so only real paragraphs do.\n\tif (!strSlideXml.includes('<a:p>')) {\n\t\tstrSlideXml += el('a:p', null, raw(voidEl('a:endParaRPr')))\n\t}\n\n\t// STEP 7: Close the textBody\n\t// LAST: Return XML\n\treturn el(slideObj._type === SlideObjectType.tablecell ? 'a:txBody' : 'p:txBody', null, raw(strSlideXml))\n}\n\n/**\n * Generate an XML Placeholder\n * @param {SlideObject} placeholderObj\n * @returns XML\n */\nexport function genXmlPlaceholder(placeholderObj: SlideObject | null): string {\n\tif (!placeholderObj) return ''\n\n\tconst placeholderIdx = placeholderObj.options?._placeholderIdx ? placeholderObj.options._placeholderIdx : ''\n\tconst placeholderTyp = placeholderObj.options?._placeholderType ? placeholderObj.options._placeholderType : ''\n\t// Normalize to the OOXML ST_PlaceholderType value, accepting either a friendly PlaceholderType\n\t// key ('image', 'table') or the mapped value ('pic', 'tbl') - the latter is what `PLACEHOLDER_TYPE`\n\t// actually declares. Unknown strings emit no type rather than an invalid attribute.\n\tconst placeholderType = PLACEHOLDER_TYPE_MAP[placeholderTyp]\n\t\t? PLACEHOLDER_TYPE_MAP[placeholderTyp].toString()\n\t\t: (Object.values(PlaceholderType) as string[]).includes(placeholderTyp)\n\t\t\t? placeholderTyp\n\t\t\t: ''\n\n\t// `hasCustomPrompt` flags a placeholder *definition* (layout/master) that carries custom\n\t// prompt text; it must not be set on a populated slide-level text shape promoted to a\n\t// placeholder, or PowerPoint would treat the visible text as prompt text.\n\tconst isPlaceholderDef = placeholderObj._type === SlideObjectType.placeholder\n\n\t// NOTE: `placeholderType` is already the mapped OOXML value (e.g. 'pic', 'tbl') validated on\n\t// the line above; do NOT re-look it up in PLACEHOLDER_TYPE_MAP (its keys are the input names,\n\t// not the mapped values), or the type attribute is silently dropped for image/table placeholders.\n\t//\n\t// NOT built with the element builder, deliberately. This template's own source indentation\n\t// reaches the file: attributes are separated by a newline + two tabs, each carries an extra\n\t// leading space, and an ABSENT attribute still emits its separator — so the whitespace depends\n\t// on which attributes are missing. `voidEl` joins attributes with exactly one space and omits\n\t// absent ones entirely, so this layout is not expressible. 105 baseline parts carry `<p:ph`,\n\t// so tidying it is a visible byte change and belongs in its own fixture-gated commit.\n\treturn `<p:ph\n\t\t${placeholderIdx ? ' idx=\"' + placeholderIdx.toString() + '\"' : ''}\n\t\t${placeholderType ? ` type=\"${placeholderType}\"` : ''}\n\t\t${isPlaceholderDef && placeholderObj.text && placeholderObj.text.length > 0 ? ' hasCustomPrompt=\"1\"' : ''}\n\t\t/>`\n}\n","/**\n * ts-pptx: an authored object's frame\n *\n * Every definer used to spell its own default for an omitted `x`/`y`/`w`/`h`, and they disagreed\n * on what \"omitted\" meant. A shape tested `x || (x === 0 ? 0 : 1)`, media `|| 2`, an image `|| 1`\n * after its natural size, a chart `|| '50%'`, OLE objects and 3D models `?? 4` and `?? 3`, zooms\n * `?? 0`. So `w: 0, h: 0` gave media a 2in square, a chart half the slide and an image its natural\n * size, while a shape, an OLE object or a zoom got nothing, and none of them said so. A `NaN` took\n * the default wherever `||` was used and reached the converter wherever `??` was.\n */\n\nimport { warn } from '../../diagnostics.js'\nimport type { Coord } from '../../types/index.js'\n\ntype Axis = 'x' | 'y' | 'w' | 'h'\nconst AXES: readonly Axis[] = ['x', 'y', 'w', 'h']\n\n/** A frame as the caller wrote it: any axis may be missing or `undefined`. */\nexport type AuthoredFrame = { [A in Axis]?: Coord | undefined }\n\n/** `0`, as a number or as a unit string such as `'0in'` or `'0%'`. */\nfunction isZeroCoord(value: Coord | undefined): boolean {\n\tif (typeof value === 'number') return value === 0\n\treturn typeof value === 'string' && /^\\s*-?(?:0+(?:\\.0*)?|\\.0+)\\s*(?:%|in|pt|px|emu)\\s*$/.test(value)\n}\n\n/**\n * An object's frame: each axis the caller stated, else the definer's default.\n *\n * Only `undefined` and `null` are unstated. `0` is a stated extent and is kept, and anything else,\n * `NaN` included, is kept for the coordinate converter to accept or refuse. Each definer passes\n * only its own defaults. An axis with neither a stated value nor a default stays absent, for the\n * render pass to default.\n *\n * A zero `w` or `h` draws nothing along that axis, so it warns `frame/zero-extent`. A line is the\n * exception: it is drawn with no height or no width on purpose, and its definer says so.\n *\n * The warning distinguishes a zero the caller wrote from one that came from the definer's own\n * default, because the two are not the same news. Zoom is the one definer whose default extent is\n * zero, so a caller who stated no frame at all was told \"w is 0 and h is 0\" -- a quotation of our\n * default, describing nothing they had written and naming nothing they could change.\n * @param given - the caller's frame\n * @param defaults - the definer's default for each axis it defaults\n * @param api - the method the caller called, opening the warning\n * @param zeroExtentAllowed - true for a line\n * @returns the resolved frame\n */\nexport function resolveAuthoredFrame<K extends Axis>(\n\tgiven: AuthoredFrame,\n\tdefaults: Record<K, Coord>,\n\tapi: string,\n\tzeroExtentAllowed = false\n): Record<K, Coord> & AuthoredFrame {\n\tconst fallback: AuthoredFrame = defaults\n\tconst frame: AuthoredFrame = {}\n\tfor (const axis of AXES) {\n\t\tconst value = given[axis] ?? fallback[axis]\n\t\tif (value !== undefined) frame[axis] = value\n\t}\n\tconst zero = (['w', 'h'] as const).filter((axis) => isZeroCoord(frame[axis]))\n\tif (zero.length > 0 && !zeroExtentAllowed) {\n\t\tconst missing = zero.map((axis) => (axis === 'w' ? 'width' : 'height')).join(' and no ')\n\t\tconst stated = (axis: 'w' | 'h'): boolean => given[axis] !== undefined && given[axis] !== null\n\t\tconst cause = zero.some(stated)\n\t\t\t? zero.map((axis) => (stated(axis) ? `${axis} is ${String(frame[axis])}` : `no ${axis} was given`)).join(' and ')\n\t\t\t: `no ${zero.join(' or ')} was given and this object has no default size`\n\t\twarn('frame/zero-extent', `${api}: ${cause}, so the object has no ${missing} and may not be visible.`)\n\t}\n\treturn frame as Record<K, Coord> & AuthoredFrame\n}\n","/**\n * ts-pptx: finding the layout placeholder a slide object names\n *\n * A slide object that names a placeholder (`addText('x', { placeholder: 'body' })`) takes options\n * from the layout's placeholder when it is defined, and its frame and `<p:ph>` from it when it is\n * written. Those lookups were written out separately, and the write-time one matched any layout\n * object carrying a `placeholder` option while the definition-time ones matched only placeholders.\n * So a slide object could take its options from one layout object and its frame and `<p:ph>` from\n * another, and bind a `<p:ph>` to a master's plain text box. This is the one lookup. It has no\n * dependencies of its own, so the render path can use it without linking the definers.\n */\n\nimport { SlideObjectType } from '../../enums.js'\nimport type { SlideLayoutInternal, SlideObject } from '../../types/internal.js'\nimport type { AuthoredFrame } from './frame.js'\n\n/**\n * The layout placeholder named `name`: the first `placeholder` object on the layout whose\n * `placeholder` option is `name`.\n *\n * Only placeholder objects qualify. A layout text box can carry a `placeholder` option too, but it is\n * not a placeholder a slide can bind a `<p:ph>` to or inherit from.\n * @param layout - the slide's layout, if it has one\n * @param name - the placeholder name the slide object states, if any\n * @returns the layout placeholder, or `null` when there is none\n */\nexport function findLayoutPlaceholder(\n\tlayout: SlideLayoutInternal | null | undefined,\n\tname: string | undefined\n): SlideObject | null {\n\tif (!layout?._slideObjects || !name) return null\n\treturn (\n\t\tlayout._slideObjects.find(\n\t\t\t(obj) => obj._type === SlideObjectType.placeholder && obj.options?.placeholder === name\n\t\t) ?? null\n\t)\n}\n\n/**\n * The frame the layout placeholder named `name` states, for an object that fills the placeholder's\n * geometry to take any axis it leaves unstated, as `given[axis] ?? placeholder[axis]`.\n *\n * An image and a table each copied the four axes themselves, under different rules: the image\n * treated a `null` axis as unstated and the table did not, so `x: null` put an image at the\n * placeholder's left edge and a table at the default half inch.\n * @param layout - the slide's layout, if it has one\n * @param name - the placeholder name the slide object states, if any\n * @returns the placeholder's axes, each absent when it states none or there is no such placeholder\n */\nexport function placeholderFrame(\n\tlayout: SlideLayoutInternal | null | undefined,\n\tname: string | undefined\n): AuthoredFrame {\n\tconst options = findLayoutPlaceholder(layout, name)?.options\n\treturn options ? { x: options.x, y: options.y, w: options.w, h: options.h } : {}\n}\n","/**\n * ts-pptx: Image Definition\n *\n * `addImageDefinition` resolves an `addImage()` source, allocates its drawing rel(s) (SVG needs\n * a second for the PNG fallback), registers the media bytes through `registerImageMediaRel` and\n * inherits any placeholder geometry. `registerImageFillMedia` does the same media-rel registration\n * for an image *fill* used by a shape or text box.\n */\nimport { SlideObjectType } from '../../enums.js'\nimport { warn } from '../../diagnostics.js'\nimport type { ImageProps, ObjectOptions } from '../../types/index.js'\nimport type { PresSlideInternal, ShapeFillPropsInternal, SlideObject } from '../../types/internal.js'\nimport { getNewRelId, preencodedPath } from '../utils.js'\nimport { normalizeShadowOptions } from '../drawingml/effect.js'\nimport { svgMarkupToDataUri } from '../../media/base64.js'\nimport { getImageSizeFromBase64 } from '../../media/image-size.js'\nimport { getSmartParseNumber } from '../../units-internal.js'\nimport { resolveObjectName } from './object-name.js'\nimport { resolveAuthoredFrame } from './frame.js'\nimport { placeholderFrame } from './layout-placeholder.js'\nimport { registerImageMediaRel, registerSvgImageRels, resolveImageSource } from './image-rel.js'\nimport { registerHyperlinkRel, validateHyperlink } from './hyperlinks.js'\nimport { InvalidOptionError } from '../../errors.js'\nimport { pickDefined } from '../../options-internal.js'\n\n/** DPI PowerPoint assumes when sizing an inserted raster image (natural pixels / 96 == inches) */\nconst IMAGE_NATURAL_DPI = 96\n\n/**\n * Register a raster image fill as a slide media relationship and stash the resolved\n * rId on the fill object so serialization can emit `<a:blipFill r:embed=\"rIdN\">`.\n * Mirrors the non-SVG media-registration path used by `addImageDefinition()`,\n * including de-duplication of identical sources. SVG sources are not\n * supported as fills yet.\n * @param target - slide the owning object belongs to\n * @param fill - fill options carrying `image: { path | data }`; the resolved media\n * relationship id is stamped back onto it\n */\nexport function registerImageFillMedia(target: PresSlideInternal, fill: ShapeFillPropsInternal): void {\n\tconst source = resolveImageSource(fill.image)\n\n\tif (source === 'missing-source') {\n\t\twarn('image-fill/missing-source', 'image fill requires `image.path` or `image.data`; ignoring image fill.')\n\t\tfill.type = 'none'\n\t\treturn\n\t}\n\tif (source === 'missing-base64-header') {\n\t\twarn(\n\t\t\t'image-fill/missing-base64-header',\n\t\t\t\"image fill `data` value lacks a base64 header (ex: 'image/png;base64,...'); ignoring image fill.\"\n\t\t)\n\t\tfill.type = 'none'\n\t\treturn\n\t}\n\n\tif (source.extn === 'svg') {\n\t\twarn(\n\t\t\t'image-fill/svg-unsupported',\n\t\t\t'SVG image fills are not supported; ignoring image fill. Use a raster format (PNG/JPEG/GIF/BMP/WebP).'\n\t\t)\n\t\tfill.type = 'none'\n\t\treturn\n\t}\n\n\tconst imageRelId = getNewRelId(target)\n\tregisterImageMediaRel(target, source, imageRelId)\n\tfill.type = 'image'\n\tfill._imgRid = imageRelId\n}\n\n/**\n * Adds an image object to a slide definition.\n * This method can be called with only two args (opt, target) - this is supposed to be the only way in future.\n * @param {ImageProps} `opt` - object containing `path`/`data`, `x`, `y`, etc.\n * @param {PresSlideInternal} `target` - slide that the image should be added to (if not specified as the 2nd arg)\n * @note: Remote images (eg: \"http://whatev.com/blah\"/from web and/or remote server arent supported yet - we'd need to create an <img>, load it, then send to canvas\n * @see: https://stackoverflow.com/questions/164181/how-to-fetch-a-remote-image-to-display-in-a-canvas)\n */\n/**\n * Normalize an `addImage()` call into a slide image object and register its media relationships.\n *\n * Resolves the image source (path or base64 `data:`), allocates the drawing relationship id(s)\n * — SVG needs a second rId for its PNG rasterization fallback — appends the bytes to\n * `target._relsMedia` (deduping identical sources), and inherits any omitted x/y/w/h from a\n * matching layout picture placeholder. The resulting `SlideObject` is pushed onto the slide;\n * `gen/slide/objects/image.ts` later emits the `<p:pic>`.\n * @param target - slide (or master/group) the image is appended to\n * @param opt - the caller's `ImageProps` (path/data, geometry, sizing, hyperlink, placeholder, …)\n */\nexport function addImageDefinition(target: PresSlideInternal, opt: ImageProps): void {\n\tconst newObject: SlideObject = {\n\t\t_type: SlideObjectType.image,\n\t}\n\n\t// Inherit geometry from a matching layout placeholder: an image targeting a\n\t// placeholder adopts that placeholder's position/size for any of x/y/w/h the caller omits.\n\t// Explicit `opt` values always win; this only fills the gaps so a picture placeholder no longer\n\t// collapses to the image's natural/1in fallback when no dimensions are supplied. Mirrors the\n\t// text-object placeholder inheritance in addTextDefinition().\n\tconst placeholder = placeholderFrame(target._slideLayout, opt.placeholder)\n\n\t// FIRST: Set vars for this image (object param replaces positional args in 1.1.0)\n\t// `undefined` when neither the caller nor the placeholder states the axis. `0` is a stated extent.\n\tconst givenX = opt.x ?? placeholder.x\n\tconst givenY = opt.y ?? placeholder.y\n\tconst givenW = opt.w ?? placeholder.w\n\tconst givenH = opt.h ?? placeholder.h\n\t// Convenience: accept raw SVG markup via `svg` and encode it to a data URI.\n\t// `data`/`path` win when also supplied, matching the documented precedence.\n\tconst strImageData = opt.data || (opt.svg && !opt.path ? svgMarkupToDataUri(opt.svg) : '')\n\tconst strImagePath = opt.path || ''\n\n\t// REALITY-CHECK: an unusable source has nothing to degrade to — there is no image to place —\n\t// so these reject rather than warn, as `addMedia()` does. Every check runs before anything is\n\t// registered, the hyperlink's included: a refused link used to throw after the image's media\n\t// part and relationship were already on the slide, with no picture ever added to use them.\n\tif (strImagePath && typeof strImagePath !== 'string') {\n\t\tthrow new InvalidOptionError(\n\t\t\t'image/path-not-a-string',\n\t\t\t`addImage(): 'path' should be a string, ex: {path:'/img/sample.png'} - you sent ${String(strImagePath)}`\n\t\t)\n\t} else if (strImageData && typeof strImageData !== 'string') {\n\t\tthrow new InvalidOptionError(\n\t\t\t'image/data-not-a-string',\n\t\t\t`addImage(): 'data' should be a string, ex: {data:'image/png;base64,NMP[...]'} - you sent ${String(strImageData)}`\n\t\t)\n\t}\n\tconst source = resolveImageSource({ path: strImagePath, data: strImageData })\n\tif (source === 'missing-source') {\n\t\tthrow new InvalidOptionError('image/missing-source', \"addImage(): either 'data' or 'path' is required\")\n\t} else if (source === 'missing-base64-header') {\n\t\tthrow new InvalidOptionError(\n\t\t\t'image/missing-base64-header',\n\t\t\t\"addImage(): `data` value lacks a base64 header, ex: 'image/png;base64,NMP[...]'\"\n\t\t)\n\t}\n\tif (opt.hyperlink) validateHyperlink(opt.hyperlink, 'addImage')\n\n\tconst imageRelId = getNewRelId(target)\n\tconst objectName = resolveObjectName(target, SlideObjectType.image, {\n\t\tlabel: 'Image',\n\t\tkind: 'image',\n\t\tsupplied: opt.objectName,\n\t})\n\n\t// STEP 1: Set extension (the `data:` mime wins over the path when both are supplied)\n\tconst strImgExtn = source.extn\n\n\t// STEP 2: Set type/path\n\tnewObject._type = SlideObjectType.image\n\tnewObject.image = strImagePath || preencodedPath('png')\n\n\t// STEP 3: Default any missing dimension from the image's intrinsic (natural) size.\n\t// For base64 `data` images the bytes are already in hand, so we can read the\n\t// natural pixel size synchronously and avoid the legacy 1x1 fallback that\n\t// squished data-only images into a 1in square.\n\t// Path images can't be measured synchronously (bytes load async during export),\n\t// so the missing extent is flagged via `_szAuto` and backfilled at serialize time\n\t// once the media bytes are available.\n\t// PowerPoint inserts images at 96 DPI, so natural pixels / 96 == inches.\n\t//\n\t// A vector source is measured for its RATIO only. An SVG's user units are dependable\n\t// relative to each other and merely conventional in absolute terms — a 24-unit icon is\n\t// authored to be drawn at whatever size it is placed, not as a quarter-inch object — so an\n\t// SVG with one side given derives the other, and an SVG with neither keeps the 1in fallback.\n\tlet defWidth = givenW\n\tlet defHeight = givenH\n\tlet szAuto: { w: boolean; h: boolean } | undefined\n\tconst vectorWithNoExtent = strImgExtn === 'svg' && givenW === undefined && givenH === undefined\n\tif ((givenW === undefined || givenH === undefined) && !vectorWithNoExtent) {\n\t\tconst natural = strImageData ? getImageSizeFromBase64(strImageData) : null\n\t\tif (natural) {\n\t\t\tif (givenW === undefined && givenH === undefined) {\n\t\t\t\t// Neither given: use the natural size (inches @ 96 DPI)\n\t\t\t\tdefWidth = natural.w / IMAGE_NATURAL_DPI\n\t\t\t\tdefHeight = natural.h / IMAGE_NATURAL_DPI\n\t\t\t} else if (typeof givenW === 'number' && givenH === undefined) {\n\t\t\t\t// Only width given: preserve aspect ratio for height (same unit as width)\n\t\t\t\tdefHeight = givenW * (natural.h / natural.w)\n\t\t\t} else if (typeof givenH === 'number' && givenW === undefined) {\n\t\t\t\t// Only height given: preserve aspect ratio for width (same unit as height)\n\t\t\t\tdefWidth = givenH * (natural.w / natural.h)\n\t\t\t} else {\n\t\t\t\t// The given side is a string (`'20%'`, `'2in'`), which resolves against the slide only\n\t\t\t\t// when the frame is written, so the other side is derived then, as for a path image. It\n\t\t\t\t// used to fall to the 1in default here, so a square image came out twice as wide as tall.\n\t\t\t\tszAuto = { w: givenW === undefined, h: givenH === undefined }\n\t\t\t}\n\t\t} else if (strImagePath) {\n\t\t\t// Path image: defer measurement to serialize time. Record which side(s) to derive\n\t\t\t// from the natural ratio; the 1in fallback below still applies if it stays unmeasurable.\n\t\t\tszAuto = { w: givenW === undefined, h: givenH === undefined }\n\t\t}\n\t}\n\n\t// STEP 4: Set image properties & options\n\tconst shadow = normalizeShadowOptions(opt.shadow)\n\t// The twelve pass-through options go through `pickDefined` rather than being listed as\n\t// `key: opt.key`: an image that asks for no `crop` carries no `crop` key, where the literal\n\t// wrote one holding `undefined`. Every one of these is read by an emitter that branches on the\n\t// option being *there* (`if (opts.crop)`, `if (opts.duotone)`), so they were two spellings of\n\t// the same request — and `ObjectOptions` is spread onto a placeholder's options besides.\n\tconst frame = resolveAuthoredFrame(\n\t\t{ x: givenX, y: givenY, w: defWidth, h: defHeight },\n\t\t{ x: 0, y: 0, w: 1, h: 1 },\n\t\t'addImage'\n\t)\n\tconst objectOptions: ObjectOptions = {\n\t\tx: frame.x,\n\t\ty: frame.y,\n\t\tw: frame.w,\n\t\th: frame.h,\n\t\taltText: opt.altText || '',\n\t\trounding: typeof opt.rounding === 'boolean' ? opt.rounding : false,\n\t\t...pickDefined(opt, [\n\t\t\t'shape',\n\t\t\t'points',\n\t\t\t'rectRadius',\n\t\t\t'shapeAdjust',\n\t\t\t'sizing',\n\t\t\t'crop',\n\t\t\t'placeholder',\n\t\t\t'duotone',\n\t\t\t'grayscale',\n\t\t\t'biLevel',\n\t\t\t'clrChange',\n\t\t\t'objectLock',\n\t\t\t// `line` is read by the picture emitter (`gen/slide/objects/image.ts`) and was the one\n\t\t\t// option it reads that this list left out, so `addImage({ line })` -- documented, with\n\t\t\t// two examples -- was dropped here and the picture came out with no border at all. The\n\t\t\t// read side was reading such a border correctly the whole time; nothing could write one.\n\t\t\t'line',\n\t\t]),\n\t\trotate: opt.rotate ?? 0,\n\t\tflipV: opt.flipV || false,\n\t\tflipH: opt.flipH || false,\n\t\ttransparency: opt.transparency ?? 0,\n\t\tobjectName,\n\t\t...(shadow ? { shadow } : {}),\n\t\t...(szAuto ? { _szAuto: szAuto } : {}),\n\t}\n\tnewObject.options = objectOptions\n\n\t// STEP 5: Add this image to this Slide Rels (rId/rels count spans all slides! Count all images to get next rId)\n\tif (strImgExtn === 'svg') {\n\t\t// An SVG consumes *TWO* rels — the PNG fallback and the SVG itself — allocated and\n\t\t// pushed by `registerSvgImageRels`, which the picture-bullet definer shares.\n\t\tnewObject.imageRid = registerSvgImageRels(target, {\n\t\t\tpath: source.path,\n\t\t\tdata: source.data,\n\t\t\tsvgSize: {\n\t\t\t\tw: getSmartParseNumber(objectOptions.w, 'X', target._presLayout),\n\t\t\t\th: getSmartParseNumber(objectOptions.h, 'Y', target._presLayout),\n\t\t\t},\n\t\t}).svgRid\n\t} else {\n\t\tregisterImageMediaRel(target, source, imageRelId)\n\t\tnewObject.imageRid = imageRelId\n\t}\n\n\t// STEP 6: Hyperlink support, already validated above. An `action` alone needs no relationship:\n\t// the picture's `<p:cNvPr>` carries it, as an action button's does.\n\tif (opt.hyperlink) {\n\t\tif (opt.hyperlink.url || opt.hyperlink.slide) registerHyperlinkRel(target, opt.hyperlink)\n\t\tnewObject.hyperlink = opt.hyperlink\n\t}\n\n\t// STEP 7: Add object to slide\n\ttarget._slideObjects.push(newObject)\n}\n","/**\n * ts-pptx: Text Definition\n *\n * `addTextDefinition` cleans shape / run options (color, bullets, placeholder inheritance, body\n * properties, columns, align / valign), registers hyperlink + picture-bullet + image-fill rels,\n * and pushes a `text` / `placeholder` object. `createBulletImageRels` handles the picture-bullet\n * media rels.\n */\nimport { rejectEmptyColor } from '../drawingml/color.js'\nimport { AlignH, type PLACEHOLDER_TYPE, ShapeType, SlideObjectType, TextAnchor } from '../../enums.js'\nimport { DEF_FONT_COLOR } from '../../constants-internal.js'\nimport { warn } from '../../diagnostics.js'\nimport type { TextProps, TextPropsOptions } from '../../types/index.js'\nimport type { ObjectOptionsInternal, PresSlideInternal, SlideObject } from '../../types/internal.js'\nimport { getNewRelId } from '../utils.js'\nimport { pushMediaRel, registerSvgImageRels, resolveImageSource } from './image-rel.js'\nimport { setOrClear } from '../../options-internal.js'\nimport { normalizeShadowOptions } from '../drawingml/effect.js'\nimport { resolveFillKind } from '../drawingml/fill.js'\nimport { withLineDefaults } from '../drawingml/line.js'\nimport { resolveTextAnchor } from '../drawingml/text-body.js'\nimport { imageContentType } from '../../media/content-type.js'\nimport { ptsToEmuLenient, resolveInsetsEmu } from '../../units-internal.js'\nimport { resolveObjectName } from './object-name.js'\nimport { resolveAuthoredFrame } from './frame.js'\nimport { findLayoutPlaceholder } from './layout-placeholder.js'\nimport { createHyperlinkRels } from './hyperlinks.js'\nimport { registerImageFillMedia } from './image.js'\n\n/**\n * Adds a text object to a slide definition.\n * @param {PresSlideInternal} target - slide object that the text should be added to\n * @param {string|TextProps[]} text text string or object\n * @param {TextPropsOptions} opts text options\n * @param {boolean} isPlaceholder whether this a placeholder object\n */\nexport function addTextDefinition(\n\ttarget: PresSlideInternal,\n\ttext: TextProps[],\n\topts: TextPropsOptions,\n\tisPlaceholder: boolean\n): void {\n\t// Take ownership of the options before touching them. Everything below writes internal state\n\t// (`_bodyProp`, `objectName`, `_placeholderType`, defaulted `color`/`line`) onto whatever object\n\t// it is handed, and `gen/drawingml/text-run.ts` writes more of it (`_lineIdx`, paragraph props\n\t// inherited from the shape) at emit time. Without `own()` that state lands on the CALLER's\n\t// object, so a style literal reused across shapes carries one shape's settings to the next:\n\t//\n\t// slide.addText('a', STYLE) // STYLE now holds a `_bodyProp`\n\t// slide.addText('b', { ...STYLE, columns: 2 }) // the spread aliases that same `_bodyProp`…\n\t// slide.addText('c', { ...STYLE }) // …so all three shapes emit numCol=\"2\"\n\t//\n\t// plus a duplicate-`objectName` warning, because the name assigned to the first shape is spread\n\t// onto the second.\n\t//\n\t// Identity WITHIN one call is preserved on purpose, which is why this memoizes instead of\n\t// spreading at each use. Sharing between the shape's options and a run's is load-bearing:\n\t// `SlideBuilder.addText`'s string shorthand hands the same object to both, so `cleanOpts` runs\n\t// over it twice, and the second pass emits bytes the first cannot (see the line-defaults case in\n\t// `test/regression/text/text-definition.test.js`). Copying each reference separately would\n\t// quietly change that shape's `<a:ln>`. The caller is protected either way — the aliasing is\n\t// between two objects this function now owns.\n\t//\n\t// Nested option objects the caller supplies (`bullet`, `shadow`, `fill`) are deliberately still\n\t// shared: `bullet._rId` and the image fill's rel id are registered through those references and\n\t// read back at emit time, and auto-paging relies on a cloned text object reaching the same bullet.\n\t// A layout placeholder's are not the caller's, and are copied: see `placeholderOptionsForSlide`.\n\tconst owned = new Map<TextPropsOptions, ObjectOptionsInternal>()\n\t/**\n\t * The keys the CALLER wrote on each owned copy, recorded before any default reaches it.\n\t *\n\t * `cleanOpts` defaults several keys (`color`, `bullet`, `line`, `_bodyProp`) on the way past,\n\t * so by the time the placeholder inheritance in A.3 runs, \"the bag has this key\" no longer\n\t * means \"the caller asked for this\". That distinction is the whole rule there: a placeholder\n\t * supplies an option the caller left out, and a *default* is not the caller leaving it out.\n\t */\n\tconst authoredKeys = new WeakMap<ObjectOptionsInternal, ReadonlySet<string>>()\n\t/** Copy a caller-supplied options object once, returning the same copy for the same input. */\n\tconst own = (source?: TextPropsOptions): ObjectOptionsInternal => {\n\t\tif (!source) return {}\n\t\tconst already = owned.get(source)\n\t\tif (already) return already\n\t\tconst copy: ObjectOptionsInternal = { ...source }\n\t\towned.set(source, copy)\n\t\tauthoredKeys.set(copy, new Set(Object.keys(source)))\n\t\treturn copy\n\t}\n\n\tconst textObjects = (!text || text.length === 0 ? [{ text: '' }] : text).map((item) => ({\n\t\t...item,\n\t\toptions: own(item.options),\n\t}))\n\tconst objectOptions: ObjectOptionsInternal = own(opts)\n\tconst newObject: SlideObject = {\n\t\t_type: isPlaceholder ? SlideObjectType.placeholder : SlideObjectType.text,\n\t\tshape: opts.shape || ShapeType.rect,\n\t\ttext: textObjects,\n\t\toptions: objectOptions,\n\t}\n\t// One index for the whole text object, taken here rather than inside `cleanOpts` — that runs once\n\t// for the object and again for every run, so naming from inside it would burn an index per run.\n\n\tfunction cleanOpts(itemOpts: ObjectOptionsInternal): TextPropsOptions {\n\t\t// STEP 1: Set some options\n\t\t{\n\t\t\t// A.1: Color (placeholders should inherit their colors or override them, so don't default them)\n\t\t\t//\n\t\t\t// The question is whether the TEXT targets a placeholder, which is not the same as\n\t\t\t// whether this bag says so. `cleanOpts` runs once for the object and again for each of\n\t\t\t// its runs, and a run states only what the caller wrote on that run: `addText('x', {\n\t\t\t// placeholder: 'title' })` reaches this line a second time with a bag carrying no\n\t\t\t// `placeholder` key at all. Testing `itemOpts` alone therefore skipped the default for\n\t\t\t// the shape and applied it to the run inside it, which is how an explicit black\n\t\t\t// `a:solidFill` landed on text whose whole point is to inherit the layout's colour.\n\t\t\t//\n\t\t\t// It went unnoticed because the bare-string overload used to hand ONE options object to\n\t\t\t// both the shape and its lone run, so the run's bag was the shape's and did carry the\n\t\t\t// key. That aliasing was removed deliberately (a run must not inherit the shape's\n\t\t\t// `shadow`), and this default was reading it.\n\t\t\t//\n\t\t\t// Suppressing the default here does not lose a colour the caller stated on the shape:\n\t\t\t// `color` is in `RUN_INHERITABLE_OPTIONS`, so a run takes the shape's at emit time. What\n\t\t\t// it stops writing is the fallback nobody asked for.\n\t\t\tconst targetsPlaceholder = Boolean(itemOpts.placeholder ?? objectOptions.placeholder) || isPlaceholder\n\t\t\tif (!targetsPlaceholder) {\n\t\t\t\t// A hyperlink run with no color configured anywhere inherits the theme hyperlink color\n\t\t\t\t// (a:schemeClr hlink, and folHlink once visited), which PowerPoint applies automatically\n\t\t\t\t// when the run carries no explicit fill. Defaulting it to DEF_FONT_COLOR would emit a\n\t\t\t\t// solidFill plus hlinkClr=\"tx\", pinning the link to black and suppressing the theme\n\t\t\t\t// hyperlink/visited colors. Only non-hyperlink text falls back to DEF_FONT_COLOR.\n\t\t\t\t// `''` at either level resolves the way an omitted colour resolves, through the same\n\t\t\t\t// `||` chain; it is reported first so the caller hears about their own missing value\n\t\t\t\t// rather than silently getting the default. See `rejectEmptyColor`.\n\t\t\t\trejectEmptyColor(itemOpts.color, 'color')\n\t\t\t\trejectEmptyColor(objectOptions.color, 'color')\n\t\t\t\tsetOrClear(\n\t\t\t\t\titemOpts,\n\t\t\t\t\t'color',\n\t\t\t\t\titemOpts.color ||\n\t\t\t\t\t\tobjectOptions.color ||\n\t\t\t\t\t\ttarget.color ||\n\t\t\t\t\t\t(itemOpts.hyperlink || objectOptions.hyperlink ? undefined : DEF_FONT_COLOR)\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// A.2: Placeholder should inherit their bullets or override them, so don't default them\n\t\t\tif (itemOpts.placeholder || isPlaceholder) {\n\t\t\t\titemOpts.bullet = itemOpts.bullet || false\n\t\t\t}\n\n\t\t\t// A.3: Text targeting a placeholder need to inherit the placeholders options (eg: margin, valign, etc.)\n\t\t\tif (itemOpts.placeholder && target._slideLayout && target._slideLayout._slideObjects) {\n\t\t\t\tconst placeHold = findLayoutPlaceholder(target._slideLayout, itemOpts.placeholder)\n\t\t\t\tif (placeHold?.options) {\n\t\t\t\t\t// A placeholder SUPPLIES an option; it never IMPOSES one. Every key the caller wrote\n\t\t\t\t\t// on this bag wins, and the placeholder fills in the rest -- which is what \"text\n\t\t\t\t\t// targeting a placeholder inherits its options\" means, and what makes a slide match\n\t\t\t\t\t// its layout without silently discarding what the caller asked for.\n\t\t\t\t\t//\n\t\t\t\t\t// `{ ...itemOpts, ...placeHold.options }` was the other way round, so the placeholder\n\t\t\t\t\t// won on every key it stated: `addText('x', { placeholder: 'body', valign: 'top' })`\n\t\t\t\t\t// took the layout's anchor and the caller's `valign` did nothing.\n\t\t\t\t\t//\n\t\t\t\t\t// It is PowerPoint's own model. A layout placeholder given a bottom anchor and a 1in\n\t\t\t\t\t// left inset, with the slide's placeholder then re-anchored to the top, writes\n\t\t\t\t\t// `<a:bodyPr lIns=\"914400\" anchor=\"b\"/>` on the layout and `<a:bodyPr anchor=\"t\"/>` on\n\t\t\t\t\t// the slide: the slide states only what it overrides, the inset is simply absent, and\n\t\t\t\t\t// the stated anchor is the one that applies (`placeholder-override.pptx`).\n\t\t\t\t\t//\n\t\t\t\t\t// `authoredKeys`, not \"is the key present\": `bullet` is defaulted to `false` a few\n\t\t\t\t\t// lines above for exactly these objects, so testing presence would let that default\n\t\t\t\t\t// beat the layout's bullet -- which is not the same statement as letting a caller\n\t\t\t\t\t// beat it.\n\t\t\t\t\tconst stated = authoredKeys.get(itemOpts) ?? new Set<string>()\n\t\t\t\t\tconst inherited: Record<string, unknown> = {}\n\t\t\t\t\tfor (const [key, value] of Object.entries(placeholderOptionsForSlide(placeHold.options))) {\n\t\t\t\t\t\t// A key the placeholder carries as an explicit `undefined` supplies nothing, and\n\t\t\t\t\t\t// copying it would turn \"the layout said nothing\" into a stated `undefined` on a\n\t\t\t\t\t\t// bag that is spread further downstream.\n\t\t\t\t\t\tif (value !== undefined && !stated.has(key)) inherited[key] = value\n\t\t\t\t\t}\n\t\t\t\t\titemOpts = { ...itemOpts, ...inherited }\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// B: Line defaults for a line-shaped text box.\n\t\t\t//\n\t\t\t// The `line = line || {}` below used to run AFTER this block, and this block only\n\t\t\t// *assigns* its result when `itemOpts.line` is already an object -- so a first pass over\n\t\t\t// options carrying no `line` at all computed the defaults and threw them away, and only\n\t\t\t// a SECOND pass over the same object saw the `{}` the line below had installed. The\n\t\t\t// bare-string form of `addText` was the only caller that got one, because it handed one\n\t\t\t// options object to both the shape and its run and so cleaned it twice: the same call,\n\t\t\t// with the same `shape: 'line'`, emitted a 1pt solid stroke through the string overload\n\t\t\t// and an empty `<a:ln>` through the array one. Installing the bag first makes one pass\n\t\t\t// enough, and makes the two overloads agree on the visible line.\n\t\t\titemOpts.line = itemOpts.line || {}\n\t\t\t// A text box has no outline unless it is drawn as a line, so only a line takes the\n\t\t\t// shape outline defaults.\n\t\t\tif (itemOpts.shape === ShapeType.line && typeof itemOpts.line === 'object')\n\t\t\t\titemOpts.line = withLineDefaults(itemOpts.line, 'line.color')\n\n\t\t\t// C: Line-spacing opts\n\t\t\t// `NaN` is falsy, so the truthiness test is the whole guard; an out-of-range value is\n\t\t\t// clamped and reported by `clamp.ts` at emit rather than dropped without a word here.\n\t\t\t// Only an unstated spacing is removed. `NaN` is kept so the clamp refuses it by name.\n\t\t\tif (itemOpts.lineSpacing == null || itemOpts.lineSpacing === 0) delete itemOpts.lineSpacing\n\t\t\tif (itemOpts.lineSpacingMultiple == null || itemOpts.lineSpacingMultiple === 0)\n\t\t\t\tdelete itemOpts.lineSpacingMultiple\n\n\t\t\t// D: Transform text options to bodyProperties as thats how we build XML\n\t\t\t// Copy, never adopt: an incoming `_bodyProp` belongs to something else. It arrives here\n\t\t\t// from a caller reusing a literal that a previous `addText` wrote to, and from the\n\t\t\t// A.3 branch above, which spreads a LAYOUT placeholder's options onto the slide's.\n\t\t\t// Adopting it makes the two shapes share one body-property record, so the last writer\n\t\t\t// of `numCol`/`anchor`/`vert` wins for all of them.\n\t\t\titemOpts._bodyProp = { ...itemOpts._bodyProp }\n\t\t\t// A placeholder inherits its anchor from the layout, so the key comes off rather than\n\t\t\t// being written as an `undefined` — this bag is spread onto a slide's options in A.3.\n\t\t\tsetOrClear(itemOpts._bodyProp, 'anchor', !itemOpts.placeholder ? TextAnchor.ctr : undefined) // VALS: [t,ctr,b]\n\t\t\t// `textDirection` is the documented public option; `vert` is a legacy/extended alias kept as an\n\t\t\t// escape hatch for the full ST_TextVerticalType range (eaVert, mongolianVert, wordArtVertRtl).\n\t\t\t// Both map directly to the `<a:bodyPr vert=\"…\">` attribute, so prefer the documented one.\n\t\t\tsetOrClear(itemOpts._bodyProp, 'vert', itemOpts.textDirection ?? itemOpts.vert) // VALS: [eaVert,horz,mongolianVert,vert,vert270,wordArtVert,wordArtVertRtl]\n\t\t\titemOpts._bodyProp.wrap = typeof itemOpts.wrap === 'boolean' ? itemOpts.wrap : true\n\t\t\t// The four text insets. This used to be computed by the text serializer, which owns no\n\t\t\t// options and says so: `_bodyProp` is normalized here, and normalizing half of it in\n\t\t\t// one place and half in another is how the two readings drift.\n\t\t\tconst insets = resolveInsetsEmu(itemOpts.margin)\n\t\t\tsetOrClear(itemOpts._bodyProp, 'lIns', insets?.l)\n\t\t\tsetOrClear(itemOpts._bodyProp, 'tIns', insets?.t)\n\t\t\tsetOrClear(itemOpts._bodyProp, 'rIns', insets?.r)\n\t\t\tsetOrClear(itemOpts._bodyProp, 'bIns', insets?.b)\n\t\t\tsetOrClear(itemOpts._bodyProp, 'prstTxWarp', itemOpts.textWarp) // preset text warp (`<a:prstTxWarp>`), e.g. 'textArchUp'\n\n\t\t\t// D.1: Text columns (`numCol` range is 1-16 per ECMA-376 ST_TextColumnCount)\n\t\t\tif (itemOpts.columns !== undefined) {\n\t\t\t\tif (\n\t\t\t\t\ttypeof itemOpts.columns !== 'number' ||\n\t\t\t\t\t!Number.isFinite(itemOpts.columns) ||\n\t\t\t\t\titemOpts.columns < 1 ||\n\t\t\t\t\titemOpts.columns > 16\n\t\t\t\t) {\n\t\t\t\t\twarn('text/invalid-columns', 'text `columns` must be a number 1-16 (ignoring value)')\n\t\t\t\t} else {\n\t\t\t\t\titemOpts._bodyProp.numCol = Math.round(itemOpts.columns)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (itemOpts.columnSpacing !== undefined) {\n\t\t\t\tif (\n\t\t\t\t\ttypeof itemOpts.columnSpacing !== 'number' ||\n\t\t\t\t\t!Number.isFinite(itemOpts.columnSpacing) ||\n\t\t\t\t\titemOpts.columnSpacing < 0\n\t\t\t\t) {\n\t\t\t\t\twarn('text/invalid-column-spacing', 'text `columnSpacing` must be a number >= 0 (ignoring value)')\n\t\t\t\t} else {\n\t\t\t\t\titemOpts._bodyProp.spcCol = ptsToEmuLenient(itemOpts.columnSpacing)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// E: Normalize shorthand `underline: true` to the object form\n\t\t\tif (typeof itemOpts.underline === 'boolean' && itemOpts.underline === true) itemOpts.underline = { style: 'sng' }\n\t\t}\n\n\t\t// STEP 2: Transform `align`/`valign` to XML values, store in _bodyProp for XML gen\n\t\t{\n\t\t\tconst align = (itemOpts.align || '').toLowerCase()\n\t\t\tif (align.startsWith('c')) itemOpts._bodyProp.align = AlignH.center\n\t\t\telse if (align.startsWith('l')) itemOpts._bodyProp.align = AlignH.left\n\t\t\telse if (align.startsWith('r')) itemOpts._bodyProp.align = AlignH.right\n\t\t\telse if (align.startsWith('j')) itemOpts._bodyProp.align = AlignH.justify\n\n\t\t\tconst anchor = resolveTextAnchor(itemOpts.valign)\n\t\t\tif (anchor) itemOpts._bodyProp.anchor = anchor\n\t\t}\n\n\t\t// STEP 3: ROBUST: Set rational values for some shadow props if needed.\n\t\t// Assigned, not discarded: the normalizer is pure, and `_alpha` is what\n\t\t// `genXmlTextRunProperties` reads for a run's shadow transparency.\n\t\tsetOrClear(itemOpts, 'shadow', normalizeShadowOptions(itemOpts.shadow))\n\n\t\treturn itemOpts\n\t}\n\n\t// STEP 1: Create/Clean object options\n\tnewObject.options = cleanOpts(objectOptions)\n\n\t// STEP 1-A: A text box with no height stated anywhere gets 0.3in of it.\n\t//\n\t// `addShapeDefinition` defaults all four axes; this path defaulted none, so `addText('hi',\n\t// { x, y, w })` emitted `<a:ext cy=\"0\">` — the degenerate zero-size object the project's own\n\t// API rules say to refuse. There WAS a rescue for it, in the text serializer, guarded by\n\t// `!itemOpts.line`; step C above has written `itemOpts.line = itemOpts.line || {}` since\n\t// before that guard existed, so the guard was never once true and the rescue never ran.\n\t//\n\t// Two things move it here rather than fixing the guard in place. It sits beside the other\n\t// defaults, where the caller's own value is still distinguishable from silence — `h: 0`\n\t// stated explicitly is kept, exactly as `addShapeDefinition` keeps it, which the serializer\n\t// could not do because a stated zero and an absent height both arrive there as `cy === 0`.\n\t// And the exemption the guard was reaching for is a *shape* question, not a line-options\n\t// one: a `line` is drawn zero-height on purpose (a horizontal rule), and that is knowable\n\t// here from `shape` alone.\n\t//\n\t// Read after `cleanOpts`, not before: a caller who named a layout placeholder inherits that\n\t// placeholder's frame in step A.3, so a height can arrive without the caller stating one.\n\t// A line takes no default height and no zero-extent warning: it is drawn with no height on purpose.\n\tif (newObject.shape !== ShapeType.line)\n\t\tObject.assign(newObject.options, resolveAuthoredFrame(newObject.options, { h: 0.3 }, 'addText'))\n\n\t// STEP 1a: Selection Pane identity (`objectName`). Set once here, on the shape-level object\n\t// only — not inside `cleanOpts`, which also runs per text run (STEP 2 below). `Slide.addText`'s\n\t// single-string convenience form reuses the same options object for both the shape and its lone\n\t// run, so encoding this inside `cleanOpts` encoded a caller-supplied name twice. A placeholder's\n\t// default identity is its declared name (falling back to its type, then its idx). Placeholders\n\t// are `placeholder`-typed objects and so take their name index from their own bucket; naming\n\t// them `Text N` off the text-box bucket would collide with the slide's real text boxes.\n\tconst placeholderName = isPlaceholder\n\t\t? String(\n\t\t\t\tnewObject.options.placeholder ||\n\t\t\t\t\tnewObject.options._placeholderType ||\n\t\t\t\t\t`Placeholder ${newObject.options._placeholderIdx ?? target._slideObjects.length}`\n\t\t\t)\n\t\t: undefined\n\tnewObject.options.objectName = resolveObjectName(target, newObject._type, {\n\t\tlabel: 'Text',\n\t\tkind: 'text',\n\t\tsupplied: newObject.options.objectName,\n\t\t...(placeholderName === undefined ? {} : { fallback: placeholderName }),\n\t})\n\n\t// STEP 1b: Standalone placeholder type (accessibility \"Missing Slide Title\")\n\t// `placeholder` is documented as a placeholder *type* ('title', 'body', et. al.). When it\n\t// resolves to a layout placeholder the layout object supplies the <p:ph> at serialize time,\n\t// but with a blank/default layout there is no match and no <p:ph> was emitted - so PowerPoint's\n\t// accessibility checker reports the slide as having no title. Record the type here so a real\n\t// <p:ph type=\"...\"/> is emitted on the slide shape even without a matching layout placeholder.\n\tif (!isPlaceholder && newObject.options.placeholder && !newObject.options._placeholderType) {\n\t\tnewObject.options._placeholderType = newObject.options.placeholder as PLACEHOLDER_TYPE\n\t}\n\n\t// STEP 2: Create/Clean text options\n\ttextObjects.forEach((item) => (item.options = cleanOpts(item.options || {})))\n\n\t// STEP 3: Create hyperlinks — for the SHAPE and for its runs, which are two `hlinkClick`\n\t// elements resolving two relationship ids (`p:cNvPr`'s and each `a:rPr`'s). Handing over the\n\t// run list alone left the shape's `r:id` pointing at a relationship nothing had minted; it went\n\t// unseen while `addText`'s bare-string form gave the shape's own options object to its one run,\n\t// because the run then minted the id the shape read back off that same object.\n\tcreateHyperlinkRels(target, newObject)\n\n\t// STEP 4: Create picture-bullet image rels\n\tcreateBulletImageRels(target, newObject.options, textObjects)\n\n\t// STEP 5: Register an image fill (if any) as a media relationship for serialize-time blipFill\n\tif (typeof newObject.options.fill === 'object' && resolveFillKind(newObject.options.fill) === 'image') {\n\t\tregisterImageFillMedia(target, newObject.options.fill)\n\t}\n\n\t// LAST: Add object to Slide\n\ttarget._slideObjects.push(newObject)\n}\n\n/**\n * A copy of a layout placeholder's options for a slide object to adopt.\n *\n * The nested options that carry a relationship id are copied too, without that id: `fill` (an\n * image fill's `_imgRid`), `hyperlink` (`_rId`) and `bullet` (a picture bullet's `_rId` and\n * `_rIdSvg`), so the slide registers its own. A plain spread shared them with the layout, so the\n * slide's registration wrote the slide's ids onto the layout's objects. The layout then emitted\n * an id its own part does not declare, and a slide that had already given that id to something\n * else was handed it a second time.\n * @param options - the layout placeholder's options\n * @returns a copy safe to register a slide's relationships through\n */\nexport function placeholderOptionsForSlide<T extends object>(options: T): T {\n\tconst copy: Record<string, unknown> = { ...(options as Record<string, unknown>) }\n\tfor (const key of ['fill', 'hyperlink', 'bullet']) {\n\t\tconst value = copy[key]\n\t\tif (value && typeof value === 'object') {\n\t\t\tconst rest: Record<string, unknown> = { ...value }\n\t\t\tdelete rest['_imgRid']\n\t\t\tdelete rest['_rId']\n\t\t\tdelete rest['_rIdSvg']\n\t\t\tcopy[key] = rest\n\t\t}\n\t}\n\treturn copy as T\n}\n\n/**\n * Register slide media relationships for any picture bullets (`bullet.image`) used by a text object.\n * Picture bullets render as `<a:buBlip><a:blip r:embed=\"rId..\"/></a:buBlip>`, so the bullet image\n * needs the same media-rel + package-part plumbing as `addImage()`. The assigned `rId` is stored on\n * the bullet options object (`_rId`) so XML generation can reference it.\n * @param {PresSlideInternal} target - slide receiving the rels\n * @param objectOptions - shape-level text options (bullet may live here)\n * @param {TextProps[]} textObjects - per-paragraph text options (bullet may live here too)\n */\nfunction createBulletImageRels(\n\ttarget: PresSlideInternal,\n\tobjectOptions: ObjectOptionsInternal,\n\ttextObjects: TextProps[]\n): void {\n\t// Collect every bullet options object that requests a picture bullet (shape-level + per-paragraph).\n\t// Shape-level bullets are later shared by reference onto the first run, so the same object may appear\n\t// twice; the `_rId` guard below makes the registration idempotent.\n\tconst bulletObjs: Array<{ image?: { path?: string; data?: string }; _rId?: number; _rIdSvg?: number }> = []\n\tconst collect = (opts?: TextPropsOptions): void => {\n\t\tif (opts && typeof opts.bullet === 'object' && opts.bullet) bulletObjs.push(opts.bullet)\n\t}\n\tcollect(objectOptions)\n\ttextObjects.forEach((item) => collect(item.options))\n\n\tbulletObjs.forEach((bullet) => {\n\t\tconst img = bullet.image\n\t\tif (!img || (!img.path && !img.data)) return\n\n\t\t// REALITY-CHECK: base64 `data` must carry a base64 header (mirror addImage()). Unlike\n\t\t// `addImage()` this warns rather than throws: refusing the rel is not fatal, because the run\n\t\t// emitter falls back to a default glyph and the deck still opens.\n\t\tconst source = resolveImageSource(img)\n\t\tif (typeof source === 'string') {\n\t\t\twarn(\n\t\t\t\t'bullet/image-missing-base64-header',\n\t\t\t\t\"bullet.image `data` value lacks a base64 header, ex: 'image/png;base64,iVBOR[...]'\"\n\t\t\t)\n\t\t\treturn\n\t\t}\n\n\t\t// Auto-paging clones text objects onto new slides while sharing the bullet options object by\n\t\t// reference, so `_rId` may already be set from the originating slide. Skip when this slide already\n\t\t// carries the rel; otherwise (re-)register so the new slide's .rels and media part exist.\n\t\tif (bullet._rId && target._relsMedia.some((rel) => rel.rId === bullet._rId)) return\n\n\t\t// The `data:` mime wins, else the path's extension (mirror addImageDefinition())\n\t\tconst strImgExtn = source.extn\n\n\t\tif (strImgExtn === 'svg') {\n\t\t\t// SVG bullets consume *TWO* rels, mirroring addImage(): a PNG preview (referenced by the\n\t\t\t// `<a:buBlip><a:blip r:embed>`) plus the SVG itself (referenced by the `asvg:svgBlip` ext).\n\t\t\t// Auto-paging shares one bullet options object across the overflow slides, so a re-registration\n\t\t\t// has to keep the pair of ids that object already carries rather than mint a new one.\n\t\t\tconst pinned = bullet._rId && bullet._rIdSvg ? { pngRid: bullet._rId, svgRid: bullet._rIdSvg } : undefined\n\t\t\tconst { pngRid, svgRid } = registerSvgImageRels(target, { path: source.path, data: source.data }, pinned)\n\t\t\tbullet._rId = pngRid\n\t\t\tbullet._rIdSvg = svgRid\n\t\t} else {\n\t\t\tconst relId = bullet._rId || getNewRelId(target)\n\t\t\tpushMediaRel(target, {\n\t\t\t\tkind: 'image',\n\t\t\t\textn: strImgExtn,\n\t\t\t\ttype: imageContentType(strImgExtn),\n\t\t\t\tpath: source.path,\n\t\t\t\tdata: source.data,\n\t\t\t\trId: relId,\n\t\t\t})\n\t\t\tbullet._rId = relId\n\t\t}\n\t})\n}\n","/**\n * ts-pptx: what an OLE object, a 3D model, a zoom and a media object record about themselves\n *\n * Each of these definers built the same options literal for its slide record, the frame, the\n * Selection Pane name, the alt text and the lock flags, with only the name's label and the frame's\n * defaults differing; media spelled it as a run of `if`s. The three that embed a payload also\n * refused a missing source with the same throw, word for word but for the method's name.\n */\n\nimport type { InvalidOptionErrorCode } from '../../codes.js'\nimport type { SlideObjectType } from '../../enums.js'\nimport { InvalidOptionError } from '../../errors.js'\nimport type { Coord } from '../../types/index.js'\nimport type { ObjectOptionsInternal, PresSlideInternal } from '../../types/internal.js'\nimport type { ObjectLockProps } from '../../types/object.js'\nimport { type AuthoredFrame, resolveAuthoredFrame } from './frame.js'\nimport { resolveObjectName } from './object-name.js'\n\n/** The options every one of these objects takes: a frame, a name, alt text and locks. */\nexport type FramedObjectProps = AuthoredFrame & {\n\tobjectName?: string | undefined\n\taltText?: string | undefined\n\tobjectLock?: ObjectLockProps | undefined\n}\n\n/**\n * The options an object's slide record carries: its frame, its Selection Pane name, and its alt\n * text and lock flags when the caller stated them.\n *\n * The name takes its index before the frame is resolved, so a definer calls this after its own\n * checks have passed: a throw before it leaves the kind's name counter where it was.\n * @param target - the slide the object is added to\n * @param type - the object's `_type`, which selects the name counter\n * @param opt - the caller's options\n * @param spec - `label` opens the default name and `kind` names the object in a name warning (see\n * `resolveObjectName`); `api` opens a frame warning and `defaults` fills each axis left unstated\n * (see `resolveAuthoredFrame`)\n */\nexport function framedObjectOptions(\n\ttarget: PresSlideInternal,\n\ttype: SlideObjectType,\n\topt: FramedObjectProps,\n\tspec: { label: string; kind: string; api: string; defaults: Record<'x' | 'y' | 'w' | 'h', Coord> }\n): ObjectOptionsInternal {\n\tconst objectName = resolveObjectName(target, type, { label: spec.label, kind: spec.kind, supplied: opt.objectName })\n\treturn {\n\t\t...resolveAuthoredFrame(opt, spec.defaults, spec.api),\n\t\tobjectName,\n\t\t...(opt.altText ? { altText: opt.altText } : {}),\n\t\t...(opt.objectLock ? { objectLock: opt.objectLock } : {}),\n\t}\n}\n\n/**\n * Refuse an embedded object that names neither a `path` nor `data`: the payload is the object, and\n * there is no default to embed in its place.\n * @param opt - the caller's options\n * @param code - the error's code, in the object's own namespace\n * @param api - the method the caller called, opening the message\n */\nexport function requirePayloadSource(\n\topt: { path?: string | undefined; data?: string | undefined },\n\tcode: Extract<InvalidOptionErrorCode, `${string}/missing-source`>,\n\tapi: string\n): void {\n\tif (!opt.path && !opt.data) throw new InvalidOptionError(code, `${api}(): either \\`data\\` or \\`path\\` are required!`)\n}\n","/**\n * ts-pptx: Media Definition\n *\n * `addMediaDefinition` registers an `addMedia()` audio / video (or online video) source: each\n * embedded A/V consumes two rels (ECMA video + MS-2007 media) plus a cover image; online videos\n * use the external-link variant. The timing / `<p:pic>` XML is emitted later.\n */\nimport { SlideObjectType } from '../../enums.js'\nimport { warn } from '../../diagnostics.js'\nimport type { MediaProps } from '../../types/index.js'\nimport type { PresSlideInternal, SlideObject } from '../../types/internal.js'\nimport { getNewRelId, preencodedPath } from '../utils.js'\nimport { hasBase64Header } from '../../media/base64.js'\nimport { pushMediaRel } from './image-rel.js'\nimport { framedObjectOptions, requirePayloadSource } from './object-options.js'\nimport { InternalError, InvalidOptionError } from '../../errors.js'\n\n/**\n * One media item costs three consecutive slide rels, allocated together by {@link addMedia}:\n * the ECMA `audio`/`video` rel (the id kept on the object as `mediaRid`), the MS-2007 `media`\n * rel sharing its Target, and the preview/poster image.\n *\n * The two offsets used to be bare arithmetic wherever a body or a descriptor needed one of the\n * other two rels, in three modules; `gen/anim/timing.ts` even carries a comment warning against\n * writing `mediaRid + 2` in a place where it means something else entirely. Naming them puts\n * the layout in one place, and {@link assertConsecutiveMediaRids} makes the assumption they\n * rest on fail loudly instead of quietly emitting a body that points at the wrong rel.\n */\nexport const msMediaRid = (mediaRid: number): number => mediaRid + 1\n\n/** The preview/poster image rel's id; see {@link msMediaRid}. */\nexport const previewRid = (mediaRid: number): number => mediaRid + 2\n\n/**\n * Check that a media item's three rels really did come out consecutive. The ids come from\n * three separate `getNewRelId` calls, so nothing but call order makes them so — and every\n * reader of the triple assumes it.\n */\nfunction assertConsecutiveMediaRids(base: number, second: number, third: number): void {\n\tif (second !== msMediaRid(base) || third !== previewRid(base))\n\t\tthrow new InternalError(\n\t\t\t'media/rel-ids-not-consecutive',\n\t\t\t`addMedia expected rel ids ${base}, ${msMediaRid(base)}, ${previewRid(base)}; got ${base}, ${second}, ${third}`\n\t\t)\n}\n\n/**\n * Adds a media object to a slide definition.\n * @param {PresSlideInternal} `target` - slide object that the media will be added to\n * @param {MediaProps} `opt` - media options\n */\nexport function addMediaDefinition(target: PresSlideInternal, opt: MediaProps): void {\n\tconst strData = opt.data || ''\n\tconst strLink = opt.link || ''\n\tconst strPath = opt.path || ''\n\tconst strType = opt.type || 'audio'\n\t// Empty when the caller passed no cover: the default play-button poster is resolved later,\n\t// by the async media pass, so that a deck carrying no media never links the artwork. The\n\t// base64-header check below still guards a cover the caller *did* pass.\n\tconst strCover = opt.cover || ''\n\tconst slideData: SlideObject = { _type: SlideObjectType.media }\n\n\t// STEP 1: REALITY-CHECK, before the object name below takes its index\n\tif (strType !== 'online') requirePayloadSource(opt, 'media/missing-source', 'addMedia')\n\tif (strData && !hasBase64Header(strData)) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'media/missing-base64-header',\n\t\t\t\"addMedia(): `data` value lacks a base64 header! Ex: 'video/mpeg;base64,NMP[...]')\"\n\t\t)\n\t} else if (strCover && !hasBase64Header(strCover)) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'media/cover-missing-base64-header',\n\t\t\t\"addMedia(): `cover` value lacks a base64 header! Ex: 'data:image/png;base64,iV[...]')\"\n\t\t)\n\t}\n\t// Online Video: requires `link`\n\tif (strType === 'online' && !strLink) {\n\t\tthrow new InvalidOptionError('media/online-missing-link', 'addMedia(): online videos require `link` value')\n\t}\n\tconst options = framedObjectOptions(target, SlideObjectType.media, opt, {\n\t\tlabel: 'Media',\n\t\tkind: 'media',\n\t\tapi: 'addMedia',\n\t\tdefaults: { x: 0, y: 0, w: 2, h: 2 },\n\t})\n\n\tconst strExtn =\n\t\topt.extn || (strData ? (strData.split(';')[0] ?? '').split('/')[1] : strPath.split('.').pop()) || 'mp3'\n\n\t// STEP 2: Set type, media and the object's options\n\tslideData.mtype = strType\n\tslideData.media = strPath || preencodedPath('mov')\n\tslideData.options = options\n\n\t// Playback looping (embedded audio/video only; online embeds have no timing tree)\n\tif (strType !== 'online') {\n\t\tif (opt.loop) slideData.loop = true\n\t\telse if (typeof opt.loopCount === 'number' && Number.isFinite(opt.loopCount) && opt.loopCount > 0)\n\t\t\tslideData.loopCount = opt.loopCount\n\t\t// A stated count that plays nothing used to be dropped without a word, and `Infinity` was\n\t\t// written as `repeatCount=\"Infinity\"`.\n\t\telse if (opt.loopCount != null)\n\t\t\twarn(\n\t\t\t\t'media/invalid-loop-count',\n\t\t\t\t`addMedia(): \\`loopCount\\` is how many times to play, a finite number above 0; got ${String(opt.loopCount)}, so the media plays once. Use \\`loop: true\\` to repeat it without end.`\n\t\t\t)\n\t}\n\n\t// STEP 3: Add this media to this Slide Rels (rId/rels count spans all slides! Count all media to get next rId)\n\t/**\n\t * NOTE:\n\t * - rId starts at 2 (hence the intRels+1 below) as slideLayout.xml is rId=1!\n\t *\n\t * NOTE:\n\t * - Audio/Video files consume *TWO* rId's:\n\t * <Relationship Id=\"rId2\" Target=\"../media/media1.mov\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video\"/>\n\t * <Relationship Id=\"rId3\" Target=\"../media/media1.mov\" Type=\"http://schemas.microsoft.com/office/2007/relationships/media\"/>\n\t */\n\t// A and B are the two rels an online video registers differently from an embedded one.\n\tlet mediaRid: number\n\tlet msRid: number\n\tif (strType === 'online') {\n\t\t// A: ECMA video rel (external link) — referenced by <a:videoFile r:link>.\n\t\tconst online = { kind: 'media', extn: strExtn, type: 'online', path: strPath, data: 'dummy' }\n\t\tmediaRid = getNewRelId(target)\n\t\tpushMediaRel(target, { ...online, rId: mediaRid, target: { external: strLink } })\n\n\t\t// B: MS-2007 media rel — PowerPoint authors a second external rel sharing the\n\t\t// same link Target; the body points at it via <p14:media r:link>. (Mirrors the\n\t\t// embedded A/V pair, but External and with no media binary part.)\n\t\tmsRid = getNewRelId(target)\n\t\tpushMediaRel(target, { ...online, rId: msRid, target: { external: strLink } })\n\t} else {\n\t\t// A: \"relationships/video\". An identical source already on the slide — the same path, or the\n\t\t// same inline payload — lends its part rather than embedding the bytes twice.\n\t\tconst embedded = { kind: 'media', extn: strExtn, type: strType + '/' + strExtn, path: strPath, data: strData }\n\t\tmediaRid = getNewRelId(target)\n\t\tconst video = pushMediaRel(target, { ...embedded, rId: mediaRid, dedupe: true })\n\n\t\t// B: \"relationships/media\", against the one part the `video` rel above named.\n\t\tmsRid = getNewRelId(target)\n\t\tpushMediaRel(target, { ...embedded, rId: msRid, target: { sameAs: video } })\n\t}\n\tslideData.mediaRid = mediaRid\n\n\t// C: Add cover (preview/overlay) image\n\tconst coverRid = getNewRelId(target)\n\tpushMediaRel(target, {\n\t\tkind: 'image',\n\t\textn: 'png',\n\t\ttype: 'image/png',\n\t\tdata: strCover,\n\t\trId: coverRid,\n\t\textra: { isDefaultCover: !strCover },\n\t})\n\tassertConsecutiveMediaRids(mediaRid, msRid, coverRid)\n\n\t// LAST\n\ttarget._slideObjects.push(slideData)\n}\n","/**\n * An `mc:AlternateContent` envelope: a Choice for consumers that understand one namespace, and an\n * optional Fallback for everyone else.\n *\n * Six emitters wrapped their markup this way (a transition's exact duration, a text shape holding\n * an equation, a chartEx frame, an OLE object, a 3D model, a zoom), and each restated the rule that\n * makes the envelope work: the prefix named in `Requires` has to be declared on the Choice itself,\n * or a consumer reading `Requires` cannot resolve it. Stated here once.\n */\n\nimport { OOXML_NS } from '../../ooxml/namespaces.js'\nimport { el, raw } from './el.js'\n\n/**\n * Build the envelope.\n * @param opts.requires - the namespace the Choice needs: its prefix and URI, declared on the Choice\n * @param opts.choice - the already-serialized markup for a consumer that understands it\n * @param opts.fallback - the already-serialized markup for one that does not, when there is any\n */\nexport function alternateContentEl(opts: {\n\trequires: { prefix: string; uri: string }\n\tchoice: string\n\tfallback?: string\n}): string {\n\tconst { prefix, uri } = opts.requires\n\treturn el('mc:AlternateContent', { 'xmlns:mc': OOXML_NS.mc }, [\n\t\traw(el('mc:Choice', { [`xmlns:${prefix}`]: uri, Requires: prefix }, raw(opts.choice))),\n\t\t...(opts.fallback === undefined ? [] : [raw(el('mc:Fallback', null, raw(opts.fallback)))]),\n\t])\n}\n","/**\n * ts-pptx: DrawingML object-lock serialization\n *\n * Emit the `a:spLocks` / `a:picLocks` / `a:graphicFrameLocks` / group-shape lock\n * elements. Each locking element type supports a different set of flags; the\n * `*_LOCK_ATTRS` tables list the valid attribute names in ECMA-376 emit order.\n */\n\nimport type { ObjectLockProps } from '../../types/index.js'\nimport { voidEl } from '../oxml/el.js'\nimport { warn } from '../../diagnostics.js'\n\n// Object lock attributes valid for each DrawingML locking element, in emit order (ECMA-376 §20.1.2.2.x / §20.1.2.2.34).\n// Every name is a key of `ObjectLockProps`, so serialization is a filtered lookup; the assertion\n// below the four tables is what keeps that true.\nexport const SHAPE_LOCK_ATTRS = [\n\t'noGrp',\n\t'noSelect',\n\t'noRot',\n\t'noChangeAspect',\n\t'noMove',\n\t'noResize',\n\t'noEditPoints',\n\t'noAdjustHandles',\n\t'noChangeArrowheads',\n\t'noChangeShapeType',\n\t'noTextEdit',\n] as const\nexport const PICTURE_LOCK_ATTRS = [\n\t'noGrp',\n\t'noSelect',\n\t'noRot',\n\t'noChangeAspect',\n\t'noMove',\n\t'noResize',\n\t'noEditPoints',\n\t'noAdjustHandles',\n\t'noChangeArrowheads',\n\t'noChangeShapeType',\n\t'noCrop',\n] as const\nexport const GRAPHIC_FRAME_LOCK_ATTRS = [\n\t'noGrp',\n\t'noDrilldown',\n\t'noSelect',\n\t'noChangeAspect',\n\t'noMove',\n\t'noResize',\n] as const\nexport const GROUP_SHAPE_LOCK_ATTRS = ['noGrp', 'noSelect', 'noRot', 'noChangeAspect', 'noMove', 'noResize'] as const\n\n/** Every attribute name the four tables between them list. */\ntype LockAttrName =\n\t| (typeof SHAPE_LOCK_ATTRS)[number]\n\t| (typeof PICTURE_LOCK_ATTRS)[number]\n\t| (typeof GRAPHIC_FRAME_LOCK_ATTRS)[number]\n\t| (typeof GROUP_SHAPE_LOCK_ATTRS)[number]\n\n/**\n * Both halves of \"the tables mirror `ObjectLockProps`\", checked rather than asserted in a comment.\n *\n * No single table can be exhaustive — the four locking elements accept different attribute\n * subsets, and each table's order is byte-significant — so the claim is about their union. A key\n * added to the interface and to no table makes the second entry `never`, and a name in a table\n * that is not a key of the interface makes the first one `never`; either way `true` stops being\n * assignable and this fails to compile.\n *\n * Nothing imports it and nothing ever will: the `export` is what keeps it from being reported as\n * an unused binding, which is the one thing that would get an assertion like this deleted. Left\n * exported deliberately rather than by oversight — this note is the difference between the two.\n */\nexport const LOCK_ATTRS_MATCH_OBJECT_LOCK_PROPS: [\n\tLockAttrName extends keyof ObjectLockProps ? true : never,\n\tkeyof Required<ObjectLockProps> extends LockAttrName ? true : never,\n] = [true, true]\n\n/**\n * Serialize an object-lock element (`a:spLocks` / `a:picLocks` / `a:graphicFrameLocks`).\n * Only flags set to `true` AND valid for this element type are emitted; a flag set on an\n * unsupported element type is dropped with a warning (silent coercion is a footgun).\n * @param tag - locking element tag, e.g. `'a:spLocks'`\n * @param allowed - attribute names this element type supports, in desired emit order\n * @param locks - merged lock flags (callers fold any hard-coded default in first)\n * @param objectName - for the warning message\n * @returns the locking element string, or `''` when no applicable flag is set\n */\nexport function genXmlObjectLock(\n\ttag: string,\n\tallowed: readonly string[],\n\tlocks: ObjectLockProps | undefined,\n\tobjectName?: string\n): string {\n\tif (!locks) return ''\n\tconst lockMap = locks as Record<string, boolean | undefined>\n\tfor (const key of Object.keys(lockMap)) {\n\t\tif (lockMap[key] && !allowed.includes(key)) {\n\t\t\twarn(\n\t\t\t\t'object-lock/unsupported-on-shape',\n\t\t\t\t`objectLock.${key} is not supported on <${tag}> (object \"${objectName ?? ''}\") and was ignored.`\n\t\t\t)\n\t\t}\n\t}\n\tconst set = allowed.filter((name) => lockMap[name] === true)\n\treturn set.length > 0 ? voidEl(tag, Object.fromEntries(set.map((name) => [name, '1']))) : ''\n}\n","/**\n * ts-pptx: the extent an image is drawn at\n *\n * An image's frame is not always the box it is drawn in. An omitted `w` or `h` is backfilled from\n * the image's natural size, and a `sizing` box replaces the frame outright. The image renderer emits\n * that extent, and a group sizing itself around an image child has to see the same one, so both\n * read it here. This module writes no XML, which is why `gen/slide/object.ts` may import it.\n */\n\nimport type {\n\tPresSlideInternal,\n\tSlideLayoutInternal,\n\tSlideMasterInternal,\n\tSlideObject,\n} from '../../../types/internal.js'\nimport { getImageSizeFromBase64 } from '../../../media/image-size.js'\nimport { pixelsToEmu } from '../../../units.js'\nimport { getSmartParseNumber } from '../../../units-internal.js'\n\n/**\n * An image's natural size in pixels, measured from its embedded media.\n *\n * The bytes are not available when `addImage()` runs, but they are loaded by the time a slide is\n * serialized, which is when every caller of this runs.\n * @param obj - the image slide object\n * @param slide - the slide or layout holding it\n * @returns the natural size, or `null` when the media is not loaded or cannot be measured\n */\nexport function imageNaturalSize(\n\tobj: SlideObject,\n\tslide: PresSlideInternal | SlideLayoutInternal | SlideMasterInternal\n): { w: number; h: number } | null {\n\tconst relData = (slide._relsMedia || []).find((rel) => rel.rId === obj.imageRid)?.data\n\treturn typeof relData === 'string' ? getImageSizeFromBase64(relData) : null\n}\n\n/**\n * The two boxes an image is placed with, in EMU.\n *\n * `frameW`/`frameH` are the frame with any omitted dimension backfilled from the natural size.\n * PowerPoint inserts images at 96 DPI, so natural pixels / 96 is the display size in inches.\n * `drawnW`/`drawnH` are the box actually drawn and emitted: the `sizing` box when there is one and\n * no `crop` overrides it, and the frame otherwise.\n * @param obj - the image slide object\n * @param slide - the slide or layout holding it\n * @param frame - the object's resolved frame\n * @returns the backfilled frame and the drawn box\n */\nexport function resolveImageExtent(\n\tobj: SlideObject,\n\tslide: PresSlideInternal | SlideLayoutInternal | SlideMasterInternal,\n\tframe: { cx: number; cy: number }\n): { frameW: number; frameH: number; drawnW: number; drawnH: number } {\n\tconst opts = obj.options ?? {}\n\tlet frameW = frame.cx\n\tlet frameH = frame.cy\n\tif (opts._szAuto) {\n\t\tconst szAuto = opts._szAuto\n\t\tconst natural = imageNaturalSize(obj, slide)\n\t\tif (natural) {\n\t\t\tif (szAuto.w && szAuto.h) {\n\t\t\t\tframeW = pixelsToEmu(natural.w, 96)\n\t\t\t\tframeH = pixelsToEmu(natural.h, 96)\n\t\t\t} else if (szAuto.h) {\n\t\t\t\t// Width supplied, derive height\n\t\t\t\tframeH = Math.round(frameW * (natural.h / natural.w))\n\t\t\t} else if (szAuto.w) {\n\t\t\t\t// Height supplied, derive width\n\t\t\t\tframeW = Math.round(frameH * (natural.w / natural.h))\n\t\t\t}\n\t\t}\n\t}\n\t// `crop` wins over `sizing`; the renderer warns about the pair.\n\tconst sizing = opts.crop ? undefined : opts.sizing\n\tif (!sizing?.type) return { frameW, frameH, drawnW: frameW, drawnH: frameH }\n\treturn {\n\t\tframeW,\n\t\tframeH,\n\t\tdrawnW: sizing.w ? getSmartParseNumber(sizing.w, 'X', slide._presLayout) : frameW,\n\t\tdrawnH: sizing.h ? getSmartParseNumber(sizing.h, 'Y', slide._presLayout) : frameH,\n\t}\n}\n","/**\n * ts-pptx: the `<a:fmtScheme>` block, shared by the two themes this library writes.\n *\n * The fill/line/effect/background style matrices that shape style indices (`<p:style>`) point\n * at. Fixed Office boilerplate: no caller data reaches it, so — unlike the `<a:clrScheme>` and\n * `<a:fontScheme>` blocks beside it in `gen/pres/theme.ts` — there is no escaping risk to remove\n * by rebuilding it node by node, and it stays a raw literal rather than ~90 nested `el()` calls\n * written for uniformity alone.\n *\n * Here rather than in either writer because both `ppt/theme/theme1.xml` and the theme inside a\n * chart's embedded workbook carry it, and they carried byte-identical 2661-character copies. Two\n * verbatim transcriptions of one Office asset is the arrangement where a correction lands in one\n * of them.\n * @raw-xml-asset\n */\nexport const FMT_SCHEME_XML =\n\t'<a:fmtScheme name=\"Office\"><a:fillStyleLst><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"110000\"/><a:satMod val=\"105000\"/><a:tint val=\"67000\"/></a:schemeClr></a:gs><a:gs pos=\"50000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"105000\"/><a:satMod val=\"103000\"/><a:tint val=\"73000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"105000\"/><a:satMod val=\"109000\"/><a:tint val=\"81000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"5400000\" scaled=\"0\"/></a:gradFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:satMod val=\"103000\"/><a:lumMod val=\"102000\"/><a:tint val=\"94000\"/></a:schemeClr></a:gs><a:gs pos=\"50000\"><a:schemeClr val=\"phClr\"><a:satMod val=\"110000\"/><a:lumMod val=\"100000\"/><a:shade val=\"100000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"99000\"/><a:satMod val=\"120000\"/><a:shade val=\"78000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"5400000\" scaled=\"0\"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w=\"6350\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/><a:miter lim=\"800000\"/></a:ln><a:ln w=\"12700\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/><a:miter lim=\"800000\"/></a:ln><a:ln w=\"19050\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/><a:miter lim=\"800000\"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad=\"57150\" dist=\"19050\" dir=\"5400000\" algn=\"ctr\" rotWithShape=\"0\"><a:srgbClr val=\"000000\"><a:alpha val=\"63000\"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:solidFill><a:schemeClr val=\"phClr\"><a:tint val=\"95000\"/><a:satMod val=\"170000\"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:tint val=\"93000\"/><a:satMod val=\"150000\"/><a:shade val=\"98000\"/><a:lumMod val=\"102000\"/></a:schemeClr></a:gs><a:gs pos=\"50000\"><a:schemeClr val=\"phClr\"><a:tint val=\"98000\"/><a:satMod val=\"130000\"/><a:shade val=\"90000\"/><a:lumMod val=\"103000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:shade val=\"63000\"/><a:satMod val=\"120000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"5400000\" scaled=\"0\"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme>'\n","/**\n * The package names a chart's parts are written under, from its package-wide id.\n *\n * Four modules spelled them: the chart definer's placeholder, the write-time pass in\n * `package/assemble.ts` that assigns the authoritative id, the chart part contributor's content-type\n * overrides, and the part writer in `embed-xlsx.ts`. A name that drifted in one of them would write a\n * part no relationship or content type names.\n *\n * Imports nothing, so `package/assemble.ts`, which every write reaches, can use it without bringing\n * chart code into a deck that has no chart.\n */\n\n/** The names one chart's parts take. */\nexport interface ChartPartNames {\n\t/** The chart part's file name, `chart{N}.xml` or `chartEx{N}.xml`. */\n\tfileName: string\n\t/** The chart part's absolute package path, as a slide relationship and a content type name it. */\n\ttarget: string\n\t/** A chartEx chart's style sidecar, `style{N}.xml`, beside the chart part. */\n\tstyleName: string\n\t/** A chartEx chart's colors sidecar, `colors{N}.xml`, beside the chart part. */\n\tcolorsName: string\n\t/** The embedded workbook's file name, in `ppt/embeddings/`. */\n\tworkbookName: string\n}\n\n/**\n * The names for the chart with package-wide id `globalId`.\n * @param globalId - the chart's id, unique across every chart part in the package\n * @param isChartEx - whether it is a chartEx chart, which uses the `chartEx{N}.xml` name family;\n * absent means a classic chart, as `SlideRelChart.isChartEx` does\n */\nexport function chartPartNames(globalId: number, isChartEx?: boolean): ChartPartNames {\n\tconst base = isChartEx ? `chartEx${globalId}` : `chart${globalId}`\n\treturn {\n\t\tfileName: `${base}.xml`,\n\t\ttarget: `/ppt/charts/${base}.xml`,\n\t\tstyleName: `style${globalId}.xml`,\n\t\tcolorsName: `colors${globalId}.xml`,\n\t\tworkbookName: `Microsoft_Excel_Worksheet${globalId}.xlsx`,\n\t}\n}\n","/**\n * ts-pptx: `docProps/core.xml`\n *\n * Emit the core-properties part (title/subject/creator/revision and the\n * created/modified timestamps).\n */\n\nimport { XML_DECL } from '../../constants-internal.js'\nimport { el, raw } from '../oxml/el.js'\nimport { OOXML_NS } from '../../ooxml/namespaces.js'\nimport { warn } from '../../diagnostics.js'\n\n/** Each property sits on its own indented line; the parent supplies the closing indent. */\nconst PROP = { openPrefix: '\\n\\t\\t' }\n\n/**\n * The five namespaces a `docProps/core.xml` declares, in the order Office writes them.\n * Shared with the embedded workbook a chart carries (`gen/chart/embed-xlsx.ts`), which is a\n * package of its own and so has a core-properties part of its own.\n */\nexport const CORE_PROPS_NS = {\n\t'xmlns:cp': OOXML_NS.cp,\n\t'xmlns:dc': OOXML_NS.dc,\n\t'xmlns:dcterms': OOXML_NS.dcterms,\n\t'xmlns:dcmitype': 'http://purl.org/dc/dcmitype/',\n\t'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',\n}\n\n/**\n * Now, as `dcterms:W3CDTF` without milliseconds — the precision Office writes.\n *\n * Call it **once** per part and reuse the value for `created` and `modified`: two calls make a\n * part whose two timestamps can disagree by a millisecond depending on when the build crossed a\n * tick, which is a difference no reader cares about and every byte-diff does.\n */\nexport function coreTimestamp(): string {\n\treturn new Date().toISOString().replace(/\\.\\d\\d\\dZ/, 'Z')\n}\n\n/**\n * `cp:revision` as it is written: a whole number, the only form PowerPoint opens.\n *\n * Anything else warns and writes `1`, the revision a new deck starts at.\n */\nfunction coreRevision(revision: string): string {\n\tif (/^\\d+$/.test(revision)) return revision\n\twarn(\n\t\t'core/revision-not-a-whole-number',\n\t\t`revision ${JSON.stringify(revision)} is not a whole number, which PowerPoint cannot open; writing 1`\n\t)\n\treturn '1'\n}\n\n/**\n * Creates `docProps/core.xml`\n * @param {string} title - metadata data\n * @param {string} subject - metadata data\n * @param {string} author - metadata value\n * @param {string} revision - metadata value\n * @returns XML\n */\nexport function makeXmlCore(title: string, subject: string, author: string, revision: string): string {\n\tconst dcterms = { 'xsi:type': 'dcterms:W3CDTF' }\n\t// One reading of the clock for both stamps; see coreTimestamp.\n\tconst now = coreTimestamp()\n\treturn (\n\t\tXML_DECL +\n\t\tel(\n\t\t\t'cp:coreProperties',\n\t\t\tCORE_PROPS_NS,\n\t\t\t[\n\t\t\t\traw(el('dc:title', null, title, PROP)),\n\t\t\t\traw(el('dc:subject', null, subject, PROP)),\n\t\t\t\traw(el('dc:creator', null, author, PROP)),\n\t\t\t\traw(el('cp:lastModifiedBy', null, author, PROP)),\n\t\t\t\t// Escaped like every other property. It went in raw on the strength of the setter's note\n\t\t\t\t// that a revision is a whole number, which nothing enforced, so a `<` or `&` in one wrote a\n\t\t\t\t// `core.xml` that does not parse.\n\t\t\t\traw(el('cp:revision', null, coreRevision(revision), PROP)),\n\t\t\t\traw(el('dcterms:created', dcterms, raw(now), PROP)),\n\t\t\t\traw(el('dcterms:modified', dcterms, raw(now), PROP)),\n\t\t\t],\n\t\t\t{ openPrefix: '\\n\\t', closePrefix: '\\n\\t' }\n\t\t)\n\t)\n}\n","/**\n * ts-pptx: the group construct family\n *\n * Both ways to make a `<p:grpSp>`: from child descriptors (`addGroup`) and from objects already on\n * the slide (`groupObjects`). The group *renderer* is not here -- it recurses back into the shape\n * walk and owns the frame and bounds logic that belongs to the dispatch, so it stays there.\n */\n\nimport { addGroupDefinition, groupObjectsDefinition } from '../gen/define/group.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const groupFamily = {\n\tname: 'group',\n\tauthors: {\n\t\taddGroup(slide, children, options) {\n\t\t\t// The child descriptors resolve through the same table `createSlideMaster` uses, so a group\n\t\t\t// can hold exactly the kinds this presentation was composed to author -- no more.\n\t\t\taddGroupDefinition(slide, children, options || {}, slide._childAuthors)\n\t\t},\n\t\tgroupObjects(slide, objectNames, options) {\n\t\t\tgroupObjectsDefinition(slide, objectNames, options || {})\n\t\t},\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: DrawingML image sizing & cropping\n *\n * Build the `<a:srcRect>` (+ `<a:stretch>`) blipFill children for the image\n * sizing modes (`cover` / `contain` / `crop` / `stretch`), for the implicit\n * aspect-correct placement a vector source gets, and for explicit percentage crops.\n */\n\nimport { fitSrcRectPercents } from '../../media/image-size.js'\nimport { PERCENT_SCALE } from '../../units.js'\nimport { voidEl } from '../oxml/el.js'\nimport { genXmlImageCropRect, STRETCH_FILL_RECT, type ImageCrop } from './src-rect.js'\nimport { InvalidOptionError } from '../../errors.js'\n\n/** Every `<a:srcRect>` below is followed by this same fill directive. */\nconst STRETCH = STRETCH_FILL_RECT\n\n/**\n * The `<a:srcRect>` fitting `imgSize` into `boxDim`, followed by the fill directive. A zero-size box\n * or image has no fit, and gets the fill directive alone, a plain stretch.\n */\nfunction fitSrcRect(\n\ttype: 'cover' | 'contain',\n\timgSize: { w: number; h: number },\n\tboxDim: { w: number; h: number }\n): string {\n\tconst rect = fitSrcRectPercents(type, imgSize, boxDim)\n\treturn rect ? voidEl('a:srcRect', rect) + STRETCH : STRETCH\n}\n\nexport const ImageSizingXml = {\n\tcover: function (imgSize: { w: number; h: number }, boxDim: { w: number; h: number; x: number; y: number }) {\n\t\treturn fitSrcRect('cover', imgSize, boxDim)\n\t},\n\tcontain: function (imgSize: { w: number; h: number }, boxDim: { w: number; h: number; x: number; y: number }) {\n\t\treturn fitSrcRect('contain', imgSize, boxDim)\n\t},\n\t/** No source rectangle at all: the image fills the box, aspect ratio be damned. */\n\tstretch: function () {\n\t\treturn STRETCH\n\t},\n\tcrop: function (imgSize: { w: number; h: number }, boxDim: { w: number; h: number; x: number; y: number }) {\n\t\tconst l = boxDim.x\n\t\tconst r = imgSize.w - (boxDim.x + boxDim.w)\n\t\tconst t = boxDim.y\n\t\tconst b = imgSize.h - (boxDim.y + boxDim.h)\n\t\tif (l < 0 || r < 0 || t < 0 || b < 0) {\n\t\t\tconst over = [\n\t\t\t\tl < 0 && `x (${l < 0 ? -l : 0} past left edge)`,\n\t\t\t\tr < 0 && `x+w (${-r} past right edge)`,\n\t\t\t\tt < 0 && `y (${-t} past top edge)`,\n\t\t\t\tb < 0 && `y+h (${-b} past bottom edge)`,\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(', ')\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'image/crop-window-overflows',\n\t\t\t\t`addImage sizing.type 'crop': crop window overflows image bounds — ${over}. Ensure x≥0, y≥0, x+w≤w, y+h≤h.`\n\t\t\t)\n\t\t}\n\t\tconst lPerc = Math.round(PERCENT_SCALE * (l / imgSize.w))\n\t\tconst rPerc = Math.round(PERCENT_SCALE * (r / imgSize.w))\n\t\tconst tPerc = Math.round(PERCENT_SCALE * (t / imgSize.h))\n\t\tconst bPerc = Math.round(PERCENT_SCALE * (b / imgSize.h))\n\t\treturn voidEl('a:srcRect', { l: lPerc, r: rPerc, t: tPerc, b: bPerc }) + STRETCH\n\t},\n}\n\n/**\n * The blipFill children for a vector source the caller gave no `sizing` for: letterbox it to its\n * own aspect ratio inside its frame, the way `sizing: 'contain'` would — an SVG carries an\n * intrinsic ratio, and stretching a glyph into a box that disagrees with it is never the intent.\n *\n * Returns `null` when the two ratios already agree, which is the overwhelmingly common case (a\n * square icon in a square box). The caller then emits the plain `<a:stretch>` it always did, so\n * this default costs nothing — neither bytes nor a behaviour change — until it actually differs.\n * @param imgSize - the vector's intrinsic size (viewBox or width/height)\n * @param boxDim - the picture's displayed frame\n * @returns the `<a:srcRect>` + `<a:stretch>` children, or `null` if no letterboxing is needed\n */\nexport function genXmlVectorAspectFit(\n\timgSize: { w: number; h: number },\n\tboxDim: { w: number; h: number }\n): string | null {\n\tconst rect = fitSrcRectPercents('contain', imgSize, boxDim)\n\tif (!rect || (rect.l === 0 && rect.r === 0 && rect.t === 0 && rect.b === 0)) return null\n\treturn voidEl('a:srcRect', rect) + STRETCH\n}\n\n/**\n * The blipFill children for an explicit percentage crop: the shared `<a:srcRect>` plus the\n * fill directive every sizing mode above pairs it with.\n * @param crop - edge insets in percent; omitted edges default to 0\n * @param objectName - for error messages\n * @returns the `<a:srcRect>` + `<a:stretch>` blipFill children\n */\nexport function genXmlImageCrop(crop: ImageCrop, objectName?: string): string {\n\tconst where = objectName ? ` for image \"${objectName}\"` : ''\n\treturn genXmlImageCropRect(crop, 'addImage', where) + STRETCH\n}\n","/**\n * ts-pptx: image slide-object serialization\n *\n * Emits an `image` slide object as a `<p:pic>`: the blip and its image effects (transparency,\n * duotone, colour change, grayscale, bi-level), the crop or `sizing` source rectangle, the\n * clipping geometry, outline and shadow. An omitted dimension is backfilled from the embedded\n * bytes' natural pixel ratio, which only becomes available once `_relsMedia` is populated.\n */\n\nimport { DEF_TEXT_SHADOW } from '../../../constants-internal.js'\nimport { createColorElement } from '../../drawingml/color.js'\nimport { createShadowEffectLst } from '../../drawingml/effect.js'\nimport { genXmlCustGeom, genXmlPresetGeom } from '../../drawingml/geometry.js'\nimport { genXmlImageCrop, genXmlVectorAspectFit, ImageSizingXml } from '../../drawingml/image.js'\nimport { genXmlObjectLock, PICTURE_LOCK_ATTRS } from '../../drawingml/locks.js'\nimport { genXmlPlaceholder } from '../../drawingml/text-body.js'\nimport { el, raw, voidEl, type XmlChild } from '../../oxml/el.js'\nimport { OOXML_NS } from '../../../ooxml/namespaces.js'\nimport { fractionToFixedPercent, getSmartParseNumber, mapStated, transparencyToAlpha } from '../../../units-internal.js'\nimport { warn } from '../../../diagnostics.js'\nimport { cNvPrEl, cNvPrHyperlink, genXmlShapeLine, type RenderContext, xfrmEl } from './shared.js'\nimport { imageNaturalSize, resolveImageExtent } from './image-extent.js'\n\n/**\n * Render an `image` slide object to its `<p:pic>` XML (sizing/crop, rounding, hyperlink, shadow).\n */\nexport function renderImageObject(ctx: RenderContext): string {\n\tconst { obj: slideItemObj, shapeId, slide, placeholder: placeholderObj, locationAttrs, itemOpts } = ctx\n\tconst { x, y } = ctx.frame\n\t// The frame, as two pairs that diverge: `_szAuto` backfills an omitted dimension from the\n\t// image's natural ratio, and `sizing` splits the two apart for good. `frameW`/`frameH` stay the\n\t// box the caller asked for, which is what the source rectangle is cropped against, while\n\t// `drawnW`/`drawnH` become the box actually drawn and emitted. Neither pair is the image's own\n\t// size; that is the third quantity here, and only `naturalSize()` answers it.\n\t// `resolveImageExtent` computes both pairs, because a parent group's bounds need the drawn box\n\t// too. `drawnW`/`drawnH` start as the frame and take the `sizing` box where the source rectangle\n\t// is emitted below.\n\tconst { frameW, frameH, drawnW: sizedW, drawnH: sizedH } = resolveImageExtent(slideItemObj, slide, ctx.frame)\n\tlet drawnW = frameW\n\tlet drawnH = frameH\n\tconst { sizing, rounding } = itemOpts\n\tlet strSlideXml = ''\n\t// `itemOpts` is the caller's already-normalized `itemOpts` (see the dispatch in\n\t// `slideObjectToXml`). Read it rather than re-narrowing the field: this function has exactly\n\t// one call site, and a contract stated there beats a defensive re-assignment here.\n\t// The media bytes this picture points at. Not available synchronously in `addImage()`, but\n\t// populated by now — which is why every question that needs the image itself (its natural\n\t// size, whether it is a vector) is answered here rather than at definition time.\n\tconst mediaRel = (slide._relsMedia || []).find((rel) => rel.rId === slideItemObj.imageRid)\n\tconst naturalSize = (): { w: number; h: number } | null => imageNaturalSize(slideItemObj, slide)\n\tconst imgOpts = itemOpts\n\tconst imgLink = slideItemObj.hyperlink\n\tstrSlideXml += '<p:pic>'\n\tstrSlideXml += ' <p:nvPicPr>'\n\tstrSlideXml += cNvPrEl(\n\t\tshapeId,\n\t\timgOpts.objectName,\n\t\t// No alt text is an empty `descr`, as PowerPoint writes for an inserted picture. The source path\n\t\t// or URL used to stand in: a screen reader read it aloud, and a local path put the author's\n\t\t// directory layout into the deck.\n\t\timgOpts.altText || '',\n\t\tcNvPrHyperlink(imgLink),\n\t\t{ closePrefix: ' ' }\n\t)\n\t// Default to locking aspect ratio (PowerPoint's own behavior); user `objectLock` overrides any flag, incl. noChangeAspect.\n\tstrSlideXml += el(\n\t\t'p:cNvPicPr',\n\t\tnull,\n\t\traw(\n\t\t\tgenXmlObjectLock(\n\t\t\t\t'a:picLocks',\n\t\t\t\tPICTURE_LOCK_ATTRS,\n\t\t\t\t{ noChangeAspect: true, ...imgOpts.objectLock },\n\t\t\t\timgOpts.objectName\n\t\t\t)\n\t\t),\n\t\t{ openPrefix: ' ' }\n\t)\n\tstrSlideXml += el('p:nvPr', null, raw(genXmlPlaceholder(placeholderObj)), { openPrefix: ' ' })\n\tstrSlideXml += ' </p:nvPicPr>'\n\n\t// The `<a:blip>` image-effect children (CT_Blip), shared by the SVG and raster branches:\n\t// transparency as `alphaModFix`, then duotone recolor (shadows→shadow, highlights→highlight),\n\t// both before any `extLst`.\n\t// NOTE: the SVG branch writes ` <a:alphaModFix` with a LEADING space and the raster branch\n\t// writes none. That space is byte-significant, so it is passed in rather than normalized away.\n\tconst blipEffects = (alphaPrefix: string): XmlChild[] => [\n\t\tmapStated(imgOpts.transparency, (transparency) =>\n\t\t\traw(voidEl('a:alphaModFix', { amt: transparencyToAlpha(transparency) }, { openPrefix: alphaPrefix }))\n\t\t) ?? null,\n\t\timgOpts.duotone\n\t\t\t? raw(\n\t\t\t\t\tel('a:duotone', null, [\n\t\t\t\t\t\traw(createColorElement(imgOpts.duotone.shadow)),\n\t\t\t\t\t\traw(createColorElement(imgOpts.duotone.highlight)),\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t: null,\n\t\timgOpts.clrChange\n\t\t\t? raw(\n\t\t\t\t\tel('a:clrChange', null, [\n\t\t\t\t\t\traw(el('a:clrFrom', null, raw(createColorElement(imgOpts.clrChange.from)))),\n\t\t\t\t\t\traw(el('a:clrTo', null, raw(createColorElement(imgOpts.clrChange.to)))),\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t: null,\n\t\timgOpts.grayscale ? raw(voidEl('a:grayscl')) : null,\n\t\timgOpts.biLevel\n\t\t\t? raw(\n\t\t\t\t\tvoidEl('a:biLevel', {\n\t\t\t\t\t\tthresh: fractionToFixedPercent(\n\t\t\t\t\t\t\timgOpts.biLevel.threshold,\n\t\t\t\t\t\t\t'image/bilevel-threshold-out-of-range',\n\t\t\t\t\t\t\t'biLevel.threshold'\n\t\t\t\t\t\t),\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t: null,\n\t]\n\n\tstrSlideXml += '<p:blipFill>'\n\t// NOTE: This works for both cases: either `path` or `data` contains the SVG\n\tconst isVector = mediaRel?.extn === 'svg'\n\tif (isVector) {\n\t\tstrSlideXml += el('a:blip', { 'r:embed': `rId${(slideItemObj.imageRid ?? 0) - 1}` }, [\n\t\t\t...blipEffects(' '),\n\t\t\traw(\n\t\t\t\tel(\n\t\t\t\t\t'a:extLst',\n\t\t\t\t\tnull,\n\t\t\t\t\traw(\n\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t'a:ext',\n\t\t\t\t\t\t\t{ uri: '{96DAC541-7B7A-43D3-8B79-37D633B846F1}' },\n\t\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t\tvoidEl(\n\t\t\t\t\t\t\t\t\t'asvg:svgBlip',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'xmlns:asvg': OOXML_NS.asvg,\n\t\t\t\t\t\t\t\t\t\t'r:embed': `rId${slideItemObj.imageRid}`,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{ openPrefix: ' ' }\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{ openPrefix: ' ', closePrefix: ' ' }\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\t{ openPrefix: ' ', closePrefix: ' ' }\n\t\t\t\t)\n\t\t\t),\n\t\t])\n\t} else {\n\t\tstrSlideXml += el('a:blip', { 'r:embed': `rId${slideItemObj.imageRid}` }, blipEffects(''))\n\t}\n\tif (itemOpts.crop) {\n\t\t// Explicit OOXML srcRect (percentage edge insets), emitted verbatim. Crops the source\n\t\t// directly, so it wins over the inch-based `sizing` crop and works for SVG/unmeasurable\n\t\t// formats; the picture's normal w/h box stays the display extent.\n\t\tif (sizing?.type)\n\t\t\twarn(\n\t\t\t\t'image/crop-and-sizing-conflict',\n\t\t\t\t`addImage 'crop' and 'sizing' are mutually exclusive for image \"${itemOpts.objectName}\"; 'sizing' was ignored.`\n\t\t\t)\n\t\tstrSlideXml += genXmlImageCrop(itemOpts.crop, itemOpts.objectName)\n\t} else if (sizing?.type) {\n\t\tconst boxW = sizedW\n\t\tconst boxH = sizedH\n\t\tconst boxX = getSmartParseNumber(sizing.x || 0, 'X', slide._presLayout)\n\t\tconst boxY = getSmartParseNumber(sizing.y || 0, 'Y', slide._presLayout)\n\n\t\t// `cover`/`contain` crop the *source* bitmap, so the srcRect must be derived from the\n\t\t// image's natural pixel ratio — not the displayed box (options.w/h). Measure it from the\n\t\t// embedded media bytes; if unmeasurable (SVG/unknown format) fall back to display dims + warn.\n\t\t// `crop` keeps display EMU: its contract treats the displayed extent as the crop frame.\n\t\tlet cropSize: { w: number; h: number } = { w: drawnW, h: drawnH }\n\t\tif (sizing.type === 'cover' || sizing.type === 'contain') {\n\t\t\tconst natural = naturalSize()\n\t\t\tif (natural) {\n\t\t\t\tcropSize = natural\n\t\t\t} else {\n\t\t\t\twarn(\n\t\t\t\t\t'image/unmeasurable-natural-size',\n\t\t\t\t\t`sizing '${sizing.type}' could not measure natural dimensions for image \"${itemOpts.objectName}\"; falling back to displayed aspect ratio (crop may be inexact). Provide a raster image (PNG/JPEG/GIF/BMP/WebP) or an SVG with width/height or a viewBox to enable an aspect-correct crop.`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tstrSlideXml += ImageSizingXml[sizing.type](cropSize, { w: boxW, h: boxH, x: boxX, y: boxY })\n\t\tdrawnW = boxW\n\t\tdrawnH = boxH\n\t} else {\n\t\t// No `sizing` at all. A raster fills its box — that box was chosen for it, and PowerPoint\n\t\t// does the same. A vector does not: an SVG states its own aspect ratio in a viewBox, and a\n\t\t// glyph squashed to a box that disagrees is a defect, not a layout choice. So a measurable\n\t\t// vector letterboxes here by default, and `sizing: { type: 'stretch' }` opts back out.\n\t\t// Unmeasurable vectors (no viewBox, no width/height) fall through silently: nothing was\n\t\t// asked for, so there is nothing to warn about.\n\t\tconst natural = isVector ? naturalSize() : null\n\t\tconst aspectFit = natural ? genXmlVectorAspectFit(natural, { w: drawnW, h: drawnH }) : null\n\t\tstrSlideXml += aspectFit ?? el('a:stretch', null, raw(voidEl('a:fillRect')), { openPrefix: ' ' })\n\t}\n\tstrSlideXml += '</p:blipFill>'\n\tstrSlideXml += '<p:spPr>'\n\tstrSlideXml += xfrmEl('a:xfrm', { x, y, cx: drawnW, cy: drawnH }, locationAttrs, {\n\t\topenPrefix: ' ',\n\t\tchildPrefix: ' ',\n\t\tclosePrefix: ' ',\n\t})\n\t// Clip the picture to a geometry. `points` (freeform custGeom) takes precedence over `shape`/`rounding`;\n\t// otherwise `shape` wins over `rounding` (shorthand for an ellipse), falling back to a plain rectangle.\n\tif (itemOpts.points) {\n\t\tstrSlideXml += ' ' + genXmlCustGeom(itemOpts, drawnW, drawnH, slide._presLayout)\n\t} else {\n\t\tstrSlideXml += ' ' + genXmlPresetGeom(itemOpts.shape ?? (rounding ? 'ellipse' : 'rect'), itemOpts, drawnW, drawnH)\n\t}\n\n\t// BORDER: `<a:ln>` outline (must precede `<a:effectLst>` per CT_ShapeProperties order)\n\tif (itemOpts.line) strSlideXml += genXmlShapeLine(itemOpts.line)\n\n\t// EFFECTS > SHADOW: REF: @see http://officeopenxml.com/drwSp-effects.php\n\tif (itemOpts.shadow && itemOpts.shadow.type !== 'none') {\n\t\tstrSlideXml += createShadowEffectLst(itemOpts.shadow, DEF_TEXT_SHADOW)\n\t}\n\tstrSlideXml += '</p:spPr>'\n\tstrSlideXml += '</p:pic>'\n\treturn strSlideXml\n}\n","/**\n * ts-pptx: the image construct family\n *\n * Raster and SVG pictures, and the `image` descriptor a slide master or a group is written with.\n */\n\nimport { SlideObjectType } from '../enums.js'\nimport { renderImageObject } from '../gen/slide/objects/image.js'\nimport { addImageDefinition } from '../gen/define/image.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const imageFamily = {\n\tname: 'image',\n\tauthors: {\n\t\taddImage(slide, options) {\n\t\t\taddImageDefinition(slide, options)\n\t\t},\n\t},\n\tchildren: {\n\t\timage(target, child) {\n\t\t\taddImageDefinition(target, child)\n\t\t},\n\t},\n\trenderers: {\n\t\t[SlideObjectType.image]: renderImageObject,\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: the speaker-notes contribution to a written package\n *\n * A notes slide per slide (empty ones included, so every slide's `.rels` numbering is the same\n * whether or not it has notes) plus the single notes master the whole deck shares.\n *\n * `ppt/theme/theme2.xml` is the one piece of this that is *not* here: `notesMaster1.xml.rels`\n * references it, but it is written on the core path because the master's own theme part is, and\n * splitting one of a pair across the seam buys nothing.\n */\n\nimport type { ZipWriter } from '../../zip.js'\nimport type { ContentTypeOverride } from '../../gen/opc/content-types.js'\nimport type { PresentationPropsInternal, PresSlideInternal } from '../../types/internal.js'\nimport {\n\tbuildNotesSlideRels,\n\tmakeXmlNotesMaster,\n\tmakeXmlNotesMasterRel,\n\tmakeXmlNotesSlide,\n\tmakeXmlNotesSlideRel,\n} from '../../gen/slide/notes.js'\nimport { NOTES_MASTER_PATH, notesSlidePath, overrideName, relsPath } from '../../gen/opc/part-paths.js'\nimport type { PartContributor } from './shared.js'\nimport { NOTES_MASTER_CONTENT_TYPE, NOTES_SLIDE_CONTENT_TYPE } from '../../ooxml/rel-types.js'\n\nexport const notesContributor: PartContributor = {\n\torder: 10,\n\tparts: {\n\t\twithEachSlide(slide: PresSlideInternal, slideNumber: number, zip: ZipWriter): void {\n\t\t\t// Notes of empty strings are created for slides which do not have notes specified, to\n\t\t\t// keep track of _rels. The body and its rels are written from one resolution of the notes,\n\t\t\t// so their hyperlink ids cannot disagree.\n\t\t\tconst notes = buildNotesSlideRels(slide)\n\t\t\tzip.add(notesSlidePath(slideNumber), makeXmlNotesSlide(slide, notes))\n\t\t\tzip.add(relsPath(notesSlidePath(slideNumber)), makeXmlNotesSlideRel(notes, slideNumber))\n\t\t},\n\t\tafterMaster(_pres: PresentationPropsInternal, zip: ZipWriter): void {\n\t\t\tzip.add(NOTES_MASTER_PATH, makeXmlNotesMaster())\n\t\t\tzip.add(relsPath(NOTES_MASTER_PATH), makeXmlNotesMasterRel())\n\t\t},\n\t},\n\tcontentTypes: {\n\t\tpresentation(): ContentTypeOverride[] {\n\t\t\treturn [{ partName: overrideName(NOTES_MASTER_PATH), contentType: NOTES_MASTER_CONTENT_TYPE }]\n\t\t},\n\t\ttrailing(pres: PresentationPropsInternal): ContentTypeOverride[] {\n\t\t\treturn pres.slides.map((_slide, idx) => ({\n\t\t\t\tpartName: overrideName(notesSlidePath(idx + 1)),\n\t\t\t\tcontentType: NOTES_SLIDE_CONTENT_TYPE,\n\t\t\t}))\n\t\t},\n\t},\n}\n","/**\n * ts-pptx: Notes Definition\n *\n * Normalizes plain or rich `addNotes()` input to a `TextProps[]` run list and pushes a\n * `notes`-type slide object; the notes-slide XML is emitted later by `gen/slide/notes.ts`.\n */\nimport { SlideObjectType } from '../../enums.js'\nimport type { NotesProps, TextProps } from '../../types/index.js'\nimport type { PresSlideInternal } from '../../types/internal.js'\nimport { validateHyperlink } from './hyperlinks.js'\n\n/**\n * Adds Notes to a slide.\n * @param {PresSlideInternal} `target` slide object\n * @param {string | NotesProps | NotesProps[]} `notes` plain text, or rich runs (inline formatting / hyperlinks)\n * @throws {InvalidOptionError} when a run's `hyperlink` is not one `addText` would accept\n */\nexport function addNotesDefinition(target: PresSlideInternal, notes: string | NotesProps | NotesProps[]): void {\n\t// Normalize all input forms to a TextProps[] run list so the notes-slide serializer\n\t// (which reuses the standard text-run generator) can handle plain and rich notes uniformly.\n\t// A run whose author stated no `options` carries no `options` key, rather than one holding\n\t// `undefined`: the text emitters spread these bags, where the two are not the same state.\n\tconst runs: TextProps[] =\n\t\ttypeof notes === 'string'\n\t\t\t? [{ text: notes }]\n\t\t\t: (Array.isArray(notes) ? notes : [notes]).map((run) =>\n\t\t\t\t\trun.options === undefined ? { text: run.text } : { text: run.text, options: run.options }\n\t\t\t\t)\n\n\t// Refused here, by the rules `addText` applies, rather than when the deck is written: a link\n\t// naming both `url` and `slide` used to be accepted and then fail the write, and an empty or\n\t// non-object one was dropped without a word.\n\tfor (const run of runs) {\n\t\tif (run.options?.hyperlink !== undefined) validateHyperlink(run.options.hyperlink, 'addNotes')\n\t}\n\n\ttarget._slideObjects.push({\n\t\t_type: SlideObjectType.notes,\n\t\ttext: runs,\n\t})\n}\n","/**\n * ts-pptx: the speaker-notes construct family\n *\n * `addNotes` and the notes-slide parts it puts in the package. Cheap, and a deck without speaker\n * notes is a poor default, so every tier carries it -- which is a reason to compose it, not a\n * reason to wire it directly.\n */\n\nimport { notesContributor } from '../package/parts/notes.js'\nimport { addNotesDefinition } from '../gen/define/notes.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const notesFamily = {\n\tname: 'notes',\n\tauthors: {\n\t\taddNotes(slide, notes) {\n\t\t\taddNotesDefinition(slide, notes)\n\t\t},\n\t},\n\tparts: notesContributor,\n} satisfies ConstructFamily\n","/**\n * ts-pptx: Shape Definition\n *\n * `addShapeDefinition` normalizes an `addShape()` preset (mapping friendly aliases, rejecting\n * presets PowerPoint can't parse), applies line defaults, registers hyperlink + image-fill rels,\n * and pushes a `text`-type shape object.\n */\nimport { type SHAPE_NAME, ShapeType, SlideObjectType } from '../../enums.js'\nimport type { ShapeProps } from '../../types/index.js'\nimport type { PresSlideInternal, SlideObject } from '../../types/internal.js'\nimport { normalizeShadowOptions } from '../drawingml/effect.js'\nimport { resolveFillKind } from '../drawingml/fill.js'\nimport { withLineDefaults } from '../drawingml/line.js'\nimport { assertKnownPreset } from '../drawingml/geometry.js'\nimport { resolveObjectName } from './object-name.js'\nimport { resolveAuthoredFrame } from './frame.js'\nimport { createHyperlinkRels } from './hyperlinks.js'\nimport { registerImageFillMedia } from './image.js'\nimport { InvalidOptionError } from '../../errors.js'\nimport { setOrClear } from '../../options-internal.js'\n\n/**\n * Map of common friendly shape names users pass as bare strings to their\n * valid OOXML preset values. PowerPoint can't parse the friendly spellings\n * and removes the shape during repair .\n */\nconst SHAPE_NAME_ALIASES: { [key: string]: SHAPE_NAME } = {\n\toval: 'ellipse',\n\trectangle: 'rect',\n\troundedRectangle: 'roundRect',\n\troundedrectangle: 'roundRect',\n}\n\n// ===== Shapes & connectors =====\n\n/**\n * Adds a shape object to a slide definition.\n * @param {PresSlideInternal} target slide object that the shape should be added to\n * @param {SHAPE_NAME} shapeName shape name\n * @param {ShapeProps} opts shape options\n */\nexport function addShapeDefinition(target: PresSlideInternal, shapeName: SHAPE_NAME, opts: ShapeProps): void {\n\t// Take ownership of the options before touching them, the same way `addTextDefinition` does.\n\t// Everything below writes normalization back onto whatever object it is handed — the `line`\n\t// defaults and the assigned `objectName` above all — so without the copy a style literal reused\n\t// across shapes carries one shape's settings to the next:\n\t//\n\t// slide.addShape('rect', STYLE) // STYLE now holds `objectName: 'Shape 1'`\n\t// slide.addShape('ellipse', { ...STYLE }) // …spread onto the second, and the third\n\t//\n\t// which emits three shapes named `Shape 1` and a duplicate-`objectName` warning.\n\t//\n\t// Nested caller objects (`fill`) stay shared by reference, as in `addTextDefinition`: the image\n\t// fill's rel id is registered through that reference and read back at emit time. `shadow` does\n\t// not — `normalizeShadowOptions` returns a fresh bag, so a shadow literal shared across shapes\n\t// gives each of them its own normalized copy and comes back as the caller wrote it.\n\t// `test/regression/shape/shared-shadow.test.js` pins that the shared literal keeps emitting the\n\t// same `<a:effectLst>` on every shape.\n\tconst options: ShapeProps = typeof opts === 'object' ? { ...opts } : {}\n\toptions.line = options.line || { type: 'none' }\n\t// A shape with no shadow carries no `shadow` key: `ShapeProps` bags are spread (a style literal\n\t// over another, and this one onto the slide object's options), so a key holding `undefined`\n\t// would suppress an inherited shadow where an absent one does not.\n\tsetOrClear(options, 'shadow', normalizeShadowOptions(options.shadow))\n\t// Normalize friendly shape names (e.g. \"oval\" -> \"ellipse\") to their valid\n\t// OOXML preset spellings before storing on the slide object.\n\tconst resolvedShapeName: SHAPE_NAME =\n\t\ttypeof shapeName === 'string' && SHAPE_NAME_ALIASES[shapeName] ? SHAPE_NAME_ALIASES[shapeName] : shapeName\n\tconst newObject: SlideObject = {\n\t\t_type: SlideObjectType.text,\n\t\tshape: resolvedShapeName || ShapeType.rect,\n\t\toptions,\n\t}\n\n\t// Reality check\n\tif (!shapeName)\n\t\tthrow new InvalidOptionError(\n\t\t\t'shape/missing-type',\n\t\t\t'Missing/Invalid shape parameter! Example: `addShape(ShapeType.line, {x:1, y:1, w:1, h:1});`'\n\t\t)\n\n\t// Reject presets PowerPoint can't parse (a typo, or an unmapped friendly name)\n\t// here at the API boundary as well as at serialization time, so the message\n\t// names the call the caller actually made.\n\tassertKnownPreset(resolvedShapeName)\n\n\t// 1: ShapeLineProps defaults. A shape has an outline unless it asks for none, so every other\n\t// line takes them.\n\tif (typeof options.line === 'object' && options.line.type !== 'none')\n\t\toptions.line = withLineDefaults(options.line, 'line.color')\n\n\t// 2: Set options defaults. A line is drawn with no height or no width on purpose.\n\tObject.assign(\n\t\toptions,\n\t\tresolveAuthoredFrame(options, { x: 1, y: 1, w: 1, h: 1 }, 'addShape', newObject.shape === ShapeType.line)\n\t)\n\t// Shapes are `_type === text` objects, so they share the text-box name bucket (`Shape 1`,\n\t// `Text 2`, …) — which is what stops a shape and a text box colliding on one index.\n\toptions.objectName = resolveObjectName(target, SlideObjectType.text, {\n\t\tlabel: 'Shape',\n\t\tkind: 'shape',\n\t\tsupplied: options.objectName,\n\t})\n\n\t// 3: Create hyperlink rels\n\tcreateHyperlinkRels(target, newObject, 'addShape')\n\n\t// 5: Register an image fill (if any) as a media relationship for serialize-time blipFill\n\tif (typeof options.fill === 'object' && resolveFillKind(options.fill) === 'image') {\n\t\tregisterImageFillMedia(target, options.fill)\n\t}\n\n\t// LAST: Add object to slide\n\ttarget._slideObjects.push(newObject)\n}\n","/**\n * ts-pptx: the shape construct family\n *\n * Preset geometry (`addShape`) and the four shape descriptors a slide master or a group is written\n * with. A shape is authored as a text object carrying a preset geometry, so the family has no\n * renderer of its own -- what it owns is the preset table and the geometry emitter under it.\n */\n\nimport { ShapeType } from '../enums.js'\nimport { addShapeDefinition } from '../gen/define/shape.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const shapeFamily = {\n\tname: 'shape',\n\tauthors: {\n\t\taddShape(slide, shapeName, options) {\n\t\t\t// `shapeName` is a plain string preset name (e.g. `ShapeType.rect` === \"rect\").\n\t\t\taddShapeDefinition(slide, shapeName, options || {})\n\t\t},\n\t},\n\tchildren: {\n\t\tline(target, child) {\n\t\t\taddShapeDefinition(target, ShapeType.line, child)\n\t\t},\n\t\trect(target, child) {\n\t\t\taddShapeDefinition(target, ShapeType.rect, child)\n\t\t},\n\t\troundRect(target, child) {\n\t\t\taddShapeDefinition(target, ShapeType.roundRect, child)\n\t\t},\n\t\tshape(target, child) {\n\t\t\taddShapeDefinition(target, child.type, child.options || {})\n\t\t},\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: text / placeholder slide-object serialization\n *\n * Emits a `text` or `placeholder` slide object as a `<p:sp>`: body insets from the caller's\n * margin, the shape geometry (preset or custom), fill, outline and shadow, then the text body.\n * An equation-bearing shape is wrapped in the `a14` markup-compatibility envelope.\n */\n\nimport { SlideObjectType } from '../../../enums.js'\nimport { DEF_TEXT_SHADOW } from '../../../constants-internal.js'\nimport { createShadowEffectLst } from '../../drawingml/effect.js'\nimport { rejectEmptyFill, genXmlColorSelection } from '../../drawingml/fill.js'\nimport { genXmlCustGeom, genXmlPresetGeom } from '../../drawingml/geometry.js'\nimport { genXmlObjectLock, SHAPE_LOCK_ATTRS } from '../../drawingml/locks.js'\nimport { genXmlPlaceholder, genXmlTextBody, objectHasMath } from '../../drawingml/text-body.js'\nimport { el, elOrVoid, raw, type XmlAttrs } from '../../oxml/el.js'\nimport { alternateContentEl } from '../../oxml/alternate-content.js'\nimport { OOXML_NS } from '../../../ooxml/namespaces.js'\nimport { cNvPrEl, cNvPrHyperlink, genXmlShapeLine, type RenderContext, xfrmEl } from './shared.js'\nimport { xsdBoolIfTrue } from '../../../ooxml/xsd-boolean.js'\n\n/**\n * Render a `text` / `placeholder` slide object to its `<p:sp>` XML.\n */\nexport function renderTextObject(ctx: RenderContext): string {\n\tconst {\n\t\tobj: slideItemObj,\n\t\tshapeId,\n\t\tslide,\n\t\tframe: { x, y, cx, cy },\n\t\tplaceholder: placeholderObj,\n\t\tlocationAttrs,\n\t\titemOpts,\n\t} = ctx\n\tlet strSlideXml = ''\n\t// `itemOpts` is the caller's already-normalized `itemOpts` (see the dispatch in\n\t// `slideObjectToXml`). Read it rather than re-narrowing the field: this function has exactly\n\t// one call site, and a contract stated there beats a defensive re-assignment here.\n\t//\n\t// The zero-height rescue that used to sit here is gone: it read `!itemOpts.line`, and both\n\t// definers write a `line` object onto every text object unconditionally, so it had never\n\t// once fired. The default it was reaching for now lives in `addTextDefinition`, where an\n\t// omitted height is still distinguishable from a stated `h: 0`.\n\n\t// A: Start SHAPE =======================================================\n\tstrSlideXml += '<p:sp>'\n\n\t// B: The addition of the \"txBox\" attribute is the sole determiner of if an object is a shape or textbox\n\tconst txtOpts = itemOpts\n\tstrSlideXml +=\n\t\t'<p:nvSpPr>' + cNvPrEl(shapeId, txtOpts.objectName, txtOpts.altText || '', cNvPrHyperlink(txtOpts.hyperlink))\n\t{\n\t\tconst spLockXml = genXmlObjectLock('a:spLocks', SHAPE_LOCK_ATTRS, txtOpts.objectLock, txtOpts.objectName)\n\t\t// Paired only when there are locks to carry; otherwise self-closing.\n\t\tconst cNvSpPrAttrs: XmlAttrs = { txBox: xsdBoolIfTrue(txtOpts?.isTextBox) }\n\t\tstrSlideXml += elOrVoid('p:cNvSpPr', cNvSpPrAttrs, spLockXml)\n\t}\n\t// Prefer the resolved slide-layout placeholder; otherwise fall back to the shape's own\n\t// placeholder type so a standalone title/body text box still emits a real <p:ph>.\n\tstrSlideXml += el(\n\t\t'p:nvPr',\n\t\tnull,\n\t\traw(\n\t\t\tgenXmlPlaceholder(\n\t\t\t\tslideItemObj._type === SlideObjectType.placeholder || (placeholderObj == null && itemOpts?._placeholderType)\n\t\t\t\t\t? slideItemObj\n\t\t\t\t\t: placeholderObj\n\t\t\t)\n\t\t)\n\t)\n\tstrSlideXml += '</p:nvSpPr><p:spPr>'\n\tstrSlideXml += xfrmEl('a:xfrm', { x, y, cx, cy }, locationAttrs)\n\n\tif (slideItemObj.shape === 'custGeom') {\n\t\tstrSlideXml += genXmlCustGeom(itemOpts, cx, cy, slide._presLayout)\n\t} else {\n\t\tstrSlideXml += genXmlPresetGeom(slideItemObj.shape ?? '', itemOpts, cx, cy)\n\t}\n\n\t// Option: FILL\n\t// A missing `fill` defaults to `<a:noFill/>` here — an unfilled box is what a text box\n\t// should be, and every deck ever authored against this writer depends on it. That default\n\t// is also why omission cannot mean *inherit* on this path: `fill: { type: 'inherit' }` is\n\t// the spelling that emits no fill child and lets `p:style/a:fillRef` or the placeholder\n\t// paint the interior.\n\t// `fill: ''` and `fill: { color: '' }` land on that same default, and are reported on the\n\t// way: they are the caller's missing value rather than a third spelling of *no fill*. Both\n\t// fold onto absence *here*, because on this path absence is `<a:noFill/>` and not the\n\t// silence {@link genXmlColorSelection} would answer with.\n\tconst statedFill = rejectEmptyFill(itemOpts.fill, 'fill') ? undefined : itemOpts.fill\n\tstrSlideXml += statedFill ? genXmlColorSelection(statedFill) : '<a:noFill/>'\n\n\t// shape Type: LINE: line color\n\tif (itemOpts.line) strSlideXml += genXmlShapeLine(itemOpts.line)\n\n\t// EFFECTS > SHADOW: REF: @see http://officeopenxml.com/drwSp-effects.php\n\tif (itemOpts.shadow && itemOpts.shadow.type !== 'none') {\n\t\tstrSlideXml += createShadowEffectLst(itemOpts.shadow, DEF_TEXT_SHADOW)\n\t}\n\n\t// B: Close shape Properties\n\tstrSlideXml += '</p:spPr>'\n\n\t// C: Add formatted text (text body \"bodyPr\")\n\tstrSlideXml += genXmlTextBody(slideItemObj)\n\n\t// LAST: Close SHAPE =======================================================\n\tstrSlideXml += '</p:sp>'\n\n\t// A native equation uses the `a14` (drawing-2010) markup-compatibility extension. PowerPoint\n\t// wraps the whole shape in <mc:AlternateContent><mc:Choice Requires=\"a14\"> so non-a14\n\t// consumers (and schema validators) treat the a14:m subtree as a known extension.\n\tif (objectHasMath(slideItemObj)) {\n\t\treturn alternateContentEl({ requires: { prefix: 'a14', uri: OOXML_NS.a14 }, choice: strSlideXml })\n\t}\n\treturn strSlideXml\n}\n","/**\n * ts-pptx: the text construct family\n *\n * Text boxes, and the shape-with-text descriptors a slide master or a group is written with. The\n * cheapest family and the one every tier carries, but it is a family like any other: a list with an\n * exception in it is a list nobody trusts.\n */\n\nimport { SlideObjectType } from '../enums.js'\nimport { InvalidOptionError } from '../errors.js'\nimport { renderTextObject } from '../gen/slide/objects/text.js'\nimport { addTextDefinition } from '../gen/define/text.js'\nimport type { ConstructFamily } from './shared.js'\n\n/**\n * Refuse a `text` that is none of the forms the signature takes. A single run object,\n * `{ text: 'x' }`, is the one a caller reaches for, and it failed inside the definer with a\n * `TypeError`.\n * @param text - the caller's `text`\n * @param call - the method or descriptor the text was authored through, opening the message\n */\nfunction requireTextForm(text: unknown, call: string): void {\n\tif (text == null || typeof text === 'string' || typeof text === 'number' || Array.isArray(text)) return\n\tthrow new InvalidOptionError(\n\t\t'text/invalid-text',\n\t\t`${call}: \\`text\\` takes a string, a number or an array of runs, got ${typeof text}. Wrap a single run in an array: \\`[{ text: 'x' }]\\`.`\n\t)\n}\n\nexport const textFamily = {\n\tname: 'text',\n\tauthors: {\n\t\taddText(slide, text, options) {\n\t\t\trequireTextForm(text, 'addText')\n\t\t\t// The bare-string form is wrapped into a one-run list carrying NO options of its own -- the\n\t\t\t// same shape a caller writing `[{ text: 'x' }]` hands in, and for the same reason: a bare\n\t\t\t// string authors no *run*, so its run states nothing and inherits everything.\n\t\t\t//\n\t\t\t// It used to hand `options` to both the shape and the run, which made one object play both\n\t\t\t// roles. Every key on it was then read twice, once as a shape property and once as a run\n\t\t\t// property, and `shadow` is a key that means something different in each place: the shape's\n\t\t\t// `<a:effectLst>` and the run's are two separate gestures in PowerPoint (Shape Effects vs\n\t\t\t// Text Effects, `shadow-shape-vs-text.pptx`), and `addText('hi', { shadow })` emitted both.\n\t\t\t// A run inherits what a run inherits -- `RUN_INHERITABLE_OPTIONS` and the paragraph list\n\t\t\t// beside it in `gen/drawingml/text-run.ts` -- and nothing else.\n\t\t\tconst runs = typeof text === 'string' || typeof text === 'number' ? [{ text }] : text\n\t\t\taddTextDefinition(slide, runs, options || {}, false)\n\t\t},\n\t},\n\tchildren: {\n\t\ttext(target, child) {\n\t\t\trequireTextForm(child.text, 'a `text` descriptor')\n\t\t\taddTextDefinition(\n\t\t\t\ttarget,\n\t\t\t\tArray.isArray(child.text) ? child.text : [{ text: child.text }],\n\t\t\t\tchild.options || {},\n\t\t\t\tfalse\n\t\t\t)\n\t\t},\n\t},\n\t// A text box and a layout placeholder are one emitter with two entry kinds: the placeholder\n\t// differences it does draw come off `ctx.placeholder`, not off the object's `_type`.\n\trenderers: {\n\t\t[SlideObjectType.placeholder]: renderTextObject,\n\t\t[SlideObjectType.text]: renderTextObject,\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: the animations construct family\n *\n * Preset build animations (`addAnimation`). Authoring one is only a push onto the slide's list --\n * what the family is really worth is the timing tree that list turns into, and that is still\n * emitted from the slide writer rather than from here.\n *\n * **That was measured, not assumed.** Moving the tree here would need a fourth seam: per-slide XML\n * outside a shape, handed to the slide writer the way the packager is handed part contributors,\n * and ordered, because `p:transition` and `p:timing` are position-significant children of `p:sld`.\n * What it would buy is `gen/anim/animation.ts` plus `gen/anim/transition.ts`, which minify to 6.6\n * kB and gzip to 2.3 kB -- about 3.6% of the composed tier's 63 kB entry chunk. And it would not\n * even buy all of that: `gen/anim/timing.ts` stays reachable either way, because looping *media*\n * goes through the same tree. A new architectural seam carrying a byte-significant ordering rule\n * is not worth 2.3 kB. Re-measure before reopening it; that number is what would have to change.\n */\n\nimport type { ConstructFamily } from './shared.js'\n\nexport const animationsFamily = {\n\tname: 'animations',\n\tauthors: {\n\t\taddAnimation(slide, options) {\n\t\t\tslide._animations.push(options)\n\t\t},\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: chart-kind predicates\n *\n * The classification questions the chart emitters ask about a chart's `_type`, in one place.\n * There is nothing clever here — each is the comparison the call sites were already writing —\n * but writing it once is what keeps `bubble3d` from being forgotten at the eleventh site the\n * way it has been at a few of the first ten.\n *\n * \"XY\" is the distinction that actually drives markup rather than a name: a scatter or bubble\n * chart plots numbers on both axes, so its *category* axis is a second `<c:valAx>`, its series\n * carry `xVal`/`yVal` rather than `cat`/`val`, and its embedded worksheet is laid out to match.\n *\n * `ChartOptsInternal._type` widens to `ChartMultiInternal[]` for a combo chart, which is not any single\n * kind, so every predicate takes the union and answers `false` for the array.\n */\n\nimport { ChartType } from '../../enums.js'\nimport type { ChartPropsChartStock } from '../../types/index.js'\nimport type { ChartMultiInternal, OptsChartDataInternal } from '../../types/internal.js'\n\n/** A `ChartOptsInternal._type`: one chart kind, or a combo chart's list of subcharts. */\ntype ChartTypeOrCombo = ChartType | ChartMultiInternal[] | undefined\n\n/** Both bubble variants (`<c:bubbleChart>`), which differ only by `<c:bubble3D>`. */\nexport function isBubbleChart(type: ChartTypeOrCombo): boolean {\n\treturn type === ChartType.bubble || type === ChartType.bubble3d\n}\n\n/** The scatter chart (`<c:scatterChart>`). */\nexport function isScatterChart(type: ChartTypeOrCombo): boolean {\n\treturn type === ChartType.scatter\n}\n\n/**\n * A chart whose categories are numbers rather than labels: scatter and both bubbles.\n * These are the ones whose category axis is emitted as a `<c:valAx>`.\n */\nexport function isXyChart(type: ChartTypeOrCombo): boolean {\n\treturn isScatterChart(type) || isBubbleChart(type)\n}\n\n/**\n * A series' `<c:idx>` and `<c:order>`, which is also the index its `seriesOptions` entry and its\n * palette colour are read at.\n *\n * `_dataIndex` is the series' row in the chart's data, counted across every subchart of a combo, so\n * no two subcharts share an index. An XY plot's first row holds the X values and is not a series, so\n * its Y series sit one below their rows: on a scatter or bubble chart of its own the first Y series\n * is 0, the index `seriesOptions` is documented against.\n * @param series - the data row the series is plotted from\n * @param plotType - the plot the series belongs to, a combo subchart's own type\n */\nexport function seriesIdx(series: OptsChartDataInternal, plotType: ChartType): number {\n\treturn isXyChart(plotType) ? series._dataIndex - 1 : series._dataIndex\n}\n\n/**\n * A grouping that stacks its series: `stacked` or `percentStacked`, on a bar, line or area plot.\n *\n * Two call sites tested this with `includes('tacked')` and two compared exactly, so an unchecked\n * value such as `'unstacked'` was stacked for one reader and not for the other.\n */\nexport function isStackedGrouping(grouping: string | undefined): grouping is 'stacked' | 'percentStacked' {\n\treturn grouping === 'stacked' || grouping === 'percentStacked'\n}\n\n/**\n * The stock-chart styles, keyed off the public option so the type is the source rather than a\n * fourth transcription of the same four names.\n */\nexport type StockStyle = NonNullable<ChartPropsChartStock['stockStyle']>\n\n/**\n * Per-style stock chart geometry: how many value series the style expects, whether the first\n * series is a Volume column drawn as a bar (on its own axis pair), and whether the open-close\n * `<c:upDownBars>` are drawn. HLC/VHLC are three-value (no open) and instead mark the close\n * with a dot; OHLC/VOHLC are four-value and use up/down bars for the open-close body.\n *\n * Here rather than in the plot builder because `addChartDefinition` needs the series counts to\n * warn on a mismatched series list, and had a second table of its own for exactly that.\n */\nexport const STOCK_STYLE_SPEC: Record<StockStyle, { seriesCount: number; volume: boolean; upDownBars: boolean }> = {\n\thlc: { seriesCount: 3, volume: false, upDownBars: false },\n\tohlc: { seriesCount: 4, volume: false, upDownBars: true },\n\tvhlc: { seriesCount: 4, volume: true, upDownBars: false },\n\tvohlc: { seriesCount: 5, volume: true, upDownBars: true },\n}\n","/**\n * ts-pptx: Chart Series-Data ↔ Worksheet-Cell Mapping\n *\n * The tiny pure helpers that both chart package parts share: the empty-array-safe\n * accessors over the normalized (internal) chart-series arrays, and the builders that\n * turn a (column, row) into an absolute reference into the chart's embedded `Sheet1`.\n * The embedded-workbook builder ({@link ../chart/embed-xlsx}) writes the cells; the\n * chart-XML builder ({@link ../chart/chart-xml}) points `<c:f>` formulas back at them —\n * so this mapping lives in one place to keep column letters and `$`-anchoring from\n * drifting between the two sides.\n */\n\nimport { LETTERS } from '../../constants-internal.js'\nimport { InvalidOptionError } from '../../errors.js'\nimport type { OptsChartDataInternal, SlideRelChart } from '../../types/internal.js'\nimport { isBubbleChart, isScatterChart } from './chart-kind.js'\n\n/**\n * The text a series' header cell holds, and so the text its `<c:tx>` caches: the series' name, or\n * the empty string for a series with none.\n *\n * The workbook and the chart part used to spell this apart. The sheet wrote an unnamed series as\n * `' '` where every cache held `''`, rewrote `X-Axis` to `X-Values` inside any name holding it, named\n * an unnamed bubble series `Y-Axis1`, and headed a bubble's X column `X-Axis` whatever it was called.\n * A bubble's size column has no name of its own and no cache reads its header, so it keeps\n * `Size<n>`.\n * @param series - the series\n * @param role - `values` for the column a series' values take, `sizes` for a bubble's size column\n */\nexport function seriesHeader(series: OptsChartDataInternal | undefined, role: 'values' | 'sizes' = 'values'): string {\n\treturn role === 'sizes' ? `Size${series?._dataIndex ?? 0}` : (series?.name ?? '')\n}\n\n// ===== Series-data accessors =====\n// The normalized (internal) chart-series arrays are populated at addChart time but stay\n// optional on OptsChartDataInternal; read them through these accessors with an empty-array\n// fallback so the OOXML/worksheet assembly never dereferences `undefined`. They also\n// tolerate an absent series (`data[0]` on an empty set) by returning an empty array.\nexport const dataLabels = (d: OptsChartDataInternal | undefined): string[][] => d?.labels ?? []\nexport const dataValues = (d: OptsChartDataInternal | undefined): number[] => d?.values ?? []\nexport const dataSizes = (d: OptsChartDataInternal | undefined): number[] => d?.sizes ?? []\n// The first label group of a series (`labels[0]`), empty when the series or group is absent.\nexport const firstLabelGroup = (d: OptsChartDataInternal | undefined): string[] => dataLabels(d)[0] ?? []\n\n/**\n * The series a category sheet takes its label columns and row count from: the first one that\n * carries labels, else the first.\n *\n * On a plain category chart that is `data[0]`. On a combo it need not be: a scatter subchart's\n * first series is its X row, which carries no labels, so a combo that opens with a scatter gave the\n * sheet no label column while a bar or line after it still wrote `<c:cat>` against column A, which\n * then held the scatter's X values.\n * @param data - the chart's series, across every subchart\n */\nexport const labelSeries = (data: readonly OptsChartDataInternal[]): OptsChartDataInternal | undefined =>\n\tdata.find((series) => dataLabels(series).length > 0) ?? data[0]\n\n// ===== Worksheet-cell references =====\n\n/** The last column a worksheet has, `XFD`. */\nconst MAX_WORKSHEET_COLUMN = 16384\n\n/**\n * The worksheet column name for a 1-based column index: `A` to `Z`, `AA` to `ZZ`, `AAA` to `XFD`.\n *\n * Column names are bijective base 26. There is no zero digit, so each step takes one off before\n * dividing. This used to handle two letters at most, and column 703 came out as `undefinedA`.\n * @param colIndex column index, 1-based\n * @return column name\n * @example 1 returns 'A'\n * @example 27 returns 'AA'\n * @example 703 returns 'AAA'\n */\nexport function getExcelColName(colIndex: number): string {\n\tif (colIndex > MAX_WORKSHEET_COLUMN)\n\t\tthrow new InvalidOptionError(\n\t\t\t'chart/too-many-columns',\n\t\t\t`A chart's worksheet would need column ${colIndex}, past XFD (column ${MAX_WORKSHEET_COLUMN}), the last column a worksheet has. Split the data across more than one chart.`\n\t\t)\n\tlet name = ''\n\tfor (let n = colIndex; n > 0; n = Math.floor((n - 1) / LETTERS.length)) {\n\t\tname = `${LETTERS[(n - 1) % LETTERS.length] ?? ''}${name}`\n\t}\n\treturn name\n}\n\n/**\n * Build an absolute single-cell reference into the embedded workbook's `Sheet1`,\n * as emitted in a chart series `<c:f>` formula: `Sheet1!$C$2`. Centralizes the\n * `$`-anchoring so the column letter and `$` placement can't drift between sites.\n * @param colIndex 1-based column index (1 => 'A')\n * @param row 1-based row number\n */\nexport function sheetCellRef(colIndex: number, row: number): string {\n\treturn `Sheet1!$${getExcelColName(colIndex)}$${row}`\n}\n\n/**\n * Build an absolute range reference into the embedded workbook's `Sheet1`, as\n * emitted in a chart series `<c:f>` formula: `Sheet1!$C$2:$C$6`. A same-column\n * range (the common case) passes the same index for `colFrom`/`colTo`; deriving\n * the column letter once per endpoint removes the duplicated `getExcelColName`\n * call that was a real off-by-one surface.\n * @param colFrom 1-based start column index\n * @param rowFrom 1-based start row\n * @param colTo 1-based end column index\n * @param rowTo 1-based end row\n */\nexport function sheetRangeRef(colFrom: number, rowFrom: number, colTo: number, rowTo: number): string {\n\treturn `Sheet1!$${getExcelColName(colFrom)}$${rowFrom}:$${getExcelColName(colTo)}$${rowTo}`\n}\n\n/**\n * Where everything in one chart's embedded worksheet falls: the workbook writer lays the sheet\n * out from it and every formula in the chart part points back into it.\n *\n * Every number is a fact about the whole chart, not about the series being emitted. The chart XML\n * once derived the label columns and row count per series, from that series' own labels, and the\n * two sides disagreed the moment a caller labelled only the first series.\n */\nexport interface WorksheetLayout {\n\t/**\n\t * `category` for a sheet with a block of label columns whose header cells point at a blank string,\n\t * whether or not any series carries labels; `xy` for a scatter or bubble sheet, which has neither.\n\t * The workbook writer reads this rather than asking the chart type again.\n\t */\n\tkind: 'category' | 'xy'\n\t/** Every column after the label block, in column order. */\n\tcolumns: readonly WorksheetColumn[]\n\t/** How many leading columns the label groups occupy. */\n\tlabelCols: number\n\t/** How many data rows the sheet has, header row excluded. */\n\trowCount: number\n\t/** How many columns the sheet has. */\n\tcolCount: number\n\t/**\n\t * The 1-based column a series' values occupy, and whose header row holds its name.\n\t * @param dataIndex - the series' position across the whole chart, its `_dataIndex`\n\t */\n\tvalueColumn(dataIndex: number): number\n}\n\n/** One column of a chart's worksheet after its label block. */\nexport interface WorksheetColumn {\n\t/** The 1-based column index. */\n\tcol: number\n\t/** The header cell's text. */\n\theader: string\n\t/**\n\t * The value in one data row.\n\t * @param row - the 0-based data row, header excluded\n\t * @returns the value, or `null`/`undefined` for a gap\n\t */\n\tvalue(row: number): number | null | undefined\n}\n\n/** A column holding one series' values under its name. */\nconst valuesColumn = (series: OptsChartDataInternal, col: number): WorksheetColumn => ({\n\tcol,\n\theader: seriesHeader(series),\n\tvalue: (row) => dataValues(series)[row],\n})\n\n/**\n * The 1-based column a bubble series' sizes occupy on a bubble chart's sheet: the one after its\n * values.\n *\n * Only a standalone bubble chart has size columns. A combo cannot hold a bubble subchart\n * (`addChartDefinition` refuses one), so no other layout is ever asked.\n * @param dataIndex - the series' position in the chart, its `_dataIndex`; 1 or more\n */\nexport const bubbleSizeColumn = (dataIndex: number): number => dataIndex * 2 + 1\n\n/**\n * The worksheet layout for one chart, decided by its kind.\n *\n * - A category chart, every combo and every chartEx layout: the label groups of\n * {@link labelSeries} take the leading columns, outermost first, and its categories decide the\n * row count. Then one column\n * per series in data order. A category-less layout (a histogram feeds raw observations with no\n * labels) sizes the sheet from the longest value series instead.\n * - Scatter: no label columns. The X row is column A and each Y series takes the next column,\n * one row per X value.\n * - Bubble: no label columns. The X row is column A and each later series takes two columns, its\n * values and then its sizes ({@link bubbleSizeColumn}).\n *\n * A combo is laid out as a category chart whatever its subcharts are, because one workbook is\n * written from the combined series. A scatter subchart's X row is therefore a column like any\n * other series.\n * @param rel - the chart, for its series and its normalized type\n */\nexport function worksheetLayout(rel: Pick<SlideRelChart, 'data' | 'opts'>): WorksheetLayout {\n\tconst data = rel.data\n\tconst type = rel.opts._type\n\tif (isBubbleChart(type)) {\n\t\tconst valueColumn = (dataIndex: number): number => (dataIndex === 0 ? 1 : dataIndex * 2)\n\t\treturn {\n\t\t\tkind: 'xy',\n\t\t\tcolumns: data.flatMap((series, idx): WorksheetColumn[] =>\n\t\t\t\tidx === 0\n\t\t\t\t\t? [valuesColumn(series, 1)]\n\t\t\t\t\t: [\n\t\t\t\t\t\t\tvaluesColumn(series, valueColumn(series._dataIndex)),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcol: bubbleSizeColumn(series._dataIndex),\n\t\t\t\t\t\t\t\theader: seriesHeader(series, 'sizes'),\n\t\t\t\t\t\t\t\tvalue: (row) => dataSizes(series)[row],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t),\n\t\t\tlabelCols: 0,\n\t\t\trowCount: dataValues(data[0]).length,\n\t\t\t// 1 for the X values, then 2 for every Y series.\n\t\t\tcolCount: (data.length - 1) * 2 + 1,\n\t\t\tvalueColumn,\n\t\t}\n\t}\n\tif (isScatterChart(type)) {\n\t\treturn {\n\t\t\tkind: 'xy',\n\t\t\tcolumns: data.map((series) => valuesColumn(series, series._dataIndex + 1)),\n\t\t\tlabelCols: 0,\n\t\t\trowCount: dataValues(data[0]).length,\n\t\t\tcolCount: data.length,\n\t\t\tvalueColumn: (dataIndex) => dataIndex + 1,\n\t\t}\n\t}\n\tconst labelled = labelSeries(data)\n\tconst labelCols = dataLabels(labelled).length\n\treturn {\n\t\tkind: 'category',\n\t\tcolumns: data.map((series) => valuesColumn(series, series._dataIndex + labelCols + 1)),\n\t\tlabelCols,\n\t\trowCount: firstLabelGroup(labelled).length || Math.max(0, ...data.map((series) => dataValues(series).length)),\n\t\tcolCount: data.length + labelCols,\n\t\tvalueColumn: (dataIndex) => dataIndex + labelCols + 1,\n\t}\n}\n\n/**\n * The category-name range in the leaf label column, header row excluded:\n * `Sheet1!$B$2:$B$<count + 1>` on a sheet with two label levels.\n *\n * Six plot families built this string by hand around the very module whose header says the mapping\n * lives in one place. It then hard-coded column A, which holds the outermost level: a leaf cache over\n * nested labels was referenced against the outer labels' cells. The workbook writes the leaf level in\n * the last label column, which for single-level labels is column A.\n * @param sheet - the chart's worksheet layout\n * @param count - how many categories the series carries\n */\nexport const categoryRange = (sheet: WorksheetLayout, count: number): string =>\n\tsheetRangeRef(sheet.labelCols, 2, sheet.labelCols, count + 1)\n","/**\n * ts-pptx: folding a chart's older stroke spellings onto {@link StrokeProps}.\n *\n * A stroke is one concept, and the chart option bag used to spell it three ways that the rest\n * of the library did not: `size` for the width, `style` for the dash, and a separate\n * `*AxisLineShow` flag for the state `type: 'none'` already names. Those spellings are kept\n * (deprecated) rather than removed, so this is where they collapse into the one shape the\n * emitters read.\n *\n * The rule is the same at every site: **a new key wins over its old counterpart**, and an\n * explicit `type` wins over an inferred one. Nothing here validates -- `define/chart.ts` warns\n * on an out-of-range width or cap before this runs, and `resolveDash` catches a dash outside\n * `ST_PresetLineDashVal` after it.\n */\n\n/* oxlint-disable typescript/no-deprecated -- reading the deprecated spellings is this module's whole job. */\n\nimport { warn } from '../../diagnostics.js'\nimport type {\n\tChartPropsAxisCat,\n\tChartPropsAxisSer,\n\tChartPropsAxisVal,\n\tOptsChartGridLine,\n\tStrokeProps,\n} from '../../types/index.js'\n\n/** The axis-line half of the chart option bag, in all three axes' spellings. */\ntype AxisLineOpts = ChartPropsAxisCat & ChartPropsAxisSer & ChartPropsAxisVal\n\n/**\n * Fold a gridline's `size` and `style` onto `width`, `dashType` and `type`.\n *\n * `style: 'none'` and `type: 'none'` are the same statement; `style: 'dash'` is the literal\n * `dash` preset and maps onto `dashType`, *not* onto `type: 'dash'`, which would mean\n * `sysDash` and would change every deck that already spelled it the old way.\n * @param gl - the caller's gridline options\n * @returns a copy with only the {@link StrokeProps} keys carrying meaning\n */\nexport function gridLineStroke(gl: OptsChartGridLine): OptsChartGridLine {\n\tconst out: OptsChartGridLine = { ...gl }\n\tif (out.width === undefined && out.size !== undefined) out.width = out.size\n\tif (out.dashType === undefined && gl.type === undefined && out.style !== undefined && out.style !== 'none')\n\t\tout.dashType = out.style\n\tif (out.type === undefined && out.style === 'none') out.type = 'none'\n\treturn out\n}\n\n/**\n * Whether a gridline (or a stacked bar's series lines) asks not to be drawn at all.\n *\n * Three axis builders and `createSerLinesElement` each spelled this as\n * `opts.style !== 'none'`, which stopped being the whole test once `type: 'none'` could say it\n * too.\n * @param gl - the caller's gridline options, if any\n * @returns true when no element should be emitted\n */\nexport function gridLineSuppressed(gl: OptsChartGridLine | undefined): boolean {\n\tif (!gl) return true\n\tconst stroke = gridLineStroke(gl)\n\treturn stroke.type === 'none'\n}\n\n/**\n * The one stroke an axis' line emitter reads, folded from whichever spelling the caller used.\n *\n * `*AxisLineShow: false` is the state `type: 'none'` names, and it is the only one of the four\n * flat keys that was not simply a different word for a {@link StrokeProps} key. What it emits\n * is `<a:noFill/>` on the axis' own `<c:spPr>` -- the axis line element is always present, so\n * \"hidden\" and \"absent\" are genuinely different here.\n *\n * All twelve deprecated reads live in this one function rather than at the three axis\n * builders, which is also what stops the three from drifting again: the series axis got its\n * width and dash hardcoded precisely because each builder spelled this out by hand.\n * @param opts - the chart option bag\n * @param axis - which axis' line to resolve\n * @returns the stroke to emit\n */\nexport function axisLineStroke(opts: AxisLineOpts, axis: 'cat' | 'val' | 'ser'): StrokeProps {\n\tconst nested = opts[`${axis}AxisLine`]\n\tconst color = opts[`${axis}AxisLineColor`]\n\tconst size = opts[`${axis}AxisLineSize`]\n\tconst style = opts[`${axis}AxisLineStyle`]\n\tconst show = opts[`${axis}AxisLineShow`]\n\n\tconst out: StrokeProps = { ...nested }\n\tif (out.color === undefined && color !== undefined) out.color = color\n\tif (out.width === undefined && size !== undefined) out.width = size\n\t// `show` and `style` are folded independently: a hidden axis line still writes its\n\t// `<a:prstDash>`, so letting the inferred `type: 'none'` swallow the dash would change\n\t// the bytes of every deck that set both.\n\tif (out.dashType === undefined && nested?.type === undefined && style !== undefined) out.dashType = style\n\tif (out.type === undefined && show === false) out.type = 'none'\n\treturn out\n}\n\n/**\n * Scrub a gridline-shaped stroke's out-of-range values so a default applies instead of a\n * PowerPoint-invalid one reaching the part.\n *\n * `width` and `size` are the same measure under two names, so both are checked and both are\n * dropped together -- leaving one behind would let the scrubbed value come back through the\n * fold. `dashType` needs nothing here: `resolveDash` checks it against the whole\n * `ST_PresetLineDashVal` set at emit, which is the check `style` never had.\n *\n * `option` exists because `c:serLines` takes the same {@link OptsChartGridLine} shape through a\n * different option, and a diagnostic naming `chart.gridLine.width` for a `barSeriesLine` mistake\n * points the caller at an option they did not set. Every entry point that reaches\n * `chartFurnitureLine` is scrubbed here, which is also what lets that emitter default a missing\n * width with `??` -- an unscrubbed caller was the one path a zero could reach the part on.\n * @param glOpts - the caller's line options, scrubbed in place\n * @param option - the option path to name in a diagnostic, as the caller spells it\n */\nexport function scrubGridLine(glOpts: OptsChartGridLine, option = 'chart.gridLine'): void {\n\tif (!glOpts || gridLineSuppressed(glOpts)) return\n\tconst width = glOpts.width ?? glOpts.size\n\tif (width !== undefined && (!Number.isFinite(Number(width)) || width <= 0)) {\n\t\twarn('chart/invalid-grid-line-size', `${option}.width must be greater than 0.`)\n\t\tdelete glOpts.width // delete prop to used defaults\n\t\tdelete glOpts.size\n\t}\n\tif (glOpts.style && !['solid', 'dash', 'dot'].includes(glOpts.style)) {\n\t\twarn('chart/invalid-grid-line-style', `${option}.style options: \\`solid\\`, \\`dash\\`, \\`dot\\`.`)\n\t\tdelete glOpts.style\n\t}\n\tif (glOpts.cap && !['flat', 'square', 'round'].includes(glOpts.cap)) {\n\t\twarn('chart/invalid-grid-line-cap', `${option}.cap options: \\`flat\\`, \\`square\\`, \\`round\\`.`)\n\t\tdelete glOpts.cap\n\t}\n}\n","/**\n * ts-pptx: Shared Chart Fragment Builders\n *\n * The leaf builders every chart region reuses -- titles, gridlines, series data points,\n * error bars, number caches, leader lines, borders. Each is a pure string builder with\n * no dependency on any other module in this directory, which is what lets the plot\n * builders ({@link ./plot-cat-axis}, {@link ./plot-scatter}, {@link ./plot-bubble},\n * {@link ./plot-pie}), the axes ({@link ./chart-axes}), and the chart envelope\n * ({@link ./chart-xml}) all draw on them without a cycle.\n */\n\nimport { ChartType } from '../../enums.js'\nimport {\n\tBARCHART_COLORS,\n\tDEF_CHART_GRIDLINE,\n\tDEF_FONT_COLOR,\n\tDEF_FONT_SIZE,\n\tDEF_SHAPE_SHADOW,\n\tPIECHART_COLORS,\n} from '../../constants-internal.js'\nimport type { BorderProps, Coord, ChartPropsTitle, ChartSeriesOpts, OptsChartGridLine } from '../../types/index.js'\nimport type {\n\tChartErrorBarInternal,\n\tChartOptsInternal,\n\tMaybeUndefined,\n\tOptsChartDataInternal,\n} from '../../types/internal.js'\nimport { TIME_UNITS, type TimeUnit } from '../../ooxml/st-enums.js'\nimport { warn } from '../../diagnostics.js'\nimport { alphaEl, createColorElement, namedColorOr } from '../drawingml/color.js'\nimport { createShadowEffectLst } from '../drawingml/effect.js'\nimport { genXmlColorSelection, genXmlPatternFill } from '../drawingml/fill.js'\nimport { clampFontSizeSz } from '../drawingml/clamp.js'\nimport { borderLine, createLineCap, noStrokeLine, resolveDash, strokeDash, strokePaint } from '../drawingml/line.js'\nimport { gridLineStroke, gridLineSuppressed } from './chart-stroke.js'\nimport { seriesIdx } from './chart-kind.js'\nimport {\n\tconvertAngleUnits,\n\tlineWidthToEmu,\n\tmapStated,\n\tpercentToFixedPercent,\n\tptsToEmuLenient,\n} from '../../units-internal.js'\nimport { coordToEmu, EMU_PER_INCH } from '../../units.js'\nimport {\n\tcategoryRange,\n\tdataLabels,\n\tdataValues,\n\tfirstLabelGroup,\n\tseriesHeader,\n\tsheetCellRef,\n\tsheetRangeRef,\n\ttype WorksheetLayout,\n} from './data-refs.js'\nimport { el, raw, voidEl, type XmlChild } from '../oxml/el.js'\nimport { type XsdBool, xsdBool } from '../../ooxml/xsd-boolean.js'\nimport { OOXML_NS } from '../../ooxml/namespaces.js'\n\n/**\n * The six `c:show*` flags every `<c:dLbls>` carries, in schema order, as `XmlChild`s for the\n * parent's child list. Eight `<c:dLbls>` builders across five modules wrote all six out by\n * hand; each cared about one or two of them and hard-coded the rest to `0`.\n *\n * The order is `CT_DLbls`'s and is not negotiable, which is the other reason to state it once:\n * a flag inserted in the wrong place is a repair prompt rather than a wrong-looking chart.\n * Every flag defaults to `0`, so a caller names only what it means to turn on.\n *\n * @param flags - the values to emit, defaulting to `0`\n */\nexport function dLblShowFlags(flags: {\n\tlegendKey?: XsdBool\n\tval?: XsdBool\n\tcatName?: XsdBool\n\tserName?: XsdBool\n\tpercent?: XsdBool\n\tbubbleSize?: XsdBool\n}): XmlChild[] {\n\treturn (\n\t\t[\n\t\t\t['c:showLegendKey', flags.legendKey],\n\t\t\t['c:showVal', flags.val],\n\t\t\t['c:showCatName', flags.catName],\n\t\t\t['c:showSerName', flags.serName],\n\t\t\t['c:showPercent', flags.percent],\n\t\t\t['c:showBubbleSize', flags.bubbleSize],\n\t\t] as const\n\t).map(([name, val]) => raw(voidEl(name, { val: val ?? 0 })))\n}\n\n/**\n * The data-label run properties, in the attribute order the scatter and custom-label paths\n * emit: `sz, b, i, u, strike`.\n *\n * There is a second ordering in this file — `b, i, strike, sz, u`, used by\n * {@link chartDataLabels} and by the bubble plot — and the two are **deliberately not\n * merged**. Attribute order carries no meaning in XML, so either is correct and a reader is\n * right to want one; but merging them moves bytes in a refactor whose whole claim is that it\n * does not, and the byte-identity gate is what makes that claim checkable. Unifying the\n * spelling is a decision to take on its own, with its own re-baseline.\n *\n * `over` layers a series' own `seriesOptions` entry on top with `??`, leaving the chart-level\n * reading below it exactly as it was — a series that states nothing produces the same bytes.\n * @param opts - the chart's normalized options\n * @param over - this series' `seriesOptions` entry, whose stated fields win over the chart's\n */\nexport function labelFontAttrs(opts: ChartOptsInternal, over?: ChartSeriesOpts): Record<string, string | number> {\n\treturn {\n\t\tsz: clampFontSizeSz(over?.dataLabelFontSize ?? opts.dataLabelFontSize ?? DEF_FONT_SIZE, 'dataLabelFontSize'),\n\t\tb: xsdBool(over?.dataLabelFontBold ?? opts.dataLabelFontBold),\n\t\ti: xsdBool(over?.dataLabelFontItalic ?? opts.dataLabelFontItalic),\n\t\tu: 'none',\n\t\tstrike: 'noStrike',\n\t}\n}\n\n/**\n * The colour a data label paints: the series' own `dataLabelColor`, else the chart's, else\n * {@link DEF_FONT_COLOR}.\n *\n * Both spellings of the option run through here so an empty string resolves once, and to the\n * same thing an omitted option resolves to. It used to reach {@link genXmlColorSelection} as\n * `''` and emit no colour at all, which made a blank `dataLabelColor` inherit while an absent\n * one painted black.\n * @param opts - the chart's normalized options\n * @param over - this series' `seriesOptions` entry, whose stated field wins over the chart's\n */\nfunction resolveDataLabelColor(opts: ChartOptsInternal, over?: ChartSeriesOpts): string {\n\treturn namedColorOr(\n\t\tover?.dataLabelColor,\n\t\tnamedColorOr(opts.dataLabelColor, DEF_FONT_COLOR, 'dataLabelColor'),\n\t\t'dataLabelColor'\n\t)\n}\n\n/**\n * The colour and typeface children of those run properties.\n *\n * The fill goes through {@link genXmlColorSelection} rather than a hand-built `<a:solidFill>`\n * around {@link createColorElement} so that both data-label builders answer an empty\n * `dataLabelColor` the same way. What that answer *is* comes from\n * {@link resolveDataLabelColor}: an empty string is the caller's missing value, so it paints\n * what omitting the option paints. For any colour that names something the two spellings are\n * the same bytes.\n * @param opts - the chart's normalized options\n * @param over - this series' `seriesOptions` entry, whose stated fields win over the chart's\n */\nexport function labelFontChildren(opts: ChartOptsInternal, over?: ChartSeriesOpts): XmlChild[] {\n\treturn [\n\t\traw(genXmlColorSelection(resolveDataLabelColor(opts, over))),\n\t\traw(createChartTextFonts(over?.dataLabelFontFace ?? opts.dataLabelFontFace ?? 'Arial')),\n\t]\n}\n\n/**\n * A data label's `<a:defRPr>` in the `sz, b, i, u, strike` ordering: {@link labelFontAttrs} over\n * {@link labelFontChildren}. The pie's label blocks, both scatter label builders and the per-point\n * custom label each built it. The other ordering stays {@link dataLabelDefRPr}.\n * @param opts - the chart's normalized options\n * @param over - this series' `seriesOptions` entry, whose stated fields win over the chart's\n */\nexport function labelDefRPr(opts: ChartOptsInternal, over?: ChartSeriesOpts): string {\n\treturn el('a:defRPr', labelFontAttrs(opts, over), labelFontChildren(opts, over))\n}\n\n/**\n * One styled data-label run: an `<a:rPr>` carrying the chart's language, the label font and\n * `dirty=\"0\"`, then the literal text. The scatter custom label and the per-point custom label each\n * built it. Both font helpers warn at most once per condition, so reading them again here adds no\n * diagnostic.\n * @param opts - the chart's normalized options\n * @param text - the label text, escaped by the builder\n * @param over - this series' `seriesOptions` entry, whose stated fields win over the chart's\n */\nexport function labelRun(opts: ChartOptsInternal, text: string, over?: ChartSeriesOpts): string {\n\treturn el('a:r', null, [\n\t\traw(el('a:rPr', { lang: chartLang(opts), ...labelFontAttrs(opts, over), dirty: 0 }, labelFontChildren(opts, over))),\n\t\traw(el('a:t', null, text)),\n\t])\n}\n\n/**\n * The `<c:txPr>` a data-label block wraps its run properties in: an empty `<a:bodyPr>`, an empty\n * `<a:lstStyle>`, then one `<a:p>` carrying the `<a:pPr>` the caller built.\n *\n * Five sites spelled this out byte-identically — the shared `<c:dLbls>` builder, the bubble,\n * category-axis and pie plots, and the pie's plot-level block. The axis one in `chart-axes.ts`\n * is deliberately NOT this: it carries a rotation on the `bodyPr` and an `<a:endParaRPr>` after\n * the `<a:pPr>`.\n * @param defRPr - the already-built `<a:defRPr>`\n */\nexport function labelTextProps(defRPr: string): string {\n\treturn el('c:txPr', null, [\n\t\traw(voidEl('a:bodyPr', null)),\n\t\traw(voidEl('a:lstStyle', null)),\n\t\traw(el('a:p', null, raw(el('a:pPr', null, raw(defRPr))))),\n\t])\n}\n\n/**\n * The language a chart's text runs are tagged with: the chart's `lang`, else `en-US`. Nine sites\n * across the axes, the plots and the chartEx part spelled the fallback.\n * @param opts - the chart's options, or anything carrying its `lang`\n */\nexport function chartLang(opts: { lang?: string | undefined }): string {\n\treturn opts.lang || 'en-US'\n}\n\n/**\n * A data-label block's `<c:dLblPos>`, or `undefined` when the chart states no position. The pie's\n * two label blocks decide the position differently and do not use it.\n * @param opts - the chart's normalized options\n */\nexport function dLblPosEl(opts: ChartOptsInternal): string | undefined {\n\treturn opts.dataLabelPosition ? voidEl('c:dLblPos', { val: opts.dataLabelPosition }) : undefined\n}\n\n/**\n * The 2012 chart extension carrying a data-label block's leader-line toggle, which has no `c:`\n * equivalent. The bubble plot passes the chart's option; the scatter `XY` labels pass `1`.\n * @param val - the toggle; the scatter `XY` labels' constant `1` is written as the same attribute\n */\nexport function c15LeaderLinesExt(val: XsdBool | 1): string {\n\treturn el(\n\t\t'c:extLst',\n\t\tnull,\n\t\traw(\n\t\t\tel(\n\t\t\t\t'c:ext',\n\t\t\t\t{ uri: '{CE6537A1-D6FC-4f65-9D91-7224C49458BB}', 'xmlns:c15': OOXML_NS.c15 },\n\t\t\t\traw(voidEl('c15:showLeaderLines', { val }))\n\t\t\t)\n\t\t)\n\t)\n}\n\n/**\n * The `<a:defRPr>` a `<c:dLbls>` text style carries, in the `b, i, strike, sz, u` ordering the\n * chart-level and bubble label blocks share. See {@link labelFontAttrs} for why there are two\n * orderings and why they stay apart.\n *\n * This and {@link labelFontAttrs} read the same five options and read them the same way:\n * `over?.X ?? opts.X ?? DEFAULT`. Attribute order is the only difference left between them.\n *\n * They disagreed on the operator once — `??` here against `||` there — and which one a chart\n * reached was decided by its type and its label format, so `dataLabelFontSize: 0` had three\n * answers: a bar warned and clamped, a pie dropped the value with no diagnostic at all, and an\n * `XY` scatter, which reaches both builders, emitted `sz=\"100\"` on one label block and\n * `sz=\"1200\"` on another of the same chart. `??` is the reading kept everywhere, because the\n * caller stating a value and the caller saying nothing are different. An explicit `0` therefore\n * goes through {@link clampFontSizeSz} and is corrected to the `ST_TextFontSize` minimum with a\n * warning, and **omitting the option is the only spelling of \"use the default\"**.\n * @param opts - the chart's normalized options\n * @param over - this series' `seriesOptions` entry, whose stated fields win over the chart's\n */\nexport function dataLabelDefRPr(opts: ChartOptsInternal, over?: ChartSeriesOpts): string {\n\treturn el(\n\t\t'a:defRPr',\n\t\t{\n\t\t\tb: xsdBool(over?.dataLabelFontBold ?? opts.dataLabelFontBold),\n\t\t\ti: xsdBool(over?.dataLabelFontItalic ?? opts.dataLabelFontItalic),\n\t\t\tstrike: 'noStrike',\n\t\t\tsz: clampFontSizeSz(over?.dataLabelFontSize ?? opts.dataLabelFontSize ?? DEF_FONT_SIZE, 'dataLabelFontSize'),\n\t\t\tu: 'none',\n\t\t},\n\t\t[\n\t\t\traw(genXmlColorSelection(resolveDataLabelColor(opts, over))),\n\t\t\traw(createChartTextFonts(over?.dataLabelFontFace ?? opts.dataLabelFontFace ?? 'Arial')),\n\t\t]\n\t)\n}\n\n/**\n * The signature every axis-plot builder shares: `<c:areaChart>`, `<c:barChart>`,\n * `<c:lineChart>`, `<c:radarChart>`, `<c:scatterChart>`, `<c:bubbleChart>`,\n * `<c:stockChart>` and `<c:surfaceChart>` are all built from the same inputs and\n * dispatched from one `switch` in {@link ./chart-xml}.\n *\n * Naming it makes adding an input one edit instead of six, and makes a builder that\n * disagrees with the dispatch a type error rather than an argument quietly dropped on the\n * floor. `makePiePlot` is deliberately not of this type: a pie has no axes, so it takes\n * neither axis id, and widening the contract to fit it would mean handing it two arguments\n * it must ignore.\n *\n * `chartType` is passed even to the builders that serve a single kind (`stock`, `surface`),\n * which spell it `_chartType`, so the dispatch stays uniform.\n */\nexport type PlotBuilder = (\n\tchartType: ChartType,\n\tdata: OptsChartDataInternal[],\n\topts: ChartOptsInternal,\n\tvalAxisId: string,\n\tcatAxisId: string,\n\tvalFmtCode: string,\n\tsheet: WorksheetLayout\n) => string\n\n/**\n * A validated, lowercased axis time unit (`ST_TimeUnit`), or `undefined` when the value is not one.\n * The case is forgiven, so `'Days'` reads as `days`.\n *\n * A garbage time unit does not degrade the chart -- it corrupts it, and PowerPoint renders\n * nothing at all -- so an unrecognized value warns and is dropped rather than emitted.\n *\n * This replaces two copies of a loop that wrote `opts[opt] = undefined` back onto the options\n * bag from inside an XML builder. Nothing downstream was corrupted (`ChartOptsInternal` is a\n * copy `gen/define/chart.ts` already made, guarded by\n * `test/regression/chart/chart-input-immutability.test.js`), but it meant calling the same axis\n * builder twice gave a different answer the second time, and it put validation somewhere nobody\n * would look for it.\n *\n * The parameter stays `string` although the three options are typed {@link TimeUnit}. The type\n * advertises the canonical spelling at the call site; this is where a value that never met a type\n * arrives -- a JavaScript caller, a JSON config, a value read back off a deck -- so it keeps\n * checking, and keeps forgiving case. The narrower option type is not permission to drop either.\n * @param value - the caller's time unit, or `undefined`\n * @param optionName - the option as the caller spells it, for the warning\n */\nexport function validTimeUnit(value: string | undefined, optionName: string): TimeUnit | undefined {\n\tif (!value) return undefined\n\tconst lowered = typeof value === 'string' ? value.toLowerCase() : ''\n\tif (!(TIME_UNITS as readonly string[]).includes(lowered)) {\n\t\twarn('chart/invalid-axis-time-unit', `\"${optionName}\" must be one of: ${TIME_UNITS.join(', ')}.`)\n\t\treturn undefined\n\t}\n\treturn lowered as TimeUnit\n}\n\n/**\n * A count attribute that `ST_Skip` (an `xsd:unsignedInt` of at least 1) will accept, or\n * `undefined` when the caller's value is not one.\n *\n * `catAxisLabelFrequency` and `serAxisLabelFrequency` were typed as free-form strings and\n * emitted verbatim, so `'every other'` reached `<c:tickLblSkip val=\"every other\"/>` — and the\n * type also rejected the natural `2`. Same shape as {@link validTimeUnit} beside it: warn and\n * emit nothing rather than write a value outside the attribute's own type.\n * @param value - the caller's value, a number or a numeric string\n * @param optionName - option name as the caller spells it, for the warning\n */\nexport function positiveIntAttr(value: number | string | undefined, optionName: string): number | undefined {\n\tif (value === undefined || value === null || value === '') return undefined\n\tconst n = Number(value)\n\tif (!Number.isInteger(n) || n < 1) {\n\t\twarn(\n\t\t\t'chart/option-out-of-range',\n\t\t\t`\"${optionName}\" must be a whole number of at least 1; ignoring ${String(value)}.`\n\t\t)\n\t\treturn undefined\n\t}\n\treturn n\n}\n\n/**\n * Where one axis meets the other: `<c:crossesAt val>` for an explicit position, `<c:crosses val>`\n * for a rule, and `defaultRule` when the caller stated neither.\n *\n * The two axis builders each spelled this decision out, and both opened it with\n * `typeof value === 'number'` — the one numeric guard in the file that `NaN` passes, since every\n * other numeric axis option is guarded by truthiness. `{ valAxisCrossesAt: NaN }` therefore\n * emitted `<c:crossesAt val=\"NaN\"/>`, and `ST_Double` has no such value.\n * @param value - the caller's `*AxisCrossesAt`: a position, a `ST_Crosses` rule, or nothing\n * @param defaultRule - the `ST_Crosses` rule to fall back on\n * @param optionName - option name as the caller spells it, for the warning\n */\nexport function axisCrossing(value: number | string | undefined, defaultRule: string, optionName: string): string {\n\tif (typeof value === 'number') {\n\t\tif (Number.isFinite(value)) return voidEl('c:crossesAt', { val: value })\n\t\twarn('chart/option-out-of-range', `${optionName} must be a finite number; using \"${defaultRule}\" instead.`)\n\t\treturn voidEl('c:crosses', { val: defaultRule })\n\t}\n\treturn voidEl('c:crosses', { val: value || defaultRule })\n}\n\n/**\n * The built-in series palette for a chart type.\n *\n * Pie and doughnut colour their *data points* rather than their series, so they take the wider,\n * flatter `PIECHART_COLORS`; everything else takes `BARCHART_COLORS`. A combo chart's `_type` is\n * an array, which is neither, and lands on the bar palette its subcharts already use.\n * @param {ChartOptsInternal['_type']} type - the normalized chart type\n * @returns {string[]} the palette that applies when the caller named none\n */\nexport function defaultChartPalette(type: ChartOptsInternal['_type']): string[] {\n\treturn type === ChartType.pie || type === ChartType.doughnut ? PIECHART_COLORS : BARCHART_COLORS\n}\n\n/**\n * The palette a chart's series and data points draw from: the caller's `chartColors` when it has\n * entries, otherwise {@link defaultChartPalette} for this chart's type.\n *\n * `addChartDefinition` resolves `chartColors` the same way, so for a plain chart this agrees with\n * what normalization already put there. It is not redundant: the palette is resolved once for the\n * whole chart, and a combo subchart that states `chartColors: []` is not put through that pass, so\n * this is the only place such a subchart's palette is decided. Six plot builders wrote the lookup out; going\n * through one function is what makes \"no colours named\" a single decision rather than six.\n */\nexport function resolveChartPalette(opts: ChartOptsInternal): string[] {\n\treturn opts.chartColors?.length ? opts.chartColors : defaultChartPalette(opts._type)\n}\n\n/**\n * The palette colour for series/point `idx`, cycling back to the start once the palette runs out.\n *\n * Every palette lookup in this directory goes through here so that a deck with more series or\n * data points than the palette has entries still emits the same bytes on every build.\n */\nexport function paletteColor(palette: readonly string[], idx: number, fallback = '000000'): string {\n\tif (palette.length === 0) return fallback\n\treturn palette[idx % palette.length] ?? fallback\n}\n\n// DEF_CHART_GRIDLINE.color is optional on the type but always present on the constant.\nexport const DEF_GRIDLINE_COLOR: string = DEF_CHART_GRIDLINE.color ?? '888888'\n\n/**\n * The `a:prstDash/@val` one plotted series' stroke takes: this series' own entry in\n * `lineDashValues`, else the chart-wide `lineDash`, else solid.\n *\n * The bubble, category and scatter plot builders each spelled that fallback chain out\n * byte-identically, and none of the three checked the result against `ST_PresetLineDashVal`.\n * @param opts - the chart's normalized options\n * @param serIndex - the series' 0-based index\n * @returns a value legal for `a:prstDash/@val`\n */\nfunction seriesDash(opts: ChartOptsInternal, serIndex: number): string {\n\treturn resolveDash(opts.lineDashValues?.[serIndex] ?? opts.lineDash, 'solid', 'lineDash')\n}\n\n/**\n * Fill fragment for a `chartColors`-derived series/line/marker colour.\n *\n * A `'transparent'` entry means \"no fill\" — an invisible series, connecting line, or marker\n * stroke — and maps to `<a:noFill/>`. Any real colour goes through the normal solid-fill path.\n * The series and marker *fill* paths already special-case `'transparent'`; without this the\n * *stroke* paths (`<a:ln>` on the series line and marker border) would instead pass the literal\n * `'transparent'` through colour validation, warn \"not a valid scheme color or hex RGB\", and\n * render as black — leaving a stray black line/border where a transparent series was requested.\n */\nexport function chartColorLineFill(color: string): string {\n\treturn color === 'transparent' ? voidEl('a:noFill') : genXmlColorSelection(color)\n}\n\n/**\n * The series *fill* for one plotted series: `<a:noFill>` for a transparent series, a solid fill\n * carrying `<a:alpha>` when the chart sets `chartColorsOpacity`, and a plain solid fill\n * otherwise.\n *\n * Read against {@link chartColorLineFill}, which is the same decision for a *stroke* and stops\n * one step earlier — a stroke has no opacity option to fold in. Three plot builders (bubble,\n * scatter, and the whole category-axis family) each carried this expression verbatim, down to\n * the diagnostic code and the option name in its message, which is what made the `transparent`\n * arm easy to add to one and forget in another.\n *\n * @param opts - the chart's normalized options, read for `chartColorsOpacity`\n * @param serColor - the series' resolved palette colour, or `'transparent'`\n */\nfunction seriesFill(opts: ChartOptsInternal, serColor: string): string {\n\tif (serColor === 'transparent') return voidEl('a:noFill')\n\t// `== null`, not truthiness: `chartColorsOpacity: 0` is a stated, fully transparent fill.\n\tif (opts.chartColorsOpacity == null) return genXmlColorSelection(serColor)\n\tconst alpha = alphaEl(\n\t\tpercentToFixedPercent(opts.chartColorsOpacity, 'chart/option-out-of-range', 'chartColorsOpacity')\n\t)\n\treturn el('a:solidFill', null, raw(createColorElement(serColor, alpha)))\n}\n\n/**\n * One plotted series' stroke: a width, this series' dash, the palette colour and a round join —\n * or `<a:noFill/>` when the caller asked for no line at all.\n *\n * Three plot builders had this, differing only in whether a per-series `lineSize` could override\n * the chart's. `lineSize: 0` is the caller's \"no outline\" and is checked for explicitly, not by\n * truthiness, because it is a stated value rather than an absent one.\n *\n * Every other width goes through {@link lineWidthToEmu}, which is what `a:ln/@w` needs: ST_LineWidth\n * is unsigned, so a negative width clamps to 0 with a warning, and `NaN` throws. A per-series\n * `seriesOptions[].lineSize` never passes the definer, so this is the one place both are checked.\n * @param opts - the chart's normalized options\n * @param color - the series' resolved palette colour\n * @param serIndex - the series' index, for `lineDashValues`\n * @param sizePt - the width in points; `undefined` falls back to the chart's, then to 2\n */\nexport function seriesStroke(opts: ChartOptsInternal, color: string, serIndex: number, sizePt?: number): string {\n\tconst widthPt = sizePt ?? opts.lineSize ?? 2\n\tif (widthPt === 0) return el('a:ln', null, raw(voidEl('a:noFill')))\n\treturn el('a:ln', { w: lineWidthToEmu(widthPt, 'lineSize'), cap: createLineCap(opts.lineCap) }, [\n\t\traw(chartColorLineFill(color)),\n\t\traw(voidEl('a:prstDash', { val: seriesDash(opts, serIndex) })),\n\t\traw(voidEl('a:round')),\n\t])\n}\n\n/**\n * The `<c:spPr>` every plotted series carries: its fill, the outline the caller built, and the\n * chart's shadow. Only the outline differs between plot families -- a line-like series strokes\n * itself, a scatter series always does, a bubble series lets `dataBorder` win -- so the caller\n * builds `<a:ln>` and hands it over rather than describing it through flags.\n *\n * @param opts - the chart's normalized options, read for `chartColorsOpacity` and `shadow`\n * @param serColor - the series' resolved palette colour, or `'transparent'`\n * @param line - the already-built `<a:ln>`, or `''` for a series with no outline\n */\nexport function seriesShapeProps(opts: ChartOptsInternal, serColor: string, line: string): string {\n\tconst fill = seriesFill(opts, serColor)\n\treturn el('c:spPr', null, [raw(fill), raw(line), raw(createShadowEffectLst(opts.shadow, DEF_SHAPE_SHADOW))])\n}\n\n/**\n * The point marker for a series drawn as a line: the symbol, an optional size, and the marker's\n * own fill and outline. `<c:marker>` must precede `<c:dLbls>` in CT_LineSer and CT_ScatterSer\n * (schema order: spPr -> marker -> dPt -> dLbls).\n *\n * @param opts - the chart's normalized options, read for the `lineDataSymbol*` family\n * @param markerColor - the marker's fill colour, or `'transparent'`\n * @param seriesColor - what the marker's outline falls back to when `lineDataSymbolLineColor` is\n * unset; a scatter series passes its own colour for both roles\n */\nexport function serMarker(opts: ChartOptsInternal, markerColor: string, seriesColor: string): string {\n\tconst spPr = el('c:spPr', null, [\n\t\traw(markerColor === 'transparent' ? voidEl('a:noFill') : genXmlColorSelection(markerColor)),\n\t\traw(\n\t\t\t// Points, clamped into ST_LineWidth by the define layer, so the conversion has nothing to refuse.\n\t\t\tel('a:ln', { w: ptsToEmuLenient(opts.lineDataSymbolLineSize ?? 0.75), cap: 'flat' }, [\n\t\t\t\traw(chartColorLineFill(namedColorOr(opts.lineDataSymbolLineColor, seriesColor, 'lineDataSymbolLineColor'))),\n\t\t\t\traw(voidEl('a:prstDash', { val: 'solid' })),\n\t\t\t\traw(voidEl('a:round')),\n\t\t\t])\n\t\t),\n\t\traw(voidEl('a:effectLst')),\n\t])\n\treturn el('c:marker', null, [\n\t\traw(voidEl('c:symbol', { val: opts.lineDataSymbol })),\n\t\t// Defaults to \"auto\" otherwise (but this is usually too small, so there is a default).\n\t\topts.lineDataSymbolSize ? raw(voidEl('c:size', { val: opts.lineDataSymbolSize })) : null,\n\t\traw(spPr),\n\t])\n}\n/**\n * Emit the `<a:latin>/<a:ea>/<a:cs>` font trio for a chart text run.\n *\n * In DrawingML run properties a typeface applies only to the script class of\n * its element: `<a:latin>` covers Latin/ASCII, `<a:ea>` covers East Asian, and\n * `<a:cs>` covers complex scripts. Emitting `<a:latin>` alone leaves East Asian\n * (e.g. Chinese) and complex-script glyphs falling back to the theme font, so a\n * user-specified font never takes effect for that text — most visibly on\n * PowerPoint for Mac. Stamping the same typeface onto all three classes is what\n * choosing a font in PowerPoint's UI does.\n * @param {string} typeface - font face name\n * @return {string} `<a:latin/><a:ea/><a:cs/>` XML\n */\n\nexport function createChartTextFonts(typeface: string): string {\n\t// Every caller passes a caller-supplied font option (dataLabelFontFace, catAxisLabelFontFace,\n\t// legendFontFace, ...), so escaping happens here — one site covers all of them. voidEl()'s\n\t// attrs escape by construction: an unescaped `\"` or `&` would otherwise close the attribute\n\t// early and emit a non-parseable chart part.\n\treturn voidEl('a:latin', { typeface }) + voidEl('a:ea', { typeface }) + voidEl('a:cs', { typeface })\n}\n\n/**\n * A chart's own `x`/`y` as inches, for folding into a manual title layout.\n *\n * `ChartOpts.x`/`y` are `Coord`, so `'10%'`, `'2in'` and `'50px'` are all legal and documented.\n * The title builder used to take them through an `as number` cast, so a string reached the\n * arithmetic below, `+` concatenated instead of adding, and `<c:x val=\"NaN\"/>` came out. The\n * cast was both the cause and what hid it.\n *\n * A percentage is the one form that cannot be resolved here: it needs the slide axis, and the\n * chart part is built without a `PresLayout`. It returns `undefined` like an absent coordinate,\n * which leaves that axis on automatic layout rather than on a wrong number.\n * @param value - the chart's `x` or `y` as the caller spelled it\n */\nfunction chartCoordInches(value: Coord | undefined): number | undefined {\n\tif (value === undefined || value === null) return undefined\n\t// A bare number is inches by definition. Taking it directly also keeps `coordToEmu` from\n\t// re-raising `coord/bare-number-is-inches`, which the graphic frame already reports for it.\n\tif (typeof value === 'number') return Number.isFinite(value) ? value : undefined\n\tif (value.trim().endsWith('%')) return undefined\n\tconst emu = coordToEmu(value, 0)\n\treturn Number.isFinite(emu) ? emu / EMU_PER_INCH : undefined\n}\n\nexport function genXmlTitle(opts: MaybeUndefined<ChartPropsTitle>, chartX?: Coord, chartY?: Coord): string {\n\t// `sizeAttr` is empty when the caller set no font size — PowerPoint then picks the default —\n\t// and interpolating it empty leaves TWO spaces between the tag name and `b=`. Those are\n\t// emitted bytes, and `el()` writes exactly one space before an attribute by design, so the\n\t// two run-property tags below stay hand-written. Dropping the padding would be the real fix —\n\t// no XML consumer can see it — but that is an output change, and a whitespace-only diff is a\n\t// stop rather than a cleanup. Flattening the chart emitters did NOT take it: that space is\n\t// inside a tag rather than between elements, which is a different claim needing different\n\t// evidence, and `prove-whitespace` freezes intra-tag whitespace so it stays visible\n\t// (`docs/contributing/testing.md`, \"Proving a change is whitespace-only\"). Two other sites in\n\t// this directory are in the same position; the ratchet header lists them.\n\t// An empty `sizeAttr` spells one state and only one: the caller stated no size, which the\n\t// axis-title path still reaches (`catAxisTitleFontSize` and its two siblings are optional).\n\t// A stated `0` is a stated value, so it clamps and warns like every other size rather than\n\t// falling through to the same silence.\n\tconst sizeAttr = opts.fontSize == null ? '' : `sz=\"${clampFontSizeSz(opts.fontSize, 'title fontSize')}\"`\n\tconst runAttrs = ` ${sizeAttr} b=\"${xsdBool(opts.titleBold)}\" i=\"${xsdBool(opts.titleItalic)}\" u=\"${opts.titleUnderline ? 'sng' : 'none'}\" strike=\"noStrike\">`\n\tconst runChildren =\n\t\tgenXmlColorSelection(namedColorOr(opts.color, DEF_FONT_COLOR, 'chart text color')) +\n\t\tcreateChartTextFonts(opts.fontFace ?? 'Arial')\n\n\t// NOTE: manualLayout x/y vals are *relative to the entire slide*. Each axis is independent in\n\t// CT_ManualLayout: omitting xMode/x (or yMode/y) leaves that axis on automatic layout, so a\n\t// caller can center horizontally while still applying a manual vertical offset (and vice-versa).\n\t// Schema order is xMode, yMode, x, y.\n\t/**\n\t * Fold a slide-relative offset into the fraction-of-chart value `c:x`/`c:y` want, or\n\t * `undefined` when it does not read as a finite number — `ST_Double` has no `NaN`, and\n\t * omitting the axis is what CT_ManualLayout already means by \"leave this one automatic\".\n\t */\n\tconst edgeFraction = (offset: number): number | undefined => {\n\t\tif (!Number.isFinite(offset)) return undefined\n\t\tlet val = offset === 0 ? 0 : (offset * (offset / 5)) / 10\n\t\tif (val >= 1) val = val / 10\n\t\tif (val >= 0.1) val = val / 10\n\t\treturn val\n\t}\n\t/**\n\t * The chart's own offset along one axis, in inches, to fold into the caller's `titlePos`.\n\t *\n\t * Resolved here rather than by the caller so the warning fires only where the value is\n\t * actually used — a chart with `showTitle` and no `titlePos` folds nothing and says nothing.\n\t */\n\tconst chartOffset = (value: Coord | undefined, axis: 'x' | 'y'): number => {\n\t\tconst inches = chartCoordInches(value)\n\t\tif (inches !== undefined) return inches\n\t\tif (value !== undefined && value !== null)\n\t\t\twarn(\n\t\t\t\t'chart/option-out-of-range',\n\t\t\t\t`chart ${axis} \"${String(value)}\" needs a slide layout to resolve and the chart part is built without one; ` +\n\t\t\t\t\t`titlePos.${axis} is placed without it.`\n\t\t\t)\n\t\treturn 0\n\t}\n\t// `Number.isFinite`, not `typeof === 'number'`: the latter is the one numeric guard `NaN`\n\t// passes, and a `titlePos: { x: NaN }` used to reach the attribute as written.\n\tconst xVal = Number.isFinite(opts.titlePos?.x)\n\t\t? edgeFraction((opts.titlePos?.x ?? 0) + chartOffset(chartX, 'x'))\n\t\t: undefined\n\tconst yVal = Number.isFinite(opts.titlePos?.y)\n\t\t? edgeFraction((opts.titlePos?.y ?? 0) + chartOffset(chartY, 'y'))\n\t\t: undefined\n\tlet layout = voidEl('c:layout')\n\tif (xVal !== undefined || yVal !== undefined) {\n\t\tconst modes =\n\t\t\t(xVal !== undefined ? voidEl('c:xMode', { val: 'edge' }) : '') +\n\t\t\t(yVal !== undefined ? voidEl('c:yMode', { val: 'edge' }) : '')\n\t\tconst vals =\n\t\t\t(xVal !== undefined ? voidEl('c:x', { val: xVal }) : '') +\n\t\t\t(yVal !== undefined ? voidEl('c:y', { val: yVal }) : '')\n\t\tlayout = el('c:layout', null, raw(el('c:manualLayout', null, raw(modes + vals))))\n\t}\n\n\tconst paragraph = el('a:p', null, [\n\t\traw(\n\t\t\tel(\n\t\t\t\t'a:pPr',\n\t\t\t\topts.titleAlign === 'left' || opts.titleAlign === 'right' ? { algn: opts.titleAlign.slice(0, 1) } : null,\n\t\t\t\traw('<a:defRPr' + runAttrs + runChildren + '</a:defRPr>')\n\t\t\t)\n\t\t),\n\t\traw(el('a:r', null, [raw('<a:rPr' + runAttrs + runChildren + '</a:rPr>'), raw(el('a:t', null, opts.title ?? ''))])),\n\t])\n\tconst rich = el('c:rich', null, [\n\t\t// Don't specify a rotation when none was asked for, so the default applies (which is\n\t\t// vertical on a category axis).\n\t\traw(voidEl('a:bodyPr', { rot: mapStated(opts.titleRotate, (d) => convertAngleUnits(d, 'titleRotate')) })),\n\t\traw(voidEl('a:lstStyle', null)),\n\t\traw(paragraph),\n\t])\n\treturn el('c:title', null, [raw(el('c:tx', null, raw(rich))), raw(layout), raw(voidEl('c:overlay', { val: 0 }))])\n}\n\n/**\n * A chart furniture line wrapped in its own element and a `<c:spPr>`: the gridlines a plot draws\n * behind its series, or the series lines a stacked bar draws between them.\n *\n * One `<a:ln>` body served two elements that differed only in their wrapping tag and in how the\n * caller decides whether to emit at all, so the tag is the parameter and the two guards stay\n * with their own entry points.\n * @param tag - `c:majorGridlines` or `c:serLines`\n * @param opts - the caller's line options\n * @param option - option name as the caller spells it, for the dash diagnostic\n */\nfunction chartFurnitureLine(\n\ttag: 'c:majorGridlines' | 'c:serLines',\n\topts: OptsChartGridLine | undefined,\n\toption: string\n): string {\n\tif (gridLineSuppressed(opts)) return ''\n\tconst stroke = gridLineStroke(opts as OptsChartGridLine)\n\tconst line = el(\n\t\t'a:ln',\n\t\t{\n\t\t\t// `??`, because every entry point here is scrubbed: `scrubGridLine` rejects `width <= 0`\n\t\t\t// with a warning and deletes it, on `barSeriesLine` as well as on the three gridlines.\n\t\t\t// A zero therefore cannot arrive undiagnosed, and `||` would only be re-deciding a\n\t\t\t// question the define layer already answered out loud.\n\t\t\tw: ptsToEmuLenient(stroke.width ?? DEF_CHART_GRIDLINE.width ?? 1),\n\t\t\tcap: createLineCap(stroke.cap || DEF_CHART_GRIDLINE.cap),\n\t\t},\n\t\t[\n\t\t\traw(strokePaint(stroke, DEF_GRIDLINE_COLOR)),\n\t\t\traw(voidEl('a:prstDash', { val: strokeDash(stroke, option) }) + voidEl('a:round')),\n\t\t]\n\t)\n\treturn el(tag, null, raw(el('c:spPr', null, raw(line))))\n}\n\n/**\n * A plot's `<c:majorGridlines>`, or `''` when the caller asked for none.\n *\n * The \"asked for none\" test used to sit at each of the three axis builders as\n * `opts.catGridLine && opts.catGridLine.style !== 'none'`, which stopped being the whole test\n * once `type: 'none'` could say the same thing.\n * @param glOpts - the caller's gridline stroke, if any\n * @return {string} XML, or `''`\n */\nexport function createGridLineElement(glOpts: OptsChartGridLine | undefined): string {\n\treturn chartFurnitureLine('c:majorGridlines', glOpts, 'gridLine dashType')\n}\n\n/**\n * The children of a `<c:dLbls>` (or a `<c:dLbl>`), in the ONE order `CT_DLbls` allows.\n *\n * `EG_DLblShared` sequences `numFmt, spPr, txPr, dLblPos`, then the six flags, then\n * `showLeaderLines` and `leaderLines`, with any per-point `<c:dLbl>` ahead of all of it and\n * `<c:extLst>` last. Five builders across four modules restated that sequence by hand, which is\n * the same shape as the axis-units bug: a child in the wrong place is a repair prompt, not a\n * wrong-looking chart. `dLblShowFlags` already owned the six-flag run for this reason and the\n * sequence around it was left copied.\n *\n * Every part is optional and stated by the caller, so the drift between the five shows up as a\n * missing argument rather than as a silently different chart: only one of them honoured\n * `dataLabelBkgrdColors`, only one a per-series `dataLabelFormatCode`, and two hard-coded\n * `showLeaderLines` to on while four read the option.\n *\n * @param parts - the children this site emits, each already built\n * @param tag - `c:dLbls` for a group of labels, `c:dLbl` for one point's\n */\nexport function dLblsBlock(\n\tparts: {\n\t\t/** Per-point `<c:dLbl>` blocks, or a `<c:idx>` on a `c:dLbl`. Emitted first, in order. */\n\t\tlead?: string | undefined\n\t\tnumFmt?: string | undefined\n\t\tspPr?: string | undefined\n\t\ttxPr?: string | undefined\n\t\tdLblPos?: string | undefined\n\t\tflags: XmlChild[]\n\t\tshowLeaderLines?: string | undefined\n\t\tleaderLines?: string | undefined\n\t\textLst?: string | undefined\n\t},\n\ttag: 'c:dLbls' | 'c:dLbl' = 'c:dLbls'\n): string {\n\treturn el(tag, null, [\n\t\tparts.lead ? raw(parts.lead) : null,\n\t\tparts.numFmt ? raw(parts.numFmt) : null,\n\t\tparts.spPr ? raw(parts.spPr) : null,\n\t\tparts.txPr ? raw(parts.txPr) : null,\n\t\tparts.dLblPos ? raw(parts.dLblPos) : null,\n\t\t...parts.flags,\n\t\tparts.showLeaderLines ? raw(parts.showLeaderLines) : null,\n\t\tparts.leaderLines ? raw(parts.leaderLines) : null,\n\t\tparts.extLst ? raw(parts.extLst) : null,\n\t])\n}\n\n/**\n * The `<c:numFmt>` a data-label block carries: the caller's format code, or `General`.\n *\n * `(x ?? '') || 'General'` stood at five sites verbatim. The two coalescers are not\n * interchangeable and both are load-bearing: `??` keeps an explicit empty string from becoming\n * `undefined`, and `||` turns that empty string into the schema's own default.\n * @param formatCode - the caller's format code, if any\n */\nexport function dLblNumFmt(formatCode: string | undefined): string {\n\treturn voidEl('c:numFmt', { formatCode: (formatCode ?? '') || 'General', sourceLinked: 0 })\n}\n\n/**\n * The plot-level `<c:dLbls>` block: number format, run properties, and the six `show*` flags.\n *\n * Shared by the category-axis and scatter plots, which carried a 20-line copy each. The two\n * differed in exactly one thing that reaches the bytes -- whether `<c:showLeaderLines>` is\n * emitted -- so that is the parameter. (They also differed in `? 1 : 0` versus `? '1' : '0'`\n * for the bold/italic flags, which is the same byte either way.)\n *\n * `<c:showLeaderLines>` is last in CT_DLbls' group and optional, which is why omitting it is a\n * legal shape and not a schema gap: leader lines connect a moved label back to its point, and a\n * scatter plot has no `<c:dLblPos>` layout that moves one.\n *\n * @param opts - the chart's normalized options\n * @param leaderLines - emit the trailing `<c:showLeaderLines>` (category-axis plots only)\n */\nexport function chartDataLabels(opts: ChartOptsInternal, leaderLines: boolean): string {\n\treturn dLblsBlock({\n\t\tnumFmt: dLblNumFmt(opts.dataLabelFormatCode),\n\t\ttxPr: labelTextProps(dataLabelDefRPr(opts)),\n\t\tdLblPos: dLblPosEl(opts),\n\t\tflags: dLblShowFlags({ val: xsdBool(opts.showValue), serName: xsdBool(opts.showSerName) }),\n\t\tshowLeaderLines: leaderLines ? voidEl('c:showLeaderLines', { val: xsdBool(opts.showLeaderLines) }) : undefined,\n\t})\n}\n\n/**\n * An `<a:solidFill>` of the theme text colour dimmed towards the background — the grey the chart\n * furniture (stock hi-low lines and up/down bars, the data-table grid) is drawn in.\n * `lumMod`/`lumOff` are the two halves of one dimming: how much of the luminance survives, and\n * how much white is mixed back in.\n * @param lumMod - surviving luminance, in thousandths of a percent\n * @param lumOff - luminance added back, in thousandths of a percent\n */\nexport function dimmedTextFill(lumMod: number, lumOff: number): string {\n\treturn el(\n\t\t'a:solidFill',\n\t\tnull,\n\t\traw(\n\t\t\tel('a:schemeClr', { val: 'tx1' }, [\n\t\t\t\traw(voidEl('a:lumMod', { val: lumMod })),\n\t\t\t\traw(voidEl('a:lumOff', { val: lumOff })),\n\t\t\t])\n\t\t)\n\t)\n}\n\n/** The hairline outline drawn in {@link dimmedTextFill}, at the same three dimming levels. */\nexport function dimmedTextLine(lumMod: number, lumOff: number): string {\n\treturn el('a:ln', { w: 9525, cap: 'flat', cmpd: 'sng', algn: 'ctr' }, [\n\t\traw(dimmedTextFill(lumMod, lumOff)),\n\t\traw(voidEl('a:round')),\n\t])\n}\n\n/**\n * Build a `<c:pt>` numeric-cache data point, or '' to leave a gap.\n *\n * A `<c:v>` holding `NaN`, `INF` or `Infinity` makes PowerPoint refuse the package with\n * 0x80070570, the corrupt-file error, so a non-finite number is skipped with a warning per the\n * library's \"warn rather than emit a degenerate result\" policy. Null/undefined are intentional\n * gaps and are skipped silently (a sparse, idx-keyed cache is valid).\n *\n * **PowerPoint is the only oracle for this.** `<c:v>` is `s:ST_Xstring` in the schema, not\n * `xsd:double` — nothing above is a schema violation, and the OpenXmlValidator reports every one\n * of those three packages clean. An *empty* `<c:v>` is the case that shows why the distinction is\n * worth stating rather than reasoning about: it looks equally invalid and it is not, opening\n * cleanly and reading back as an empty point. See `pieValues` in\n * `src/gen/chart/plot-pie.ts`, which emitted both spellings until the measurement was made.\n * @param idx - zero-based data-point index (emitted as `idx`)\n * @param value - numeric value (or null/undefined gap)\n */\nexport function numCachePt(idx: number, value: number | null | undefined): string {\n\tif (value == null) return ''\n\tif (!Number.isFinite(value)) {\n\t\twarn('chart/non-finite-value', `chart value \"${value}\" at index ${idx} is not a finite number; data point omitted.`)\n\t\treturn ''\n\t}\n\treturn el('c:pt', { idx }, raw(el('c:v', null, value)))\n}\n\n/**\n * Build the error-bar elements (`<c:errBars>`) for a single series.\n *\n * Schema position (CT_*Ser): after `dLbls`/`trendline`, before `cat`/`val` (bar/line/area)\n * or `xVal`/`yVal` (scatter). CT_ErrBars child order is errDir → errBarType → errValType →\n * noEndCap → plus → minus → val → spPr.\n *\n * The bars arrive vetted (`normalizeErrorBars` in `gen/define/chart.ts`): an enumeration the schema\n * does not have is already gone, so the defaults below fill only what the caller left out.\n *\n * @param chartType - chart this series belongs to (used to bound how many bars are legal)\n * @param errorBars - the series' bars, X+Y for scatter/area; bar/line keep only the first\n * @param obj - the series data object (only `name`, for warnings)\n */\nexport function makeChartErrorBarsXml(\n\tchartType: ChartType,\n\terrorBars: ChartErrorBarInternal[] | undefined,\n\tobj: OptsChartDataInternal\n): string {\n\tif (!errorBars) return ''\n\t// CT_BarSer/CT_LineSer allow a single <c:errBars>; only scatter/area permit two (x + y).\n\tconst maxBars = chartType === ChartType.scatter || chartType === ChartType.area ? 2 : 1\n\tlet strXml = ''\n\n\terrorBars.slice(0, maxBars).forEach((eb) => {\n\t\tconst valueType = eb.valueType ?? 'fixedVal'\n\t\tconst barType = eb.barType ?? 'both'\n\t\tconst direction = eb.direction ?? 'y'\n\n\t\tlet children =\n\t\t\tvoidEl('c:errDir', { val: direction }) +\n\t\t\tvoidEl('c:errBarType', { val: barType }) +\n\t\t\tvoidEl('c:errValType', { val: valueType }) +\n\t\t\tvoidEl('c:noEndCap', { val: xsdBool(eb.noEndCap) })\n\n\t\tif (valueType === 'cust') {\n\t\t\t// Custom amounts: <c:plus>/<c:minus> each hold a number source (we emit <c:numLit>).\n\t\t\t// `barType` decides which sides are present; warn (don't silently drop) on a missing side.\n\t\t\tif (barType !== 'minus') {\n\t\t\t\tif (!eb.plusValues?.length)\n\t\t\t\t\twarn(\n\t\t\t\t\t\t'chart/error-bars-missing-values',\n\t\t\t\t\t\t`chart series \"${obj.name}\" errorBars valueType 'cust' needs \\`plusValues\\` for barType '${barType}'.`\n\t\t\t\t\t)\n\t\t\t\tchildren += makeErrBarNumLit('plus', eb.plusValues || [])\n\t\t\t}\n\t\t\tif (barType !== 'plus') {\n\t\t\t\tif (!eb.minusValues?.length)\n\t\t\t\t\twarn(\n\t\t\t\t\t\t'chart/error-bars-missing-values',\n\t\t\t\t\t\t`chart series \"${obj.name}\" errorBars valueType 'cust' needs \\`minusValues\\` for barType '${barType}'.`\n\t\t\t\t\t)\n\t\t\t\tchildren += makeErrBarNumLit('minus', eb.minusValues || [])\n\t\t\t}\n\t\t} else if (valueType !== 'stdErr') {\n\t\t\t// fixedVal / percentage / stdDev use a single magnitude (stdErr derives it from the data).\n\t\t\tchildren += voidEl('c:val', { val: eb.value ?? 1 })\n\t\t}\n\n\t\t// The error bar is a stroke like any other, so it takes the same keys: `width` (with\n\t\t// `size` still accepted), plus the `dashType`, `cap` and `transparency` the old\n\t\t// two-key shape could not say. A bar that states none of them keeps emitting no\n\t\t// `<c:spPr>` at all, which is what leaves PowerPoint's own error-bar style in charge.\n\t\t// A bar that names a colour or a transparency paints one; `type: 'none'` paints an\n\t\t// explicit `<a:noFill/>`; a bar that names only a width or a dash leaves the paint to\n\t\t// PowerPoint's own error-bar style, which is what \"no `<a:solidFill>`\" has always meant\n\t\t// here. `type: 'dash'` must NOT conjure a colour out of the default.\n\t\tconst paint =\n\t\t\teb.type === 'none'\n\t\t\t\t? voidEl('a:noFill')\n\t\t\t\t: eb.color !== undefined || eb.transparency !== undefined\n\t\t\t\t\t? strokePaint(eb, DEF_GRIDLINE_COLOR)\n\t\t\t\t\t: ''\n\t\tconst dash =\n\t\t\teb.dashType !== undefined || eb.type === 'dash'\n\t\t\t\t? voidEl('a:prstDash', { val: strokeDash(eb, 'errorBars dashType') })\n\t\t\t\t: ''\n\t\tif (paint || dash || eb.widthEmu !== undefined || eb.cap !== undefined) {\n\t\t\tchildren += el(\n\t\t\t\t'c:spPr',\n\t\t\t\tnull,\n\t\t\t\traw(\n\t\t\t\t\tel(\n\t\t\t\t\t\t'a:ln',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tw: eb.widthEmu,\n\t\t\t\t\t\t\tcap: eb.cap !== undefined ? createLineCap(eb.cap) : undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\traw(paint + dash)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\n\t\tstrXml += el('c:errBars', null, raw(children))\n\t})\n\n\treturn strXml\n}\n\n/**\n * Build a `<c:plus>`/`<c:minus>` number-literal source for custom error-bar amounts.\n * @param tag - `'plus'` or `'minus'`\n * @param values - per-point magnitudes (index-aligned with the series values)\n */\nfunction makeErrBarNumLit(tag: 'plus' | 'minus', values: number[]): string {\n\tconst numLit = el('c:numLit', null, [\n\t\traw(el('c:formatCode', null, 'General')),\n\t\traw(voidEl('c:ptCount', { val: values.length })),\n\t\traw(values.map((value, idx) => numCachePt(idx, value)).join('')),\n\t])\n\treturn el(`c:${tag}`, null, raw(numLit))\n}\n\n/**\n * Build a `<c:serLines>` (\"Series Lines\") element for a bar chart.\n * @param opt - `true` for PowerPoint automatic styling, an {@link OptsChartGridLine}\n * to customize the line, or falsy / `{ style: 'none' }` to omit the element.\n */\nexport function createSerLinesElement(opt?: boolean | OptsChartGridLine): string {\n\tif (!opt) return ''\n\tif (opt === true) return voidEl('c:serLines')\n\treturn chartFurnitureLine('c:serLines', opt, 'serLine dashType')\n}\n\n/**\n * Build the `<c:leaderLines>` element for pie/doughnut data labels.\n *\n * Schema position: inside `<c:dLbls>`, immediately after `<c:showLeaderLines>`\n * (CT_DLbls / Group_DLbls order: showLeaderLines → leaderLines).\n *\n * Returns `''` unless the caller both enabled leader lines (`showLeaderLines`)\n * and configured their appearance (`leaderLineColor` / `leaderLineSize`). When\n * appearance is unset we leave the element off so PowerPoint applies its\n * automatic leader-line color, matching prior behavior.\n *\n * @param opts - chart options (reads `showLeaderLines`, `leaderLineColor`, `leaderLineSize`)\n */\nexport function createLeaderLinesElement(opts: ChartOptsInternal): string {\n\tif (!opts.showLeaderLines) return ''\n\tif (!opts.leaderLineColor && opts.leaderLineSize == null) return ''\n\tconst w = ptsToEmuLenient(opts.leaderLineSize ?? 0.75)\n\tconst color = namedColorOr(opts.leaderLineColor, '808080', 'leaderLineColor')\n\tconst line = el('a:ln', { w, cap: 'flat' }, [\n\t\traw(genXmlColorSelection(color)),\n\t\traw(voidEl('a:prstDash', { val: 'solid' })),\n\t\traw(voidEl('a:round')),\n\t])\n\treturn el('c:leaderLines', null, raw(el('c:spPr', null, [raw(line), raw(voidEl('a:effectLst'))])))\n}\n\n/**\n * Build a single custom `<c:dLbl>` (rich-text data label) overriding one data point's label.\n *\n * Used when a series supplies explicit per-point label text: the emitted `<c:idx>` pins the\n * override to that point, and the `<c:rich>` run carries the label's own font styling (size,\n * bold, italic, color, face) resolved from the chart-level dataLabel* options. All the\n * `show*` flags are forced off so only the literal `text` renders (no value/category/percent).\n * @param idx - zero-based data-point index this label overrides\n * @param text - the literal label text (XML-escaped here)\n * @param opts - chart options supplying dataLabel font/color defaults and `lang`\n * @return {string} a `<c:dLbl>` element\n */\nexport function makeCustomDLblXml(idx: number, text: string, opts: ChartOptsInternal): string {\n\tconst paragraph = el('a:p', null, [raw(el('a:pPr', null, raw(labelDefRPr(opts)))), raw(labelRun(opts, text))])\n\tconst rich = el('c:rich', null, [raw(voidEl('a:bodyPr')), raw(voidEl('a:lstStyle')), raw(paragraph)])\n\treturn el('c:dLbl', null, [\n\t\traw(voidEl('c:idx', { val: idx })),\n\t\traw(el('c:tx', null, raw(rich))),\n\t\t...dLblShowFlags({}),\n\t])\n}\n\n/**\n * The `<a:ln>` a chart-level `dataBorder` paints around every data point — the bubble, the\n * pie slice, the bar.\n *\n * A near-sibling of {@link createChartBorderLine} rather than the same thing, and the three\n * remaining differences are all deliberate: a data-point outline defaults to 0.75pt against a\n * chart border's 1pt, to `363636` against `666666`, and is always solid because `dataBorder`\n * has no dash spelling of its own. It also has no `type: 'none'` arm, because the caller\n * decides whether to emit it at all. Three plot builders carried a byte-identical copy of it.\n *\n * `cap` is the one thing that genuinely varies: the bubble and pie paths pin `flat`, the\n * category-axis path resolves the chart's own `lineCap`.\n * @param dataBorder - the chart's `dataBorder`\n * @param cap - the `cap` attribute value, already resolved\n */\nexport function createDataBorderLine(dataBorder: BorderProps, cap: string): string {\n\treturn borderLine('a:ln', dataBorder, {\n\t\tdefaultWidth: 0.75,\n\t\tdefaultColor: '363636',\n\t\tcap,\n\t\tdash: 'solid',\n\t\ttail: [voidEl('a:round')],\n\t})\n}\n\n/**\n * The `<a:ln>` a chart-area or plot-area `border` paints, or an explicit `<a:noFill>` when the\n * caller asked for none. See {@link createDataBorderLine} for why the two are separate.\n *\n * `type: 'dash'` here means the `dash` preset, not the `sysDash` a table border's `type`\n * resolves to — a chart border has no `dashType` of its own to name a preset with, so the\n * three-way switch is the whole vocabulary and it picks the plain one.\n * @param border - the chart's `border` (`type`, `color`, `width`, `transparency`)\n */\nexport function createChartBorderLine(border: BorderProps): string {\n\tif (border.type === 'none') return noStrokeLine()\n\treturn borderLine('a:ln', border, {\n\t\tdefaultWidth: 1,\n\t\tdefaultColor: '666666',\n\t\tcap: 'flat',\n\t\tdash: border.type === 'dash' ? 'dash' : 'solid',\n\t\ttail: [voidEl('a:round')],\n\t})\n}\n\n/**\n * Build `<c:dPt>` entries for a series in the bar/line/area/scatter loops.\n *\n * Merges two sources into a single `c:dPt` per index so we never emit a\n * duplicate `<c:idx>` (which corrupts the chart):\n * - legacy single-series color-vary fills (bar/scatter), supplied via `varyColors`\n * - per-point `pointStyles` border/fill overrides\n *\n * Must be emitted in schema position *before* `c:dLbls` (CT_*Ser order).\n * RADAR is skipped: extra per-point markup historically corrupts the chart.\n *\n * @param chartType - series chart type\n * @param obj - series data (reads `values`, `pointStyles`)\n * @param opts - chart options (fill/shadow/lineSize context)\n * @param varyColors - color array when single-series color-vary applies, else `null`\n */\nexport function makeSeriesDataPointsXml(\n\tchartType: ChartType,\n\tobj: OptsChartDataInternal,\n\topts: ChartOptsInternal,\n\tvaryColors: string[] | null\n): string {\n\tif (chartType === ChartType.radar) return ''\n\tconst pointStyles = obj.pointStyles\n\tif (!varyColors && !pointStyles?.length) return ''\n\n\tconst isBar = chartType === ChartType.bar || chartType === ChartType.bar3d\n\tconst isScatter = chartType === ChartType.scatter\n\tlet xml = ''\n\tdataValues(obj).forEach((value, index) => {\n\t\tconst ptStyle = pointStyles?.[index]\n\t\tconst arrColors = varyColors\n\t\t\t? value < 0\n\t\t\t\t? opts.invertedColors || opts.chartColors || BARCHART_COLORS\n\t\t\t\t: varyColors\n\t\t\t: null\n\t\tconst fillColor = ptStyle?.fill || (arrColors ? paletteColor(arrColors, index) : null)\n\t\tconst pattern = ptStyle?.pattern\n\t\tconst border = ptStyle?.border\n\t\t// Nothing to style for this point -> omit the c:dPt entirely\n\t\tif (!fillColor && !pattern && !border) return\n\n\t\tlet shape = ''\n\t\tif ((isBar || isScatter) && opts.lineSize === 0 && !border && !ptStyle?.fill && !pattern) {\n\t\t\t// Preserve legacy color-vary behavior: hide outline when lineSize===0\n\t\t\tshape = noStrokeLine()\n\t\t} else {\n\t\t\t// Pattern fill takes precedence over a solid fill (OOXML allows only one fill per c:dPt).\n\t\t\t// Default the pattern foreground to this point's resolved color so it reads as a hatched bar.\n\t\t\tif (pattern) {\n\t\t\t\tshape = genXmlPatternFill(fillColor && !pattern.fgColor ? { ...pattern, fgColor: fillColor } : pattern)\n\t\t\t} else if (fillColor) {\n\t\t\t\t// BAR3D color-vary historically tints the edge line, not the face fill\n\t\t\t\tshape =\n\t\t\t\t\tchartType === ChartType.bar3d\n\t\t\t\t\t\t? el('a:ln', null, raw(genXmlColorSelection(fillColor)))\n\t\t\t\t\t\t: genXmlColorSelection(fillColor)\n\t\t\t}\n\t\t\tif (border) shape += createChartBorderLine(border)\n\t\t}\n\t\txml += el('c:dPt', null, [\n\t\t\traw(voidEl('c:idx', { val: index })),\n\t\t\tisBar ? raw(voidEl('c:invertIfNegative', { val: 0 })) : null,\n\t\t\traw(voidEl('c:bubble3D', { val: 0 })),\n\t\t\traw(el('c:spPr', null, [raw(shape), raw(createShadowEffectLst(opts.shadow, DEF_SHAPE_SHADOW))])),\n\t\t])\n\t})\n\treturn xml\n}\n\n/**\n * A `<c:tx>` series-name block: the `<c:f>` formula plus the one-point `<c:strCache>` mirroring\n * the header cell it points at. The string counterpart of {@link numRefBlock}.\n *\n * The five copies this replaces were all hand-built strings, so routing them here takes\n * fifty-odd hand-written delimiters out of `src/gen/chart/` rather than moving them into one\n * file.\n * @param ref - the `<c:f>` formula, from {@link sheetCellRef} or written inline\n * @param name - the series name to cache; escaped on the way into `<c:v>`\n */\nexport function strRefBlock(ref: string, name: string): string {\n\tconst pt = el('c:pt', { idx: 0 }, raw(el('c:v', null, name)))\n\tconst strCache = el('c:strCache', null, [raw(voidEl('c:ptCount', { val: 1 })), raw(pt)])\n\tconst strRef = el('c:strRef', null, [raw(el('c:f', null, ref)), raw(strCache)])\n\treturn el('c:tx', null, raw(strRef))\n}\n\n/**\n * A series' `<c:tx>`: its header cell in the embedded workbook, and the header text cached beside it,\n * which {@link seriesHeader} decides for both sides.\n * @param obj - the series\n * @param sheet - the chart's worksheet layout\n */\nexport function seriesNameRef(obj: OptsChartDataInternal, sheet: WorksheetLayout): string {\n\treturn strRefBlock(sheetCellRef(sheet.valueColumn(obj._dataIndex), 1), seriesHeader(obj))\n}\n\n/**\n * A category series' `<c:cat>` and `<c:val>`: the category reference over the leaf label column, and\n * the value cache over the series' own column, one point per sheet row.\n *\n * The category-axis, stock and surface plots each built these. Surface ignored `catLabelFormatCode`\n * where the other two honoured it, and all three pointed a single-column reference at column A, which\n * on a sheet with nested labels holds the outermost level rather than the leaf level the cache holds.\n *\n * A series with no labels of its own states no categories: `<c:cat>` is optional in `CT_Ser`.\n * @param obj - the series\n * @param opts - the chart's options, for `catLabelFormatCode`\n * @param valFmtCode - the value cache's format code\n * @param sheet - the chart's worksheet layout\n * @param shape - `multiLevel` caches every label level as a `<c:multiLvlStrRef>`. Only the\n * category-axis plots take it; a stock or surface chart caches the leaf level.\n */\nexport function catValRefs(\n\tobj: OptsChartDataInternal,\n\topts: ChartOptsInternal,\n\tvalFmtCode: string,\n\tsheet: WorksheetLayout,\n\tshape: { multiLevel: boolean }\n): string {\n\tconst valCol = sheet.valueColumn(obj._dataIndex)\n\tconst val = numRefBlock(\n\t\t'c:val',\n\t\tsheetRangeRef(valCol, 2, valCol, sheet.rowCount + 1),\n\t\tvalFmtCode,\n\t\tdataValues(obj),\n\t\tsheet.rowCount\n\t)\n\tconst groups = dataLabels(obj)\n\tconst cats = firstLabelGroup(obj)\n\tif (cats.length === 0) return val\n\tlet cat: string\n\tif (opts.catLabelFormatCode) {\n\t\t// A `catLabelFormatCode` means numbers (dates), which take a `numRef` carrying that format so\n\t\t// PowerPoint renders them as dates rather than serial numbers.\n\t\tcat = catRefBlock('num', categoryRange(sheet, cats.length), cats, opts.catLabelFormatCode)\n\t} else if (groups.length === 1 || !shape.multiLevel) {\n\t\tcat = catRefBlock('str', categoryRange(sheet, cats.length), cats)\n\t} else {\n\t\tconst lvls = groups\n\t\t\t.map((labelsGroup) =>\n\t\t\t\tel(\n\t\t\t\t\t'c:lvl',\n\t\t\t\t\tnull,\n\t\t\t\t\traw(labelsGroup.map((label, idx) => el('c:pt', { idx }, raw(el('c:v', null, label)))).join(''))\n\t\t\t\t)\n\t\t\t)\n\t\t\t.join('')\n\t\tconst cache = el('c:multiLvlStrCache', null, [raw(voidEl('c:ptCount', { val: cats.length })), raw(lvls)])\n\t\tcat = el('c:multiLvlStrRef', null, [\n\t\t\traw(el('c:f', null, sheetRangeRef(1, 2, groups.length, cats.length + 1))),\n\t\t\traw(cache),\n\t\t])\n\t}\n\treturn el('c:cat', null, raw(cat)) + val\n}\n\n/** What {@link xySeriesRefs} resolves for one scatter or bubble series. */\nexport interface XySeriesRefs {\n\t/** The series' `<c:idx>`: its position across the chart less one, for the X row. */\n\tidx: number\n\t/** Its `seriesOptions` entry. */\n\tover: ChartSeriesOpts | undefined\n\t/** Its resolved colour. */\n\tcolor: string\n\txVal: string\n\tyVal: string\n\t/** How many points each cache holds: the sheet's rows. */\n\trows: number\n}\n\n/**\n * What a scatter and a bubble series share: its index, its `seriesOptions` entry, its colour, and its\n * X and Y caches cut to the sheet's rows.\n *\n * Both plot builders spelled this out near verbatim, and both cached against the X row's own length.\n * That is the sheet's row count on a chart of their own, but not in a combo, whose sheet has one row\n * per category: a scatter subchart with five X values in a three-category combo cached\n * `Sheet1!$C$2:$C$6` over a workbook four rows deep. `addChartDefinition` warns about the values past\n * the rows.\n *\n * The index is {@link seriesIdx}: one below the series' row, for the X row that precedes it.\n * @param chartType - the plot, scatter or either bubble\n * @param obj - the Y series\n * @param data - the plot's series, X row first\n * @param opts - the chart's options, for the palette and `seriesOptions`\n * @param sheet - the chart's worksheet layout\n * @param valFmtCode - the caches' format code\n */\nexport function xySeriesRefs(\n\tchartType: ChartType,\n\tobj: OptsChartDataInternal,\n\tdata: readonly OptsChartDataInternal[],\n\topts: ChartOptsInternal,\n\tsheet: WorksheetLayout,\n\tvalFmtCode: string\n): XySeriesRefs {\n\tconst rows = sheet.rowCount\n\tconst idx = seriesIdx(obj, chartType)\n\tconst over = opts.seriesOptions?.[idx]\n\tconst xCol = sheet.valueColumn(data[0]?._dataIndex ?? 0)\n\tconst yCol = sheet.valueColumn(obj._dataIndex)\n\tconst yValues = dataValues(obj)\n\treturn {\n\t\tidx,\n\t\tover,\n\t\tcolor: namedColorOr(over?.color, paletteColor(resolveChartPalette(opts), idx), 'seriesOptions color'),\n\t\txVal: numRefBlock('c:xVal', sheetRangeRef(xCol, 2, xCol, rows + 1), valFmtCode, dataValues(data[0]), rows),\n\t\t// A Y series shorter than the rows leaves gaps rather than a short cache.\n\t\tyVal: numRefBlock(\n\t\t\t'c:yVal',\n\t\t\tsheetRangeRef(yCol, 2, yCol, rows + 1),\n\t\t\tvalFmtCode,\n\t\t\tArray.from({ length: rows }, (_unused, i) => yValues[i]),\n\t\t\trows\n\t\t),\n\t\trows,\n\t}\n}\n\n/**\n * A `<c:cat>` category reference: the `<c:f>` formula plus the `<c:numCache>`/`<c:strCache>` that\n * mirrors the label cells it points at.\n *\n * `kind` picks the cache: `'num'` for numeric categories — dates, which need a `<c:formatCode>` so\n * PowerPoint renders them as dates rather than serial numbers — and `'str'` for text ones. Stock\n * and cat-axis each carried both arms of that choice, and surface carried the string one, five\n * copies of the same `<c:f>` + `<c:ptCount>` + `<c:pt idx>` loop.\n *\n * The `<c:multiLvlStrRef>` arm of a cat-axis is deliberately not folded in: multi-level\n * categories nest a `<c:lvl>` per label group, which is a different shape rather than a\n * different spelling.\n * @param kind - `num` for a numeric (date) category cache, `str` for a text one\n * @param ref - the `<c:f>` formula\n * @param labels - the category labels, in order; escaped on the way into `<c:v>`\n * @param formatCode - the cached `<c:formatCode>`; numeric caches only\n */\nexport function catRefBlock(kind: 'num' | 'str', ref: string, labels: string[], formatCode?: string): string {\n\tconst points = labels.map((label, idx) => el('c:pt', { idx }, raw(el('c:v', null, label)))).join('')\n\tconst cache = el(`c:${kind}Cache`, null, [\n\t\tformatCode === undefined ? null : raw(el('c:formatCode', null, formatCode)),\n\t\traw(voidEl('c:ptCount', { val: labels.length }) + points),\n\t])\n\treturn el(`c:${kind}Ref`, null, [raw(el('c:f', null, ref)), raw(cache)])\n}\n\n/**\n * A numeric-reference block: the `<c:f>` formula plus the `<c:numCache>` that mirrors the cells\n * it points at.\n *\n * Scatter and bubble each carried their own copy of this twice over, four near-identical\n * twelve-line blocks, and bubble's per-point sizes were a fifth — the same block under a third\n * wrapping tag with a constant format code. `values` is the exact point list to cache, so the\n * caller decides what a gap is: the Y series is emitted against the X series' length (a caller\n * may supply fewer Y values than X — a timeline with only the first few months filled in), and\n * the shorter array's tail arrives here as `undefined`, which {@link numCachePt} skips.\n *\n * `ptCount` is the length of the cached *range* — the number of cells `ref` spans — which is not\n * always `values.length`. A category chart caches one column against the chart's category count\n * and may hold fewer values than that, so it states the count explicitly; scatter and bubble pad\n * their arrays to the range instead and let the default stand. Both spellings mean the same\n * thing, and having only one of them derived by accident is how they drifted apart.\n *\n * Values past `ptCount` are not cached. The range has no cells for them and the workbook does not\n * write them, so a category series with more values than categories used to cache\n * `<c:pt idx=\"2\">` after `<c:ptCount val=\"2\"/>`, which the reader then reported as a mismatch in\n * the library's own output. `addChartDefinition` warns about the dropped values.\n *\n * @param tag - the wrapping element: `c:val`, `c:xVal`, `c:yVal` or `c:bubbleSize`\n * @param ref - the `<c:f>` formula, from {@link sheetRangeRef} or written inline\n * @param formatCode - the cached `<c:formatCode>`\n * @param values - the points to cache, in order; `null`/`undefined` entries are gaps\n * @param ptCount - cells spanned by `ref`; defaults to `values.length`\n */\nexport function numRefBlock(\n\ttag: 'c:val' | 'c:xVal' | 'c:yVal' | 'c:bubbleSize',\n\tref: string,\n\tformatCode: string,\n\tvalues: Array<number | null | undefined>,\n\tptCount: number = values.length\n): string {\n\tconst numCache = el('c:numCache', null, [\n\t\traw(el('c:formatCode', null, formatCode)),\n\t\traw(voidEl('c:ptCount', { val: ptCount })),\n\t\traw(\n\t\t\tvalues\n\t\t\t\t.slice(0, ptCount)\n\t\t\t\t.map((value, idx) => numCachePt(idx, value))\n\t\t\t\t.join('')\n\t\t),\n\t])\n\tconst numRef = el('c:numRef', null, [raw(el('c:f', null, ref)), raw(numCache)])\n\treturn el(tag, null, raw(numRef))\n}\n","/**\n * ts-pptx: Chart Axis Assembly\n *\n * Builds the `<c:catAx>` / `<c:valAx>` / `<c:serAx>` elements. The three share a\n * structure -- scaling, delete flag, tick marks, label position, text properties,\n * gridlines, optional axis title -- but PowerPoint requires the child elements in a\n * fixed order that differs per axis, so they stay as three separate builders rather\n * than one parameterized one. Called by {@link ./chart-xml}'s axis region.\n *\n * Sub-blocks are shared where they can be shared *exactly*: {@link axisLineSpPr} covers\n * `<c:spPr>` and {@link axisTextProps} the whole `<c:txPr>`. Both used to take indentation\n * arguments, which is what had kept them copied rather than shared; the emitters are flat now,\n * so they take only what they are about.\n */\n\nimport { asChartType, ChartType } from '../../enums.js'\nimport {\n\tAXIS_ID_CATEGORY_PRIMARY,\n\tAXIS_ID_CATEGORY_SECONDARY,\n\tAXIS_ID_VALUE_PRIMARY,\n\tAXIS_ID_VALUE_SECONDARY,\n\tDEF_FONT_COLOR,\n\tDEF_FONT_SIZE,\n} from '../../constants-internal.js'\nimport type { StrokeProps } from '../../types/index.js'\nimport type { ChartOptsInternal } from '../../types/internal.js'\nimport { warn } from '../../diagnostics.js'\nimport { clampFontSizeSz } from '../drawingml/clamp.js'\nimport { createLineCap, strokeDash, strokePaint } from '../drawingml/line.js'\nimport { axisLineStroke } from './chart-stroke.js'\nimport { namedColorOr } from '../drawingml/color.js'\nimport { genXmlColorSelection } from '../drawingml/fill.js'\nimport { convertAngleUnits, mapStated, ptsToEmuLenient } from '../../units-internal.js'\nimport { EMU_PER_POINT } from '../../units.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport {\n\taxisCrossing,\n\tchartLang,\n\tcreateChartTextFonts,\n\tcreateGridLineElement,\n\tDEF_GRIDLINE_COLOR,\n\tgenXmlTitle,\n\tpositiveIntAttr,\n\tvalidTimeUnit,\n} from './chart-parts.js'\nimport { isScatterChart, isXyChart } from './chart-kind.js'\nimport { xsdBool } from '../../ooxml/xsd-boolean.js'\n\n/**\n * The `<c:spPr>` axis-line block, identical on all three axes.\n *\n * The three axes each took four flat options here (`*AxisLineSize`, `*AxisLineShow`,\n * `*AxisLineColor`, `*AxisLineStyle`) and passed them positionally, which is how the series\n * axis came to hardcode a width and a dash the other two read from the caller. They now take\n * one {@link StrokeProps}, folded from whichever spelling the caller used, and the cap and\n * transparency the flat keys could not express come along with it.\n * @param stroke - the axis line's resolved stroke\n * @return {string} XML `<c:spPr>`\n */\nfunction axisLineSpPr(stroke: StrokeProps): string {\n\tconst line = el(\n\t\t'a:ln',\n\t\t{ w: stroke.width ? ptsToEmuLenient(stroke.width) : EMU_PER_POINT, cap: createLineCap(stroke.cap) },\n\t\t[\n\t\t\traw(strokePaint(stroke, DEF_GRIDLINE_COLOR)),\n\t\t\traw(voidEl('a:prstDash', { val: strokeDash(stroke, 'axis line dashType') })),\n\t\t\traw(voidEl('a:round', null)),\n\t\t]\n\t)\n\treturn el('c:spPr', null, raw(line))\n}\n\n/**\n * The `<c:txPr>` an axis wraps its label run properties in: `<a:bodyPr>`, an empty\n * `<a:lstStyle>`, then the `<a:pPr>` carrying `defRPr` and an empty `<a:endParaRPr>`. All three\n * axis builders emit exactly this; only the rotation differs, and the series axis has none.\n *\n * @param defRPr - the already-built `<a:defRPr>`\n * @param lang - the deck's language tag, for `endParaRPr`\n * @param rot - `a:bodyPr@rot`, already in 60000ths of a degree. `undefined` omits the\n * attribute, which is what gets the auto behaviour -- do not pass `0` for it.\n */\nfunction axisTextProps(defRPr: string, lang: string, rot?: number): string {\n\treturn el('c:txPr', null, [\n\t\traw(voidEl('a:bodyPr', { rot })),\n\t\traw(voidEl('a:lstStyle', null)),\n\t\traw(el('a:p', null, [raw(el('a:pPr', null, raw(defRPr))), raw(voidEl('a:endParaRPr', { lang }))])),\n\t])\n}\n\n/** One axis' label font, as the three axis builders each spelled it. */\ninterface AxisLabelFont {\n\t/** Option name as the caller spells it (`catAxisLabelFontSize` and its two siblings). */\n\toption: string\n\tsize: number | undefined\n\tbold: boolean | undefined\n\titalic: boolean | undefined\n\tcolor: string | undefined\n\tfontFace: string | undefined\n}\n\n/**\n * The `<a:defRPr>` an axis' tick labels carry, in the `sz, b, i, u, strike` order all three\n * axes emit.\n *\n * Three copies differed only in the `catAxis…`/`valAxis…`/`serAxis…` option prefix. The header\n * of this module explains that the rest of the axis blocks stayed copied because the emitters\n * took indentation arguments; the flatten removed that reason and left these behind.\n */\nfunction axisLabelDefRPr(font: AxisLabelFont): string {\n\treturn el(\n\t\t'a:defRPr',\n\t\t{\n\t\t\tsz: clampFontSizeSz(font.size ?? DEF_FONT_SIZE, font.option),\n\t\t\tb: xsdBool(font.bold),\n\t\t\ti: xsdBool(font.italic),\n\t\t\tu: 'none',\n\t\t\tstrike: 'noStrike',\n\t\t},\n\t\t[\n\t\t\traw(genXmlColorSelection(namedColorOr(font.color, DEF_FONT_COLOR, 'axis label color'))),\n\t\t\traw(createChartTextFonts(font.fontFace ?? 'Arial')),\n\t\t]\n\t)\n}\n\n/** One axis' `<c:title>` as the three builders each spelled it, down to the shared default. */\ninterface AxisTitle {\n\ttext: string | undefined\n\tcolor: string | undefined\n\tfontFace: string | undefined\n\tfontSize: number | undefined\n\trotate: number | undefined\n}\n\n/** The axis `<c:title>`, or `''` when the caller asked for none. */\nfunction axisTitleXml(show: boolean | undefined, title: AxisTitle): string {\n\tif (!show) return ''\n\treturn genXmlTitle({\n\t\tcolor: title.color,\n\t\tfontFace: title.fontFace,\n\t\tfontSize: title.fontSize,\n\t\ttitleRotate: title.rotate,\n\t\ttitle: title.text || 'Axis Title',\n\t})\n}\n\n/**\n * Report an axis option the chosen axis tag has no slot for, and emit nothing.\n *\n * The category builder emits one of three tags and the three have three content models, so a\n * unit option is not \"an option the axis ignores\" but one the schema has no place for --\n * writing it anyway is what made `<c:catAx>` and `<c:serAx>` reject on open. Silence would be\n * the footgun; the option is named back to the caller instead.\n * @param tag - the axis element actually being emitted\n * @param optionName - option name as the caller spells it\n * @param value - the caller's value; nothing is reported when they named none\n */\nfunction warnNoSlot(tag: string, optionName: string, value: number | string | undefined): void {\n\tif (value === undefined || value === null || value === '') return\n\twarn('chart/option-not-on-axis', `\"${optionName}\" has no place on <${tag}>; ignoring it.`)\n}\n\nexport function makeCatAxis(opts: ChartOptsInternal, axisId: string, valAxisId: string): string {\n\tconst usesValueAxisForCategories = isXyChart(opts._type)\n\tconst usesCategoryAxis = !usesValueAxisForCategories && !opts.catLabelFormatCode\n\t// NOTE: scatter and bubble charts display numbers on the X axis, so their category axis is a\n\t// second value axis; a `catLabelFormatCode` means dates, which is a `<c:dateAx>`.\n\tconst tag = usesValueAxisForCategories ? 'c:valAx' : opts.catLabelFormatCode ? 'c:dateAx' : 'c:catAx'\n\n\tconst scaling = el('c:scaling', null, [\n\t\traw(voidEl('c:orientation', { val: opts.catAxisOrientation || 'minMax' })),\n\t\t// The define layer refuses a bound that is not a finite number, so a present one is meant.\n\t\topts.catAxisMaxVal != null ? raw(voidEl('c:max', { val: opts.catAxisMaxVal })) : null,\n\t\topts.catAxisMinVal != null ? raw(voidEl('c:min', { val: opts.catAxisMinVal })) : null,\n\t])\n\n\t// Scatter/bubble read the X format off the category option, falling back to the value one, and a\n\t// stated format is written unlinked. A source-linked axis paints its labels in the X cache's format,\n\t// which is the value format: `catAxisLabelFormatCode: '0.00'` over a `0%` cache drew 0% 20% 40% in\n\t// PowerPoint, and the same bytes with `sourceLinked=\"0\"` drew 0.00 0.20 0.40\n\t// (`test/read/fixtures/authoring/probe-scatter-x-cache-format.mjs`).\n\tconst xFormat = usesValueAxisForCategories\n\t\t? (opts.catAxisLabelFormatCode ?? opts.valAxisLabelFormatCode) || null\n\t\t: null\n\tconst numFmt = usesValueAxisForCategories\n\t\t? voidEl('c:numFmt', { formatCode: xFormat ?? 'General', sourceLinked: xFormat ? 0 : 1 })\n\t\t: voidEl('c:numFmt', { formatCode: (opts.catLabelFormatCode ?? '') || 'General', sourceLinked: 1 })\n\n\tconst ticks = isScatterChart(opts._type)\n\t\t? voidEl('c:majorTickMark', { val: 'none' }) +\n\t\t\tvoidEl('c:minorTickMark', { val: 'none' }) +\n\t\t\tvoidEl('c:tickLblPos', { val: opts.catAxisLabelPos || 'nextTo' })\n\t\t: voidEl('c:majorTickMark', { val: opts.catAxisMajorTickMark || 'out' }) +\n\t\t\tvoidEl('c:minorTickMark', { val: opts.catAxisMinorTickMark || 'none' }) +\n\t\t\tvoidEl('c:tickLblPos', { val: opts.catAxisLabelPos || (opts.barDir === 'col' ? 'low' : 'nextTo') })\n\n\tconst defRPr = axisLabelDefRPr({\n\t\toption: 'catAxisLabelFontSize',\n\t\tsize: opts.catAxisLabelFontSize,\n\t\tbold: opts.catAxisLabelFontBold,\n\t\titalic: opts.catAxisLabelFontItalic,\n\t\tcolor: opts.catAxisLabelColor,\n\t\tfontFace: opts.catAxisLabelFontFace,\n\t})\n\tconst txPr = axisTextProps(\n\t\tdefRPr,\n\t\tchartLang(opts),\n\t\tmapStated(opts.catAxisLabelRotate, (d) => convertAngleUnits(d, 'catAxisLabelRotate'))\n\t)\n\n\tconst catLabelSkip = positiveIntAttr(opts.catAxisLabelFrequency, 'catAxisLabelFrequency')\n\tconst valAxisCrossing = axisCrossing(opts.valAxisCrossesAt, 'autoZero', 'valAxisCrossesAt')\n\n\t// Which units this axis can carry is decided by the tag, not by the option: the three tags\n\t// this one builder emits have three different content models. `CT_CatAx` has no unit slot at\n\t// all; `CT_ValAx` -- the tag a scatter/bubble X axis takes -- has the numeric pair only;\n\t// `CT_DateAx` has all five, and wants them interleaved rather than time-then-numeric.\n\tlet units = ''\n\tif (tag === 'c:dateAx') {\n\t\t// All three resolved before any is emitted, so the warnings still arrive in option order.\n\t\tconst baseTimeUnit = validTimeUnit(opts.catAxisBaseTimeUnit, 'catAxisBaseTimeUnit')\n\t\tconst majorTimeUnit = validTimeUnit(opts.catAxisMajorTimeUnit, 'catAxisMajorTimeUnit')\n\t\tconst minorTimeUnit = validTimeUnit(opts.catAxisMinorTimeUnit, 'catAxisMinorTimeUnit')\n\t\tif (baseTimeUnit) units += voidEl('c:baseTimeUnit', { val: baseTimeUnit })\n\t\tif (opts.catAxisMajorUnit) units += voidEl('c:majorUnit', { val: opts.catAxisMajorUnit })\n\t\tif (majorTimeUnit) units += voidEl('c:majorTimeUnit', { val: majorTimeUnit })\n\t\tif (opts.catAxisMinorUnit) units += voidEl('c:minorUnit', { val: opts.catAxisMinorUnit })\n\t\tif (minorTimeUnit) units += voidEl('c:minorTimeUnit', { val: minorTimeUnit })\n\t} else {\n\t\tif (tag === 'c:valAx') {\n\t\t\tif (opts.catAxisMajorUnit) units += voidEl('c:majorUnit', { val: opts.catAxisMajorUnit })\n\t\t\tif (opts.catAxisMinorUnit) units += voidEl('c:minorUnit', { val: opts.catAxisMinorUnit })\n\t\t} else {\n\t\t\twarnNoSlot(tag, 'catAxisMajorUnit', opts.catAxisMajorUnit)\n\t\t\twarnNoSlot(tag, 'catAxisMinorUnit', opts.catAxisMinorUnit)\n\t\t}\n\t\twarnNoSlot(tag, 'catAxisBaseTimeUnit', opts.catAxisBaseTimeUnit)\n\t\twarnNoSlot(tag, 'catAxisMajorTimeUnit', opts.catAxisMajorTimeUnit)\n\t\twarnNoSlot(tag, 'catAxisMinorTimeUnit', opts.catAxisMinorTimeUnit)\n\t}\n\n\treturn el(tag, null, [\n\t\traw(voidEl('c:axId', { val: axisId })),\n\t\traw(scaling),\n\t\traw(voidEl('c:delete', { val: xsdBool(opts.catAxisHidden) })),\n\t\traw(voidEl('c:axPos', { val: opts.barDir === 'col' ? 'b' : 'l' })),\n\t\traw(createGridLineElement(opts.catGridLine)),\n\t\t// `<c:title>` comes between `</c:majorGridlines>` and `<c:numFmt>`.\n\t\traw(\n\t\t\taxisTitleXml(opts.showCatAxisTitle, {\n\t\t\t\ttext: opts.catAxisTitle,\n\t\t\t\tcolor: opts.catAxisTitleColor,\n\t\t\t\tfontFace: opts.catAxisTitleFontFace,\n\t\t\t\tfontSize: opts.catAxisTitleFontSize,\n\t\t\t\trotate: opts.catAxisTitleRotate,\n\t\t\t})\n\t\t),\n\t\traw(numFmt),\n\t\traw(ticks),\n\t\traw(axisLineSpPr(axisLineStroke(opts, 'cat'))),\n\t\traw(txPr),\n\t\traw(voidEl('c:crossAx', { val: valAxisId })),\n\t\traw(valAxisCrossing),\n\t\tusesValueAxisForCategories ? null : raw(voidEl('c:auto', { val: 1 })),\n\t\tusesCategoryAxis ? raw(voidEl('c:lblAlgn', { val: 'ctr' })) : null,\n\t\tusesCategoryAxis && catLabelSkip !== undefined ? raw(voidEl('c:tickLblSkip', { val: catLabelSkip })) : null,\n\t\tusesCategoryAxis ? raw(voidEl('c:noMultiLvlLbl', { val: opts.catAxisMultiLevelLabels ? 0 : 1 })) : null,\n\t\traw(units),\n\t])\n}\n\n/**\n * Create Value Axis (Used by `bar3D`)\n * @param {ChartOptsInternal} opts - chart options\n * @param {string} valAxisId - value\n * @return {string} XML\n */\nexport function makeValAxis(opts: ChartOptsInternal, valAxisId: string): string {\n\tlet axisPos =\n\t\tvalAxisId === AXIS_ID_VALUE_PRIMARY ? (opts.barDir === 'col' ? 'l' : 'b') : opts.barDir !== 'col' ? 'r' : 't'\n\tif (valAxisId === AXIS_ID_VALUE_SECONDARY) axisPos = 'r' // default behavior for PPT is showing 2nd val axis on right (primary axis on left)\n\tconst crossAxId = valAxisId === AXIS_ID_VALUE_PRIMARY ? AXIS_ID_CATEGORY_PRIMARY : AXIS_ID_CATEGORY_SECONDARY\n\n\tconst scaling = el('c:scaling', null, [\n\t\topts.valAxisLogScaleBase ? raw(voidEl('c:logBase', { val: opts.valAxisLogScaleBase })) : null,\n\t\traw(voidEl('c:orientation', { val: opts.valAxisOrientation || 'minMax' })),\n\t\topts.valAxisMaxVal != null ? raw(voidEl('c:max', { val: opts.valAxisMaxVal })) : null,\n\t\topts.valAxisMinVal != null ? raw(voidEl('c:min', { val: opts.valAxisMinVal })) : null,\n\t])\n\n\tconst ticks = isScatterChart(opts._type)\n\t\t? voidEl('c:majorTickMark', { val: 'none' }) +\n\t\t\tvoidEl('c:minorTickMark', { val: 'none' }) +\n\t\t\tvoidEl('c:tickLblPos', { val: 'nextTo' })\n\t\t: voidEl('c:majorTickMark', { val: opts.valAxisMajorTickMark || 'out' }) +\n\t\t\tvoidEl('c:minorTickMark', { val: opts.valAxisMinorTickMark || 'none' }) +\n\t\t\tvoidEl('c:tickLblPos', { val: opts.valAxisLabelPos || (opts.barDir === 'col' ? 'nextTo' : 'low') })\n\n\tconst defRPr = axisLabelDefRPr({\n\t\toption: 'valAxisLabelFontSize',\n\t\tsize: opts.valAxisLabelFontSize,\n\t\tbold: opts.valAxisLabelFontBold,\n\t\titalic: opts.valAxisLabelFontItalic,\n\t\tcolor: opts.valAxisLabelColor,\n\t\tfontFace: opts.valAxisLabelFontFace,\n\t})\n\tconst txPr = axisTextProps(\n\t\tdefRPr,\n\t\tchartLang(opts),\n\t\tmapStated(opts.valAxisLabelRotate, (d) => convertAngleUnits(d, 'valAxisLabelRotate'))\n\t)\n\n\t// Where this axis meets its category axis: an explicit position, an explicit rule, or the\n\t// default — a right/top axis crosses at the maximum, everything else at zero.\n\tconst crosses = axisCrossing(\n\t\topts.catAxisCrossesAt,\n\t\taxisPos === 'r' || axisPos === 't' ? 'max' : 'autoZero',\n\t\t'catAxisCrossesAt'\n\t)\n\tconst crossBetween =\n\t\topts.valAxisCrossBetween ||\n\t\t(isScatterChart(opts._type) ||\n\t\t!!(Array.isArray(opts._type) && opts._type.some((type) => asChartType(type.type) === ChartType.area))\n\t\t\t? 'midCat'\n\t\t\t: 'between')\n\n\treturn el('c:valAx', null, [\n\t\traw(voidEl('c:axId', { val: valAxisId })),\n\t\traw(scaling),\n\t\traw(voidEl('c:delete', { val: xsdBool(opts.valAxisHidden) })),\n\t\traw(voidEl('c:axPos', { val: axisPos })),\n\t\traw(createGridLineElement(opts.valGridLine)),\n\t\t// `<c:title>` comes between `</c:majorGridlines>` and `<c:numFmt>`.\n\t\traw(\n\t\t\taxisTitleXml(opts.showValAxisTitle, {\n\t\t\t\ttext: opts.valAxisTitle,\n\t\t\t\tcolor: opts.valAxisTitleColor,\n\t\t\t\tfontFace: opts.valAxisTitleFontFace,\n\t\t\t\tfontSize: opts.valAxisTitleFontSize,\n\t\t\t\trotate: opts.valAxisTitleRotate,\n\t\t\t})\n\t\t),\n\t\traw(voidEl('c:numFmt', { formatCode: opts.valAxisLabelFormatCode || 'General', sourceLinked: 0 })),\n\t\traw(ticks),\n\t\traw(axisLineSpPr(axisLineStroke(opts, 'val'))),\n\t\traw(txPr),\n\t\traw(voidEl('c:crossAx', { val: crossAxId })),\n\t\traw(crosses),\n\t\traw(voidEl('c:crossBetween', { val: crossBetween })),\n\t\topts.valAxisMajorUnit ? raw(voidEl('c:majorUnit', { val: opts.valAxisMajorUnit })) : null,\n\t\topts.valAxisMinorUnit ? raw(voidEl('c:minorUnit', { val: opts.valAxisMinorUnit })) : null,\n\t\topts.valAxisDisplayUnit\n\t\t\t? raw(\n\t\t\t\t\tel('c:dispUnits', null, [\n\t\t\t\t\t\traw(voidEl('c:builtInUnit', { val: opts.valAxisDisplayUnit })),\n\t\t\t\t\t\traw(opts.valAxisDisplayUnitLabel ? voidEl('c:dispUnitsLbl') : ''),\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t: null,\n\t])\n}\n\n/**\n * Create Series Axis (Used by `bar3D`)\n *\n * `CT_SerAx` carries no unit of any kind -- neither the numeric `majorUnit`/`minorUnit` pair\n * nor the three time units -- which is why this builder emits none and the options that named\n * them are gone from `ChartPropsAxisSer` rather than warned about.\n * @param {ChartOptsInternal} opts - chart options\n * @param {string} axisId - axis ID\n * @param {string} valAxisId - value\n * @return {string} XML\n */\nexport function makeSerAxis(opts: ChartOptsInternal, axisId: string, valAxisId: string): string {\n\tconst defRPr = axisLabelDefRPr({\n\t\toption: 'serAxisLabelFontSize',\n\t\tsize: opts.serAxisLabelFontSize,\n\t\tbold: opts.serAxisLabelFontBold,\n\t\titalic: opts.serAxisLabelFontItalic,\n\t\tcolor: opts.serAxisLabelColor,\n\t\tfontFace: opts.serAxisLabelFontFace,\n\t})\n\t// No `serAxisLabelRotate` option exists, so the series axis always takes the auto rotation.\n\tconst txPr = axisTextProps(defRPr, chartLang(opts))\n\tconst serLabelSkip = positiveIntAttr(opts.serAxisLabelFrequency, 'serAxisLabelFrequency')\n\n\treturn el('c:serAx', null, [\n\t\traw(voidEl('c:axId', { val: axisId })),\n\t\traw(el('c:scaling', null, raw(voidEl('c:orientation', { val: opts.serAxisOrientation || 'minMax' })))),\n\t\traw(voidEl('c:delete', { val: xsdBool(opts.serAxisHidden) })),\n\t\traw(voidEl('c:axPos', { val: opts.barDir === 'col' ? 'b' : 'l' })),\n\t\traw(createGridLineElement(opts.serGridLine)),\n\t\t// `<c:title>` comes between `</c:majorGridlines>` and `<c:numFmt>`.\n\t\traw(\n\t\t\taxisTitleXml(opts.showSerAxisTitle, {\n\t\t\t\ttext: opts.serAxisTitle,\n\t\t\t\tcolor: opts.serAxisTitleColor,\n\t\t\t\tfontFace: opts.serAxisTitleFontFace,\n\t\t\t\tfontSize: opts.serAxisTitleFontSize,\n\t\t\t\trotate: opts.serAxisTitleRotate,\n\t\t\t})\n\t\t),\n\t\traw(voidEl('c:numFmt', { formatCode: (opts.serLabelFormatCode ?? '') || 'General', sourceLinked: 0 })),\n\t\traw(voidEl('c:majorTickMark', { val: 'out' })),\n\t\traw(voidEl('c:minorTickMark', { val: 'none' })),\n\t\traw(voidEl('c:tickLblPos', { val: opts.serAxisLabelPos || (opts.barDir === 'col' ? 'low' : 'nextTo') })),\n\t\traw(axisLineSpPr(axisLineStroke(opts, 'ser'))),\n\t\traw(txPr),\n\t\traw(voidEl('c:crossAx', { val: valAxisId })),\n\t\traw(voidEl('c:crosses', { val: 'autoZero' })),\n\t\tserLabelSkip !== undefined ? raw(voidEl('c:tickLblSkip', { val: serLabelSkip })) : null,\n\t])\n}\n","/**\n * ts-pptx: Category-Axis Plot Assembly\n *\n * Emits the `<c:areaChart>` / `<c:barChart>` / `<c:bar3DChart>` / `<c:lineChart>` /\n * `<c:radarChart>` plot elements. These five chart types share one builder because they\n * share a plot shape -- grouping, per-series `<c:ser>` with a category reference and a\n * value cache, then the axis-id pair -- and differ only in a handful of type-gated\n * children. Reached through {@link ./chart-xml}'s `makeChartType` dispatch.\n */\n\nimport { namedColorOr } from '../drawingml/color.js'\nimport { ChartType } from '../../enums.js'\nimport { AXIS_ID_SERIES_PRIMARY, BARCHART_COLORS } from '../../constants-internal.js'\nimport type { ChartOptsInternal, OptsChartDataInternal } from '../../types/internal.js'\nimport { genXmlColorSelection } from '../drawingml/fill.js'\nimport { createLineCap } from '../drawingml/line.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport { xsdBool } from '../../ooxml/xsd-boolean.js'\nimport { isStackedGrouping, seriesIdx } from './chart-kind.js'\nimport {\n\tcatValRefs,\n\tchartDataLabels,\n\tcreateDataBorderLine,\n\tcreateSerLinesElement,\n\tdataLabelDefRPr,\n\tdLblNumFmt,\n\tdLblPosEl,\n\tdLblsBlock,\n\tdLblShowFlags,\n\tlabelTextProps,\n\tmakeChartErrorBarsXml,\n\tmakeCustomDLblXml,\n\tmakeSeriesDataPointsXml,\n\tpaletteColor,\n\ttype PlotBuilder,\n\tresolveChartPalette,\n\tseriesNameRef,\n\tseriesShapeProps,\n\tseriesStroke,\n\tserMarker,\n} from './chart-parts.js'\n\n/** The chart types drawn as a line (a marker per point, an optional smooth) rather than as a body. */\nconst isLineLike = (chartType: ChartType): boolean => chartType === ChartType.line || chartType === ChartType.radar\n\n/** The two bar families, which share `<c:barDir>`, `<c:invertIfNegative>` and a gap width. */\nconst isBarLike = (chartType: ChartType): boolean => chartType === ChartType.bar || chartType === ChartType.bar3d\n\n/**\n * The type-gated children that open a plot element, before `<c:varyColors>`.\n *\n * `barGrouping`, `barDir` and `radarStyle` arrive resolved for this plot's own type, a combo\n * subchart's included (`normalizePlotOptions` in `gen/define/chart.ts`), so they are written as\n * found. The radar arm used to apply the alias map a second time, which looked like handling and\n * let a subchart's `radarStyle: 'bogus'` through untouched.\n */\nfunction plotGrouping(chartType: ChartType, opts: ChartOptsInternal): string {\n\tif (chartType === ChartType.area || chartType === ChartType.line) {\n\t\t// CT_Line/AreaChart take ST_Grouping, which has no `clustered`; anything not stacked is standard.\n\t\treturn voidEl('c:grouping', { val: isStackedGrouping(opts.barGrouping) ? opts.barGrouping : 'standard' })\n\t}\n\tif (isBarLike(chartType)) {\n\t\treturn voidEl('c:barDir', { val: opts.barDir }) + voidEl('c:grouping', { val: opts.barGrouping })\n\t}\n\tif (chartType === ChartType.radar) return voidEl('c:radarStyle', { val: opts.radarStyle })\n\treturn ''\n}\n\n/** Fill, outline and shadow for one series, from its resolved colour and the line/border options. */\nfunction serShapeProps(\n\tchartType: ChartType,\n\topts: ChartOptsInternal,\n\tseriesColor: string,\n\tlineSize: number | undefined,\n\tserIndex: number\n): string {\n\tlet line = ''\n\tif (isLineLike(chartType)) {\n\t\tline = seriesStroke(opts, seriesColor, serIndex, lineSize)\n\t} else if (opts.dataBorder) {\n\t\tline = createDataBorderLine(opts.dataBorder, createLineCap(opts.lineCap))\n\t}\n\treturn seriesShapeProps(opts, seriesColor, line)\n}\n\n/** Per-series `<c:dLbls>`: number format, an optional label background, text style, show flags. */\nfunction serDataLabels(obj: OptsChartDataInternal, opts: ChartOptsInternal, seriesColor: string, idx: number): string {\n\tconst over = opts.seriesOptions?.[idx]\n\tconst defRPr = dataLabelDefRPr(opts, over)\n\tconst txPr = labelTextProps(defRPr)\n\tconst lblFmtCode = over?.dataLabelFormatCode ?? opts.dataLabelFormatCode\n\treturn dLblsBlock({\n\t\t// Per-point custom labels precede the aggregate settings (CT_DLbls order: dLbl* then Group_DLbls).\n\t\tlead: (obj.customLabels ?? []).map((lbl, idx) => (lbl ? makeCustomDLblXml(idx, lbl, opts) : '')).join(''),\n\t\tnumFmt: dLblNumFmt(lblFmtCode),\n\t\tspPr: opts.dataLabelBkgrdColors ? el('c:spPr', null, raw(genXmlColorSelection(seriesColor))) : undefined,\n\t\ttxPr,\n\t\tdLblPos: dLblPosEl(opts),\n\t\tflags: dLblShowFlags({ val: xsdBool(opts.showValue), serName: xsdBool(opts.showSerName) }),\n\t\tshowLeaderLines: voidEl('c:showLeaderLines', { val: xsdBool(opts.showLeaderLines) }),\n\t})\n}\n\n/**\n * Plot a category-axis chart family (area / bar / bar3d / line / radar) into a\n * `<c:xxxChart>` element. These share the grouping / series / cat+val axis structure.\n */\nexport const makeCatAxisPlot: PlotBuilder = (chartType, data, opts, valAxisId, catAxisId, valFmtCode, sheet) => {\n\t/* EX1:\n\t\t\t\tdata: [\n\t\t\t\t {\n\t\t\t\t name: 'Region 1',\n\t\t\t\t labels: [['April', 'May', 'June', 'July']],\n\t\t\t\t values: [17, 26, 53, 96]\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t name: 'Region 2',\n\t\t\t\t labels: [['April', 'May', 'June', 'July']],\n\t\t\t\t values: [55, 43, 70, 58]\n\t\t\t\t }\n\t\t\t\t]\n */\n\t/* EX2:\n\t\t\t\tdata: [\n\t\t\t\t {\n\t\t\t\t name: 'Region 1',\n\t\t\t\t labels: [\n\t\t\t\t\t ['April', 'May', 'June', 'April', 'May', 'June'],\n\t\t\t\t\t ['2020', '', '', '2021', '', '']\n\t\t\t\t ],\n\t\t\t\t values: [17, 26, 53, 96, 40, 33]\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t name: 'Region 2',\n\t\t\t\t labels: [\n\t\t\t\t\t ['April', 'May', 'June', 'April', 'May', 'June'],\n\t\t\t\t\t ['2020', '', '', '2021', '', '']\n\t\t\t\t ],\n\t\t\t\t values: [55, 43, 70, 58, 78, 63]\n\t\t\t\t }\n\t\t\t\t]\n */\n\t// `chartColors` is always populated by addChartDefinition() (defaulting to BARCHART_COLORS); the\n\t// fallback in `paletteColor` only satisfies the optional type and keeps a colour a non-null string.\n\tconst chartColors = resolveChartPalette(opts)\n\t// A single bar series varies its own colours when the caller asked for a palette other than the\n\t// default one, or supplied `invertedColors`; every other shape colours by series.\n\tconst barVaryColors =\n\t\tisBarLike(chartType) &&\n\t\tdata.length === 1 &&\n\t\t((opts.chartColors && opts.chartColors !== BARCHART_COLORS && opts.chartColors.length > 1) ||\n\t\t\topts.invertedColors?.length)\n\t\t\t? opts.chartColors || BARCHART_COLORS\n\t\t\t: null\n\n\t// One `<c:ser>` per data row.\n\tconst sers = data\n\t\t.map((obj) => {\n\t\t\t// EVERY per-series lookup here keys on `seriesIdx`, the series' position across the whole\n\t\t\t// chart -- the same number written to `<c:idx>`/`<c:order>` just below. For a single-type\n\t\t\t// chart that is also its position within this subchart, so the two only part company on a\n\t\t\t// combo, where each subchart's own loop restarts at 0.\n\t\t\t//\n\t\t\t// The palette used to key on that per-subchart position, so a bar(2) + line(1) combo painted\n\t\t\t// the line with palette entry 0 -- the first bar's colour. PowerPoint does not restart the\n\t\t\t// cycle per plot group: a three-series clustered-column chart whose third series is switched\n\t\t\t// to a line keeps that series' third colour and merely moves it from the fill to the stroke\n\t\t\t// (read back over COM; `test/regression/chart/combo-charts.test.js` carries the case).\n\t\t\t// `lineDashValues` moved with it, for the same reason and by the same reading of \"the series\n\t\t\t// order in the `data` array\".\n\t\t\tconst idx = seriesIdx(obj, chartType)\n\t\t\tconst seriesOverride = opts.seriesOptions?.[idx]\n\t\t\tconst seriesColor = namedColorOr(seriesOverride?.color, paletteColor(chartColors, idx), 'seriesOptions color')\n\t\t\treturn el('c:ser', null, [\n\t\t\t\traw(voidEl('c:idx', { val: idx })),\n\t\t\t\traw(voidEl('c:order', { val: idx })),\n\t\t\t\traw(seriesNameRef(obj, sheet)),\n\t\t\t\traw(serShapeProps(chartType, opts, seriesColor, seriesOverride?.lineSize, idx)),\n\t\t\t\t// `invertIfNegative` is bar-only in the schema (CT_BarSer); area/line/radar must omit it.\n\t\t\t\tisBarLike(chartType) ? raw(voidEl('c:invertIfNegative', { val: 0 })) : null,\n\t\t\t\t// The marker takes the series' own colour, not a second palette lookup — the two used to\n\t\t\t\t// read different entries, so bar(2) + line(1) drew a `C0504D` line with `9BBB59` dots and\n\t\t\t\t// a `seriesOptions.color` override moved the body and not the dots.\n\t\t\t\tisLineLike(chartType) ? raw(serMarker(opts, seriesColor, seriesColor)) : null,\n\t\t\t\t// Per-point data points (`c:dPt`) MUST precede `c:dLbls` in CT_*Ser schema order.\n\t\t\t\traw(makeSeriesDataPointsXml(chartType, obj, opts, barVaryColors)),\n\t\t\t\t// NOTE: [20190117] Adding data labels to a RADAR chart causes unrecoverable corruption,\n\t\t\t\t// and CT_RadarSer has no error bars either.\n\t\t\t\tchartType === ChartType.radar ? null : raw(serDataLabels(obj, opts, seriesColor, idx)),\n\t\t\t\tchartType === ChartType.radar ? null : raw(makeChartErrorBarsXml(chartType, obj.errorBars, obj)),\n\t\t\t\traw(catValRefs(obj, opts, valFmtCode, sheet, { multiLevel: true })),\n\t\t\t\tchartType === ChartType.line ? raw(voidEl('c:smooth', { val: xsdBool(opts.lineSmooth) })) : null,\n\t\t\t])\n\t\t})\n\t\t.join('')\n\n\t// Per-type plot options. Schema order (CT_BarChart): gapWidth → overlap → serLines → axId.\n\tlet plotOptions = ''\n\tif (chartType === ChartType.bar) {\n\t\tplotOptions =\n\t\t\tvoidEl('c:gapWidth', { val: opts.barGapWidthPct }) +\n\t\t\tvoidEl('c:overlap', { val: opts.barOverlapPct ?? (isStackedGrouping(opts.barGrouping) ? 100 : 0) }) +\n\t\t\t// `<c:serLines>` connects data points across stacked bar/column series.\n\t\t\tcreateSerLinesElement(opts.barSeriesLine)\n\t} else if (chartType === ChartType.bar3d) {\n\t\tplotOptions =\n\t\t\tvoidEl('c:gapWidth', { val: opts.barGapWidthPct }) +\n\t\t\tvoidEl('c:gapDepth', { val: opts.barGapDepthPct }) +\n\t\t\tvoidEl('c:shape', { val: opts.bar3DShape })\n\t} else if (chartType === ChartType.line) {\n\t\tplotOptions = voidEl('c:marker', { val: 1 })\n\t}\n\n\treturn el(`c:${chartType}Chart`, null, [\n\t\traw(plotGrouping(chartType, opts)),\n\t\traw(voidEl('c:varyColors', { val: 0 })),\n\t\traw(sers),\n\t\traw(chartDataLabels(opts, true)),\n\t\traw(plotOptions),\n\t\t// Axis id order matters: category comes first. Only 3-D charts get a series axis — emitting a\n\t\t// SERIES_PRIMARY axId for a 2-D chart left a dangling reference, and every axId in\n\t\t// `<c:plotArea>` must resolve to a defined catAx/valAx.\n\t\traw(voidEl('c:axId', { val: catAxisId })),\n\t\traw(voidEl('c:axId', { val: valAxisId })),\n\t\tchartType === ChartType.bar3d ? raw(voidEl('c:axId', { val: AXIS_ID_SERIES_PRIMARY })) : null,\n\t])\n}\n","/**\n * ts-pptx: Scatter Plot Assembly\n *\n * Emits the `<c:scatterChart>` plot element. Scatter is the one family whose first data\n * row supplies X *values* rather than categories, so each `<c:ser>` carries an\n * `<c:xVal>`/`<c:yVal>` pair instead of `<c:cat>`/`<c:val>` -- which is why it does not\n * share the category-axis builder. Reached through {@link ./chart-xml}'s `makeChartType`\n * dispatch.\n */\n\nimport { BARCHART_COLORS } from '../../constants-internal.js'\nimport type { ChartSeriesOpts } from '../../types/index.js'\nimport type { ChartOptsInternal, OptsChartDataInternal } from '../../types/internal.js'\nimport { getUuid } from '../utils.js'\nimport { dataLabels, firstLabelGroup } from './data-refs.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport { xsdBool } from '../../ooxml/xsd-boolean.js'\nimport { OOXML_NS } from '../../ooxml/namespaces.js'\nimport {\n\tc15LeaderLinesExt,\n\tchartDataLabels,\n\tchartLang,\n\tdLblPosEl,\n\tdLblsBlock,\n\tdLblShowFlags,\n\tlabelDefRPr,\n\tlabelRun,\n\tmakeChartErrorBarsXml,\n\tmakeSeriesDataPointsXml,\n\ttype PlotBuilder,\n\tseriesNameRef,\n\tseriesShapeProps,\n\tseriesStroke,\n\tserMarker,\n\txySeriesRefs,\n} from './chart-parts.js'\n\n/**\n * The `<c:spPr>` a scatter data label carries: no fill, no outline, no effects — the label is\n * text on the plot rather than a box. Both label builders in this file spelled it out.\n */\nconst TRANSPARENT_LABEL_SPPR = el('c:spPr', null, [\n\traw(voidEl('a:noFill', null)),\n\traw(el('a:ln', null, raw(voidEl('a:noFill', null)))),\n\traw(voidEl('a:effectLst', null)),\n])\n\n/**\n * The `(x, y)` runs appended to a `customXY` label: a literal `\" (\"`, an `XVALUE` field, a\n * `\", \"`, a `YVALUE` field and a `\")\"`.\n *\n * Each `<a:fld>` id is minted per build. A field id has to be unique, which is a property a\n * derived id would have to reproduce without an oracle for how far that uniqueness has to\n * reach — so the ids stay random and the *comparison* gives: `NORMALIZERS` in\n * `scripts/pptx-parts.mjs` erases exactly these two field types before the byte-identity gate\n * diffs a part. Do not \"fix\" the nondeterminism here.\n */\nfunction customXYRuns(obj: OptsChartDataInternal, opts: ChartOptsInternal): string {\n\tconst lang = chartLang(opts)\n\tconst literal = (text: string): string =>\n\t\tel('a:r', null, [raw(voidEl('a:rPr', { lang, baseline: 0, dirty: 0 })), raw(el('a:t', null, text))])\n\t// Upper-cased: `a:fld/@id` is `ST_Guid`, whose pattern is `[0-9A-F]` only, so a lower-case\n\t// nibble is a schema error the validator reports at every field. `getUuid` emits lower case.\n\tconst field = (type: 'XVALUE' | 'YVALUE', text: string): string =>\n\t\tel('a:fld', { id: `{${getUuid('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx').toUpperCase()}}`, type }, [\n\t\t\traw(voidEl('a:rPr', { lang, baseline: 0 })),\n\t\t\traw(el('a:pPr', null, raw(voidEl('a:defRPr', null)))),\n\t\t\traw(el('a:t', null, text)),\n\t\t])\n\treturn (\n\t\tliteral(' (') +\n\t\tfield('XVALUE', '[' + (obj.name ?? '')) +\n\t\tliteral(', ') +\n\t\tfield('YVALUE', '[' + (obj.name ?? '') + ']') +\n\t\tliteral(')') +\n\t\tvoidEl('a:endParaRPr', { lang, dirty: 0 })\n\t)\n}\n\n/**\n * One per-point `<c:dLbl>` for the `custom` / `customXY` label formats: rich text carrying the\n * caller's label, optionally followed by the X/Y value fields.\n */\nfunction scatterCustomLabel(\n\tobj: OptsChartDataInternal,\n\topts: ChartOptsInternal,\n\tlabel: string,\n\tidx: number,\n\tchartUuid: string,\n\tover?: ChartSeriesOpts\n): string {\n\tconst rich = el('c:rich', null, [\n\t\traw(el('a:bodyPr', null, raw(voidEl('a:spAutoFit', null)))),\n\t\traw(voidEl('a:lstStyle', null)),\n\t\traw(\n\t\t\tel('a:p', null, [\n\t\t\t\traw(el('a:pPr', null, raw(labelDefRPr(opts, over)))),\n\t\t\t\traw(labelRun(opts, label, over)),\n\t\t\t\t// The X/Y values are appended only for a label that is not blank or all spaces,\n\t\t\t\t// which is what lets a caller label a subset of the points.\n\t\t\t\topts.dataLabelFormatScatter === 'customXY' && !/^ *$/.test(label) ? raw(customXYRuns(obj, opts)) : null,\n\t\t\t])\n\t\t),\n\t])\n\tconst extLst = el('c:extLst', null, [\n\t\traw(\n\t\t\tvoidEl('c:ext', {\n\t\t\t\turi: '{CE6537A1-D6FC-4f65-9D91-7224C49458BB}',\n\t\t\t\t'xmlns:c15': OOXML_NS.c15,\n\t\t\t})\n\t\t),\n\t\traw(\n\t\t\tel(\n\t\t\t\t'c:ext',\n\t\t\t\t{\n\t\t\t\t\turi: '{C3380CC4-5D6E-409C-BE32-E72D297353CC}',\n\t\t\t\t\t'xmlns:c16': 'http://schemas.microsoft.com/office/drawing/2014/chart',\n\t\t\t\t},\n\t\t\t\traw(voidEl('c16:uniqueId', { val: `{${String(idx + 1).padStart(8, '0')}${chartUuid}}` }))\n\t\t\t)\n\t\t),\n\t])\n\treturn dLblsBlock(\n\t\t{\n\t\t\tlead: voidEl('c:idx', { val: idx }) + el('c:tx', null, raw(rich)),\n\t\t\tspPr: TRANSPARENT_LABEL_SPPR,\n\t\t\tdLblPos: dLblPosEl(opts),\n\t\t\tflags: dLblShowFlags({}),\n\t\t\t// No `c:showLeaderLines` here. It used to be written hard-coded on, and `CT_DLbl` has no\n\t\t\t// such child -- it belongs to `CT_DLbls`, the plural container -- so every scatter with\n\t\t\t// `showLabel` and a `custom` or `customXY` format failed the schema validator at every\n\t\t\t// point. Desktop PowerPoint opened it anyway, and no schema case covered scatter custom\n\t\t\t// labels, so it went unseen.\n\t\t\t//\n\t\t\t// It was kept on the reasoning that a moved custom label with no leader line is a\n\t\t\t// different chart. A COM probe settles that: drag a scatter's data label away from its\n\t\t\t// point in PowerPoint and the `c:dLbl` it writes carries `c:idx`, a\n\t\t\t// `c:layout/c:manualLayout` holding the drag offset, `c:tx`, the six show flags and an\n\t\t\t// `extLst` of `c15:showDataLabelsRange` and `c16:uniqueId`. No leader line, in any\n\t\t\t// spelling, and none on the enclosing `c:dLbls` either. PowerPoint records nothing there,\n\t\t\t// so neither do we.\n\t\t\textLst,\n\t\t},\n\t\t'c:dLbl'\n\t)\n}\n\n/** The per-series `<c:dLbls>` of the `XY` label format: PowerPoint composes the text. */\nfunction scatterXYLabels(opts: ChartOptsInternal, over?: ChartSeriesOpts): string {\n\tconst txPr = el('c:txPr', null, [\n\t\traw(el('a:bodyPr', null, raw(voidEl('a:spAutoFit', null)))),\n\t\traw(voidEl('a:lstStyle', null)),\n\t\traw(\n\t\t\tel('a:p', null, [\n\t\t\t\traw(el('a:pPr', null, raw(labelDefRPr(opts, over)))),\n\t\t\t\traw(voidEl('a:endParaRPr', { lang: chartLang(opts) })),\n\t\t\t])\n\t\t),\n\t])\n\tconst extLst = c15LeaderLinesExt(1)\n\treturn dLblsBlock({\n\t\tspPr: TRANSPARENT_LABEL_SPPR,\n\t\ttxPr,\n\t\tdLblPos: dLblPosEl(opts),\n\t\tflags: dLblShowFlags({\n\t\t\tval: xsdBool(opts.showLabel),\n\t\t\tcatName: xsdBool(opts.showLabel),\n\t\t\tserName: xsdBool(opts.showSerName),\n\t\t}),\n\t\textLst,\n\t})\n}\n\n/** Fill, outline and shadow for one scatter series. */\nfunction scatterSerShapeProps(opts: ChartOptsInternal, serColor: string, serIndex: number, lineSize?: number): string {\n\treturn seriesShapeProps(opts, serColor, seriesStroke(opts, serColor, serIndex, lineSize))\n}\n\n/**\n * Plot an XY scatter chart into `<c:scatterChart>` (paired X/Y numeric series).\n */\nexport const makeScatterPlot: PlotBuilder = (chartType, data, opts, valAxisId, catAxisId, valFmtCode, sheet) => {\n\t/*\n\t\t\t\t`data` = [\n\t\t\t\t\t{ name:'X-Axis', values:[1,2,3,4,5,6,7,8,9,10,11,12] },\n\t\t\t\t\t{ name:'Y-Value 1', values:[13, 20, 21, 25] },\n\t\t\t\t\t{ name:'Y-Value 2', values:[ 1, 2, 5, 9] }\n\t\t\t\t];\n */\n\t// X values come from the first row; each later row is one Y series. Every column comes from the\n\t// worksheet layout: a standalone scatter's sheet puts X in column A, and a combo's sheet puts it\n\t// in the X row's own column after the label columns.\n\t// Legacy single-series colour-vary, and it can never fire: a scatter `data` array is one row of\n\t// X values plus one row per Y series, the loop below runs over `data.slice(1)`, so by the time\n\t// `data.length === 1` there are no series left to colour. The intent was presumably \"one Y\n\t// series\" (`=== 2`). Fixing it would start emitting `<c:dPt>` colour-vary for single-series\n\t// scatter charts, which is an output change and a question about what such a chart should look\n\t// like — so the condition is left exactly as it has always been, said out loud rather than\n\t// quietly corrected.\n\tconst scatterVaryColors =\n\t\tdata.length === 1 && opts.chartColors !== BARCHART_COLORS ? opts.chartColors || BARCHART_COLORS : null\n\n\tconst sers = data\n\t\t.slice(1)\n\t\t.map((obj) => {\n\t\t\t// `seriesOptions[0]` styles the FIRST Y series, `data[1]`: `data[0]` is the shared X row and is\n\t\t\t// not a series. In a combo the index stays clear of every other subchart's, where a count\n\t\t\t// restarting at 0 gave a bar and a scatter the same `<c:idx>` and the same colour.\n\t\t\tconst { idx, over, color: serColor, xVal, yVal } = xySeriesRefs(chartType, obj, data, opts, sheet, valFmtCode)\n\n\t\t\t// Scatter data point labels. `chartUuid` tails each point's `c16:uniqueId` and is minted\n\t\t\t// per build, for the reason {@link customXYRuns} gives about the `a:fld` ids.\n\t\t\tlet labels = ''\n\t\t\tif (opts.showLabel) {\n\t\t\t\t// Upper-cased for the same reason as the `a:fld` ids above, and to match what\n\t\t\t\t// PowerPoint writes: `{00000001-10AD-4F37-A175-DD7655EB2B6B}`.\n\t\t\t\tconst chartUuid = getUuid('-xxxx-xxxx-xxxx-xxxxxxxxxxxx').toUpperCase()\n\t\t\t\tconst isCustom = opts.dataLabelFormatScatter === 'custom' || opts.dataLabelFormatScatter === 'customXY'\n\t\t\t\tif (dataLabels(obj)[0] && isCustom) {\n\t\t\t\t\tlabels += el(\n\t\t\t\t\t\t'c:dLbls',\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\traw(\n\t\t\t\t\t\t\tfirstLabelGroup(obj)\n\t\t\t\t\t\t\t\t.map((label, pointIdx) => scatterCustomLabel(obj, opts, label, pointIdx, chartUuid, over))\n\t\t\t\t\t\t\t\t.join('')\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (opts.dataLabelFormatScatter === 'XY') labels += scatterXYLabels(opts, over)\n\t\t\t}\n\n\t\t\treturn el('c:ser', null, [\n\t\t\t\traw(voidEl('c:idx', { val: idx })),\n\t\t\t\traw(voidEl('c:order', { val: idx })),\n\t\t\t\traw(seriesNameRef(obj, sheet)),\n\t\t\t\traw(scatterSerShapeProps(opts, serColor, idx, over?.lineSize)),\n\t\t\t\traw(serMarker(opts, serColor, serColor)),\n\t\t\t\t// Per-point data points (`c:dPt`) MUST precede `c:dLbls` (CT_ScatterSer schema order).\n\t\t\t\traw(makeSeriesDataPointsXml(chartType, obj, opts, scatterVaryColors)),\n\t\t\t\traw(labels),\n\t\t\t\t// Error bars come after dLbls and before xVal/yVal in schema order.\n\t\t\t\traw(makeChartErrorBarsXml(chartType, obj.errorBars, obj)),\n\t\t\t\traw(xVal + yVal),\n\t\t\t\traw(voidEl('c:smooth', { val: xsdBool(opts.lineSmooth) })),\n\t\t\t])\n\t\t})\n\t\t.join('')\n\n\treturn el(`c:${chartType}Chart`, null, [\n\t\traw(voidEl('c:scatterStyle', { val: 'lineMarker' })),\n\t\traw(voidEl('c:varyColors', { val: 0 })),\n\t\traw(sers),\n\t\traw(chartDataLabels(opts, false)),\n\t\t// Axis id order matters: category comes first.\n\t\traw(voidEl('c:axId', { val: catAxisId })),\n\t\traw(voidEl('c:axId', { val: valAxisId })),\n\t])\n}\n","/**\n * ts-pptx: Bubble Plot Assembly\n *\n * Emits the `<c:bubbleChart>` plot element for `bubble` and `bubble3D`. Like scatter it\n * takes X values from the first data row, and adds a third `<c:bubbleSize>` cache per\n * series. Reached through {@link ./chart-xml}'s `makeChartType` dispatch.\n */\n\nimport { ChartType } from '../../enums.js'\nimport type { ChartOptsInternal } from '../../types/internal.js'\nimport { createLineCap } from '../drawingml/line.js'\nimport { bubbleSizeColumn, dataSizes, sheetRangeRef } from './data-refs.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport { xsdBool } from '../../ooxml/xsd-boolean.js'\nimport {\n\tc15LeaderLinesExt,\n\tcreateDataBorderLine,\n\tdataLabelDefRPr,\n\tdLblNumFmt,\n\tdLblPosEl,\n\tdLblsBlock,\n\tdLblShowFlags,\n\tlabelTextProps,\n\tnumRefBlock,\n\ttype PlotBuilder,\n\tseriesNameRef,\n\tseriesShapeProps,\n\tseriesStroke,\n\txySeriesRefs,\n} from './chart-parts.js'\n\n/**\n * Fill + outline + shadow for one bubble series, from the palette colour and the line options.\n *\n * Both the stroke fill and the cap read the same way as in `plot-scatter.ts` and\n * `plot-cat-axis.ts`, which this used to differ from on both counts with nothing saying why.\n * The colour went through `genXmlColorSelection` directly, so a `'transparent'` palette entry\n * reached colour validation, warned, and painted the bubble outline black — the exact hole\n * `chartColorLineFill` exists to close. The cap was hardcoded `flat`, so `lineCap` was accepted\n * and silently dropped for bubble charts alone; it is visible here, because a bubble outline\n * carries `lineDash` and a cap shapes the end of every dash.\n */\nfunction bubbleSerShapeProps(opts: ChartOptsInternal, serColor: string, serIndex: number, lineSize?: number): string {\n\t// A stated `lineSize: 0` is \"no outline\", and it beats `dataBorder` for the same reason the\n\t// chart-level one does: the caller asked for no line, and a border is a line.\n\tconst line =\n\t\t(lineSize ?? opts.lineSize) !== 0 && opts.dataBorder\n\t\t\t? createDataBorderLine(opts.dataBorder, createLineCap(opts.lineCap))\n\t\t\t: seriesStroke(opts, serColor, serIndex, lineSize)\n\treturn seriesShapeProps(opts, serColor, line)\n}\n\n/** The shared `<c:dLbls>` block: number format, label text style, and which parts are shown. */\nfunction bubbleDataLabels(opts: ChartOptsInternal): string {\n\tconst defRPr = dataLabelDefRPr(opts)\n\tconst txPr = labelTextProps(defRPr)\n\tconst extLst = c15LeaderLinesExt(xsdBool(opts.showLeaderLines))\n\treturn dLblsBlock({\n\t\tnumFmt: dLblNumFmt(opts.dataLabelFormatCode),\n\t\ttxPr,\n\t\tdLblPos: dLblPosEl(opts),\n\t\tflags: dLblShowFlags({\n\t\t\tval: xsdBool(opts.showValue),\n\t\t\tserName: xsdBool(opts.showSerName),\n\t\t\tbubbleSize: xsdBool(opts.showBubbleSize),\n\t\t}),\n\t\textLst,\n\t})\n}\n\n/**\n * Plot a bubble / bubble3d chart into `<c:bubbleChart>` (X/Y plus per-point size).\n */\nexport const makeBubblePlot: PlotBuilder = (chartType, data, opts, valAxisId, catAxisId, valFmtCode, sheet) => {\n\t/*\n\t\t\t\t`data` = [\n\t\t\t\t\t{ name:'X-Axis', values:[1,2,3,4,5,6,7,8,9,10,11,12] },\n\t\t\t\t\t{ name:'Y-Values 1', values:[13, 20, 21, 25], sizes:[10, 5, 20, 15] },\n\t\t\t\t\t{ name:'Y-Values 2', values:[ 1, 2, 5, 9], sizes:[ 5, 3, 9, 3] }\n\t\t\t\t];\n */\n\t// X values come from the first row; each later row is one series, and consumes two sheet\n\t// columns, its Y values and its sizes. Every column comes from the worksheet layout.\n\tconst sers = data\n\t\t.slice(1)\n\t\t.map((obj) => {\n\t\t\tconst { idx, over, color, xVal, yVal, rows } = xySeriesRefs(chartType, obj, data, opts, sheet, valFmtCode)\n\t\t\tconst spPr = bubbleSerShapeProps(opts, color, idx, over?.lineSize)\n\t\t\t// The sizes carry a constant `General` format code: no option spells a size number format.\n\t\t\t// Cached against the sheet's rows like the Y values: sized from the sizes themselves, a\n\t\t\t// series with none wrote the backwards range `Sheet1!$C$2:$C$1`.\n\t\t\tconst sizes = dataSizes(obj)\n\t\t\tconst sizeCol = bubbleSizeColumn(obj._dataIndex)\n\t\t\tconst sizeVal = numRefBlock(\n\t\t\t\t'c:bubbleSize',\n\t\t\t\tsheetRangeRef(sizeCol, 2, sizeCol, rows + 1),\n\t\t\t\t'General',\n\t\t\t\tArray.from({ length: rows }, (_unused, i) => sizes[i]),\n\t\t\t\trows\n\t\t\t)\n\t\t\treturn el('c:ser', null, [\n\t\t\t\traw(voidEl('c:idx', { val: idx })),\n\t\t\t\traw(voidEl('c:order', { val: idx })),\n\t\t\t\traw(seriesNameRef(obj, sheet)),\n\t\t\t\traw(spPr),\n\t\t\t\t// No `<c:dLbls>` per series — the chart-level block below carries the labels.\n\t\t\t\traw(xVal),\n\t\t\t\traw(yVal),\n\t\t\t\traw(sizeVal),\n\t\t\t\traw(voidEl('c:bubble3D', { val: xsdBool(chartType === ChartType.bubble3d) })),\n\t\t\t])\n\t\t})\n\t\t.join('')\n\n\t// `<c:bubbleScale>` / `<c:showNegBubbles>` are intentionally omitted so PowerPoint applies its\n\t// own defaults; no library option exposes them yet.\n\treturn el('c:bubbleChart', null, [\n\t\traw(voidEl('c:varyColors', { val: 0 })),\n\t\traw(sers),\n\t\traw(bubbleDataLabels(opts)),\n\t\t// Axis id order matters: category comes first.\n\t\traw(voidEl('c:axId', { val: catAxisId })),\n\t\traw(voidEl('c:axId', { val: valAxisId })),\n\t])\n}\n","/**\n * ts-pptx: Pie & Doughnut Plot Assembly\n *\n * Emits the `<c:pieChart>` / `<c:doughnutChart>` plot elements. These are the only\n * families with no axes at all -- a single series, one `<c:dPt>` per slice carrying its\n * own fill, and optional leader lines -- so the builder takes no axis ids. Reached\n * through {@link ./chart-xml}'s `makeChartType` dispatch.\n */\n\nimport { ChartType } from '../../enums.js'\nimport { DEF_SHAPE_SHADOW } from '../../constants-internal.js'\nimport type { ChartDataPointStyle } from '../../types/chart.js'\nimport type { ChartOptsInternal, OptsChartDataInternal } from '../../types/internal.js'\nimport { warn } from '../../diagnostics.js'\nimport { createColorElement, namedColorOr } from '../drawingml/color.js'\nimport { createShadowEffectLst } from '../drawingml/effect.js'\nimport { categoryRange, dataValues, firstLabelGroup, sheetRangeRef, type WorksheetLayout } from './data-refs.js'\nimport { el, raw, voidEl, type XmlChild } from '../oxml/el.js'\nimport { xsdBool } from '../../ooxml/xsd-boolean.js'\nimport {\n\tcatRefBlock,\n\tchartLang,\n\tcreateChartBorderLine,\n\tcreateDataBorderLine,\n\tcreateLeaderLinesElement,\n\tdLblNumFmt,\n\tdLblsBlock,\n\tdLblShowFlags,\n\tlabelDefRPr,\n\tlabelTextProps,\n\tnumRefBlock,\n\tpaletteColor,\n\tresolveChartPalette,\n\tseriesNameRef,\n} from './chart-parts.js'\n\n/** One `<c:dPt>`: the slice's own fill, its border override, and the shared shadow. */\nfunction pieDataPoint(\n\tidx: number,\n\tptStyle: ChartDataPointStyle | undefined,\n\topts: ChartOptsInternal,\n\tfallbackColor: string\n): string {\n\t// A per-point border override takes precedence over the chart-level `dataBorder`.\n\tconst border = ptStyle?.border\n\t\t? createChartBorderLine(ptStyle.border)\n\t\t: opts.dataBorder\n\t\t\t? createDataBorderLine(opts.dataBorder, 'flat')\n\t\t\t: ''\n\tconst spPr = el('c:spPr', null, [\n\t\traw(\n\t\t\tel(\n\t\t\t\t'a:solidFill',\n\t\t\t\tnull,\n\t\t\t\traw(createColorElement(namedColorOr(ptStyle?.fill, fallbackColor, 'dataPointStyle fill')))\n\t\t\t)\n\t\t),\n\t\traw(border),\n\t\traw(createShadowEffectLst(opts.shadow, DEF_SHAPE_SHADOW)),\n\t])\n\treturn el('c:dPt', null, [raw(voidEl('c:idx', { val: idx })), raw(voidEl('c:bubble3D', { val: 0 })), raw(spPr)])\n}\n\n/**\n * One `<c:dLbl>`: a pie labels its points, not its series, so every slice carries its own copy of\n * the number format, text style and show flags. A `customLabels` entry replaces the value with\n * literal rich text, which is why it also forces `<c:showVal>` off.\n */\nfunction pieDataLabel(idx: number, customLbl: string | undefined, opts: ChartOptsInternal, chartType: ChartType) {\n\t// `c:idx` and `c:tx` both precede `c:numFmt` per CT_DLbl / Group_DLbl / EG_DLblShared order,\n\t// which is what `lead` is for.\n\tconst tx = customLbl\n\t\t? el(\n\t\t\t\t'c:tx',\n\t\t\t\tnull,\n\t\t\t\traw(\n\t\t\t\t\tel('c:rich', null, [\n\t\t\t\t\t\traw(voidEl('a:bodyPr')),\n\t\t\t\t\t\traw(voidEl('a:lstStyle')),\n\t\t\t\t\t\traw(\n\t\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t\t'a:p',\n\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t\t\tel('a:r', null, [\n\t\t\t\t\t\t\t\t\t\traw(voidEl('a:rPr', { lang: chartLang(opts), dirty: 0 })),\n\t\t\t\t\t\t\t\t\t\traw(el('a:t', null, customLbl)),\n\t\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t)\n\t\t: ''\n\treturn dLblsBlock(\n\t\t{\n\t\t\tlead: voidEl('c:idx', { val: idx }) + tx,\n\t\t\tnumFmt: dLblNumFmt(opts.dataLabelFormatCode),\n\t\t\tspPr: voidEl('c:spPr', null),\n\t\t\ttxPr: labelTextProps(labelDefRPr(opts)),\n\t\t\tdLblPos:\n\t\t\t\tchartType === ChartType.pie && opts.dataLabelPosition\n\t\t\t\t\t? voidEl('c:dLblPos', { val: opts.dataLabelPosition })\n\t\t\t\t\t: undefined,\n\t\t\tflags: pieLabelFlags(opts, customLbl),\n\t\t},\n\t\t'c:dLbl'\n\t)\n}\n\n/**\n * The four `<c:show*>` flags a pie's data labels carry.\n *\n * The per-point `<c:dLbl>` read the caller's options; the plot-level `<c:dLbls>` wrote\n * `catName: 1, percent: 1` as constants, so a caller's `showLabel: false` and\n * `showPercent: false` both came back inverted. The constants were masked while every point\n * carried its own `<c:dLbl>` to override them, which holds only while the pie has labels.\n * @param opts - the chart's normalized options\n * @param customLbl - this point's literal label text, which replaces the value and so forces\n * `<c:showVal>` off. Absent at the plot level, which states no text of its own.\n */\nfunction pieLabelFlags(opts: ChartOptsInternal, customLbl?: string): XmlChild[] {\n\treturn dLblShowFlags({\n\t\tval: customLbl ? '0' : xsdBool(opts.showValue),\n\t\tcatName: xsdBool(opts.showLabel),\n\t\tserName: xsdBool(opts.showSerName),\n\t\tpercent: xsdBool(opts.showPercent),\n\t})\n}\n\n/**\n * The `<c:cat>` slice-name reference, keyed on the label count.\n *\n * The cache holds the leaf labels, and the workbook writes the leaf level in the last label\n * column, outermost level first ({@link categoryRange}).\n */\nfunction pieCategories(labels: string[], sheet: WorksheetLayout): string {\n\treturn el('c:cat', null, raw(catRefBlock('str', categoryRange(sheet, labels.length), labels)))\n}\n\n/**\n * The `<c:val>` numeric cache, keyed on the slice count.\n *\n * This was the last hand-built copy of {@link numRefBlock}, and it was kept out of that merge\n * because it disagreed about a gap rather than merely spelling one differently: it emitted a\n * `<c:pt>` with an empty `<c:v>` for a `null`/`undefined`/`NaN` and `<c:v>Infinity</c:v>` for an\n * infinity, where `numCachePt` leaves the point out. Measured against desktop PowerPoint,\n * the two disagreements are not alike:\n *\n * - The empty `<c:v>` was harmless. A pie with the point present-but-empty and the same pie with\n * the point absent open without a repair prompt, resolve to the same object model\n * (`SeriesCollection(1).Values` reads `Empty` at that index in both), and export to a\n * byte-identical PNG. A sensitivity check confirms the cache is what paints: perturbing a\n * *neighbouring* cached value moves both the read-back and the pixels.\n * - `<c:v>Infinity</c:v>` was not. PowerPoint refuses the package with 0x80070570 — the\n * corrupt-file error — and so does `NaN` or `INF` in that position. A pie was therefore the one\n * family where a non-finite value reached the deck instead of being warned about and dropped.\n */\nfunction pieValues(obj: OptsChartDataInternal, count: number, valFmtCode: string, sheet: WorksheetLayout): string {\n\tconst valCol = sheet.valueColumn(obj._dataIndex)\n\treturn numRefBlock('c:val', sheetRangeRef(valCol, 2, valCol, count + 1), valFmtCode, dataValues(obj), count)\n}\n\n/**\n * Plot a single-series pie / doughnut chart into `<c:pieChart>` / `<c:doughnutChart>`.\n *\n * The series name and values take their column from the worksheet layout. Both were column B,\n * which is right for one label level only: an unlabelled pie writes its values in column A, and\n * a pie with two label levels in column C.\n */\nexport function makePiePlot(\n\tchartType: ChartType,\n\tdata: OptsChartDataInternal[],\n\topts: ChartOptsInternal,\n\tvalFmtCode: string,\n\tsheet: WorksheetLayout\n): string {\n\t/* EX:\n\t\t\t\tdata: [\n\t\t\t\t {\n\t\t\t\t name: 'Project Status',\n\t\t\t\t labels: ['Red', 'Amber', 'Green', 'Unknown'],\n\t\t\t\t values: [10, 20, 38, 2]\n\t\t\t\t }\n\t\t\t\t]\n */\n\tconst optsChartData = data[0]\n\tif (!optsChartData) return ''\n\tconst chartColors = resolveChartPalette(opts)\n\tconst labels = firstLabelGroup(optsChartData)\n\t// A pie slices its values, so the values are what decide how many slices there are. Keying\n\t// everything on `labels.length` meant an unlabelled pie emitted no `<c:dPt>` at all and\n\t// reversed both sheet ranges (`Sheet1!$A$2:$A$1`), because the end row is `count + 1`.\n\tconst sliceCount = labels.length || dataValues(optsChartData).length\n\tif (sliceCount === 0) {\n\t\twarn('chart/point-count-mismatch', 'addChart: a pie/doughnut series with no values plots nothing; skipping it.')\n\t\treturn ''\n\t}\n\n\t// The series' own shape props are a placeholder — every slice overrides them in its `<c:dPt>`.\n\tconst spPr = el('c:spPr', null, [\n\t\traw(el('a:solidFill', null, raw(voidEl('a:schemeClr', { val: 'accent1' })))),\n\t\traw(\n\t\t\tel('a:ln', { w: 9525, cap: 'flat' }, [\n\t\t\t\traw(el('a:solidFill', null, raw(voidEl('a:srgbClr', { val: 'F9F9F9' })))),\n\t\t\t\traw(voidEl('a:prstDash', { val: 'solid' })),\n\t\t\t\traw(voidEl('a:round')),\n\t\t\t])\n\t\t),\n\t\traw(opts.dataNoEffects ? voidEl('a:effectLst') : createShadowEffectLst(opts.shadow, DEF_SHAPE_SHADOW)),\n\t])\n\n\t// The plot-level `<c:dLbls>` carries the defaults; the per-point ones above it carry the overrides.\n\tconst dLbls = dLblsBlock({\n\t\tlead: Array.from({ length: sliceCount }, (_unused, idx) =>\n\t\t\tpieDataLabel(idx, optsChartData.customLabels?.[idx], opts, chartType)\n\t\t).join(''),\n\t\tnumFmt: dLblNumFmt(opts.dataLabelFormatCode),\n\t\ttxPr: labelTextProps(labelDefRPr(opts)),\n\t\tdLblPos: chartType === ChartType.pie ? voidEl('c:dLblPos', { val: opts.dataLabelPosition || 'ctr' }) : undefined,\n\t\tflags: pieLabelFlags(opts),\n\t\tshowLeaderLines: voidEl('c:showLeaderLines', { val: xsdBool(opts.showLeaderLines) }),\n\t\tleaderLines: createLeaderLinesElement(opts),\n\t})\n\n\tconst ser = el('c:ser', null, [\n\t\traw(voidEl('c:idx', { val: 0 })),\n\t\traw(voidEl('c:order', { val: 0 })),\n\t\traw(seriesNameRef(optsChartData, sheet)),\n\t\traw(spPr),\n\t\traw(\n\t\t\tArray.from({ length: sliceCount }, (_unused, idx) =>\n\t\t\t\tpieDataPoint(idx, optsChartData.pointStyles?.[idx], opts, paletteColor(chartColors, idx))\n\t\t\t).join('')\n\t\t),\n\t\traw(dLbls),\n\t\t// `<c:cat>` is optional on a `CT_PieSer`; an unlabelled pie states no category names\n\t\t// rather than referencing an empty range.\n\t\tlabels.length > 0 ? raw(pieCategories(labels, sheet)) : null,\n\t\traw(pieValues(optsChartData, sliceCount, valFmtCode, sheet)),\n\t])\n\n\treturn el(`c:${chartType}Chart`, null, [\n\t\traw(voidEl('c:varyColors', { val: 1 })),\n\t\traw(ser),\n\t\t// Both arrive clamped and rounded (`clampChartInt` in `gen/define/chart.ts`), or absent.\n\t\traw(voidEl('c:firstSliceAng', { val: opts.firstSliceAng ?? 0 })),\n\t\tchartType === ChartType.doughnut ? raw(voidEl('c:holeSize', { val: opts.holeSize ?? 50 })) : null,\n\t])\n}\n","/**\n * ts-pptx: Stock (High-Low-Close) Plot Assembly\n *\n * Emits the classic `<c:stockChart>` element (plus, for the volume styles, a leading\n * `<c:barChart>` volume series on a secondary axis pair). A stock chart is a fixed-order\n * multi-series line chart drawn with invisible lines: `<c:hiLowLines>` connect the\n * high/low of each category, and the open-high-low-close styles add `<c:upDownBars>`.\n * Reached through {@link ./chart-xml}'s `makeChartType` dispatch; its axes are built by\n * the stock branch of `makeChartAxesXml` (which reuses {@link ./chart-axes}).\n */\n\nimport { namedColorOr } from '../drawingml/color.js'\nimport {\n\tAXIS_ID_CATEGORY_PRIMARY,\n\tAXIS_ID_CATEGORY_SECONDARY,\n\tAXIS_ID_VALUE_PRIMARY,\n\tAXIS_ID_VALUE_SECONDARY,\n} from '../../constants-internal.js'\nimport type { ChartOptsInternal, OptsChartDataInternal } from '../../types/internal.js'\nimport { genXmlColorSelection } from '../drawingml/fill.js'\nimport type { WorksheetLayout } from './data-refs.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport {\n\tcatValRefs,\n\tdLblShowFlags,\n\tdimmedTextFill,\n\tdimmedTextLine,\n\tpaletteColor,\n\tresolveChartPalette,\n\tseriesNameRef,\n\ttype PlotBuilder,\n} from './chart-parts.js'\nimport { seriesIdx, STOCK_STYLE_SPEC, type StockStyle } from './chart-kind.js'\n\n/** True when the given (already-normalized) stock style leads with a Volume bar series. */\nexport const isVolumeStockStyle = (style: StockStyle | undefined): boolean => !!style && STOCK_STYLE_SPEC[style].volume\n\n/** Minimal `<c:dLbls>` block (all labels off) shared by the stock and volume-bar subcharts. */\nconst STOCK_DLBLS = el('c:dLbls', null, [...dLblShowFlags({})])\n\n/** Emit a single stock (line) series: invisible line, optional close-marker, cat/val refs. */\nfunction makeStockLineSer(\n\tidx: number,\n\tobj: OptsChartDataInternal,\n\topts: ChartOptsInternal,\n\tvalFmtCode: string,\n\tmarkCloseColor: string | null,\n\tsheet: WorksheetLayout\n): string {\n\t// Stock series draw no line themselves (the hi-low lines / up-down bars carry the visual).\n\tconst spPr = el('c:spPr', null, [\n\t\traw(el('a:ln', { w: 19050, cap: 'rnd' }, [raw(voidEl('a:noFill')), raw(voidEl('a:round'))])),\n\t\traw(voidEl('a:effectLst')),\n\t])\n\tconst marker = markCloseColor\n\t\t? el('c:marker', null, [\n\t\t\t\traw(voidEl('c:symbol', { val: 'dot' })),\n\t\t\t\traw(voidEl('c:size', { val: 5 })),\n\t\t\t\traw(\n\t\t\t\t\tel('c:spPr', null, [\n\t\t\t\t\t\traw(genXmlColorSelection(markCloseColor)),\n\t\t\t\t\t\traw(el('a:ln', { w: 9525 }, raw(genXmlColorSelection(markCloseColor)))),\n\t\t\t\t\t\traw(voidEl('a:effectLst')),\n\t\t\t\t\t])\n\t\t\t\t),\n\t\t\t])\n\t\t: el('c:marker', null, raw(voidEl('c:symbol', { val: 'none' })))\n\treturn el('c:ser', null, [\n\t\traw(voidEl('c:idx', { val: idx })),\n\t\traw(voidEl('c:order', { val: idx })),\n\t\traw(seriesNameRef(obj, sheet)),\n\t\traw(spPr),\n\t\traw(marker),\n\t\traw(catValRefs(obj, opts, valFmtCode, sheet, { multiLevel: false })),\n\t\traw(voidEl('c:smooth', { val: 0 })),\n\t])\n}\n\n/**\n * Plot a stock chart. For `vhlc`/`vohlc` the first data series is a Volume column drawn as a\n * `<c:barChart>` on the primary axis pair, with the remaining high/low/close(/open) series in a\n * `<c:stockChart>` on the secondary axis pair; the non-volume styles draw only the stock chart on\n * the primary pair. `valAxisId`/`catAxisId` are the primary ids passed by the dispatch.\n */\nexport const makeStockPlot: PlotBuilder = (chartType, data, opts, valAxisId, catAxisId, valFmtCode, sheet) => {\n\tconst spec = STOCK_STYLE_SPEC[(opts.stockStyle as StockStyle) || 'hlc']\n\tconst chartColors = resolveChartPalette(opts)\n\tconst volumeSeries = spec.volume ? data[0] : null\n\tconst stockSeries = spec.volume ? data.slice(1) : data\n\tlet strXml = ''\n\n\t// VOLUME: a bar series on the PRIMARY axis pair (drawn behind the price series).\n\tif (volumeSeries) {\n\t\tconst volumeIdx = seriesIdx(volumeSeries, chartType)\n\t\tconst volumeSer = el('c:ser', null, [\n\t\t\traw(voidEl('c:idx', { val: volumeIdx })),\n\t\t\traw(voidEl('c:order', { val: volumeIdx })),\n\t\t\traw(seriesNameRef(volumeSeries, sheet)),\n\t\t\traw(\n\t\t\t\tel(\n\t\t\t\t\t'c:spPr',\n\t\t\t\t\tnull,\n\t\t\t\t\traw(\n\t\t\t\t\t\tgenXmlColorSelection(\n\t\t\t\t\t\t\tnamedColorOr(opts.seriesOptions?.[volumeIdx]?.color, chartColors[0] ?? '4472C4', 'seriesOptions color')\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t),\n\t\t\traw(voidEl('c:invertIfNegative', { val: 0 })),\n\t\t\traw(catValRefs(volumeSeries, opts, valFmtCode, sheet, { multiLevel: false })),\n\t\t])\n\t\tstrXml += el('c:barChart', null, [\n\t\t\traw(voidEl('c:barDir', { val: 'col' })),\n\t\t\traw(voidEl('c:grouping', { val: 'clustered' })),\n\t\t\traw(voidEl('c:varyColors', { val: 0 })),\n\t\t\traw(volumeSer),\n\t\t\traw(STOCK_DLBLS),\n\t\t\traw(voidEl('c:gapWidth', { val: 150 })),\n\t\t\traw(voidEl('c:axId', { val: AXIS_ID_CATEGORY_PRIMARY })),\n\t\t\traw(voidEl('c:axId', { val: AXIS_ID_VALUE_PRIMARY })),\n\t\t])\n\t}\n\n\t// STOCK: the price series drawn with invisible lines + hi-low lines (+ up-down bars for OHLC).\n\tconst sers = stockSeries\n\t\t.map((obj, pos) => {\n\t\t\tconst idx = seriesIdx(obj, chartType)\n\t\t\t// HLC/VHLC (no up-down bars) mark the final \"close\" series with a dot so it reads on the chart.\n\t\t\tconst isClose = !spec.upDownBars && pos === stockSeries.length - 1\n\t\t\t// The price series draw no line of their own -- the hi-low lines and up-down bars carry the\n\t\t\t// visual -- so a `seriesOptions.color` has exactly two referents on a stock chart: the\n\t\t\t// volume bar above, and the dot that marks the close series where there are no up-down bars.\n\t\t\tconst markColor = isClose\n\t\t\t\t? namedColorOr(\n\t\t\t\t\t\topts.seriesOptions?.[idx]?.color,\n\t\t\t\t\t\tpaletteColor(chartColors, idx, 'ED7D31'),\n\t\t\t\t\t\t'seriesOptions color'\n\t\t\t\t\t)\n\t\t\t\t: null\n\t\t\treturn makeStockLineSer(idx, obj, opts, valFmtCode, markColor, sheet)\n\t\t})\n\t\t.join('')\n\tconst hiLowLines = el(\n\t\t'c:hiLowLines',\n\t\tnull,\n\t\traw(el('c:spPr', null, [raw(dimmedTextLine(75000, 25000)), raw(voidEl('a:effectLst'))]))\n\t)\n\t// The up bar is a hollow body (background fill), the down bar a filled one; both are outlined in\n\t// the same grey, which is how a rising and a falling category tell themselves apart.\n\tconst upDownBars = spec.upDownBars\n\t\t? el('c:upDownBars', null, [\n\t\t\t\traw(voidEl('c:gapWidth', { val: 150 })),\n\t\t\t\traw(\n\t\t\t\t\tel(\n\t\t\t\t\t\t'c:upBars',\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\traw(\n\t\t\t\t\t\t\tel('c:spPr', null, [\n\t\t\t\t\t\t\t\traw(el('a:solidFill', null, raw(voidEl('a:schemeClr', { val: 'bg1' })))),\n\t\t\t\t\t\t\t\traw(dimmedTextLine(65000, 35000)),\n\t\t\t\t\t\t\t\traw(voidEl('a:effectLst')),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\traw(\n\t\t\t\t\tel(\n\t\t\t\t\t\t'c:downBars',\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\traw(\n\t\t\t\t\t\t\tel('c:spPr', null, [\n\t\t\t\t\t\t\t\traw(dimmedTextFill(65000, 35000)),\n\t\t\t\t\t\t\t\traw(dimmedTextLine(65000, 35000)),\n\t\t\t\t\t\t\t\traw(voidEl('a:effectLst')),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t])\n\t\t: ''\n\t// Volume styles put the price series on the SECONDARY axis pair (the bar owns the primary pair).\n\tconst stockCatId = spec.volume ? AXIS_ID_CATEGORY_SECONDARY : catAxisId\n\tconst stockValId = spec.volume ? AXIS_ID_VALUE_SECONDARY : valAxisId\n\tstrXml += el('c:stockChart', null, [\n\t\traw(sers),\n\t\traw(STOCK_DLBLS),\n\t\traw(hiLowLines),\n\t\traw(upDownBars),\n\t\traw(voidEl('c:axId', { val: stockCatId })),\n\t\traw(voidEl('c:axId', { val: stockValId })),\n\t])\n\n\treturn strXml\n}\n","/**\n * ts-pptx: Surface Plot Assembly\n *\n * Emits the classic `<c:surface3DChart>` (a 3-D surface) or `<c:surfaceChart>` (a 2-D\n * contour / top view), selected by the `surface3D` option; `wireframe` toggles the\n * mesh-only look. A surface chart interpolates a colored sheet over the category (X) and\n * series (Z) axes with the value as height (Y), so — like `bar3D` — it needs all three\n * axes and a `<c:view3D>` + floor/side/back walls (emitted by the surface branch of\n * `makeChartHeaderXml`). Reached through {@link ./chart-xml}'s `makeChartType` dispatch.\n */\n\nimport { AXIS_ID_SERIES_PRIMARY } from '../../constants-internal.js'\nimport type { ChartType } from '../../enums.js'\nimport type { ChartOptsInternal, OptsChartDataInternal } from '../../types/internal.js'\nimport { genXmlColorSelection } from '../drawingml/fill.js'\nimport type { WorksheetLayout } from './data-refs.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport { xsdBool } from '../../ooxml/xsd-boolean.js'\nimport { catValRefs, paletteColor, resolveChartPalette, seriesNameRef, type PlotBuilder } from './chart-parts.js'\nimport { seriesIdx } from './chart-kind.js'\n\n/** True when the (normalized) surface options select the 3-D surface rather than a 2-D contour. */\nconst isSurface3D = (opts: ChartOptsInternal): boolean => opts.surface3D !== false\n\n/** Emit a single surface series: name ref, 3-D shape props, and cat/val refs. */\nfunction makeSurfaceSer(\n\tchartType: ChartType,\n\tobj: OptsChartDataInternal,\n\topts: ChartOptsInternal,\n\tvalFmtCode: string,\n\tseriesColor: string,\n\tsheet: WorksheetLayout\n): string {\n\t// A surface series carries 3-D shape props; the surface itself is colored by value band, but the\n\t// per-series fill still styles the wireframe / legend key.\n\tconst spPr = el('c:spPr', null, [\n\t\traw(genXmlColorSelection(seriesColor)),\n\t\traw(voidEl('a:ln')),\n\t\traw(voidEl('a:effectLst')),\n\t\traw(voidEl('a:sp3d')),\n\t])\n\tconst idx = seriesIdx(obj, chartType)\n\treturn el('c:ser', null, [\n\t\traw(voidEl('c:idx', { val: idx })),\n\t\traw(voidEl('c:order', { val: idx })),\n\t\traw(seriesNameRef(obj, sheet)),\n\t\traw(spPr),\n\t\traw(catValRefs(obj, opts, valFmtCode, sheet, { multiLevel: false })),\n\t])\n}\n\n/**\n * Plot a surface chart into a `<c:surface3DChart>` (3-D) or `<c:surfaceChart>` (2-D contour). Every\n * series shares the category axis; the series axis (Z) is the third axis. `valAxisId`/`catAxisId`\n * are the primary ids passed by the dispatch; the series axis uses `AXIS_ID_SERIES_PRIMARY`.\n */\nexport const makeSurfacePlot: PlotBuilder = (chartType, data, opts, valAxisId, catAxisId, valFmtCode, sheet) => {\n\tconst tag = isSurface3D(opts) ? 'surface3DChart' : 'surfaceChart'\n\tconst chartColors = resolveChartPalette(opts)\n\t// The palette counts this plot's own series from 0, where `<c:idx>` counts rows across the chart;\n\t// the two agree on a surface chart of its own.\n\tconst sers = data\n\t\t.map((obj, idx) =>\n\t\t\tmakeSurfaceSer(chartType, obj, opts, valFmtCode, paletteColor(chartColors, idx, '4472C4'), sheet)\n\t\t)\n\t\t.join('')\n\treturn el(`c:${tag}`, null, [\n\t\traw(voidEl('c:wireframe', { val: xsdBool(opts.surfaceWireframe) })),\n\t\traw(sers),\n\t\t// Surface, value and series axes (category X, value Y/height, series Z).\n\t\traw(voidEl('c:axId', { val: catAxisId })),\n\t\traw(voidEl('c:axId', { val: valAxisId })),\n\t\traw(voidEl('c:axId', { val: AXIS_ID_SERIES_PRIMARY })),\n\t])\n}\n\n/**\n * Build the `<c:view3D>` + floor/side/back walls for a surface chart. A 3-D surface tilts the scene\n * (using the shared `v3DRotX`/`v3DRotY` options, which the define layer defaults to 30); a 2-D\n * contour looks straight down the value axis (rotX 90, flat perspective). These precede\n * `<c:plotArea>` in CT_Chart document order (view3D → floor → sideWall → backWall → plotArea).\n */\nexport function makeSurfaceScene(opts: ChartOptsInternal): string {\n\tconst wall =\n\t\tvoidEl('c:thickness', { val: 0 }) +\n\t\tel('c:spPr', null, [\n\t\t\traw(voidEl('a:noFill')),\n\t\t\traw(el('a:ln', null, raw(voidEl('a:noFill')))),\n\t\t\traw(voidEl('a:effectLst')),\n\t\t\traw(voidEl('a:sp3d')),\n\t\t])\n\tconst scene = isSurface3D(opts)\n\t\t? [\n\t\t\t\traw(voidEl('c:rotX', { val: opts.v3DRotX })),\n\t\t\t\traw(voidEl('c:rotY', { val: opts.v3DRotY })),\n\t\t\t\traw(voidEl('c:rAngAx', { val: 0 })),\n\t\t\t]\n\t\t: // Contour / top view: look straight down the value axis, flat perspective.\n\t\t\t[\n\t\t\t\traw(voidEl('c:rotX', { val: 90 })),\n\t\t\t\traw(voidEl('c:rotY', { val: 0 })),\n\t\t\t\traw(voidEl('c:rAngAx', { val: 0 })),\n\t\t\t\traw(voidEl('c:perspective', { val: 0 })),\n\t\t\t]\n\treturn (\n\t\tel('c:view3D', null, scene) +\n\t\tel('c:floor', null, raw(wall)) +\n\t\tel('c:sideWall', null, raw(wall)) +\n\t\tel('c:backWall', null, raw(wall))\n\t)\n}\n","/**\n * ts-pptx: Chart DrawingML Assembly\n *\n * Builds a chart's `ppt/charts/chartN.xml` -- the `<c:chartSpace>` DrawingML that\n * PowerPoint renders. `makeXmlCharts` assembles the top-level envelope (header, plot\n * area, axes region, legend, metadata) and `makeChartType` dispatches the plot itself to\n * the per-family builder: {@link ./plot-cat-axis} for area/bar/bar3D/line/radar,\n * {@link ./plot-scatter}, {@link ./plot-bubble}, {@link ./plot-pie}. Axes come from\n * {@link ./chart-axes} and the shared leaf fragments from {@link ./chart-parts}.\n *\n * Every function in this directory is a pure string builder -- no I/O, no mutation of\n * the presentation model. The `<c:f>` series formulas here point back at the cells\n * written by the embedded workbook ({@link ./embed-xlsx}); that mapping lives in\n * {@link ./data-refs}.\n */\n\nimport { asChartType, ChartType } from '../../enums.js'\nimport {\n\tAXIS_ID_CATEGORY_PRIMARY,\n\tAXIS_ID_CATEGORY_SECONDARY,\n\tAXIS_ID_SERIES_PRIMARY,\n\tAXIS_ID_VALUE_PRIMARY,\n\tAXIS_ID_VALUE_SECONDARY,\n\tDEF_FONT_SIZE,\n\tDEF_FONT_TITLE_SIZE,\n\tXML_DECL,\n} from '../../constants-internal.js'\nimport type {\n\tChartMultiInternal,\n\tChartOptsInternal,\n\tChartOptsOverrides,\n\tOptsChartDataInternal,\n\tSlideRelChart,\n} from '../../types/internal.js'\nimport type { BorderProps, FillOption } from '../../types/index.js'\nimport { warn } from '../../diagnostics.js'\nimport { clampFontSizeSz } from '../drawingml/clamp.js'\nimport { namedColorOr } from '../drawingml/color.js'\nimport { genXmlColorSelection } from '../drawingml/fill.js'\nimport { borderLine, noStrokeLine } from '../drawingml/line.js'\n\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport { createChartTextFonts, dimmedTextFill, dimmedTextLine, genXmlTitle } from './chart-parts.js'\nimport { type WorksheetLayout, worksheetLayout } from './data-refs.js'\nimport { makeCatAxis, makeSerAxis, makeValAxis } from './chart-axes.js'\nimport { makeCatAxisPlot } from './plot-cat-axis.js'\nimport { makeScatterPlot } from './plot-scatter.js'\nimport { makeBubblePlot } from './plot-bubble.js'\nimport { makePiePlot } from './plot-pie.js'\nimport { isVolumeStockStyle, makeStockPlot } from './plot-stock.js'\nimport { makeSurfacePlot, makeSurfaceScene } from './plot-surface.js'\nimport { InternalError, InvalidOptionError } from '../../errors.js'\nimport { isScatterChart, isXyChart } from './chart-kind.js'\nimport { OOXML_NS } from '../../ooxml/namespaces.js'\nimport { xsdBool } from '../../ooxml/xsd-boolean.js'\n\n/** The three namespaces every `<c:chartSpace>` declares, in the order PowerPoint writes them. */\nconst CHART_SPACE_NS = {\n\t'xmlns:c': OOXML_NS.c,\n\t'xmlns:a': OOXML_NS.a,\n\t'xmlns:r': OOXML_NS.r,\n}\n\n/**\n * Whether a chart-area/plot-area `fill` says anything the fill dispatch can act on.\n *\n * `c:spPr` is `a:CT_ShapeProperties` — the same optional `EG_FillProperties` group the\n * shape path writes into — so gradient, pattern and an omitted fill child are all legal\n * here. The gate used to be `fill?.color`, which meant every spelling carrying no colour\n * (`gradient`, `pattern`, `image`, `inherit`) fell to the no-fill arm and did nothing.\n *\n * The gate cannot simply be `fill != null`. `normalizeChartOptions` defaults\n * `plotArea.fill` to `{}`, so every chart in existence arrives here with a fill object,\n * and a presence check would paint each one a default grey. The same is true of the one\n * input a caller can write by hand: `{ transparency: 50 }` alone is not a fill, since\n * there is no colour for the alpha to apply to. Both stay no-fill.\n *\n * A payload with no `type` (`{ gradient }`, `{ pattern }`) is likewise not stated, which\n * matches the shape path: only `line` infers its type from a bare `gradient`, fills have\n * always wanted `type: 'gradient'` spelled out.\n *\n * A bare {@link Color} string is stated — it is the solid-colour shorthand every other fill\n * site takes. This one used to be the exception: the string reached here having already been\n * spread into `{0:'F',1:'F',…}` by `copyChartOptions`, so it named neither `color` nor `type`\n * and a chart area asked for `fill: 'FF0000'` came out `<a:noFill/>`.\n */\nfunction isStatedFill(fill?: FillOption): fill is FillOption {\n\tif (typeof fill === 'string') return fill.length > 0\n\treturn Boolean(fill?.color || fill?.type)\n}\n\n/**\n * Resolve one combo subchart's overrides against the chart-level options.\n *\n * The override bag carries a third state the rest of the generator does not: a *present*\n * `undefined`, meaning \"this subchart's own value was rejected, so emit nothing here\", as against\n * an absent key, which inherits the chart-level value (see {@link ChartOptsOverrides}). The spread\n * is what applies that distinction — and once it has, the keys still holding `undefined` have said\n * everything they had to say, so they are dropped. What the plot builders receive is an ordinary\n * options bag with one spelling of absent.\n * @param chartOptions - the chart-level options, already normalized\n * @param overrides - this subchart's vetted overrides\n */\nfunction resolveSubchartOptions(chartOptions: ChartOptsInternal, overrides: ChartOptsOverrides): ChartOptsInternal {\n\tconst merged: Record<string, unknown> = { ...chartOptions, ...overrides }\n\tfor (const key of Object.keys(merged)) {\n\t\tif (merged[key] === undefined) delete merged[key]\n\t}\n\treturn merged\n}\n\n/**\n * The chart title (or the `autoTitleDeleted` flag that suppresses PowerPoint's default one)\n * followed by the 3-D scene, for the two families that plot into one.\n */\nfunction makeChartHeaderXml(rel: SlideRelChart): string {\n\t// NOTE: `autoTitleDeleted` is emitted in both arms — without it PowerPoint creates a default\n\t// chart title even when `showTitle` is false.\n\tconst title = rel.opts.showTitle\n\t\t? genXmlTitle(\n\t\t\t\t{\n\t\t\t\t\ttitle: rel.opts.title || 'Chart Title',\n\t\t\t\t\tcolor: rel.opts.titleColor,\n\t\t\t\t\tfontFace: rel.opts.titleFontFace,\n\t\t\t\t\tfontSize: rel.opts.titleFontSize ?? DEF_FONT_TITLE_SIZE,\n\t\t\t\t\ttitleAlign: rel.opts.titleAlign,\n\t\t\t\t\ttitleBold: rel.opts.titleBold,\n\t\t\t\t\ttitleItalic: rel.opts.titleItalic,\n\t\t\t\t\ttitleUnderline: rel.opts.titleUnderline,\n\t\t\t\t\ttitlePos: rel.opts.titlePos,\n\t\t\t\t\ttitleRotate: rel.opts.titleRotate,\n\t\t\t\t},\n\t\t\t\trel.opts.x,\n\t\t\t\trel.opts.y\n\t\t\t) + voidEl('c:autoTitleDeleted', { val: 0 })\n\t\t: voidEl('c:autoTitleDeleted', { val: 1 })\n\t// 3-D view: https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_perspective_topic_ID0E6BUQB.html\n\tif (rel.opts._type === ChartType.bar3d) {\n\t\treturn (\n\t\t\ttitle +\n\t\t\tel('c:view3D', null, [\n\t\t\t\traw(voidEl('c:rotX', { val: rel.opts.v3DRotX })),\n\t\t\t\traw(voidEl('c:rotY', { val: rel.opts.v3DRotY })),\n\t\t\t\traw(voidEl('c:rAngAx', { val: !rel.opts.v3DRAngAx ? 0 : 1 })),\n\t\t\t\traw(voidEl('c:perspective', { val: rel.opts.v3DPerspective })),\n\t\t\t])\n\t\t)\n\t}\n\t// A surface chart is a 3-D scene: view3D + floor/side/back walls precede the plotArea.\n\tif (rel.opts._type === ChartType.surface) return title + makeSurfaceScene(rel.opts)\n\treturn title\n}\n\n/**\n * The plot area's `<c:layout>`. Manual layout is emitted only when the caller asked for one:\n * an empty `<c:layout/>` lets PowerPoint auto-fit, which it does well across all four TRBL\n * legend positions.\n */\nfunction makePlotAreaLayoutXml(rel: SlideRelChart): string {\n\tconst layout = rel.opts.layout\n\tif (!layout) return voidEl('c:layout')\n\tconst manualLayout = el('c:manualLayout', null, [\n\t\t// Every space here sits before `/>`, INSIDE the tag rather than between elements, so\n\t\t// flattening the chart emitters did not take it, and it stays. `prove-whitespace` freezes\n\t\t// intra-tag whitespace, and reported these when the flattening codemod first took them,\n\t\t// which is the whole reason it looks at them.\n\t\traw(voidEl('c:layoutTarget', { val: 'inner' }, { closePrefix: ' ' })),\n\t\traw(voidEl('c:xMode', { val: 'edge' }, { closePrefix: ' ' })),\n\t\traw(voidEl('c:yMode', { val: 'edge' }, { closePrefix: ' ' })),\n\t\t// `??` and not `||`: the define layer has already deleted every value outside the range\n\t\t// each key allows -- `x`/`y` take 0, `w`/`h` do not -- so what survives to here is either\n\t\t// absent or meant, and `||` would have turned a stated `w: 0` into a full-bleed plot area.\n\t\traw(voidEl('c:x', { val: layout.x ?? 0 }, { closePrefix: ' ' })),\n\t\traw(voidEl('c:y', { val: layout.y ?? 0 }, { closePrefix: ' ' })),\n\t\traw(voidEl('c:w', { val: layout.w ?? 1 }, { closePrefix: ' ' })),\n\t\traw(voidEl('c:h', { val: layout.h ?? 1 }, { closePrefix: ' ' })),\n\t])\n\treturn el('c:layout', null, raw(manualLayout))\n}\n\n/** What one of a combo chart's two category axes has to be, decided by the subcharts using it. */\ninterface ComboCatAxis {\n\t/**\n\t * The scatter/bubble subchart type that owns this axis, or `null` when none does.\n\t *\n\t * A scatter/bubble subchart draws numbers on its category (X) axis, so that axis has to be\n\t * emitted as a `<c:valAx>` rather than a `<c:catAx>` or PowerPoint flags the file for repair.\n\t */\n\txyType: ChartType | null\n\t/** Whether a category-based subchart also references this axis - unsatisfiable together with {@link xyType}. */\n\thasCategoryChart: boolean\n}\n\n/** Which axes a combo chart needs, and what each of its category axes has to be. */\ninterface ComboAxisPlan {\n\t/** Whether any subchart plots on the secondary axis pair, so both secondary axes are emitted. */\n\tsecondary: boolean\n\t/** Whether a subchart asked for the secondary value axis. When none did, that axis is hidden. */\n\tsecondaryVal: boolean\n\t/** Whether a subchart asked for the secondary category axis. When none did, that axis is hidden. */\n\tsecondaryCat: boolean\n\tcat: Record<'primary' | 'secondary', ComboCatAxis>\n}\n\n/**\n * Whether a subchart plots on the secondary axis pair: it asked for the secondary value axis, the\n * secondary category axis, or both.\n *\n * A plot group has to reference a category axis and a value axis that cross each other, so one\n * flag moves the subchart onto both secondary axes. A line on the primary category axis and the\n * secondary value axis was refused by PowerPoint as corrupt (0x80070570), whether or not a\n * secondary category axis was also emitted; on the secondary pair it opens.\n * @param options - the subchart's merged options\n */\nconst plotsOnSecondaryAxes = (options: ChartOptsInternal): boolean =>\n\tBoolean(options.secondaryValAxis || options.secondaryCatAxis)\n\n/**\n * Read a combo chart's subcharts for what its axes have to be.\n *\n * Pure, and separate from the plot walk on purpose: these six facts used to be six `let`\n * bindings the walk mutated as it emitted, so \"build the plots\" was also secretly computing the\n * axis plan, and they then reached `makeChartAxesXml` as six positional parameters that it\n * re-paired by hand into exactly this record.\n * @param chartOptions - the chart-level options each subchart's overrides are merged over\n * @param types - the combo's subcharts, or `undefined` for a single-type chart\n */\nfunction planComboAxes(chartOptions: ChartOptsInternal, types: ChartMultiInternal[] | undefined): ComboAxisPlan {\n\tconst plan: ComboAxisPlan = {\n\t\tsecondary: false,\n\t\tsecondaryVal: false,\n\t\tsecondaryCat: false,\n\t\tcat: {\n\t\t\tprimary: { xyType: null, hasCategoryChart: false },\n\t\t\tsecondary: { xyType: null, hasCategoryChart: false },\n\t\t},\n\t}\n\tfor (const type of types ?? []) {\n\t\t// The MERGED options, exactly as the plot walk resolves them: a subchart that states\n\t\t// neither flag inherits the chart-level one, and the axis ids it plots against follow that.\n\t\tconst options = resolveSubchartOptions(chartOptions, type.options)\n\t\tconst secondary = plotsOnSecondaryAxes(options)\n\t\tplan.secondary = plan.secondary || secondary\n\t\tplan.secondaryVal = plan.secondaryVal || Boolean(options.secondaryValAxis)\n\t\tplan.secondaryCat = plan.secondaryCat || Boolean(options.secondaryCatAxis)\n\t\tconst axis = plan.cat[secondary ? 'secondary' : 'primary']\n\t\tconst subType = asChartType(type.type)\n\t\tif (isXyChart(subType)) axis.xyType = subType\n\t\telse axis.hasCategoryChart = true\n\t}\n\treturn plan\n}\n\n/**\n * Build the category/value/series axis XML (empty for pie/doughnut). Resolves combo-chart\n * category axes to val axes when owned by a scatter/bubble subchart, per {@link planComboAxes}.\n */\nfunction makeChartAxesXml(rel: SlideRelChart, plan: ComboAxisPlan): string {\n\tlet strXml = ''\n\t// Stock charts drive their own (date/category)+value axis pair. The non-volume styles use just\n\t// the primary pair (the generic path below would also produce it), but the volume styles add a\n\t// secondary pair for the price series (the volume bar owns the primary pair) — so route all stock\n\t// axes here, reusing the shared cat/val emitters. `barDir` defaults to 'col' in the define layer,\n\t// which already gives the correct axis positions (category at bottom, value at left).\n\tif (rel.opts._type === ChartType.stock) {\n\t\tlet stockXml = makeCatAxis(rel.opts, AXIS_ID_CATEGORY_PRIMARY, AXIS_ID_VALUE_PRIMARY)\n\t\tstockXml += makeValAxis(rel.opts, AXIS_ID_VALUE_PRIMARY)\n\t\tif (isVolumeStockStyle(rel.opts.stockStyle)) {\n\t\t\t// Secondary value axis (right) for the price series, then a hidden secondary category axis.\n\t\t\tstockXml += makeValAxis(rel.opts, AXIS_ID_VALUE_SECONDARY)\n\t\t\tstockXml += makeCatAxis({ ...rel.opts, catAxisHidden: true }, AXIS_ID_CATEGORY_SECONDARY, AXIS_ID_VALUE_SECONDARY)\n\t\t}\n\t\treturn stockXml\n\t}\n\tif (rel.opts._type !== ChartType.pie && rel.opts._type !== ChartType.doughnut) {\n\t\t// Param check\n\t\tif (rel.opts.valAxes && rel.opts.valAxes.length > 1 && !plan.secondary) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'chart/secondary-axis-unused',\n\t\t\t\t'Secondary axis must be used by one of the multiple charts'\n\t\t\t)\n\t\t}\n\n\t\t// Resolve the effective `_type` for a combo category axis so scatter/bubble\n\t\t// subcharts get a `<c:valAx>` X axis. Returns the scatter/bubble type when\n\t\t// that axis is owned only by such a subchart, else null (category axis).\n\t\tconst comboCatAxisType = (isSecondary: boolean): { _type: ChartType } | Record<string, never> => {\n\t\t\tconst { xyType: valType, hasCategoryChart } = plan.cat[isSecondary ? 'secondary' : 'primary']\n\t\t\tif (!valType) return {}\n\t\t\tif (hasCategoryChart) {\n\t\t\t\t// A category-based chart and a scatter/bubble chart cannot share one\n\t\t\t\t// axis (one needs <c:catAx>, the other <c:valAx>). Keep the category\n\t\t\t\t// axis and warn rather than silently emit a repair-triggering file.\n\t\t\t\twarn(\n\t\t\t\t\t'chart/axis-type-conflict',\n\t\t\t\t\t`A category-based chart and a scatter/bubble chart cannot share the same ${isSecondary ? 'secondary' : 'primary'} category axis; emitting a category axis. Put the scatter/bubble series on a separate axis.`\n\t\t\t\t)\n\t\t\t\treturn {}\n\t\t\t}\n\t\t\treturn { _type: valType }\n\t\t}\n\n\t\tif (rel.opts.catAxes && (!rel.opts.valAxes || rel.opts.valAxes.length !== rel.opts.catAxes.length)) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'chart/axis-count-mismatch',\n\t\t\t\t'There must be the same number of value and category axes.'\n\t\t\t)\n\t\t}\n\n\t\t// What the plots reference comes first, and the `catAxes[i]`/`valAxes[i]` overrides apply to\n\t\t// it. The overrides used to decide which axes existed: with `valAxes` set, the series axis of\n\t\t// a 3-D bar or surface chart and the secondary value axis a `secondaryValAxis` subchart\n\t\t// plots on were never emitted, and the plot referenced ids no axis carried.\n\t\tconst catOverride = (idx: number) => rel.opts.catAxes?.[idx]\n\t\tconst valOverride = (idx: number) => rel.opts.valAxes?.[idx]\n\t\tconst overrideCount = rel.opts.valAxes?.length ?? 0\n\t\tif (overrideCount > 2) {\n\t\t\twarn(\n\t\t\t\t'chart/option-not-supported',\n\t\t\t\t`\"valAxes\" and \"catAxes\" have ${overrideCount} entries, but a chart has one primary and one secondary axis of each kind; the entries past the second are ignored.`\n\t\t\t)\n\t\t}\n\n\t\tstrXml += makeCatAxis(\n\t\t\t{ ...rel.opts, ...catOverride(0), ...comboCatAxisType(false) },\n\t\t\tAXIS_ID_CATEGORY_PRIMARY,\n\t\t\tAXIS_ID_VALUE_PRIMARY\n\t\t)\n\t\tstrXml += makeValAxis({ ...rel.opts, ...valOverride(0) }, AXIS_ID_VALUE_PRIMARY)\n\n\t\t// 3D bar and surface plot over a category × series grid.\n\t\tif (rel.opts._type === ChartType.bar3d || rel.opts._type === ChartType.surface) {\n\t\t\tstrXml += makeSerAxis(rel.opts, AXIS_ID_SERIES_PRIMARY, AXIS_ID_VALUE_PRIMARY)\n\t\t}\n\n\t\t// A subchart on either secondary axis plots on both, so both are emitted, and the one no\n\t\t// subchart asked for is hidden: the arrangement PowerPoint gives a series moved to its\n\t\t// secondary axis. An override can still show it.\n\t\tif (plan.secondary) {\n\t\t\tstrXml += makeValAxis(\n\t\t\t\t{ ...rel.opts, ...(plan.secondaryVal ? {} : { valAxisHidden: true }), ...valOverride(1) },\n\t\t\t\tAXIS_ID_VALUE_SECONDARY\n\t\t\t)\n\t\t\tstrXml += makeCatAxis(\n\t\t\t\t{\n\t\t\t\t\t...rel.opts,\n\t\t\t\t\t...(plan.secondaryCat ? {} : { catAxisHidden: true }),\n\t\t\t\t\t...catOverride(1),\n\t\t\t\t\t...comboCatAxisType(true),\n\t\t\t\t},\n\t\t\t\tAXIS_ID_CATEGORY_SECONDARY,\n\t\t\t\tAXIS_ID_VALUE_SECONDARY\n\t\t\t)\n\t\t}\n\t}\n\treturn strXml\n}\n\n/**\n * The `<c:spPr>` shared by the plot area and the chart space: a stated fill or none, a border\n * or an explicit no-line, and an empty effect list.\n *\n * The lightest of the four `BorderProps` strokes: paint only, with neither the `a:prstDash`\n * nor the `a:round` its siblings write. It also branches on the border being *absent* rather\n * than on `type: 'none'` — the caller here has an optional border where\n * `createChartBorderLine` (`gen/chart/chart-parts.ts`) has a resolved one.\n */\nfunction chartShapeProps(fill: FillOption | undefined, border: BorderProps | undefined): string {\n\treturn el('c:spPr', null, [\n\t\traw(isStatedFill(fill) ? genXmlColorSelection(fill) : voidEl('a:noFill')),\n\t\traw(\n\t\t\tborder\n\t\t\t\t? borderLine('a:ln', border, {\n\t\t\t\t\t\tdefaultWidth: 1,\n\t\t\t\t\t\tdefaultColor: '363636',\n\t\t\t\t\t\tcap: 'flat',\n\t\t\t\t\t\tdash: null,\n\t\t\t\t\t\ttail: [],\n\t\t\t\t\t})\n\t\t\t\t: noStrokeLine()\n\t\t),\n\t\traw(voidEl('a:effectLst', null)),\n\t])\n}\n\n/**\n * The `<c:dTable>` grid drawn under the plot. Sits between the last `</c:valAx>` and the plot\n * area's own `<c:spPr>`.\n */\nfunction makeDataTableXml(rel: SlideRelChart): string {\n\tconst spPr = el('c:spPr', null, [\n\t\traw(voidEl('a:noFill', null)),\n\t\traw(dimmedTextLine(15000, 85000)),\n\t\traw(voidEl('a:effectLst', null)),\n\t])\n\tconst defRPr = el(\n\t\t'a:defRPr',\n\t\t{\n\t\t\tsz: clampFontSizeSz(rel.opts.dataTableFontSize ?? DEF_FONT_SIZE, 'dataTableFontSize'),\n\t\t\tb: 0,\n\t\t\ti: 0,\n\t\t\tu: 'none',\n\t\t\tstrike: 'noStrike',\n\t\t\tkern: 1200,\n\t\t\tbaseline: 0,\n\t\t},\n\t\t[\n\t\t\traw(dimmedTextFill(65000, 35000)),\n\t\t\traw(voidEl('a:latin', { typeface: '+mn-lt' })),\n\t\t\traw(voidEl('a:ea', { typeface: '+mn-ea' })),\n\t\t\traw(voidEl('a:cs', { typeface: '+mn-cs' })),\n\t\t]\n\t)\n\tconst txPr = el('c:txPr', null, [\n\t\traw(\n\t\t\tvoidEl('a:bodyPr', {\n\t\t\t\trot: 0,\n\t\t\t\tspcFirstLastPara: 1,\n\t\t\t\tvertOverflow: 'ellipsis',\n\t\t\t\tvert: 'horz',\n\t\t\t\twrap: 'square',\n\t\t\t\tanchor: 'ctr',\n\t\t\t\tanchorCtr: 1,\n\t\t\t})\n\t\t),\n\t\traw(voidEl('a:lstStyle', null)),\n\t\traw(el('a:p', null, [raw(el('a:pPr', { rtl: 0 }, raw(defRPr))), raw(voidEl('a:endParaRPr', { lang: 'en-US' }))])),\n\t])\n\treturn el('c:dTable', null, [\n\t\traw(voidEl('c:showHorzBorder', { val: !rel.opts.showDataTableHorzBorder ? 0 : 1 })),\n\t\traw(voidEl('c:showVertBorder', { val: !rel.opts.showDataTableVertBorder ? 0 : 1 })),\n\t\t// These two `val` attributes were written padded into a column with the two above, and that\n\t\t// padding is emitted bytes. `el()` writes exactly one space before an attribute, by design,\n\t\t// so the aligned pair stays hand-written rather than bending the builder around a cosmetic\n\t\t// quirk. Removing the padding is an output change, not a cleanup; the ratchet header says why.\n\t\traw(` <c:showOutline val=\"${!rel.opts.showDataTableOutline ? 0 : 1}\"/>`),\n\t\traw(` <c:showKeys val=\"${!rel.opts.showDataTableKeys ? 0 : 1}\"/>`),\n\t\traw(spPr),\n\t\traw(txPr),\n\t])\n}\n\n/**\n * Where each chart type sits in the order a combo chart's legend lists its series, once the\n * subcharts are on different axis groups. Lower is listed first, and an equal rank is a real tie.\n *\n * Measured off PowerPoint renders, every ordered pair in both directions, by\n * `test/read/fixtures/authoring/probe-combo-legend-order.mjs` and its reader. The rank beats the\n * axis group in every pairing: area leads bar even with bar on the primary axis. Line and radar\n * tie -- both orderings of that pair listed the *other* subchart first, which is not a rank -- and\n * the tie is broken by the axis group below.\n *\n * Bubble is absent because it cannot be in a combo at all: `addChart` refuses it, citing\n * PowerPoint, so there is no pairing to rank.\n */\nconst LEGEND_TYPE_RANK: ReadonlyMap<ChartType, number> = new Map([\n\t[ChartType.area, 0],\n\t[ChartType.bar, 1],\n\t[ChartType.line, 2],\n\t[ChartType.radar, 2],\n\t[ChartType.scatter, 3],\n])\n\n/**\n * A combo chart's subcharts in the order its legend lists their series.\n *\n * Read off PowerPoint renders (`test/read/fixtures/authoring/probe-combo-legend-order.mjs`). On one\n * axis group the legend follows the order the subcharts are given in, which is plotArea order. Once\n * they sit on different axis groups it reorders by chart type ({@link LEGEND_TYPE_RANK}), and two\n * subcharts of equal rank are listed primary axis group first, whatever order they were given in.\n *\n * A type the rank does not name sorts last and keeps its given order among its peers, which is\n * where an unmeasured sixth type would land. The sort is stable, so that is the old behaviour for\n * anything the probe has not reached.\n */\nfunction legendOrder(chartOptions: ChartOptsInternal, types: ChartMultiInternal[]): ChartMultiInternal[] {\n\tconst secondary = types.map((type) => plotsOnSecondaryAxes(resolveSubchartOptions(chartOptions, type.options)))\n\tif (secondary.every((onSecondary) => onSecondary === secondary[0])) return types\n\tconst rankOf = (type: ChartMultiInternal): number =>\n\t\tLEGEND_TYPE_RANK.get(asChartType(type.type)) ?? LEGEND_TYPE_RANK.size\n\t// `map` to indices and sort those: `Array.prototype.sort` is stable, and the index keeps the\n\t// given order as the last tiebreak without relying on that.\n\treturn types\n\t\t.map((type, index) => ({ type, index, rank: rankOf(type), onSecondary: secondary[index] === true }))\n\t\t.sort((a, b) => a.rank - b.rank || Number(a.onSecondary) - Number(b.onSecondary) || a.index - b.index)\n\t\t.map((entry) => entry.type)\n}\n\n/**\n * The `<c:legend>`: position, the entries a combo chart deletes, an optional manual placement,\n * and the text properties when any legend font option is set.\n */\nfunction makeLegendXml(rel: SlideRelChart): string {\n\t// For combo charts: delete the legend entries of the series whose subchart sets `showLegend: false`.\n\t// `c:legendEntry/c:idx` is the entry's position in the legend, not the series' `c:idx`: PowerPoint,\n\t// deleting the first entry of a legend that lists series 1, 2 and 0, writes idx 0\n\t// (`test/read/fixtures/chart-legend-entry.pptx`). A scatter's or bubble's X row is not a series and\n\t// holds no entry.\n\tlet entries = ''\n\tif (Array.isArray(rel.opts._type)) {\n\t\tlet position = 0\n\t\tfor (const type of legendOrder(rel.opts, rel.opts._type)) {\n\t\t\tconst seriesCount = isXyChart(asChartType(type.type)) ? Math.max(0, type.data.length - 1) : type.data.length\n\t\t\tfor (let i = 0; i < seriesCount; i++, position++) {\n\t\t\t\tif (type.options?.showLegend !== false) continue\n\t\t\t\tentries += el('c:legendEntry', null, [\n\t\t\t\t\traw(voidEl('c:idx', { val: position })),\n\t\t\t\t\traw(voidEl('c:delete', { val: 1 })),\n\t\t\t\t])\n\t\t\t}\n\t\t}\n\t}\n\n\t// Manual legend placement. Each axis of CT_ManualLayout is independent: omitting xMode/x (or\n\t// yMode/y, etc.) leaves that axis on automatic layout. x/y use edge mode so they are absolute\n\t// fractions of the chart; w/h are fractions of the chart size. Schema order: xMode, yMode, x, y, w, h.\n\tconst legendLayout = rel.opts.legendLayout\n\tconst placed = (key: 'x' | 'y' | 'w' | 'h'): boolean => typeof legendLayout?.[key] === 'number'\n\tlet layout = ''\n\tif (placed('x') || placed('y') || placed('w') || placed('h')) {\n\t\tconst modes =\n\t\t\t(placed('x') ? voidEl('c:xMode', { val: 'edge' }) : '') + (placed('y') ? voidEl('c:yMode', { val: 'edge' }) : '')\n\t\tconst vals = (['x', 'y', 'w', 'h'] as const)\n\t\t\t.filter(placed)\n\t\t\t.map((key) => voidEl(`c:${key}`, { val: legendLayout?.[key] }))\n\t\t\t.join('')\n\t\tlayout = el('c:layout', null, raw(el('c:manualLayout', null, raw(modes + vals))))\n\t}\n\n\tlet txPr = ''\n\t// `!= null` for the size, not truthiness: `legendFontSize: 0` is a stated size, and it clamps to\n\t// the ST_TextFontSize minimum with a warning the way `dataTableFontSize: 0` does, instead of\n\t// being dropped without one.\n\tconst legendFontSize = rel.opts.legendFontSize\n\tif (rel.opts.legendFontFace || legendFontSize != null || rel.opts.legendColor) {\n\t\t// No `Number()` here, and none at the ten sibling font-size options either: the\n\t\t// option is typed `number`, and a caller from untyped JS who passes a string now\n\t\t// gets `coord/non-finite` from the converter rather than a silent coercion.\n\t\tconst defRPr = el(\n\t\t\t'a:defRPr',\n\t\t\t{ sz: legendFontSize != null ? clampFontSizeSz(legendFontSize, 'legendFontSize') : undefined },\n\t\t\t[\n\t\t\t\traw(genXmlColorSelection(namedColorOr(rel.opts.legendColor, undefined, 'legendColor'))),\n\t\t\t\traw(rel.opts.legendFontFace ? createChartTextFonts(rel.opts.legendFontFace) : ''),\n\t\t\t]\n\t\t)\n\t\ttxPr = el('c:txPr', null, [\n\t\t\traw(voidEl('a:bodyPr', null)),\n\t\t\traw(voidEl('a:lstStyle', null)),\n\t\t\traw(el('a:p', null, [raw(el('a:pPr', null, raw(defRPr))), raw(voidEl('a:endParaRPr', { lang: 'en-US' }))])),\n\t\t])\n\t}\n\n\treturn el('c:legend', null, [\n\t\traw(voidEl('c:legendPos', { val: rel.opts.legendPos })),\n\t\traw(entries),\n\t\traw(layout),\n\t\traw(voidEl('c:overlay', { val: 0 })),\n\t\traw(txPr),\n\t])\n}\n\n/**\n * Main entry point method for create charts\n * @see: http://www.datypic.com/sc/ooxml/s-dml-chart.xsd.html\n * @param {SlideRelChart} rel - chart object\n * @return {string} XML\n */\nexport function makeXmlCharts(rel: SlideRelChart): string {\n\t// `chartArea`/`plotArea` are always populated by addChartDefinition() but stay optional on the type.\n\tconst chartArea = rel.opts.chartArea ?? {}\n\tconst plotAreaOpts = rel.opts.plotArea ?? {}\n\t// STEP 1: what the axes have to be, read off the subcharts before anything is emitted.\n\tconst plan = planComboAxes(rel.opts, Array.isArray(rel.opts._type) ? rel.opts._type : undefined)\n\n\t// STEP 2: the plot for every subchart's series and points. The worksheet layout is a fact\n\t// about the WHOLE chart -- one workbook is written from `rel.data` -- so it is resolved once\n\t// here and handed down; a combo subchart sees only its own slice of the series and could not\n\t// derive it.\n\tconst sheet = worksheetLayout(rel)\n\tlet plots = ''\n\tif (Array.isArray(rel.opts._type)) {\n\t\tfor (const type of rel.opts._type) {\n\t\t\tconst options = resolveSubchartOptions(rel.opts, type.options)\n\t\t\tconst secondary = plotsOnSecondaryAxes(options)\n\t\t\tconst valAxisId = secondary ? AXIS_ID_VALUE_SECONDARY : AXIS_ID_VALUE_PRIMARY\n\t\t\tconst catAxisId = secondary ? AXIS_ID_CATEGORY_SECONDARY : AXIS_ID_CATEGORY_PRIMARY\n\t\t\tplots += makeChartType(asChartType(type.type), type.data, options, valAxisId, catAxisId, sheet)\n\t\t}\n\t} else if (rel.opts._type) {\n\t\tplots = makeChartType(rel.opts._type, rel.data, rel.opts, AXIS_ID_VALUE_PRIMARY, AXIS_ID_CATEGORY_PRIMARY, sheet)\n\t}\n\n\t// STEP 3: the axes the plots just referenced.\n\tconst axes = makeChartAxesXml(rel, plan)\n\n\t// STEP 4: the plot area, then the chart it sits in.\n\tconst plotArea = el('c:plotArea', null, [\n\t\traw(makePlotAreaLayoutXml(rel)),\n\t\traw(plots),\n\t\traw(axes),\n\t\t// NOTE: the data table goes between `</c:valAx>` and `<c:spPr>`.\n\t\trel.opts.showDataTable ? raw(makeDataTableXml(rel)) : null,\n\t\traw(chartShapeProps(plotAreaOpts.fill, plotAreaOpts.border)),\n\t])\n\tconst chart = el('c:chart', null, [\n\t\traw(makeChartHeaderXml(rel)),\n\t\traw(plotArea),\n\t\trel.opts.showLegend ? raw(makeLegendXml(rel)) : null,\n\t\traw(voidEl('c:plotVisOnly', { val: 1 })),\n\t\traw(voidEl('c:dispBlanksAs', { val: rel.opts.displayBlanksAs })),\n\t\tisScatterChart(rel.opts._type) ? raw(voidEl('c:showDLblsOverMax', { val: 1 })) : null,\n\t])\n\n\t// STEP 4: the chart space around it — shape props, the embedded workbook relationship, and\n\t// the metadata extension (CT_ChartSpace order: externalData → printSettings → userShapes → extLst).\n\treturn (\n\t\tXML_DECL +\n\t\tel('c:chartSpace', CHART_SPACE_NS, [\n\t\t\t// PowerPoint defaults to 1904 dates, Excel to 1900.\n\t\t\traw(voidEl('c:date1904', { val: 0 })),\n\t\t\traw(voidEl('c:roundedCorners', { val: xsdBool(chartArea.roundedCorners) })),\n\t\t\traw(chart),\n\t\t\traw(chartShapeProps(chartArea.fill, chartArea.border)),\n\t\t\traw(el('c:externalData', { 'r:id': 'rId1' }, raw(voidEl('c:autoUpdate', { val: 0 })))),\n\t\t\traw(genXmlChartMetadata(rel.opts.metadata)),\n\t\t])\n\t)\n}\n\n/**\n * Stable ts-pptx vendor GUID identifying the chart-metadata extension on `c:chartSpace/c:extLst`.\n * Custom data rides under this URI in a foreign namespace so PowerPoint preserves it (the extLst\n * mechanism) instead of stripping/repairing it as it would an unrecognised sibling element.\n */\nconst CHART_METADATA_EXT_URI = '{094A432E-1F6C-499B-95B8-B57DC9536949}'\n\n/** Foreign namespace for the chart-metadata extension payload. */\nconst CHART_METADATA_NS = 'http://ts-pptx.com/schema/chart/metadata'\n\n/**\n * Create the chart-space extension-list XML carrying custom `metadata` key/value annotations.\n * Emits nothing when metadata is absent or contains no valid entries. Keys must be non-empty\n * strings and values must be strings; invalid entries are dropped with a warning rather than\n * emitting degenerate XML (per the \"no silent coercion\" policy).\n * @param {Record<string, string>} [metadata] custom chart-level metadata\n * @return {string} `<c:extLst>…</c:extLst>` XML, or '' when there is nothing valid to emit\n */\nfunction genXmlChartMetadata(metadata?: Record<string, string>): string {\n\tif (metadata == null) return ''\n\tif (typeof metadata !== 'object' || Array.isArray(metadata)) {\n\t\twarn('chart/invalid-metadata', 'chart `metadata` must be a plain object of string key/value pairs; ignored.')\n\t\treturn ''\n\t}\n\n\tlet items = ''\n\tfor (const [key, value] of Object.entries(metadata)) {\n\t\tif (typeof key !== 'string' || key.length === 0) {\n\t\t\twarn(\n\t\t\t\t'chart/invalid-metadata-key',\n\t\t\t\t`chart metadata key \"${String(key)}\" is not a non-empty string; entry skipped.`\n\t\t\t)\n\t\t\tcontinue\n\t\t}\n\t\tif (typeof value !== 'string') {\n\t\t\twarn('chart/invalid-metadata-value', `chart metadata value for key \"${key}\" is not a string; entry skipped.`)\n\t\t\tcontinue\n\t\t}\n\t\titems += voidEl('pgm:item', { key, value })\n\t}\n\tif (items === '') return ''\n\n\treturn el(\n\t\t'c:extLst',\n\t\tnull,\n\t\traw(\n\t\t\tel(\n\t\t\t\t'c:ext',\n\t\t\t\t{ uri: CHART_METADATA_EXT_URI },\n\t\t\t\traw(el('pgm:metadata', { 'xmlns:pgm': CHART_METADATA_NS }, raw(items)))\n\t\t\t)\n\t\t)\n\t)\n}\n\n/**\n * Create XML string for any given chart type.\n * Dispatches to a per-family plot helper; resolves the effective value number format first.\n * @param {ChartType} chartType chart type name\n * @param {OptsChartDataInternal[]} data chart data\n * @param {ChartOptsInternal} opts chart options\n * @param {string} valAxisId chart val axis id\n * @param {string} catAxisId chart cat axis id\n * @example 'bubble' returns <c:bubbleChart></c>\n * @example '<c:lineChart>'\n * @return {string} XML chart\n */\n\nfunction makeChartType(\n\tchartType: ChartType,\n\tdata: OptsChartDataInternal[],\n\topts: ChartOptsInternal,\n\tvalAxisId: string,\n\tcatAxisId: string,\n\tsheet: WorksheetLayout\n): string {\n\t// NOTE: \"Chart Range\" (as shown in \"select Chart Area dialog\") is calculated.\n\t// ....: Ensure each X/Y Axis/Col has same row height (esp. applicable to XY Scatter where X can often be larger than Y's)\n\t//\n\t// PowerPoint and Google Slides render values using the cached *source* number format carried in\n\t// each series' `<c:numCache><c:formatCode>` (mirroring the embedded workbook cell format), NOT the\n\t// `<c:dLbls><c:numFmt>` mask, so one effective value format is resolved here and stamped onto\n\t// every value cache below and every dLbls mask, and all three engines agree.\n\t// Precedence keeps the historical `valLabelFormatCode` winner, then the data-table format, then\n\t// `dataLabelFormatCode` — which `normalizeChartOptions` always assigns, defaulting it to `#,##0`,\n\t// so there is no fourth arm: the cache is never left as `General` by this path.\n\tconst valFmtCode = opts.valLabelFormatCode || opts.dataTableFormatCode || opts.dataLabelFormatCode || '#,##0'\n\n\tswitch (chartType) {\n\t\tcase ChartType.area:\n\t\tcase ChartType.bar:\n\t\tcase ChartType.bar3d:\n\t\tcase ChartType.line:\n\t\tcase ChartType.radar:\n\t\t\treturn makeCatAxisPlot(chartType, data, opts, valAxisId, catAxisId, valFmtCode, sheet)\n\t\tcase ChartType.scatter:\n\t\t\treturn makeScatterPlot(chartType, data, opts, valAxisId, catAxisId, valFmtCode, sheet)\n\t\tcase ChartType.bubble:\n\t\tcase ChartType.bubble3d:\n\t\t\treturn makeBubblePlot(chartType, data, opts, valAxisId, catAxisId, valFmtCode, sheet)\n\t\tcase ChartType.stock:\n\t\t\treturn makeStockPlot(chartType, data, opts, valAxisId, catAxisId, valFmtCode, sheet)\n\t\tcase ChartType.surface:\n\t\t\treturn makeSurfacePlot(chartType, data, opts, valAxisId, catAxisId, valFmtCode, sheet)\n\t\tcase ChartType.doughnut:\n\t\tcase ChartType.pie:\n\t\t\treturn makePiePlot(chartType, data, opts, valFmtCode, sheet)\n\t\tdefault:\n\t\t\t// The unmatched members are exactly the chartEx catalog (`CHARTEX_TYPES` in `enums.ts`),\n\t\t\t// which `chartExLayoutId` in `./chartex-xml` owns; callers pick between the two builders\n\t\t\t// with `isChartExType`, so arriving here means the chart was routed to the wrong emitter.\n\t\t\t// Returning `''` here used to hide that: it emitted a `<c:plotArea>` with axes and no plot\n\t\t\t// at all, i.e. a chart-shaped hole PowerPoint opens and shows empty.\n\t\t\tthrow new InternalError(\n\t\t\t\t'chart/type-not-routed',\n\t\t\t\t`makeChartType: \"${String(chartType)}\" has no <c:...Chart> plot — the chartEx catalog is built by makeXmlChartEx, and a newly added classic type needs an arm here`,\n\t\t\t\t{ detail: { chartType } }\n\t\t\t)\n\t}\n}\n","/**\n * ts-pptx: chartEx (`cx:`) Chart-Data Builder\n *\n * Builds the `<cx:chartData>` block of a chartEx chart part (waterfall, and the other\n * Office-2016 layouts as they land). This is the chartEx analogue of the `<c:cat>`/`<c:val>`\n * caches on the classic side: it names the embedded-workbook cells via `<cx:f>` formulas and\n * mirrors their values into `<cx:lvl>` string/number caches so PowerPoint can render without\n * opening the workbook. The category label levels occupy the leading columns (0 of them for a\n * category-less histogram, 1 for a flat chart, N for a hierarchical treemap/sunburst) and the one\n * value series sits in the next column — so the references here line up 1:1 with the workbook\n * written by {@link ./embed-xlsx}.\n */\n\nimport { ChartType } from '../../enums.js'\nimport type { SlideRelChart } from '../../types/internal.js'\nimport { warn } from '../../diagnostics.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport { dataLabels, dataValues, sheetCellRef, sheetRangeRef, type WorksheetLayout } from './data-refs.js'\n\n/**\n * The numeric-dimension tag PowerPoint expects varies by layout. The flat layouts (waterfall,\n * funnel, histogram, pareto, boxWhisker) use `type=\"val\"`; the hierarchical treemap/sunburst use\n * `type=\"size\"`; a `regionMap` uses `type=\"colorVal\"` (the value drives each region's fill color).\n * The value always comes from the series' `values`; only the dimension tag differs.\n */\nfunction valueDimType(type: ChartType): 'size' | 'val' | 'colorVal' {\n\tif (type === ChartType.treemap || type === ChartType.sunburst) return 'size'\n\tif (type === ChartType.regionMap) return 'colorVal'\n\treturn 'val'\n}\n\n/**\n * Build the `<cx:chartData>` for a single-series chartEx chart.\n *\n * `<cx:data id=\"0\">` carries a `<cx:strDim type=\"cat\">` (category labels) and a numeric dimension\n * (`type=\"val\"` for flat layouts, `type=\"size\"` for the hierarchical treemap/sunburst);\n * `<cx:externalData r:id=\"rId1\">` points at the embedded workbook (same `rId1` the chart part's\n * `.rels` maps to the `.xlsx`).\n *\n * Category labels are `string[][]` — one inner array per hierarchy level (leaf first). A flat chart\n * has a single level; treemap/sunburst carry several. Each level becomes one `<cx:lvl>`, emitted\n * leaf-first to match PowerPoint. The workbook ({@link ./embed-xlsx}) lays the levels out in\n * columns A..N (outermost in A, leaf in the last label column) with the value series in the next\n * column; the single `<cx:f>` range on each dimension spans exactly those columns.\n *\n * The rows come from the worksheet layout, the same one the workbook is written from. They were\n * sized from the longer of the labels and the values here, while the workbook writes one row per\n * label, so a waterfall with 2 labels and 4 values referenced rows 2 to 5 of a sheet with rows 2\n * and 3.\n * @param {SlideRelChart} rel - the registered chart\n * @param {WorksheetLayout} sheet - the chart's worksheet layout\n * @return {string} `<cx:chartData>…</cx:chartData>` XML\n */\nexport function makeChartExData(rel: SlideRelChart, sheet: WorksheetLayout): string {\n\tconst series = rel.data[0]\n\tconst type = rel.opts._type as ChartType\n\tconst levels = dataLabels(series)\n\tconst totLvl = levels.length // 0 for a category-less layout (histogram), 1 flat, N hierarchical\n\tconst vals = dataValues(series)\n\tconst ptCount = sheet.rowCount\n\tconst lastRow = ptCount + 1\n\tconst valueCol = sheet.valueColumn(0)\n\n\t// Category (string) dimension — one <cx:lvl> per hierarchy level, leaf-first, over columns A..totLvl.\n\t// A category-less layout (histogram bins raw observations itself) emits no strDim at all.\n\tlet catDim = ''\n\tif (totLvl > 0) {\n\t\tconst catLvls = levels\n\t\t\t.map((group) => {\n\t\t\t\tconst pts = group.map((label, idx) => el('cx:pt', { idx }, label ?? '')).join('')\n\t\t\t\treturn el('cx:lvl', { ptCount: group.length }, raw(pts))\n\t\t\t})\n\t\t\t.join('')\n\t\tcatDim = el('cx:strDim', { type: 'cat' }, [\n\t\t\traw(el('cx:f', null, sheetRangeRef(1, 2, totLvl, lastRow))),\n\t\t\traw(catLvls),\n\t\t])\n\t}\n\n\t// Numeric dimension — the value column. Skip null/non-finite points (a valid sparse cache);\n\t// warn on non-finite, matching the classic side's `numCachePt` policy.\n\tlet valPts = ''\n\tvals.forEach((value, idx) => {\n\t\t// Past the sheet's rows there is no cell to mirror; `addChartDefinition` warns about these.\n\t\tif (value == null || idx >= ptCount) return\n\t\tif (!Number.isFinite(value)) {\n\t\t\twarn(\n\t\t\t\t'chart/non-finite-value',\n\t\t\t\t`chartEx value \"${value}\" at index ${idx} is not a finite number; data point omitted.`\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tvalPts += el('cx:pt', { idx }, value)\n\t})\n\tconst valDim = el('cx:numDim', { type: valueDimType(type) }, [\n\t\traw(el('cx:f', null, sheetRangeRef(valueCol, 2, valueCol, lastRow))),\n\t\traw(el('cx:lvl', { ptCount, formatCode: 'General' }, raw(valPts))),\n\t])\n\n\tconst data = el('cx:data', { id: 0 }, [raw(catDim), raw(valDim)])\n\t// CT_ChartData order is externalData? → data+. externalData is a LEAF whose only attribute is\n\t// `id` (r:id → the embedded workbook); it carries no `autoUpdate` and no child elements.\n\tconst externalData = voidEl('cx:externalData', { 'r:id': 'rId1' })\n\treturn el('cx:chartData', null, [raw(externalData), raw(data)])\n}\n\n/**\n * The `Sheet1` cell holding the series name (the numeric dimension's header) — column immediately\n * after all label columns, row 1. A category-less histogram lands on `$A$1`; a flat chart on\n * `$B$1`; a 3-level treemap on `$D$1`.\n * @param {WorksheetLayout} sheet - the chart's worksheet layout\n * @return {string} an absolute single-cell reference, e.g. `Sheet1!$B$1`\n */\nexport function chartExSeriesNameRef(sheet: WorksheetLayout): string {\n\treturn sheetCellRef(sheet.valueColumn(0), 1)\n}\n","/**\n * ts-pptx: chartEx (`cx:`) Chart Assembly\n *\n * Builds a chartEx chart part `ppt/charts/chartEx{N}.xml` — the `<cx:chartSpace>` for the\n * Office-2016 chart family (currently `waterfall`, `funnel`, `treemap`, `sunburst`, `histogram`,\n * `pareto`, `boxWhisker`, `regionMap`).\n * This is the chartEx analogue of\n * {@link ./chart-xml} (`makeXmlCharts`): a pure string builder, no I/O, no model mutation.\n *\n * chartEx differs from the classic `<c:chartSpace>` in three ways the rest of the package must\n * account for (all handled at the call sites, not here):\n * - it is a **separate part** with content type `application/vnd.ms-office.chartex+xml`,\n * - it is referenced from the slide through `<mc:AlternateContent>` (see `gen/slide/objects/chart.ts`),\n * - it renders **only in PowerPoint 2016+/Microsoft 365**; other consumers show the fallback shape.\n *\n * The `<cx:f>` formulas point back at the same embedded workbook the classic charts use\n * ({@link ./embed-xlsx}); the cell mapping lives in {@link ./chartex-data} / {@link ./data-refs}.\n */\n\nimport { namedColorOr } from '../drawingml/color.js'\nimport { ChartType } from '../../enums.js'\nimport { InternalError } from '../../errors.js'\nimport { DEF_FONT_COLOR, XML_DECL } from '../../constants-internal.js'\nimport type { ChartExBinning, ChartExGeography, ChartExStatistics } from '../../types/chart.js'\nimport type { SlideRelChart } from '../../types/internal.js'\nimport { genXmlColorSelection } from '../drawingml/fill.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport { chartLang, createChartTextFonts } from './chart-parts.js'\nimport { chartExSeriesNameRef, makeChartExData } from './chartex-data.js'\nimport { seriesHeader, type WorksheetLayout, worksheetLayout } from './data-refs.js'\nimport { OOXML_NS } from '../../ooxml/namespaces.js'\nimport { type XsdBool, xsdBool } from '../../ooxml/xsd-boolean.js'\n\n/**\n * Map a chartEx {@link ChartType} to its `<cx:series layoutId>` token (the CT_SeriesLayout value\n * PowerPoint keys the chart geometry on). Throws on anything it does not own — see the `default`\n * arm for which members those are and why reaching it is a routing bug.\n */\nfunction chartExLayoutId(type: ChartType): string {\n\tswitch (type) {\n\t\tcase ChartType.waterfall:\n\t\t\treturn 'waterfall'\n\t\tcase ChartType.funnel:\n\t\t\treturn 'funnel'\n\t\tcase ChartType.treemap:\n\t\t\treturn 'treemap'\n\t\tcase ChartType.sunburst:\n\t\t\treturn 'sunburst'\n\t\tcase ChartType.histogram:\n\t\t\t// A histogram is a clustered-column series whose bins PowerPoint computes from <cx:binning>.\n\t\t\treturn 'clusteredColumn'\n\t\tcase ChartType.boxWhisker:\n\t\t\treturn 'boxWhisker'\n\t\tcase ChartType.regionMap:\n\t\t\treturn 'regionMap'\n\t\tdefault:\n\t\t\t// The unmatched members are the classic 2007 catalog — owned by `makeChartType` in\n\t\t\t// `./chart-xml` — plus `pareto`, which is multi-series and is diverted to `makeParetoSeries`\n\t\t\t// before any single layoutId is asked for. Both are unreachable through `isChartExType`\n\t\t\t// routing; `''` here used to emit `<cx:series layoutId=\"\">`, which PowerPoint cannot render.\n\t\t\tthrow new InternalError(\n\t\t\t\t'chart/type-not-routed',\n\t\t\t\t`chartExLayoutId: \"${String(type)}\" has no <cx:series> layoutId — classic chart types belong to makeXmlCharts, pareto is built by makeParetoSeries, and a newly added chartEx type needs an arm here`,\n\t\t\t\t{ detail: { chartType: type } }\n\t\t\t)\n\t}\n}\n\n/**\n * A deterministic `uniqueId` GUID for a `<cx:series>`, derived from the chart's package-global id.\n * PowerPoint stamps a random GUID here; deriving it keeps output byte-stable (the project pins\n * chart determinism — the package-wide id this derives from is assigned at write time in\n * `package/assemble.ts`, STEP 2). `seriesIdx`\n * distinguishes multiple series within one chart (pareto emits two), varying the 4th GUID group so\n * every series still gets a distinct id.\n */\nfunction chartExUniqueId(globalId: number, seriesIdx = 0): string {\n\treturn `{00000000-0000-0000-${String(seriesIdx).padStart(4, '0')}-${String(globalId).padStart(12, '0')}}`\n}\n\n/** chartEx legend positions are `t|b|l|r`; clamp the classic `'tr'` (and anything else) to `'t'`. */\nfunction chartExLegendPos(pos: string | undefined): string {\n\treturn pos === 'b' || pos === 'l' || pos === 'r' ? pos : 't'\n}\n\n/**\n * The `<cx:axisId>` binding on a `<cx:series>` (which value/category axis the series plots against).\n *\n * NOTE — a schema-vs-PowerPoint divergence (the exact mirror of the histogram `binCount` gotcha):\n * the OpenXML SDK models `cx:axisId` as an `OpenXmlLeafTextElement`, so the OOXML validator only\n * accepts the text-content form `<cx:axisId>1</cx:axisId>` and flags the `val` attribute as\n * undeclared. But PowerPoint desktop REFUSES to open a deck using the text form (0x80070570) — it\n * writes and requires the ATTRIBUTE form `<cx:axisId val=\"1\"/>` (matching the classic `c:axId`).\n * PowerPoint is the authoritative oracle here, so the attribute form is emitted; the resulting\n * validator complaint on `cx:axisId/@val` is expected and whitelisted in the schema-case test.\n */\nfunction makeChartExAxisId(id: number): string {\n\treturn voidEl('cx:axisId', { val: id })\n}\n\n/**\n * Build the histogram `<cx:binning>` element from the caller's `binning` opt. PowerPoint bins the\n * raw observations automatically; the only control wired here is `intervalClosed` — whether each\n * bin interval is right-closed (`\"r\"`, PowerPoint's default) or left-closed (`\"l\"`).\n *\n * NOTE: explicit bin geometry (`binCount`/`binSize` child elements, `underflow`/`overflow`\n * attributes) is intentionally NOT emitted. Although `<cx:binCount>`/`<cx:binSize>` pass OOXML\n * schema validation (they are declared children of `cx:binning` in the OpenXML SDK), PowerPoint\n * desktop refuses to open a deck that contains them (0x80004005) — so shipping them would corrupt\n * the file. They stay deferred until their real requirements are pinned down against PowerPoint.\n */\nfunction makeChartExBinning(binning: ChartExBinning | undefined): string {\n\treturn voidEl('cx:binning', { intervalClosed: binning?.intervalClosed === 'l' ? 'l' : 'r' })\n}\n\n/**\n * Build the box-and-whisker `<cx:layoutPr>` body — a `<cx:visibility>` toggle set plus a\n * `<cx:statistics>` quartile-method choice, in that document order (what PowerPoint itself emits).\n * All flags default to PowerPoint's own defaults: exclusive quartiles, mean marker on, outlier\n * points on, the mean-line and the full non-outlier scatter off. Booleans map to the `0`/`1`\n * attribute form PowerPoint uses.\n */\nfunction makeBoxWhiskerLayoutPr(stats: ChartExStatistics | undefined): string {\n\tconst bit = (v: boolean | undefined, dflt: boolean): XsdBool => xsdBool(v ?? dflt)\n\tconst visibility = voidEl('cx:visibility', {\n\t\tmeanLine: bit(stats?.meanLine, false),\n\t\tmeanMarker: bit(stats?.meanMarker, true),\n\t\tnonoutliers: bit(stats?.nonoutliers, false),\n\t\toutliers: bit(stats?.outliers, true),\n\t})\n\tconst statistics = voidEl('cx:statistics', {\n\t\tquartileMethod: stats?.quartileMethod === 'inclusive' ? 'inclusive' : 'exclusive',\n\t})\n\treturn el('cx:layoutPr', null, [raw(visibility), raw(statistics)])\n}\n\n/**\n * Build the region-map `<cx:layoutPr>` body — a single `<cx:geography>` hint telling PowerPoint how\n * to interpret the category labels as geographic region names. `cultureLanguage`/`cultureRegion`\n * (both schema-REQUIRED) resolve ambiguous names (e.g. \"Georgia\" the country vs. the US state);\n * `attribution` is Bing's fixed acknowledgement string.\n *\n * NOTE — PowerPoint itself also nests a `<cx:geoCache>` here holding a base64 binary blob: its\n * cached Bing geometry for the resolved regions. That blob is produced by an online Bing lookup and\n * cannot be reproduced offline, so it is intentionally OMITTED. PowerPoint re-resolves the geography\n * from the region names when the deck is opened (verified over COM: the deck opens and reads back as\n * a regionMap either way) — this is why a region map is documented as best-effort/write-only and\n * renders blank if the names don't match PowerPoint's geography database.\n */\nfunction makeGeographyLayoutPr(geo: ChartExGeography | undefined): string {\n\tconst geography = voidEl('cx:geography', {\n\t\tcultureLanguage: geo?.cultureLanguage || 'en-US',\n\t\tcultureRegion: geo?.cultureRegion || 'US',\n\t\tattribution: 'Powered by Bing',\n\t})\n\treturn el('cx:layoutPr', null, raw(geography))\n}\n\n/** The `<cx:tx>` series-name cell/value block (shared by every layout that names its series). */\nfunction makeChartExSeriesName(rel: SlideRelChart, sheet: WorksheetLayout): string {\n\treturn el(\n\t\t'cx:tx',\n\t\tnull,\n\t\traw(\n\t\t\tel('cx:txData', null, [\n\t\t\t\traw(el('cx:f', null, chartExSeriesNameRef(sheet))),\n\t\t\t\traw(el('cx:v', null, seriesHeader(rel.data[0]))),\n\t\t\t])\n\t\t)\n\t)\n}\n\n/**\n * Data labels: chartEx toggles each field via `<cx:visibility>`. Only emitted when the caller asked\n * to show values, matching the classic default of no data labels.\n */\nfunction makeChartExDataLabels(rel: SlideRelChart): string {\n\tconst showValue = !!(rel.opts.showValue || rel.opts.showLabel)\n\treturn showValue\n\t\t? el('cx:dataLabels', { pos: 'outEnd' }, raw(voidEl('cx:visibility', { seriesName: 0, categoryName: 0, value: 1 })))\n\t\t: ''\n}\n\n/**\n * Build the pareto `<cx:series>` PAIR — pareto is the first chartEx layout that emits more than one\n * series. Series 0 is a `clusteredColumn` bound to value axis 1 whose `<cx:aggregation/>` tells\n * PowerPoint to sum the values per category, sort the bars descending, and drive the cumulative\n * line. Series 1 is the `paretoLine` itself: it carries `ownerIdx=\"0\"` (it derives its data from\n * series 0, so it has NO `<cx:tx>` or `<cx:dataId>`) and binds to the secondary percentage axis 2.\n */\nfunction makeParetoSeries(rel: SlideRelChart, sheet: WorksheetLayout): string {\n\tconst bar = el('cx:series', { layoutId: 'clusteredColumn', uniqueId: chartExUniqueId(rel.globalId, 0) }, [\n\t\traw(makeChartExSeriesName(rel, sheet)),\n\t\traw(makeChartExDataLabels(rel)),\n\t\traw(voidEl('cx:dataId', { val: 0 })),\n\t\traw(el('cx:layoutPr', null, raw(voidEl('cx:aggregation')))),\n\t\traw(makeChartExAxisId(1)),\n\t])\n\tconst line = el('cx:series', { layoutId: 'paretoLine', ownerIdx: 0, uniqueId: chartExUniqueId(rel.globalId, 1) }, [\n\t\traw(makeChartExAxisId(2)),\n\t])\n\treturn bar + line\n}\n\n/** Build the `<cx:series>` (title cell, data labels, dataId, and layout-specific `<cx:layoutPr>`). */\nfunction makeChartExSeries(rel: SlideRelChart, sheet: WorksheetLayout): string {\n\tconst opts = rel.opts\n\tconst type = opts._type as ChartType\n\n\t// Pareto is multi-series (a column series + a cumulative line on a secondary axis).\n\tif (type === ChartType.pareto) return makeParetoSeries(rel, sheet)\n\n\t// Layout-specific series props.\n\tlet layoutPr = ''\n\tif (type === ChartType.waterfall && Array.isArray(opts.subtotals) && opts.subtotals.length > 0) {\n\t\t// waterfall: subtotal/total column indices.\n\t\tconst idxs = opts.subtotals.map((idx) => voidEl('cx:idx', { val: idx })).join('')\n\t\tlayoutPr = el('cx:layoutPr', null, raw(el('cx:subtotals', null, raw(idxs))))\n\t} else if (type === ChartType.treemap) {\n\t\t// treemap: how parent-category banners are placed (PowerPoint's default is `overlapping`).\n\t\tlayoutPr = el('cx:layoutPr', null, raw(voidEl('cx:parentLabelLayout', { val: 'overlapping' })))\n\t} else if (type === ChartType.histogram) {\n\t\t// histogram: how PowerPoint bins the raw observations. Default is auto binning with\n\t\t// right-closed intervals; the `binning` opt exposes explicit width/count/overflow control.\n\t\tlayoutPr = el('cx:layoutPr', null, raw(makeChartExBinning(opts.binning)))\n\t} else if (type === ChartType.boxWhisker) {\n\t\t// box-and-whisker: quartile method + which box adornments (mean line/marker, outliers) show.\n\t\tlayoutPr = makeBoxWhiskerLayoutPr(opts.statistics)\n\t} else if (type === ChartType.regionMap) {\n\t\t// region map: the <cx:geography> hint PowerPoint resolves the region names against.\n\t\tlayoutPr = makeGeographyLayoutPr(opts.geography)\n\t}\n\n\treturn el('cx:series', { layoutId: chartExLayoutId(type), uniqueId: chartExUniqueId(rel.globalId) }, [\n\t\traw(makeChartExSeriesName(rel, sheet)),\n\t\traw(makeChartExDataLabels(rel)),\n\t\traw(voidEl('cx:dataId', { val: 0 })),\n\t\traw(layoutPr),\n\t])\n}\n\n/** The chartEx category axis: a gap width and tick labels. `id` is 0 except on the funnel. */\nfunction catScalingAxis(gapWidth: string, id = 0): string {\n\treturn el('cx:axis', { id }, [raw(voidEl('cx:catScaling', { gapWidth })), raw(voidEl('cx:tickLabels'))])\n}\n\n/** The chartEx primary value axis (id 1): a linear scale, gridlines and tick labels. */\nfunction gridlinedValAxis(): string {\n\treturn el('cx:axis', { id: 1 }, [\n\t\traw(voidEl('cx:valScaling')),\n\t\traw(voidEl('cx:majorGridlines')),\n\t\traw(voidEl('cx:tickLabels')),\n\t])\n}\n\n/**\n * The category-axis gap width each axis-bearing chartEx layout uses. A chartEx `catScaling`\n * gapWidth is a **fraction** (1.0 = 100%), NOT the classic integer percent.\n *\n * Histogram bins abut, so they take 0; the pareto's aggregated columns are histogram columns\n * and take the same. A layout absent from this table has no axes at all: the hierarchical\n * treemap and sunburst encode categories in nested tiles and rings rather than an axis scale,\n * and a `regionMap` plots on geography.\n */\nconst CHARTEX_CAT_GAP_WIDTH: Partial<Record<ChartType, string>> = {\n\t[ChartType.waterfall]: '0.5',\n\t[ChartType.histogram]: '0',\n\t[ChartType.pareto]: '0',\n\t[ChartType.boxWhisker]: '1',\n}\n\n/**\n * Build the `<cx:axis>` list for a layout, matched to what PowerPoint itself emits for each.\n *\n * Four of the five axis-bearing layouts are the same pair — a category axis (id 0) and a\n * gridlined value axis (id 1) — differing only in gap width, so they are a table rather than\n * four arms. The two that are not: the **funnel** has a SINGLE category axis, which PowerPoint\n * numbers id 1, with no value axis and no gridlines (its bars run horizontally off one\n * category scale); and the **pareto** adds a third axis for its cumulative line.\n */\nfunction makeChartExAxes(type: ChartType): string {\n\t// The funnel is the one asymmetric layout: a single axis, and it is the *value* id the\n\t// category scale hangs off, so it is not a row in the table above.\n\tif (type === ChartType.funnel) return catScalingAxis('2.19', 1)\n\n\tconst gapWidth = CHARTEX_CAT_GAP_WIDTH[type]\n\tif (gapWidth === undefined) return ''\n\tconst axes = catScalingAxis(gapWidth) + gridlinedValAxis()\n\t// The pareto adds a SECONDARY value axis (id 2) for the cumulative paretoLine: a 0..1\n\t// percentage scale, no gridlines, since the primary value axis already carries them.\n\tif (type !== ChartType.pareto) return axes\n\treturn (\n\t\taxes +\n\t\tel('cx:axis', { id: 2 }, [\n\t\t\traw(voidEl('cx:valScaling', { max: '1', min: '0' })),\n\t\t\traw(voidEl('cx:units', { unit: 'percentage' })),\n\t\t\traw(voidEl('cx:tickLabels')),\n\t\t])\n\t)\n}\n\n/** Build a minimal `<cx:title>` from the chart title options (only when `showTitle`). */\nfunction makeChartExTitle(rel: SlideRelChart): string {\n\tif (!rel.opts.showTitle) return ''\n\tconst color = namedColorOr(rel.opts.titleColor, DEF_FONT_COLOR, 'titleColor')\n\tconst face = rel.opts.titleFontFace ?? 'Calibri'\n\tconst rPr = el('a:defRPr', null, [raw(genXmlColorSelection(color)), raw(createChartTextFonts(face))])\n\tconst rich = el('cx:rich', null, [\n\t\traw(voidEl('a:bodyPr')),\n\t\traw(voidEl('a:lstStyle')),\n\t\traw(\n\t\t\tel('a:p', null, [\n\t\t\t\traw(el('a:pPr', null, raw(rPr))),\n\t\t\t\traw(\n\t\t\t\t\tel('a:r', null, [\n\t\t\t\t\t\traw(voidEl('a:rPr', { lang: chartLang(rel.opts) })),\n\t\t\t\t\t\traw(el('a:t', null, rel.opts.title || 'Chart Title')),\n\t\t\t\t\t])\n\t\t\t\t),\n\t\t\t])\n\t\t),\n\t])\n\treturn el('cx:title', { pos: 't', align: 'ctr', overlay: 0 }, raw(el('cx:tx', null, raw(rich))))\n}\n\n/**\n * Assemble the full `<cx:chartSpace>` for a chartEx chart part.\n * Document order (CT_ChartSpace): `chartData` → `chart`; the `<cx:chart>` holds\n * `title? → plotArea → legend?`.\n * @param {SlideRelChart} rel - the registered chartEx chart\n * @return {string} the `ppt/charts/chartEx{N}.xml` body\n */\nexport function makeXmlChartEx(rel: SlideRelChart): string {\n\tconst type = rel.opts._type as ChartType\n\n\tconst sheet = worksheetLayout(rel)\n\tconst plotAreaRegion = el('cx:plotAreaRegion', null, raw(makeChartExSeries(rel, sheet)))\n\tconst plotArea = el('cx:plotArea', null, [raw(plotAreaRegion), raw(makeChartExAxes(type))])\n\tconst legend = rel.opts.showLegend\n\t\t? voidEl('cx:legend', { pos: chartExLegendPos(rel.opts.legendPos), align: 'ctr', overlay: 0 })\n\t\t: ''\n\tconst chart = el('cx:chart', null, [raw(makeChartExTitle(rel)), raw(plotArea), raw(legend)])\n\n\treturn (\n\t\tXML_DECL +\n\t\tel('cx:chartSpace', { 'xmlns:cx': OOXML_NS.cx, 'xmlns:a': OOXML_NS.a, 'xmlns:r': OOXML_NS.r }, [\n\t\t\traw(makeChartExData(rel, sheet)),\n\t\t\traw(chart),\n\t\t])\n\t)\n}\n","/**\n * ts-pptx: chartEx (cx:) Style + Color Parts\n *\n * Every chartEx chart part (`chartEx{N}.xml`) MUST be accompanied by a chart-style part\n * (`style{N}.xml`, `cs:chartStyle`) and a chart-color-style part (`colors{N}.xml`,\n * `cs:colorStyle`), linked from the chartEx part's `.rels` via the MS `chartStyle` /\n * `chartColorStyle` relationship types. This is NOT optional: PowerPoint reports a chartEx deck\n * that lacks them as corrupt (0x80070570) — a failure the OOXML schema validator does not catch,\n * found via the desktop COM smoke (`pnpm run test:com`).\n *\n * The two payloads below are PowerPoint's own generic, chart-type-agnostic defaults (the same\n * boilerplate Office writes for any new chartEx chart), captured verbatim and shipped as a static\n * template — analogous to the default theme/worksheet boilerplate the library already embeds. They\n * reference theme scheme colors, so they adapt to the deck theme without per-chart customization.\n */\n\nimport { XML_DECL } from '../../constants-internal.js'\n\n/**\n * The `cs:colorStyle` payload for a chartEx chart's `colors{N}.xml` part (theme-accent cycle).\n * @raw-xml-asset Captured verbatim from PowerPoint; not built here, so not a migration target.\n */\nconst CHARTEX_COLORS_BODY =\n\t'<cs:colorStyle xmlns:cs=\"http://schemas.microsoft.com/office/drawing/2012/chartStyle\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" meth=\"cycle\" id=\"10\"><a:schemeClr val=\"accent1\"/><a:schemeClr val=\"accent2\"/><a:schemeClr val=\"accent3\"/><a:schemeClr val=\"accent4\"/><a:schemeClr val=\"accent5\"/><a:schemeClr val=\"accent6\"/><cs:variation/><cs:variation><a:lumMod val=\"60000\"/></cs:variation><cs:variation><a:lumMod val=\"80000\"/><a:lumOff val=\"20000\"/></cs:variation><cs:variation><a:lumMod val=\"80000\"/></cs:variation><cs:variation><a:lumMod val=\"60000\"/><a:lumOff val=\"40000\"/></cs:variation><cs:variation><a:lumMod val=\"50000\"/></cs:variation><cs:variation><a:lumMod val=\"70000\"/><a:lumOff val=\"30000\"/></cs:variation><cs:variation><a:lumMod val=\"70000\"/></cs:variation><cs:variation><a:lumMod val=\"50000\"/><a:lumOff val=\"50000\"/></cs:variation></cs:colorStyle>'\n\n/**\n * The `cs:chartStyle` payload for a chartEx chart's `style{N}.xml` part (PowerPoint default).\n * @raw-xml-asset Captured verbatim from PowerPoint; not built here, so not a migration target.\n */\nconst CHARTEX_STYLE_BODY =\n\t'<cs:chartStyle xmlns:cs=\"http://schemas.microsoft.com/office/drawing/2012/chartStyle\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" id=\"395\"><cs:axisTitle><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></cs:fontRef><cs:defRPr sz=\"1197\"/></cs:axisTitle><cs:categoryAxis><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></cs:fontRef><cs:spPr><a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"15000\"/><a:lumOff val=\"85000\"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr><cs:defRPr sz=\"1197\"/></cs:categoryAxis><cs:chartArea mods=\"allowNoFillOverride allowNoLineOverride\"><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val=\"bg1\"/></a:solidFill><a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"15000\"/><a:lumOff val=\"85000\"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr><cs:defRPr sz=\"1330\"/></cs:chartArea><cs:dataLabel><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></cs:fontRef><cs:defRPr sz=\"1197\"/></cs:dataLabel><cs:dataLabelCallout><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"dk1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill><a:ln><a:solidFill><a:schemeClr val=\"dk1\"><a:lumMod val=\"25000\"/><a:lumOff val=\"75000\"/></a:schemeClr></a:solidFill></a:ln></cs:spPr><cs:defRPr sz=\"1197\"/><cs:bodyPr rot=\"0\" spcFirstLastPara=\"1\" vertOverflow=\"clip\" horzOverflow=\"clip\" vert=\"horz\" wrap=\"square\" lIns=\"36576\" tIns=\"18288\" rIns=\"36576\" bIns=\"18288\" anchor=\"ctr\" anchorCtr=\"1\"><a:spAutoFit/></cs:bodyPr></cs:dataLabelCallout><cs:dataPoint><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"><cs:styleClr val=\"auto\"/></cs:fillRef><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill></cs:spPr></cs:dataPoint><cs:dataPoint3D><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"><cs:styleClr val=\"auto\"/></cs:fillRef><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill></cs:spPr></cs:dataPoint3D><cs:dataPointLine><cs:lnRef idx=\"0\"><cs:styleClr val=\"auto\"/></cs:lnRef><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:ln w=\"28575\" cap=\"rnd\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:round/></a:ln></cs:spPr></cs:dataPointLine><cs:dataPointMarker><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"><cs:styleClr val=\"auto\"/></cs:fillRef><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:ln w=\"9525\"><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill></a:ln></cs:spPr></cs:dataPointMarker><cs:dataPointMarkerLayout symbol=\"circle\" size=\"5\"/><cs:dataPointWireframe><cs:lnRef idx=\"0\"><cs:styleClr val=\"auto\"/></cs:lnRef><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:ln w=\"28575\" cap=\"rnd\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:round/></a:ln></cs:spPr></cs:dataPointWireframe><cs:dataTable><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></cs:fontRef><cs:spPr><a:ln w=\"9525\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"15000\"/><a:lumOff val=\"85000\"/></a:schemeClr></a:solidFill></a:ln></cs:spPr><cs:defRPr sz=\"1197\"/></cs:dataTable><cs:downBar><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"dk1\"/></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val=\"dk1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></a:solidFill><a:ln w=\"9525\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></a:solidFill></a:ln></cs:spPr></cs:downBar><cs:dropLine><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"35000\"/><a:lumOff val=\"65000\"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:dropLine><cs:errorBar><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:errorBar><cs:floor><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef></cs:floor><cs:gridlineMajor><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"15000\"/><a:lumOff val=\"85000\"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:gridlineMajor><cs:gridlineMinor><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"15000\"/><a:lumOff val=\"85000\"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:gridlineMinor><cs:hiLoLine><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"75000\"/><a:lumOff val=\"25000\"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:hiLoLine><cs:leaderLine><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"35000\"/><a:lumOff val=\"65000\"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:leaderLine><cs:legend><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></cs:fontRef><cs:defRPr sz=\"1197\"/></cs:legend><cs:plotArea mods=\"allowNoFillOverride allowNoLineOverride\"><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef></cs:plotArea><cs:plotArea3D mods=\"allowNoFillOverride allowNoLineOverride\"><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef></cs:plotArea3D><cs:seriesAxis><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></cs:fontRef><cs:spPr><a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"15000\"/><a:lumOff val=\"85000\"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr><cs:defRPr sz=\"1197\"/></cs:seriesAxis><cs:seriesLine><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:ln w=\"9525\" cap=\"flat\"><a:solidFill><a:srgbClr val=\"D9D9D9\"/></a:solidFill><a:round/></a:ln></cs:spPr></cs:seriesLine><cs:title><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></cs:fontRef><cs:defRPr sz=\"1862\"/></cs:title><cs:trendline><cs:lnRef idx=\"0\"><cs:styleClr val=\"auto\"/></cs:lnRef><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef><cs:spPr><a:ln w=\"19050\" cap=\"rnd\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"sysDash\"/></a:ln></cs:spPr></cs:trendline><cs:trendlineLabel><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></cs:fontRef><cs:defRPr sz=\"1197\"/></cs:trendlineLabel><cs:upBar><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"dk1\"/></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val=\"lt1\"/></a:solidFill><a:ln w=\"9525\"><a:solidFill><a:schemeClr val=\"tx1\"><a:lumMod val=\"15000\"/><a:lumOff val=\"85000\"/></a:schemeClr></a:solidFill></a:ln></cs:spPr></cs:upBar><cs:valueAxis><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"><a:lumMod val=\"65000\"/><a:lumOff val=\"35000\"/></a:schemeClr></cs:fontRef><cs:defRPr sz=\"1197\"/></cs:valueAxis><cs:wall><cs:lnRef idx=\"0\"/><cs:fillRef idx=\"0\"/><cs:effectRef idx=\"0\"/><cs:fontRef idx=\"minor\"><a:schemeClr val=\"tx1\"/></cs:fontRef></cs:wall></cs:chartStyle>'\n\n/** Build the `ppt/charts/colors{N}.xml` part body. */\nexport function makeChartExColorsXml(): string {\n\treturn XML_DECL + CHARTEX_COLORS_BODY\n}\n\n/** Build the `ppt/charts/style{N}.xml` part body. */\nexport function makeChartExStyleXml(): string {\n\treturn XML_DECL + CHARTEX_STYLE_BODY\n}\n","/**\n * ts-pptx: Chart Embedded-Workbook Generation\n *\n * Builds the embedded `.xlsx` workbook that backs a chart's cached data — the data\n * source PowerPoint opens when a user edits the chart. `createExcelWorksheet` writes\n * the workbook plus the chart part + its `.rels` into the presentation package;\n * `buildEmbeddedWorksheet` and `chartPartBodies` are also used by slide extraction\n * (`TsPptx.extractSlides`), whose chart relationships `appendSlides` rebuilds itself against the\n * parts it reserves. Everything here is a pure string/bytes\n * builder — no I/O beyond the passed-in ZipWriter, no mutation of the presentation model.\n *\n * The chart's `chart.xml` DrawingML lives in `./chart-xml.ts`; the series↔worksheet-cell\n * mapping the two sides share lives in `./data-refs.ts`.\n */\n\nimport { XML_DECL } from '../../constants-internal.js'\nimport type { SlideRelChart, OptsChartDataInternal } from '../../types/internal.js'\nimport { ZipWriter } from '../../zip.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport { chartPartNames } from './part-names.js'\nimport {\n\tCHART_COLOR_STYLE_REL,\n\tCHART_STYLE_REL,\n\tCORE_PROPS_CONTENT_TYPE,\n\tCORE_PROPS_REL,\n\tEXTENDED_PROPS_CONTENT_TYPE,\n\tEXTENDED_PROPS_REL,\n\tOFFICE_DOCUMENT_REL,\n\tOFFICE_REL,\n\tPACKAGE_REL,\n\tRELATIONSHIPS_CONTENT_TYPE,\n\tTHEME_CONTENT_TYPE,\n\tTHEME_REL,\n\tOD_CONTENT,\n} from '../../ooxml/rel-types.js'\nimport { OOXML_NS } from '../../ooxml/namespaces.js'\nimport { relationshipEl, relationshipsEl } from '../opc/rels.js'\nimport { CORE_PROPS_NS, coreTimestamp } from '../opc/core.js'\nimport { dataLabels, getExcelColName, labelSeries, type WorksheetLayout, worksheetLayout } from './data-refs.js'\nimport { makeXmlCharts } from './chart-xml.js'\nimport { makeXmlChartEx } from './chartex-xml.js'\nimport { makeChartExColorsXml, makeChartExStyleXml } from './chartex-style.js'\nimport { FMT_SCHEME_XML } from '../oxml/fmt-scheme.js'\n\n/** MS chart-extension relationship types (chartEx style + color-style sidecar parts). */\n\n/** The SpreadsheetML namespace every part of the embedded workbook is written in. */\nconst SML_NS = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'\n/** The prefix the embedded workbook's SpreadsheetML part types share. */\nconst SML_CT = OD_CONTENT + 'spreadsheetml.'\n\n/** One `<si>` shared string carrying literal text. */\nconst sharedString = (text: string): string => el('si', null, raw(el('t', null, text)))\n\n/**\n * The embedded workbook's style sheet, captured verbatim from an Excel-authored chart workbook.\n * @raw-xml-asset\n */\nconst XLSX_STYLES_XML =\n\t'<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"><numFmts count=\"1\"><numFmt numFmtId=\"0\" formatCode=\"General\"/></numFmts><fonts count=\"4\"><font><sz val=\"9\"/><color indexed=\"8\"/><name val=\"Geneva\"/></font><font><sz val=\"9\"/><color indexed=\"8\"/><name val=\"Geneva\"/></font><font><sz val=\"10\"/><color indexed=\"8\"/><name val=\"Geneva\"/></font><font><sz val=\"18\"/><color indexed=\"8\"/>' +\n\t'<name val=\"Arial\"/></font></fonts><fills count=\"2\"><fill><patternFill patternType=\"none\"/></fill><fill><patternFill patternType=\"gray125\"/></fill></fills><borders count=\"1\"><border><left/><right/><top/><bottom/><diagonal/></border></borders><dxfs count=\"0\"/><tableStyles count=\"0\"/><colors><indexedColors><rgbColor rgb=\"ff000000\"/><rgbColor rgb=\"ffffffff\"/><rgbColor rgb=\"ffff0000\"/><rgbColor rgb=\"ff00ff00\"/><rgbColor rgb=\"ff0000ff\"/>' +\n\t'<rgbColor rgb=\"ffffff00\"/><rgbColor rgb=\"ffff00ff\"/><rgbColor rgb=\"ff00ffff\"/><rgbColor rgb=\"ff000000\"/><rgbColor rgb=\"ffffffff\"/><rgbColor rgb=\"ff878787\"/><rgbColor rgb=\"fff9f9f9\"/></indexedColors></colors></styleSheet>\\n'\n\n/**\n * The Office theme the embedded workbook ships, captured verbatim. PowerPoint reads it when a user\n * opens the chart's data, so it has to be exactly the bytes Office writes.\n *\n * Its `<a:fmtScheme>` comes from {@link FMT_SCHEME_XML} rather than sitting inline: `theme1.xml`\n * carried a byte-identical 2661-character copy of it, and one asset transcribed twice is the\n * arrangement where a correction lands in only one of them. The two literals around the splice\n * are unchanged character for character, which the byte-identity gate is what proves.\n * @raw-xml-asset\n */\nconst XLSX_THEME_XML =\n\t'<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\"><a:themeElements><a:clrScheme name=\"Office\"><a:dk1><a:sysClr val=\"windowText\" lastClr=\"000000\"/></a:dk1><a:lt1><a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1><a:dk2><a:srgbClr val=\"44546A\"/></a:dk2><a:lt2><a:srgbClr val=\"E7E6E6\"/></a:lt2><a:accent1><a:srgbClr val=\"4472C4\"/></a:accent1><a:accent2><a:srgbClr val=\"ED7D31\"/></a:accent2><a:accent3><a:srgbClr val=\"A5A5A5\"/></a:accent3><a:accent4><a:srgbClr val=\"FFC000\"/></a:accent4><a:accent5><a:srgbClr val=\"5B9BD5\"/></a:accent5><a:accent6><a:srgbClr val=\"70AD47\"/></a:accent6><a:hlink><a:srgbClr val=\"0563C1\"/></a:hlink><a:folHlink><a:srgbClr val=\"954F72\"/></a:folHlink></a:clrScheme><a:fontScheme name=\"Office\"><a:majorFont><a:latin typeface=\"Calibri Light\" panose=\"020F0302020204030204\"/><a:ea typeface=\"\"/><a:cs typeface=\"\"/><a:font script=\"Jpan\" typeface=\"Yu Gothic Light\"/><a:font script=\"Hang\" typeface=\"맑은 고딕\"/><a:font script=\"Hans\" typeface=\"DengXian Light\"/><a:font script=\"Hant\" typeface=\"新細明體\"/><a:font script=\"Arab\" typeface=\"Times New Roman\"/><a:font script=\"Hebr\" typeface=\"Times New Roman\"/><a:font script=\"Thai\" typeface=\"Tahoma\"/><a:font script=\"Ethi\" typeface=\"Nyala\"/><a:font script=\"Beng\" typeface=\"Vrinda\"/><a:font script=\"Gujr\" typeface=\"Shruti\"/><a:font script=\"Khmr\" typeface=\"MoolBoran\"/><a:font script=\"Knda\" typeface=\"Tunga\"/><a:font script=\"Guru\" typeface=\"Raavi\"/><a:font script=\"Cans\" typeface=\"Euphemia\"/><a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/><a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/><a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/><a:font script=\"Thaa\" typeface=\"MV Boli\"/><a:font script=\"Deva\" typeface=\"Mangal\"/><a:font script=\"Telu\" typeface=\"Gautami\"/><a:font script=\"Taml\" typeface=\"Latha\"/><a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/><a:font script=\"Orya\" typeface=\"Kalinga\"/><a:font script=\"Mlym\" typeface=\"Kartika\"/><a:font script=\"Laoo\" typeface=\"DokChampa\"/><a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/><a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/><a:font script=\"Viet\" typeface=\"Times New Roman\"/><a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/><a:font script=\"Geor\" typeface=\"Sylfaen\"/></a:majorFont><a:minorFont><a:latin typeface=\"Calibri\" panose=\"020F0502020204030204\"/><a:ea typeface=\"\"/><a:cs typeface=\"\"/><a:font script=\"Jpan\" typeface=\"Yu Gothic\"/><a:font script=\"Hang\" typeface=\"맑은 고딕\"/><a:font script=\"Hans\" typeface=\"DengXian\"/><a:font script=\"Hant\" typeface=\"新細明體\"/><a:font script=\"Arab\" typeface=\"Arial\"/><a:font script=\"Hebr\" typeface=\"Arial\"/><a:font script=\"Thai\" typeface=\"Tahoma\"/><a:font script=\"Ethi\" typeface=\"Nyala\"/><a:font script=\"Beng\" typeface=\"Vrinda\"/><a:font script=\"Gujr\" typeface=\"Shruti\"/><a:font script=\"Khmr\" typeface=\"DaunPenh\"/><a:font script=\"Knda\" typeface=\"Tunga\"/><a:font script=\"Guru\" typeface=\"Raavi\"/><a:font script=\"Cans\" typeface=\"Euphemia\"/><a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/><a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/><a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/><a:font script=\"Thaa\" typeface=\"MV Boli\"/><a:font script=\"Deva\" typeface=\"Mangal\"/><a:font script=\"Telu\" typeface=\"Gautami\"/><a:font script=\"Taml\" typeface=\"Latha\"/><a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/><a:font script=\"Orya\" typeface=\"Kalinga\"/><a:font script=\"Mlym\" typeface=\"Kartika\"/><a:font script=\"Laoo\" typeface=\"DokChampa\"/><a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/><a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/><a:font script=\"Viet\" typeface=\"Arial\"/><a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/><a:font script=\"Geor\" typeface=\"Sylfaen\"/></a:minorFont></a:fontScheme>' +\n\tFMT_SCHEME_XML +\n\t'</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/><a:extLst><a:ext uri=\"{05A4C25C-085E-4340-85A3-A5531E510DB2}\"><thm15:themeFamily xmlns:thm15=\"http://schemas.microsoft.com/office/thememl/2012/main\" name=\"Office Theme\" id=\"{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}\" vid=\"{4A3C46E8-61CC-4603-A589-7422A47A8E4A}\"/></a:ext></a:extLst></a:theme>'\n\n/**\n * Build the chart's embedded Excel workbook as a standalone OPC package and\n * return its bytes — the data source PowerPoint opens when a user edits the\n * chart's data. Pure (no zip side effects), so both the package write path\n * ({@link createExcelWorksheet}) and the read-side injection path\n * (`TsPptx.extractSlides`) can reuse it.\n * @param {SlideRelChart} chartObject - chart object\n * @return {Uint8Array} the embedded `.xlsx` package bytes\n */\n// ===== Embedded worksheet =====\n\nexport function buildEmbeddedWorksheet(chartObject: SlideRelChart): Uint8Array {\n\tconst data = chartObject.data\n\n\t{\n\t\t// The embedded workbook is its own OPC package: build it in a nested ZipWriter,\n\t\t// then embed its bytes (no folder scaffolding; fflate emits no directory entries).\n\t\tconst zipExcel = new ZipWriter()\n\t\tconst layout = worksheetLayout(chartObject)\n\n\t\t// B: Add core contents\n\t\t{\n\t\t\tconst override = (partName: string, contentType: string): string =>\n\t\t\t\tvoidEl('Override', { PartName: partName, ContentType: contentType }, { openPrefix: ' ' })\n\t\t\tzipExcel.add(\n\t\t\t\t'[Content_Types].xml',\n\t\t\t\tXML_DECL +\n\t\t\t\t\tel('Types', { xmlns: OOXML_NS.ct }, [\n\t\t\t\t\t\traw(\n\t\t\t\t\t\t\tvoidEl('Default', { Extension: 'rels', ContentType: RELATIONSHIPS_CONTENT_TYPE }, { openPrefix: ' ' })\n\t\t\t\t\t\t),\n\t\t\t\t\t\traw(voidEl('Default', { Extension: 'xml', ContentType: 'application/xml' }, { openPrefix: ' ' })),\n\t\t\t\t\t\traw(override('/xl/workbook.xml', SML_CT + 'sheet.main+xml')),\n\t\t\t\t\t\traw(override('/xl/worksheets/sheet1.xml', SML_CT + 'worksheet+xml')),\n\t\t\t\t\t\traw(override('/xl/theme/theme1.xml', THEME_CONTENT_TYPE)),\n\t\t\t\t\t\traw(override('/xl/styles.xml', SML_CT + 'styles+xml')),\n\t\t\t\t\t\traw(override('/xl/sharedStrings.xml', SML_CT + 'sharedStrings+xml')),\n\t\t\t\t\t\traw(override('/xl/tables/table1.xml', SML_CT + 'table+xml')),\n\t\t\t\t\t\traw(override('/docProps/core.xml', CORE_PROPS_CONTENT_TYPE)),\n\t\t\t\t\t\traw(override('/docProps/app.xml', EXTENDED_PROPS_CONTENT_TYPE)),\n\t\t\t\t\t]) +\n\t\t\t\t\t'\\n'\n\t\t\t)\n\t\t\tzipExcel.add(\n\t\t\t\t'_rels/.rels',\n\t\t\t\tXML_DECL +\n\t\t\t\t\trelationshipsEl([\n\t\t\t\t\t\trelationshipEl('rId1', CORE_PROPS_REL, 'docProps/core.xml'),\n\t\t\t\t\t\trelationshipEl('rId2', EXTENDED_PROPS_REL, 'docProps/app.xml'),\n\t\t\t\t\t\trelationshipEl('rId3', OFFICE_DOCUMENT_REL, 'xl/workbook.xml'),\n\t\t\t\t\t]) +\n\t\t\t\t\t'\\n'\n\t\t\t)\n\t\t\tconst headingPairs = el('vt:vector', { size: 2, baseType: 'variant' }, [\n\t\t\t\traw(el('vt:variant', null, raw(el('vt:lpstr', null, 'Worksheets')))),\n\t\t\t\traw(el('vt:variant', null, raw(el('vt:i4', null, 1)))),\n\t\t\t])\n\t\t\tzipExcel.add(\n\t\t\t\t'docProps/app.xml',\n\t\t\t\tXML_DECL +\n\t\t\t\t\tel(\n\t\t\t\t\t\t'Properties',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\txmlns: OOXML_NS.ep,\n\t\t\t\t\t\t\t'xmlns:vt': OOXML_NS.vt,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\traw(el('Application', null, 'Microsoft Macintosh Excel')),\n\t\t\t\t\t\t\traw(el('DocSecurity', null, 0)),\n\t\t\t\t\t\t\traw(el('ScaleCrop', null, 'false')),\n\t\t\t\t\t\t\traw(el('HeadingPairs', null, raw(headingPairs))),\n\t\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t\t\t'TitlesOfParts',\n\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\traw(el('vt:vector', { size: 1, baseType: 'lpstr' }, raw(el('vt:lpstr', null, 'Sheet1'))))\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\traw(el('Company', null)),\n\t\t\t\t\t\t\traw(el('LinksUpToDate', null, 'false')),\n\t\t\t\t\t\t\traw(el('SharedDoc', null, 'false')),\n\t\t\t\t\t\t\traw(el('HyperlinksChanged', null, 'false')),\n\t\t\t\t\t\t\traw(el('AppVersion', null, '16.0300')),\n\t\t\t\t\t\t]\n\t\t\t\t\t) +\n\t\t\t\t\t'\\n'\n\t\t\t)\n\t\t\t// One reading of the clock for both stamps: two calls make `created` and `modified`\n\t\t\t// disagree whenever the build crosses a millisecond, which no reader notices and\n\t\t\t// every byte-diff does.\n\t\t\tconst now = coreTimestamp()\n\t\t\tzipExcel.add(\n\t\t\t\t'docProps/core.xml',\n\t\t\t\tXML_DECL +\n\t\t\t\t\tel('cp:coreProperties', CORE_PROPS_NS, [\n\t\t\t\t\t\traw(el('dc:creator', null, 'TsPptx')),\n\t\t\t\t\t\traw(el('cp:lastModifiedBy', null, 'TsPptx')),\n\t\t\t\t\t\traw(el('dcterms:created', { 'xsi:type': 'dcterms:W3CDTF' }, now)),\n\t\t\t\t\t\traw(el('dcterms:modified', { 'xsi:type': 'dcterms:W3CDTF' }, now)),\n\t\t\t\t\t])\n\t\t\t)\n\t\t\tzipExcel.add(\n\t\t\t\t'xl/_rels/workbook.xml.rels',\n\t\t\t\tXML_DECL +\n\t\t\t\t\t// Ids are deliberately out of order (3/2/1/4) — that is how this part has\n\t\t\t\t\t// always been emitted, and rel order is byte-significant.\n\t\t\t\t\trelationshipsEl([\n\t\t\t\t\t\trelationshipEl('rId3', OFFICE_REL + 'styles', 'styles.xml'),\n\t\t\t\t\t\trelationshipEl('rId2', THEME_REL, 'theme/theme1.xml'),\n\t\t\t\t\t\trelationshipEl('rId1', OFFICE_REL + 'worksheet', 'worksheets/sheet1.xml'),\n\t\t\t\t\t\trelationshipEl('rId4', OFFICE_REL + 'sharedStrings', 'sharedStrings.xml'),\n\t\t\t\t\t])\n\t\t\t)\n\t\t\tzipExcel.add('xl/styles.xml', XML_DECL + XLSX_STYLES_XML)\n\t\t\tzipExcel.add('xl/theme/theme1.xml', XML_DECL + XLSX_THEME_XML)\n\t\t\tzipExcel.add(\n\t\t\t\t'xl/workbook.xml',\n\t\t\t\tXML_DECL +\n\t\t\t\t\tel(\n\t\t\t\t\t\t'workbook',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\txmlns: SML_NS,\n\t\t\t\t\t\t\t'xmlns:r': OOXML_NS.r,\n\t\t\t\t\t\t\t'xmlns:mc': OOXML_NS.mc,\n\t\t\t\t\t\t\t'mc:Ignorable': 'x15',\n\t\t\t\t\t\t\t'xmlns:x15': 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\traw(voidEl('fileVersion', { appName: 'xl', lastEdited: 7, lowestEdited: 6, rupBuild: 10507 })),\n\t\t\t\t\t\t\traw(voidEl('workbookPr')),\n\t\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t\t\t'bookViews',\n\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t\t\t\tvoidEl('workbookView', {\n\t\t\t\t\t\t\t\t\t\t\txWindow: 0,\n\t\t\t\t\t\t\t\t\t\t\tyWindow: 500,\n\t\t\t\t\t\t\t\t\t\t\twindowWidth: 20960,\n\t\t\t\t\t\t\t\t\t\t\twindowHeight: 15960,\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\traw(el('sheets', null, raw(voidEl('sheet', { name: 'Sheet1', sheetId: 1, 'r:id': 'rId1' })))),\n\t\t\t\t\t\t\traw(voidEl('calcPr', { calcId: 0, concurrentCalc: 0 })),\n\t\t\t\t\t\t]\n\t\t\t\t\t) +\n\t\t\t\t\t'\\n'\n\t\t\t)\n\t\t\tzipExcel.add(\n\t\t\t\t'xl/worksheets/_rels/sheet1.xml.rels',\n\t\t\t\tXML_DECL + relationshipsEl([relationshipEl('rId1', OFFICE_REL + 'table', '../tables/table1.xml')]) + '\\n'\n\t\t\t)\n\t\t}\n\n\t\tzipExcel.add('xl/sharedStrings.xml', buildXlsxSharedStrings(data, layout))\n\t\tzipExcel.add('xl/tables/table1.xml', buildXlsxTable(layout))\n\t\tzipExcel.add('xl/worksheets/sheet1.xml', buildXlsxSheet(data, layout))\n\n\t\t// Done — return the embedded workbook bytes for the caller to place.\n\t\treturn zipExcel.toBytes()\n\t}\n}\n\n/** One category label the sheet writes: its label column (1-based), its row (0-based) and its text. */\ninterface LabelCell {\n\tcol: number\n\trow: number\n\tlabel: string\n}\n\n/**\n * The label cells of a category chart's sheet, outermost level first and down each column: the\n * order their shared strings are written in.\n *\n * A blank label has no cell and no string. The shared-string index of the cell at position `k` is\n * therefore `data.length + 1 + k`, after the blank entry and the series names, whether or not any\n * label before it was blank. The one-level arm used to index every row as if none were, so from\n * the first blank label on each cell read the next label's string or ran past the end.\n * @param data - the chart's series; the labels are {@link labelSeries}'\n */\nfunction categoryLabelCells(data: readonly OptsChartDataInternal[]): LabelCell[] {\n\t// labels[0] is the leaf level and the last is the outermost, which takes column A.\n\treturn dataLabels(labelSeries(data))\n\t\t.slice()\n\t\t.reverse()\n\t\t.flatMap((group, level) =>\n\t\t\tgroup.flatMap((label, row) => (label && label !== '' ? [{ col: level + 1, row, label }] : []))\n\t\t)\n}\n\n/**\n * Build the embedded workbook's `xl/sharedStrings.xml`: the column headers, and on a category sheet a\n * leading blank and the category labels.\n *\n * The headers are the layout's, which the chart part caches as well ({@link seriesHeader}).\n */\nfunction buildXlsxSharedStrings(data: OptsChartDataInternal[], layout: WorksheetLayout): string {\n\tconst headers = layout.columns.map((column) => sharedString(column.header)).join('')\n\tlet count = layout.columns.length\n\tlet uniqueCount = count\n\tlet blank = ''\n\tlet labels = ''\n\tif (layout.kind === 'category') {\n\t\t// A blank, the headers, then every non-blank label. `count` is how many cells refer to a\n\t\t// string: each label column's header points at the blank, then one per header and per label.\n\t\tconst cells = categoryLabelCells(data)\n\t\tcount = layout.labelCols + layout.columns.length + cells.length\n\t\tuniqueCount = 1 + layout.columns.length + cells.length\n\t\tlabels = cells.map((cell) => sharedString(cell.label)).join('')\n\t\t// The leading entry is the blank the header row's label columns point at. Its two spellings\n\t\t// are not interchangeable: `<t/>` is the empty string, `<t xml:space=\"preserve\"></t>` is a\n\t\t// preserved one, and next to character data that difference is content rather than layout.\n\t\tblank =\n\t\t\tlayout.labelCols > 1\n\t\t\t\t? el('si', null, raw(voidEl('t')))\n\t\t\t\t: el('si', null, raw(el('t', { 'xml:space': 'preserve' })))\n\t}\n\treturn XML_DECL + el('sst', { xmlns: SML_NS, count, uniqueCount }, [raw(blank), raw(headers), raw(labels)]) + '\\n'\n}\n\n/**\n * Build the embedded workbook's `xl/tables/table1.xml` (the data table over the sheet range).\n *\n * Its range comes from the same layout as the sheet's `<dimension>`. The two were derived\n * separately once, and the bubble range used the column count as its row count, so one workbook\n * said `ref=\"A1:C3\"` in this part and `<dimension ref=\"A1:C5\"/>` in the other.\n *\n * Each column after the label block is named by its header. A scatter's used to be `X-Values0` and\n * `Y-Value 1`, and a bubble's X column `X-Values`, names no header cell held.\n */\nfunction buildXlsxTable(layout: WorksheetLayout): string {\n\tconst ref = `A1:${getExcelColName(layout.colCount)}${layout.rowCount + 1}`\n\t// The leading columns are the label groups; the named columns follow them.\n\tconst columns =\n\t\tArray.from({ length: layout.labelCols }, (_unused, idx) =>\n\t\t\tvoidEl('tableColumn', { id: idx + 1, name: `Column${idx + 1}` })\n\t\t).join('') + layout.columns.map((column) => voidEl('tableColumn', { id: column.col, name: column.header })).join('')\n\treturn (\n\t\tXML_DECL +\n\t\tel('table', { xmlns: SML_NS, id: 1, name: 'Table1', displayName: 'Table1', ref, totalsRowShown: 0 }, [\n\t\t\traw(el('tableColumns', { count: layout.colCount }, raw(columns))),\n\t\t\traw(\n\t\t\t\tvoidEl('tableStyleInfo', {\n\t\t\t\t\tshowFirstColumn: 0,\n\t\t\t\t\tshowLastColumn: 0,\n\t\t\t\t\tshowRowStripes: 1,\n\t\t\t\t\tshowColumnStripes: 0,\n\t\t\t\t})\n\t\t\t),\n\t\t])\n\t)\n}\n\n/**\n * Build the embedded workbook's `xl/worksheets/sheet1.xml` (header row + per-series data rows).\n */\nfunction buildXlsxSheet(data: OptsChartDataInternal[], layout: WorksheetLayout): string {\n\tconst { labelCols, colCount, rowCount } = layout\n\t/**\n\t * One cell. `t=\"s\"` marks a shared-string index; without it the value is a number.\n\t *\n\t * A gap is written as a present-but-empty `<v></v>`, which is how a missing value has always\n\t * reached this sheet (`?? ''` at the call sites) and which Excel reads back as an empty cell.\n\t * A **non-finite** number is the same thing: `<v>Infinity</v>` (or `NaN`, or `INF`) is not a\n\t * number Excel will parse, and it refuses the whole workbook with 0x3EC rather than skipping\n\t * the cell — a failure PowerPoint hides, because it does not parse the embedding on open. It\n\t * surfaces on \"Edit Data\", by which point the chart's own cache is already clean: `numCachePt`\n\t * (`./chart-parts.ts`) and the chartEx numeric dimension (`./chartex-data.ts`) both drop a\n\t * non-finite point, with a `chart/non-finite-value` warning, before it reaches the chart part.\n\t * Every numeric cell written here is mirrored by one of those caches, so the drop is silent on\n\t * this side rather than warned about twice for the same value.\n\t */\n\tconst cell = (col: number, row: number, value: string | number, shared = false): string => {\n\t\tconst cellValue = typeof value === 'number' && !Number.isFinite(value) ? '' : value\n\t\treturn el('c', { r: `${getExcelColName(col)}${row}`, t: shared ? 's' : undefined }, raw(el('v', null, cellValue)))\n\t}\n\t/** One row, spanning the sheet's full column count. */\n\tconst sheetRow = (row: number, span: number, cells: string): string =>\n\t\tel('row', { r: row, spans: `1:${span}` }, raw(cells))\n\n\t/* EX: a category sheet, labels in A and one column per series:\n\t\t\t\t-|---A---|--B--|--C--|--D--|\n\t\t\t\t1| | Red | Amb | Grn |\n\t\t\t\t2|Jan-17 | 11| 22| 33|\n\t\t\t\t3|Feb-17 | 55| 43| 70|\n\t\t\t\t-|-------|-----|-----|-----|\n\t\t\tA scatter sheet has no label block: X in A and one column per Y series. A bubble sheet\n\t\t\tfollows each Y column with that series' sizes. */\n\tlet rows = ''\n\n\t// Header row. On a category sheet the label columns point at the blank shared string, which the\n\t// column headers follow; an xy sheet has neither, so its first header is string 0.\n\tconst headerOffset = layout.kind === 'category' ? 1 : 0\n\tlet header = ''\n\tfor (let col = 1; col <= labelCols; col++) header += cell(col, 1, 0, true)\n\tlayout.columns.forEach((column, k) => (header += cell(column.col, 1, headerOffset + k, true)))\n\trows += sheetRow(1, colCount, header)\n\n\t// Each non-blank label's cell, by row, in column order. Its shared string follows the blank entry\n\t// and the headers, in the order the strings part writes them.\n\tconst labelsByRow = new Map<number, string>()\n\tif (layout.kind === 'category') {\n\t\tcategoryLabelCells(data).forEach(({ col, row }, k) =>\n\t\t\tlabelsByRow.set(row, (labelsByRow.get(row) ?? '') + cell(col, row + 2, layout.columns.length + 1 + k, true))\n\t\t)\n\t}\n\n\t// One row per category, or per X value. A category-less chartEx layout (a histogram feeds\n\t// PowerPoint raw observations with no labels) has no label groups, so the row count falls back to\n\t// the longest value series and the leading label columns are simply skipped: values land in A.\n\tfor (let idx = 0; idx < rowCount; idx++) {\n\t\tlet cells = labelsByRow.get(idx) ?? ''\n\t\tfor (const column of layout.columns) cells += cell(column.col, idx + 2, column.value(idx) ?? '')\n\t\trows += sheetRow(idx + 2, colCount, cells)\n\t}\n\n\tconst sheetView = el(\n\t\t'sheetViews',\n\t\tnull,\n\t\traw(\n\t\t\tel(\n\t\t\t\t'sheetView',\n\t\t\t\t{ tabSelected: 1, workbookViewId: 0 },\n\t\t\t\traw(voidEl('selection', { activeCell: 'B1', sqref: 'B1' }))\n\t\t\t)\n\t\t)\n\t)\n\treturn (\n\t\tXML_DECL +\n\t\tel(\n\t\t\t'worksheet',\n\t\t\t{\n\t\t\t\txmlns: SML_NS,\n\t\t\t\t'xmlns:r': OOXML_NS.r,\n\t\t\t\t'xmlns:mc': OOXML_NS.mc,\n\t\t\t\t'mc:Ignorable': 'x14ac',\n\t\t\t\t'xmlns:x14ac': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac',\n\t\t\t},\n\t\t\t[\n\t\t\t\traw(voidEl('dimension', { ref: `A1:${getExcelColName(colCount)}${rowCount + 1}` })),\n\t\t\t\traw(sheetView),\n\t\t\t\traw(voidEl('sheetFormatPr', { baseColWidth: 10, defaultRowHeight: 16 })),\n\t\t\t\traw(el('sheetData', null, raw(rows))),\n\t\t\t\traw(voidEl('pageMargins', { left: 0.7, right: 0.7, top: 0.75, bottom: 0.75, header: 0.3, footer: 0.3 })),\n\t\t\t\t// NOTE: Intentionally no `<tableParts>`. A tablePart only works for scatter charts; every\n\t\t\t\t// other chart type reports a \"cannot find linked file\" error. The chart data can be\n\t\t\t\t// edited / range-selected without it, so it is deliberately never emitted.\n\t\t\t]\n\t\t) +\n\t\t'\\n'\n\t)\n}\n\n/**\n * Build the standalone `.rels` for a classic chart part: a single `rId1` relationship to the\n * chart's embedded workbook (`Target`). Package write path only: `appendSlides` builds a chart's\n * relationships through the package model instead.\n * @param {string} embeddingTarget - the workbook target, relative to the chart part\n * @return {string} the chart part's `.rels` XML\n */\nfunction buildChartRelsXml(embeddingTarget: string): string {\n\treturn XML_DECL + relationshipsEl([relationshipEl('rId1', PACKAGE_REL, embeddingTarget)])\n}\n\n/**\n * Build the `.rels` for a chartEx chart part: the embedded workbook (rId1, via `<cx:externalData>`)\n * plus the mandatory color-style (rId2) and chart-style (rId3) sidecar parts. PowerPoint treats a\n * chartEx part without the style/color rels as corrupt, so these are not optional.\n * @param {string} embeddingTarget - workbook target, relative to the chart part\n * @param {string} colorsTarget - `colors{N}.xml`, relative to the chart part\n * @param {string} styleTarget - `style{N}.xml`, relative to the chart part\n */\nfunction buildChartExRelsXml(embeddingTarget: string, colorsTarget: string, styleTarget: string): string {\n\treturn (\n\t\tXML_DECL +\n\t\trelationshipsEl([\n\t\t\trelationshipEl('rId1', PACKAGE_REL, embeddingTarget),\n\t\t\trelationshipEl('rId2', CHART_COLOR_STYLE_REL, colorsTarget),\n\t\t\trelationshipEl('rId3', CHART_STYLE_REL, styleTarget),\n\t\t])\n\t)\n}\n\n/** A chart part's own XML, and a chartEx chart's two sidecars. */\nexport interface ChartPartBodies {\n\tchartXml: string\n\t/** Present exactly for a chartEx chart, which PowerPoint reports as corrupt without both. */\n\tchartEx?: { styleXml: string; colorsXml: string }\n}\n\n/**\n * What a chart's parts contain: `makeXmlChartEx` and the style and colors sidecars for a chartEx\n * chart, `makeXmlCharts` for a classic one.\n *\n * The package writer and slide extraction each made that choice. A chart built as the wrong kind is\n * what used to put a `<c:chartSpace>` with axes and no plot behind a slide still pointing at it\n * through `<cx:chart>`.\n * @param rel - the chart relationship, with its data and options\n */\nexport function chartPartBodies(rel: SlideRelChart): ChartPartBodies {\n\treturn rel.isChartEx\n\t\t? { chartXml: makeXmlChartEx(rel), chartEx: { styleXml: makeChartExStyleXml(), colorsXml: makeChartExColorsXml() } }\n\t\t: { chartXml: makeXmlCharts(rel) }\n}\n\n/**\n * Create the chart's embedded Excel worksheet and add the chart + workbook parts\n * to `zip` (package write path). Slide extraction takes the same contents from\n * {@link buildEmbeddedWorksheet} and {@link chartPartBodies}, and `appendSlides` rebuilds the\n * chart's relationships itself.\n * @param {SlideRelChart} chartObject - chart object\n * @param {ZipWriter} zip - zip writer the resulting XLSX (and chart parts) are added to\n * @return {Promise} promise of generating the XLSX file\n */\nexport async function createExcelWorksheet(chartObject: SlideRelChart, zip: ZipWriter): Promise<string> {\n\tconst names = chartPartNames(chartObject.globalId, chartObject.isChartEx)\n\n\t// 1: Embed the workbook. The xlsx is itself a zip, so STORE it — re-DEFLATING\n\t// already-compressed bytes wastes CPU.\n\tzip.add(`ppt/embeddings/${names.workbookName}`, buildEmbeddedWorksheet(chartObject), { store: true })\n\n\t// 2: Create the chart part, its rels, and (for chartEx) the required style/color sidecar parts.\n\tconst embeddingTarget = `../embeddings/${names.workbookName}`\n\tconst bodies = chartPartBodies(chartObject)\n\tif (bodies.chartEx) {\n\t\t// chartEx charts REQUIRE a chart-style + color-style part or PowerPoint reports the deck as\n\t\t// corrupt (schema-valid but unopenable) — see gen/chart/chartex-style.ts.\n\t\tzip.add(`ppt/charts/${names.colorsName}`, bodies.chartEx.colorsXml)\n\t\tzip.add(`ppt/charts/${names.styleName}`, bodies.chartEx.styleXml)\n\t\tzip.add(\n\t\t\t'ppt/charts/_rels/' + chartObject.fileName + '.rels',\n\t\t\tbuildChartExRelsXml(embeddingTarget, names.colorsName, names.styleName)\n\t\t)\n\t} else {\n\t\tzip.add('ppt/charts/_rels/' + chartObject.fileName + '.rels', buildChartRelsXml(embeddingTarget))\n\t}\n\tzip.add(`ppt/charts/${chartObject.fileName}`, bodies.chartXml)\n\n\treturn ''\n}\n","/**\n * ts-pptx: the chart half of a slide extraction\n *\n * Apart from `gen/extract-slides.ts` for one reason: it names the chart emitters, and extraction\n * is reachable from every program that can build a deck. A module of its own is what lets the\n * extraction load it on a deck that has a chart and never mention it on a deck that has none.\n */\n\nimport type { ExtractedSlide } from '../read/api/presentation-types.js'\nimport type { PresSlideInternal } from '../types/internal.js'\nimport { buildEmbeddedWorksheet, chartPartBodies } from './chart/embed-xlsx.js'\n\n/**\n * Charts: the chart part XML plus its embedded workbook bytes. The chart part's own `.rels`\n * (workbook reference) is rebuilt on injection.\n *\n * chartEx charts are a different part behind a different rel type and content type, and\n * PowerPoint reports one as corrupt without its style/colors sidecars (see\n * gen/chart/chartex-style.ts). Both ride in the descriptor's `chartEx` slot, which is what tells\n * `appendSlides` the two shapes apart: it cannot be inferred from the XML. `chartPartBodies` makes\n * the classic-or-chartEx choice for the package writer too.\n */\nexport function chartsOf(slide: PresSlideInternal): ExtractedSlide['charts'] {\n\treturn (slide._relsChart || []).map((rel) => ({\n\t\trId: rel.rId,\n\t\tembeddingBytes: buildEmbeddedWorksheet(rel),\n\t\t...chartPartBodies(rel),\n\t}))\n}\n","/**\n * ts-pptx: the chart contribution to a written package\n *\n * The expensive one. A chart rel pulls in its `chart.xml`, the embedded workbook PowerPoint opens\n * when the user edits the data, the chart part's own rels, and — for a chartEx chart — the\n * style/colors sidecars without which PowerPoint reports the deck as corrupt. `createExcelWorksheet`\n * reaches every plot module, axis and sidecar builder under `gen/chart/`, which is why the packager\n * must not name it: doing so put ~22 kB gzip of chart code in the graph of a text-only deck.\n *\n * What is *not* here: the pass that assigns each chart rel its `globalId`, filename and Target.\n * That is package-wide ordering rather than chart knowledge — it numbers across slides, layouts and\n * the master before anything is written, and `gen/chart/chartex-xml.ts` derives series GUIDs from\n * the id it hands out — so it stays on the core path in `package/assemble.ts`.\n */\n\nimport type { ZipWriter } from '../../zip.js'\nimport type { ContentTypeDefault, ContentTypeOverride } from '../../gen/opc/content-types.js'\nimport type {\n\tPresentationPropsInternal,\n\tPresSlideInternal,\n\tSlideLayoutInternal,\n\tSlideRelChart,\n} from '../../types/internal.js'\nimport { createExcelWorksheet } from '../../gen/chart/embed-xlsx.js'\nimport { chartPartNames } from '../../gen/chart/part-names.js'\nimport type { PartContributor, PartTarget } from './shared.js'\nimport {\n\tCHART_COLOR_STYLE_CONTENT_TYPE,\n\tCHART_CONTENT_TYPE,\n\tCHART_STYLE_CONTENT_TYPE,\n\tCHARTEX_CONTENT_TYPE,\n\tXLSX_CONTENT_TYPE,\n} from '../../ooxml/rel-types.js'\n\n/** The embedded workbook every chart carries; one Default covers all of them. */\nconst XLSX_DEFAULT: ContentTypeDefault = { extension: 'xlsx', contentType: XLSX_CONTENT_TYPE }\n\n/**\n * Content-type Override(s) for a chart rel. A classic chart is one Override; a chartEx chart is\n * three: the `chartEx{N}.xml` part plus its mandatory `style{N}.xml` and `colors{N}.xml` sidecars\n * (keyed to the same `globalId`).\n */\nfunction chartOverrides(rel: SlideRelChart, leadingSpace = false): ContentTypeOverride[] {\n\tif (!rel.isChartEx) return [{ partName: rel.Target, contentType: CHART_CONTENT_TYPE, leadingSpace }]\n\tconst { styleName, colorsName } = chartPartNames(rel.globalId, true)\n\treturn [\n\t\t{ partName: rel.Target, contentType: CHARTEX_CONTENT_TYPE, leadingSpace },\n\t\t{ partName: `/ppt/charts/${styleName}`, contentType: CHART_STYLE_CONTENT_TYPE, leadingSpace },\n\t\t{ partName: `/ppt/charts/${colorsName}`, contentType: CHART_COLOR_STYLE_CONTENT_TYPE, leadingSpace },\n\t]\n}\n\nexport const chartContributor: PartContributor = {\n\torder: 30,\n\tparts: {\n\t\tfromTargetRels(target: PartTarget, zip: ZipWriter): Promise<unknown>[] {\n\t\t\treturn (target._relsChart || []).map((rel) => createExcelWorksheet(rel, zip))\n\t\t},\n\t},\n\tcontentTypes: {\n\t\tdefaults(pres: PresentationPropsInternal): ContentTypeDefault[] {\n\t\t\tconst targets: Array<PartTarget | undefined> = [...pres.slides, ...pres.slideLayouts, pres.masterSlide]\n\t\t\treturn targets.some((target) => (target?._relsChart || []).length > 0) ? [XLSX_DEFAULT] : []\n\t\t},\n\t\tperSlide(slide: PresSlideInternal): ContentTypeOverride[] {\n\t\t\treturn slide._relsChart.flatMap((rel) => chartOverrides(rel))\n\t\t},\n\t\tperLayout(layout: SlideLayoutInternal): ContentTypeOverride[] {\n\t\t\treturn (layout._relsChart || []).flatMap((rel) => chartOverrides(rel, true))\n\t\t},\n\t\ttrailing(pres: PresentationPropsInternal): ContentTypeOverride[] {\n\t\t\treturn (pres.masterSlide?._relsChart || []).flatMap((rel) => chartOverrides(rel, true))\n\t\t},\n\t},\n}\n","/**\n * ts-pptx: chart slide-object serialization\n *\n * Emits a `chart` slide object as the `<p:graphicFrame>` that references the chart part.\n * Classic charts emit that frame bare; chartEx charts wrap it in `<mc:AlternateContent>` with a\n * plain-shape `<mc:Fallback>` for consumers older than PowerPoint 2016.\n */\n\nimport { ChartType, isChartExType } from '../../../enums.js'\nimport { prstGeomRect } from '../../drawingml/geometry.js'\nimport type { ObjectOptions } from '../../../types/index.js'\nimport { genXmlPlaceholder } from '../../drawingml/text-body.js'\nimport { el, raw, voidEl } from '../../oxml/el.js'\nimport { alternateContentEl } from '../../oxml/alternate-content.js'\nimport { cNvPrEl, graphicFrameEl, type RenderContext, xfrmEl } from './shared.js'\nimport { OOXML_NS } from '../../../ooxml/namespaces.js'\n\n/** The chart types `isChartExType` accepts: the ones emitted as a chartEx part. */\ntype ChartExChartType =\n\t| ChartType.waterfall\n\t| ChartType.funnel\n\t| ChartType.treemap\n\t| ChartType.sunburst\n\t| ChartType.histogram\n\t| ChartType.pareto\n\t| ChartType.boxWhisker\n\t| ChartType.regionMap\n\n/** The first chartEx feature level, which every chartEx type without a later one requires. */\nconst CX1 = { prefix: 'cx1', uri: 'http://schemas.microsoft.com/office/drawing/2015/9/8/chartex' }\n\n/**\n * chartEx feature-version namespace declared on `<mc:Choice Requires>`. Each 2016 chart wave\n * introduced a feature level a consumer must \"understand\" to render the chart; a consumer that\n * doesn't falls through to `<mc:Fallback>`. Keyed by every chartEx `ChartType`, so a lookup cannot\n * miss: the five types that name no later level used to reach `cx1` through a fallback instead.\n */\nconst CHARTEX_FEATURE_NS: Readonly<Record<ChartExChartType, { prefix: string; uri: string }>> = {\n\t[ChartType.waterfall]: CX1,\n\t[ChartType.funnel]: { prefix: 'cx2', uri: 'http://schemas.microsoft.com/office/drawing/2015/10/21/chartex' },\n\t[ChartType.treemap]: CX1,\n\t[ChartType.sunburst]: CX1,\n\t[ChartType.histogram]: CX1,\n\t[ChartType.pareto]: CX1,\n\t[ChartType.boxWhisker]: CX1,\n\t[ChartType.regionMap]: { prefix: 'cx4', uri: 'http://schemas.microsoft.com/office/drawing/2016/5/10/chartex' },\n}\n\n/**\n * Render a `chart` slide object to its `<p:graphicFrame>` XML referencing the chart part.\n *\n * Classic charts emit a bare `<p:graphicFrame>` pointing at a `<c:chart>`. chartEx charts\n * (waterfall, …) instead wrap that graphicFrame in `<mc:AlternateContent>`: an `<mc:Choice>`\n * carrying the `<cx:chart>` reference (rendered by PowerPoint 2016+/Microsoft 365) and an\n * `<mc:Fallback>` placeholder shape shown by every other consumer.\n */\nexport function renderChartObject(ctx: RenderContext): string {\n\tconst {\n\t\tobj: slideItemObj,\n\t\tshapeId,\n\t\tframe: { x, y, cx, cy },\n\t\tplaceholder: placeholderObj,\n\t\titemOpts,\n\t} = ctx\n\t// `itemOpts` is the caller's already-normalized `itemOpts` (see the dispatch in\n\t// `slideObjectToXml`). Read it rather than re-narrowing the field: this function has exactly\n\t// one call site, and a contract stated there beats a defensive re-assignment here.\n\t// A chart's options are really `ChartOptsInternal`; `_type` is not on the broad `ObjectOptions`.\n\tconst chartType = (itemOpts as { _type?: ChartType })._type\n\tconst isChartEx = isChartExType(chartType)\n\n\tconst graphicDataUri = isChartEx ? OOXML_NS.cx : OOXML_NS.c\n\tconst chartChild = isChartEx\n\t\t? voidEl('cx:chart', { 'xmlns:cx': OOXML_NS.cx, 'r:id': `rId${slideItemObj.chartRid}` }, { openPrefix: ' ' })\n\t\t: voidEl('c:chart', { 'r:id': `rId${slideItemObj.chartRid}`, 'xmlns:c': OOXML_NS.c }, { openPrefix: ' ' })\n\n\tconst graphicFrame = graphicFrameEl({\n\t\tnvGraphicFramePr: el(\n\t\t\t'p:nvGraphicFramePr',\n\t\t\tnull,\n\t\t\t[\n\t\t\t\traw(cNvPrEl(shapeId, itemOpts.objectName, itemOpts.altText || '', undefined, { openPrefix: ' ' })),\n\t\t\t\traw(voidEl('p:cNvGraphicFramePr', null, { openPrefix: ' ' })),\n\t\t\t\traw(el('p:nvPr', null, raw(genXmlPlaceholder(placeholderObj)), { openPrefix: ' ' })),\n\t\t\t],\n\t\t\t{ openPrefix: ' ', closePrefix: ' ' }\n\t\t),\n\t\tframe: { x, y, cx, cy },\n\t\turi: graphicDataUri,\n\t\tpayload: chartChild,\n\t\tfmt: {\n\t\t\txfrm: { openPrefix: ' ' },\n\t\t\tgraphic: { openPrefix: ' ', closePrefix: ' ' },\n\t\t\tgraphicData: { openPrefix: ' ', closePrefix: ' ' },\n\t\t\t// PowerPoint redeclares `xmlns:a` on a chart frame's `a:graphic`.\n\t\t\tgraphicAttrs: { 'xmlns:a': OOXML_NS.a },\n\t\t},\n\t})\n\n\tif (!isChartEx) return graphicFrame\n\n\t// chartEx: wrap the graphicFrame in <mc:AlternateContent>. The Choice declares the feature-level\n\t// namespace it Requires; the Fallback is a plain shape so non-2016 consumers show something.\n\treturn alternateContentEl({\n\t\trequires: CHARTEX_FEATURE_NS[chartType as ChartExChartType],\n\t\tchoice: graphicFrame,\n\t\tfallback: renderChartExFallback(shapeId, itemOpts, x, y, cx, cy),\n\t})\n}\n\n/**\n * Build the `<mc:Fallback>` placeholder shape shown when a chartEx chart cannot be rendered\n * (any consumer older than PowerPoint 2016 / Microsoft 365). A light-grey rectangle at the chart's\n * position carrying a short explanatory note — enough that the slide reads sensibly rather than\n * showing a void where the chart would be.\n */\nfunction renderChartExFallback(\n\tshapeId: number,\n\titemOpts: ObjectOptions,\n\tx: number,\n\ty: number,\n\tcx: number,\n\tcy: number\n): string {\n\treturn el('p:sp', null, [\n\t\traw(\n\t\t\tel('p:nvSpPr', null, [\n\t\t\t\traw(cNvPrEl(shapeId, itemOpts.objectName, itemOpts.altText || '')),\n\t\t\t\traw(voidEl('p:cNvSpPr')),\n\t\t\t\traw(voidEl('p:nvPr')),\n\t\t\t])\n\t\t),\n\t\traw(\n\t\t\tel('p:spPr', null, [\n\t\t\t\traw(xfrmEl('a:xfrm', { x, y, cx, cy })),\n\t\t\t\traw(prstGeomRect()),\n\t\t\t\traw(el('a:solidFill', null, raw(voidEl('a:srgbClr', { val: 'F2F2F2' })))),\n\t\t\t\traw(el('a:ln', null, raw(el('a:solidFill', null, raw(voidEl('a:srgbClr', { val: 'BFBFBF' })))))),\n\t\t\t])\n\t\t),\n\t\traw(\n\t\t\tel('p:txBody', null, [\n\t\t\t\traw(voidEl('a:bodyPr')),\n\t\t\t\traw(voidEl('a:lstStyle')),\n\t\t\t\traw(\n\t\t\t\t\tel('a:p', null, [\n\t\t\t\t\t\traw(\n\t\t\t\t\t\t\tel('a:r', null, [\n\t\t\t\t\t\t\t\traw(voidEl('a:rPr', { lang: 'en-US' })),\n\t\t\t\t\t\t\t\traw(el('a:t', null, 'This chart requires PowerPoint 2016 or newer to display.')),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t),\n\t\t\t\t\t])\n\t\t\t\t),\n\t\t\t])\n\t\t),\n\t])\n}\n","/**\n * ts-pptx: Chart Definition\n *\n * `addChartDefinition` normalizes `addChart()` options onto the slide model and registers the\n * chart part rel; the `normalize*` / `clamp*` helpers apply the schema-valid defaults and range\n * clamps. The chart *XML* is emitted later by `gen/chart/chart-xml.ts`.\n */\nimport { isColorValue, namedColorOr } from '../drawingml/color.js'\nimport { asChartType, type CHART_NAME, ChartType, isChartExType, isChartType, SlideObjectType } from '../../enums.js'\nimport { DEF_CHART_BORDER } from '../../constants-internal.js'\nimport { checkEnumOrWarn } from '../../ooxml/check-enum.js'\nimport {\n\tAXIS_ORIENTATIONS,\n\tBAR_3D_SHAPES,\n\tBAR_DIRECTIONS,\n\tBAR_GROUPINGS,\n\tBUILT_IN_UNITS,\n\tCROSS_BETWEEN,\n\tDISPLAY_BLANKS_AS,\n\tERROR_BAR_DIRECTIONS,\n\tERROR_BAR_TYPES,\n\tERROR_BAR_VALUE_TYPES,\n\tGROUPINGS,\n\tLEGEND_POSITIONS,\n\tLINE_DATA_SYMBOLS,\n\tRADAR_STYLE_ALIAS_NAMES,\n\tRADAR_STYLE_ALIASES,\n\tRADAR_STYLES,\n\ttype RadarStyleAlias,\n\tTICK_LABEL_POSITIONS,\n\tTICK_MARKS,\n} from '../../ooxml/st-enums.js'\nimport { defaultChartPalette } from '../chart/chart-parts.js'\nimport { warn } from '../../diagnostics.js'\nimport type { DiagnosticCode } from '../../codes.js'\nimport { InvalidOptionError } from '../../errors.js'\nimport type {\n\tBorderProps,\n\tChartErrorBarOptions,\n\tChartMulti,\n\tChartOpts,\n\tChartPropsAxisCat,\n\tChartPropsAxisSer,\n\tChartPropsAxisVal,\n\tChartPropsDataLabel,\n\tChartSeriesOpts,\n\tOptsChartData,\n\tOptsChartGridLine,\n\tPositionProps,\n} from '../../types/index.js'\nimport { scrubGridLine } from '../chart/chart-stroke.js'\nimport type {\n\tChartErrorBarInternal,\n\tChartMultiInternal,\n\tChartOptsInternal,\n\tChartOptsOverrides,\n\tOptsChartDataInternal,\n\tPresSlideInternal,\n\tSlideObject,\n} from '../../types/internal.js'\nimport { getNewRelId } from '../utils.js'\nimport { resolveObjectName } from './object-name.js'\nimport { resolveAuthoredFrame } from './frame.js'\nimport { setOrClear } from '../../options-internal.js'\nimport { normalizeShadowOptions } from '../drawingml/effect.js'\nimport { clampRangedInput, lineWidthToEmu, mapStated } from '../../units-internal.js'\nimport { isBubbleChart, isStackedGrouping, isXyChart, STOCK_STYLE_SPEC, type StockStyle } from '../chart/chart-kind.js'\nimport { dataSizes, dataValues, worksheetLayout } from '../chart/data-refs.js'\nimport { chartPartNames } from '../chart/part-names.js'\n\n/**\n * Copy one series into the internal shape the emitters read, without touching the caller's object.\n *\n * `labels` is widened to the nested `string[][]` form the multi-level category serializer wants and\n * `_dataIndex` records the series' position. Both used to be assigned back onto the caller's own\n * series object, so `data[0].labels` became `[['A','B','C']]` after `addChart` and any code that\n * reused the same array afterwards (a legend, a table, a second chart) silently saw one nested array\n * instead of three strings.\n *\n * The copy is one level deep on purpose: everything under `src/gen/chart/` is a pure string builder\n * that only reads `values`/`sizes`/`customLabels`/`pointStyles`, so sharing those arrays with the\n * caller is safe. `errorBars` is the exception, rebuilt by {@link normalizeErrorBars}, because it is\n * vetted here and the emitter writes it as it finds it.\n * @param item - caller-supplied series\n * @param index - series position, across all subcharts for a combo chart\n */\nfunction normalizeChartSeries(item: OptsChartData, index: number): OptsChartDataInternal {\n\t// `labels` and `errorBars` are destructured out rather than overwritten so a series with none\n\t// carries no key at all: absent is this model's one spelling of \"no categories\", and the\n\t// emitters read it with `series.labels?.length`, which cannot tell the two apart anyway.\n\tconst { labels, errorBars, ...rest } = item\n\tconst series: OptsChartDataInternal = { ...rest, _dataIndex: index }\n\tif (labels !== undefined) series.labels = Array.isArray(labels[0]) ? (labels as string[][]) : [labels as string[]]\n\tif (errorBars) series.errorBars = normalizeErrorBars(errorBars, item.name ?? `series ${index + 1}`)\n\treturn series\n}\n\n/**\n * A series' error bars, each with its enumerations checked, its amount vetted and its width\n * resolved, so the emitter writes what it reads.\n *\n * All three enumerations were emitted verbatim, so `direction: 'z'` reached `<c:errDir>`, and\n * `value: NaN` wrote `<c:val val=\"NaN\"/>`. The width went through a lenient conversion, so `NaN`\n * became `w=\"0\"` in silence while the series' own stroke threw for the same value; it now takes\n * that stroke's converter.\n *\n * An entry that is not an object is dropped. The emitter skipped one anyway, but it still counted\n * against the one bar a bar or line series keeps.\n * @param errorBars - the caller's bar, or X and Y bars\n * @param series - the series' name, for the diagnostics\n */\nfunction normalizeErrorBars(\n\terrorBars: ChartErrorBarOptions | ChartErrorBarOptions[],\n\tseries: string\n): ChartErrorBarInternal[] {\n\tconst option = `series \"${series}\" errorBars`\n\treturn (Array.isArray(errorBars) ? errorBars : [errorBars])\n\t\t.filter((bar) => bar && typeof bar === 'object')\n\t\t.map((bar) => {\n\t\t\t// oxlint-disable-next-line typescript/no-deprecated -- `size` is the pre-4.0 spelling of `width` and is still honoured.\n\t\t\tconst { width, size, ...rest } = bar\n\t\t\tconst vetted: ChartErrorBarInternal = rest\n\t\t\tif (bar.direction !== undefined && !chartEnum(bar.direction, ERROR_BAR_DIRECTIONS, `${option}.direction`))\n\t\t\t\tdelete vetted.direction\n\t\t\tif (bar.barType !== undefined && !chartEnum(bar.barType, ERROR_BAR_TYPES, `${option}.barType`))\n\t\t\t\tdelete vetted.barType\n\t\t\tif (bar.valueType !== undefined && !chartEnum(bar.valueType, ERROR_BAR_VALUE_TYPES, `${option}.valueType`))\n\t\t\t\tdelete vetted.valueType\n\t\t\tif (bar.value !== undefined && !(typeof bar.value === 'number' && Number.isFinite(bar.value))) {\n\t\t\t\tthrow new InvalidOptionError(\n\t\t\t\t\t'chart/option-non-finite',\n\t\t\t\t\t`${option}.value must be a finite number; received ${String(bar.value)}.`\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst stated = width ?? size\n\t\t\t// Named as the caller spelled it, `width` or the pre-4.0 `size`, so a refusal is actionable.\n\t\t\tif (stated != null)\n\t\t\t\tvetted.widthEmu = lineWidthToEmu(stated, `${option}.${width !== undefined ? 'width' : 'size'}`)\n\t\t\treturn vetted\n\t\t})\n}\n\n/**\n * Report the series whose shape the chart cannot plot as given. Nothing is corrected here: the\n * emitters already cache only what the worksheet has cells for, and this names what that loses.\n *\n * - More values than the chart has points: a category series' values past the category count, or a\n * scatter or bubble series' values or sizes past the X values. The worksheet writes one row per\n * point, so the extra values are in neither the workbook nor the cache.\n * - A bubble series with no sizes, which draws no bubbles.\n * - More than one series on a chart that plots one: pie, doughnut and every chartEx layout plot the\n * first series and ignore the rest, while the workbook still carries them.\n * @param options - the chart's normalized options, for its type\n * @param data - the chart's normalized series\n */\nfunction reportMismatchedSeries(options: ChartOptsInternal, data: OptsChartDataInternal[]): void {\n\tconst type = options._type\n\tconst { rowCount } = worksheetLayout({ data, opts: options })\n\tconst xy = isXyChart(type)\n\tconst points = xy ? 'X values' : 'categories'\n\tfor (const series of xy ? data.slice(1) : data) {\n\t\tconst name = series.name ?? `series ${series._dataIndex + 1}`\n\t\tconst counts: Array<[string, number]> = [['values', dataValues(series).length]]\n\t\tif (isBubbleChart(type)) counts.push(['sizes', dataSizes(series).length])\n\t\tfor (const [what, count] of counts) {\n\t\t\tif (count > rowCount)\n\t\t\t\twarn(\n\t\t\t\t\t'chart/point-count-mismatch',\n\t\t\t\t\t`addChart: \"${name}\" has ${count} ${what} but the chart has ${rowCount} ${points}; the ${what} past ${rowCount} are not plotted.`\n\t\t\t\t)\n\t\t}\n\t\tif (isBubbleChart(type) && rowCount > 0 && dataSizes(series).length === 0)\n\t\t\twarn(\n\t\t\t\t'chart/point-count-mismatch',\n\t\t\t\t`addChart: bubble series \"${name}\" has no sizes, so none of its bubbles are drawn.`\n\t\t\t)\n\t}\n\tconst plotsOneSeries = type === ChartType.pie || type === ChartType.doughnut || isChartExType(type)\n\tif (plotsOneSeries && data.length > 1)\n\t\twarn(\n\t\t\t'chart/point-count-mismatch',\n\t\t\t`addChart: a ${String(type)} chart plots one series; the ${data.length - 1} after the first ${data.length === 2 ? 'is' : 'are'} ignored.`\n\t\t)\n}\n\n/**\n * Copy a caller-supplied `ChartOpts` so the normalization below never writes back onto it.\n *\n * `addChartDefinition` fills in defaults, clamps out-of-range values and deletes invalid keys\n * (`layout.x`, `catGridLine.size`, `dataLabelPosition`, …). Doing that in place mutated the\n * caller's object, which is both surprising on its own and order-dependent when one options\n * object is shared across two charts.\n *\n * Nested objects are copied wherever a normalizer writes into them. `structuredClone` is\n * deliberately not used: it would deep-copy the `ChartMulti[]` on `_type` — breaking the series\n * identity the combo emit path depends on — and throws on a stray function in an untyped\n * caller's option bag.\n * @param opts - caller-supplied chart options\n */\nfunction copyChartOptions(opts: ChartOpts | ChartOptsInternal): ChartOptsInternal {\n\tconst copy: ChartOptsInternal = { ...opts }\n\t// `_type` is derived from the `type` argument below; never inherit a caller-stamped one.\n\tdelete copy._type\n\tif (copy.plotArea) {\n\t\tcopy.plotArea = { ...copy.plotArea }\n\t\tif (copy.plotArea.border) copy.plotArea.border = { ...copy.plotArea.border }\n\t\t// `typeof === 'object'`, not just truthy: `fill` takes a bare colour string as the\n\t\t// solid-fill shorthand, and spreading a string produces `{0:'F',1:'F',…}` — an object\n\t\t// that names neither `color` nor `type`, so `isStatedFill` rejected it and the area\n\t\t// came out `<a:noFill/>`. A string is immutable and needs no defensive copy anyway.\n\t\tif (typeof copy.plotArea.fill === 'object') copy.plotArea.fill = { ...copy.plotArea.fill }\n\t}\n\tif (copy.chartArea) copy.chartArea = { ...copy.chartArea }\n\tif (copy.dataBorder) copy.dataBorder = { ...copy.dataBorder }\n\tif (copy.layout) copy.layout = { ...copy.layout }\n\tif (copy.legendLayout) copy.legendLayout = { ...copy.legendLayout }\n\tif (Array.isArray(copy.catAxes)) copy.catAxes = copy.catAxes.map((axis) => ({ ...axis }))\n\tif (Array.isArray(copy.valAxes)) copy.valAxes = copy.valAxes.map((axis) => ({ ...axis }))\n\tif (copy.catGridLine) copy.catGridLine = { ...copy.catGridLine }\n\tif (copy.valGridLine) copy.valGridLine = { ...copy.valGridLine }\n\tif (copy.serGridLine) copy.serGridLine = { ...copy.serGridLine }\n\treturn copy\n}\n\n/**\n * A border width the emitter can use: a positive, finite number of points.\n *\n * `0` counts as \"not stated\" here and takes the default, which is what the truthiness test\n * this replaces already did. What it adds is `Infinity` and a negative — neither is a width,\n * and a negative one reached `a:ln/@w` as a negative attribute.\n */\nfunction isUsableBorderWidth(width: number | undefined): width is number {\n\treturn typeof width === 'number' && Number.isFinite(width) && width > 0\n}\n\n/**\n * A chart `BorderProps` with its width and colour resolved, or `undefined` when there is no\n * border object at all.\n *\n * The plot area, the chart area and `dataBorder` each normalized the same shape ten lines apart,\n * with three answers. `width: -2, color: 123` took the plot area's defaults in silence, while the\n * chart area wrote `w=\"0\"` and a warned-about black. `color: 'red'` became `F9F9F9` on a data\n * border in silence, and black with a warning on the chart area.\n *\n * - An absent or `0` width is not stated and takes `defaultWidth`. A negative or infinite one warns\n * and takes it too. A width that is not a number throws, as every chart option does.\n * - An absent or empty colour takes `defaultColor`. A colour {@link createColorElement} would not\n * paint warns and takes it too, rather than the emitter's black.\n * @param border - the caller's border, possibly absent or not an object\n * @param spec - this border's defaults, its option name, and which keys survive (all of them when\n * `keep` is omitted)\n */\nfunction normalizeChartBorder(\n\tborder: BorderProps | undefined,\n\tspec: { defaultWidth: number; defaultColor: string; option: string; keep?: readonly (keyof BorderProps)[] }\n): BorderProps | undefined {\n\tif (!border || typeof border !== 'object') return undefined\n\tconst normalized: BorderProps = spec.keep ? {} : { ...border }\n\tfor (const key of spec.keep ?? []) {\n\t\tif (border[key] !== undefined) (normalized as Record<string, unknown>)[key] = border[key]\n\t}\n\n\tconst width = border.width\n\tif (width !== undefined && width !== 0 && (typeof width !== 'number' || Number.isNaN(width))) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'coord/non-finite',\n\t\t\t`${spec.option}.width must be a number of points; received ${String(width)}.`\n\t\t)\n\t}\n\tif (width !== undefined && width !== 0 && !isUsableBorderWidth(width)) {\n\t\twarn(\n\t\t\t'chart/option-out-of-range',\n\t\t\t`${spec.option}.width ${String(width)} is not a positive, finite width; using ${spec.defaultWidth}.`\n\t\t)\n\t}\n\tnormalized.width = isUsableBorderWidth(width) ? width : spec.defaultWidth\n\n\tconst color = namedColorOr(border.color, undefined, `${spec.option}.color`)\n\tif (color !== undefined && !isColorValue(color)) {\n\t\twarn(\n\t\t\t'color/invalid-value',\n\t\t\t`${spec.option}.color \"${String(color)}\" is not a 6-digit hex RGB or scheme colour; using ${spec.defaultColor}.`\n\t\t)\n\t}\n\tnormalized.color = color !== undefined && isColorValue(color) ? color : spec.defaultColor\n\treturn normalized\n}\n\n/**\n * Round and clamp an integer chart option into the range its schema type allows.\n *\n * Several chart attributes are bounded integer types whose out-of-range values make PowerPoint\n * report the package as needing repair: `<c:overlap>` (ST_Overlap, -100..100),\n * `<c:gapWidth>`/`<c:gapDepth>` (ST_GapAmount, 0..500), `<c:holeSize>` (ST_HoleSize, 10..90),\n * `<c:firstSliceAng>` (ST_FirstSliceAng, 0..360) and `<c:size>` (ST_MarkerSize, 2..72).\n *\n * The out-of-range policy is {@link clampRangedInput}'s, which is the library's one policy and\n * says so in its own docblock: a finite value has a nearest legal neighbour, so it clamps and\n * warns; a value that is not a number at all has none, so the request is discarded and that\n * throws. This helper used to answer `undefined` for the second case -- discarding the request\n * and reporting nothing -- so `holeSize: NaN` silently took the default while `holeSize: 200`\n * warned. Same option, same class of mistake, two behaviours.\n *\n * `undefined` in still means `undefined` out: that is the genuine \"unset\" case, and the callers\n * spell their own default with `??` or `setOrClear`.\n *\n * @param value - caller-supplied option value\n * @param min - inclusive lower bound\n * @param max - inclusive upper bound\n * @param name - option name, as the caller spells it, for the diagnostic\n * @param code - the out-of-range diagnostic this option raises\n */\nfunction clampChartInt(\n\tvalue: number | undefined | null,\n\tmin: number,\n\tmax: number,\n\tname: string,\n\tcode: DiagnosticCode = 'chart/option-out-of-range'\n): number | undefined {\n\tif (value === undefined || value === null) return undefined\n\tconst clamped = clampRangedInput(value, min, max, code, name, 'chart/option-non-finite')\n\tconst rounded = Math.round(clamped)\n\t// A fractional in-range value is still coerced, and the caller is still told: these are\n\t// integer types, so `holeSize: 42.5` is as much a correction as `holeSize: 200`.\n\tif (rounded !== clamped) warn(code, `${name} ${String(value)} must be a whole number; using ${rounded}.`)\n\treturn rounded\n}\n\n/** {@link clampChartInt} for the percentage and angle options, which share one diagnostic. */\nfunction clampChartPct(value: number | undefined, min: number, max: number, name: string): number | undefined {\n\treturn clampChartInt(value, min, max, name)\n}\n\n/**\n * `<c:size val>` is ST_MarkerSize: an integer 2..72 points. Two copies of this clamp, with the\n * same bounds and the same message, sat 170 lines apart -- one for the chart-level option and\n * one for a combo subchart's override.\n */\nfunction clampSymbolSize(value: number | undefined | null): number | undefined {\n\treturn clampChartInt(value, 2, 72, 'lineDataSymbolSize', 'chart/symbol-size-out-of-range')\n}\n\n/**\n * Both vocabularies `radarStyle` accepts: `ST_RadarStyle`'s own members and this library's two\n * PowerPoint-UI aliases for them. Validated against the union and normalized to the wire member\n * by {@link normalizeRadarStyle}, so the emitter reads an `ST_RadarStyle` value and nothing else.\n */\nconst RADAR_STYLE_INPUTS = [...RADAR_STYLES, ...RADAR_STYLE_ALIAS_NAMES] as const\n\n/**\n * Resolve `radarStyle` to its wire spelling, defaulting an absent or rejected one to `standard`\n * (the PowerPoint UI's plain \"Radar\"). The alias map is applied after the check rather than\n * before it, so a diagnostic names the value the caller actually wrote.\n */\nfunction normalizeRadarStyle(options: ChartOptsOverrides): void {\n\tconst stated = chartEnum(options.radarStyle, RADAR_STYLE_INPUTS, 'radarStyle')\n\toptions.radarStyle = stated ? (RADAR_STYLE_ALIASES[stated as RadarStyleAlias] ?? stated) : 'standard'\n}\n\n/**\n * `ST_BarGrouping` minus `standard`, which PowerPoint does not offer on a 2-D bar plot.\n */\nconst BAR_GROUPINGS_2D = BAR_GROUPINGS.filter((g) => g !== 'standard')\n\n/**\n * The `ST_DLblPos` members PowerPoint actually offers per plot type. The attribute's own value\n * space is `DATA_LABEL_POSITIONS`; these are the subsets of it a given plot accepts, and a value\n * outside its own plot's subset makes PowerPoint flag the file.\n */\nconst DATA_LABEL_POSITIONS_PIE = ['bestFit', 'ctr', 'inEnd', 'outEnd'] as const\n/** Bubble, line and scatter: the four sides and the centre. */\nconst DATA_LABEL_POSITIONS_POINT = ['b', 'ctr', 'l', 'r', 't'] as const\n/** A stacked or percent-stacked bar has no outside, so `outEnd` is not among its choices. */\nconst DATA_LABEL_POSITIONS_BAR_STACKED = ['ctr', 'inBase', 'inEnd'] as const\n/** A clustered bar adds `outEnd` to the stacked set. */\nconst DATA_LABEL_POSITIONS_BAR_CLUSTERED = ['ctr', 'inBase', 'inEnd', 'outEnd'] as const\n\n/**\n * Check one chart option against the values the library accepts for it, reporting and dropping\n * an unrecognized one so the caller's own default can stand.\n *\n * The definer hand-rolled about twenty of these as bare `Array.includes` tests with the list\n * written inline -- three of the lists twice, verbatim -- and every one was silent, while\n * `correctGridLineOptions` a few lines away reported the same class of mistake under its own\n * code. One wrapper puts them all on the reporting policy `check-enum.ts` describes.\n * @param value - the caller's value, if any\n * @param valid - the values this option accepts\n * @param option - option name as the caller spells it\n * @returns the value when accepted, else `null`\n */\nfunction chartEnum<T extends string>(value: string | undefined, valid: readonly T[], option: string): T | null {\n\treturn checkEnumOrWarn(value, valid, 'chart/invalid-option-value', `chart: ${option}`)\n}\n\n/** The axis options one bag can carry: the chart's own, or one `catAxes[]` / `valAxes[]` entry. */\ntype AxisOptions = ChartPropsAxisCat & ChartPropsAxisVal & ChartPropsAxisSer\n\n/** The enumerated axis options, each emitted verbatim into its attribute. */\nconst AXIS_ENUM_OPTIONS = [\n\t['catAxisOrientation', AXIS_ORIENTATIONS],\n\t['valAxisOrientation', AXIS_ORIENTATIONS],\n\t['serAxisOrientation', AXIS_ORIENTATIONS],\n\t['catAxisLabelPos', TICK_LABEL_POSITIONS],\n\t['valAxisLabelPos', TICK_LABEL_POSITIONS],\n\t['serAxisLabelPos', TICK_LABEL_POSITIONS],\n\t['catAxisMajorTickMark', TICK_MARKS],\n\t['catAxisMinorTickMark', TICK_MARKS],\n\t['valAxisMajorTickMark', TICK_MARKS],\n\t['valAxisMinorTickMark', TICK_MARKS],\n\t['valAxisCrossBetween', CROSS_BETWEEN],\n\t['valAxisDisplayUnit', BUILT_IN_UNITS],\n] as const satisfies ReadonlyArray<readonly [keyof AxisOptions, readonly string[]]>\n\n/** `c:majorUnit` / `c:minorUnit`, both `ST_AxisUnit`: a double above 0. */\nconst AXIS_UNIT_OPTIONS = ['catAxisMajorUnit', 'catAxisMinorUnit', 'valAxisMajorUnit', 'valAxisMinorUnit'] as const\n/** `c:max` / `c:min`, both `ST_Double`. */\nconst AXIS_BOUND_OPTIONS = ['catAxisMaxVal', 'catAxisMinVal', 'valAxisMaxVal', 'valAxisMinVal'] as const\n\n/**\n * Vet the axis options the axis builders write as they find them.\n *\n * One bar chart could carry `<c:majorUnit val=\"-5\"/>`, `<c:logBase val=\"1\"/>`,\n * `<c:orientation val=\"up\"/>` and `<c:tickLblPos val=\"bogus\"/>` without a word, and a `NaN` bound\n * vanished because the emitter tested `x || x === 0`. The `catAxes[]` and `valAxes[]` overrides are\n * spread over the chart's options at emit time, after every other check, so each entry is vetted\n * here too, under the name the caller reaches it by.\n *\n * - An enumeration outside its `ST_` type warns and is dropped, so the builder's default stands.\n * The time units are not here: whether one has a slot depends on the axis tag, which only the\n * builder knows (`validTimeUnit`).\n * - A unit that is not a number above 0 warns and is dropped, as `ST_AxisUnit` excludes 0.\n * - `valAxisLogScaleBase` clamps into `ST_LogBase` (2-1000) with a warning, and `NaN` throws.\n * - A bound that is not a finite number throws. It has no nearest legal neighbour, and dropping it\n * rescales the axis the caller pinned.\n *\n * `null` counts as unset, as it does for the chart clamps.\n * @param axis - the bag to correct in place\n * @param prefix - how the caller reaches this bag: `''` for the chart's own, `'valAxes[1].'` for an entry\n */\nfunction normalizeAxisOptions(axis: AxisOptions, prefix: string): void {\n\tfor (const [key, valid] of AXIS_ENUM_OPTIONS) {\n\t\tif (axis[key] != null && !chartEnum(axis[key], valid, prefix + key)) delete axis[key]\n\t}\n\tfor (const key of AXIS_UNIT_OPTIONS) {\n\t\tconst unit = axis[key]\n\t\tif (unit == null) continue\n\t\tif (typeof unit !== 'number' || !Number.isFinite(unit) || unit <= 0) {\n\t\t\twarn('chart/option-out-of-range', `\"${prefix}${key}\" must be a number above 0; ignoring ${String(unit)}.`)\n\t\t\tdelete axis[key]\n\t\t}\n\t}\n\tfor (const key of AXIS_BOUND_OPTIONS) {\n\t\tconst bound = axis[key]\n\t\tif (bound != null && (typeof bound !== 'number' || !Number.isFinite(bound))) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'chart/option-non-finite',\n\t\t\t\t`${prefix}${key} must be a finite number; received ${String(bound)}.`\n\t\t\t)\n\t\t}\n\t}\n\tif (axis.valAxisLogScaleBase != null) {\n\t\taxis.valAxisLogScaleBase = clampRangedInput(\n\t\t\taxis.valAxisLogScaleBase,\n\t\t\t2,\n\t\t\t1000,\n\t\t\t'chart/option-out-of-range',\n\t\t\t`${prefix}valAxisLogScaleBase`,\n\t\t\t'chart/option-non-finite'\n\t\t)\n\t}\n}\n\n/**\n * Drop each `x`/`y`/`w`/`h` of a manual layout that is not a fraction of the chart, warning, so that\n * axis stays automatic. Shared by the plot area's `layout` and `legendLayout`; the legend's used to\n * reach `<c:x val=\"NaN\"/>` and `<c:w val=\"-1\"/>` while the same values on `layout` warned.\n *\n * `w`/`h` take the open range: a plot area of zero width or height is inside 0-1 and paints nothing,\n * and the emitter used to turn it into a full-bleed plot with `|| 1`, the caller's zero silently\n * becoming the largest value the option has. Rejecting it here is what lets the emitter default\n * with `??`.\n *\n * A key the caller left out is not checked, since each axis of `CT_ManualLayout` is independent. The\n * check used to report every absent key of `layout` as out of range. A numeric string that passes is\n * stored as the number, which the legend emitter needs to write it at all.\n * @param layout - the layout to correct in place\n * @param option - option name as the caller spells it\n */\nfunction normalizeManualLayout(layout: PositionProps | undefined, option: string): void {\n\tif (!layout || typeof layout !== 'object') return\n\tfor (const key of ['x', 'y', 'w', 'h'] as const) {\n\t\tconst val = layout[key]\n\t\tif (val === undefined) continue\n\t\tconst numVal = Number(val)\n\t\tconst zeroAllowed = key === 'x' || key === 'y'\n\t\tif (!Number.isFinite(numVal) || numVal > 1 || numVal < 0 || (!zeroAllowed && numVal === 0)) {\n\t\t\twarn(\n\t\t\t\t'chart/layout-out-of-range',\n\t\t\t\t`${option}.${key} can only be ${zeroAllowed ? '0-1' : 'greater than 0 and at most 1'}`\n\t\t\t)\n\t\t\tdelete layout[key]\n\t\t} else {\n\t\t\tlayout[key] = numVal\n\t\t}\n\t}\n}\n\n/** `dataLabelFormatScatter`'s values, keyed off its type so a member added there is a compile error here. */\nconst SCATTER_LABEL_FORMATS = Object.keys({ custom: true, customXY: true, XY: true } satisfies Record<\n\tNonNullable<ChartPropsDataLabel['dataLabelFormatScatter']>,\n\ttrue\n>) as ReadonlyArray<NonNullable<ChartPropsDataLabel['dataLabelFormatScatter']>>\n\n/** The stock styles, read off the table the plot builder lays a stock chart out from. */\nconst STOCK_STYLES = Object.keys(STOCK_STYLE_SPEC) as readonly StockStyle[]\n\n/**\n * Drop `dataLabelPosition` values that are invalid for the chart type / bar grouping,/**\n * Drop `dataLabelPosition` values that are invalid for the chart type / bar grouping,\n * per the OOXML data-label placement rules, so PowerPoint does not flag the file.\n *\n * `chartType` is passed in rather than read off `options._type` so the combo path can run the\n * same rules per subchart: a combo chart's `_type` is a `ChartMulti[]`, which matches none of\n * the comparisons below (see {@link normalizeComboSubchartOptions}).\n * @param options - options bag to correct in place\n * @param chartType - the plot type these options are emitted for, if known\n */\nfunction normalizeChartDataLabelPosition(options: ChartOptsOverrides, chartType: ChartType | undefined): void {\n\tif (!options.dataLabelPosition) return\n\tconst allowed = dataLabelPositionsFor(chartType, options.barGrouping)\n\tif (allowed === null) return\n\tif (allowed.length === 0 || !chartEnum(options.dataLabelPosition, allowed, 'dataLabelPosition')) {\n\t\tdelete options.dataLabelPosition\n\t}\n}\n\n/**\n * The `ST_DLblPos` values one plot accepts, or `null` where this library states no rule.\n *\n * An empty list means the plot takes no position at all: `<c:dLblPos>` on an area, 3-D bar,\n * doughnut or radar chart is a PowerPoint repair prompt whatever its value.\n *\n * The bar row is the one that was wrong, and wrong in the direction that hurts: the list\n * *containing* `outEnd` was applied when the grouping was NOT clustered and the list without it\n * when the grouping was NOT stacked, so `{ barGrouping: 'clustered', dataLabelPosition:\n * 'outEnd' }` -- the most ordinary combination there is -- was silently deleted, while the\n * stacked form that PowerPoint itself refuses was kept. Settled against PowerPoint over COM:\n * setting `DataLabels.Position` to `xlLabelPositionOutsideEnd` on a clustered column chart is\n * accepted and reads back, and on a stacked or 100%-stacked one it raises 0x80004005, while\n * inside-end, inside-base and centre are accepted on all three.\n *\n * `barGrouping` is already defaulted by the time this runs -- {@link normalizeChartBarGrouping}\n * gives a 2-D bar `clustered` -- so there is no third arm for \"no grouping stated\".\n */\nfunction dataLabelPositionsFor(\n\tchartType: ChartType | undefined,\n\tbarGrouping: string | undefined\n): readonly string[] | null {\n\tswitch (chartType) {\n\t\tcase ChartType.area:\n\t\tcase ChartType.bar3d:\n\t\tcase ChartType.doughnut:\n\t\tcase ChartType.radar:\n\t\t\treturn []\n\t\tcase ChartType.pie:\n\t\t\treturn DATA_LABEL_POSITIONS_PIE\n\t\tcase ChartType.line:\n\t\tcase ChartType.scatter:\n\t\t\treturn DATA_LABEL_POSITIONS_POINT\n\t\tcase ChartType.bar:\n\t\t\treturn isStackedGrouping(barGrouping) ? DATA_LABEL_POSITIONS_BAR_STACKED : DATA_LABEL_POSITIONS_BAR_CLUSTERED\n\t\tdefault:\n\t\t\treturn isBubbleChart(chartType) ? DATA_LABEL_POSITIONS_POINT : null\n\t}\n}\n\n/**\n * Correct `barGrouping` to a value `<c:grouping>` (ST_Grouping) accepts for the given chart type.\n *\n * Split out of `addChartDefinition` for the same reason as\n * {@link normalizeChartDataLabelPosition}: the combo path needs it per subchart, keyed to that\n * subchart's own type.\n * @param options - options bag to correct in place\n * @param chartType - the plot type these options are emitted for, if known\n */\nfunction normalizeChartBarGrouping(options: ChartOptsOverrides, chartType: ChartType | undefined): void {\n\t// An area plot writes `<c:grouping>` (ST_Grouping), which has no clustered form; the two bar\n\t// plots write the `<c:grouping>` inside `c:barChart`/`c:bar3DChart`, which is ST_BarGrouping.\n\t// A 2-D bar additionally has no `standard`, PowerPoint offering clustered in its place.\n\tif (chartType === ChartType.area) {\n\t\tif (!chartEnum(options.barGrouping, GROUPINGS, 'barGrouping')) options.barGrouping = 'standard'\n\t}\n\tif (chartType === ChartType.bar) {\n\t\tif (!chartEnum(options.barGrouping, BAR_GROUPINGS_2D, 'barGrouping')) options.barGrouping = 'clustered'\n\t}\n\tif (chartType === ChartType.bar3d) {\n\t\tif (!chartEnum(options.barGrouping, BAR_GROUPINGS, 'barGrouping')) options.barGrouping = 'standard'\n\t}\n}\n\n/**\n * Resolve everything a plot builder reads off an options bag: its enumerations, its bounded numbers,\n * its outline, shadow and series-line shapes, and the defaults that depend on the plot type.\n *\n * A single-type chart runs this once, on its own options. A combo chart runs it on its own options\n * with no `plotType`, which resolves everything that does not depend on one, and then once per\n * subchart, on the subchart's options merged over the chart's and keyed to the subchart's own type\n * ({@link normalizeComboSubchartOptions}). So every step is idempotent: a second pass over a value\n * the first pass resolved changes nothing and says nothing. That is why the marker line width stays\n * in points here and `serMarker` converts it, since converting twice would draw a hairline.\n *\n * A subchart used to go through thirteen hand-listed keys. Its `shadow` reached the part as\n * `<a:weirdShdw>`, its `dataBorder` skipped the border defaults, its `radarStyle` was written as\n * given, a scatter subchart took no label format and drew no labels, and a clustered bar under a\n * stacked chart took the stacked gap.\n * @param options - the bag to correct in place\n * @param plotType - the plot these options are emitted for; `undefined` for a combo chart's own options\n * @param callerSetGap - whether the caller stated `barGapWidthPct` for this plot, at either level\n */\nfunction normalizePlotOptions(\n\toptions: ChartOptsOverrides,\n\tplotType: ChartType | undefined,\n\tcallerSetGap: boolean\n): void {\n\t// Enumerations emitted verbatim: `<c:barDir>` (ST_BarDir), `<c:grouping>`, `<c:shape>` (ST_Shape),\n\t// `<c:symbol>` (ST_MarkerStyle), `<c:radarStyle>` (ST_RadarStyle).\n\tif (!chartEnum(options.barDir, BAR_DIRECTIONS, 'barDir')) options.barDir = 'col'\n\tnormalizeChartBarGrouping(options, plotType)\n\tif (!chartEnum(options.bar3DShape, BAR_3D_SHAPES, 'bar3DShape')) options.bar3DShape = 'box'\n\tif (!chartEnum(options.lineDataSymbol, LINE_DATA_SYMBOLS, 'lineDataSymbol')) options.lineDataSymbol = 'circle'\n\tnormalizeRadarStyle(options)\n\t// Depends on the corrected grouping, so it runs after it.\n\t// REFERENCE: https://docs.microsoft.com/en-us/openspecs/office_standards/ms-oi29500/e2b1697c-7adc-463d-9081-3daef72f656f?redirectedfrom=MSDN\n\tnormalizeChartDataLabelPosition(options, plotType)\n\n\t// `<c:gapWidth>`/`<c:gapDepth>` are ST_GapAmount (integer 0..500), `<c:overlap>` ST_Overlap\n\t// (integer -100..100), `<c:holeSize>` ST_HoleSize (10..90), `<c:firstSliceAng>` ST_FirstSliceAng\n\t// (0..360). An unstated gap width is decided per plot: a stacked group takes the narrower 50 and\n\t// anything else 150. \"Stated\" is any value other than absent, `0` and `NaN` included, and the clamp\n\t// reports the second.\n\toptions.barGapWidthPct = callerSetGap\n\t\t? (clampChartPct(options.barGapWidthPct, 0, 500, 'barGapWidthPct') ?? 150)\n\t\t: isStackedGrouping(options.barGrouping)\n\t\t\t? 50\n\t\t\t: 150\n\toptions.barGapDepthPct = clampChartPct(options.barGapDepthPct, 0, 500, 'barGapDepthPct') ?? 150\n\t// These three have no default, so a value the clamp rejects has to *leave*, not become an explicit\n\t// `undefined`: a bag is spread over another (the axis builders merge `catAxes[n]`/`valAxes[n]` onto\n\t// the chart's), where a present-but-undefined key overrides and an absent one inherits.\n\tsetOrClear(options, 'barOverlapPct', clampChartPct(options.barOverlapPct, -100, 100, 'barOverlapPct'))\n\tsetOrClear(options, 'holeSize', clampChartPct(options.holeSize, 10, 90, 'holeSize'))\n\tsetOrClear(options, 'firstSliceAng', clampChartPct(options.firstSliceAng, 0, 360, 'firstSliceAng'))\n\t// Marker size emits as `<c:size val>` (ST_MarkerSize): an integer in [2,72] points.\n\toptions.lineDataSymbolSize = clampSymbolSize(options.lineDataSymbolSize) ?? 6\n\t// `a:ln/@w` is ST_LineWidth, so an out-of-range width clamps rather than collapsing to a hairline.\n\t// `0` means what leaving it out means, the 0.75pt default.\n\toptions.lineDataSymbolLineSize =\n\t\tmapStated(options.lineDataSymbolLineSize, (width) =>\n\t\t\tclampRangedInput(width, 0, 1584, 'line/width-out-of-range', 'lineDataSymbolLineSize', 'coord/non-finite')\n\t\t) ?? 0.75\n\n\t// `barSeriesLine` reaches the gridline emitter through the gridline shape. Scrubbed on a copy,\n\t// because `scrubGridLine` mutates and the object is the caller's. `true` is the \"let PowerPoint\n\t// style it\" spelling and carries nothing to scrub.\n\tif (options.barSeriesLine && options.barSeriesLine !== true) {\n\t\toptions.barSeriesLine = { ...options.barSeriesLine }\n\t\tscrubGridLine(options.barSeriesLine, 'chart.barSeriesLine')\n\t}\n\tsetOrClear(options, 'shadow', normalizeShadowOptions(options.shadow))\n\t// Tested against `undefined`, not truthiness. `0` is a stated opacity, a fully transparent fill\n\t// that makes the series invisible. `NaN` has no nearest legal value, so it throws.\n\tif (options.chartColorsOpacity !== undefined) {\n\t\toptions.chartColorsOpacity = clampRangedInput(\n\t\t\toptions.chartColorsOpacity,\n\t\t\t0,\n\t\t\t100,\n\t\t\t'chart/option-out-of-range',\n\t\t\t'chartColorsOpacity',\n\t\t\t'chart/option-non-finite'\n\t\t)\n\t}\n\t// `dataBorder`'s defaults are `createDataBorderLine`'s, so an unstated width or colour paints as\n\t// it did when the emitter supplied them.\n\tsetOrClear(\n\t\toptions,\n\t\t'dataBorder',\n\t\tnormalizeChartBorder(options.dataBorder, { defaultWidth: 0.75, defaultColor: '363636', option: 'dataBorder' })\n\t)\n\t// A stated width, `NaN` included, reaches `seriesStroke`, whose converter clamps a negative one\n\t// and refuses a value that is not a number.\n\toptions.lineSize = options.lineSize ?? 2\n\n\t// A scatter's label format defaults to `custom`. A value it does not recognise matched none of the\n\t// plot builder's three arms, so `showLabel` drew no labels and said nothing.\n\tif (!chartEnum(options.dataLabelFormatScatter, SCATTER_LABEL_FORMATS, 'dataLabelFormatScatter')) {\n\t\tif (plotType === ChartType.scatter) options.dataLabelFormatScatter = 'custom'\n\t\telse delete options.dataLabelFormatScatter\n\t}\n\t// The label number format's default depends on the plot, so a combo chart's own options leave it\n\t// to each subchart.\n\tif (plotType !== undefined) {\n\t\tif (!options.dataLabelFormatCode && plotType === ChartType.scatter) options.dataLabelFormatCode = 'General'\n\t\tif (!options.dataLabelFormatCode && (plotType === ChartType.pie || plotType === ChartType.doughnut)) {\n\t\t\toptions.dataLabelFormatCode = options.showPercent ? '0%' : 'General'\n\t\t}\n\t\toptions.dataLabelFormatCode =\n\t\t\toptions.dataLabelFormatCode && typeof options.dataLabelFormatCode === 'string'\n\t\t\t\t? options.dataLabelFormatCode\n\t\t\t\t: '#,##0'\n\t}\n}\n\n/**\n * Apply plotArea option defaults: show* toggles, axis-line visibility, and the 3D view angles.\n */\nfunction normalizeChartPlotAreaOptions(options: ChartOptsInternal): void {\n\t// The eleven `show*` toggles are deliberately NOT defaulted here. Each one used to carry\n\t// a statement of the form `x = x || !x ? x : <default>`, but `a || !a` is true for every\n\t// value of `a`, so the alternative never ran and the whole statement was an identity\n\t// assignment. Every consumer reads these as plain truthiness (`opts.showPercent ? 1 : 0`,\n\t// `!opts.showDataTableKeys ? 0 : 1`), which makes an absent option behave as `false` — and\n\t// that is what the public types document (`@default false` on `showDataTable`,\n\t// `showPercent`, `v3DRAngAx`). Removing the dead statements changes no emitted byte;\n\t// *applying* the defaults those ternaries appear to promise would, so do not \"restore\"\n\t// them without treating it as the behavior change it is.\n\t// The three `*AxisLineShow` defaults that used to sit here are gone: they wrote `true` over\n\t// an absent flag, and the axis emitter now folds the flag into a stroke where only an\n\t// explicit `false` says anything (`type: 'none'`). Defaulting it was the last thing keeping\n\t// \"the caller said nothing\" and \"the caller said yes\" distinguishable, and nothing read the\n\t// distinction.\n\n\t// `<c:rotX>` is ST_RotX (-90..90), `<c:rotY>` ST_RotY (0..360) and `<c:perspective>`\n\t// ST_Perspective (0..240), all integers. They go through the chart clamp like every other bounded\n\t// chart option: an out-of-range value used to be replaced by 30 without a word, so `v3DRotX: 200`\n\t// came out further from what the caller asked than the bound it had passed.\n\toptions.v3DRotX = clampChartInt(options.v3DRotX, -90, 90, 'v3DRotX') ?? 30\n\toptions.v3DRotY = clampChartInt(options.v3DRotY, 0, 360, 'v3DRotY') ?? 30\n\t// v3DRAngAx: same dead-ternary shape as the show* block above, same reason for its absence.\n\toptions.v3DPerspective = clampChartInt(options.v3DPerspective, 0, 240, 'v3DPerspective') ?? 30\n}\n\n/** The five data-label font fields, which every per-series `<c:dLbls>` builder reads. */\nconst SERIES_LABEL_FONT_FIELDS = [\n\t'dataLabelColor',\n\t'dataLabelFontBold',\n\t'dataLabelFontFace',\n\t'dataLabelFontItalic',\n\t'dataLabelFontSize',\n] as const\n\n/**\n * Which {@link ChartSeriesOpts} fields each plot builder actually reads.\n *\n * The check this drives is per FIELD, not per chart type, because \"the caller said it and nothing\n * happened\" does not stop at the type boundary: `lineSize` reaches a stroke only where a series\n * draws one, so it was accepted and dropped on `bar`/`bar3d`/`area` even though those types read\n * every other field. A stock chart is the extreme of the same shape -- its price series draw no\n * line by design and its `<c:dLbls>` is a constant, so `color` is the only field with a referent.\n *\n * A type absent from this table supports nothing: a pie colours *points* rather than series and a\n * surface colours bands, so a per-series override has no referent on either even in principle.\n *\n * Keep each row in step with the builder named beside it. The rows are the only statement of what\n * is wired; nothing derives them from the emitters, so a field threaded through a builder without\n * being added here goes on warning that it does nothing.\n */\nconst SERIES_OPTION_FIELDS: ReadonlyMap<ChartType, ReadonlySet<keyof ChartSeriesOpts>> = new Map([\n\t// `makeCatAxisPlot`: `serShapeProps` + `serDataLabels`. `lineSize` reaches `seriesStroke` only\n\t// for the two line-like types; a bar or an area takes its outline from `dataBorder` instead.\n\t[ChartType.area, new Set(['color', ...SERIES_LABEL_FONT_FIELDS, 'dataLabelFormatCode'] as const)],\n\t[ChartType.bar, new Set(['color', ...SERIES_LABEL_FONT_FIELDS, 'dataLabelFormatCode'] as const)],\n\t[ChartType.bar3d, new Set(['color', ...SERIES_LABEL_FONT_FIELDS, 'dataLabelFormatCode'] as const)],\n\t[ChartType.line, new Set(['color', 'lineSize', ...SERIES_LABEL_FONT_FIELDS, 'dataLabelFormatCode'] as const)],\n\t[ChartType.radar, new Set(['color', 'lineSize', ...SERIES_LABEL_FONT_FIELDS, 'dataLabelFormatCode'] as const)],\n\t// `makeScatterPlot`: `scatterSerShapeProps`, plus `labelFontAttrs`/`labelFontChildren` inside\n\t// both label builders. Neither emits a `<c:numFmt>`, so `dataLabelFormatCode` has no referent.\n\t[ChartType.scatter, new Set(['color', 'lineSize', ...SERIES_LABEL_FONT_FIELDS] as const)],\n\t// `makeBubblePlot`: `bubbleSerShapeProps`. Its `<c:dLbls>` is one chart-level block, not one\n\t// per series, so no data-label field can be resolved per series.\n\t[ChartType.bubble, new Set(['color', 'lineSize'] as const)],\n\t[ChartType.bubble3d, new Set(['color', 'lineSize'] as const)],\n\t// `makeStockPlot`: the volume bar's fill and the close-series marker.\n\t[ChartType.stock, new Set(['color'] as const)],\n])\n\n/**\n * The `ChartOpts` keys a chartEx chart (waterfall, funnel, treemap, sunburst, histogram, pareto,\n * box and whisker, region map) acts on. Everything else is accepted by the type and read by no part\n * of a chartEx chart, which PowerPoint styles from its own chart-style sidecar parts instead.\n *\n * Keep these in step with what `makeXmlChartEx` (`gen/chart/chartex-xml.ts`) and the chart frame\n * (`gen/slide/objects/chart.ts`) read. Nothing derives them from those, so a key threaded through\n * the emitter without being added here goes on warning that it does nothing.\n *\n * The frame and the call itself: placement, name, alt text, placeholder and the type.\n */\nconst CHARTEX_FRAME_KEYS = ['type', 'x', 'y', 'w', 'h', 'objectName', 'altText', 'placeholder'] as const\n/** `makeXmlChartEx`: title, legend and data labels. */\nconst CHARTEX_CHART_KEYS = [\n\t'showTitle',\n\t'title',\n\t'titleColor',\n\t'titleFontFace',\n\t'lang',\n\t'showLegend',\n\t'legendPos',\n\t'showValue',\n\t'showLabel',\n] as const\n/** The option one layout reads into its `<cx:layoutPr>`, and no other layout does. */\nconst CHARTEX_LAYOUT_KEYS: Partial<Record<ChartType, string>> = {\n\t[ChartType.waterfall]: 'subtotals',\n\t[ChartType.histogram]: 'binning',\n\t[ChartType.boxWhisker]: 'statistics',\n\t[ChartType.regionMap]: 'geography',\n}\n\n/**\n * Warn about each option a chartEx chart accepts and ignores, read off the caller's own options\n * before any default is filled in, so only what the caller stated is named.\n *\n * `legendPos: 'tr'` is honoured in part: a chartEx legend has no top-right position, so it sits at\n * the top, and that is said too.\n * @param stated - the caller's options, before normalization\n * @param type - the chart type\n */\nfunction reportChartExOptions(stated: ChartOptsInternal, type: ChartType): void {\n\tconst layoutKey = CHARTEX_LAYOUT_KEYS[type]\n\tconst read: string[] = [...CHARTEX_CHART_KEYS, ...(layoutKey ? [layoutKey] : [])]\n\tconst allowed = new Set<string>([...CHARTEX_FRAME_KEYS, ...read])\n\tconst ignored = Object.keys(stated)\n\t\t.filter((key) => (stated as Record<string, unknown>)[key] !== undefined && !allowed.has(key))\n\t\t.sort()\n\tif (ignored.length > 0) {\n\t\twarn(\n\t\t\t'chart/option-not-supported',\n\t\t\t`addChart: ${ignored.map((key) => `\"${key}\"`).join(', ')} ${ignored.length === 1 ? 'has' : 'have'} no effect on a ${type} chart, which reads ${read.join('/')} besides its position and name.`\n\t\t)\n\t}\n\tif (stated.legendPos === 'tr') {\n\t\twarn(\n\t\t\t'chart/option-not-supported',\n\t\t\t`addChart: a ${type} chart has no top-right legend; legendPos \"tr\" places it at the top.`\n\t\t)\n\t}\n}\n\n/**\n * Resolve the options that belong to the chart as a whole rather than to one plot: the palette, the\n * plot-area and chart-area borders and fills, the category axis' multi-level labels and a waterfall's\n * subtotals. The plot's own options are {@link normalizePlotOptions}'.\n */\nfunction normalizeChartOptions(options: ChartOptsInternal): void {\n\t// An empty array is not a palette, so it means what saying nothing means: the built-in\n\t// default for this chart type. It used to survive this pass (`Array.isArray([])` is true)\n\t// and meet the plot builders' fallback instead, which was the *bar* palette on every type —\n\t// so `{ chartColors: [] }` on a pie was neither the caller's colours nor the pie default.\n\toptions.chartColors = options.chartColors?.length ? options.chartColors : defaultChartPalette(options._type)\n\toptions.plotArea = options.plotArea || {}\n\tsetOrClear(\n\t\toptions.plotArea,\n\t\t'border',\n\t\tnormalizeChartBorder(options.plotArea.border, {\n\t\t\tdefaultWidth: DEF_CHART_BORDER.width,\n\t\t\tdefaultColor: DEF_CHART_BORDER.color,\n\t\t\toption: 'plotArea.border',\n\t\t})\n\t)\n\toptions.plotArea.fill = options.plotArea.fill || {}\n\toptions.chartArea = options.chartArea || {}\n\t// Only the three keys the chart-area emitter reads survive: `type` and `dashType` are dropped,\n\t// as they always have been here.\n\tsetOrClear(\n\t\toptions.chartArea,\n\t\t'border',\n\t\tnormalizeChartBorder(options.chartArea.border, {\n\t\t\tdefaultWidth: DEF_CHART_BORDER.width,\n\t\t\tdefaultColor: DEF_CHART_BORDER.color,\n\t\t\toption: 'chartArea.border',\n\t\t\tkeep: ['color', 'width', 'transparency'],\n\t\t})\n\t)\n\toptions.chartArea.roundedCorners =\n\t\ttypeof options.chartArea.roundedCorners === 'boolean' ? options.chartArea.roundedCorners : true\n\n\tif (\n\t\toptions._type === ChartType.area ||\n\t\toptions._type === ChartType.bar ||\n\t\toptions._type === ChartType.bar3d ||\n\t\toptions._type === ChartType.line\n\t) {\n\t\toptions.catAxisMultiLevelLabels = !!options.catAxisMultiLevelLabels\n\t} else {\n\t\tdelete options.catAxisMultiLevelLabels\n\t}\n\n\tif (options._type === ChartType.waterfall && options.subtotals !== undefined) {\n\t\t// <cx:subtotals> holds zero-based category indices; drop non-integer / negative entries\n\t\t// (they would make PowerPoint report the chartEx part as needing repair). Warn per the\n\t\t// library's warn-rather-than-degrade policy.\n\t\tconst clean = (Array.isArray(options.subtotals) ? options.subtotals : []).filter((idx) => {\n\t\t\tconst ok = typeof idx === 'number' && Number.isInteger(idx) && idx >= 0\n\t\t\tif (!ok)\n\t\t\t\twarn(\n\t\t\t\t\t'chart/invalid-subtotal-index',\n\t\t\t\t\t`chart waterfall subtotal index \"${String(idx)}\" is not a non-negative integer; entry skipped.`\n\t\t\t\t)\n\t\t\treturn ok\n\t\t})\n\t\tif (clean.length > 0) options.subtotals = clean\n\t\telse delete options.subtotals\n\t}\n}\n\n/**\n * Resolve one combo subchart's options against its own plot type.\n *\n * A subchart's `ChartMulti.options` is a whole `ChartOpts`, merged over the chart's options only at\n * emit time (`gen/chart/chart-xml.ts`). So the bag vetted here is the one the emitter will read,\n * `{ ...chartOptions, ...subOptions }`, and it goes through {@link normalizePlotOptions} keyed to the\n * subchart's type: the chart's own `_type` is the subchart list, which matches no plot.\n *\n * What comes back is still a sparse override: the caller's keys, plus every key whose value the pass\n * changed, found by comparing the corrected bag with the merged one. A key the pass removed comes\n * back as a present `undefined`, which suppresses the chart's value at emit time (see\n * {@link ChartOptsOverrides}). This used to write back thirteen hand-listed keys, and every option\n * off the list reached the part as the caller wrote it.\n * @param subOptions - caller-supplied `ChartMulti.options` (never written to)\n * @param chartOptions - the chart's own options, through the type-agnostic pass\n * @param subType - this subchart's own plot type\n * @param callerSetBarGapWidthPct - whether the caller supplied a chart-level `barGapWidthPct`\n */\nfunction normalizeComboSubchartOptions(\n\tsubOptions: ChartOptsOverrides | undefined,\n\tchartOptions: ChartOptsInternal,\n\tsubType: ChartType,\n\tcallerSetBarGapWidthPct: boolean\n): ChartOptsOverrides {\n\tconst sub: ChartOptsOverrides = subOptions && typeof subOptions === 'object' ? subOptions : {}\n\tconst merged: Record<string, unknown> = { ...chartOptions, ...sub }\n\tconst fixed: Record<string, unknown> = { ...merged }\n\tnormalizePlotOptions(fixed, subType, callerSetBarGapWidthPct || sub.barGapWidthPct != null)\n\n\tconst result: Record<string, unknown> = { ...sub }\n\tfor (const key of new Set([...Object.keys(merged), ...Object.keys(fixed)])) {\n\t\tif (fixed[key] !== merged[key]) result[key] = fixed[key]\n\t}\n\treturn result\n}\n\n/**\n * Generate the chart based on input data.\n * OOXML Chart Spec: ISO/IEC 29500-1:2016(E)\n *\n * @param {CHART_NAME | ChartMulti[]} `type` should belong to: 'column', 'pie'\n * @param {[]} `data` a JSON object with follow the following format\n * @param {ChartOptsInternal} `opt` chart options\n * @param {PresSlideInternal} `target` slide object that the chart will be added to\n * @return {object} chart object\n * {\n * title: 'eSurvey chart',\n * data: [\n * {\n * name: 'Income',\n * labels: ['2005', '2006', '2007', '2008', '2009'],\n * values: [23.5, 26.2, 30.1, 29.5, 24.6]\n * },\n * {\n * name: 'Expense',\n * labels: ['2005', '2006', '2007', '2008', '2009'],\n * values: [18.1, 22.8, 23.9, 25.1, 25]\n * }\n * ]\n * }\n */\nexport function addChartDefinition(\n\ttarget: PresSlideInternal,\n\ttype: CHART_NAME | ChartMulti[],\n\tdata: OptsChartData[] | ChartOpts,\n\topt?: ChartOptsInternal\n): object {\n\t// Placeholder part identity, unique only within this target. The authoritative,\n\t// package-unique chart part filename is assigned at write time by a per-presentation\n\t// pass in `buildPackageParts` (`package/assemble.ts`, STEP 2). A module-global counter\n\t// here was never reset, so two identical decks built in one process emitted different\n\t// chart part filenames — same input, different bytes.\n\tconst chartId = target._relsChart.length + 1\n\tconst resultObject: SlideObject = {\n\t\t_type: SlideObjectType.chart,\n\t}\n\t// DESIGN: `type` can an object (ex: `ChartType.doughnut`) or an array of chart objects\n\t// EX: addChartDefinition([ { type:ChartType.bar, data:{name:'', labels:[], values[]} }, {<etc>} ])\n\t// Multi-Type Charts\n\tlet tmpOpt: ChartOpts | ChartOptsInternal | undefined\n\tlet tmpData: OptsChartDataInternal[] = []\n\tlet tmpTypes: ChartMultiInternal[] | undefined\n\tif (Array.isArray(type)) {\n\t\t// For multi-type charts there needs to be data for each type, as well as a single data\n\t\t// source for non-series operations. The series are indexed across subcharts to keep the\n\t\t// data in order when segmented into types.\n\t\t//\n\t\t// The whole `ChartMulti[]` is rebuilt around the normalized copies, not just flattened\n\t\t// into `tmpData`: the combo emit path plots each subchart from `opts._type[i].data`\n\t\t// (see gen/chart/chart-xml.ts), so both views have to reference the same series objects.\n\t\tlet seriesIndex = 0\n\t\ttmpTypes = type.map((obj) => {\n\t\t\tconst seriesData = (Array.isArray(obj.data) ? obj.data : []).map((item) =>\n\t\t\t\tnormalizeChartSeries(item, seriesIndex++)\n\t\t\t)\n\t\t\ttmpData = tmpData.concat(seriesData)\n\t\t\treturn { ...obj, data: seriesData }\n\t\t})\n\t\ttmpOpt = !Array.isArray(data) && data && typeof data === 'object' ? data : opt\n\t} else {\n\t\ttmpData = (Array.isArray(data) ? data : []).map(normalizeChartSeries)\n\t\ttmpOpt = opt\n\t}\n\t// Everything below normalizes onto this copy; the caller's options object is a read-only input.\n\tconst options: ChartOptsInternal = copyChartOptions(tmpOpt && typeof tmpOpt === 'object' ? tmpOpt : {})\n\t// Captured before normalization fills in the default, so the combo pass below can tell an\n\t// explicit gap width from an inherited one.\n\tconst callerSetBarGapWidthPct = options.barGapWidthPct != null\n\n\t// STEP 1: Set default options/decode user options\n\t// A: Core\n\t// The `type` is checked against the catalog here, at the boundary, because neither emitter can:\n\t// `makeChartType` and `chartExLayoutId` each own half of `ChartType` and treat the other half as\n\t// not theirs, so an off-catalog string matches no arm anywhere and would otherwise reach the deck\n\t// as a chart frame with no plot inside it.\n\tfor (const name of tmpTypes ? tmpTypes.map((sub) => sub.type) : [type as CHART_NAME]) {\n\t\tif (!isChartType(name)) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'chart/unknown-type',\n\t\t\t\t`addChart: \"${String(name)}\" is not a chart type. Valid types are: ${Object.values(ChartType).join(', ')}.`,\n\t\t\t\t{ detail: { type: name } }\n\t\t\t)\n\t\t}\n\t}\n\t// PowerPoint does not combine a bubble chart with any other plot, another bubble chart included.\n\t// A combo holding one opens as corrupt (0x80070570) whether its sizes carry a workbook\n\t// reference, a literal or nothing at all, while the same bubble chart alone opens and a bar and\n\t// scatter combo opens. The combo workbook has no size columns either, so there is nothing to\n\t// repair here short of a different chart.\n\tif (tmpTypes?.some((sub) => isBubbleChart(asChartType(sub.type)))) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'chart/bubble-in-combo',\n\t\t\t'addChart: a bubble chart cannot be combined with other chart types; PowerPoint refuses the deck. Add it as a chart of its own.',\n\t\t\t{ detail: { types: tmpTypes.map((sub) => sub.type) } }\n\t\t)\n\t}\n\t// Before `_type` and any default lands on the copy, so it holds exactly what the caller stated.\n\tif (!tmpTypes && isChartExType(type)) reportChartExOptions(options, asChartType(type as CHART_NAME))\n\toptions._type = tmpTypes ?? asChartType(type as CHART_NAME)\n\t// Default only what the caller omitted. The guard used to be `!isNaN(Number(x))`, which is\n\t// false for every `Coord` that is not a bare number — so `x: '50%'` and `x: '2in'` were\n\t// thrown away and replaced by 1 inch, and a `NaN` was too, silently. `getSmartParseNumber`\n\t// is what vets a coordinate, and it reports a bad one instead of guessing.\n\tObject.assign(options, resolveAuthoredFrame(options, { x: 1, y: 1, w: '50%', h: '50%' }, 'addChart'))\n\t// Was the one definer still counting `_slideObjects` for its default name, which numbers a\n\t// chart by how many charts are *currently* on the slide rather than by how many have been\n\t// added — the difference `nextObjectNameIdx` exists for.\n\toptions.objectName = resolveObjectName(target, SlideObjectType.chart, {\n\t\tlabel: 'Chart',\n\t\tkind: 'chart',\n\t\tsupplied: options.objectName,\n\t})\n\n\t// B: Options: the plot. A combo chart's own `_type` is its subchart list, which is no plot, so only\n\t// the type-agnostic half runs here, and each subchart runs the whole pass in E below.\n\tnormalizePlotOptions(options, Array.isArray(options._type) ? undefined : options._type, callerSetBarGapWidthPct)\n\t// dataLabelBkgrdColors: same dead-ternary shape as the show* block in\n\t// normalizeChartPlotAreaOptions, same reason for its absence.\n\tif (!chartEnum(options.legendPos, LEGEND_POSITIONS, 'legendPos')) options.legendPos = 'r'\n\tif (!chartEnum(options.displayBlanksAs, DISPLAY_BLANKS_AS, 'displayBlanksAs')) options.displayBlanksAs = 'gap'\n\t// `layout` allows the override of PPT defaults to maximize space\n\tnormalizeManualLayout(options.layout, 'chart.layout')\n\tnormalizeManualLayout(options.legendLayout, 'chart.legendLayout')\n\tnormalizeAxisOptions(options, '')\n\toptions.catAxes?.forEach((axis, idx) => normalizeAxisOptions(axis, `catAxes[${idx}].`))\n\toptions.valAxes?.forEach((axis, idx) => normalizeAxisOptions(axis, `valAxes[${idx}].`))\n\n\t// Set gridline defaults\n\tconst scatterGrid: OptsChartGridLine = { color: 'D9D9D9', width: 1 }\n\toptions.catGridLine =\n\t\toptions.catGridLine || (options._type === ChartType.scatter ? { ...scatterGrid } : { type: 'none' })\n\toptions.valGridLine = options.valGridLine || (options._type === ChartType.scatter ? { ...scatterGrid } : {})\n\toptions.serGridLine =\n\t\toptions.serGridLine || (options._type === ChartType.scatter ? { ...scatterGrid } : { type: 'none' })\n\tscrubGridLine(options.catGridLine)\n\tscrubGridLine(options.valGridLine)\n\tscrubGridLine(options.serGridLine)\n\n\t// C: Options: plotArea\n\tnormalizeChartPlotAreaOptions(options)\n\n\t// D: Options: chart\n\tnormalizeChartOptions(options)\n\n\t// D.1: A stated `seriesOptions` field that no plot builder reads is the third state the option\n\t// rules forbid -- \"the caller said it and nothing happened\" -- so each one is named against the\n\t// type that will drop it. The check is per field because the gaps are per field: a `lineSize` on\n\t// a bar series and a `dataLabelFormatCode` on a scatter series are both accepted by the type and\n\t// reach nothing in the part.\n\tif (options.seriesOptions?.length) {\n\t\tconst types = (Array.isArray(options._type) ? options._type.map((sub) => sub.type) : [options._type]).map((name) =>\n\t\t\tasChartType(name)\n\t\t)\n\t\tconst stated = new Set(\n\t\t\toptions.seriesOptions.flatMap((entry) =>\n\t\t\t\tentry ? (Object.keys(entry) as Array<keyof ChartSeriesOpts>).filter((key) => entry[key] !== undefined) : []\n\t\t\t)\n\t\t)\n\t\tfor (const type of new Set(types)) {\n\t\t\tconst supported = SERIES_OPTION_FIELDS.get(type)\n\t\t\tconst dropped = [...stated].filter((field) => !supported?.has(field)).sort()\n\t\t\tif (dropped.length > 0) {\n\t\t\t\twarn(\n\t\t\t\t\t'chart/option-not-supported',\n\t\t\t\t\t`\"seriesOptions\" ${dropped.map((field) => `\\`${field}\\``).join(', ')} ${dropped.length === 1 ? 'has' : 'have'} no effect on ${type}; ${supported ? `that plot reads ${[...supported].sort().join('/')} only` : 'that plot colours points or bands rather than series'}. Style them through the chart-level options.`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\t// E: Options: combo subcharts\n\t// A `ChartMulti` entry's options override the chart-level ones at emit time, so they have to\n\t// go through the same clamps and enum corrections — keyed to that subchart's own plot type.\n\tif (Array.isArray(options._type)) {\n\t\toptions._type.forEach((sub) => {\n\t\t\t// Safe to assign: these entries are the copies built above, not the caller's objects.\n\t\t\tsub.options = normalizeComboSubchartOptions(sub.options, options, asChartType(sub.type), callerSetBarGapWidthPct)\n\t\t})\n\t}\n\n\t// Stock charts require their series in a fixed order (see `stockStyle`); default to the\n\t// three-value High-Low-Close style and warn (rather than corrupt) when the number of data\n\t// series doesn't match the style, since PowerPoint expects an exact count per style.\n\tif (options._type === ChartType.stock) {\n\t\t// The same table the plot builder lays the series out from — a second copy here is how the\n\t\t// warning and the emitted chart came to disagree about what a style expects.\n\t\t// A style it does not recognise used to become `hlc` in silence.\n\t\tconst stockStyle = chartEnum(options.stockStyle, STOCK_STYLES, 'stockStyle') ?? 'hlc'\n\t\toptions.stockStyle = stockStyle\n\t\tconst expected = STOCK_STYLE_SPEC[stockStyle].seriesCount\n\t\tif (tmpData.length !== expected) {\n\t\t\twarn(\n\t\t\t\t'chart/stock-series-count',\n\t\t\t\t`stock chart style \"${options.stockStyle}\" expects ${expected} data series (got ${tmpData.length}); the chart may not render as intended.`\n\t\t\t)\n\t\t}\n\t}\n\n\treportMismatchedSeries(options, tmpData)\n\n\t// STEP 4: Set props\n\tresultObject._type = SlideObjectType.chart\n\tresultObject.options = options\n\tresultObject.chartRid = getNewRelId(target)\n\n\t// STEP 5: Add this chart to this Slide Rels (rId/rels count spans all slides! Count all images to get next rId)\n\t// chartEx charts (waterfall, …) live alongside classic charts in `ppt/charts/` but use the\n\t// `chartEx{N}.xml` name, the `chartex+xml` content type and the MS chartEx rel type. The\n\t// authoritative, package-unique filename is (re)assigned at write time in\n\t// `buildPackageParts` (`package/assemble.ts`); this placeholder mirrors the same\n\t// Ex-prefix rule so a single-chart deck is already correct.\n\tconst isChartEx = isChartExType(options._type)\n\tconst { fileName, target: chartTarget } = chartPartNames(chartId, isChartEx)\n\ttarget._relsChart.push({\n\t\trId: getNewRelId(target),\n\t\tdata: tmpData,\n\t\topts: options,\n\t\ttype: options._type,\n\t\tglobalId: chartId,\n\t\tisChartEx,\n\t\tfileName,\n\t\tTarget: chartTarget,\n\t})\n\n\ttarget._slideObjects.push(resultObject)\n\treturn resultObject\n}\n","/**\n * ts-pptx: the chart construct family\n *\n * The expensive one: `addChart` reaches every plot module, axis and sidecar builder under\n * `gen/chart/`, which is what a program that never draws a chart is paying for when a slide method\n * names it by import.\n */\n\nimport { chartsOf } from '../gen/extract-charts.js'\nimport { chartContributor } from '../package/parts/chart.js'\nimport { SlideObjectType, type CHART_NAME } from '../enums.js'\nimport { renderChartObject } from '../gen/slide/objects/chart.js'\n\nimport { InvalidOptionError } from '../errors.js'\nimport type { ChartMulti, OptsChartData } from '../types/index.js'\nimport { addChartDefinition } from '../gen/define/chart.js'\nimport type { ConstructFamily } from './shared.js'\n\n/** Distinguish a multi-type (combo) chart array (`ChartMulti[]`) from a single chart's data (`OptsChartData[]`). */\nfunction isMultiChart(arg: OptsChartData[] | ChartMulti[]): arg is ChartMulti[] {\n\tconst first = arg[0] as Partial<ChartMulti> | undefined\n\treturn !!first && typeof first === 'object' && 'type' in first && 'data' in first\n}\n\nexport const chartFamily = {\n\tname: 'chart',\n\tauthors: {\n\t\taddChart(slide, arg1, arg2) {\n\t\t\tlet type: CHART_NAME | ChartMulti[]\n\t\t\tlet data: OptsChartData[]\n\n\t\t\tconst options = arg2 ?? {}\n\t\t\tif (Array.isArray(arg1) && isMultiChart(arg1)) {\n\t\t\t\t// Multi-type (combo) chart: addChart(ChartMulti[], options?)\n\t\t\t\ttype = arg1\n\t\t\t\tdata = []\n\t\t\t} else {\n\t\t\t\t// Canonical single-type form: addChart(data, { type, ...options })\n\t\t\t\tdata = arg1 ?? []\n\t\t\t\tconst optType = options.type\n\t\t\t\tif (!optType) {\n\t\t\t\t\tthrow new InvalidOptionError(\n\t\t\t\t\t\t'chart/missing-type',\n\t\t\t\t\t\t'addChart: a chart `type` is required on the options object, e.g. addChart(data, { type: ChartType.bar }).'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\ttype = optType\n\t\t\t}\n\n\t\t\t// `_type` is set by `addChartDefinition` on its own copy of the options -- stamping it here\n\t\t\t// too would write an internal field onto the caller's object for no gain.\n\t\t\t// addChartDefinition's multi-type branch reads the shared options from its `data` slot\n\t\t\tif (Array.isArray(type)) addChartDefinition(slide, type, options, undefined)\n\t\t\telse addChartDefinition(slide, type, data, options)\n\t\t},\n\t},\n\tchildren: {\n\t\tchart(target, child) {\n\t\t\taddChartDefinition(target, child.type, child.data, child.options || {})\n\t\t},\n\t},\n\trenderers: {\n\t\t[SlideObjectType.chart]: renderChartObject,\n\t},\n\tparts: chartContributor,\n\textract: { charts: chartsOf },\n} satisfies ConstructFamily\n","/**\n * ts-pptx: comment parts\n *\n * Resolve every slide's comments into a deck-wide author registry with per-author\n * numbering, then emit the presentation-level `commentAuthors.xml` and each\n * slide's `comments/commentN.xml` part.\n */\n\nimport { CRLF, XML_DECL } from '../../constants-internal.js'\nimport type { ResolvedCommentAuthor, SlideComment } from '../../types/index.js'\nimport type { PresSlideInternal } from '../../types/internal.js'\nimport { inch2Emu } from '../../units-internal.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\nimport { PML_ROOT_NS } from '../../ooxml/namespaces.js'\n\n/** Result of resolving every slide's comments into a deck-wide author registry + per-comment numbering. */\ninterface ResolvedComments {\n\t/** Authors in first-appearance order, ready to serialize to `commentAuthors.xml`. */\n\tauthors: ResolvedCommentAuthor[]\n\t/** Per-comment `authorId`/`idx` keyed by the stored comment object. */\n\tmeta: Map<SlideComment, { authorId: number; idx: number }>\n}\n\n/**\n * Walk every slide's comments and build the deck-wide author registry + per-comment numbering.\n *\n * Legacy comments number each comment with a *per-author* 1-based `idx`; an author's `lastIdx` is the\n * highest `idx` it used. Authors are keyed by `name`+`initials` and assigned ids in first-appearance\n * order (slide order, then insertion order). `clrIdx` mirrors `id` (one colour slot per author).\n * @param {PresSlideInternal[]} slides - all presentation slides\n * @return {ResolvedComments} the author list and per-comment metadata\n */\nexport function resolveCommentAuthors(slides: PresSlideInternal[]): ResolvedComments {\n\tconst byKey = new Map<string, ResolvedCommentAuthor>()\n\tconst authors: ResolvedCommentAuthor[] = []\n\tconst perAuthorCount = new Map<number, number>()\n\tconst meta = new Map<SlideComment, { authorId: number; idx: number }>()\n\n\t;(slides || []).forEach((slide) => {\n\t\t;(slide._comments || []).forEach((comment) => {\n\t\t\tconst key = comment.author + '\\0' + comment.initials\n\t\t\tlet author = byKey.get(key)\n\t\t\tif (!author) {\n\t\t\t\tauthor = {\n\t\t\t\t\tid: authors.length,\n\t\t\t\t\tname: comment.author,\n\t\t\t\t\tinitials: comment.initials,\n\t\t\t\t\tlastIdx: 0,\n\t\t\t\t\tclrIdx: authors.length,\n\t\t\t\t}\n\t\t\t\tbyKey.set(key, author)\n\t\t\t\tauthors.push(author)\n\t\t\t\tperAuthorCount.set(author.id, 0)\n\t\t\t}\n\t\t\tconst idx = (perAuthorCount.get(author.id) ?? 0) + 1\n\t\t\tperAuthorCount.set(author.id, idx)\n\t\t\tauthor.lastIdx = idx\n\t\t\tmeta.set(comment, { authorId: author.id, idx })\n\t\t})\n\t})\n\n\treturn { authors, meta }\n}\n\n/**\n * Creates the presentation-level `ppt/commentAuthors.xml` part (`<p:cmAuthorLst>`).\n * @param {ResolvedCommentAuthor[]} authors - resolved deck-wide author registry\n * @return {string} XML\n */\nexport function makeXmlCommentAuthors(authors: ResolvedCommentAuthor[]): string {\n\tconst cmAuthors = authors\n\t\t.map((author) =>\n\t\t\tvoidEl('p:cmAuthor', {\n\t\t\t\tid: author.id,\n\t\t\t\tname: author.name,\n\t\t\t\tinitials: author.initials,\n\t\t\t\tlastIdx: author.lastIdx,\n\t\t\t\tclrIdx: author.clrIdx,\n\t\t\t})\n\t\t)\n\t\t.join('')\n\treturn (\n\t\tXML_DECL +\n\t\tCRLF +\n\t\tel(\n\t\t\t'p:cmAuthorLst',\n\t\t\t{\n\t\t\t\t...PML_ROOT_NS,\n\t\t\t},\n\t\t\traw(cmAuthors)\n\t\t)\n\t)\n}\n\n/**\n * Creates a per-slide comments part `ppt/comments/comment{N}.xml` (`<p:cmLst>`).\n * @param {PresSlideInternal} slide - the slide whose comments are serialized\n * @param {Map} meta - per-comment `authorId`/`idx` from {@link resolveCommentAuthors}\n * @return {string} XML\n */\nexport function makeXmlComments(\n\tslide: PresSlideInternal,\n\tmeta: Map<SlideComment, { authorId: number; idx: number }>\n): string {\n\tconst cms = (slide._comments || [])\n\t\t.map((comment) => {\n\t\t\tconst m = meta.get(comment)\n\t\t\tif (!m) return '' // defensive: comment must have been seen by resolveCommentAuthors\n\t\t\t// Child order is fixed by CT_Comment: <p:pos> then <p:text>. pos x/y are ST_Coordinate (EMU).\n\t\t\treturn el('p:cm', { authorId: m.authorId, dt: comment.date || null, idx: m.idx }, [\n\t\t\t\traw(voidEl('p:pos', { x: Math.round(inch2Emu(comment.x)), y: Math.round(inch2Emu(comment.y)) })),\n\t\t\t\traw(el('p:text', null, comment.text)),\n\t\t\t])\n\t\t})\n\t\t.join('')\n\treturn (\n\t\tXML_DECL +\n\t\tCRLF +\n\t\tel(\n\t\t\t'p:cmLst',\n\t\t\t{\n\t\t\t\t...PML_ROOT_NS,\n\t\t\t},\n\t\t\traw(cms)\n\t\t)\n\t)\n}\n","/**\n * ts-pptx: the comments contribution to a written package\n *\n * The deck-wide author registry (`ppt/commentAuthors.xml`) plus one comment part per slide that\n * has comments. A deck with no comments writes neither, so the registry is resolved once here and\n * the whole contribution collapses to nothing.\n */\n\nimport type { ZipWriter } from '../../zip.js'\nimport type { ContentTypeOverride } from '../../gen/opc/content-types.js'\nimport type { PresentationPropsInternal } from '../../types/internal.js'\nimport { makeXmlCommentAuthors, makeXmlComments, resolveCommentAuthors } from '../../gen/slide/comments.js'\nimport { commentPath, overrideName } from '../../gen/opc/part-paths.js'\nimport type { PartContributor } from './shared.js'\nimport { COMMENT_AUTHORS_CONTENT_TYPE, COMMENTS_CONTENT_TYPE } from '../../ooxml/rel-types.js'\n\nconst COMMENT_AUTHORS_PATH = 'ppt/commentAuthors.xml'\n\nexport const commentsContributor: PartContributor = {\n\torder: 20,\n\tparts: {\n\t\tafterMaster(pres: PresentationPropsInternal, zip: ZipWriter): void {\n\t\t\t// Resolve the deck-wide author registry once, then emit the shared commentAuthors part\n\t\t\t// plus a per-slide comment part for each slide that has comments.\n\t\t\tconst resolved = resolveCommentAuthors(pres.slides)\n\t\t\tif (resolved.authors.length === 0) return\n\t\t\tzip.add(COMMENT_AUTHORS_PATH, makeXmlCommentAuthors(resolved.authors))\n\t\t\tpres.slides.forEach((slide, idx) => {\n\t\t\t\tif ((slide._comments || []).length > 0) {\n\t\t\t\t\tzip.add(commentPath(idx + 1), makeXmlComments(slide, resolved.meta))\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t},\n\tcontentTypes: {\n\t\ttrailing(pres: PresentationPropsInternal): ContentTypeOverride[] {\n\t\t\tconst entries: ContentTypeOverride[] = []\n\t\t\tpres.slides.forEach((slide, idx) => {\n\t\t\t\tif ((slide._comments || []).length > 0) {\n\t\t\t\t\tentries.push({ partName: overrideName(commentPath(idx + 1)), contentType: COMMENTS_CONTENT_TYPE })\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (entries.length > 0)\n\t\t\t\tentries.push({ partName: '/' + COMMENT_AUTHORS_PATH, contentType: COMMENT_AUTHORS_CONTENT_TYPE })\n\t\t\treturn entries\n\t\t},\n\t},\n}\n","/**\n * ts-pptx: Comment Definition\n *\n * Validates `addComment()` author / text / position and stashes a review comment on the slide\n * (`_comments`); the `<p:cm>` XML is emitted later by `gen/slide/comments.ts`.\n */\nimport { warn } from '../../diagnostics.js'\nimport type { CommentProps } from '../../types/index.js'\nimport type { PresSlideInternal } from '../../types/internal.js'\n\n/**\n * Derive 1-2 letter initials from an author display name (e.g. \"Ada Lovelace\" -> \"AL\").\n * Falls back to the first character when the name is a single word.\n */\nfunction deriveAuthorInitials(author: string): string {\n\tconst words = author.trim().split(/\\s+/).filter(Boolean)\n\tconst first = words[0]\n\tif (!first) return '?'\n\tif (words.length === 1) return first.charAt(0).toUpperCase()\n\tconst last = words[words.length - 1] ?? first\n\treturn (first.charAt(0) + last.charAt(0)).toUpperCase()\n}\n\n/**\n * Adds a review comment to a slide (legacy ISO/IEC 29500 §13 comment).\n * @param {PresSlideInternal} target slide object the comment is attached to\n * @param {CommentProps} opts comment author/text/position options\n */\nexport function addCommentDefinition(target: PresSlideInternal, opts: CommentProps): void {\n\tconst author = typeof opts?.author === 'string' ? opts.author.trim() : ''\n\tconst text = typeof opts?.text === 'string' ? opts.text : ''\n\t// Don't silently coerce: a comment with no author or no body is meaningless, so warn + skip\n\t// rather than emit a degenerate <p:cm> (API policy: warn over silent coercion).\n\tif (!author) {\n\t\twarn('comment/missing-author', 'addComment() requires a non-empty `author`; comment ignored.')\n\t\treturn\n\t}\n\tif (!text) {\n\t\twarn('comment/missing-text', 'addComment() requires non-empty `text`; comment ignored.')\n\t\treturn\n\t}\n\n\tconst initials =\n\t\ttypeof opts.initials === 'string' && opts.initials.trim() ? opts.initials.trim() : deriveAuthorInitials(author)\n\tconst x = typeof opts.x === 'number' && Number.isFinite(opts.x) ? opts.x : 0.5\n\tconst y = typeof opts.y === 'number' && Number.isFinite(opts.y) ? opts.y : 0.5\n\tlet date: string | undefined\n\tif (opts.date instanceof Date) date = opts.date.toISOString()\n\telse if (typeof opts.date === 'string' && opts.date) date = opts.date\n\n\tif (!target._comments) target._comments = []\n\t// `date` is omitted rather than written as `undefined` when the caller stated none: the\n\t// comments emitter falls back to its own timestamp on an absent one, and the two spellings\n\t// would otherwise be two ways of asking for that.\n\ttarget._comments.push(date === undefined ? { author, initials, text, x, y } : { author, initials, text, x, y, date })\n}\n","/**\n * ts-pptx: the comments construct family\n *\n * Legacy PowerPoint review comments: the marker on the slide, the per-slide comment part, and the\n * deck-wide author list.\n */\n\nimport { commentsContributor } from '../package/parts/comments.js'\nimport { addCommentDefinition } from '../gen/define/comment.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const commentsFamily = {\n\tname: 'comments',\n\tauthors: {\n\t\taddComment(slide, options) {\n\t\t\taddCommentDefinition(slide, options)\n\t\t},\n\t},\n\tparts: commentsContributor,\n} satisfies ConstructFamily\n","/**\n * ts-pptx: connector slide-object serialization\n *\n * Emits a `connector` slide object as a `<p:cxnSp>`. The start/end shape bindings resolve a\n * caller-supplied `objectName` to the target's slide-wide `<p:cNvPr>` id; an unresolved name\n * falls back to the static endpoint geometry rather than emitting a dangling id.\n */\n\nimport { warn } from '../../../diagnostics.js'\nimport { el, elOrVoid, raw, voidEl } from '../../oxml/el.js'\nimport { resolveObjectNameToId } from '../shape-ids.js'\nimport { cNvPrEl, genXmlShapeLine, type RenderContext, xfrmEl } from './shared.js'\n\n/**\n * Render a `connector` slide object to its `<p:cxnSp>` XML (start/end shape bindings via shapeIds).\n */\nexport function renderConnectorObject(ctx: RenderContext): string {\n\tconst {\n\t\tobj: slideItemObj,\n\t\tshapeId,\n\t\tshapeIds,\n\t\tframe: { x, y, cx, cy },\n\t\tlocationAttrs,\n\t\titemOpts,\n\t} = ctx\n\t// `itemOpts` is the caller's already-normalized `itemOpts` (see the dispatch in\n\t// `slideObjectToXml`). Read it rather than re-narrowing the field: this function has exactly\n\t// one call site, and a contract stated there beats a defensive re-assignment here.\n\tlet strSlideXml = ''\n\t// A connector is emitted as <p:cxnSp> (a connector shape) rather than <p:sp>, so\n\t// PowerPoint treats it as a connector. Geometry/flip come from the shared resolution\n\t// above; the preset (straightConnector1 / bentConnector3 / curvedConnector3) is on `shape`.\n\tstrSlideXml += '<p:cxnSp><p:nvCxnSpPr>'\n\tstrSlideXml += cNvPrEl(shapeId, itemOpts.objectName, itemOpts.altText || '')\n\t{\n\t\t// Shape binding: resolve each bound target's objectName to its cNvPr id and emit\n\t\t// <a:stCxn>/<a:endCxn> in schema order. Resolution goes through `shapeIds`, so a shape\n\t\t// inside a group binds like any other (it is cNvPr-named on this slide); the old\n\t\t// `_slideObjects`-only lookup missed those and warned that the shape did not exist.\n\t\t// An unresolved name falls back to the static endpoint geometry (warn, don't corrupt)\n\t\t// rather than a dangling id.\n\t\tconst cxnTag = (binding: { name: string; idx: number } | undefined, tag: 'a:stCxn' | 'a:endCxn'): string => {\n\t\t\tif (!binding) return ''\n\t\t\tconst id = resolveObjectNameToId(shapeIds, binding.name)\n\t\t\tif (id === null) {\n\t\t\t\twarn(\n\t\t\t\t\t'connector/unresolved-binding',\n\t\t\t\t\t`addConnector could not bind to shape \"${binding.name}\" (no object with that objectName on the slide); using endpoint coordinates instead.`\n\t\t\t\t)\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\treturn voidEl(tag, { id, idx: binding.idx })\n\t\t}\n\t\tconst cxnSpPr = cxnTag(itemOpts._startCxn, 'a:stCxn') + cxnTag(itemOpts._endCxn, 'a:endCxn')\n\t\t// Arity, not value: paired only when a binding resolved, self-closing otherwise.\n\t\tstrSlideXml += elOrVoid('p:cNvCxnSpPr', null, cxnSpPr)\n\t}\n\tstrSlideXml += '<p:nvPr/></p:nvCxnSpPr><p:spPr>'\n\tstrSlideXml += xfrmEl('a:xfrm', { x, y, cx, cy }, locationAttrs)\n\t{\n\t\t// Bent/curved connectors carry adjustable jogs as `<a:gd name=\"adjN\" fmla=\"val …\"/>`\n\t\t// (1000ths-of-a-percent). With none, the empty `<a:avLst/>` leaves the preset default (50%).\n\t\tconst adj = itemOpts._connectorAdj || []\n\t\tconst avLst = adj.map((val, i) => voidEl('a:gd', { name: `adj${i + 1}`, fmla: `val ${val}` })).join('')\n\t\tstrSlideXml += el('a:prstGeom', { prst: slideItemObj.shape }, raw(el('a:avLst', null, raw(avLst))))\n\t}\n\tstrSlideXml += genXmlShapeLine(itemOpts.line || {})\n\tstrSlideXml += '</p:spPr></p:cxnSp>'\n\treturn strSlideXml\n}\n","/**\n * ts-pptx: Connector Definition\n *\n * `addConnectorDefinition` converts two endpoints to a flip-oriented bounding box, resolves the\n * connector preset + adjust guides, and optionally binds start / end shapes. Emitted later as\n * `<p:cxnSp>`.\n */\nimport { withLineDefaults } from '../drawingml/line.js'\nimport { connectorPresetFor, SlideObjectType } from '../../enums.js'\nimport { warn } from '../../diagnostics.js'\nimport type { ConnectorProps } from '../../types/index.js'\nimport type { PresSlideInternal, SlideObject } from '../../types/internal.js'\nimport { EMU_PER_INCH, FIXED_PCT_PER_PERCENT } from '../../units.js'\nimport { getSmartParseNumber } from '../../units-internal.js'\nimport { resolveObjectName } from './object-name.js'\nimport { InvalidOptionError } from '../../errors.js'\nimport { pickDefined } from '../../options-internal.js'\n\n/**\n * Adds a connector object to a slide definition.\n * A connector is a line between two points emitted as a PowerPoint connector (`<p:cxnSp>`).\n * Endpoints are converted to a bounding box (`x/y/w/h`) plus `flipH`/`flipV` so the box can be\n * oriented from any corner; the connector preset geometry is derived from `type`.\n * @param {PresSlideInternal} target - slide the connector is added to\n * @param {ConnectorProps} opts - connector options (endpoints + line styling)\n */\nexport function addConnectorDefinition(target: PresSlideInternal, opts: ConnectorProps): void {\n\tif (!opts || [opts.x1, opts.y1, opts.x2, opts.y2].some((v) => typeof v === 'undefined')) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'connector/missing-endpoints',\n\t\t\t'addConnector requires { x1, y1, x2, y2 }. Example: `slide.addConnector({ x1:1, y1:1, x2:4, y2:3 })`'\n\t\t)\n\t}\n\n\tconst type = opts.type || 'straight'\n\tif (type !== 'straight' && type !== 'elbow' && type !== 'curved') {\n\t\tthrow new InvalidOptionError(\n\t\t\t'connector/invalid-type',\n\t\t\t`Invalid connector type \"${String(type)}\". Use 'straight', 'elbow', or 'curved'.`\n\t\t)\n\t}\n\n\t// Resolve the preset variant + adjust guides. `bentConnector{3,4,5}` / `curvedConnector{3,4,5}`\n\t// each expose `bends` adjustable jogs as `<a:gd name=\"adjN\" fmla=\"val …\"/>` (1000ths-of-a-percent,\n\t// so 50% → 50000; values verified against PowerPoint-authored decks). `straightConnector1` has none.\n\tconst adjInput = opts.adj === undefined ? [] : Array.isArray(opts.adj) ? opts.adj : [opts.adj]\n\tconst bends = opts.bends ?? (adjInput.length || 1)\n\tlet connectorAdj: number[] = []\n\tif (type === 'straight') {\n\t\tif (opts.bends !== undefined || opts.adj !== undefined) {\n\t\t\twarn(\n\t\t\t\t'connector/bends-ignored-for-straight',\n\t\t\t\t'addConnector `bends`/`adj` are ignored for type \"straight\" (a straight connector has no bends).'\n\t\t\t)\n\t\t}\n\t} else {\n\t\tif (bends !== 1 && bends !== 2 && bends !== 3) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'connector/invalid-bends',\n\t\t\t\t`addConnector \\`bends\\` must be 1, 2, or 3 (got ${String(bends)}).`\n\t\t\t)\n\t\t}\n\t\tif (opts.adj !== undefined && adjInput.length !== bends) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'connector/adj-count-mismatch',\n\t\t\t\t`addConnector \\`adj\\` must supply ${bends} value(s) to match \\`bends\\`=${bends} (got ${adjInput.length}).`\n\t\t\t)\n\t\t}\n\t\t// Convert each percent to OOXML 1000ths-of-a-percent. Fail loud on non-finite input\n\t\t// (silent coercion would emit a degenerate guide PowerPoint repairs); warn but allow\n\t\t// out-of-range, which legitimately places a jog beyond the endpoint box.\n\t\tconnectorAdj = adjInput.map((pct, i) => {\n\t\t\tif (typeof pct !== 'number' || !Number.isFinite(pct)) {\n\t\t\t\tthrow new InvalidOptionError(\n\t\t\t\t\t'connector/adj-non-finite',\n\t\t\t\t\t`addConnector \\`adj\\` value #${i + 1} must be a finite number (percent 0–100); got ${String(pct)}.`\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (pct < 0 || pct > 100) {\n\t\t\t\twarn(\n\t\t\t\t\t'connector/adj-out-of-range',\n\t\t\t\t\t`addConnector \\`adj\\` value ${pct} is outside 0–100; the bend will sit beyond the endpoint box.`\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn Math.round(pct * FIXED_PCT_PER_PERCENT)\n\t\t})\n\t}\n\tconst preset = connectorPresetFor(type, bends)\n\n\t// Optional shape binding (<a:stCxn>/<a:endCxn>). The target id is resolved at serialize time,\n\t// through the slide's shape-id allocator; here we just capture the name + site index.\n\t// The site index must be a non-negative integer — a bad idx makes PowerPoint repair the connector.\n\tconst resolveCxn = (\n\t\tshapeName: string | undefined,\n\t\tidx: number | undefined,\n\t\tend: 'startShape' | 'endShape'\n\t): { name: string; idx: number } | undefined => {\n\t\tif (shapeName === undefined) return undefined\n\t\tif (typeof shapeName !== 'string' || shapeName.trim().length === 0) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'connector/invalid-binding-name',\n\t\t\t\t`addConnector \\`${end}\\` must be a non-empty shape objectName.`\n\t\t\t)\n\t\t}\n\t\tconst site = idx ?? 0\n\t\tif (!Number.isInteger(site) || site < 0) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'connector/invalid-connection-site',\n\t\t\t\t`addConnector \\`${end}Idx\\` must be a non-negative integer (got ${String(site)}).`\n\t\t\t)\n\t\t}\n\t\t// Stored as the caller spelled it: `resolveObjectNameToId` compares raw names, and a name is\n\t\t// escaped only when `cNvPrOpen` writes it (see its docblock).\n\t\treturn { name: shapeName, idx: site }\n\t}\n\tconst startCxn = resolveCxn(opts.startShape, opts.startShapeIdx, 'startShape')\n\tconst endCxn = resolveCxn(opts.endShape, opts.endShapeIdx, 'endShape')\n\tconst objectName = resolveObjectName(target, SlideObjectType.connector, {\n\t\tlabel: 'Connector',\n\t\tkind: 'connector',\n\t\tsupplied: opts.objectName,\n\t})\n\n\t// Resolve all four endpoints to inches up front (handles every `Coord` form: number,\n\t// '50%', '2in', etc.). The connector box uses the min corner as its origin and flips\n\t// horizontally/vertically when the end point is left of / above the start point.\n\tconst x1 = getSmartParseNumber(opts.x1, 'X', target._presLayout) / EMU_PER_INCH\n\tconst y1 = getSmartParseNumber(opts.y1, 'Y', target._presLayout) / EMU_PER_INCH\n\tconst x2 = getSmartParseNumber(opts.x2, 'X', target._presLayout) / EMU_PER_INCH\n\tconst y2 = getSmartParseNumber(opts.y2, 'Y', target._presLayout) / EMU_PER_INCH\n\n\tconst newObject: SlideObject = {\n\t\t_type: SlideObjectType.connector,\n\t\t// store the connector preset on `shape`; the serializer emits it as the prstGeom `prst`\n\t\tshape: preset,\n\t\toptions: {\n\t\t\tx: Math.min(x1, x2),\n\t\t\ty: Math.min(y1, y2),\n\t\t\tw: Math.abs(x2 - x1),\n\t\t\th: Math.abs(y2 - y1),\n\t\t\tflipH: x2 < x1,\n\t\t\tflipV: y2 < y1,\n\t\t\t// A straight connector has no adjust values and an unattached end no `cxn`; each is one\n\t\t\t// absent key rather than a key holding `undefined`, which is what the emitters test for.\n\t\t\t...(connectorAdj.length ? { _connectorAdj: connectorAdj } : {}),\n\t\t\t...pickDefined({ _startCxn: startCxn, _endCxn: endCxn }, ['_startCxn', '_endCxn']),\n\t\t\t// The outline defaults every shape takes, so `width: 0` is the 1pt default here as well.\n\t\t\tline: withLineDefaults(\n\t\t\t\t{ type: 'solid', ...pickDefined(opts, ['color', 'width', 'dashType', 'beginArrowType', 'endArrowType']) },\n\t\t\t\t'connector color'\n\t\t\t),\n\t\t\t...pickDefined(opts, ['altText']),\n\t\t\tobjectName,\n\t\t},\n\t}\n\n\ttarget._slideObjects.push(newObject)\n}\n","/**\n * ts-pptx: the connector construct family\n *\n * Lines drawn between two points, emitted as `<p:cxnSp>`.\n */\n\nimport { SlideObjectType } from '../enums.js'\nimport { renderConnectorObject } from '../gen/slide/objects/connector.js'\nimport { addConnectorDefinition } from '../gen/define/connector.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const connectorFamily = {\n\tname: 'connector',\n\tauthors: {\n\t\taddConnector(slide, options) {\n\t\t\taddConnectorDefinition(slide, options)\n\t\t},\n\t},\n\trenderers: {\n\t\t[SlideObjectType.connector]: renderConnectorObject,\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: the measurement construct family\n *\n * The three presentation methods that measure without authoring anything: `measureText`,\n * `overflowsBox` and `tableLayout`. They measure through `measure/fit.ts` and\n * `measure/table-fit.ts`, which the core reaches anyway through the export-time bake below.\n *\n * Only one of the three is a second spelling of something the `pptx-ts/measure` subpath also\n * exports, and even that one differs where it matters: the subpath's `measureText` takes a\n * `FontMetricsRegistry`, this binds the presentation's own. `overflowsBox` and `tableLayout` have\n * no subpath equivalent at all -- the first composes two of the subpath's primitives, and the\n * second needs `pres.presLayout`, which a free function has no way to reach. So the pair is a\n * primitive and its bound convenience, not one capability written twice.\n *\n * The export-time autofit bake is NOT here. `applyMeasuredFit` (`gen/prepare.ts`) runs on the\n * ordinary write path for `fit:'shrink'` text, so it belongs to the core rather than to a family a\n * program can leave out.\n */\n\nimport { measureText, requireBoxHeight } from '../measure/fit.js'\nimport { computeTableLayout } from '../measure/table-fit.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const measureFamily = {\n\tname: 'measure',\n\tpresentationAuthors: {\n\t\tmeasureText(ctx, text, opts) {\n\t\t\treturn measureText(ctx.fontMetrics, text, opts)\n\t\t},\n\t\toverflowsBox(ctx, text, opts) {\n\t\t\t// Checked first: text that cannot be measured never reached the height check.\n\t\t\trequireBoxHeight(opts.hIn, 'overflowsBox')\n\t\t\tconst m = measureText(ctx.fontMetrics, text, opts)\n\t\t\treturn m.measurable && !m.fitsBox(opts.hIn)\n\t\t},\n\t\ttableLayout(ctx, rows, opts) {\n\t\t\treturn computeTableLayout(rows, opts, ctx.pres.presLayout, ctx.fontMetrics)\n\t\t},\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: media (audio / video / online video) slide-object serialization\n *\n * Emits a `media` slide object as a `<p:pic>` carrying the required preview image. The online\n * and embedded forms differ in exactly two tokens — the EG_Media choice element and whether the\n * paired `<p14:media>` rel binds by `r:link` or `r:embed` — so they share one body.\n */\n\nimport { genXmlObjectLock, PICTURE_LOCK_ATTRS } from '../../drawingml/locks.js'\nimport { STRETCH_FILL_RECT } from '../../drawingml/src-rect.js'\nimport { prstGeomRect } from '../../drawingml/geometry.js'\nimport { el, raw, voidEl } from '../../oxml/el.js'\nimport { msMediaRid, previewRid } from '../../define/media.js'\nimport { cNvPrEl, type RenderContext, xfrmEl } from './shared.js'\nimport { OOXML_NS } from '../../../ooxml/namespaces.js'\n\n/**\n * Render a `media` (audio/video/online) slide object to its `<p:pic>` XML.\n */\nexport function renderMediaObject(ctx: RenderContext): string {\n\tconst {\n\t\tobj: slideItemObj,\n\t\tshapeId,\n\t\tframe: { x, y, cx, cy },\n\t\tlocationAttrs,\n\t\titemOpts,\n\t} = ctx\n\t// `itemOpts` is the caller's already-normalized `itemOpts` (see the dispatch in\n\t// `slideObjectToXml`). Read it rather than re-narrowing the field: this function has exactly\n\t// one call site, and a contract stated there beats a defensive re-assignment here.\n\tconst mediaRid = slideItemObj.mediaRid ?? 0\n\n\t// The online (external-link) and embedded forms differ in exactly two tokens, so they share\n\t// one body rather than two near-identical branches:\n\t// - EG_Media choice: audio embeds use <a:audioFile>, video and online video <a:videoFile>;\n\t// - the paired <p14:media> rel is bound by r:link for an external link (no media binary\n\t// part, sharing the link Target with the ECMA rel) and by r:embed for an embedded file.\n\t// Note the ECMA media element itself is r:link in BOTH forms.\n\tconst mediaTag = slideItemObj.mtype === 'audio' ? 'a:audioFile' : 'a:videoFile'\n\tconst p14MediaAttr = slideItemObj.mtype === 'online' ? 'r:link' : 'r:embed'\n\n\treturn el('p:pic', null, [\n\t\traw(\n\t\t\tel(\n\t\t\t\t'p:nvPicPr',\n\t\t\t\tnull,\n\t\t\t\t[\n\t\t\t\t\t// cNvPr/@id must be unique across every shape on the slide, so it uses the slide-object\n\t\t\t\t\t// index (idx + 2) like all other shapes — NOT mediaRid, which lives in the relationship-id\n\t\t\t\t\t// space and collides with a sibling shape's idx (duplicate ids => PowerPoint reports the\n\t\t\t\t\t// file corrupt, 0x80070570). The preview image is still bound via <a:blip r:embed> below.\n\t\t\t\t\traw(\n\t\t\t\t\t\tcNvPrEl(\n\t\t\t\t\t\t\tshapeId,\n\t\t\t\t\t\t\titemOpts.objectName,\n\t\t\t\t\t\t\titemOpts.altText || '',\n\t\t\t\t\t\t\tvoidEl('a:hlinkClick', { 'r:id': '', action: 'ppaction://media' })\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\traw(\n\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t'p:cNvPicPr',\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t\tgenXmlObjectLock(\n\t\t\t\t\t\t\t\t\t'a:picLocks',\n\t\t\t\t\t\t\t\t\tPICTURE_LOCK_ATTRS,\n\t\t\t\t\t\t\t\t\t{ noChangeAspect: true, ...itemOpts.objectLock },\n\t\t\t\t\t\t\t\t\titemOpts.objectName\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{ openPrefix: ' ' }\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\traw(\n\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t'p:nvPr',\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\traw(voidEl(mediaTag, { 'r:link': `rId${mediaRid}` }, { openPrefix: ' ' })),\n\t\t\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t\t\t\t'p:extLst',\n\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t\t\t\t\t\t'p:ext',\n\t\t\t\t\t\t\t\t\t\t\t\t{ uri: '{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}' },\n\t\t\t\t\t\t\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t\t\t\t\t\t\tvoidEl(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'p14:media',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ 'xmlns:p14': OOXML_NS.p14, [p14MediaAttr]: `rId${msMediaRid(mediaRid)}` },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ openPrefix: ' ' }\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t{ openPrefix: ' ', closePrefix: ' ' }\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t{ openPrefix: ' ', closePrefix: ' ' }\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t{ openPrefix: ' ', closePrefix: ' ' }\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\t{ openPrefix: ' ', closePrefix: ' ' }\n\t\t\t)\n\t\t),\n\t\t// NOTE: Preview image is required!\n\t\traw(\n\t\t\tel(\n\t\t\t\t'p:blipFill',\n\t\t\t\tnull,\n\t\t\t\t[raw(voidEl('a:blip', { 'r:embed': `rId${previewRid(mediaRid)}` })), raw(STRETCH_FILL_RECT)],\n\t\t\t\t{ openPrefix: ' ' }\n\t\t\t)\n\t\t),\n\t\traw(\n\t\t\tel(\n\t\t\t\t'p:spPr',\n\t\t\t\tnull,\n\t\t\t\t[\n\t\t\t\t\traw(xfrmEl('a:xfrm', { x, y, cx, cy }, locationAttrs, { openPrefix: ' ' })),\n\t\t\t\t\traw(prstGeomRect({ openPrefix: ' ' })),\n\t\t\t\t],\n\t\t\t\t{ openPrefix: ' ', closePrefix: ' ' }\n\t\t\t)\n\t\t),\n\t])\n}\n","/**\n * ts-pptx: the media construct family\n *\n * Embedded and online audio/video. The default video poster already loads with the media rather\n * than with the library; this is the rest of it.\n */\n\nimport { SlideObjectType } from '../enums.js'\nimport { renderMediaObject } from '../gen/slide/objects/media.js'\nimport { addMediaDefinition } from '../gen/define/media.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const mediaFamily = {\n\tname: 'media',\n\tauthors: {\n\t\taddMedia(slide, options) {\n\t\t\taddMediaDefinition(slide, options)\n\t\t},\n\t},\n\trenderers: {\n\t\t[SlideObjectType.media]: renderMediaObject,\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: 3D model (`am3d:model3d`) slide-object serialization\n *\n * Emits a `model3d` slide object as an `<mc:AlternateContent>`. The `mc:Choice` carries the real\n * `<p:graphicFrame>` in the 2017 `am3d` namespace, rendered live by PowerPoint 2019+; the\n * `mc:Fallback` carries a plain preview picture, which is what every other consumer — older\n * PowerPoint, applications without a 3D renderer — actually draws. See `gen/define/model3d.ts`.\n *\n * Every constant below is transcribed from a PowerPoint-authored deck\n * (`test/read/fixtures/model3d.pptx`, `Shapes.Add3DModel`), including the lighting rig, which came\n * out byte-identical for every probe model and is therefore emitted as a fixed studio setup rather\n * than derived from anything.\n */\n\nimport type { Model3dInternal } from '../../../types/internal.js'\nimport { prstGeomRect } from '../../drawingml/geometry.js'\nimport { el, raw, voidEl } from '../../oxml/el.js'\nimport { alternateContentEl } from '../../oxml/alternate-content.js'\nimport {\n\tFALLBACK_PICTURE_LOCKS,\n\ttype RenderContext,\n\tcNvPrEl,\n\tgraphicFrameEl,\n\tpreviewPicBody,\n\txfrmEl,\n} from './shared.js'\nimport { GRAPHIC_FRAME_LOCK_ATTRS, PICTURE_LOCK_ATTRS, genXmlObjectLock } from '../../drawingml/locks.js'\n\n/** The `am3d` namespace, doubling as `a:graphicData@uri` and the `mc:Choice Requires` token's URI. */\nconst AM3D_NS = 'http://schemas.microsoft.com/office/drawing/2017/model3d'\n/** Denominator of every `am3d` rational element (`@n`/`@d`). */\nconst RATIO_DEN = 1000000\n/**\n * `am3d:raster@rName`/`@rVer` — the renderer that produced the cached preview. PowerPoint stamps\n * its own renderer here; ts-pptx did not rasterize anything, but the attributes are what PowerPoint\n * writes and the element is where the preview blip lives, so they are reproduced verbatim.\n */\nconst RASTER = { rName: 'Office3DRenderer', rVer: '16.0.8326' }\n/**\n * `am3d:objViewport@viewportSz`. Bounding-box derived in PowerPoint's output (a cube and a slab\n * gave different values); the cube's is emitted, matching the fixed default camera.\n */\nconst OBJ_VIEWPORT_SZ = 3338805\n\n/** One `am3d:ptLight` of the fixed studio rig: colour (scRGB, 1000ths of a percent), intensity, position. */\ninterface PtLight {\n\tclr: { r: number; g: number; b: number }\n\tintensityN: number\n\tpos: { x: number; y: number; z: number }\n}\n/** The three point lights PowerPoint writes for every inserted model — key, fill and rim. */\nconst PT_LIGHTS: readonly PtLight[] = [\n\t{ clr: { r: 100000, g: 75000, b: 50000 }, intensityN: 9765625, pos: { x: 21959998, y: 70920001, z: 16344003 } },\n\t{ clr: { r: 40000, g: 60000, b: 95000 }, intensityN: 12250000, pos: { x: -37964106, y: 51130435, z: 57631972 } },\n\t{ clr: { r: 86837, g: 72700, b: 100000 }, intensityN: 3125000, pos: { x: -37739122, y: 58056624, z: -34769649 } },\n]\n/** `am3d:ambientLight` — neutral 50% scRGB at half illuminance, constant like the point lights. */\nconst AMBIENT = { clr: { r: 50000, g: 50000, b: 50000 }, illuminanceN: 500000 }\n\n/** `<am3d:clr><a:scrgbClr …/></am3d:clr>` — the colour wrapper both light kinds share. */\nfunction lightColor(clr: { r: number; g: number; b: number }): string {\n\treturn el('am3d:clr', null, raw(voidEl('a:scrgbClr', clr)))\n}\n\n/** The `am3d:camera` block: eye position, up vector, aim point and perspective fov. */\nfunction cameraEl(model: Model3dInternal): string {\n\treturn el('am3d:camera', null, [\n\t\traw(voidEl('am3d:pos', model.pos)),\n\t\traw(voidEl('am3d:up', model.up)),\n\t\traw(voidEl('am3d:lookAt', model.lookAt)),\n\t\traw(voidEl('am3d:perspective', { fov: model.fov })),\n\t])\n}\n\n/**\n * The `am3d:trans` block: model-unit scale plus an identity placement. Only `meterPerModelUnit`\n * varies — `preTrans`/`scale`/`rot`/`postTrans` are the identity PowerPoint writes for a model\n * inserted without any subsequent 3D manipulation, and `am3d:rot` is emitted attribute-less.\n */\nfunction transEl(model: Model3dInternal): string {\n\tconst unit = { n: RATIO_DEN, d: RATIO_DEN }\n\treturn el('am3d:trans', null, [\n\t\traw(voidEl('am3d:meterPerModelUnit', { n: model.meterPerModelUnitN, d: RATIO_DEN })),\n\t\traw(voidEl('am3d:preTrans', { dx: 0, dy: 0, dz: 0 })),\n\t\traw(\n\t\t\tel('am3d:scale', null, [raw(voidEl('am3d:sx', unit)), raw(voidEl('am3d:sy', unit)), raw(voidEl('am3d:sz', unit))])\n\t\t),\n\t\traw(voidEl('am3d:rot')),\n\t\traw(voidEl('am3d:postTrans', { dx: 0, dy: 0, dz: 0 })),\n\t])\n}\n\n/** The fixed lighting rig: one ambient light and three point lights, in PowerPoint's order. */\nfunction lightsXml(): string {\n\treturn (\n\t\tel('am3d:ambientLight', null, [\n\t\t\traw(lightColor(AMBIENT.clr)),\n\t\t\traw(voidEl('am3d:illuminance', { n: AMBIENT.illuminanceN, d: RATIO_DEN })),\n\t\t]) +\n\t\tPT_LIGHTS.map((light) =>\n\t\t\tel('am3d:ptLight', { rad: 0 }, [\n\t\t\t\traw(lightColor(light.clr)),\n\t\t\t\traw(voidEl('am3d:intensity', { n: light.intensityN, d: RATIO_DEN })),\n\t\t\t\traw(voidEl('am3d:pos', light.pos)),\n\t\t\t])\n\t\t).join('')\n\t)\n}\n\n/** The `mc:Fallback` picture — the cached preview, drawn by everything that is not PowerPoint 2019+. */\nfunction fallbackPic(\n\tpicId: number,\n\tobjectName: string | undefined,\n\taltText: string,\n\tmodel: Model3dInternal,\n\txf: { x: number; y: number; cx: number; cy: number }\n): string {\n\treturn el('p:pic', null, [\n\t\traw(\n\t\t\tel('p:nvPicPr', null, [\n\t\t\t\traw(cNvPrEl(picId, objectName, altText)),\n\t\t\t\traw(\n\t\t\t\t\tel(\n\t\t\t\t\t\t'p:cNvPicPr',\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t// PowerPoint's model-3d lock set: the zoom/picture set plus `noCrop` — a 3D model is\n\t\t\t\t\t\t\t// reframed by its camera, never by cropping the cached raster. Fixed even though\n\t\t\t\t\t\t\t// `Model3dProps` has an `objectLock`, for the reason the zoom emitter spells out:\n\t\t\t\t\t\t\t// this is the `mc:Fallback` picture, and `a:picLocks` takes a different flag set\n\t\t\t\t\t\t\t// from the `a:graphicFrameLocks` the caller's locks land on.\n\t\t\t\t\t\t\tgenXmlObjectLock('a:picLocks', PICTURE_LOCK_ATTRS, { ...FALLBACK_PICTURE_LOCKS, noCrop: true })\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\traw(voidEl('p:nvPr')),\n\t\t\t])\n\t\t),\n\t\traw(previewPicBody(model.previewRid, xf)),\n\t])\n}\n\n/**\n * Render a `model3d` slide object to its `<mc:AlternateContent>` XML. The `mc:Choice` carries the\n * real `<p:graphicFrame>` (the `am3d:model3d` graphicData PowerPoint 2019+ renders live); the\n * `mc:Fallback` carries the cached preview picture. See `gen/define/model3d.ts`.\n */\nexport function renderModel3dObject(ctx: RenderContext): string {\n\tconst {\n\t\tobj: slideItemObj,\n\t\tshapeId,\n\t\tframe: { x, y, cx, cy },\n\t} = ctx\n\tconst model = slideItemObj.model3d\n\tif (!model) return ''\n\tconst opts = slideItemObj.options || {}\n\tconst altText = opts.altText || ''\n\n\t// `am3d:spPr`'s xfrm is FRAME-LOCAL: origin 0,0 with the graphic frame's own extent. The\n\t// slide-absolute position lives on `p:xfrm` below (and on the fallback picture's `p:spPr`).\n\tconst spPr = el('am3d:spPr', null, [raw(xfrmEl('a:xfrm', { x: 0, y: 0, cx, cy })), raw(prstGeomRect())])\n\n\tconst model3d = el('am3d:model3d', { 'r:embed': `rId${model.modelRid}` }, [\n\t\traw(spPr),\n\t\traw(cameraEl(model)),\n\t\traw(transEl(model)),\n\t\t// The raster's blip and the fallback picture share one image rel, as PowerPoint writes it.\n\t\traw(el('am3d:raster', RASTER, raw(voidEl('am3d:blip', { 'r:embed': `rId${model.previewRid}` })))),\n\t\traw(voidEl('am3d:objViewport', { viewportSz: OBJ_VIEWPORT_SZ })),\n\t\traw(lightsXml()),\n\t])\n\n\tconst nvGraphicFramePr = el('p:nvGraphicFramePr', null, [\n\t\traw(cNvPrEl(shapeId, opts.objectName, altText)),\n\t\traw(\n\t\t\tel(\n\t\t\t\t'p:cNvGraphicFramePr',\n\t\t\t\tnull,\n\t\t\t\t// PowerPoint writes an empty `<a:graphicFrameLocks/>` here — no flags, but the\n\t\t\t\t// element present — so that is what an unlocked model emits. `genXmlObjectLock`\n\t\t\t\t// returns `''` when nothing is set, hence the fallback.\n\t\t\t\traw(\n\t\t\t\t\tgenXmlObjectLock('a:graphicFrameLocks', GRAPHIC_FRAME_LOCK_ATTRS, opts.objectLock, opts.objectName) ||\n\t\t\t\t\t\tvoidEl('a:graphicFrameLocks')\n\t\t\t\t)\n\t\t\t)\n\t\t),\n\t\traw(voidEl('p:nvPr')),\n\t])\n\tconst graphicFrame = graphicFrameEl({\n\t\tnvGraphicFramePr,\n\t\tframe: { x, y, cx, cy },\n\t\turi: AM3D_NS,\n\t\tpayload: model3d,\n\t})\n\n\treturn alternateContentEl({\n\t\trequires: { prefix: 'am3d', uri: AM3D_NS },\n\t\tchoice: graphicFrame,\n\t\tfallback: fallbackPic(shapeId, opts.objectName, altText, model, { x, y, cx, cy }),\n\t})\n}\n","/**\n * ts-pptx: preview/cover image registration.\n *\n * Several objects are drawn from a cached raster the library cannot render itself — a Zoom tile's\n * thumbnail of its target slide, an OLE object's picture of the embedded document, a 3D model's\n * preview. Each registers that raster as an ordinary slide image rel and references it by rId.\n * Shared here so the definers agree on the placeholder fallback and on extension sniffing; the rel itself goes through\n * `registerImageMediaRel`, the same call `addImage` and image fills use.\n */\nimport { warn } from '../../diagnostics.js'\nimport type { PresSlideInternal } from '../../types/internal.js'\nimport { getNewRelId } from '../utils.js'\nimport { type ImageSource, registerImageMediaRel, resolveImageSource } from './image-rel.js'\n\n/** 32×32 solid #E7E6E6 PNG — the neutral placeholder shown when the caller supplies no cover image. */\nconst PLACEHOLDER_PNG =\n\t'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAxSURBVFhH7c4hAQAACMAw+geFGOAJAGbi5mpRmf1Z7HEdAAAAAAAAAAAAAAAAAADAAPwOyNPFH3F8AAAAAElFTkSuQmCC'\n\nconst PLACEHOLDER_SOURCE: ImageSource = { path: '', data: 'image/png;base64,' + PLACEHOLDER_PNG, extn: 'png' }\n\n/**\n * Register a preview/cover image as a slide media rel (deduped like `addImage`) and return its rId.\n * Falls back to the gray placeholder PNG when no cover image is supplied, and when the one supplied\n * has `data` with no base64 header, which says so. That cover used to be written as a part holding\n * the caller's text.\n * @param target - slide the image rel is registered on\n * @param cover - caller-supplied cover image (`path` or base64 `data`); omitted → gray placeholder\n * @param label - the option the cover was supplied through, for the warning, e.g. \"addOleObject `cover`\"\n * @returns the rId of the image rel\n */\nexport function registerPreviewImage(\n\ttarget: PresSlideInternal,\n\tcover: { path?: string; data?: string } | undefined,\n\tlabel: string\n): number {\n\tconst resolved = resolveImageSource(cover)\n\tif (resolved === 'missing-base64-header')\n\t\twarn(\n\t\t\t'preview-image/missing-base64-header',\n\t\t\t`${label} \\`data\\` value lacks a base64 header (ex: 'image/png;base64,...'); the gray placeholder is embedded instead.`\n\t\t)\n\tconst source = typeof resolved === 'string' ? PLACEHOLDER_SOURCE : resolved\n\n\tconst rId = getNewRelId(target)\n\tregisterImageMediaRel(target, source, rId)\n\treturn rId\n}\n","/**\n * ts-pptx: 3D model Definition (`addModel3d()` — PowerPoint's Insert ▸ 3D Models).\n *\n * Registers the `.glb` payload as an embedded media part plus a preview-picture image rel, and\n * pushes a `SlideObject{ _type: model3d, model3d }` for `gen/slide/objects/model3d.ts` to emit as\n * an `<mc:AlternateContent>` wrapping a `<p:graphicFrame>`.\n *\n * Ground truth for the package-level choices here (verified against a deck authored by PowerPoint\n * via `Shapes.Add3DModel` — `test/read/fixtures/model3d.pptx`):\n * - the payload is referenced with the Microsoft `…/office/2017/06/relationships/model3d` rel\n * type and registered by a content-type `Default` for `glb` — `model/gltf.binary`, spelled\n * with a dot, not the `model/gltf-binary` of the IANA-style media type;\n * - both the payload and the preview picture live in `ppt/media/`, the payload named `model3dN`;\n * - the preview picture is an ordinary image rel, referenced twice — once by `am3d:raster`'s\n * `am3d:blip` and once by the `mc:Fallback` picture.\n *\n * Camera: PowerPoint derives its camera from the model's bounding box (it normalizes the largest\n * extent to 1 metre, then frames the resulting bounding sphere). This library does not parse\n * glTF, so it emits the camera PowerPoint wrote for a 2×2×2 cube and lets the caller override the\n * scale — see `docs/3d-models.md`.\n */\nimport { SlideObjectType } from '../../enums.js'\nimport type { Model3dProps, Model3dPoint, Model3dCameraProps } from '../../types/model3d.js'\nimport type { PresSlideInternal, SlideObject, Model3dInternal } from '../../types/internal.js'\nimport { getNewRelId } from '../utils.js'\nimport { framedObjectOptions, requirePayloadSource } from './object-options.js'\nimport { registerPreviewImage } from './preview-image.js'\nimport { pushMediaRel } from './image-rel.js'\nimport { InvalidOptionError } from '../../errors.js'\nimport { warn } from '../../diagnostics.js'\nimport { ANGLE_UNITS_PER_DEGREE } from '../../units.js'\nimport { MODEL3D_REL } from '../../ooxml/rel-types.js'\n\n/** OPC content type for a glTF binary, as PowerPoint spells it in `[Content_Types].xml`. */\nconst GLB_CONTENT_TYPE = 'model/gltf.binary'\n\n/** Fixed-point denominator for `am3d` linear values: `am3d:up@dy=\"36000000\"` is the unit vector. */\nconst AM3D_UNIT = 36000000\n/** Denominator of every `am3d` rational (`meterPerModelUnit`, `scale`, `illuminance`, `intensity`). */\nconst AM3D_RATIO_DEN = 1000000\n\n/**\n * The camera PowerPoint wrote for the 2×2×2 cube fixture, in caller units (metres / degrees).\n * `z` is `sqrt(3)/2 / sin(22.5°)` — the bounding sphere of a 1-metre cube framed at a 45° fov.\n */\nconst DEFAULT_CAMERA = {\n\tpos: { x: 0, y: 0, z: 2.2630334 },\n\tlookAt: { x: 0, y: 0, z: 0 },\n\tup: { x: 0, y: 1, z: 0 },\n\tfov: 45,\n} as const\n/** `am3d:meterPerModelUnit` for the cube fixture: 1 / (its 2-unit largest extent). */\nconst DEFAULT_METER_PER_MODEL_UNIT = 0.5\n\n/** Reject a non-finite camera component rather than letting `NaN` reach the XML as `\"NaN\"`. */\nfunction toAm3dUnits(point: Model3dPoint | undefined, fallback: Model3dPoint, label: string): Model3dPoint {\n\tconst src = point ?? fallback\n\tfor (const axis of ['x', 'y', 'z'] as const) {\n\t\tif (!Number.isFinite(src[axis])) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'model3d/invalid-camera',\n\t\t\t\t`addModel3d(): camera.${label}.${axis} must be a finite number, got ${String(src[axis])}.`\n\t\t\t)\n\t\t}\n\t}\n\treturn { x: Math.round(src.x * AM3D_UNIT), y: Math.round(src.y * AM3D_UNIT), z: Math.round(src.z * AM3D_UNIT) }\n}\n\n/** Resolve `camera` + `meterPerModelUnit` into the wire units {@link Model3dInternal} carries. */\nfunction resolveCamera(\n\tcamera: Model3dCameraProps | undefined,\n\tmeterPerModelUnit: number | undefined\n): Omit<Model3dInternal, 'modelRid' | 'previewRid'> {\n\tconst fovDeg = camera?.fov ?? DEFAULT_CAMERA.fov\n\tif (!Number.isFinite(fovDeg) || fovDeg <= 0 || fovDeg >= 180) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'model3d/invalid-fov',\n\t\t\t`addModel3d(): camera.fov must be greater than 0 and less than 180 degrees, got ${String(fovDeg)}.`\n\t\t)\n\t}\n\tconst scale = meterPerModelUnit ?? DEFAULT_METER_PER_MODEL_UNIT\n\tif (!Number.isFinite(scale) || scale <= 0) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'model3d/invalid-scale',\n\t\t\t`addModel3d(): meterPerModelUnit must be a finite number greater than 0, got ${String(scale)}.`\n\t\t)\n\t}\n\t// The ratio is stored in millionths, so a positive value under half a millionth would be written\n\t// as `n=\"0\"` and scale the model to nothing.\n\tconst meterPerModelUnitN = Math.round(scale * AM3D_RATIO_DEN)\n\tif (meterPerModelUnitN === 0) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'model3d/invalid-scale',\n\t\t\t`addModel3d(): meterPerModelUnit ${String(scale)} rounds to 0 at the six decimal places the file stores; use at least 0.0000005.`\n\t\t)\n\t}\n\tconst up = toAm3dUnits(camera?.up, DEFAULT_CAMERA.up, 'up')\n\treturn {\n\t\tpos: toAm3dUnits(camera?.pos, DEFAULT_CAMERA.pos, 'pos'),\n\t\tlookAt: toAm3dUnits(camera?.lookAt, DEFAULT_CAMERA.lookAt, 'lookAt'),\n\t\tup: { dx: up.x, dy: up.y, dz: up.z },\n\t\tfov: Math.round(fovDeg * ANGLE_UNITS_PER_DEGREE),\n\t\tmeterPerModelUnitN: Math.round(scale * AM3D_RATIO_DEN),\n\t}\n}\n\n/**\n * Adds an embedded 3D model to a slide definition.\n * @param {PresSlideInternal} target - slide the model will be added to\n * @param {Model3dProps} opt - 3D model options\n */\nexport function addModel3dDefinition(target: PresSlideInternal, opt: Model3dProps): void {\n\tconst strData = opt.data || ''\n\tconst strPath = opt.path || ''\n\n\t// STEP 1: REALITY-CHECK. The payload is the whole point; there is no meaningful default.\n\trequirePayloadSource(opt, 'model3d/missing-source', 'addModel3d')\n\n\t// STEP 2: Resolve the camera and the object's own options before touching the rel table, so an\n\t// invalid option throws without leaving a half-registered part behind. A 3D model has no aspect\n\t// ratio and the library never opens the payload, so — as with `addOleObject` — there is no\n\t// natural size to measure.\n\tconst camera = resolveCamera(opt.camera, opt.meterPerModelUnit)\n\tconst options = framedObjectOptions(target, SlideObjectType.model3d, opt, {\n\t\tlabel: '3D Model',\n\t\tkind: 'model3d',\n\t\tapi: 'addModel3d',\n\t\tdefaults: { x: 0, y: 0, w: 4, h: 3 },\n\t})\n\n\t// STEP 3: Register the `.glb` payload rel. Every model gets its own rel and its own camera; the\n\t// package-part de-dup in `package/assemble.ts` still collapses byte-identical payloads to one\n\t// part, which is wanted here (a model is read-only geometry, unlike an OLE payload, which is\n\t// exempted there because double-clicking one would rewrite the other's source).\n\tconst modelRid = getNewRelId(target)\n\tpushMediaRel(target, {\n\t\tkind: 'model3d',\n\t\textn: 'glb',\n\t\ttype: GLB_CONTENT_TYPE,\n\t\tpath: strPath,\n\t\tdata: strData,\n\t\trId: modelRid,\n\t\textra: { model3dRelType: MODEL3D_REL },\n\t})\n\n\t// STEP 4: Register the preview picture. Unlike OLE's silent placeholder, say so out loud — a\n\t// missing preview is invisible in PowerPoint, which draws the live model on screen, in exports\n\t// and in print, and shows up only in another application, i.e. long after the deck was checked.\n\tif (!opt.preview?.path && !opt.preview?.data) {\n\t\twarn(\n\t\t\t'model3d/preview-missing',\n\t\t\t'addModel3d(): no `preview` image supplied, so a gray placeholder is embedded. PowerPoint 2019+ ' +\n\t\t\t\t'draws the live model, but older PowerPoint and applications without a 3D renderer show the placeholder.'\n\t\t)\n\t}\n\tconst previewRid = registerPreviewImage(target, opt.preview, 'addModel3d `preview`')\n\n\t// LAST: Push the slide object for the `<mc:AlternateContent>` emitter.\n\tconst slideData: SlideObject = {\n\t\t_type: SlideObjectType.model3d,\n\t\toptions,\n\t\tmodel3d: { modelRid, previewRid, ...camera },\n\t}\n\ttarget._slideObjects.push(slideData)\n}\n","/**\n * ts-pptx: the 3D-model construct family\n *\n * Embedded `.glb` models (PowerPoint's Insert > 3D Models), with the preview picture every other\n * consumer draws instead.\n */\n\nimport { SlideObjectType } from '../enums.js'\nimport { renderModel3dObject } from '../gen/slide/objects/model3d.js'\nimport { addModel3dDefinition } from '../gen/define/model3d.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const model3dFamily = {\n\tname: 'model3d',\n\tauthors: {\n\t\taddModel3d(slide, options) {\n\t\t\taddModel3dDefinition(slide, options)\n\t\t},\n\t},\n\trenderers: {\n\t\t[SlideObjectType.model3d]: renderModel3dObject,\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: OLE-object slide-object serialization\n */\n\nimport { genXmlObjectLock, GRAPHIC_FRAME_LOCK_ATTRS } from '../../drawingml/locks.js'\nimport { el, raw, voidEl, type XmlAttrs, type XmlChild } from '../../oxml/el.js'\nimport { alternateContentEl } from '../../oxml/alternate-content.js'\nimport { type RenderContext, cNvPrEl, graphicFrameEl, previewPicBody } from './shared.js'\nimport { xsdBoolIfTrue } from '../../../ooxml/xsd-boolean.js'\n\n/** VML namespace — declared by an OLE object's `mc:Choice Requires=\"v\"` (no VML content is emitted). */\nconst VML_NS = 'urn:schemas-microsoft-com:vml'\n/** graphicData URI for an embedded OLE object (`<p:oleObj>`). */\nconst OLE_NS = 'http://schemas.openxmlformats.org/presentationml/2006/ole'\n\n/**\n * Render an `oleObject` slide object to its `<p:graphicFrame>` XML.\n *\n * Mirrors what PowerPoint authors for Insert ▸ Object: a graphicFrame in the `.../ole` graphicData\n * namespace holding an `<mc:AlternateContent>`. The `mc:Choice` carries the bare `<p:oleObj>` (which\n * PowerPoint renders by drawing the live embedded document); the `mc:Fallback` repeats it with a\n * `<p:pic>` preview so every other consumer shows the cached picture.\n *\n * Note `mc:Choice Requires=\"v\"` only *declares* the VML namespace — modern PowerPoint writes no\n * `spid` and no `vmlDrawing` part, so neither is emitted here.\n */\nexport function renderOleObject(ctx: RenderContext): string {\n\tconst {\n\t\tobj: slideItemObj,\n\t\tshapeId,\n\t\tframe: { x, y, cx, cy },\n\t} = ctx\n\tconst ole = slideItemObj.ole\n\tif (!ole) return ''\n\tconst opts = slideItemObj.options || {}\n\n\t// Shared by both branches; attribute order matches PowerPoint's.\n\tconst oleAttrs: XmlAttrs = {\n\t\tname: ole.name,\n\t\tshowAsIcon: xsdBoolIfTrue(ole.showAsIcon),\n\t\t'r:id': `rId${ole.objectRid}`,\n\t\timgW: ole.imgW ?? cx,\n\t\timgH: ole.imgH ?? cy,\n\t\tprogId: ole.progId,\n\t}\n\tconst oleObj = (children: XmlChild[]): string => el('p:oleObj', oleAttrs, children)\n\n\t// The Fallback's cached picture. Its `cNvPr` is the id-less `0`/`\"\"` form PowerPoint writes:\n\t// the picture is an alternate rendering of the graphicFrame above, never a sibling shape, so it\n\t// takes no id from the slide's shape-id space.\n\tconst previewPic = el('p:pic', null, [\n\t\traw(\n\t\t\tel('p:nvPicPr', null, [\n\t\t\t\traw(voidEl('p:cNvPr', { id: 0, name: '' })),\n\t\t\t\traw(voidEl('p:cNvPicPr')),\n\t\t\t\traw(voidEl('p:nvPr')),\n\t\t\t])\n\t\t),\n\t\traw(previewPicBody(ole.previewRid, { x, y, cx, cy })),\n\t])\n\n\tconst alternateContent = alternateContentEl({\n\t\trequires: { prefix: 'v', uri: VML_NS },\n\t\tchoice: oleObj([raw(voidEl('p:embed'))]),\n\t\tfallback: oleObj([raw(voidEl('p:embed')), raw(previewPic)]),\n\t})\n\n\tconst nvGraphicFramePr = el('p:nvGraphicFramePr', null, [\n\t\traw(cNvPrEl(shapeId, opts.objectName, opts.altText || '')),\n\t\traw(\n\t\t\tel(\n\t\t\t\t'p:cNvGraphicFramePr',\n\t\t\t\tnull,\n\t\t\t\traw(\n\t\t\t\t\tgenXmlObjectLock(\n\t\t\t\t\t\t'a:graphicFrameLocks',\n\t\t\t\t\t\tGRAPHIC_FRAME_LOCK_ATTRS,\n\t\t\t\t\t\t{ noChangeAspect: true, ...opts.objectLock },\n\t\t\t\t\t\topts.objectName\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t),\n\t\traw(voidEl('p:nvPr')),\n\t])\n\treturn graphicFrameEl({ nvGraphicFramePr, frame: { x, y, cx, cy }, uri: OLE_NS, payload: alternateContent })\n}\n","/**\n * ts-pptx: OLE / Embedded Object Definition (`addOleObject()` — PowerPoint's Insert ▸ Object).\n *\n * Registers the payload as an embedded package part plus a preview-picture image rel, and pushes a\n * `SlideObject{ _type: oleObject, ole }` for `gen/slide/objects/ole.ts` to emit as a `<p:graphicFrame>`.\n *\n * Ground truth for the two package-level choices here (verified against a deck authored by\n * PowerPoint via `Shapes.AddOLEObject`):\n * - an embedded Office file (xlsx/docx/pptx — each an OPC package in its own right) is referenced\n * with the `.../relationships/package` rel type and gets a content-type `Default` for its\n * extension; only a non-package OLE server blob uses `.../relationships/oleObject` with a `.bin`\n * part (ECMA-376 Part 1 §15.2.10);\n * - the payload lives in `ppt/embeddings/`, the preview picture in `ppt/media/` as an ordinary image.\n */\nimport { SlideObjectType } from '../../enums.js'\nimport type { OleObjectProps } from '../../types/media.js'\nimport type { PresSlideInternal, SlideObject } from '../../types/internal.js'\nimport { getNewRelId } from '../utils.js'\nimport { framedObjectOptions, requirePayloadSource } from './object-options.js'\nimport { registerPreviewImage } from './preview-image.js'\nimport { pushMediaRel } from './image-rel.js'\nimport { InvalidOptionError } from '../../errors.js'\nimport { OD_CONTENT, OFFICE_REL, PACKAGE_REL, PPTX_CONTENT_TYPE, XLSX_CONTENT_TYPE } from '../../ooxml/rel-types.js'\n\n/** Rel type for a generic OLE-server blob — a compound-file `.bin` (ECMA-376 Part 1 §15.2.10). */\nconst OLE_OBJECT_REL = OFFICE_REL + 'oleObject'\n\ninterface OleFormat {\n\t/** OPC content type, emitted as a `Default` entry for the part's extension. */\n\tcontentType: string\n\t/** `.rels` `Type` URI for the payload part. */\n\trelType: string\n\t/** Default `p:oleObj@progId`. */\n\tprogId: string\n\t/** Default `p:oleObj@name` — how PowerPoint labels the object's kind. */\n\tname: string\n}\n\n/**\n * Embeddable payload formats, keyed by file extension. The six Office extensions are OPC packages\n * and keep their own extension in `ppt/embeddings/`; everything else is embedded as a generic OLE\n * blob under {@link BIN_FORMAT}.\n */\nconst OLE_FORMATS: Record<string, OleFormat> = {\n\txlsx: { contentType: XLSX_CONTENT_TYPE, relType: PACKAGE_REL, progId: 'Excel.Sheet.12', name: 'Worksheet' },\n\txlsm: {\n\t\tcontentType: 'application/vnd.ms-excel.sheet.macroEnabled.12',\n\t\trelType: PACKAGE_REL,\n\t\tprogId: 'Excel.SheetMacroEnabled.12',\n\t\tname: 'Worksheet',\n\t},\n\tdocx: {\n\t\tcontentType: OD_CONTENT + 'wordprocessingml.document',\n\t\trelType: PACKAGE_REL,\n\t\tprogId: 'Word.Document.12',\n\t\tname: 'Document',\n\t},\n\tdocm: {\n\t\tcontentType: 'application/vnd.ms-word.document.macroEnabled.12',\n\t\trelType: PACKAGE_REL,\n\t\tprogId: 'Word.DocumentMacroEnabled.12',\n\t\tname: 'Document',\n\t},\n\tpptx: {\n\t\tcontentType: PPTX_CONTENT_TYPE,\n\t\trelType: PACKAGE_REL,\n\t\tprogId: 'PowerPoint.Show.12',\n\t\tname: 'Presentation',\n\t},\n\tpptm: {\n\t\tcontentType: 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',\n\t\trelType: PACKAGE_REL,\n\t\tprogId: 'PowerPoint.ShowMacroEnabled.12',\n\t\tname: 'Presentation',\n\t},\n}\n/** Fallback for any payload that is not one of the {@link OLE_FORMATS} Office packages. */\nconst BIN_FORMAT: OleFormat = {\n\tcontentType: OD_CONTENT + 'oleObject',\n\trelType: OLE_OBJECT_REL,\n\tprogId: 'Package',\n\tname: 'Object',\n}\n\n/** Reverse of {@link OLE_FORMATS}: a caller-supplied `progId` implies the payload's extension. */\nconst EXTN_BY_PROG_ID = new Map(Object.entries(OLE_FORMATS).map(([extn, fmt]) => [fmt.progId.toLowerCase(), extn]))\n/** Reverse of {@link OLE_FORMATS}: a `data:` URI's MIME implies the payload's extension. */\nconst EXTN_BY_CONTENT_TYPE = new Map(\n\tObject.entries(OLE_FORMATS).map(([extn, fmt]) => [fmt.contentType.toLowerCase(), extn])\n)\n\n/**\n * Resolve the embedded part's extension from whatever the caller gave us, in decreasing order of\n * explicitness: `extn`, the `data:` URI's MIME, the `path`'s extension, then the `progId`. Anything\n * unrecognized becomes `bin`, the generic OLE blob — which is what PowerPoint itself writes for a\n * shell-packaged payload, so an unknown extension never leaks into `[Content_Types].xml`.\n */\nfunction resolvePartExtn(opt: OleObjectProps): string {\n\tconst explicit = (opt.extn || '').replace(/^\\./, '').toLowerCase()\n\tif (explicit) return explicit in OLE_FORMATS ? explicit : 'bin'\n\n\tconst mime = /^data:([^;,]+)[;,]/.exec(opt.data || '')?.[1]?.toLowerCase()\n\tconst byMime = mime ? EXTN_BY_CONTENT_TYPE.get(mime) : undefined\n\tif (byMime) return byMime\n\n\tconst file = (opt.path || '').split(/[?#]/)[0] ?? ''\n\tconst byPath = file.includes('.') ? (file.split('.').pop() ?? '').toLowerCase() : ''\n\tif (byPath in OLE_FORMATS) return byPath\n\n\treturn EXTN_BY_PROG_ID.get((opt.progId || '').toLowerCase()) ?? 'bin'\n}\n\n/** The largest `ST_PositiveCoordinate32`, the type of `p:oleObj@imgW` and `@imgH`. */\nconst MAX_POSITIVE_COORDINATE_32 = 2147483647\n\n/**\n * The caller's `imgW` or `imgH`, as the whole EMU `ST_PositiveCoordinate32` allows, or `undefined`\n * when it is not stated. A value that is not a number from 0 to that type's maximum throws naming\n * the option, as a 3D model's camera does: `NaN` and `-5` were written into both the choice and the\n * fallback, and a fraction was written as given.\n * @param value - the caller's option\n * @param name - which of the two it is\n */\nfunction oleImageSize(value: number | undefined, name: 'imgW' | 'imgH'): number | undefined {\n\tif (value === undefined || value === null) return undefined\n\tif (typeof value !== 'number' || !(value >= 0 && value <= MAX_POSITIVE_COORDINATE_32))\n\t\tthrow new InvalidOptionError(\n\t\t\t'ole/invalid-image-size',\n\t\t\t`addOleObject(): \\`${name}\\` is a size in EMU from 0 to ${MAX_POSITIVE_COORDINATE_32}; got ${String(value)}.`\n\t\t)\n\treturn Math.round(value)\n}\n\n/**\n * Adds an embedded OLE object to a slide definition.\n * @param {PresSlideInternal} target - slide the object will be added to\n * @param {OleObjectProps} opt - OLE object options\n */\nexport function addOleObjectDefinition(target: PresSlideInternal, opt: OleObjectProps): void {\n\tconst strData = opt.data || ''\n\tconst strPath = opt.path || ''\n\n\t// STEP 1: REALITY-CHECK. The payload is the whole point; there is no meaningful default.\n\trequirePayloadSource(opt, 'ole/missing-source', 'addOleObject')\n\tconst imgW = oleImageSize(opt.imgW, 'imgW')\n\tconst imgH = oleImageSize(opt.imgH, 'imgH')\n\n\t// STEP 2: Resolve the payload format — part extension, content type, rel type, progId — and the\n\t// object's own options. The library never opens the payload, so there is no natural size to measure.\n\tconst extn = resolvePartExtn(opt)\n\tconst format = OLE_FORMATS[extn] ?? BIN_FORMAT\n\tconst options = framedObjectOptions(target, SlideObjectType.oleObject, opt, {\n\t\tlabel: 'Object',\n\t\tkind: 'oleObject',\n\t\tapi: 'addOleObject',\n\t\tdefaults: { x: 0, y: 0, w: 4, h: 3 },\n\t})\n\n\t// STEP 3: Register the payload part rel. Deliberately NOT deduped against an identical payload\n\t// elsewhere in the deck: PowerPoint gives every OLE object its own embedding part, and sharing\n\t// one would make editing either object rewrite the other's source.\n\tconst objectRid = getNewRelId(target)\n\tpushMediaRel(target, {\n\t\tkind: 'oleObject',\n\t\textn,\n\t\ttype: format.contentType,\n\t\tpath: strPath,\n\t\tdata: strData,\n\t\trId: objectRid,\n\t\tdir: 'embeddings',\n\t\textra: { oleRelType: format.relType },\n\t})\n\n\t// STEP 4: Register the preview picture (gray placeholder when the caller supplied no cover).\n\tconst previewRid = registerPreviewImage(target, opt.cover, 'addOleObject `cover`')\n\n\t// LAST: Push the slide object for the `<p:graphicFrame>` emitter.\n\tconst slideData: SlideObject = {\n\t\t_type: SlideObjectType.oleObject,\n\t\toptions,\n\t\tole: {\n\t\t\tobjectRid,\n\t\t\tpreviewRid,\n\t\t\tprogId: opt.progId || format.progId,\n\t\t\tname: format.name,\n\t\t\tshowAsIcon: !!opt.showAsIcon,\n\t\t\t...(imgW !== undefined ? { imgW } : {}),\n\t\t\t...(imgH !== undefined ? { imgH } : {}),\n\t\t},\n\t}\n\ttarget._slideObjects.push(slideData)\n}\n","/**\n * ts-pptx: the OLE construct family\n *\n * Embedded OLE objects (PowerPoint's Insert > Object > Create from File): the payload's bytes ship\n * inside the `.pptx`, so a double-click opens the source document in place.\n */\n\nimport { SlideObjectType } from '../enums.js'\nimport { renderOleObject } from '../gen/slide/objects/ole.js'\nimport { addOleObjectDefinition } from '../gen/define/ole.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const oleFamily = {\n\tname: 'ole',\n\tauthors: {\n\t\taddOleObject(slide, options) {\n\t\t\taddOleObjectDefinition(slide, options)\n\t\t},\n\t},\n\trenderers: {\n\t\t[SlideObjectType.oleObject]: renderOleObject,\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: DrawingML table-cell borders\n *\n * Emit the `<a:lnL>/<a:lnR>/<a:lnT>/<a:lnB>` border children of a table cell's\n * `<a:tcPr>`, in the LRTB document order PowerPoint requires, plus the two\n * optional diagonals (`<a:lnTlToBr>`/`<a:lnBlToTr>`) that follow them.\n */\n\nimport type { BorderProps, TableCellDiagonals } from '../../types/index.js'\nimport { borderLine, createLineCap, resolveBorderDash } from './line.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\n\n/**\n * One `<a:lnX>` border element. Every side of a table cell — the four edges and the two\n * diagonals — is a `CT_LineProperties`, so they differ only in element name.\n * @param {string} name - the element's local name (`lnL`, `lnTlToBr`, …)\n * @param {BorderProps} border - the resolved border for that side\n * @return {string} the border element XML\n */\nfunction genBorderLine(name: string, border: BorderProps): string {\n\tconst cap = createLineCap(border.cap)\n\t// A cell's *no border* keeps the attributes and zeroes the width, where the chart side\n\t// drops them (`noStrokeLine` in `gen/drawingml/line.ts`): this is the direct formatting that\n\t// overrides whatever the table style would have drawn on that edge, and an attribute-less\n\t// rule does not.\n\tif (border.type === 'none') return el(`a:${name}`, { w: 0, cap, cmpd: 'sng', algn: 'ctr' }, raw(voidEl('a:noFill')))\n\treturn borderLine(`a:${name}`, border, {\n\t\tdefaultWidth: 1,\n\t\tdefaultColor: '363636',\n\t\tcap,\n\t\textraAttrs: { cmpd: 'sng', algn: 'ctr' },\n\t\t// The only one of the four to honour `dashType`: a table border is the only place the\n\t\t// full `ST_PresetLineDashVal` range is authorable.\n\t\tdash: resolveBorderDash(border),\n\t\ttail: [\n\t\t\tvoidEl('a:round'),\n\t\t\tvoidEl('a:headEnd', { type: 'none', w: 'med', len: 'med' }),\n\t\t\tvoidEl('a:tailEnd', { type: 'none', w: 'med', len: 'med' }),\n\t\t],\n\t})\n}\n\n/**\n * Emit the border children of an `<a:tcPr>` for a table cell: the four edges, then the two\n * diagonals when the cell asks for them.\n *\n * The edges are shared by normal cells and the dummy span (`_hmerge`/`_vmerge`) cells so a\n * merged region's outer edges render with the same border as its origin cell. The diagonals\n * are **not**: a diagonal across a merged region is one stroke corner-to-corner, and\n * repeating it on each covered cell would draw a sawtooth instead. Only the span origin\n * carries them, which is also where PowerPoint puts them.\n *\n * A side may be missing, and missing is not the same as `{type:'none'}`: `none` writes an\n * explicit `w=\"0\"` rule, which is direct formatting and overrides whatever a built-in table\n * style would have drawn there, while an omitted side leaves that edge to the style. The\n * definition step sends every cell here dense; a caller reaching this directly may not.\n *\n * @param {BorderProps[]} cellBorder - up to a 4-tuple of border props in [top, right, bottom, left] order\n * @param {TableCellDiagonals} [diagonal] - the cell's optional corner-to-corner rules\n * @return {string} concatenated border element XML, in the document order PowerPoint expects\n */\nexport function genTableCellBorderXml(\n\tcellBorder: ReadonlyArray<BorderProps | undefined>,\n\tdiagonal?: TableCellDiagonals\n): string {\n\tlet strXml = ''\n\t// NOTE: *** IMPORTANT! *** LRTB order matters! (Reorder a line below to watch the borders go wonky in MS-PPT-2013!!)\n\t;(\n\t\t[\n\t\t\t{ idx: 3, name: 'lnL' },\n\t\t\t{ idx: 1, name: 'lnR' },\n\t\t\t{ idx: 0, name: 'lnT' },\n\t\t\t{ idx: 2, name: 'lnB' },\n\t\t] as const\n\t).forEach((obj) => {\n\t\tconst border = cellBorder[obj.idx]\n\t\tif (!border) return\n\t\tstrXml += genBorderLine(obj.name, border)\n\t})\n\t// CT_TableCellProperties declares the diagonals immediately after `lnB` and before\n\t// `cell3D`/the fill, so they append here rather than being emitted by the caller.\n\tif (diagonal?.tlToBr) strXml += genBorderLine('lnTlToBr', diagonal.tlToBr)\n\tif (diagonal?.blToTr) strXml += genBorderLine('lnBlToTr', diagonal.blToTr)\n\treturn strXml\n}\n","/**\n * ts-pptx: DrawingML table-cell 3-D bevel\n *\n * Emit the `<a:cell3D>` child of a table cell's `<a:tcPr>`. `CT_Cell3D` is a **required**\n * `a:bevel` plus an optional `a:lightRig`, which is why an empty `cell3D: {}` still produces\n * a bevel element (at the schema's own defaults) rather than an empty, invalid `a:cell3D`.\n *\n * The surface is deliberately minimal — preset, size, material and light rig. PowerPoint's\n * table UI exposes no control for any of it, so a cell3D reaches a deck from a theme or\n * another producer; this exists to author and reproduce one, not to model DrawingML 3-D.\n */\n\nimport type { TableCell3DProps } from '../../types/index.js'\nimport { warnOnce } from '../../diagnostics.js'\nimport { checkEnumOrWarn } from '../../ooxml/check-enum.js'\nimport { BEVEL_PRESETS, LIGHT_RIGS, LIGHT_RIG_DIRECTIONS, PRESET_MATERIALS } from '../../ooxml/st-enums.js'\nimport { ptsToEmuLenient } from '../../units-internal.js'\nimport { el, raw, voidEl } from '../oxml/el.js'\n\n/**\n * Vet one enumerated value before it reaches the XML, reporting and dropping anything outside\n * its `ST_` union. See `ooxml/check-enum.ts` for why the write path drops rather than throws.\n */\nfunction resolveEnum<T extends string>(value: string | undefined, valid: readonly T[], field: string): T | null {\n\treturn checkEnumOrWarn(value, valid, 'table/invalid-cell3d', `table cell: cell3D \\`${field}\\``, { field })\n}\n\n/**\n * A bevel dimension in EMU (`ST_PositiveCoordinate`), from a width in points.\n * A negative or non-finite value cannot be written, so it falls back to the attribute's\n * own default of 76200 EMU (6pt) rather than emitting something PowerPoint would reject.\n */\nfunction bevelSizeEmu(points: number | undefined, field: string): number | null {\n\tif (points === undefined || points === null) return null\n\tif (!Number.isFinite(points) || points < 0) {\n\t\twarnOnce(\n\t\t\t'table/invalid-cell3d',\n\t\t\t`table cell: cell3D \\`${field}\\` must be a non-negative number of points; \\`${String(points)}\\` is ignored.`,\n\t\t\t{ received: points, field }\n\t\t)\n\t\treturn null\n\t}\n\treturn ptsToEmuLenient(points)\n}\n\n/**\n * Emit a cell's `<a:cell3D>`, or `''` when it has none.\n * @param {TableCell3DProps} [cell3D] - the cell's 3-D options\n * @return {string} the `a:cell3D` element XML\n */\nexport function genTableCell3DXml(cell3D?: TableCell3DProps): string {\n\tif (!cell3D || typeof cell3D !== 'object') return ''\n\tconst bevel = voidEl('a:bevel', {\n\t\tw: bevelSizeEmu(cell3D.width, 'width'),\n\t\th: bevelSizeEmu(cell3D.height, 'height'),\n\t\tprst: resolveEnum(cell3D.preset, BEVEL_PRESETS, 'preset'),\n\t})\n\t// Both `rig` and `dir` are required on CT_LightRig, so a half-specified rig is dropped\n\t// whole — emitting one attribute would produce a part PowerPoint calls corrupt.\n\tconst rig = resolveEnum(cell3D.lightRig?.rig, LIGHT_RIGS, 'lightRig.rig')\n\tconst dir = resolveEnum(cell3D.lightRig?.dir, LIGHT_RIG_DIRECTIONS, 'lightRig.dir')\n\tconst lightRig = rig && dir ? voidEl('a:lightRig', { rig, dir }) : ''\n\tif (cell3D.lightRig && !lightRig) {\n\t\twarnOnce(\n\t\t\t'table/invalid-cell3d',\n\t\t\t'table cell: cell3D `lightRig` needs both `rig` and `dir` (both are required by CT_LightRig); ' +\n\t\t\t\t'the light rig is dropped and the bevel takes the renderer default.',\n\t\t\t{ received: cell3D.lightRig }\n\t\t)\n\t}\n\treturn el('a:cell3D', { prstMaterial: resolveEnum(cell3D.material, PRESET_MATERIALS, 'material') }, [\n\t\traw(bevel),\n\t\tlightRig ? raw(lightRig) : null,\n\t])\n}\n","/**\n * ts-pptx: table slide-object serialization\n *\n * Emits a `table` slide object as a `<p:graphicFrame>` wrapping `<a:tbl>`: the merge grid\n * (`_hmerge`/`_vmerge` dummy cells for col/rowspan), the column widths, and per-cell borders,\n * fill, margins and text body.\n */\n\nimport { SlideObjectType } from '../../../enums.js'\nimport type { TableCellInternal } from '../../../types/internal.js'\nimport type { BorderProps, ObjectOptions, TableCellProps } from '../../../types/index.js'\nimport { checkEnumOrWarn } from '../../../ooxml/check-enum.js'\nimport { TEXT_HORZ_OVERFLOW } from '../../../ooxml/st-enums.js'\nimport { rejectEmptyColor } from '../../drawingml/color.js'\nimport { genXmlColorSelection } from '../../drawingml/fill.js'\nimport { genXmlObjectLock, GRAPHIC_FRAME_LOCK_ATTRS } from '../../drawingml/locks.js'\nimport { genTableCellBorderXml } from '../../drawingml/table-border.js'\nimport { resolveSpan, withCheckedSpans } from '../../table/spans.js'\nimport { genTableCell3DXml } from '../../drawingml/table-cell3d.js'\nimport { genXmlPlaceholder, genXmlTextBody, resolveTextAnchor } from '../../drawingml/text-body.js'\nimport { el, elOrVoid, raw, voidEl, type XmlAttrs } from '../../oxml/el.js'\nimport {\n\tmarginToEmu,\n\tresolveCellMarginsInches,\n\tresolveTableColWidthsEmu,\n\tresolveTableRowHeightEmu,\n} from '../../../units-internal.js'\nimport { EMU_PER_INCH } from '../../../units.js'\nimport { type RenderContext, cNvPrEl, graphicFrameEl } from './shared.js'\nimport { OOXML_NS, TABLE_GRAPHIC_DATA_URI } from '../../../ooxml/namespaces.js'\nimport { xsdBoolIfTrue } from '../../../ooxml/xsd-boolean.js'\nimport { type GridPlacement, tableColCount, walkTableGrid } from '../../table/grid.js'\nimport { CELL_INHERITED_KEYS } from '../../table/cell-inherit.js'\nimport { warn } from '../../../diagnostics.js'\n\n/**\n * The table-level options a cell inherits when it states none of its own.\n * @see http://officeopenxml.com/drwTableCellProperties-alignment.php\n */\ntype TableInheritableOption = (typeof CELL_INHERITED_KEYS)[number]\ntype TableInheritableValue = ObjectOptions[TableInheritableOption]\n\n/**\n * Validate a cell's `horzOverflow` before it reaches the XML, reporting and dropping anything\n * outside `ST_TextHorzOverflowType`. `undefined` (the common case) emits nothing.\n */\nfunction resolveHorzOverflow(value: TableCellProps['horzOverflow']): string | null {\n\treturn checkEnumOrWarn(value, TEXT_HORZ_OVERFLOW, 'table/invalid-horz-overflow', 'table cell: horzOverflow')\n}\n\n/** A cell's grid position, for deciding which of the table's outer edges it sits on. */\ninterface GridEdge {\n\trIdx: number\n\tcIdx: number\n\tlastRow: number\n\tlastCol: number\n}\n\n/**\n * Overlay `TableProps.outerBorder` onto one cell's own 4-side border tuple.\n *\n * The perimeter is decided per **grid position**, not per authored cell, which is what makes\n * merges work: a colspan's origin sits at the left of its span and its covered `_hmerge`\n * cells sit to the right, so a span straddling the last column gets that column's rule on the\n * covered cell — exactly where PowerPoint defines a merged region's outer edge. A cell in the\n * table's interior touches no edge and comes back untouched.\n *\n * Returns the input array (not a copy) when nothing applies, so the common no-perimeter path\n * allocates nothing and stays byte-identical. Never mutates: `arrTabRows` holds the caller's\n * own cell objects and repeated `write()` calls must not accumulate borders.\n *\n * @param base - the cell's resolved `[top, right, bottom, left]` borders, or `null` when it has none\n * @param outer - the normalized perimeter tuple, `undefined` for a side the caller left out\n * @param at - where this cell sits in the merge grid\n * @returns the borders to emit, or `null` when there are none and the perimeter adds none\n */\nfunction applyOuterBorder(\n\tbase: ReadonlyArray<BorderProps | undefined> | null,\n\touter: ReadonlyArray<BorderProps | undefined> | undefined,\n\tat: GridEdge\n): ReadonlyArray<BorderProps | undefined> | null {\n\tif (!outer) return base\n\t// TRBL, matching the public tuple order.\n\tconst onEdge = [at.rIdx === 0, at.cIdx === at.lastCol, at.rIdx === at.lastRow, at.cIdx === 0]\n\tconst applies = ([0, 1, 2, 3] as const).filter((idx) => onEdge[idx] && outer[idx])\n\tif (applies.length === 0) return base\n\t// A missing base is a cell the definition step left with no border tuple at all, which is\n\t// a styled table nobody authored a border on. Its other three sides stay holes so the\n\t// chosen table style keeps painting them: inventing `{type:'none'}` here would erase the\n\t// style's interior grid the moment an `outerBorder` was added (#23).\n\tconst merged: (BorderProps | undefined)[] = base ? [...base] : [undefined, undefined, undefined, undefined]\n\tfor (const idx of applies) {\n\t\tconst side = outer[idx]\n\t\tif (side) merged[idx] = side\n\t}\n\treturn merged\n}\n\n/**\n * The options a table cell is emitted with: its own values, with the table's filled in wherever\n * the cell stated nothing.\n *\n * The guard is `=== undefined`, not a falsy test: the question is whether the CELL said\n * anything, and `false`/`0`/`''` are things it said. An older guard rescued `0` with an\n * explicit `!== 0` arm and nothing else, so a cell's `bold: false` was still overwritten by the\n * table's `bold: true`.\n *\n * `src/measure/table-fit.ts` resolves the same inheritance for the measured-fit pass, over the\n * text half of the same list -- see `gen/table/cell-inherit.ts`, which owns both halves.\n * @param cellOpts - the cell's own options, if any\n * @param tableOpts - the table's options\n * @returns a fresh bag; neither input is written to\n */\nfunction inheritTableOptions(cellOpts: TableCellProps | undefined, tableOpts: ObjectOptions): TableCellProps {\n\tconst merged: TableCellProps = { ...cellOpts }\n\tconst inheritedCell = merged as Partial<Record<TableInheritableOption, TableInheritableValue>>\n\tconst inheritedTable = tableOpts as Partial<Record<TableInheritableOption, TableInheritableValue>>\n\tfor (const name of CELL_INHERITED_KEYS) {\n\t\tif (inheritedCell[name] === undefined && inheritedTable[name] !== undefined)\n\t\t\tinheritedCell[name] = inheritedTable[name]\n\t}\n\treturn merged\n}\n\n/**\n * The origin cell a placement writes: the authored cell, carrying the spans the grid gave it.\n *\n * `walkTableGrid` clamps a colspan to the columns left and a rowspan to the rows left. The emitter\n * used to write the authored spans unclamped, so `[[{ text: 'A', rowspan: 3 }, 'B'], ['C']]` wrote\n * `rowSpan=\"3\"` into a two-row table while the auto-pager and `tableLayout()` described the clamped\n * one. A span the grid had to shorten is reported and written shortened. A cell whose spans stand\n * is returned by identity, which is what its covered cells' `_spanOrigin` points at.\n * @param placement - the cell's placement on the grid\n */\nfunction placedOrigin({ cell, rowSpan, colSpan }: GridPlacement): TableCellInternal {\n\tconst opts = cell.options\n\tconst statedCol = resolveSpan(opts?.colspan, 'colspan')\n\tconst statedRow = resolveSpan(opts?.rowspan, 'rowspan')\n\tif (statedCol === colSpan && statedRow === rowSpan) return cell\n\tif (statedCol !== colSpan)\n\t\twarn(\n\t\t\t'table/span-out-of-range',\n\t\t\t`table cell: colspan ${statedCol} reaches past the table's last column; using ${colSpan}.`\n\t\t)\n\tif (statedRow !== rowSpan)\n\t\twarn(\n\t\t\t'table/span-out-of-range',\n\t\t\t`table cell: rowspan ${statedRow} reaches past the table's last row; using ${rowSpan}.`\n\t\t)\n\treturn { ...cell, options: { ...opts, colspan: colSpan, rowspan: rowSpan } }\n}\n\n/**\n * The table as the grid it is written on: one cell per row and grid column.\n *\n * Every position is filled. An origin sits at its `walkTableGrid` placement, and each position its\n * span covers gets a covered cell pointing back at it: `_hmerge` right of the origin, `_vmerge`\n * below it, both where the span runs both ways. A covered cell in the origin's own row repeats the\n * origin's `rowspan`, and one in its column repeats its `colspan`, which is how PowerPoint writes a\n * merged region. A position no cell reaches (a row shorter than the grid) is a blank cell, and a cell\n * starting past the last column is dropped and reported, because a `<a:tr>` whose `<a:tc>` count\n * differs from `<a:tblGrid>` is a table PowerPoint repairs.\n *\n * Two splice passes used to insert the covered cells into the authored rows by index. They read the\n * spans unclamped, so a span past the table edge wrote cells past it:\n * `[['A', 'B'], [{ text: 'D', colspan: 3 }]]` wrote three `<a:tc>` against two `<a:gridCol>`.\n * @param rows - the table's rows, spans already range-checked\n * @param numCols - the grid's column count\n */\nfunction buildMergeGrid(rows: TableCellInternal[][], numCols: number): TableCellInternal[][] {\n\tconst grid: Array<Array<TableCellInternal | undefined>> = rows.map(() =>\n\t\tArray.from({ length: numCols }, (): TableCellInternal | undefined => undefined)\n\t)\n\tconst placedPerRow = rows.map(() => 0)\n\tfor (const placement of walkTableGrid(rows, numCols)) {\n\t\tplacedPerRow[placement.row] = (placedPerRow[placement.row] ?? 0) + 1\n\t\tconst origin = placedOrigin(placement)\n\t\tconst { row, col, rowSpan, colSpan } = placement\n\t\tfor (let dr = 0; dr < rowSpan; dr++) {\n\t\t\tconst target = grid[row + dr]\n\t\t\tif (!target) continue\n\t\t\tfor (let dc = 0; dc < colSpan; dc++) {\n\t\t\t\tif (dr === 0 && dc === 0) {\n\t\t\t\t\ttarget[col] = origin\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst options: TableCellProps = {}\n\t\t\t\tif (dr === 0 && rowSpan > 1) options.rowspan = rowSpan\n\t\t\t\tif (dc === 0 && colSpan > 1) options.colspan = colSpan\n\t\t\t\tconst covered: TableCellInternal = { _type: SlideObjectType.tablecell, options, _spanOrigin: origin }\n\t\t\t\tif (dr > 0) covered._vmerge = true\n\t\t\t\tif (dc > 0) covered._hmerge = true\n\t\t\t\ttarget[col + dc] = covered\n\t\t\t}\n\t\t}\n\t}\n\tconst dropped = rows.reduce((count, row, r) => count + row.length - (placedPerRow[r] ?? 0), 0)\n\tif (dropped > 0)\n\t\twarn(\n\t\t\t'table/cell-past-grid',\n\t\t\t`table: ${dropped} cell(s) start past the last of the table's ${numCols} grid columns and are not written. The first row decides how many columns a table has.`\n\t\t)\n\treturn grid.map((cells) =>\n\t\tcells.map((cell): TableCellInternal => cell ?? { _type: SlideObjectType.tablecell, text: '' })\n\t)\n}\n\n/**\n * Render a `table` slide object to its `<p:graphicFrame>` XML (merge-grid, row/col spans, per-cell styling).\n */\nexport function renderTableObject(ctx: RenderContext): string {\n\tconst {\n\t\tobj: slideItemObj,\n\t\tshapeId,\n\t\tframe: { x, y, cx, cy },\n\t\tplaceholder: placeholderObj,\n\t\titemOpts,\n\t} = ctx\n\t// `itemOpts` is the caller's already-normalized `itemOpts` (see the dispatch in\n\t// `slideObjectToXml`). Read it rather than re-narrowing the field: this function has exactly\n\t// one call site, and a contract stated there beats a defensive re-assignment here.\n\tlet tblInner = ''\n\t// Checked again here, not only in `addTableDefinition`: the merge grid below is laid out from the\n\t// spans, and an emitter must not size anything from a number it has not seen. Rows that came\n\t// through the definer are already correct, so this warns about nothing. Nothing below writes to\n\t// the rows, so the stored `arrTabRows` survive repeated `write()` calls without a copy.\n\tconst arrTabRows: TableCellInternal[][] = withCheckedSpans(slideItemObj.arrTabRows ?? [])\n\tconst objTabOpts: ObjectOptions = itemOpts\n\tconst intColCnt = tableColCount(arrTabRows)\n\n\t// STEP 1: Start Table XML\n\t// NOTE: The cNvPr id must be unique among ALL shapes on the slide. A table is an\n\t// ordinary top-level slide object, so it uses the same `idx + 2` scheme as every other\n\t// object type below. The legacy `intTableNum * slide._slideNum + 1` formula could collide\n\t// with another shape's `idx + 2` on the same slide (e.g. a table plus enough sibling\n\t// shapes on slide 7), producing a duplicate id that makes PowerPoint report the file as\n\t// corrupt/unreadable (0x80070570) while LibreOffice silently tolerates it.\n\tconst nvGraphicFramePr = el('p:nvGraphicFramePr', null, [\n\t\traw(cNvPrEl(shapeId, itemOpts.objectName, itemOpts.altText || '')),\n\t\traw(\n\t\t\tel(\n\t\t\t\t'p:cNvGraphicFramePr',\n\t\t\t\tnull,\n\t\t\t\traw(\n\t\t\t\t\tgenXmlObjectLock(\n\t\t\t\t\t\t'a:graphicFrameLocks',\n\t\t\t\t\t\tGRAPHIC_FRAME_LOCK_ATTRS,\n\t\t\t\t\t\t{ noGrp: true, ...itemOpts.objectLock },\n\t\t\t\t\t\titemOpts.objectName\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t),\n\t\t// A table bound to a layout placeholder emits that placeholder's <p:ph> (idx/type) so\n\t\t// PowerPoint treats the graphicFrame as filling the placeholder. The <p:ph>\n\t\t// precedes <p:extLst> per CT_ApplicationNonVisualDrawingProps document order.\n\t\traw(\n\t\t\tel(\n\t\t\t\t'p:nvPr',\n\t\t\t\tnull,\n\t\t\t\t[\n\t\t\t\t\traw(genXmlPlaceholder(placeholderObj)),\n\t\t\t\t\traw(\n\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t'p:extLst',\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\traw(\n\t\t\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t\t\t'p:ext',\n\t\t\t\t\t\t\t\t\t{ uri: '{D42A27DB-BD31-4B8C-83A1-F6EECF244321}' },\n\t\t\t\t\t\t\t\t\traw(voidEl('p14:modId', { 'xmlns:p14': OOXML_NS.p14, val: '1579011935' }))\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\t{ openPrefix: ' ' }\n\t\t\t)\n\t\t),\n\t])\n\t// A table's box falls back to one inch on any axis the caller left undefined, rather than to\n\t// the zero a missing extent would otherwise emit.\n\tconst frame = {\n\t\tx: x || (x === 0 ? 0 : EMU_PER_INCH),\n\t\ty: y || (y === 0 ? 0 : EMU_PER_INCH),\n\t\tcx: cx || (cx === 0 ? 0 : EMU_PER_INCH),\n\t\tcy: cy || EMU_PER_INCH,\n\t}\n\t{\n\t\t// NOTE: attribute ORDER is byte-significant. None of these flags appears in the byte-gate\n\t\t// baseline (zero parts each), so their emission is pinned by test/regression instead.\n\t\tconst tblPrAttrs: XmlAttrs = {\n\t\t\trtl: xsdBoolIfTrue(objTabOpts.rtl),\n\t\t\tfirstRow: xsdBoolIfTrue(objTabOpts.hasHeader),\n\t\t\tlastRow: xsdBoolIfTrue(objTabOpts.hasFooter),\n\t\t\tbandRow: xsdBoolIfTrue(objTabOpts.hasBandedRows),\n\t\t\tbandCol: xsdBoolIfTrue(objTabOpts.hasBandedColumns),\n\t\t\tfirstCol: xsdBoolIfTrue(objTabOpts.hasFirstColumn),\n\t\t\tlastCol: xsdBoolIfTrue(objTabOpts.hasLastColumn),\n\t\t}\n\t\t// `CT_TableProperties` sequences its children as EG_FillProperties, EG_EffectProperties,\n\t\t// then the tableStyle/tableStyleId choice — so a table background precedes the style id.\n\t\t// (No effects surface: PowerPoint's UI exposes no table-level effect, so a source deck\n\t\t// will not contain one and there would be nothing to reproduce.)\n\t\trejectEmptyColor(objTabOpts.tableFill, 'tableFill')\n\t\tconst tableFillXml = objTabOpts.tableFill ? genXmlColorSelection(objTabOpts.tableFill) : ''\n\t\tconst tblPrChildren =\n\t\t\ttableFillXml + (objTabOpts.tableStyle ? el('a:tableStyleId', null, objTabOpts.tableStyle) : '')\n\t\t// Paired when it carries a fill or a style id, else self-closing — an arity difference.\n\t\tconst tblPr = elOrVoid('a:tblPr', tblPrAttrs, tblPrChildren)\n\t\t// The `<a:tbl>` children accumulate here and are wrapped once at STEP 5, so the byte-significant\n\t\t// (and non-depth-regular) indentation on the closing tags is described in one place.\n\t\ttblInner = tblPr\n\t}\n\n\t// `addTableDefinition` normalizes `outerBorder` to a TRBL tuple, but a table object built by\n\t// hand (or replayed from an older serialized form) can still carry the single-`BorderProps`\n\t// form, so broadcast that here rather than silently dropping the perimeter.\n\tconst outerBorder: ReadonlyArray<BorderProps | undefined> | undefined = !objTabOpts.outerBorder\n\t\t? undefined\n\t\t: Array.isArray(objTabOpts.outerBorder)\n\t\t\t? objTabOpts.outerBorder\n\t\t\t: [objTabOpts.outerBorder, objTabOpts.outerBorder, objTabOpts.outerBorder, objTabOpts.outerBorder]\n\n\t// STEP 2: Set column widths\n\t// Per-column inches from an explicit `colW` array, else split the table's\n\t// resolved EMU width (`cx`) evenly. `resolveTableColWidthsEmu` is the single\n\t// source of truth shared with the measured-fit pass. NOTE: divide the EMU\n\t// width, not the raw inches `options.w` — the latter collapsed auto-width\n\t// tables to ~0-EMU columns (e.g. `w=9` → `gridCol w=\"3\"`).\n\t{\n\t\tconst gridColsEmu = resolveTableColWidthsEmu(objTabOpts.colW, cx, intColCnt)\n\t\ttblInner += el(\n\t\t\t'a:tblGrid',\n\t\t\tnull,\n\t\t\tgridColsEmu.map((w) => raw(voidEl('a:gridCol', { w })))\n\t\t)\n\t}\n\n\t// STEP 3: Build our row arrays into an actual grid to match the XML we will be building next\n\t// Note row arrays can arrive \"lopsided\" as in row1:[1,2,3] row2:[3] when first two cols rowspan!,\n\t// so a simple loop below in XML building wont suffice to build table correctly.\n\t// We have to build an actual grid now\n\t/*\n\t\t\t\t\tEX: (A0:rowspan=3, B1:rowspan=2, C1:colspan=2)\n\n\t\t\t\t\t/------|------|------|------\\\n\t\t\t\t\t| A0 | B0 | C0 | D0 |\n\t\t\t\t\t| | B1 | C1 | |\n\t\t\t\t\t| | | C2 | D2 |\n\t\t\t\t\t\\------|------|------|------/\n\t\t\t\t*/\n\t// Placement comes from `walkTableGrid`, the traversal the auto-pager and the measured-fit pass\n\t// read, so the table written is the one they paged and measured.\n\tconst grid = buildMergeGrid(arrTabRows, intColCnt)\n\n\t// STEP 4: Build table rows/cells\n\tgrid.forEach((cells, rIdx) => {\n\t\t// A: `rowH` pins the row; a table height provided without one is split evenly.\n\t\t// The height comes from the PLACED frame, not from `options.h`, which is why this does not\n\t\t// go through `resolveTableGridEmu` the way `pptx.tableLayout()` and the measured-fit pass\n\t\t// do: only the emitter knows the frame, and a layout placeholder overrides `h` there. The\n\t\t// row split itself is the same `resolveTableRowHeightEmu` all three read.\n\t\t// IMPORTANT: `null` (auto-height) must reach the attribute as zero for auto-sizing to work.\n\t\tconst tableHeightEmu = itemOpts.h ? cy : typeof itemOpts.cy === 'number' ? itemOpts.cy : 0\n\t\tconst intRowH = resolveTableRowHeightEmu(objTabOpts.rowH, rIdx, tableHeightEmu, arrTabRows.length) ?? 0\n\n\t\t// B: Start row — cells accumulate here and the row wraps them once, below.\n\t\tconst rowCells: string[] = []\n\n\t\t// C: Loop over each CELL\n\t\tcells.forEach((cellObj, cIdx) => {\n\t\t\tconst cell: TableCellInternal = cellObj\n\t\t\t// The grid is rectangular by now (STEP 3 filled every span with a dummy cell), so a\n\t\t\t// cell's index in its row *is* its grid column and the perimeter can be decided here.\n\t\t\tconst at: GridEdge = { rIdx, cIdx, lastRow: arrTabRows.length - 1, lastCol: cells.length - 1 }\n\n\t\t\t// NOTE: attribute ORDER is byte-significant; `undefined` omits the attribute entirely,\n\t\t\t// which is what the old `.filter(([, v]) => !!v)` did.\n\t\t\tconst cellSpanAttrs: XmlAttrs = {\n\t\t\t\trowSpan: cell.options?.rowspan && cell.options.rowspan > 1 ? cell.options.rowspan : undefined,\n\t\t\t\tgridSpan: cell.options?.colspan && cell.options.colspan > 1 ? cell.options.colspan : undefined,\n\t\t\t\tvMerge: cell._vmerge ? 1 : undefined,\n\t\t\t\thMerge: cell._hmerge ? 1 : undefined,\n\t\t\t}\n\n\t\t\t// 1: COLSPAN/ROWSPAN: Emit the dummy covered cell for any active span. PowerPoint defines a\n\t\t\t// merged region's outer edges (e.g. the right border of a colspan, the bottom border of a\n\t\t\t// rowspan) on the *covered* cells, so inherit the origin cell's border + fill here instead of\n\t\t\t// emitting an empty `<a:tcPr/>` that drops those edges.\n\t\t\tif (cell._hmerge || cell._vmerge) {\n\t\t\t\tconst origin = cell._spanOrigin\n\t\t\t\tconst originOpts = origin?.options || {}\n\t\t\t\tlet spanPrXml = ''\n\t\t\t\t// Outside the `origin` guard below: a covered cell on the table's edge carries that\n\t\t\t\t// edge's rule whether or not its origin was resolvable.\n\t\t\t\t// A null tuple side means \"this edge is omitted\" (inherits) — normalize it to a\n\t\t\t\t// hole here, which `applyOuterBorder` already treats as \"leave the edge alone\".\n\t\t\t\tconst originBorder = applyOuterBorder(\n\t\t\t\t\tArray.isArray(originOpts.border) ? originOpts.border.map((side) => side ?? undefined) : null,\n\t\t\t\t\touterBorder,\n\t\t\t\t\tat\n\t\t\t\t)\n\t\t\t\tif (originBorder) spanPrXml += genTableCellBorderXml(originBorder)\n\t\t\t\tif (origin) {\n\t\t\t\t\t// Resolve the origin's fill with the same precedence the origin cell itself uses below,\n\t\t\t\t\t// so the whole merged region fills uniformly. This is the origin's fill *object*, so\n\t\t\t\t\t// an image fill arrives with its `_imgRid` already stashed and the covered cell emits\n\t\t\t\t\t// a `blipFill` against the same relationship.\n\t\t\t\t\t// NOTE: PowerPoint itself writes a bare `<a:tcPr/>` on a covered cell and repeats no\n\t\t\t\t\t// fill there (verified against `test/read/fixtures/table-cell-image-fill.pptx`). We\n\t\t\t\t\t// diverge deliberately: a covered cell is never rendered — the origin spans over it —\n\t\t\t\t\t// so copying the fill is invisible either way, and keeping it uniform with the solid\n\t\t\t\t\t// case avoids a branch that would change nothing on screen.\n\t\t\t\t\trejectEmptyColor(originOpts.fill, 'cell fill')\n\t\t\t\t\tconst spanFill = originOpts.fill || ''\n\t\t\t\t\tif (spanFill) spanPrXml += genXmlColorSelection(spanFill)\n\t\t\t\t}\n\t\t\t\t// NOTE: the covered cell is FLAT, unlike the real cell below, which carries indentation\n\t\t\t\t// before its `</a:tcPr>` and `</a:tc>`.\n\t\t\t\trowCells.push(el('a:tc', cellSpanAttrs, raw(el('a:tcPr', null, raw(spanPrXml)))))\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// 2: OPTIONS: the cell's own values, with the table's filled in where the cell said\n\t\t\t// nothing. Resolved into a LOCAL bag: this used to be written back onto `cell.options`,\n\t\t\t// which is the stored model, so emitting the same deck twice inherited into it again and\n\t\t\t// the reference handed to `genXmlTextBody` below carried keys the cell never stated.\n\t\t\t// The invariant at the head of this file has said \"never mutates\" throughout.\n\t\t\tconst cellOpts = inheritTableOptions(cell.options, objTabOpts)\n\n\t\t\tconst cellValign = resolveTextAnchor(cellOpts.valign)\n\t\t\tconst cellTextDir = cellOpts.textDirection && cellOpts.textDirection !== 'horz' ? cellOpts.textDirection : null\n\n\t\t\trejectEmptyColor(cellOpts.fill, 'cell fill')\n\t\t\tconst fillColor = cellOpts.fill || ''\n\t\t\tconst cellFill = fillColor ? genXmlColorSelection(fillColor) : ''\n\n\t\t\tconst cellMargin = resolveCellMarginsInches(cellOpts.margin)\n\t\t\t// Cell text ALWAYS wraps — PowerPoint has no per-cell no-wrap, so there is nothing to emit\n\t\t\t// for one. `wrap=\"none\"` on a cell's `<a:bodyPr>` renders inert and is stripped on the next\n\t\t\t// save, and `TextFrame.WordWrap` is read-only on a cell over COM (it reports msoTrue whatever\n\t\t\t// the XML says). `horzOverflow` below is NOT that switch: per ECMA-376 §20.1.10.68 it decides\n\t\t\t// whether a single glyph too wide for the line is clipped or draws past the cell edge.\n\t\t\t// Probe for both: `test/read/fixtures/authoring/probe-table-cell-wrap.ps1`\n\t\t\tconst cellHorzOverflow = resolveHorzOverflow(cellOpts.horzOverflow)\n\n\t\t\t// Cell margins are inches (see `marginToEmu`); a `>= 1` value warns once as a likely legacy points value.\n\t\t\t// NOTE: attribute ORDER is byte-significant (margins, then anchor, then vert). `horzOverflow`\n\t\t\t// goes last, which is both where CT_TableCellProperties declares it and where PowerPoint\n\t\t\t// writes it, so an existing cell's bytes are unchanged while it stays unset. `anchorCtr`\n\t\t\t// follows `anchor`, matching the schema's own adjacency; that the emitter's `anchor`/`vert`\n\t\t\t// pair is inverted relative to CT_TableCellProperties is pre-existing and harmless — XML\n\t\t\t// attributes are unordered, so the order is only about keeping emitted bytes stable.\n\t\t\tconst tcPrAttrs: XmlAttrs = {\n\t\t\t\tmarL: marginToEmu(cellMargin[3]),\n\t\t\t\tmarR: marginToEmu(cellMargin[1]),\n\t\t\t\tmarT: marginToEmu(cellMargin[0]),\n\t\t\t\tmarB: marginToEmu(cellMargin[2]),\n\t\t\t\tanchor: cellValign,\n\t\t\t\t// `false` is the schema default, so only `true` is worth writing.\n\t\t\t\tanchorCtr: xsdBoolIfTrue(cellOpts.anchorCtr),\n\t\t\t\tvert: cellTextDir,\n\t\t\t\thorzOverflow: cellHorzOverflow,\n\t\t\t}\n\n\t\t\t// 4: Set CELL content and properties; 5: borders; 6: fill ==============\n\t\t\t// The trailing indentation before `</a:tcPr>` and `</a:tc>` is byte-significant.\n\t\t\t// Child order is the CT_TableCellProperties sequence: the four edges, the two diagonals,\n\t\t\t// `cell3D`, then the fill. Unlike the edges, the diagonals are NOT copied onto a merged\n\t\t\t// region's covered cells (see `genTableCellBorderXml`).\n\t\t\t// A null tuple side is *omitted* (inherits) — normalize it to a hole, which\n\t\t\t// `applyOuterBorder` already treats as \"leave the edge alone\".\n\t\t\tconst cellBorder = applyOuterBorder(\n\t\t\t\tArray.isArray(cellOpts.border) ? cellOpts.border.map((side) => side ?? undefined) : null,\n\t\t\t\touterBorder,\n\t\t\t\tat\n\t\t\t)\n\t\t\tconst cellDiagonal = cellOpts.diagonal\n\t\t\tconst cellBorderXml = cellBorder || cellDiagonal ? genTableCellBorderXml(cellBorder ?? [], cellDiagonal) : ''\n\t\t\trowCells.push(\n\t\t\t\tel(\n\t\t\t\t\t'a:tc',\n\t\t\t\t\tcellSpanAttrs,\n\t\t\t\t\t[\n\t\t\t\t\t\traw(genXmlTextBody({ ...cell, options: cellOpts })),\n\t\t\t\t\t\traw(\n\t\t\t\t\t\t\tel('a:tcPr', tcPrAttrs, [raw(cellBorderXml), raw(genTableCell3DXml(cellOpts.cell3D)), raw(cellFill)], {\n\t\t\t\t\t\t\t\tclosePrefix: ' ',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t),\n\t\t\t\t\t],\n\t\t\t\t\t{ closePrefix: ' ' }\n\t\t\t\t)\n\t\t\t)\n\t\t})\n\n\t\t// D: Complete row\n\t\ttblInner += el('a:tr', { h: intRowH }, rowCells.map(raw))\n\t})\n\n\t// STEP 5: Complete table. NOTE: the closing tags carry indentation the opening tags do not,\n\t// so each `closePrefix` is stated explicitly rather than derived from depth.\n\treturn graphicFrameEl({\n\t\tnvGraphicFramePr,\n\t\tframe,\n\t\turi: TABLE_GRAPHIC_DATA_URI,\n\t\tpayload: el('a:tbl', null, raw(tblInner), { closePrefix: ' ' }),\n\t\tfmt: { graphic: { closePrefix: ' ' }, graphicData: { closePrefix: ' ' } },\n\t})\n}\n","/**\n * ts-pptx: Table Definition\n *\n * `addTableDefinition` applies the `headerRow` / `columns` sugar, normalizes rows into\n * fully-resolved `TableCellInternal`s (incl. 4-side borders), computes width, and — when `autoPage` is\n * set — shreds the table across overflow slides via `getSlidesForTableRows`.\n */\nimport { namedColorOr } from '../drawingml/color.js'\nimport { SlideObjectType } from '../../enums.js'\nimport { DEF_CELL_BORDER, DEF_FONT_COLOR, DEF_FONT_SIZE } from '../../constants-internal.js'\nimport { warn } from '../../diagnostics.js'\nimport type {\n\tBorderProps,\n\tFillOption,\n\tShapeFillProps,\n\tTableCellProps,\n\tTableProps,\n\tTableRow,\n} from '../../types/index.js'\nimport type {\n\tPresSlideInternal,\n\tSlideLayoutInternal,\n\tTableCellInternal,\n\tTablePropsInternal,\n} from '../../types/internal.js'\nimport { getSlidesForTableRows } from '../table/autopage.js'\nimport { tableHasHyperlink, withCheckedSpans } from '../table/spans.js'\nimport { tableColCount, walkTableGrid } from '../table/grid.js'\nimport {\n\tgetSmartParseNumber,\n\tresolveCellMarginsInches,\n\tresolveSlideMarginsInches,\n\tusableTableWidthEmu,\n} from '../../units-internal.js'\nimport { resolveObjectName } from './object-name.js'\nimport { placeholderFrame } from './layout-placeholder.js'\nimport { EMU_PER_INCH } from '../../units.js'\nimport { createHyperlinkRels } from './hyperlinks.js'\nimport { resolveFillKind } from '../drawingml/fill.js'\nimport { registerImageFillMedia } from './image.js'\nimport { InvalidOptionError } from '../../errors.js'\n\n/** A per-cell TRBL border tuple; a null side is *omitted* (inherits), not erased. */\ntype BorderTuple = [BorderProps | null, BorderProps | null, BorderProps | null, BorderProps | null]\ntype OuterBorderTuple = [BorderProps?, BorderProps?, BorderProps?, BorderProps?]\n\n/**\n * Expand a cell/table border into the 4-side tuple the rest of the pipeline expects.\n * A single `BorderProps` is broadcast to all four sides `[top, right, bottom, left]`;\n * an already-4-element `BorderTuple` passes through unchanged.\n * @param border - one border style (applied to every side) or a per-side tuple\n * @return {BorderTuple} a 4-element `[top, right, bottom, left]` tuple\n */\nfunction normalizeBorderTuple(border: BorderProps | BorderTuple): BorderTuple {\n\t// A fresh array either way. A cell that inherits the TABLE's tuple used to be handed the same\n\t// array object as every other cell, so the per-side completion below wrote through all of\n\t// them — and the table-level pass that ran afterwards reached into cells that had already\n\t// captured it.\n\treturn Array.isArray(border) ? [...border] : [border, border, border, border]\n}\n\n/** Fill a border's defaulted keys, preserving anything else the caller set (`cap`, `dashType`, …). */\nfunction withBorderDefaults(side: BorderProps): BorderProps {\n\treturn {\n\t\t...side,\n\t\ttype: side.type || DEF_CELL_BORDER.type,\n\t\tcolor: namedColorOr(side.color, DEF_CELL_BORDER.color, 'border.color'),\n\t\twidth: typeof side.width === 'number' ? side.width : DEF_CELL_BORDER.width,\n\t}\n}\n\n/**\n * Resolve `TableProps.outerBorder` into the `[top, right, bottom, left]` tuple the emitter\n * applies to the table's edge cells, with `undefined` for a side the caller left out.\n *\n * A sparse side is *not* the same as `{ type: 'none' }`: it means \"leave this edge to\n * whatever `border` (or the cell's own `options.border`) already drew\", whereas `'none'` is\n * an explicit instruction to erase the rule there. Keeping the hole is what lets\n * `outerBorder: [rule, undefined, rule, undefined]` add rules above and below a table\n * without also clearing its left and right edges.\n */\nfunction normalizeOuterBorder(outer: TableProps['outerBorder']): OuterBorderTuple | undefined {\n\tif (!outer || typeof outer !== 'object') return undefined\n\tconst sides: OuterBorderTuple = Array.isArray(outer) ? outer : [outer, outer, outer, outer]\n\tconst resolved = ([0, 1, 2, 3] as const).map((idx) => {\n\t\tconst side = sides[idx]\n\t\treturn side && typeof side === 'object' ? withBorderDefaults(side) : undefined\n\t}) as OuterBorderTuple\n\treturn resolved.some((side) => side !== undefined) ? resolved : undefined\n}\n\n/**\n * Apply the `headerRow` / `columns` inline-styling sugar: bake blanket header/column\n * formatting into per-cell options so it flows through the normal cell pipeline. Sets\n * `opt.hasHeader` when `headerRow` implies it. Returns the (possibly shallow-copied) rows.\n */\nfunction applyTableHeaderColumnSugar(tableRows: TableRow[], opt: TablePropsInternal): TableRow[] {\n\tconst hdr = opt.headerRow && typeof opt.headerRow === 'object' ? opt.headerRow : undefined\n\tconst cols = Array.isArray(opt.columns) && opt.columns.length ? opt.columns : undefined\n\tlet srcRows: TableRow[] = tableRows\n\tif ((hdr || cols) && Array.isArray(tableRows[0])) {\n\t\tif (hdr && opt.hasHeader === undefined) opt.hasHeader = true\n\t\t// The grid column each cell starts in, from the walk the emitter, the auto-pager and the\n\t\t// measured fit read. This kept a cursor of its own, `colCursor += colspan || 1`, which ignored\n\t\t// a rowspan from an earlier row: under `[[{ text: 'A', rowspan: 2 }, 'B'], ['C']]` it gave `C`\n\t\t// the first column's definition though `C` sits in the second. A string or number cell spans\n\t\t// one column. A cell starting past the grid gets no definition; the emitter drops it.\n\t\tconst gridRows = tableRows as TableCellInternal[][]\n\t\tconst gridCols: number[][] = gridRows.map(() => [])\n\t\tif (cols) {\n\t\t\tfor (const placement of walkTableGrid(gridRows, tableColCount(gridRows))) {\n\t\t\t\tgridCols[placement.row]?.push(placement.col)\n\t\t\t}\n\t\t}\n\t\tsrcRows = tableRows.map((row, rowIdx) => {\n\t\t\tif (!Array.isArray(row)) return row\n\t\t\t// Column-scoped defaults only apply when we actually have `columns`; the header row\n\t\t\t// alone is a cheaper positional map. Skip untouched body rows to avoid needless copies.\n\t\t\tif (!cols && rowIdx !== 0) return row\n\t\t\treturn row.map((cell: number | string | TableCellInternal, cellIdx): TableCellInternal => {\n\t\t\t\tconst cellObj: TableCellInternal =\n\t\t\t\t\ttypeof cell === 'string' || typeof cell === 'number'\n\t\t\t\t\t\t? { text: String(cell), options: {} }\n\t\t\t\t\t\t: { ...cell, options: { ...cell.options } }\n\t\t\t\tconst gridCol = gridCols[rowIdx]?.[cellIdx]\n\t\t\t\tconst colDef = cols && gridCol !== undefined ? cols[gridCol] : undefined\n\t\t\t\tcellObj.options = {\n\t\t\t\t\t...(colDef && typeof colDef === 'object' ? colDef : {}),\n\t\t\t\t\t...(rowIdx === 0 && hdr ? hdr : {}),\n\t\t\t\t\t...cellObj.options,\n\t\t\t\t}\n\t\t\t\treturn cellObj\n\t\t\t})\n\t\t})\n\t}\n\treturn srcRows\n}\n\n/**\n * Transform loosely-typed table rows (strings / numbers / TableCellInternal) into a grid of\n * well-formed TableCellInternal objects with fully-resolved 4-side cell borders.\n *\n * @param srcRows - the rows as authored, after the `headerRow`/`columns` sugar\n * @param opt - the table's options\n */\nfunction normalizeTableRows(srcRows: TableRow[], opt: TablePropsInternal): TableCellInternal[][] {\n\tconst arrRows: TableCellInternal[][] = []\n\t// Every row is an array by now: STEP 1 of `addTableDefinition` refuses one that is not.\n\tsrcRows.forEach((row) => {\n\t\tconst newRow: TableCellInternal[] = []\n\n\t\tif (Array.isArray(row)) {\n\t\t\trow.forEach((cell: number | string | TableCellInternal) => {\n\t\t\t\t// A: the cell's options, COPIED. `addTableDefinition` takes ownership of the table\n\t\t\t\t// options for exactly this reason and left the per-cell ones aliased, so everything\n\t\t\t\t// below — the border completion here, the hyperlink `_rId` the definer stamps later,\n\t\t\t\t// and the table-level inheritance the emitter resolves — wrote into the caller's own\n\t\t\t\t// object. A `rows` literal reused across two tables therefore came out styled by the\n\t\t\t\t// first table both times, and came back holding keys the caller never wrote.\n\t\t\t\tconst newCellOptions: TableCellProps = typeof cell === 'object' && cell.options ? { ...cell.options } : {}\n\t\t\t\tconst newCell: TableCellInternal = {\n\t\t\t\t\t_type: SlideObjectType.tablecell,\n\t\t\t\t\ttext: '',\n\t\t\t\t\toptions: newCellOptions,\n\t\t\t\t}\n\n\t\t\t\t// B:\n\t\t\t\tif (typeof cell === 'string' || typeof cell === 'number') newCell.text = cell.toString()\n\t\t\t\telse if (cell.text) {\n\t\t\t\t\t// Cell can contain complex text type, or string, or number\n\t\t\t\t\tif (typeof cell.text === 'string' || typeof cell.text === 'number') newCell.text = cell.text.toString()\n\t\t\t\t\t// Runs COPIED as well, each with an options bag of its own, for the reason A gives: the run\n\t\t\t\t\t// emitter writes into a run's options (`_lineIdx`, the run options it inherits from the\n\t\t\t\t\t// cell), and those were the caller's run objects. A nested object the caller supplied, a\n\t\t\t\t\t// hyperlink included, stays shared, because the id registered for it is read back through\n\t\t\t\t\t// that reference.\n\t\t\t\t\telse if (Array.isArray(cell.text))\n\t\t\t\t\t\tnewCell.text = cell.text.map((run) => (run.options ? { ...run, options: { ...run.options } } : { ...run }))\n\t\t\t\t\telse if (cell.text) newCell.text = cell.text\n\t\t\t\t\t// Capture options (the copy made above; `newCell.options` already is it)\n\t\t\t\t}\n\n\t\t\t\t// C: Set cell borders\n\t\t\t\t// A side nobody asked for is written as an explicit `{type:'none'}`. That is direct\n\t\t\t\t// formatting, so it beats any border a built-in table style would draw — which is\n\t\t\t\t// what keeps an unstyled table free of grid lines, PowerPoint's own no-style look\n\t\t\t\t// being a black hairline grid. Whatever the caller *did* author, on the cell or on\n\t\t\t\t// the table, is untouched.\n\t\t\t\t//\n\t\t\t\t// A table that names a `tableStyle` asked for that style's grid, so the default is\n\t\t\t\t// skipped there and the edges stay absent: direct formatting beats the style, and\n\t\t\t\t// filling in four no-fills erased the very thing the caller selected the style for\n\t\t\t\t// (#23). Author `border: { type: 'none' }` to erase a styled table's grid anyway.\n\t\t\t\t// A cell `border` that is neither a `BorderProps` nor a tuple is dropped, as the table's is.\n\t\t\t\tif (newCellOptions.border != null && typeof newCellOptions.border !== 'object') {\n\t\t\t\t\twarn('table/invalid-border', \"addTable cell `border` option must be an object. Ex: `{border: {type:'none'}}`\")\n\t\t\t\t\tdelete newCellOptions.border\n\t\t\t\t}\n\t\t\t\tconst authoredBorder = newCellOptions.border || opt.border\n\t\t\t\tif (authoredBorder) newCellOptions.border = authoredBorder\n\t\t\t\telse if (opt.tableStyle) delete newCellOptions.border\n\t\t\t\telse newCellOptions.border = [{ type: 'none' }, { type: 'none' }, { type: 'none' }, { type: 'none' }]\n\t\t\t\tlet cellBorder = newCellOptions.border\n\n\t\t\t\t// CASE 1: border interface is: BorderOptions | [BorderOptions, BorderOptions, BorderOptions, BorderOptions]\n\t\t\t\tif (cellBorder && typeof cellBorder === 'object') {\n\t\t\t\t\tcellBorder = normalizeBorderTuple(cellBorder)\n\t\t\t\t\tnewCellOptions.border = cellBorder\n\t\t\t\t}\n\t\t\t\t// Handle: [null, null, {type:'solid'}, null]. A null side is *omitted*, not erased:\n\t\t\t\t// it keeps inheriting from the built-in style/theme, exactly the distinction\n\t\t\t\t// `normalizeOuterBorder` documents for the perimeter (\"a sparse side is NOT\n\t\t\t\t// `{ type: 'none' }`\"). Converting a hole into an explicit `<a:noFill/>` overrides\n\t\t\t\t// that inheritance and there was no spelling left for \"draw this edge, leave that one\".\n\t\t\t\t// The whole tuple is absent when a styled table authored no border at all, which is\n\t\t\t\t// the same distinction one level up: nothing to complete, nothing to emit.\n\t\t\t\tconst cellBorderTuple = newCellOptions.border as BorderTuple | undefined\n\n\t\t\t\t// set complete BorderOptions for the sides that were authored\n\t\t\t\tif (cellBorderTuple) {\n\t\t\t\t\tconst arrSides = [0, 1, 2, 3] as const\n\t\t\t\t\tarrSides.forEach((idx) => {\n\t\t\t\t\t\tconst side = cellBorderTuple[idx]\n\t\t\t\t\t\tif (!side) return\n\t\t\t\t\t\t// `withBorderDefaults` spreads first and overrides only the defaulted keys.\n\t\t\t\t\t\t// Rebuilding the side from a fixed key list dropped `cap` — public on\n\t\t\t\t\t\t// `BorderProps` and already read by `genTableCellBorderXml`, so every table\n\t\t\t\t\t\t// border emitted cap=\"flat\" whatever the caller asked for (and `dashType`\n\t\t\t\t\t\t// would go the same way). The spread also gives each side its own object,\n\t\t\t\t\t\t// which the single-BorderProps form (one object shared across all four)\n\t\t\t\t\t\t// relies on.\n\t\t\t\t\t\tcellBorderTuple[idx] = withBorderDefaults(side)\n\t\t\t\t\t})\n\t\t\t\t\tnewCellOptions.border = cellBorderTuple\n\t\t\t\t}\n\n\t\t\t\t// LAST:\n\t\t\t\tnewRow.push(newCell)\n\t\t\t})\n\t\t}\n\n\t\tarrRows.push(newRow)\n\t})\n\treturn arrRows\n}\n\n/**\n * Resolve `autoPageHeaderRows` to a usable count of header rows.\n *\n * It is a count, so it has to be a whole number, at least one, and no larger than the table\n * itself — a header taller than the table repeats every row onto every continuation slide and\n * leaves no room for body content. Anything else falls back to `1` and reports\n * `table/invalid-header-row-count`.\n *\n * The test this replaces was `!isNaN(Number(x))`, which is none of those things: `''` and `[]`\n * both read as `0` header rows, `2.5` survived as a fraction, and `Infinity` was accepted as a\n * count. Its sibling `autoPageLineWeight` has been range-clamped since it was written.\n *\n * @param value - the caller's `autoPageHeaderRows`\n * @param rowCount - how many rows the table has\n */\nfunction resolveHeaderRowCount(value: number | undefined, rowCount: number): number {\n\tif (value === undefined) return 1\n\tconst rows = Number(value)\n\tif (Number.isInteger(rows) && rows >= 1 && rows <= rowCount) return rows\n\twarn(\n\t\t'table/invalid-header-row-count',\n\t\t`autoPageHeaderRows ${String(value)} must be a whole number from 1 to the table's row count (${rowCount}); using 1.`\n\t)\n\treturn 1\n}\n\n/**\n * Register the slide media relationship behind every image fill this table uses, so the\n * cell emitter can resolve `<a:blipFill r:embed=\"rIdN\">` instead of warning and dropping\n * the fill. Tables were the last major object kind not wired into `registerImageFillMedia`\n * (shapes do it at `define/shape.ts`, text boxes at `define/text.ts`).\n *\n * Three fill sources are walked, which between them cover every way a picture reaches a table:\n * the resolved cells (per-cell `options.fill`, plus `headerRow` and `columns[i]`, both baked\n * onto cells by the sugar step above), the table-level `fill`, which is *not* baked —\n * `gen/slide/objects/table.ts` copies it onto each cell at emit time — and `tableFill`, which\n * lands on `a:tblPr` itself and so needs its own relationship for the same reason.\n *\n * Keyed on fill **object identity**, not on the image source. The sugar spreads its options\n * shallowly, so one `headerRow` fill object is shared by every cell it styles; registering\n * per cell would mint a redundant relationship each time and let the later call overwrite\n * the `_imgRid` the first one stashed. Two cells given separately-authored fills for the\n * same file still get one relationship each — matching how two shapes sharing an image\n * behave — while the bytes are deduped into a single media part downstream.\n *\n * Must run only after auto-paging has shredded the rows across slides, for the same reason\n * `createHyperlinkRels` does: `target` has to be the slide the cell actually lands on, or\n * every relationship piles onto the first slide.\n */\nfunction registerTableImageFills(\n\ttarget: PresSlideInternal,\n\trows: TableCellInternal[][],\n\topt: TablePropsInternal\n): void {\n\tconst seen = new Set<ShapeFillProps>()\n\tconst register = (fill: FillOption | undefined): void => {\n\t\t// `type:'image'` and a bare `image:{…}` are both accepted, mirroring the shape path.\n\t\t// A bare colour string is the solid-fill shorthand and never carries media.\n\t\tif (!fill || typeof fill !== 'object') return\n\t\tif (resolveFillKind(fill) !== 'image') return\n\t\tif (seen.has(fill)) return\n\t\tseen.add(fill)\n\t\tregisterImageFillMedia(target, fill)\n\t}\n\n\tregister(opt.fill)\n\tregister(opt.tableFill)\n\trows.forEach((row) => {\n\t\trow.forEach((cell) => {\n\t\t\tregister(cell.options?.fill)\n\t\t})\n\t})\n}\n\n/**\n * The slide a table is added to, with the two presentation callbacks auto-paging needs: `getSlide`\n * finds the slide a continuation lands on, and `addSlide` creates it when there is none.\n */\ntype TableHostSlide = PresSlideInternal & {\n\taddSlide: (layout: SlideLayoutInternal | null) => PresSlideInternal\n\tgetSlide: (slideNumber: number) => PresSlideInternal | undefined\n}\n\n/**\n * Adds a table object to a slide definition.\n *\n * The slide layout, the presentation layout and the paging callbacks are read off `target`. They\n * were separate parameters, which the one caller filled from the same slide, and which could\n * therefore have described a different slide than the one the table was added to.\n * @param target - the slide the table is added to\n * @param tableRows - table data\n * @param options - table options\n * @returns the slides after `target` the table was paged onto, found or created\n */\nexport function addTableDefinition(\n\ttarget: TableHostSlide,\n\ttableRows: TableRow[],\n\toptions: TableProps\n): PresSlideInternal[] {\n\tconst slideLayout = target._slideLayout\n\tconst presLayout = target._presLayout\n\tconst slides: PresSlideInternal[] = [target] // Create array of Slides as more may be added by auto-paging\n\t// Take ownership of the options before touching them, the same way `addTextDefinition` does.\n\t// Everything below normalizes in place — `objectName`, `fontSize`, `margin`, `color`, the\n\t// `autoPage*` family, the resolved `w`/`colW` — and without the copy all of that lands on the\n\t// CALLER's object, so a style literal reused across tables carries one table's settings (and its\n\t// `objectName`) into the next. No cell shares this object: `normalizeTableRows` gives every cell,\n\t// a plain string included, an options bag of its own, and the emitter resolves the table-level\n\t// values each cell inherits into a separate bag at write time.\n\t//\n\t// `border` is copied because the array normalization below writes `withBorderDefaults` results\n\t// back into its slots; `fill` and the cell-level objects stay shared by reference, since rel ids\n\t// are registered through them and read back at emit time.\n\tconst opt: TablePropsInternal = options && typeof options === 'object' ? { ...options } : {}\n\tif (Array.isArray(opt.border)) opt.border = [...opt.border] as typeof opt.border\n\t// Through `nextObjectNameIdx` like every other definer. This counted the tables already in\n\t// `_slideObjects` instead — the derivation `object-name.ts` documents as having been replaced,\n\t// because a splice into a group makes the count go backwards.\n\topt.objectName = resolveObjectName(target, SlideObjectType.table, {\n\t\tlabel: 'Table',\n\t\tkind: 'table',\n\t\tsupplied: opt.objectName,\n\t})\n\n\t// STEP 0: PLACEHOLDER — a table targeting a layout placeholder inherits that placeholder's\n\t// position/size for any of x/y/w/h the caller omits, mirroring the image and\n\t// text placeholder inheritance. Explicit values always win; this only fills the gaps so\n\t// the table fills the placeholder geometry rather than the default 1in/full-width fallback.\n\t// An axis stated as `null` is unstated here, as it is for an image; it used to be kept and later\n\t// became the half-inch default.\n\tif (opt.placeholder) {\n\t\tconst placeholder = placeholderFrame(slideLayout, opt.placeholder)\n\t\t// A placeholder that states none of its own leaves the gap open for the fallback\n\t\t// below to fill, so the key stays absent rather than being written as `undefined`.\n\t\tconst x = opt.x ?? placeholder.x\n\t\tconst y = opt.y ?? placeholder.y\n\t\tconst w = opt.w ?? placeholder.w\n\t\tconst h = opt.h ?? placeholder.h\n\t\tif (x !== undefined) opt.x = x\n\t\tif (y !== undefined) opt.y = y\n\t\tif (w !== undefined) opt.w = w\n\t\tif (h !== undefined) opt.h = h\n\t}\n\n\t// STEP 1: REALITY-CHECK\n\t{\n\t\t// A: check for empty\n\t\tif (tableRows === null || tableRows.length === 0 || !Array.isArray(tableRows)) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'table/rows-not-an-array',\n\t\t\t\t\"addTable: Array expected! EX: 'slide.addTable( [rows], {options} );'\"\n\t\t\t)\n\t\t}\n\n\t\t// B: check for non-well-formatted array (ex: rows=['a','b'] instead of [['a','b']])\n\t\tif (!tableRows[0] || !Array.isArray(tableRows[0])) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'table/rows-not-nested',\n\t\t\t\t\"addTable: 'rows' should be an array of cells! EX: 'slide.addTable( [ ['A'], ['B'], {text:'C',options:{align:'center'}} ] );'\"\n\t\t\t)\n\t\t}\n\t\t// Every later row too, and here rather than while normalizing: the span check and the\n\t\t// `columns` sugar below both read rows as arrays, and a later row that was not one used to\n\t\t// reach them before `normalizeTableRows` refused it, failing as a raw `TypeError`.\n\t\ttableRows.forEach((row, idx) => {\n\t\t\tif (idx === 0 || Array.isArray(row)) return\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'table/rows-not-nested',\n\t\t\t\t`addTable: 'rows' should be an array of cells! Row ${idx} is ${JSON.stringify(row)}`\n\t\t\t)\n\t\t})\n\t}\n\n\t// STEP 1.5: `headerRow` / `columns` inline sugar — bake blanket styling into cells as\n\t// direct per-cell formatting so it flows through the normal cell pipeline (incl. border\n\t// defaulting below). Precedence (highest wins), matching how PowerPoint resolves styling\n\t// (direct formatting overrides a style region): explicit per-cell `options` > `headerRow`\n\t// (row 0) > `columns[colIdx]` > `tableStyle`/defaults. The merge is property-level, so a\n\t// header cell keeps `headerRow` typography and takes its column's fill when they differ.\n\t// Setting `headerRow` implies `hasHeader` unless the caller set it explicitly. The caller's\n\t// `tableRows` array is not mutated — only affected rows (and their cells) are shallow-copied.\n\t// Range-check the spans before anything reads them, the sugar's grid walk included. The\n\t// auto-pager and the emitter's merge grid both lay a grid out from a span, and a caller-supplied\n\t// `colspan: 4294967295` aborts the process rather than throwing. Checking once, here, is what\n\t// makes one bad cell warn once and keeps the paged and unpaged paths agreeing on the grid; the\n\t// corrected span rides on the cell's options through normalization. A string or number cell\n\t// carries no span and passes through. Every row is an array by here: STEP 1 refuses one that is\n\t// not.\n\tconst srcRows = applyTableHeaderColumnSugar(withCheckedSpans(tableRows), opt)\n\n\t// STEP 2: Transform `tableRows` into well-formatted TableCellInternal's\n\t// tableRows can be object or plain text array: `[{text:'cell 1'}, {text:'cell 2', options:{color:'ff0000'}}]` | `[\"cell 1\", \"cell 2\"]`\n\t// A table `border` that is neither a `BorderProps` nor a tuple is dropped first: the row\n\t// normalization completes whatever border a cell inherits by indexing into it.\n\tif (opt.border != null && typeof opt.border !== 'object') {\n\t\twarn('table/invalid-border', \"addTable `border` option must be an object. Ex: `{border: {type:'none'}}`\")\n\t\tdelete opt.border\n\t}\n\tconst arrRows = normalizeTableRows(srcRows, opt)\n\n\t// STEP 3: Set options\n\t// Keep x/y/w/h as raw user `Coord` (inches/percent/unit-string). They are resolved to EMU\n\t// exactly once at emission (`gen/slide/objects/table.ts`) and by the auto-pager (getSlidesForTableRows); no\n\t// pre-conversion here, so a value is never parsed twice. Default position is 0.5in.\n\tif (opt.x === undefined || opt.x === null) opt.x = 0.5\n\tif (opt.y === undefined || opt.y === null) opt.y = 0.5\n\t// NOTE: Dont set default `h` - leaving it null triggers auto-rowH in `makeXMLSlide()`\n\topt.fontSize = opt.fontSize || DEF_FONT_SIZE\n\topt.margin = resolveCellMarginsInches(opt.margin)\n\t// Black lands on the table and is inherited by every cell that has no colour of its own\n\t// (`gen/slide/objects/table.ts`), as direct formatting. One thing stands it down: a\n\t// hyperlink anywhere in the grid, because the default paints the whole run, so the words\n\t// *after* a link come out black instead of following the link colour. That run is then\n\t// emitted with no `<a:solidFill>` and PowerPoint resolves the text from the theme's `tx1`.\n\tif (!tableHasHyperlink(arrRows)) {\n\t\tif (!opt.color) opt.color = DEF_FONT_COLOR // table option > inherit from Slide > default to black\n\t}\n\tif (Array.isArray(opt.border)) {\n\t\t// A HOLE stays a hole. The cell path has always been explicit that a `null` side is\n\t\t// *omitted* rather than erased — it keeps inheriting from the built-in style — and this\n\t\t// filled it with `{ type: 'none' }`, so the identical sparse tuple meant \"inherit\" on a\n\t\t// cell and \"erase the style's rule\" on the table. Same reading now on both, which is what\n\t\t// leaves `[rule, null, rule, null]` with one meaning instead of two.\n\t\topt.border = ([0, 1, 2, 3] as const).map((idx) => {\n\t\t\tconst side = (opt.border as BorderTuple)[idx]\n\t\t\treturn side ? withBorderDefaults(side) : undefined\n\t\t}) as BorderTuple\n\t}\n\tif (typeof opt.outerBorder === 'string') {\n\t\twarn(\n\t\t\t'table/invalid-outer-border',\n\t\t\t\"addTable `outerBorder` option must be an object. Ex: `{outerBorder: {type:'solid'}}`\"\n\t\t)\n\t\tdelete opt.outerBorder\n\t}\n\t// The perimeter is resolved here but applied at emit time: which cells sit on the table's\n\t// outer edge is only knowable once the merge grid exists, and the serializer is what builds\n\t// it — a colspan reaching the last column puts that column's rule on a *covered* cell.\n\tconst outerBorder = normalizeOuterBorder(opt.outerBorder)\n\tif (outerBorder) opt.outerBorder = outerBorder\n\telse delete opt.outerBorder\n\n\topt.autoPage = typeof opt.autoPage === 'boolean' ? opt.autoPage : false\n\topt.autoPagePlaceholder = typeof opt.autoPagePlaceholder === 'boolean' ? opt.autoPagePlaceholder : false\n\topt.autoPageRepeatHeader = typeof opt.autoPageRepeatHeader === 'boolean' ? opt.autoPageRepeatHeader : false\n\t// A header-row count is a count: a whole number, not negative, and not more rows than the\n\t// table has. The NaN test this replaces was none of those — `''` read as `0` header rows and\n\t// `Infinity` was accepted as a count, which is the same shape of hole `autoPageLineWeight`\n\t// has been guarded against two lines down since it was written.\n\topt.autoPageHeaderRows = resolveHeaderRowCount(opt.autoPageHeaderRows, tableRows.length)\n\tconst lineWeight = Number(opt.autoPageLineWeight)\n\topt.autoPageLineWeight = typeof opt.autoPageLineWeight !== 'undefined' && Number.isFinite(lineWeight) ? lineWeight : 0\n\tif (opt.autoPageLineWeight) {\n\t\tif (opt.autoPageLineWeight > 1) opt.autoPageLineWeight = 1\n\t\telse if (opt.autoPageLineWeight < -1) opt.autoPageLineWeight = -1\n\t}\n\t// autoPage ^^^\n\n\t// Set/Calc table width\n\t// Get slide margins - start with default values, then adjust if master or slide margins exist\n\t// Master margins override the defaults, if present.\n\t// `opt.slideMargin` belongs here as much as it does in the pager, which is the only place it\n\t// used to be read: whether a table respected the option depended on whether `autoPage` was on.\n\tconst arrTableMargin = resolveSlideMarginsInches(slideLayout?._margin, opt.slideMargin)\n\n\t/**\n\t * Calc table width depending upon what data we have - several scenarios exist (including bad data, eg: colW doesnt match col count)\n\t * The API does not require a `w` value, but XML generation does, hence, code to calc a width below using colW value(s)\n\t */\n\t/**\n\t * The width a table with nothing to size it from gets: the slide from the table's own left\n\t * edge to the right margin, in whole inches.\n\t *\n\t * Through `usableTableWidthEmu` rather than its own subtraction, because there were two\n\t * formulas for one quantity: this one was `W - right - left` and ignored `x`, while the\n\t * pager's is `W - x - right`, and the pager's own doc claimed the two were \"the same\n\t * reading\". A table at a stated `x` was sized as though it started at the left margin, so it\n\t * ran off the right of the slide by the difference. `x` is already defaulted above, and its\n\t * default equals the default left margin, which is why symmetric decks see no change.\n\t */\n\tconst defaultTableWidthIn = (): number =>\n\t\tMath.floor(\n\t\t\tusableTableWidthEmu(presLayout, getSmartParseNumber(opt.x, 'X', presLayout), arrTableMargin) / EMU_PER_INCH\n\t\t)\n\n\tif (opt.colW) {\n\t\t// The grid's column count, read the way every other table reader reads it.\n\t\tconst firstRowColCnt = tableColCount(arrRows)\n\n\t\t/**\n\t\t * One column width, in inches, spread across every column: `opt.w` becomes the total and\n\t\t * `colW` is unset, so the emitter divides `w` evenly and lands back on the same number.\n\t\t *\n\t\t * The width is NOT floored. `colW` is documented as inches with no rounding rule, and the\n\t\t * only rounding a length needs happens once in `inch2Emu`; flooring here threw away up to\n\t\t * a full inch per table (`colW: 2.4` on three columns emitted 7in, not 7.2in). A value\n\t\t * that is not a usable number warns here rather than reaching `getSmartParseNumber` as\n\t\t * `NaN`, whose `coord/non-finite` message describes a missing layout dimension and names\n\t\t * nothing the caller wrote.\n\t\t */\n\t\tconst spreadUniformColW = (raw: unknown): void => {\n\t\t\tconst inches = Number(raw)\n\t\t\tif (!Number.isFinite(inches) || inches <= 0) {\n\t\t\t\twarn(\n\t\t\t\t\t'table/invalid-col-width',\n\t\t\t\t\t`addTable: \\`colW\\` must be a positive number of inches, got ${String(raw)}; using the default table width instead.`\n\t\t\t\t)\n\t\t\t\topt.w = defaultTableWidthIn()\n\t\t\t} else {\n\t\t\t\topt.w = inches * firstRowColCnt\n\t\t\t}\n\t\t\tdelete opt.colW // IMPORTANT: Unset `colW` so table is created using `opt.w`, which will evenly divide cols\n\t\t}\n\n\t\tif (typeof opt.colW === 'string' || typeof opt.colW === 'number') {\n\t\t\t// Ex: `colW = 3` or `colW = '3'`\n\t\t\tspreadUniformColW(opt.colW)\n\t\t} else if (opt.colW && Array.isArray(opt.colW) && opt.colW.length === 1 && firstRowColCnt > 1) {\n\t\t\t// Ex: `colW=[3]` but with >1 cols (same as above, user is saying \"use this width for all\")\n\t\t\tspreadUniformColW(opt.colW[0])\n\t\t} else if (opt.colW && Array.isArray(opt.colW) && opt.colW.length !== firstRowColCnt) {\n\t\t\t// Err: Mismatched colW and cols count\n\t\t\twarn(\n\t\t\t\t'table/col-width-count-mismatch',\n\t\t\t\t'addTable: mismatch: (colW.length != data.length) Therefore, defaulting to evenly distributed col widths.'\n\t\t\t)\n\t\t\tdelete opt.colW\n\t\t}\n\t} else if (opt.w) {\n\t\t// Keep raw user `Coord` — resolved to EMU once at emission. (No pre-conversion.)\n\t} else {\n\t\topt.w = defaultTableWidthIn()\n\t}\n\n\t// Shrink-to-fit (`fitColumns: 'shrink'`): proportionally scale columns down so a\n\t// too-wide table fits between `x` and the right slide margin. Runs after the width-calc\n\t// above so it sees the resolved form — either a surviving per-column `colW` array, or a\n\t// single `w`. Rewriting the widths here (the table definition) means both the emitter and\n\t// the measured-fit pass inherit the fitted grid; shrink only, no minimum-width floor.\n\tif (opt.fitColumns === 'shrink') {\n\t\t// The same quantity `defaultTableWidthIn` resolves, un-floored: `fitColumns` scales a grid\n\t\t// into it rather than picking a whole-inch width, so a floor here would throw away up to\n\t\t// an inch of the space it is fitting to.\n\t\tconst availWin =\n\t\t\tusableTableWidthEmu(presLayout, getSmartParseNumber(opt.x, 'X', presLayout), arrTableMargin) / EMU_PER_INCH\n\t\tif (availWin > 0) {\n\t\t\tif (Array.isArray(opt.colW)) {\n\t\t\t\tconst sumIn = opt.colW.reduce((p, n) => p + (Number.isFinite(n) ? n : 0), 0)\n\t\t\t\tif (sumIn > availWin) {\n\t\t\t\t\tconst factor = availWin / sumIn\n\t\t\t\t\topt.colW = opt.colW.map((n) => (Number.isFinite(n) ? n * factor : n))\n\t\t\t\t\topt.w = availWin\n\t\t\t\t}\n\t\t\t} else if (typeof opt.w === 'number' && opt.w > availWin) {\n\t\t\t\topt.w = availWin\n\t\t\t}\n\t\t}\n\t}\n\n\t// If autoPage = true, we need to return references to newly created slides if any\n\tconst newAutoPagedSlides: PresSlideInternal[] = []\n\n\t// STEP 6: Auto-Paging: (via {options} and used internally)\n\t// (used internally by `tableToSlides()` to not engage recursion - we've already paged the table data, just add this one)\n\tif (opt && !opt.autoPage) {\n\t\t// Create hyperlink rels (IMPORTANT: Wait until table has been shredded across Slides or all rels will end-up on Slide 1!)\n\t\tcreateHyperlinkRels(target, arrRows, 'addTable')\n\n\t\t// Same timing rule as the hyperlink rels above: resolve cell image fills to media rels\n\t\t// on the slide this table actually landed on.\n\t\tregisterTableImageFills(target, arrRows, opt)\n\n\t\t// Add slideObjects (NOTE: Use `extend` to avoid mutation)\n\t\t// `columns` (per-column TableCellProps[]) is consumed in STEP 1.5 and baked into cells;\n\t\t// drop it here so it is not carried into `ObjectOptions`, where `columns` is the unrelated\n\t\t// text-column *count* (`number`). Leaving it in would be both meaningless and a type clash.\n\t\t// `columns` is destructured out rather than overwritten with `undefined`: `ObjectOptions`\n\t\t// declares no such key, and a present one holding `undefined` would still be enumerated by\n\t\t// anything that walks these options.\n\t\tconst { columns: _columns, ...tableObjectOptions } = opt\n\t\ttarget._slideObjects.push({\n\t\t\t_type: SlideObjectType.table,\n\t\t\tarrTabRows: arrRows,\n\t\t\toptions: tableObjectOptions,\n\t\t})\n\t} else {\n\t\tif (opt.autoPageRepeatHeader)\n\t\t\topt._arrObjTabHeadRows = arrRows.filter((_row, idx) => idx < (opt.autoPageHeaderRows || 1))\n\n\t\t// snapshot populated placeholders on the source slide (e.g. a title added via\n\t\t// `addText(text, { placeholder })`) so they can be re-rendered on each overflow slide.\n\t\t// Overflow slides otherwise inherit only the layout's empty placeholders. Captured before\n\t\t// the loop so the table object added per-slide below is never included.\n\t\tconst sourcePlaceholders =\n\t\t\topt.autoPagePlaceholder && Array.isArray(target._slideObjects)\n\t\t\t\t? target._slideObjects.filter((obj) => obj._type !== SlideObjectType.table && obj.options?.placeholder)\n\t\t\t\t: []\n\n\t\t// Loop over rows and create 1-N tables as needed\n\t\tgetSlidesForTableRows(arrRows, opt, presLayout, slideLayout).forEach((slide, idx) => {\n\t\t\t// A: Create new Slide when needed, otherwise, use existing (NOTE: More than 1 table can be on a Slide, so we will go up AND down the Slide chain)\n\t\t\tlet newSlide = target.getSlide(target._slideNum + idx)\n\t\t\tif (!newSlide) {\n\t\t\t\t// The layout itself, not its name: only the presentation knows whether it is a registered\n\t\t\t\t// layout or the unregistered default a slide added with no `masterTitle` carries, whose\n\t\t\t\t// name is the slide size and matches no master.\n\t\t\t\tnewSlide = target.addSlide(slideLayout)\n\t\t\t\tslides.push(newSlide)\n\t\t\t}\n\n\t\t\t// B: Reset opt.y to `option`/`margin` after first Slide\n\t\t\t// Keep raw inches — resolved to EMU once at emission. (No pre-conversion.)\n\t\t\t// The pager decided where each continuation starts when it budgeted its height, and hands\n\t\t\t// it back on the page. This used to re-derive it as `autoPageSlideStartY || margin`, which\n\t\t\t// dropped a stated `0` and lacked the pager's `Math.min(y, margin)`, so a continuation\n\t\t\t// could land lower than the height it was paged for and run off the slide.\n\t\t\tif (idx > 0 && slide.y !== undefined) opt.y = slide.y\n\n\t\t\t// C: Add this table to new Slide\n\t\t\t{\n\t\t\t\topt.autoPage = false\n\n\t\t\t\t// copy the source slide's populated placeholders onto each overflow slide\n\t\t\t\t// (idx 0 is the source slide itself and already has them).\n\t\t\t\tif (idx > 0 && sourcePlaceholders.length > 0) {\n\t\t\t\t\tsourcePlaceholders.forEach((ph) => newSlide._slideObjects.push(structuredClone(ph)))\n\t\t\t\t}\n\n\t\t\t\t// Create hyperlink rels (IMPORTANT: Wait until table has been shredded across Slides or all rels will end-up on Slide 1!)\n\t\t\t\tcreateHyperlinkRels(newSlide, slide.rows, 'addTable')\n\n\t\t\t\t// Add rows to new slide. When `rowH` is an array it is keyed by *original* row index,\n\t\t\t\t// which no longer matches the per-slide physical row order after pagination; use the\n\t\t\t\t// per-slide heights the auto-pager resolved so each row keeps its configured height\n\t\t\t\t// instead of inheriting whatever row lands at the same index.\n\t\t\t\t// `slide.rowH` may contain `undefined` holes (auto-height rows); the table serializer\n\t\t\t\t// treats a falsy per-row height as \"auto\", so the cast to number[] is safe.\n\t\t\t\t// Overwritten only when there is a per-slide mapping to apply; otherwise `rowH` is left\n\t\t\t\t// exactly as the caller spelled it, absent included.\n\t\t\t\t// `headerRow` is inline styling for row 0 and was baked into the cells at definition\n\t\t\t\t// time. Carrying it here made the recursive `addTable` re-run that sugar against\n\t\t\t\t// EACH PAGE's row 0 — an arbitrary body row — so with the default repeat-header off,\n\t\t\t\t// row 11 and row 22 came out bold and filled like the header. Stripped by key rather\n\t\t\t\t// than by a blanket strip: `columns` is positional, so re-applying it per page is\n\t\t\t\t// correct and it has to stay.\n\t\t\t\t//\n\t\t\t\t// `hasHeader` is the same fact one level down (`a:tblPr/@firstRow`, which every page\n\t\t\t\t// emitted). It is true on the first page, and on a later page only when the header\n\t\t\t\t// row is genuinely repeated onto it.\n\t\t\t\tconst { headerRow: _headerRow, ...pagedOpt } = opt\n\t\t\t\tif (idx > 0 && !opt.autoPageRepeatHeader) pagedOpt.hasHeader = false\n\t\t\t\t// The pager resolves the column grid it wraps text against and hands it back on\n\t\t\t\t// each page; the emitted table takes that grid rather than re-deriving one.\n\t\t\t\tif (slide.colW) pagedOpt.colW = slide.colW\n\t\t\t\tif (Array.isArray(opt.rowH) && slide.rowH) pagedOpt.rowH = slide.rowH as number[]\n\t\t\t\tnewSlide.addTable(slide.rows, pagedOpt)\n\n\t\t\t\t// Add reference to the new slide so it can be returned, but don't add the first one because the user already has a reference to that one.\n\t\t\t\tif (idx > 0) newAutoPagedSlides.push(newSlide)\n\t\t\t}\n\t\t})\n\t}\n\treturn newAutoPagedSlides\n}\n","/**\n * ts-pptx: the table construct family\n *\n * Tables and their auto-paging, from rows a caller already holds. Reproducing a rendered HTML\n * `<table>` belongs to this family too, but only where there is a DOM to read it from, so it is\n * composed separately by the browser entry.\n */\n\nimport { SlideObjectType } from '../enums.js'\nimport { renderTableObject } from '../gen/slide/objects/table.js'\nimport { addTableDefinition } from '../gen/define/table.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const tableFamily = {\n\tname: 'table',\n\tauthors: {\n\t\taddTable(slide, tableRows, options) {\n\t\t\t// Appended, not assigned. Two `addTable` calls on one slide used to leave the accessor\n\t\t\t// reporting only the second table's continuations; the first table's were in the deck and\n\t\t\t// invisible through the one API that names them.\n\t\t\t//\n\t\t\t// Appended by identity, though. A table pages onto the slides after this one whether it\n\t\t\t// created them or found them already there, so a second table on the same slide usually\n\t\t\t// lands on the first table's continuations -- the same slide, spilled onto twice. The\n\t\t\t// accessor names slides so a caller can address them; naming one twice is noise, not\n\t\t\t// information.\n\t\t\tconst paged = addTableDefinition(slide, tableRows, options || {})\n\t\t\tfor (const made of paged) if (!slide._newAutoPagedSlides.includes(made)) slide._newAutoPagedSlides.push(made)\n\t\t},\n\t},\n\trenderers: {\n\t\t[SlideObjectType.table]: renderTableObject,\n\t},\n} satisfies ConstructFamily\n","/**\n * ts-pptx: Zoom (Slide / Section / Summary) slide-object serialization\n *\n * Emits a `zoom` slide object as an `<mc:AlternateContent>`. The `mc:Choice` carries the real\n * `<p:graphicFrame>` in the 2016 zoom namespaces, read by PowerPoint 2016+; the `mc:Fallback`\n * carries a hyperlinked preview picture — or, for a Summary Zoom, a group of them — so older\n * consumers still get a clickable navigation thumbnail. See `gen/define/zoom.ts`.\n */\n\nimport type { ZoomInternal, ZoomTileInternal } from '../../../types/internal.js'\nimport { el, raw, voidEl, type XmlAttrs } from '../../oxml/el.js'\nimport { alternateContentEl } from '../../oxml/alternate-content.js'\nimport {\n\tcNvPrEl,\n\tFALLBACK_PICTURE_LOCKS,\n\tgraphicFrameEl,\n\tgrpXfrmEl,\n\tpreviewPicBody,\n\ttype RenderContext,\n\ttype XfrmFrame,\n} from './shared.js'\nimport { GRAPHIC_FRAME_LOCK_ATTRS, PICTURE_LOCK_ATTRS, genXmlObjectLock } from '../../drawingml/locks.js'\nimport { xsdBool } from '../../../ooxml/xsd-boolean.js'\n\n/** Zoom (Slide/Section/Summary) graphicData URI + `mc:Choice Requires` prefix + element local-names, per variant. */\nconst ZOOM_VARIANTS = {\n\tslide: {\n\t\turi: 'http://schemas.microsoft.com/office/powerpoint/2016/slidezoom',\n\t\tprefix: 'pslz',\n\t\tzm: 'sldZm',\n\t\tobj: 'sldZmObj',\n\t},\n\tsection: {\n\t\turi: 'http://schemas.microsoft.com/office/powerpoint/2016/sectionzoom',\n\t\tprefix: 'psez',\n\t\tzm: 'sectionZm',\n\t\tobj: 'sectionZmObj',\n\t},\n\tsummary: {\n\t\turi: 'http://schemas.microsoft.com/office/powerpoint/2016/summaryzoom',\n\t\tprefix: 'psuz',\n\t\tzm: 'summaryZm',\n\t\tobj: 'summaryZmObj',\n\t},\n} as const\n/** Namespace of the zoom preview `blipFill`/`spPr` (children of `zmPr`). */\nconst P166_NS = 'http://schemas.microsoft.com/office/powerpoint/2016/6/main'\n\n/**\n * The `p166:blipFill` + `p166:spPr` (preview image + framed tile) shared by a zoom tile's `zmPr`.\n *\n * The same body `previewPicBody` builds for a `p:pic`, one namespace over — which is the only\n * thing that ever differed between them.\n */\nfunction zoomBlipSpPr(previewRid: number, xf: XfrmFrame): string {\n\treturn previewPicBody(previewRid, xf, true, { ns: 'p166', nsUri: P166_NS })\n}\n\n/** One `{prefix}:{obj}` targeting element (sldZmObj/sectionZmObj/summaryZmObj) with its nested `zmPr`. */\nfunction zoomObjEl(\n\tvariant: ZoomInternal['variant'],\n\ttile: ZoomTileInternal,\n\treturnToParent: boolean,\n\ttransitionDur: number,\n\tlocalXf: { x: number; y: number; cx: number; cy: number }\n): string {\n\tconst { prefix, obj } = ZOOM_VARIANTS[variant]\n\tconst objAttrs: XmlAttrs = variant === 'slide' ? { sldId: tile.sldId ?? null } : { sectionId: tile.sectionId ?? null }\n\t// zmPr attrs: id, (Slide Zoom only) returnToParent, transitionDur — matching PowerPoint's order.\n\tconst zmAttrs: XmlAttrs = { id: tile.zmPrId }\n\tif (variant === 'slide') zmAttrs['returnToParent'] = xsdBool(returnToParent)\n\tzmAttrs['transitionDur'] = transitionDur\n\treturn el(\n\t\t`${prefix}:${obj}`,\n\t\tobjAttrs,\n\t\traw(el(`${prefix}:zmPr`, zmAttrs, raw(zoomBlipSpPr(tile.previewRid, localXf))))\n\t)\n}\n\n/** The `mc:Fallback` picture (or grouped pictures) — a hyperlinked thumbnail for pre-2016 consumers. */\nfunction zoomFallbackPic(\n\tpicId: number,\n\tobjectName: string | undefined,\n\ttile: ZoomTileInternal,\n\tabsXf: { x: number; y: number; cx: number; cy: number }\n): string {\n\treturn el('p:pic', null, [\n\t\traw(\n\t\t\tel('p:nvPicPr', null, [\n\t\t\t\traw(\n\t\t\t\t\tcNvPrEl(\n\t\t\t\t\t\tpicId,\n\t\t\t\t\t\tobjectName,\n\t\t\t\t\t\t'',\n\t\t\t\t\t\tvoidEl('a:hlinkClick', { 'r:id': `rId${tile.fallbackSlideRid}`, action: 'ppaction://hlinksldjump' })\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\traw(\n\t\t\t\t\tel(\n\t\t\t\t\t\t'p:cNvPicPr',\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t// PowerPoint's zoom-tile lock set, and fixed on purpose even though `ZoomBaseProps`\n\t\t\t\t\t\t// now has an `objectLock`: this is the `mc:Fallback` picture, which only a pre-2016\n\t\t\t\t\t\t// consumer draws, and `a:picLocks` and `a:graphicFrameLocks` accept different flags\n\t\t\t\t\t\t// — folding the caller's graphic-frame set onto it would warn about every flag the\n\t\t\t\t\t\t// two element types do not share. The caller's locks go on the `mc:Choice` frame\n\t\t\t\t\t\t// below, which is the object PowerPoint actually manipulates. Routed through\n\t\t\t\t\t\t// `genXmlObjectLock` so the attribute order is the table's rather than this\n\t\t\t\t\t\t// literal's, and a flag added to the set lands in the right place.\n\t\t\t\t\t\traw(genXmlObjectLock('a:picLocks', PICTURE_LOCK_ATTRS, FALLBACK_PICTURE_LOCKS))\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\traw(voidEl('p:nvPr')),\n\t\t\t])\n\t\t),\n\t\traw(previewPicBody(tile.previewRid, absXf, true)),\n\t])\n}\n\n/**\n * Render a `zoom` slide object to its `<mc:AlternateContent>` XML. The `mc:Choice` carries the real\n * `<p:graphicFrame>` (Slide/Section/Summary Zoom in the 2016 zoom namespaces, read by PowerPoint\n * 2016+); the `mc:Fallback` carries a hyperlinked picture — or, for a Summary Zoom, a group of them —\n * so pre-2016 consumers still get a clickable navigation thumbnail. See `gen/define/zoom.ts`.\n */\nexport function renderZoomObject(ctx: RenderContext): string {\n\tconst {\n\t\tobj: slideItemObj,\n\t\tshapeId,\n\t\tframe: { x, y, cx, cy },\n\t} = ctx\n\tconst zoom = slideItemObj.zoom\n\tif (!zoom) return ''\n\tconst opts = slideItemObj.options || {}\n\tconst objectName = opts.objectName\n\tconst { uri, prefix, zm } = ZOOM_VARIANTS[zoom.variant]\n\tconst firstTile = zoom.tiles[0]\n\tif (!firstTile) return '' // every zoom is registered with >= 1 tile; keeps this a total function\n\n\t// Choice: the zoom `graphicData` body. Single-tile (slide/section) uses a frame-local 0,0 xfrm;\n\t// summary lays each tile out at its precomputed grid cell (frame-local EMU).\n\tconst objectsXml =\n\t\tzoom.variant === 'summary'\n\t\t\t? zoom.tiles\n\t\t\t\t\t.map((t) =>\n\t\t\t\t\t\traw(zoomObjEl('summary', t, zoom.returnToParent, zoom.transitionDur, t.grid ?? { x: 0, y: 0, cx, cy }))\n\t\t\t\t\t)\n\t\t\t\t\t.concat(raw(voidEl(`${prefix}:gridLayout`)))\n\t\t\t: [raw(zoomObjEl(zoom.variant, firstTile, zoom.returnToParent, zoom.transitionDur, { x: 0, y: 0, cx, cy }))]\n\n\tconst nvGraphicFramePr = el('p:nvGraphicFramePr', null, [\n\t\traw(cNvPrEl(shapeId, objectName, '')),\n\t\traw(\n\t\t\tel(\n\t\t\t\t'p:cNvGraphicFramePr',\n\t\t\t\tnull,\n\t\t\t\t// `noChangeAspect` is PowerPoint's own default for a zoom tile (it mirrors the\n\t\t\t\t// target slide's aspect); the caller's flags fold over it, so passing\n\t\t\t\t// `noChangeAspect: false` lifts it.\n\t\t\t\traw(\n\t\t\t\t\tgenXmlObjectLock(\n\t\t\t\t\t\t'a:graphicFrameLocks',\n\t\t\t\t\t\tGRAPHIC_FRAME_LOCK_ATTRS,\n\t\t\t\t\t\t{ noChangeAspect: true, ...opts.objectLock },\n\t\t\t\t\t\tobjectName\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t),\n\t\traw(voidEl('p:nvPr')),\n\t])\n\tconst graphicFrame = graphicFrameEl({\n\t\tnvGraphicFramePr,\n\t\tframe: { x, y, cx, cy },\n\t\turi,\n\t\tpayload: el(`${prefix}:${zm}`, null, objectsXml),\n\t})\n\n\t// Fallback: a hyperlinked picture per tile at its slide-absolute position.\n\tlet fallbackInner: string\n\tif (zoom.variant === 'summary') {\n\t\t// The pictures take the ids after the zoom's own, which `shapeIdCount` holds for them so the\n\t\t// shapes after this zoom are numbered past the last one.\n\t\tconst pics = zoom.tiles.map((t, k) => {\n\t\t\tconst g = t.grid ?? { x: 0, y: 0, cx, cy }\n\t\t\treturn raw(zoomFallbackPic(shapeId + 1 + k, objectName, t, { x: x + g.x, y: y + g.y, cx: g.cx, cy: g.cy }))\n\t\t})\n\t\tfallbackInner = el('p:grpSp', null, [\n\t\t\traw(\n\t\t\t\tel('p:nvGrpSpPr', null, [\n\t\t\t\t\traw(cNvPrEl(shapeId, objectName, '')),\n\t\t\t\t\traw(voidEl('p:cNvGrpSpPr')),\n\t\t\t\t\traw(voidEl('p:nvPr')),\n\t\t\t\t])\n\t\t\t),\n\t\t\traw(el('p:grpSpPr', null, raw(grpXfrmEl({ x, y, cx, cy })))),\n\t\t\t...pics,\n\t\t])\n\t} else {\n\t\tfallbackInner = zoomFallbackPic(shapeId, objectName, firstTile, { x, y, cx, cy })\n\t}\n\n\treturn alternateContentEl({ requires: { prefix, uri }, choice: graphicFrame, fallback: fallbackInner })\n}\n","/**\n * ts-pptx: Zoom Definition (Slide / Section / Summary Zoom — Insert ▸ Zoom).\n *\n * Resolves a zoom's target(s) to the ids the emitter needs (`sldId` / section GUID), registers\n * the preview-image media rel and the `.../slide` fallback rel(s), lays out the Summary Zoom grid,\n * and pushes a `SlideObject{ _type: zoom, zoom }` for `gen/slide/objects/zoom.ts` to emit as a\n * `<p:graphicFrame>`. See {@link ../../types/zoom} for the preview-image behavior.\n */\nimport { SlideObjectType } from '../../enums.js'\nimport { warn } from '../../diagnostics.js'\nimport type { SectionZoomProps, SlideZoomProps, SummaryZoomProps } from '../../types/zoom.js'\nimport type {\n\tObjectOptionsInternal,\n\tPresSlideInternal,\n\tSectionInternalProps,\n\tSlideObject,\n\tZoomInternal,\n\tZoomTileInternal,\n} from '../../types/internal.js'\nimport { bracedGuid, getNewRelId } from '../utils.js'\nimport { clampRangedInput, getSmartParseNumber } from '../../units-internal.js'\nimport { framedObjectOptions } from './object-options.js'\nimport { registerPreviewImage } from './preview-image.js'\nimport { MIN_SLIDE_ID } from '../../ooxml/ids.js'\n\nconst ZOOM_LABEL = { slide: 'Slide Zoom', section: 'Section Zoom', summary: 'Summary Zoom' } as const\nconst ZOOM_API = { slide: 'addSlideZoom', section: 'addSectionZoom', summary: 'addSummaryZoom' } as const\n\n/** The longest `zmPr@transitionDur` written, in milliseconds: the largest signed 32-bit integer. */\nconst MAX_TRANSITION_DUR_MS = 2147483647\n\n/** Register a `.../slide` rel (used by the fallback picture's `hlinkClick`) to a 1-based slide number. */\nfunction registerSlideRel(target: PresSlideInternal, slideNum: number): number {\n\tconst rId = getNewRelId(target)\n\ttarget._rels.push({ type: SlideObjectType.hyperlink, data: 'slide', rId, Target: String(slideNum) })\n\treturn rId\n}\n\n/** The two `zmPr` settings every variant takes from its options the same way. */\ntype ZoomSettings = Pick<ZoomInternal, 'returnToParent' | 'transitionDur'>\n\n/**\n * Resolve the `zmPr` settings a zoom's options state, before the definer registers anything.\n *\n * All three definers copied these, and `transitionDur` went into the attribute unchecked: `NaN`\n * and `Infinity` were written as that text, and `-1` and `1.5` as given. It is clamped here the\n * one way an out-of-range number is: `NaN` throws naming the option, a number outside\n * 0-2147483647 moves to the bound with a warning, and the result is a whole number of milliseconds.\n * @param opts - the zoom's options\n * @param variant - which zoom, for the option name in a message\n */\nfunction resolveZoomSettings(\n\topts: SlideZoomProps | SectionZoomProps | SummaryZoomProps,\n\tvariant: ZoomInternal['variant']\n): ZoomSettings {\n\tconst transitionDur =\n\t\topts.transitionDur == null\n\t\t\t? 1000\n\t\t\t: Math.round(\n\t\t\t\t\tclampRangedInput(\n\t\t\t\t\t\topts.transitionDur,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\tMAX_TRANSITION_DUR_MS,\n\t\t\t\t\t\t'zoom/transition-duration-out-of-range',\n\t\t\t\t\t\t`${ZOOM_API[variant]} transitionDur`,\n\t\t\t\t\t\t'zoom/invalid-transition-duration'\n\t\t\t\t\t)\n\t\t\t\t)\n\treturn { returnToParent: !!opts.returnToParent, transitionDur }\n}\n\n/**\n * A zoom's resolved options: its Selection Pane name and its frame.\n *\n * Split from {@link pushZoomObject} so the Summary grid can lay itself out inside the *resolved*\n * frame. It used to re-read `opts.w ?? 0` and `opts.h ?? 0` for the grid while the emitted object\n * took its frame from here, so the same input was parsed twice by two expressions that nothing\n * held together.\n *\n * A zoom has no default size, unlike every other framed object: `{ w: 0, h: 0 }` is what the\n * caller gets when they state no frame, and `resolveAuthoredFrame` says so rather than quoting the\n * zero back at them.\n */\nfunction zoomObjectOptions(\n\ttarget: PresSlideInternal,\n\tvariant: ZoomInternal['variant'],\n\topts: SlideZoomProps | SectionZoomProps | SummaryZoomProps\n): ObjectOptionsInternal {\n\t// A zoom's options declare no `altText`, and its emitter writes none.\n\treturn framedObjectOptions(target, SlideObjectType.zoom, opts, {\n\t\tlabel: ZOOM_LABEL[variant],\n\t\tkind: 'zoom',\n\t\tapi: ZOOM_API[variant],\n\t\tdefaults: { x: 0, y: 0, w: 0, h: 0 },\n\t})\n}\n\n/** Shared object-scaffold for all three variants. */\nfunction pushZoomObject(\n\ttarget: PresSlideInternal,\n\tvariant: ZoomInternal['variant'],\n\toptions: ObjectOptionsInternal,\n\tzoom: Omit<ZoomInternal, 'variant'>\n): void {\n\tconst newObject: SlideObject = {\n\t\t_type: SlideObjectType.zoom,\n\t\toptions,\n\t\tzoom: { variant, ...zoom },\n\t}\n\ttarget._slideObjects.push(newObject)\n}\n\n/** Slide Zoom — one tile linking to a single target slide. */\nexport function addSlideZoomDefinition(target: PresSlideInternal, opts: SlideZoomProps): void {\n\tif (!opts?.target) {\n\t\twarn(\n\t\t\t'zoom/missing-target',\n\t\t\t'addSlideZoom requires a `target` slide (a Slide object or its 1-based number); ignoring.'\n\t\t)\n\t\treturn\n\t}\n\t// A number has to be a slide number: `-2` and `1.5` were written as `slide-2.xml` and\n\t// `sldId=\"256.5\"`. Whether that slide exists is checked when the deck is written, once it is complete.\n\tif (typeof opts.target === 'number' && !(Number.isInteger(opts.target) && opts.target >= 1)) {\n\t\twarn('zoom/unresolved-target', `addSlideZoom: \\`target\\` ${opts.target} is not a 1-based slide number; ignoring.`)\n\t\treturn\n\t}\n\tconst targetSlide = opts.target as PresSlideInternal\n\tconst sldId = typeof opts.target === 'number' ? MIN_SLIDE_ID + (opts.target - 1) : targetSlide._slideId\n\tconst slideNum = typeof opts.target === 'number' ? opts.target : targetSlide._slideNum\n\tif (sldId == null || slideNum == null) {\n\t\twarn('zoom/unresolved-target', 'addSlideZoom: could not resolve the target slide; ignoring.')\n\t\treturn\n\t}\n\tconst settings = resolveZoomSettings(opts, 'slide')\n\n\tconst previewRid = registerPreviewImage(target, opts.coverImage, 'a zoom `coverImage`')\n\tconst fallbackSlideRid = registerSlideRel(target, slideNum)\n\tconst tile: ZoomTileInternal = { sldId, previewRid, fallbackSlideRid, zmPrId: bracedGuid() }\n\tpushZoomObject(target, 'slide', zoomObjectOptions(target, 'slide', opts), {\n\t\ttiles: [tile],\n\t\t...settings,\n\t})\n}\n\n/** Section Zoom — one tile linking to the start of a named section. */\nexport function addSectionZoomDefinition(\n\ttarget: PresSlideInternal,\n\topts: SectionZoomProps,\n\tsections: SectionInternalProps[]\n): void {\n\tif (!opts?.sectionTitle) {\n\t\twarn('zoom/missing-section-title', 'addSectionZoom requires a `sectionTitle`; ignoring.')\n\t\treturn\n\t}\n\tconst section = sections.find((s) => s.title === opts.sectionTitle)\n\tif (!section) {\n\t\twarn('zoom/section-not-found', `addSectionZoom: no section titled \"${opts.sectionTitle}\"; ignoring.`)\n\t\treturn\n\t}\n\tconst firstSlide = section._slides[0]\n\tif (!firstSlide) {\n\t\twarn('zoom/section-empty', `addSectionZoom: section \"${opts.sectionTitle}\" has no slides; ignoring.`)\n\t\treturn\n\t}\n\tconst settings = resolveZoomSettings(opts, 'section')\n\n\tconst previewRid = registerPreviewImage(target, opts.coverImage, 'a zoom `coverImage`')\n\tconst fallbackSlideRid = registerSlideRel(target, firstSlide._slideNum)\n\tconst tile: ZoomTileInternal = { sectionId: section._id, previewRid, fallbackSlideRid, zmPrId: bracedGuid() }\n\tpushZoomObject(target, 'section', zoomObjectOptions(target, 'section', opts), {\n\t\ttiles: [tile],\n\t\t...settings,\n\t})\n}\n\n/**\n * Summary Zoom — a grid of tiles, one per section (excluding the host slide's own section).\n * All tiles share the single placeholder/cover image; each links to its section's first slide.\n */\nexport function addSummaryZoomDefinition(\n\ttarget: PresSlideInternal,\n\topts: SummaryZoomProps,\n\tsections: SectionInternalProps[]\n): void {\n\t// Exclude the section that contains this (host) slide — a summary does not link to itself.\n\tconst hostSection = sections.find((s) => s._slides.some((sl) => sl._slideNum === target._slideNum))\n\tconst targets = sections.filter((s) => s !== hostSection && s._slides.length > 0)\n\tif (targets.length === 0) {\n\t\twarn(\n\t\t\t'zoom/no-sections-to-summarize',\n\t\t\t'addSummaryZoom: no sections to summarize (need at least one section besides this slide’s own); ignoring.'\n\t\t)\n\t\treturn\n\t}\n\tconst settings = resolveZoomSettings(opts, 'summary')\n\n\tconst options = zoomObjectOptions(target, 'summary', opts)\n\n\t// Grid geometry (EMU). Tiles preserve the slide aspect ratio; the grid is centered in the frame,\n\t// last row left-aligned (matching PowerPoint). See the Summary oracle in plan `foamy-imagining-narwhal`.\n\t// The frame is the one `options` carries, not a second reading of `opts`.\n\tconst frameCx = getSmartParseNumber(options.w ?? 0, 'X', target._presLayout)\n\tconst frameCy = getSmartParseNumber(options.h ?? 0, 'Y', target._presLayout)\n\tconst ar = target._presLayout.width / target._presLayout.height\n\tconst n = targets.length\n\tconst cols = Math.ceil(Math.sqrt(n))\n\tconst rows = Math.ceil(n / cols)\n\tconst gap = Math.round(frameCx * 0.0124)\n\tlet tileW = (frameCx - (cols - 1) * gap) / cols\n\tlet tileH = tileW / ar\n\tconst tileHFit = (frameCy - (rows - 1) * gap) / rows\n\tif (tileH > tileHFit) {\n\t\ttileH = tileHFit\n\t\ttileW = tileH * ar\n\t}\n\ttileW = Math.round(tileW)\n\ttileH = Math.round(tileH)\n\tconst gridW = cols * tileW + (cols - 1) * gap\n\tconst gridH = rows * tileH + (rows - 1) * gap\n\tconst originX = Math.round((frameCx - gridW) / 2)\n\tconst originY = Math.round((frameCy - gridH) / 2)\n\n\t// One shared preview image across all tiles (identical placeholder/cover).\n\tconst previewRid = registerPreviewImage(target, opts.coverImage, 'a zoom `coverImage`')\n\tconst tiles: ZoomTileInternal[] = []\n\ttargets.forEach((section, i) => {\n\t\tconst firstSlide = section._slides[0]\n\t\tif (!firstSlide) return // guarded above (length > 0), but keeps the emit total-function\n\t\tconst r = Math.floor(i / cols)\n\t\tconst c = i % cols\n\t\ttiles.push({\n\t\t\tsectionId: section._id,\n\t\t\tpreviewRid,\n\t\t\tfallbackSlideRid: registerSlideRel(target, firstSlide._slideNum),\n\t\t\tzmPrId: bracedGuid(),\n\t\t\tgrid: { x: originX + c * (tileW + gap), y: originY + r * (tileH + gap), cx: tileW, cy: tileH },\n\t\t})\n\t})\n\n\tpushZoomObject(target, 'summary', options, {\n\t\ttiles,\n\t\t...settings,\n\t})\n}\n","/**\n * ts-pptx: the zoom construct family\n *\n * Slide, Section and Summary Zoom (PowerPoint's Insert > Zoom) -- clickable tiles that zoom to a\n * slide or to the start of a section. The two section forms resolve their targets against the live\n * section list the slide carries.\n */\n\nimport { SlideObjectType } from '../enums.js'\nimport { renderZoomObject } from '../gen/slide/objects/zoom.js'\nimport { addSectionZoomDefinition, addSlideZoomDefinition, addSummaryZoomDefinition } from '../gen/define/zoom.js'\nimport type { ConstructFamily } from './shared.js'\n\nexport const zoomFamily = {\n\tname: 'zoom',\n\tauthors: {\n\t\taddSlideZoom(slide, options) {\n\t\t\taddSlideZoomDefinition(slide, options)\n\t\t},\n\t\taddSectionZoom(slide, options) {\n\t\t\taddSectionZoomDefinition(slide, options, slide.getSections())\n\t\t},\n\t\taddSummaryZoom(slide, options) {\n\t\t\taddSumma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