pptx-ts 0.0.1 → 4.0.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 (136) hide show
  1. package/README.md +116 -269
  2. package/dist/autopage-odPz7zZO.js +536 -0
  3. package/dist/autopage-odPz7zZO.js.map +1 -0
  4. package/dist/binary-string-CKVAYI3M.js +24 -0
  5. package/dist/binary-string-CKVAYI3M.js.map +1 -0
  6. package/dist/body-insets-Dw_BeWD_.js +54 -0
  7. package/dist/body-insets-Dw_BeWD_.js.map +1 -0
  8. package/dist/browser.d.ts +29 -9
  9. package/dist/browser.d.ts.map +1 -1
  10. package/dist/browser.js +41 -14
  11. package/dist/browser.js.map +1 -1
  12. package/dist/clip-Bl01BPcN.d.ts +67 -0
  13. package/dist/clip-Bl01BPcN.d.ts.map +1 -0
  14. package/dist/diagnostics-D8ot4Ei7.d.ts +244 -0
  15. package/dist/diagnostics-D8ot4Ei7.d.ts.map +1 -0
  16. package/dist/embedded-fonts-DarT9aoa.d.ts +20 -0
  17. package/dist/embedded-fonts-DarT9aoa.d.ts.map +1 -0
  18. package/dist/entry-compose-DCnvBZz2.d.ts +1046 -0
  19. package/dist/entry-compose-DCnvBZz2.d.ts.map +1 -0
  20. package/dist/{enums-CvRYniUA.d.ts → enums-BUKTUB6V.d.ts} +21 -13
  21. package/dist/{enums-CvRYniUA.d.ts.map → enums-BUKTUB6V.d.ts.map} +1 -1
  22. package/dist/{errors-Bvln0H-7.js → errors-C4oENPcu.js} +92 -2
  23. package/dist/errors-C4oENPcu.js.map +1 -0
  24. package/dist/families.d.ts +260 -0
  25. package/dist/families.d.ts.map +1 -0
  26. package/dist/families.js +57 -0
  27. package/dist/families.js.map +1 -0
  28. package/dist/{fit-BKs0zxMI.js → fit-Cb7naFj6.js} +249 -167
  29. package/dist/fit-Cb7naFj6.js.map +1 -0
  30. package/dist/font-metrics-v5fn7s7e.d.ts +613 -0
  31. package/dist/font-metrics-v5fn7s7e.d.ts.map +1 -0
  32. package/dist/grid-DikTjFey.js +187 -0
  33. package/dist/grid-DikTjFey.js.map +1 -0
  34. package/dist/{html-dom-B0I0QSbU.js → html-dom-Iuog2wdK.js} +121 -91
  35. package/dist/html-dom-Iuog2wdK.js.map +1 -0
  36. package/dist/html.d.ts +6 -6
  37. package/dist/html.d.ts.map +1 -1
  38. package/dist/html.js +7 -6
  39. package/dist/html.js.map +1 -1
  40. package/dist/image-size-CvN2iCA4.js +1611 -0
  41. package/dist/image-size-CvN2iCA4.js.map +1 -0
  42. package/dist/index.d.ts +24 -10
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +31 -11
  45. package/dist/index.js.map +1 -1
  46. package/dist/inspect.d.ts +40 -31
  47. package/dist/inspect.d.ts.map +1 -1
  48. package/dist/inspect.js +40 -48
  49. package/dist/inspect.js.map +1 -1
  50. package/dist/math.d.ts +7 -5
  51. package/dist/math.d.ts.map +1 -1
  52. package/dist/math.js +16 -7
  53. package/dist/math.js.map +1 -1
  54. package/dist/measure.d.ts +12 -225
  55. package/dist/measure.d.ts.map +1 -1
  56. package/dist/measure.js +3 -3
  57. package/dist/node.d.ts +22 -8
  58. package/dist/node.d.ts.map +1 -1
  59. package/dist/node.js +27 -7
  60. package/dist/node.js.map +1 -1
  61. package/dist/notes-Dh12JAbn.js +3264 -0
  62. package/dist/notes-Dh12JAbn.js.map +1 -0
  63. package/dist/options-internal-WqgMf720.js +43 -0
  64. package/dist/options-internal-WqgMf720.js.map +1 -0
  65. package/dist/{package-CaOLXSNi.d.ts → package-J49Ck6S2.d.ts} +27 -12
  66. package/dist/package-J49Ck6S2.d.ts.map +1 -0
  67. package/dist/playbtn-CUqQdoDf.js +22 -0
  68. package/dist/playbtn-CUqQdoDf.js.map +1 -0
  69. package/dist/{slide-js0QpRV-.d.ts → pres-C6qgOFAa.d.ts} +1021 -1370
  70. package/dist/pres-C6qgOFAa.d.ts.map +1 -0
  71. package/dist/{presentation-Cp7vzlAw.js → presentation-DGYlAWhl.js} +3208 -2727
  72. package/dist/presentation-DGYlAWhl.js.map +1 -0
  73. package/dist/{presentation-types-DP_8jog7.d.ts → presentation-types-8jLQHI4M.d.ts} +1070 -683
  74. package/dist/presentation-types-8jLQHI4M.d.ts.map +1 -0
  75. package/dist/read.d.ts +9 -9
  76. package/dist/read.d.ts.map +1 -1
  77. package/dist/read.js +4 -4
  78. package/dist/script.d.ts +80 -66
  79. package/dist/script.d.ts.map +1 -1
  80. package/dist/script.js +2399 -1139
  81. package/dist/script.js.map +1 -1
  82. package/dist/{shapes-BemroU-z.js → shapes-re0KyQk_.js} +2807 -1609
  83. package/dist/shapes-re0KyQk_.js.map +1 -0
  84. package/dist/slide-Dx2ZeVZ6.d.ts +1256 -0
  85. package/dist/slide-Dx2ZeVZ6.d.ts.map +1 -0
  86. package/dist/slide-size-BalTjFuv.js +88 -0
  87. package/dist/slide-size-BalTjFuv.js.map +1 -0
  88. package/dist/{units-internal-Dg95w_YD.js → table-cell-margins-EVg0EwxT.js} +235 -273
  89. package/dist/table-cell-margins-EVg0EwxT.js.map +1 -0
  90. package/dist/table-dom-BTDP3lEP.js +21 -0
  91. package/dist/table-dom-BTDP3lEP.js.map +1 -0
  92. package/dist/text-KnLOtEEu.js +3980 -0
  93. package/dist/text-KnLOtEEu.js.map +1 -0
  94. package/dist/text-anchor-CrYXAfUu.js +176 -0
  95. package/dist/text-anchor-CrYXAfUu.js.map +1 -0
  96. package/dist/transition-speed-kUEWDWTx.js +14 -0
  97. package/dist/transition-speed-kUEWDWTx.js.map +1 -0
  98. package/dist/units-internal-XJlf-hOl.js +649 -0
  99. package/dist/units-internal-XJlf-hOl.js.map +1 -0
  100. package/dist/zip-C0leZZMj.d.ts +67 -0
  101. package/dist/zip-C0leZZMj.d.ts.map +1 -0
  102. package/dist/zip-CKd8ihcf.js +177 -0
  103. package/dist/zip-CKd8ihcf.js.map +1 -0
  104. package/dist/zip.d.ts +3 -68
  105. package/dist/zip.js +3 -163
  106. package/dist/zoom-cX9sllpH.js +8865 -0
  107. package/dist/zoom-cX9sllpH.js.map +1 -0
  108. package/package.json +106 -19
  109. package/skills/ts-pptx-upstream/SKILL.md +58 -57
  110. package/dist/autopage-DkjYZUFD.js +0 -423
  111. package/dist/autopage-DkjYZUFD.js.map +0 -1
  112. package/dist/diagnostics-Du_s75MT.d.ts +0 -829
  113. package/dist/diagnostics-Du_s75MT.d.ts.map +0 -1
  114. package/dist/errors-Bvln0H-7.js.map +0 -1
  115. package/dist/errors-PflMPWBn.d.ts +0 -182
  116. package/dist/errors-PflMPWBn.d.ts.map +0 -1
  117. package/dist/fit-BKs0zxMI.js.map +0 -1
  118. package/dist/html-dom-B0I0QSbU.js.map +0 -1
  119. package/dist/namespaces-BVnNu7sg.js +0 -666
  120. package/dist/namespaces-BVnNu7sg.js.map +0 -1
  121. package/dist/notes-RLCwdlTE.js +0 -1703
  122. package/dist/notes-RLCwdlTE.js.map +0 -1
  123. package/dist/package-CaOLXSNi.d.ts.map +0 -1
  124. package/dist/pres-C5__xkDh.d.ts +0 -202
  125. package/dist/pres-C5__xkDh.d.ts.map +0 -1
  126. package/dist/presentation-Cp7vzlAw.js.map +0 -1
  127. package/dist/presentation-types-DP_8jog7.d.ts.map +0 -1
  128. package/dist/shapes-BemroU-z.js.map +0 -1
  129. package/dist/slide-js0QpRV-.d.ts.map +0 -1
  130. package/dist/text-CyetbF6p.js +0 -11278
  131. package/dist/text-CyetbF6p.js.map +0 -1
  132. package/dist/units-1kRzYShk.js +0 -231
  133. package/dist/units-1kRzYShk.js.map +0 -1
  134. package/dist/units-internal-Dg95w_YD.js.map +0 -1
  135. package/dist/zip.d.ts.map +0 -1
  136. package/dist/zip.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapes-re0KyQk_.js","names":["childTnLst","checkEnum"],"sources":["../src/read/oxml/dom.ts","../src/read/opc/partnames.ts","../src/ooxml/sequence.ts","../src/read/oxml/color-transform.ts","../src/read/oxml/fill.ts","../src/read/oxml/preset-color.ts","../src/read/oxml/theme.ts","../src/read/oxml/slide-dom.ts","../src/read/oxml/placeholder-inherit.ts","../src/read/api/coords.ts","../src/read/api/shapes/geometry.ts","../src/read/api/theme-context.ts","../src/read/api/gradient.ts","../src/read/api/picture-fill.ts","../src/read/api/pattern-fill.ts","../src/read/api/shapes/oxml.ts","../src/read/api/shapes/group-transform.ts","../src/read/api/line.ts","../src/read/api/hyperlink.ts","../src/read/api/shapes/effects.ts","../src/read/api/text/run.ts","../src/read/api/text/edit.ts","../src/read/api/text/paragraph.ts","../src/read/api/text/frame.ts","../src/read/api/animation.ts","../src/read/api/shapes/base.ts","../src/read/api/shapes/autoshape.ts","../src/read/api/shapes/picture.ts","../src/read/api/shapes/connector.ts","../src/read/oxml/point-cache.ts","../src/read/api/chart.ts","../src/read/api/chartex.ts","../src/read/api/diagram.ts","../src/read/api/table-structure.ts","../src/read/api/table-style-resolve.ts","../src/read/api/table-edit.ts","../src/read/api/table-cell.ts","../src/read/api/table-row.ts","../src/read/api/table.ts","../src/read/api/shapes/graphic-frame.ts","../src/read/api/shapes.ts"],"sourcesContent":["/**\n * Thin wrapper over `@xmldom/xmldom` — the only module in `src/read/` that\n * imports it directly.\n *\n * `@xmldom/xmldom` ships its own DOM types that are NOT assignable to the\n * lib.dom `Document`/`Element`; all of `src/read/` must import DOM types from\n * here, never from lib.dom and never from `@xmldom/xmldom` directly.\n */\nimport {\n\tDOMParser,\n\tMIME_TYPE,\n\tXMLSerializer,\n\tonErrorStopParsing,\n\ttype Document,\n\ttype Element,\n\ttype Node,\n} from '@xmldom/xmldom'\n\nexport type { Document, Element, Node } from '@xmldom/xmldom'\nimport { InternalError, InvalidOptionError } from '../../errors.js'\nimport { OOXML_NS } from '../../ooxml/namespaces.js'\nimport { boolValue } from '../../ooxml/xsd-boolean.js'\nimport { FIXED_PCT_PER_PERCENT, PERCENT_SCALE } from '../../units.js'\n\n/** DOM `Node.ELEMENT_NODE` constant (xmldom does not expose it statically). */\nexport const ELEMENT_NODE = 1\n\n/** Parse an XML string strictly: any well-formedness error throws. */\nexport function parseXml(xml: string): Document {\n\treturn new DOMParser({ onError: onErrorStopParsing }).parseFromString(xml, MIME_TYPE.XML_TEXT)\n}\n\n/**\n * Serialize a Document to an XML string. Does not pretty-print or normalize\n * whitespace. The XML declaration is not part of the DOM; callers that need\n * it (see `Part.serialize`) must prepend it themselves.\n */\nexport function serializeXml(doc: Document): string {\n\treturn new XMLSerializer().serializeToString(doc)\n}\n\n// The registry itself lives in `ooxml/namespaces.ts`, which has no runtime imports, so the\n// write side can reach it without pulling `@xmldom/xmldom` into the write-only bundle. Re-exported\n// here so every existing `from '.../oxml/dom.js'` import keeps working. `qn` stays in this module:\n// it raises a diagnostic, and giving the import-free registry a dependency on `errors.ts` would\n// cost exactly what moving the table there bought.\nexport { OOXML_NS } from '../../ooxml/namespaces.js'\n\n/** Build a prefixed qname string, e.g. `qn('p', 'sld')` → `\"p:sld\"`. */\nexport function qn(prefix: string, local: string): string {\n\tif (!(prefix in OOXML_NS))\n\t\tthrow new InvalidOptionError('oxml/unknown-namespace-prefix', `Unknown OOXML namespace prefix: ${prefix}`)\n\treturn `${prefix}:${local}`\n}\n\nfunction splitQName(qname: string): { uri: string; local: string } {\n\tconst colon = qname.indexOf(':')\n\tif (colon < 0)\n\t\tthrow new InvalidOptionError('oxml/invalid-qname', `Expected a prefixed qname like \"p:sld\", got: ${qname}`)\n\tconst prefix = qname.slice(0, colon)\n\tconst uri = (OOXML_NS as Record<string, string>)[prefix]\n\tif (!uri) throw new InvalidOptionError('oxml/unknown-namespace-prefix', `Unknown OOXML namespace prefix: ${prefix}`)\n\treturn { uri, local: qname.slice(colon + 1) }\n}\n\n/**\n * Direct child elements of `parent` matching a qname. Matching is by\n * namespace URI + local name, so it is independent of the prefixes the\n * document happens to declare.\n */\nexport function getElements(parent: Node, qname: string): Element[] {\n\tconst { uri, local } = splitQName(qname)\n\tconst out: Element[] = []\n\tfor (let node = parent.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType === ELEMENT_NODE) {\n\t\t\tconst element = node as Element\n\t\t\tif (element.localName === local && element.namespaceURI === uri) out.push(element)\n\t\t}\n\t}\n\treturn out\n}\n\n/** All direct child elements in document order, regardless of qname. */\nexport function childElements(parent: Node): Element[] {\n\tconst out: Element[] = []\n\tfor (let node = parent.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType === ELEMENT_NODE) out.push(node as Element)\n\t}\n\treturn out\n}\n\n/**\n * All *descendant* elements of `root` matching a namespace + local name, snapshotted into an\n * array. Unlike {@link getElements} (direct children only) this searches the whole subtree, and\n * unlike the live `HTMLCollection` that `getElementsByTagNameNS` returns, the result does not\n * change as the caller mutates the tree — which is what makes it safe to iterate while replacing\n * the very elements being iterated.\n *\n * Note the DOM's own exclusion: `root` itself is never a candidate, only its descendants.\n */\nexport function descendantsByTag(root: Element, ns: string, local: string): Element[] {\n\tconst out: Element[] = []\n\tfor (const element of root.getElementsByTagNameNS(ns, local)) out.push(element)\n\treturn out\n}\n\n/** First direct child element matching a qname, or `null`. */\nexport function firstChild(parent: Node, qname: string): Element | null {\n\tconst { uri, local } = splitQName(qname)\n\tfor (let node = parent.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType === ELEMENT_NODE) {\n\t\t\tconst element = node as Element\n\t\t\tif (element.localName === local && element.namespaceURI === uri) return element\n\t\t}\n\t}\n\treturn null\n}\n\n/** First direct child *element* of `parent` (skipping text/comment nodes), or `null`. */\nexport function firstChildElement(parent: Node): Element | null {\n\tfor (let node = parent.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType === ELEMENT_NODE) return node as Element\n\t}\n\treturn null\n}\n\n/** First direct child element matching any of the given qnames, or `null`. */\nfunction firstChildMatchingAny(parent: Node, qnames: readonly string[]): Element | null {\n\tconst wanted = qnames.map(splitQName)\n\tfor (let node = parent.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\tconst element = node as Element\n\t\tif (wanted.some(({ uri, local }) => element.localName === local && element.namespaceURI === uri)) return element\n\t}\n\treturn null\n}\n\n// --- Mutation helpers (editing) --------------------------------------------\n//\n// `src/read/` mutates the live DOM in place; these are the only sanctioned way\n// to create elements, set attributes, and keep a parent's children in the\n// sequence OOXML requires. They never mark a part dirty — callers own that.\n\n/** Create a namespaced element from a prefixed qname (e.g. `createElement(doc, 'a:off')`). */\nexport function createElement(doc: Document, qname: string): Element {\n\tconst { uri } = splitQName(qname)\n\treturn doc.createElementNS(uri, qname)\n}\n\n/**\n * The owning document of a node. `Node.ownerDocument` is typed `Document | null`\n * (it is null only for a `Document` itself), but every element parsed from or\n * created within a package document has one; this encodes that invariant and\n * throws loudly if it is ever violated rather than deferring to a downstream NPE.\n */\nexport function ownerDocumentOf(node: Node): Document {\n\tconst doc = node.ownerDocument\n\tif (!doc) throw new InternalError('oxml/node-has-no-document', 'Node has no ownerDocument')\n\treturn doc\n}\n\n/**\n * Replace `oldNode` with `newNode` in `oldNode`'s parent. `Node.parentNode` is\n * typed `Node | null`; a node reached by walking a tree always has a parent, so\n * this captures the common replace-in-place pattern and fails clearly when the\n * node is unexpectedly detached.\n */\nexport function replaceInParent(oldNode: Node, newNode: Node): void {\n\tconst parent = oldNode.parentNode\n\tif (!parent) throw new InternalError('oxml/node-has-no-parent', 'Node has no parent to replace within')\n\tparent.replaceChild(newNode, oldNode)\n}\n\n/**\n * Set an attribute by qname. An unprefixed name (`sz`, `x`) sets a plain\n * attribute; a prefixed name (`r:id`) resolves the prefix to its namespace and\n * sets it via `setAttributeNS`. The reserved `xml:` prefix is handled by the\n * DOM itself.\n */\nexport function setAttr(element: Element, qname: string, value: string): void {\n\tconst colon = qname.indexOf(':')\n\tif (colon < 0 || qname.startsWith('xml:')) {\n\t\telement.setAttribute(qname, value)\n\t\treturn\n\t}\n\tconst { uri } = splitQName(qname)\n\telement.setAttributeNS(uri, qname, value)\n}\n\n/** Remove an attribute by qname; a no-op when the attribute is absent. */\nexport function removeAttr(element: Element, qname: string): void {\n\tconst colon = qname.indexOf(':')\n\tif (colon < 0 || qname.startsWith('xml:')) {\n\t\telement.removeAttribute(qname)\n\t\treturn\n\t}\n\tconst { uri, local } = splitQName(qname)\n\telement.removeAttributeNS(uri, local)\n}\n\n/**\n * Get the first child element matching `qname`, creating and inserting it when\n * absent. A newly created element is inserted before the first existing child\n * whose qname appears in `before` (the schema successors of the new element),\n * or appended when none are present — keeping the parent's children in the\n * sequence order OOXML mandates.\n */\nexport function getOrAddChild(parent: Element, qname: string, before: readonly string[] = []): Element {\n\tconst existing = firstChild(parent, qname)\n\tif (existing) return existing\n\tconst doc = parent.ownerDocument\n\tif (!doc)\n\t\tthrow new InternalError(\n\t\t\t'oxml/node-has-no-document',\n\t\t\t`Cannot create <${qname}>: parent element has no owner document`\n\t\t)\n\tconst child = createElement(doc, qname)\n\tconst successor = before.length ? firstChildMatchingAny(parent, before) : null\n\tparent.insertBefore(child, successor) // insertBefore(node, null) appends\n\treturn child\n}\n\n/**\n * Insert an already-built `node` into `parent` in document order: before the\n * first existing child whose qname is in `before` (the new node's schema\n * successors), or appended when none are present. Unlike {@link getOrAddChild}\n * this always inserts the given node (no get-or-create), so callers can place a\n * freshly-constructed subtree at the right position.\n */\nexport function insertInOrder(parent: Element, node: Node, before: readonly string[] = []): void {\n\tconst successor = before.length ? firstChildMatchingAny(parent, before) : null\n\tparent.insertBefore(node, successor)\n}\n\n/** Remove every direct child element matching any of the given qnames. */\nexport function removeChildrenByQName(parent: Element, qnames: readonly string[]): void {\n\tconst toRemove: Element[] = []\n\tfor (let node = parent.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\ttoRemove.push(node as Element)\n\t}\n\tconst wanted = qnames.map(splitQName)\n\tfor (const element of toRemove) {\n\t\tif (wanted.some(({ uri, local }) => element.localName === local && element.namespaceURI === uri)) {\n\t\t\tparent.removeChild(element)\n\t\t}\n\t}\n}\n\n/**\n * Read an attribute by qname. An unprefixed name (`sz`, `b`) reads the plain\n * attribute; a prefixed name (`r:id`, `r:embed`) resolves the prefix to its\n * namespace URI and reads via `getAttributeNS`, so it is robust to whatever\n * prefix the document declared. Returns `null` when the attribute is absent.\n */\nexport function attr(element: Element, qname: string): string | null {\n\tconst colon = qname.indexOf(':')\n\tif (colon < 0) return element.getAttribute(qname)\n\tconst { uri, local } = splitQName(qname)\n\treturn element.getAttributeNS(uri, local)\n}\n\n/**\n * Parse a numeric OOXML attribute; `null`/empty/non-finite → `null`.\n *\n * Not an integer parser: the schema types it reads span `xsd:int`, `xsd:double`\n * and the fractional scales chartEx writes, and every one of them goes through\n * the same `Number()`.\n */\nexport function numberValue(value: string | null): number | null {\n\tif (value === null || value === '') return null\n\tconst number = Number(value)\n\treturn Number.isFinite(number) ? number : null\n}\n\n/** {@link numberValue} over an attribute read by qname. */\nexport function numberAttr(element: Element, qname: string): number | null {\n\treturn numberValue(attr(element, qname))\n}\n\n// The parser itself lives in `ooxml/xsd-boolean.ts` for the same reason the namespace registry\n// does: it is a fact about the schema, it has no runtime imports, and code outside `read/` should\n// not have to take a `@xmldom/xmldom` dependency to reach it. Re-exported here so every existing\n// `from '.../oxml/dom.js'` import keeps working.\nexport { boolValue } from '../../ooxml/xsd-boolean.js'\n\n/** {@link boolValue} over an attribute read by qname. */\nexport function boolAttr(element: Element, qname: string): boolean | null {\n\treturn boolValue(attr(element, qname))\n}\n\n/**\n * DrawingML percentage → fraction, or `null` when unparseable.\n *\n * `a:ST_Percentage` is a *union* in the Transitional profile: the fixed-point integer form\n * Office writes (`100%` → `100000`) and a decimal string with a literal `%` (`-?[0-9]+(\\.[0-9]+)?%`),\n * which is the only form the Strict profile has. Both are read here — a reader that took only the\n * first dropped a schema-legal value silently, and the two are one `endsWith` apart.\n * @param value - the raw attribute value, or `null` when the attribute is absent\n */\nexport function parsePercent(value: string | null): number | null {\n\tif (value === null || value === '') return null\n\tif (value.endsWith('%')) {\n\t\tconst n = Number(value.slice(0, -1))\n\t\treturn Number.isFinite(n) ? n / 100 : null\n\t}\n\tconst n = Number(value)\n\treturn Number.isFinite(n) ? n / PERCENT_SCALE : null\n}\n\n/** {@link parsePercent} over an attribute read by qname. */\nexport function pctAttr(element: Element, qname: string): number | null {\n\treturn parsePercent(attr(element, qname))\n}\n\n/**\n * DrawingML percentage → percent *points* (`55000` → `55`), or `null` when unparseable.\n *\n * Not `parsePercent(v) * 100`. The fixed-point form divides by 100000 and multiplying the\n * result back by 100 re-introduces the rounding that division just took on: `55000` came out\n * of three public accessors as `55.00000000000001`, and one of them wrote that into the\n * committed inspect snapshot, where it made the sidecar unreproducible from its own generator.\n * Dividing once by {@link FIXED_PCT_PER_PERCENT} is exact for every value Office writes.\n * @param value - the raw attribute value, or `null` when the attribute is absent\n */\nexport function parsePercentPoints(value: string | null): number | null {\n\tif (value === null || value === '') return null\n\tif (value.endsWith('%')) {\n\t\tconst n = Number(value.slice(0, -1))\n\t\treturn Number.isFinite(n) ? n : null\n\t}\n\tconst n = Number(value)\n\treturn Number.isFinite(n) ? n / FIXED_PCT_PER_PERCENT : null\n}\n\n/** {@link parsePercentPoints} over an attribute read by qname. */\nexport function pctPointsAttr(element: Element, qname: string): number | null {\n\treturn parsePercentPoints(attr(element, qname))\n}\n\n/**\n * The text of a DrawingML rich-text body: every `a:t` under `rich`, concatenated, or `null` when\n * there is none.\n *\n * `null` rather than `''` for an empty body, because a title element with no runs and no title\n * element at all are the same fact to a caller. The two chart readers (`c:rich` and `cx:rich`)\n * were the only occurrences of this loop in `src/` and each had its own copy.\n * @param rich - the `a:*`-bearing rich-text element, or `null`\n */\nexport function concatDrawingMLText(rich: Element | null): string | null {\n\tif (!rich) return null\n\tlet out = ''\n\tfor (const t of rich.getElementsByTagNameNS(OOXML_NS.a, 't')) out += t.textContent ?? ''\n\treturn out === '' ? null : out\n}\n","/**\n * OPC partname helpers (ECMA-376 Part 2 pack-URI grammar).\n *\n * A partname is an absolute, `/`-separated path inside the package, e.g.\n * `/ppt/slides/slide1.xml`. Zip entry paths omit the leading slash.\n */\nimport { PackageReadError } from '../../errors.js'\nimport type { OpcPackage } from './package.js'\nimport type { Part } from './part.js'\nimport type { Relationships } from './relationships.js'\n\n/**\n * Resolve the single relationship of `type` owned by `partName` to its target partname, or\n * `null` when the part declares none. For the one-of-a-kind links in a deck's spine — a slide to\n * its layout, a layout to its master, a master to its theme — where a second relationship of the\n * same type would itself be malformed.\n *\n * The `OpcPackage` import is type-only, so this does not create a cycle with `package.ts` (which\n * imports this module at run time).\n */\nexport function resolveSingleRel(opc: OpcPackage, partName: string, type: string): string | null {\n\tconst rels = opc.relationshipsFor(partName)\n\tconst rel = rels.byType(type)[0]\n\treturn rel ? rels.resolveTarget(rel.id) : null\n}\n\n/**\n * The part `relId` names in `rels`, or `null` when the package holds no such part.\n *\n * Ten sites in the API layer wrote the `resolveTarget` + `opc.part` pair out; two more wrote\n * the `byType(T)[0]` that precedes it (see {@link singleRelPart}). `resolveTarget` keeps its\n * throw on an id the part does not declare — a dangling `r:id` is a malformed package, not a\n * missing part, and the graphic-frame accessors rely on the distinction.\n */\nexport function relPart(opc: OpcPackage, rels: Relationships, relId: string): Part | null {\n\treturn opc.part(rels.resolveTarget(relId)) ?? null\n}\n\n/**\n * The absolute partname `relId` names, or `null` when there is nothing in the package to name:\n * no id, no relationship declaring it, or a relationship whose target is **external**.\n *\n * `Relationships.resolveTarget` throws on both of the last two, which is right where the caller\n * is asking a question a malformed package cannot answer (the graphic-frame accessors below rely\n * on it). It is wrong for the accessors that already report \"absent\" as `null`: the SAME\n * `a:blip/@r:embed` reached through a picture fill degraded to `null` and through\n * `Picture.imagePartName` threw, so one broken embed on an imported deck took out a whole\n * `slide.shapes` walk -- and `Picture.mediaPartName`, the \"just give me the bytes\" accessor,\n * inherited the throw from both halves. A `p:pic` holding a LINKED image, which `mediaKind`'s\n * own documentation names, threw rather than reporting `'none'`.\n * @param relId - the relationship id, if any\n * @param rels - the owning part's relationships, if any\n * @returns the absolute partname, or `null`\n */\nexport function resolvePartName(relId: string | null | undefined, rels: Relationships | null): string | null {\n\tif (!relId || !rels) return null\n\tconst rel = rels.get(relId)\n\tif (!rel || rel.targetMode === 'External') return null\n\treturn rels.resolveTarget(relId)\n}\n\n/**\n * {@link resolveSingleRel}, resolved the rest of the way to the {@link Part}.\n *\n * For the one-of-a-kind links in a deck's spine, where the caller wants the part rather than\n * its name — a slide to its notes slide or its layout, a layout to its master, a part to its\n * `core.xml` or `app.xml`.\n */\nexport function singleRelPart(opc: OpcPackage, partName: string, type: string): Part | null {\n\tconst rels = opc.relationshipsFor(partName)\n\tconst rel = rels.byType(type)[0]\n\treturn rel ? relPart(opc, rels, rel.id) : null\n}\n\nexport function zipPathToPartName(zipPath: string): string {\n\treturn zipPath.startsWith('/') ? zipPath : `/${zipPath}`\n}\n\nexport function partNameToZipPath(partName: string): string {\n\treturn partName.startsWith('/') ? partName.slice(1) : partName\n}\n\n/**\n * Lowercased extension without the dot, or `''` when the part has none.\n * Per OPC, the extension is everything after the last dot — so the leading\n * dot of `/_rels/.rels` still yields `rels`.\n */\nexport function partNameExtension(partName: string): string {\n\tconst lastSegment = partName.slice(partName.lastIndexOf('/') + 1)\n\tconst dot = lastSegment.lastIndexOf('.')\n\treturn dot < 0 ? '' : lastSegment.slice(dot + 1).toLowerCase()\n}\n\n/** Partname of the `.rels` part holding `sourcePartName`'s relationships ('/' = package). */\nexport function relsPartNameFor(sourcePartName: string): string {\n\tif (sourcePartName === '/') return '/_rels/.rels'\n\tconst dir = sourcePartName.slice(0, sourcePartName.lastIndexOf('/'))\n\tconst file = sourcePartName.slice(sourcePartName.lastIndexOf('/') + 1)\n\treturn `${dir}/_rels/${file}.rels`\n}\n\n/**\n * Build a relationship `Target` for `targetPartName` relative to its source\n * part's directory — the inverse of {@link resolveRelativePartName}. Both names\n * are absolute partnames. E.g. source `/ppt/slides/slide1.xml`, target\n * `/ppt/media/image1.png` → `../media/image1.png`.\n */\nexport function relativePartName(sourcePartName: string, targetPartName: string): string {\n\tconst from = sourcePartName.slice(1).split('/').slice(0, -1) // source directory segments\n\tconst to = targetPartName.slice(1).split('/') // target segments incl. filename\n\tlet common = 0\n\twhile (common < from.length && common < to.length - 1 && from[common] === to[common]) common++\n\tconst up = from.slice(common).map(() => '..')\n\tconst down = to.slice(common)\n\treturn [...up, ...down].join('/')\n}\n\n/**\n * Resolve a relationship target against its source part, per OPC pack-URI\n * resolution: relative targets resolve against the source part's directory.\n *\n * @param sourcePartName partname of the part owning the relationship ('/' for package-level)\n * @param target relationship Target attribute (relative like `../media/image1.png`, or absolute)\n */\nexport function resolveRelativePartName(sourcePartName: string, target: string): string {\n\tconst path = target.startsWith('/') ? target : sourcePartName.slice(0, sourcePartName.lastIndexOf('/') + 1) + target\n\tconst segments: string[] = []\n\tfor (const segment of path.split('/')) {\n\t\tif (segment === '' || segment === '.') continue\n\t\tif (segment === '..') {\n\t\t\tif (segments.length === 0)\n\t\t\t\tthrow new PackageReadError(\n\t\t\t\t\t'package/relationship-target-escapes-root',\n\t\t\t\t\t`Relationship target ${target} escapes the package root (source ${sourcePartName})`\n\t\t\t\t)\n\t\t\tsegments.pop()\n\t\t} else {\n\t\t\tsegments.push(segment)\n\t\t}\n\t}\n\treturn `/${segments.join('/')}`\n}\n","/**\n * Schema child-sequence order for the OOXML complexTypes both halves of the library insert into.\n *\n * **What these are for.** `getOrAddChild(parent, qname, before)` / `insertInOrder(parent, node,\n * before)` place a newly created child before the first sibling named in `before`. So `before`\n * must list exactly the children that legally *follow* the one being inserted. Get it wrong and\n * the part is schema-invalid — which PowerPoint reports as a corrupt file, not as a bad option,\n * so the failure surfaces far from its cause with no compile-time signal.\n *\n * **Why they are derived, not written out.** These successor lists used to be hand-maintained,\n * and the same four had drifted into two copies apiece (`read/api/shapes/oxml.ts` and\n * `read/oxml/theme.ts`), including one pair whose names were transposed (`SPPR_AFTER_XFRM` vs\n * `SPPR_XFRM_AFTER`) while the contents stayed identical. Declaring each complexType's sequence\n * **once** and slicing the successors out of it removes that class of bug outright: there is a\n * single ordering to be right about, and adding a child to a sequence updates every successor\n * list that follows it in one edit. This is the technique `TCPR_AFTER` already used for\n * `CT_TableCellProperties`; this module generalizes it.\n *\n * **Why this module is neither `gen/` nor `read/`.** Document order is a fact about the schema,\n * not about writing or reading it. `read/` inserts into a live DOM and `gen/` emits strings, but\n * both are bound by the same ECMA-376 sequence.\n */\n\nimport { EMBEDDED_FONT_SLOTS } from './st-enums.js'\nimport { InternalError } from '../errors.js'\n\n/**\n * One step of a schema sequence: a single element, or a choice group whose members are mutually\n * exclusive. A group is spelled as an array so {@link successorsOf} can treat every member as\n * occupying the same slot — the successors of `a:solidFill` are what follows the *whole*\n * `EG_FillProperties` group, not its sibling choices.\n */\ntype SequenceStep = string | readonly string[]\n\n/**\n * `EG_FillProperties` — the mutually exclusive fill choices, in schema order.\n * @see ECMA-376 Part 1 §20.1.8 (DrawingML fill group)\n */\nexport const FILL_CHOICES = ['a:noFill', 'a:solidFill', 'a:gradFill', 'a:blipFill', 'a:pattFill', 'a:grpFill'] as const\n\n/** `EG_EffectProperties` — the two mutually exclusive effect containers. */\nconst EFFECT_CHOICES = ['a:effectLst', 'a:effectDag'] as const\n\n/** `EG_Geometry` — the two mutually exclusive geometry choices. */\nconst GEOMETRY_CHOICES = ['a:custGeom', 'a:prstGeom'] as const\n\n/**\n * Everything that legally follows `member` in `sequence`, flattened.\n *\n * `member` may name a single element or any member of a choice group; either way the result\n * starts after the step it occupies, so a choice member never lists its own siblings. Throws on\n * an unknown name rather than returning `[]` — an empty successor list silently *appends*, which\n * is exactly the corruption these lists exist to prevent, so a typo must fail loudly and at\n * module-load time rather than produce a subtly out-of-order part at run time.\n */\nfunction successorsOf(sequence: readonly SequenceStep[], member: string): string[] {\n\tconst index = sequence.findIndex((step) => (typeof step === 'string' ? step === member : step.includes(member)))\n\tif (index < 0)\n\t\tthrow new InternalError('ooxml/member-not-in-sequence', `successorsOf: ${member} is not part of the given sequence`)\n\treturn sequence.slice(index + 1).flat()\n}\n\n/**\n * `CT_ShapeProperties` (`p:spPr`), in declaration order.\n * @see ECMA-376 Part 1 §20.1.2.2.35\n */\nconst SPPR_SEQUENCE: readonly SequenceStep[] = [\n\t'a:xfrm',\n\tGEOMETRY_CHOICES,\n\tFILL_CHOICES,\n\t'a:ln',\n\tEFFECT_CHOICES,\n\t'a:scene3d',\n\t'a:sp3d',\n\t'a:extLst',\n]\n\n/**\n * `CT_Shape` (`p:sp`), in declaration order.\n *\n * `p:pic` (`CT_Picture`) and `p:cxnSp` (`CT_Connector`) are not this type, but their successors\n * of `p:spPr` are a *subset* of this one's in the same relative order — both run `p:spPr`,\n * `p:style`, `p:extLst` and neither has a `p:txBody`. So {@link SHAPE_AFTER_SPPR} serves all\n * three: naming an element that cannot occur in a given parent is inert, because the successor\n * list is only ever matched against children that are actually there.\n * @see ECMA-376 Part 1 §19.3.1.43\n */\nconst SP_SEQUENCE: readonly SequenceStep[] = ['p:nvSpPr', 'p:spPr', 'p:style', 'p:txBody', 'p:extLst']\n\n/**\n * `CT_GroupShapeProperties` (`p:grpSpPr`), in declaration order. A group carries no `a:ln` and\n * no `a:sp3d` — which is exactly why it needs its own successor lists rather than borrowing the\n * shape ones.\n * @see ECMA-376 Part 1 §20.1.2.2.19\n */\nconst GRPSPPR_SEQUENCE: readonly SequenceStep[] = ['a:xfrm', FILL_CHOICES, EFFECT_CHOICES, 'a:scene3d', 'a:extLst']\n\n/**\n * `CT_GroupShape` (`p:grpSp`, and `p:spTree`, which is the same type), in declaration order.\n *\n * The drawable children are one repeated choice, so they share a slot: everything that may follow\n * `p:grpSpPr` follows it whichever of them is present. `p:contentPart` (ink) and `p:extLst` are in\n * that tail and were missing from the hand-written list this replaces, so a group whose only\n * children were ink or an extension list had `p:grpSpPr` appended *after* them, which is invalid.\n * @see ECMA-376 Part 1 §19.3.1.22\n */\nconst GROUP_SHAPE_SEQUENCE: readonly SequenceStep[] = [\n\t'p:nvGrpSpPr',\n\t'p:grpSpPr',\n\t['p:sp', 'p:grpSp', 'p:graphicFrame', 'p:cxnSp', 'p:pic', 'p:contentPart'],\n\t'p:extLst',\n]\n\n/**\n * `CT_LineProperties` (`a:ln`), in declaration order.\n * @see ECMA-376 Part 1 §20.1.2.2.24\n */\nconst LN_SEQUENCE: readonly SequenceStep[] = [\n\tFILL_CHOICES,\n\t['a:prstDash', 'a:custDash'],\n\t['a:round', 'a:bevel', 'a:miter'],\n\t'a:headEnd',\n\t'a:tailEnd',\n\t'a:extLst',\n]\n\n/**\n * `CT_TextCharacterProperties` (`a:rPr`/`a:defRPr`/`a:endParaRPr`), in declaration order.\n * @see ECMA-376 Part 1 §21.1.2.3.9\n */\nconst RPR_SEQUENCE: readonly SequenceStep[] = [\n\t'a:ln',\n\tFILL_CHOICES,\n\tEFFECT_CHOICES,\n\t'a:highlight',\n\t['a:uLnTx', 'a:uLn'],\n\t['a:uFillTx', 'a:uFill'],\n\t'a:latin',\n\t'a:ea',\n\t'a:cs',\n\t'a:sym',\n\t'a:hlinkClick',\n\t'a:hlinkMouseOver',\n\t'a:rtl',\n\t'a:extLst',\n]\n\n/**\n * `CT_TableCellProperties` (`a:tcPr`), in declaration order.\n * @see ECMA-376 Part 1 §21.1.3.17\n */\nexport const TCPR_SEQUENCE: readonly string[] = [\n\t'a:lnL',\n\t'a:lnR',\n\t'a:lnT',\n\t'a:lnB',\n\t'a:lnTlToBr',\n\t'a:lnBlToTr',\n\t'a:cell3D',\n\t...FILL_CHOICES,\n\t'a:headers',\n\t'a:extLst',\n]\n\n/**\n * For each `a:tcPr` child, the children that must follow it — i.e. what a new one is inserted\n * *before*. Every child gets an entry, so a caller can look one up by qname.\n */\nexport const TCPR_AFTER: Record<string, string[]> = Object.fromEntries(\n\tTCPR_SEQUENCE.map((qname, index) => [qname, TCPR_SEQUENCE.slice(index + 1)])\n)\n\n// --- p:spPr / p:grpSpPr ------------------------------------------------------\n\n/** Successors of `a:xfrm` inside `p:spPr`. */\nexport const SPPR_AFTER_XFRM = successorsOf(SPPR_SEQUENCE, 'a:xfrm')\n/** Successors of a fill choice inside `p:spPr`. */\nexport const SPPR_FILL_AFTER = successorsOf(SPPR_SEQUENCE, 'a:solidFill')\n/** Successors of `a:ln` inside `p:spPr`. */\nexport const SPPR_LN_AFTER = successorsOf(SPPR_SEQUENCE, 'a:ln')\n/** Successors of an effect container inside `p:spPr`. */\nexport const SPPR_EFFECT_AFTER = successorsOf(SPPR_SEQUENCE, 'a:effectLst')\n/** Successors of `a:scene3d` inside `p:spPr`. */\nexport const SPPR_SCENE3D_AFTER = successorsOf(SPPR_SEQUENCE, 'a:scene3d')\n/** Successors of `a:sp3d` inside `p:spPr`. */\nexport const SPPR_SP3D_AFTER = successorsOf(SPPR_SEQUENCE, 'a:sp3d')\n\n/** Successors of `a:xfrm` inside `p:grpSpPr`. */\nexport const GRPSPPR_AFTER_XFRM = successorsOf(GRPSPPR_SEQUENCE, 'a:xfrm')\n/** Successors of a fill choice inside `p:grpSpPr`. */\nexport const GRPSPPR_FILL_AFTER = successorsOf(GRPSPPR_SEQUENCE, 'a:solidFill')\n\n/**\n * Successors of `p:grpSpPr` within `p:grpSp` — every drawable child, plus `p:contentPart` and\n * `p:extLst`. Derived rather than written out, which is the whole point of this module: the\n * literal it replaces named five of the seven.\n */\nexport const GROUP_AFTER_GRPSPPR = successorsOf(GROUP_SHAPE_SEQUENCE, 'p:grpSpPr')\n\n/**\n * Successors of `p:spPr` within `p:sp`, and equally within `p:pic` / `p:cxnSp` — see\n * {@link SP_SEQUENCE} for why one list covers all three. `p:blipFill` and the `p:nv*Pr` wrapper\n * precede `p:spPr`, so slicing the sequence drops them without anyone having to remember to.\n */\nexport const SHAPE_AFTER_SPPR = successorsOf(SP_SEQUENCE, 'p:spPr')\n\n// --- a:ln / a:rPr ------------------------------------------------------------\n\n/** Successors of a fill choice inside `a:ln`. */\nexport const LN_FILL_AFTER = successorsOf(LN_SEQUENCE, 'a:solidFill')\n/**\n * `CT_LineProperties`'s slots in order, each spelled as a group, for a merge that has to ask\n * whether a line states anything in a slot rather than place one known child.\n */\nexport const LN_SLOTS: readonly (readonly string[])[] = LN_SEQUENCE.map((step) =>\n\ttypeof step === 'string' ? [step] : step\n)\n/** Successors of a fill choice inside `a:rPr` (and `a:defRPr`/`a:endParaRPr`). */\nexport const RPR_FILL_AFTER = successorsOf(RPR_SEQUENCE, 'a:solidFill')\n/** Successors of `a:latin` inside `a:rPr` (and `a:defRPr`/`a:endParaRPr`). */\nexport const RPR_LATIN_AFTER = successorsOf(RPR_SEQUENCE, 'a:latin')\n\n// --- p:presentation ----------------------------------------------------------\n\n/**\n * `CT_Presentation` (`p:presentation`), in declaration order. Every child is a single element —\n * there are no choice groups — so the declaration is a plain string list.\n * @see ECMA-376 Part 1 §19.2.1.26\n */\nconst PRESENTATION_SEQUENCE: readonly SequenceStep[] = [\n\t'p:sldMasterIdLst',\n\t'p:notesMasterIdLst',\n\t'p:handoutMasterIdLst',\n\t'p:sldIdLst',\n\t'p:sldSz',\n\t'p:notesSz',\n\t'p:smartTags',\n\t'p:embeddedFontLst',\n\t'p:custShowLst',\n\t'p:photoAlbum',\n\t'p:custDataLst',\n\t'p:kinsoku',\n\t'p:defaultTextStyle',\n\t'p:modifyVerifier',\n\t'p:extLst',\n]\n\n/** Successors of `p:sldMasterIdLst` inside `p:presentation`. */\nexport const PRESENTATION_AFTER_SLD_MASTER_ID_LST = successorsOf(PRESENTATION_SEQUENCE, 'p:sldMasterIdLst')\n/** Successors of `p:notesMasterIdLst` inside `p:presentation`. */\nexport const PRESENTATION_AFTER_NOTES_MASTER_ID_LST = successorsOf(PRESENTATION_SEQUENCE, 'p:notesMasterIdLst')\n/** Successors of `p:sldIdLst` inside `p:presentation`. */\nexport const PRESENTATION_AFTER_SLD_ID_LST = successorsOf(PRESENTATION_SEQUENCE, 'p:sldIdLst')\n/** Successors of `p:embeddedFontLst` inside `p:presentation`. */\nexport const PRESENTATION_AFTER_EMBEDDED_FONT_LST = successorsOf(PRESENTATION_SEQUENCE, 'p:embeddedFontLst')\n\n/**\n * `CT_EmbeddedFontListEntry` (`p:embeddedFont`), in declaration order: the typeface identity\n * followed by one optional element per face slot. Every child is a single element, so the\n * declaration is a plain string list.\n * @see ECMA-376 Part 1 §19.2.1.9\n */\nconst EMBEDDED_FONT_ENTRY_SEQUENCE: readonly string[] = ['p:font', ...EMBEDDED_FONT_SLOTS.map((slot) => `p:${slot}`)]\n\n/**\n * For each `p:embeddedFont` child, the children that must follow it — i.e. what a new one is\n * inserted *before*. Every child gets an entry, so a caller can look one up by qname.\n */\nexport const EMBEDDED_FONT_ENTRY_AFTER: Record<string, string[]> = Object.fromEntries(\n\tEMBEDDED_FONT_ENTRY_SEQUENCE.map((qname, index) => [qname, EMBEDDED_FONT_ENTRY_SEQUENCE.slice(index + 1)])\n)\n\n// --- p:pic / a:blipFill ------------------------------------------------------\n\n/**\n * `CT_Picture` (`p:pic`), in declaration order.\n * @see ECMA-376 Part 1 §19.3.1.37\n */\nconst PIC_SEQUENCE: readonly SequenceStep[] = ['p:nvPicPr', 'p:blipFill', 'p:spPr', 'p:style', 'p:extLst']\n\n/**\n * `CT_BlipFillProperties` (`a:blipFill`), in declaration order. `a:tile` and `a:stretch` are the\n * `EG_FillModeProperties` choice and share one slot, so neither lists the other as a successor.\n * @see ECMA-376 Part 1 §20.1.8.14\n */\nconst BLIPFILL_SEQUENCE: readonly SequenceStep[] = ['a:blip', 'a:srcRect', ['a:tile', 'a:stretch']]\n\n/** Successors of `p:blipFill` inside `p:pic`. */\nexport const PIC_BLIPFILL_AFTER = successorsOf(PIC_SEQUENCE, 'p:blipFill')\n/** Successors of `a:blip` inside `a:blipFill`. */\nexport const BLIPFILL_BLIP_AFTER = successorsOf(BLIPFILL_SEQUENCE, 'a:blip')\n/** Successors of `a:srcRect` inside `a:blipFill`. */\nexport const BLIPFILL_SRCRECT_AFTER = successorsOf(BLIPFILL_SEQUENCE, 'a:srcRect')\n\n// --- p:sldMaster / p:sld / p:cSld / p:timing ---------------------------------\n\n/**\n * `CT_SlideMaster` (`p:sldMaster`), in declaration order. `p:clrMap` is the whole of the\n * `EG_TopLevelSlide` group.\n */\nconst SLIDE_MASTER_SEQUENCE: readonly SequenceStep[] = [\n\t'p:cSld',\n\t'p:clrMap',\n\t'p:sldLayoutIdLst',\n\t'p:transition',\n\t'p:timing',\n\t'p:hf',\n\t'p:txStyles',\n\t'p:extLst',\n]\n\n/** `CT_Slide` (`p:sld`), in declaration order. `p:clrMapOvr` is the whole of `EG_ChildSlide`. */\nconst SLIDE_SEQUENCE: readonly SequenceStep[] = ['p:cSld', 'p:clrMapOvr', 'p:transition', 'p:timing', 'p:extLst']\n\n/** `CT_CommonSlideData` (`p:cSld`), in declaration order. */\nconst COMMON_SLIDE_DATA_SEQUENCE: readonly SequenceStep[] = [\n\t'p:bg',\n\t'p:spTree',\n\t'p:custDataLst',\n\t'p:controls',\n\t'p:extLst',\n]\n\n/** `CT_SlideTiming` (`p:timing`), in declaration order. */\nconst SLIDE_TIMING_SEQUENCE: readonly SequenceStep[] = ['p:tnLst', 'p:bldLst', 'p:extLst']\n\n/** Successors of `p:sldLayoutIdLst` inside `p:sldMaster`. */\nexport const SLIDE_MASTER_AFTER_SLD_LAYOUT_ID_LST = successorsOf(SLIDE_MASTER_SEQUENCE, 'p:sldLayoutIdLst')\n/** Successors of `p:transition` inside `p:sld`. */\nexport const SLIDE_AFTER_TRANSITION = successorsOf(SLIDE_SEQUENCE, 'p:transition')\n/** Successors of `p:timing` inside `p:sld`. */\nexport const SLIDE_AFTER_TIMING = successorsOf(SLIDE_SEQUENCE, 'p:timing')\n/** Successors of `p:bg` inside `p:cSld`. */\nexport const CSLD_AFTER_BG = successorsOf(COMMON_SLIDE_DATA_SEQUENCE, 'p:bg')\n/** Successors of `p:tnLst` inside `p:timing`. */\nexport const TIMING_AFTER_TNLST = successorsOf(SLIDE_TIMING_SEQUENCE, 'p:tnLst')\n\n// --- a:r / a:fld -------------------------------------------------------------\n\n/**\n * `CT_TextField` (`a:fld`), in declaration order. `CT_RegularTextRun` (`a:r`) is the same without\n * `a:pPr`, so one successor list places an `a:rPr` in either.\n */\nconst TEXT_FIELD_SEQUENCE: readonly SequenceStep[] = ['a:rPr', 'a:pPr', 'a:t']\n\n/** Successors of `a:rPr` inside a run or a field. */\nexport const RUN_AFTER_RPR = successorsOf(TEXT_FIELD_SEQUENCE, 'a:rPr')\n\n// --- p:txBody ----------------------------------------------------------------\n\n/** `CT_TextBody` (`p:txBody`, and `a:txBody` in a table cell), in declaration order. */\nconst TEXT_BODY_SEQUENCE: readonly SequenceStep[] = ['a:bodyPr', 'a:lstStyle', 'a:p']\n\n/** Successors of `a:bodyPr` inside a text body. */\nexport const TXBODY_AFTER_BODYPR = successorsOf(TEXT_BODY_SEQUENCE, 'a:bodyPr')\n/** Successors of `a:lstStyle` inside a text body. */\nexport const TXBODY_AFTER_LSTSTYLE = successorsOf(TEXT_BODY_SEQUENCE, 'a:lstStyle')\n\n/**\n * Every sequence declared here, keyed by the element names that carry it.\n *\n * The successor lists above serve the read path, which inserts into a live DOM. The write path\n * has no equivalent: each emitter states its children in order by hand, and the only thing\n * checking that order is PowerPoint refusing to open the file. This table is what lets a test\n * compare the two -- an emitted element's children must be a subsequence of the sequence its\n * type declares -- so the next transposed child is a failing assertion rather than a repair\n * prompt in front of a user.\n *\n * The same complexType appears under several names: `CT_ShapeProperties` is `p:spPr` on a slide\n * and `c:spPr` inside a chart, and `CT_TextCharacterProperties` is `a:rPr`, `a:defRPr` and\n * `a:endParaRPr`. Each name maps to the one sequence, which is the point -- a chart's `spPr` is\n * bound by the same order a slide's is, and it was a chart emitter that last got one wrong.\n */\nexport const CHILD_SEQUENCES: Readonly<Record<string, readonly SequenceStep[]>> = {\n\t'p:spPr': SPPR_SEQUENCE,\n\t'c:spPr': SPPR_SEQUENCE,\n\t'a:spPr': SPPR_SEQUENCE,\n\t'cx:spPr': SPPR_SEQUENCE,\n\t'p:grpSpPr': GRPSPPR_SEQUENCE,\n\t'p:grpSp': GROUP_SHAPE_SEQUENCE,\n\t'p:spTree': GROUP_SHAPE_SEQUENCE,\n\t'p:sp': SP_SEQUENCE,\n\t'a:ln': LN_SEQUENCE,\n\t'a:rPr': RPR_SEQUENCE,\n\t'a:defRPr': RPR_SEQUENCE,\n\t'a:endParaRPr': RPR_SEQUENCE,\n\t'a:tcPr': TCPR_SEQUENCE,\n\t'p:presentation': PRESENTATION_SEQUENCE,\n\t'p:pic': PIC_SEQUENCE,\n\t'p:blipFill': BLIPFILL_SEQUENCE,\n\t'a:blipFill': BLIPFILL_SEQUENCE,\n\t'p:sldMaster': SLIDE_MASTER_SEQUENCE,\n\t'p:sld': SLIDE_SEQUENCE,\n\t'p:cSld': COMMON_SLIDE_DATA_SEQUENCE,\n\t'p:timing': SLIDE_TIMING_SEQUENCE,\n\t'p:txBody': TEXT_BODY_SEQUENCE,\n\t'a:txBody': TEXT_BODY_SEQUENCE,\n}\n","/**\n * Apply DrawingML colour-transform modifiers (`lumMod`/`lumOff`/`shade`/`tint`/\n * `satMod`/`alpha`/…) to a base sRGB colour, returning the *effective* colour a\n * renderer would paint.\n *\n * The read model resolves a `schemeClr`/`srgbClr` reference to its **base** hex\n * and carries the transform children verbatim (so the `theme: 'preserve'` flatten\n * path can re-emit them byte-for-byte). This module is the missing step that\n * turns that base hex + transform list into the final rendered hex, so a consumer\n * never hand-computes a tint/shade again.\n *\n * Colour-space model (verified against PowerPoint output — see\n * `test/read/color-transform.test.js`): the working colour is kept canonical as\n * sRGB between transforms; each transform converts into the space its family\n * operates in, applies, and converts back to sRGB. Transforms apply in **document\n * order** (ECMA-376 §20.1.2.3).\n *\n * - `lumMod` / `lumOff` — luminance (L) in HSL: `L' = L·mod + off`. PowerPoint's\n * \"Lighter/Darker N%\" family.\n * - `satMod` / `satOff` — saturation (S) in HSL.\n * - `hueMod` / `hueOff` — hue (H) in HSL (`hueMod` scales, `hueOff` offsets by\n * degrees). Not exercised by any current source; implemented for completeness.\n * - `shade` — toward black in **linear** RGB: `c' = c·k`.\n * - `tint` — toward white in **linear** RGB: `c' = c·k + (1−k)`.\n * - `alpha` / `alphaMod` / `alphaOff` — opacity, returned alongside the hex\n * (never folded into RGB).\n * - `comp` / `inv` / `gray` / `gamma` / `invGamma` — pass-through for now (no\n * current source needs them; add when one does).\n *\n * All DrawingML percentage values are stored in thousandths of a percent\n * (`100%` → `100000`), so a modifier's fraction is `val / PERCENT_SCALE`.\n */\nimport { ANGLE_UNITS_PER_DEGREE } from '../../units.js'\nimport { isHexColor, stripHash } from '../../hex-color.js'\nimport { parsePercent } from './dom.js'\n\n/** A colour-transform modifier in its read-model form: tag local-name + raw `@val`. */\nexport interface ColorTransform {\n\tname: string\n\tvalue: string | null\n}\n\n/** The effective colour after applying transforms: final sRGB hex, plus opacity when an `alpha*` modifier was present. */\nexport interface EffectiveColor {\n\thex: string\n\talpha?: number\n}\n\nconst clamp01 = (n: number): number => (n < 0 ? 0 : n > 1 ? 1 : n)\n\n/** Parse a 6-hex string (`RRGGBB`, optional `#`) into 0–1 sRGB channels, or `null`. */\nfunction parseHex(hex: string): { r: number; g: number; b: number } | null {\n\tconst h = stripHash(hex)\n\tif (!isHexColor(h)) return null\n\treturn {\n\t\tr: parseInt(h.slice(0, 2), 16) / 255,\n\t\tg: parseInt(h.slice(2, 4), 16) / 255,\n\t\tb: parseInt(h.slice(4, 6), 16) / 255,\n\t}\n}\n\n/** 0–1 sRGB channels → uppercase `RRGGBB`, rounding and clamping each channel. */\nfunction toHex(c: { r: number; g: number; b: number }): string {\n\tconst ch = (v: number): string =>\n\t\tMath.round(clamp01(v) * 255)\n\t\t\t.toString(16)\n\t\t\t.toUpperCase()\n\t\t\t.padStart(2, '0')\n\treturn `${ch(c.r)}${ch(c.g)}${ch(c.b)}`\n}\n\n/** sRGB channel (0–1) → linear-light (gamma decode). */\nfunction srgbToLinear(c: number): number {\n\treturn c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4)\n}\n\n/** Linear-light channel (0–1) → sRGB (gamma encode). */\nfunction linearToSrgb(c: number): number {\n\treturn c <= 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 1 / 2.4) - 0.055\n}\n\n/** sRGB (0–1) → HSL with H in degrees [0,360), S/L in [0,1]. */\nfunction rgbToHsl(c: { r: number; g: number; b: number }): { h: number; s: number; l: number } {\n\tconst { r, g, b } = c\n\tconst max = Math.max(r, g, b)\n\tconst min = Math.min(r, g, b)\n\tconst l = (max + min) / 2\n\tconst d = max - min\n\tif (d === 0) return { h: 0, s: 0, l }\n\tconst s = d / (1 - Math.abs(2 * l - 1))\n\tlet h: number\n\tif (max === r) h = ((g - b) / d) % 6\n\telse if (max === g) h = (b - r) / d + 2\n\telse h = (r - g) / d + 4\n\th *= 60\n\tif (h < 0) h += 360\n\treturn { h, s, l }\n}\n\n/** HSL (H degrees, S/L 0–1) → sRGB (0–1). */\nfunction hslToRgb({ h, s, l }: { h: number; s: number; l: number }): { r: number; g: number; b: number } {\n\tconst c = (1 - Math.abs(2 * l - 1)) * s\n\tconst hp = (((h % 360) + 360) % 360) / 60\n\tconst x = c * (1 - Math.abs((hp % 2) - 1))\n\tconst [r, g, b] =\n\t\thp < 1 ? [c, x, 0] : hp < 2 ? [x, c, 0] : hp < 3 ? [0, c, x] : hp < 4 ? [0, x, c] : hp < 5 ? [x, 0, c] : [c, 0, x]\n\tconst m = l - c / 2\n\treturn { r: r + m, g: g + m, b: b + m }\n}\n\n/**\n * An `a:hslClr` triple → 6-hex sRGB, or `null` when any of the three is unparseable.\n *\n * The colour space is the one `lumMod`/`satMod` already work in — DrawingML's HSL is sRGB-HSL,\n * which is what the transform family below is verified against — so this shares that conversion\n * rather than introducing a second one. Units are the schema's: `@hue` is\n * `a:ST_PositiveFixedAngle`, i.e. 60,000ths of a degree, and `@sat`/`@lum` are `a:ST_Percentage`\n * (see {@link parsePercent}). Saturation and luminance are clamped to 0–1; hue wraps.\n * @param hue - raw `@hue`\n * @param sat - raw `@sat`\n * @param lum - raw `@lum`\n */\nexport function hslClrToHex(hue: string | null, sat: string | null, lum: string | null): string | null {\n\tconst h = hue === null || hue === '' ? null : Number(hue)\n\tconst s = parsePercent(sat)\n\tconst l = parsePercent(lum)\n\tif (h === null || !Number.isFinite(h) || s === null || l === null) return null\n\treturn toHex(hslToRgb({ h: h / ANGLE_UNITS_PER_DEGREE, s: clamp01(s), l: clamp01(l) }))\n}\n\n/**\n * Apply an ordered list of DrawingML colour transforms to a base sRGB hex,\n * returning the effective sRGB hex (and opacity, when an `alpha*` modifier set\n * it). Pure: no DOM, no theme lookup — the caller has already resolved the base\n * colour and extracted each modifier's `{ name, value }`.\n *\n * An unparseable base hex is returned unchanged (with no transforms applied); an\n * unparseable/`null` modifier value is skipped.\n */\nexport function applyColorTransforms(baseHex: string, transforms: ColorTransform[]): EffectiveColor {\n\tconst parsed = parseHex(baseHex)\n\tif (!parsed) return { hex: baseHex }\n\tlet rgb = parsed\n\tlet alpha: number | undefined\n\n\tfor (const { name, value } of transforms) {\n\t\tswitch (name) {\n\t\t\tcase 'lumMod':\n\t\t\tcase 'lumOff': {\n\t\t\t\tconst f = parsePercent(value)\n\t\t\t\tif (f === null) break\n\t\t\t\tconst hsl = rgbToHsl(rgb)\n\t\t\t\thsl.l = clamp01(name === 'lumMod' ? hsl.l * f : hsl.l + f)\n\t\t\t\trgb = hslToRgb(hsl)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'satMod':\n\t\t\tcase 'satOff': {\n\t\t\t\tconst f = parsePercent(value)\n\t\t\t\tif (f === null) break\n\t\t\t\tconst hsl = rgbToHsl(rgb)\n\t\t\t\thsl.s = clamp01(name === 'satMod' ? hsl.s * f : hsl.s + f)\n\t\t\t\trgb = hslToRgb(hsl)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'hueMod':\n\t\t\tcase 'hueOff': {\n\t\t\t\tconst hsl = rgbToHsl(rgb)\n\t\t\t\t// hueMod is a percentage scale; hueOff is an angle in 60000ths of a degree.\n\t\t\t\tif (name === 'hueMod') {\n\t\t\t\t\tconst f = parsePercent(value)\n\t\t\t\t\tif (f === null) break\n\t\t\t\t\thsl.h = (((hsl.h * f) % 360) + 360) % 360\n\t\t\t\t} else {\n\t\t\t\t\tconst n = value === null ? NaN : Number(value)\n\t\t\t\t\tif (!Number.isFinite(n)) break\n\t\t\t\t\thsl.h = (((hsl.h + n / ANGLE_UNITS_PER_DEGREE) % 360) + 360) % 360\n\t\t\t\t}\n\t\t\t\trgb = hslToRgb(hsl)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shade':\n\t\t\tcase 'tint': {\n\t\t\t\tconst k = parsePercent(value)\n\t\t\t\tif (k === null) break\n\t\t\t\tconst lin = { r: srgbToLinear(rgb.r), g: srgbToLinear(rgb.g), b: srgbToLinear(rgb.b) }\n\t\t\t\tconst apply = (c: number): number => clamp01(name === 'shade' ? c * k : c * k + (1 - k))\n\t\t\t\trgb = { r: linearToSrgb(apply(lin.r)), g: linearToSrgb(apply(lin.g)), b: linearToSrgb(apply(lin.b)) }\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'alpha': {\n\t\t\t\tconst f = parsePercent(value)\n\t\t\t\tif (f !== null) alpha = clamp01(f)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'alphaMod': {\n\t\t\t\tconst f = parsePercent(value)\n\t\t\t\tif (f !== null) alpha = clamp01((alpha ?? 1) * f)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'alphaOff': {\n\t\t\t\tconst f = parsePercent(value)\n\t\t\t\tif (f !== null) alpha = clamp01((alpha ?? 1) + f)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\t// comp/inv/gray/gamma/invGamma: pass-through until a source needs them.\n\t\t\tdefault:\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\treturn alpha === undefined ? { hex: toHex(rgb) } : { hex: toHex(rgb), alpha }\n}\n","/**\n * Shared solid-fill read/mutation helpers for DrawingML colour-bearing parents:\n * a run's `a:rPr`, a shape's `p:spPr` / `p:grpSpPr`, and a line's `a:ln`.\n *\n * A parent carries at most one `EG_FillProperties` choice, so setting a solid\n * fill first clears any competing choice, then inserts `a:solidFill` in document\n * order. These helpers never mark a part dirty — callers own that.\n */\nimport { InvalidOptionError } from '../../errors.js'\nimport { isHexColor, stripHash } from '../../hex-color.js'\nimport { FILL_CHOICES } from '../../ooxml/sequence.js'\nimport { checkEnumOrThrow } from '../../ooxml/check-enum.js'\nimport { SCHEME_COLOR_VALUES } from '../../ooxml/st-enums.js'\nimport {\n\tattr,\n\tcreateElement,\n\tfirstChild,\n\tgetOrAddChild,\n\townerDocumentOf,\n\tremoveChildrenByQName,\n\tsetAttr,\n\ttype Element,\n} from './dom.js'\n\n/**\n * The mutually-exclusive fill choices (`EG_FillProperties`); a parent has at most one.\n * Declared in `src/ooxml/sequence.ts`, where the schema sequences that embed it live too.\n */\nexport { FILL_CHOICES }\n\n/** Normalize a 6-hex RGB string (optional leading `#`) to upper-case, or throw. */\nexport function normalizeHex(value: string): string {\n\tconst hex = stripHash(value)\n\tif (!isHexColor(hex))\n\t\tthrow new InvalidOptionError(\n\t\t\t'color/invalid-hex',\n\t\t\t`Expected a 6-digit hex RGB colour, got: ${JSON.stringify(value)}`\n\t\t)\n\treturn hex.toUpperCase()\n}\n\n/**\n * A theme colour token for `a:schemeClr/@val`, or a thrown error. The scheme-colour counterpart of\n * {@link normalizeHex}: a read-model setter that writes a token checks it here, against\n * `ST_SchemeColorVal`, so a misspelled one is refused rather than written into the part.\n */\nexport function schemeToken(value: string): string {\n\treturn checkEnumOrThrow(value, SCHEME_COLOR_VALUES, 'scheme colour token', 'color/invalid-scheme-token')\n}\n\n/** The `@val` of a colour child (`qname`) under `parent/a:solidFill`, or `null`. */\nexport function solidFillColor(parent: Element | null, qname: string): string | null {\n\tconst fill = parent && firstChild(parent, 'a:solidFill')\n\tconst clr = fill && firstChild(fill, qname)\n\treturn clr ? attr(clr, 'val') : null\n}\n\n/**\n * The `@val` of an **already-resolved** colour element, when it is exactly the named kind.\n *\n * The sibling of {@link solidFillColor}, for the callers that hold the colour element itself\n * rather than its parent: a run's `a:highlight` child, a bullet's `a:buClr` child, a picture\n * recolour's `a:duotone` entries. Each of those wrote the `localName` test inline, and each\n * paired it with the same `attr(el, 'val')`.\n *\n * `null` for a different colour kind is the point, not a failure: a `schemeClr` has no literal\n * hex to give, and a caller with no theme context has nothing to resolve it against.\n *\n * @param el - a DrawingML colour element (`a:srgbClr`, `a:schemeClr`, …), or nothing\n * @param kind - the colour element this caller can use\n */\nexport function colorValueIf(el: Element | null | undefined, kind: 'srgbClr' | 'schemeClr' | 'prstClr'): string | null {\n\treturn el && el.localName === kind ? (attr(el, 'val') ?? null) : null\n}\n\n/** A solid colour a read-model setter writes: a 6-hex RGB value, or a theme colour token. */\nexport type SolidFillEdit = { readonly hex: string } | { readonly scheme: string }\n\n/**\n * Whether `container` states a fill of its own: any `EG_FillProperties` choice, solid or not.\n *\n * A container that does decides its own colour. When that choice is not a solid colour\n * (`a:noFill`, a gradient), a resolver reports no colour rather than falling through to one the\n * element would otherwise inherit and does not paint in.\n */\nexport function hasFillChoice(container: Element | null | undefined): container is Element {\n\treturn !!container && FILL_CHOICES.some((qname) => firstChild(container, qname))\n}\n\n/**\n * Clear `container`'s solid fill, or replace its fill with a solid colour, and report whether the\n * container changed.\n *\n * Every read-model paint setter goes through this, so they agree on when a part is dirty. A clear\n * changes something only when there was an `a:solidFill` to remove, and leaves any other fill\n * choice alone. A colour is checked (`normalizeHex`, `schemeToken`) before anything is touched,\n * then replaces whatever fill choice was there.\n * @param container - the element holding the fill, or `null` when it does not exist yet\n * @param edit - the colour to write, or `null` to clear\n * @param getOrAdd - the container, created in document order when absent; called only to write\n * @param after - the successors `a:solidFill` is inserted before\n */\nexport function applySolidFill(container: Element | null, edit: null): boolean\nexport function applySolidFill(\n\tcontainer: Element | null,\n\tedit: SolidFillEdit,\n\tgetOrAdd: () => Element,\n\tafter: readonly string[]\n): boolean\nexport function applySolidFill(\n\tcontainer: Element | null,\n\tedit: SolidFillEdit | null,\n\tgetOrAdd?: () => Element,\n\tafter: readonly string[] = []\n): boolean {\n\tif (edit === null) {\n\t\tif (!container || !firstChild(container, 'a:solidFill')) return false\n\t\tremoveChildrenByQName(container, ['a:solidFill'])\n\t\treturn true\n\t}\n\tconst color =\n\t\t'hex' in edit\n\t\t\t? { qname: 'a:srgbClr', val: normalizeHex(edit.hex) }\n\t\t\t: { qname: 'a:schemeClr', val: schemeToken(edit.scheme) }\n\tconst target = getOrAdd?.() ?? container\n\tif (!target) return false\n\tsetSolidFill(target, after, color)\n\treturn true\n}\n\n/**\n * Replace `container`'s fill with an explicit `a:noFill`, and report whether the container\n * changed. It does not when the container already holds `a:noFill` and no other fill choice.\n * @param container - the element holding the fill, or `null` when it does not exist yet\n * @param getOrAdd - the container, created in document order when absent\n * @param after - the successors `a:noFill` is inserted before\n */\nexport function applyNoFill(container: Element | null, getOrAdd: () => Element, after: readonly string[]): boolean {\n\tconst alreadyNoFill =\n\t\t!!container &&\n\t\t!!firstChild(container, 'a:noFill') &&\n\t\tFILL_CHOICES.every((qname) => qname === 'a:noFill' || !firstChild(container, qname))\n\tif (alreadyNoFill) return false\n\tconst target = getOrAdd()\n\tremoveChildrenByQName(target, FILL_CHOICES)\n\tgetOrAddChild(target, 'a:noFill', after)\n\treturn true\n}\n\n/**\n * Replace `parent`'s solid fill with a single colour element. Any competing fill\n * choice is dropped first, then `a:solidFill` is inserted before `afterOrder`\n * (its schema successors). To *clear* a fill instead, remove `a:solidFill`\n * directly via `removeChildrenByQName`, which leaves any other choice untouched.\n */\nexport function setSolidFill(\n\tparent: Element,\n\tafterOrder: readonly string[],\n\tcolor: { qname: string; val: string }\n): void {\n\tremoveChildrenByQName(parent, FILL_CHOICES)\n\tconst fill = getOrAddChild(parent, 'a:solidFill', afterOrder)\n\tconst clr = createElement(ownerDocumentOf(parent), color.qname)\n\tsetAttr(clr, 'val', color.val)\n\tfill.appendChild(clr)\n}\n","/**\n * The ECMA-376 preset colour table (`a:prstClr/@val` → literal RGB).\n *\n * `ST_PresetColorVal` (§20.1.10.47) enumerates 190 names, and the standard gives each one an\n * RGB triple. They are the HTML/CSS named colours: every value in the enumeration has the same\n * RGB here as the CSS colour of the same name, and the 190 names collapse to the 140 distinct\n * CSS names below through three mechanical spelling rules the enumeration adds on top —\n *\n * - abbreviated prefixes: `dk*`/`lt*`/`med*` alongside `dark*`/`light*`/`medium*`\n * (`dkSlateBlue` is `darkSlateBlue`), and only as a *prefix* — `medium…` is not `mediumium…`;\n * - both spellings of grey: `dimGrey` is `dimGray`;\n * - case: the enumeration is camelCase, the table below is folded to lower case.\n *\n * So the table holds one row per colour rather than one per spelling, and {@link presetColorHex}\n * normalizes a name into it. That is the difference between 140 hand-checked constants and 190,\n * and it makes the abbreviation rule something a reader can see rather than something spread\n * across fifty near-duplicate rows.\n *\n * This is spec data, not observed behaviour: the values come from the enumeration's own\n * documentation, and the table is asserted complete against the schema's 190-value list in\n * `test/read/preset-color.test.js` — a name the reader cannot resolve is a hole in the table,\n * and that test is what finds it.\n */\n\n/**\n * Canonical (lower-case, unabbreviated, `gray`-spelled) preset colour name → 6-hex RGB.\n * Reach it through {@link presetColorHex}, which does the normalizing.\n */\nconst PRESET_COLOR_HEX: Readonly<Record<string, string>> = {\n\taliceblue: 'F0F8FF',\n\tantiquewhite: 'FAEBD7',\n\taqua: '00FFFF',\n\taquamarine: '7FFFD4',\n\tazure: 'F0FFFF',\n\tbeige: 'F5F5DC',\n\tbisque: 'FFE4C4',\n\tblack: '000000',\n\tblanchedalmond: 'FFEBCD',\n\tblue: '0000FF',\n\tblueviolet: '8A2BE2',\n\tbrown: 'A52A2A',\n\tburlywood: 'DEB887',\n\tcadetblue: '5F9EA0',\n\tchartreuse: '7FFF00',\n\tchocolate: 'D2691E',\n\tcoral: 'FF7F50',\n\tcornflowerblue: '6495ED',\n\tcornsilk: 'FFF8DC',\n\tcrimson: 'DC143C',\n\tcyan: '00FFFF',\n\tdarkblue: '00008B',\n\tdarkcyan: '008B8B',\n\tdarkgoldenrod: 'B8860B',\n\tdarkgray: 'A9A9A9',\n\tdarkgreen: '006400',\n\tdarkkhaki: 'BDB76B',\n\tdarkmagenta: '8B008B',\n\tdarkolivegreen: '556B2F',\n\tdarkorange: 'FF8C00',\n\tdarkorchid: '9932CC',\n\tdarkred: '8B0000',\n\tdarksalmon: 'E9967A',\n\tdarkseagreen: '8FBC8F',\n\tdarkslateblue: '483D8B',\n\tdarkslategray: '2F4F4F',\n\tdarkturquoise: '00CED1',\n\tdarkviolet: '9400D3',\n\tdeeppink: 'FF1493',\n\tdeepskyblue: '00BFFF',\n\tdimgray: '696969',\n\tdodgerblue: '1E90FF',\n\tfirebrick: 'B22222',\n\tfloralwhite: 'FFFAF0',\n\tforestgreen: '228B22',\n\tfuchsia: 'FF00FF',\n\tgainsboro: 'DCDCDC',\n\tghostwhite: 'F8F8FF',\n\tgold: 'FFD700',\n\tgoldenrod: 'DAA520',\n\tgray: '808080',\n\tgreen: '008000',\n\tgreenyellow: 'ADFF2F',\n\thoneydew: 'F0FFF0',\n\thotpink: 'FF69B4',\n\tindianred: 'CD5C5C',\n\tindigo: '4B0082',\n\tivory: 'FFFFF0',\n\tkhaki: 'F0E68C',\n\tlavender: 'E6E6FA',\n\tlavenderblush: 'FFF0F5',\n\tlawngreen: '7CFC00',\n\tlemonchiffon: 'FFFACD',\n\tlightblue: 'ADD8E6',\n\tlightcoral: 'F08080',\n\tlightcyan: 'E0FFFF',\n\tlightgoldenrodyellow: 'FAFAD2',\n\tlightgray: 'D3D3D3',\n\tlightgreen: '90EE90',\n\tlightpink: 'FFB6C1',\n\tlightsalmon: 'FFA07A',\n\tlightseagreen: '20B2AA',\n\tlightskyblue: '87CEFA',\n\tlightslategray: '778899',\n\tlightsteelblue: 'B0C4DE',\n\tlightyellow: 'FFFFE0',\n\tlime: '00FF00',\n\tlimegreen: '32CD32',\n\tlinen: 'FAF0E6',\n\tmagenta: 'FF00FF',\n\tmaroon: '800000',\n\tmediumaquamarine: '66CDAA',\n\tmediumblue: '0000CD',\n\tmediumorchid: 'BA55D3',\n\tmediumpurple: '9370DB',\n\tmediumseagreen: '3CB371',\n\tmediumslateblue: '7B68EE',\n\tmediumspringgreen: '00FA9A',\n\tmediumturquoise: '48D1CC',\n\tmediumvioletred: 'C71585',\n\tmidnightblue: '191970',\n\tmintcream: 'F5FFFA',\n\tmistyrose: 'FFE4E1',\n\tmoccasin: 'FFE4B5',\n\tnavajowhite: 'FFDEAD',\n\tnavy: '000080',\n\toldlace: 'FDF5E6',\n\tolive: '808000',\n\tolivedrab: '6B8E23',\n\torange: 'FFA500',\n\torangered: 'FF4500',\n\torchid: 'DA70D6',\n\tpalegoldenrod: 'EEE8AA',\n\tpalegreen: '98FB98',\n\tpaleturquoise: 'AFEEEE',\n\tpalevioletred: 'DB7093',\n\tpapayawhip: 'FFEFD5',\n\tpeachpuff: 'FFDAB9',\n\tperu: 'CD853F',\n\tpink: 'FFC0CB',\n\tplum: 'DDA0DD',\n\tpowderblue: 'B0E0E6',\n\tpurple: '800080',\n\tred: 'FF0000',\n\trosybrown: 'BC8F8F',\n\troyalblue: '4169E1',\n\tsaddlebrown: '8B4513',\n\tsalmon: 'FA8072',\n\tsandybrown: 'F4A460',\n\tseagreen: '2E8B57',\n\tseashell: 'FFF5EE',\n\tsienna: 'A0522D',\n\tsilver: 'C0C0C0',\n\tskyblue: '87CEEB',\n\tslateblue: '6A5ACD',\n\tslategray: '708090',\n\tsnow: 'FFFAFA',\n\tspringgreen: '00FF7F',\n\tsteelblue: '4682B4',\n\ttan: 'D2B48C',\n\tteal: '008080',\n\tthistle: 'D8BFD8',\n\ttomato: 'FF6347',\n\tturquoise: '40E0D0',\n\tviolet: 'EE82EE',\n\twheat: 'F5DEB3',\n\twhite: 'FFFFFF',\n\twhitesmoke: 'F5F5F5',\n\tyellow: 'FFFF00',\n\tyellowgreen: '9ACD32',\n}\n\n/**\n * Resolve an `a:prstClr/@val` preset colour name to its 6-hex RGB, or `null` when the name is\n * not one of the 190 `ST_PresetColorVal` values.\n *\n * Lenient about case for the same reason the rest of the read path is: the input is a file\n * someone else wrote, and a producer that spelled `Black` has still said which colour it meant.\n * A name that is not in the enumeration at all resolves to `null` rather than to a guess, so the\n * caller reports \"no colour\" instead of painting an invented one.\n * @param name - the raw attribute value, or `null` when the attribute is absent\n */\nexport function presetColorHex(name: string | null): string | null {\n\tif (!name) return null\n\t// Case first, so the abbreviation rules below need one spelling each rather than two. The\n\t// `med` rule needs the guard and the other two do not: no canonical name starts with `dk` or\n\t// `lt`, but `medium*` does start with `med`, and expanding it again yields `mediumium*`.\n\tconst canonical = name\n\t\t.toLowerCase()\n\t\t.replace(/grey/g, 'gray')\n\t\t.replace(/^dk/, 'dark')\n\t\t.replace(/^lt/, 'light')\n\t\t.replace(/^med(?!ium)/, 'medium')\n\treturn PRESET_COLOR_HEX[canonical] ?? null\n}\n","/**\n * Theme colour resolution: turning a DrawingML colour reference or a style-matrix reference into\n * something literal.\n *\n * Two maps do the colour work. A scheme token (`accent1`, `bg1`, …) routes through the master's\n * `clrMap` to a `clrScheme` slot, whose literal RGB is the answer; child colour transforms\n * (`lumMod`/`shade`/`alpha`/…) are carried through untouched rather than computed, so a caller\n * that re-emits them renders identically. A style-matrix reference (`a:fillRef`/`a:lnRef`) instead\n * indexes the theme's `fmtScheme`, and resolves to a deep-cloned entry with its `phClr`\n * placeholder substituted.\n *\n * Everything here is **pure**: it reads a DOM and builds detached elements, and mutates nothing\n * the caller passes in. Two very different consumers depend on that:\n *\n * - the read model's colour getters, which resolve a colour to report it;\n * - the import-time flatten passes (`read/api/ops/flatten.ts`), which resolve the same colour in\n * order to *bake* it into a slide.\n *\n * They must agree, so they share this. The passes that write results back into a part live with\n * the other import operations, not here — this module deliberately has no mutating exports.\n * Placeholder-inheritance resolution (what a placeholder gets from its layout/master chain) is\n * its own concern and lives in `placeholder-inherit.ts`.\n */\nimport { COLOR_MAP_TOKENS, THEME_COLOR_SLOTS } from '../../ooxml/st-enums.js'\nimport { hslClrToHex } from './color-transform.js'\nimport { presetColorHex } from './preset-color.js'\nimport {\n\tOOXML_NS,\n\tattr,\n\tchildElements,\n\tcreateElement,\n\tdescendantsByTag,\n\tfirstChild,\n\tfirstChildElement,\n\tnumberAttr,\n\townerDocumentOf,\n\treplaceInParent,\n\tsetAttr,\n\ttype Element,\n} from './dom.js'\n\n/** Scheme tokens that name a `clrScheme` slot directly, bypassing the `clrMap`. */\nconst DIRECT_SLOT_TOKENS = new Set(['dk1', 'lt1', 'dk2', 'lt2'])\n\n/**\n * The colour-resolution context: the two maps that turn a DrawingML colour\n * reference into a literal hex — the effective colour map (token → `clrScheme`\n * slot, honouring any slide `clrMapOvr`) and the resolved colour scheme (slot →\n * 6-hex RGB). Shared by the read-model colour getters and `ThemeContext`.\n */\nexport interface ColorContext {\n\tclrMap: Map<string, string>\n\tclrScheme: Map<string, string>\n}\n\n/**\n * The source theme subgraph a slide, notes slide, layout or master resolves against: the\n * {@link ColorContext} maps, the live `a:fmtScheme` for style-matrix resolution, and the roots\n * of the inheritance chain a placeholder reads through.\n *\n * Every root here is **read-only** — nothing in this module or in `placeholder-inherit.ts`\n * mutates one. The import-time flatten pass extends this with the one field it needs to write\n * from (see `FlattenContext` in `read/api/ops/flatten.ts`).\n */\nexport interface ThemeContext extends ColorContext {\n\tfmtScheme: Element | null\n\t/**\n\t * The source `slideLayout` root element, for resolving what a placeholder inherits.\n\t * `null`/absent disables the layout tier.\n\t */\n\tlayoutRoot?: Element | null\n\t/**\n\t * The source `slideMaster` root element, for resolving placeholder inheritance via its\n\t * placeholder `a:lstStyle` and `p:txStyles`.\n\t */\n\tmasterRoot?: Element | null\n\t/**\n\t * The theme's `a:fontScheme`, for resolving a `+mj-*`/`+mn-*` major/minor font\n\t * token (the placeholder-inherited typeface chain bottoms out in one) to a\n\t * literal face name via `resolveThemeFont` in this module. (Named rather than linked: it is\n\t * internal, so a reference link to it resolves to nothing in the published reference.)\n\t * `null`/absent leaves such a\n\t * token unresolved.\n\t */\n\tfontScheme?: Element | null\n\t/**\n\t * The notesMaster's `p:notesStyle` (a `CT_TextListStyle`), for resolving the\n\t * character properties a *notes-body* run inherits when it sets none of its own.\n\t * Only ever set on a notes context (see `resolveNotesColorContext`); on a slide\n\t * context it is absent, so the slide placeholder chain (layout/master\n\t * `a:lstStyle` → `p:txStyles`) is unaffected. It is the notes analogue of the\n\t * master `p:txStyles` category style, keyed by level rather than placeholder\n\t * type. Read-only — never mutated.\n\t */\n\tnotesStyle?: Element | null\n\t/**\n\t * The presentation's `p:defaultTextStyle` (a `CT_TextListStyle` from\n\t * `presentation.xml`), keyed by level — PowerPoint's lowest-priority text\n\t * fallback, applying to any run (placeholder or not) that resolves nothing\n\t * above it. Only ever set on a *slide* context (see `resolveSlideColorContext`);\n\t * absent on notes/master/layout contexts, so their chains are unaffected. A table\n\t * cell's text is read against a copy that holds the slide master's `p:otherStyle`\n\t * here instead, the tier PowerPoint resolves cell text through (`TableCell.textFrame`).\n\t * Read-only — never mutated.\n\t */\n\tdefaultTextStyle?: Element | null\n\t/**\n\t * Memo for the placeholder lookups `findPlaceholder` (`read/oxml/placeholder-inherit.ts`)\n\t * performs against\n\t * {@link layoutRoot} and {@link masterRoot}, keyed by tier, placeholder type and `idx`.\n\t *\n\t * The lookup is a full subtree scan, and reading one run's five inherited properties used\n\t * to perform ten of them: each property walks the tier chain, and each tier walk scans a\n\t * layout and a master. The answer depends only on the roots and the `(type, idx)` asked\n\t * for, and the roots on a context never change — so it is computed once per context.\n\t *\n\t * The memo lives here rather than in a module-level cache keyed by the root element\n\t * because that is what scopes it correctly: a context is built per `Slide`/`TemplatePart`\n\t * proxy, so the memo lasts exactly as long as the captured roots it agrees with, and a\n\t * caller who mutates the deck and reads again gets a fresh context along with a fresh\n\t * everything else. Written by `placeholder-inherit.ts` and read by nothing else.\n\t */\n\tplaceholderMemo?: Map<string, Element | null>\n}\n\n/** Parse an `a:clrScheme` into slot → 6-hex RGB, reading `srgbClr`/`sysClr`. */\nexport function parseClrScheme(clrScheme: Element | null): Map<string, string> {\n\tconst out = new Map<string, string>()\n\tif (!clrScheme) return out\n\tfor (const slot of THEME_COLOR_SLOTS) {\n\t\tconst slotEl = firstChild(clrScheme, `a:${slot}`)\n\t\tconst hex = slotEl && colorElementHex(firstChildElement(slotEl))\n\t\tif (hex) out.set(slot, hex)\n\t}\n\treturn out\n}\n\n/**\n * Parse the `bg1`/`tx1`/`bg2`/`tx2`/`accent*`/`hlink`/`folHlink` attributes of an\n * `a:clrMap` (or `a:overrideClrMapping`) into token → slot.\n */\nexport function parseClrMap(clrMap: Element | null): Map<string, string> {\n\tconst out = new Map<string, string>()\n\tif (!clrMap) return out\n\tfor (const token of COLOR_MAP_TOKENS) {\n\t\tconst slot = attr(clrMap, token)\n\t\tif (slot) out.set(token, slot)\n\t}\n\treturn out\n}\n\n/** Resolve a scheme token (`accent1`, `bg1`, `dk1`, …) to a 6-hex RGB, or `null`. */\nexport function resolveSchemeToken(token: string, ctx: ColorContext): string | null {\n\tif (token === 'phClr') return null\n\tconst slot = DIRECT_SLOT_TOKENS.has(token) ? token : ctx.clrMap.get(token)\n\treturn slot ? (ctx.clrScheme.get(slot) ?? null) : null\n}\n\n/** Whether `el` is a DrawingML element with the given local name. */\nexport function isA(el: Element | null, local: string): boolean {\n\treturn !!el && el.namespaceURI === OOXML_NS.a && el.localName === local\n}\n\n/**\n * The literal RGB of a *non-scheme* colour element, or `null` for one that needs the theme\n * (`a:schemeClr`) or that this reader does not resolve.\n *\n * Four of `a:EG_ColorChoice`'s six members land here. `a:scrgbClr` is the one deliberately left\n * out: its channels are percentages of a colour space the schema does not pin down, so whether\n * `50%` is linear-light or sRGB-encoded decides the answer and neither the schema nor the\n * transform work in `color-transform.ts` settles it. Guessing would produce a colour that is\n * wrong by a gamma curve and says nothing about it, which is worse than reporting no colour.\n * Closing it needs a render oracle — a deck with an `a:scrgbClr` fill authored in PowerPoint\n * and the painted pixel read back — not a reading of the schema.\n */\nfunction colorElementHex(color: Element | null): string | null {\n\tif (!color) return null\n\tif (isA(color, 'srgbClr')) return attr(color, 'val')\n\tif (isA(color, 'sysClr')) return attr(color, 'lastClr') ?? attr(color, 'val')\n\tif (isA(color, 'prstClr')) return presetColorHex(attr(color, 'val'))\n\tif (isA(color, 'hslClr')) return hslClrToHex(attr(color, 'hue'), attr(color, 'sat'), attr(color, 'lum'))\n\treturn null\n}\n\n/**\n * The `a:themeElements` of a theme part's root, or `null` when either is absent.\n *\n * Three walks read it: the `Theme` accessor, the by-partname `themeElementsOf` the context\n * builders share, and `resolveSlideThemeParts`.\n */\nexport function themeElementsOfRoot(themeRoot: Element | null): Element | null {\n\treturn themeRoot ? firstChild(themeRoot, 'a:themeElements') : null\n}\n\n/** A colour reference resolved to a literal base RGB plus its transform children. */\nexport interface ResolvedColorRef {\n\thex: string\n\ttransforms: Element[]\n}\n\n/**\n * Resolve a DrawingML colour element to a literal `{ hex, transforms }`, routing\n * `a:schemeClr` through the context. Returns `null` when the base cannot be made\n * literal (unmapped token, or a colour model we do not flatten).\n *\n * Five of `a:EG_ColorChoice`'s six members resolve: `a:srgbClr`, `a:sysClr`, `a:schemeClr`,\n * `a:prstClr` (through the {@link presetColorHex} table) and `a:hslClr`. `a:scrgbClr` does not —\n * see {@link colorElementHex} for why that one is a `null` rather than a guess.\n */\nexport function resolveColor(color: Element | null, ctx: ColorContext): ResolvedColorRef | null {\n\tif (!color) return null\n\tconst transforms = childElements(color)\n\tif (isA(color, 'srgbClr')) {\n\t\tconst hex = attr(color, 'val')\n\t\treturn hex ? { hex, transforms } : null\n\t}\n\tif (isA(color, 'sysClr') || isA(color, 'prstClr') || isA(color, 'hslClr')) {\n\t\tconst hex = colorElementHex(color)\n\t\treturn hex ? { hex, transforms } : null\n\t}\n\tif (isA(color, 'schemeClr')) {\n\t\tconst token = attr(color, 'val')\n\t\tconst hex = token ? resolveSchemeToken(token, ctx) : null\n\t\treturn hex ? { hex, transforms } : null\n\t}\n\treturn null\n}\n\n/**\n * Resolve a `+mj-*`/`+mn-*` major/minor font token against a theme `a:fontScheme`\n * to a literal typeface name. A non-token `typeface` (an already-literal face) is\n * returned verbatim. `null` when `typeface` is absent, or when a token cannot be\n * resolved (no `fontScheme`, or the indexed major/minor script slot is empty).\n * The script suffix selects the scheme child: `lt`→`a:latin`, `ea`→`a:ea`,\n * `cs`→`a:cs`.\n */\nexport function resolveThemeFont(typeface: string | null, fontScheme: Element | null): string | null {\n\tif (!typeface) return null\n\tconst match = /^\\+(mj|mn)-(lt|ea|cs)$/.exec(typeface)\n\tif (!match) return typeface\n\tif (!fontScheme) return null\n\tconst font = firstChild(fontScheme, match[1] === 'mj' ? 'a:majorFont' : 'a:minorFont')\n\tconst childName = match[2] === 'lt' ? 'a:latin' : match[2] === 'ea' ? 'a:ea' : 'a:cs'\n\tconst child = font && firstChild(font, childName)\n\tconst resolved = child && attr(child, 'typeface')\n\treturn resolved || null\n}\n\n/**\n * Swap one colour element for another, MOVING the old element's transform children onto the new\n * one — and, optionally, seeding it with a set of transforms of its own first.\n *\n * The move is the whole rule the flatten path exists to preserve: only the base reference is\n * swapped, never the transform math. Three sites implemented it and a fourth cloned instead of\n * moving, each with its own `while (old.firstChild) …` loop — duplication of exactly the one\n * invariant that must not vary.\n *\n * Transform ORDER matters and is the reason `seed` is separate: `substitutePhClr` puts the\n * theme reference's own `lumMod`/`alpha` ahead of the ones the `phClr` carried, because the\n * reference's are the outer adjustment.\n * @param old - the element being replaced; it is detached from its parent\n * @param qname - the replacement's qualified name, e.g. `a:srgbClr`\n * @param val - the replacement's `@val`\n * @param seed - transforms to place on the replacement before the moved ones, deep-cloned\n * @returns the replacement element\n */\nexport function replaceColorElement(old: Element, qname: string, val: string, seed: readonly Element[] = []): Element {\n\tconst replacement = createElement(ownerDocumentOf(old), qname)\n\tsetAttr(replacement, 'val', val)\n\tfor (const transform of seed) replacement.appendChild(transform.cloneNode(true))\n\twhile (old.firstChild) replacement.appendChild(old.firstChild)\n\treplaceInParent(old, replacement)\n\treturn replacement\n}\n\n/** Replace every `phClr` under `el` with the ref colour (ref transforms first, then the `phClr`'s own). */\nexport function substitutePhClr(el: Element, ref: ResolvedColorRef): void {\n\tfor (const phClr of descendantsByTag(el, OOXML_NS.a, 'schemeClr')) {\n\t\tif (attr(phClr, 'val') !== 'phClr') continue\n\t\treplaceColorElement(phClr, 'a:srgbClr', ref.hex, ref.transforms)\n\t}\n}\n\n/** The `idx`-th entry (1-based) of a `fmtScheme` style list, deep-cloned, or `null`. */\nexport function fmtEntry(ctx: ThemeContext, listName: string, idx: number): Element | null {\n\tconst list = ctx.fmtScheme && firstChild(ctx.fmtScheme, listName)\n\tif (!list || idx < 1) return null\n\tconst entry = childElements(list)[idx - 1]\n\treturn entry ? (entry.cloneNode(true) as Element) : null\n}\n\n/**\n * Build the explicit fill element a `p:style` `a:fillRef` resolves to — the indexed\n * `fmtScheme` `fillStyleLst`/`bgFillStyleLst` entry (deep-cloned) with its `phClr`\n * replaced by the ref's resolved colour. Pure: mutates neither the ref nor the\n * theme. `null` when the ref is absent, `idx` is 0/unset, or the entry or its\n * colour cannot be resolved. Shared by the flatten path and the read-model\n * `resolveStyleFillColor` getter so both see the same fill.\n */\nexport function styleRefFill(fillRef: Element | null, ctx: ThemeContext): Element | null {\n\tif (!fillRef) return null\n\tconst idx = numberAttr(fillRef, 'idx')\n\tif (idx === null || idx <= 0) return null\n\t// idx >= 1000 selects bgFillStyleLst (offset by 1000); otherwise fillStyleLst.\n\tconst fill = idx >= 1000 ? fmtEntry(ctx, 'a:bgFillStyleLst', idx - 1000) : fmtEntry(ctx, 'a:fillStyleLst', idx)\n\tconst ref = resolveColor(firstChildElement(fillRef), ctx)\n\tif (!fill || !ref) return null\n\tsubstitutePhClr(fill, ref)\n\treturn fill\n}\n\n/**\n * Build the explicit `a:ln` element a `p:style` `a:lnRef` resolves to — the indexed\n * `fmtScheme` `lnStyleLst` entry (deep-cloned) with its `phClr` replaced by the\n * ref's resolved colour. Pure; the line/read counterpart of {@link styleRefFill}.\n */\nexport function styleRefLine(lnRef: Element | null, ctx: ThemeContext): Element | null {\n\tif (!lnRef) return null\n\tconst idx = numberAttr(lnRef, 'idx')\n\tif (idx === null || idx <= 0) return null\n\tconst ln = fmtEntry(ctx, 'a:lnStyleLst', idx)\n\tconst ref = resolveColor(firstChildElement(lnRef), ctx)\n\tif (!ln || !ref) return null\n\tsubstitutePhClr(ln, ref)\n\treturn ln\n}\n","/**\n * Small DOM helpers shared by the read-model slide/import paths.\n *\n * Each works on a live OOXML node alone -- no package state -- which is why they sit outside\n * `Presentation` rather than as private methods on it. All but {@link reassignDrawingIds} are\n * pure queries; that one rewrites the ids in the subtrees it is handed.\n */\n\nimport type { Part } from '../opc/part.js'\nimport {\n\tELEMENT_NODE,\n\tOOXML_NS,\n\tattr,\n\tfirstChild,\n\tfirstChildElement,\n\tnumberValue,\n\tsetAttr,\n\ttype Element,\n} from './dom.js'\n\n/**\n * The `p:cSld` of a slide/layout/master/notes part root.\n *\n * Takes a nullable root and returns a nullable element so a caller can chain from\n * `part?.dom.documentElement` without a guard of its own — which is what a dozen callers were\n * writing by hand, each in a slightly different spelling (`root && …`, `root ? … : null`).\n */\nexport function cSldOf(root: Element | null | undefined): Element | null {\n\treturn root ? firstChild(root, 'p:cSld') : null\n}\n\n/** The `p:spTree` of a slide/layout/master/notes part root, through its `p:cSld`. */\nexport function spTreeOf(root: Element | null | undefined): Element | null {\n\tconst cSld = cSldOf(root)\n\treturn cSld ? firstChild(cSld, 'p:spTree') : null\n}\n\n/**\n * The `p:nvPr` of a shape, whichever `*nvPr` wrapper its kind uses.\n *\n * The wrapper's name varies by shape kind — `p:nvSpPr` on a `p:sp`, `p:nvPicPr` on a `p:pic`,\n * `p:nvGraphicFramePr`, `p:nvCxnSpPr`, `p:nvGrpSpPr` — but it is always the shape's first child\n * element, and `p:nvPr` is always inside it. Taking the first child element rather than naming\n * the wrapper is what lets one helper serve every kind; the callers that named `p:nvSpPr`\n * silently returned null on a picture.\n */\nexport function nvPrOf(shape: Element): Element | null {\n\tconst nv = firstChildElement(shape)\n\treturn nv ? firstChild(nv, 'p:nvPr') : null\n}\n\n/** The `p:cSld@name` of a slide/layout/master part (`''` when absent). */\nexport function cSldName(part: Part | undefined): string {\n\tconst cSld = cSldOf(part?.dom.documentElement)\n\treturn (cSld && attr(cSld, 'name')) ?? ''\n}\n\n/**\n * Whether a `p:spTree` child is one of the tree's own children rather than a shape:\n * `p:nvGrpSpPr` and `p:grpSpPr` before the shapes, `p:extLst` after them.\n *\n * `CT_GroupShape` sequences `nvGrpSpPr, grpSpPr, (shape)*, extLst?`, so all three are\n * positional and none of them is something a shape walk should return. Three helpers below\n * asked this question and only one of them excluded `p:extLst`, so `carriedDecorations`\n * reported it as a decoration to carry -- and the slide importer inserts each of those BEFORE\n * the destination's shapes, which puts an `extLst` where the content model has none and makes\n * the part invalid. The read corpus holds no direct `p:spTree/p:extLst` at all, across 776\n * shape trees, so nothing existing could have caught it.\n */\nfunction isSpTreeOwnChild(el: Element): boolean {\n\treturn (\n\t\tel.namespaceURI === OOXML_NS.p &&\n\t\t(el.localName === 'nvGrpSpPr' || el.localName === 'grpSpPr' || el.localName === 'extLst')\n\t)\n}\n\n/** Whether a `p:spTree` child is a placeholder shape (its `*nvPr` carries a `p:ph`). */\nfunction isPlaceholderShape(shape: Element): boolean {\n\tconst nvPr = nvPrOf(shape)\n\treturn !!(nvPr && firstChild(nvPr, 'p:ph'))\n}\n\n/** The decorative shapes on a layout/master `p:spTree`: every shape child except placeholders. */\nexport function carriedDecorations(root: Element | null): Element[] {\n\tconst spTree = spTreeOf(root)\n\tif (!spTree) return []\n\tconst out: Element[] = []\n\tfor (let node = spTree.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\tconst el = node as Element\n\t\tif (isSpTreeOwnChild(el) || isPlaceholderShape(el)) continue\n\t\tout.push(el)\n\t}\n\treturn out\n}\n\n/**\n * The `n`-th shape child of a `p:spTree` in document (z-)order, skipping the tree's own\n * children. Returns `null` when `n` is past the last shape (the caller then appends).\n */\nexport function nthShapeChild(spTree: Element, n: number): Element | null {\n\tlet i = 0\n\tfor (let node = spTree.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\tconst el = node as Element\n\t\tif (isSpTreeOwnChild(el)) continue\n\t\tif (i === n) return el\n\t\ti++\n\t}\n\treturn null\n}\n\n/** The first shape child of a `p:spTree` (skipping the tree's own children), or `null`. */\nexport function firstShapeChild(spTree: Element): Element | null {\n\tfor (let node = spTree.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\tconst el = node as Element\n\t\tif (!isSpTreeOwnChild(el)) return el\n\t}\n\treturn null\n}\n\n/** One past the highest drawing id (`p:cNvPr/@id`) under `root`, and never less than 2. */\nexport function nextDrawingId(root: Element | null | undefined): number {\n\tlet max = 1\n\tif (root) {\n\t\tfor (const cNvPr of root.getElementsByTagNameNS(OOXML_NS.p, 'cNvPr')) {\n\t\t\tconst id = numberValue(attr(cNvPr, 'id'))\n\t\t\tif (id !== null && id > max) max = id\n\t\t}\n\t}\n\treturn max + 1\n}\n\n/**\n * Give every drawing in `subtrees` a fresh id counting up from `nextId`, repoint each connector\n * binding (`a:stCxn`/`a:endCxn`) that named a drawing inside them, and drop each binding that named\n * a drawing outside them.\n *\n * For shapes being carried into another tree, whose source ids mean nothing there. A drawing id is\n * what an animation's `spid` and a connector's bindings name a shape by, so a carried shape that\n * kept its id could share it with a shape already on the slide, and a binding inside a renumbered\n * subtree that kept the old id named a different shape. A binding to a drawing that was not carried\n * has nothing to name in the new tree: kept, its source id named whatever shape holds that id there,\n * including one inside the carried subtree once renumbering hands out small ids. The connector keeps\n * its geometry and lands unbound, which is how PowerPoint leaves a connector whose shape is deleted.\n *\n * Pass every subtree carried together, so a connector bound to a sibling subtree is repointed too.\n * @returns the next unused id, and each old id's new one (for remapping a carried animation's `spid`)\n */\nexport function reassignDrawingIds(\n\tsubtrees: readonly Element[],\n\tnextId: number\n): { next: number; map: Map<number, number> } {\n\tconst map = new Map<number, number>()\n\tlet next = nextId\n\tfor (const root of subtrees) {\n\t\tfor (const cNvPr of root.getElementsByTagNameNS(OOXML_NS.p, 'cNvPr')) {\n\t\t\tconst oldId = numberValue(attr(cNvPr, 'id'))\n\t\t\tif (oldId !== null) map.set(oldId, next)\n\t\t\tsetAttr(cNvPr, 'id', String(next++))\n\t\t}\n\t}\n\tfor (const root of subtrees) {\n\t\tfor (const local of ['stCxn', 'endCxn']) {\n\t\t\t// Copied out first: removing a binding from a live collection skips the one after it.\n\t\t\tfor (const binding of Array.from(root.getElementsByTagNameNS(OOXML_NS.a, local))) {\n\t\t\t\tconst oldId = numberValue(attr(binding, 'id'))\n\t\t\t\tconst newId = oldId === null ? undefined : map.get(oldId)\n\t\t\t\tif (newId === undefined) binding.parentNode?.removeChild(binding)\n\t\t\t\telse setAttr(binding, 'id', String(newId))\n\t\t\t}\n\t\t}\n\t}\n\treturn { next, map }\n}\n\n/** Every drawing id (`p:cNvPr/@id`) in `root`'s subtree: the shape itself, or a group and everything in it. */\nexport function drawingIdsIn(root: Element): Set<number> {\n\tconst ids = new Set<number>()\n\tfor (const cNvPr of root.getElementsByTagNameNS(OOXML_NS.p, 'cNvPr')) {\n\t\tconst id = numberValue(attr(cNvPr, 'id'))\n\t\tif (id !== null) ids.add(id)\n\t}\n\treturn ids\n}\n\n/**\n * Drop every connector binding (`a:stCxn`/`a:endCxn`) under `root` that names one of `ids`. The\n * connector keeps its geometry and that end lands unbound, as in {@link reassignDrawingIds}.\n *\n * For shapes being removed: PowerPoint keeps a binding to a missing id through its own save, and\n * its object model fails reading the shape the connector claims to be attached to.\n */\nexport function unbindConnectors(root: Element, ids: ReadonlySet<number>): void {\n\tfor (const local of ['stCxn', 'endCxn']) {\n\t\t// Copied out first: removing a binding from a live collection skips the one after it.\n\t\tfor (const binding of Array.from(root.getElementsByTagNameNS(OOXML_NS.a, local))) {\n\t\t\tconst id = numberValue(attr(binding, 'id'))\n\t\t\tif (id !== null && ids.has(id)) binding.parentNode?.removeChild(binding)\n\t\t}\n\t}\n}\n\n/** Collect `node` and all its descendant elements (document order) into `out`. */\nexport function collectElements(node: Element, out: Element[]): void {\n\tout.push(node)\n\tfor (let child = node.firstChild; child; child = child.nextSibling) {\n\t\tif (child.nodeType === ELEMENT_NODE) collectElements(child as Element, out)\n\t}\n}\n","/**\n * Resolving what a placeholder shape *inherits* from its source layout/master chain.\n *\n * A placeholder that sets none of its own colour, size, geometry, anchor or list style takes\n * each from a chain: the layout placeholder's `a:lstStyle`, then the master placeholder's, then\n * the master's `p:txStyles` category style (and, on a notes context, the notesMaster\n * `p:notesStyle`). Every function here answers \"what would this placeholder get?\" — none of them\n * writes anything.\n *\n * **Two callers, one answer.** The read model's getters (`Run.resolvedColor`,\n * `TextFrame.resolvedAnchor`, the font getters) and the import-time flatten passes\n * (`read/api/ops/flatten.ts`, which bakes the inherited values onto a slide so they survive a\n * rebind to a different master) both ask the same questions. They must not answer them\n * differently: if the getter and the bake disagreed, a caller would see one colour before export\n * and another in the file. Sharing this module is what makes that structurally impossible.\n *\n * This module is pure — mutation lives in the flatten pass, which is also why it sits in\n * `read/oxml/` (substrate) rather than `read/api/ops/`.\n */\n\nimport { attr, descendantsByTag, firstChild, firstChildElement, OOXML_NS, type Element } from './dom.js'\nimport { FILL_CHOICES } from './fill.js'\nimport { resolveColor, type ResolvedColorRef, type ThemeContext } from './theme.js'\nimport { nvPrOf } from './slide-dom.js'\n\n/** The master `p:txStyles` style element name for a placeholder category. */\nconst TX_STYLE_NAME: Record<'title' | 'body' | 'other', string> = {\n\ttitle: 'p:titleStyle',\n\tbody: 'p:bodyStyle',\n\tother: 'p:otherStyle',\n}\n\n/** The ordered children of a `CT_TextListStyle` (`a:lstStyle` / a `p:txStyles` style). */\nexport const LST_STYLE_LEVELS = [\n\t'a:defPPr',\n\t'a:lvl1pPr',\n\t'a:lvl2pPr',\n\t'a:lvl3pPr',\n\t'a:lvl4pPr',\n\t'a:lvl5pPr',\n\t'a:lvl6pPr',\n\t'a:lvl7pPr',\n\t'a:lvl8pPr',\n\t'a:lvl9pPr',\n]\n\n/** Inheritable run properties baked under `preserve`: size and weight/slant (not typeface). */\nexport const RUN_PROP_NAMES = ['sz', 'b', 'i'] as const\nexport type RunProps = Record<(typeof RUN_PROP_NAMES)[number], string | null>\n\n/** The `p:ph` element of a shape (`p:sp/p:nvSpPr/p:nvPr/p:ph`), or `null`. */\nexport function placeholderOf(sp: Element): Element | null {\n\tconst nvPr = nvPrOf(sp)\n\treturn nvPr ? firstChild(nvPr, 'p:ph') : null\n}\n\n/**\n * The master text-style *category* a placeholder type resolves against\n * (absent ⇒ `obj` ⇒ body). This is a `p:txStyles` selector — it picks\n * `p:titleStyle`/`p:bodyStyle`/`p:otherStyle` (see {@link TX_STYLE_NAME}) and\n * deliberately collapses `dt`/`ftr`/`sldNum`/`hdr` (and anything else) into\n * `'other'`. It is **not** a placeholder *identity* predicate: it must not be\n * used to decide which source placeholder a slide placeholder inherits geometry\n * from, or the footer trio become mutually interchangeable — use the exact\n * `type` match in {@link findPlaceholder} for that.\n */\nexport function phCategory(type: string | null): 'title' | 'body' | 'other' {\n\tif (type === 'title' || type === 'ctrTitle') return 'title'\n\tif (type === null || type === 'body' || type === 'subTitle' || type === 'obj') return 'body'\n\treturn 'other'\n}\n\n/**\n * Placeholder types of which a layout/master holds at most one, and whose\n * identity is their `type` alone: `dt`, `ftr`, `sldNum`, `hdr`. A slide\n * placeholder of one of these types must inherit **only** from a source\n * placeholder of the *same type* — never via `idx` or the txStyles *category*,\n * both of which lump the whole trio together and would let `sldNum` borrow the\n * footer's box (and vice versa).\n */\nconst SINGLETON_PH = new Set(['dt', 'ftr', 'sldNum', 'hdr'])\n\n/**\n * The placeholder shape in `root` (a layout/master) that the given slide\n * placeholder inherits from.\n *\n * A singleton-type slide placeholder (`dt`/`ftr`/`sldNum`/`hdr`) matches only an\n * exact same-`type` source placeholder — PowerPoint gives the trio different\n * `idx` on the layout (dt=10/ftr=11/sldNum=12) than the master (dt=2/ftr=3/\n * sldNum=4), so an `idx`- or category-based fallback would silently pick the\n * wrong member of the trio. Every other type prefers a same-`idx` placeholder of\n * the same category, then any same-`idx`, then any same-category, and never\n * lands on a singleton placeholder. Returns `null` when nothing matches.\n */\nexport function findPlaceholder(root: Element, slideType: string | null, slideIdx: string): Element | null {\n\tif (slideType && SINGLETON_PH.has(slideType)) {\n\t\tfor (const sp of descendantsByTag(root, OOXML_NS.p, 'sp')) {\n\t\t\tconst ph = placeholderOf(sp)\n\t\t\tif (ph && attr(ph, 'type') === slideType) return sp\n\t\t}\n\t\treturn null\n\t}\n\tconst cat = phCategory(slideType)\n\tlet idxMatch: Element | null = null\n\tlet catMatch: Element | null = null\n\tfor (const sp of descendantsByTag(root, OOXML_NS.p, 'sp')) {\n\t\tconst ph = placeholderOf(sp)\n\t\tif (!ph) continue\n\t\tconst type = attr(ph, 'type')\n\t\tif (type && SINGLETON_PH.has(type)) continue // a non-singleton must never inherit from the footer trio\n\t\tconst i = attr(ph, 'idx') ?? '0'\n\t\tconst sameCat = phCategory(type) === cat\n\t\tif (i === slideIdx && sameCat) return sp\n\t\tif (i === slideIdx && !idxMatch) idxMatch = sp\n\t\tif (sameCat && !catMatch) catMatch = sp\n\t}\n\treturn idxMatch ?? catMatch\n}\n\n/**\n * {@link findPlaceholder} against one tier of `ctx`, through the context's memo.\n *\n * Every placeholder question in this module funnels through here, which is what makes the memo\n * worth having: resolving one run's colour, size, face, bold and italic asks the same question\n * ten times, and a paragraph asks it again for every run.\n *\n * @param root - the layout or master root to scan\n * @param tier - which of the two it is, so the two answers cannot collide in one memo\n */\nfunction memoizedPlaceholder(\n\troot: Element,\n\ttier: 'layout' | 'master',\n\ttype: string | null,\n\tidx: string,\n\tctx: ThemeContext\n): Element | null {\n\tconst key = `${tier}\u0000${type ?? ''}\u0000${idx}`\n\tconst memo = (ctx.placeholderMemo ??= new Map<string, Element | null>())\n\tconst hit = memo.get(key)\n\tif (hit !== undefined || memo.has(key)) return hit ?? null\n\tconst found = findPlaceholder(root, type, idx)\n\tmemo.set(key, found)\n\treturn found\n}\n\n/** The `a:lstStyle` of a placeholder shape's `p:txBody`, or `null`. */\nfunction placeholderLstStyle(sp: Element): Element | null {\n\tconst txBody = firstChild(sp, 'p:txBody')\n\treturn txBody ? firstChild(txBody, 'a:lstStyle') : null\n}\n\n/**\n * The `a:defRPr` for `level` (0-based) in a `CT_TextListStyle` (`a:lstStyle` or a\n * `p:txStyles` style): the level-specific `a:lvlNpPr/a:defRPr`, else the\n * `a:defPPr/a:defRPr` fallback. The shared root for colour and size resolution.\n */\nexport function lstStyleLevelDefRPr(listStyle: Element | null, level: number): Element | null {\n\tif (!listStyle) return null\n\tconst lvl = firstChild(listStyle, `a:lvl${level + 1}pPr`) ?? firstChild(listStyle, 'a:defPPr')\n\treturn lvl ? firstChild(lvl, 'a:defRPr') : null\n}\n\n/** The `a:solidFill` of a level's `a:defRPr`, or `null` when none is defined there. */\nexport function lstStyleLevelFill(listStyle: Element | null, level: number): Element | null {\n\tconst defRPr = lstStyleLevelDefRPr(listStyle, level)\n\treturn defRPr ? firstChild(defRPr, 'a:solidFill') : null\n}\n\n/**\n * The source style tiers a placeholder resolves against, most specific first: the layout\n * placeholder's `a:lstStyle`, the master placeholder's, then the master `p:txStyles` category\n * style — and, on a notes context only, the notesMaster `p:notesStyle`.\n *\n * The one place the chain is spelled out. `placeholderInherited*` differ only in what they pull\n * from each tier, so they all walk this.\n */\nfunction styleTiers(type: string | null, idx: string, ctx: ThemeContext): Element[] {\n\tconst tiers: (Element | null)[] = []\n\tif (ctx.layoutRoot) {\n\t\tconst layoutPh = memoizedPlaceholder(ctx.layoutRoot, 'layout', type, idx, ctx)\n\t\ttiers.push(layoutPh && placeholderLstStyle(layoutPh))\n\t}\n\tif (ctx.masterRoot) {\n\t\tconst masterPh = memoizedPlaceholder(ctx.masterRoot, 'master', type, idx, ctx)\n\t\ttiers.push(masterPh && placeholderLstStyle(masterPh))\n\t\tconst txStyles = firstChild(ctx.masterRoot, 'p:txStyles')\n\t\ttiers.push(txStyles && firstChild(txStyles, TX_STYLE_NAME[phCategory(type)]))\n\t}\n\t// Notes body runs inherit from the notesMaster's `p:notesStyle` (keyed by level, not\n\t// placeholder type); it is the bottom tier of the notes chain — see the field note on\n\t// `ThemeContext.notesStyle`. Never set on a slide context.\n\tif (ctx.notesStyle) tiers.push(ctx.notesStyle)\n\treturn tiers.filter((t): t is Element => t !== null)\n}\n\n/**\n * The colour *element* a placeholder run inherits from the source style chain. Returns the\n * first tier's colour element that resolves against `ctx` (the `a:srgbClr`/`a:schemeClr`/…\n * inside its `a:solidFill`), or `null` when nothing in the chain defines a resolvable colour.\n * The read-model `Run.resolvedColor` getter feeds this element to `resolveColorElement` for the\n * `effectiveHex`; the flatten path resolves it directly via {@link placeholderInheritedColor}.\n */\nexport function placeholderInheritedFill(\n\ttype: string | null,\n\tidx: string,\n\tlevel: number,\n\tctx: ThemeContext\n): Element | null {\n\tfor (const tier of styleTiers(type, idx, ctx)) {\n\t\tconst fill = lstStyleLevelFill(tier, level)\n\t\tconst colorEl = fill && firstChildElement(fill)\n\t\tif (colorEl && resolveColor(colorEl, ctx)) return colorEl\n\t}\n\treturn null\n}\n\n/**\n * The level `a:defRPr` elements a placeholder inherits from the source style chain, in\n * resolution order. Tiers with no `a:defRPr` for `level` are dropped. The shared root for\n * inherited run *size* and *typeface* resolution (the size/face sibling of\n * {@link placeholderInheritedFill}), read directly by the flatten path and the read-model font\n * getters.\n */\nexport function placeholderInheritedDefRPrs(\n\ttype: string | null,\n\tidx: string,\n\tlevel: number,\n\tctx: ThemeContext\n): Element[] {\n\treturn styleTiers(type, idx, ctx)\n\t\t.map((tier) => lstStyleLevelDefRPr(tier, level))\n\t\t.filter((t): t is Element => t !== null)\n}\n\n/**\n * The source list-style tiers a placeholder inherits paragraph formatting from, most specific\n * first. The paragraph-level sibling of {@link placeholderInheritedDefRPrs} — it hands back the\n * tier elements whole rather than pulling one level's properties out of each.\n *\n * The notes tier is included for consistency with the rest of the chain, though it cannot arise\n * in practice: the only caller is the list-style bake in `flattenShape`, which runs on slide and\n * shape contexts, and `ctx.notesStyle` is set only on a notes context.\n */\nexport function placeholderInheritedListStyles(type: string | null, idx: string, ctx: ThemeContext): Element[] {\n\treturn styleTiers(type, idx, ctx)\n}\n\n/**\n * The colour a placeholder run inherits from the source style chain, resolved to a\n * literal `{ hex, transforms }`. Thin wrapper over {@link placeholderInheritedFill}\n * for the flatten path, which re-emits the transforms verbatim. Returns `null`\n * when nothing in the chain defines a resolvable colour (the run then re-binds to\n * the destination).\n */\nexport function placeholderInheritedColor(\n\ttype: string | null,\n\tidx: string,\n\tlevel: number,\n\tctx: ThemeContext\n): ResolvedColorRef | null {\n\tconst colorEl = placeholderInheritedFill(type, idx, level, ctx)\n\treturn colorEl ? resolveColor(colorEl, ctx) : null\n}\n\n/**\n * The run size/weight a placeholder run inherits from the source style chain, per list level.\n * Each of `sz`/`b`/`i` is taken from the first tier that defines it (properties resolve\n * independently). Returns `null` when no tier defines any of them.\n */\nexport function placeholderInheritedRunProps(\n\ttype: string | null,\n\tidx: string,\n\tlevel: number,\n\tctx: ThemeContext\n): RunProps | null {\n\tconst tiers = placeholderInheritedDefRPrs(type, idx, level, ctx)\n\tconst props = {} as RunProps\n\tlet any = false\n\tfor (const name of RUN_PROP_NAMES) {\n\t\tlet value: string | null = null\n\t\tfor (const tier of tiers) {\n\t\t\tvalue = attr(tier, name)\n\t\t\tif (value != null) break\n\t\t}\n\t\tprops[name] = value\n\t\tif (value != null) any = true\n\t}\n\treturn any ? props : null\n}\n\n/**\n * The `a:xfrm` a placeholder inherits from the source layout, then master,\n * tagged with which tier it came from — `null` when neither defines one. The\n * read-model `resolveInheritedFrame` (`theme-context.ts`) sibling of\n * {@link placeholderInheritedAnchor}; also the bake source for the flatten pass'\n * `resolvePlaceholderGeometry`.\n */\nexport function placeholderInheritedXfrm(\n\ttype: string | null,\n\tidx: string,\n\tctx: ThemeContext\n): { xfrm: Element; source: 'layout' | 'master' } | null {\n\tfor (const [root, source] of [\n\t\t[ctx.layoutRoot, 'layout'],\n\t\t[ctx.masterRoot, 'master'],\n\t] as const) {\n\t\tif (!root) continue\n\t\tconst ph = memoizedPlaceholder(root, source, type, idx, ctx)\n\t\tconst spPr = ph && firstChild(ph, 'p:spPr')\n\t\tconst xfrm = spPr && firstChild(spPr, 'a:xfrm')\n\t\tif (xfrm) return { xfrm, source }\n\t}\n\treturn null\n}\n\n/**\n * The vertical anchor (`a:bodyPr/@anchor`) a placeholder inherits from the source\n * layout, then master, or `null`. Resolves per-attribute: the first tier whose\n * placeholder `a:bodyPr` actually sets `@anchor` wins, so a layout `a:bodyPr`\n * present but without `@anchor` does not mask the master's. The read-model\n * `TextFrame.resolvedAnchor` sibling of {@link placeholderInheritedXfrm}.\n */\nexport function placeholderInheritedAnchor(type: string | null, idx: string, ctx: ThemeContext): string | null {\n\tfor (const [root, tier] of [\n\t\t[ctx.layoutRoot, 'layout'],\n\t\t[ctx.masterRoot, 'master'],\n\t] as const) {\n\t\tif (!root) continue\n\t\tconst ph = memoizedPlaceholder(root, tier, type, idx, ctx)\n\t\tconst txBody = ph && firstChild(ph, 'p:txBody')\n\t\tconst bodyPr = txBody && firstChild(txBody, 'a:bodyPr')\n\t\tconst anchor = bodyPr && attr(bodyPr, 'anchor')\n\t\tif (anchor) return anchor\n\t}\n\treturn null\n}\n\n/** Whether the *slide itself* already fixes this run's colour (so a rebind cannot change it). */\nexport function slideDefinesColor(run: Element, pPr: Element | null, slideLst: Element | null, level: number): boolean {\n\tconst rPr = firstChild(run, 'a:rPr')\n\tif (rPr && FILL_CHOICES.some((q) => firstChild(rPr, q))) return true\n\tconst defRPr = pPr && firstChild(pPr, 'a:defRPr')\n\tif (defRPr && firstChild(defRPr, 'a:solidFill')) return true\n\treturn !!lstStyleLevelFill(slideLst, level)\n}\n\n/** Whether the *slide itself* already fixes a run property (so a rebind cannot change it). */\nexport function slideDefinesProp(\n\tname: string,\n\trun: Element,\n\tpPr: Element | null,\n\tslideLst: Element | null,\n\tlevel: number\n): boolean {\n\tconst rPr = firstChild(run, 'a:rPr')\n\tif (rPr && attr(rPr, name) != null) return true\n\tconst defRPr = pPr && firstChild(pPr, 'a:defRPr')\n\tif (defRPr && attr(defRPr, name) != null) return true\n\tconst slideDefRPr = lstStyleLevelDefRPr(slideLst, level)\n\treturn !!(slideDefRPr && attr(slideDefRPr, name) != null)\n}\n","/**\n * ts-pptx: units at the read model's boundary — validated on the way in, converted on the way out.\n *\n * Every read-side setter that takes a measurement has to answer the same two questions before\n * the value reaches an attribute: is it finite, and (for an extent) is it positive. `NaN` or\n * `Infinity` written verbatim makes the part invalid, and silently coercing it to something\n * drawable is exactly the footgun the project's API policy rules out — so both are a throw.\n *\n * The two halves used to be split across `table-edit.ts` (threw, then rounded) and `slide.ts`\n * (threw only, with the rounding done eight lines later at each build site), under two spellings\n * of one message. Rounding *here* is what makes the split unnecessary: a caller that has checked\n * the value already holds the integer it is going to write.\n */\n\nimport { InvalidOptionError } from '../../errors.js'\nimport type { InvalidOptionErrorCode } from '../../codes.js'\nimport { emuToPoints, HUNDREDTHS_PER_POINT } from '../../units.js'\n\n/**\n * Round a measurement to whole EMU, rejecting a value that cannot be written.\n * @param value - the caller's measurement, in EMU\n * @param field - the option name, opening the message\n * @param code - the error code to raise; defaults to the generic coordinate one\n */\nexport function checkFiniteEmu(\n\tvalue: number,\n\tfield: string,\n\tcode: InvalidOptionErrorCode = 'coord/non-finite'\n): number {\n\tif (!Number.isFinite(value))\n\t\tthrow new InvalidOptionError(code, `${field} must be a finite number of EMU, got: ${String(value)}`)\n\treturn Math.round(value)\n}\n\n/**\n * As {@link checkFiniteEmu}, and additionally rejects a non-positive value — the guard an\n * *extent* needs, since `ST_PositiveCoordinate` has no room for zero or below and a zero-size\n * shape is a degenerate result rather than a small one.\n */\nexport function checkPositiveEmu(value: number, field: string): number {\n\tconst rounded = checkFiniteEmu(value, field)\n\tif (value <= 0) throw new InvalidOptionError('coord/not-positive', `${field} must be positive, got: ${String(value)}`)\n\treturn rounded\n}\n\n/** `ST_LineWidth`'s upper bound, 1584pt in EMU. */\nconst MAX_LINE_WIDTH_EMU = 20116800\n\n/**\n * Round a line width to whole EMU, rejecting one `ST_LineWidth` cannot hold: it has to be\n * finite and from 0 to {@link MAX_LINE_WIDTH_EMU}. A value outside that range is not a thin or a\n * thick line, it is a part PowerPoint reports as needing repair.\n * @param value - the caller's width, in EMU\n * @param field - the option name, opening the message\n * @param code - the error code to raise\n */\nexport function checkLineWidthEmu(value: number, field: string, code: InvalidOptionErrorCode): number {\n\tconst rounded = checkFiniteEmu(value, field, code)\n\tif (rounded < 0 || rounded > MAX_LINE_WIDTH_EMU)\n\t\tthrow new InvalidOptionError(\n\t\t\tcode,\n\t\t\t`${field} must be from 0 to ${MAX_LINE_WIDTH_EMU} EMU (1584pt), got: ${String(value)} EMU`\n\t\t)\n\treturn rounded\n}\n\n/**\n * EMU → points, propagating \"absent\". The read model reports line widths, effect radii and text\n * insets in points while the DOM stores EMU, so `x === null ? null : x / EMU_PER_POINT` stood at\n * five getters across `chart.ts`, `shapes/base.ts`, `table.ts` and `text.ts`.\n *\n * The accumulator sites whose target is `number | undefined` do not come through here —\n * propagating a `null` would only have to be unwrapped again — but they do not open-code the\n * division either: they unwrap the `null` themselves and call `emuToPoints`. {@link emuToPoints}\n * states the whole policy and names the one place still allowed to divide inline.\n */\nexport function ptFromEmu(emu: number | null): number | null {\n\treturn emu === null ? null : emuToPoints(emu)\n}\n\n/**\n * Hundredths of a point → points, propagating \"absent\". DrawingML measures font size, character\n * spacing, point line spacing and bullet size in hundredths (`a:rPr/@sz`, `@spc`,\n * `a:spcPts/@val`, `a:buSzPts/@val`), and six getters across `text.ts` and `theme-context.ts`\n * each wrote the divisor out as a bare `100`.\n *\n * Naming the unit is the point: `a:buSzPct` next door is *thousandths of a percent*, or a string\n * with a literal `%`, so a bare divisor leaves a reader to remember which attribute is which. That\n * one is read through `pctPointsAttr` in `read/oxml/dom.ts`, which knows both spellings.\n *\n * The two `LineSpacing` sites divide by {@link HUNDREDTHS_PER_POINT} and\n * `FIXED_PCT_PER_PERCENT` in place, for the reason {@link ptFromEmu} gives about\n * accumulators: their field is a plain `number` inside an object the caller's own null check\n * already guards, so a nullable return would only be unwrapped again.\n */\nexport function ptFromHundredths(value: number | null): number | null {\n\treturn value === null ? null : value / HUNDREDTHS_PER_POINT\n}\n","/**\n * Reading geometry out of a shape: transform boxes, rotation and flips, and custom-geometry paths.\n *\n * Every value here comes straight off `a:xfrm` / `a:path` attributes, so these are pure element\n * readers with no theme or relationship context.\n */\n\nimport {\n\tELEMENT_NODE,\n\tOOXML_NS,\n\tattr,\n\tboolValue,\n\tfirstChild,\n\tgetElements,\n\tnumberValue,\n\ttype Element,\n} from '../../oxml/dom.js'\nimport type { CustomGeometryPath, GeometryCommand } from './types.js'\nimport { ANGLE_UNITS_PER_DEGREE } from '../../../units.js'\n\n/**\n * One `a:pt` coordinate as a raw path-unit integer. A guide-name reference\n * (the `ST_AdjCoordinate` string form) is not produced by authored freeforms;\n * a non-numeric value degrades to `0` rather than crashing (documented edge).\n */\nfunction ptAxis(pt: Element | undefined, axis: 'x' | 'y'): number {\n\treturn (pt ? numberValue(attr(pt, axis)) : null) ?? 0\n}\n\n/** Parse one `<a:path>` into its viewport attrs (with schema defaults) and ordered segments. */\nexport function readGeometryPath(path: Element): CustomGeometryPath {\n\tconst commands: GeometryCommand[] = []\n\tfor (let node = path.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\tconst seg = node as Element\n\t\tif (seg.namespaceURI !== OOXML_NS.a) continue\n\t\tconst pts = getElements(seg, 'a:pt')\n\t\tswitch (seg.localName) {\n\t\t\tcase 'moveTo':\n\t\t\t\tcommands.push({ cmd: 'moveTo', x: ptAxis(pts[0], 'x'), y: ptAxis(pts[0], 'y') })\n\t\t\t\tbreak\n\t\t\tcase 'lnTo':\n\t\t\t\tcommands.push({ cmd: 'lnTo', x: ptAxis(pts[0], 'x'), y: ptAxis(pts[0], 'y') })\n\t\t\t\tbreak\n\t\t\tcase 'cubicBezTo':\n\t\t\t\tcommands.push({\n\t\t\t\t\tcmd: 'cubicBezTo',\n\t\t\t\t\tx1: ptAxis(pts[0], 'x'),\n\t\t\t\t\ty1: ptAxis(pts[0], 'y'),\n\t\t\t\t\tx2: ptAxis(pts[1], 'x'),\n\t\t\t\t\ty2: ptAxis(pts[1], 'y'),\n\t\t\t\t\tx: ptAxis(pts[2], 'x'),\n\t\t\t\t\ty: ptAxis(pts[2], 'y'),\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\tcase 'quadBezTo':\n\t\t\t\tcommands.push({\n\t\t\t\t\tcmd: 'quadBezTo',\n\t\t\t\t\tx1: ptAxis(pts[0], 'x'),\n\t\t\t\t\ty1: ptAxis(pts[0], 'y'),\n\t\t\t\t\tx: ptAxis(pts[1], 'x'),\n\t\t\t\t\ty: ptAxis(pts[1], 'y'),\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\tcase 'arcTo':\n\t\t\t\tcommands.push({\n\t\t\t\t\tcmd: 'arcTo',\n\t\t\t\t\twR: numberValue(attr(seg, 'wR')) ?? 0,\n\t\t\t\t\thR: numberValue(attr(seg, 'hR')) ?? 0,\n\t\t\t\t\tstAng: (numberValue(attr(seg, 'stAng')) ?? 0) / ANGLE_UNITS_PER_DEGREE,\n\t\t\t\t\tswAng: (numberValue(attr(seg, 'swAng')) ?? 0) / ANGLE_UNITS_PER_DEGREE,\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\tcase 'close':\n\t\t\t\tcommands.push({ cmd: 'close' })\n\t\t\t\tbreak\n\t\t}\n\t}\n\treturn {\n\t\tw: numberValue(attr(path, 'w')) ?? 0,\n\t\th: numberValue(attr(path, 'h')) ?? 0,\n\t\tfill: attr(path, 'fill') ?? 'norm',\n\t\tstroke: boolValue(attr(path, 'stroke')) ?? true,\n\t\tcommands,\n\t}\n}\n\n/** A point + extent pair (`a:off`/`a:ext` or `a:chOff`/`a:chExt`) from a transform, or `null` if either is incomplete. */\nexport function readBox(\n\txfrm: Element,\n\toffName: string,\n\textName: string\n): { x: number; y: number; cx: number; cy: number } | null {\n\tconst off = firstChild(xfrm, offName)\n\tconst ext = firstChild(xfrm, extName)\n\tconst x = off && numberValue(attr(off, 'x'))\n\tconst y = off && numberValue(attr(off, 'y'))\n\tconst cx = ext && numberValue(attr(ext, 'cx'))\n\tconst cy = ext && numberValue(attr(ext, 'cy'))\n\tif (x === null || y === null || cx === null || cy === null) return null\n\treturn { x, y, cx, cy }\n}\n\nexport function rotationDegrees(xfrm: Element): number {\n\tconst rot = numberValue(attr(xfrm, 'rot'))\n\treturn rot === null ? 0 : rot / ANGLE_UNITS_PER_DEGREE\n}\n\nexport function transformFlipH(xfrm: Element): boolean {\n\treturn boolValue(attr(xfrm, 'flipH')) === true\n}\n\nexport function transformFlipV(xfrm: Element): boolean {\n\treturn boolValue(attr(xfrm, 'flipV')) === true\n}\n","/**\n * Resolve a slide's theme colour context: the slide → slideLayout → slideMaster\n * → theme walk that turns a `schemeClr` token into a literal hex, plus the\n * `a:solidFill` helper the read-model colour getters share.\n *\n * One implementation backs two callers — the read-model getters\n * (`Slide.themeContext` → `Shape.resolvedFill` / `Run.resolvedColor`) and the\n * `importSlide` `theme: 'preserve'` flatten path, which layers its `fmtScheme` /\n * background needs on top of {@link resolveSlideThemeParts} — so a token resolves\n * identically whether it is read or baked.\n */\nimport { applyColorTransforms, type ColorTransform } from '../oxml/color-transform.js'\nimport { attr, boolValue, firstChild, firstChildElement, numberValue, type Element } from '../oxml/dom.js'\nimport { colorValueIf } from '../oxml/fill.js'\nimport {\n\tparseClrMap,\n\tparseClrScheme,\n\tresolveColor,\n\tresolveThemeFont,\n\tstyleRefFill,\n\tstyleRefLine,\n\tthemeElementsOfRoot,\n\ttype ColorContext,\n\ttype ThemeContext,\n} from '../oxml/theme.js'\nimport {\n\tlstStyleLevelDefRPr,\n\tlstStyleLevelFill,\n\tplaceholderInheritedAnchor,\n\tplaceholderInheritedDefRPrs,\n\tplaceholderInheritedFill,\n\tplaceholderInheritedXfrm,\n} from '../oxml/placeholder-inherit.js'\nimport type { OpcPackage } from '../opc/package.js'\nimport { ptFromHundredths } from './coords.js'\nimport { readBox } from './shapes/geometry.js'\nimport { resolveSingleRel } from '../opc/partnames.js'\nimport {\n\tNOTES_MASTER_REL,\n\tOFFICE_DOCUMENT_REL,\n\tSLIDE_LAYOUT_REL,\n\tSLIDE_MASTER_REL,\n\tTHEME_REL,\n} from '../../ooxml/rel-types.js'\n\n/** The resolved theme subgraph a slide depends on, plus its parsed colour maps. */\nexport interface SlideThemeParts extends ColorContext {\n\tslideRoot: Element | null\n\tlayoutPartName: string | null\n\tmasterPartName: string | null\n\tlayoutRoot: Element | null\n\tmasterRoot: Element | null\n\t/**\n\t * Partname of the theme part the chain bottoms out in, or `null`. Callers that\n\t * materialize a fill out of the theme (a `p:bgRef`'s `fmtScheme` entry) need it to\n\t * resolve that fill's relationship ids against the *theme's* rels.\n\t */\n\tthemePartName: string | null\n\t/** The theme's `a:themeElements`, for callers that also need `a:fmtScheme`. */\n\tthemeElements: Element | null\n}\n\n/** The document element of a part, or `null` when the partname/part is absent. */\nfunction documentElement(opc: OpcPackage, partName: string | null): Element | null {\n\treturn partName ? (opc.part(partName)?.dom.documentElement ?? null) : null\n}\n\n/**\n * The presentation's `p:defaultTextStyle` (`presentation.xml`, reached via the\n * package `officeDocument` relationship), or `null` when absent. This is\n * PowerPoint's lowest-priority text fallback — the bottom tier of a slide run's\n * size/colour/face/bold resolution (see `ThemeContext.defaultTextStyle`).\n */\nfunction presentationDefaultTextStyle(opc: OpcPackage): Element | null {\n\tconst root = documentElement(opc, resolveSingleRel(opc, '/', OFFICE_DOCUMENT_REL))\n\treturn root ? firstChild(root, 'p:defaultTextStyle') : null\n}\n\n/**\n * Walk slide → slideLayout → slideMaster → theme, returning the resolved part\n * roots plus the parsed colour map (`clrMap`, honouring the slide's `clrMapOvr`)\n * and colour scheme (`clrScheme`). A missing link degrades to `null` roots and\n * empty maps rather than throwing.\n */\nexport function resolveSlideThemeParts(opc: OpcPackage, slidePartName: string): SlideThemeParts {\n\tconst layoutPartName = resolveSingleRel(opc, slidePartName, SLIDE_LAYOUT_REL)\n\tconst masterPartName = layoutPartName ? resolveSingleRel(opc, layoutPartName, SLIDE_MASTER_REL) : null\n\tconst themePartName = masterPartName ? resolveSingleRel(opc, masterPartName, THEME_REL) : null\n\n\tconst slideRoot = documentElement(opc, slidePartName)\n\tconst layoutRoot = documentElement(opc, layoutPartName)\n\tconst masterRoot = documentElement(opc, masterPartName)\n\tconst themeRoot = documentElement(opc, themePartName)\n\n\tconst themeElements = themeElementsOfRoot(themeRoot)\n\n\treturn {\n\t\tslideRoot,\n\t\tlayoutPartName,\n\t\tmasterPartName,\n\t\tlayoutRoot,\n\t\tmasterRoot,\n\t\tthemePartName,\n\t\tthemeElements,\n\t\tclrMap: parseClrMap(effectiveClrMap(slideRoot, masterRoot)),\n\t\tclrScheme: themeTier(themeElements).clrScheme,\n\t}\n}\n\n/**\n * The colour context a slide's read-model getters resolve against: the\n * {@link ColorContext} maps plus the theme's `a:fmtScheme` (so a colour delivered\n * through a shape's `p:style` `fillRef`/`lnRef` can be resolved like the\n * `theme: 'preserve'` flatten path does). The `fmtScheme` is `null` when the\n * slide's theme is missing.\n * @param opc - the package, for the presentation's default text style\n * @param parts - the slide's theme parts, as {@link resolveSlideThemeParts} walks them; a caller that\n * also needs the part names walks once and hands the result to both\n */\nexport function resolveSlideColorContext(opc: OpcPackage, parts: SlideThemeParts): ThemeContext {\n\tconst { clrMap, themeElements, layoutRoot, masterRoot } = parts\n\treturn {\n\t\tclrMap,\n\t\t// `fontScheme` is what lets the run font getters resolve a +mj-*/+mn-* token (the\n\t\t// placeholder-inherited typeface chain bottoms out in one) to a literal face.\n\t\t...themeTier(themeElements),\n\t\t// layout/master roots let the read-model run-colour/size/face getters resolve\n\t\t// a placeholder-inherited value the same way the flatten path does.\n\t\tlayoutRoot,\n\t\tmasterRoot,\n\t\t// The presentation's default text style — the lowest-priority tier a slide run\n\t\t// (placeholder or not) falls back to when it resolves nothing above it.\n\t\tdefaultTextStyle: presentationDefaultTextStyle(opc),\n\t}\n}\n\n/**\n * The colour context a slide's *speaker-notes* getters resolve against. A notes\n * slide inherits its theme through its notesMaster (`notesSlideN.xml.rels`\n * carries the `notesMaster` relationship), which in turn points at the notes\n * theme (`theme2.xml`). Walk notesSlide → notesMaster → theme, taking `clrMap`\n * from the notesMaster's own `p:clrMap` and `clrScheme`/`fontScheme` from that\n * theme, so a notes run's own `schemeClr` fill resolves to a literal hex the same\n * way a slide run's does (backing `Run.resolvedColor` on {@link Slide.notesTextFrame}).\n *\n * Notes runs inherit character properties from the notesMaster's `p:notesStyle`,\n * not from a slide layout/master placeholder chain, so `layoutRoot`/`masterRoot`\n * are deliberately left absent. Instead the notesMaster's `p:notesStyle` is carried\n * as `notesStyle`, and the notes body `TextFrame` is built with a placeholder\n * context (see `NotesPlaceholder`) so a body run's\n * effective size/face/bold (and inherited colour) resolve against it — the notes\n * analogue of the slide placeholder chain. The maps are empty when the\n * notesMaster/theme chain is incomplete, in which case tokens stay unresolved.\n */\nexport function resolveNotesColorContext(opc: OpcPackage, notesPartName: string): ThemeContext {\n\tconst masterPartName = resolveSingleRel(opc, notesPartName, NOTES_MASTER_REL)\n\tconst themePartName = masterPartName ? resolveSingleRel(opc, masterPartName, THEME_REL) : null\n\tconst masterRoot = documentElement(opc, masterPartName)\n\tconst themeRoot = documentElement(opc, themePartName)\n\tconst themeElements = themeElementsOfRoot(themeRoot)\n\treturn {\n\t\tclrMap: parseClrMap(effectiveClrMap(masterRoot, masterRoot)),\n\t\t// `fontScheme` is what lets a notes run resolve a +mj-*/+mn-* theme-font token to a\n\t\t// literal face; the writer's notesStyle uses +mn-lt, so an authored notes run that\n\t\t// omits its own face resolves through here.\n\t\t...themeTier(themeElements),\n\t\t// The notesMaster's text style — the tier a notes-body run's inherited\n\t\t// size/face/bold/colour resolves against (see `ThemeContext.notesStyle`).\n\t\tnotesStyle: masterRoot ? firstChild(masterRoot, 'p:notesStyle') : null,\n\t}\n}\n\n/**\n * The colour context a *slide master*'s own getters resolve against: the master's\n * `p:clrMap` plus its theme's `clrScheme`/`fmtScheme`/`fontScheme` (walked master →\n * theme). Backs the text frames of `SlideMaster`'s\n * placeholders — a master placeholder run's own `schemeClr` resolves to a literal\n * hex the same way a slide run's does. `masterRoot` is carried so an inherited\n * placeholder value still resolves against the master's own text styles. The maps\n * are empty when the theme is missing, in which case tokens stay unresolved.\n */\nexport function resolveMasterColorContext(opc: OpcPackage, masterPartName: string): ThemeContext {\n\tconst themePartName = resolveSingleRel(opc, masterPartName, THEME_REL)\n\tconst masterRoot = documentElement(opc, masterPartName)\n\tconst themeElements = themeElementsOf(opc, themePartName)\n\treturn {\n\t\tclrMap: parseClrMap(effectiveClrMap(masterRoot, masterRoot)),\n\t\t...themeTier(themeElements),\n\t\tmasterRoot,\n\t}\n}\n\n/**\n * The colour context a *slide layout*'s own getters resolve against: walk layout →\n * master → theme. The effective `clrMap` is the layout's own\n * `p:clrMapOvr/a:overrideClrMapping` when present (rare), else the master's\n * `p:clrMap` — the layout's usual `a:masterClrMapping` means \"inherit the master\n * map\". `clrScheme`/`fmtScheme`/`fontScheme` come from the master's theme, and both\n * `layoutRoot`/`masterRoot` are carried for inherited-placeholder resolution. Backs\n * the text frames of `SlideLayout`'s placeholders.\n */\nexport function resolveLayoutColorContext(opc: OpcPackage, layoutPartName: string): ThemeContext {\n\tconst masterPartName = resolveSingleRel(opc, layoutPartName, SLIDE_MASTER_REL)\n\tconst themePartName = masterPartName ? resolveSingleRel(opc, masterPartName, THEME_REL) : null\n\tconst layoutRoot = documentElement(opc, layoutPartName)\n\tconst masterRoot = documentElement(opc, masterPartName)\n\tconst themeElements = themeElementsOf(opc, themePartName)\n\treturn {\n\t\tclrMap: parseClrMap(effectiveClrMap(layoutRoot, masterRoot)),\n\t\t...themeTier(themeElements),\n\t\tlayoutRoot,\n\t\tmasterRoot,\n\t}\n}\n\n/**\n * The three theme tiers every colour context carries, read off one `a:themeElements`.\n *\n * `clrScheme` is parsed into the token map the resolvers read; `fmtScheme` and `fontScheme`\n * ride as elements, because a style ref and a `+mj-*`/`+mn-*` token are resolved against the\n * live DOM rather than a snapshot. Four builders spelled these three lookups out.\n */\nfunction themeTier(themeElements: Element | null): Pick<ThemeContext, 'clrScheme' | 'fmtScheme' | 'fontScheme'> {\n\treturn {\n\t\tclrScheme: parseClrScheme(themeElements ? firstChild(themeElements, 'a:clrScheme') : null),\n\t\tfmtScheme: themeElements ? firstChild(themeElements, 'a:fmtScheme') : null,\n\t\tfontScheme: themeElements ? firstChild(themeElements, 'a:fontScheme') : null,\n\t}\n}\n\n/**\n * The colour map in force for `ownerRoot`: its own `p:clrMapOvr/a:overrideClrMapping` when it\n * has one, else the master's `p:clrMap`.\n *\n * A slide's and a layout's usual `a:masterClrMapping` means \"inherit the master map\", which is\n * why an absent override falls through rather than mapping nothing. A master is its own owner\n * and has no override, so it passes its root as both.\n */\nfunction effectiveClrMap(ownerRoot: Element | null, masterRoot: Element | null): Element | null {\n\tconst clrMapOvr = ownerRoot ? firstChild(ownerRoot, 'p:clrMapOvr') : null\n\tconst override = clrMapOvr ? firstChild(clrMapOvr, 'a:overrideClrMapping') : null\n\treturn override ?? (masterRoot ? firstChild(masterRoot, 'p:clrMap') : null)\n}\n\n/** The `a:themeElements` of a theme part (by partname), or `null` when the part/element is absent. */\nfunction themeElementsOf(opc: OpcPackage, themePartName: string | null): Element | null {\n\treturn themeElementsOfRoot(documentElement(opc, themePartName))\n}\n\n/** Identifies a placeholder by its `p:ph` `type`/`idx` for inheritance lookups. */\nexport interface PlaceholderRef {\n\ttype: string | null\n\tidx: string\n}\n\n/**\n * The colour a run effectively renders when its own `a:rPr` defines none,\n * resolved to a full {@link ResolvedColor}. Walks the inheritance the way\n * PowerPoint does: the paragraph's `a:pPr/a:defRPr` colour, then the slide text\n * body's `a:lstStyle` colour for the run's `level`, then — only for a placeholder\n * run — the placeholder's layout → master → master-`p:txStyles` chain (via\n * {@link placeholderInheritedFill}), then the presentation's `p:defaultTextStyle`\n * for the run's level (`ctx.defaultTextStyle`). The first tier that defines a\n * colour wins. `ph` is `null` for a non-placeholder run, which skips the\n * placeholder chain but still reaches `p:defaultTextStyle`. `null` when nothing in\n * the chain defines a colour, or it cannot be made literal.\n */\nexport function resolveInheritedRunColor(\n\tph: PlaceholderRef | null,\n\tlevel: number,\n\tpPr: Element | null,\n\tslideLstStyle: Element | null,\n\tctx: ThemeContext\n): ResolvedColor | null {\n\tconst defRPr = pPr && firstChild(pPr, 'a:defRPr')\n\tconst paraFill = defRPr && firstChild(defRPr, 'a:solidFill')\n\tif (paraFill) return resolveColorElement(firstChildElement(paraFill), ctx)\n\tconst slideFill = lstStyleLevelFill(slideLstStyle, level)\n\tif (slideFill) return resolveColorElement(firstChildElement(slideFill), ctx)\n\tif (ph) {\n\t\tconst colorEl = placeholderInheritedFill(ph.type, ph.idx, level, ctx)\n\t\tif (colorEl) return resolveColorElement(colorEl, ctx)\n\t}\n\tconst defaultFill = lstStyleLevelFill(ctx.defaultTextStyle ?? null, level)\n\treturn defaultFill ? resolveColorElement(firstChildElement(defaultFill), ctx) : null\n}\n\n/**\n * The `a:defRPr` tiers a run resolves an inherited character property against, in\n * priority order: the paragraph's `a:pPr/a:defRPr`, then the slide text body's\n * `a:lstStyle` level `a:defRPr`, then — only for a placeholder run — the\n * placeholder's layout → master → master-`p:txStyles` chain (via\n * {@link placeholderInheritedDefRPrs}), then the presentation's\n * `p:defaultTextStyle` level `a:defRPr` (`ctx.defaultTextStyle`). The first tier\n * that defines the property wins — each property resolves independently, mirroring\n * how the colour resolver walks the same chain. `ph` is `null` for a\n * non-placeholder run, which skips the placeholder chain but still reaches\n * `p:defaultTextStyle`.\n */\nfunction inheritedRunDefRPrs(\n\tph: PlaceholderRef | null,\n\tlevel: number,\n\tpPr: Element | null,\n\tslideLstStyle: Element | null,\n\tctx: ThemeContext\n): Element[] {\n\tconst tiers: Element[] = []\n\tconst paraDefRPr = pPr && firstChild(pPr, 'a:defRPr')\n\tif (paraDefRPr) tiers.push(paraDefRPr)\n\tconst slideDefRPr = lstStyleLevelDefRPr(slideLstStyle, level)\n\tif (slideDefRPr) tiers.push(slideDefRPr)\n\tif (ph) tiers.push(...placeholderInheritedDefRPrs(ph.type, ph.idx, level, ctx))\n\tconst defaultDefRPr = lstStyleLevelDefRPr(ctx.defaultTextStyle ?? null, level)\n\tif (defaultDefRPr) tiers.push(defaultDefRPr)\n\treturn tiers\n}\n\n/**\n * The point size a run effectively renders when its own `a:rPr` sets no `@sz`,\n * walking the inheritance the way PowerPoint does (see {@link inheritedRunDefRPrs}):\n * the first `a:defRPr/@sz` (hundredths of a point) in the paragraph → slide →\n * (placeholder) layout → master → `p:txStyles` → `p:defaultTextStyle` chain,\n * converted to points. A non-placeholder run skips the placeholder tiers but still\n * reaches `p:defaultTextStyle`. `null` when nothing in the chain defines a size.\n */\nexport function resolveInheritedRunSize(\n\tph: PlaceholderRef | null,\n\tlevel: number,\n\tpPr: Element | null,\n\tslideLstStyle: Element | null,\n\tctx: ThemeContext\n): number | null {\n\tfor (const defRPr of inheritedRunDefRPrs(ph, level, pPr, slideLstStyle, ctx)) {\n\t\tconst sz = numberValue(attr(defRPr, 'sz'))\n\t\tif (sz !== null) return ptFromHundredths(sz)\n\t}\n\treturn null\n}\n\n/**\n * The typeface a run effectively renders when its own `a:rPr` sets no `a:latin`,\n * walking the same chain as {@link resolveInheritedRunSize}: the first\n * `a:defRPr/a:latin/@typeface` it finds, then resolving a `+mj-*`/`+mn-*` theme\n * font token to a literal face name through the theme `fontScheme`. A\n * non-placeholder run skips the placeholder tiers but still reaches\n * `p:defaultTextStyle` (whose level `a:latin` is `+mn-lt` in a PowerPoint-written\n * deck). `null` when nothing in the chain names a face, or the token cannot be\n * resolved.\n */\nexport function resolveInheritedRunFontFace(\n\tph: PlaceholderRef | null,\n\tlevel: number,\n\tpPr: Element | null,\n\tslideLstStyle: Element | null,\n\tctx: ThemeContext\n): string | null {\n\tfor (const defRPr of inheritedRunDefRPrs(ph, level, pPr, slideLstStyle, ctx)) {\n\t\tconst latin = firstChild(defRPr, 'a:latin')\n\t\tconst typeface = latin && attr(latin, 'typeface')\n\t\tif (typeface) return resolveThemeFont(typeface, ctx.fontScheme ?? null)\n\t}\n\treturn null\n}\n\n/**\n * Whether a run effectively renders with the boolean character property `name`\n * (`b`/`i`) when its own `a:rPr` sets none, walking the same chain as\n * {@link resolveInheritedRunSize}: the first `a:defRPr/@<name>` in the paragraph →\n * slide → (placeholder) layout → master → `p:txStyles` → `p:defaultTextStyle`\n * chain. The first tier that *states* the attribute wins, and its value is parsed\n * by {@link boolValue} — the same `xsd:boolean` parser the run's own `bold`/`italic`\n * getters use — so an unparseable value reports `null` rather than being read as\n * `false`. `null` when nothing in the chain states it.\n */\nfunction resolveInheritedRunFlag(\n\tname: string,\n\tph: PlaceholderRef | null,\n\tlevel: number,\n\tpPr: Element | null,\n\tslideLstStyle: Element | null,\n\tctx: ThemeContext\n): boolean | null {\n\tfor (const defRPr of inheritedRunDefRPrs(ph, level, pPr, slideLstStyle, ctx)) {\n\t\tconst raw = attr(defRPr, name)\n\t\tif (raw !== null) return boolValue(raw)\n\t}\n\treturn null\n}\n\n/**\n * Whether a run effectively renders bold when its own `a:rPr` sets no `@b`: the\n * first `a:defRPr/@b` in the inheritance chain (see {@link resolveInheritedRunFlag}).\n * A non-placeholder run skips the placeholder tiers but still reaches\n * `p:defaultTextStyle` (which sets no `@b` in a PowerPoint-written deck, so bold\n * stays `null` there). `null` when nothing in the chain defines bold.\n */\nexport function resolveInheritedRunBold(\n\tph: PlaceholderRef | null,\n\tlevel: number,\n\tpPr: Element | null,\n\tslideLstStyle: Element | null,\n\tctx: ThemeContext\n): boolean | null {\n\treturn resolveInheritedRunFlag('b', ph, level, pPr, slideLstStyle, ctx)\n}\n\n/**\n * Whether a run effectively renders italic when its own `a:rPr` sets no `@i`: the\n * first `a:defRPr/@i` in the inheritance chain (see {@link resolveInheritedRunFlag}).\n * `@b` and `@i` are siblings on `CT_TextCharacterProperties` and a master text\n * style states them together, so this is the exact twin of\n * {@link resolveInheritedRunBold} one attribute along. `null` when nothing in the\n * chain defines italic.\n */\nexport function resolveInheritedRunItalic(\n\tph: PlaceholderRef | null,\n\tlevel: number,\n\tpPr: Element | null,\n\tslideLstStyle: Element | null,\n\tctx: ThemeContext\n): boolean | null {\n\treturn resolveInheritedRunFlag('i', ph, level, pPr, slideLstStyle, ctx)\n}\n\n/**\n * The vertical anchor a placeholder text frame effectively renders when its own\n * `a:bodyPr` sets no `@anchor`: the value inherited from the layout → master\n * placeholder `a:bodyPr` (see {@link placeholderInheritedAnchor}). `null` when the\n * frame is not in a placeholder or nothing in the chain sets an anchor (PowerPoint\n * then defaults to top).\n */\nexport function resolveInheritedAnchor(ph: PlaceholderRef, ctx: ThemeContext): string | null {\n\treturn placeholderInheritedAnchor(ph.type, ph.idx, ctx)\n}\n\n/** Which tier of the slide → layout → master chain a {@link ResolvedFrame} resolved from. */\nexport type GeometrySource = 'own' | 'layout' | 'master'\n\n/** A shape's effective position and size in EMU, tagged with where it resolved from. */\nexport interface ResolvedFrame {\n\tleft: number\n\ttop: number\n\twidth: number\n\theight: number\n\tsource: GeometrySource\n}\n\n/**\n * The position/size a placeholder inherits when its own `a:spPr` carries no\n * `a:xfrm`: the matching layout placeholder's geometry, else the master's (see\n * {@link placeholderInheritedXfrm}). `null` when the chain has no matching\n * placeholder geometry to inherit, or the matched `a:xfrm` is missing an\n * `a:off`/`a:ext` coordinate. Callers that also need the \"own `a:xfrm` wins\"\n * check (the common case) use {@link Shape.resolvedFrame}, which layers that on\n * top of this.\n */\nexport function resolveInheritedFrame(ph: PlaceholderRef, ctx: ThemeContext): ResolvedFrame | null {\n\tconst found = placeholderInheritedXfrm(ph.type, ph.idx, ctx)\n\tif (!found) return null\n\t// `readBox` is the same read `absoluteFrame` and `GroupShape.childFrame` already use, and it\n\t// returns `null` for an incomplete box, which is what the four unreachable `=== undefined`\n\t// arms here were guarding against.\n\tconst box = readBox(found.xfrm, 'a:off', 'a:ext')\n\tif (!box) return null\n\treturn { left: box.x, top: box.y, width: box.cx, height: box.cy, source: found.source }\n}\n\n/**\n * A DrawingML colour reference resolved against a slide's theme to a literal hex.\n *\n * `hex` is the **base** token colour and `transforms` reports the colour-transform\n * children (`lumMod`/`lumOff`/`shade`/`tint`/`alpha`/…) in document order as\n * `{ name, value }` pairs — both kept for traceability and for the\n * `theme: 'preserve'` flatten path that re-emits the transforms verbatim.\n *\n * `effectiveHex` is the colour a renderer actually paints: `hex` with its\n * `transforms` applied (see {@link applyColorTransforms}). Read this for the final\n * rendered colour. `alpha` (0–1) is present only when an `alpha*` transform set an\n * opacity.\n */\nexport interface ResolvedColor {\n\thex: string\n\ttransforms: ColorTransform[]\n\teffectiveHex: string\n\talpha?: number\n}\n\n/**\n * Resolve a DrawingML colour *element* (every `a:EG_ColorChoice` member except\n * `a:scrgbClr` — see `read/oxml/theme.ts`) against `ctx` into a full\n * {@link ResolvedColor} — base hex, raw transform list,\n * and the `effectiveHex`/`alpha` after applying those transforms. `null` when the\n * element cannot be made literal (unmapped token, or a colour model we do not\n * resolve). Shared by the solid-fill and gradient-stop colour reads.\n */\nexport function resolveColorElement(colorEl: Element | null, ctx: ColorContext): ResolvedColor | null {\n\tconst resolved = resolveColor(colorEl, ctx)\n\tif (!resolved) return null\n\tconst transforms = resolved.transforms.map((t) => ({ name: t.localName ?? '', value: attr(t, 'val') }))\n\tconst { hex, alpha } = applyColorTransforms(resolved.hex, transforms)\n\treturn alpha === undefined\n\t\t? { hex: resolved.hex, transforms, effectiveHex: hex }\n\t\t: { hex: resolved.hex, transforms, effectiveHex: hex, alpha }\n}\n\n/**\n * A DrawingML colour as the file writes it and as it renders. Every read value type that carries a\n * colour carries one of these: a gradient stop, a shadow or glow, a bullet, a cell border, a\n * pattern's two colours, a picture's recolour, a solid background, and a chart series' fill and line.\n *\n * At most one of {@link srgb}, {@link scheme} and {@link preset} is set, naming the colour model the\n * file used. A colour written as `a:sysClr` or `a:hslClr` sets none of the three and is reported\n * through {@link resolved} alone. With no colour at all, every field is `null`.\n */\nexport interface ColorRef {\n\t/** `a:srgbClr/@val`, a 6-hex literal, or `null`. */\n\tsrgb: string | null\n\t/** `a:schemeClr/@val`, a theme token such as `accent1`, or `null`. */\n\tscheme: string | null\n\t/** `a:prstClr/@val`, a preset name such as `black`, or `null`; `presetColorHex` makes one literal. */\n\tpreset: string | null\n\t/**\n\t * The colour resolved against the theme, with its transforms applied, or `null` when there is no\n\t * colour, it cannot be made literal (an unmapped token, or `a:scrgbClr`), or it was read without a\n\t * theme, as a chart part's colours are. Read `resolved.transforms` when re-authoring against a\n\t * different theme: `effectiveHex` alone is one theme baked in, and an empty list means the file\n\t * stated no transforms.\n\t */\n\tresolved: ResolvedColor | null\n}\n\n/**\n * Read a colour element into a {@link ColorRef}.\n * @param colorEl - an `a:EG_ColorChoice` element, or `null` for no colour\n * @param ctx - the theme to resolve against, or `null` to leave {@link ColorRef.resolved} unset\n */\nexport function readColorRef(colorEl: Element | null, ctx: ColorContext | null): ColorRef {\n\treturn {\n\t\tsrgb: colorValueIf(colorEl, 'srgbClr'),\n\t\tscheme: colorValueIf(colorEl, 'schemeClr'),\n\t\tpreset: colorValueIf(colorEl, 'prstClr'),\n\t\tresolved: ctx ? resolveColorElement(colorEl, ctx) : null,\n\t}\n}\n\n/**\n * Resolve the `a:solidFill` colour of a properties container (`p:spPr`,\n * `p:grpSpPr`, `a:ln`, or a run's `a:rPr`) to a literal hex through `ctx`.\n * `null` when the container has no solid fill, or the colour cannot be made\n * literal (an unmapped token, or a colour model we do not resolve).\n */\nexport function resolveSolidFillColor(container: Element | null, ctx: ColorContext): ResolvedColor | null {\n\tif (!container) return null\n\tconst solidFill = firstChild(container, 'a:solidFill')\n\tif (!solidFill) return null\n\treturn resolveColorElement(firstChildElement(solidFill), ctx)\n}\n\n/**\n * Resolve the fill colour a shape inherits from its `p:style` `a:fillRef`\n * (style-matrix fill) to a literal hex through `ctx`. Used as the fallback for\n * `Shape.resolvedFill` when the shape carries no\n * explicit `spPr` fill choice. `null` when there is no `fillRef`, it cannot be\n * resolved, or the indexed style entry is not a solid fill (a gradient style fill\n * has no single colour — read it through `gradientStops` instead).\n */\nexport function resolveStyleFillColor(shape: Element, ctx: ThemeContext): ResolvedColor | null {\n\tconst style = firstChild(shape, 'p:style')\n\tconst fill = style && styleRefFill(firstChild(style, 'a:fillRef'), ctx)\n\tif (!fill || fill.localName !== 'solidFill') return null\n\treturn resolveColorElement(firstChildElement(fill), ctx)\n}\n\n/**\n * Resolve the line colour a shape inherits from its `p:style` `a:lnRef`\n * (style-matrix line) to a literal hex through `ctx`. Used as the fallback for\n * `Shape.resolvedLine` when the shape's `spPr/a:ln` states\n * no fill of its own. `null` when there is no `lnRef` or it cannot be resolved.\n */\nexport function resolveStyleLineColor(shape: Element, ctx: ThemeContext): ResolvedColor | null {\n\tconst style = firstChild(shape, 'p:style')\n\tconst ln = style && styleRefLine(firstChild(style, 'a:lnRef'), ctx)\n\treturn ln ? resolveSolidFillColor(ln, ctx) : null\n}\n\n/** A shape's resolved `p:style/a:fontRef` text tier: its colour and theme face. */\nexport interface StyleFontRef {\n\t/** The `a:fontRef` child colour (`a:schemeClr`/`a:srgbClr`/…) resolved through the theme, or `null` when it names none / cannot be made literal. */\n\tcolor: ResolvedColor | null\n\t/** The face named by `a:fontRef/@idx` (`major`→`+mj-lt`, `minor`→`+mn-lt`) resolved through the theme `fontScheme`, or `null` for `idx=\"none\"` / an unresolvable token. */\n\tface: string | null\n}\n\n/**\n * Resolve the text colour and typeface a shape derives from its `p:style/a:fontRef`\n * (the style-matrix font reference) — the tier PowerPoint applies to a shape's runs\n * just below their own `a:rPr` and above the placeholder/`p:defaultTextStyle` chain.\n * The `a:fontRef` child colour resolves through `ctx` like any other (it can carry\n * `lumMod`/`shade` transforms); `@idx` (`major`|`minor`|`none`) maps to the theme's\n * major/minor Latin font. `null` when the shape has no `p:style/a:fontRef` at all.\n */\nexport function resolveStyleFontRef(shape: Element, ctx: ThemeContext): StyleFontRef | null {\n\tconst style = firstChild(shape, 'p:style')\n\tconst fontRef = style && firstChild(style, 'a:fontRef')\n\tif (!fontRef) return null\n\tconst color = resolveColorElement(firstChildElement(fontRef), ctx)\n\tconst idx = attr(fontRef, 'idx')\n\tconst token = idx === 'major' ? '+mj-lt' : idx === 'minor' ? '+mn-lt' : null\n\treturn { color, face: token ? resolveThemeFont(token, ctx.fontScheme ?? null) : null }\n}\n","/**\n * Shared gradient-fill reader for DrawingML colour-bearing containers: a shape's\n * `p:spPr`, a line's `a:ln`, and a slide's `p:bg/p:bgPr`. Decodes an `a:gradFill`\n * into its stops (colour + position) plus the linear/path geometry, resolving each\n * stop's colour against the slide theme.\n */\nimport { attr, firstChild, firstChildElement, getElements, numberValue, pctAttr, type Element } from '../oxml/dom.js'\nimport type { ColorContext } from '../oxml/theme.js'\nimport { readColorRef, type ColorRef } from './theme-context.js'\nimport { ANGLE_UNITS_PER_DEGREE } from '../../units.js'\n\n/** One stop of a gradient fill (`a:gsLst/a:gs`), as read from a shape. */\nexport interface GradientStop {\n\t/** Stop offset along the gradient, 0–1 (from `@pos`, thousandths of a percent), or `null` if unset. */\n\tposition: number | null\n\t/**\n\t * The stop's colour, as written and resolved against the slide theme. Its `resolved.effectiveHex` is\n\t * the rendered colour and `resolved.alpha` the stop's opacity, when an `alpha*` transform set one.\n\t */\n\tcolorRef: ColorRef\n}\n\n/**\n * A gradient fill (`a:gradFill`), as read from a container — the stops plus the\n * geometry that a bare stop list omits. `linear` gradients carry an\n * {@link GradientFill.angleDeg} (the `a:lin/@ang` direction); `radial`/`path`\n * gradients carry a {@link GradientFill.path} shape (`a:path/@path`, e.g.\n * `circle`). The angle is in **OOXML degrees** (clockwise from 3 o'clock), the\n * same convention the write-side `GradientFillProps.angle` expects, so it\n * round-trips directly.\n */\nexport interface GradientFill {\n\t/** `linear` (`a:lin`) or `path` (`a:path`, i.e. radial/rectangular). `null` when neither child is present. */\n\tkind: 'linear' | 'path' | null\n\t/** Linear direction in OOXML degrees (clockwise from 3 o'clock), or `null` for a path gradient / when unset. */\n\tangleDeg: number | null\n\t/** Path-gradient shape (`a:path/@path`: `circle`/`rect`/`shape`), or `null` for a linear gradient. */\n\tpath: string | null\n\t/** The gradient stops in document order. */\n\tstops: GradientStop[]\n}\n\n/**\n * Read `a:gradFill/a:gsLst` stops from a container (`p:spPr` for a fill, `a:ln`\n * for a line stroke, or `p:bgPr` for a slide background). `null` when the\n * container has no gradient; `[]` when the gradient carries no stop list.\n */\nexport function readGradientStops(container: Element, ctx: ColorContext): GradientStop[] | null {\n\tconst grad = firstChild(container, 'a:gradFill')\n\tif (!grad) return null\n\tconst gsLst = firstChild(grad, 'a:gsLst')\n\tif (!gsLst) return []\n\t// `a:gs` holds exactly one `a:EG_ColorChoice` child, so the stop's colour is whichever element\n\t// that is. Reading it by *position* rather than by hunting for known tag names is what lets every\n\t// model the resolver handles reach it: a `a:prstClr`/`a:sysClr`/`a:hslClr` stop used to come back\n\t// blank in every field, though the reader resolves all three everywhere else.\n\treturn getElements(gsLst, 'a:gs').map((gs) => ({\n\t\tposition: pctAttr(gs, 'pos'),\n\t\tcolorRef: readColorRef(firstChildElement(gs), ctx),\n\t}))\n}\n\n/**\n * Read the full `a:gradFill` (stops + linear angle / path shape) from a container\n * (`p:spPr` for a fill, `a:ln` for a line stroke, or `p:bgPr` for a slide\n * background). `null` when the container has no gradient.\n */\nexport function readGradientFill(container: Element, ctx: ColorContext): GradientFill | null {\n\tconst grad = firstChild(container, 'a:gradFill')\n\tif (!grad) return null\n\tconst lin = firstChild(grad, 'a:lin')\n\tconst path = firstChild(grad, 'a:path')\n\tconst ang = lin ? numberValue(attr(lin, 'ang')) : null\n\treturn {\n\t\tkind: lin ? 'linear' : path ? 'path' : null,\n\t\tangleDeg: ang === null ? null : ang / ANGLE_UNITS_PER_DEGREE,\n\t\tpath: path ? (attr(path, 'path') ?? null) : null,\n\t\tstops: readGradientStops(container, ctx) ?? [],\n\t}\n}\n","/**\n * Shared picture-fill reader for DrawingML fill-bearing containers: a shape's\n * `p:spPr`, a table cell's `a:tcPr`, and a slide's `p:bg/p:bgPr`. Decodes an\n * `a:blipFill` into the embedded image reference plus the geometry that decides\n * how the image covers the surface — stretch vs tile, the source crop, and the\n * tile offsets/scale.\n *\n * A picture fill is not a colour, so the solid-fill accessors\n * (`AutoShape.resolvedFill`, `TableCell.resolvedFill`) report `null` for one and\n * a surface filled with an image reads as unfilled without this.\n */\nimport { attr, boolValue, firstChild, numberValue, pctAttr, type Element } from '../oxml/dom.js'\nimport type { Relationships } from '../opc/relationships.js'\nimport { resolvePartName } from '../opc/partnames.js'\n\n/** A rectangle expressed as per-edge fractions (`a:srcRect`/`a:fillRect`), `0.1` = 10 %. */\nexport interface FillRect {\n\tleft: number\n\ttop: number\n\tright: number\n\tbottom: number\n}\n\n/**\n * The tiling geometry of a tiled picture fill (`a:blipFill/a:tile`). Offsets stay\n * in EMU (the attribute's own unit); scales are fractions (`1` = 100 %), matching\n * the read API's convention elsewhere.\n */\nexport interface PictureFillTile {\n\t/** Horizontal tile offset in EMU (`@tx`), `0` when unset. */\n\toffsetXEmu: number\n\t/** Vertical tile offset in EMU (`@ty`), `0` when unset. */\n\toffsetYEmu: number\n\t/** Horizontal tile scale as a fraction (`@sx`, thousandths of a percent), `1` when unset. */\n\tscaleX: number\n\t/** Vertical tile scale as a fraction (`@sy`), `1` when unset. */\n\tscaleY: number\n\t/** Tile mirroring (`@flip`: `none`/`x`/`y`/`xy`), or `null` when unset. */\n\tflip: string | null\n\t/** Tile alignment within the surface (`@algn`, e.g. `tl`), or `null` when unset. */\n\talign: string | null\n}\n\n/**\n * A picture (image) fill (`a:blipFill`) read from a fill-bearing container. The\n * image itself is {@link relId} / {@link partName}; the rest is the geometry a\n * faithful replica needs — {@link mode} (`stretch` or `tile`), the source crop\n * {@link srcRect}, the destination inset {@link fillRect}, and {@link tile}.\n *\n * Rect fields follow the read API's fraction convention (see\n * {@link Picture.crop}): the raw attributes are\n * thousandths of a percent and are divided by 100000, so `0.1` is 10 % and a\n * negative value (a `fillRect` that bleeds past the edge) stays negative.\n */\nexport interface PictureFill {\n\t/** Relationship id of the embedded image (`a:blip/@r:embed`), or `null` when the blip embeds none. */\n\trelId: string | null\n\t/** Absolute partname of the embedded image, or `null` when it has no rel id / no resolvable target. */\n\tpartName: string | null\n\t/** `stretch` (`a:stretch`) or `tile` (`a:tile`); `null` when the fill states neither. */\n\tmode: 'stretch' | 'tile' | null\n\t/** Source crop as per-edge fractions (`a:srcRect`), or `null` when absent. An explicit `<a:srcRect/>` reports zeros. */\n\tsrcRect: FillRect | null\n\t/** Stretch destination rect as per-edge fractions (`a:stretch/a:fillRect`), or `null` when absent. */\n\tfillRect: FillRect | null\n\t/** Tiling geometry (`a:tile`), or `null` when the fill is not tiled. */\n\ttile: PictureFillTile | null\n\t/** Blip opacity 0–1 (`a:blip/a:alphaModFix/@amt`), or `null` when the blip sets none. */\n\talpha: number | null\n\t/** DPI override the image is rendered at (`@dpi`), or `null` when unset. `0` means \"use the image's own\". */\n\tdpi: number | null\n\t/** Whether the fill rotates with its shape (`@rotWithShape`), or `null` when unset. */\n\trotWithShape: boolean | null\n}\n\n/** Per-edge fractions of a rect element, absent attributes reading as `0`. */\nexport function readRect(rect: Element): FillRect {\n\tconst edge = (name: string): number => pctAttr(rect, name) ?? 0\n\treturn { left: edge('l'), top: edge('t'), right: edge('r'), bottom: edge('b') }\n}\n\n/** Decode an `a:tile`: offsets stay in EMU, scales become fractions defaulting to `1`. */\nfunction readTile(tile: Element): PictureFillTile {\n\tconst scale = (name: string): number => pctAttr(tile, name) ?? 1\n\treturn {\n\t\toffsetXEmu: numberValue(attr(tile, 'tx')) ?? 0,\n\t\toffsetYEmu: numberValue(attr(tile, 'ty')) ?? 0,\n\t\tscaleX: scale('sx'),\n\t\tscaleY: scale('sy'),\n\t\tflip: attr(tile, 'flip'),\n\t\talign: attr(tile, 'algn'),\n\t}\n}\n\n/**\n * Read an `a:blipFill` from a container (`p:spPr`, `a:tcPr`, or `p:bgPr`) into a\n * {@link PictureFill}. `rels` — the *owning part's* relationships — resolves the\n * blip's `r:embed` to an absolute partname; pass `null` (or omit) to read the\n * geometry without resolving the image. `null` when the container's fill is not\n * a picture.\n */\nexport function readPictureFill(container: Element, rels: Relationships | null = null): PictureFill | null {\n\tconst blipFill = firstChild(container, 'a:blipFill')\n\tif (!blipFill) return null\n\n\tconst blip = firstChild(blipFill, 'a:blip')\n\tconst relId = blip ? attr(blip, 'r:embed') : null\n\tconst alphaMod = blip && firstChild(blip, 'a:alphaModFix')\n\tconst amt = alphaMod ? pctAttr(alphaMod, 'amt') : null\n\n\tconst srcRect = firstChild(blipFill, 'a:srcRect')\n\tconst stretch = firstChild(blipFill, 'a:stretch')\n\tconst fillRect = stretch && firstChild(stretch, 'a:fillRect')\n\tconst tile = firstChild(blipFill, 'a:tile')\n\n\treturn {\n\t\trelId,\n\t\tpartName: resolvePartName(relId, rels),\n\t\tmode: stretch ? 'stretch' : tile ? 'tile' : null,\n\t\tsrcRect: srcRect ? readRect(srcRect) : null,\n\t\tfillRect: fillRect ? readRect(fillRect) : null,\n\t\ttile: tile ? readTile(tile) : null,\n\t\t// `a:alphaModFix` omits `amt` to mean fully opaque (the schema default).\n\t\talpha: alphaMod ? (amt ?? 1) : null,\n\t\tdpi: numberValue(attr(blipFill, 'dpi')),\n\t\trotWithShape: boolValue(attr(blipFill, 'rotWithShape')),\n\t}\n}\n","/**\n * Shared pattern-fill reader for DrawingML colour-bearing containers: a shape's `p:spPr`, a\n * slide's `p:bg/p:bgPr`, and a table's `a:tblPr` / cell's `a:tcPr`.\n *\n * `a:pattFill` is a preset hatch name plus two wrapped colours, and decoding it is three\n * lines — which is exactly why it had been open-coded in each place that needed it. Sharing\n * it is what keeps the three from drifting into different answers for the same element, the\n * same reason `readGradientFill` and\n * `readPictureFill` are shared.\n */\nimport { attr, firstChild, firstChildElement, type Element } from '../oxml/dom.js'\nimport type { ColorContext } from '../oxml/theme.js'\nimport { readColorRef, type ColorRef } from './theme-context.js'\n\n/**\n * A pattern fill (`a:pattFill`) — a two-colour preset hatch. The write-side\n * `fill: { type: 'pattern', pattern: { preset, fgColor, bgColor } }` emits the same element,\n * so the {@link preset} name and both colours round-trip.\n */\nexport interface PatternFill {\n\t/** Preset pattern name (`@prst`, e.g. `pct50`/`diagCross`/`ltUpDiag`), or `null` when unset. */\n\tpreset: string | null\n\t/** Foreground colour (`a:fgClr`); every field is `null` when the pattern states none. */\n\tforeground: ColorRef\n\t/** Background colour (`a:bgClr`); every field is `null` when the pattern states none. */\n\tbackground: ColorRef\n}\n\n/**\n * Read a container's `a:pattFill`, or `null` when its fill is not a pattern.\n * @param {Element} container - the fill-bearing parent (`p:spPr`, `p:bgPr`, `a:tblPr`, `a:tcPr`, …)\n * @param {ColorContext} ctx - the theme colour context each colour resolves against\n * @returns {PatternFill | null} the decoded hatch, or `null`\n */\nexport function readPatternFill(container: Element, ctx: ColorContext): PatternFill | null {\n\tconst patt = firstChild(container, 'a:pattFill')\n\tif (!patt) return null\n\t// `a:fgClr` and `a:bgClr` wrap their colour element, unlike `a:highlight`'s bare child.\n\tconst colorOf = (qname: string): ColorRef => {\n\t\tconst wrap = firstChild(patt, qname)\n\t\treturn readColorRef(wrap ? firstChildElement(wrap) : null, ctx)\n\t}\n\treturn {\n\t\tpreset: attr(patt, 'prst') ?? null,\n\t\tforeground: colorOf('a:fgClr'),\n\t\tbackground: colorOf('a:bgClr'),\n\t}\n}\n","/**\n * Shape-element plumbing: the small element lookups every shape kind performs, plus the\n * shape-scoped re-exports of the shared schema-successor lists.\n *\n * The successor arrays are the reason a setter can create a missing `a:xfrm` / `a:solidFill` /\n * `a:ln` without corrupting the part: `getOrAddChild` inserts before the first listed sibling it\n * finds, so each list must name exactly the children that legally *follow* the one being added.\n * They are declared once in `src/ooxml/sequence.ts` (derived from each complexType's sequence)\n * and re-exported here so the shape modules keep importing them from one place.\n */\n\nimport {\n\tELEMENT_NODE,\n\tOOXML_NS,\n\tattr,\n\tchildElements,\n\tfirstChild,\n\tgetOrAddChild,\n\tnumberValue,\n\ttype Element,\n} from '../../oxml/dom.js'\nimport { SHAPE_AFTER_SPPR, SPPR_AFTER_XFRM } from '../../../ooxml/sequence.js'\n\nexport {\n\tGROUP_AFTER_GRPSPPR,\n\tGRPSPPR_AFTER_XFRM,\n\tGRPSPPR_FILL_AFTER,\n\tLN_FILL_AFTER,\n\tSHAPE_AFTER_SPPR,\n\tSPPR_AFTER_XFRM,\n\tSPPR_FILL_AFTER,\n\tSPPR_LN_AFTER,\n} from '../../../ooxml/sequence.js'\n\n/**\n * Where a shape kind's paint is written: its properties element (`p:spPr` / `p:grpSpPr`), created\n * in document order on demand, and for each paint the schema successors that paint's element is\n * inserted before, or `null` for a paint the kind cannot carry (a group's `p:grpSpPr` has no\n * `a:ln`).\n */\nexport interface PaintSurface {\n\tgetOrAdd(): Element\n\tfill: readonly string[] | null\n\tline: readonly string[] | null\n}\n\n/** First `<p:cNvPr>` reached through the shape's non-visual properties wrapper (`p:nv*Pr`). */\nexport function nonVisualCNvPr(element: Element): Element | null {\n\tfor (let node = element.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\tconst child = node as Element\n\t\tif (child.namespaceURI === OOXML_NS.p && child.localName?.startsWith('nv')) {\n\t\t\treturn firstChild(child, 'p:cNvPr')\n\t\t}\n\t}\n\treturn null\n}\n\nexport function emuFrom(parent: Element | null, qname: string, attribute: string): number | null {\n\tconst element = parent && firstChild(parent, qname)\n\treturn element ? numberValue(attr(element, attribute)) : null\n}\n\nexport { childElements }\n\n/** Get-or-add `p:spPr/a:xfrm` for shapes whose transform lives in `p:spPr` (`p:sp`, `p:pic`, `p:cxnSp`). */\nexport function getOrAddSpPrXfrm(shapeElement: Element): Element {\n\tconst spPr = getOrAddChild(shapeElement, 'p:spPr', SHAPE_AFTER_SPPR)\n\treturn getOrAddChild(spPr, 'a:xfrm', SPPR_AFTER_XFRM)\n}\n","/**\n * Group-shape transform composition — the `p:grpSp` child-space mapping, shared\n * by every surface that needs slide-absolute geometry.\n *\n * A `p:grpSp` declares two frames on its `a:xfrm`: where it sits on the slide\n * (`a:off`/`a:ext`) and the coordinate space its children are authored in\n * (`a:chOff`/`a:chExt`). A child's own `a:off`/`a:ext` is expressed in that child\n * space, so it is not directly placeable on the slide — it must be mapped through\n * `off + (p - chOff) * (ext / chExt)` for every enclosing group, with the group's\n * `@rot`/`@flipH`/`@flipV` composed on top.\n *\n * This module is deliberately **pure**: it takes decoded numbers, not XML, so the\n * mapping stays one implementation no matter how many surfaces need it. It was\n * shared between two independent readers before the inspect surface became a\n * projection over the read model; today `Shape.absoluteFrame` is the only caller,\n * and the separation still earns its keep by keeping the arithmetic testable\n * without a package to parse.\n */\n\n/** A position + extent pair in EMU (`a:off`/`a:ext`, or `a:chOff`/`a:chExt`). */\ninterface TransformBox {\n\tx: number\n\ty: number\n\tcx: number\n\tcy: number\n}\n\n/** A shape's own `a:xfrm`, decoded. `rotation` is in degrees (the raw `@rot` / 60000). */\ninterface ShapeTransform {\n\tbox: TransformBox\n\trotation: number\n\tflipH: boolean\n\tflipV: boolean\n}\n\n/**\n * An enclosing `p:grpSp`'s `a:xfrm`, decoded: `outer` is the group's own frame on\n * the slide (`a:off`/`a:ext`), `child` the space its children are authored in\n * (`a:chOff`/`a:chExt`).\n */\nexport interface GroupTransform {\n\touter: TransformBox\n\tchild: TransformBox\n\trotation: number\n\tflipH: boolean\n\tflipV: boolean\n}\n\n/** A slide-absolute frame: the unrotated placement box plus effective orientation. */\ninterface ComposedFrame {\n\tbox: TransformBox\n\t/** Effective clockwise rotation in degrees, normalised to [0, 360). */\n\trotation: number\n\t/** Effective horizontal flip, XOR-composed across the group chain. */\n\tflipH: boolean\n\t/** Effective vertical flip, XOR-composed across the group chain. */\n\tflipV: boolean\n}\n\n/** Normalise a degree value into [0, 360). */\nfunction normalizeDegrees(value: number): number {\n\treturn ((value % 360) + 360) % 360\n}\n\n/** Rotate `point` clockwise about `center` by `degrees`. */\nfunction rotatePoint(\n\tpoint: { x: number; y: number },\n\tcenter: { x: number; y: number },\n\tdegrees: number\n): { x: number; y: number } {\n\tif (degrees === 0) return point\n\tconst angle = (degrees * Math.PI) / 180\n\tconst cos = Math.cos(angle)\n\tconst sin = Math.sin(angle)\n\tconst dx = point.x - center.x\n\tconst dy = point.y - center.y\n\treturn {\n\t\tx: center.x + cos * dx - sin * dy,\n\t\ty: center.y + sin * dx + cos * dy,\n\t}\n}\n\n/**\n * Compose a shape's own transform with every enclosing group transform into a\n * slide-absolute frame.\n *\n * `groups` runs **innermost first** (the shape's immediate `p:grpSp` parent, then\n * outward). An empty list returns the shape's own box and orientation unchanged.\n *\n * The returned `box` is the *unrotated* placement box — the same box PowerPoint\n * writes when you Ungroup — with the effective rotation reported separately.\n * Values are exact; callers round or convert units as they see fit.\n *\n * Returns `null` when a group's `a:chExt` is degenerate (zero on either axis):\n * the child-space ratio is then undefined and there is no resolvable frame.\n */\nexport function composeGroupFrame(shape: ShapeTransform, groups: GroupTransform[]): ComposedFrame | null {\n\tlet center = { x: shape.box.x + shape.box.cx / 2, y: shape.box.y + shape.box.cy / 2 }\n\tlet width = shape.box.cx\n\tlet height = shape.box.cy\n\tlet flipH = shape.flipH\n\tlet flipV = shape.flipV\n\n\t// Group centres are collected on the way out, then rotated on the way back in:\n\t// an outer group rotates the centres of the inner groups nested inside it, so\n\t// the two passes cannot be merged.\n\tconst chain: { center: { x: number; y: number }; rotation: number; flipH: boolean; flipV: boolean }[] = []\n\n\tfor (const group of groups) {\n\t\tif (group.child.cx === 0 || group.child.cy === 0) return null // degenerate child frame — no resolvable mapping\n\t\tconst ratioX = group.outer.cx / group.child.cx\n\t\tconst ratioY = group.outer.cy / group.child.cy\n\n\t\tconst mapPoint = (point: { x: number; y: number }): { x: number; y: number } => {\n\t\t\tlet x = group.outer.x + (point.x - group.child.x) * ratioX\n\t\t\tlet y = group.outer.y + (point.y - group.child.y) * ratioY\n\t\t\tif (group.flipH) x = group.outer.x + group.outer.cx - (x - group.outer.x)\n\t\t\tif (group.flipV) y = group.outer.y + group.outer.cy - (y - group.outer.y)\n\t\t\treturn { x, y }\n\t\t}\n\t\tcenter = mapPoint(center)\n\t\tfor (const entry of chain) entry.center = mapPoint(entry.center)\n\t\twidth *= Math.abs(ratioX)\n\t\theight *= Math.abs(ratioY)\n\t\tchain.push({\n\t\t\tcenter: { x: group.outer.x + group.outer.cx / 2, y: group.outer.y + group.outer.cy / 2 },\n\t\t\trotation: group.rotation,\n\t\t\tflipH: group.flipH,\n\t\t\tflipV: group.flipV,\n\t\t})\n\t\tflipH = flipH !== group.flipH\n\t\tflipV = flipV !== group.flipV\n\t}\n\n\tlet rotation = 0\n\t// A group flipped on exactly one axis mirrors the sense of every rotation\n\t// nested inside it, so track orientation as the chain is walked back inward.\n\tlet orientation = 1\n\tfor (let index = chain.length - 1; index >= 0; index--) {\n\t\tconst group = chain[index]\n\t\tif (!group) continue\n\t\tconst groupRotation = group.rotation * orientation\n\t\tcenter = rotatePoint(center, group.center, groupRotation)\n\t\tfor (let innerIndex = 0; innerIndex < index; innerIndex++) {\n\t\t\tconst inner = chain[innerIndex]\n\t\t\tif (inner) inner.center = rotatePoint(inner.center, group.center, groupRotation)\n\t\t}\n\t\trotation += groupRotation\n\t\tif (group.flipH !== group.flipV) orientation *= -1\n\t}\n\n\treturn {\n\t\tbox: { x: center.x - width / 2, y: center.y - height / 2, cx: width, cy: height },\n\t\trotation: normalizeDegrees(rotation + shape.rotation * orientation),\n\t\tflipH,\n\t\tflipV,\n\t}\n}\n","/**\n * Shared line reader for DrawingML strokes: a shape's `p:spPr/a:ln`, a table cell's edges\n * (`a:tcPr/a:lnL` and its siblings, each a `CT_LineProperties`), and a chart series'\n * `c:spPr/a:ln`.\n *\n * Each of the three decoded the width, the dash preset, the solid colour and an explicit no-line\n * on its own, the drift `readGradientFill` and\n * `readPatternFill` are shared to prevent.\n */\nimport { attr, firstChild, firstChildElement, numberValue, type Element } from '../oxml/dom.js'\nimport type { ColorContext } from '../oxml/theme.js'\nimport { ptFromEmu } from './coords.js'\nimport { readColorRef, type ColorRef } from './theme-context.js'\n\n/** What every reader of an `a:ln` decodes from it. */\nexport interface LineBasics {\n\t/** Stroke width in points (`@w` is EMU; 12700 EMU = 1pt), or `null` when unset. */\n\twidthPt: number | null\n\t/** Dash preset (`a:prstDash/@val`, e.g. `sysDash`), or `null` when unset. */\n\tdash: string | null\n\t/**\n\t * The line's solid colour (`a:solidFill`); every field is `null` when it has none. `resolved` is\n\t * also `null` when no theme was given to resolve it against.\n\t */\n\tcolorRef: ColorRef\n\t/** `true` when the line is explicitly suppressed (`a:noFill`). */\n\tnoFill: boolean\n}\n\n/**\n * Decode a line element's width, dash, solid colour and no-fill flag.\n * @param ln - the `CT_LineProperties` element\n * @param ctx - the theme the colour resolves against, or `null` to leave `colorRef.resolved` unset\n */\nexport function readLineBasics(ln: Element, ctx: ColorContext | null): LineBasics {\n\tconst dash = firstChild(ln, 'a:prstDash')\n\tconst solidFill = firstChild(ln, 'a:solidFill')\n\treturn {\n\t\twidthPt: ptFromEmu(numberValue(attr(ln, 'w'))),\n\t\tdash: dash ? (attr(dash, 'val') ?? null) : null,\n\t\tcolorRef: readColorRef(solidFill ? firstChildElement(solidFill) : null, ctx),\n\t\tnoFill: !!firstChild(ln, 'a:noFill'),\n\t}\n}\n","/**\n * `a:hlinkClick` — the one reading of a click hyperlink, wherever it hangs.\n *\n * DrawingML puts the same element in two places: on a run's `a:rPr`, which links a span of text,\n * and on a shape's `p:cNvPr`, which links the whole shape. They are the same element with the same\n * attributes and the same relationship resolution, so they are read here once. The run's reader\n * used to hold the only copy, and the shape's reader did not exist -- a shape-level link read back\n * as nothing at all, so a replica lost it with nothing to say so.\n */\n\nimport { attr, type Element, firstChild } from '../oxml/dom.js'\nimport type { Relationships } from '../opc/relationships.js'\n\n/**\n * A click hyperlink (`a:hlinkClick`), on a run or on a shape. A URL link carries an external\n * {@link url}; a slide jump carries the internal {@link targetPartName} (the linked slide's part)\n * alongside its `hlinksldjump` {@link action}. `tooltip` and `relId` are surfaced when present.\n */\nexport interface Hyperlink {\n\t/** External URL target (its `@r:id` resolves to a `TargetMode=\"External\"` rel), or `null` for an internal/action-only link. */\n\turl: string | null\n\t/** Absolute partname of an internal target (e.g. the slide a jump points at), or `null`. */\n\ttargetPartName: string | null\n\t/** Navigation action token (`@action`, e.g. `ppaction://hlinksldjump`), or `null` when absent/empty. */\n\taction: string | null\n\t/** Tooltip text (`@tooltip`), or `null` when absent/empty. */\n\ttooltip: string | null\n\t/** The relationship id (`@r:id`) backing the link, or `null` when the link is action-only. */\n\trelId: string | null\n}\n\n/**\n * Read the `a:hlinkClick` child of `parent`, or `null` when there is none.\n *\n * Without `rels` only the raw `@r:id`/`@action`/`@tooltip` are reported and the target stays\n * `null`: an id means nothing outside the part that declares it, and guessing at one would be\n * worse than saying nothing. That is the case a SmartArt drawing's cached text is read in.\n * @param parent - the element that may carry the link (`a:rPr` or `p:cNvPr`)\n * @param rels - the owning part's relationships, or `null` when they are not available\n */\nexport function readHyperlink(parent: Element | null, rels: Relationships | null): Hyperlink | null {\n\tconst hlink = parent && firstChild(parent, 'a:hlinkClick')\n\tif (!hlink) return null\n\tconst relId = attr(hlink, 'r:id') || null\n\tconst action = attr(hlink, 'action') || null\n\tconst tooltip = attr(hlink, 'tooltip') || null\n\tlet url: string | null = null\n\tlet targetPartName: string | null = null\n\tif (relId && rels) {\n\t\tconst rel = rels.get(relId)\n\t\tif (rel?.targetMode === 'External') url = rel.target\n\t\telse if (rel) targetPartName = rels.resolveTarget(relId)\n\t}\n\treturn { url, targetPartName, action, tooltip, relId }\n}\n","/**\n * Decoding a shape's `a:effectLst` — shadow, glow, reflection, soft edge.\n *\n * Free functions over `(effectLst, ctx)` rather than methods, because that is all they ever\n * needed: the block was five getters and two private helpers on `Shape` whose only reference\n * to the class was `themeContext()`. Lifting it out is what makes `shapes/base.ts` a shape\n * rather than a shape plus an effect decoder, and it puts the effects beside the other\n * per-concern modules `shapes/` already has (`oxml.ts`, `geometry.ts`).\n *\n * Every decoder returns `null` for an absent element rather than an empty object, and leaves an\n * unstated attribute off its result rather than defaulting it — \"absent\" and \"stated as the\n * default\" are different facts about the source part, and a replica that has to carry the\n * effect needs to know which it is.\n */\n\nimport { attr, firstChild, firstChildElement, numberValue, pctAttr, type Element } from '../../oxml/dom.js'\nimport { readColorRef } from '../theme-context.js'\nimport type { ColorContext } from '../../oxml/theme.js'\nimport type { Glow, InnerShadow, OuterShadow, Reflection, SoftEdge } from './types.js'\nimport { ANGLE_UNITS_PER_DEGREE, EMU_PER_POINT } from '../../../units.js'\n\n/**\n * One scaled attribute of an effect element, or `null` when the element does not state it.\n *\n * `a:effectLst`'s children carry their measures in EMU and 60,000ths of a degree, and every\n * decoder below has to divide. Four of them did it inline and one built a local `put` helper\n * four lines from the last inline copy; naming the operation once is what keeps the divisor and\n * the \"absent stays absent\" rule from being restated per attribute.\n * @param el - the effect element\n * @param name - the attribute name\n * @param divisor - EMU per point, or angle units per degree\n * @returns the scaled value, or `null`\n */\nfunction scaledAttr(el: Element, name: string, divisor: number): number | null {\n\tconst raw = numberValue(attr(el, name))\n\treturn raw === null ? null : raw / divisor\n}\n\n/** A named child of an effect list (`a:effectLst/<qname>`), or `null`. */\nfunction effect(effectLst: Element | null, qname: string): Element | null {\n\treturn effectLst ? firstChild(effectLst, qname) : null\n}\n\n/**\n * Decode a shadow element (`a:outerShdw`/`a:innerShdw` share the fields), resolving its colour.\n * @param shdw - the shadow element\n * @param ctx - the host's colour context\n * @returns the decoded shadow\n */\nfunction readShadow(shdw: Element, ctx: ColorContext): OuterShadow {\n\t// `a:EG_ColorChoice` is a required, single-member group, so the colour element is the shadow's\n\t// only child and taking the first one is both correct and total — the same thing `glow` below\n\t// does. Naming `a:srgbClr` and `a:schemeClr` explicitly dropped the other four models on the\n\t// floor: `a:sysClr` resolves everywhere else in the read model, and this library emits\n\t// `a:prstClr` itself (`gen/slide/notes.ts`). `resolveColor` now answers for five of the six\n\t// (`a:scrgbClr` is the exception, and reports no colour rather than a guessed one).\n\tconst out: OuterShadow = { colorRef: readColorRef(firstChildElement(shdw), ctx) }\n\tconst blur = scaledAttr(shdw, 'blurRad', EMU_PER_POINT)\n\tconst dist = scaledAttr(shdw, 'dist', EMU_PER_POINT)\n\tconst dir = scaledAttr(shdw, 'dir', ANGLE_UNITS_PER_DEGREE)\n\tif (blur !== null) out.blurPt = blur\n\tif (dist !== null) out.offsetPt = dist\n\tif (dir !== null) out.angleDeg = dir\n\treturn out\n}\n\n/**\n * The outer drop shadow (`a:effectLst/a:outerShdw`), or `null`.\n * @param effectLst - the shape's effect list, if any\n * @param ctx - the host's colour context\n */\nexport function readOuterShadow(effectLst: Element | null, ctx: ColorContext): OuterShadow | null {\n\tconst shdw = effect(effectLst, 'a:outerShdw')\n\treturn shdw ? readShadow(shdw, ctx) : null\n}\n\n/**\n * The inner shadow (`a:effectLst/a:innerShdw`), or `null`.\n * @param effectLst - the shape's effect list, if any\n * @param ctx - the host's colour context\n */\nexport function readInnerShadow(effectLst: Element | null, ctx: ColorContext): InnerShadow | null {\n\tconst shdw = effect(effectLst, 'a:innerShdw')\n\treturn shdw ? readShadow(shdw, ctx) : null\n}\n\n/**\n * The glow halo (`a:effectLst/a:glow`), or `null`.\n * @param effectLst - the shape's effect list, if any\n * @param ctx - the host's colour context\n */\nexport function readGlow(effectLst: Element | null, ctx: ColorContext): Glow | null {\n\tconst glow = effect(effectLst, 'a:glow')\n\tif (!glow) return null\n\tconst out: Glow = { colorRef: readColorRef(firstChildElement(glow), ctx) }\n\tconst rad = scaledAttr(glow, 'rad', EMU_PER_POINT)\n\tif (rad !== null) out.radiusPt = rad\n\treturn out\n}\n\n/**\n * The reflection (`a:effectLst/a:reflection`), or `null`. Carries no colour: a reflection is a\n * transform of what is already painted.\n * @param effectLst - the shape's effect list, if any\n */\nexport function readReflection(effectLst: Element | null): Reflection | null {\n\tconst refl = effect(effectLst, 'a:reflection')\n\tif (!refl) return null\n\tconst out: Reflection = {}\n\tconst put = (target: keyof Reflection, name: string, div: number): void => {\n\t\tconst v = scaledAttr(refl, name, div)\n\t\tif (v !== null) out[target] = v\n\t}\n\tconst putPct = (target: keyof Reflection, name: string): void => {\n\t\tconst v = pctAttr(refl, name)\n\t\tif (v !== null) out[target] = v\n\t}\n\tput('blurPt', 'blurRad', EMU_PER_POINT)\n\tput('offsetPt', 'dist', EMU_PER_POINT)\n\tput('angleDeg', 'dir', ANGLE_UNITS_PER_DEGREE)\n\tput('fadeAngleDeg', 'fadeDir', ANGLE_UNITS_PER_DEGREE)\n\tputPct('startAlpha', 'stA')\n\tputPct('startPos', 'stPos')\n\tputPct('endAlpha', 'endA')\n\tputPct('endPos', 'endPos')\n\treturn out\n}\n\n/**\n * The soft (feathered) edge (`a:effectLst/a:softEdge`), or `null`.\n * @param effectLst - the shape's effect list, if any\n */\nexport function readSoftEdge(effectLst: Element | null): SoftEdge | null {\n\tconst soft = effect(effectLst, 'a:softEdge')\n\tif (!soft) return null\n\tconst rad = scaledAttr(soft, 'rad', EMU_PER_POINT)\n\treturn { radiusPt: rad ?? 0 }\n}\n","/**\n * The `Run` read/write proxy (`a:r`), and the value types a run's own reads answer with.\n *\n * A run is where inheritance actually bites: an uncoloured, unsized, unfaced run resolves\n * through the placeholder tier, the shape's `p:style/a:fontRef` and the presentation's\n * `p:defaultTextStyle`, which is why {@link TextContext} threads down to here from the frame.\n */\nimport type { Part } from '../../opc/part.js'\nimport type { Relationships } from '../../opc/relationships.js'\nimport { type Hyperlink, readHyperlink } from '../hyperlink.js'\nimport {\n\tattr,\n\tboolValue,\n\ttype Element,\n\tfirstChild,\n\tfirstChildElement,\n\tgetOrAddChild,\n\tnumberValue,\n\tpctPointsAttr,\n\tremoveAttr,\n\tremoveChildrenByQName,\n\tsetAttr,\n} from '../../oxml/dom.js'\nimport { applySolidFill, hasFillChoice, solidFillColor, type SolidFillEdit } from '../../oxml/fill.js'\nimport { checkEnumOrThrow } from '../../../ooxml/check-enum.js'\nimport { TEXT_UNDERLINE_TYPES } from '../../../ooxml/st-enums.js'\nimport { resolveThemeFont, type ThemeContext } from '../../oxml/theme.js'\nimport {\n\tresolveColorElement,\n\tresolveSolidFillColor,\n\ttype ColorRef,\n\ttype PlaceholderRef,\n\ttype ResolvedColor,\n\ttype StyleFontRef,\n} from '../theme-context.js'\nimport { InvalidOptionError } from '../../../errors.js'\nimport { ptToHundredths } from '../../../units.js'\nimport { RPR_FILL_AFTER, RPR_LATIN_AFTER } from '../../../ooxml/sequence.js'\nimport { ptFromHundredths } from '../coords.js'\nimport type { TableCellTextStyle } from '../table-style-resolve.js'\n\n/**\n * What a text body is read against, handed from a {@link TextFrame} to each paragraph and run: the\n * part an edit marks dirty, the theme the `resolved*` getters resolve against, the relationships\n * a hyperlink or a picture bullet resolves through, and the inheritance its runs fall back through.\n */\nexport interface TextContext {\n\t/** The part the text lives in. */\n\tpart: Part\n\t/** The theme the text resolves against: the colour maps, `fontScheme`, and the layout and master roots. */\n\tctx: ThemeContext\n\t/**\n\t * The owning part's relationships, or `null` for text read without them — a SmartArt drawing's\n\t * cached text — whose run hyperlinks then report their raw `@r:id`, `@action` and `@tooltip`.\n\t */\n\trels: Relationships | null\n\t/**\n\t * What a run that sets no colour, size, face, bold or italic of its own inherits through, or\n\t * `null` for text that inherits through nothing, such as a SmartArt point's.\n\t */\n\tinherit: TextInheritance | null\n}\n\n/** The inheritance a shape's or a table cell's text resolves through below its own run properties. */\nexport interface TextInheritance {\n\t/**\n\t * The placeholder the text lives in, or `null` for a non-placeholder shape, which still resolves\n\t * its `p:style/a:fontRef` and the presentation's `p:defaultTextStyle`.\n\t */\n\tph: PlaceholderRef | null\n\t/** The shape's resolved `p:style/a:fontRef` colour and face, or `null` when it has none. */\n\tfontRef: StyleFontRef | null\n\t/**\n\t * A table cell's text style: what the table style's `a:tcTxStyle` gives the cell's region, with\n\t * the theme's `tx1` and minor font where it names no colour or face. Read after {@link fontRef}\n\t * and before the list-style chain. Absent for text outside a table.\n\t */\n\ttableText?: TableCellTextStyle | null\n}\n\n/**\n * What the runs of one paragraph inherit, each property resolved at most once and only when a run\n * that sets no value of its own asks. Every run in a paragraph shares its level and `a:pPr`, so\n * they share one of these.\n */\nexport interface InheritedRunProps {\n\tcolor(): ResolvedColor | null\n\tsize(): number | null\n\tface(): string | null\n\tbold(): boolean | null\n\titalic(): boolean | null\n}\n\n/**\n * A paragraph's line spacing (`a:pPr/a:lnSpc`), in whichever of the two OOXML\n * forms the file uses: an exact point height (`a:spcPts`) or a percentage of the\n * single-line height (`a:spcPct` — e.g. `percent: 150` for 1.5× spacing).\n */\nexport type LineSpacing = { type: 'points'; valuePt: number } | { type: 'percent'; percent: number }\n\n/**\n * The bullet's own font, size and colour (`a:buFont` / `a:buSzPct` / `a:buSzPts` /\n * `a:buClr`) — the properties that style the glyph or number itself rather than\n * the text after it. Every field is `null` when the paragraph leaves it to be\n * inherited from the list style.\n *\n * These are siblings of the bullet kind in `a:pPr`, not children of it, so they\n * are carried alongside each kind rather than inside it.\n */\nexport interface BulletStyle {\n\t/** `a:buFont/@typeface` — the face the glyph is drawn in (a symbol font such as `Wingdings`), or `null`. */\n\tfont: string | null\n\t/** `a:buSzPct/@val` as a percentage of the run size (e.g. `80`; the raw attribute is thousandths of a percent), or `null`. */\n\tsizePct: number | null\n\t/** `a:buSzPts/@val` as an absolute point size (the raw attribute is hundredths of a point), or `null`. The alternative to {@link sizePct}; at most one is set. */\n\tsizePt: number | null\n\t/** The bullet's own colour (`a:buClr`); every field is `null` when the paragraph leaves it to be inherited. */\n\tcolorRef: ColorRef\n}\n\n/**\n * A paragraph's bullet, as the structured counterpart of the `a:pPr` bullet\n * children. Discriminated on `kind`, which is one of the four mutually\n * exclusive choices the schema allows:\n *\n * - `'none'` — `a:buNone`, the bullet explicitly suppressed. Carries no style,\n * because there is no glyph to style.\n * - `'char'` — `a:buChar`, a literal glyph.\n * - `'autoNum'` — `a:buAutoNum`, an auto-numbered list.\n * - `'picture'` — `a:buBlip`, an image used as the glyph.\n *\n * A paragraph that names none of them inherits its bullet from the list style and\n * reports `null` rather than a member of this union.\n */\nexport type BulletDetail =\n\t| { kind: 'none' }\n\t| ({\n\t\t\tkind: 'char'\n\t\t\t/** The glyph itself (`a:buChar/@char`) — a bare character, never a tagged string. */\n\t\t\tchar: string\n\t } & BulletStyle)\n\t| ({\n\t\t\tkind: 'autoNum'\n\t\t\t/** The numbering scheme (`a:buAutoNum/@type`, e.g. `arabicPeriod`). */\n\t\t\tscheme: string\n\t\t\t/**\n\t\t\t * The number this list starts at (`a:buAutoNum/@startAt`), or `null` when\n\t\t\t * unset (the schema default is 1). Content rather than styling: a list\n\t\t\t * continuing \"5. Deploy\" that restarts at 1 is a different slide.\n\t\t\t */\n\t\t\tstartAt: number | null\n\t } & BulletStyle)\n\t| ({\n\t\t\tkind: 'picture'\n\t\t\t/**\n\t\t\t * Absolute partname of the image used as the glyph (`a:buBlip/a:blip/@r:embed`,\n\t\t\t * resolved through the owning part's relationships), or `null` when the\n\t\t\t * paragraph was reached without them or the blip carries no `r:embed`.\n\t\t\t */\n\t\t\timagePartName: string | null\n\t } & BulletStyle)\n\n/** One text run (`a:r`): a span of text with uniform character formatting. */\nexport class Run {\n\tconstructor(\n\t\tprivate readonly element: Element,\n\t\t/**\n\t\t * What the run is read against; see {@link TextContext}. Its `inherit.fontRef` is the tier\n\t\t * {@link resolvedColor} and {@link resolvedFontFace} consult just below the run's own `a:rPr`\n\t\t * and above the placeholder and `p:defaultTextStyle` chain.\n\t\t */\n\t\tprivate readonly context: TextContext,\n\t\t/**\n\t\t * What the run inherits when it sets no colour, size, face, bold or italic of its own, or `null`\n\t\t * for text that inherits through nothing. Built by the owning {@link Paragraph} and shared by\n\t\t * its runs; nothing in it is resolved until a run asks.\n\t\t */\n\t\tprivate readonly inherited: InheritedRunProps | null\n\t) {}\n\n\t/** The run's text (`a:t`), verbatim — whitespace is not normalized. */\n\tget text(): string {\n\t\treturn firstChild(this.element, 'a:t')?.textContent ?? ''\n\t}\n\n\tset text(value: string) {\n\t\tconst t = getOrAddChild(this.element, 'a:t')\n\t\tt.textContent = value\n\t\t// Preserve significant leading/trailing whitespace per the XML spec.\n\t\tif (value !== value.trim()) setAttr(t, 'xml:space', 'preserve')\n\t\telse removeAttr(t, 'xml:space')\n\t\tthis.context.part.markDirty()\n\t}\n\n\t/** Font size in points (`a:rPr/@sz` is hundredths of a point), or `null` if unset. */\n\tget fontSizePt(): number | null {\n\t\tconst size = this.#rPrAttr('sz')\n\t\treturn ptFromHundredths(size)\n\t}\n\n\tset fontSizePt(value: number | null) {\n\t\tif (value === null) {\n\t\t\tthis.#removeRPrAttr('sz')\n\t\t\treturn\n\t\t}\n\t\tif (!Number.isFinite(value) || value <= 0)\n\t\t\tthrow new InvalidOptionError('font/size-not-positive', `fontSizePt must be a positive number, got ${value}`)\n\t\tsetAttr(this.#getOrAddRPr(), 'sz', String(ptToHundredths(value)))\n\t\tthis.context.part.markDirty()\n\t}\n\n\t/** Bold (`a:rPr/@b`), or `null` when unset (inherited from style). */\n\tget bold(): boolean | null {\n\t\treturn boolValue(this.#rPrAttrRaw('b'))\n\t}\n\n\tset bold(value: boolean | null) {\n\t\tthis.#setBoolRPrAttr('b', value)\n\t}\n\n\t/** Italic (`a:rPr/@i`), or `null` when unset (inherited from style). */\n\tget italic(): boolean | null {\n\t\treturn boolValue(this.#rPrAttrRaw('i'))\n\t}\n\n\tset italic(value: boolean | null) {\n\t\tthis.#setBoolRPrAttr('i', value)\n\t}\n\n\t/** Underline style token (`a:rPr/@u`, e.g. `sng`), or `null` when unset. */\n\tget underline(): string | null {\n\t\treturn this.#rPrAttrRaw('u')\n\t}\n\n\t/** @throws {InvalidOptionError} when the token is not an `ST_TextUnderlineType` */\n\tset underline(value: string | null) {\n\t\tif (value === null) {\n\t\t\tthis.#removeRPrAttr('u')\n\t\t\treturn\n\t\t}\n\t\tconst token = checkEnumOrThrow(value, TEXT_UNDERLINE_TYPES, 'underline', 'text/invalid-underline')\n\t\tsetAttr(this.#getOrAddRPr(), 'u', token)\n\t\tthis.context.part.markDirty()\n\t}\n\n\t/**\n\t * Strikethrough token (`a:rPr/@strike`: `noStrike` | `sngStrike` |\n\t * `dblStrike`), or `null` when unset (inherited from the style). Surfaced as\n\t * the raw token — `sngStrike` is the writer's single-strike value.\n\t */\n\tget strike(): string | null {\n\t\treturn this.#rPrAttrRaw('strike')\n\t}\n\n\t/**\n\t * Capitalization token (`a:rPr/@cap`: `none` | `small` | `all`), or `null`\n\t * when unset. `small` renders small-caps, `all` renders all-caps.\n\t */\n\tget caps(): string | null {\n\t\treturn this.#rPrAttrRaw('cap')\n\t}\n\n\t/**\n\t * Baseline shift as a percentage of the font size (`a:rPr/@baseline`, stored\n\t * in 1000ths of a percent): positive for superscript (the writer's default is\n\t * `30`), negative for subscript (`-40`), or `null` when unset. Reported as the\n\t * percentage (`@baseline` ÷ 1000).\n\t *\n\t * `@baseline` is `a:ST_Percentage`, a union that also admits `\"62.5%\"` — the only form the\n\t * Strict profile has — so it is read through `parsePercentPoints` rather than as a bare number.\n\t */\n\tget baselinePct(): number | null {\n\t\tconst rPr = this.#rPr()\n\t\treturn rPr ? pctPointsAttr(rPr, 'baseline') : null\n\t}\n\n\t/**\n\t * Character spacing (tracking) in points (`a:rPr/@spc`, authored in hundredths\n\t * of a point), or `null` when unset. Negative tightens. The read counterpart of\n\t * the write-side `charSpacing` option.\n\t */\n\tget charSpacingPt(): number | null {\n\t\tconst raw = this.#rPrAttr('spc')\n\t\treturn ptFromHundredths(raw)\n\t}\n\n\t/**\n\t * The run's highlight colour (`a:rPr/a:highlight`), resolved to a literal hex\n\t * through the owning slide's theme, or `null` when the run has no highlight or\n\t * its colour cannot be made literal. The writer authors highlights from a hex\n\t * colour, so `effectiveHex` is that colour; imported decks may carry a theme token.\n\t */\n\tget highlight(): ResolvedColor | null {\n\t\tconst rPr = this.#rPr()\n\t\tconst hl = rPr && firstChild(rPr, 'a:highlight')\n\t\tif (!hl) return null\n\t\tconst colorEl = firstChildElement(hl)\n\t\treturn colorEl ? resolveColorElement(colorEl, this.context.ctx) : null\n\t}\n\n\t/**\n\t * The run's click hyperlink (`a:rPr/a:hlinkClick`), or `null` when the run\n\t * carries none. A URL link resolves its `@r:id` to the external target\n\t * ({@link Hyperlink.url}); a slide jump resolves it to the linked slide's\n\t * partname ({@link Hyperlink.targetPartName}). When the run is read without\n\t * its part's relationships (see {@link TextContext.rels}), only the raw\n\t * `@r:id`/`@action`/`@tooltip` are reported (the target stays `null`).\n\t */\n\tget hyperlink(): Hyperlink | null {\n\t\treturn readHyperlink(this.#rPr(), this.context.rels)\n\t}\n\n\t/** Latin typeface name (`a:rPr/a:latin/@typeface`), or `null` when unset. */\n\tget fontName(): string | null {\n\t\tconst rPr = this.#rPr()\n\t\tconst latin = rPr && firstChild(rPr, 'a:latin')\n\t\treturn latin ? attr(latin, 'typeface') : null\n\t}\n\n\tset fontName(value: string | null) {\n\t\tif (value === null) {\n\t\t\tconst rPr = this.#rPr()\n\t\t\tif (!rPr || !firstChild(rPr, 'a:latin')) return\n\t\t\tremoveChildrenByQName(rPr, ['a:latin'])\n\t\t\tthis.context.part.markDirty()\n\t\t\treturn\n\t\t}\n\t\tconst latin = getOrAddChild(this.#getOrAddRPr(), 'a:latin', RPR_LATIN_AFTER)\n\t\tsetAttr(latin, 'typeface', value)\n\t\tthis.context.part.markDirty()\n\t}\n\n\t/** Explicit RGB fill colour as a 6-hex string (`a:solidFill/a:srgbClr/@val`), or `null`. */\n\tget color(): string | null {\n\t\treturn solidFillColor(this.#rPr(), 'a:srgbClr')\n\t}\n\n\tset color(value: string | null) {\n\t\tthis.#applyFill(value === null ? null : { hex: value })\n\t}\n\n\t/** Theme colour token when the fill is a scheme colour (`a:schemeClr/@val`, e.g. `accent2`), or `null`. */\n\tget schemeColor(): string | null {\n\t\treturn solidFillColor(this.#rPr(), 'a:schemeClr')\n\t}\n\n\t/** @throws {InvalidOptionError} when the token is not an `ST_SchemeColorVal` */\n\tset schemeColor(value: string | null) {\n\t\tthis.#applyFill(value === null ? null : { scheme: value })\n\t}\n\n\t/**\n\t * The colour this run effectively renders, resolved against the owning slide's\n\t * theme to a literal hex. It is the run's own solid fill\n\t * ({@link color}/{@link schemeColor}) when set; otherwise the shape's\n\t * `p:style/a:fontRef` colour, then — for a run inside a placeholder — the colour\n\t * it inherits from the placeholder/list-style chain (layout → master placeholder\n\t * `a:lstStyle` → master `p:txStyles`), then the presentation's\n\t * `p:defaultTextStyle`. `null` when the run sets no colour and inherits none, or the\n\t * colour cannot be made literal.\n\t * `null` too when the run's own fill is not a solid colour (`a:noFill`, a gradient):\n\t * the run decides its own colour then, and the one it would otherwise inherit is not\n\t * what it paints in, the rule `Shape.resolvedFill` and `TableCell.resolvedFill` follow.\n\t * The returned {@link ResolvedColor} carries `effectiveHex` — the base colour with\n\t * its child transforms (`lumMod`/`shade`/…) applied — for the final rendered colour.\n\t */\n\tget resolvedColor(): ResolvedColor | null {\n\t\tconst rPr = this.#rPr()\n\t\tif (hasFillChoice(rPr)) return resolveSolidFillColor(rPr, this.context.ctx)\n\t\tconst inherit = this.context.inherit\n\t\treturn inherit?.fontRef?.color ?? inherit?.tableText?.color ?? this.inherited?.color() ?? null\n\t}\n\n\t/**\n\t * The point size this run effectively renders. It is the run's own `@sz`\n\t * ({@link fontSizePt}) when set; otherwise, for a run inside a placeholder, the\n\t * size it inherits from the placeholder/list-style chain (paragraph `a:defRPr` →\n\t * slide `a:lstStyle` → layout → master placeholder `a:lstStyle` → master\n\t * `p:txStyles`). `null` when the run sets no size and inherits none — the\n\t * resolved counterpart of {@link fontSizePt}, which reports only the run's own value.\n\t */\n\tget resolvedSizePt(): number | null {\n\t\treturn this.fontSizePt ?? this.inherited?.size() ?? null\n\t}\n\n\t/**\n\t * The typeface this run effectively renders, resolved to a literal face name. It\n\t * is the run's own `a:latin` ({@link fontName}) when set; otherwise the face named\n\t * by the shape's `p:style/a:fontRef` (`idx` → theme major/minor font), then — for a\n\t * run inside a placeholder — the face it inherits from the placeholder/list-style\n\t * chain, then the presentation's `p:defaultTextStyle`. A `+mj-*`/`+mn-*`\n\t * major/minor theme-font token — on the run itself or reached through the chain —\n\t * is resolved through the theme `fontScheme` to its concrete face. `null` when the\n\t * run names no face and inherits none, or a token cannot be resolved — the resolved\n\t * counterpart of {@link fontName}, which reports the raw `@typeface` (possibly a token).\n\t */\n\tget resolvedFontFace(): string | null {\n\t\tconst own = this.fontName\n\t\tif (own !== null) return resolveThemeFont(own, this.context.ctx.fontScheme ?? null)\n\t\tconst inherit = this.context.inherit\n\t\treturn inherit?.fontRef?.face ?? inherit?.tableText?.face ?? this.inherited?.face() ?? null\n\t}\n\n\t/**\n\t * Whether this run effectively renders bold. It is the run's own `@b`\n\t * ({@link bold}) when set; otherwise, for a run inside a placeholder, the bold\n\t * state it inherits from the placeholder/list-style chain (paragraph `a:defRPr` →\n\t * slide `a:lstStyle` → layout → master placeholder `a:lstStyle` → master\n\t * `p:txStyles`). `null` when the run sets no `@b` and inherits none — the\n\t * resolved counterpart of {@link bold}, which reports only the run's own value.\n\t */\n\tget resolvedBold(): boolean | null {\n\t\treturn this.bold ?? this.context.inherit?.tableText?.bold ?? this.inherited?.bold() ?? null\n\t}\n\n\t/**\n\t * Whether this run effectively renders italic. It is the run's own `@i`\n\t * ({@link italic}) when set; otherwise, for a run inside a placeholder, the italic\n\t * state it inherits from the placeholder/list-style chain (paragraph `a:defRPr` →\n\t * slide `a:lstStyle` → layout → master placeholder `a:lstStyle` → master\n\t * `p:txStyles`). `null` when the run sets no `@i` and inherits none — the\n\t * resolved counterpart of {@link italic}, and the twin of {@link resolvedBold}:\n\t * `@b` and `@i` are siblings a master text style states together, so a deck that\n\t * can be authored with an inherited italic can be read back with one.\n\t */\n\tget resolvedItalic(): boolean | null {\n\t\treturn this.italic ?? this.context.inherit?.tableText?.italic ?? this.inherited?.italic() ?? null\n\t}\n\n\t/** Escape hatch: the underlying `a:r` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.element\n\t}\n\n\t/** Mark the owning part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.context.part.markDirty()\n\t}\n\n\t#rPr(): Element | null {\n\t\treturn firstChild(this.element, 'a:rPr')\n\t}\n\n\t#getOrAddRPr(): Element {\n\t\treturn getOrAddChild(this.element, 'a:rPr', ['a:t'])\n\t}\n\n\t#rPrAttrRaw(name: string): string | null {\n\t\tconst rPr = this.#rPr()\n\t\treturn rPr ? attr(rPr, name) : null\n\t}\n\n\t#rPrAttr(name: string): number | null {\n\t\treturn numberValue(this.#rPrAttrRaw(name))\n\t}\n\n\t#removeRPrAttr(name: string): void {\n\t\tconst rPr = this.#rPr()\n\t\tif (!rPr) return\n\t\tremoveAttr(rPr, name)\n\t\tthis.context.part.markDirty()\n\t}\n\n\t#setBoolRPrAttr(name: string, value: boolean | null): void {\n\t\tif (value === null) {\n\t\t\tthis.#removeRPrAttr(name)\n\t\t\treturn\n\t\t}\n\t\tsetAttr(this.#getOrAddRPr(), name, value ? '1' : '0')\n\t\tthis.context.part.markDirty()\n\t}\n\n\t/** Replace the run's solid fill with a single colour, or clear it when `null`. */\n\t#applyFill(edit: SolidFillEdit | null): void {\n\t\tconst changed =\n\t\t\tedit === null\n\t\t\t\t? applySolidFill(this.#rPr(), null)\n\t\t\t\t: applySolidFill(this.#rPr(), edit, () => this.#getOrAddRPr(), RPR_FILL_AFTER)\n\t\tif (changed) this.context.part.markDirty()\n\t}\n}\n","/**\n * The two free text-body mutators, shared by the three proxies that own an `a:txBody`.\n *\n * `TextFrame.text`, `TableCell.text` and `DiagramPoint.text` all replace a body's content with\n * one paragraph and one run, preserving the first existing run's `a:rPr`. Neither function\n * marks a part dirty: the caller owns the `Part` and calls `markDirty()` after.\n */\nimport {\n\tchildElements,\n\tcreateElement,\n\ttype Element,\n\tfirstChild,\n\tgetElements,\n\tremoveAttr,\n\tsetAttr,\n} from '../../oxml/dom.js'\nimport { InternalError } from '../../../errors.js'\n/**\n * Replace a text body's content (`a:txBody` or `a:txBody`-shaped element) with a\n * single paragraph and run, preserving the `a:rPr` of the body's first existing\n * run when there is one. Shared by {@link TextFrame.text} and `TableCell.text`.\n * Does **not** mark any part dirty — the caller owns the `Part` and must call\n * `markDirty()` after.\n */\nexport function setTextBodyText(txBody: Element, value: string): void {\n\tconst doc = txBody.ownerDocument\n\tif (!doc) throw new InternalError('oxml/node-has-no-document', 'Cannot set text: text body has no owner document')\n\n\t// Collapse to a single paragraph, dropping any extras, then let the paragraph-level\n\t// setter do the rest — the run rule is the same one, stated once.\n\tconst paragraphs = getElements(txBody, 'a:p')\n\tfor (let i = paragraphs.length - 1; i >= 1; i--) {\n\t\tconst extra = paragraphs[i]\n\t\tif (extra) txBody.removeChild(extra)\n\t}\n\tlet p = paragraphs[0]\n\tif (!p) {\n\t\tp = createElement(doc, 'a:p')\n\t\ttxBody.appendChild(p)\n\t}\n\tsetParagraphText(p, value)\n}\n\n/**\n * Replace **one paragraph's** content with a single run, preserving the `a:rPr` of that\n * paragraph's first existing run and leaving its `a:pPr` (level, alignment, bullet) alone.\n * Sibling paragraphs are untouched, which is the whole difference from\n * {@link setTextBodyText} and the reason this exists: a SmartArt drawing cache packs several\n * nodes' text into one `dsp:txBody`, so collapsing the body there would delete the other\n * nodes' strings. Does **not** mark any part dirty — the caller owns the `Part`.\n */\nexport function setParagraphText(p: Element, value: string): void {\n\tconst doc = p.ownerDocument\n\tif (!doc) throw new InternalError('oxml/node-has-no-document', 'Cannot set text: paragraph has no owner document')\n\n\t// Capture the first run's character formatting before we discard runs.\n\tconst firstRun = firstChild(p, 'a:r')\n\tconst rPrTemplate = firstRun && firstChild(firstRun, 'a:rPr')\n\n\t// Remove every run-level child (runs, breaks, fields); keep a:pPr / a:endParaRPr.\n\tfor (const child of childElements(p)) {\n\t\tif (child.localName === 'r' || child.localName === 'br' || child.localName === 'fld') p.removeChild(child)\n\t}\n\n\t// Build a single run, carrying over the captured formatting if present.\n\tconst run = createElement(doc, 'a:r')\n\tif (rPrTemplate) run.appendChild(rPrTemplate.cloneNode(true))\n\tconst t = createElement(doc, 'a:t')\n\tt.textContent = value\n\tif (value !== value.trim()) setAttr(t, 'xml:space', 'preserve')\n\telse removeAttr(t, 'xml:space')\n\trun.appendChild(t)\n\n\t// Insert before a:endParaRPr if present (it must stay last), else append.\n\tconst endParaRPr = firstChild(p, 'a:endParaRPr')\n\tp.insertBefore(run, endParaRPr)\n}\n","/**\n * The `Paragraph` read/write proxy (`a:p`).\n *\n * A paragraph owns its `a:pPr` — alignment, indents, spacing, the bullet — and hands each\n * `a:r` to a {@link Run}. It is handed its frame's {@link TextContext}, and builds the one\n * {@link InheritedRunProps} its runs share.\n */\nimport { resolvePartName } from '../../opc/partnames.js'\nimport {\n\tattr,\n\ttype Element,\n\tELEMENT_NODE,\n\tfirstChild,\n\tfirstChildElement,\n\tgetElements,\n\tnumberValue,\n\tpctPointsAttr,\n} from '../../oxml/dom.js'\nimport { type ThemeContext } from '../../oxml/theme.js'\nimport {\n\treadColorRef,\n\tresolveInheritedRunBold,\n\tresolveInheritedRunItalic,\n\tresolveInheritedRunColor,\n\tresolveInheritedRunFontFace,\n\tresolveInheritedRunSize,\n\ttype PlaceholderRef,\n} from '../theme-context.js'\nimport { HUNDREDTHS_PER_POINT } from '../../../units.js'\nimport { ptFromEmu, ptFromHundredths } from '../coords.js'\nimport {\n\tRun,\n\ttype BulletDetail,\n\ttype BulletStyle,\n\ttype InheritedRunProps,\n\ttype LineSpacing,\n\ttype TextContext,\n} from './run.js'\nimport { setParagraphText } from './edit.js'\n/** One paragraph (`a:p`) of a text frame. */\nexport class Paragraph {\n\tconstructor(\n\t\tprivate readonly element: Element,\n\t\t/** What the paragraph is read against; see {@link TextContext}. */\n\t\tprivate readonly context: TextContext,\n\t\t/**\n\t\t * The owning text body's own `a:lstStyle`, the tier just below the paragraph in the chain its\n\t\t * runs inherit through. Read only when {@link TextContext.inherit} is set.\n\t\t */\n\t\tprivate readonly slideLstStyle: Element | null\n\t) {}\n\n\t/** The runs (`a:r`) in document order. Fields (`a:fld`) and breaks are not runs; see `text`. */\n\tget runs(): Run[] {\n\t\tconst inherited = this.#inheritedRunProps()\n\t\treturn getElements(this.element, 'a:r').map((element) => new Run(element, this.context, inherited))\n\t}\n\n\t/**\n\t * What every run in this paragraph inherits when it sets no value of its own, or `null` for text\n\t * that inherits through nothing. Runs in one paragraph share a level and `a:pPr`, so each\n\t * property is resolved at most once per paragraph, and only when a run lacking its own value asks.\n\t */\n\t#inheritedRunProps(): InheritedRunProps | null {\n\t\tconst inherit = this.context.inherit\n\t\tif (!inherit) return null\n\t\tconst pPr = firstChild(this.element, 'a:pPr')\n\t\tconst level = this.level\n\t\tconst { ctx } = this.context\n\t\tconst slideLstStyle = this.slideLstStyle\n\t\tconst once = <T>(\n\t\t\tresolve: (\n\t\t\t\tph: PlaceholderRef | null,\n\t\t\t\tlevel: number,\n\t\t\t\tpPr: Element | null,\n\t\t\t\tslideLstStyle: Element | null,\n\t\t\t\tctx: ThemeContext\n\t\t\t) => T | null\n\t\t): (() => T | null) => {\n\t\t\tlet cached: T | null | undefined\n\t\t\treturn () => (cached === undefined ? (cached = resolve(inherit.ph, level, pPr, slideLstStyle, ctx)) : cached)\n\t\t}\n\t\treturn {\n\t\t\tcolor: once(resolveInheritedRunColor),\n\t\t\tsize: once(resolveInheritedRunSize),\n\t\t\tface: once(resolveInheritedRunFontFace),\n\t\t\tbold: once(resolveInheritedRunBold),\n\t\t\titalic: once(resolveInheritedRunItalic),\n\t\t}\n\t}\n\n\t/** Indent level (`a:pPr/@lvl`), 0 when unset. */\n\tget level(): number {\n\t\tconst pPr = firstChild(this.element, 'a:pPr')\n\t\treturn (pPr && numberValue(attr(pPr, 'lvl'))) ?? 0\n\t}\n\n\t/**\n\t * Horizontal alignment token (`a:pPr/@algn`: `l` | `ctr` | `r` | `just` |\n\t * `dist` | `thaiDist`), or `null` when unset (inherited from the list style).\n\t */\n\tget align(): string | null {\n\t\tconst pPr = firstChild(this.element, 'a:pPr')\n\t\treturn pPr ? attr(pPr, 'algn') : null\n\t}\n\n\t/**\n\t * Space before the paragraph in points (`a:pPr/a:spcBef/a:spcPts/@val` is\n\t * hundredths of a point), or `null` when unset or expressed as a percentage\n\t * (`a:spcPct`, which has no fixed point value).\n\t */\n\tget spaceBeforePt(): number | null {\n\t\treturn this.#spacingPt('a:spcBef')\n\t}\n\n\t/** Space after the paragraph in points; see {@link spaceBeforePt} for the percentage caveat. */\n\tget spaceAfterPt(): number | null {\n\t\treturn this.#spacingPt('a:spcAft')\n\t}\n\n\t/**\n\t * The paragraph's line spacing (`a:pPr/a:lnSpc`), as an exact point height\n\t * (`a:spcPts`) or a percentage of the single-line height (`a:spcPct`), or\n\t * `null` when unset (inherited from the list style). See {@link LineSpacing}.\n\t */\n\tget lineSpacing(): LineSpacing | null {\n\t\tconst pPr = firstChild(this.element, 'a:pPr')\n\t\tconst lnSpc = pPr && firstChild(pPr, 'a:lnSpc')\n\t\tif (!lnSpc) return null\n\t\tconst pts = firstChild(lnSpc, 'a:spcPts')\n\t\tif (pts) {\n\t\t\tconst val = numberValue(attr(pts, 'val'))\n\t\t\treturn val === null ? null : { type: 'points', valuePt: val / HUNDREDTHS_PER_POINT }\n\t\t}\n\t\tconst pct = firstChild(lnSpc, 'a:spcPct')\n\t\tif (pct) {\n\t\t\t// `ST_TextSpacingPercentOrPercentString`: the name says it, and the string half is the\n\t\t\t// only spelling Strict has.\n\t\t\tconst val = pctPointsAttr(pct, 'val')\n\t\t\treturn val === null ? null : { type: 'percent', percent: val }\n\t\t}\n\t\treturn null\n\t}\n\n\t/** Left margin of the paragraph in points (`a:pPr/@marL` is EMU; 12700 EMU = 1pt), or `null` when unset. */\n\tget marginLeftPt(): number | null {\n\t\treturn this.#emuAttrPt('marL')\n\t}\n\n\t/** First-line indent in points (`a:pPr/@indent` is EMU; negative for a hanging indent), or `null` when unset. */\n\tget indentPt(): number | null {\n\t\treturn this.#emuAttrPt('indent')\n\t}\n\n\t/**\n\t * This paragraph's bullet — its kind, and for a drawn bullet the glyph, the\n\t * numbering start, and the bullet's own font/size/colour. `null` when the\n\t * paragraph names no bullet at all and inherits one from the list style.\n\t *\n\t * Structured rather than a tagged string, which is not merely tidier. The\n\t * previous `bullet` accessor reported `'none'` / `'char:•'` /\n\t * `'autoNum:arabicPeriod'`, and that shape is ambiguous when the glyph is\n\t * itself a colon; worse, it reads as a bare glyph, which is exactly how the\n\t * script converter first consumed it — `'none'.codePointAt(0)` put a literal\n\t * `n` bullet on every converted deck, silently. See {@link BulletDetail}.\n\t */\n\tget bulletDetail(): BulletDetail | null {\n\t\tconst pPr = firstChild(this.element, 'a:pPr')\n\t\tif (!pPr) return null\n\t\tif (firstChild(pPr, 'a:buNone')) return { kind: 'none' }\n\n\t\tconst style = this.#bulletStyle(pPr)\n\t\tconst buChar = firstChild(pPr, 'a:buChar')\n\t\tif (buChar) return { kind: 'char', char: attr(buChar, 'char') ?? '', ...style }\n\n\t\tconst buAutoNum = firstChild(pPr, 'a:buAutoNum')\n\t\tif (buAutoNum) {\n\t\t\treturn {\n\t\t\t\tkind: 'autoNum',\n\t\t\t\tscheme: attr(buAutoNum, 'type') ?? '',\n\t\t\t\tstartAt: numberValue(attr(buAutoNum, 'startAt')),\n\t\t\t\t...style,\n\t\t\t}\n\t\t}\n\n\t\tconst buBlip = firstChild(pPr, 'a:buBlip')\n\t\tif (buBlip) return { kind: 'picture', imagePartName: this.#bulletImagePartName(buBlip), ...style }\n\n\t\treturn null\n\t}\n\n\t/** The `a:buFont` / `a:buSz*` / `a:buClr` siblings of a `a:pPr` bullet choice. */\n\t#bulletStyle(pPr: Element): BulletStyle {\n\t\tconst buFont = firstChild(pPr, 'a:buFont')\n\t\tconst buSzPct = firstChild(pPr, 'a:buSzPct')\n\t\tconst buSzPts = firstChild(pPr, 'a:buSzPts')\n\t\tconst buClr = firstChild(pPr, 'a:buClr')\n\t\t// `a:buClr` holds the colour element directly (CT_Color), not wrapped in an\n\t\t// `a:solidFill` the way a run or a shape fill does.\n\t\tconst colorEl = buClr ? firstChildElement(buClr) : null\n\t\tconst ptVal = buSzPts ? numberValue(attr(buSzPts, 'val')) : null\n\t\treturn {\n\t\t\tfont: buFont ? (attr(buFont, 'typeface') ?? null) : null,\n\t\t\t// `ST_TextBulletSizePercent` is a string type whose declared form is `80%`; Office writes the\n\t\t\t// fixed-point `80000`. Reading only the second reported the first as no size at all.\n\t\t\tsizePct: buSzPct ? pctPointsAttr(buSzPct, 'val') : null,\n\t\t\tsizePt: ptFromHundredths(ptVal),\n\t\t\tcolorRef: readColorRef(colorEl, this.context.ctx),\n\t\t}\n\t}\n\n\t/**\n\t * Resolve a picture bullet's `a:buBlip/a:blip/@r:embed` to an absolute partname, or `null` when\n\t * it names no internal part.\n\t *\n\t * Through `resolvePartName` rather than `resolveTarget`, which throws on a dangling id and on an\n\t * External target: a linked or missing bullet image is \"no part\", as it already is for a picture,\n\t * not a throw out of `bulletDetail`.\n\t */\n\t#bulletImagePartName(buBlip: Element): string | null {\n\t\tconst blip = firstChild(buBlip, 'a:blip')\n\t\treturn resolvePartName(blip && attr(blip, 'r:embed'), this.context.rels)\n\t}\n\n\t/** Points from a spacing child's `a:spcPts/@val` (hundredths of a point), or `null`. */\n\t#spacingPt(qname: string): number | null {\n\t\tconst pPr = firstChild(this.element, 'a:pPr')\n\t\tconst spc = pPr && firstChild(pPr, qname)\n\t\tconst pts = spc && firstChild(spc, 'a:spcPts')\n\t\tconst val = pts ? numberValue(attr(pts, 'val')) : null\n\t\treturn ptFromHundredths(val)\n\t}\n\n\t/** Points from an EMU-valued `a:pPr` attribute (`marL` / `indent`), or `null`. */\n\t#emuAttrPt(name: string): number | null {\n\t\tconst pPr = firstChild(this.element, 'a:pPr')\n\t\tconst emu = pPr ? numberValue(attr(pPr, name)) : null\n\t\treturn ptFromEmu(emu)\n\t}\n\n\t/**\n\t * The paragraph's text: run (`a:r`) and field (`a:fld`) text concatenated in\n\t * document order, with each line break (`a:br`) rendered as `\\n`.\n\t */\n\tget text(): string {\n\t\tlet out = ''\n\t\tfor (let node = this.element.firstChild; node; node = node.nextSibling) {\n\t\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\t\tconst element = node as Element\n\t\t\tif (element.localName === 'r' || element.localName === 'fld') {\n\t\t\t\tout += firstChild(element, 'a:t')?.textContent ?? ''\n\t\t\t} else if (element.localName === 'br') {\n\t\t\t\tout += '\\n'\n\t\t\t}\n\t\t}\n\t\treturn out\n\t}\n\n\t/**\n\t * Replace **this paragraph's** content with a single run, preserving the character\n\t * formatting (`a:rPr`) of its first existing run and leaving its `a:pPr` (level,\n\t * alignment, bullet) alone. Sibling paragraphs are untouched — the difference from\n\t * {@link TextFrame.text}, which collapses the whole body to one paragraph.\n\t */\n\tset text(value: string) {\n\t\tsetParagraphText(this.element, value)\n\t\tthis.context.part.markDirty()\n\t}\n\n\t/** Escape hatch: the underlying `a:p` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.element\n\t}\n\n\t/** Mark the owning part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.context.part.markDirty()\n\t}\n}\n\n/** A shape's text frame (`p:txBody`): an ordered list of paragraphs. */\n","/**\n * The `TextFrame` read/write proxy (`p:txBody` / `a:txBody`), and its `a:bodyPr` value types.\n *\n * The frame is where a shape's text begins: it owns the body properties (insets, anchor,\n * wrap, autofit) and hands each `a:p` to a {@link Paragraph}.\n */\nimport { attr, type Element, firstChild, getElements, numberValue, pctPointsAttr } from '../../oxml/dom.js'\nimport { resolveInheritedAnchor } from '../theme-context.js'\nimport { emuToPoints } from '../../../units.js'\nimport type { TextContext } from './run.js'\nimport { Paragraph } from './paragraph.js'\nimport { setTextBodyText } from './edit.js'\n/**\n * A text frame's body properties (`a:bodyPr`), as read from a shape. Carries the\n * inset/anchor/vertical-text settings that govern where text sits inside its box\n * — the difference between a label that clears a left rail and one that overlaps\n * it. Only **explicitly set** attributes are reported; an absent inset means the\n * PowerPoint default (`lIns`/`rIns` = 0.1\", `tIns`/`bIns` = 0.05\").\n */\nexport interface BodyProperties {\n\t/** Text direction (`@vert`: `horz`/`vert`/`vert270`/`eaVert`/`wordArtVert`…), or `null` when horizontal/unset. */\n\tvert: string | null\n\t/** Vertical anchor (`@anchor`: `t`/`ctr`/`b`), or `null` when unset (defaults to top). */\n\tanchor: string | null\n\t/** Wrap mode (`@wrap`: `square`/`none`), or `null` when unset. */\n\twrap: string | null\n\t/** Explicitly-set text insets in points (`@lIns`/`@rIns`/`@tIns`/`@bIns` ÷ 12700); a missing side uses the PowerPoint default. */\n\tinsetsPt: { left?: number; right?: number; top?: number; bottom?: number }\n}\n\n/**\n * A text frame's vertical-autofit mode, read from its `a:bodyPr` autofit child:\n * - `'none'` — `a:noAutofit`, or no autofit child at all (the box has a fixed\n * size and text can overflow); write-side `fit: 'none'`.\n * - `'normAutofit'`— `a:normAutofit` (shrink text to fit); write-side `fit: 'shrink'`.\n * - `'spAutoFit'` — `a:spAutoFit` (resize the shape to fit text); write-side `fit: 'resize'`.\n */\nexport type AutofitMode = 'none' | 'normAutofit' | 'spAutoFit'\n\nexport class TextFrame {\n\tconstructor(\n\t\tprivate readonly txBody: Element,\n\t\t/**\n\t\t * What the frame is read against — its part, the theme, the part's relationships and the\n\t\t * inheritance its runs fall back through — handed on to each {@link Paragraph} and {@link Run}.\n\t\t */\n\t\tprivate readonly context: TextContext\n\t) {}\n\n\t/** Paragraphs (`a:p`) in document order. */\n\tget paragraphs(): Paragraph[] {\n\t\t// The text body's own list style is the tier just below the run/paragraph in the\n\t\t// inheritance chain; resolve it once and share it.\n\t\tconst slideLstStyle = this.context.inherit ? firstChild(this.txBody, 'a:lstStyle') : null\n\t\treturn getElements(this.txBody, 'a:p').map((element) => new Paragraph(element, this.context, slideLstStyle))\n\t}\n\n\t/**\n\t * The frame's body properties (`a:bodyPr`: insets, anchor, vertical text), or\n\t * `null` when there is no `a:bodyPr`. Only explicitly-set insets are reported\n\t * (a missing side is the PowerPoint default — see {@link BodyProperties}).\n\t */\n\tget bodyProperties(): BodyProperties | null {\n\t\tconst bodyPr = firstChild(this.txBody, 'a:bodyPr')\n\t\tif (!bodyPr) return null\n\t\tconst insetsPt: BodyProperties['insetsPt'] = {}\n\t\tconst inset = (qn: string, key: keyof BodyProperties['insetsPt']): void => {\n\t\t\tconst v = numberValue(attr(bodyPr, qn))\n\t\t\tif (v !== null) insetsPt[key] = emuToPoints(v)\n\t\t}\n\t\tinset('lIns', 'left')\n\t\tinset('rIns', 'right')\n\t\tinset('tIns', 'top')\n\t\tinset('bIns', 'bottom')\n\t\treturn {\n\t\t\tvert: attr(bodyPr, 'vert') ?? null,\n\t\t\tanchor: attr(bodyPr, 'anchor') ?? null,\n\t\t\twrap: attr(bodyPr, 'wrap') ?? null,\n\t\t\tinsetsPt,\n\t\t}\n\t}\n\n\t/**\n\t * The effective vertical anchor (`t`/`ctr`/`b`): the frame's own\n\t * `a:bodyPr/@anchor` when set, else the anchor it inherits from its\n\t * layout → master placeholder `a:bodyPr`. `null` when nothing in the chain sets\n\t * one (PowerPoint then defaults to top). Unlike {@link bodyProperties}'s\n\t * `anchor` (own attribute only), this surfaces the inherited anchor a\n\t * placeholder title relies on — the difference between a top- and\n\t * centre-anchored title that own-attribute reads alone cannot see.\n\t */\n\tget resolvedAnchor(): string | null {\n\t\tconst own = this.bodyProperties?.anchor\n\t\tif (own) return own\n\t\t// Anchor inheritance is placeholder-only; a non-placeholder frame (ph null) has none.\n\t\tconst ph = this.context.inherit?.ph\n\t\tif (!ph) return null\n\t\treturn resolveInheritedAnchor(ph, this.context.ctx)\n\t}\n\n\t/**\n\t * The frame's vertical-autofit mode (`a:bodyPr` autofit child), or `null` when\n\t * there is no `a:bodyPr`. A `bodyPr` with no autofit child — or an explicit\n\t * `a:noAutofit` — reads `'none'`. See {@link AutofitMode}. This is the deep-model\n\t * counterpart of `inspectPptx`'s per-shape `autofit`; unlike the shallow surface\n\t * it hangs off the navigable text frame.\n\t */\n\tget autofit(): AutofitMode | null {\n\t\tconst bodyPr = firstChild(this.txBody, 'a:bodyPr')\n\t\tif (!bodyPr) return null\n\t\tif (firstChild(bodyPr, 'a:spAutoFit')) return 'spAutoFit'\n\t\tif (firstChild(bodyPr, 'a:normAutofit')) return 'normAutofit'\n\t\treturn 'none'\n\t}\n\n\t/**\n\t * The baked shrink scale of a `normAutofit` frame as a percent (62.5 = 62.5%),\n\t * or `null` when the frame has no `a:normAutofit` or bakes no scale. A bare\n\t * `<a:normAutofit/>` (write-side `fit: 'shrink'`) carries no scale — PowerPoint\n\t * computes it on edit and draws at 100% until then — so it too reads `null`; an\n\t * explicit scale comes from `fit: { type: 'shrink', fontScale }`.\n\t */\n\tget autofitFontScale(): number | null {\n\t\treturn this.#normAutofitPct('fontScale')\n\t}\n\n\t/**\n\t * The baked line-spacing reduction of a `normAutofit` frame as a percent\n\t * (`a:normAutofit/@lnSpcReduction` ÷ 1000), or `null` when unset. The companion\n\t * to {@link autofitFontScale} (write-side `fit: { type: 'shrink', lnSpcReduction }`).\n\t */\n\tget autofitLineSpaceReduction(): number | null {\n\t\treturn this.#normAutofitPct('lnSpcReduction')\n\t}\n\n\t/**\n\t * A `a:normAutofit` percentage attribute → percent, or `null`.\n\t *\n\t * `fontScale` is `ST_TextFontScalePercentOrPercentString` and `lnSpcReduction` is\n\t * `ST_TextSpacingPercentOrPercentString`; both admit the `\"62.5%\"` spelling alongside the\n\t * fixed-point one, and it is the only spelling Strict has.\n\t */\n\t#normAutofitPct(name: string): number | null {\n\t\tconst bodyPr = firstChild(this.txBody, 'a:bodyPr')\n\t\tconst norm = bodyPr && firstChild(bodyPr, 'a:normAutofit')\n\t\treturn norm ? pctPointsAttr(norm, name) : null\n\t}\n\n\t/** All paragraph text joined by `\\n` (mirrors python-pptx `TextFrame.text`). */\n\tget text(): string {\n\t\treturn this.paragraphs.map((paragraph) => paragraph.text).join('\\n')\n\t}\n\n\t/**\n\t * Replace the frame's text with a single paragraph and run, preserving the\n\t * character formatting (`a:rPr`) of the frame's first existing run when there\n\t * is one. For multiple runs or per-run formatting, edit\n\t * `paragraphs[].runs[]` directly.\n\t */\n\tset text(value: string) {\n\t\tsetTextBodyText(this.txBody, value)\n\t\tthis.context.part.markDirty()\n\t}\n\n\t/** Escape hatch: the underlying `p:txBody` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.txBody\n\t}\n\n\t/** Mark the owning part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.context.part.markDirty()\n\t}\n}\n","/**\n * Spid-aware, otherwise-opaque handling of a slide's build-animation tree\n * (`p:timing` / `p:bldLst`).\n *\n * The `p:timing` subtree is `CT_TimeNodeList` — deeply recursive and modeled\n * here as opaque DOM (an unmodified slide round-trips it byte-identically for\n * free). The only structured data we extract or rewrite is the set of `spid`\n * references — `<p:spTgt spid>` inside the timing tree and `<p:bldP spid>` in the\n * build list — so animations stay coherent when shape ids change. Three purely\n * structural operations: **enumerate**, **remap**, and **prune**. See\n * `docs/contributing/design/animations.md` (\"spid-aware operations\").\n */\nimport {\n\tOOXML_NS,\n\tattr,\n\tchildElements,\n\tcreateElement,\n\tfirstChild,\n\tinsertInOrder,\n\tnumberValue,\n\tparseXml,\n\tsetAttr,\n\ttype Document,\n\ttype Element,\n} from '../oxml/dom.js'\nimport { InternalError } from '../../errors.js'\nimport { SLIDE_AFTER_TIMING, TIMING_AFTER_TNLST } from '../../ooxml/sequence.js'\n\nconst P_NS = OOXML_NS.p\n\n/** Every element carrying an animation `spid` reference, across the timing tree and build list, `root` included. */\nfunction spidElements(root: Element): Element[] {\n\tconst out: Element[] = []\n\tif (root.namespaceURI === OOXML_NS.p && (root.localName === 'spTgt' || root.localName === 'bldP')) out.push(root)\n\tfor (const el of root.getElementsByTagNameNS(OOXML_NS.p, 'spTgt')) out.push(el)\n\tfor (const el of root.getElementsByTagNameNS(OOXML_NS.p, 'bldP')) out.push(el)\n\treturn out\n}\n\n/**\n * Whether the slide carries build animations — a `<p:bldP>` entry or any timing\n * node with a `presetID` (distinguishing animation timing from the media-loop\n * timing that has neither).\n */\nexport function hasAnimations(root: Element): boolean {\n\tif (root.getElementsByTagNameNS(OOXML_NS.p, 'bldP').length > 0) return true\n\tfor (const cTn of root.getElementsByTagNameNS(OOXML_NS.p, 'cTn')) {\n\t\tif (attr(cTn, 'presetID') !== null) return true\n\t}\n\treturn false\n}\n\n/** The sorted, de-duplicated set of `spid`s referenced by the slide's animations. */\nexport function enumerateSpids(root: Element): number[] {\n\tconst seen = new Set<number>()\n\tfor (const element of spidElements(root)) {\n\t\tconst spid = numberValue(attr(element, 'spid'))\n\t\tif (spid !== null) seen.add(spid)\n\t}\n\treturn [...seen].sort((a, b) => a - b)\n}\n\n/**\n * Rewrite every animation `spid` according to `mapping` (old → new). Returns\n * `true` when at least one reference changed, so callers can `markDirty()` only\n * when needed.\n */\nexport function remapSpids(root: Element, mapping: Map<number, number>): boolean {\n\tlet changed = false\n\tfor (const element of spidElements(root)) {\n\t\tconst spid = numberValue(attr(element, 'spid'))\n\t\tif (spid === null) continue\n\t\tconst next = mapping.get(spid)\n\t\tif (next !== undefined && next !== spid) {\n\t\t\tsetAttr(element, 'spid', String(next))\n\t\t\tchanged = true\n\t\t}\n\t}\n\treturn changed\n}\n\n/** The nearest ancestor `<p:par>` whose `<p:cTn>` carries a `presetID` (the effect node), or `null`. */\nfunction effectParFor(spTgt: Element): Element | null {\n\tfor (let node: Element | null = spTgt.parentNode as Element | null; node; node = node.parentNode as Element | null) {\n\t\tif (node.localName === 'par' && node.namespaceURI === OOXML_NS.p) {\n\t\t\tconst cTn = firstChild(node, 'p:cTn')\n\t\t\tif (cTn && attr(cTn, 'presetID') !== null) return node\n\t\t}\n\t}\n\treturn null\n}\n\n/** Whether a `<p:par>` wrapper node has become empty (its `p:cTn/p:childTnLst` has no element children). */\nfunction isEmptyWrapperPar(par: Element): boolean {\n\tif (par.localName !== 'par' || par.namespaceURI !== OOXML_NS.p) return false\n\tconst cTn = firstChild(par, 'p:cTn')\n\tif (!cTn || attr(cTn, 'presetID') !== null) return false // an effect par, not a wrapper\n\tconst childTnLst = firstChild(cTn, 'p:childTnLst')\n\treturn !childTnLst || childElements(childTnLst).length === 0\n}\n\n/**\n * Remove all animation traces of the given `spid`s: each shape's `<p:bldP>` and\n * the effect-level `<p:par>` nodes whose `<p:spTgt>` targets it, then any wrapper\n * `<p:par>` left empty by the removal. Keeps the opaque timing tree free of\n * dangling references when shapes are deleted. Returns `true` when anything was\n * removed.\n */\nexport function pruneSpids(root: Element, spids: Iterable<number>): boolean {\n\tconst drop = new Set<number>()\n\tfor (const s of spids) drop.add(s)\n\tif (drop.size === 0) return false\n\n\tlet changed = false\n\tconst wrappersToCheck = new Set<Element>()\n\n\t// Remove effect pars whose spTgt targets a pruned shape.\n\tconst spTgts = Array.from(root.getElementsByTagNameNS(OOXML_NS.p, 'spTgt'))\n\tconst effectPars = new Set<Element>()\n\tfor (const spTgt of spTgts) {\n\t\tconst spid = numberValue(attr(spTgt, 'spid'))\n\t\tif (spid === null || !drop.has(spid)) continue\n\t\tconst effectPar = effectParFor(spTgt)\n\t\tif (effectPar) effectPars.add(effectPar)\n\t}\n\tfor (const effectPar of effectPars) {\n\t\tconst parent = effectPar.parentNode as Element | null\n\t\teffectPar.parentNode?.removeChild(effectPar)\n\t\tchanged = true\n\t\t// The wrapper par is two levels up: childTnLst → par.\n\t\tconst childTnLst = parent\n\t\tconst wrapperPar = childTnLst?.parentNode?.parentNode as Element | null\n\t\tif (wrapperPar) wrappersToCheck.add(wrapperPar)\n\t}\n\n\t// Remove now-empty wrapper pars, climbing while they keep collapsing.\n\tlet progress = true\n\twhile (progress) {\n\t\tprogress = false\n\t\t// The spread is a snapshot, not a redundant copy: the body both deletes the\n\t\t// current wrapper and adds its grandparent, and iterating a Set while mutating\n\t\t// it would visit entries added during this pass.\n\t\t// oxlint-disable-next-line unicorn/no-useless-spread\n\t\tfor (const wrapper of [...wrappersToCheck]) {\n\t\t\tif (isEmptyWrapperPar(wrapper)) {\n\t\t\t\tconst grandWrapper = wrapper.parentNode?.parentNode?.parentNode as Element | null\n\t\t\t\twrapper.parentNode?.removeChild(wrapper)\n\t\t\t\twrappersToCheck.delete(wrapper)\n\t\t\t\tif (grandWrapper) wrappersToCheck.add(grandWrapper)\n\t\t\t\tprogress = true\n\t\t\t\tchanged = true\n\t\t\t}\n\t\t}\n\t}\n\n\t// Remove the build-list entries.\n\tconst bldPs = Array.from(root.getElementsByTagNameNS(OOXML_NS.p, 'bldP'))\n\tfor (const bldP of bldPs) {\n\t\tconst spid = numberValue(attr(bldP, 'spid'))\n\t\tif (spid !== null && drop.has(spid)) {\n\t\t\tbldP.parentNode?.removeChild(bldP)\n\t\t\tchanged = true\n\t\t}\n\t}\n\n\t// Drop an emptied <p:bldLst>.\n\tconst bldLsts = Array.from(root.getElementsByTagNameNS(OOXML_NS.p, 'bldLst'))\n\tfor (const bldLst of bldLsts) {\n\t\tif (childElements(bldLst).length === 0) bldLst.parentNode?.removeChild(bldLst)\n\t}\n\n\treturn changed\n}\n\n/**\n * Flatten the whole slide to its final static state by removing the build\n * animation timeline: drop the `<p:timing>` block (which carries the `<p:bldLst>`\n * and the effect tree) so every shape renders at once with no click-through\n * staging. Gated on {@link hasAnimations}: a `<p:timing>` that is purely a\n * media loop (no `<p:bldP>` and no `presetID`-bearing node) is left untouched so\n * media playback survives. Returns `true` when a timing block was removed.\n *\n * This is the whole-slide counterpart to {@link pruneSpids} (which drops the\n * builds of specific shapes). It only removes staging; it never deletes shapes,\n * so a slide that animated alternating states over the same region will show\n * them all at once after flattening — that is \"drop animations\", distinct from\n * \"remove staged/duplicate shapes\".\n */\nexport function flattenAnimations(root: Element): boolean {\n\tif (!hasAnimations(root)) return false\n\tconst timing = firstChild(root, 'p:timing')\n\tif (!timing) return false\n\ttiming.parentNode?.removeChild(timing)\n\treturn true\n}\n\n// --- carry: bring a copied shape's build animation into a destination slide ---\n\nconst P_XMLNS = `xmlns:p=\"${P_NS}\"`\n/** A fresh `p:timing` carrying only an empty `tmRoot` (no effects yet). */\nconst TIMING_SCAFFOLD = `<p:timing ${P_XMLNS}><p:tnLst><p:par><p:cTn id=\"1\" dur=\"indefinite\" restart=\"never\" nodeType=\"tmRoot\"><p:childTnLst/></p:cTn></p:par></p:tnLst></p:timing>`\n/** A fresh `mainSeq` `p:seq` (its `cTn@id` is filled in by the caller). */\nconst MAIN_SEQ_SCAFFOLD =\n\t`<p:seq ${P_XMLNS} concurrent=\"1\" nextAc=\"seek\"><p:cTn id=\"0\" dur=\"indefinite\" nodeType=\"mainSeq\"><p:childTnLst/></p:cTn>` +\n\t'<p:prevCondLst><p:cond evt=\"onPrev\" delay=\"0\"><p:tgtEl><p:sldTgt/></p:tgtEl></p:cond></p:prevCondLst>' +\n\t'<p:nextCondLst><p:cond evt=\"onNext\" delay=\"0\"><p:tgtEl><p:sldTgt/></p:tgtEl></p:cond></p:nextCondLst></p:seq>'\n\n/** Largest `<p:cTn @id>` in a subtree (0 when none). */\nfunction maxCTnId(scope: Element): number {\n\tlet max = 0\n\tfor (const cTn of scope.getElementsByTagNameNS(P_NS, 'cTn')) {\n\t\tconst id = numberValue(attr(cTn, 'id'))\n\t\tif (id !== null && id > max) max = id\n\t}\n\treturn max\n}\n\n/** Renumber every `<p:cTn @id>` in `node` (document order) starting at `start`; returns the next free id. */\nfunction renumberCTnIds(node: Element, start: number): number {\n\tlet id = start\n\tfor (const cTn of node.getElementsByTagNameNS(P_NS, 'cTn')) setAttr(cTn, 'id', String(id++))\n\treturn id\n}\n\n/** Whether `par`'s subtree targets any of `spids` via a `<p:spTgt>`. */\nfunction targetsAnySpid(par: Element, spids: Set<number>): boolean {\n\tfor (const spTgt of par.getElementsByTagNameNS(P_NS, 'spTgt')) {\n\t\tconst spid = numberValue(attr(spTgt, 'spid'))\n\t\tif (spid !== null && spids.has(spid)) return true\n\t}\n\treturn false\n}\n\n/** Parse a namespaced scaffold string and import its root into `doc`. */\nfunction importScaffold(doc: Document, xml: string): Element {\n\treturn doc.importNode(parseXml(xml).documentElement as Element, true)\n}\n\n/**\n * A slide timing's main sequence: the `p:seq` whose `p:cTn` is marked `nodeType=\"mainSeq\"`, or\n * `null` when it has none.\n *\n * Not simply the first `p:seq`. A slide's embedded or online media is timed in an\n * `interactiveSeq`, and PowerPoint's media slides carry one and no `mainSeq`, so the first\n * `p:seq` there is the media trigger sequence. Taken as the main one, a carried click step landed\n * in it on the destination, and a media trigger lifted off such a slide was carried as a click\n * step.\n */\nfunction mainSeqOf(timing: Element): Element | null {\n\tfor (const seq of timing.getElementsByTagNameNS(P_NS, 'seq')) {\n\t\tconst cTn = firstChild(seq, 'p:cTn')\n\t\tif (cTn && attr(cTn, 'nodeType') === 'mainSeq') return seq\n\t}\n\treturn null\n}\n\n/** The destination `mainSeq` `p:childTnLst` to append click groups into, creating the timing/seq scaffold as needed. */\nfunction getOrCreateMainSeqChildTnLst(root: Element, doc: Document): Element {\n\tlet timing = firstChild(root, 'p:timing')\n\tif (!timing) {\n\t\ttiming = importScaffold(doc, TIMING_SCAFFOLD)\n\t\tinsertInOrder(root, timing, SLIDE_AFTER_TIMING)\n\t}\n\t// Reuse an existing mainSeq if present.\n\tconst existingSeq = mainSeqOf(timing)\n\tif (existingSeq) {\n\t\tconst seqCTn = firstChild(existingSeq, 'p:cTn')\n\t\tif (seqCTn) {\n\t\t\tlet childLst = firstChild(seqCTn, 'p:childTnLst')\n\t\t\tif (!childLst) {\n\t\t\t\tchildLst = createElement(doc, 'p:childTnLst')\n\t\t\t\tseqCTn.appendChild(childLst)\n\t\t\t}\n\t\t\treturn childLst\n\t\t}\n\t}\n\t// Otherwise insert a fresh mainSeq into the tmRoot child list (before any media nodes).\n\tlet tmRootChildLst = timing.getElementsByTagNameNS(P_NS, 'childTnLst')[0]\n\tif (!tmRootChildLst) {\n\t\t// Degenerate timing with no tmRoot child list — graft the full scaffold's tnLst.\n\t\tconst fresh = importScaffold(doc, TIMING_SCAFFOLD)\n\t\tconst freshTnLst = firstChild(fresh, 'p:tnLst')\n\t\tif (freshTnLst) insertInOrder(timing, freshTnLst, TIMING_AFTER_TNLST)\n\t\ttmRootChildLst = timing.getElementsByTagNameNS(P_NS, 'childTnLst')[0]\n\t}\n\tif (!tmRootChildLst)\n\t\tthrow new InternalError(\n\t\t\t'animation/timing-scaffold-failed',\n\t\t\t'getOrCreateMainSeqChildTnLst: failed to resolve or create the tmRoot child list'\n\t\t)\n\tconst seq = importScaffold(doc, MAIN_SEQ_SCAFFOLD)\n\tsetAttr(firstChild(seq, 'p:cTn') as Element, 'id', String(maxCTnId(timing) + 1))\n\ttmRootChildLst.insertBefore(seq, tmRootChildLst.firstChild)\n\treturn firstChild(firstChild(seq, 'p:cTn') as Element, 'p:childTnLst') as Element\n}\n\n/** The destination `p:bldLst` (under `p:timing`), creating it before any `p:extLst`. */\nfunction getOrCreateBldLst(timing: Element, doc: Document): Element {\n\tlet bldLst = firstChild(timing, 'p:bldLst')\n\tif (!bldLst) {\n\t\tbldLst = createElement(doc, 'p:bldLst')\n\t\tinsertInOrder(timing, bldLst, ['p:extLst'])\n\t}\n\treturn bldLst\n}\n\n/**\n * Carry the build animation of one or more copied shapes from `sourceRoot`'s\n * timing into `targetRoot`'s, remapping shape ids via `spidMap` (source id → new\n * id on the destination). For each mapped shape: its mainSeq click-group `<p:par>`\n * (the whole click step) and `<p:bldP>` are cloned, their `spid`s remapped, their\n * `<p:cTn>` ids renumbered to stay collision-free in the destination, and appended\n * after any existing build — matching how PowerPoint merges a pasted shape's\n * animation. Returns `true` when anything was carried (so the caller can\n * `markDirty()`), `false` when the source shapes have no animation.\n */\nexport function carryShapeAnimations(sourceRoot: Element, targetRoot: Element, spidMap: Map<number, number>): boolean {\n\tconst sourceTiming = firstChild(sourceRoot, 'p:timing')\n\tif (!sourceTiming) return false\n\tconst carriedSpids = new Set(spidMap.keys())\n\n\t// Source click groups (direct children of the mainSeq child list) that target a carried shape.\n\tconst sourceSeq = mainSeqOf(sourceTiming)\n\tconst groups: Element[] = []\n\tif (sourceSeq) {\n\t\tconst seqCTn = firstChild(sourceSeq, 'p:cTn')\n\t\tconst seqChildLst = seqCTn ? firstChild(seqCTn, 'p:childTnLst') : null\n\t\tif (seqChildLst) {\n\t\t\tfor (const par of childElements(seqChildLst)) {\n\t\t\t\tif (targetsAnySpid(par, carriedSpids)) groups.push(par)\n\t\t\t}\n\t\t}\n\t}\n\t// Source build-list entries for the carried shapes.\n\tconst sourceBldLst = firstChild(sourceTiming, 'p:bldLst')\n\tconst bldPs: Element[] = []\n\tif (sourceBldLst) {\n\t\tfor (const bldP of childElements(sourceBldLst)) {\n\t\t\tconst spid = numberValue(attr(bldP, 'spid'))\n\t\t\tif (spid !== null && carriedSpids.has(spid)) bldPs.push(bldP)\n\t\t}\n\t}\n\tconst doc = targetRoot.ownerDocument as Document\n\t// A click group can animate several shapes, and only the carried ones have a counterpart here.\n\t// An effect on any other shape would keep its source id, and so animate whatever shape carries\n\t// that id on this slide, or name nothing. Those effects are pruned from the copy, and a group\n\t// left animating nothing that was carried is not carried at all.\n\tconst clones = groups\n\t\t.map((par) => doc.importNode(par, true))\n\t\t.filter((clone) => {\n\t\t\tpruneSpids(clone, spidsNotIn(clone, spidMap))\n\t\t\treturn targetsOnly(clone, spidMap)\n\t\t})\n\tif (clones.length === 0 && bldPs.length === 0) return false\n\n\tconst destChildLst = getOrCreateMainSeqChildTnLst(targetRoot, doc)\n\tconst destTiming = firstChild(targetRoot, 'p:timing') as Element\n\tlet nextId = maxCTnId(destTiming) + 1\n\n\tfor (const clone of clones) {\n\t\tremapSpids(clone, spidMap)\n\t\tnextId = renumberCTnIds(clone, nextId)\n\t\tdestChildLst.appendChild(clone)\n\t}\n\tif (bldPs.length > 0) {\n\t\tconst destBldLst = getOrCreateBldLst(destTiming, doc)\n\t\tfor (const bldP of bldPs) {\n\t\t\tconst clone = doc.importNode(bldP, true)\n\t\t\tremapSpids(clone, spidMap)\n\t\t\tdestBldLst.appendChild(clone)\n\t\t}\n\t}\n\treturn true\n}\n\n/** The `spid`s referenced under `root`, `root` included, that `spidMap` has no entry for. */\nfunction spidsNotIn(root: Element, spidMap: ReadonlyMap<number, number>): Set<number> {\n\tconst out = new Set<number>()\n\tfor (const element of spidElements(root)) {\n\t\tconst spid = numberValue(attr(element, 'spid'))\n\t\tif (spid !== null && !spidMap.has(spid)) out.add(spid)\n\t}\n\treturn out\n}\n\n/** Whether `root` still targets a shape, and every shape it targets is one `spidMap` carries. */\nfunction targetsOnly(root: Element, spidMap: ReadonlyMap<number, number>): boolean {\n\tconst targets = [...root.getElementsByTagNameNS(P_NS, 'spTgt')].map((spTgt) => numberValue(attr(spTgt, 'spid')))\n\treturn targets.length > 0 && targets.every((spid) => spid !== null && spidMap.has(spid))\n}\n","/**\n * The abstract base every shape kind extends.\n *\n * It owns everything a shape has regardless of kind: non-visual identity (id / name / hidden /\n * description / decorative), geometry through the subclass-supplied `a:xfrm`, and the `p:spPr`\n * surface — fill, line, gradient, effects — resolved against the host's theme. Kind-specific\n * reads live on the subclasses in the sibling modules.\n *\n * A proxy holds a back-reference to its owning {@link ShapeHost} — a `Slide`, a `SlideLayout` or a\n * `SlideMaster` — so it can resolve relationships and theme colours, and so a mutation can mark\n * that host's part dirty.\n */\n\nimport {\n\tELEMENT_NODE,\n\tOOXML_NS,\n\tattr,\n\tboolValue,\n\tfirstChild,\n\tgetElements,\n\tgetOrAddChild,\n\tnumberValue,\n\tremoveAttr,\n\tsetAttr,\n\ttype Element,\n} from '../../oxml/dom.js'\nimport { composeGroupFrame, type GroupTransform } from './group-transform.js'\nimport { applyNoFill, applySolidFill, hasFillChoice, solidFillColor, type SolidFillEdit } from '../../oxml/fill.js'\nimport {\n\tresolveInheritedFrame,\n\tresolveSolidFillColor,\n\tresolveStyleFillColor,\n\tresolveStyleLineColor,\n\ttype PlaceholderRef,\n\ttype ResolvedColor,\n\ttype ResolvedFrame,\n} from '../theme-context.js'\nimport { readGradientFill, readGradientStops, type GradientFill, type GradientStop } from '../gradient.js'\nimport { readPictureFill, type PictureFill } from '../picture-fill.js'\nimport { readPatternFill } from '../pattern-fill.js'\nimport { readLineBasics, type LineBasics } from '../line.js'\nimport { type Hyperlink, readHyperlink } from '../hyperlink.js'\nimport { readGlow, readInnerShadow, readOuterShadow, readReflection, readSoftEdge } from './effects.js'\nimport { TextFrame } from '../text.js'\nimport type { ShapeHost } from './host.js'\nimport {\n\tchildElements,\n\temuFrom,\n\tgetOrAddSpPrXfrm,\n\tnonVisualCNvPr,\n\tLN_FILL_AFTER,\n\tSHAPE_AFTER_SPPR,\n\tSPPR_FILL_AFTER,\n\tSPPR_LN_AFTER,\n\ttype PaintSurface,\n} from './oxml.js'\nimport { readBox, readGeometryPath, rotationDegrees, transformFlipH, transformFlipV } from './geometry.js'\nimport type {\n\tAbsoluteFrame,\n\tAbsoluteFrameFailure,\n\tCustomGeometry,\n\tGlow,\n\tInnerShadow,\n\tLineEnd,\n\tLineEnds,\n\tOuterShadow,\n\tPatternFill,\n\tReflection,\n\tShapeType,\n\tSoftEdge,\n} from './types.js'\nimport { InternalError, PackageReadError, UnsupportedFeatureError } from '../../../errors.js'\nimport { checkFiniteEmu, checkPositiveEmu } from '../coords.js'\nimport { drawingIdsIn, unbindConnectors } from '../../oxml/slide-dom.js'\nimport { pruneSpids } from '../animation.js'\n\n// Microsoft's \"decorative\" accessibility extension: p:cNvPr/a:extLst/a:ext\n// (uri {C183D7F6-B498-43B3-948B-1728B52AA6E4}) / adec:decorative. Confirmed\n// against real PowerPoint output (\"Mark as decorative\").\nconst ADEC_NS = 'http://schemas.microsoft.com/office/drawing/2017/decorative'\n\n/** Common base for every shape in a shape tree — a slide's, a layout's, or a master's. */\nexport abstract class Shape {\n\tconstructor(\n\t\tprotected readonly element: Element,\n\t\t/**\n\t\t * The part that owns this shape's tree — a `Slide`, a `SlideLayout`, or a\n\t\t * `SlideMaster`. Narrow it with `instanceof` when you need the concrete class;\n\t\t * {@link ShapeHost.partName} tells the tiers apart without one.\n\t\t */\n\t\treadonly host: ShapeHost\n\t) {}\n\n\t/** Which concrete shape kind this is. */\n\tabstract readonly shapeType: ShapeType\n\n\t/**\n\t * The transform element carrying this shape's geometry, or `null` if inherited.\n\t *\n\t * Defaults to `p:spPr/a:xfrm`, which is where three of the four shape kinds keep it\n\t * (`p:sp`, `p:pic`, `p:cxnSp`). {@link GraphicFrame} overrides it: a `p:graphicFrame`\n\t * has no `p:spPr` and carries a `p:xfrm` of its own directly.\n\t */\n\tprotected xfrm(): Element | null {\n\t\tconst spPr = firstChild(this.element, 'p:spPr')\n\t\treturn spPr ? firstChild(spPr, 'a:xfrm') : null\n\t}\n\n\t/** The transform element, creating it (and its container) in document order if absent. */\n\tprotected getOrAddXfrm(): Element {\n\t\treturn getOrAddSpPrXfrm(this.element)\n\t}\n\n\t/**\n\t * Mark the owning host's part dirty so `save()` reserializes it. Public\n\t * because {@link element_} hands out the live DOM node: the hatch and the\n\t * obligation that comes with it belong on the same object.\n\t */\n\tmarkDirty(): void {\n\t\tthis.host.part.markDirty()\n\t}\n\n\t/** Drawing id (`p:cNvPr/@id`), or `null` if absent. */\n\tget id(): number | null {\n\t\tconst cNvPr = nonVisualCNvPr(this.element)\n\t\treturn cNvPr ? numberValue(attr(cNvPr, 'id')) : null\n\t}\n\n\t/** Shape name (`p:cNvPr/@name`), or `''` if unnamed. */\n\tget name(): string {\n\t\tconst cNvPr = nonVisualCNvPr(this.element)\n\t\treturn (cNvPr && attr(cNvPr, 'name')) ?? ''\n\t}\n\n\t/**\n\t * The shape's own click hyperlink (`p:cNvPr/a:hlinkClick`), or `null` when it carries none.\n\t *\n\t * This is the link PowerPoint's Insert > Link puts on a whole shape, as opposed to the one a\n\t * {@link Run} carries on a span of text. It is the same element, read the same way, and it had\n\t * no reader at all -- so a linked shape read back as an ordinary one and a replica lost the\n\t * link with nothing to say so. `addShape`, `addText` and `addImage` all take `hyperlink`.\n\t *\n\t * A URL link resolves its `@r:id` to the external target; a slide jump resolves it to the\n\t * linked slide's partname and reports `ppaction://hlinksldjump` as its `action`. An\n\t * action-only link (a slide-show navigation button) has no `@r:id` and resolves to neither.\n\t */\n\tget hyperlink(): Hyperlink | null {\n\t\treturn readHyperlink(nonVisualCNvPr(this.element), this.host.relationships)\n\t}\n\n\t/**\n\t * Whether the shape is explicitly hidden (`p:cNvPr/@hidden=\"1\"`); `false` when\n\t * the attribute is unset. A hidden shape stays in the slide XML but is not\n\t * rendered — decks use it as a fallback layer (e.g. a duotone-recolour source\n\t * sitting behind the visible icon), so a faithful reader must distinguish it\n\t * from the drawn shapes.\n\t */\n\tget hidden(): boolean {\n\t\tconst cNvPr = nonVisualCNvPr(this.element)\n\t\treturn boolValue(cNvPr && attr(cNvPr, 'hidden')) === true\n\t}\n\n\t/**\n\t * The shape's alt-text description (`p:cNvPr/@descr`), or `null` when unset.\n\t * This is the accessibility primitive a screen reader announces; an audit or\n\t * accessible-export tool reads it here. Distinct from {@link name}, which is\n\t * the authoring-time shape name and is never surfaced to assistive tech.\n\t */\n\tget description(): string | null {\n\t\tconst cNvPr = nonVisualCNvPr(this.element)\n\t\tconst v = cNvPr && attr(cNvPr, 'descr')\n\t\treturn v ?? null\n\t}\n\n\t/**\n\t * Set (or clear, with `''`) the alt-text description. Requires the shape's\n\t * `p:cNvPr` to exist, which every well-formed shape carries.\n\t */\n\tset description(value: string) {\n\t\tconst cNvPr = nonVisualCNvPr(this.element)\n\t\tif (!cNvPr)\n\t\t\tthrow new PackageReadError('shape/no-non-visual-properties', 'cannot set description: shape has no p:cNvPr')\n\t\tif (value === '') removeAttr(cNvPr, 'descr')\n\t\telse setAttr(cNvPr, 'descr', value)\n\t\tthis.markDirty()\n\t}\n\n\t/**\n\t * The shape's alt-text title (`p:cNvPr/@title`), or `null` when unset. Modern\n\t * PowerPoint no longer exposes a separate title field (only description +\n\t * \"mark as decorative\"), so this is usually `null`; it survives on decks\n\t * authored by older PowerPoint or other producers that still write it.\n\t */\n\tget title(): string | null {\n\t\tconst cNvPr = nonVisualCNvPr(this.element)\n\t\tconst v = cNvPr && attr(cNvPr, 'title')\n\t\treturn v ?? null\n\t}\n\n\t/**\n\t * Whether the shape is flagged **decorative** (`p:cNvPr/a:extLst/a:ext`\n\t * uri `{C183D7F6-…}` / `adec:decorative@val`), PowerPoint's \"Mark as\n\t * decorative\" — a purely visual element assistive tech should skip. `false`\n\t * when the extension is absent. A decorative shape typically has no\n\t * {@link description}; the two are alternatives, not companions.\n\t */\n\tget isDecorative(): boolean {\n\t\tconst cNvPr = nonVisualCNvPr(this.element)\n\t\tconst extLst = cNvPr && firstChild(cNvPr, 'a:extLst')\n\t\tif (!extLst) return false\n\t\tfor (const ext of getElements(extLst, 'a:ext')) {\n\t\t\tfor (const child of childElements(ext)) {\n\t\t\t\tif (child.localName === 'decorative' && child.namespaceURI === ADEC_NS) {\n\t\t\t\t\treturn boolValue(attr(child, 'val')) === true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\n\t/** Left edge in EMU (`a:off/@x`), or `null` when the shape has no own transform. */\n\tget left(): number | null {\n\t\treturn emuFrom(this.xfrm(), 'a:off', 'x')\n\t}\n\n\tset left(value: number) {\n\t\tthis.#setOffset('x', value)\n\t}\n\n\t/** Top edge in EMU (`a:off/@y`), or `null` when the shape has no own transform. */\n\tget top(): number | null {\n\t\treturn emuFrom(this.xfrm(), 'a:off', 'y')\n\t}\n\n\tset top(value: number) {\n\t\tthis.#setOffset('y', value)\n\t}\n\n\t/** Width in EMU (`a:ext/@cx`), or `null` when the shape has no own transform. */\n\tget width(): number | null {\n\t\treturn emuFrom(this.xfrm(), 'a:ext', 'cx')\n\t}\n\n\tset width(value: number) {\n\t\tthis.#setExtent('cx', value)\n\t}\n\n\t/** Height in EMU (`a:ext/@cy`), or `null` when the shape has no own transform. */\n\tget height(): number | null {\n\t\treturn emuFrom(this.xfrm(), 'a:ext', 'cy')\n\t}\n\n\tset height(value: number) {\n\t\tthis.#setExtent('cy', value)\n\t}\n\n\t/**\n\t * This shape's effective position and size in EMU: its own `a:xfrm` when it has\n\t * one ({@link left}/{@link top}/{@link width}/{@link height}, tagged\n\t * `source: 'own'`); otherwise, for a placeholder, the geometry it inherits from\n\t * the matching layout placeholder, else the master's (tagged accordingly). A\n\t * non-placeholder shape with no own transform has nothing to inherit from and\n\t * reads `null`, as does a placeholder whose layout/master chain defines no\n\t * matching geometry either.\n\t *\n\t * The writer always emits an explicit `a:xfrm` on every placeholder it authors,\n\t * so `source` reads `'own'` for every authored deck; `'layout'`/`'master'` is\n\t * the case an *imported* deck exercises, when PowerPoint itself leaves a\n\t * placeholder's geometry to inherit.\n\t */\n\tget resolvedFrame(): ResolvedFrame | null {\n\t\tconst left = this.left\n\t\tconst top = this.top\n\t\tconst width = this.width\n\t\tconst height = this.height\n\t\tif (left !== null && top !== null && width !== null && height !== null) {\n\t\t\treturn { left, top, width, height, source: 'own' }\n\t\t}\n\t\tconst ph = this.placeholder\n\t\tif (!ph) return null\n\t\treturn resolveInheritedFrame(ph, this.host.themeContext())\n\t}\n\n\t/**\n\t * Clockwise rotation in degrees (`a:xfrm/@rot` ÷ 60000), or `null` when the\n\t * shape has no own transform. A present xfrm with no `@rot` reads as `0`, so\n\t * — mirroring {@link left}/{@link top}/{@link width}/{@link height} — `null`\n\t * (\"inherits layout geometry\") stays distinct from `0` (\"has a transform, not\n\t * rotated\"). The value is faithful to the XML and not normalised to a signed\n\t * range, so a `@rot` past 360° (e.g. a negative angle stored as `19216344`)\n\t * reads back greater than 360. This is the shape's own orientation; use\n\t * {@link absoluteFrame} when you need the effective orientation after\n\t * enclosing group transforms are composed.\n\t */\n\tget rotation(): number | null {\n\t\tconst xfrm = this.xfrm()\n\t\tif (!xfrm) return null\n\t\treturn rotationDegrees(xfrm)\n\t}\n\n\t/**\n\t * Whether the shape is flipped horizontally (`a:xfrm/@flipH`); `false` when\n\t * unset or when the shape has no own transform. This is the shape's own\n\t * horizontal flip; use {@link absoluteFrame} for the effective value after\n\t * enclosing group transforms are composed.\n\t */\n\tget flipH(): boolean {\n\t\tconst xfrm = this.xfrm()\n\t\treturn xfrm !== null && transformFlipH(xfrm)\n\t}\n\n\t/**\n\t * Whether the shape is flipped vertically (`a:xfrm/@flipV`); `false` when\n\t * unset or when the shape has no own transform. This is the shape's own\n\t * vertical flip; use {@link absoluteFrame} for the effective value after\n\t * enclosing group transforms are composed.\n\t */\n\tget flipV(): boolean {\n\t\tconst xfrm = this.xfrm()\n\t\treturn xfrm !== null && transformFlipV(xfrm)\n\t}\n\n\t/**\n\t * This shape's position, size, and effective orientation in **slide-absolute**\n\t * EMU/degrees, composing every enclosing group transform.\n\t *\n\t * {@link left}/{@link top}/{@link width}/{@link height} report a group child's\n\t * geometry in its group's child coordinate space (`a:chOff`/`a:chExt`), which is\n\t * not directly placeable on the slide. This getter walks the `p:grpSp` ancestor\n\t * chain outward, mapping the box through each group's\n\t * `off + (p - chOff) * (ext / chExt)` transform, then composing group flips and\n\t * rotations about the group centre. For a shape already at slide level the box\n\t * equals its own `{ left, top, width, height }`, while `rotation`/`flipH`/`flipV`\n\t * equal the shape's own transform values.\n\t *\n\t * `null` when the shape (or any enclosing group) has no own transform, or a\n\t * group's `a:chExt` is degenerate (zero) — there is then no resolvable frame.\n\t * {@link absoluteFrameFailure} says which of those it was.\n\t *\n\t * A rotated shape's returned `left`/`top` remain PowerPoint's unrotated\n\t * placement box (the same box PowerPoint writes after Ungroup), with the\n\t * effective rotation exposed separately.\n\t */\n\tget absoluteFrame(): AbsoluteFrame | null {\n\t\tconst resolved = this.#resolveAbsoluteFrame()\n\t\treturn typeof resolved === 'string' ? null : resolved\n\t}\n\n\t/**\n\t * Why {@link absoluteFrame} is `null`, or `null` when it resolved.\n\t *\n\t * `absoluteFrame` reports one `null` for three different situations, and only a\n\t * caller that wants to *report* the unresolvable shape needs them apart — an\n\t * inherited placeholder box is ordinary, a group with no usable `a:xfrm` is not.\n\t * The distinction is not recoverable from the `null`, and re-deriving it means\n\t * walking the same ancestry a second time, so it is named here instead. See\n\t * {@link AbsoluteFrameFailure} for what each value means.\n\t */\n\tget absoluteFrameFailure(): AbsoluteFrameFailure | null {\n\t\tconst resolved = this.#resolveAbsoluteFrame()\n\t\treturn typeof resolved === 'string' ? resolved : null\n\t}\n\n\t/**\n\t * The one ancestry walk behind {@link absoluteFrame} and\n\t * {@link absoluteFrameFailure}: the composed frame, or the reason there is none.\n\t * A frame is always an object and a failure always a string, so the two project\n\t * out of it without a wrapper.\n\t */\n\t#resolveAbsoluteFrame(): AbsoluteFrame | AbsoluteFrameFailure {\n\t\tconst xfrm = this.xfrm()\n\t\tif (!xfrm) return 'no-own-transform'\n\t\tconst box = readBox(xfrm, 'a:off', 'a:ext')\n\t\tif (!box) return 'no-own-transform'\n\n\t\tconst groups: GroupTransform[] = []\n\t\tfor (let node = this.element.parentNode; node && node.nodeType === ELEMENT_NODE; node = node.parentNode) {\n\t\t\tconst parent = node as Element\n\t\t\tif (parent.namespaceURI !== OOXML_NS.p || parent.localName !== 'grpSp') break // reached the shape tree (or a non-group)\n\t\t\tconst grpSpPr = firstChild(parent, 'p:grpSpPr')\n\t\t\tconst groupXfrm = grpSpPr && firstChild(grpSpPr, 'a:xfrm')\n\t\t\tconst outer = groupXfrm && readBox(groupXfrm, 'a:off', 'a:ext')\n\t\t\tconst child = groupXfrm && readBox(groupXfrm, 'a:chOff', 'a:chExt')\n\t\t\tif (!groupXfrm || !outer || !child) return 'group-transform-missing'\n\t\t\tgroups.push({\n\t\t\t\touter,\n\t\t\t\tchild,\n\t\t\t\trotation: rotationDegrees(groupXfrm),\n\t\t\t\tflipH: transformFlipH(groupXfrm),\n\t\t\t\tflipV: transformFlipV(groupXfrm),\n\t\t\t})\n\t\t}\n\n\t\tconst frame = composeGroupFrame(\n\t\t\t{ box, rotation: rotationDegrees(xfrm), flipH: transformFlipH(xfrm), flipV: transformFlipV(xfrm) },\n\t\t\tgroups\n\t\t)\n\t\t// `composeGroupFrame` returns `null` for exactly one reason — a group's zero\n\t\t// `a:chExt` — and it is the authority on that rule. Re-testing `chExt` here to\n\t\t// name the failure would put the rule in two places for no gain.\n\t\tif (!frame) return 'group-transform-degenerate'\n\t\treturn {\n\t\t\tleft: Math.round(frame.box.x),\n\t\t\ttop: Math.round(frame.box.y),\n\t\t\twidth: Math.round(frame.box.cx),\n\t\t\theight: Math.round(frame.box.cy),\n\t\t\trotation: frame.rotation,\n\t\t\tflipH: frame.flipH,\n\t\t\tflipV: frame.flipV,\n\t\t}\n\t}\n\n\t#setOffset(axis: 'x' | 'y', value: number): void {\n\t\t// An offset may be negative — a shape can sit off the left or top edge — so it needs the\n\t\t// finite check and nothing more. Both setters used a private `toEmu` that also rejected a\n\t\t// negative *extent* under its own `coord/negative`; `checkPositiveEmu` is the rule the\n\t\t// rest of the read model's setters already apply, and `ST_PositiveCoordinate` has no room\n\t\t// for zero either.\n\t\tconst emu = checkFiniteEmu(value, axis)\n\t\tconst off = getOrAddChild(this.getOrAddXfrm(), 'a:off', ['a:ext'])\n\t\tsetAttr(off, axis, String(emu))\n\t\tthis.markDirty()\n\t}\n\n\t#setExtent(axis: 'cx' | 'cy', value: number): void {\n\t\tconst emu = checkPositiveEmu(value, axis)\n\t\tconst ext = getOrAddChild(this.getOrAddXfrm(), 'a:ext')\n\t\tsetAttr(ext, axis, String(emu))\n\t\tthis.markDirty()\n\t}\n\n\t/** The shape's properties element (`p:spPr` / `p:grpSpPr`), or `null` when absent. */\n\tprotected properties(): Element | null {\n\t\treturn firstChild(this.element, 'p:spPr')\n\t}\n\n\t/**\n\t * Where this kind's paint is written, and which paints it can carry: its properties element,\n\t * and for each paint the successors that paint's element goes before, or `null` for a paint\n\t * the kind cannot carry. `null` for a kind with no properties element at all.\n\t *\n\t * The one capability a kind declares about paint, checked in one place. Setting a fill (a\n\t * colour, a theme token, {@link noFill}) on a kind that cannot carry one throws\n\t * `shape/fill-unsupported`, and setting a line colour throws `shape/line-unsupported`.\n\t * Clearing never throws: a kind that cannot be *given* a paint may still hold one a deck wrote,\n\t * so clearing removes whatever of that paint the element has, and changes nothing when it has\n\t * none.\n\t */\n\tprotected paintSurface(): PaintSurface | null {\n\t\treturn {\n\t\t\tgetOrAdd: () => getOrAddChild(this.element, 'p:spPr', SHAPE_AFTER_SPPR),\n\t\t\tfill: SPPR_FILL_AFTER,\n\t\t\tline: SPPR_LN_AFTER,\n\t\t}\n\t}\n\n\t/** Explicit RGB fill colour as a 6-hex string (`spPr/a:solidFill/a:srgbClr/@val`), or `null`. */\n\tget fillColor(): string | null {\n\t\treturn solidFillColor(this.properties(), 'a:srgbClr')\n\t}\n\n\tset fillColor(value: string | null) {\n\t\tthis.#applyFill(value === null ? null : { hex: value })\n\t}\n\n\t/** Theme colour token when the fill is a scheme colour (`a:solidFill/a:schemeClr/@val`, e.g. `accent2`), or `null`. */\n\tget fillSchemeColor(): string | null {\n\t\treturn solidFillColor(this.properties(), 'a:schemeClr')\n\t}\n\n\tset fillSchemeColor(value: string | null) {\n\t\tthis.#applyFill(value === null ? null : { scheme: value })\n\t}\n\n\t/**\n\t * `true` when the shape sets an explicit no-fill (`spPr/a:noFill`) — a\n\t * deliberately transparent surface. The fill-side counterpart of\n\t * {@link lineNoFill}, and the only accessor that separates it from a shape\n\t * carrying no fill child at all (one inheriting through `p:style/a:fillRef`):\n\t * every other fill accessor — {@link fillColor}, {@link fillSchemeColor},\n\t * {@link resolvedFill}, {@link gradientFill}, {@link patternFill},\n\t * {@link pictureFill} — reports `null` for both. The two paint completely\n\t * differently, so a consumer that cannot tell them apart paints a transparent\n\t * shape in the theme's accent colour.\n\t */\n\tget fillNoFill(): boolean {\n\t\tconst props = this.properties()\n\t\treturn !!(props && firstChild(props, 'a:noFill'))\n\t}\n\n\t/**\n\t * Set an explicit `<a:noFill/>` on the shape — a transparent surface. This is\n\t * distinct from clearing the fill (`fillColor = null`), which removes the\n\t * `a:solidFill` and lets the fill inherit from the shape's style/placeholder.\n\t * Read it back with {@link fillNoFill}.\n\t */\n\tnoFill(): void {\n\t\tconst { getOrAdd, after } = this.#paintTarget('fill')\n\t\tif (applyNoFill(this.properties(), getOrAdd, after)) this.markDirty()\n\t}\n\n\t/** Explicit RGB line/border colour (`spPr/a:ln/a:solidFill/a:srgbClr/@val`), or `null`. */\n\tget lineColor(): string | null {\n\t\treturn this.#lineBasics()?.colorRef.srgb ?? null\n\t}\n\n\tset lineColor(value: string | null) {\n\t\tthis.#applyLine(value === null ? null : { hex: value })\n\t}\n\n\t/** Theme colour token when the line is a scheme colour (`a:ln/a:solidFill/a:schemeClr/@val`), or `null`. */\n\tget lineSchemeColor(): string | null {\n\t\treturn this.#lineBasics()?.colorRef.scheme ?? null\n\t}\n\n\tset lineSchemeColor(value: string | null) {\n\t\tthis.#applyLine(value === null ? null : { scheme: value })\n\t}\n\n\t/** Line/border width in points (`spPr/a:ln/@w` is EMU; 12700 EMU = 1pt), or `null` when unset. */\n\tget lineWidthPt(): number | null {\n\t\treturn this.#lineBasics()?.widthPt ?? null\n\t}\n\n\t/**\n\t * The line/border dash style (`spPr/a:ln/a:prstDash/@val`), e.g. `'dash'`,\n\t * `'lgDashDot'`, `'sysDot'`, or `null` when the line is solid/unset. A faithful\n\t * replica of dashed dividers and dashed card borders needs this — it is\n\t * otherwise invisible in {@link lineColor}/{@link lineWidthPt} alone.\n\t */\n\tget lineDash(): string | null {\n\t\treturn this.#lineBasics()?.dash ?? null\n\t}\n\n\t/**\n\t * `true` when the shape sets an explicit no-line (`spPr/a:ln/a:noFill`) — a\n\t * deliberately border-less shape. Distinct from simply having no `a:ln`\n\t * (an inherited line), which {@link resolvedLine} cannot tell apart: both\n\t * report `null`. A replica that relies on a shadow instead of a border needs\n\t * to know the border was explicitly suppressed.\n\t */\n\tget lineNoFill(): boolean {\n\t\treturn this.#lineBasics()?.noFill ?? false\n\t}\n\n\t/**\n\t * The line end cap (`spPr/a:ln/@cap`) as the raw OOXML token — `'flat'`,\n\t * `'rnd'` (round) or `'sq'` (square) — or `null` when unset (PowerPoint's\n\t * default is `flat`). The write API authors this attribute through\n\t * `ShapeLineProps.cap`, so without the accessor a deck this library produced\n\t * could not be read back without losing it.\n\t *\n\t * Not cosmetic on a thick dashed rule: the cap decides whether each dash reads\n\t * as a rectangle or a lozenge, and it extends every dash by the stroke width.\n\t * SVG's `stroke-linecap` is the exact equivalent (`flat`→`butt`, `rnd`→`round`,\n\t * `sq`→`square`).\n\t */\n\tget lineCap(): string | null {\n\t\tconst ln = this.#line()\n\t\treturn ln ? (attr(ln, 'cap') ?? null) : null\n\t}\n\n\t/**\n\t * The line alignment (`spPr/a:ln/@algn`) as the raw OOXML token — `'ctr'`\n\t * (centred on the shape's outline) or `'in'` (inset, drawn wholly inside it) —\n\t * or `null` when unset. It shifts a thick outline by half its width, so it\n\t * changes where the border sits relative to the fill.\n\t */\n\tget lineAlign(): string | null {\n\t\tconst ln = this.#line()\n\t\treturn ln ? (attr(ln, 'algn') ?? null) : null\n\t}\n\n\t/**\n\t * Preset geometry name (`spPr/a:prstGeom/@prst`, e.g. `rect`), or `null` for\n\t * custom geometry or none. Not an auto-shape-only property: PowerPoint gives a\n\t * picture and a connector a preset geometry too (a `p:pic` is `rect` unless it\n\t * has been cropped to a shape), so it reads off whichever properties element\n\t * this kind carries. A group has no geometry of its own and reads `null`.\n\t */\n\tget presetGeometry(): string | null {\n\t\tconst props = this.properties()\n\t\tconst prstGeom = props && firstChild(props, 'a:prstGeom')\n\t\treturn prstGeom ? attr(prstGeom, 'prst') : null\n\t}\n\n\t/**\n\t * Custom freeform geometry (`spPr/a:custGeom/a:pathLst`), or `null` when the\n\t * shape uses preset geometry / none. The faithful, multi-path counterpart of\n\t * {@link presetGeometry}: each `a:path` keeps its own path-unit viewport\n\t * (`w`/`h`) and ordered {@link GeometryCommand}s. Coordinates are raw path-unit\n\t * integers, not EMU — pair the path `w`/`h` with the shape's box size to map\n\t * them into slide space.\n\t *\n\t * Not an auto-shape-only property either: a picture clipped to a freeform (what\n\t * PowerPoint writes when Merge Shapes intersects a picture with a shape, and what\n\t * `addImage({ points })` writes) carries its clip here. A group reads `null`.\n\t */\n\tget customGeometry(): CustomGeometry | null {\n\t\tconst props = this.properties()\n\t\tconst custGeom = props && firstChild(props, 'a:custGeom')\n\t\tif (!custGeom) return null\n\t\tconst pathLst = firstChild(custGeom, 'a:pathLst')\n\t\tconst paths = pathLst ? getElements(pathLst, 'a:path').map((p) => readGeometryPath(p)) : []\n\t\treturn { paths }\n\t}\n\n\t/**\n\t * Preset-geometry adjustment values (`spPr/a:prstGeom/a:avLst/a:gd`) as a\n\t * name → formula map, e.g. `{ adj: 'val 16667' }`. Empty when the shape has no\n\t * adjust handles (or uses custom geometry). Pair with {@link presetGeometry}.\n\t */\n\tget adjustValues(): Record<string, string> {\n\t\tconst props = this.properties()\n\t\tconst prstGeom = props && firstChild(props, 'a:prstGeom')\n\t\tconst avLst = prstGeom && firstChild(prstGeom, 'a:avLst')\n\t\tconst out: Record<string, string> = {}\n\t\tif (avLst) {\n\t\t\tfor (const gd of getElements(avLst, 'a:gd')) {\n\t\t\t\tconst name = attr(gd, 'name')\n\t\t\t\tif (name) out[name] = attr(gd, 'fmla') ?? ''\n\t\t\t}\n\t\t}\n\t\treturn out\n\t}\n\n\t/**\n\t * Gradient fill stops (`spPr/a:gradFill/a:gsLst/a:gs`) in document order, or\n\t * `null` when the shape's fill is not a gradient. Each stop carries its\n\t * position (0–1, from `@pos` in thousandths of a percent) and either an\n\t * explicit `color` (hex) or a `schemeColor` token, mirroring the\n\t * {@link fillColor} / {@link fillSchemeColor} split for solid fills.\n\t */\n\tget gradientStops(): GradientStop[] | null {\n\t\tconst props = this.properties()\n\t\treturn props ? this.#gradientStopsIn(props) : null\n\t}\n\n\t/**\n\t * Read `a:gradFill/a:gsLst` stops from a container (either `spPr` for a fill or\n\t * `a:ln` for a line stroke). `null` when the container has no gradient; `[]`\n\t * when the gradient carries no stop list.\n\t */\n\t#gradientStopsIn(container: Element): GradientStop[] | null {\n\t\treturn readGradientStops(container, this.host.themeContext())\n\t}\n\n\t/**\n\t * Read the full `a:gradFill` (stops + linear angle / path shape) from a\n\t * container (`spPr` for a fill or `a:ln` for a line stroke). `null` when the\n\t * container has no gradient.\n\t */\n\t#gradientFillIn(container: Element): GradientFill | null {\n\t\treturn readGradientFill(container, this.host.themeContext())\n\t}\n\n\t/**\n\t * The shape's gradient fill with its geometry (`spPr/a:gradFill`), or `null`\n\t * when the fill is not a gradient. Unlike {@link gradientStops} (stops only),\n\t * this also carries the linear {@link GradientFill.angleDeg} or the\n\t * {@link GradientFill.path} shape — the geometry a faithful replica needs and\n\t * which the bare stop list omits.\n\t */\n\tget gradientFill(): GradientFill | null {\n\t\tconst props = this.properties()\n\t\treturn props ? this.#gradientFillIn(props) : null\n\t}\n\n\t/**\n\t * The shape's line/border **gradient** stroke (`spPr/a:ln/a:gradFill`), or\n\t * `null` when the line is a solid, absent, or inherited border (see\n\t * {@link resolvedLine}). The line counterpart of {@link gradientFill}: a\n\t * gradient-stroked connector — common for faded process arrows in styled decks\n\t * — otherwise surfaces only its {@link lineWidthPt}, dropping the colour\n\t * entirely, so a replica cannot reproduce the stroke.\n\t */\n\tget lineGradient(): GradientFill | null {\n\t\tconst ln = this.#line()\n\t\treturn ln ? this.#gradientFillIn(ln) : null\n\t}\n\n\t/**\n\t * The shape's line/connector arrowheads (`a:ln/a:headEnd` + `a:tailEnd`), or\n\t * `null` when neither end carries one. Essential for replicating connectors,\n\t * whose dot/arrow ends are otherwise invisible in the geometry.\n\t */\n\tget lineEnds(): LineEnds | null {\n\t\tconst ln = this.#line()\n\t\tif (!ln) return null\n\t\tconst read = (qn: string): LineEnd | null => {\n\t\t\tconst el = firstChild(ln, qn)\n\t\t\tif (!el) return null\n\t\t\treturn { type: attr(el, 'type') ?? 'none', width: attr(el, 'w') ?? null, length: attr(el, 'len') ?? null }\n\t\t}\n\t\tconst head = read('a:headEnd')\n\t\tconst tail = read('a:tailEnd')\n\t\treturn head || tail ? { head, tail } : null\n\t}\n\n\t/**\n\t * The shape's outer drop shadow (`spPr/a:effectLst/a:outerShdw`), resolved\n\t * against the host's theme, or `null` when the shape has no outer shadow. The\n\t * soft brand shadows the eye reads as \"floating\" panels live here and are\n\t * invisible in geometry/fill alone.\n\t */\n\tget shadow(): OuterShadow | null {\n\t\treturn readOuterShadow(this.#effectLst(), this.host.themeContext())\n\t}\n\n\t/**\n\t * The shape's **inner** shadow (`spPr/a:effectLst/a:innerShdw`), resolved against\n\t * the host's theme, or `null` when the shape has no inner shadow. The inset\n\t * counterpart of {@link shadow}: the write-side `shadow: { type: 'inner' }`\n\t * emits it, and it is invisible in geometry/fill alone.\n\t */\n\tget innerShadow(): InnerShadow | null {\n\t\treturn readInnerShadow(this.#effectLst(), this.host.themeContext())\n\t}\n\n\t/**\n\t * The shape's glow halo (`spPr/a:effectLst/a:glow`), resolved against the host's\n\t * theme, or `null` when the shape has no glow. The write-side `glow` option is a\n\t * text glow in run properties, so it does not read back here.\n\t */\n\tget glow(): Glow | null {\n\t\treturn readGlow(this.#effectLst(), this.host.themeContext())\n\t}\n\n\t/**\n\t * The shape's reflection (`spPr/a:effectLst/a:reflection`), or `null` when it has\n\t * none. Read-only: this library authors no reflection, so a replica should carry\n\t * the part rather than regenerate it — see {@link Reflection}.\n\t */\n\tget reflection(): Reflection | null {\n\t\treturn readReflection(this.#effectLst())\n\t}\n\n\t/**\n\t * The shape's soft (feathered) edge (`spPr/a:effectLst/a:softEdge`), or `null`\n\t * when it has none. Read-only like {@link reflection}: carry, don't regenerate.\n\t */\n\tget softEdge(): SoftEdge | null {\n\t\treturn readSoftEdge(this.#effectLst())\n\t}\n\n\t/**\n\t * The shape's pattern (hatch) fill (`spPr/a:pattFill`), or `null` when the fill\n\t * is not a pattern. Surfaces the {@link PatternFill.preset} name and both\n\t * colours resolved against the host's theme — the pattern counterpart of\n\t * {@link resolvedFill}, which reports `null` for a non-solid fill and so drops a\n\t * hatched surface entirely.\n\t */\n\tget patternFill(): PatternFill | null {\n\t\tconst props = this.properties()\n\t\treturn props ? readPatternFill(props, this.host.themeContext()) : null\n\t}\n\n\t/**\n\t * The shape's picture (image) fill (`spPr/a:blipFill`), or `null` when the fill\n\t * is not a picture. The image-fill counterpart of {@link patternFill}: a shape\n\t * whose *surface* is an image is not a {@link Picture} — it is an autoShape with\n\t * a blip fill — and {@link resolvedFill} reports `null` for one, so without this\n\t * an image-filled shape reads as unfilled. Carries the embedded image\n\t * ({@link PictureFill.relId}/{@link PictureFill.partName}) plus the stretch/tile\n\t * geometry.\n\t */\n\tget pictureFill(): PictureFill | null {\n\t\tconst props = this.properties()\n\t\treturn props ? readPictureFill(props, this.host.relationships) : null\n\t}\n\n\t/** The shape's effect list (`spPr/a:effectLst`), or `null` — what `shapes/effects.ts` decodes. */\n\t#effectLst(): Element | null {\n\t\tconst props = this.properties()\n\t\treturn props ? firstChild(props, 'a:effectLst') : null\n\t}\n\n\t/**\n\t * The shape's solid fill resolved against the host's theme\n\t * ({@link Slide.themeContext}) to a literal hex — the resolved counterpart of\n\t * {@link fillColor}/{@link fillSchemeColor}, which report the raw reference.\n\t * `null` when the shape has no `a:solidFill` (a gradient/none/inherited fill)\n\t * or the colour cannot be made literal. The returned {@link ResolvedColor}\n\t * carries the base `hex` and raw transforms, and `effectiveHex` — the base with\n\t * its colour transforms (`lumMod`/`shade`/…) applied (read that for the final\n\t * rendered colour).\n\t *\n\t * When the shape carries no explicit `spPr` fill choice, this falls back to the\n\t * fill the shape inherits from its `p:style` `a:fillRef` (the theme style\n\t * matrix), resolved the same way the `theme: 'preserve'` flatten path bakes it.\n\t */\n\tget resolvedFill(): ResolvedColor | null {\n\t\tconst ctx = this.host.themeContext()\n\t\tconst props = this.properties()\n\t\tif (hasFillChoice(props)) return resolveSolidFillColor(props, ctx)\n\t\treturn resolveStyleFillColor(this.element, ctx)\n\t}\n\n\t/**\n\t * The shape's line/border solid fill resolved against the host's theme to a\n\t * literal hex — the resolved counterpart of {@link lineColor}/{@link lineSchemeColor}.\n\t * `null` when the shape has no `a:ln/a:solidFill` or it cannot be made literal.\n\t * Like {@link resolvedFill}, the result carries `effectiveHex` (the base colour\n\t * with its transforms applied) for the final rendered colour.\n\t *\n\t * When the shape's `spPr/a:ln` states no fill of its own, this falls back to the line\n\t * colour the shape inherits from its `p:style` `a:lnRef` (the theme style matrix). An\n\t * `a:ln` without a fill is not a replacement: PowerPoint layers it over the style line one\n\t * property at a time, and changing only an outline's weight writes `<a:ln w=\"76200\"/>`\n\t * and paints the style colour (`test/read/fixtures/shape-line-style-override.pptx`).\n\t */\n\tget resolvedLine(): ResolvedColor | null {\n\t\tconst ctx = this.host.themeContext()\n\t\tconst ln = this.#line()\n\t\treturn hasFillChoice(ln) ? readLineBasics(ln, ctx).colorRef.resolved : resolveStyleLineColor(this.element, ctx)\n\t}\n\n\t/** The line element (`spPr/a:ln`), or `null` when absent. */\n\t#line(): Element | null {\n\t\tconst props = this.properties()\n\t\treturn props ? firstChild(props, 'a:ln') : null\n\t}\n\n\t/** The line element's width, dash, raw colour and no-fill flag, or `null` when the shape has no `a:ln`. */\n\t#lineBasics(): LineBasics | null {\n\t\tconst ln = this.#line()\n\t\treturn ln ? readLineBasics(ln, null) : null\n\t}\n\n\t/**\n\t * The element a paint is written into and the successors its solid fill goes before, or a thrown\n\t * error when this kind cannot carry that paint (see {@link paintSurface}). A kind that cannot be\n\t * given a paint is a caller mistake rather than a no-op: silently accepting the call would\n\t * report success for a shape that never changes.\n\t */\n\t#paintTarget(paint: 'fill' | 'line'): { getOrAdd: () => Element; after: readonly string[] } {\n\t\tconst surface = this.paintSurface()\n\t\tconst successors = surface?.[paint]\n\t\tif (!surface || !successors)\n\t\t\tthrow new UnsupportedFeatureError(\n\t\t\t\tpaint === 'fill' ? 'shape/fill-unsupported' : 'shape/line-unsupported',\n\t\t\t\t`${this.shapeType} shapes do not support a ${paint === 'fill' ? 'fill' : 'line colour'}`\n\t\t\t)\n\t\tif (paint === 'fill') return { getOrAdd: () => surface.getOrAdd(), after: successors }\n\t\treturn { getOrAdd: () => getOrAddChild(surface.getOrAdd(), 'a:ln', successors), after: LN_FILL_AFTER }\n\t}\n\n\t/** Set or clear the shape's solid fill. */\n\t#applyFill(edit: SolidFillEdit | null): void {\n\t\tif (edit === null) {\n\t\t\tif (applySolidFill(this.properties(), null)) this.markDirty()\n\t\t\treturn\n\t\t}\n\t\tconst { getOrAdd, after } = this.#paintTarget('fill')\n\t\tif (applySolidFill(this.properties(), edit, getOrAdd, after)) this.markDirty()\n\t}\n\n\t/** Set or clear the solid fill of the shape's line. */\n\t#applyLine(edit: SolidFillEdit | null): void {\n\t\tif (edit === null) {\n\t\t\tif (applySolidFill(this.#line(), null)) this.markDirty()\n\t\t\treturn\n\t\t}\n\t\tconst { getOrAdd, after } = this.#paintTarget('line')\n\t\tif (applySolidFill(this.#line(), edit, getOrAdd, after)) this.markDirty()\n\t}\n\n\t/** Whether this shape can hold text (only `p:sp` does in this read model). */\n\tget hasTextFrame(): boolean {\n\t\treturn false\n\t}\n\n\t/** The shape's text frame, or `null` when it cannot hold text. */\n\tget textFrame(): TextFrame | null {\n\t\treturn null\n\t}\n\n\t/** Convenience: the shape's full text, or `''` if it has none. */\n\tget text(): string {\n\t\treturn this.textFrame?.text ?? ''\n\t}\n\n\t/**\n\t * Convenience: replace the shape's text with a single run, preserving the\n\t * first existing run's formatting (see {@link TextFrame.text}). Throws when the\n\t * shape has no text frame. For multiple runs or per-run formatting, edit\n\t * `textFrame.paragraphs[].runs[]` directly.\n\t */\n\tset text(value: string) {\n\t\tconst frame = this.textFrame\n\t\tif (!frame) throw new UnsupportedFeatureError('shape/no-text-frame', 'Shape has no text frame to set text on')\n\t\tframe.text = value\n\t}\n\n\t/**\n\t * This shape's placeholder identity (`p:ph` `type`/`idx`), or `null` when it is\n\t * not a placeholder. Only `p:sp` shapes can be placeholders, so the base\n\t * implementation always returns `null`; {@link AutoShape} overrides it.\n\t */\n\tget placeholder(): PlaceholderRef | null {\n\t\treturn null\n\t}\n\n\t/**\n\t * Remove this shape from its parent (the host's shape tree, or an enclosing\n\t * group) and mark the owning host's part dirty. The proxy is dead afterwards.\n\t *\n\t * The build animations targeting the shape, or any shape inside a deleted group, go with it,\n\t * and a connector attached to one of them keeps its geometry with that end unbound. PowerPoint\n\t * refuses a deck whose animation names a shape that is not on the slide.\n\t */\n\tdelete(): void {\n\t\tconst parent = this.element.parentNode\n\t\tif (!parent)\n\t\t\tthrow new InternalError('oxml/node-has-no-parent', 'Shape is not attached to a parent and cannot be deleted')\n\t\tconst ids = drawingIdsIn(this.element)\n\t\tconst root = this.element.ownerDocument?.documentElement\n\t\tparent.removeChild(this.element)\n\t\tif (root) {\n\t\t\tpruneSpids(root, ids)\n\t\t\tunbindConnectors(root, ids)\n\t\t}\n\t\tthis.markDirty()\n\t}\n\n\t/** Escape hatch: the underlying shape element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.element\n\t}\n}\n","/**\n * An auto shape, text box, or placeholder (`p:sp`) — the only shape kind that holds text.\n */\n\nimport { attr, firstChild } from '../../oxml/dom.js'\nimport { resolveStyleFontRef, type PlaceholderRef } from '../theme-context.js'\nimport { TextFrame } from '../text.js'\nimport { Shape } from './base.js'\nimport { nvPrOf } from '../../oxml/slide-dom.js'\n\n/** An auto shape, text box, or placeholder (`p:sp`). The only kind that holds text. */\nexport class AutoShape extends Shape {\n\treadonly shapeType = 'autoShape' as const\n\n\toverride get hasTextFrame(): boolean {\n\t\treturn firstChild(this.element, 'p:txBody') !== null\n\t}\n\n\toverride get textFrame(): TextFrame | null {\n\t\tconst txBody = firstChild(this.element, 'p:txBody')\n\t\tif (!txBody) return null\n\t\tconst ctx = this.host.themeContext()\n\t\t// Every shape resolves its `p:style/a:fontRef` and the presentation's\n\t\t// `p:defaultTextStyle`, so an inheritance is always supplied; `ph` is null for a\n\t\t// non-placeholder shape, which then skips only the layout/master placeholder tiers.\n\t\tconst inherit = { ph: this.placeholder, fontRef: resolveStyleFontRef(this.element, ctx) }\n\t\treturn new TextFrame(txBody, { part: this.host.part, ctx, rels: this.host.relationships, inherit })\n\t}\n\n\t/**\n\t * This shape's placeholder identity (`p:ph` `type`/`idx`), or `null` when it is\n\t * not a placeholder. `idx` defaults to `'0'` when the attribute is absent, as\n\t * PowerPoint does. Use {@link Slide.placeholder} to find a placeholder by type.\n\t */\n\toverride get placeholder(): PlaceholderRef | null {\n\t\tconst nvPr = nvPrOf(this.element)\n\t\tconst ph = nvPr && firstChild(nvPr, 'p:ph')\n\t\treturn ph ? { type: attr(ph, 'type'), idx: attr(ph, 'idx') ?? '0' } : null\n\t}\n}\n","/**\n * A picture (`p:pic`).\n *\n * A picture's drawn data is its sibling `p:blipFill`, not a fill of `p:spPr`, which is why the\n * blip plumbing (content-type → extension, the SVG extension blip, the recolour effects) lives\n * here rather than on the base: no other shape kind carries it.\n */\n\nimport {\n\tELEMENT_NODE,\n\tattr,\n\tfirstChild,\n\tfirstChildElement,\n\tgetElements,\n\tgetOrAddChild,\n\tpctAttr,\n\tremoveChildrenByQName,\n\tsetAttr,\n\tOOXML_NS,\n\ttype Element,\n} from '../../oxml/dom.js'\nimport { fitSrcRectPercents, getImageSizeFromBytes } from '../../../media/image-size.js'\nimport { imageFormatForContentType } from '../../../media/image-formats.js'\nimport { warn } from '../../../diagnostics.js'\nimport { relativePartName, resolvePartName } from '../../opc/partnames.js'\nimport type { ColorContext } from '../../oxml/theme.js'\nimport { readRect, type FillRect } from '../picture-fill.js'\nimport { readColorRef, type ColorRef } from '../theme-context.js'\nimport { Shape } from './base.js'\nimport { childElements, type PaintSurface } from './oxml.js'\nimport type { Recolor } from './types.js'\nimport { IMAGE_REL } from '../../../ooxml/rel-types.js'\nimport { InvalidOptionError } from '../../../errors.js'\nimport { BLIPFILL_BLIP_AFTER, BLIPFILL_SRCRECT_AFTER, PIC_BLIPFILL_AFTER } from '../../../ooxml/sequence.js'\n\n/**\n * Default a media-part file extension from a content type. A format the registry in\n * `media/image-formats.ts` names uses its canonical extension; otherwise fall back to the\n * content-type subtype (before any `+suffix`, with a leading `x-` stripped), e.g.\n * `image/x-foo` → `foo`.\n */\nfunction extFromContentType(contentType: string): string {\n\tconst known = imageFormatForContentType(contentType)?.ext\n\tif (known) return known\n\tconst subtype = contentType.toLowerCase().split('/')[1] ?? ''\n\tconst ext = (subtype.split('+')[0] ?? '').replace(/^x-/, '')\n\tif (!ext)\n\t\tthrow new InvalidOptionError(\n\t\t\t'image/undeterminable-extension',\n\t\t\t`Cannot derive a file extension from content type \"${contentType}\"; pass { extension }`\n\t\t)\n\treturn ext\n}\n\n/**\n * Read a recolour effect's DrawingML colour element into a {@link ColorRef} resolved against `ctx`,\n * or `null` when it is not an `a:` colour element.\n */\nfunction recolorColorOf(color: Element | null, ctx: ColorContext): ColorRef | null {\n\tif (!color || color.namespaceURI !== OOXML_NS.a) return null\n\treturn readColorRef(color, ctx)\n}\n\n/** A picture (`p:pic`). */\nexport class Picture extends Shape {\n\treadonly shapeType = 'picture' as const\n\n\t// A picture's image is its sibling `p:blipFill`, not a fill of `p:spPr`, so a\n\t// solid `spPr` fill would not clobber the image. Setting one is still refused —\n\t// recolouring a picture surface is rarely what a caller means — and the border\n\t// takes a line colour. A fill a deck already wrote still reads and clears.\n\tprotected override paintSurface(): PaintSurface | null {\n\t\tconst surface = super.paintSurface()\n\t\treturn surface && { ...surface, fill: null }\n\t}\n\n\t/** Relationship id of the embedded image (`p:blipFill/a:blip/@r:embed`), or `null`. */\n\tget imageRelId(): string | null {\n\t\tconst blip = this.#blip()\n\t\treturn blip ? attr(blip, 'r:embed') : null\n\t}\n\n\t/**\n\t * Repoint the blip at a relationship id already present in the owning part's\n\t * relationships, without minting a new media part. The caller owns ensuring\n\t * the id exists and targets an image; use {@link setImage} to add fresh bytes.\n\t */\n\tset imageRelId(value: string) {\n\t\tsetAttr(this.#getOrAddBlip(), 'r:embed', value)\n\t\tthis.markDirty()\n\t}\n\n\t/**\n\t * Absolute partname of the embedded image, resolved via the owning part's relationships.\n\t *\n\t * `null` covers every way there is nothing to name: no `r:embed`, an id the part does not\n\t * declare, or a relationship whose target is external (a LINKED image). It used to throw on\n\t * the last two while the same blip reached through a picture fill returned `null`.\n\t */\n\tget imagePartName(): string | null {\n\t\treturn resolvePartName(this.imageRelId, this.host.relationships)\n\t}\n\n\t/**\n\t * Relationship id of the embedded **vector (SVG)** image, read from the\n\t * Microsoft SVG blip extension (`a:blip/a:extLst/a:ext/asvg:svgBlip/@r:embed`),\n\t * or `null` when the picture has no SVG. PowerPoint usually pairs this with a\n\t * raster fallback in `a:blip/@r:embed` ({@link imageRelId}), but some exporters\n\t * emit an SVG-only blip where `imageRelId` is absent and only this resolves —\n\t * so a reader that wants the real drawn art must consult both.\n\t */\n\tget svgRelId(): string | null {\n\t\tconst svg = this.#svgBlip()\n\t\treturn svg ? attr(svg, 'r:embed') : null\n\t}\n\n\t/** Absolute partname of the embedded SVG image, or `null`. Same rule as {@link imagePartName}. */\n\tget svgPartName(): string | null {\n\t\treturn resolvePartName(this.svgRelId, this.host.relationships)\n\t}\n\n\t/**\n\t * Which drawable media this picture carries:\n\t * - `'raster'` — only a raster blip (`a:blip/@r:embed`);\n\t * - `'svg'` — only a vector blip (`asvg:svgBlip/@r:embed`, no raster). This\n\t * is what PowerPoint's *Insert → Icons* and a plain SVG insert produce;\n\t * - `'both'` — a raster fallback *and* an SVG (PowerPoint's usual pairing);\n\t * - `'none'` — a `p:pic` with no embedded blip at all (e.g. a linked image).\n\t *\n\t * Lets a caller distinguish an SVG-only picture — where {@link imagePartName}\n\t * is legitimately `null` — from a genuinely empty one, without two null checks.\n\t */\n\tget mediaKind(): 'raster' | 'svg' | 'both' | 'none' {\n\t\tconst hasRaster = this.imageRelId != null\n\t\tconst hasSvg = this.svgRelId != null\n\t\tif (hasRaster && hasSvg) return 'both'\n\t\tif (hasRaster) return 'raster'\n\t\tif (hasSvg) return 'svg'\n\t\treturn 'none'\n\t}\n\n\t/**\n\t * Absolute partname of whichever part actually carries this picture's drawn\n\t * data — the raster part when present, otherwise the SVG part — or `null`\n\t * when the picture embeds neither. Use this when you just want \"the bytes\n\t * this picture shows\"; prefer {@link imagePartName} / {@link svgPartName}\n\t * (and {@link mediaKind}) when you need to know *which* kind it is. An\n\t * SVG-only picture returns its SVG part here even though `imagePartName` is\n\t * `null`.\n\t */\n\tget mediaPartName(): string | null {\n\t\treturn this.imagePartName ?? this.svgPartName\n\t}\n\n\t/**\n\t * The picture's crop as fractions of the *source image*, read from\n\t * `p:blipFill/a:srcRect` — `{ left, top, right, bottom }`, each the amount\n\t * trimmed off that edge (so `0.1` = 10 % cropped away, an uncropped edge is\n\t * `0`). `null` when there is no `a:srcRect` at all; an explicit\n\t * `{0,0,0,0}` crop still reports zeros, since its presence is meaningful.\n\t * The raw attributes are thousandths of a percent; this divides by 100000 to\n\t * match the fraction convention used elsewhere in the read API (see\n\t * {@link recolor}).\n\t */\n\tget crop(): FillRect | null {\n\t\tconst blipFill = firstChild(this.element, 'p:blipFill')\n\t\tconst srcRect = blipFill && firstChild(blipFill, 'a:srcRect')\n\t\treturn srcRect ? readRect(srcRect) : null\n\t}\n\n\t/**\n\t * The picture's blip recolour effect (`p:blipFill/a:blip` recolour child), or\n\t * `null` when the blip carries none. Recognises the effects a faithful reader\n\t * needs to reproduce a recoloured image: `a:duotone` (the two-stop icon-tint\n\t * trick), `a:clrChange`, `a:grayscl`, `a:biLevel`, and `a:alphaModFix`; the\n\t * first such effect in document order wins. Colours mirror the\n\t * {@link GradientStop} split (`color`/`schemeColor`/`presetColor`) so theme\n\t * tokens resolve through {@link Slide.themeContext}. `threshold`/`amount` are\n\t * 0–1 fractions. {@link hidden} (the duotone fallback-layer trick) reports the\n\t * *visibility* of a recolour source; this reports the *tint* itself.\n\t */\n\tget recolor(): Recolor | null {\n\t\tconst blip = this.#blip()\n\t\tif (!blip) return null\n\t\tconst ctx = this.host.themeContext()\n\t\tfor (const child of childElements(blip)) {\n\t\t\tif (child.namespaceURI !== OOXML_NS.a) continue\n\t\t\tswitch (child.localName) {\n\t\t\t\tcase 'duotone':\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: 'duotone',\n\t\t\t\t\t\tstops: childElements(child)\n\t\t\t\t\t\t\t.map((color) => recolorColorOf(color, ctx))\n\t\t\t\t\t\t\t.filter((c): c is ColorRef => c !== null),\n\t\t\t\t\t}\n\t\t\t\tcase 'clrChange': {\n\t\t\t\t\tconst from = firstChild(child, 'a:clrFrom')\n\t\t\t\t\tconst to = firstChild(child, 'a:clrTo')\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: 'clrChange',\n\t\t\t\t\t\tfrom: from ? recolorColorOf(firstChildElement(from), ctx) : null,\n\t\t\t\t\t\tto: to ? recolorColorOf(firstChildElement(to), ctx) : null,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase 'grayscl':\n\t\t\t\t\treturn { kind: 'grayscale' }\n\t\t\t\tcase 'biLevel': {\n\t\t\t\t\treturn { kind: 'biLevel', threshold: pctAttr(child, 'thresh') }\n\t\t\t\t}\n\t\t\t\tcase 'alphaModFix': {\n\t\t\t\t\treturn { kind: 'alphaModFix', amount: pctAttr(child, 'amt') ?? 1 }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n\n\t/**\n\t * The `p:blipFill/a:blip` this picture draws, or `null` when it has none. Three getters and\n\t * the SVG lookup each walked the pair.\n\t */\n\t#blip(): Element | null {\n\t\tconst blipFill = firstChild(this.element, 'p:blipFill')\n\t\treturn blipFill ? firstChild(blipFill, 'a:blip') : null\n\t}\n\n\t/** The `<asvg:svgBlip>` element inside the blip's extLst, or `null` when the picture carries no SVG. */\n\t#svgBlip(): Element | null {\n\t\tconst blip = this.#blip()\n\t\tconst extLst = blip && firstChild(blip, 'a:extLst')\n\t\tif (!extLst) return null\n\t\tfor (const ext of getElements(extLst, 'a:ext')) {\n\t\t\tfor (let node = ext.firstChild; node; node = node.nextSibling) {\n\t\t\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\t\t\tconst el = node as Element\n\t\t\t\tif (el.localName === 'svgBlip' && el.namespaceURI === OOXML_NS.asvg) return el\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n\n\t/**\n\t * Replace this picture's image with new bytes. Mints a fresh media part under\n\t * `/ppt/media/`, registers its content type, wires an `image` relationship\n\t * from the owning part, and repoints the blip's `@r:embed` at it.\n\t *\n\t * Copy-on-write: the previous media part is never mutated or removed, so any\n\t * other picture sharing it (common after `importSlide`/dedup) is unaffected;\n\t * an orphaned old part is left in place for a later GC pass to prune.\n\t *\n\t * `contentType` is required (e.g. `image/png`); the bytes are not sniffed.\n\t * `extension` defaults from the content type.\n\t *\n\t * `fit` controls the picture's `a:srcRect` crop against its current frame\n\t * extent (`a:xfrm/a:ext`):\n\t * - omitted (default): geometry and crop are left untouched — the caller owns\n\t * sizing. Note an inherited `a:srcRect` was tuned to the *previous* image's\n\t * aspect ratio, so swapping in an image of a different ratio reuses a crop\n\t * that no longer fits and the result looks stretched; pass `fit` to refit.\n\t * - `'cover'`: fill the frame, cropping the overflowing axis (no distortion).\n\t * - `'contain'`: fit the whole image inside the frame, letterboxing the short\n\t * axis (no distortion).\n\t * - `'stretch'`: drop any crop so the full image is stretched to the frame.\n\t *\n\t * `'cover'`/`'contain'` measure the new bytes' natural size; if unmeasurable\n\t * (e.g. an unknown format) the crop is left as-is and a warning is emitted.\n\t */\n\tsetImage(\n\t\tbytes: Uint8Array,\n\t\toptions: { contentType: string; extension?: string; fit?: 'cover' | 'contain' | 'stretch' }\n\t): void {\n\t\tconst { contentType } = options\n\t\tif (!contentType)\n\t\t\tthrow new InvalidOptionError('image/missing-content-type', 'setImage requires a contentType (e.g. \"image/png\")')\n\t\t// Checked before the image part is added, so a refused fit leaves the picture as it was.\n\t\tif (options.fit === 'cover' || options.fit === 'contain') this.#requireFitExtent(options.fit)\n\t\tconst extension = (options.extension ?? extFromContentType(contentType)).toLowerCase().replace(/^\\./, '')\n\n\t\tconst opc = this.host.opc\n\t\tconst mediaPartName = opc.reserveMediaPartName(extension)\n\t\topc.addPart(mediaPartName, contentType, bytes)\n\t\tconst relId = this.host.relationships.add(IMAGE_REL, relativePartName(this.host.partName, mediaPartName)).id\n\n\t\tsetAttr(this.#getOrAddBlip(), 'r:embed', relId)\n\t\tif (options.fit) this.#applyFit(options.fit, bytes)\n\t\tthis.markDirty()\n\t}\n\n\t/**\n\t * Refuse a `cover` or `contain` fit on a picture with no extent to fit into: no transform, or a\n\t * side that is not greater than zero. A zero extent used to write every crop percentage as `NaN`.\n\t */\n\t#requireFitExtent(fit: 'cover' | 'contain'): void {\n\t\tconst cx = this.width\n\t\tconst cy = this.height\n\t\tif (cx == null || cy == null) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'image/fit-needs-extent',\n\t\t\t\t`setImage fit '${fit}' needs a frame extent (a:xfrm/a:ext); this picture has no transform`\n\t\t\t)\n\t\t}\n\t\tif (!(cx > 0 && cy > 0)) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'image/fit-needs-extent',\n\t\t\t\t`setImage fit '${fit}' needs a frame extent greater than zero; this picture is ${cx} x ${cy} EMU`\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Refit the blip crop after a {@link setImage} swap. `stretch` removes any\n\t * `a:srcRect`; `cover`/`contain` recompute it from the new image's natural\n\t * size against the frame extent so the swap is aspect-correct.\n\t */\n\t#applyFit(fit: 'cover' | 'contain' | 'stretch', bytes: Uint8Array): void {\n\t\tconst blipFill = getOrAddChild(this.element, 'p:blipFill', PIC_BLIPFILL_AFTER)\n\t\tif (fit === 'stretch') {\n\t\t\tremoveChildrenByQName(blipFill, ['a:srcRect'])\n\t\t\treturn\n\t\t}\n\t\tconst natural = getImageSizeFromBytes(bytes)\n\t\t// The extent was checked by `setImage`; a natural size of zero has no fit either.\n\t\tconst rect = natural && fitSrcRectPercents(fit, natural, { w: this.width ?? 0, h: this.height ?? 0 })\n\t\tif (!rect) {\n\t\t\twarn(\n\t\t\t\t'image/unmeasurable-natural-size',\n\t\t\t\t`setImage fit '${fit}': could not measure the new image's natural size; leaving the crop unchanged (it may look stretched). Provide a raster (PNG/JPEG/GIF/BMP/WebP) or an SVG with width/height or a viewBox.`\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tconst { l, r, t, b } = rect\n\t\tconst srcRect = getOrAddChild(blipFill, 'a:srcRect', BLIPFILL_SRCRECT_AFTER)\n\t\tsetAttr(srcRect, 'l', String(l))\n\t\tsetAttr(srcRect, 'r', String(r))\n\t\tsetAttr(srcRect, 't', String(t))\n\t\tsetAttr(srcRect, 'b', String(b))\n\t}\n\n\t/** Get-or-add `p:blipFill/a:blip`, keeping both in document order. */\n\t#getOrAddBlip(): Element {\n\t\tconst blipFill = getOrAddChild(this.element, 'p:blipFill', PIC_BLIPFILL_AFTER)\n\t\treturn getOrAddChild(blipFill, 'a:blip', BLIPFILL_BLIP_AFTER)\n\t}\n}\n","/**\n * A connector / line (`p:cxnSp`).\n */\n\nimport { attr, firstChild, numberValue } from '../../oxml/dom.js'\nimport { Shape } from './base.js'\nimport type { ConnectionSite } from './types.js'\n\n/** A connector / line (`p:cxnSp`). */\nexport class Connector extends Shape {\n\treadonly shapeType = 'connector' as const\n\n\t/**\n\t * The connector's **start**-point shape binding (`p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn`),\n\t * or `null` when the start point is unbound (a bare `p:cNvCxnSpPr`, i.e. a\n\t * connector placed by static endpoint geometry). Mirrors the write API's\n\t * `startShape`/`startShapeIdx` split; see {@link endConnection} for the other end.\n\t */\n\tget startConnection(): ConnectionSite | null {\n\t\treturn this.#connection('a:stCxn')\n\t}\n\n\t/**\n\t * The connector's **end**-point shape binding (`p:nvCxnSpPr/p:cNvCxnSpPr/a:endCxn`),\n\t * or `null` when the end point is unbound. See {@link startConnection}.\n\t */\n\tget endConnection(): ConnectionSite | null {\n\t\treturn this.#connection('a:endCxn')\n\t}\n\n\t/** Decode one `a:stCxn` / `a:endCxn` binding, resolving its `@id` to a shape in the same tree. */\n\t#connection(qname: string): ConnectionSite | null {\n\t\tconst nvCxnSpPr = firstChild(this.element, 'p:nvCxnSpPr')\n\t\tconst cNvCxnSpPr = nvCxnSpPr && firstChild(nvCxnSpPr, 'p:cNvCxnSpPr')\n\t\tconst cxn = cNvCxnSpPr && firstChild(cNvCxnSpPr, qname)\n\t\tif (!cxn) return null\n\t\tconst shapeId = numberValue(attr(cxn, 'id'))\n\t\tconst siteIndex = numberValue(attr(cxn, 'idx'))\n\t\t// CT_Connection requires both @id and @idx; an unparseable pair degrades to null\n\t\t// rather than a half-populated site.\n\t\tif (shapeId === null || siteIndex === null) return null\n\t\treturn { shapeId, siteIndex, boundShape: this.host.shapeByIdDeep(shapeId) ?? null }\n\t}\n}\n","/**\n * The one place a chart point cache is turned into an idx-ordered array.\n *\n * Both chart families cache their category/value data the same way: a run of indexed point\n * elements plus a declared count, which the reader widens back into a dense array so\n * `series.values[3]` means the point at `idx=\"3\"` and a gap reads as `null`. Classic `c:`\n * charts and 2016 `cx:` charts spell it differently — `c:ptCount/@val` and a `c:v` child\n * against `cx:lvl/@ptCount` and the point's own text — and nothing else about the two decodes\n * differs, so the shape parameterizes over exactly those two differences.\n *\n * **Why neither number out of the file is trusted.** `@ptCount` is `xsd:unsignedInt`, so\n * `4294967295` is schema-valid, and `new Array(n).fill(null)` at that size is not a slow path\n * but a process kill: V8 answers `FATAL ERROR: invalid table size` and the host dies with no\n * exception to catch. That was reachable through the public read API — `Presentation.load()`\n * on a deck with an edited `c:ptCount` returned normally and the first `chart.series` access\n * killed the process. A single `<c:pt idx=\"900000000\"/>` does the same thing on its own.\n * Reading a deck is the one part of this library whose input comes from somewhere other than\n * the calling program, so both numbers are bounded here.\n *\n * The array is sized by the points that are really there, not by the declared count. The cost\n * of that is a *trailing* gap: a cache declaring four points but carrying three (the fourth\n * cell blank) reads three long rather than four. No value is lost — the dropped slots are the\n * ones that would have been `null` — and the disagreement is warned about either way.\n */\nimport { attr, numberValue, type Element } from './dom.js'\nimport { warn } from '../../diagnostics.js'\n\n/**\n * The highest point index this reader will honour.\n *\n * A cache references a range in the embedded workbook, and a worksheet has 1,048,576 rows, so\n * a point index at or above that cannot describe data any producer could have charted. Using\n * the sheet bound rather than a round number keeps the ceiling something a reader can check:\n * below it every real cache fits, above it the file is wrong by construction. It also caps the\n * worst-case allocation at about 8 MB of `null` — survivable, and reported — instead of an\n * unbounded one that takes the process with it.\n */\nconst MAX_POINT_INDEX = 1048576\n\n/** Whether `idx` can name a slot: a whole number from 0 below {@link MAX_POINT_INDEX}. */\nfunction isPointIndex(idx: number): boolean {\n\treturn Number.isInteger(idx) && idx >= 0 && idx < MAX_POINT_INDEX\n}\n\n/**\n * Read indexed cache points into a dense, idx-ordered array.\n *\n * The result is as long as the highest `@idx` actually present, and holds `null` at every\n * index no point claimed. A declared count that disagrees is warned about and not obeyed; a\n * point indexed past {@link MAX_POINT_INDEX} is warned about and dropped.\n * @param pts - the point elements, in document order\n * @param declaredCount - the cache's own count attribute, or `null` when absent\n * @param valueOf - reads one point's value; the two chart families differ only here\n * @param label - what to call the count in a diagnostic, e.g. `c:ptCount`\n */\nexport function readIndexedPoints(\n\tpts: Element[],\n\tdeclaredCount: number | null,\n\tvalueOf: (pt: Element) => string | null,\n\tlabel: string\n): (string | null)[] {\n\t// One pass to find the real extent — one past the highest index a point actually claims,\n\t// ignoring the ones that claim an impossible index. A cache carrying no points has no\n\t// extent at all, whatever it declares.\n\tlet count = 0\n\tlet dropped = 0\n\tfor (const pt of pts) {\n\t\tconst idx = numberValue(attr(pt, 'idx')) ?? 0\n\t\t// A fractional index is as impossible as an out-of-range one. It used to size the array as\n\t\t// `new Array(16.5)`, a raw `RangeError`, or land on a property rather than a slot.\n\t\tif (!isPointIndex(idx)) {\n\t\t\tdropped++\n\t\t\tcontinue\n\t\t}\n\t\tif (idx + 1 > count) count = idx + 1\n\t}\n\tif (dropped > 0) {\n\t\twarn(\n\t\t\t'chart/point-index-out-of-range',\n\t\t\t`${label}: ${dropped} cache point(s) are not indexed by a whole number within 0..${MAX_POINT_INDEX - 1}, which no worksheet-backed chart can reference; they were dropped`\n\t\t)\n\t}\n\tif (declaredCount !== null && declaredCount !== count) {\n\t\twarn(\n\t\t\t'chart/point-count-mismatch',\n\t\t\t`${label} declares ${declaredCount} point(s) but the cache carries ${pts.length - dropped} usable; reading ${count} rather than allocating the declared size`\n\t\t)\n\t}\n\tconst points: (string | null)[] = new Array<string | null>(count).fill(null)\n\tfor (const pt of pts) {\n\t\tconst idx = numberValue(attr(pt, 'idx')) ?? 0\n\t\tif (!isPointIndex(idx) || idx >= count) continue\n\t\tpoints[idx] = valueOf(pt)\n\t}\n\treturn points\n}\n","/**\n * Read-only proxies for a chart (`c:chart`) hosted in a `p:graphicFrame`.\n *\n * A chart lives in its own part (`/ppt/charts/chartN.xml`), referenced from the\n * graphic frame by relationship id. `Chart` reads the chart type, title, series,\n * and the **cached** category/value data (`c:numCache` / `c:strCache`) that\n * PowerPoint stores alongside the embedded workbook. Editing the underlying\n * workbook is out of scope; this surface is read-only.\n */\nimport type { Part } from '../opc/part.js'\nimport {\n\tattr,\n\tboolValue,\n\tconcatDrawingMLText,\n\ttype Element,\n\tELEMENT_NODE,\n\tfirstChild,\n\tfirstChildElement,\n\tgetElements,\n\tnumberValue,\n\tOOXML_NS,\n} from '../oxml/dom.js'\nimport { readIndexedPoints } from '../oxml/point-cache.js'\nimport { readLineBasics } from './line.js'\nimport { readColorRef, type ColorRef } from './theme-context.js'\n\n/** A chart axis number format (`c:numFmt`). */\nexport interface AxisNumberFormat {\n\t/** The format mask (`@formatCode`), e.g. `\"General\"`, `\"0.0%\"`. */\n\tformatCode: string | null\n\t/** Whether the mask is linked to the source cell format (`@sourceLinked`). */\n\tsourceLinked: boolean | null\n}\n\n/** A chart legend (`c:legend`). */\nexport interface ChartLegend {\n\t/** Legend position (`c:legendPos/@val`): `r`/`l`/`t`/`b`/`tr`. */\n\tposition: string | null\n\t/** Whether the legend overlays the plot area (`c:overlay/@val`). */\n\toverlay: boolean | null\n}\n\n/** Data-label settings (`c:dLbls`), read from a plot group or from one series. */\nexport interface ChartDataLabels {\n\t/** Show the point value (`c:showVal`). */\n\tshowValue: boolean | null\n\t/** Show the series name (`c:showSerName`). */\n\tshowSeriesName: boolean | null\n\t/** Show the category name (`c:showCatName`). */\n\tshowCategoryName: boolean | null\n\t/** Show the percentage (`c:showPercent`). */\n\tshowPercent: boolean | null\n\t/** Show the legend key swatch (`c:showLegendKey`). */\n\tshowLegendKey: boolean | null\n\t/** Show the bubble size (`c:showBubbleSize`). */\n\tshowBubbleSize: boolean | null\n\t/** Show leader lines (`c:showLeaderLines`). */\n\tshowLeaderLines: boolean | null\n\t/** Label position (`c:dLblPos/@val`), or `null` when auto. */\n\tposition: string | null\n\t/** Label number format (`c:numFmt`), or `null` when absent. */\n\tnumberFormat: AxisNumberFormat | null\n}\n\n/** A series' solid fill (`c:ser/c:spPr`). */\nexport interface ChartFill {\n\t/**\n\t * The fill's solid colour; every field is `null` for a non-solid fill. A chart part is read\n\t * without a theme, so `resolved` is always `null` and a scheme colour stays a token.\n\t */\n\tcolorRef: ColorRef\n\t/** Whether the fill is explicitly suppressed (`a:noFill`). */\n\tnoFill: boolean\n}\n\n/** A series' line/stroke (`c:ser/c:spPr/a:ln`). */\nexport interface ChartLine {\n\t/** Stroke width in points (`@w`/12700), or `null` when unset. */\n\twidthPt: number | null\n\t/** Dash style (`a:prstDash/@val`), or `null` when solid/unset. */\n\tdash: string | null\n\t/** The stroke's solid colour; unresolved, as {@link ChartFill.colorRef} is. */\n\tcolorRef: ColorRef\n\t/** Whether the line is explicitly suppressed (`a:noFill`). */\n\tnoFill: boolean\n}\n\n/** A chart graphic-frame's chart, backed by its chart part. */\nexport class Chart {\n\tconstructor(\n\t\t/** The chart's OPC part (`/ppt/charts/chartN.xml`). */\n\t\treadonly part: Part\n\t) {}\n\n\t/** Partname of the chart part. */\n\tget partName(): string {\n\t\treturn this.part.partName\n\t}\n\n\t/**\n\t * The chart-group type tokens present in the plot area, in document order\n\t * (e.g. `['line']`, `['bar']`, `['bar', 'line']` for a combo chart). Derived\n\t * from the plot-area element local names (`lineChart` → `line`).\n\t */\n\tget chartTypes(): string[] {\n\t\treturn this.#chartGroups().map((group) => (group.localName ?? '').replace(/Chart$/, ''))\n\t}\n\n\t/** The first chart-group type, or `null` for an empty plot area. */\n\tget chartType(): string | null {\n\t\treturn this.chartTypes[0] ?? null\n\t}\n\n\t/** The chart title (`c:chart/c:title` rich text), or `null` when absent/auto. */\n\tget title(): string | null {\n\t\tconst chart = this.#chart()\n\t\treturn readTitleText(chart && firstChild(chart, 'c:title'))\n\t}\n\n\t/**\n\t * The category/value/series axes (`c:catAx`/`c:valAx`/`c:dateAx`/`c:serAx`)\n\t * in plot-area document order. Empty for pie/doughnut charts (no axes).\n\t */\n\tget axes(): ChartAxis[] {\n\t\tconst plotArea = this.#plotArea()\n\t\tif (!plotArea) return []\n\t\tconst out: ChartAxis[] = []\n\t\tfor (let node = plotArea.firstChild; node; node = node.nextSibling) {\n\t\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\t\tconst element = node as Element\n\t\t\tif (element.namespaceURI === OOXML_NS.c && (element.localName ?? '').endsWith('Ax'))\n\t\t\t\tout.push(new ChartAxis(element, this.part))\n\t\t}\n\t\treturn out\n\t}\n\n\t/** The category axis (`c:catAx`/`c:dateAx`), or `null` when the chart has none. */\n\tget categoryAxis(): ChartAxis | null {\n\t\treturn this.axes.find((axis) => axis.kind === 'cat' || axis.kind === 'date') ?? null\n\t}\n\n\t/** The (primary) value axis (`c:valAx`), or `null` when the chart has none. */\n\tget valueAxis(): ChartAxis | null {\n\t\treturn this.axes.find((axis) => axis.kind === 'val') ?? null\n\t}\n\n\t/** The legend (`c:chart/c:legend`) position + overlay, or `null` when hidden. */\n\tget legend(): ChartLegend | null {\n\t\tconst chart = this.#chart()\n\t\tconst legend = chart && firstChild(chart, 'c:legend')\n\t\tif (!legend) return null\n\t\tconst pos = firstChild(legend, 'c:legendPos')\n\t\tconst overlay = firstChild(legend, 'c:overlay')\n\t\treturn {\n\t\t\tposition: pos ? attr(pos, 'val') : null,\n\t\t\toverlay: overlay ? boolValue(attr(overlay, 'val')) : null,\n\t\t}\n\t}\n\n\t/**\n\t * The chart-level data-label settings, read from the first plot group's\n\t * aggregate `c:dLbls` (the group-wide block after the series). `null` when the\n\t * plot group carries no data-label block.\n\t *\n\t * A pie keeps its labels on the series instead: PowerPoint writes the flags the\n\t * user set into `c:ser/c:dLbls` and leaves this block all off, and this library's\n\t * writer emits no group block for a pie at all. Read those through\n\t * {@link ChartSeries.dataLabels}.\n\t */\n\tget dataLabels(): ChartDataLabels | null {\n\t\tconst group = this.#chartGroups()[0]\n\t\treturn readDataLabels(group ? firstChild(group, 'c:dLbls') : null)\n\t}\n\n\t/** The data series (`c:ser`) across all chart groups, in document order. */\n\tget series(): ChartSeries[] {\n\t\treturn this.#chartGroups()\n\t\t\t.flatMap((group) => getElements(group, 'c:ser'))\n\t\t\t.map((ser) => new ChartSeries(ser, this.part))\n\t}\n\n\t/**\n\t * Category labels, read from the first series' cached categories\n\t * (`c:cat`), as written. Empty when the chart has no category axis.\n\t */\n\tget categories(): (string | null)[] {\n\t\tconst firstSer = this.series[0]\n\t\treturn firstSer ? firstSer.categories : []\n\t}\n\n\t/** Every category level of the first series, leaf first; see {@link ChartSeries.categoryLevels}. */\n\tget categoryLevels(): (string | null)[][] {\n\t\tconst firstSer = this.series[0]\n\t\treturn firstSer ? firstSer.categoryLevels : []\n\t}\n\n\t/** Escape hatch: the underlying `c:chartSpace` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element | null {\n\t\treturn this.part.dom.documentElement\n\t}\n\n\t/** Mark the chart part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.part.markDirty()\n\t}\n\n\t#chart(): Element | null {\n\t\tconst root = this.part.dom.documentElement\n\t\treturn root ? firstChild(root, 'c:chart') : null\n\t}\n\n\t#plotArea(): Element | null {\n\t\tconst chart = this.#chart()\n\t\treturn chart ? firstChild(chart, 'c:plotArea') : null\n\t}\n\n\t/** Plot-area children that are chart groups (local name ends with `Chart`). */\n\t#chartGroups(): Element[] {\n\t\tconst plotArea = this.#plotArea()\n\t\tif (!plotArea) return []\n\t\tconst groups: Element[] = []\n\t\tfor (let node = plotArea.firstChild; node; node = node.nextSibling) {\n\t\t\tif (node.nodeType !== 1) continue\n\t\t\tconst element = node as Element\n\t\t\tif (element.namespaceURI === OOXML_NS.c && element.localName?.endsWith('Chart')) groups.push(element)\n\t\t}\n\t\treturn groups\n\t}\n}\n\n/**\n * One axis (`c:catAx`/`c:valAx`/`c:dateAx`/`c:serAx`) of a chart's plot area.\n * All four share the scaling/delete/position/tickmark structure; `kind`\n * distinguishes them.\n */\nexport class ChartAxis {\n\tconstructor(\n\t\tprivate readonly ax: Element,\n\t\t/** The owning chart's OPC part, so {@link markDirty} can reach it from {@link element_}. */\n\t\tprivate readonly part: Part\n\t) {}\n\n\t/** Axis kind derived from the element name: `cat`/`val`/`date`/`ser`. */\n\tget kind(): 'cat' | 'val' | 'date' | 'ser' | null {\n\t\tswitch (this.ax.localName) {\n\t\t\tcase 'catAx':\n\t\t\t\treturn 'cat'\n\t\t\tcase 'valAx':\n\t\t\t\treturn 'val'\n\t\t\tcase 'dateAx':\n\t\t\t\treturn 'date'\n\t\t\tcase 'serAx':\n\t\t\t\treturn 'ser'\n\t\t\tdefault:\n\t\t\t\treturn null\n\t\t}\n\t}\n\n\t/** Axis id (`c:axId/@val`). */\n\tget id(): number | null {\n\t\tconst el = firstChild(this.ax, 'c:axId')\n\t\treturn el ? numberValue(attr(el, 'val')) : null\n\t}\n\n\t/** Scaling orientation (`c:scaling/c:orientation/@val`): `minMax`/`maxMin`. */\n\tget orientation(): string | null {\n\t\tconst orient = this.#scaling('c:orientation')\n\t\treturn orient ? attr(orient, 'val') : null\n\t}\n\n\t/** Scale minimum (`c:scaling/c:min/@val`), or `null` when auto. */\n\tget min(): number | null {\n\t\tconst el = this.#scaling('c:min')\n\t\treturn el ? numberValue(attr(el, 'val')) : null\n\t}\n\n\t/** Scale maximum (`c:scaling/c:max/@val`), or `null` when auto. */\n\tget max(): number | null {\n\t\tconst el = this.#scaling('c:max')\n\t\treturn el ? numberValue(attr(el, 'val')) : null\n\t}\n\n\t/** Logarithmic scale base (`c:scaling/c:logBase/@val`), or `null` when linear. */\n\tget logBase(): number | null {\n\t\tconst el = this.#scaling('c:logBase')\n\t\treturn el ? numberValue(attr(el, 'val')) : null\n\t}\n\n\t/** Whether the axis is hidden (`c:delete/@val` = 1). */\n\tget hidden(): boolean {\n\t\tconst el = firstChild(this.ax, 'c:delete')\n\t\treturn el ? boolValue(attr(el, 'val')) === true : false\n\t}\n\n\t/** Axis position (`c:axPos/@val`): `b`/`l`/`r`/`t`. */\n\tget position(): string | null {\n\t\tconst el = firstChild(this.ax, 'c:axPos')\n\t\treturn el ? attr(el, 'val') : null\n\t}\n\n\t/** Whether the axis draws major gridlines (`c:majorGridlines`). */\n\tget majorGridlines(): boolean {\n\t\treturn !!firstChild(this.ax, 'c:majorGridlines')\n\t}\n\n\t/** Whether the axis draws minor gridlines (`c:minorGridlines`). */\n\tget minorGridlines(): boolean {\n\t\treturn !!firstChild(this.ax, 'c:minorGridlines')\n\t}\n\n\t/** Axis title text (`c:title` rich text), or `null` when absent. */\n\tget title(): string | null {\n\t\treturn readTitleText(firstChild(this.ax, 'c:title'))\n\t}\n\n\t/** Axis number format (`c:numFmt`), or `null` when absent. */\n\tget numberFormat(): AxisNumberFormat | null {\n\t\treturn readNumberFormat(this.ax)\n\t}\n\n\t/** Major tick-mark style (`c:majorTickMark/@val`): `out`/`in`/`cross`/`none`. */\n\tget majorTickMark(): string | null {\n\t\tconst el = firstChild(this.ax, 'c:majorTickMark')\n\t\treturn el ? attr(el, 'val') : null\n\t}\n\n\t/** Minor tick-mark style (`c:minorTickMark/@val`). */\n\tget minorTickMark(): string | null {\n\t\tconst el = firstChild(this.ax, 'c:minorTickMark')\n\t\treturn el ? attr(el, 'val') : null\n\t}\n\n\t/** Tick-label position (`c:tickLblPos/@val`): `nextTo`/`high`/`low`/`none`. */\n\tget tickLabelPosition(): string | null {\n\t\tconst el = firstChild(this.ax, 'c:tickLblPos')\n\t\treturn el ? attr(el, 'val') : null\n\t}\n\n\t/** Major unit (`c:majorUnit/@val`), or `null` when auto. */\n\tget majorUnit(): number | null {\n\t\tconst el = firstChild(this.ax, 'c:majorUnit')\n\t\treturn el ? numberValue(attr(el, 'val')) : null\n\t}\n\n\t/** Minor unit (`c:minorUnit/@val`), or `null` when auto. */\n\tget minorUnit(): number | null {\n\t\tconst el = firstChild(this.ax, 'c:minorUnit')\n\t\treturn el ? numberValue(attr(el, 'val')) : null\n\t}\n\n\t/** Escape hatch: the underlying axis element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.ax\n\t}\n\n\t/** Mark the owning chart part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.part.markDirty()\n\t}\n\n\t/** A named child of `c:scaling`. */\n\t#scaling(qname: string): Element | null {\n\t\tconst scaling = firstChild(this.ax, 'c:scaling')\n\t\treturn scaling ? firstChild(scaling, qname) : null\n\t}\n}\n\n/** One data series (`c:ser`) of a chart. */\nexport class ChartSeries {\n\tconstructor(\n\t\tprivate readonly ser: Element,\n\t\t/** The owning chart's OPC part, so {@link markDirty} can reach it from {@link element_}. */\n\t\tprivate readonly part: Part\n\t) {}\n\n\t/**\n\t * Series fill (`c:spPr` solid fill / no-fill). `null` when the series carries\n\t * no `c:spPr` or its `c:spPr` declares no fill choice (inherits the theme).\n\t */\n\tget fill(): ChartFill | null {\n\t\tconst spPr = firstChild(this.ser, 'c:spPr')\n\t\treturn spPr ? readSolidFill(spPr) : null\n\t}\n\n\t/**\n\t * Series line/stroke (`c:spPr/a:ln`) — width, dash, colour. `null` when the\n\t * series `c:spPr` has no `a:ln` (bar/area fills carry no line by default).\n\t */\n\tget line(): ChartLine | null {\n\t\tconst spPr = firstChild(this.ser, 'c:spPr')\n\t\tconst ln = spPr && firstChild(spPr, 'a:ln')\n\t\tif (!ln) return null\n\t\t// The chart part is read without a theme, so the colour stays unresolved.\n\t\tconst { widthPt, dash, colorRef, noFill } = readLineBasics(ln, null)\n\t\treturn { widthPt, dash, colorRef, noFill }\n\t}\n\n\t/** Series index (`c:idx/@val`), or `null` if absent. */\n\tget index(): number | null {\n\t\tconst idx = firstChild(this.ser, 'c:idx')\n\t\treturn idx ? numberValue(attr(idx, 'val')) : null\n\t}\n\n\t/** Series name from the cached `c:tx`, or `null` when unnamed. */\n\tget name(): string | null {\n\t\tconst tx = firstChild(this.ser, 'c:tx')\n\t\tif (!tx) return null\n\t\tconst direct = firstChild(tx, 'c:v')\n\t\tif (direct) return direct.textContent ?? null\n\t\tconst points = readPoints(findCache(tx))\n\t\treturn points[0] ?? null\n\t}\n\n\t/**\n\t * Cached numeric values (`c:val`); non-numeric or missing points are `null`. Empty on a\n\t * scatter or bubble series, which caches its values as {@link yValues} instead.\n\t */\n\tget values(): (number | null)[] {\n\t\treturn this.#numbers('c:val')\n\t}\n\n\t/**\n\t * Cached X values of a scatter or bubble series (`c:xVal`); missing points are `null`.\n\t * A series plotted against text X labels reads `null` at every point, a label that looks like a\n\t * number included: {@link xLabels} has the text. A series with no `c:xVal` reads `[]`, and\n\t * PowerPoint plots it at X = 1, 2, … n, as it does a series plotted against text.\n\t */\n\tget xValues(): (number | null)[] {\n\t\tconst cache = findCache(firstChild(this.ser, 'c:xVal'))\n\t\tif (cache && isTextCache(cache)) return textPoints(cache).map(() => null)\n\t\treturn readPoints(cache).map(numberValue)\n\t}\n\n\t/**\n\t * The X labels of a series plotted against text (`c:xVal` holding a string cache rather than\n\t * numbers), as written, or `null` when its X values are numbers or absent.\n\t *\n\t * One text cell makes the whole X column a string cache, so the numbers in it arrive as text too.\n\t * PowerPoint then plots the points at X = 1, 2, … n in point order and uses none of the labels\n\t * as a coordinate, not even one that reads as a number.\n\t */\n\tget xLabels(): (string | null)[] | null {\n\t\tconst cache = findCache(firstChild(this.ser, 'c:xVal'))\n\t\treturn cache && isTextCache(cache) ? textPoints(cache) : null\n\t}\n\n\t/** Cached Y values of a scatter or bubble series (`c:yVal`); non-numeric or missing points are `null`. */\n\tget yValues(): (number | null)[] {\n\t\treturn this.#numbers('c:yVal')\n\t}\n\n\t/** Cached bubble sizes of a bubble series (`c:bubbleSize`); non-numeric or missing points are `null`. */\n\tget bubbleSizes(): (number | null)[] {\n\t\treturn this.#numbers('c:bubbleSize')\n\t}\n\n\t/**\n\t * Cached category labels for this series (`c:cat`), as written. On a multi-level axis this\n\t * is the leaf level, the labels next to the plot; {@link categoryLevels} has the rest.\n\t */\n\tget categories(): (string | null)[] {\n\t\treturn this.categoryLevels[0] ?? []\n\t}\n\n\t/**\n\t * Every level of cached category labels (`c:cat`), leaf first: the order PowerPoint writes the\n\t * `c:multiLvlStrCache/c:lvl` children in, and the order `OptsChartData.labels` takes them.\n\t * Each level is as long as the leaf level. An outer level names a group once, at the group's\n\t * first category, so the other slots of that group are `null`. A single-level axis reads as\n\t * one level, and a series with no categories as none.\n\t */\n\tget categoryLevels(): (string | null)[][] {\n\t\tconst cat = firstChild(this.ser, 'c:cat')\n\t\tconst cache = cat && findCache(cat)\n\t\tif (!cache) return []\n\t\tif (cache.localName !== 'multiLvlStrCache') return [readPoints(cache)]\n\t\treturn readCategoryLevels(cache)\n\t}\n\n\t/**\n\t * The data-label settings this series carries itself (`c:ser/c:dLbls`), or `null` when it has\n\t * none. This is where a pie's labels are: see {@link Chart.dataLabels}.\n\t */\n\tget dataLabels(): ChartDataLabels | null {\n\t\treturn readDataLabels(firstChild(this.ser, 'c:dLbls'))\n\t}\n\n\t/** Escape hatch: the underlying `c:ser` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.ser\n\t}\n\n\t/** Mark the owning chart part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.part.markDirty()\n\t}\n\n\t/** The cached points of a numeric child of the series (`c:val`, `c:xVal`, …), as numbers. */\n\t#numbers(qname: string): (number | null)[] {\n\t\tconst container = firstChild(this.ser, qname)\n\t\treturn readPoints(container && findCache(container)).map(numberValue)\n\t}\n}\n\n/** Read a `c:dLbls` block's show flags, position and number format, or `null` when there is no block. */\nfunction readDataLabels(dLbls: Element | null): ChartDataLabels | null {\n\tif (!dLbls) return null\n\tconst flag = (qname: string): boolean | null => {\n\t\tconst el = firstChild(dLbls, qname)\n\t\treturn el ? boolValue(attr(el, 'val')) : null\n\t}\n\tconst pos = firstChild(dLbls, 'c:dLblPos')\n\treturn {\n\t\tshowValue: flag('c:showVal'),\n\t\tshowSeriesName: flag('c:showSerName'),\n\t\tshowCategoryName: flag('c:showCatName'),\n\t\tshowPercent: flag('c:showPercent'),\n\t\tshowLegendKey: flag('c:showLegendKey'),\n\t\tshowBubbleSize: flag('c:showBubbleSize'),\n\t\tshowLeaderLines: flag('c:showLeaderLines'),\n\t\tposition: pos ? attr(pos, 'val') : null,\n\t\tnumberFormat: readNumberFormat(dLbls),\n\t}\n}\n\n/**\n * Read a `c:multiLvlStrCache` into its levels, in document order.\n *\n * The cache's `c:ptCount` counts categories, which is the leaf level's length, so only the leaf\n * is checked against it. An outer level is sparse by design, one point per group, and checking\n * it would warn about every multi-level chart PowerPoint writes. Every level is then widened to\n * the longest, so `levels[n][i]` is category `i`'s label at level `n`.\n */\nfunction readCategoryLevels(cache: Element): (string | null)[][] {\n\tconst ptCount = firstChild(cache, 'c:ptCount')\n\tconst declared = ptCount ? numberValue(attr(ptCount, 'val')) : null\n\tconst levels = getElements(cache, 'c:lvl').map((lvl, depth) =>\n\t\treadIndexedPoints(\n\t\t\tgetElements(lvl, 'c:pt'),\n\t\t\tdepth === 0 ? declared : null,\n\t\t\t(pt) => firstChild(pt, 'c:v')?.textContent ?? null,\n\t\t\t'c:multiLvlStrCache/c:ptCount'\n\t\t)\n\t)\n\tconst width = Math.max(0, ...levels.map((level) => level.length))\n\tfor (const level of levels) while (level.length < width) level.push(null)\n\treturn levels\n}\n\n/** Concatenate the rich-text runs of a `c:title` element, or `null` when absent/empty. */\nfunction readTitleText(titleEl: Element | null): string | null {\n\tif (!titleEl) return null\n\tconst tx = firstChild(titleEl, 'c:tx')\n\treturn concatDrawingMLText(tx && firstChild(tx, 'c:rich'))\n}\n\n/** Read a `c:numFmt` child of `parent` into `{ formatCode, sourceLinked }`, or `null` when absent. */\nfunction readNumberFormat(parent: Element): AxisNumberFormat | null {\n\tconst nf = firstChild(parent, 'c:numFmt')\n\tif (!nf) return null\n\treturn { formatCode: attr(nf, 'formatCode'), sourceLinked: boolValue(attr(nf, 'sourceLinked')) }\n}\n\n/**\n * The solid fill (or explicit `a:noFill`) a series' `c:spPr` declares, or `null` when it declares\n * neither and the series inherits the theme. The chart part carries no theme context, so the\n * colour is left unresolved and a scheme token surfaces raw rather than flattened to hex.\n *\n * Whether a fill is *there* is decided by the element, not by the colour inside it. The caller\n * used to ask whether the decoded `colorRef` carried an `srgb` or a `scheme` value -- two of the\n * three literal forms {@link readColorRef} reads, and none of the forms it does not, such as\n * `a:sysClr`. So a series filled with an `a:prstClr` reported no fill at all, and re-authoring it\n * silently dropped a fill the file states.\n */\nfunction readSolidFill(container: Element): ChartFill | null {\n\tconst solidFill = firstChild(container, 'a:solidFill')\n\tconst noFill = !!firstChild(container, 'a:noFill')\n\tif (!solidFill && !noFill) return null\n\treturn { colorRef: readColorRef(solidFill ? firstChildElement(solidFill) : null, null), noFill }\n}\n\n/** Resolve a `c:cat`/`c:val`/`c:tx` container to its cache element (`c:numCache`/`c:strCache`/literal). */\nfunction findCache(container: Element | null): Element | null {\n\tif (!container) return null\n\tfor (const refName of ['c:numRef', 'c:strRef', 'c:multiLvlStrRef']) {\n\t\tconst ref = firstChild(container, refName)\n\t\tif (ref) {\n\t\t\tfor (const cacheName of ['c:numCache', 'c:strCache', 'c:multiLvlStrCache']) {\n\t\t\t\tconst cache = firstChild(ref, cacheName)\n\t\t\t\tif (cache) return cache\n\t\t\t}\n\t\t}\n\t}\n\t// Inline literals (no workbook reference).\n\treturn firstChild(container, 'c:numLit') ?? firstChild(container, 'c:strLit')\n}\n\n/**\n * Whether a cache holds text rather than numbers. `c:xVal` takes any of the data-source forms a\n * `c:cat` does, so a scatter's X values can arrive as a string cache, a string literal or even a\n * multi-level cache.\n */\nfunction isTextCache(cache: Element): boolean {\n\treturn cache.localName !== 'numCache' && cache.localName !== 'numLit'\n}\n\n/** A text cache's labels, idx-ordered: the leaf level of a multi-level cache. */\nfunction textPoints(cache: Element): (string | null)[] {\n\treturn cache.localName === 'multiLvlStrCache' ? (readCategoryLevels(cache)[0] ?? []) : readPoints(cache)\n}\n\n/** Read a cache's points (`c:pt[@idx]/c:v`) into an idx-ordered array; `c:ptCount` is the declared count. */\nfunction readPoints(cache: Element | null): (string | null)[] {\n\tif (!cache) return []\n\tconst ptCount = firstChild(cache, 'c:ptCount')\n\treturn readIndexedPoints(\n\t\tgetElements(cache, 'c:pt'),\n\t\tptCount ? numberValue(attr(ptCount, 'val')) : null,\n\t\t(pt) => firstChild(pt, 'c:v')?.textContent ?? null,\n\t\t'c:ptCount'\n\t)\n}\n","/**\n * Read-only proxies for a chartEx (`cx:chartSpace`) chart hosted in a\n * `p:graphicFrame`. chartEx is the Office-2016 chart family — waterfall, funnel,\n * treemap, sunburst, histogram, pareto, box-and-whisker, region map — a separate\n * subsystem from the classic `c:chart` (see {@link ./chart.js `Chart`}).\n *\n * A chartEx chart lives in its own part (`/ppt/charts/chartEx{N}.xml`) whose root\n * is `cx:chartSpace`, referenced from the graphic frame by relationship id (the MS\n * `chartEx` rel, not the ECMA `chart` rel). The frame itself is wrapped in an\n * `mc:AlternateContent` — the reader unwraps the `mc:Choice` to reach it.\n *\n * Unlike the classic side, the layout geometry is keyed on `cx:series/@layoutId`\n * (`waterfall`, `funnel`, `treemap`, `clusteredColumn` for histogram/pareto, …)\n * rather than the plot-group element name, and category/value data lives in a\n * top-level `cx:chartData/cx:data` block the series point at by `cx:dataId`. This\n * surface reads the layout, title, legend, series, and the cached data; the\n * embedded workbook, the style/colors sidecars, and (for a region map) the online\n * geo-cache are out of scope.\n */\nimport type { Part } from '../opc/part.js'\nimport {\n\tattr,\n\tboolAttr,\n\tconcatDrawingMLText,\n\ttype Element,\n\tfirstChild,\n\tgetElements,\n\tnumberAttr,\n\tnumberValue,\n} from '../oxml/dom.js'\nimport { readIndexedPoints } from '../oxml/point-cache.js'\n\n/** A chartEx legend (`cx:legend`) — a leaf element carrying position/alignment attributes. */\nexport interface ChartExLegend {\n\t/** Legend position (`@pos`): `t`/`b`/`l`/`r`. */\n\tposition: string | null\n\t/** Legend alignment along its edge (`@align`), e.g. `ctr`. */\n\talign: string | null\n\t/** Whether the legend overlays the plot area (`@overlay`). */\n\toverlay: boolean | null\n}\n\n/** A chartEx series' data-label toggles (`cx:dataLabels` + its `cx:visibility` child). */\nexport interface ChartExDataLabels {\n\t/** Label position (`@pos`), e.g. `outEnd`, or `null` when unset. */\n\tposition: string | null\n\t/** Show the point value (`cx:visibility/@value`). */\n\tvalue: boolean | null\n\t/** Show the series name (`cx:visibility/@seriesName`). */\n\tseriesName: boolean | null\n\t/** Show the category name (`cx:visibility/@categoryName`). */\n\tcategoryName: boolean | null\n}\n\n/** A chartEx graphic-frame's chart, backed by its `cx:chartSpace` part. */\nexport class ChartEx {\n\tconstructor(\n\t\t/** The chartEx chart's OPC part (`/ppt/charts/chartEx{N}.xml`). */\n\t\treadonly part: Part\n\t) {}\n\n\t/** Partname of the chartEx chart part. */\n\tget partName(): string {\n\t\treturn this.part.partName\n\t}\n\n\t/**\n\t * The `cx:series/@layoutId` tokens in plot-area document order — the raw chartEx\n\t * layout names (`waterfall`, `funnel`, `treemap`, `sunburst`, `boxWhisker`,\n\t * `regionMap`, or `clusteredColumn`/`paretoLine` for histogram & pareto). This is\n\t * the OOXML truth: a histogram and a pareto both surface as `clusteredColumn`, so\n\t * the token does not always round-trip to the write-side `ChartType`.\n\t */\n\tget layoutIds(): string[] {\n\t\treturn this.#seriesElements()\n\t\t\t.map((ser) => attr(ser, 'layoutId'))\n\t\t\t.filter((id): id is string => id !== null && id !== '')\n\t}\n\n\t/** The first series' `@layoutId`, or `null` for an empty plot area. */\n\tget layoutId(): string | null {\n\t\treturn this.layoutIds[0] ?? null\n\t}\n\n\t/** The chart title (`cx:chart/cx:title` rich text), or `null` when absent. */\n\tget title(): string | null {\n\t\tconst chart = this.#chart()\n\t\tconst title = chart && firstChild(chart, 'cx:title')\n\t\tif (!title) return null\n\t\tconst tx = firstChild(title, 'cx:tx')\n\t\treturn concatDrawingMLText(tx && firstChild(tx, 'cx:rich'))\n\t}\n\n\t/** The legend (`cx:chart/cx:legend`) position/alignment, or `null` when hidden. */\n\tget legend(): ChartExLegend | null {\n\t\tconst chart = this.#chart()\n\t\tconst legend = chart && firstChild(chart, 'cx:legend')\n\t\tif (!legend) return null\n\t\treturn {\n\t\t\tposition: attr(legend, 'pos'),\n\t\t\talign: attr(legend, 'align'),\n\t\t\toverlay: boolAttr(legend, 'overlay'),\n\t\t}\n\t}\n\n\t/** The data series (`cx:plotAreaRegion/cx:series`) in document order. */\n\tget series(): ChartExSeries[] {\n\t\treturn this.#seriesElements().map((ser) => new ChartExSeries(ser, this))\n\t}\n\n\t/** The plot-area axes (`cx:plotArea/cx:axis`) in document order. */\n\tget axes(): ChartExAxis[] {\n\t\tconst plotArea = this.#plotArea()\n\t\treturn plotArea ? getElements(plotArea, 'cx:axis').map((ax) => new ChartExAxis(ax, this)) : []\n\t}\n\n\t/**\n\t * Category labels from the first series' cached leaf level (`cx:strDim`'s first\n\t * `cx:lvl`). Empty for a category-less layout (a histogram bins raw observations).\n\t */\n\tget categories(): (string | null)[] {\n\t\treturn this.series[0]?.categories ?? []\n\t}\n\n\t/** Escape hatch: the underlying `cx:chartSpace` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element | null {\n\t\treturn this.part.dom.documentElement\n\t}\n\n\t/** Mark the chartEx part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.part.markDirty()\n\t}\n\n\t/**\n\t * The `cx:data` block a series' `cx:dataId` points at (`cx:chartData/cx:data[@id]`),\n\t * or `null` when the id is unset or unmatched.\n\t */\n\tdataElementById(id: number | null): Element | null {\n\t\tif (id === null) return null\n\t\tconst chartData = this.#chartData()\n\t\tif (!chartData) return null\n\t\treturn getElements(chartData, 'cx:data').find((data) => numberValue(attr(data, 'id')) === id) ?? null\n\t}\n\n\t#root(): Element | null {\n\t\treturn this.part.dom.documentElement\n\t}\n\n\t#chartData(): Element | null {\n\t\tconst root = this.#root()\n\t\treturn root ? firstChild(root, 'cx:chartData') : null\n\t}\n\n\t#chart(): Element | null {\n\t\tconst root = this.#root()\n\t\treturn root ? firstChild(root, 'cx:chart') : null\n\t}\n\n\t#plotArea(): Element | null {\n\t\tconst chart = this.#chart()\n\t\treturn chart ? firstChild(chart, 'cx:plotArea') : null\n\t}\n\n\t#seriesElements(): Element[] {\n\t\tconst plotArea = this.#plotArea()\n\t\tconst region = plotArea && firstChild(plotArea, 'cx:plotAreaRegion')\n\t\treturn region ? getElements(region, 'cx:series') : []\n\t}\n}\n\n/** One data series (`cx:series`) of a chartEx chart. */\nexport class ChartExSeries {\n\tconstructor(\n\t\tprivate readonly ser: Element,\n\t\tprivate readonly chart: ChartEx\n\t) {}\n\n\t/** The layout token (`@layoutId`) that keys this series' geometry, e.g. `waterfall`. */\n\tget layoutId(): string | null {\n\t\treturn attr(this.ser, 'layoutId')\n\t}\n\n\t/** The deterministic series GUID (`@uniqueId`), or `null`. */\n\tget uniqueId(): string | null {\n\t\treturn attr(this.ser, 'uniqueId')\n\t}\n\n\t/**\n\t * The owner series index (`@ownerIdx`) for a derived series (a `paretoLine`\n\t * derives its data from series 0), or `null` for a self-contained series.\n\t */\n\tget ownerIndex(): number | null {\n\t\treturn numberValue(attr(this.ser, 'ownerIdx'))\n\t}\n\n\t/** Series name from the cached `cx:tx/cx:txData/cx:v`, or `null` when unnamed. */\n\tget name(): string | null {\n\t\tconst tx = firstChild(this.ser, 'cx:tx')\n\t\tconst txData = tx && firstChild(tx, 'cx:txData')\n\t\tconst v = txData && firstChild(txData, 'cx:v')\n\t\treturn v ? (v.textContent ?? null) : null\n\t}\n\n\t/** The data-block id this series plots (`cx:dataId/@val`), or `null`. */\n\tget dataId(): number | null {\n\t\tconst dataId = firstChild(this.ser, 'cx:dataId')\n\t\treturn dataId ? numberValue(attr(dataId, 'val')) : null\n\t}\n\n\t/** Cached numeric values (`cx:numDim`); non-numeric or missing points are `null`. */\n\tget values(): (number | null)[] {\n\t\tconst data = this.chart.dataElementById(this.dataId)\n\t\tconst numDim = data && firstChild(data, 'cx:numDim')\n\t\treturn readLevelPoints(numDim && firstChild(numDim, 'cx:lvl')).map(numberValue)\n\t}\n\n\t/**\n\t * Cached category labels (`cx:strDim`'s leaf `cx:lvl` — the first level, which\n\t * the writer emits leaf-first). Empty when the data block carries no `cx:strDim`.\n\t */\n\tget categories(): (string | null)[] {\n\t\tconst data = this.chart.dataElementById(this.dataId)\n\t\tconst strDim = data && firstChild(data, 'cx:strDim')\n\t\treturn readLevelPoints(strDim && firstChild(strDim, 'cx:lvl'))\n\t}\n\n\t/** The data-label toggles (`cx:dataLabels`), or `null` when the series shows none. */\n\tget dataLabels(): ChartExDataLabels | null {\n\t\tconst dLbls = firstChild(this.ser, 'cx:dataLabels')\n\t\tif (!dLbls) return null\n\t\tconst vis = firstChild(dLbls, 'cx:visibility')\n\t\treturn {\n\t\t\tposition: attr(dLbls, 'pos'),\n\t\t\tvalue: vis ? boolAttr(vis, 'value') : null,\n\t\t\tseriesName: vis ? boolAttr(vis, 'seriesName') : null,\n\t\t\tcategoryName: vis ? boolAttr(vis, 'categoryName') : null,\n\t\t}\n\t}\n\n\t/** Escape hatch: the underlying `cx:series` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.ser\n\t}\n\n\t/** Mark the owning chartEx part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.chart.part.markDirty()\n\t}\n}\n\n/**\n * One axis (`cx:axis`) of a chartEx plot area. chartEx axes carry no `catAx`/`valAx`\n * element-name distinction; the kind is read from the scaling child\n * (`cx:catScaling` vs `cx:valScaling`).\n */\nexport class ChartExAxis {\n\tconstructor(\n\t\tprivate readonly ax: Element,\n\t\t/** The owning chartEx chart, so {@link markDirty} can reach its part from {@link element_}. */\n\t\tprivate readonly chart: ChartEx\n\t) {}\n\n\t/** Axis id (`@id`), the value a series' `cx:axisId` binds to. */\n\tget id(): number | null {\n\t\treturn numberValue(attr(this.ax, 'id'))\n\t}\n\n\t/** Axis kind from its scaling child: `cat` (`cx:catScaling`) / `val` (`cx:valScaling`). */\n\tget kind(): 'cat' | 'val' | null {\n\t\tif (firstChild(this.ax, 'cx:catScaling')) return 'cat'\n\t\tif (firstChild(this.ax, 'cx:valScaling')) return 'val'\n\t\treturn null\n\t}\n\n\t/**\n\t * Category-axis gap width (`cx:catScaling/@gapWidth`) as a fraction (1.0 = 100%,\n\t * the chartEx convention, unlike the classic integer percent), or `null`.\n\t */\n\tget gapWidth(): number | null {\n\t\tconst cat = firstChild(this.ax, 'cx:catScaling')\n\t\treturn cat ? numberAttr(cat, 'gapWidth') : null\n\t}\n\n\t/** Value-axis scale minimum (`cx:valScaling/@min`), or `null` when auto. */\n\tget min(): number | null {\n\t\tconst val = firstChild(this.ax, 'cx:valScaling')\n\t\treturn val ? numberAttr(val, 'min') : null\n\t}\n\n\t/** Value-axis scale maximum (`cx:valScaling/@max`), or `null` when auto. */\n\tget max(): number | null {\n\t\tconst val = firstChild(this.ax, 'cx:valScaling')\n\t\treturn val ? numberAttr(val, 'max') : null\n\t}\n\n\t/** Whether the axis draws major gridlines (`cx:majorGridlines`). */\n\tget majorGridlines(): boolean {\n\t\treturn !!firstChild(this.ax, 'cx:majorGridlines')\n\t}\n\n\t/** Whether the axis draws tick labels (`cx:tickLabels`). */\n\tget tickLabels(): boolean {\n\t\treturn !!firstChild(this.ax, 'cx:tickLabels')\n\t}\n\n\t/** Escape hatch: the underlying `cx:axis` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.ax\n\t}\n\n\t/** Mark the owning chartEx part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.chart.part.markDirty()\n\t}\n}\n\n/** Read a `cx:lvl`'s points (`cx:pt[@idx]` text) into an idx-ordered array; `@ptCount` is the declared count. */\nfunction readLevelPoints(lvl: Element | null): (string | null)[] {\n\tif (!lvl) return []\n\treturn readIndexedPoints(\n\t\tgetElements(lvl, 'cx:pt'),\n\t\tnumberValue(attr(lvl, 'ptCount')),\n\t\t(pt) => pt.textContent ?? null,\n\t\t'cx:lvl/@ptCount'\n\t)\n}\n","/**\n * Read proxies for a SmartArt diagram (`dgm:dataModel`) hosted in a `p:graphicFrame`.\n *\n * SmartArt is a four-part construct, and the frame itself holds none of it: the\n * `a:graphicData` carries only a `dgm:relIds` with four relationship ids pointing at the\n * data, layout, quick-style and colours parts under `/ppt/diagrams/`. The **data** part is\n * the one with content in it — a flat `dgm:ptLst` of points plus a `dgm:cxnLst` of\n * connections that give the points their tree — and it is what this surface decodes. The\n * other three are generated presets (`urn:microsoft.com/office/officeart/…`) describing how\n * PowerPoint *draws* the graph rather than what it says; they surface as parts, not getters.\n *\n * The text is ordinary DrawingML: `dgm:pt/dgm:t` is an `a:CT_TextBody`, the same type a\n * shape's `p:txBody` is, so a point's text reads back through the same\n * {@link TextFrame}/`Paragraph`/`Run` proxies as any other text on the slide, run formatting\n * included.\n *\n * **Not every point is content.** A saved data model interleaves the user's nodes with\n * points the layout engine generated (`pres`), the diagram root (`doc`), and the transition\n * points sitting on each edge (`parTrans`/`sibTrans`, which carry text only where a layout\n * labels its arrows). {@link Diagram.text} applies exactly that filter; {@link Diagram.points}\n * applies none, so a consumer that needs the raw graph gets it.\n *\n * **The structure is in the connections, and {@link Diagram.nodes} is the view of it.** A\n * `parOf` edge names the parent in `@srcId`, the child in `@destId` and the child's sibling\n * position in `@srcOrd`; `points` order is document order and says nothing about depth. Three\n * decisions that tree makes, each of which could defensibly have gone the other way:\n *\n * - **`asst` points are in it.** An assistant is user content, and an org chart merely draws\n * it off the main branch rather than under it. {@link DiagramPoint.type} carries the\n * distinction, so folding it silently in with `node` would hide something a consumer can\n * act on while omitting it would lose authored text.\n * - **Transition points are not.** A `parTrans`/`sibTrans` labels an *edge*, not a node, and\n * reaches its edge through {@link DiagramConnection.parentTransitionId} /\n * `siblingTransitionId`. Hanging one off `children` would make the tree disagree with what\n * PowerPoint's own text pane shows.\n * - **A cycle in `parOf` throws.** It is a corrupt model rather than a shape the format can\n * express, and the walk would not terminate; see `diagram/parent-edge-cycle`.\n *\n * **A point's text is stored twice.** The data model is what PowerPoint reads, but a deck\n * also carries a *drawing* part (`dsp:drawing`) holding a copy of every drawn string, and\n * every renderer without a SmartArt layout engine — LibreOffice, Google Slides, thumbnailers\n * — paints that copy and nothing else. {@link DiagramPoint.drawnShape} is the link between\n * the two, and {@link DiagramPoint.text}'s setter is what keeps them in step.\n *\n * Authoring a SmartArt graphic from nothing is out of scope: the layout part is a\n * constraint-solver program PowerPoint executes, and the presentation tree it generates is\n * not derivable from the user's content. Editing the text of one that already exists is\n * supported — see {@link DiagramPoint.text}.\n */\nimport { warn } from '../../diagnostics.js'\nimport { PackageReadError } from '../../errors.js'\nimport type { OpcPackage } from '../opc/package.js'\nimport type { Part } from '../opc/part.js'\nimport type { Relationships } from '../opc/relationships.js'\nimport {\n\tOOXML_NS,\n\tattr,\n\tboolValue,\n\tdescendantsByTag,\n\tfirstChild,\n\tfirstChildElement,\n\tgetElements,\n\tnumberValue,\n\ttype Element,\n} from '../oxml/dom.js'\nimport type { ThemeContext } from '../oxml/theme.js'\nimport { setParagraphText, TextFrame } from './text.js'\n\n/**\n * `ST_PtType` — what a `dgm:pt` is.\n *\n * - `node` — a user-authored node, and the default when `@type` is absent.\n * - `asst` — an assistant node (an org chart's off-branch box); user content too.\n * - `doc` — the data model's single root; carries the layout/style/colour preset ids.\n * - `pres` — generated by the layout engine to position a node; never user content.\n * - `parTrans` / `sibTrans` — the two transition points of an edge, which a few layouts\n * (arrow processes, org-chart branches) let the user type a label into.\n */\nexport type DiagramPointType = 'node' | 'asst' | 'doc' | 'pres' | 'parTrans' | 'sibTrans'\n\nconst POINT_TYPES: readonly string[] = ['node', 'asst', 'doc', 'pres', 'parTrans', 'sibTrans']\n\n/**\n * `ST_CxnType` — what a `dgm:cxn` asserts. `parOf` (the default) is the parent/child edge of\n * the user's tree; `presOf` and `presParOf` bind a node to the generated `pres` point that\n * draws it, and are the layout engine's bookkeeping rather than structure.\n */\nexport type DiagramConnectionType = 'parOf' | 'presOf' | 'presParOf' | 'unknownRelationship'\n\nconst CONNECTION_TYPES: readonly string[] = ['parOf', 'presOf', 'presParOf', 'unknownRelationship']\n\n/** The MS extension (`dgm:extLst/a:ext`) whose `@relId` names the fallback drawing part. */\nconst DRAWING_EXT_URI = OOXML_NS.dsp\n\n/**\n * One edge of a diagram's data model (`dgm:cxn`) — an attribute-only element, so it reads as\n * plain data rather than as a proxy.\n *\n * The ids are `ST_ModelId` GUIDs matching a {@link DiagramPoint.modelId}. `parOf` edges are\n * the tree a reader cares about: `sourceId` is the parent, `destinationId` the child, and\n * `sourceOrder` the child's position among its siblings.\n */\nexport interface DiagramConnection {\n\t/** This edge's own id (`@modelId`). */\n\tmodelId: string | null\n\t/** What the edge asserts (`@type`); `parOf` when absent, its schema default. */\n\ttype: DiagramConnectionType\n\t/** The `@srcId` end — the parent, for a `parOf` edge. */\n\tsourceId: string | null\n\t/** The `@destId` end — the child, for a `parOf` edge. */\n\tdestinationId: string | null\n\t/** The child's index among its siblings (`@srcOrd`). */\n\tsourceOrder: number | null\n\t/** The parent's index as seen from the child (`@destOrd`). */\n\tdestinationOrder: number | null\n\t/** The `parTrans` point labelling this edge (`@parTransId`), or `null` when unset. */\n\tparentTransitionId: string | null\n\t/** The `sibTrans` point labelling this edge (`@sibTransId`), or `null` when unset. */\n\tsiblingTransitionId: string | null\n\t/** The layout preset this edge belongs to (`@presId`), set on generated edges only. */\n\tpresentationId: string | null\n}\n\n/**\n * Where a point's text is drawn in the fallback drawing part — the second copy of every\n * string a diagram carries, and the only one a renderer without a SmartArt layout engine\n * paints. See {@link DiagramPoint.drawnShape} for how a point reaches it.\n */\nexport interface DiagramDrawnShape {\n\t/** The drawing part (`/ppt/diagrams/drawing{N}.xml`) the shape lives in. */\n\treadonly part: Part\n\t/** The `pres` point this shape draws (`dsp:sp/@modelId`) — never the authored point's own id. */\n\treadonly modelId: string\n\t/** Which paragraph of {@link textFrame} carries this point's text (the `presOf` edge's `@destOrd`). */\n\treadonly paragraphIndex: number\n\t/**\n\t * The shape's `dsp:txBody`, bound to the **drawing** part rather than the data part, so\n\t * an edit made through it marks the part that actually changed.\n\t *\n\t * One shape commonly draws several points — three of them in `mixed.pptx` — so writing\n\t * `textFrame.text` here would delete the siblings' text. Replace paragraph\n\t * {@link paragraphIndex} instead, which is what {@link DiagramPoint.text}'s setter does.\n\t */\n\treadonly textFrame: TextFrame\n\t/** Escape hatch: the underlying `dsp:sp`. After mutating it call `part.markDirty()`. */\n\treadonly element_: Element\n}\n\n/** One `presOf` edge out of a point, as the index keeps it. */\ninterface PresentationArm {\n\treadonly destId: string\n\t/** `@destOrd` — the paragraph index this point occupies inside the drawn shape. */\n\treadonly destinationOrder: number\n\t/** `@srcOrd` — which of the point's several presentations this is. */\n\treadonly sourceOrder: number\n}\n\n/**\n * The node → drawn-shape index of one diagram: the `presOf` edges of the data model and the\n * `dsp:sp` elements of the drawing part, both keyed for lookup.\n *\n * Built once per {@link Diagram}, and only when a point is actually asked what draws it — the\n * drawing part is a second XML DOM and a consumer reading node text should not pay to parse\n * it. The consequence of that memo: a consumer who *adds* or *removes* shapes in the drawing\n * part through the escape hatches must re-reach the diagram to see them here.\n */\nclass DrawingIndex {\n\t/** `presOf` arms out of each source point, in `@srcOrd` order. */\n\treadonly #arms = new Map<string, PresentationArm[]>()\n\t/** Each `dsp:sp` by the `pres` modelId it draws. */\n\treadonly #shapes = new Map<string, Element>()\n\n\tconstructor(\n\t\troot: Element | null,\n\t\tprivate readonly drawingPart: Part | null,\n\t\tprivate readonly themeContext: ThemeContext,\n\t\t/**\n\t\t * The drawing part's own relationships, so a hyperlink in the cached text resolves to a url\n\t\t * rather than reporting a raw `@r:id`. It used to be read without them, so the same run\n\t\t * answered differently depending on which of the two paths reached it: through the point's\n\t\t * own `textFrame` it resolved, through `drawnShape.textFrame` it did not.\n\t\t */\n\t\tprivate readonly drawingRelationships: Relationships | null\n\t) {\n\t\tconst cxnLst = root && firstChild(root, 'dgm:cxnLst')\n\t\tfor (const cxn of cxnLst ? getElements(cxnLst, 'dgm:cxn') : []) {\n\t\t\tif (attr(cxn, 'type') !== 'presOf') continue\n\t\t\tconst srcId = attr(cxn, 'srcId')\n\t\t\tconst destId = attr(cxn, 'destId')\n\t\t\tif (!srcId || !destId) continue\n\t\t\tconst arm: PresentationArm = {\n\t\t\t\tdestId,\n\t\t\t\tdestinationOrder: numberValue(attr(cxn, 'destOrd')) ?? 0,\n\t\t\t\tsourceOrder: numberValue(attr(cxn, 'srcOrd')) ?? 0,\n\t\t\t}\n\t\t\tconst list = this.#arms.get(srcId)\n\t\t\tif (list) list.push(arm)\n\t\t\telse this.#arms.set(srcId, [arm])\n\t\t}\n\t\tfor (const list of this.#arms.values()) list.sort((a, b) => a.sourceOrder - b.sourceOrder)\n\n\t\t// `dsp:spTree` nests, so this is a descendant scan rather than a child one. Matched on\n\t\t// the `dsp` namespace rather than on local name alone: `sp` and `txBody` are among the\n\t\t// most-reused local names in DrawingML, and unlike `dataModelExt` (which `drawingPart`\n\t\t// still matches loosely, because nothing else can appear in that extension) they carry\n\t\t// no uri to disambiguate them.\n\t\tconst drawingRoot = drawingPart?.dom.documentElement ?? null\n\t\tfor (const sp of drawingRoot ? descendantsByTag(drawingRoot, OOXML_NS.dsp, 'sp') : []) {\n\t\t\tconst modelId = attr(sp, 'modelId')\n\t\t\tif (modelId !== null && !this.#shapes.has(modelId)) this.#shapes.set(modelId, sp)\n\t\t}\n\t}\n\n\t/**\n\t * Resolve one authored point to the `pres` point that presents it and to the drawn\n\t * paragraph carrying its text.\n\t *\n\t * A point commonly has **several** `presOf` arms — an org-chart node's box and the\n\t * connector beneath it are two presentations of one node — so the arm is chosen by what it\n\t * reaches rather than by its `@srcOrd`: the first, in `@srcOrd` order, whose `pres` point\n\t * draws a `dsp:sp` that has a `dsp:txBody`. That selector produced a unique hit for all 90\n\t * authored points measured across five layout families, and it degrades to \"no arm\" rather\n\t * than to \"the wrong arm\" on a layout that was not.\n\t */\n\tresolve(modelId: string | null): { presentationId: string | null; drawnShape: DiagramDrawnShape | null } {\n\t\tconst arms = (modelId === null ? undefined : this.#arms.get(modelId)) ?? []\n\t\tconst first = arms[0]\n\t\tif (!first) return { presentationId: null, drawnShape: null }\n\t\tfor (const arm of arms) {\n\t\t\tconst sp = this.#shapes.get(arm.destId)\n\t\t\tconst txBody = sp && firstChild(sp, 'dsp:txBody')\n\t\t\tif (!sp || !txBody || !this.drawingPart) continue\n\t\t\t// A `@destOrd` past the end of the body is a drawing cache that disagrees with the\n\t\t\t// data model — no paragraph to point at, so the same \"nothing is drawn\" answer.\n\t\t\tconst paragraph = getElements(txBody, 'a:p')[arm.destinationOrder]\n\t\t\treturn {\n\t\t\t\tpresentationId: arm.destId,\n\t\t\t\tdrawnShape: paragraph\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tpart: this.drawingPart,\n\t\t\t\t\t\t\tmodelId: arm.destId,\n\t\t\t\t\t\t\tparagraphIndex: arm.destinationOrder,\n\t\t\t\t\t\t\ttextFrame: new TextFrame(txBody, {\n\t\t\t\t\t\t\t\tpart: this.drawingPart,\n\t\t\t\t\t\t\t\tctx: this.themeContext,\n\t\t\t\t\t\t\t\trels: this.drawingRelationships,\n\t\t\t\t\t\t\t\tinherit: null,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\telement_: sp,\n\t\t\t\t\t\t}\n\t\t\t\t\t: null,\n\t\t\t}\n\t\t}\n\t\treturn { presentationId: first.destId, drawnShape: null }\n\t}\n}\n\n/** One point (`dgm:pt`) of a diagram's data model. */\nexport class DiagramPoint {\n\tconstructor(\n\t\tprivate readonly pt: Element,\n\t\t/** The diagram data part, so a text edit marks the right part dirty. */\n\t\tprivate readonly part: Part,\n\t\tprivate readonly themeContext: ThemeContext,\n\t\tprivate readonly relationships: Relationships,\n\t\t/** The owning diagram's drawing index, built on first use; absent when reached without one. */\n\t\tprivate readonly drawing?: () => DrawingIndex\n\t) {}\n\n\t/** This point's id (`@modelId`), which connections reference. */\n\tget modelId(): string | null {\n\t\treturn attr(this.pt, 'modelId')\n\t}\n\n\t/** What kind of point this is (`@type`); `node` when absent, its schema default. */\n\tget type(): DiagramPointType {\n\t\tconst raw = attr(this.pt, 'type')\n\t\treturn raw !== null && POINT_TYPES.includes(raw) ? (raw as DiagramPointType) : 'node'\n\t}\n\n\t/**\n\t * For a transition point, the edge it labels (`@cxnId`), or `null`. The schema's default\n\t * is the literal `0`, which means \"none\" rather than naming a point, so it reads `null`.\n\t */\n\tget connectionId(): string | null {\n\t\treturn idAttr(this.pt, 'cxnId')\n\t}\n\n\t/**\n\t * Whether this point is an unfilled prompt (`dgm:prSet/@phldr`) — a node PowerPoint draws\n\t * with a grey placeholder string and treats as empty. Excluded from {@link Diagram.text}:\n\t * a layout that stores its prompt in `dgm:t` would otherwise extract as content.\n\t */\n\tget isPlaceholder(): boolean {\n\t\tconst prSet = this.#prSet()\n\t\treturn prSet ? boolValue(attr(prSet, 'phldr')) === true : false\n\t}\n\n\t/** The prompt string a placeholder point displays (`dgm:prSet/@phldrT`), or `null`. */\n\tget placeholderText(): string | null {\n\t\tconst prSet = this.#prSet()\n\t\treturn prSet ? attr(prSet, 'phldrT') : null\n\t}\n\n\t/**\n\t * This point's text body (`dgm:t`) as a {@link TextFrame}, or `null` when the point\n\t * carries none. It is an `a:CT_TextBody` like any other, so `paragraphs`, `runs` and the\n\t * `resolved*` getters all apply.\n\t *\n\t * **Writing through this edits the data model only**, and leaves the drawing cache\n\t * holding the old string — which is what PowerPoint-less renderers draw. It is the escape\n\t * hatch for run-level formatting, so it does exactly what it is told and nothing more;\n\t * {@link text}'s setter is the path that mirrors.\n\t */\n\tget textFrame(): TextFrame | null {\n\t\tconst t = firstChild(this.pt, 'dgm:t')\n\t\treturn t\n\t\t\t? new TextFrame(t, { part: this.part, ctx: this.themeContext, rels: this.relationships, inherit: null })\n\t\t\t: null\n\t}\n\n\t/**\n\t * The generated `pres` point that presents this one (`dgm:cxn[@type=\"presOf\"]/@destId`),\n\t * or `null` when nothing presents it — the normal state of an unlabelled transition point.\n\t *\n\t * Where a point has several `presOf` arms the one named here is the arm that draws text;\n\t * see {@link drawnShape}, which resolves both.\n\t */\n\tget presentationId(): string | null {\n\t\treturn this.drawing?.().resolve(this.modelId).presentationId ?? null\n\t}\n\n\t/**\n\t * The paragraph of the fallback drawing part (`dsp:drawing`) that carries this point's\n\t * text, or `null` when nothing draws it.\n\t *\n\t * The mapping runs through the `pres` point rather than directly: a `dsp:sp/@modelId` is\n\t * always a `pres` point's id, so a lookup keyed on the authored point's own id finds\n\t * nothing at all. It is many-to-one in both directions — one shape draws several points\n\t * (`@destOrd` says which paragraph is whose, and it can contradict document order), and\n\t * one point has several presentations, of which at most one holds text.\n\t *\n\t * `null` is a defined outcome, not a failure, and covers four real cases: the package\n\t * carries no drawing part; the point has no `presOf` edge (every unlabelled\n\t * `parTrans`/`sibTrans`); the `pres` point draws no `dsp:sp`; and the shape it draws has\n\t * no `dsp:txBody` (a connector, or a picture node's filled rectangle).\n\t */\n\tget drawnShape(): DiagramDrawnShape | null {\n\t\treturn this.drawing?.().resolve(this.modelId).drawnShape ?? null\n\t}\n\n\t/** This point's text, paragraphs joined by `\\n`; `''` when it carries none. */\n\tget text(): string {\n\t\treturn this.textFrame?.text ?? ''\n\t}\n\n\t/**\n\t * Replace this point's text, in the data model **and** in the drawing cache.\n\t *\n\t * A diagram stores every string twice. `dgm:t` is what PowerPoint reads, and it recomputes\n\t * the drawing from the data model on open; the `dsp:drawing` part is what every other\n\t * renderer paints, and none of them recompute anything. Writing only the first is an edit\n\t * that is invisible in LibreOffice, Google Slides, thumbnailers and web previews until\n\t * someone opens the deck in PowerPoint and saves it.\n\t *\n\t * The data-model write always happens. The mirror is best-effort: when the point resolves\n\t * to no drawn paragraph (see {@link drawnShape} for the four ways that occurs) the cache\n\t * keeps the old string and a `diagram/drawing-cache-not-updated` diagnostic says so.\n\t * Throwing instead would make the common case unusable in order to report the rare one,\n\t * and returning a status would be a shape no other text setter here has.\n\t *\n\t * Two things it deliberately does not do. It does **not** recompute geometry: the drawn\n\t * shape keeps its cached position and size, so a much longer string overflows its box in\n\t * those same renderers until PowerPoint re-lays the diagram out. And it does not *create*\n\t * a place to draw text — a transition point whose layout has no label slot has no\n\t * `dsp:sp`, and PowerPoint strips text put on one, so the honest outcome is the\n\t * diagnostic. Like every other `text` setter here it collapses the point to one run,\n\t * keeping the first run's `a:rPr`; use {@link textFrame} for run-level work.\n\t */\n\tset text(value: string) {\n\t\tconst frame = this.textFrame\n\t\tif (!frame) {\n\t\t\t// No `dgm:t` at all. Synthesizing one is the case measurement says not to take: a\n\t\t\t// transition point whose layout has no label slot is stored exactly like this, and\n\t\t\t// PowerPoint strips text put on one at the next save. So the point is left alone.\n\t\t\twarn(\n\t\t\t\t'diagram/point-has-no-text-body',\n\t\t\t\t`SmartArt point ${this.#label()} (type ${this.type}) has no dgm:t, so it is not a point text can be written to; nothing was changed`\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tframe.text = value\n\n\t\tconst drawn = this.drawnShape\n\t\tconst paragraph = drawn?.textFrame.paragraphs[drawn.paragraphIndex]\n\t\tif (!drawn || !paragraph) {\n\t\t\twarn(\n\t\t\t\t'diagram/drawing-cache-not-updated',\n\t\t\t\t`SmartArt point ${this.#label()} resolves to no drawn paragraph, so ${this.part.partName} now holds the new text but the drawing cache still holds the old one; PowerPoint redraws it on open, other renderers do not`\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tsetParagraphText(paragraph.element_, value)\n\t\t// The drawing is a different `Part` from the data model, and only a marked part is\n\t\t// reserialized — missing this one is silent, not loud.\n\t\tdrawn.part.markDirty()\n\t}\n\n\t/** Escape hatch: the underlying `dgm:pt` element. After mutating it call {@link Diagram.markDirty}. */\n\tget element_(): Element {\n\t\treturn this.pt\n\t}\n\n\t#prSet(): Element | null {\n\t\treturn firstChild(this.pt, 'dgm:prSet')\n\t}\n\n\t/** How a diagnostic names this point: its `@modelId`, which is all a corrupt point may have. */\n\t#label(): string {\n\t\treturn this.modelId ?? '(no modelId)'\n\t}\n}\n\n/**\n * One user-authored point in its place in the diagram's tree — a `node` or an `asst`, never a\n * generated `pres` point or a transition label. See {@link Diagram.nodes}.\n */\nexport class DiagramNode {\n\t/** Child nodes, ordered by their `parOf` edge's `@srcOrd`. Empty for a leaf. */\n\treadonly children: DiagramNode[] = []\n\n\tconstructor(\n\t\t/** The point itself: its text, its type, and its link to what is drawn for it. */\n\t\treadonly point: DiagramPoint,\n\t\t/** The parent node, or `null` for a root. */\n\t\treadonly parent: DiagramNode | null,\n\t\t/** Depth below the root, `0` for a root. */\n\t\treadonly level: number\n\t) {}\n}\n\n/** A `parOf` edge, reduced to what building the tree needs. */\ninterface ParentEdge {\n\treadonly parentId: string\n\treadonly childId: string\n\treadonly order: number\n}\n\n/** Sort key for a root with no `parOf` edge at all, so it lands after the ordered ones. */\nconst MAX_ORDER = Number.MAX_SAFE_INTEGER\n\n/** A SmartArt graphic frame's diagram, backed by its `dgm:dataModel` part. */\nexport class Diagram {\n\t#relationships: Relationships | undefined\n\t#docPrSetCache: Element | null | undefined\n\t#drawing: DrawingIndex | undefined\n\n\tconstructor(\n\t\t/** The diagram's data part (`/ppt/diagrams/data{N}.xml`), whose root is `dgm:dataModel`. */\n\t\treadonly part: Part,\n\t\t/** The frame's `dgm:relIds`, which names the other three parts by relationship id. */\n\t\tprivate readonly relIds: Element,\n\t\tprivate readonly opc: OpcPackage,\n\t\t/** Relationships of the part holding the frame — what `dgm:relIds` resolves against. */\n\t\tprivate readonly frameRelationships: Relationships,\n\t\tprivate readonly themeContext: ThemeContext\n\t) {}\n\n\t/** Partname of the diagram data part. */\n\tget partName(): string {\n\t\treturn this.part.partName\n\t}\n\n\t/**\n\t * Every point (`dgm:ptLst/dgm:pt`) in document order, unfiltered — generated `pres`\n\t * points and the `doc` root included. Filter on {@link DiagramPoint.type} for the user's\n\t * nodes; {@link text} is the shortcut for the common case, {@link nodes} the structured one.\n\t *\n\t * Built per access like every other read proxy (`docs/reference/read-object-model.md`, \"Object\n\t * model\"), so `points[0] !== points[0]` while both wrap the same `dgm:pt`. Key a `Map`\n\t * on {@link DiagramPoint.modelId}, not on the point.\n\t */\n\tget points(): DiagramPoint[] {\n\t\tconst root = this.#root()\n\t\tconst ptLst = root && firstChild(root, 'dgm:ptLst')\n\t\tif (!ptLst) return []\n\t\tconst relationships = (this.#relationships ??= this.opc.relationshipsFor(this.part.partName))\n\t\tconst drawing = (): DrawingIndex => this.#drawingIndex()\n\t\treturn getElements(ptLst, 'dgm:pt').map(\n\t\t\t(pt) => new DiagramPoint(pt, this.part, this.themeContext, relationships, drawing)\n\t\t)\n\t}\n\n\t/**\n\t * The authored tree — every `node` and `asst` point in its place, roots in `@srcOrd`\n\t * order — as a view over {@link points} and {@link connections} rather than a replacement\n\t * for either.\n\t *\n\t * A root is a content point whose `parOf` parent is not itself content, which in a\n\t * PowerPoint-authored model means the `doc` point. Transition points are not members; see\n\t * this module's header for that decision and the two beside it.\n\t *\n\t * @throws PackageReadError `diagram/parent-edge-cycle` when the `parOf` edges make a\n\t * point its own ancestor, which is a corrupt model rather than a diagram shape.\n\t */\n\tget nodes(): DiagramNode[] {\n\t\tconst content = new Map<string, DiagramPoint>()\n\t\tfor (const point of this.points) {\n\t\t\tconst modelId = point.modelId\n\t\t\tif (modelId !== null && (point.type === 'node' || point.type === 'asst')) content.set(modelId, point)\n\t\t}\n\n\t\tconst childrenOf = new Map<string, ParentEdge[]>()\n\t\tconst edgeTo = new Map<string, ParentEdge>()\n\t\tfor (const connection of this.connections) {\n\t\t\tconst { sourceId, destinationId } = connection\n\t\t\tif (connection.type !== 'parOf' || sourceId === null || destinationId === null) continue\n\t\t\tif (!content.has(destinationId)) continue\n\t\t\tconst edge: ParentEdge = { parentId: sourceId, childId: destinationId, order: connection.sourceOrder ?? 0 }\n\t\t\tconst list = childrenOf.get(sourceId)\n\t\t\tif (list) list.push(edge)\n\t\t\telse childrenOf.set(sourceId, [edge])\n\t\t\tedgeTo.set(destinationId, edge)\n\t\t}\n\t\tfor (const list of childrenOf.values()) list.sort((a, b) => a.order - b.order)\n\n\t\t// `content` is in document order and `sort` is stable, so a point with no `parOf` edge\n\t\t// at all — a hand-built model, not something PowerPoint writes — keeps its place at the\n\t\t// end rather than being dropped.\n\t\tconst roots = [...content].filter(([modelId]) => {\n\t\t\tconst parentId = edgeTo.get(modelId)?.parentId\n\t\t\treturn parentId === undefined || !content.has(parentId)\n\t\t})\n\t\troots.sort(([a], [b]) => (edgeTo.get(a)?.order ?? MAX_ORDER) - (edgeTo.get(b)?.order ?? MAX_ORDER))\n\n\t\tconst placed = new Set<string>()\n\t\tconst build = (point: DiagramPoint, parent: DiagramNode | null, level: number, path: Set<string>): DiagramNode => {\n\t\t\tconst modelId = point.modelId\n\t\t\tif (modelId !== null && path.has(modelId)) throw this.#cycleError(modelId)\n\t\t\tconst node = new DiagramNode(point, parent, level)\n\t\t\tif (modelId === null) return node\n\t\t\tplaced.add(modelId)\n\t\t\tpath.add(modelId)\n\t\t\tfor (const edge of childrenOf.get(modelId) ?? []) {\n\t\t\t\tconst child = content.get(edge.childId)\n\t\t\t\tif (child) node.children.push(build(child, node, level + 1, path))\n\t\t\t}\n\t\t\tpath.delete(modelId)\n\t\t\treturn node\n\t\t}\n\t\tconst tree = roots.map(([, point]) => build(point, null, 0, new Set()))\n\n\t\t// A cycle that no root reaches would otherwise drop its members from the tree in\n\t\t// silence, since the walk never enters it. Every content point has at most one recorded\n\t\t// parent, so following parents from an unplaced point must repeat: unreachable and\n\t\t// cyclic are the same condition, and it gets the same answer as the reachable form.\n\t\tif (placed.size !== content.size) {\n\t\t\tconst orphan = [...content.keys()].find((modelId) => !placed.has(modelId))\n\t\t\tthrow this.#cycleError(orphan ?? '(unidentified)')\n\t\t}\n\t\treturn tree\n\t}\n\n\t/**\n\t * The point with this `@modelId`, or `null` — the lookup every connection getter implies,\n\t * since a `DiagramConnection` names its ends by id and nothing else resolves them.\n\t */\n\tpoint(modelId: string): DiagramPoint | null {\n\t\treturn this.points.find((candidate) => candidate.modelId === modelId) ?? null\n\t}\n\n\t/** Every edge (`dgm:cxnLst/dgm:cxn`) in document order. */\n\tget connections(): DiagramConnection[] {\n\t\tconst root = this.#root()\n\t\tconst cxnLst = root && firstChild(root, 'dgm:cxnLst')\n\t\tif (!cxnLst) return []\n\t\treturn getElements(cxnLst, 'dgm:cxn').map((cxn) => {\n\t\t\tconst rawType = attr(cxn, 'type')\n\t\t\treturn {\n\t\t\t\tmodelId: attr(cxn, 'modelId'),\n\t\t\t\ttype: rawType !== null && CONNECTION_TYPES.includes(rawType) ? (rawType as DiagramConnectionType) : 'parOf',\n\t\t\t\tsourceId: attr(cxn, 'srcId'),\n\t\t\t\tdestinationId: attr(cxn, 'destId'),\n\t\t\t\tsourceOrder: numberValue(attr(cxn, 'srcOrd')),\n\t\t\t\tdestinationOrder: numberValue(attr(cxn, 'destOrd')),\n\t\t\t\tparentTransitionId: idAttr(cxn, 'parTransId'),\n\t\t\t\tsiblingTransitionId: idAttr(cxn, 'sibTransId'),\n\t\t\t\tpresentationId: attr(cxn, 'presId') || null,\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * The diagram's text in document order, blocks joined by `\\n` — the counterpart to\n\t * `TextFrame.text` for a construct that has no single text body.\n\t *\n\t * Contributing points are the ones a user can type into: everything except the generated\n\t * `pres` points, the `doc` root, and any point flagged as an unfilled placeholder. A\n\t * point with no text contributes no blank line. Transition labels (`parTrans`/`sibTrans`)\n\t * are included where a layout has them, which is why this is not simply the node list.\n\t */\n\tget text(): string {\n\t\treturn this.points\n\t\t\t.filter((point) => point.type !== 'pres' && point.type !== 'doc' && !point.isPlaceholder)\n\t\t\t.map((point) => point.text)\n\t\t\t.filter((text) => text.length > 0)\n\t\t\t.join('\\n')\n\t}\n\n\t/**\n\t * The layout preset the diagram is drawn with (the `doc` point's `dgm:prSet/@loTypeId`),\n\t * e.g. `urn:microsoft.com/office/officeart/2005/8/layout/hList1`. This is what names the\n\t * SmartArt *kind*; {@link layoutPart} is that preset's definition.\n\t */\n\tget layoutTypeId(): string | null {\n\t\treturn this.#docPrSetAttr('loTypeId')\n\t}\n\n\t/** The quick-style preset (the `doc` point's `dgm:prSet/@qsTypeId`). */\n\tget quickStyleTypeId(): string | null {\n\t\treturn this.#docPrSetAttr('qsTypeId')\n\t}\n\n\t/** The colour preset (the `doc` point's `dgm:prSet/@csTypeId`). */\n\tget colorsTypeId(): string | null {\n\t\treturn this.#docPrSetAttr('csTypeId')\n\t}\n\n\t/** The layout definition part (`dgm:relIds/@r:lo`), or `null` when missing from the package. */\n\tget layoutPart(): Part | null {\n\t\treturn this.#relPart('r:lo')\n\t}\n\n\t/** The quick-style part (`dgm:relIds/@r:qs`), or `null` when missing from the package. */\n\tget quickStylePart(): Part | null {\n\t\treturn this.#relPart('r:qs')\n\t}\n\n\t/** The colours part (`dgm:relIds/@r:cs`), or `null` when missing from the package. */\n\tget colorsPart(): Part | null {\n\t\treturn this.#relPart('r:cs')\n\t}\n\n\t/**\n\t * The fallback drawing part (`dsp:drawing`) that renders the diagram for a consumer with\n\t * no SmartArt layout engine, or `null` when the deck carries none. It is named by an MS\n\t * extension on the data model rather than by `dgm:relIds`, so a slide holding two\n\t * diagrams still resolves each to its own drawing.\n\t */\n\tget drawingPart(): Part | null {\n\t\tconst root = this.#root()\n\t\tconst extLst = root && firstChild(root, 'dgm:extLst')\n\t\tif (!extLst) return null\n\t\tfor (const ext of getElements(extLst, 'a:ext')) {\n\t\t\tif (attr(ext, 'uri') !== DRAWING_EXT_URI) continue\n\t\t\t// Matched on local name alone: the `dsp` namespace appears nowhere else in the read\n\t\t\t// path, and registering a prefix for one attribute lookup buys nothing.\n\t\t\tconst dataModelExt = firstChildElement(ext)\n\t\t\tif (!dataModelExt || dataModelExt.localName !== 'dataModelExt') continue\n\t\t\treturn this.#partForRelId(attr(dataModelExt, 'relId'))\n\t\t}\n\t\treturn null\n\t}\n\n\t/** Escape hatch: the underlying `dgm:dataModel` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element | null {\n\t\treturn this.part.dom.documentElement\n\t}\n\n\t/** Mark the diagram data part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.part.markDirty()\n\t}\n\n\t#root(): Element | null {\n\t\treturn this.part.dom.documentElement\n\t}\n\n\t#cycleError(modelId: string): PackageReadError {\n\t\treturn new PackageReadError(\n\t\t\t'diagram/parent-edge-cycle',\n\t\t\t`Diagram ${this.part.partName} has a parOf cycle reaching point ${modelId}, so its points do not form a tree`\n\t\t)\n\t}\n\n\t/**\n\t * The `doc` point's `dgm:prSet`, which carries all three preset ids — resolved once\n\t * rather than once per getter, since each lookup is a scan of the whole `ptLst`.\n\t * `undefined` means \"not looked up yet\"; `null` means \"looked up, not there\".\n\t */\n\t#docPrSet(): Element | null {\n\t\tif (this.#docPrSetCache !== undefined) return this.#docPrSetCache\n\t\tconst root = this.#root()\n\t\tconst ptLst = root && firstChild(root, 'dgm:ptLst')\n\t\tconst doc = ptLst && getElements(ptLst, 'dgm:pt').find((pt) => attr(pt, 'type') === 'doc')\n\t\treturn (this.#docPrSetCache = (doc && firstChild(doc, 'dgm:prSet')) || null)\n\t}\n\n\t#docPrSetAttr(name: string): string | null {\n\t\tconst prSet = this.#docPrSet()\n\t\treturn prSet ? attr(prSet, name) : null\n\t}\n\n\t/**\n\t * The drawing index, built on first use and kept — see {@link DrawingIndex} for what that\n\t * memo costs a consumer who mutates the drawing part's shape tree by hand.\n\t */\n\t#drawingIndex(): DrawingIndex {\n\t\tconst drawing = this.drawingPart\n\t\treturn (this.#drawing ??= new DrawingIndex(\n\t\t\tthis.#root(),\n\t\t\tdrawing,\n\t\t\tthis.themeContext,\n\t\t\tdrawing ? this.opc.relationshipsFor(drawing.partName) : null\n\t\t))\n\t}\n\n\t#relPart(qname: string): Part | null {\n\t\treturn this.#partForRelId(attr(this.relIds, qname))\n\t}\n\n\t#partForRelId(relId: string | null): Part | null {\n\t\tif (!relId) return null\n\t\t// A `dgm:relIds` id naming no relationship is a corrupt package rather than a missing\n\t\t// feature, so letting `resolveTarget` throw is the right outcome — the same contract\n\t\t// the chart and chartEx getters keep.\n\t\treturn this.opc.part(this.frameRelationships.resolveTarget(relId)) ?? null\n\t}\n}\n\n/** An `ST_ModelId` attribute whose schema default `0` means \"unset\" rather than naming a point. */\nfunction idAttr(element: Element, name: string): string | null {\n\tconst raw = attr(element, name)\n\treturn raw === null || raw === '' || raw === '0' ? null : raw\n}\n","/**\n * Structural edits to an existing `a:tbl`: adding and removing rows and columns, and\n * merging and unmerging cells.\n *\n * The one fact that makes this tractable is that a stored table's grid is already\n * **rectangular**. Unlike the write path — which receives lopsided row arrays and has to\n * build the merge grid itself (`gen/slide/objects/table.ts` STEP 3) — every `a:tr` in a\n * conformant `a:tbl` holds exactly one `a:tc` per grid column, with the covered half of each\n * span present and flagged. So \"the cell at (r, c)\" is simply the c-th `a:tc` of the r-th\n * `a:tr`, and an edit's whole job is keeping that rectangle true.\n *\n * Three things have to stay in step, and every function here is written around them:\n *\n * 1. `a:tblGrid/a:gridCol` count == each row's `a:tc` count.\n * 2. A cell with `@gridSpan=\"n\"` is followed by exactly `n-1` cells carrying `@hMerge=\"1\"`,\n * and a cell with `@rowSpan=\"n\"` is under-hung by `n-1` cells carrying `@vMerge=\"1\"`, in\n * the same columns.\n * 3. A covered cell's own span attributes, where it has any, agree with its origin's.\n *\n * The third is looser than it could be because a merge reaches this module in two forms.\n * PowerPoint repeats the spans on covered cells: the covered cells of a region's first row carry\n * its `@rowSpan`, and those of its first column its `@gridSpan`, and inserting or deleting a row\n * or column through the region rewrites them (`test/read/fixtures/table-merge-encoding.pptx`).\n * This library's writer and {@link mergeCells} write that form too, but another producer may\n * leave covered cells without span attributes. A table in either form has to take every edit, so no edit reads\n * a span off a covered cell. {@link regionAt} resolves a cell to its region's origin and the\n * spans come from there, and an edit that changes a region's extent rewrites the spans its\n * covered cells already carry, so the region stays in the form it was written in.\n *\n * Breaking any of them produces a table PowerPoint reports as a corrupt file rather than as\n * a bad edit, which is why the span bookkeeping here is explicit rather than incidental.\n */\nimport { InvalidOptionError } from '../../errors.js'\nimport { EMU_PER_INCH } from '../../units.js'\nimport {\n\tattr,\n\tboolAttr,\n\tconcatDrawingMLText,\n\tcreateElement,\n\tfirstChild,\n\tgetElements,\n\tnumberValue,\n\townerDocumentOf,\n\tremoveAttr,\n\tsetAttr,\n\ttype Document,\n\ttype Element,\n} from '../oxml/dom.js'\nimport { checkPositiveEmu } from './coords.js'\n\n/** Every `a:tr` of a table, in document order. */\nexport function rowsOf(tbl: Element): Element[] {\n\treturn getElements(tbl, 'a:tr')\n}\n\n/** Every `a:tc` of a row, in document (left-to-right) order. */\nfunction cellsOf(tr: Element): Element[] {\n\treturn getElements(tr, 'a:tc')\n}\n\n/** The table's `a:tblGrid`, or a thrown error — `CT_Table` requires one. */\nfunction gridOf(tbl: Element): Element {\n\tconst grid = firstChild(tbl, 'a:tblGrid')\n\tif (!grid)\n\t\tthrow new InvalidOptionError(\n\t\t\t'table/column-index-out-of-range',\n\t\t\t'This table has no a:tblGrid, so its columns cannot be edited'\n\t\t)\n\treturn grid\n}\n\n/** A cell's `@gridSpan`, defaulting to 1. */\nfunction gridSpanOf(tc: Element): number {\n\treturn numberValue(attr(tc, 'gridSpan')) ?? 1\n}\n\n/** A cell's `@rowSpan`, defaulting to 1. */\nfunction rowSpanOf(tc: Element): number {\n\treturn numberValue(attr(tc, 'rowSpan')) ?? 1\n}\n\n/** Whether a cell is the covered half of a horizontal merge. */\nexport function isHMerge(tc: Element): boolean {\n\treturn boolAttr(tc, 'hMerge') === true\n}\n\n/** Whether a cell is the covered half of a vertical merge. */\nexport function isVMerge(tc: Element): boolean {\n\treturn boolAttr(tc, 'vMerge') === true\n}\n\n/**\n * Set a span attribute, removing it when the span collapses to 1 — the schema default, and\n * what PowerPoint itself writes for an unmerged cell.\n */\nfunction setSpan(tc: Element, name: 'gridSpan' | 'rowSpan', value: number): void {\n\tif (value <= 1) removeAttr(tc, name)\n\telse setAttr(tc, name, String(value))\n}\n\n/** A merged region, or a lone cell as a region of one: where its origin is, and how far it reaches. */\ninterface Region {\n\treadonly originRow: number\n\treadonly originCol: number\n\treadonly rowSpan: number\n\treadonly gridSpan: number\n}\n\n/**\n * The region the cell at `(row, col)` belongs to.\n *\n * Walks up through `vMerge` cells to the origin's row, then left through `hMerge` cells to the\n * origin itself, and takes the extent from the origin alone, since a covered cell may or may not\n * repeat it.\n */\nfunction regionAt(grid: Element[][], row: number, col: number): Region {\n\tlet originRow = row\n\twhile (originRow > 0) {\n\t\tconst cell = grid[originRow]?.[col]\n\t\tif (!cell || !isVMerge(cell)) break\n\t\toriginRow -= 1\n\t}\n\tlet originCol = col\n\twhile (originCol > 0) {\n\t\tconst cell = grid[originRow]?.[originCol]\n\t\tif (!cell || !isHMerge(cell)) break\n\t\toriginCol -= 1\n\t}\n\tconst origin = grid[originRow]?.[originCol]\n\treturn {\n\t\toriginRow,\n\t\toriginCol,\n\t\trowSpan: origin ? rowSpanOf(origin) : 1,\n\t\tgridSpan: origin ? gridSpanOf(origin) : 1,\n\t}\n}\n\n/** The distinct regions the given cells belong to, each once, in the order first met. */\nfunction regionsAt(grid: Element[][], positions: Iterable<readonly [number, number]>): Region[] {\n\tconst regions = new Map<string, Region>()\n\tfor (const [row, col] of positions) {\n\t\tconst region = regionAt(grid, row, col)\n\t\tconst key = `${region.originRow},${region.originCol}`\n\t\tif (!regions.has(key)) regions.set(key, region)\n\t}\n\treturn [...regions.values()]\n}\n\n/** The regions crossing row `row`. */\nfunction regionsInRow(grid: Element[][], row: number): Region[] {\n\treturn regionsAt(\n\t\tgrid,\n\t\t(grid[row] ?? []).map((_, col) => [row, col] as const)\n\t)\n}\n\n/** The regions crossing column `col`. */\nfunction regionsInColumn(grid: Element[][], col: number): Region[] {\n\treturn regionsAt(\n\t\tgrid,\n\t\tgrid.map((_, row) => [row, col] as const)\n\t)\n}\n\n/** Every cell of `region` except its origin. */\nfunction coveredCells(grid: Element[][], region: Region): Element[] {\n\tconst out: Element[] = []\n\tfor (let r = region.originRow; r < region.originRow + region.rowSpan; r++) {\n\t\tfor (let c = region.originCol; c < region.originCol + region.gridSpan; c++) {\n\t\t\tif (r === region.originRow && c === region.originCol) continue\n\t\t\tconst tc = grid[r]?.[c]\n\t\t\tif (tc) out.push(tc)\n\t\t}\n\t}\n\treturn out\n}\n\n/**\n * Give a region a new `rowSpan` or `gridSpan`: on its origin, and on each covered cell of it that\n * already carries that attribute, so the region keeps the form it was written in.\n */\nfunction setRegionSpan(grid: Element[][], region: Region, name: 'gridSpan' | 'rowSpan', value: number): void {\n\tconst origin = grid[region.originRow]?.[region.originCol]\n\tif (origin) setSpan(origin, name, value)\n\tfor (const tc of coveredCells(grid, region)) {\n\t\tif (attr(tc, name) !== null) setSpan(tc, name, value)\n\t}\n}\n\n/** A fresh, empty `a:tc`, shaped the way PowerPoint writes one. */\nfunction makeCell(doc: Document): Element {\n\tconst tc = createElement(doc, 'a:tc')\n\tconst txBody = createElement(doc, 'a:txBody')\n\ttxBody.appendChild(createElement(doc, 'a:bodyPr'))\n\ttxBody.appendChild(createElement(doc, 'a:lstStyle'))\n\ttxBody.appendChild(createElement(doc, 'a:p'))\n\ttc.appendChild(txBody)\n\ttc.appendChild(createElement(doc, 'a:tcPr'))\n\treturn tc\n}\n\n/**\n * A fresh covered cell for a region an insertion widens, flagged and spanned exactly as `covered`,\n * the cell of the same region it is inserted beside.\n */\nfunction coveredCellLike(doc: Document, covered: Element): Element {\n\tconst tc = makeCell(doc)\n\tfor (const name of ['gridSpan', 'rowSpan', 'hMerge', 'vMerge']) {\n\t\tconst value = attr(covered, name)\n\t\tif (value !== null) setAttr(tc, name, value)\n\t}\n\treturn tc\n}\n\n/** The grid as a row-major array of `a:tc` elements. */\nfunction gridOfCells(tbl: Element): Element[][] {\n\treturn rowsOf(tbl).map((tr) => cellsOf(tr))\n}\n\n/** Guard an index against `[0, limit]` (inclusive upper bound, for insertion points). */\nfunction checkIndex(index: number, limit: number, what: 'row' | 'column', inclusive: boolean): number {\n\tconst max = inclusive ? limit : limit - 1\n\tif (!Number.isInteger(index) || index < 0 || index > max) {\n\t\tthrow new InvalidOptionError(\n\t\t\twhat === 'row' ? 'table/row-index-out-of-range' : 'table/column-index-out-of-range',\n\t\t\t`${what} index ${String(index)} is out of range (expected 0..${max})`\n\t\t)\n\t}\n\treturn index\n}\n\n/**\n * Insert a row at `index` (default: append).\n *\n * The subtle case is inserting **through** a vertical merge. A region that started above the row\n * being pushed down straddles the insertion point, so the new row must continue it rather than\n * interrupt it: the region grows by one row, once however many columns it spans, and the new\n * cells under it are covered cells. Interrupting it instead would leave an origin claiming more\n * rows than it has continuations, which is the corrupt-file case.\n */\nexport function insertRow(tbl: Element, index?: number): Element {\n\tconst rows = rowsOf(tbl)\n\tconst at = index === undefined ? rows.length : checkIndex(index, rows.length, 'row', true)\n\tconst grid = gridOfCells(tbl)\n\tconst colCount = getElements(gridOf(tbl), 'a:gridCol').length\n\tconst doc = ownerDocumentOf(tbl)\n\n\tfor (const region of regionsInRow(grid, at)) {\n\t\tif (region.originRow < at) setRegionSpan(grid, region, 'rowSpan', region.rowSpan + 1)\n\t}\n\n\tconst tr = createElement(doc, 'a:tr')\n\t// `@h` is required on CT_TableRow. Zero means \"auto — as tall as the content needs\",\n\t// which is the right default for a row nobody has sized.\n\tsetAttr(tr, 'h', '0')\n\tfor (let col = 0; col < colCount; col++) {\n\t\t// A pushed-down cell flagged `vMerge` is inside a region that started above, so the new\n\t\t// cell joins that region in the same form.\n\t\tconst displaced = grid[at]?.[col]\n\t\ttr.appendChild(displaced && isVMerge(displaced) ? coveredCellLike(doc, displaced) : makeCell(doc))\n\t}\n\n\t// `CT_Table` sequences tblPr, tblGrid, then the rows, so an insert is always relative to\n\t// an existing `a:tr` (or appended, which lands after tblGrid either way).\n\ttbl.insertBefore(tr, rows[at] ?? null)\n\treturn tr\n}\n\n/**\n * Remove the row at `index`.\n *\n * Two span cases, and they pull in opposite directions. A region that started above this row\n * shortens by one. A region that *starts* in this row and continues below cannot simply lose its\n * origin, since the rows below still hold its covered cells, so the next row takes over as its\n * first row and inherits the remaining extent. The origin's content is gone with the row, which is\n * inherent to removing a row rather than a choice made here.\n */\nexport function removeRow(tbl: Element, index: number): void {\n\tconst rows = rowsOf(tbl)\n\tconst at = checkIndex(index, rows.length, 'row', false)\n\tconst grid = gridOfCells(tbl)\n\n\tfor (const region of regionsInRow(grid, at)) {\n\t\tif (region.originRow < at) {\n\t\t\tsetRegionSpan(grid, region, 'rowSpan', region.rowSpan - 1)\n\t\t} else if (region.rowSpan > 1) {\n\t\t\tpromoteNextRow(grid, region)\n\t\t}\n\t}\n\n\tconst tr = rows[at]\n\tif (tr) tbl.removeChild(tr)\n}\n\n/**\n * Make the second row of `region` its first, for a removal of the row its origin is in. The cell\n * under the origin becomes the origin, and each covered cell of the new first row takes on the\n * `@rowSpan` the removed row's cell above it carried, if any.\n */\nfunction promoteNextRow(grid: Element[][], region: Region): void {\n\tconst heirRow = region.originRow + 1\n\tfor (let col = region.originCol; col < region.originCol + region.gridSpan; col++) {\n\t\tconst removed = grid[region.originRow]?.[col]\n\t\tconst heir = grid[heirRow]?.[col]\n\t\tif (!removed || !heir) continue\n\t\tremoveAttr(heir, 'vMerge')\n\t\tif (col === region.originCol) {\n\t\t\tsetSpan(heir, 'rowSpan', region.rowSpan - 1)\n\t\t\tsetSpan(heir, 'gridSpan', region.gridSpan)\n\t\t} else if (attr(removed, 'rowSpan') !== null) {\n\t\t\tsetSpan(heir, 'rowSpan', region.rowSpan - 1)\n\t\t}\n\t}\n}\n\n/**\n * Insert a column at `index` (default: append), `widthEmu` wide.\n *\n * Mirrors {@link insertRow}'s split case on the other axis: a region that started left of the\n * insertion point widens by one, and the new cells inside it are covered cells.\n * @throws {InvalidOptionError} when `widthEmu` is not a positive number\n */\nexport function insertColumn(tbl: Element, index?: number, widthEmu = EMU_PER_INCH): Element {\n\tconst width = checkPositiveEmu(widthEmu, 'widthEmu')\n\tconst tblGrid = gridOf(tbl)\n\tconst cols = getElements(tblGrid, 'a:gridCol')\n\tconst at = index === undefined ? cols.length : checkIndex(index, cols.length, 'column', true)\n\tconst grid = gridOfCells(tbl)\n\tconst doc = ownerDocumentOf(tbl)\n\n\tfor (const region of regionsInColumn(grid, at)) {\n\t\tif (region.originCol < at) setRegionSpan(grid, region, 'gridSpan', region.gridSpan + 1)\n\t}\n\n\tconst gridCol = createElement(doc, 'a:gridCol')\n\tsetAttr(gridCol, 'w', String(width))\n\ttblGrid.insertBefore(gridCol, cols[at] ?? null)\n\n\trowsOf(tbl).forEach((tr, row) => {\n\t\tconst displaced = grid[row]?.[at]\n\t\tconst tc = displaced && isHMerge(displaced) ? coveredCellLike(doc, displaced) : makeCell(doc)\n\t\ttr.insertBefore(tc, displaced ?? firstChild(tr, 'a:extLst'))\n\t})\n\treturn gridCol\n}\n\n/**\n * Remove the column at `index`.\n *\n * A region the column crosses narrows by one, from its right-hand end: every covered column of a\n * region holds the same kind of cell, so taking the last one keeps the origin, and its content,\n * where it is. Only a column whose cell stands alone loses that cell outright.\n */\nexport function removeColumn(tbl: Element, index: number): void {\n\tconst tblGrid = gridOf(tbl)\n\tconst cols = getElements(tblGrid, 'a:gridCol')\n\tconst at = checkIndex(index, cols.length, 'column', false)\n\tconst grid = gridOfCells(tbl)\n\n\tconst removed = grid.map((cells) => cells[at])\n\tfor (const region of regionsInColumn(grid, at)) {\n\t\tif (region.gridSpan <= 1) continue\n\t\tsetRegionSpan(grid, region, 'gridSpan', region.gridSpan - 1)\n\t\tconst lastCol = region.originCol + region.gridSpan - 1\n\t\tfor (let row = region.originRow; row < region.originRow + region.rowSpan; row++) {\n\t\t\tremoved[row] = grid[row]?.[lastCol]\n\t\t}\n\t}\n\n\tconst col = cols[at]\n\tif (col) tblGrid.removeChild(col)\n\trowsOf(tbl).forEach((tr, row) => {\n\t\tconst tc = removed[row]\n\t\tif (tc) tr.removeChild(tc)\n\t})\n}\n\n/**\n * Merge the rectangle `(row1, col1)`–`(row2, col2)` into one cell.\n *\n * The top-left cell becomes the origin; every other cell in the rectangle becomes a covered cell\n * — flagged, given the spans PowerPoint repeats on a region's first row and column, and emptied,\n * since a covered cell is never rendered.\n *\n * **The covered cells' text moves into the origin**, as PowerPoint's own Merge Cells does: each\n * covered cell's paragraphs are appended to the origin's, in row-major order, keeping their runs\n * and their formatting. A covered cell with no text contributes nothing, so merging over empty\n * cells does not pad the origin with blank lines. This used to discard that text outright, which\n * is not a defensible default for an editing API: a caller who wants it gone can clear the cells\n * first, and one who did not expect to lose it had no way back.\n *\n * Ground truth is `test/read/fixtures/table-merge-encoding.pptx`, whose origin holds `1,1`, `1,2`,\n * `2,1` and `2,2` as four paragraphs, plus a COM probe for the two cases that fixture cannot show:\n * an empty covered cell (contributes no paragraph) and a bold, coloured one (keeps both).\n *\n * A rectangle whose boundary **cuts through** an existing merge is rejected rather than\n * silently widened. Widening would be the friendlier-looking choice and the wrong one: the\n * caller asked for a specific region, and quietly returning a different one is how a layout\n * ends up subtly wrong with nothing to point at.\n */\nexport function mergeCells(tbl: Element, row1: number, col1: number, row2: number, col2: number): void {\n\tconst grid = gridOfCells(tbl)\n\tconst rowCount = grid.length\n\tconst colCount = getElements(gridOf(tbl), 'a:gridCol').length\n\tconst r1 = Math.min(row1, row2)\n\tconst r2 = Math.max(row1, row2)\n\tconst c1 = Math.min(col1, col2)\n\tconst c2 = Math.max(col1, col2)\n\tcheckIndex(r1, rowCount, 'row', false)\n\tcheckIndex(r2, rowCount, 'row', false)\n\tcheckIndex(c1, colCount, 'column', false)\n\tcheckIndex(c2, colCount, 'column', false)\n\tif (r1 === r2 && c1 === c2) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'table/merge-range-invalid',\n\t\t\t'A merge needs at least two cells; the given range covers one'\n\t\t)\n\t}\n\n\t// Every region touching the rectangle must lie entirely inside it.\n\tfor (let r = r1; r <= r2; r++) {\n\t\tfor (let c = c1; c <= c2; c++) {\n\t\t\tconst region = regionAt(grid, r, c)\n\t\t\tif (region.originRow < r1 || region.originCol < c1) {\n\t\t\t\tthrow new InvalidOptionError(\n\t\t\t\t\t'table/merge-range-invalid',\n\t\t\t\t\t`The range (${r1},${c1})-(${r2},${c2}) starts inside an existing merged cell at (${region.originRow},${region.originCol}); unmerge it first`\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (region.originRow + region.rowSpan - 1 > r2 || region.originCol + region.gridSpan - 1 > c2) {\n\t\t\t\tthrow new InvalidOptionError(\n\t\t\t\t\t'table/merge-range-invalid',\n\t\t\t\t\t`The range (${r1},${c1})-(${r2},${c2}) cuts through an existing merged cell at (${region.originRow},${region.originCol}); unmerge it first`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\tconst origin = grid[r1]?.[c1]\n\tif (!origin) return\n\t// Before the covered cells are emptied, and in row-major order over the rectangle, which is\n\t// the order PowerPoint appends them in.\n\tfor (let r = r1; r <= r2; r++) {\n\t\tfor (let c = c1; c <= c2; c++) {\n\t\t\tif (r === r1 && c === c1) continue\n\t\t\tconst tc = grid[r]?.[c]\n\t\t\tif (tc) moveCellParagraphs(tc, origin)\n\t\t}\n\t}\n\tsetSpan(origin, 'gridSpan', c2 - c1 + 1)\n\tsetSpan(origin, 'rowSpan', r2 - r1 + 1)\n\tremoveAttr(origin, 'hMerge')\n\tremoveAttr(origin, 'vMerge')\n\n\tfor (let r = r1; r <= r2; r++) {\n\t\tfor (let c = c1; c <= c2; c++) {\n\t\t\tif (r === r1 && c === c1) continue\n\t\t\tconst tc = grid[r]?.[c]\n\t\t\tif (!tc) continue\n\t\t\tremoveAttr(tc, 'gridSpan')\n\t\t\tremoveAttr(tc, 'rowSpan')\n\t\t\t// What PowerPoint writes: the region's row span on the covered cells of its first row,\n\t\t\t// its column span on those of its first column, and neither on the cells inside.\n\t\t\tif (r === r1) setSpan(tc, 'rowSpan', r2 - r1 + 1)\n\t\t\tif (c === c1) setSpan(tc, 'gridSpan', c2 - c1 + 1)\n\t\t\tif (c > c1) setAttr(tc, 'hMerge', '1')\n\t\t\telse removeAttr(tc, 'hMerge')\n\t\t\tif (r > r1) setAttr(tc, 'vMerge', '1')\n\t\t\telse removeAttr(tc, 'vMerge')\n\t\t\temptyCellText(tc)\n\t\t}\n\t}\n}\n\n/**\n * Split the merged cell whose origin is `(row, col)` back into individual cells.\n * The origin keeps its content; the cells it covered come back empty, which is what they\n * already were, and with no span attributes of their own.\n */\nexport function unmergeCell(tbl: Element, row: number, col: number): void {\n\tconst grid = gridOfCells(tbl)\n\tcheckIndex(row, grid.length, 'row', false)\n\tcheckIndex(col, getElements(gridOf(tbl), 'a:gridCol').length, 'column', false)\n\tconst origin = grid[row]?.[col]\n\tif (!origin) return\n\tconst region = regionAt(grid, row, col)\n\tif (isHMerge(origin) || isVMerge(origin)) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'table/merge-range-invalid',\n\t\t\t`The cell at (${row},${col}) is a covered cell, not a merge origin; unmerge the origin at (${region.originRow},${region.originCol}) instead`\n\t\t)\n\t}\n\tif (region.rowSpan === 1 && region.gridSpan === 1) return\n\n\tfor (const tc of [origin, ...coveredCells(grid, region)]) {\n\t\tfor (const name of ['gridSpan', 'rowSpan', 'hMerge', 'vMerge']) removeAttr(tc, name)\n\t}\n}\n\n/**\n * Append `from`'s non-empty paragraphs to `into`'s text body, moving the nodes themselves so their\n * runs and formatting come with them.\n *\n * A paragraph that carries no text is dropped rather than appended as a blank line: merging a 2x2\n * whose second cell is empty gives an origin with three paragraphs, not four. Emptiness is measured\n * by the text, not by the markup, because the two encodings of an empty cell differ and the caller\n * meant the same thing by both -- PowerPoint writes a bare `<a:p>` for a cell never typed into,\n * while this library writes a run holding an empty string for `{ text: '' }`.\n */\nfunction moveCellParagraphs(from: Element, into: Element): void {\n\tconst source = firstChild(from, 'a:txBody')\n\tconst target = firstChild(into, 'a:txBody')\n\tif (!source || !target) return\n\tfor (const p of getElements(source, 'a:p')) {\n\t\tif (concatDrawingMLText(p) === null) continue\n\t\tsource.removeChild(p)\n\t\ttarget.appendChild(p)\n\t}\n}\n\n/** Reduce a cell's text body to a single empty paragraph. */\nfunction emptyCellText(tc: Element): void {\n\tconst txBody = firstChild(tc, 'a:txBody')\n\tif (!txBody) return\n\tfor (const p of getElements(txBody, 'a:p')) txBody.removeChild(p)\n\ttxBody.appendChild(createElement(ownerDocumentOf(txBody), 'a:p'))\n}\n","/**\n * Resolve a table's `a:tableStyleId` against the deck-wide `tableStyles.xml` and\n * compose the style graph into a per-cell fill.\n *\n * A table cell that defines no own `a:tcPr` fill still renders shaded, because the\n * referenced `a:tblStyle` supplies conditional formatting: `wholeTbl` under\n * `band1H`/`band2H` (row banding), `band1V`/`band2V` (column banding),\n * `firstRow`/`lastRow`, `firstCol`/`lastCol`, and the four corner cells. Resolving\n * a cell means picking, in ECMA-376 precedence order, the highest-priority part\n * that actually defines a fill, then resolving that fill through the slide theme.\n *\n * This is read-only; it does not touch the import/copy path in `table-styles.ts`.\n */\n\nimport type { OpcPackage } from '../opc/package.js'\nimport { attr, firstChild, firstChildElement, getElements, type Element } from '../oxml/dom.js'\nimport { resolveThemeFont, styleRefFill, type ThemeContext } from '../oxml/theme.js'\nimport { resolveColorElement, type ResolvedColor } from './theme-context.js'\nimport { TABLE_STYLES_CONTENT_TYPE } from '../../ooxml/rel-types.js'\n\n/**\n * The `a:tblPr` condition flags that gate which style parts apply to a table.\n * `firstRow`/`bandRow` are the ones PowerPoint turns on by default; the rest are\n * off unless the author enabled the corresponding \"Header Column\" / \"Total Row\" /\n * \"Banded Columns\" toggle.\n */\nexport interface TableConditionFlags {\n\tfirstRow: boolean\n\tlastRow: boolean\n\tfirstCol: boolean\n\tlastCol: boolean\n\tbandRow: boolean\n\tbandCol: boolean\n}\n\n/** A table's resolved entry in `tableStyles.xml`: its GUID, display name, and raw element. */\nexport interface ResolvedTableStyle {\n\t/** The matched `@styleId` GUID (e.g. `{5C22544A-…}`). */\n\tstyleId: string\n\t/** The style's display name (`@styleName`, e.g. `Medium Style 2 - Accent 1`), or `null`. */\n\tname: string | null\n\t/** Escape hatch: the underlying `a:tblStyle` element. After mutating it call {@link ResolvedTableStyle.markDirty}, or `save()` writes the original bytes. */\n\telement_: Element\n\t/**\n\t * Mark `tableStyles.xml` dirty so `save()` reserializes it. Call after mutating\n\t * {@link ResolvedTableStyle.element_}. Note the part is deck-wide: an edit here\n\t * reaches every table bound to this style.\n\t */\n\tmarkDirty(): void\n}\n\n/**\n * Look up the `a:tblStyle` whose `@styleId` equals `styleId` in the deck's single\n * `tableStyles.xml`, or `null` when there is no such part or no matching style\n * (a built-in `[MS-OE376]` style the deck does not materialise resolves to `null`).\n */\nexport function resolveTableStyle(opc: OpcPackage, styleId: string | null): ResolvedTableStyle | null {\n\tif (!styleId) return null\n\tconst part = opc.partsByContentType(TABLE_STYLES_CONTENT_TYPE)[0]\n\tconst list = part?.dom.documentElement\n\tif (!part || !list) return null\n\tfor (const st of getElements(list, 'a:tblStyle')) {\n\t\tif (attr(st, 'styleId') === styleId) {\n\t\t\treturn {\n\t\t\t\tstyleId,\n\t\t\t\tname: attr(st, 'styleName'),\n\t\t\t\telement_: st,\n\t\t\t\tmarkDirty: () => {\n\t\t\t\t\tpart.markDirty()\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\treturn null\n}\n\n/**\n * The style-part qnames that apply to the cell at `(row, col)`, highest precedence\n * first. Corner cells beat the row/column edge conditions, which beat banding,\n * which beats `wholeTbl`. Banding is suppressed on the header/footer rows and the\n * first/last columns, and its band ordinal is counted from the first body cell\n * (i.e. after a `firstRow` header), so the first body row is `band1H`.\n *\n * Only the `firstRow` / `band1H` / `band2H` / `wholeTbl` path is exercised by a\n * fixture today; the column/corner ordering follows the ECMA-376 conditional-format\n * precedence but is not render-verified.\n */\nfunction cellStyleParts(\n\tflags: TableConditionFlags,\n\trow: number,\n\tcol: number,\n\trowCount: number,\n\tcolCount: number\n): string[] {\n\tconst isFirstRow = flags.firstRow && row === 0\n\tconst isLastRow = flags.lastRow && row === rowCount - 1\n\tconst isFirstCol = flags.firstCol && col === 0\n\tconst isLastCol = flags.lastCol && col === colCount - 1\n\tconst parts: string[] = []\n\tif (isFirstRow && isFirstCol) parts.push('a:nwCell')\n\tif (isFirstRow && isLastCol) parts.push('a:neCell')\n\tif (isLastRow && isFirstCol) parts.push('a:swCell')\n\tif (isLastRow && isLastCol) parts.push('a:seCell')\n\tif (isFirstRow) parts.push('a:firstRow')\n\tif (isLastRow) parts.push('a:lastRow')\n\tif (isFirstCol) parts.push('a:firstCol')\n\tif (isLastCol) parts.push('a:lastCol')\n\tif (flags.bandRow && !isFirstRow && !isLastRow) {\n\t\tconst ordinal = row - (flags.firstRow ? 1 : 0)\n\t\tparts.push(ordinal % 2 === 0 ? 'a:band1H' : 'a:band2H')\n\t}\n\tif (flags.bandCol && !isFirstCol && !isLastCol) {\n\t\tconst ordinal = col - (flags.firstCol ? 1 : 0)\n\t\tparts.push(ordinal % 2 === 0 ? 'a:band1V' : 'a:band2V')\n\t}\n\tparts.push('a:wholeTbl')\n\treturn parts\n}\n\n/**\n * The fill a single `a:tcStyle` contributes. `fall` means the part defines no fill\n * (only borders, or nothing) so resolution continues to the next-lower part;\n * `stop` means the part settles the fill — either a resolved solid colour or `null`\n * for an explicit `a:noFill` / a non-solid style fill (a gradient has no single hex).\n */\nfunction tcStyleFill(\n\ttcStyle: Element,\n\tctx: ThemeContext\n): { stop: true; color: ResolvedColor | null } | { stop: false } {\n\tconst fillRef = firstChild(tcStyle, 'a:fillRef')\n\tif (fillRef) {\n\t\tconst fill = styleRefFill(fillRef, ctx)\n\t\tconst color = fill && fill.localName === 'solidFill' ? resolveColorElement(firstChildElement(fill), ctx) : null\n\t\treturn { stop: true, color }\n\t}\n\tconst fill = firstChild(tcStyle, 'a:fill')\n\tif (!fill) return { stop: false }\n\tconst solid = firstChild(fill, 'a:solidFill')\n\treturn { stop: true, color: solid ? resolveColorElement(firstChildElement(solid), ctx) : null }\n}\n\n/**\n * The fill the table style contributes to the cell at `(row, col)`, resolved to a\n * literal hex through the slide theme, or `null` when the applicable style parts\n * define no solid fill (an explicit `a:noFill`, e.g. a \"Light Style\" body cell,\n * also reads `null`). The caller supplies the resolved `a:tblStyle`, the table's\n * condition flags, and the grid dimensions.\n */\nexport function resolveTableCellStyleFill(\n\tstyle: Element,\n\tflags: TableConditionFlags,\n\trow: number,\n\tcol: number,\n\trowCount: number,\n\tcolCount: number,\n\tctx: ThemeContext\n): ResolvedColor | null {\n\tfor (const partName of cellStyleParts(flags, row, col, rowCount, colCount)) {\n\t\tconst part = firstChild(style, partName)\n\t\tconst tcStyle = part && firstChild(part, 'a:tcStyle')\n\t\tif (!tcStyle) continue\n\t\tconst outcome = tcStyleFill(tcStyle, ctx)\n\t\tif (outcome.stop) return outcome.color\n\t}\n\treturn null\n}\n\n/**\n * What a table style's text styles (`a:tcTxStyle`) give the text of one cell. Each property is\n * taken from the highest-precedence part that states it, so a `firstRow` that makes the header\n * bold and white still leaves the header's other properties to `wholeTbl`. Every field is `null`\n * when no applicable part states it.\n */\nexport interface TableCellTextStyle {\n\t/** The text colour: the style's own colour child, else its `a:fontRef` colour, resolved. */\n\tcolor: ResolvedColor | null\n\t/** The face its `a:font/a:latin` names, or the theme font its `a:fontRef/@idx` names, resolved. */\n\tface: string | null\n\t/** `@b`: `on` is `true` and `off` is `false`; `def`, the schema default, states nothing. */\n\tbold: boolean | null\n\t/** `@i`, read the same way as {@link bold}. */\n\titalic: boolean | null\n}\n\n/** The `EG_ColorChoice` members, the colour a `CT_TableStyleTextStyle` states after its font. */\nconst COLOR_CHOICES = ['a:scrgbClr', 'a:srgbClr', 'a:hslClr', 'a:sysClr', 'a:schemeClr', 'a:prstClr'] as const\n\n/** An `ST_OnOffStyleType` value as a flag: `def` and absence state nothing. */\nfunction onOff(value: string | null): boolean | null {\n\treturn value === 'on' ? true : value === 'off' ? false : null\n}\n\n/** The face a `tcTxStyle` names: `a:font/a:latin`, or the major or minor font of its `a:fontRef`. */\nfunction textStyleFace(txStyle: Element, ctx: ThemeContext): string | null {\n\tconst fontScheme = ctx.fontScheme ?? null\n\tconst font = firstChild(txStyle, 'a:font')\n\tif (font) {\n\t\tconst latin = firstChild(font, 'a:latin')\n\t\treturn resolveThemeFont(latin && attr(latin, 'typeface'), fontScheme)\n\t}\n\tconst idx = attr(firstChild(txStyle, 'a:fontRef') ?? txStyle, 'idx')\n\treturn idx === 'major'\n\t\t? resolveThemeFont('+mj-lt', fontScheme)\n\t\t: idx === 'minor'\n\t\t\t? resolveThemeFont('+mn-lt', fontScheme)\n\t\t\t: null\n}\n\n/**\n * The colour a `tcTxStyle` gives its text. Its own colour child wins over the colour inside its\n * `a:fontRef`: Medium Style 2 names `a:prstClr black` in the fontRef and `dk1` beside it, and a\n * cell paints `dk1` (`test/read/fixtures/table-text-inheritance.pptx`, with `dk1` set to purple).\n */\nfunction textStyleColor(txStyle: Element, ctx: ThemeContext): ResolvedColor | null {\n\tfor (const qname of COLOR_CHOICES) {\n\t\tconst color = firstChild(txStyle, qname)\n\t\tif (color) return resolveColorElement(color, ctx)\n\t}\n\tconst fontRef = firstChild(txStyle, 'a:fontRef')\n\treturn fontRef ? resolveColorElement(firstChildElement(fontRef), ctx) : null\n}\n\n/**\n * The text style the table style gives the cell at `(row, col)`: each property from the first\n * part in {@link cellStyleParts} order whose `a:tcTxStyle` states it.\n */\nexport function resolveTableCellTextStyle(\n\tstyle: Element,\n\tflags: TableConditionFlags,\n\trow: number,\n\tcol: number,\n\trowCount: number,\n\tcolCount: number,\n\tctx: ThemeContext\n): TableCellTextStyle {\n\tconst out: TableCellTextStyle = { color: null, face: null, bold: null, italic: null }\n\tfor (const partName of cellStyleParts(flags, row, col, rowCount, colCount)) {\n\t\tconst part = firstChild(style, partName)\n\t\tconst txStyle = part && firstChild(part, 'a:tcTxStyle')\n\t\tif (!txStyle) continue\n\t\tout.bold ??= onOff(attr(txStyle, 'b'))\n\t\tout.italic ??= onOff(attr(txStyle, 'i'))\n\t\tout.face ??= textStyleFace(txStyle, ctx)\n\t\tout.color ??= textStyleColor(txStyle, ctx)\n\t}\n\treturn out\n}\n","/**\n * Ordered mutation of a table cell's `a:tcPr`, and the cell-scoped schema facts every such\n * edit needs.\n *\n * `CT_TableCellProperties` declares its children as a **sequence**, so an append-only\n * implementation produces an out-of-order `a:tcPr` — which PowerPoint reports as a corrupt\n * file rather than as a bad edit. Every insertion therefore goes through\n * {@link getOrAddChild} / {@link insertInOrder} with the new element's *successors*, which is\n * what `TCPR_AFTER` tabulates; it and the sequence it derives from live in\n * `src/ooxml/sequence.ts` alongside the other complexType orderings.\n *\n * The attribute values are the other half. A value outside its `ST_` union is equally fatal\n * and equally silent, so each is checked against the enum before it is written — the same\n * validate-at-the-boundary rule the write path follows, with the difference that here there\n * is a caller to throw at rather than a deck to degrade (see `ooxml/check-enum.ts`).\n */\nimport { getOrAddChild, insertInOrder, type Element } from '../oxml/dom.js'\nimport { TCPR_AFTER } from '../../ooxml/sequence.js'\nimport { TEXT_ANCHORS, TEXT_HORZ_OVERFLOW, TEXT_VERTICAL } from '../../ooxml/st-enums.js'\n\nexport { TCPR_AFTER, TCPR_SEQUENCE } from '../../ooxml/sequence.js'\nexport { checkEnumOrThrow as checkEnum } from '../../ooxml/check-enum.js'\n\n/** `ST_TextAnchoringType` — `a:tcPr/@anchor`. */\nexport const ANCHOR_VALUES = TEXT_ANCHORS\n/** `ST_TextVerticalType` — `a:tcPr/@vert`. */\nexport const VERT_VALUES = TEXT_VERTICAL\n/** `ST_TextHorzOverflowType` — `a:tcPr/@horzOverflow`. */\nexport const HORZ_OVERFLOW_VALUES = TEXT_HORZ_OVERFLOW\n\n/** The four edges plus the two diagonals, keyed as {@link TableCellEdge} names them. */\nexport const EDGE_QNAMES = {\n\tleft: 'a:lnL',\n\tright: 'a:lnR',\n\ttop: 'a:lnT',\n\tbottom: 'a:lnB',\n\ttlToBr: 'a:lnTlToBr',\n\tblToTr: 'a:lnBlToTr',\n} as const\n\n/** Which border of a cell an edit addresses. */\nexport type TableCellEdge = keyof typeof EDGE_QNAMES\n\n/**\n * Get or create a child of `a:tcPr` at its schema position.\n * @param {Element} tcPr - the cell's properties element\n * @param {string} qname - the child to get or create\n * @returns {Element} the existing or newly-inserted child\n */\nexport function tcPrChild(tcPr: Element, qname: string): Element {\n\treturn getOrAddChild(tcPr, qname, TCPR_AFTER[qname] ?? [])\n}\n\n/**\n * Insert an already-built subtree into `a:tcPr` at its schema position.\n * @param {Element} tcPr - the cell's properties element\n * @param {string} qname - the qname of the node being inserted (decides where it goes)\n * @param {Element} node - the subtree to insert\n */\nexport function insertTcPrChild(tcPr: Element, qname: string, node: Element): void {\n\tinsertInOrder(tcPr, node, TCPR_AFTER[qname] ?? [])\n}\n","/**\n * The `TableCell` read/edit proxy (`a:tc`), and the value types a cell's paint reads answer\n * with.\n *\n * Split out of `table.ts`, which held `Table`, `TableRow` and `TableCell` with no shared state\n * between them; this class alone was more than half the file. It stays whole here rather than\n * splitting again along its own properties/paint seam, because both halves read the same\n * `a:tcPr` and the style-graph fallback threads through both.\n */\nimport type { Part } from '../opc/part.js'\nimport type { Relationships } from '../opc/relationships.js'\nimport {\n\tattr,\n\tboolAttr,\n\tcreateElement,\n\ttype Element,\n\tfirstChild,\n\tgetElements,\n\tgetOrAddChild,\n\tnumberValue,\n\townerDocumentOf,\n\tremoveAttr,\n\tremoveChildrenByQName,\n\tsetAttr,\n} from '../oxml/dom.js'\nimport {\n\tapplyNoFill,\n\tapplySolidFill,\n\thasFillChoice,\n\tnormalizeHex,\n\tschemeToken,\n\tsolidFillColor,\n\ttype SolidFillEdit,\n} from '../oxml/fill.js'\nimport { checkEnumOrThrow } from '../../ooxml/check-enum.js'\nimport { PRESET_LINE_DASHES } from '../../ooxml/st-enums.js'\nimport {\n\tANCHOR_VALUES,\n\tcheckEnum,\n\tEDGE_QNAMES,\n\tHORZ_OVERFLOW_VALUES,\n\tinsertTcPrChild,\n\tTCPR_AFTER,\n\tVERT_VALUES,\n\ttype TableCellEdge,\n} from './table-edit.js'\nimport { checkFiniteEmu, checkLineWidthEmu, ptFromEmu } from './coords.js'\nimport { isHMerge, isVMerge } from './table-structure.js'\nimport type { InvalidOptionErrorCode } from '../../codes.js'\nimport { resolveSchemeToken, resolveThemeFont, type ThemeContext } from '../oxml/theme.js'\nimport { readPictureFill, type PictureFill } from './picture-fill.js'\nimport { readGradientFill, type GradientFill } from './gradient.js'\nimport { readPatternFill, type PatternFill } from './pattern-fill.js'\nimport { readLineBasics } from './line.js'\nimport {\n\tresolveTableCellStyleFill,\n\tresolveTableCellTextStyle,\n\ttype ResolvedTableStyle,\n\ttype TableCellTextStyle,\n\ttype TableConditionFlags,\n} from './table-style-resolve.js'\nimport { resolveSolidFillColor, type ColorRef, type ResolvedColor } from './theme-context.js'\nimport { setTextBodyText, TextFrame } from './text.js'\nimport { InvalidOptionError, PackageReadError } from '../../errors.js'\nimport { EMU_PER_POINT } from '../../units.js'\n\n/**\n * One border as {@link TableCell.setBorder} takes it — the write-side mirror of\n * {@link CellBorder}, which is what reading one gives back.\n *\n * Deliberately not `CellBorder` itself: that type reports every field, `null` included, so\n * passing one back would make \"leave this alone\" unsayable. Here an omitted field is simply\n * not written, which is what an edit usually means.\n */\nexport interface TableCellBorderEdit {\n\t/** Border width in points; omitted leaves `@w` unset, which renders as a hairline. */\n\twidthPt?: number | null\n\t/** Dash preset (`a:prstDash/@val`, e.g. `sysDash`); omitted leaves the border solid. */\n\tdash?: string\n\t/** Explicit colour as 6-hex (`#` optional). Ignored when {@link schemeColor} is given. */\n\tcolor?: string\n\t/** Theme colour token (e.g. `accent1`); preferred over {@link color} when both are set. */\n\tschemeColor?: string\n\t/** Write an explicit `a:noFill` — a deliberately suppressed edge, not an absent one. */\n\tnoFill?: boolean\n}\n\n/**\n * The context a cell needs to resolve its style-graph fill: the table's resolved\n * `a:tblStyle`, its condition flags, and the grid dimensions. Threaded from\n * {@link Table} down to each {@link TableCell} alongside the cell's own position.\n * `null` when the table references no resolvable style.\n */\nexport interface TableCellStyleContext {\n\tstyle: ResolvedTableStyle\n\tflags: TableConditionFlags\n\trowCount: number\n\tcolCount: number\n\tctx: ThemeContext\n}\n\n/**\n * One edge border of a table cell (`a:tcPr/a:lnL|lnR|lnT|lnB|lnTlToBr|lnBlToTr`).\n * Mirrors the `a:ln`-style decode used for shape strokes: {@link widthPt} from\n * `@w` (EMU → points), {@link dash} from `a:prstDash/@val`, and the stroke colour as a\n * {@link ColorRef} — the cell-border counterpart of a shape's line accessors.\n */\nexport interface CellBorder {\n\t/** Border width in points (`@w` is EMU; 12700 EMU = 1pt), or `null` when unset. */\n\twidthPt: number | null\n\t/** Dash style (`a:prstDash/@val`, e.g. `solid`/`sysDash`), or `null` when unset. */\n\tdash: string | null\n\t/**\n\t * The stroke's solid colour, as written and resolved against the slide theme; every field is\n\t * `null` when the edge carries no solid fill. `resolved.effectiveHex` is what a renderer paints,\n\t * and `resolved.transforms` is what to carry when re-authoring a border against a different\n\t * theme: a `lumMod`-darkened accent carried forward as a literal hex stops tracking its theme.\n\t */\n\tcolorRef: ColorRef\n\t/** `true` when the edge is an explicit no-border (`a:noFill`) — a deliberately suppressed side. */\n\tnoFill: boolean\n}\n\n/**\n * A table cell's six possible borders, keyed by edge. Each side is `null` when the\n * cell defines no line for it; the diagonals ({@link tlToBr} `╲`, {@link blToTr} `╱`)\n * are rarely authored. The whole object is `null` when the cell carries no border\n * element at all (see {@link TableCell.borders}).\n */\nexport interface CellBorders {\n\tleft: CellBorder | null\n\tright: CellBorder | null\n\ttop: CellBorder | null\n\tbottom: CellBorder | null\n\ttlToBr: CellBorder | null\n\tblToTr: CellBorder | null\n}\n\n/**\n * A table cell's 3-D bevel (`a:tcPr/a:cell3D`), as read back. Every field is `null` when the\n * source leaves it to the schema default, so a reader can tell \"PowerPoint wrote `circle`\"\n * from \"PowerPoint wrote nothing and `circle` is what it means\".\n */\nexport interface CellThreeD {\n\t/** `a:cell3D/@prstMaterial` (`ST_PresetMaterialType`), or `null` when unset. */\n\tmaterial: string | null\n\t/** The required `a:bevel`. Present whenever the cell has a `a:cell3D` at all. */\n\tbevel: {\n\t\t/** `a:bevel/@prst` (`ST_BevelPresetType`), or `null` when unset. */\n\t\tpreset: string | null\n\t\t/** `a:bevel/@w` converted from EMU to points, or `null` when unset. */\n\t\twidthPt: number | null\n\t\t/** `a:bevel/@h` converted from EMU to points, or `null` when unset. */\n\t\theightPt: number | null\n\t}\n\t/** `a:cell3D/a:lightRig`, or `null` when the cell leaves lighting to the renderer. */\n\tlightRig: { rig: string | null; dir: string | null } | null\n}\n\n/** One table cell (`a:tc`). */\nexport class TableCell {\n\tconstructor(\n\t\tprivate readonly tc: Element,\n\t\tprivate readonly part: Part,\n\t\t/** The owning slide's theme colour context, threaded to the cell's text for `Run.resolvedColor`. */\n\t\tprivate readonly themeContext: ThemeContext,\n\t\t/** The table's style-resolution context, for the {@link resolvedFill} style-graph fallback; `null` when no style resolves. */\n\t\tprivate readonly style: TableCellStyleContext | null,\n\t\t/** This cell's zero-based row index in the table. */\n\t\tprivate readonly rowIndex: number,\n\t\t/** This cell's zero-based column index in its row. */\n\t\tprivate readonly colIndex: number,\n\t\t/** The owning slide's relationships, for resolving {@link pictureFill}'s `r:embed` to a partname. */\n\t\tprivate readonly rels: Relationships\n\t) {}\n\n\t/**\n\t * The cell's text frame (`a:txBody`); `null` only if the cell has none (non-conformant).\n\t *\n\t * A run that sets nothing of its own resolves the way PowerPoint paints it\n\t * (`test/read/fixtures/table-text-inheritance.pptx`). Its colour, face, bold and italic come\n\t * first from the table style's text style for the cell's region, and a colour or face no part\n\t * states is the theme's `tx1` and minor font, with no table style at all as much as with one.\n\t * Below that, the chain a text box's runs walk bottoms out in the slide master's\n\t * `p:otherStyle` rather than in `p:defaultTextStyle`, which cell text never reads. So size comes\n\t * from `p:otherStyle`, and so do bold and italic where the table style says nothing.\n\t */\n\tget textFrame(): TextFrame | null {\n\t\tconst txBody = firstChild(this.tc, 'a:txBody')\n\t\tif (!txBody) return null\n\t\tconst ctx = this.themeContext\n\t\tconst txStyles = ctx.masterRoot ? firstChild(ctx.masterRoot, 'p:txStyles') : null\n\t\tconst styled = this.style ? this.#styleText() : null\n\t\tconst tx1 = resolveSchemeToken('tx1', ctx)\n\t\tconst tableText = {\n\t\t\tcolor: styled?.color ?? (tx1 ? { hex: tx1, transforms: [], effectiveHex: tx1 } : null),\n\t\t\tface: styled?.face ?? resolveThemeFont('+mn-lt', ctx.fontScheme ?? null),\n\t\t\tbold: styled?.bold ?? null,\n\t\t\titalic: styled?.italic ?? null,\n\t\t}\n\t\t// The cell's own relationships, so a run's `<a:hlinkClick r:id>` resolves to a url the same\n\t\t// way the identical run in a text box on this slide does.\n\t\treturn new TextFrame(txBody, {\n\t\t\tpart: this.part,\n\t\t\tctx: { ...ctx, defaultTextStyle: txStyles ? firstChild(txStyles, 'p:otherStyle') : null },\n\t\t\trels: this.rels,\n\t\t\tinherit: { ph: null, fontRef: null, tableText },\n\t\t})\n\t}\n\n\t/** The text style this cell takes from the table style graph. */\n\t#styleText(): TableCellTextStyle | null {\n\t\tconst s = this.style\n\t\tif (!s) return null\n\t\treturn resolveTableCellTextStyle(\n\t\t\ts.style.element_,\n\t\t\ts.flags,\n\t\t\tthis.rowIndex,\n\t\t\tthis.colIndex,\n\t\t\ts.rowCount,\n\t\t\ts.colCount,\n\t\t\ts.ctx\n\t\t)\n\t}\n\n\t/** The cell's text, paragraphs joined by `\\n`. */\n\tget text(): string {\n\t\treturn this.textFrame?.text ?? ''\n\t}\n\n\t/**\n\t * Replace the cell's text with a single paragraph and run, preserving the\n\t * formatting (`a:rPr`) of the cell's first existing run when there is one.\n\t * For finer control (multiple runs, per-run formatting), edit\n\t * `textFrame.paragraphs[].runs[]` directly.\n\t */\n\tset text(value: string) {\n\t\tconst txBody = firstChild(this.tc, 'a:txBody')\n\t\tif (!txBody) throw new PackageReadError('table/cell-has-no-text-body', 'Table cell has no a:txBody to set text on')\n\t\tsetTextBodyText(txBody, value)\n\t\tthis.part.markDirty()\n\t}\n\n\t/** The cell's properties element (`a:tcPr`), or `null` when the cell defines none. */\n\t#tcPr(): Element | null {\n\t\treturn firstChild(this.tc, 'a:tcPr')\n\t}\n\n\t/**\n\t * The cell's `a:tcPr`, creating it when absent.\n\t *\n\t * `CT_TableCell` sequences `a:txBody` then `a:tcPr` then `a:extLst`, so a newly created\n\t * one is inserted before `a:extLst` — appending it blindly would put it after and make\n\t * the part invalid. Every setter below goes through here for that reason.\n\t */\n\t#getOrAddTcPr(): Element {\n\t\treturn getOrAddChild(this.tc, 'a:tcPr', ['a:extLst'])\n\t}\n\n\t/**\n\t * Set (or clear) the cell's vertical text anchor (`a:tcPr/@anchor`).\n\t * `null` removes the attribute, leaving PowerPoint's default of top.\n\t * @throws {InvalidOptionError} when the value is outside `ST_TextAnchoringType`\n\t */\n\tsetAnchor(value: string | null): void {\n\t\tthis.#setTcPrAttr('anchor', value, ANCHOR_VALUES, 'table/invalid-cell-anchor')\n\t}\n\n\t/**\n\t * Set (or clear) the cell's text direction (`a:tcPr/@vert`), e.g. `'vert270'`.\n\t * `null` removes the attribute, leaving the default horizontal text.\n\t * @throws {InvalidOptionError} when the value is outside `ST_TextVerticalType`\n\t */\n\tsetVerticalText(value: string | null): void {\n\t\tthis.#setTcPrAttr('vert', value, VERT_VALUES, 'table/invalid-cell-vert')\n\t}\n\n\t/**\n\t * Set (or clear) `a:tcPr/@horzOverflow` — what a single glyph too wide for the cell does.\n\t * `null` removes the attribute; so does `'clip'` in effect, since it is the schema\n\t * default, but the attribute is still written as asked.\n\t * @throws {InvalidOptionError} when the value is outside `ST_TextHorzOverflowType`\n\t */\n\tsetHorzOverflow(value: string | null): void {\n\t\tthis.#setTcPrAttr('horzOverflow', value, HORZ_OVERFLOW_VALUES, 'table/invalid-cell-overflow')\n\t}\n\n\t/**\n\t * Centre the cell's text block horizontally, or stop doing so (`a:tcPr/@anchorCtr`).\n\t * `false` removes the attribute rather than writing `\"0\"`, since `false` is the schema\n\t * default and the two are indistinguishable to a renderer.\n\t */\n\tsetAnchorCtr(value: boolean): void {\n\t\tconst tcPr = this.#getOrAddTcPr()\n\t\tif (value) setAttr(tcPr, 'anchorCtr', '1')\n\t\telse removeAttr(tcPr, 'anchorCtr')\n\t\tthis.part.markDirty()\n\t}\n\n\t/**\n\t * Set the cell's text insets in EMU (`a:tcPr/@marL`/`@marR`/`@marT`/`@marB`).\n\t *\n\t * Partial: only the sides named are touched, so `{ left: 0 }` flushes the text left and\n\t * leaves the other three alone. A side given as `null` has its attribute removed, which\n\t * returns it to the schema default (91440 EMU left/right, 45720 top/bottom) — not to\n\t * zero. Pass `{}` to change nothing.\n\t * @throws {InvalidOptionError} when a value is not a finite number\n\t */\n\tsetMarginsEmu(margins: {\n\t\tleft?: number | null\n\t\tright?: number | null\n\t\ttop?: number | null\n\t\tbottom?: number | null\n\t}): void {\n\t\tconst tcPr = this.#getOrAddTcPr()\n\t\tconst sides = [\n\t\t\t['marL', margins.left],\n\t\t\t['marR', margins.right],\n\t\t\t['marT', margins.top],\n\t\t\t['marB', margins.bottom],\n\t\t] as const\n\t\tfor (const [name, value] of sides) {\n\t\t\tif (value === undefined) continue\n\t\t\tif (value === null) removeAttr(tcPr, name)\n\t\t\telse setAttr(tcPr, name, String(checkFiniteEmu(value, name, 'table/invalid-cell-margin')))\n\t\t}\n\t\tthis.part.markDirty()\n\t}\n\n\t/**\n\t * Set (or clear) one of the cell's six borders — the four edges and the two diagonals.\n\t *\n\t * `null` removes the element entirely, which is \"inherit\", and is a different thing from\n\t * `{ noFill: true }`, which writes an explicit no-border and suppresses whatever would\n\t * otherwise be inherited. The element is inserted at its schema position rather than\n\t * appended: `CT_TableCellProperties` is a sequence, and an out-of-order `a:tcPr` is\n\t * reported by PowerPoint as a corrupt file rather than as a bad edit.\n\t *\n\t * Colour is either `color` (6-hex, `#` optional) or `schemeColor` (a theme token); giving\n\t * both prefers the token, matching how the read side reports them.\n\t * @throws {InvalidOptionError} when the width or colour cannot be written\n\t */\n\tsetBorder(edge: TableCellEdge, border: TableCellBorderEdit | null): void {\n\t\tconst qname = EDGE_QNAMES[edge]\n\t\tif (!qname) {\n\t\t\tthrow new InvalidOptionError(\n\t\t\t\t'table/invalid-cell-border',\n\t\t\t\t`Unknown table cell edge: ${JSON.stringify(edge)}. Expected one of: ${Object.keys(EDGE_QNAMES).join(', ')}.`\n\t\t\t)\n\t\t}\n\t\tif (border === null) {\n\t\t\tconst tcPr = this.#tcPr()\n\t\t\tif (!tcPr || !firstChild(tcPr, qname)) return\n\t\t\tremoveChildrenByQName(tcPr, [qname])\n\t\t\tthis.part.markDirty()\n\t\t\treturn\n\t\t}\n\n\t\t// Every value is checked before the cell is touched, so a refused border leaves the old one.\n\t\tconst width =\n\t\t\tborder.widthPt !== undefined && border.widthPt !== null\n\t\t\t\t? checkLineWidthEmu(border.widthPt * EMU_PER_POINT, 'widthPt', 'table/invalid-cell-border')\n\t\t\t\t: null\n\t\tconst scheme = !border.noFill && border.schemeColor ? schemeToken(border.schemeColor) : null\n\t\tconst hex = !border.noFill && !scheme && border.color ? normalizeHex(border.color) : null\n\t\tconst dash = border.dash\n\t\t\t? checkEnumOrThrow(border.dash, PRESET_LINE_DASHES, 'border dash', 'table/invalid-cell-border')\n\t\t\t: null\n\n\t\tconst tcPr = this.#getOrAddTcPr()\n\t\t// Rebuilt rather than patched in place: a half-edited `a:ln` (say, a new colour left\n\t\t// beside a stale `a:noFill`) is a state neither the reader nor PowerPoint expects, and\n\t\t// the element is small enough that replacing it is simpler than reconciling it.\n\t\tremoveChildrenByQName(tcPr, [qname])\n\t\tconst doc = ownerDocumentOf(tcPr)\n\t\tconst ln = createElement(doc, qname)\n\t\tif (width !== null) setAttr(ln, 'w', String(width))\n\t\tif (border.noFill) {\n\t\t\tln.appendChild(createElement(doc, 'a:noFill'))\n\t\t} else if (scheme || hex) {\n\t\t\tconst fill = createElement(doc, 'a:solidFill')\n\t\t\tconst clr = createElement(doc, scheme ? 'a:schemeClr' : 'a:srgbClr')\n\t\t\tsetAttr(clr, 'val', scheme ?? hex ?? '')\n\t\t\tfill.appendChild(clr)\n\t\t\tln.appendChild(fill)\n\t\t}\n\t\t// `a:prstDash` follows the fill group in CT_LineProperties, so it is appended after.\n\t\tif (dash) {\n\t\t\tconst prstDash = createElement(doc, 'a:prstDash')\n\t\t\tsetAttr(prstDash, 'val', dash)\n\t\t\tln.appendChild(prstDash)\n\t\t}\n\t\tinsertTcPrChild(tcPr, qname, ln)\n\t\tthis.part.markDirty()\n\t}\n\n\t/**\n\t * Replace the cell's fill with a solid colour (`a:tcPr/a:solidFill`), or clear it.\n\t *\n\t * `null` removes the `a:solidFill` and lets the cell inherit from the table style again.\n\t * That is not the same as {@link noFill}, which writes an explicit `a:noFill` and so\n\t * suppresses the inherited shading. Any competing fill choice (`a:gradFill`,\n\t * `a:blipFill`, …) is dropped first — `EG_FillProperties` admits one.\n\t * @throws {InvalidOptionError} when `color` is not a 6-digit hex string\n\t */\n\tsetFillColor(color: string | null): void {\n\t\tthis.#applyFill(color === null ? null : { hex: color })\n\t}\n\n\t/**\n\t * Replace the cell's fill with a theme colour token (`a:solidFill/a:schemeClr/@val`), or\n\t * clear it. Preferred over {@link setFillColor} when the deck's theme should keep\n\t * driving the colour.\n\t */\n\tsetFillSchemeColor(token: string | null): void {\n\t\tthis.#applyFill(token === null ? null : { scheme: token })\n\t}\n\n\t/**\n\t * Write an explicit `<a:noFill/>` on the cell — a transparent cell that shows the table\n\t * background (or the slide) through. Distinct from `setFillColor(null)`, which removes\n\t * the fill and lets the table style's shading apply again.\n\t */\n\tnoFill(): void {\n\t\tif (applyNoFill(this.#tcPr(), () => this.#getOrAddTcPr(), TCPR_AFTER['a:noFill'] ?? [])) this.part.markDirty()\n\t}\n\n\t/** Set or clear one `a:tcPr` attribute, vetting it against its schema enum first. */\n\t#setTcPrAttr(name: string, value: string | null, valid: readonly string[], code: InvalidOptionErrorCode): void {\n\t\tif (value === null) {\n\t\t\tconst tcPr = this.#tcPr()\n\t\t\tif (!tcPr) return\n\t\t\tremoveAttr(tcPr, name)\n\t\t\tthis.part.markDirty()\n\t\t\treturn\n\t\t}\n\t\tconst checked = checkEnum(value, valid, name, code)\n\t\tsetAttr(this.#getOrAddTcPr(), name, checked)\n\t\tthis.part.markDirty()\n\t}\n\n\t/** Replace (or remove) the cell's solid fill, keeping `EG_FillProperties` single-valued. */\n\t#applyFill(edit: SolidFillEdit | null): void {\n\t\tconst changed =\n\t\t\tedit === null\n\t\t\t\t? applySolidFill(this.#tcPr(), null)\n\t\t\t\t: applySolidFill(this.#tcPr(), edit, () => this.#getOrAddTcPr(), TCPR_AFTER['a:solidFill'] ?? [])\n\t\tif (changed) this.part.markDirty()\n\t}\n\n\t/**\n\t * The cell's solid fill resolved against the table's theme colour context to a\n\t * literal hex — the table-cell counterpart of\n\t * {@link AutoShape.resolvedFill}. The cell's own\n\t * `a:tcPr/a:solidFill` wins; when the cell defines none, this falls back to the\n\t * table **style** graph (the `firstRow`/banded/`wholeTbl` shading the\n\t * `a:tableStyleId` supplies — see {@link Table.resolvedStyle}), so a styled cell\n\t * with an empty `a:tcPr` reports the colour PowerPoint actually renders rather\n\t * than `null`.\n\t *\n\t * A cell that carries *some other* fill choice (`a:blipFill`/`a:gradFill`/\n\t * `a:pattFill`/`a:noFill`) overrides the style graph in PowerPoint, so this\n\t * reports `null` for one rather than falling through to the inherited shading —\n\t * the same guard {@link AutoShape.resolvedFill} applies to\n\t * the style matrix. Read {@link pictureFill} for an image-filled cell. Also\n\t * `null` when neither source yields a solid colour (an\n\t * unmapped token, an explicit style `a:noFill`). The returned\n\t * {@link ResolvedColor} carries `effectiveHex` (the base colour with its\n\t * `lumMod`/`lumOff`/… transforms applied) — read that for the final colour.\n\t */\n\tget resolvedFill(): ResolvedColor | null {\n\t\tif (this.hasOwnFill) return resolveSolidFillColor(this.#tcPr(), this.themeContext)\n\t\treturn this.style ? this.#styleFill() : null\n\t}\n\n\t/**\n\t * Whether the cell carries a fill of its **own** (`a:tcPr` holds an `EG_FillProperties`\n\t * child), as opposed to inheriting one from the table style's header/banding rules.\n\t *\n\t * This is the flag that disambiguates {@link resolvedFill}, which deliberately reports\n\t * either — it answers \"what colour does this cell render as\", and both sources are valid\n\t * answers to that. Anything that has to reproduce the cell rather than describe it needs\n\t * to know which: baking an inherited banding colour into a copy makes the copy look right\n\t * until someone changes its table style, and then nothing moves. `false` for a cell whose\n\t * `a:tcPr` is empty or absent, whatever the style graph would render it as.\n\t */\n\tget hasOwnFill(): boolean {\n\t\tconst tcPr = this.#tcPr()\n\t\treturn hasFillChoice(tcPr)\n\t}\n\n\t/**\n\t * `true` when the cell sets an explicit no-fill (`a:tcPr/a:noFill`) — a deliberately\n\t * transparent cell showing the table background (or the slide) through. The cell-side\n\t * counterpart of {@link AutoShape.fillNoFill}, and what\n\t * {@link noFill} writes.\n\t *\n\t * {@link hasOwnFill} is not this question: it is `true` for *any* `EG_FillProperties`\n\t * child, so on its own it cannot separate a suppressed fill from a gradient or an image\n\t * one — and every colour accessor ({@link resolvedFill}, {@link fillSchemeColor})\n\t * reports `null` for a no-fill cell exactly as it does for a\n\t * cell that inherits its shading from the table style. Deriving it as \"has a fill of its\n\t * own, and no accessor recognises it\" instead of reading it has two failure modes: it\n\t * folds `a:grpFill` in with `a:noFill`, and its meaning changes silently the day a\n\t * further fill kind gets an accessor. The two paint completely differently — an\n\t * inherited banding colour versus nothing at all — so a consumer that cannot tell them\n\t * apart paints a transparent cell in the style's shading.\n\t */\n\tget fillNoFill(): boolean {\n\t\tconst tcPr = this.#tcPr()\n\t\treturn !!tcPr && !!firstChild(tcPr, 'a:noFill')\n\t}\n\n\t/**\n\t * The cell's picture (image) fill (`a:tcPr/a:blipFill`), or `null` when the cell\n\t * is not image-filled. The cell counterpart of\n\t * {@link AutoShape.pictureFill}: {@link resolvedFill}\n\t * decodes only solid colours, so without this an image-filled cell is\n\t * indistinguishable from an empty one. Carries the embedded image\n\t * ({@link PictureFill.relId}/{@link PictureFill.partName}) plus the stretch/tile\n\t * geometry; {@link PictureFill.partName} needs the owning slide's relationships,\n\t * which a {@link Table} built without them cannot supply.\n\t */\n\tget pictureFill(): PictureFill | null {\n\t\tconst tcPr = this.#tcPr()\n\t\treturn tcPr ? readPictureFill(tcPr, this.rels) : null\n\t}\n\n\t/** The fill this cell inherits from the table style graph, or `null` when the style defines none for it. */\n\t#styleFill(): ResolvedColor | null {\n\t\tconst s = this.style\n\t\tif (!s) return null\n\t\treturn resolveTableCellStyleFill(\n\t\t\ts.style.element_,\n\t\t\ts.flags,\n\t\t\tthis.rowIndex,\n\t\t\tthis.colIndex,\n\t\t\ts.rowCount,\n\t\t\ts.colCount,\n\t\t\ts.ctx\n\t\t)\n\t}\n\n\t/**\n\t * The cell's gradient fill (`a:tcPr/a:gradFill`), or `null` when the cell is not\n\t * gradient-filled. The cell twin of {@link Table.gradientFill}, and needed for the same\n\t * reason {@link pictureFill} is: {@link resolvedFill} reports `null` for every non-solid\n\t * choice, so without this a gradient cell is indistinguishable from an unfilled one.\n\t */\n\tget gradientFill(): GradientFill | null {\n\t\tconst tcPr = this.#tcPr()\n\t\treturn tcPr ? readGradientFill(tcPr, this.themeContext) : null\n\t}\n\n\t/**\n\t * The cell's pattern (hatch) fill (`a:tcPr/a:pattFill`), or `null` when the cell is not\n\t * pattern-filled.\n\t */\n\tget patternFill(): PatternFill | null {\n\t\tconst tcPr = this.#tcPr()\n\t\treturn tcPr ? readPatternFill(tcPr, this.themeContext) : null\n\t}\n\n\t/**\n\t * The raw `schemeClr` token of the cell's solid fill (`a:tcPr/a:solidFill/a:schemeClr/@val`),\n\t * e.g. `accent1`/`bg1`, or `null` when the fill is absent or an explicit `srgbClr`.\n\t * The resolved literal is {@link resolvedFill}; this is the unresolved reference.\n\t */\n\tget fillSchemeColor(): string | null {\n\t\t// `#tcPr()` alone, as every sibling fill accessor reads it. `a:tc/a:solidFill` is a\n\t\t// location `CT_TableCell` does not permit, so the `?? this.tc` fallback was unreachable on\n\t\t// a well-formed deck and, on a malformed one, reported a scheme token that `resolvedFill`\n\t\t// and `hasOwnFill` both denied.\n\t\treturn solidFillColor(this.#tcPr(), 'a:schemeClr')\n\t}\n\n\t/**\n\t * The cell's edge borders (`a:tcPr/a:lnL|lnR|lnT|lnB|lnTlToBr|lnBlToTr`), or\n\t * `null` when the cell defines none. Each present edge decodes to a\n\t * {@link CellBorder} (width / dash / resolved colour + its raw token and transform\n\t * list / suppressed flag);\n\t * absent edges are `null`. Cell borders are the biggest visible table gap — a\n\t * replica built only from geometry and fill draws every cell edge-to-edge with\n\t * no rule, so this surfaces the per-side stroke the writer's `border` option emits.\n\t */\n\tget borders(): CellBorders | null {\n\t\tconst tcPr = this.#tcPr()\n\t\tif (!tcPr) return null\n\t\tconst decode = (qname: string): CellBorder | null => {\n\t\t\tconst ln = firstChild(tcPr, qname)\n\t\t\tif (!ln) return null\n\t\t\treturn readLineBasics(ln, this.themeContext)\n\t\t}\n\t\tconst borders: CellBorders = {\n\t\t\tleft: decode('a:lnL'),\n\t\t\tright: decode('a:lnR'),\n\t\t\ttop: decode('a:lnT'),\n\t\t\tbottom: decode('a:lnB'),\n\t\t\ttlToBr: decode('a:lnTlToBr'),\n\t\t\tblToTr: decode('a:lnBlToTr'),\n\t\t}\n\t\treturn Object.values(borders).some((b) => b !== null) ? borders : null\n\t}\n\n\t/**\n\t * The cell's text direction (`a:tcPr/@vert`), e.g. `vert270` for a bottom-to-top\n\t * vertical label, or `null` for default horizontal text.\n\t */\n\tget verticalText(): string | null {\n\t\tconst tcPr = this.#tcPr()\n\t\treturn (tcPr && attr(tcPr, 'vert')) ?? null\n\t}\n\n\t/**\n\t * The cell's vertical text anchor (`a:tcPr/@anchor`): `t`/`ctr`/`b` (top/middle/\n\t * bottom), or `null` when unset (PowerPoint defaults to top).\n\t */\n\tget anchor(): string | null {\n\t\tconst tcPr = this.#tcPr()\n\t\treturn (tcPr && attr(tcPr, 'anchor')) ?? null\n\t}\n\n\t/**\n\t * Whether the cell's whole text **block** is centred horizontally within it\n\t * (`a:tcPr/@anchorCtr`). `false` when unset — that is the schema default, and it is\n\t * what PowerPoint writes nothing for.\n\t *\n\t * Distinct from a paragraph's `align`, which decides where each *line* sits inside the\n\t * text block; this decides where the block sits inside the cell.\n\t */\n\tget anchorCtr(): boolean {\n\t\tconst tcPr = this.#tcPr()\n\t\treturn tcPr ? boolAttr(tcPr, 'anchorCtr') === true : false\n\t}\n\n\t/**\n\t * The cell's 3-D bevel (`a:tcPr/a:cell3D`), or `null` when it has none.\n\t *\n\t * `CT_Cell3D` requires an `a:bevel`, so a present `cell3D` always reports a bevel;\n\t * `lightRig` is `null` when the cell leaves the scene lighting to the renderer. Sizes are\n\t * reported in **points** (the attributes are EMU), matching how the write option takes them.\n\t */\n\tget cell3D(): CellThreeD | null {\n\t\tconst tcPr = this.#tcPr()\n\t\tconst cell3D = tcPr && firstChild(tcPr, 'a:cell3D')\n\t\tif (!cell3D) return null\n\t\tconst bevel = firstChild(cell3D, 'a:bevel')\n\t\tconst rig = firstChild(cell3D, 'a:lightRig')\n\t\tconst pts = (value: string | null): number | null => {\n\t\t\tconst emu = numberValue(value)\n\t\t\treturn ptFromEmu(emu)\n\t\t}\n\t\treturn {\n\t\t\tmaterial: attr(cell3D, 'prstMaterial') ?? null,\n\t\t\tbevel: {\n\t\t\t\tpreset: bevel ? (attr(bevel, 'prst') ?? null) : null,\n\t\t\t\twidthPt: bevel ? pts(attr(bevel, 'w')) : null,\n\t\t\t\theightPt: bevel ? pts(attr(bevel, 'h')) : null,\n\t\t\t},\n\t\t\tlightRig: rig ? { rig: attr(rig, 'rig') ?? null, dir: attr(rig, 'dir') ?? null } : null,\n\t\t}\n\t}\n\n\t/**\n\t * The cell's unique identifier (`a:tc/@id`), or `null` when it has none.\n\t *\n\t * This is what {@link headerIds} references: a data cell names the header cells that\n\t * govern it by their `@id`, which is how a complex table tells a screen reader what a\n\t * value means. Unrelated to the shape-level `p:cNvPr/@id` — it is an `xs:string` scoped\n\t * to the table, not a slide-wide numeric id.\n\t *\n\t * **PowerPoint does not write this and strips it on save**, so it will read `null` on\n\t * any deck PowerPoint has saved, however it was produced. It is surfaced for decks from\n\t * other producers. There is deliberately no write-API counterpart — see\n\t * `test/read/fixtures/authoring/probe-table-cell-a11y-and-3d.ps1` for the measurement.\n\t */\n\tget id(): string | null {\n\t\treturn attr(this.tc, 'id') ?? null\n\t}\n\n\t/**\n\t * The `@id`s of the header cells that govern this cell\n\t * (`a:tcPr/a:headers/a:header/@val`), in document order. Empty when the cell declares no\n\t * header association — which is the common case, since only a complex table needs one.\n\t *\n\t * Carries the same caveat as {@link id}: PowerPoint strips `a:headers` on save, so this\n\t * is empty on any PowerPoint-saved deck. `Table.firstRowHeader` (`a:tblPr/@firstRow`) is\n\t * the header marker PowerPoint does keep.\n\t */\n\tget headerIds(): string[] {\n\t\tconst tcPr = this.#tcPr()\n\t\tconst headers = tcPr && firstChild(tcPr, 'a:headers')\n\t\tif (!headers) return []\n\t\treturn getElements(headers, 'a:header')\n\t\t\t.map((header) => attr(header, 'val'))\n\t\t\t.filter((val): val is string => val !== null && val !== '')\n\t}\n\n\t/**\n\t * How the cell treats a glyph too wide for its text width (`a:tcPr/@horzOverflow`):\n\t * `'clip'` cuts it at the cell edge, `'overflow'` lets it draw past. `null` when unset\n\t * (PowerPoint clips). Not a wrap flag — cell text always wraps to the column width.\n\t */\n\tget horzOverflow(): string | null {\n\t\tconst tcPr = this.#tcPr()\n\t\treturn (tcPr && attr(tcPr, 'horzOverflow')) ?? null\n\t}\n\n\t/**\n\t * The cell's text insets in EMU (`a:tcPr/@marL`/`@marR`/`@marT`/`@marB`), or\n\t * `null` when the cell sets none. Each side is `null` when only some are set.\n\t */\n\tget marginsEmu(): { left: number | null; right: number | null; top: number | null; bottom: number | null } | null {\n\t\tconst tcPr = this.#tcPr()\n\t\tif (!tcPr) return null\n\t\tconst left = numberValue(attr(tcPr, 'marL'))\n\t\tconst right = numberValue(attr(tcPr, 'marR'))\n\t\tconst top = numberValue(attr(tcPr, 'marT'))\n\t\tconst bottom = numberValue(attr(tcPr, 'marB'))\n\t\tif (left === null && right === null && top === null && bottom === null) return null\n\t\treturn { left, right, top, bottom }\n\t}\n\n\t/** Number of grid columns this cell spans (`a:tc/@gridSpan`), default 1. */\n\tget gridSpan(): number {\n\t\treturn numberValue(attr(this.tc, 'gridSpan')) ?? 1\n\t}\n\n\t/** Number of rows this cell spans (`a:tc/@rowSpan`), default 1. */\n\tget rowSpan(): number {\n\t\treturn numberValue(attr(this.tc, 'rowSpan')) ?? 1\n\t}\n\n\t/** Whether this cell is a continuation of a merge (`@hMerge` or `@vMerge`), i.e. not the merge origin. */\n\tget isMergeContinuation(): boolean {\n\t\treturn isHMerge(this.tc) || isVMerge(this.tc)\n\t}\n\n\t/** Escape hatch: the underlying `a:tc` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.tc\n\t}\n\n\t/** Mark the owning part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.part.markDirty()\n\t}\n}\n","/**\n * The `TableRow` read/edit proxy (`a:tr`).\n *\n * A row is a thin walk: its cells, its height, and the two escape hatches. It is its own file\n * only because it sits between the other two in the chain `Table -> TableRow -> TableCell`,\n * and a chain is what keeps the three modules acyclic.\n */\nimport type { Part } from '../opc/part.js'\nimport type { Relationships } from '../opc/relationships.js'\nimport { attr, type Element, getElements, numberValue } from '../oxml/dom.js'\nimport type { ThemeContext } from '../oxml/theme.js'\nimport { TableCell, type TableCellStyleContext } from './table-cell.js'\n/** One table row (`a:tr`). */\nexport class TableRow {\n\tconstructor(\n\t\tprivate readonly tr: Element,\n\t\tprivate readonly part: Part,\n\t\t/** The owning slide's theme colour context, threaded to each {@link TableCell}. */\n\t\tprivate readonly themeContext: ThemeContext,\n\t\t/** The table's style-resolution context, threaded to each cell for {@link TableCell.resolvedFill}; `null` when no style resolves. */\n\t\tprivate readonly style: TableCellStyleContext | null,\n\t\t/** This row's zero-based index in the table, for style-graph banding/edge conditions. */\n\t\tprivate readonly rowIndex: number,\n\t\t/** The owning slide's relationships, threaded to each cell for {@link TableCell.pictureFill}. */\n\t\tprivate readonly rels: Relationships\n\t) {}\n\n\t/** The row's cells (`a:tc`) in left-to-right order. */\n\tget cells(): TableCell[] {\n\t\treturn getElements(this.tr, 'a:tc').map(\n\t\t\t(tc, colIndex) => new TableCell(tc, this.part, this.themeContext, this.style, this.rowIndex, colIndex, this.rels)\n\t\t)\n\t}\n\n\t/** Row height in EMU (`a:tr/@h`), or `null` if unset. */\n\tget heightEmu(): number | null {\n\t\treturn numberValue(attr(this.tr, 'h'))\n\t}\n\n\t/** Escape hatch: the underlying `a:tr` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.tr\n\t}\n\n\t/** Mark the owning part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.part.markDirty()\n\t}\n}\n","/**\n * The `Table` read/edit proxy (`a:tbl`) hosted in a `p:graphicFrame`, and the barrel the rest\n * of the tree imports the table surface through.\n *\n * `Table -> TableRow[] -> TableCell[]`, each wrapping a live DOM element and holding the\n * owning slide `Part` so edits mutate the node in place and call `part.markDirty()`. Cell text\n * reuses the `TextFrame`/`Paragraph`/`Run` proxies, so per-run formatting edits work exactly\n * as on a shape's text.\n *\n * The three classes share no state, so they are three files; this one re-exports the other two\n * and the cell value types, keeping `read.ts`'s import surface exactly as it was.\n */\nimport type { OpcPackage } from '../opc/package.js'\nimport type { Part } from '../opc/part.js'\nimport type { Relationships } from '../opc/relationships.js'\nimport { attr, boolAttr, type Element, firstChild, getElements, numberValue } from '../oxml/dom.js'\nimport { hasFillChoice, solidFillColor } from '../oxml/fill.js'\nimport { insertColumn, insertRow, mergeCells, removeColumn, removeRow, rowsOf, unmergeCell } from './table-structure.js'\nimport type { ThemeContext } from '../oxml/theme.js'\nimport { readPictureFill, type PictureFill } from './picture-fill.js'\nimport { readGradientFill, type GradientFill } from './gradient.js'\nimport { readPatternFill, type PatternFill } from './pattern-fill.js'\nimport { resolveTableStyle, type ResolvedTableStyle } from './table-style-resolve.js'\nimport { resolveSolidFillColor, type ResolvedColor } from './theme-context.js'\nimport { TableRow } from './table-row.js'\nimport { TableCell, type TableCellStyleContext } from './table-cell.js'\n/** A table: a grid of rows and cells inside a graphic frame. */\nexport class Table {\n\tconstructor(\n\t\tprivate readonly tbl: Element,\n\t\tprivate readonly part: Part,\n\t\t/** The owning slide's theme colour context, threaded to each cell's text for `Run.resolvedColor`. */\n\t\tprivate readonly themeContext: ThemeContext,\n\t\t/** The deck package, for resolving `a:tableStyleId` against `tableStyles.xml` (style-graph cell fills). */\n\t\tprivate readonly opc: OpcPackage,\n\t\t/** The owning slide's relationships, for resolving a cell picture fill's `r:embed` to a partname. */\n\t\tprivate readonly rels: Relationships\n\t) {}\n\n\t/** The table's rows (`a:tr`) in document (top-to-bottom) order. */\n\tget rows(): TableRow[] {\n\t\tconst style = this.#styleContext()\n\t\treturn getElements(this.tbl, 'a:tr').map(\n\t\t\t(tr, rowIndex) => new TableRow(tr, this.part, this.themeContext, style, rowIndex, this.rels)\n\t\t)\n\t}\n\n\t/**\n\t * The table's style graph entry (`styleId`, `name`, raw `a:tblStyle`) resolved\n\t * from the deck's `tableStyles.xml`, or `null` when the table names no\n\t * `a:tableStyleId`, the deck has no `tableStyles.xml`, or the id is a built-in\n\t * `[MS-OE376]` style the deck does not materialise. This is what supplies the\n\t * banded-row / header shading a cell with no own fill inherits — read the\n\t * resolved per-cell colour off {@link TableCell.resolvedFill}.\n\t *\n\t * Resolved afresh on every read, not through the per-instance memo the cells share, so an\n\t * edit made through the returned `element_` shows in the next read's `name`. A caller reads\n\t * this once per table; the memo exists for the per-cell path that reads it hundreds of times.\n\t */\n\tget resolvedStyle(): ResolvedTableStyle | null {\n\t\treturn resolveTableStyle(this.opc, this.styleId)\n\t}\n\n\t/**\n\t * The table's entry in the deck's `tableStyles.xml`, resolved once per instance.\n\t *\n\t * Resolving it means scanning the package for the table-styles part and then its\n\t * `a:tblStyle` list, and every cell needs the answer -- so reading a 20x8 table cell by\n\t * cell did it 160 times for one unchanging answer. The memo is scoped to this instance,\n\t * which is rebuilt on every `GraphicFrame.table` access, so it cannot outlive the deck\n\t * state it was resolved against.\n\t *\n\t * A flag rather than a `??=` on a nullable field: \"this table names no style\" is the\n\t * common answer and the expensive one to recompute, and `??=` would memoize every answer\n\t * except that one.\n\t */\n\t#resolvedStyle: ResolvedTableStyle | null = null\n\t#styleAsked = false\n\n\t/** The per-cell style-resolution context, or `null` when no style resolves. */\n\t#styleContext(): TableCellStyleContext | null {\n\t\tif (!this.#styleAsked) {\n\t\t\tthis.#resolvedStyle = resolveTableStyle(this.opc, this.styleId)\n\t\t\tthis.#styleAsked = true\n\t\t}\n\t\tconst style = this.#resolvedStyle\n\t\tif (!style) return null\n\t\treturn {\n\t\t\tstyle,\n\t\t\t// Through the public getters, so the six a caller reads and the six that decide which\n\t\t\t// style regions paint cannot come to disagree.\n\t\t\tflags: {\n\t\t\t\tfirstRow: this.firstRowHeader,\n\t\t\t\tlastRow: this.lastRowFooter,\n\t\t\t\tfirstCol: this.firstColumnHeader,\n\t\t\t\tlastCol: this.lastColumnFooter,\n\t\t\t\tbandRow: this.bandedRows,\n\t\t\t\tbandCol: this.bandedColumns,\n\t\t\t},\n\t\t\trowCount: this.rowCount,\n\t\t\tcolCount: this.columnCount,\n\t\t\tctx: this.themeContext,\n\t\t}\n\t}\n\n\t/** Number of rows (`a:tr`). */\n\tget rowCount(): number {\n\t\treturn getElements(this.tbl, 'a:tr').length\n\t}\n\n\t/** Number of grid columns (`a:tblGrid/a:gridCol`). */\n\tget columnCount(): number {\n\t\tconst grid = firstChild(this.tbl, 'a:tblGrid')\n\t\treturn grid ? getElements(grid, 'a:gridCol').length : 0\n\t}\n\n\t/** Column widths in EMU (`a:gridCol/@w`), one per grid column. */\n\tget columnWidths(): (number | null)[] {\n\t\tconst grid = firstChild(this.tbl, 'a:tblGrid')\n\t\tif (!grid) return []\n\t\treturn getElements(grid, 'a:gridCol').map((col) => numberValue(attr(col, 'w')))\n\t}\n\n\t/**\n\t * The table's style GUID (`a:tblPr/a:tableStyleId` text), e.g.\n\t * `{5940675A-B579-460E-94D1-54222C63F5DA}`, or `null` when the table carries no\n\t * `a:tableStyleId`. This is the reference into `ppt/tableStyles.xml` (or a\n\t * built-in `[MS-OE376]` style) that supplies the banded-row / header shading the\n\t * `firstRow`/`bandRow` flags activate — without it a replica loses the whole\n\t * table style, so it is the read counterpart of the writer's `tableStyle` option.\n\t */\n\tget styleId(): string | null {\n\t\tconst tblPr = firstChild(this.tbl, 'a:tblPr')\n\t\tconst idEl = tblPr && firstChild(tblPr, 'a:tableStyleId')\n\t\tconst id = idEl?.textContent?.trim()\n\t\treturn id ? id : null\n\t}\n\n\t/**\n\t * The table's own background (`a:tblPr` fill) resolved against the slide's theme colour\n\t * context to a literal hex, or `null` when the table carries no solid background.\n\t *\n\t * This is the table-level counterpart of {@link TableCell.resolvedFill}, and it is a\n\t * genuinely different thing from a cell fill: a `a:tblPr` fill sits *behind* the grid, so\n\t * a cell with no fill of its own shows it through. Reports `null` for a non-solid choice\n\t * (`a:blipFill`/`a:gradFill`/`a:pattFill`/`a:noFill`) — read {@link pictureFill} for an\n\t * image background.\n\t */\n\tget resolvedFill(): ResolvedColor | null {\n\t\tconst tblPr = firstChild(this.tbl, 'a:tblPr')\n\t\tif (!hasFillChoice(tblPr)) return null\n\t\treturn resolveSolidFillColor(tblPr, this.themeContext)\n\t}\n\n\t/**\n\t * The table's picture background (`a:tblPr/a:blipFill`), or `null` when the table is not\n\t * image-backed. The table-level twin of {@link TableCell.pictureFill}, and needed for the\n\t * same reason: {@link resolvedFill} decodes only solid colours, so without this an\n\t * image-backed table is indistinguishable from an unfilled one.\n\t */\n\tget pictureFill(): PictureFill | null {\n\t\tconst tblPr = firstChild(this.tbl, 'a:tblPr')\n\t\treturn tblPr ? readPictureFill(tblPr, this.rels) : null\n\t}\n\n\t/**\n\t * The table's gradient background (`a:tblPr/a:gradFill`), or `null` when it is not\n\t * gradient-filled. Needed for the same reason {@link pictureFill} is:\n\t * {@link resolvedFill} decodes only solid colours.\n\t */\n\tget gradientFill(): GradientFill | null {\n\t\tconst tblPr = firstChild(this.tbl, 'a:tblPr')\n\t\treturn tblPr ? readGradientFill(tblPr, this.themeContext) : null\n\t}\n\n\t/**\n\t * The table's pattern (hatch) background (`a:tblPr/a:pattFill`), or `null` when it is not\n\t * pattern-filled.\n\t */\n\tget patternFill(): PatternFill | null {\n\t\tconst tblPr = firstChild(this.tbl, 'a:tblPr')\n\t\treturn tblPr ? readPatternFill(tblPr, this.themeContext) : null\n\t}\n\n\t/**\n\t * The raw `schemeClr` token of the table's own background\n\t * (`a:tblPr/a:solidFill/a:schemeClr/@val`), or `null` for an absent or `srgbClr` fill.\n\t * {@link resolvedFill} is the literal it resolves to; this is the unresolved reference,\n\t * which is what a replica should carry so the copy still tracks its theme.\n\t */\n\tget fillSchemeColor(): string | null {\n\t\treturn solidFillColor(firstChild(this.tbl, 'a:tblPr'), 'a:schemeClr')\n\t}\n\n\t/**\n\t * Whether the first row is styled as a header (`a:tblPr/@firstRow`), which `addTable` writes\n\t * from `hasHeader`.\n\t *\n\t * This and the five below are PowerPoint's Table Style Options, the six flags that decide which\n\t * regions of the table style paint. Two of them were readable and four were not, although\n\t * {@link resolvedStyle} has always read all six to resolve a cell: `addTable` writes every one,\n\t * so a table read back and re-authored lost its footer row, its banded columns and its first\n\t * and last column emphasis with nothing to say so.\n\t */\n\tget firstRowHeader(): boolean {\n\t\treturn this.#tblPrFlag('firstRow')\n\t}\n\n\t/** Whether the last row is styled as a footer (`a:tblPr/@lastRow`), from `addTable`'s `hasFooter`. */\n\tget lastRowFooter(): boolean {\n\t\treturn this.#tblPrFlag('lastRow')\n\t}\n\n\t/** Whether rows are banded (`a:tblPr/@bandRow`), from `addTable`'s `hasBandedRows`. */\n\tget bandedRows(): boolean {\n\t\treturn this.#tblPrFlag('bandRow')\n\t}\n\n\t/** Whether columns are banded (`a:tblPr/@bandCol`), from `addTable`'s `hasBandedColumns`. */\n\tget bandedColumns(): boolean {\n\t\treturn this.#tblPrFlag('bandCol')\n\t}\n\n\t/** Whether the first column is emphasised (`a:tblPr/@firstCol`), from `addTable`'s `hasFirstColumn`. */\n\tget firstColumnHeader(): boolean {\n\t\treturn this.#tblPrFlag('firstCol')\n\t}\n\n\t/** Whether the last column is emphasised (`a:tblPr/@lastCol`), from `addTable`'s `hasLastColumn`. */\n\tget lastColumnFooter(): boolean {\n\t\treturn this.#tblPrFlag('lastCol')\n\t}\n\n\t/**\n\t * The cell at `(rowIndex, columnIndex)` (both zero-based), or `null` when out\n\t * of range. Column index counts `a:tc` elements in the row, so a cell that\n\t * spans columns (`gridSpan`) occupies a single index here.\n\t */\n\tcell(rowIndex: number, columnIndex: number): TableCell | null {\n\t\t// Indexed rather than `this.rows[r]?.cells[c]`: that built a `TableRow` for every row\n\t\t// and a `TableCell` for every cell of the one row asked for, so the natural\n\t\t// `for (r) for (c) cell(r, c)` loop over a 20x8 table allocated 3,000 objects and\n\t\t// resolved the table's style 160 times to hand back 160 cells.\n\t\tconst tr = getElements(this.tbl, 'a:tr')[rowIndex]\n\t\tconst tc = tr && getElements(tr, 'a:tc')[columnIndex]\n\t\tif (!tc) return null\n\t\treturn new TableCell(tc, this.part, this.themeContext, this.#styleContext(), rowIndex, columnIndex, this.rels)\n\t}\n\n\t/**\n\t * Insert a row, defaulting to the bottom of the table. Returns the new {@link TableRow}.\n\t *\n\t * The new row is auto-height (`a:tr/@h=\"0\"`) and its cells are empty. Inserting *through*\n\t * a vertical merge extends that merge rather than interrupting it: the span's origin\n\t * grows by a row and the new cell joins as a continuation, because an origin claiming\n\t * more rows than it has continuations is a table PowerPoint reports as corrupt.\n\t * @param {number} [index] - where to insert, `0`..`rowCount`; appended when omitted\n\t * @throws {InvalidOptionError} when `index` is outside that range\n\t */\n\taddRow(index?: number): TableRow {\n\t\tconst tr = insertRow(this.tbl, index)\n\t\tthis.part.markDirty()\n\t\treturn new TableRow(tr, this.part, this.themeContext, this.#styleContext(), rowsOf(this.tbl).indexOf(tr), this.rels)\n\t}\n\n\t/**\n\t * Remove the row at `index`, with its content.\n\t *\n\t * A cell in the row that *continues* a vertical merge shortens that merge. A cell that\n\t * *starts* one hands the region to its first continuation, which becomes the new origin —\n\t * the merged region survives one row shorter, and only the removed row's own text is lost.\n\t * @throws {InvalidOptionError} when `index` is out of range\n\t */\n\tremoveRow(index: number): void {\n\t\tremoveRow(this.tbl, index)\n\t\tthis.part.markDirty()\n\t}\n\n\t/**\n\t * Insert a column, defaulting to the right-hand end. Updates `a:tblGrid` **and** every\n\t * row, which is the pair that has to stay in step.\n\t *\n\t * The mirror of {@link addRow}'s merge case: inserting inside a horizontal merge widens\n\t * it instead of splitting it.\n\t * @param {number} [index] - where to insert, `0`..`columnCount`; appended when omitted\n\t * @param {number} [widthEmu] - the new column's width; defaults to 1 inch\n\t * @throws {InvalidOptionError} when `index` is outside that range\n\t */\n\taddColumn(index?: number, widthEmu?: number): void {\n\t\tinsertColumn(this.tbl, index, widthEmu)\n\t\tthis.part.markDirty()\n\t}\n\n\t/**\n\t * Remove the column at `index`, from `a:tblGrid` and from every row.\n\t *\n\t * Inside a horizontal merge the region narrows by one and keeps its content: a covered\n\t * cell is dropped rather than the origin. Elsewhere the column's cells go with it.\n\t * @throws {InvalidOptionError} when `index` is out of range\n\t */\n\tremoveColumn(index: number): void {\n\t\tremoveColumn(this.tbl, index)\n\t\tthis.part.markDirty()\n\t}\n\n\t/**\n\t * Merge the rectangle between two cell positions into one cell. The top-left cell keeps\n\t * its content; the rest become covered cells and are emptied, since a covered cell is\n\t * never rendered.\n\t *\n\t * A rectangle that cuts through an existing merge is **rejected**, not silently widened\n\t * to fit — the caller asked for a specific region, and quietly producing a different one\n\t * is how a layout ends up wrong with nothing to point at. Unmerge first.\n\t * @throws {InvalidOptionError} when an index is out of range, the range covers one cell,\n\t * or it partially overlaps an existing merge\n\t */\n\tmergeCells(row1: number, col1: number, row2: number, col2: number): void {\n\t\tmergeCells(this.tbl, row1, col1, row2, col2)\n\t\tthis.part.markDirty()\n\t}\n\n\t/**\n\t * Split the merged cell whose **origin** is `(row, col)` back into individual cells.\n\t * A no-op on a cell that is not merged; addressing a covered cell instead of the origin\n\t * throws, and the message names the origin to use.\n\t * @throws {InvalidOptionError} when an index is out of range or the cell is a covered cell\n\t */\n\tunmergeCell(row: number, col: number): void {\n\t\tunmergeCell(this.tbl, row, col)\n\t\tthis.part.markDirty()\n\t}\n\n\t/** Escape hatch: the underlying `a:tbl` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */\n\tget element_(): Element {\n\t\treturn this.tbl\n\t}\n\n\t/** Mark the owning part dirty so `save()` reserializes it. Call after mutating {@link element_}. */\n\tmarkDirty(): void {\n\t\tthis.part.markDirty()\n\t}\n\n\t#tblPrFlag(name: string): boolean {\n\t\tconst tblPr = firstChild(this.tbl, 'a:tblPr')\n\t\treturn tblPr ? boolAttr(tblPr, name) === true : false\n\t}\n}\n\nexport { TableRow } from './table-row.js'\nexport {\n\tTableCell,\n\ttype CellBorder,\n\ttype CellBorders,\n\ttype CellThreeD,\n\ttype TableCellBorderEdit,\n} from './table-cell.js'\n","/**\n * A graphic frame (`p:graphicFrame`) — the host element for a table, a chart, a chartEx\n * chart, or a SmartArt diagram.\n *\n * Which one it holds is told by the `a:graphicData/@uri`, so the accessors below each check\n * that URI before wrapping the payload. {@link GraphicFrame.graphicDataUri} reports it raw,\n * which is the only signal for the frames this library still does not model (OLE, ink):\n * without it a consumer cannot tell \"this frame holds content I cannot reach\" from \"this\n * frame holds a chart with nothing in it\", since every predicate answers `false` for both.\n */\n\nimport { OOXML_NS, attr, firstChild, getOrAddChild, type Element } from '../../oxml/dom.js'\nimport { TABLE_GRAPHIC_DATA_URI } from '../../../ooxml/namespaces.js'\nimport { relPart } from '../../opc/partnames.js'\nimport { Chart } from '../chart.js'\nimport { ChartEx } from '../chartex.js'\nimport { Diagram } from '../diagram.js'\nimport { Table } from '../table.js'\nimport { Shape } from './base.js'\nimport type { PaintSurface } from './oxml.js'\n\n/** A graphic frame (`p:graphicFrame`) — host for tables, charts and SmartArt diagrams. */\nexport class GraphicFrame extends Shape {\n\treadonly shapeType = 'graphicFrame' as const\n\n\tprotected override xfrm(): Element | null {\n\t\t// graphicFrame carries its own `p:xfrm` directly, not inside `p:spPr`.\n\t\treturn firstChild(this.element, 'p:xfrm')\n\t}\n\n\tprotected override getOrAddXfrm(): Element {\n\t\t// p:xfrm sits between p:nvGraphicFramePr and a:graphic.\n\t\treturn getOrAddChild(this.element, 'p:xfrm', ['a:graphic', 'p:extLst'])\n\t}\n\n\t// A graphicFrame has no p:spPr; its hosted table/chart carries its own fill\n\t// model, so the frame carries neither paint.\n\tprotected override paintSurface(): PaintSurface | null {\n\t\treturn null\n\t}\n\n\t/** Whether this frame hosts a table (`a:graphicData/@uri` is the table URI). */\n\tget hasTable(): boolean {\n\t\treturn this.#graphicDataUri() === TABLE_GRAPHIC_DATA_URI\n\t}\n\n\t/** Whether this frame hosts a classic chart (`a:graphicData/@uri` is the chart URI). */\n\tget hasChart(): boolean {\n\t\treturn this.#graphicDataUri() === OOXML_NS.c\n\t}\n\n\t/**\n\t * Whether this frame hosts a chartEx chart. Its `a:graphicData/@uri` is the `cx` namespace,\n\t * which the reference child (`cx:chart`) is also in.\n\t */\n\tget hasChartEx(): boolean {\n\t\treturn this.#graphicDataUri() === OOXML_NS.cx\n\t}\n\n\t/**\n\t * Whether this frame hosts a SmartArt diagram. Its `a:graphicData/@uri` is the `dgm`\n\t * namespace, and the payload under it is a `dgm:relIds` reference rather than the drawing.\n\t */\n\tget hasDiagram(): boolean {\n\t\treturn this.#graphicDataUri() === OOXML_NS.dgm\n\t}\n\n\t/**\n\t * The `a:graphicData/@uri` verbatim — the namespace naming what this frame hosts, or\n\t * `null` when the frame carries no `a:graphicData`.\n\t *\n\t * Every `has*` predicate is a comparison against this, so a frame whose URI matches none\n\t * of them is one the read model does not decode (an OLE object, an ink `p:contentPart`).\n\t * Reading the URI is what lets a consumer say *which* construct it could not reach\n\t * instead of inferring loss from four `false`s.\n\t */\n\tget graphicDataUri(): string | null {\n\t\treturn this.#graphicDataUri()\n\t}\n\n\t/** The hosted table, or `null` when this frame is not a table. */\n\tget table(): Table | null {\n\t\tif (!this.hasTable) return null\n\t\tconst graphicData = this.#graphicData()\n\t\tconst tbl = graphicData && firstChild(graphicData, 'a:tbl')\n\t\tif (!tbl) return null\n\t\treturn new Table(tbl, this.host.part, this.host.themeContext(), this.host.opc, this.host.relationships)\n\t}\n\n\t/** The hosted chart, or `null` when this frame is not a chart or its part is missing. */\n\tget chart(): Chart | null {\n\t\tif (!this.hasChart) return null\n\t\tconst graphicData = this.#graphicData()\n\t\tconst chartRef = graphicData && firstChild(graphicData, 'c:chart')\n\t\tconst relId = chartRef && attr(chartRef, 'r:id')\n\t\tif (!relId) return null\n\t\tconst part = relPart(this.host.opc, this.host.relationships, relId)\n\t\treturn part ? new Chart(part) : null\n\t}\n\n\t/**\n\t * The hosted chartEx chart (waterfall/funnel/treemap/…), or `null` when this\n\t * frame is not a chartEx chart or its part is missing. The reference child is\n\t * `cx:chart` (not the classic `c:chart`), carrying the MS `chartEx` rel id.\n\t */\n\tget chartEx(): ChartEx | null {\n\t\tif (!this.hasChartEx) return null\n\t\tconst graphicData = this.#graphicData()\n\t\tconst chartRef = graphicData && firstChild(graphicData, 'cx:chart')\n\t\tconst relId = chartRef && attr(chartRef, 'r:id')\n\t\tif (!relId) return null\n\t\tconst part = relPart(this.host.opc, this.host.relationships, relId)\n\t\treturn part ? new ChartEx(part) : null\n\t}\n\n\t/**\n\t * The hosted SmartArt diagram, or `null` when this frame is not a diagram or its data\n\t * part is missing. The payload child is `dgm:relIds`, which names four parts by\n\t * relationship id; the `@r:dm` one is the data model this resolves.\n\t */\n\tget diagram(): Diagram | null {\n\t\tif (!this.hasDiagram) return null\n\t\tconst graphicData = this.#graphicData()\n\t\tconst relIds = graphicData && firstChild(graphicData, 'dgm:relIds')\n\t\tif (!relIds) return null\n\t\tconst relId = attr(relIds, 'r:dm')\n\t\tif (!relId) return null\n\t\tconst part = relPart(this.host.opc, this.host.relationships, relId)\n\t\treturn part ? new Diagram(part, relIds, this.host.opc, this.host.relationships, this.host.themeContext()) : null\n\t}\n\n\t#graphicData(): Element | null {\n\t\tconst graphic = firstChild(this.element, 'a:graphic')\n\t\treturn graphic ? firstChild(graphic, 'a:graphicData') : null\n\t}\n\n\t#graphicDataUri(): string | null {\n\t\tconst graphicData = this.#graphicData()\n\t\treturn graphicData ? attr(graphicData, 'uri') : null\n\t}\n}\n","/**\n * Read-model proxies for the shapes in a `p:spTree`.\n *\n * The `p:spTree` holds five shape kinds; each wraps its element and exposes\n * non-visual identity (id/name), geometry (left/top/width/height in EMU), and\n * kind-specific reads. Proxies hold a back-reference to the owning\n * {@link ShapeHost} — the slide, layout, or master whose part carries the tree —\n * so pictures can resolve their image relationship and so edits can mark that\n * part dirty.\n *\n * This module is the entry point for that model: the `Shape` base and the four leaf kinds live in\n * `./shapes/`, and only the dispatch that turns an element into a proxy — plus `GroupShape`, which\n * recurses back through it — is here. Everything the read API surfaces is re-exported below, so\n * `pptx-ts/read` and its consumers keep importing shapes from one place.\n */\nimport { ELEMENT_NODE, OOXML_NS, firstChild, getElements, getOrAddChild, type Element } from '../oxml/dom.js'\nimport { GROUP_AFTER_GRPSPPR, GRPSPPR_AFTER_XFRM, GRPSPPR_FILL_AFTER, type PaintSurface } from './shapes/oxml.js'\nimport { readBox } from './shapes/geometry.js'\nimport type { ChildFrame } from './shapes/types.js'\nimport { Shape } from './shapes/base.js'\nimport { AutoShape } from './shapes/autoshape.js'\nimport { Picture } from './shapes/picture.js'\nimport { Connector } from './shapes/connector.js'\nimport { GraphicFrame } from './shapes/graphic-frame.js'\nimport type { ShapeHost } from './shapes/host.js'\n\nexport { Shape } from './shapes/base.js'\nexport type { ShapeHost } from './shapes/host.js'\nexport { AutoShape } from './shapes/autoshape.js'\nexport { Picture } from './shapes/picture.js'\nexport { Connector } from './shapes/connector.js'\nexport { GraphicFrame } from './shapes/graphic-frame.js'\n\n// Re-exported so `pptx-ts/read` keeps surfacing the gradient types from here even\n// though their definitions moved to ./gradient.js (shared with the slide-background reader).\nexport type { GradientStop, GradientFill } from './gradient.js'\nexport type { PictureFill, PictureFillTile, FillRect } from './picture-fill.js'\n// Likewise for the shape value types, whose definitions live in ./shapes/types.js.\nexport type {\n\tAbsoluteFrame,\n\tAbsoluteFrameFailure,\n\tChildFrame,\n\tConnectionSite,\n\tCustomGeometry,\n\tCustomGeometryPath,\n\tGeometryCommand,\n\tGlow,\n\tInnerShadow,\n\tLineEnd,\n\tLineEnds,\n\tOuterShadow,\n\tPatternFill,\n\tRecolor,\n\tReflection,\n\tShapeType,\n\tSoftEdge,\n} from './shapes/types.js'\n\n/**\n * A group shape (`p:grpSp`) — contains nested shapes.\n *\n * It is the one kind defined here rather than under `./shapes/`: its `shapes` getter recurses\n * through `buildShapes` below, so putting it in a sibling module would make the dispatch and the\n * group import each other.\n */\nexport class GroupShape extends Shape {\n\treadonly shapeType = 'group' as const\n\n\tprotected override xfrm(): Element | null {\n\t\tconst grpSpPr = firstChild(this.element, 'p:grpSpPr')\n\t\treturn grpSpPr ? firstChild(grpSpPr, 'a:xfrm') : null\n\t}\n\n\tprotected override getOrAddXfrm(): Element {\n\t\treturn getOrAddChild(this.#getOrAddGrpSpPr(), 'a:xfrm', GRPSPPR_AFTER_XFRM)\n\t}\n\n\tprotected override properties(): Element | null {\n\t\treturn firstChild(this.element, 'p:grpSpPr')\n\t}\n\n\t// A group's fill lives in p:grpSpPr, which has no a:ln, so it carries a fill and no line.\n\tprotected override paintSurface(): PaintSurface | null {\n\t\treturn { getOrAdd: () => this.#getOrAddGrpSpPr(), fill: GRPSPPR_FILL_AFTER, line: null }\n\t}\n\n\t#getOrAddGrpSpPr(): Element {\n\t\treturn getOrAddChild(this.element, 'p:grpSpPr', GROUP_AFTER_GRPSPPR)\n\t}\n\n\t/**\n\t * The group's own child coordinate space (`p:grpSpPr/a:xfrm/a:chOff` and\n\t * `a:chExt`) in EMU, or `null` when the group has no transform or either\n\t * element is incomplete.\n\t *\n\t * Most consumers should not need this: {@link Shape.absoluteFrame} already\n\t * composes the whole ancestor chain — child space, group flips and rotations —\n\t * and doing that arithmetic per consumer is how a shape in a nested group ends\n\t * up subtly displaced. It is here for a *replica* consumer rather than a\n\t * *paint* one: rebuilding this group and its children as OOXML needs the\n\t * source child space to reproduce the scaling, and without it only groups whose\n\t * child space is the identity can be rebuilt.\n\t */\n\tget childFrame(): ChildFrame | null {\n\t\tconst xfrm = this.xfrm()\n\t\tconst box = xfrm && readBox(xfrm, 'a:chOff', 'a:chExt')\n\t\tif (!box) return null\n\t\treturn { offsetX: box.x, offsetY: box.y, extentX: box.cx, extentY: box.cy }\n\t}\n\n\t/** The shapes nested directly inside this group, in document order. */\n\tget shapes(): AnyShape[] {\n\t\treturn buildShapes(this.element, this.host)\n\t}\n}\n\n/**\n * The concrete shape kinds as a discriminated union keyed on the\n * {@link Shape.shapeType} literal. The read API (`Slide.shapes`,\n * `Slide.shapeById`, `GroupShape.shapes`, `Presentation.importShape`, …) returns\n * this rather than the abstract {@link Shape} base, so a consumer can narrow to a\n * subtype by its discriminant and reach the subtype-only members — e.g.\n * `if (shape.shapeType === 'graphicFrame') shape.chart` or, equivalently, the\n * {@link isGraphicFrame} guard. The abstract {@link Shape} base is still exported\n * for the \"common members only\" case and for `instanceof` checks.\n */\nexport type AnyShape = AutoShape | Picture | Connector | GraphicFrame | GroupShape\n\n/** Narrow a shape to an {@link AutoShape} (`p:sp` — auto shape, text box, or placeholder). */\nexport function isAutoShape(shape: Shape): shape is AutoShape {\n\treturn shape.shapeType === 'autoShape'\n}\n\n/** Narrow a shape to a {@link Picture} (`p:pic`). */\nexport function isPicture(shape: Shape): shape is Picture {\n\treturn shape.shapeType === 'picture'\n}\n\n/** Narrow a shape to a {@link Connector} (`p:cxnSp`). */\nexport function isConnector(shape: Shape): shape is Connector {\n\treturn shape.shapeType === 'connector'\n}\n\n/** Narrow a shape to a {@link GraphicFrame} (`p:graphicFrame` — table/chart host). */\nexport function isGraphicFrame(shape: Shape): shape is GraphicFrame {\n\treturn shape.shapeType === 'graphicFrame'\n}\n\n/** Narrow a shape to a {@link GroupShape} (`p:grpSp`). */\nexport function isGroupShape(shape: Shape): shape is GroupShape {\n\treturn shape.shapeType === 'group'\n}\n\n/**\n * Wrap a single shape-tree element (`p:sp`/`p:pic`/`p:cxnSp`/`p:graphicFrame`/\n * `p:grpSp`) in its concrete `Shape` proxy, or `null` if it is not a shape kind\n * (e.g. `p:nvGrpSpPr`, `p:grpSpPr`, `p:extLst`).\n */\nexport function wrapShapeElement(element: Element, host: ShapeHost): AnyShape | null {\n\tif (element.namespaceURI !== OOXML_NS.p) return null\n\tswitch (element.localName) {\n\t\tcase 'sp':\n\t\t\treturn new AutoShape(element, host)\n\t\tcase 'pic':\n\t\t\treturn new Picture(element, host)\n\t\tcase 'cxnSp':\n\t\t\treturn new Connector(element, host)\n\t\tcase 'graphicFrame':\n\t\t\treturn new GraphicFrame(element, host)\n\t\tcase 'grpSp':\n\t\t\treturn new GroupShape(element, host)\n\t\tdefault:\n\t\t\treturn null\n\t}\n}\n\n/**\n * The richer of an `mc:AlternateContent`'s two branches: the first `mc:Choice`\n * that carries a shape element (what PowerPoint renders when it understands the\n * required feature), falling back to `mc:Fallback`. PowerPoint wraps a shape this\n * way when its full form needs a feature namespace a plain consumer lacks — a\n * chartEx chart's `p:graphicFrame`, a zoom frame, an inline-math shape. Returns\n * the wrapped inner shape, or `null` when neither branch holds one.\n */\nfunction unwrapAlternateContent(altContent: Element, host: ShapeHost): AnyShape | null {\n\tconst branches = [...getElements(altContent, 'mc:Choice'), ...getElements(altContent, 'mc:Fallback')]\n\tfor (const branch of branches) {\n\t\tfor (let node = branch.firstChild; node; node = node.nextSibling) {\n\t\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\t\tconst shape = wrapShapeElement(node as Element, host)\n\t\t\tif (shape) return shape\n\t\t}\n\t}\n\treturn null\n}\n\n/**\n * Build shape proxies for the shape-tree children of `parent` (a `p:spTree` or\n * `p:grpSp`), skipping non-shape children (`p:nvGrpSpPr`, `p:grpSpPr`, …). An\n * `mc:AlternateContent` wrapper (chartEx charts, zoom frames, inline math) is\n * unwrapped to the shape inside its preferred branch.\n */\nexport function buildShapes(parent: Element, host: ShapeHost): AnyShape[] {\n\tconst shapes: AnyShape[] = []\n\tfor (let node = parent.firstChild; node; node = node.nextSibling) {\n\t\tif (node.nodeType !== ELEMENT_NODE) continue\n\t\tconst element = node as Element\n\t\tif (element.namespaceURI === OOXML_NS.mc && element.localName === 'AlternateContent') {\n\t\t\tconst unwrapped = unwrapAlternateContent(element, host)\n\t\t\tif (unwrapped) shapes.push(unwrapped)\n\t\t\tcontinue\n\t\t}\n\t\tconst shape = wrapShapeElement(element, host)\n\t\tif (shape) shapes.push(shape)\n\t}\n\treturn shapes\n}\n\n/**\n * The first shape in `shapes` with the given drawing id (`p:cNvPr/@id`), walked\n * pre-order so a group is visited before its children. Backs\n * {@link ShapeHost.shapeByIdDeep} on all three hosts — drawing ids are unique\n * within a part, so the first match is the only match and the walk order just\n * fixes a deterministic one.\n */\nexport function findShapeByIdDeep(shapes: AnyShape[], id: number): AnyShape | undefined {\n\tfor (const shape of shapes) {\n\t\tif (shape.id === id) return shape\n\t\tif (shape instanceof GroupShape) {\n\t\t\tconst found = findShapeByIdDeep(shape.shapes, id)\n\t\t\tif (found) return found\n\t\t}\n\t}\n\treturn undefined\n}\n"],"mappings":";;;;;AA4BA,SAAgB,SAAS,KAAuB;CAC/C,OAAO,IAAI,UAAU,EAAE,SAAS,mBAAmB,CAAC,CAAC,CAAC,gBAAgB,KAAK,UAAU,QAAQ;AAC9F;;;;;;AAOA,SAAgB,aAAa,KAAuB;CACnD,OAAO,IAAI,cAAc,CAAC,CAAC,kB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