@pptx-studio/model 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/LICENSE +202 -0
- package/NOTICE +43 -0
- package/README.md +183 -0
- package/dist/index.d.ts +1340 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3042 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["boolOf","intOf","enumOf","intOf"],"sources":["../src/errors.ts","../src/types.ts","../src/parse/paint.ts","../src/parse/geometry.ts","../src/parse/body.ts","../src/text.ts","../src/parse/text.ts","../src/parse/sheet.ts","../src/resolve/placeholder.ts","../src/resolve/resolve.ts","../src/style.ts","../src/resolve/background.ts","../src/document.ts","../src/builtin-text-styles.ts","../src/resolve/typeface.ts","../src/resolve/text.ts","../src/resolve/body.ts"],"sourcesContent":["/**\n * Typed failures, as everywhere else in this repository.\n *\n * Two kinds of thing go wrong here and they want different treatment.\n *\n * A **broken package** - a slide that names no layout, a layout whose master is\n * missing, a master with no theme - is not a programming mistake. PowerPoint\n * repairs all three rather than refusing them (measured in 2.9, and after the\n * repair the binding is simply gone), and a viewer that throws on a file\n * PowerPoint opens is a viewer nobody can use. So those are *not* errors here:\n * the chain records what it found and `parent` is `null`. There is a code for\n * each all the same, because `validate` refuses to *write* one, and because a\n * caller that asks for the theme of a master that has none needs an answer with\n * a name.\n *\n * A **caller mistake** - resolving `phClr` outside a style invocation, asking\n * for a sheet that is not in the document - is an error and throws.\n */\nexport type ModelErrorCode =\n /** A part the chain needs is not in the package. */\n | 'MODEL_PART_MISSING'\n /** A part is present but its root element is not the one its rel promised. */\n | 'MODEL_PART_KIND'\n /** `ppt/presentation.xml` is missing, or the root rels do not name it. */\n | 'MODEL_NO_PRESENTATION'\n /** A slide has no `slideLayout` relationship, or a layout no `slideMaster`. */\n | 'MODEL_NO_PARENT'\n /** A master has no `theme` relationship. */\n | 'MODEL_NO_THEME'\n /** A `p:clrMap` or `a:overrideClrMapping` missing one of its twelve attributes. */\n | 'MODEL_CLRMAP_INCOMPLETE'\n /** A `p:clrMap` attribute naming something that is not one of the twelve slots. */\n | 'MODEL_CLRMAP_SLOT'\n /** A `p:ph/@idx` that is not a non-negative integer below 2^32. */\n | 'MODEL_PLACEHOLDER_IDX'\n /** An `a:off`/`a:ext`/`@rot` attribute that is not an integer. */\n | 'MODEL_XFRM_NUMBER'\n /** A style-matrix reference whose `@idx` does not parse. */\n | 'MODEL_STYLE_IDX'\n /** An `a:fontRef/@idx` outside `major`, `minor` and `none`. */\n | 'MODEL_FONT_COLLECTION'\n /** A theme with no `a:fmtScheme`, asked for a style-matrix entry. */\n | 'MODEL_NO_STYLE_MATRIX'\n /** A `a:fillStyleLst`/`a:lnStyleLst`/`a:bgFillStyleLst` with no entries at all. */\n | 'MODEL_STYLE_LIST_EMPTY'\n /** A sheet chain that returns to a sheet it has already visited. */\n | 'MODEL_SHEET_CYCLE'\n /** A sheet that does not belong to the document it was asked about. */\n | 'MODEL_FOREIGN_SHEET'\n /** `a:prstGeom` with no `@prst`, or an `a:custGeom` command missing a point. */\n | 'MODEL_GEOMETRY'\n /** A text attribute whose value is not of the type its schema names. */\n | 'MODEL_TEXT_ATTR'\n /** An `a:fld` with no `@id`, which is a required `ST_Guid`. */\n | 'MODEL_TEXT_FIELD'\n /**\n * A bullet that contradicts itself or omits what the schema requires.\n *\n * The four kinds are an exclusive group, `a:buAutoNum` must carry a @type and\n * `a:buBlip` must resolve to a relationship. A file that breaks one of those is\n * one PowerPoint would repair, and repairing it here quietly would hide which.\n */\n | 'MODEL_TEXT_BULLET'\n /** A paragraph level that is not an integer. */\n | 'MODEL_TEXT_LEVEL'\n | 'MODEL_TEXT_TYPEFACE'\n | 'BLIP_NO_EMBED'\n | 'BLIP_DUOTONE'\n | 'BLIP_CLR_CHANGE'\n | 'BLIP_TILE_ALIGN'\n | 'BLIP_TILE_FLIP';\n\nexport class ModelError extends Error {\n override readonly name = 'ModelError';\n readonly code: ModelErrorCode;\n /** The part the failure is about, when there is one. */\n readonly partName: string | null;\n /** Whatever detail names the failure: an attribute value, a rel id, a slot. */\n readonly detail: string | null;\n\n constructor(\n code: ModelErrorCode,\n message: string,\n partName: string | null = null,\n detail: string | null = null,\n ) {\n super(message);\n this.code = code;\n this.partName = partName;\n this.detail = detail;\n }\n}\n\nexport function isModelError(value: unknown): value is ModelError {\n return value instanceof ModelError;\n}\n\nexport const MODEL_ERROR_CODES: readonly ModelErrorCode[] = [\n 'MODEL_PART_MISSING',\n 'MODEL_PART_KIND',\n 'MODEL_NO_PRESENTATION',\n 'MODEL_NO_PARENT',\n 'MODEL_NO_THEME',\n 'MODEL_CLRMAP_INCOMPLETE',\n 'MODEL_CLRMAP_SLOT',\n 'MODEL_PLACEHOLDER_IDX',\n 'MODEL_XFRM_NUMBER',\n 'MODEL_GEOMETRY',\n 'MODEL_STYLE_IDX',\n 'MODEL_FONT_COLLECTION',\n 'MODEL_NO_STYLE_MATRIX',\n 'MODEL_STYLE_LIST_EMPTY',\n 'MODEL_SHEET_CYCLE',\n 'MODEL_FOREIGN_SHEET',\n 'MODEL_TEXT_ATTR',\n 'MODEL_TEXT_FIELD',\n 'MODEL_TEXT_LEVEL',\n 'MODEL_TEXT_TYPEFACE',\n];\n","/**\n * The document model, and the one property that makes the whole product\n * possible: **`undefined` means \"this sheet did not say\".**\n *\n * Every visual property below is `T | undefined`, and absence is a fact the\n * file states rather than a gap to be filled in. PowerPoint writes a slide\n * placeholder with no `a:xfrm` at all - measured in 2.9 on its own output,\n * where a title that was typed into but not moved still has none, and one\n * nudged by a single point suddenly has the full resolved rectangle baked in -\n * so a parser that defaults geometry at parse time destroys the only record of\n * which shapes are still bound to their layout. That record is what Change\n * Layout reads, what the inspector's provenance chips read, and what tells a\n * theme swap which shapes to invalidate.\n *\n * So nothing here is resolved. `resolve.ts` walks the chain, `style.ts` reaches\n * the theme, and both report *where* the answer came from.\n */\n\nimport type { ClrMap, ClrScheme, Color, Effect, Fill, Line } from '@pptx-studio/paint';\nimport type { ShapeGeometry } from './parse/geometry.js';\nimport type { TextBody, TextStyles } from './text.js';\nimport type { XElement } from '@pptx-studio/xml';\n\n/* -------------------------------------------------------------------------- */\n/* geometry */\n/* -------------------------------------------------------------------------- */\n\n/** `a:off` and `a:ext` together, in EMU, plus the three transform attributes. */\nexport interface Xfrm {\n readonly x: number;\n readonly y: number;\n readonly cx: number;\n readonly cy: number;\n /** `@rot`, sixtieths of a degree. Zero when the attribute was absent. */\n readonly rot: number;\n readonly flipH: boolean;\n readonly flipV: boolean;\n /** `a:chOff`/`a:chExt`, present only on a group's `a:xfrm`. */\n readonly child: {\n readonly x: number;\n readonly y: number;\n readonly cx: number;\n readonly cy: number;\n } | null;\n}\n\n/* -------------------------------------------------------------------------- */\n/* placeholders */\n/* -------------------------------------------------------------------------- */\n\n/**\n * `ST_PlaceholderType`. All nineteen, as written.\n *\n * Not all nineteen are legal everywhere. A slide **master** accepts only\n * `title`, `body`, `dt`, `ftr`, `sldNum` and `hdr`: a master carrying\n * `ctrTitle`, `subTitle`, `obj` or `pic` is repaired on open, measured in 2.9.\n * That is not a curiosity - it is the reason the layout-to-master hop has to\n * fold `ctrTitle` into `title` and every content type into `body`, because\n * otherwise the stock \"Title and Content\" layout could inherit nothing from the\n * stock master.\n */\nexport type PlaceholderType =\n | 'title'\n | 'body'\n | 'ctrTitle'\n | 'subTitle'\n | 'obj'\n | 'chart'\n | 'tbl'\n | 'clipArt'\n | 'dgm'\n | 'media'\n | 'sldImg'\n | 'pic'\n | 'sldNum'\n | 'hdr'\n | 'ftr'\n | 'dt';\n\nexport const PLACEHOLDER_TYPES: readonly PlaceholderType[] = [\n 'title',\n 'body',\n 'ctrTitle',\n 'subTitle',\n 'obj',\n 'chart',\n 'tbl',\n 'clipArt',\n 'dgm',\n 'media',\n 'sldImg',\n 'pic',\n 'sldNum',\n 'hdr',\n 'ftr',\n 'dt',\n];\n\n/** The six a slide master may carry. Measured; see `PlaceholderType`. */\nexport const MASTER_PLACEHOLDER_TYPES: readonly PlaceholderType[] = [\n 'title',\n 'body',\n 'dt',\n 'ftr',\n 'sldNum',\n 'hdr',\n];\n\n/** `@sz`, a sizing hint. Recorded, and not part of matching - measured. */\nexport type PlaceholderSize = 'full' | 'half' | 'quarter';\n\nexport interface Placeholder {\n /**\n * `@type` as written, or `null` when the attribute was absent.\n *\n * `null` is kept rather than defaulted, because \"the file said `obj`\" and\n * \"the file said nothing\" are different facts and only the second one is safe\n * to rewrite. `normalizePlaceholder` supplies the default when a comparison\n * needs one.\n */\n readonly type: PlaceholderType | null;\n /** `@idx` as written, or `null` when absent. Defaults to 0 when compared. */\n readonly idx: number | null;\n readonly size: PlaceholderSize | null;\n /** `@orient`. Recorded, and not part of matching. */\n readonly orient: 'horz' | 'vert' | null;\n readonly hasCustomPrompt: boolean;\n}\n\n/** A placeholder with its defaults supplied: what the matcher compares. */\nexport interface NormalPlaceholder {\n readonly type: PlaceholderType;\n readonly idx: number;\n}\n\n/* -------------------------------------------------------------------------- */\n/* shapes */\n/* -------------------------------------------------------------------------- */\n\n/** One of the six things a `p:spTree` may contain. */\nexport type ShapeKind = 'sp' | 'pic' | 'grpSp' | 'graphicFrame' | 'cxnSp' | 'contentPart';\n\n/** `a:lnRef`, `a:fillRef` and `a:effectRef`: an index into the style matrix. */\nexport interface StyleRef {\n /**\n * `@idx`. Zero means none; 1..999 index the main list; 1001 and up index the\n * background list, offset by 1000. Measured on both `a:fillRef` and\n * `p:bgRef`, which turn out to be the same rule over the same six entries.\n */\n readonly idx: number;\n /** The colour `phClr` takes inside the entry this reference names. */\n readonly color: Color | null;\n}\n\n/** `a:fontRef`. `@idx` is a collection name, never a number. */\nexport interface FontRef {\n readonly idx: 'major' | 'minor' | 'none';\n readonly color: Color | null;\n}\n\n/** `p:style`: four references into the theme's `a:fmtScheme` and `a:fontScheme`. */\nexport interface ShapeStyle {\n readonly lnRef: StyleRef;\n readonly fillRef: StyleRef;\n readonly effectRef: StyleRef;\n readonly fontRef: FontRef;\n}\n\n/**\n * A shape, exactly as its part wrote it.\n *\n * Everything optional here is optional *in the file*, and the resolver is the\n * only thing entitled to fill any of it in.\n */\nexport interface Shape {\n readonly kind: ShapeKind;\n /** `p:cNvPr/@id`. Unique within a part, and may repeat across parts. */\n readonly cNvPrId: number;\n readonly name: string;\n /** `p:cNvPr/@descr`, the alt text. */\n readonly descr: string | null;\n readonly hidden: boolean;\n readonly placeholder: Placeholder | null;\n readonly xfrm: Xfrm | undefined;\n readonly fill: Fill | undefined;\n readonly line: Line | undefined;\n readonly effects: readonly Effect[] | undefined;\n readonly style: ShapeStyle | undefined;\n /** `a:prstGeom/@prst`, or `null` for a `custGeom` or no geometry at all. */\n readonly prstGeom: string | undefined;\n /**\n * `a:prstGeom` or `a:custGeom`, parsed far enough to draw.\n *\n * `undefined` when the shape declares neither, which is the ordinary state of\n * a slide placeholder: it inherits its outline from its layout exactly as it\n * inherits its rectangle, and `resolve` is what asks.\n */\n readonly geometry: ShapeGeometry | undefined;\n /**\n * `p:txBody`, when the shape has one.\n *\n * Present on every `p:sp` PowerPoint writes, including the ones with no text\n * in them, and absent from a `p:pic` or a `p:graphicFrame`. Its `a:lstStyle`\n * is one level of the text cascade; the paragraphs are the text itself.\n */\n readonly text: TextBody | undefined;\n /** Children, for a `grpSp`. Empty for everything else. */\n readonly children: readonly Shape[];\n /** The element this was read from. Edits go here, never to the fields above. */\n readonly node: XElement;\n}\n\n/* -------------------------------------------------------------------------- */\n/* the background */\n/* -------------------------------------------------------------------------- */\n\n/**\n * `p:bg`, which is one of two quite different things.\n *\n * `p:bgPr` states a fill. `p:bgRef` names an entry of the theme's style matrix\n * and the colour to invoke it with - the same mechanism as `a:fillRef` on a\n * shape, over the same table, with the same 1000-offset. Both were measured\n * against the same six theme entries in 2.9 and agreed on all six.\n */\nexport type Background =\n | { readonly kind: 'fill'; readonly fill: Fill; readonly effects: readonly Effect[] | undefined }\n | { readonly kind: 'ref'; readonly ref: StyleRef };\n\n/* -------------------------------------------------------------------------- */\n/* the theme */\n/* -------------------------------------------------------------------------- */\n\n/** `a:fmtScheme`: four lists of style entries, held as the elements they were. */\nexport interface FormatScheme {\n readonly name: string | null;\n /** `a:fillStyleLst`. Each entry is a whole `EG_FillProperties` element. */\n readonly fillStyles: readonly Fill[];\n /** `a:lnStyleLst`. Each entry is a whole `a:ln`. */\n readonly lineStyles: readonly Line[];\n /** `a:effectStyleLst`. Each entry's `a:effectLst`, flattened. */\n readonly effectStyles: readonly (readonly Effect[])[];\n /** `a:bgFillStyleLst`, which `@idx` 1001 and up reach. */\n readonly bgFillStyles: readonly Fill[];\n}\n\n/**\n * `a:fontScheme`: the two collections `+mj-` and `+mn-` name.\n *\n * Three scripts each, because `a:rPr` has four typeface slots and three of them\n * take a theme reference - `+mn-ea` on an `a:ea` is how a CJK run follows the\n * theme. The `a:font` script-tag list under each collection is 3.7's business\n * and is not modelled here.\n */\nexport interface FontCollection {\n /** `a:latin/@typeface`. An empty string means the theme states none. */\n readonly latin: string | null;\n readonly ea: string | null;\n readonly cs: string | null;\n}\n\nexport interface FontScheme {\n readonly name: string | null;\n readonly major: FontCollection;\n readonly minor: FontCollection;\n}\n\nexport interface Theme {\n readonly partName: string;\n readonly name: string | null;\n readonly scheme: ClrScheme;\n readonly fonts: FontScheme;\n readonly format: FormatScheme | null;\n readonly node: XElement;\n}\n\n/* -------------------------------------------------------------------------- */\n/* sheets */\n/* -------------------------------------------------------------------------- */\n\nexport type SheetKind = 'slide' | 'layout' | 'master';\n\n/**\n * `p:clrMapOvr`, which has exactly two forms and one surprise.\n *\n * `a:masterClrMapping` means \"use the map already in force\". The surprise,\n * measured in 2.9, is what \"already in force\" means for a slide: it is the\n * **layout's** map, not the master's. A layout carrying an\n * `a:overrideClrMapping` changes the colours of every slide bound to it that\n * says `masterClrMapping`, and a slide's own override beats its layout's. The\n * element's name says master and it means parent.\n */\nexport type ColorMapOverride =\n { readonly kind: 'inherit' } | { readonly kind: 'override'; readonly map: ClrMap };\n\n/**\n * A slide, a layout or a master, with its parent already resolved.\n *\n * The parent link comes from **this part's own `.rels`** and from nowhere else.\n * Not from `p:sldLayoutIdLst`, not from `p:sldMasterIdLst`, and not from the\n * part's number in its folder: a two-master deck saved by PowerPoint numbers its\n * layouts `slideLayout1..22` in one flat folder, and which master owns which is\n * recorded only in the masters' relationship parts. The list elements exist to\n * give each sheet an id and an order in the UI, not to bind anything.\n */\nexport interface Sheet {\n readonly kind: SheetKind;\n readonly partName: string;\n /** `p:cSld/@name`. */\n readonly name: string | null;\n /** `p:sldLayout/@type`, one of `ST_SlideLayoutType`. Layouts only. */\n readonly layoutType: string | null;\n /** `p:sldLayout/@matchingName`. Layouts only, and only when written. */\n readonly matchingName: string | null;\n readonly shapes: readonly Shape[];\n readonly background: Background | undefined;\n /** `p:clrMap`, on a master. `undefined` everywhere else. */\n readonly clrMap: ClrMap | undefined;\n /**\n * `p:txStyles`, on a master. `undefined` everywhere else, and meaningfully so.\n *\n * A master that declares none does not get a partial one: PowerPoint\n * substitutes its whole built-in set, measured in 3.1. So the difference\n * between `undefined` and a `p:txStyles` whose buckets say nothing is the\n * difference between a 28-point body placeholder and an 18-point one.\n */\n readonly txStyles: TextStyles | undefined;\n /** `p:clrMapOvr`, on a layout or a slide. */\n readonly clrMapOvr: ColorMapOverride | undefined;\n /** `@showMasterSp`, defaulting to true. Slides and layouts. */\n readonly showMasterShapes: boolean;\n /** The layout of a slide, the master of a layout, `null` for a master and for\n * a sheet whose binding is missing - which PowerPoint repairs rather than\n * refuses, so it has to be representable. */\n readonly parent: Sheet | null;\n /** The theme, on a master. Every other sheet reaches it through `parent`. */\n readonly theme: Theme | null;\n readonly node: XElement;\n}\n\n/* -------------------------------------------------------------------------- */\n/* resolution */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Where a resolved value came from.\n *\n * 2.9 declared this union in advance, guessing at the members the text cascade\n * would need. 3.1 measured them, and the guess was wrong in one place:\n * `themeObjDefaults` is gone, because `a:objectDefaults/a:spDef/a:lstStyle` is\n * not a source. A package declaring a size there and nowhere else resolves to\n * the built-in default, so the member named a level that never fires - see\n * `corpus/ground-truth/text-cascade.json`.\n */\nexport type Origin =\n /** The run's own `a:rPr`. */\n | 'run'\n /** The paragraph's `a:pPr`, or its `a:defRPr`. */\n | 'paragraph'\n /** The shape itself: its `p:spPr`, or its own `a:lstStyle`. */\n | 'shape'\n | 'layoutPh'\n | 'masterPh'\n /** The master's `p:txStyles`, in the bucket the chain's last type selects. */\n | 'txStyles'\n /** `p:defaultTextStyle`, which only a shape with no bucket reaches. */\n | 'defaultTextStyle'\n /** PowerPoint's own text styles, substituted for a master that declares none. */\n | 'builtin'\n | 'theme'\n | 'schemaDefault';\n\n/**\n * A value, where it came from, and whether the thing that owns it said so.\n *\n * `explicit` is not the same as `origin === 'shape'`: a layout placeholder that\n * declares a fill is explicit *about that fill*, and the slide that inherits it\n * is not. The inspector's hollow-versus-filled dot is exactly this bit.\n */\nexport interface Resolved<T> {\n readonly value: T;\n readonly origin: Origin;\n readonly explicit: boolean;\n /** The sheet the value was found on, when one was involved. */\n readonly sheet: Sheet | null;\n /** The shape the value was found on, when one was involved. */\n readonly shape: Shape | null;\n}\n","/**\n * DrawingML markup into the types `@pptx-studio/paint` defines.\n *\n * Paint depends on nothing but arithmetic - it has never seen an `XElement` and\n * must not, or it would inherit the XML layer's whole surface for the sake of\n * six element names. So the crossing lives here, at layer 2, which is the first\n * place that knows about both.\n *\n * Every function returns `undefined` when the element is absent, and `undefined`\n * is load-bearing: \"this shape declares no fill\" and \"this shape declares\n * `a:noFill`\" are different files with different resolutions, and only the first\n * one inherits.\n */\n\nimport {\n COLOR_TRANSFORM_OPS,\n PaintError,\n parseAngle,\n parsePercentage,\n transformShape,\n WHOLE_RECT,\n type Color,\n type ColorTransform,\n type ColorTransformOp,\n type DashSegment,\n type Effect,\n type BlipEffect,\n type BlipStretch,\n type BlipTile,\n type Fill,\n type GradientShade,\n type GradientStop,\n type Line,\n type LineCap,\n type LineDash,\n type LineEnd,\n type LineEndSize,\n type LineJoin,\n type LineJoinKind,\n type PenAlignment,\n type RectAlignment,\n type RelativeRect,\n type SchemeColorName,\n type ShadowGeometry,\n type TileAlign,\n type TileFlipMode,\n} from '@pptx-studio/paint';\nimport { attributeValue, childElements, firstChild, type XElement } from '@pptx-studio/xml';\n\nimport { ModelError } from '../errors.js';\n\n/* -------------------------------------------------------------------------- */\n/* small readers */\n/* -------------------------------------------------------------------------- */\n\nconst COLOR_ELEMENTS = new Set([\n 'a:srgbClr',\n 'a:scrgbClr',\n 'a:hslClr',\n 'a:schemeClr',\n 'a:sysClr',\n 'a:prstClr',\n]);\n\nconst FILL_ELEMENTS = new Set([\n 'a:noFill',\n 'a:solidFill',\n 'a:gradFill',\n 'a:blipFill',\n 'a:pattFill',\n 'a:grpFill',\n]);\n\n/** An integer attribute, or `fallback` when absent. Throws on a non-integer. */\nfunction intAttr(element: XElement, name: string, fallback: number, what: string): number {\n const raw = attributeValue(element, name);\n if (raw === undefined) return fallback;\n const value = Number(raw);\n if (!Number.isInteger(value)) {\n throw new ModelError('MODEL_XFRM_NUMBER', `${what}/@${name} is \"${raw}\"`, null, raw);\n }\n return value;\n}\n\n/**\n * `ST_Percentage`, which may legally be written `\"40000\"` or `\"40%\"`.\n *\n * The second spelling is Strict's and a Transitional part accepts it anyway -\n * measured in 2.6. `parseInt` on `\"40%\"` yields 40, which is 0.04%, and that is\n * how a line-spacing of 150% becomes a collapsed slide.\n */\nfunction percentAttr(element: XElement, name: string, fallback: number): number {\n const raw = attributeValue(element, name);\n if (raw === undefined) return fallback;\n return parsePercentage(raw);\n}\n\nfunction boolAttr(element: XElement, name: string, fallback: boolean): boolean {\n const raw = attributeValue(element, name);\n if (raw === undefined) return fallback;\n return raw === '1' || raw === 'true';\n}\n\n/* -------------------------------------------------------------------------- */\n/* colour */\n/* -------------------------------------------------------------------------- */\n\nfunction parseTransforms(element: XElement): ColorTransform[] {\n const out: ColorTransform[] = [];\n for (const child of childElements(element)) {\n const local = child.qname.startsWith('a:') ? child.qname.slice(2) : child.qname;\n const shape = transformShape(local);\n if (shape === null) continue;\n const op = local as ColorTransformOp;\n const raw = attributeValue(child, 'val');\n if (shape === 'flag') {\n out.push({ op } as ColorTransform);\n continue;\n }\n if (raw === undefined) {\n throw new PaintError('COLOR_NUMBER', `a:${local} has no @val`, local);\n }\n const val = shape === 'angle' ? parseAngle(raw) : parsePercentage(raw);\n out.push({ op, val } as ColorTransform);\n }\n return out;\n}\n\n/** One of the six `EG_ColorChoice` members. */\nexport function parseColorElement(element: XElement): Color {\n const transforms = parseTransforms(element);\n switch (element.qname) {\n case 'a:srgbClr':\n return { space: 'srgb', hex: attributeValue(element, 'val') ?? '', transforms };\n case 'a:scrgbClr':\n return {\n space: 'scrgb',\n r: percentAttr(element, 'r', 0),\n g: percentAttr(element, 'g', 0),\n b: percentAttr(element, 'b', 0),\n transforms,\n };\n case 'a:hslClr':\n return {\n space: 'hsl',\n hue: Number(attributeValue(element, 'hue') ?? '0'),\n sat: percentAttr(element, 'sat', 0),\n lum: percentAttr(element, 'lum', 0),\n transforms,\n };\n case 'a:schemeClr':\n return {\n space: 'scheme',\n name: (attributeValue(element, 'val') ?? '') as SchemeColorName,\n transforms,\n };\n case 'a:sysClr':\n return {\n space: 'sys',\n name: attributeValue(element, 'val') ?? '',\n lastClr: attributeValue(element, 'lastClr') ?? null,\n transforms,\n };\n case 'a:prstClr':\n return { space: 'prst', name: attributeValue(element, 'val') ?? '', transforms };\n default:\n throw new PaintError(\n 'COLOR_SCHEME_NAME',\n `${element.qname} is not a colour element`,\n element.qname,\n );\n }\n}\n\n/** The first colour child of a wrapper such as `a:solidFill` or `a:fillRef`. */\nexport function parseColorChild(parent: XElement | undefined): Color | null {\n if (parent === undefined) return null;\n for (const child of childElements(parent)) {\n if (COLOR_ELEMENTS.has(child.qname)) return parseColorElement(child);\n }\n return null;\n}\n\n/* -------------------------------------------------------------------------- */\n/* fills */\n/* -------------------------------------------------------------------------- */\n\nfunction parseRelativeRect(element: XElement | undefined): RelativeRect {\n if (element === undefined) return WHOLE_RECT;\n return {\n l: percentAttr(element, 'l', 0),\n t: percentAttr(element, 't', 0),\n r: percentAttr(element, 'r', 0),\n b: percentAttr(element, 'b', 0),\n };\n}\n\nfunction parseGradientShade(element: XElement): GradientShade | null {\n const lin = firstChild(element, 'a:lin');\n if (lin !== undefined) {\n return {\n kind: 'linear',\n ang: Number(attributeValue(lin, 'ang') ?? '0'),\n scaled: boolAttr(lin, 'scaled', false),\n };\n }\n const path = firstChild(element, 'a:path');\n if (path === undefined) return null;\n // An absent `@path` paints the box ramp, measured against 27 probes: ADR 0022.\n const raw = attributeValue(path, 'path') ?? 'rect';\n const kind = raw === 'circle' || raw === 'rect' ? raw : 'shape';\n const rect = firstChild(path, 'a:fillToRect');\n return {\n kind: 'path',\n path: kind,\n fillToRect: rect === undefined ? null : parseRelativeRect(rect),\n };\n}\n\nconst TILE_ALIGNS = new Set<string>(['tl', 't', 'tr', 'l', 'ctr', 'r', 'bl', 'b', 'br']);\nconst TILE_FLIPS = new Set<string>(['none', 'x', 'y', 'xy']);\n\n/** `a:blip`'s colour effects, in document order, which is the order they apply. */\n/** The `{96DAC541-...}` extension PowerPoint writes on a blip with an SVG original. */\nconst SVG_BLIP_EXT = '{96DAC541-7B7A-43D3-8B79-37D633B846F1}';\n\n/** `a:blip/a:extLst/a:ext[@uri=SVG_BLIP_EXT]/asvg:svgBlip/@r:embed`, or `null`. */\nfunction svgBlipEmbed(blip: XElement): string | null {\n const extLst = firstChild(blip, 'a:extLst');\n if (extLst === undefined) return null;\n for (const ext of childElements(extLst)) {\n if (ext.qname !== 'a:ext' || attributeValue(ext, 'uri') !== SVG_BLIP_EXT) continue;\n for (const child of childElements(ext)) {\n // The prefix is the writer's to choose; only the local name is fixed.\n if (child.qname.split(':').pop() !== 'svgBlip') continue;\n const embed = attributeValue(child, 'r:embed');\n if (embed !== undefined) return embed;\n }\n }\n return null;\n}\nfunction parseBlipEffects(blip: XElement): BlipEffect[] {\n const effects: BlipEffect[] = [];\n for (const child of childElements(blip)) {\n switch (child.qname) {\n case 'a:grayscl':\n effects.push({ kind: 'grayscale' });\n break;\n case 'a:biLevel':\n effects.push({ kind: 'biLevel', thresh: percentAttr(child, 'thresh', 0) });\n break;\n case 'a:lum':\n effects.push({\n kind: 'lum',\n bright: percentAttr(child, 'bright', 0),\n contrast: percentAttr(child, 'contrast', 0),\n });\n break;\n case 'a:duotone': {\n const colors = childElements(child)\n .filter((c) => COLOR_ELEMENTS.has(c.qname))\n .map(parseColorElement);\n const [from, to] = colors;\n if (from === undefined || to === undefined) {\n throw new ModelError('BLIP_DUOTONE', 'a:duotone needs two colours', 'a:duotone');\n }\n effects.push({ kind: 'duotone', from, to });\n break;\n }\n case 'a:alphaModFix':\n effects.push({ kind: 'alphaModFix', amt: percentAttr(child, 'amt', 100000) });\n break;\n case 'a:clrChange': {\n const from = parseColorChild(firstChild(child, 'a:clrFrom'));\n const to = parseColorChild(firstChild(child, 'a:clrTo'));\n if (from === null || to === null) {\n throw new ModelError('BLIP_CLR_CHANGE', 'a:clrChange needs both colours', 'a:clrChange');\n }\n effects.push({ kind: 'clrChange', from, to, useAlpha: boolAttr(child, 'useA', true) });\n break;\n }\n default:\n break;\n }\n }\n return effects;\n}\n\n/**\n * `a:blipFill`.\n *\n * The relationship id is carried, never resolved: a fill in a layout resolves\n * against the layout's rels and the same markup inherited onto a slide still\n * means the layout's image. Same contract as `a:buBlip`.\n */\nfunction parseBlipFill(element: XElement, partName: string): Fill {\n const blip = firstChild(element, 'a:blip');\n if (blip === undefined) {\n throw new ModelError('BLIP_NO_EMBED', 'a:blipFill has no a:blip', 'a:blipFill');\n }\n const embed = attributeValue(blip, 'r:embed') ?? null;\n const svgEmbed = svgBlipEmbed(blip);\n // A blip naming neither a raster nor an SVG resolves to no image at all,\n // which is markup PowerPoint does not write.\n if (embed === null && svgEmbed === null) {\n throw new ModelError('BLIP_NO_EMBED', 'a:blip names no image to resolve', 'a:blip');\n }\n\n const tile = firstChild(element, 'a:tile');\n const stretch = firstChild(element, 'a:stretch');\n let mode: BlipStretch | BlipTile;\n if (tile !== undefined) {\n const algn = attributeValue(tile, 'algn') ?? 'tl';\n const flip = attributeValue(tile, 'flip') ?? 'none';\n if (!TILE_ALIGNS.has(algn)) {\n throw new ModelError('BLIP_TILE_ALIGN', `a:tile/@algn is \"${algn}\"`, 'a:tile');\n }\n if (!TILE_FLIPS.has(flip)) {\n throw new ModelError('BLIP_TILE_FLIP', `a:tile/@flip is \"${flip}\"`, 'a:tile');\n }\n mode = {\n kind: 'tile',\n tx: intAttr(tile, 'tx', 0, 'a:tile'),\n ty: intAttr(tile, 'ty', 0, 'a:tile'),\n sx: percentAttr(tile, 'sx', 100000),\n sy: percentAttr(tile, 'sy', 100000),\n flip: flip as TileFlipMode,\n algn: algn as TileAlign,\n };\n } else {\n // No `a:tile` and no `a:stretch` is legal and behaves as a bare stretch.\n mode = {\n kind: 'stretch',\n fillRect: parseRelativeRect(\n stretch === undefined ? undefined : firstChild(stretch, 'a:fillRect'),\n ),\n };\n }\n\n return {\n type: 'blip',\n embed,\n svgEmbed,\n part: partName,\n srcRect: parseRelativeRect(firstChild(element, 'a:srcRect')),\n mode,\n effects: parseBlipEffects(blip),\n dpi: intAttr(element, 'dpi', 0, 'a:blipFill'),\n rotWithShape: boolAttr(element, 'rotWithShape', true),\n };\n}\n\n/**\n * `p:pic/p:blipFill` - the image a picture shape draws.\n *\n * `CT_Picture` is `nvPicPr, blipFill, spPr`, so the image sits *beside*\n * `p:spPr` rather than inside it, and in PresentationML. ADR 0037.\n */\nexport function parsePictureFill(pic: XElement, partName: string): Fill | undefined {\n const blipFill = firstChild(pic, 'p:blipFill');\n return blipFill === undefined ? undefined : parseBlipFill(blipFill, partName);\n}\n\n/** One member of `EG_FillProperties`. */\nexport function parseFillElement(element: XElement, partName: string): Fill {\n switch (element.qname) {\n case 'a:noFill':\n return { type: 'none' };\n case 'a:grpFill':\n return { type: 'group' };\n case 'a:blipFill':\n return parseBlipFill(element, partName);\n case 'a:solidFill': {\n const color = parseColorChild(element);\n if (color === null) {\n // A `solidFill` with no colour child is not something PowerPoint writes,\n // and black is the wrong guess: it is indistinguishable from a real\n // black and would paint over a themed shape silently.\n throw new PaintError('COLOR_SCHEME_NAME', 'a:solidFill has no colour child', 'a:solidFill');\n }\n return { type: 'solid', color };\n }\n case 'a:pattFill':\n return {\n type: 'pattern',\n prst: attributeValue(element, 'prst') ?? '',\n fg: parseColorChild(firstChild(element, 'a:fgClr')),\n bg: parseColorChild(firstChild(element, 'a:bgClr')),\n };\n case 'a:gradFill': {\n const stops: GradientStop[] = [];\n const list = firstChild(element, 'a:gsLst');\n if (list !== undefined) {\n for (const gs of childElements(list)) {\n if (gs.qname !== 'a:gs') continue;\n const color = parseColorChild(gs);\n if (color === null) continue;\n stops.push({ pos: percentAttr(gs, 'pos', 0), color });\n }\n }\n const flip = (attributeValue(element, 'flip') ?? 'none') as TileFlipMode;\n return {\n type: 'gradient',\n stops,\n shade: parseGradientShade(element),\n tileRect:\n firstChild(element, 'a:tileRect') === undefined\n ? null\n : parseRelativeRect(firstChild(element, 'a:tileRect')),\n flip,\n rotWithShape: boolAttr(element, 'rotWithShape', true),\n };\n }\n default:\n throw new PaintError(\n 'FILL_PATTERN_UNKNOWN',\n `${element.qname} is not a fill element`,\n element.qname,\n );\n }\n}\n\n/** The fill a container declares, or `undefined` when it declares none. */\nexport function parseFill(parent: XElement, partName: string): Fill | undefined {\n for (const child of childElements(parent)) {\n if (FILL_ELEMENTS.has(child.qname)) return parseFillElement(child, partName);\n }\n return undefined;\n}\n\n/* -------------------------------------------------------------------------- */\n/* lines */\n/* -------------------------------------------------------------------------- */\n\nconst JOIN_KINDS: Readonly<Record<string, LineJoinKind>> = {\n 'a:round': 'round',\n 'a:bevel': 'bevel',\n 'a:miter': 'miter',\n};\n\nfunction parseLineEnd(element: XElement | undefined): LineEnd | null {\n if (element === undefined) return null;\n const size = (name: string): LineEndSize => {\n const raw = attributeValue(element, name);\n return raw === 'sm' || raw === 'med' || raw === 'lg' ? raw : 'med';\n };\n return { type: attributeValue(element, 'type') ?? 'none', w: size('w'), len: size('len') };\n}\n\nfunction parseDash(element: XElement): LineDash | null {\n const preset = firstChild(element, 'a:prstDash');\n if (preset !== undefined) {\n return { kind: 'preset', val: attributeValue(preset, 'val') ?? 'solid' };\n }\n const custom = firstChild(element, 'a:custDash');\n if (custom === undefined) return null;\n const stops: DashSegment[] = [];\n for (const ds of childElements(custom)) {\n if (ds.qname !== 'a:ds') continue;\n // `@d` and `@sp` are percentages of the line width, so a `1000` is ten\n // widths and not a thousand of anything.\n stops.push({ d: percentAttr(ds, 'd', 0) / 100000, sp: percentAttr(ds, 'sp', 0) / 100000 });\n }\n return { kind: 'custom', stops };\n}\n\n/** `a:ln`, lazily: every field is `null` when the attribute was absent. */\nexport function parseLineElement(element: XElement, partName: string): Line {\n let join: LineJoin | null = null;\n for (const child of childElements(element)) {\n const kind = JOIN_KINDS[child.qname];\n if (kind === undefined) continue;\n const lim = attributeValue(child, 'lim');\n join = { kind, limit: lim === undefined ? null : parsePercentage(lim) / 100000 };\n break;\n }\n\n const cap = attributeValue(element, 'cap');\n const algn = attributeValue(element, 'algn');\n const w = attributeValue(element, 'w');\n\n return {\n w: w === undefined ? null : intAttr(element, 'w', 0, 'a:ln'),\n cap: cap === 'flat' || cap === 'sq' || cap === 'rnd' ? (cap satisfies LineCap) : null,\n cmpd: attributeValue(element, 'cmpd') ?? null,\n algn: algn === 'ctr' || algn === 'in' ? (algn satisfies PenAlignment) : null,\n fill: parseFill(element, partName) ?? null,\n dash: parseDash(element),\n join,\n headEnd: parseLineEnd(firstChild(element, 'a:headEnd')),\n tailEnd: parseLineEnd(firstChild(element, 'a:tailEnd')),\n };\n}\n\nexport function parseLine(parent: XElement, partName: string): Line | undefined {\n const element = firstChild(parent, 'a:ln');\n return element === undefined ? undefined : parseLineElement(element, partName);\n}\n\n/* -------------------------------------------------------------------------- */\n/* effects */\n/* -------------------------------------------------------------------------- */\n\nconst RECT_ALIGNMENTS = new Set(['tl', 't', 'tr', 'l', 'ctr', 'r', 'bl', 'b', 'br']);\n\nfunction alignAttr(element: XElement, fallback: RectAlignment): RectAlignment {\n const raw = attributeValue(element, 'algn');\n return raw !== undefined && RECT_ALIGNMENTS.has(raw) ? (raw as RectAlignment) : fallback;\n}\n\nfunction shadowGeometry(element: XElement): ShadowGeometry {\n return {\n blurRad: intAttr(element, 'blurRad', 0, element.qname),\n dist: intAttr(element, 'dist', 0, element.qname),\n dir: intAttr(element, 'dir', 0, element.qname),\n sx: percentAttr(element, 'sx', 100000),\n sy: percentAttr(element, 'sy', 100000),\n kx: intAttr(element, 'kx', 0, element.qname),\n ky: intAttr(element, 'ky', 0, element.qname),\n // Measured in 2.8: bottom-centre, not the centre. `sy=\"-100000\"` mirrors\n // about the bottom edge, which is what a floor reflection wants.\n algn: alignAttr(element, 'b'),\n rotWithShape: boolAttr(element, 'rotWithShape', true),\n };\n}\n\nfunction requireColor(element: XElement): Color {\n const color = parseColorChild(element);\n if (color === null) {\n throw new PaintError(\n 'COLOR_SCHEME_NAME',\n `${element.qname} has no colour child`,\n element.qname,\n );\n }\n return color;\n}\n\n/** One member of `a:effectLst`, or `null` for an element this does not model. */\nfunction parseEffectElement(element: XElement): Effect | null {\n switch (element.qname) {\n case 'a:outerShdw':\n return { kind: 'outerShdw', color: requireColor(element), ...shadowGeometry(element) };\n case 'a:innerShdw':\n return {\n kind: 'innerShdw',\n color: requireColor(element),\n ...shadowGeometry(element),\n };\n case 'a:prstShdw':\n return {\n kind: 'prstShdw',\n prst: attributeValue(element, 'prst') ?? '',\n dist: intAttr(element, 'dist', 0, 'a:prstShdw'),\n dir: intAttr(element, 'dir', 0, 'a:prstShdw'),\n color: requireColor(element),\n };\n case 'a:glow':\n return {\n kind: 'glow',\n rad: intAttr(element, 'rad', 0, 'a:glow'),\n color: requireColor(element),\n };\n case 'a:softEdge':\n return { kind: 'softEdge', rad: intAttr(element, 'rad', 0, 'a:softEdge') };\n case 'a:blur':\n return {\n kind: 'blur',\n rad: intAttr(element, 'rad', 0, 'a:blur'),\n grow: boolAttr(element, 'grow', true),\n };\n case 'a:reflection':\n return {\n kind: 'reflection',\n blurRad: intAttr(element, 'blurRad', 0, 'a:reflection'),\n stA: percentAttr(element, 'stA', 100000),\n stPos: percentAttr(element, 'stPos', 0),\n endA: percentAttr(element, 'endA', 0),\n endPos: percentAttr(element, 'endPos', 100000),\n dist: intAttr(element, 'dist', 0, 'a:reflection'),\n dir: intAttr(element, 'dir', 0, 'a:reflection'),\n fadeDir: intAttr(element, 'fadeDir', 5400000, 'a:reflection'),\n sx: percentAttr(element, 'sx', 100000),\n sy: percentAttr(element, 'sy', 100000),\n kx: intAttr(element, 'kx', 0, 'a:reflection'),\n ky: intAttr(element, 'ky', 0, 'a:reflection'),\n algn: alignAttr(element, 'b'),\n rotWithShape: boolAttr(element, 'rotWithShape', true),\n };\n default:\n return null;\n }\n}\n\n/**\n * `a:effectLst`, in the order the file wrote it.\n *\n * Which is not the order it is painted in: 2.8 measured a glow painting *over*\n * an outer shadow, the reverse of the schema's sequence. `effectFilter` in\n * `paint` owns that, and this owns only the reading.\n *\n * `a:effectDag` is not modelled, so the shape is re-emitted byte for byte\n * rather than approximated. PowerPoint writes none but does render one:\n * measured on `a04-effects-03`, where it composites a glow over the fill.\n */\nexport function parseEffects(parent: XElement): readonly Effect[] | undefined {\n const list = firstChild(parent, 'a:effectLst');\n if (list === undefined) return undefined;\n const out: Effect[] = [];\n for (const child of childElements(list)) {\n const effect = parseEffectElement(child);\n if (effect !== null) out.push(effect);\n }\n return out;\n}\n\n/** The 28 transform names, re-exported so a caller can test a tag without paint. */\nexport { COLOR_TRANSFORM_OPS };\n","/**\n * `a:prstGeom` and `a:custGeom`, into the one type `@pptx-studio/geometry` takes.\n *\n * ## Why this is in the model rather than in the renderer\n *\n * Because geometry inherits. A slide placeholder that states no `a:spPr/a:xfrm`\n * usually states no `a:prstGeom` either, and takes both from its layout - so\n * \"which shape is this\" is a question for the resolver, and the resolver only\n * works over fields on `Shape`. Reading the geometry off `shape.node` in a\n * renderer would put half of one answer in the model and the other half\n * somewhere that cannot see the chain.\n *\n * 2.9 recorded only the preset's *name*, which is enough to say what a shape is\n * and not enough to draw it: `a:avLst` is where a rounded rectangle's corner\n * radius and a chevron's notch depth live, and a preset drawn with its defaults\n * when the file overrode them is a visibly wrong shape.\n *\n * ## The two are one type, and that is 2.4's finding rather than a convenience\n *\n * `a:custGeom` carries `avLst`, `gdLst`, `ahLst`, `cxnLst`, `rect` and\n * `pathLst`: the same six children with the same meanings as a preset\n * definition, written inline instead of looked up by name. So both parse into\n * `Geometry` and the evaluator has one code path. The only difference is that a\n * preset has a name and a `custGeom` does not.\n */\n\nimport {\n custGeom,\n type Geometry,\n type PresetAdjustHandle,\n type PresetCommand,\n type PresetConnectionSite,\n type PresetGuide,\n type PresetPath,\n type PresetPathFill,\n type PresetPoint,\n type PresetTextRect,\n} from '@pptx-studio/geometry';\nimport { attributeValue, childElements, firstChild, type XElement } from '@pptx-studio/xml';\n\nimport { ModelError } from '../errors.js';\n\n/**\n * What a shape says it is.\n *\n * `preset` keeps the adjust values as guides rather than numbers, because\n * `a:avLst` is a `CT_GeomGuideList` and a guide may in principle carry any\n * formula - `evaluateGuides` takes either form and the file's form is the one\n * that round-trips.\n */\nexport type ShapeGeometry =\n | { readonly kind: 'preset'; readonly prst: string; readonly adjust: readonly PresetGuide[] }\n | { readonly kind: 'custom'; readonly geometry: Geometry };\n\nfunction guides(parent: XElement | undefined, qname: string): PresetGuide[] {\n const list = parent === undefined ? undefined : firstChild(parent, qname);\n if (list === undefined) return [];\n const out: PresetGuide[] = [];\n for (const child of childElements(list)) {\n if (child.qname !== 'a:gd') continue;\n const name = attributeValue(child, 'name');\n const fmla = attributeValue(child, 'fmla');\n if (name === undefined || fmla === undefined) continue;\n // Split on whitespace and keep every token: the arity is not fixed, and\n // `OVER_LONG_FORMULAS` in the preset buckets is the evidence.\n out.push({ name, fmla: fmla.trim().split(/\\s+/) });\n }\n return out;\n}\n\nfunction point(element: XElement, partName: string): PresetPoint {\n const x = attributeValue(element, 'x');\n const y = attributeValue(element, 'y');\n if (x === undefined || y === undefined) {\n throw new ModelError('MODEL_GEOMETRY', `<${element.qname}> has no x or no y`, partName);\n }\n return { x, y };\n}\n\nconst PATH_FILLS = new Set<string>([\n 'none',\n 'norm',\n 'lighten',\n 'lightenLess',\n 'darken',\n 'darkenLess',\n]);\n\nfunction pathFill(raw: string | undefined): PresetPathFill {\n return raw !== undefined && PATH_FILLS.has(raw) ? (raw as PresetPathFill) : 'norm';\n}\n\n/** `@w`/`@h` on an `a:path`. Absent means zero, which means no path space. */\nfunction pathExtent(element: XElement, name: string, partName: string): number {\n const raw = attributeValue(element, name);\n if (raw === undefined) return 0;\n const value = Number(raw);\n if (!Number.isFinite(value)) {\n throw new ModelError('MODEL_GEOMETRY', `a:path/@${name} is \"${raw}\"`, partName);\n }\n return value;\n}\n\nfunction commands(path: XElement, partName: string): PresetCommand[] {\n const out: PresetCommand[] = [];\n for (const child of childElements(path)) {\n switch (child.qname) {\n case 'a:moveTo':\n case 'a:lnTo': {\n const pt = firstChild(child, 'a:pt');\n if (pt === undefined) break;\n out.push({\n kind: child.qname === 'a:moveTo' ? 'moveTo' : 'lnTo',\n to: point(pt, partName),\n });\n break;\n }\n case 'a:quadBezTo': {\n const pts = childElements(child).filter((c) => c.qname === 'a:pt');\n if (pts.length < 2) break;\n out.push({\n kind: 'quadBezTo',\n c1: point(pts[0]!, partName),\n to: point(pts[1]!, partName),\n });\n break;\n }\n case 'a:cubicBezTo': {\n const pts = childElements(child).filter((c) => c.qname === 'a:pt');\n if (pts.length < 3) break;\n out.push({\n kind: 'cubicBezTo',\n c1: point(pts[0]!, partName),\n c2: point(pts[1]!, partName),\n to: point(pts[2]!, partName),\n });\n break;\n }\n case 'a:arcTo': {\n const wR = attributeValue(child, 'wR');\n const hR = attributeValue(child, 'hR');\n const stAng = attributeValue(child, 'stAng');\n const swAng = attributeValue(child, 'swAng');\n if (wR === undefined || hR === undefined || stAng === undefined || swAng === undefined) {\n throw new ModelError('MODEL_GEOMETRY', 'a:arcTo is missing an attribute', partName);\n }\n out.push({ kind: 'arcTo', wR, hR, stAng, swAng });\n break;\n }\n case 'a:close':\n out.push({ kind: 'close' });\n break;\n default:\n break;\n }\n }\n return out;\n}\n\nfunction paths(parent: XElement, partName: string): PresetPath[] {\n const list = firstChild(parent, 'a:pathLst');\n if (list === undefined) return [];\n const out: PresetPath[] = [];\n for (const child of childElements(list)) {\n if (child.qname !== 'a:path') continue;\n out.push({\n w: pathExtent(child, 'w', partName),\n h: pathExtent(child, 'h', partName),\n fill: pathFill(attributeValue(child, 'fill')),\n // `@stroke` defaults to true, which is not the same as \"absent means no\".\n stroke: attributeValue(child, 'stroke') !== '0',\n extrusionOk: attributeValue(child, 'extrusionOk') === '1',\n commands: commands(child, partName),\n });\n }\n return out;\n}\n\nfunction handles(parent: XElement, partName: string): PresetAdjustHandle[] {\n const list = firstChild(parent, 'a:ahLst');\n if (list === undefined) return [];\n const out: PresetAdjustHandle[] = [];\n for (const child of childElements(list)) {\n const pos = firstChild(child, 'a:pos');\n if (pos === undefined) continue;\n const at = point(pos, partName);\n if (child.qname === 'a:ahXY') {\n out.push({\n kind: 'xy',\n pos: at,\n gdRefX: attributeValue(child, 'gdRefX') ?? null,\n minX: attributeValue(child, 'minX') ?? null,\n maxX: attributeValue(child, 'maxX') ?? null,\n gdRefY: attributeValue(child, 'gdRefY') ?? null,\n minY: attributeValue(child, 'minY') ?? null,\n maxY: attributeValue(child, 'maxY') ?? null,\n });\n } else if (child.qname === 'a:ahPolar') {\n out.push({\n kind: 'polar',\n pos: at,\n gdRefAng: attributeValue(child, 'gdRefAng') ?? null,\n minAng: attributeValue(child, 'minAng') ?? null,\n maxAng: attributeValue(child, 'maxAng') ?? null,\n gdRefR: attributeValue(child, 'gdRefR') ?? null,\n minR: attributeValue(child, 'minR') ?? null,\n maxR: attributeValue(child, 'maxR') ?? null,\n });\n }\n }\n return out;\n}\n\nfunction sites(parent: XElement, partName: string): PresetConnectionSite[] {\n const list = firstChild(parent, 'a:cxnLst');\n if (list === undefined) return [];\n const out: PresetConnectionSite[] = [];\n for (const child of childElements(list)) {\n if (child.qname !== 'a:cxn') continue;\n const pos = firstChild(child, 'a:pos');\n const ang = attributeValue(child, 'ang');\n if (pos === undefined || ang === undefined) continue;\n out.push({ ang, pos: point(pos, partName) });\n }\n return out;\n}\n\nfunction textRect(parent: XElement): PresetTextRect | null {\n const rect = firstChild(parent, 'a:rect');\n if (rect === undefined) return null;\n const l = attributeValue(rect, 'l');\n const t = attributeValue(rect, 't');\n const r = attributeValue(rect, 'r');\n const b = attributeValue(rect, 'b');\n return l === undefined || t === undefined || r === undefined || b === undefined\n ? null\n : { l, t, r, b };\n}\n\n/**\n * The geometry a shape declares, or `undefined` when it declares none.\n *\n * `undefined` is the whole point: a slide placeholder with no `a:prstGeom` has\n * not chosen to be a rectangle, it has said nothing, and `resolve` is what turns\n * that into the layout's answer.\n */\nexport function parseGeometry(\n spPr: XElement | undefined,\n partName: string,\n): ShapeGeometry | undefined {\n if (spPr === undefined) return undefined;\n\n const preset = firstChild(spPr, 'a:prstGeom');\n if (preset !== undefined) {\n const prst = attributeValue(preset, 'prst');\n if (prst === undefined) {\n throw new ModelError('MODEL_GEOMETRY', 'a:prstGeom has no @prst', partName);\n }\n return { kind: 'preset', prst, adjust: guides(preset, 'a:avLst') };\n }\n\n const custom = firstChild(spPr, 'a:custGeom');\n if (custom === undefined) return undefined;\n return {\n kind: 'custom',\n geometry: custGeom({\n avLst: guides(custom, 'a:avLst'),\n gdLst: guides(custom, 'a:gdLst'),\n ahLst: handles(custom, partName),\n cxnLst: sites(custom, partName),\n rect: textRect(custom),\n pathLst: paths(custom, partName),\n }) satisfies Geometry,\n };\n}\n","/**\n * `a:bodyPr`: the text frame, as the file states it.\n *\n * Every field is `T | undefined` for the reason the rest of the model is - a\n * frame that states no anchor is not a top-anchored frame, and 3.6 measured that\n * the difference is the whole of the placeholder cascade.\n */\n\nimport { attributeValue, firstChild } from '@pptx-studio/xml';\nimport type { XElement } from '@pptx-studio/xml';\n\nimport { ModelError } from '../errors.js';\nimport type {\n Autofit,\n BodyProps,\n HorzOverflow,\n TextAnchor,\n TextWrap,\n VertOverflow,\n VerticalText,\n} from '../text.js';\n\nconst ANCHORS: readonly TextAnchor[] = ['t', 'ctr', 'b', 'just', 'dist'];\nconst VERTICALS: readonly VerticalText[] = [\n 'horz',\n 'vert',\n 'vert270',\n 'wordArtVert',\n 'eaVert',\n 'mongolianVert',\n 'wordArtVertRtl',\n];\nconst WRAPS: readonly TextWrap[] = ['none', 'square'];\nconst VERT_OVERFLOWS: readonly VertOverflow[] = ['overflow', 'ellipsis', 'clip'];\nconst HORZ_OVERFLOWS: readonly HorzOverflow[] = ['overflow', 'clip'];\n\nfunction attrError(element: XElement, name: string, raw: string, why: string, part: string): never {\n throw new ModelError(\n 'MODEL_TEXT_ATTR',\n `${element.qname}/@${name} is \"${raw}\", which is not ${why}`,\n part,\n name,\n );\n}\n\nfunction boolOf(element: XElement, name: string, part: string): boolean | undefined {\n const raw = attributeValue(element, name);\n if (raw === undefined) return undefined;\n if (raw === '1' || raw === 'true') return true;\n if (raw === '0' || raw === 'false') return false;\n return attrError(element, name, raw, 'a ST_OnOff', part);\n}\n\nfunction intOf(element: XElement, name: string, part: string): number | undefined {\n const raw = attributeValue(element, name);\n if (raw === undefined) return undefined;\n const value = Number(raw);\n if (!Number.isInteger(value)) return attrError(element, name, raw, 'an integer', part);\n return value;\n}\n\nfunction enumOf<T extends string>(\n element: XElement,\n name: string,\n allowed: readonly T[],\n part: string,\n): T | undefined {\n const raw = attributeValue(element, name);\n if (raw === undefined) return undefined;\n if (!(allowed as readonly string[]).includes(raw)) {\n return attrError(element, name, raw, `one of ${allowed.join(', ')}`, part);\n }\n return raw as T;\n}\n\n/**\n * `a:noAutofit` / `a:normAutofit` / `a:spAutoFit`, whichever is present.\n *\n * The scale attributes are `ST_TextFontScalePercentOrPercentString`, which is\n * the same both-spellings grammar as every other percentage here; they are kept\n * as thousandths so `@pptx-studio/text` reads them the way it was measured.\n */\nfunction parseAutofit(element: XElement, part: string): Autofit | undefined {\n if (firstChild(element, 'a:noAutofit') !== undefined) return { kind: 'none' };\n if (firstChild(element, 'a:spAutoFit') !== undefined) return { kind: 'shape' };\n const norm = firstChild(element, 'a:normAutofit');\n if (norm === undefined) return undefined;\n return {\n kind: 'normal',\n fontScale: percentOf(norm, 'fontScale', part),\n lnSpcReduction: percentOf(norm, 'lnSpcReduction', part),\n };\n}\n\n/** Thousandths of a percent, accepting both the `92500` and the `92.5%` spellings. */\nfunction percentOf(element: XElement, name: string, part: string): number | undefined {\n const raw = attributeValue(element, name);\n if (raw === undefined) return undefined;\n const value = raw.endsWith('%') ? Number(raw.slice(0, -1)) * 1000 : Number(raw);\n if (!Number.isFinite(value)) return attrError(element, name, raw, 'a ST_Percentage', part);\n return value;\n}\n\n/** Parse an `a:bodyPr`. Lengths stay in EMU and angles in 60000ths of a degree. */\nexport function parseBodyProps(element: XElement, partName: string): BodyProps {\n return {\n anchor: enumOf(element, 'anchor', ANCHORS, partName),\n anchorCtr: boolOf(element, 'anchorCtr', partName),\n lIns: intOf(element, 'lIns', partName),\n tIns: intOf(element, 'tIns', partName),\n rIns: intOf(element, 'rIns', partName),\n bIns: intOf(element, 'bIns', partName),\n vert: enumOf(element, 'vert', VERTICALS, partName),\n wrap: enumOf(element, 'wrap', WRAPS, partName),\n vertOverflow: enumOf(element, 'vertOverflow', VERT_OVERFLOWS, partName),\n horzOverflow: enumOf(element, 'horzOverflow', HORZ_OVERFLOWS, partName),\n rot: intOf(element, 'rot', partName),\n upright: boolOf(element, 'upright', partName),\n numCol: intOf(element, 'numCol', partName),\n spcCol: intOf(element, 'spcCol', partName),\n rtlCol: boolOf(element, 'rtlCol', partName),\n spcFirstLastPara: boolOf(element, 'spcFirstLastPara', partName),\n compatLnSpc: boolOf(element, 'compatLnSpc', partName),\n fromWordArt: boolOf(element, 'fromWordArt', partName),\n forceAA: boolOf(element, 'forceAA', partName),\n autofit: parseAutofit(element, partName),\n node: element,\n };\n}\n\n/** The `a:bodyPr` of a `p:txBody`, when it has one. */\nexport function parseBodyPropsChild(parent: XElement, partName: string): BodyProps | undefined {\n const element = firstChild(parent, 'a:bodyPr');\n return element === undefined ? undefined : parseBodyProps(element, partName);\n}\n","/**\n * The text model, and the ten sources a run's size can come from.\n *\n * Everything here is `T | undefined` for the same reason the rest of the model\n * is: a run whose `a:rPr` declares no size is not an 18-point run, it is a run\n * that has not said, and the difference is what the whole cascade is about.\n *\n * ## What the cascade turned out to be\n *\n * Measured in 3.1 against PowerPoint, over a ladder of nine packages each\n * declaring one source fewer than the last. Scored over all 40320 permutations\n * of the eight sources the plan names: **none of them fits** while a placeholder\n * is assumed to read every source, and exactly one order fits once the two it\n * ignores are dropped. `corpus/ground-truth/text-cascade.json`, and\n * `docs/adr/phase-3-text/0027-the-text-cascade.md`.\n *\n * The walk, nearest first:\n *\n * 1. the run's own `a:rPr`\n * 2. the paragraph's `a:pPr/a:defRPr`\n * 3. the shape's `a:lstStyle`, at the paragraph's level\n * 4. each ancestor placeholder's `a:lstStyle`, up the same chain 2.9 measured\n * for geometry - `@idx` alone to the layout, the folded `@type` to the master\n *\n * and then **one of two termini**, which is where every implementation this\n * project has read goes wrong:\n *\n * - a shape whose chain ends at a type with a bucket reads the master's\n * `p:txStyles[bucket]` **and stops**\n * - a shape with no bucket reads `p:defaultTextStyle` **and stops**\n *\n * A body placeholder ignores a `p:defaultTextStyle` that is right there in the\n * package; a slide-number placeholder reads it. They are not two rungs of one\n * ladder.\n *\n * ## Three things the plan calls sources and PowerPoint does not read\n *\n * `a:objectDefaults/a:spDef/a:lstStyle`, `a:defPPr`, and `p:otherStyle`. The\n * last is the surprising one: ECMA calls it \"the text style for all other text\",\n * and nothing measurable reads it - not a shape that is not a placeholder on the\n * slide, the layout or the master, and not the `dt`/`ftr`/`sldNum` placeholders\n * the plan assigned to it, which fall through to `p:defaultTextStyle` instead.\n */\n\nimport type { Color, Effect, Fill, Line } from '@pptx-studio/paint';\nimport type { XElement } from '@pptx-studio/xml';\n\n/* -------------------------------------------------------------------------- */\n/* scalars */\n/* -------------------------------------------------------------------------- */\n\n/** `ST_TextAlignType`. */\nexport type TextAlign = 'l' | 'ctr' | 'r' | 'just' | 'justLow' | 'dist' | 'thaiDist';\n\n/** `ST_TextFontAlignType`. */\nexport type FontAlign = 'auto' | 't' | 'ctr' | 'base' | 'b';\n\n/** `ST_TextUnderlineType`, all seventeen, as written. */\nexport type Underline =\n | 'none'\n | 'words'\n | 'sng'\n | 'dbl'\n | 'heavy'\n | 'dotted'\n | 'dottedHeavy'\n | 'dash'\n | 'dashHeavy'\n | 'dashLong'\n | 'dashLongHeavy'\n | 'dotDash'\n | 'dotDashHeavy'\n | 'dotDotDash'\n | 'dotDotDashHeavy'\n | 'wavy'\n | 'wavyHeavy'\n | 'wavyDbl';\n\n/** `ST_TextStrikeType`. */\nexport type Strike = 'noStrike' | 'sngStrike' | 'dblStrike';\n\n/** `ST_TextCapsType`. */\nexport type Caps = 'none' | 'small' | 'all';\n\n/**\n * `a:lnSpc`, `a:spcBef` and `a:spcAft`, which are one of two quite different\n * things and say which in their child element's name.\n *\n * `a:spcPct` is hundred-thousandths of the line height - 150000 is 150%.\n * `a:spcPts` is hundredths of a point - 3000 is 30pt. Conflating them collapses\n * every slide that uses the second, and `ST_Percentage` accepts *both* the\n * `150000` and the `150%` spellings, so the parse is not `parseInt` either:\n * `parseInt(\"150%\")` is 150, which is 0.15% line spacing. Measured in 3.1, and\n * in 2.6 for the colour transforms that share the type.\n */\nexport type Spacing =\n | { readonly kind: 'percent'; readonly value: number }\n | { readonly kind: 'points'; readonly value: number };\n\n/**\n * One of the four typeface slots on a run.\n *\n * `@typeface` may be a real face name or a theme reference - `+mj-lt`,\n * `+mn-lt`, `+mj-ea`, `+mn-ea`, `+mj-cs`, `+mn-cs` - and the reference is kept\n * as written rather than resolved here, because which theme it resolves against\n * is a property of the sheet and not of the run.\n */\nexport interface Typeface {\n readonly typeface: string;\n /** `@panose`, twenty hex characters. */\n readonly panose: string | undefined;\n /** `@pitchFamily`, `(family << 4) | pitch`. */\n readonly pitchFamily: number | undefined;\n /** `@charset`, **signed**: Shift-JIS is -128, not 128. */\n readonly charset: number | undefined;\n}\n\n/**\n * Which of a theme's two font collections a `+mj-`/`+mn-` reference names.\n *\n * `script` is spelled the way `FontCollection` spells it rather than the way the\n * reference does - `lt` in the markup is the `a:latin` element, and a resolver\n * that carried the reference's spelling would need a second map between two\n * three-member sets to index the thing it just parsed.\n */\nexport type ThemeFontRef = {\n readonly collection: 'major' | 'minor';\n readonly script: 'latin' | 'ea' | 'cs';\n};\n\nconst THEME_FONT = /^\\+(mj|mn)-(lt|ea|cs)$/;\n\n/** `+mn-lt` and its five siblings, or `null` for a real typeface name. */\nexport function themeFontRef(typeface: string): ThemeFontRef | null {\n const match = THEME_FONT.exec(typeface);\n if (match === null) return null;\n const script = match[2];\n return {\n collection: match[1] === 'mj' ? 'major' : 'minor',\n script: script === 'lt' ? 'latin' : (script as 'ea' | 'cs'),\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* run properties */\n/* -------------------------------------------------------------------------- */\n\n/**\n * `CT_TextCharacterProperties` - `a:rPr`, `a:defRPr` and `a:endParaRPr`.\n *\n * Every field is optional in the file and optional here. The cascade merges\n * these **per property**: measured in 3.1 with five levels declaring one\n * property each, which produced a 24-point bold italic underlined struck run\n * where a nearest-level-takes-all reading gives an 18-point struck one.\n */\nexport interface RunProps {\n /** `@sz`, hundredths of a point. 2400 is 24pt. */\n readonly sz: number | undefined;\n readonly b: boolean | undefined;\n readonly i: boolean | undefined;\n readonly u: Underline | undefined;\n readonly strike: Strike | undefined;\n readonly cap: Caps | undefined;\n /** `@spc`, hundredths of a point. May be negative. */\n readonly spc: number | undefined;\n /** `@kern`, hundredths of a point: the size at or above which to kern. */\n readonly kern: number | undefined;\n /** `@baseline`, hundred-thousandths. 30000 is superscript. */\n readonly baseline: number | undefined;\n readonly noProof: boolean | undefined;\n readonly lang: string | undefined;\n readonly altLang: string | undefined;\n readonly latin: Typeface | undefined;\n readonly ea: Typeface | undefined;\n readonly cs: Typeface | undefined;\n readonly sym: Typeface | undefined;\n /** The text's own fill: `a:solidFill` and its siblings inside `a:rPr`. */\n readonly fill: Fill | undefined;\n /** `a:ln` inside `a:rPr`: the outline of the glyphs. */\n readonly line: Line | undefined;\n readonly effects: readonly Effect[] | undefined;\n /** `a:highlight`, which is a colour and not a fill. */\n readonly highlight: Color | undefined;\n /** The element this was read from. Edits go here, never to the fields above. */\n readonly node: XElement;\n}\n\n/* -------------------------------------------------------------------------- */\n/* paragraph properties */\n/* -------------------------------------------------------------------------- */\n\n/* -------------------------------------------------------------------------- */\n/* bullets */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The exclusive group in `CT_TextParagraphProperties`: one of four, or nothing.\n *\n * `undefined` on `ParaProps` is the fifth case and the one that matters -\n * a level that declares no bullet element at all **inherits** one, where\n * `'none'` suppresses it.\n */\nexport type BulletKind = 'none' | 'char' | 'autonum' | 'blip';\n\n/** `a:buFont` / `a:buFontTx`, which are exclusive of each other. */\nexport type BulletFont =\n | { readonly kind: 'typeface'; readonly value: Typeface }\n /** `a:buFontTx`: follow the text, and cancel anything inherited. */\n | { readonly kind: 'text' };\n\n/** `a:buSzPct` / `a:buSzPts` / `a:buSzTx`. */\nexport type BulletSize =\n /** `a:buSzPct/@val`, thousandths of a percent of the first run's size. */\n | { readonly kind: 'percent'; readonly value: number }\n /** `a:buSzPts/@val`, hundredths of a point, absolute. */\n | { readonly kind: 'points'; readonly value: number }\n | { readonly kind: 'text' };\n\n/** `a:buClr` / `a:buClrTx`. */\nexport type BulletColor =\n { readonly kind: 'color'; readonly value: Color } | { readonly kind: 'text' };\n\n/** `a:buAutoNum`. */\nexport interface BulletAutoNum {\n /** `@type`, one of the 41 `ST_TextAutonumberScheme` values. */\n readonly type: string;\n /**\n * `@startAt`. Absent is measured to behave exactly as `1` - but the two are\n * kept apart, because a paragraph whose `startAt` differs from its\n * predecessor's begins a new run, and \"absent\" has to compare equal to \"1\"\n * for that rule rather than to nothing.\n */\n readonly startAt: number | undefined;\n}\n\n/**\n * `CT_TextParagraphProperties` - `a:pPr` and every `a:lvlNpPr`.\n *\n * `@lvl` is deliberately absent. It is the level a paragraph *is at*, not a\n * property that inherits: an `a:lvl3pPr` carrying `lvl=\"7\"` would be nonsense,\n * and a cascade that inherited it would change which level the next lookup used\n * halfway through resolving one paragraph.\n */\nexport interface ParaProps {\n /** `@marL`, EMU. Measured to default to **0**, not to the schema's 347663. */\n readonly marL: number | undefined;\n readonly marR: number | undefined;\n /** `@indent`, EMU, usually negative. Defaults to 0, not to -342900. */\n readonly indent: number | undefined;\n readonly algn: TextAlign | undefined;\n /** `@defTabSz`, EMU. */\n readonly defTabSz: number | undefined;\n readonly rtl: boolean | undefined;\n readonly eaLnBrk: boolean | undefined;\n readonly fontAlgn: FontAlign | undefined;\n /** `@latinLnBrk`. ECMA says the default is true; PowerPoint behaves as false. */\n readonly latinLnBrk: boolean | undefined;\n readonly hangingPunct: boolean | undefined;\n readonly lnSpc: Spacing | undefined;\n readonly spcBef: Spacing | undefined;\n readonly spcAft: Spacing | undefined;\n /** `a:defRPr`: the run properties every run in this paragraph starts from. */\n readonly defRPr: RunProps | undefined;\n /**\n * Which of `a:buNone`, `a:buChar`, `a:buAutoNum` and `a:buBlip` this level\n * states, or `undefined` where it states none and inherits instead.\n */\n readonly buKind: BulletKind | undefined;\n /** `a:buChar/@char`, exactly as written. The symbol mapping happens at draw time. */\n readonly buChar: string | undefined;\n readonly buAutoNum: BulletAutoNum | undefined;\n /** `a:buBlip/a:blip/@r:embed`. */\n readonly buBlip: string | undefined;\n /**\n * The three decorations, each its own slot.\n *\n * They merge independently of the kind and of each other, which is measured\n * rather than assumed: a level declaring only `a:buFont` re-faces the\n * character it inherits and keeps its size and colour, and a level declaring\n * only `a:buSzTx` cancels an inherited `a:buSzPct` and keeps the rest.\n * Measured on eleven cases twice - once through a shape's own `a:lstStyle`\n * and once through three hops of the master chain.\n */\n readonly buFont: BulletFont | undefined;\n readonly buSize: BulletSize | undefined;\n readonly buColor: BulletColor | undefined;\n readonly node: XElement;\n}\n\n/**\n * `CT_TextListStyle`: nine levels, and an `a:defPPr` nothing reads.\n *\n * `levels[0]` is `a:lvl1pPr`, which a paragraph at `lvl=\"0\"` uses. Measured in\n * 3.1: the levels are independent all the way up the chain - a layout\n * placeholder declaring only `a:lvl2pPr` changes the second level and leaves the\n * first and third to the master - so this is nine slots and not one object.\n *\n * `a:defPPr` is parsed and kept because it is in the file, and it is **not** a\n * source: measured on a shape's own `a:lstStyle` and on `p:defaultTextStyle`,\n * declaring only an `a:defPPr` changed nothing either time.\n */\nexport interface ListStyle {\n /** Nine entries, `a:lvl1pPr` through `a:lvl9pPr`, absent ones `undefined`. */\n readonly levels: readonly (ParaProps | undefined)[];\n /** `a:defPPr`. Preserved, never resolved against. */\n readonly defPPr: ParaProps | undefined;\n readonly node: XElement;\n}\n\n/** The number of levels a `CT_TextListStyle` holds, and `@lvl`'s range plus one. */\nexport const LEVELS = 9;\n\n/* -------------------------------------------------------------------------- */\n/* the text body */\n/* -------------------------------------------------------------------------- */\n\n/** `a:r`: a run of text with its own properties. */\nexport interface TextRun {\n readonly kind: 'run';\n readonly props: RunProps | undefined;\n readonly text: string;\n readonly node: XElement;\n}\n\n/**\n * `a:br`: a hard line break.\n *\n * Not a paragraph break. It starts no new bullet, resets no first-line indent\n * and applies neither `spcBef` nor `spcAft` - which is 3.6's problem, and is\n * recorded here so that nothing later mistakes it for an `a:p`.\n */\nexport interface TextBreak {\n readonly kind: 'br';\n readonly props: RunProps | undefined;\n readonly node: XElement;\n}\n\n/** `a:fld`: a field, with the text PowerPoint last cached for it. */\nexport interface TextField {\n readonly kind: 'field';\n /** `@id`, a required `ST_Guid`. Regenerating it is a repair risk. */\n readonly id: string;\n /** `@type`, one of the fourteen reserved names or a custom one. */\n readonly fieldType: string | undefined;\n readonly props: RunProps | undefined;\n readonly text: string;\n readonly node: XElement;\n}\n\nexport type TextContent = TextRun | TextBreak | TextField;\n\n/** `a:p`. */\nexport interface Paragraph {\n readonly props: ParaProps | undefined;\n /**\n * `a:pPr/@lvl`, 0 through 8, defaulting to 0.\n *\n * Read off the paragraph rather than inherited, and clamped rather than\n * thrown on: `ST_TextIndentLevelType` bounds it at 8, and a file outside the\n * bound is one PowerPoint still opens.\n */\n readonly level: number;\n readonly content: readonly TextContent[];\n /** `a:endParaRPr`: the properties of the (empty) run after the last one. */\n readonly endParaRPr: RunProps | undefined;\n readonly node: XElement;\n}\n\n/** `ST_TextAnchoringType`. PowerPoint lays `just` and `dist` out as `b`. */\nexport type TextAnchor = 't' | 'ctr' | 'b' | 'just' | 'dist';\n\n/** `ST_TextVerticalType`. */\nexport type VerticalText =\n 'horz' | 'vert' | 'vert270' | 'wordArtVert' | 'eaVert' | 'mongolianVert' | 'wordArtVertRtl';\n\n/** `ST_TextWrappingType`. */\nexport type TextWrap = 'none' | 'square';\n\n/** `ST_TextVertOverflowType`. */\nexport type VertOverflow = 'overflow' | 'ellipsis' | 'clip';\n\n/** `ST_TextHorzOverflowType`. */\nexport type HorzOverflow = 'overflow' | 'clip';\n\n/** The one autofit child an `a:bodyPr` may carry. */\nexport type Autofit =\n | { readonly kind: 'none' }\n | { readonly kind: 'shape' }\n | {\n readonly kind: 'normal';\n /** `@fontScale`, thousandths of a percent. */\n readonly fontScale: number | undefined;\n /** `@lnSpcReduction`, thousandths of a percent. */\n readonly lnSpcReduction: number | undefined;\n };\n\n/**\n * `a:bodyPr`, as the file states it.\n *\n * Lengths are EMU and `rot` is 60000ths of a degree, both as written. Every\n * attribute inherits through the placeholder chain on its own - measured in 3.6\n * at all three levels - so absence has to survive parsing.\n */\nexport interface BodyProps {\n readonly anchor: TextAnchor | undefined;\n readonly anchorCtr: boolean | undefined;\n readonly lIns: number | undefined;\n readonly tIns: number | undefined;\n readonly rIns: number | undefined;\n readonly bIns: number | undefined;\n readonly vert: VerticalText | undefined;\n readonly wrap: TextWrap | undefined;\n readonly vertOverflow: VertOverflow | undefined;\n readonly horzOverflow: HorzOverflow | undefined;\n readonly rot: number | undefined;\n readonly upright: boolean | undefined;\n readonly numCol: number | undefined;\n readonly spcCol: number | undefined;\n readonly rtlCol: boolean | undefined;\n readonly spcFirstLastPara: boolean | undefined;\n readonly compatLnSpc: boolean | undefined;\n readonly fromWordArt: boolean | undefined;\n readonly forceAA: boolean | undefined;\n readonly autofit: Autofit | undefined;\n readonly node: XElement;\n}\n\n/** `p:txBody` / `a:txBody`. */\nexport interface TextBody {\n readonly bodyPr: BodyProps | undefined;\n readonly lstStyle: ListStyle | undefined;\n readonly paragraphs: readonly Paragraph[];\n readonly node: XElement;\n}\n\n/* -------------------------------------------------------------------------- */\n/* the master's text styles */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The bucket of `p:txStyles` a shape reads, or `null` for one that reads none.\n *\n * `other` is in the union because the element exists, not because anything\n * reaches it - see the module comment.\n */\nexport type TextStyleBucket = 'title' | 'body' | 'other';\n\n/** `p:txStyles` on a master. */\nexport interface TextStyles {\n readonly title: ListStyle | undefined;\n readonly body: ListStyle | undefined;\n readonly other: ListStyle | undefined;\n readonly node: XElement;\n}\n","/**\n * `p:txBody`, `a:lstStyle` and `p:txStyles` into the text model.\n *\n * Nothing here resolves anything and nothing here defaults anything the file\n * could have said. That is the same rule the rest of the parser follows, and in\n * this one corner it is load-bearing rather than tidy: `@marL` and `@indent`\n * have schema defaults of 347663 and -342900, and a parser that materialises\n * them gives every paragraph a 27-point hanging indent it never asked for *and*\n * blocks the value it should have inherited, because a default that has been\n * written down cannot be told from a declaration. Measured in 3.1 - PowerPoint\n * resolves both to 0 when nothing declares them.\n *\n * The one place a value is supplied is `Paragraph.level`, which is 0 when\n * `@lvl` is absent because that is what the attribute means rather than what the\n * schema says, and which is not inherited by anything.\n */\n\nimport { parsePercentage } from '@pptx-studio/paint';\nimport { attributeValue, childElements, firstChild, textContent } from '@pptx-studio/xml';\nimport type { XElement } from '@pptx-studio/xml';\n\nimport { ModelError } from '../errors.js';\nimport { parseBodyPropsChild } from './body.js';\nimport { parseColorChild, parseEffects, parseFill, parseLine } from './paint.js';\nimport {\n type BulletAutoNum,\n type BulletColor,\n type BulletFont,\n type BulletKind,\n type BulletSize,\n LEVELS,\n type Caps,\n type FontAlign,\n type ListStyle,\n type Paragraph,\n type ParaProps,\n type RunProps,\n type Spacing,\n type Strike,\n type TextAlign,\n type TextBody,\n type TextContent,\n type TextStyles,\n type Typeface,\n type Underline,\n} from '../text.js';\n\n/* -------------------------------------------------------------------------- */\n/* attribute readers */\n/* -------------------------------------------------------------------------- */\n\n/**\n * `ST_OnOff`, which has four lexical forms and not two.\n *\n * `1`/`true` and `0`/`false`. Anything else is a file that says something we do\n * not understand, and guessing is how an explicit `b=\"0\"` becomes bold.\n */\nfunction boolOf(element: XElement, name: string, partName: string): boolean | undefined {\n const raw = attributeValue(element, name);\n if (raw === undefined) return undefined;\n if (raw === '1' || raw === 'true') return true;\n if (raw === '0' || raw === 'false') return false;\n throw new ModelError(\n 'MODEL_TEXT_ATTR',\n `${element.qname}/@${name} is \"${raw}\", which is not a ST_OnOff`,\n partName,\n name,\n );\n}\n\nfunction intOf(element: XElement, name: string, partName: string): number | undefined {\n const raw = attributeValue(element, name);\n if (raw === undefined) return undefined;\n const value = Number(raw);\n if (!Number.isInteger(value)) {\n throw new ModelError(\n 'MODEL_TEXT_ATTR',\n `${element.qname}/@${name} is \"${raw}\", which is not an integer`,\n partName,\n name,\n );\n }\n return value;\n}\n\n/**\n * An attribute whose value must be one of a fixed set.\n *\n * A value outside the set throws rather than falling back to the first member.\n * A silent fallback here paints the wrong thing and gives nothing to trace it\n * by, and `ST_TextAlignType` in particular has a member - `just` - whose\n * substitute would be plausible on most slides and wrong on the rest.\n */\nfunction enumOf<T extends string>(\n element: XElement,\n name: string,\n allowed: readonly T[],\n partName: string,\n): T | undefined {\n const raw = attributeValue(element, name);\n if (raw === undefined) return undefined;\n if (!(allowed as readonly string[]).includes(raw)) {\n throw new ModelError(\n 'MODEL_TEXT_ATTR',\n `${element.qname}/@${name} is \"${raw}\", which is not one of ${allowed.join(', ')}`,\n partName,\n name,\n );\n }\n return raw as T;\n}\n\nconst ALIGN: readonly TextAlign[] = ['l', 'ctr', 'r', 'just', 'justLow', 'dist', 'thaiDist'];\nconst FONT_ALIGN: readonly FontAlign[] = ['auto', 't', 'ctr', 'base', 'b'];\nconst STRIKE: readonly Strike[] = ['noStrike', 'sngStrike', 'dblStrike'];\nconst CAPS: readonly Caps[] = ['none', 'small', 'all'];\nconst UNDERLINE: readonly Underline[] = [\n 'none',\n 'words',\n 'sng',\n 'dbl',\n 'heavy',\n 'dotted',\n 'dottedHeavy',\n 'dash',\n 'dashHeavy',\n 'dashLong',\n 'dashLongHeavy',\n 'dotDash',\n 'dotDashHeavy',\n 'dotDotDash',\n 'dotDotDashHeavy',\n 'wavy',\n 'wavyHeavy',\n 'wavyDbl',\n];\n\n/* -------------------------------------------------------------------------- */\n/* typefaces */\n/* -------------------------------------------------------------------------- */\n\n/**\n * `a:latin` and its three siblings.\n *\n * `@charset` is **signed**: Shift-JIS is written `-128`, and reading it as an\n * unsigned byte turns the one value that identifies Japanese text into 128,\n * which is nothing. `@panose` is kept as the twenty hex characters it is,\n * because it is written back verbatim and nothing here interprets it.\n */\nfunction typefaceOf(element: XElement, partName: string): Typeface {\n const typeface = attributeValue(element, 'typeface');\n if (typeface === undefined) {\n throw new ModelError(\n 'MODEL_TEXT_ATTR',\n `${element.qname} has no @typeface`,\n partName,\n element.qname,\n );\n }\n return {\n typeface,\n panose: attributeValue(element, 'panose'),\n pitchFamily: intOf(element, 'pitchFamily', partName),\n charset: intOf(element, 'charset', partName),\n };\n}\n\n/**\n * A named typeface child.\n *\n * Split from `typefaceOf` because `a:buFont` carries the same attributes on the\n * element itself rather than on a child of a known name, and reading it through\n * a lookup by qname would need the caller to pass its own element as its own\n * parent.\n */\nfunction parseTypeface(parent: XElement, qname: string, partName: string): Typeface | undefined {\n const element = firstChild(parent, qname);\n return element === undefined ? undefined : typefaceOf(element, partName);\n}\n\n/* -------------------------------------------------------------------------- */\n/* run properties */\n/* -------------------------------------------------------------------------- */\n\n/** `a:rPr`, `a:defRPr` or `a:endParaRPr` - one type under three names. */\nexport function parseRunProps(element: XElement, partName: string): RunProps {\n return {\n sz: intOf(element, 'sz', partName),\n b: boolOf(element, 'b', partName),\n i: boolOf(element, 'i', partName),\n u: enumOf(element, 'u', UNDERLINE, partName),\n strike: enumOf(element, 'strike', STRIKE, partName),\n cap: enumOf(element, 'cap', CAPS, partName),\n spc: intOf(element, 'spc', partName),\n kern: intOf(element, 'kern', partName),\n baseline: intOf(element, 'baseline', partName),\n noProof: boolOf(element, 'noProof', partName),\n lang: attributeValue(element, 'lang'),\n altLang: attributeValue(element, 'altLang'),\n latin: parseTypeface(element, 'a:latin', partName),\n ea: parseTypeface(element, 'a:ea', partName),\n cs: parseTypeface(element, 'a:cs', partName),\n sym: parseTypeface(element, 'a:sym', partName),\n fill: parseFill(element, partName),\n line: parseLine(element, partName),\n effects: parseEffects(element),\n highlight: parseColorChild(firstChild(element, 'a:highlight')) ?? undefined,\n node: element,\n };\n}\n\nfunction parseRunPropsChild(\n parent: XElement,\n qname: string,\n partName: string,\n): RunProps | undefined {\n const element = firstChild(parent, qname);\n return element === undefined ? undefined : parseRunProps(element, partName);\n}\n\n/* -------------------------------------------------------------------------- */\n/* spacing */\n/* -------------------------------------------------------------------------- */\n\n/**\n * `a:lnSpc`, `a:spcBef` or `a:spcAft`.\n *\n * The child's name is the unit. `a:spcPct` is a `ST_TextSpacingPercentOrPercentString`\n * and so accepts both the `150000` and the `150%` spellings - `parsePercentage`\n * handles the second, measured in 2.6 for colour and again in 3.1 here.\n * `a:spcPts` is hundredths of a point and has only one spelling.\n */\nfunction parseSpacing(parent: XElement, qname: string, partName: string): Spacing | undefined {\n const element = firstChild(parent, qname);\n if (element === undefined) return undefined;\n const pct = firstChild(element, 'a:spcPct');\n if (pct !== undefined) {\n const raw = attributeValue(pct, 'val');\n if (raw === undefined) {\n throw new ModelError('MODEL_TEXT_ATTR', `${qname}/a:spcPct has no @val`, partName, qname);\n }\n return { kind: 'percent', value: parsePercentage(raw) };\n }\n const pts = firstChild(element, 'a:spcPts');\n if (pts !== undefined) {\n const value = intOf(pts, 'val', partName);\n if (value === undefined) {\n throw new ModelError('MODEL_TEXT_ATTR', `${qname}/a:spcPts has no @val`, partName, qname);\n }\n return { kind: 'points', value };\n }\n // `<a:lnSpc/>` with neither child is legal markup that states nothing, and\n // that is different from stating a spacing of zero.\n return undefined;\n}\n\n/* -------------------------------------------------------------------------- */\n/* paragraph properties */\n/* -------------------------------------------------------------------------- */\n\n/** `a:pPr`, `a:defPPr` or any `a:lvlNpPr` - one type under eleven names. */\nexport function parseParaProps(element: XElement, partName: string): ParaProps {\n return {\n marL: intOf(element, 'marL', partName),\n marR: intOf(element, 'marR', partName),\n indent: intOf(element, 'indent', partName),\n algn: enumOf(element, 'algn', ALIGN, partName),\n defTabSz: intOf(element, 'defTabSz', partName),\n rtl: boolOf(element, 'rtl', partName),\n eaLnBrk: boolOf(element, 'eaLnBrk', partName),\n fontAlgn: enumOf(element, 'fontAlgn', FONT_ALIGN, partName),\n latinLnBrk: boolOf(element, 'latinLnBrk', partName),\n hangingPunct: boolOf(element, 'hangingPunct', partName),\n lnSpc: parseSpacing(element, 'a:lnSpc', partName),\n spcBef: parseSpacing(element, 'a:spcBef', partName),\n spcAft: parseSpacing(element, 'a:spcAft', partName),\n defRPr: parseRunPropsChild(element, 'a:defRPr', partName),\n ...parseBullet(element, partName),\n node: element,\n };\n}\n\n/** The four bullet elements, of which at most one may appear. */\nconst BULLET_KINDS: readonly (readonly [string, BulletKind])[] = [\n ['a:buNone', 'none'],\n ['a:buChar', 'char'],\n ['a:buAutoNum', 'autonum'],\n ['a:buBlip', 'blip'],\n];\n\n/**\n * The bullet, as four independent slots plus the exclusive kind.\n *\n * Four rather than one because T5 measured them to merge separately: a level\n * that declares only `a:buFont` re-faces an inherited `a:buChar` and keeps\n * everything else. Folding them into a single value would make that impossible\n * to express, and the fold is what a reader writes first because the schema puts\n * the four kinds in one exclusive group.\n *\n * `a:buFontTx`, `a:buSzTx` and `a:buClrTx` are parsed as *values* rather than as\n * absences, because they are: PowerPoint writes nothing at all to mean \"follow\n * the text\", so the explicit element only ever appears in order to cancel\n * something a level above declared.\n */\nfunction parseBullet(\n element: XElement,\n partName: string,\n): Pick<ParaProps, 'buKind' | 'buChar' | 'buAutoNum' | 'buBlip' | 'buFont' | 'buSize' | 'buColor'> {\n let buKind: BulletKind | undefined;\n for (const [name, kind] of BULLET_KINDS) {\n if (firstChild(element, name) !== undefined) {\n if (buKind !== undefined) {\n throw new ModelError(\n 'MODEL_TEXT_BULLET',\n `a:pPr declares both ${buKind} and ${kind} bullets, which are exclusive`,\n partName,\n 'a:pPr',\n );\n }\n buKind = kind;\n }\n }\n\n const charElement = firstChild(element, 'a:buChar');\n const autoNum = firstChild(element, 'a:buAutoNum');\n const blip = firstChild(element, 'a:buBlip');\n const font = firstChild(element, 'a:buFont');\n const szPct = firstChild(element, 'a:buSzPct');\n const szPts = firstChild(element, 'a:buSzPts');\n const clr = firstChild(element, 'a:buClr');\n\n let buAutoNum: BulletAutoNum | undefined;\n if (autoNum !== undefined) {\n const type = attributeValue(autoNum, 'type');\n if (type === undefined) {\n throw new ModelError(\n 'MODEL_TEXT_BULLET',\n 'a:buAutoNum has no @type, which the schema requires',\n partName,\n 'a:buAutoNum',\n );\n }\n buAutoNum = { type, startAt: intOf(autoNum, 'startAt', partName) };\n }\n\n let buBlip: string | undefined;\n if (blip !== undefined) {\n const embed = firstChild(blip, 'a:blip');\n buBlip = embed === undefined ? undefined : attributeValue(embed, 'r:embed');\n if (buBlip === undefined) {\n throw new ModelError(\n 'MODEL_TEXT_BULLET',\n 'a:buBlip has no a:blip/@r:embed to resolve',\n partName,\n 'a:buBlip',\n );\n }\n }\n\n let buFont: BulletFont | undefined;\n if (firstChild(element, 'a:buFontTx') !== undefined) buFont = { kind: 'text' };\n else if (font !== undefined) buFont = { kind: 'typeface', value: typefaceOf(font, partName) };\n\n let buSize: BulletSize | undefined;\n if (firstChild(element, 'a:buSzTx') !== undefined) buSize = { kind: 'text' };\n else if (szPct !== undefined) {\n buSize = { kind: 'percent', value: requiredPercentage(szPct, partName, 'a:buSzPct') };\n } else if (szPts !== undefined) {\n buSize = { kind: 'points', value: requiredInt(szPts, partName, 'a:buSzPts') };\n }\n\n let buColor: BulletColor | undefined;\n if (firstChild(element, 'a:buClrTx') !== undefined) buColor = { kind: 'text' };\n else if (clr !== undefined) {\n const value = parseColorChild(clr);\n if (value === undefined || value === null) {\n throw new ModelError('MODEL_TEXT_BULLET', 'a:buClr holds no colour', partName, 'a:buClr');\n }\n buColor = { kind: 'color', value };\n }\n\n return {\n buKind,\n buChar: charElement === undefined ? undefined : (attributeValue(charElement, 'char') ?? ''),\n buAutoNum,\n buBlip,\n buFont,\n buSize,\n buColor,\n };\n}\n\n/** `@val` on a `a:buSzPct`, which the schema makes required. */\nfunction requiredPercentage(element: XElement, partName: string, what: string): number {\n const raw = attributeValue(element, 'val');\n if (raw === undefined) {\n throw new ModelError('MODEL_TEXT_BULLET', `${what} has no @val`, partName, what);\n }\n return parsePercentage(raw);\n}\n\n/** `@val` on a `a:buSzPts`, in hundredths of a point. */\nfunction requiredInt(element: XElement, partName: string, what: string): number {\n const value = intOf(element, 'val', partName);\n if (value === undefined) {\n throw new ModelError('MODEL_TEXT_BULLET', `${what} has no @val`, partName, what);\n }\n return value;\n}\n\n/* -------------------------------------------------------------------------- */\n/* list styles */\n/* -------------------------------------------------------------------------- */\n\nconst LEVEL_NAMES: readonly string[] = Array.from(\n { length: LEVELS },\n (_, i) => `a:lvl${String(i + 1)}pPr`,\n);\n\n/**\n * `a:lstStyle`, or a `p:txStyles` bucket, which is the same type unwrapped.\n *\n * The nine levels are independent: measured in 3.1, a layout placeholder\n * declaring only `a:lvl2pPr` changes the second level and leaves the first and\n * third to the master. So a level nobody declared stays `undefined` rather than\n * falling back to level one, and the resolver asks per level.\n */\nexport function parseListStyle(element: XElement, partName: string): ListStyle {\n const levels: (ParaProps | undefined)[] = [];\n for (const name of LEVEL_NAMES) {\n const level = firstChild(element, name);\n levels.push(level === undefined ? undefined : parseParaProps(level, partName));\n }\n const defPPr = firstChild(element, 'a:defPPr');\n return {\n levels,\n defPPr: defPPr === undefined ? undefined : parseParaProps(defPPr, partName),\n node: element,\n };\n}\n\nfunction parseListStyleChild(\n parent: XElement,\n qname: string,\n partName: string,\n): ListStyle | undefined {\n const element = firstChild(parent, qname);\n return element === undefined ? undefined : parseListStyle(element, partName);\n}\n\n/** `p:txStyles` on a master. */\nexport function parseTextStyles(element: XElement, partName: string): TextStyles {\n return {\n title: parseListStyleChild(element, 'p:titleStyle', partName),\n body: parseListStyleChild(element, 'p:bodyStyle', partName),\n other: parseListStyleChild(element, 'p:otherStyle', partName),\n node: element,\n };\n}\n\n/** `p:defaultTextStyle` on `ppt/presentation.xml`, which is a `CT_TextListStyle`. */\nexport function parseDefaultTextStyle(\n presentation: XElement,\n partName: string,\n): ListStyle | undefined {\n return parseListStyleChild(presentation, 'p:defaultTextStyle', partName);\n}\n\n/* -------------------------------------------------------------------------- */\n/* paragraphs and runs */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The paragraph's level, from `a:pPr/@lvl`.\n *\n * `ST_TextIndentLevelType` bounds it at 0..8 and PowerPoint still opens a file\n * outside the bound, so this clamps rather than throws - refusing to render a\n * deck PowerPoint renders is a worse answer than rendering it the way\n * PowerPoint does. A non-integer is a different matter and does throw: that is\n * a file saying something nobody can act on.\n */\nfunction levelOf(pPr: XElement | undefined, partName: string): number {\n if (pPr === undefined) return 0;\n const lvl = intOf(pPr, 'lvl', partName);\n if (lvl === undefined) return 0;\n return Math.max(0, Math.min(LEVELS - 1, lvl));\n}\n\nfunction parseContent(element: XElement, partName: string): TextContent | null {\n if (element.qname === 'a:r') {\n const t = firstChild(element, 'a:t');\n return {\n kind: 'run',\n props: parseRunPropsChild(element, 'a:rPr', partName),\n text: t === undefined ? '' : textContent(t),\n node: element,\n };\n }\n if (element.qname === 'a:br') {\n return {\n kind: 'br',\n props: parseRunPropsChild(element, 'a:rPr', partName),\n node: element,\n };\n }\n if (element.qname === 'a:fld') {\n const id = attributeValue(element, 'id');\n if (id === undefined) {\n // `@id` is a required `ST_Guid` and PowerPoint may repair a file that\n // lost one. Inventing a replacement would be writing markup we did not\n // read, so this refuses instead.\n throw new ModelError('MODEL_TEXT_FIELD', 'a:fld has no @id', partName, 'a:fld');\n }\n const t = firstChild(element, 'a:t');\n return {\n kind: 'field',\n id,\n fieldType: attributeValue(element, 'type'),\n props: parseRunPropsChild(element, 'a:rPr', partName),\n text: t === undefined ? '' : textContent(t),\n node: element,\n };\n }\n return null;\n}\n\nfunction parseParagraph(element: XElement, partName: string): Paragraph {\n const pPr = firstChild(element, 'a:pPr');\n const content: TextContent[] = [];\n for (const child of childElements(element)) {\n const parsed = parseContent(child, partName);\n if (parsed !== null) content.push(parsed);\n }\n return {\n props: pPr === undefined ? undefined : parseParaProps(pPr, partName),\n level: levelOf(pPr, partName),\n content,\n endParaRPr: parseRunPropsChild(element, 'a:endParaRPr', partName),\n node: element,\n };\n}\n\n/** A `p:txBody` or an `a:txBody`. */\nexport function parseTextBody(element: XElement, partName: string): TextBody {\n return {\n bodyPr: parseBodyPropsChild(element, partName),\n lstStyle: parseListStyleChild(element, 'a:lstStyle', partName),\n paragraphs: childElements(element)\n .filter((child) => child.qname === 'a:p')\n .map((child) => parseParagraph(child, partName)),\n node: element,\n };\n}\n\n/** The `p:txBody` of a shape, when it has one. */\nexport function parseTextBodyChild(parent: XElement, partName: string): TextBody | undefined {\n const element = firstChild(parent, 'p:txBody') ?? firstChild(parent, 'a:txBody');\n return element === undefined ? undefined : parseTextBody(element, partName);\n}\n","/**\n * A slide, layout or master part into a `Sheet`; a theme part into a `Theme`.\n *\n * Nothing here resolves anything and nothing here defaults anything that the\n * file could have said. The one exception is `showMasterShapes`, whose default\n * is `true` and which has no third state to preserve.\n */\n\nimport {\n MAPPED_COLOR_NAMES,\n SCHEME_SLOTS,\n type ClrMap,\n type ClrScheme,\n type Color,\n type Effect,\n type Fill,\n type Line,\n type MappedColorName,\n type SchemeSlot,\n} from '@pptx-studio/paint';\nimport { attributeValue, childElements, firstChild, type XElement } from '@pptx-studio/xml';\n\nimport { parseGeometry } from './geometry.js';\n\nimport { ModelError } from '../errors.js';\nimport {\n parseColorElement,\n parseEffects,\n parseFill,\n parseFillElement,\n parsePictureFill,\n parseLine,\n parseLineElement,\n} from './paint.js';\nimport { parseTextBodyChild, parseTextStyles } from './text.js';\nimport {\n PLACEHOLDER_TYPES,\n type Background,\n type ColorMapOverride,\n type FontCollection,\n type FontScheme,\n type FormatScheme,\n type Placeholder,\n type PlaceholderSize,\n type PlaceholderType,\n type Shape,\n type ShapeKind,\n type ShapeStyle,\n type Sheet,\n type SheetKind,\n type StyleRef,\n type Theme,\n type Xfrm,\n} from '../types.js';\n\n/* -------------------------------------------------------------------------- */\n/* the colour map */\n/* -------------------------------------------------------------------------- */\n\nconst SLOT_SET: ReadonlySet<string> = new Set<string>(SCHEME_SLOTS);\n\n/**\n * `p:clrMap` or `a:overrideClrMapping`: all twelve attributes, every time.\n *\n * Eleven is a repair prompt, so a map that is missing one is a broken file\n * rather than a partial opinion, and there is nothing sensible to default the\n * missing one to.\n */\nexport function parseClrMap(element: XElement, partName: string): ClrMap {\n const out: Partial<Record<MappedColorName, SchemeSlot>> = {};\n for (const name of MAPPED_COLOR_NAMES) {\n const raw = attributeValue(element, name);\n if (raw === undefined) {\n throw new ModelError(\n 'MODEL_CLRMAP_INCOMPLETE',\n `${element.qname} has no @${name}`,\n partName,\n name,\n );\n }\n if (!SLOT_SET.has(raw)) {\n throw new ModelError(\n 'MODEL_CLRMAP_SLOT',\n `${element.qname}/@${name} is \"${raw}\", which is not a clrScheme slot`,\n partName,\n raw,\n );\n }\n out[name] = raw as SchemeSlot;\n }\n return out as ClrMap;\n}\n\nfunction parseClrMapOvr(parent: XElement, partName: string): ColorMapOverride | undefined {\n const element = firstChild(parent, 'p:clrMapOvr');\n if (element === undefined) return undefined;\n const override = firstChild(element, 'a:overrideClrMapping');\n if (override !== undefined) return { kind: 'override', map: parseClrMap(override, partName) };\n return { kind: 'inherit' };\n}\n\n/* -------------------------------------------------------------------------- */\n/* geometry */\n/* -------------------------------------------------------------------------- */\n\nfunction intOf(element: XElement, name: string, partName: string): number {\n const raw = attributeValue(element, name);\n if (raw === undefined) return 0;\n const value = Number(raw);\n if (!Number.isInteger(value)) {\n throw new ModelError(\n 'MODEL_XFRM_NUMBER',\n `${element.qname}/@${name} is \"${raw}\"`,\n partName,\n raw,\n );\n }\n return value;\n}\n\n/**\n * The transform, from whichever element holds it.\n *\n * A `p:graphicFrame` keeps its geometry in a **PresentationML** `p:xfrm` and\n * has no `p:spPr` at all - it is a different element in a different namespace\n * from the `a:xfrm` every other shape uses, and looking for the wrong one gives\n * every chart, table, diagram and OLE object a size of zero.\n */\nfunction parseXfrm(parent: XElement, partName: string, qname = 'a:xfrm'): Xfrm | undefined {\n const element = firstChild(parent, qname);\n if (element === undefined) return undefined;\n const off = firstChild(element, 'a:off');\n const ext = firstChild(element, 'a:ext');\n const chOff = firstChild(element, 'a:chOff');\n const chExt = firstChild(element, 'a:chExt');\n return {\n x: off === undefined ? 0 : intOf(off, 'x', partName),\n y: off === undefined ? 0 : intOf(off, 'y', partName),\n cx: ext === undefined ? 0 : intOf(ext, 'cx', partName),\n cy: ext === undefined ? 0 : intOf(ext, 'cy', partName),\n rot: intOf(element, 'rot', partName),\n flipH: attributeValue(element, 'flipH') === '1',\n flipV: attributeValue(element, 'flipV') === '1',\n child:\n chOff === undefined && chExt === undefined\n ? null\n : {\n x: chOff === undefined ? 0 : intOf(chOff, 'x', partName),\n y: chOff === undefined ? 0 : intOf(chOff, 'y', partName),\n cx: chExt === undefined ? 0 : intOf(chExt, 'cx', partName),\n cy: chExt === undefined ? 0 : intOf(chExt, 'cy', partName),\n },\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* placeholders and styles */\n/* -------------------------------------------------------------------------- */\n\nconst TYPE_SET: ReadonlySet<string> = new Set<string>(PLACEHOLDER_TYPES);\nconst SIZE_SET: ReadonlySet<string> = new Set<string>(['full', 'half', 'quarter']);\n\n/** `2^32 - 1`, the top of `xsd:unsignedInt`, which is what `@idx` is. */\nconst MAX_IDX = 4294967295;\n\nfunction parsePlaceholder(nvPr: XElement | undefined, partName: string): Placeholder | null {\n if (nvPr === undefined) return null;\n const ph = firstChild(nvPr, 'p:ph');\n if (ph === undefined) return null;\n\n const rawType = attributeValue(ph, 'type');\n const rawIdx = attributeValue(ph, 'idx');\n let idx: number | null = null;\n if (rawIdx !== undefined) {\n const value = Number(rawIdx);\n if (!Number.isInteger(value) || value < 0 || value > MAX_IDX) {\n throw new ModelError(\n 'MODEL_PLACEHOLDER_IDX',\n `p:ph/@idx is \"${rawIdx}\", which is not an unsignedInt`,\n partName,\n rawIdx,\n );\n }\n idx = value;\n }\n\n const rawSize = attributeValue(ph, 'sz');\n const orient = attributeValue(ph, 'orient');\n return {\n // An unknown `@type` is recorded as written rather than dropped, so a\n // round trip keeps it. PowerPoint repairs the file and normalises it to\n // `obj`; the matcher below treats anything it does not know the same way.\n type: rawType !== undefined && TYPE_SET.has(rawType) ? (rawType as PlaceholderType) : null,\n idx,\n size: rawSize !== undefined && SIZE_SET.has(rawSize) ? (rawSize as PlaceholderSize) : null,\n orient: orient === 'vert' ? 'vert' : orient === 'horz' ? 'horz' : null,\n hasCustomPrompt: attributeValue(ph, 'hasCustomPrompt') === '1',\n };\n}\n\nfunction parseStyleRef(element: XElement | undefined, partName: string): StyleRef {\n if (element === undefined) return { idx: 0, color: null };\n const raw = attributeValue(element, 'idx');\n const idx = raw === undefined ? 0 : Number(raw);\n if (!Number.isInteger(idx) || idx < 0) {\n throw new ModelError(\n 'MODEL_STYLE_IDX',\n `${element.qname}/@idx is \"${String(raw)}\"`,\n partName,\n raw ?? '',\n );\n }\n let color: Color | null = null;\n for (const child of childElements(element)) {\n if (child.qname.startsWith('a:') && child.qname.endsWith('Clr')) {\n color = parseColorElement(child);\n break;\n }\n }\n return { idx, color };\n}\n\nfunction parseStyle(parent: XElement, partName: string): ShapeStyle | undefined {\n const element = firstChild(parent, 'p:style');\n if (element === undefined) return undefined;\n\n const fontRefElement = firstChild(element, 'a:fontRef');\n const rawFont = fontRefElement === undefined ? undefined : attributeValue(fontRefElement, 'idx');\n if (rawFont !== undefined && rawFont !== 'major' && rawFont !== 'minor' && rawFont !== 'none') {\n // `a:fontRef/@idx` is `ST_FontCollectionIndex`, a name, and never a number.\n // PowerPoint repairs a numeric one; a parser that reads it as an integer\n // gets `NaN` and silently loses the shape's font.\n throw new ModelError(\n 'MODEL_FONT_COLLECTION',\n `a:fontRef/@idx is \"${rawFont}\", not major, minor or none`,\n partName,\n rawFont,\n );\n }\n let fontColor: Color | null = null;\n if (fontRefElement !== undefined) {\n for (const child of childElements(fontRefElement)) {\n if (child.qname.startsWith('a:') && child.qname.endsWith('Clr')) {\n fontColor = parseColorElement(child);\n break;\n }\n }\n }\n\n return {\n lnRef: parseStyleRef(firstChild(element, 'a:lnRef'), partName),\n fillRef: parseStyleRef(firstChild(element, 'a:fillRef'), partName),\n effectRef: parseStyleRef(firstChild(element, 'a:effectRef'), partName),\n fontRef: { idx: rawFont ?? 'minor', color: fontColor },\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* shapes */\n/* -------------------------------------------------------------------------- */\n\nconst SHAPE_KINDS: Readonly<Record<string, ShapeKind>> = {\n 'p:sp': 'sp',\n 'p:pic': 'pic',\n 'p:grpSp': 'grpSp',\n 'p:graphicFrame': 'graphicFrame',\n 'p:cxnSp': 'cxnSp',\n 'p:contentPart': 'contentPart',\n};\n\n/** Where each shape kind keeps its non-visual properties. */\nconst NV_CONTAINERS: Readonly<Record<ShapeKind, string>> = {\n sp: 'p:nvSpPr',\n pic: 'p:nvPicPr',\n grpSp: 'p:nvGrpSpPr',\n graphicFrame: 'p:nvGraphicFramePr',\n cxnSp: 'p:nvCxnSpPr',\n contentPart: 'p:nvContentPartPr',\n};\n\nfunction parseShape(element: XElement, kind: ShapeKind, partName: string): Shape {\n const nv = firstChild(element, NV_CONTAINERS[kind]);\n const cNvPr = nv === undefined ? undefined : firstChild(nv, 'p:cNvPr');\n\n // `p:graphicFrame` keeps its geometry in a **PresentationML** `p:xfrm`, not\n // in an `a:xfrm` inside `p:spPr`, and has no `p:spPr` at all. Reading it the\n // other way gives every chart, table and diagram a size of zero.\n const spPr = firstChild(element, kind === 'grpSp' ? 'p:grpSpPr' : 'p:spPr');\n const geometryHost = kind === 'graphicFrame' ? element : spPr;\n\n const prstGeom = spPr === undefined ? undefined : firstChild(spPr, 'a:prstGeom');\n\n const children: Shape[] = [];\n if (kind === 'grpSp') {\n for (const child of childElements(element)) {\n const childKind = SHAPE_KINDS[child.qname];\n if (childKind !== undefined) children.push(parseShape(child, childKind, partName));\n }\n }\n\n // A `p:pic` draws the image in its `p:blipFill`, which sits beside `p:spPr`\n // rather than in it, so reading only `spPr` leaves every picture blank.\n const picture = kind === 'pic' ? parsePictureFill(element, partName) : undefined;\n const rawId = cNvPr === undefined ? undefined : attributeValue(cNvPr, 'id');\n return {\n kind,\n cNvPrId: rawId === undefined ? 0 : Number(rawId),\n name: (cNvPr === undefined ? undefined : attributeValue(cNvPr, 'name')) ?? '',\n descr: (cNvPr === undefined ? undefined : attributeValue(cNvPr, 'descr')) ?? null,\n hidden: cNvPr !== undefined && attributeValue(cNvPr, 'hidden') === '1',\n placeholder: parsePlaceholder(\n nv === undefined ? undefined : firstChild(nv, 'p:nvPr'),\n partName,\n ),\n xfrm:\n geometryHost === undefined\n ? undefined\n : parseXfrm(geometryHost, partName, kind === 'graphicFrame' ? 'p:xfrm' : 'a:xfrm'),\n fill: picture ?? (spPr === undefined ? undefined : parseFill(spPr, partName)),\n line: spPr === undefined ? undefined : parseLine(spPr, partName),\n effects: spPr === undefined ? undefined : parseEffects(spPr),\n style: parseStyle(element, partName),\n prstGeom: prstGeom === undefined ? undefined : (attributeValue(prstGeom, 'prst') ?? ''),\n geometry: parseGeometry(spPr, partName),\n text: parseTextBodyChild(element, partName),\n children,\n node: element,\n };\n}\n\nfunction parseShapeTree(cSld: XElement, partName: string): Shape[] {\n const tree = firstChild(cSld, 'p:spTree');\n if (tree === undefined) return [];\n const out: Shape[] = [];\n for (const child of childElements(tree)) {\n const kind = SHAPE_KINDS[child.qname];\n if (kind !== undefined) out.push(parseShape(child, kind, partName));\n }\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* the background */\n/* -------------------------------------------------------------------------- */\n\nfunction parseBackground(cSld: XElement, partName: string): Background | undefined {\n const bg = firstChild(cSld, 'p:bg');\n if (bg === undefined) return undefined;\n\n const ref = firstChild(bg, 'p:bgRef');\n if (ref !== undefined) return { kind: 'ref', ref: parseStyleRef(ref, partName) };\n\n const pr = firstChild(bg, 'p:bgPr');\n if (pr === undefined) return undefined;\n const fill = parseFill(pr, partName);\n // `p:bgPr` requires a fill. An `a:noFill` inside one is honoured rather than\n // treated as absent: measured in 2.9, a slide declaring it paints nothing and\n // does not fall through to its layout.\n return { kind: 'fill', fill: fill ?? { type: 'none' }, effects: parseEffects(pr) };\n}\n\n/* -------------------------------------------------------------------------- */\n/* the theme */\n/* -------------------------------------------------------------------------- */\n\nfunction parseScheme(element: XElement, partName: string): ClrScheme {\n const out: Partial<Record<SchemeSlot, Color>> = {};\n for (const slot of SCHEME_SLOTS) {\n const child = firstChild(element, `a:${slot}`);\n if (child === undefined) continue;\n for (const grandchild of childElements(child)) {\n if (grandchild.qname.startsWith('a:') && grandchild.qname.endsWith('Clr')) {\n out[slot] = parseColorElement(grandchild);\n break;\n }\n }\n }\n const missing = SCHEME_SLOTS.filter((slot) => out[slot] === undefined);\n if (missing.length > 0) {\n throw new ModelError(\n 'MODEL_CLRMAP_INCOMPLETE',\n `a:clrScheme is missing ${missing.join(', ')}`,\n partName,\n missing.join(','),\n );\n }\n return out as ClrScheme;\n}\n\nfunction parseFontScheme(element: XElement | undefined): FontScheme {\n // All three scripts, because `a:rPr` has four typeface slots and three of them\n // take a theme reference: `+mn-ea` on an `a:ea` is how a CJK run follows the\n // theme, and reading only `a:latin` leaves it unresolvable.\n const collection = (which: string): FontCollection => {\n const font = element === undefined ? undefined : firstChild(element, which);\n const face = (script: string): string | null => {\n if (font === undefined) return null;\n const child = firstChild(font, script);\n return child === undefined ? null : (attributeValue(child, 'typeface') ?? null);\n };\n return { latin: face('a:latin'), ea: face('a:ea'), cs: face('a:cs') };\n };\n return {\n name: element === undefined ? null : (attributeValue(element, 'name') ?? null),\n major: collection('a:majorFont'),\n minor: collection('a:minorFont'),\n };\n}\n\nfunction parseFormatScheme(element: XElement | undefined, partName: string): FormatScheme | null {\n if (element === undefined) return null;\n const fills = (name: string): Fill[] => {\n const list = firstChild(element, name);\n if (list === undefined) return [];\n return childElements(list).map((child) => parseFillElement(child, partName));\n };\n const lineList = firstChild(element, 'a:lnStyleLst');\n const lines: Line[] =\n lineList === undefined\n ? []\n : childElements(lineList)\n .filter((child) => child.qname === 'a:ln')\n .map((child) => parseLineElement(child, partName));\n const effectList = firstChild(element, 'a:effectStyleLst');\n const effects: (readonly Effect[])[] =\n effectList === undefined\n ? []\n : childElements(effectList)\n .filter((child) => child.qname === 'a:effectStyle')\n .map((child) => parseEffects(child) ?? []);\n\n return {\n name: attributeValue(element, 'name') ?? null,\n fillStyles: fills('a:fillStyleLst'),\n lineStyles: lines,\n effectStyles: effects,\n bgFillStyles: fills('a:bgFillStyleLst'),\n };\n}\n\nexport function parseTheme(root: XElement, partName: string): Theme {\n const elements = firstChild(root, 'a:themeElements');\n const scheme = elements === undefined ? undefined : firstChild(elements, 'a:clrScheme');\n if (elements === undefined || scheme === undefined) {\n throw new ModelError('MODEL_PART_KIND', 'a theme with no a:clrScheme', partName);\n }\n return {\n partName,\n name: attributeValue(root, 'name') ?? null,\n scheme: parseScheme(scheme, partName),\n fonts: parseFontScheme(firstChild(elements, 'a:fontScheme')),\n format: parseFormatScheme(firstChild(elements, 'a:fmtScheme'), partName),\n node: root,\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* the sheet */\n/* -------------------------------------------------------------------------- */\n\nconst ROOTS: Readonly<Record<string, SheetKind>> = {\n 'p:sld': 'slide',\n 'p:sldLayout': 'layout',\n 'p:sldMaster': 'master',\n};\n\n/**\n * One part into one sheet. The parent and the theme are filled in by\n * `document.ts`, which is the only thing that can follow a relationship.\n */\nexport function parseSheet(root: XElement, partName: string): Omit<Sheet, 'parent' | 'theme'> {\n const kind = ROOTS[root.qname];\n if (kind === undefined) {\n throw new ModelError('MODEL_PART_KIND', `${root.qname} is not a sheet root`, partName);\n }\n const cSld = firstChild(root, 'p:cSld');\n if (cSld === undefined) {\n throw new ModelError('MODEL_PART_KIND', `${root.qname} has no p:cSld`, partName);\n }\n const clrMapElement = kind === 'master' ? firstChild(root, 'p:clrMap') : undefined;\n // Only a master carries `p:txStyles`, and whether it carries one at all is a\n // load-bearing distinction: PowerPoint substitutes its whole built-in set for\n // a master that declares none, measured in 3.1.\n const txStylesElement = kind === 'master' ? firstChild(root, 'p:txStyles') : undefined;\n\n return {\n kind,\n partName,\n name: attributeValue(cSld, 'name') ?? null,\n layoutType: kind === 'layout' ? (attributeValue(root, 'type') ?? null) : null,\n matchingName: kind === 'layout' ? (attributeValue(root, 'matchingName') ?? null) : null,\n shapes: parseShapeTree(cSld, partName),\n background: parseBackground(cSld, partName),\n clrMap: clrMapElement === undefined ? undefined : parseClrMap(clrMapElement, partName),\n txStyles:\n txStylesElement === undefined ? undefined : parseTextStyles(txStylesElement, partName),\n clrMapOvr: kind === 'master' ? undefined : parseClrMapOvr(root, partName),\n // `@showMasterSp` sits on `p:sld` and `p:sldLayout` themselves, not inside\n // `p:cSld` where the rest of this comes from.\n showMasterShapes: attributeValue(root, 'showMasterSp') !== '0',\n node: root,\n };\n}\n","/**\n * Which placeholder on the parent sheet a placeholder inherits from.\n *\n * ## The two hops do not use the same key, and neither uses the pair\n *\n * Every implementation this project has read matches on `(type, idx)`, usually\n * with a ladder of fallbacks for titles and for the header-and-footer trio. That\n * is not what PowerPoint does. Measured in 2.9 across 46 probes, each a slide\n * placeholder with no geometry of its own whose *rendered position* names the\n * layout placeholder it matched:\n *\n * - **Slide to layout matches on `@idx` alone.** `@type` is not consulted, not\n * as a tiebreak and not as a fallback. A slide `title` at idx 0 takes a layout\n * `body` at idx 0; a slide `body` at idx 2 takes a layout `sldNum` at idx 2; a\n * slide `title` at idx 9 against a layout holding a title at idx 0 matches\n * **nothing** and renders at the origin with zero size. Scored against the\n * probes: `idx` alone 34/34, `(type, idx)` 13/34, family-and-idx 24/34, type\n * alone 6/34.\n * - **Layout to master matches on type alone**, taking the *first* placeholder\n * of that type in the master's shape tree - `@idx` is not even a tiebreak. A\n * layout body at idx 5, against a master holding bodies at idx 1 and idx 5,\n * takes the one at idx 1.\n *\n * The asymmetry is not arbitrary. Every stock PowerPoint layout numbers its\n * date, footer and slide-number placeholders 10, 11 and 12 while every stock\n * master numbers the same three 2, 3 and 4, so a second hop that looked at `idx`\n * would inherit nothing in the templates Office ships. And a master's\n * placeholder vocabulary is only `title`, `body`, `dt`, `ftr`, `sldNum` and\n * `hdr` - PowerPoint repairs any master carrying `ctrTitle`, `subTitle`, `obj`\n * or `pic` - so a second hop that looked at the type as written would find\n * nothing for the `ctrTitle` in layout 1 or the `obj` in layout 2.\n *\n * ## Each hop reads the placeholder of the sheet it is leaving\n *\n * A slide placeholder with no `@type` (so `obj`) matching a layout `ctrTitle`\n * reaches the master's **title**, not its body. So the type used for the second\n * hop is the *layout's*, not the slide's - which is what one would expect from a\n * chain of sheets, and is worth stating because the alternative reading gives a\n * different answer on exactly this case.\n */\n\nimport type { NormalPlaceholder, Placeholder, PlaceholderType, Shape, Sheet } from '../types.js';\n\n/**\n * The type of a `p:ph` that has none.\n *\n * `obj`, measured: a bare `<p:ph/>` on a slide reads back through PowerPoint's\n * object model as `ppPlaceholderObject`. ECMA's own default for the attribute\n * is `body`, and the two behave identically at the first hop because that hop\n * ignores the type - but they differ at the second, where `obj` folds to `body`\n * and `body` is already there. They agree, and it is worth knowing why rather\n * than by luck.\n */\nexport const DEFAULT_PLACEHOLDER_TYPE: PlaceholderType = 'obj';\n\n/** The `@idx` of a `p:ph` that has none. */\nexport const DEFAULT_PLACEHOLDER_IDX = 0;\n\n/** Supply the two defaults, so a comparison has something to compare. */\nexport function normalizePlaceholder(ph: Placeholder): NormalPlaceholder {\n return {\n type: ph.type ?? DEFAULT_PLACEHOLDER_TYPE,\n idx: ph.idx ?? DEFAULT_PLACEHOLDER_IDX,\n };\n}\n\n/** The four types that fold to `title` or stay as themselves on a master. */\nconst MASTER_TITLE: ReadonlySet<PlaceholderType> = new Set<PlaceholderType>(['title', 'ctrTitle']);\n\n/** The types a master may carry, which are the only targets of the second hop. */\nconst MASTER_OWN: ReadonlySet<PlaceholderType> = new Set<PlaceholderType>([\n 'body',\n 'dt',\n 'ftr',\n 'sldNum',\n 'hdr',\n]);\n\n/**\n * The type a placeholder presents when it asks a master for its parent.\n *\n * `ctrTitle` becomes `title`; everything a master may not carry - `subTitle`,\n * `obj`, `pic`, `chart`, `tbl`, `clipArt`, `dgm`, `media`, `sldImg` - becomes\n * `body`. Measured on `pic`, `obj`, `subTitle` and `ctrTitle`; the rest follow\n * because a master cannot hold them either and `body` is the only remaining\n * content type.\n */\nexport function masterPlaceholderType(type: PlaceholderType): PlaceholderType {\n if (MASTER_TITLE.has(type)) return 'title';\n if (MASTER_OWN.has(type)) return type;\n return 'body';\n}\n\n/** Every placeholder in a sheet's top-level shape tree, in document order. */\nexport function placeholders(sheet: Sheet): readonly Shape[] {\n return sheet.shapes.filter((shape) => shape.placeholder !== null);\n}\n\n/**\n * Slide to layout: the first placeholder whose `@idx` agrees.\n *\n * \"First\" matters only for a layout that has two placeholders at one index,\n * which PowerPoint accepts without repairing; the first in the shape tree is\n * the one that wins.\n */\nexport function matchInLayout(ph: Placeholder, layout: Sheet): Shape | null {\n const want = normalizePlaceholder(ph);\n for (const shape of layout.shapes) {\n if (shape.placeholder === null) continue;\n if (normalizePlaceholder(shape.placeholder).idx === want.idx) return shape;\n }\n return null;\n}\n\n/** Layout to master: the first placeholder of the folded type. */\nexport function matchInMaster(ph: Placeholder, master: Sheet): Shape | null {\n const want = masterPlaceholderType(normalizePlaceholder(ph).type);\n for (const shape of master.shapes) {\n if (shape.placeholder === null) continue;\n if (masterPlaceholderType(normalizePlaceholder(shape.placeholder).type) === want) return shape;\n }\n return null;\n}\n\n/** One link of the chain: a shape, the sheet it is on, and how it was reached. */\nexport interface ChainLink {\n readonly shape: Shape;\n readonly sheet: Sheet;\n /** `shape` for the first link, then `layoutPh`, then `masterPh`. */\n readonly origin: 'shape' | 'layoutPh' | 'masterPh';\n}\n\n/**\n * The chain a shape inherits along, nearest first.\n *\n * One entry for a non-placeholder, and for a placeholder that matched nothing.\n * Up to three for a slide placeholder that reached the master. Each hop asks\n * with the placeholder of the sheet it is leaving, which is why the layout's\n * `@type` and not the slide's decides the second hop.\n */\nexport function inheritanceChain(shape: Shape, sheet: Sheet): readonly ChainLink[] {\n const chain: ChainLink[] = [{ shape, sheet, origin: 'shape' }];\n if (shape.placeholder === null) return chain;\n\n let current = shape;\n let currentSheet = sheet;\n const seen = new Set<string>([sheet.partName]);\n\n while (currentSheet.parent !== null && current.placeholder !== null) {\n const parentSheet = currentSheet.parent;\n if (seen.has(parentSheet.partName)) break;\n seen.add(parentSheet.partName);\n\n const next =\n parentSheet.kind === 'master'\n ? matchInMaster(current.placeholder, parentSheet)\n : matchInLayout(current.placeholder, parentSheet);\n if (next === null) break;\n\n chain.push({\n shape: next,\n sheet: parentSheet,\n origin: parentSheet.kind === 'master' ? 'masterPh' : 'layoutPh',\n });\n current = next;\n currentSheet = parentSheet;\n }\n\n return chain;\n}\n\n/**\n * A placeholder that reached no parent and states no geometry of its own.\n *\n * PowerPoint renders one at the origin with zero width and height - it does not\n * refuse the file, does not drop the shape, and does not invent a rectangle.\n * Measured on four probes: a title where the layout has none, a body at an index\n * nobody has, and both against a layout with no placeholders at all.\n */\nexport const ORPHAN_RECT = { x: 0, y: 0, cx: 0, cy: 0 } as const;\n","/**\n * The generic resolver: one function, and four features fall out of it.\n *\n * `resolve(shape, sheet, pick)` walks the inheritance chain and returns the\n * first level that declared the thing asked for, **with a record of which level\n * that was**. Carrying the origin costs one field and buys the inspector's\n * provenance chips, per-property Reset, layout-compatibility scoring, and\n * correct invalidation on a theme swap - all reading the same function the\n * renderer reads, so none of them can drift from what is on the screen.\n *\n * What descends is not a guess. Measured in 2.9, on a slide placeholder that\n * declares nothing: an `spPr` solid fill, a `p:style` and an `a:ln` all arrive\n * from the layout placeholder, and all three arrive from the *master*\n * placeholder when the layout placeholder declares nothing either. Geometry is\n * not special; it travels the same chain as everything else.\n */\n\nimport type { ClrMap, ClrScheme, ColorContext, Rgba } from '@pptx-studio/paint';\n\nimport { ModelError } from '../errors.js';\nimport { inheritanceChain } from './placeholder.js';\nimport type { Resolved, Shape, Sheet, Theme, Xfrm } from '../types.js';\n\n/**\n * The first level of the chain that declared something.\n *\n * `pick` must return `undefined` for \"this level did not say\" and anything else\n * for a value, including `null` - a shape may legitimately declare a `null`, and\n * conflating that with silence is how an explicit `a:noFill` gets overwritten by\n * an inherited colour.\n */\nexport function resolve<T>(\n shape: Shape,\n sheet: Sheet,\n pick: (shape: Shape) => T | undefined,\n): Resolved<T> | undefined {\n const chain = inheritanceChain(shape, sheet);\n for (const [index, link] of chain.entries()) {\n const value = pick(link.shape);\n if (value === undefined) continue;\n return {\n value,\n origin: link.origin,\n explicit: index === 0,\n sheet: link.sheet,\n shape: link.shape,\n };\n }\n return undefined;\n}\n\n/**\n * The rectangle a shape occupies, and which sheet stated it.\n *\n * The single most consequential call in the package. A slide placeholder that\n * PowerPoint wrote has **no** `a:xfrm` - not when it was created, not when text\n * was typed into it, only when the user moved or resized it, at which point the\n * whole resolved rectangle is baked in at once. So an absent `xfrm` is the\n * statement \"still bound to my layout\", and it is what Change Layout reads.\n */\nexport function resolveXfrm(shape: Shape, sheet: Sheet): Resolved<Xfrm> | undefined {\n return resolve(shape, sheet, (s) => s.xfrm);\n}\n\n/* -------------------------------------------------------------------------- */\n/* the sheet chain */\n/* -------------------------------------------------------------------------- */\n\n/** Every sheet from this one up to its master, nearest first. */\nexport function sheetChain(sheet: Sheet): readonly Sheet[] {\n const chain: Sheet[] = [];\n const seen = new Set<string>();\n let current: Sheet | null = sheet;\n while (current !== null) {\n if (seen.has(current.partName)) {\n throw new ModelError(\n 'MODEL_SHEET_CYCLE',\n `the sheet chain returns to ${current.partName}`,\n current.partName,\n );\n }\n seen.add(current.partName);\n chain.push(current);\n current = current.parent;\n }\n return chain;\n}\n\n/** The master at the top of a sheet's chain, or `null` if the chain is broken. */\nexport function masterOf(sheet: Sheet): Sheet | null {\n for (const link of sheetChain(sheet)) if (link.kind === 'master') return link;\n return null;\n}\n\n/**\n * The theme a sheet resolves against.\n *\n * The master's, reached through this sheet's own chain. **Not** the one\n * `ppt/presentation.xml.rels` names: PowerPoint writes a `theme` relationship\n * there too, it always points at `theme1.xml`, and on a two-master deck every\n * slide on the second master would take the first master's palette. Measured -\n * the two masters resolved `accent1` to two different colours, and each\n * master's background used its own theme's `bgFillStyleLst`.\n *\n * A master must own its theme part outright: two masters pointing at the same\n * one is repaired on open, so a shared theme is a broken file rather than an\n * economy.\n */\nexport function themeOf(sheet: Sheet): Theme | null {\n return masterOf(sheet)?.theme ?? null;\n}\n\nexport function schemeOf(sheet: Sheet): ClrScheme | undefined {\n return themeOf(sheet)?.scheme;\n}\n\n/**\n * The colour map in force on a sheet.\n *\n * `a:masterClrMapping` says \"the map already in force\", and the surprise is what\n * that means: for a slide it is the **layout's** map, not the master's. Measured\n * - a layout carrying an `a:overrideClrMapping` changed `accent1` on a slide\n * that declared `masterClrMapping`, and a slide with an override of its own beat\n * its layout's. The element is named for the sheet it usually ends at rather\n * than for the one it asks.\n */\nexport function colorMapOf(sheet: Sheet): ClrMap | undefined {\n for (const link of sheetChain(sheet)) {\n if (link.kind === 'master') return link.clrMap;\n if (link.clrMapOvr?.kind === 'override') return link.clrMapOvr.map;\n }\n return undefined;\n}\n\n/**\n * Everything `resolveColor` needs, for a colour written on this sheet.\n *\n * `phClr` is supplied by whatever style invocation the colour sits inside, and\n * there is nothing sensible to default it to: `style.ts` passes it in, and a\n * `schemeClr val=\"phClr\"` reached any other way throws rather than painting\n * black.\n */\nexport function colorContextOf(sheet: Sheet, phClr?: Rgba): ColorContext {\n const scheme = schemeOf(sheet);\n const map = colorMapOf(sheet);\n return {\n ...(scheme === undefined ? {} : { scheme }),\n ...(map === undefined ? {} : { map }),\n ...(phClr === undefined ? {} : { phClr }),\n };\n}\n","/**\n * The style matrix, the 1000-offset, and `phClr`.\n *\n * A `p:style` holds four references into the theme. Each names an entry by\n * index and carries the colour that entry's `schemeClr val=\"phClr\"` is to be\n * resolved with - so an entry such as\n * `<a:solidFill><a:schemeClr val=\"phClr\"><a:lumMod val=\"60000\"/></a:schemeClr></a:solidFill>`\n * is a *function* of a colour, and the reference is the call.\n *\n * Miss `phClr` and every themed shape renders black, which is the failure this\n * whole file exists to prevent.\n */\n\nimport {\n resolveColor,\n type Color,\n type Effect,\n type Fill,\n type Line,\n type Rgba,\n} from '@pptx-studio/paint';\n\nimport { ModelError } from './errors.js';\nimport { colorContextOf, resolve, themeOf } from './resolve/resolve.js';\nimport type { Origin, Resolved, Shape, Sheet, StyleRef, Theme } from './types.js';\n\n/**\n * The offset that separates the two style lists.\n *\n * `0` and `1000` mean *nothing at all*; `1..999` index the main list; `1001` and\n * up index the background list. Measured on both `a:fillRef` and `p:bgRef`\n * against a theme whose six entries paint six distinguishable colours - all six\n * agreed between the two elements, and `idx=\"0\"` and `idx=\"1000\"` both painted\n * nothing.\n */\nexport const STYLE_MATRIX_OFFSET = 1000;\n\n/** Which of the two lists an index reaches, and where in it. */\nexport type StyleMatrixTarget =\n | { readonly list: 'none' }\n | { readonly list: 'main'; readonly at: number }\n | { readonly list: 'background'; readonly at: number };\n\n/**\n * Where an index points, before anything is fetched.\n *\n * Out of range is not an error. A `fillRef idx=\"4\"` against a three-entry list\n * paints the third entry, and a `bgRef idx=\"9999\"` paints the last background\n * entry: PowerPoint clamps, opens the file without repairing it, and a renderer\n * that throws here refuses a deck PowerPoint shows.\n */\nexport function styleMatrixTarget(idx: number): StyleMatrixTarget {\n if (idx === 0 || idx === STYLE_MATRIX_OFFSET) return { list: 'none' };\n if (idx < STYLE_MATRIX_OFFSET) return { list: 'main', at: idx - 1 };\n return { list: 'background', at: idx - STYLE_MATRIX_OFFSET - 1 };\n}\n\nfunction clampInto<T>(entries: readonly T[], at: number, what: string, theme: Theme): T {\n if (entries.length === 0) {\n throw new ModelError('MODEL_STYLE_LIST_EMPTY', `${what} has no entries`, theme.partName, what);\n }\n return entries[Math.min(Math.max(at, 0), entries.length - 1)] as T;\n}\n\n/** The fill a `fillRef`/`bgRef` index names, or `null` for none. */\nexport function styleMatrixFill(ref: StyleRef, theme: Theme): Fill | null {\n const target = styleMatrixTarget(ref.idx);\n if (target.list === 'none') return null;\n const format = theme.format;\n if (format === null) {\n throw new ModelError('MODEL_NO_STYLE_MATRIX', 'the theme has no a:fmtScheme', theme.partName);\n }\n return target.list === 'main'\n ? clampInto(format.fillStyles, target.at, 'a:fillStyleLst', theme)\n : clampInto(format.bgFillStyles, target.at, 'a:bgFillStyleLst', theme);\n}\n\n/**\n * The line an `lnRef` index names, or `null` for none.\n *\n * `a:lnStyleLst` has no background counterpart, so an index above 1000 clamps\n * into the same list rather than reaching a second one.\n */\nexport function styleMatrixLine(ref: StyleRef, theme: Theme): Line | null {\n const target = styleMatrixTarget(ref.idx);\n if (target.list === 'none') return null;\n const format = theme.format;\n if (format === null) {\n throw new ModelError('MODEL_NO_STYLE_MATRIX', 'the theme has no a:fmtScheme', theme.partName);\n }\n return clampInto(format.lineStyles, target.at, 'a:lnStyleLst', theme);\n}\n\n/** The effects an `effectRef` index names. Empty for none. */\nexport function styleMatrixEffects(ref: StyleRef, theme: Theme): readonly Effect[] {\n const target = styleMatrixTarget(ref.idx);\n if (target.list === 'none') return [];\n const format = theme.format;\n if (format === null) {\n throw new ModelError('MODEL_NO_STYLE_MATRIX', 'the theme has no a:fmtScheme', theme.partName);\n }\n return clampInto(format.effectStyles, target.at, 'a:effectStyleLst', theme);\n}\n\n/**\n * The colour a style reference invokes its entry with.\n *\n * The reference's own colour child, resolved against the sheet - and it may\n * carry transforms of its own. PowerPoint's shape-style gallery writes\n * `<a:schemeClr val=\"accent1\"><a:shade val=\"15000\"/></a:schemeClr>` on seven of\n * its forty-two entries, so `phClr` is a fully transformed colour and not a\n * theme slot name.\n */\nexport function phClrOf(ref: StyleRef, sheet: Sheet): Rgba | null {\n if (ref.color === null) return null;\n return resolveColor(ref.color, colorContextOf(sheet));\n}\n\n/* -------------------------------------------------------------------------- */\n/* the whole answer for one shape */\n/* -------------------------------------------------------------------------- */\n\n/** What a shape paints, and where each half of the answer came from. */\nexport interface ResolvedAppearance {\n /** `null` means nothing is painted: no fill was declared and no style names one. */\n readonly fill: Fill | null;\n readonly fillOrigin: Origin | null;\n /** The colour `phClr` resolves to inside `fill`, when it came from the theme. */\n readonly fillPhClr: Rgba | null;\n readonly line: Line | null;\n readonly lineOrigin: Origin | null;\n readonly linePhClr: Rgba | null;\n readonly effects: readonly Effect[] | null;\n}\n\nfunction styleOf(shape: Shape, sheet: Sheet): Resolved<Shape['style']> | undefined {\n return resolve(shape, sheet, (s) => s.style);\n}\n\n/**\n * What a shape paints, following both routes and in the right order.\n *\n * An explicit `spPr` fill beats the `fillRef`, and an explicit `a:noFill` beats\n * it too - both measured. A shape with neither paints nothing rather than black.\n *\n * The two routes are searched independently: the `spPr` fill is looked for down\n * the whole inheritance chain first, and only if no level declared one does the\n * `p:style` - itself inherited down the same chain - get consulted.\n */\nexport function resolveAppearance(shape: Shape, sheet: Sheet): ResolvedAppearance {\n const theme = themeOf(sheet);\n const style = styleOf(shape, sheet);\n\n const directFill = resolve(shape, sheet, (s) => s.fill);\n const directLine = resolve(shape, sheet, (s) => s.line);\n const directEffects = resolve(shape, sheet, (s) => s.effects);\n\n let fill: Fill | null = directFill?.value ?? null;\n let fillOrigin: ResolvedAppearance['fillOrigin'] = directFill?.origin ?? null;\n let fillPhClr: Rgba | null = null;\n if (directFill === undefined && style !== undefined && theme !== null) {\n const ref = style.value?.fillRef;\n if (ref !== undefined) {\n fill = styleMatrixFill(ref, theme);\n fillOrigin = fill === null ? null : 'theme';\n fillPhClr = fill === null ? null : phClrOf(ref, sheet);\n }\n }\n\n let line: Line | null = directLine?.value ?? null;\n let lineOrigin: ResolvedAppearance['lineOrigin'] = directLine?.origin ?? null;\n let linePhClr: Rgba | null = null;\n if (directLine === undefined && style !== undefined && theme !== null) {\n const ref = style.value?.lnRef;\n if (ref !== undefined) {\n line = styleMatrixLine(ref, theme);\n lineOrigin = line === null ? null : 'theme';\n linePhClr = line === null ? null : phClrOf(ref, sheet);\n }\n }\n\n let effects: readonly Effect[] | null = directEffects?.value ?? null;\n if (directEffects === undefined && style !== undefined && theme !== null) {\n const ref = style.value?.effectRef;\n if (ref !== undefined) effects = styleMatrixEffects(ref, theme);\n }\n\n return { fill, fillOrigin, fillPhClr, line, lineOrigin, linePhClr, effects };\n}\n\n/**\n * A shape's fill as a single colour, when it is one.\n *\n * A convenience over `resolveAppearance` for the common case, and the shape the\n * ground-truth fixture is in: PowerPoint's object model reports one RGB per\n * shape, so this is what a measurement can be compared against.\n */\nexport function resolveSolidFill(shape: Shape, sheet: Sheet): Rgba | null {\n const appearance = resolveAppearance(shape, sheet);\n if (appearance.fill === null || appearance.fill.type !== 'solid') return null;\n const phClr = appearance.fillPhClr;\n return resolveColor(\n appearance.fill.color,\n colorContextOf(sheet, phClr === null ? undefined : phClr),\n );\n}\n\n/** Resolve any colour written on a sheet, with an optional `phClr` in scope. */\nexport function resolveOnSheet(color: Color, sheet: Sheet, phClr?: Rgba): Rgba {\n return resolveColor(color, colorContextOf(sheet, phClr));\n}\n","/**\n * What is behind everything on a slide.\n *\n * Two questions, and they are independent. *Which sheet's* background applies,\n * and *what* that background is.\n *\n * **Which sheet.** The nearest one that declares a `p:bg` at all: the slide,\n * else its layout, else the master. Measured on all three. An absent `p:bg` is\n * the only thing that inherits - a slide declaring `<p:bgPr><a:noFill/>` paints\n * nothing and does *not* fall through, which is the distinction between \"I have\n * no opinion\" and \"my opinion is nothing\", and the reason `Background` is a\n * value rather than a nullable fill.\n *\n * **What it is.** `p:bgPr` states a fill outright. `p:bgRef` names an entry of\n * the theme's style matrix and the colour to invoke its `phClr` with, using the\n * same 1000-offset as `a:fillRef` over the same two lists - measured on six\n * indices through both elements, agreeing on all six. PowerPoint's own master\n * writes `<p:bgRef idx=\"1001\"><a:schemeClr val=\"bg1\"/></p:bgRef>`, which is the\n * first entry of `a:bgFillStyleLst` invoked with whatever `bg1` maps to.\n *\n * And `bg1` there is resolved through the colour map in force **on the sheet\n * that owns the shape**, not on the sheet that owns the background: a slide\n * whose `clrMapOvr` remaps `bg1` gets a different background out of the same\n * master. Measured.\n */\n\nimport { resolveColor, type Fill, type Rgba } from '@pptx-studio/paint';\n\nimport { colorContextOf, sheetChain, themeOf } from './resolve.js';\nimport { phClrOf, styleMatrixFill } from '../style.js';\nimport type { Background, Sheet } from '../types.js';\n\n/** A background, with the sheet that declared it and how it was expressed. */\nexport interface ResolvedBackground {\n readonly fill: Fill;\n /** The sheet whose `p:bg` this is. */\n readonly sheet: Sheet;\n /** True when the sheet asked for it is the one that declared it. */\n readonly explicit: boolean;\n /** `bgPr` or `bgRef`, because they round-trip differently. */\n readonly form: 'bgPr' | 'bgRef';\n /** The colour `phClr` takes inside `fill`, for a `bgRef`. */\n readonly phClr: Rgba | null;\n}\n\n/** Which sheet's `p:bg` applies, without unpacking it. */\nexport function backgroundSheet(sheet: Sheet): { sheet: Sheet; background: Background } | null {\n for (const link of sheetChain(sheet)) {\n if (link.background !== undefined) return { sheet: link, background: link.background };\n }\n return null;\n}\n\n/**\n * The background of a slide, layout or master.\n *\n * `null` when no sheet in the chain declares one, which is a legal file: a deck\n * whose master has no `p:bg` paints nothing behind its slides.\n */\nexport function resolveBackground(sheet: Sheet): ResolvedBackground | null {\n const found = backgroundSheet(sheet);\n if (found === null) return null;\n\n if (found.background.kind === 'fill') {\n return {\n fill: found.background.fill,\n sheet: found.sheet,\n explicit: found.sheet === sheet,\n form: 'bgPr',\n phClr: null,\n };\n }\n\n const theme = themeOf(sheet);\n if (theme === null) return null;\n const fill = styleMatrixFill(found.background.ref, theme);\n if (fill === null) {\n // `idx=\"0\"` and `idx=\"1000\"` both paint nothing at all - not white, and not\n // the sheet above's background. Measured on both.\n return {\n fill: { type: 'none' },\n sheet: found.sheet,\n explicit: found.sheet === sheet,\n form: 'bgRef',\n phClr: null,\n };\n }\n return {\n fill,\n sheet: found.sheet,\n explicit: found.sheet === sheet,\n form: 'bgRef',\n // The map in force on the sheet being asked about, not on the sheet the\n // `bgRef` was written on.\n phClr: phClrOf(found.background.ref, sheet),\n };\n}\n\n/** The background as one colour, when it is a solid. `null` otherwise. */\nexport function resolveBackgroundColor(sheet: Sheet): Rgba | null {\n const background = resolveBackground(sheet);\n if (background === null || background.fill.type !== 'solid') return null;\n return resolveColor(\n background.fill.color,\n colorContextOf(sheet, background.phClr === null ? undefined : background.phClr),\n );\n}\n","/**\n * The package into sheets, and the sheets into a chain.\n *\n * ## Every binding comes from the part's own `.rels`, and from nothing else\n *\n * A slide part does not name its layout. A layout does not name its master. A\n * master does not name its theme. Each of those bindings lives in exactly one\n * place - `ppt/slides/_rels/slideN.xml.rels`, and its two counterparts - and\n * every other candidate is a trap:\n *\n * - **`p:sldLayoutIdLst` is not the binding.** It gives each layout an id and an\n * order for the UI. A two-master deck saved by PowerPoint puts all 22 layouts\n * in one flat `ppt/slideLayouts/` folder, numbered 1 to 22, and which master\n * owns which is recorded only in the two masters' relationship parts.\n * - **The part number is not the binding.** Same reason.\n * - **`ppt/presentation.xml.rels` has a `theme` relationship**, it always points\n * at `theme1.xml`, and reading it gives every slide the first master's palette.\n * On a one-master deck - which is every deck most people ever test with - that\n * is indistinguishable from correct.\n * - **The order of a `.rels` file is not `rId` order.** PowerPoint writes them\n * in whatever order it likes; `rId8` routinely comes first. Anything that\n * reads a relationship part positionally is wrong on the files Office writes.\n *\n * ## A broken binding is not an error\n *\n * A slide with no layout relationship, a layout with no master, a master with no\n * theme: PowerPoint repairs all three rather than refusing them, and after the\n * repair the binding is simply gone. So this loads them with `parent` or `theme`\n * as `null` and records the problem, rather than throwing. Refusing to *write*\n * one is `validate`'s job, and it is a different question.\n */\n\nimport { REL_TYPE, type PartStore } from '@pptx-studio/opc';\nimport { parseXml, type XElement } from '@pptx-studio/xml';\n\nimport { ModelError } from './errors.js';\nimport { parseSheet, parseTheme } from './parse/sheet.js';\nimport { parseDefaultTextStyle } from './parse/text.js';\nimport type { ListStyle } from './text.js';\nimport type { Sheet, Theme } from './types.js';\n\n/** One thing wrong with the package that did not stop the load. */\nexport interface DocumentProblem {\n readonly code: 'MODEL_NO_PARENT' | 'MODEL_NO_THEME' | 'MODEL_PART_MISSING' | 'MODEL_PART_KIND';\n readonly partName: string;\n readonly message: string;\n}\n\nconst REL_SLIDE = REL_TYPE.slide;\nconst REL_LAYOUT = REL_TYPE.slideLayout;\nconst REL_MASTER = REL_TYPE.slideMaster;\nconst REL_THEME = REL_TYPE.theme;\n\ninterface Loading {\n readonly problems: DocumentProblem[];\n readonly sheets: Map<string, Sheet>;\n readonly themes: Map<string, Theme>;\n readonly loading: Set<string>;\n readonly store: PartStore;\n}\n\nfunction rootOf(store: PartStore, partName: string): XElement {\n const document = parseXml(store.read(partName));\n const root = document.root;\n if (root === null) {\n throw new ModelError('MODEL_PART_KIND', `${partName} has no root element`, partName);\n }\n return root;\n}\n\nfunction themeFor(state: Loading, masterPartName: string): Theme | null {\n const rels = state.store.relationships(masterPartName);\n const rel = rels.firstOfType(REL_THEME);\n if (rel === undefined) {\n state.problems.push({\n code: 'MODEL_NO_THEME',\n partName: masterPartName,\n message: 'the master has no theme relationship',\n });\n return null;\n }\n const target = rels.resolve(rel);\n const cached = state.themes.get(target);\n if (cached !== undefined) return cached;\n if (!state.store.has(target)) {\n state.problems.push({\n code: 'MODEL_PART_MISSING',\n partName: target,\n message: `${masterPartName} names a theme part that is not in the package`,\n });\n return null;\n }\n const theme = parseTheme(rootOf(state.store, target), target);\n state.themes.set(target, theme);\n return theme;\n}\n\n/**\n * Load one sheet and, recursively, its parent.\n *\n * The `loading` set is a cycle guard rather than an optimisation. A layout whose\n * `slideMaster` relationship points back at a layout is a package a hostile\n * input can produce, and following it without a guard is an unbounded recursion\n * in a Web Worker.\n */\nfunction loadSheet(state: Loading, partName: string): Sheet | null {\n const cached = state.sheets.get(partName);\n if (cached !== undefined) return cached;\n if (state.loading.has(partName)) {\n state.problems.push({\n code: 'MODEL_PART_KIND',\n partName,\n message: 'the sheet chain returns to this part',\n });\n return null;\n }\n if (!state.store.has(partName)) {\n state.problems.push({\n code: 'MODEL_PART_MISSING',\n partName,\n message: 'the part is not in the package',\n });\n return null;\n }\n\n state.loading.add(partName);\n let parsed;\n try {\n parsed = parseSheet(rootOf(state.store, partName), partName);\n } catch (error) {\n state.loading.delete(partName);\n if (error instanceof ModelError && error.code === 'MODEL_PART_KIND') {\n state.problems.push({ code: 'MODEL_PART_KIND', partName, message: error.message });\n return null;\n }\n throw error;\n }\n\n let parent: Sheet | null = null;\n let theme: Theme | null = null;\n\n if (parsed.kind === 'master') {\n theme = themeFor(state, partName);\n } else {\n const wantedType = parsed.kind === 'slide' ? REL_LAYOUT : REL_MASTER;\n const rels = state.store.relationships(partName);\n const rel = rels.firstOfType(wantedType);\n if (rel === undefined) {\n state.problems.push({\n code: 'MODEL_NO_PARENT',\n partName,\n message: `no ${parsed.kind === 'slide' ? 'slideLayout' : 'slideMaster'} relationship`,\n });\n } else {\n parent = loadSheet(state, rels.resolve(rel));\n if (parent !== null && parent.kind === parsed.kind) {\n // A layout whose `slideMaster` relationship points at another layout.\n // The chain would still terminate, and it would be the wrong chain.\n state.problems.push({\n code: 'MODEL_PART_KIND',\n partName,\n message: `the parent of a ${parsed.kind} is another ${parsed.kind}`,\n });\n parent = null;\n }\n }\n }\n\n state.loading.delete(partName);\n const sheet: Sheet = { ...parsed, parent, theme };\n state.sheets.set(partName, sheet);\n return sheet;\n}\n\n/**\n * A loaded presentation: its slides, in `p:sldIdLst` order, each with its chain.\n *\n * Nothing here is a class with behaviour. It is the result of a load, and every\n * question about it is a free function in `resolve.ts`, `style.ts` or\n * `background.ts` - so a caller can hold a `Sheet` from anywhere and still ask\n * everything, and so the whole surface stays tree-shakable.\n */\nexport interface Document {\n /** The presentation part, for the parts of it 2.9 does not model. */\n readonly presentation: XElement;\n readonly presentationPartName: string;\n /** In `p:sldIdLst` order, which *is* the deck's order. */\n readonly slides: readonly Sheet[];\n /** In `p:sldMasterIdLst` order. */\n readonly masters: readonly Sheet[];\n /** Every layout reachable from a master, in the order its master lists it. */\n readonly layouts: readonly Sheet[];\n readonly themes: readonly Theme[];\n readonly problems: readonly DocumentProblem[];\n /**\n * `p:defaultTextStyle`, the terminus of the text cascade for every shape that\n * reaches no `p:txStyles` bucket - which is every shape that is not a\n * placeholder, and the `dt`, `ftr`, `sldNum` and `hdr` placeholders besides.\n *\n * It lives on the presentation part, so it belongs to the package rather than\n * to any sheet, and `undefined` means the package declared none.\n */\n readonly defaultTextStyle: ListStyle | undefined;\n /** Slide size in EMU, from `p:sldSz`. */\n readonly slideSize: { readonly cx: number; readonly cy: number };\n sheet(partName: string): Sheet | undefined;\n}\n\nfunction officeDocumentOf(store: PartStore): string {\n const rel = store.rootRelationships().firstOfType(REL_TYPE.officeDocument);\n if (rel === undefined) {\n throw new ModelError('MODEL_NO_PRESENTATION', 'the package root names no officeDocument');\n }\n return store.rootRelationships().resolve(rel);\n}\n\nexport function loadDocument(store: PartStore): Document {\n const presentationPartName = officeDocumentOf(store);\n if (!store.has(presentationPartName)) {\n throw new ModelError(\n 'MODEL_NO_PRESENTATION',\n `${presentationPartName} is not in the package`,\n presentationPartName,\n );\n }\n const presentation = rootOf(store, presentationPartName);\n\n const state: Loading = {\n problems: [],\n sheets: new Map(),\n themes: new Map(),\n loading: new Set(),\n store,\n };\n\n const rels = store.relationships(presentationPartName);\n\n // Slides in `p:sldIdLst` order. The list gives the order; the `r:id` on each\n // entry gives the part, through this part's own rels.\n const slides: Sheet[] = [];\n const slideList = presentation.children.find(\n (child) => child.type === 'element' && child.qname === 'p:sldIdLst',\n );\n if (slideList !== undefined && slideList.type === 'element') {\n for (const entry of slideList.children) {\n if (entry.type !== 'element' || entry.qname !== 'p:sldId') continue;\n const id = entry.attributes.find((attr) => attr.qname === 'r:id')?.value;\n if (id === undefined) continue;\n const target = rels.targetOf(id);\n if (target === undefined) continue;\n const sheet = loadSheet(state, target);\n if (sheet !== null) slides.push(sheet);\n }\n }\n\n // Any slide the list forgot is still a slide, and a package that lost its\n // `p:sldIdLst` should still show something.\n for (const rel of rels.byType(REL_SLIDE)) {\n const target = rels.resolve(rel);\n if (state.sheets.has(target)) continue;\n const sheet = loadSheet(state, target);\n if (sheet !== null) slides.push(sheet);\n }\n\n const masters: Sheet[] = [];\n for (const rel of rels.byType(REL_MASTER)) {\n const sheet = loadSheet(state, rels.resolve(rel));\n if (sheet !== null) masters.push(sheet);\n }\n\n // Layouts, through each master's own rels - which is the only record of which\n // master owns which layout.\n const layouts: Sheet[] = [];\n for (const master of masters) {\n const masterRels = store.relationships(master.partName);\n for (const rel of masterRels.byType(REL_LAYOUT)) {\n const sheet = loadSheet(state, masterRels.resolve(rel));\n if (sheet !== null && !layouts.includes(sheet)) layouts.push(sheet);\n }\n }\n\n const size = presentation.children.find(\n (child) => child.type === 'element' && child.qname === 'p:sldSz',\n );\n const dimension = (name: string): number => {\n if (size === undefined || size.type !== 'element') return 0;\n const raw = size.attributes.find((attr) => attr.qname === name)?.value;\n return raw === undefined ? 0 : Number(raw);\n };\n\n const sheets = state.sheets;\n return {\n presentation,\n presentationPartName,\n slides,\n masters,\n layouts,\n themes: [...state.themes.values()],\n problems: state.problems,\n defaultTextStyle: parseDefaultTextStyle(presentation, presentationPartName),\n slideSize: { cx: dimension('cx'), cy: dimension('cy') },\n sheet(partName: string): Sheet | undefined {\n return sheets.get(partName);\n },\n };\n}\n","/**\n * PowerPoint's own `p:txStyles`, substituted when a master declares none.\n *\n * GENERATED by tools/ground-truth/text/cascade/write-tables.ts from\n * corpus/ground-truth/text-cascade.json. Do not edit by hand.\n *\n * Measured, not transcribed. Nine paragraphs at `lvl=\"0\"` through `lvl=\"8\"` in a\n * title placeholder, a body placeholder and a shape that is not a placeholder,\n * in a package whose master carries no `p:txStyles` at all, read back through\n * PowerPoint's own object model. The body ladder - 28, 24, 20 and then 18 for\n * the rest - is not a number anything in the file declares, which is how the\n * ladder experiment discovered there was a source below every source the plan\n * names.\n *\n * A PowerPoint-authored master always writes `p:txStyles`, so this table only\n * ever applies to a hand-written or damaged one. It exists because the\n * alternative is a placeholder resolving to no size at all, and because a\n * measured answer costs one deck.\n *\n * `bullet` says whether PowerPoint drew one, which is what 3.5 reproduces; the\n * glyph and its font belong to that sub-phase and are in the fixture, not here.\n */\n\n/** One level of a built-in list style. */\nexport interface BuiltinLevel {\n /** Hundredths of a point, as `a:defRPr/@sz` holds it. */\n readonly sz: number;\n /** EMU, as `a:lvlNpPr/@marL` holds it. */\n readonly marL: number;\n /** EMU, as `a:lvlNpPr/@indent` holds it. Negative is a hanging indent. */\n readonly indent: number;\n readonly bullet: boolean;\n /**\n * The theme reference this level names, or `null` where it names none.\n *\n * A reference and not a face, because the built-in styles are the same\n * whatever theme a package carries: `+mj-lt` measured as the theme's major\n * face and `+mn-lt` as its minor.\n */\n readonly typeface: string | null;\n}\n\n/** The three buckets, nine levels each, level 1 first. */\nexport const BUILTIN_TEXT_STYLES: {\n readonly title: readonly BuiltinLevel[];\n readonly body: readonly BuiltinLevel[];\n readonly other: readonly BuiltinLevel[];\n} = {\n title: [\n { sz: 4400, marL: 0, indent: 0, bullet: false, typeface: '+mj-lt' },\n { sz: 1800, marL: 0, indent: 0, bullet: false, typeface: null },\n { sz: 1800, marL: 0, indent: 0, bullet: false, typeface: null },\n { sz: 1800, marL: 0, indent: 0, bullet: false, typeface: null },\n { sz: 1800, marL: 0, indent: 0, bullet: false, typeface: null },\n { sz: 1800, marL: 0, indent: 0, bullet: false, typeface: null },\n { sz: 1800, marL: 0, indent: 0, bullet: false, typeface: null },\n { sz: 1800, marL: 0, indent: 0, bullet: false, typeface: null },\n { sz: 1800, marL: 0, indent: 0, bullet: false, typeface: null },\n ],\n body: [\n { sz: 2800, marL: 228600, indent: -228600, bullet: true, typeface: '+mn-lt' },\n { sz: 2400, marL: 685800, indent: -228600, bullet: true, typeface: '+mn-lt' },\n { sz: 2000, marL: 1143000, indent: -228600, bullet: true, typeface: '+mn-lt' },\n { sz: 1800, marL: 1600200, indent: -228600, bullet: true, typeface: '+mn-lt' },\n { sz: 1800, marL: 2057400, indent: -228600, bullet: true, typeface: '+mn-lt' },\n { sz: 1800, marL: 2514600, indent: -228600, bullet: true, typeface: '+mn-lt' },\n { sz: 1800, marL: 2971800, indent: -228600, bullet: true, typeface: '+mn-lt' },\n { sz: 1800, marL: 3429000, indent: -228600, bullet: true, typeface: '+mn-lt' },\n { sz: 1800, marL: 3886200, indent: -228600, bullet: true, typeface: '+mn-lt' },\n ],\n other: [\n { sz: 1800, marL: 0, indent: 0, bullet: false, typeface: '+mn-lt' },\n { sz: 1800, marL: 457200, indent: 0, bullet: false, typeface: '+mn-lt' },\n { sz: 1800, marL: 914400, indent: 0, bullet: false, typeface: '+mn-lt' },\n { sz: 1800, marL: 1371600, indent: 0, bullet: false, typeface: '+mn-lt' },\n { sz: 1800, marL: 1828800, indent: 0, bullet: false, typeface: '+mn-lt' },\n { sz: 1800, marL: 2286000, indent: 0, bullet: false, typeface: '+mn-lt' },\n { sz: 1800, marL: 2743200, indent: 0, bullet: false, typeface: '+mn-lt' },\n { sz: 1800, marL: 3200400, indent: 0, bullet: false, typeface: '+mn-lt' },\n { sz: 1800, marL: 3657600, indent: 0, bullet: false, typeface: '+mn-lt' },\n ],\n};\n\n/**\n * What is left when every source is silent and the master *does* declare\n * `p:txStyles`.\n *\n * Distinct from the table above, and measured separately: a body placeholder\n * whose `p:bodyStyle/a:lvl1pPr` declares only a `marL` came back at\n * 18 points rather than the built-in body style's\n * 28, and with no indent rather than the built-in's\n * hanging one. So the built-in styles are substituted wholesale for an absent\n * `p:txStyles` and are not a per-property backstop underneath a present one.\n *\n * `marL` and `indent` are **0**, not the ECMA-376 schema defaults of 347663 and\n * -342900. Materialising those at parse time gives every paragraph a\n * 27-point hanging indent nothing asked for, and blocks the inherited value on\n * top of it, because a default that has been written down cannot be told from a\n * declaration.\n *\n * The typeface is the minor face on all 6 probes that reach a silent cascade.\n */\nexport const TEXT_FLOOR: BuiltinLevel = {\n sz: 1800,\n marL: 0,\n indent: 0,\n bullet: false,\n typeface: '+mn-lt',\n};\n","/**\n * `+mn-lt` and its five siblings, resolved against a theme's `a:fontScheme`.\n *\n * Measured 8 of 8 against a reading that swaps the two collections, which fits\n * 2. ADR 0033.\n */\n\nimport { themeFontRef, type Typeface } from '../text.js';\nimport type { FontCollection, FontScheme } from '../types.js';\n\n/** The four slots a `CT_TextCharacterProperties` can name. */\nexport type ScriptSlot = 'latin' | 'ea' | 'cs' | 'sym';\n\n/**\n * The typeface a slot asks for, with any theme reference followed.\n *\n * `undefined` means the reference resolved to a collection entry the theme\n * leaves empty, which is not the same as the theme naming nothing.\n */\nexport function resolveTypeface(typeface: string, scheme: FontScheme): string | undefined {\n const ref = themeFontRef(typeface);\n if (ref === null) return typeface;\n const collection: FontCollection = ref.collection === 'major' ? scheme.major : scheme.minor;\n const name = collection[ref.script];\n if (name === null || name.length === 0) return undefined;\n return name;\n}\n\n/** The same, for a whole `CT_TextFont`. */\nexport function resolveTypefaceOf(font: Typeface, scheme: FontScheme): string | undefined {\n return resolveTypeface(font.typeface, scheme);\n}\n\n/**\n * Every distinct typeface a set of runs asks for, theme references followed.\n *\n * This is what `fontReport` is given: a report keyed on `+mn-lt` would name a\n * token no user recognises and would collapse two themes into one row.\n */\nexport function requestedTypefaces(\n fonts: Iterable<Typeface | undefined>,\n scheme: FontScheme,\n): readonly string[] {\n const out: string[] = [];\n for (const font of fonts) {\n if (font === undefined) continue;\n const name = resolveTypeface(font.typeface, scheme);\n if (name !== undefined) out.push(name);\n }\n return out;\n}\n","/**\n * The text cascade: one walk, two termini, and the origin of every answer.\n *\n * `resolveRun(context, paragraph, run, pick)` returns the first level that\n * declared the property asked for **and which level that was**, exactly as\n * `resolve` does for geometry and fills. The inspector's provenance chips,\n * per-property Reset, and knowing what a theme swap invalidates all fall out of\n * the same field, read by the same function the renderer reads.\n *\n * ## The walk\n *\n * 1. the run's own `a:rPr`\n * 2. the paragraph's `a:pPr/a:defRPr`\n * 3. the shape's `a:lstStyle`, at the paragraph's level\n * 4. each ancestor placeholder's `a:lstStyle`, up the chain 2.9 measured for\n * geometry: `@idx` alone to the layout, the folded `@type` to the master\n *\n * ## The two termini, which are not one ladder\n *\n * A shape whose chain ends at a type with a bucket - `title` and `ctrTitle` to\n * `p:titleStyle`, the content types to `p:bodyStyle` - reads that bucket and\n * **stops**. A shape with no bucket reads `p:defaultTextStyle` and **stops**.\n *\n * Measured in 3.1, and it is where every implementation this project has read\n * goes wrong. Scored over the eight combinations of the three choices anyone\n * could make, this reading fits 37 of 37 probes and the reading the plan\n * specified - the shape's own `@type` picks the bucket, the header-and-footer\n * trio reads `p:otherStyle`, and so does a shape that is not a placeholder -\n * fits 13. Three of the four disagreements are visible on any deck:\n *\n * - **The `@type` at the end of the chain picks the bucket, not the shape's.**\n * The first hop matches on `@idx` alone, so a slide `title` at idx 0 really\n * does land on a layout `body` at idx 0, and when it does it reads\n * `p:bodyStyle`. Measured both ways round and twice more through a `sldNum`.\n * - **`dt`, `ftr`, `sldNum` and `hdr` reach no bucket at all** and fall through\n * to `p:defaultTextStyle`, which a body placeholder ignores even when it is\n * there in the same package.\n * - **Nothing measurable reads `p:otherStyle`** - not those four, not a shape\n * that is not a placeholder, on the slide, the layout or the master.\n *\n * ## Every level contributes only what it declares\n *\n * The walk is per property, not per level. Measured with five levels declaring\n * one property each: the run came back 24-point bold italic underlined and\n * struck through, where a nearest-level-takes-all reading gives an 18-point run\n * that is only struck through.\n */\n\nimport { ModelError } from '../errors.js';\nimport { inheritanceChain, normalizePlaceholder } from './placeholder.js';\nimport { themeOf } from './resolve.js';\nimport { resolveTypeface } from './typeface.js';\nimport { BUILTIN_TEXT_STYLES, TEXT_FLOOR, type BuiltinLevel } from '../builtin-text-styles.js';\nimport {\n type BulletAutoNum,\n type BulletColor,\n type BulletFont,\n type BulletKind,\n type BulletSize,\n LEVELS,\n type ListStyle,\n type Paragraph,\n type ParaProps,\n type RunProps,\n type TextContent,\n themeFontRef,\n} from '../text.js';\nimport type { Origin, Resolved, Shape, Sheet } from '../types.js';\n\n/* -------------------------------------------------------------------------- */\n/* the bucket */\n/* -------------------------------------------------------------------------- */\n\n/** `title` and `ctrTitle`. Everything else with a bucket has the body one. */\nconst TITLE_TYPES: ReadonlySet<string> = new Set(['title', 'ctrTitle']);\n\n/**\n * The four types that reach no bucket.\n *\n * Measured, and against the plan, which assigned all four to `p:otherStyle`. A\n * `sldNum` placeholder in a package declaring `p:otherStyle` at 12 points and\n * `p:defaultTextStyle` at 20 came back at 20.\n */\nconst NO_BUCKET_TYPES: ReadonlySet<string> = new Set(['dt', 'ftr', 'sldNum', 'hdr']);\n\n/** Which `p:txStyles` bucket a placeholder type reads, or `null` for none. */\nexport function bucketOf(type: string): 'title' | 'body' | null {\n if (TITLE_TYPES.has(type)) return 'title';\n if (NO_BUCKET_TYPES.has(type)) return null;\n return 'body';\n}\n\n/* -------------------------------------------------------------------------- */\n/* the context */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Everything the cascade needs that is not on the shape.\n *\n * `defaultTextStyle` comes from `ppt/presentation.xml` and is therefore a\n * property of the package rather than of any sheet, which is why it is passed\n * in rather than walked to. A caller that has a `Document` has it already;\n * `undefined` means the package declared none, which is a state PowerPoint\n * distinguishes and this must too.\n */\nexport interface TextContext {\n readonly sheet: Sheet;\n readonly shape: Shape;\n readonly defaultTextStyle: ListStyle | undefined;\n}\n\n/** One level of the walk: a list style, and what to call it if it answers. */\ninterface Level {\n readonly style: ListStyle | undefined;\n readonly origin: Origin;\n readonly sheet: Sheet | null;\n readonly shape: Shape | null;\n}\n\n/** Where the walk ends: the bucket the chain's last type selects, and whose. */\ninterface Terminus {\n readonly bucket: 'title' | 'body' | null;\n readonly master: Sheet | null;\n}\n\nfunction terminusOf(context: TextContext): Terminus {\n const chain = inheritanceChain(context.shape, context.sheet);\n // The type at the *end* of the chain, not the shape's own. A slide title that\n // matched a layout body reads p:bodyStyle - measured, both ways round.\n const placeholder = chain.at(-1)?.shape.placeholder ?? null;\n let master: Sheet | null = null;\n for (let sheet: Sheet | null = context.sheet; sheet !== null; sheet = sheet.parent) {\n if (sheet.kind === 'master') {\n master = sheet;\n break;\n }\n }\n return {\n bucket: placeholder === null ? null : bucketOf(normalizePlaceholder(placeholder).type),\n master,\n };\n}\n\n/**\n * The list styles a shape reads, nearest first, ending at whichever terminus it\n * reaches.\n *\n * Exported because it *is* the finding: a caller that wants to show the user\n * where a value could have come from - the inspector's Overrides panel, layout\n * compatibility scoring - needs the same list the resolver walks, not a second\n * opinion about it.\n */\nexport function textLevels(context: TextContext): readonly Level[] {\n const levels: Level[] = inheritanceChain(context.shape, context.sheet).map((link, index) => ({\n style: link.shape.text?.lstStyle,\n origin: index === 0 ? 'shape' : link.origin,\n sheet: link.sheet,\n shape: link.shape,\n }));\n\n const { bucket, master } = terminusOf(context);\n if (bucket === null) {\n levels.push({\n style: context.defaultTextStyle,\n origin: 'defaultTextStyle',\n sheet: null,\n shape: null,\n });\n return levels;\n }\n\n // The master's own p:txStyles. When it has none, PowerPoint substitutes its\n // built-in styles wholesale rather than merging them underneath - that is not\n // a `ListStyle`, so `floorOf` applies it and this level is simply absent.\n levels.push({\n style: master?.txStyles?.[bucket],\n origin: 'txStyles',\n sheet: master,\n shape: null,\n });\n return levels;\n}\n\n/**\n * The values left when every level has been asked and none of them said.\n *\n * Two quite different things, and which applies turns on one question: does the\n * master declare `p:txStyles` at all? If it does not, PowerPoint substitutes its\n * whole built-in set, and a body placeholder is 28 points with a hanging bullet\n * indent. If it does, there is no per-property backstop underneath it and what\n * remains is the floor - 18 points, no margin, no indent. Measured as two\n * separate probes precisely because the two are easy to conflate and differ on\n * every partially-specified master.\n */\nexport function floorOf(context: TextContext, level: number): BuiltinLevel {\n const { bucket, master } = terminusOf(context);\n if (master?.txStyles !== undefined) return TEXT_FLOOR;\n return BUILTIN_TEXT_STYLES[bucket ?? 'other'][clampLevel(level)] ?? TEXT_FLOOR;\n}\n\nfunction clampLevel(level: number): number {\n if (!Number.isInteger(level)) {\n throw new ModelError('MODEL_TEXT_LEVEL', `paragraph level ${String(level)} is not an integer`);\n }\n return Math.max(0, Math.min(LEVELS - 1, level));\n}\n\n/* -------------------------------------------------------------------------- */\n/* resolving */\n/* -------------------------------------------------------------------------- */\n\nfunction resolvedAt<T>(value: T, level: Level, explicit: boolean): Resolved<T> {\n return { value, origin: level.origin, explicit, sheet: level.sheet, shape: level.shape };\n}\n\n/**\n * A paragraph property, from the paragraph's own `a:pPr` or up the walk.\n *\n * `pick` returns `undefined` for \"this level did not say\" and anything else for\n * a value, including `null` - the same contract `resolve` uses, and for the same\n * reason: a level may legitimately declare a `null`, and conflating that with\n * silence is how an explicit value gets overwritten by an inherited one.\n */\nexport function resolveParagraph<T>(\n context: TextContext,\n paragraph: Paragraph,\n pick: (props: ParaProps) => T | undefined,\n): Resolved<T> | undefined {\n if (paragraph.props !== undefined) {\n const own = pick(paragraph.props);\n if (own !== undefined) {\n return {\n value: own,\n origin: 'paragraph',\n explicit: true,\n sheet: context.sheet,\n shape: context.shape,\n };\n }\n }\n const level = clampLevel(paragraph.level);\n for (const entry of textLevels(context)) {\n const props = entry.style?.levels[level];\n if (props === undefined) continue;\n const value = pick(props);\n if (value !== undefined) return resolvedAt(value, entry, entry.origin === 'shape');\n }\n return undefined;\n}\n\n/**\n * A run property, from the run's own `a:rPr` and then every `a:defRPr` above it.\n *\n * The paragraph's `a:pPr/a:defRPr` is one level, not a special case: it sits\n * between the run and the shape's `a:lstStyle`, which the ladder pinned by\n * declaring a different size at each and reading back which one won.\n */\nexport function resolveRun<T>(\n context: TextContext,\n paragraph: Paragraph,\n run: TextContent | undefined,\n pick: (props: RunProps) => T | undefined,\n): Resolved<T> | undefined {\n if (run?.props !== undefined) {\n const own = pick(run.props);\n if (own !== undefined) {\n return {\n value: own,\n origin: 'run',\n explicit: true,\n sheet: context.sheet,\n shape: context.shape,\n };\n }\n }\n if (paragraph.props?.defRPr !== undefined) {\n const value = pick(paragraph.props.defRPr);\n if (value !== undefined) {\n return {\n value,\n origin: 'paragraph',\n explicit: true,\n sheet: context.sheet,\n shape: context.shape,\n };\n }\n }\n const level = clampLevel(paragraph.level);\n for (const entry of textLevels(context)) {\n const defRPr = entry.style?.levels[level]?.defRPr;\n if (defRPr === undefined) continue;\n const value = pick(defRPr);\n if (value !== undefined) return resolvedAt(value, entry, entry.origin === 'shape');\n }\n return undefined;\n}\n\n/* -------------------------------------------------------------------------- */\n/* the three properties with a measured floor */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The font size of a run, in hundredths of a point, always.\n *\n * The only resolver here that cannot return `undefined`: text has to be drawn at\n * some size, and the size when nothing declared one is measured rather than\n * chosen. `origin` is `builtin` when the master declares no `p:txStyles` and\n * `schemaDefault` when it does and the bucket said nothing - two different\n * numbers on the same slide, and the field says which was used.\n */\nexport function resolveSize(\n context: TextContext,\n paragraph: Paragraph,\n run: TextContent | undefined,\n): Resolved<number> {\n const found = resolveRun(context, paragraph, run, (props) => props.sz);\n if (found !== undefined) return found;\n return floorResolved(context, paragraph, (level) => level.sz);\n}\n\n/**\n * The Latin typeface of a run, with any theme reference followed.\n *\n * The second resolver that cannot return `undefined`: a run has to be drawn in\n * some face, and the face when nothing named one is measured rather than\n * chosen - the theme's minor, on all six probes reaching a silent cascade.\n */\nexport function resolveLatinTypeface(\n context: TextContext,\n paragraph: Paragraph,\n run: TextContent | undefined,\n): Resolved<string> {\n const scheme = themeOf(context.sheet)?.fonts ?? null;\n /** A name a source gave, with a theme reference followed where one can be. */\n const faceOf = (typeface: string): string | undefined => {\n if (themeFontRef(typeface) === null) return typeface;\n return scheme === null ? undefined : resolveTypeface(typeface, scheme);\n };\n\n const named = resolveRun(context, paragraph, run, (props) => props.latin);\n if (named !== undefined) {\n const face = faceOf(named.value.typeface);\n if (face !== undefined) return { ...named, value: face };\n }\n const floor = floorOf(context, paragraph.level);\n const reference = floor.typeface ?? TEXT_FLOOR.typeface;\n const face = reference === null ? undefined : faceOf(reference);\n if (face === undefined) {\n throw new ModelError(\n 'MODEL_TEXT_TYPEFACE',\n 'no source in the cascade names a typeface, and the theme names none either',\n );\n }\n return {\n value: face,\n origin: floor === TEXT_FLOOR ? 'schemaDefault' : 'builtin',\n explicit: false,\n sheet: null,\n shape: null,\n };\n}\n\n/** `@marL` in EMU. Measured to be 0 when nothing declares it, not 347663. */\nexport function resolveMarginLeft(context: TextContext, paragraph: Paragraph): Resolved<number> {\n const found = resolveParagraph(context, paragraph, (props) => props.marL);\n if (found !== undefined) return found;\n return floorResolved(context, paragraph, (level) => level.marL);\n}\n\n/** `@indent` in EMU. Measured to be 0 when nothing declares it, not -342900. */\nexport function resolveIndent(context: TextContext, paragraph: Paragraph): Resolved<number> {\n const found = resolveParagraph(context, paragraph, (props) => props.indent);\n if (found !== undefined) return found;\n return floorResolved(context, paragraph, (level) => level.indent);\n}\n\n/* -------------------------------------------------------------------------- */\n/* bullets */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The bullet, merged the way T5 measured it: five slots, each on its own.\n *\n * The kind is one slot because the schema makes the four elements exclusive, and\n * the three decorations are three more because PowerPoint merges them\n * separately - a level declaring only `a:buFont` re-faces the character it\n * inherits and keeps its size and colour. Measured on eleven cases twice over,\n * once through a shape's own `a:lstStyle` and once through three hops of the\n * master chain, and the two agree.\n *\n * Every one of these returns `undefined` when nothing in the chain declares the\n * slot, which for the kind is the difference between \"no bullet\" and \"nobody\n * said\" - `a:buNone` resolves to `'none'` and an empty chain to `undefined`.\n * Nothing here supplies a default, because a paragraph with no bullet anywhere\n * in its chain genuinely has none.\n */\nexport function resolveBulletKind(\n context: TextContext,\n paragraph: Paragraph,\n): Resolved<BulletKind> | undefined {\n return resolveParagraph(context, paragraph, (props) => props.buKind);\n}\n\n/** `a:buChar/@char`, as written. The symbol mapping belongs to the renderer. */\nexport function resolveBulletChar(\n context: TextContext,\n paragraph: Paragraph,\n): Resolved<string> | undefined {\n return resolveParagraph(context, paragraph, (props) => props.buChar);\n}\n\n/** `a:buAutoNum`, type and start value together, since one is meaningless alone. */\nexport function resolveBulletAutoNum(\n context: TextContext,\n paragraph: Paragraph,\n): Resolved<BulletAutoNum> | undefined {\n return resolveParagraph(context, paragraph, (props) => props.buAutoNum);\n}\n\n/** `a:buBlip/a:blip/@r:embed`, which the caller resolves against the part's rels. */\nexport function resolveBulletBlip(\n context: TextContext,\n paragraph: Paragraph,\n): Resolved<string> | undefined {\n return resolveParagraph(context, paragraph, (props) => props.buBlip);\n}\n\n/**\n * `a:buFont` or `a:buFontTx`.\n *\n * Worth knowing before using it: this is **inert for an autonumber**. PowerPoint\n * draws a number in the first run's face whatever `a:buFont` says - measured on\n * twenty probes, including one where `buFont` named Wingdings and the run named\n * Courier New - and its own UI writes `buFont=\"+mj-lt\"` on every list it\n * numbers. The resolver still reports it, because the file says it and 1.3 has\n * to write it back; the renderer is where it is ignored.\n */\nexport function resolveBulletFont(\n context: TextContext,\n paragraph: Paragraph,\n): Resolved<BulletFont> | undefined {\n return resolveParagraph(context, paragraph, (props) => props.buFont);\n}\n\n/** `a:buSzPct`, `a:buSzPts` or `a:buSzTx`; a percentage is of the first run's size. */\nexport function resolveBulletSize(\n context: TextContext,\n paragraph: Paragraph,\n): Resolved<BulletSize> | undefined {\n return resolveParagraph(context, paragraph, (props) => props.buSize);\n}\n\n/** `a:buClr` or `a:buClrTx`. Unlike the font, this one *does* reach an autonumber. */\nexport function resolveBulletColor(\n context: TextContext,\n paragraph: Paragraph,\n): Resolved<BulletColor> | undefined {\n return resolveParagraph(context, paragraph, (props) => props.buColor);\n}\n\nfunction floorResolved(\n context: TextContext,\n paragraph: Paragraph,\n pick: (level: BuiltinLevel) => number,\n): Resolved<number> {\n const floor = floorOf(context, paragraph.level);\n return {\n value: pick(floor),\n origin: floor === TEXT_FLOOR ? 'schemaDefault' : 'builtin',\n explicit: false,\n sheet: null,\n shape: null,\n };\n}\n","/**\n * `a:bodyPr`, resolved up the placeholder chain.\n *\n * Every attribute inherits on its own, from any level: a bare `<a:bodyPr/>` on a\n * slide is anchored where its master says, not at the schema default. ADR 0032.\n */\n\nimport { inheritanceChain } from './placeholder.js';\nimport type { Resolved, Shape, Sheet } from '../types.js';\nimport type { BodyProps, TextAnchor, TextWrap, VerticalText } from '../text.js';\n\nconst EMU_PER_POINT = 12700;\n\n/**\n * The four insets in points, per attribute.\n *\n * Restated here rather than imported from `@pptx-studio/text`, which is a layer\n * below and which this package does not depend on - the same posture\n * `line-model.ts` takes towards `Spacing`.\n */\nexport interface ResolvedInsets {\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\n/** Points. Asymmetric, and each edge defaults on its own. */\nconst DEFAULT_INSETS: ResolvedInsets = { left: 7.2, top: 3.6, right: 7.2, bottom: 3.6 };\n\n/**\n * One property of the text frame, from the shape's own `a:bodyPr` or above it.\n *\n * `pick` returns `undefined` for \"this level did not say\", the same contract the\n * text cascade uses.\n */\nexport function resolveBody<T>(\n shape: Shape,\n sheet: Sheet,\n pick: (props: BodyProps) => T | undefined,\n): Resolved<T> | undefined {\n for (const [index, link] of inheritanceChain(shape, sheet).entries()) {\n const props = link.shape.text?.bodyPr;\n if (props === undefined) continue;\n const value = pick(props);\n if (value === undefined) continue;\n return {\n value,\n origin: index === 0 ? 'shape' : link.origin,\n explicit: index === 0,\n sheet: link.sheet,\n shape: link.shape,\n };\n }\n return undefined;\n}\n\nexport function resolveAnchor(shape: Shape, sheet: Sheet): Resolved<TextAnchor> | undefined {\n return resolveBody(shape, sheet, (p) => p.anchor);\n}\n\nexport function resolveAnchorCtr(shape: Shape, sheet: Sheet): Resolved<boolean> | undefined {\n return resolveBody(shape, sheet, (p) => p.anchorCtr);\n}\n\nexport function resolveVertical(shape: Shape, sheet: Sheet): Resolved<VerticalText> | undefined {\n return resolveBody(shape, sheet, (p) => p.vert);\n}\n\nexport function resolveWrap(shape: Shape, sheet: Sheet): Resolved<TextWrap> | undefined {\n return resolveBody(shape, sheet, (p) => p.wrap);\n}\n\nexport function resolveColumns(shape: Shape, sheet: Sheet): Resolved<number> | undefined {\n return resolveBody(shape, sheet, (p) => p.numCol);\n}\n\n/**\n * The four insets, in points, each falling back on its own.\n *\n * A frame stating only `lIns` still gets 3.6 above and below, so this resolves\n * four times rather than once.\n */\nexport function resolveInsets(shape: Shape, sheet: Sheet): ResolvedInsets {\n const at = (pick: (p: BodyProps) => number | undefined, fallback: number): number => {\n const found = resolveBody(shape, sheet, pick);\n return found === undefined ? fallback : found.value / EMU_PER_POINT;\n };\n return {\n left: at((p) => p.lIns, DEFAULT_INSETS.left),\n top: at((p) => p.tIns, DEFAULT_INSETS.top),\n right: at((p) => p.rIns, DEFAULT_INSETS.right),\n bottom: at((p) => p.bIns, DEFAULT_INSETS.bottom),\n };\n}\n"],"mappings":";;;;;AAwEA,IAAa,aAAb,cAAgC,MAAM;CACpC,OAAyB;CACzB;;CAEA;;CAEA;CAEA,YACE,MACA,SACA,WAA0B,MAC1B,SAAwB,MACxB;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,WAAW;EAChB,KAAK,SAAS;CAChB;AACF;AAEA,SAAgB,aAAa,OAAqC;CAChE,OAAO,iBAAiB;AAC1B;AAEA,MAAa,oBAA+C;CAC1D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;ACvCA,MAAa,oBAAgD;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,2BAAuD;CAClE;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;;ACnDA,MAAM,iCAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,SAAS,QAAQ,SAAmB,MAAc,UAAkB,MAAsB;CACxF,MAAM,MAAM,eAAe,SAAS,IAAI;CACxC,IAAI,QAAQ,KAAA,GAAW,OAAO;CAC9B,MAAM,QAAQ,OAAO,GAAG;CACxB,IAAI,CAAC,OAAO,UAAU,KAAK,GACzB,MAAM,IAAI,WAAW,qBAAqB,GAAG,KAAK,IAAI,KAAK,OAAO,IAAI,IAAI,MAAM,GAAG;CAErF,OAAO;AACT;;;;;;;;AASA,SAAS,YAAY,SAAmB,MAAc,UAA0B;CAC9E,MA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