@office-open/docx 0.9.4 → 0.9.6

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"document-B_uvEH8b.mjs","names":["xmlChildren","createWrapPolygon","md"],"sources":["../src/shared/media/media.ts","../src/shared/media/data.ts","../src/parts/drawing/inline/graphic/graphic-data/wps/body-properties.ts","../src/parts/paragraph/run/form-field.ts","../src/parts/table/table-cell/table-cell-components.ts","../src/shared/border.ts","../src/parts/table/table-width.ts","../src/parts/drawing/text-wrap/text-wrapping.ts","../src/parts/drawing/text-wrap/wrap-tight.ts","../src/parts/drawing/text-wrap/wrap-through.ts","../src/shared/constants.ts","../src/parts/drawing/floating/floating-position.ts","../src/parts/drawing/floating/horizontal-position.ts","../src/parts/drawing/floating/vertical-position.ts","../src/parts/drawing/drawing-parse.ts","../src/parts/drawing/descriptor.ts","../src/parts/paragraph/math/stringify.ts","../src/parts/paragraph/run/field.ts","../src/parts/paragraph/stringify.ts","../src/parts/inline.ts","../src/parts/table/stringify.ts","../src/parts/table/descriptor.ts","../src/parts/document/document-attributes.ts","../src/parts/document/body/section-properties/properties/page-size.ts","../src/parts/document/body/section-properties/properties/page-text-direction.ts","../src/parts/document/body/section-properties/section-properties.ts","../src/parts/document/body/section-properties/properties/doc-grid.ts","../src/parts/document/body/section-properties/properties/page-number.ts","../src/parts/document/body/section-properties/properties/page-borders.ts","../src/parts/document/body/section-properties/properties/page-margin.ts","../src/parts/document/body/section-properties/properties/line-number.ts","../src/parts/document/body/section-properties/properties/section-type.ts","../src/parts/document/body/section-properties/properties/header-footer-reference.ts","../src/parts/document/body/section-properties/descriptor.ts"],"sourcesContent":["import type { UniversalMeasure } from \"@office-open/core\";\nimport { convertPixelsToEmu, convertUniversalMeasureToEmu } from \"@office-open/core\";\n\n/**\n * Media module for WordprocessingML documents.\n *\n * This module provides support for managing embedded media (images)\n * within a document.\n *\n * @module\n */\nimport type { MediaDataTransformation } from \"./data\";\nimport type { MediaData } from \"./data\";\n\n/**\n * Transformation options for media display.\n *\n * Specifies how an image should be transformed when displayed in the document.\n * Width and height can be specified as numbers (in pixels) or as universal measures\n * (e.g., \"100mm\", \"2in\").\n */\nexport interface MediaTransformation {\n offset?: {\n top?: number | UniversalMeasure;\n left?: number | UniversalMeasure;\n };\n width: number | UniversalMeasure;\n /** Display height in pixels or universal measure */\n height: number | UniversalMeasure;\n /** Optional flip transformations */\n flip?: {\n /** Whether to flip the image vertically */\n vertical?: boolean;\n /** Whether to flip the image horizontally */\n horizontal?: boolean;\n };\n /** Optional rotation angle in degrees */\n rotation?: number;\n}\n\n/**\n * Converts user-facing transformation options (pixels or universal measure) to internal\n * transformation data (pixels + EMUs).\n *\n * @param options - User-facing transformation in pixels or universal measure\n * @returns Internal transformation data with both pixel and EMU values\n */\nexport const createTransformation = (options: MediaTransformation): MediaDataTransformation => ({\n emus: {\n x:\n typeof options.width === \"string\"\n ? convertUniversalMeasureToEmu(options.width)\n : convertPixelsToEmu(options.width),\n y:\n typeof options.height === \"string\"\n ? convertUniversalMeasureToEmu(options.height)\n : convertPixelsToEmu(options.height),\n },\n flip: options.flip,\n offset: {\n emus: {\n x:\n typeof options.offset?.left === \"string\"\n ? convertUniversalMeasureToEmu(options.offset.left)\n : convertPixelsToEmu(options.offset?.left ?? 0),\n y:\n typeof options.offset?.top === \"string\"\n ? convertUniversalMeasureToEmu(options.offset.top)\n : convertPixelsToEmu(options.offset?.top ?? 0),\n },\n pixels: {\n x: typeof options.offset?.left === \"number\" ? Math.round(options.offset.left) : 0,\n y: typeof options.offset?.top === \"number\" ? Math.round(options.offset.top) : 0,\n },\n },\n pixels: {\n x: typeof options.width === \"number\" ? Math.round(options.width) : 0,\n y: typeof options.height === \"number\" ? Math.round(options.height) : 0,\n },\n rotation: options.rotation ? options.rotation * 60_000 : undefined,\n});\n\n/**\n * Manages embedded media (images) in a document.\n *\n * Media stores all images referenced in the document and provides\n * access to their data for packaging into the DOCX file. Each image\n * is stored with a unique key for retrieval.\n *\n * @example\n * ```typescript\n * const media = new Media();\n * media.addImage(\"image1\", {\n * type: \"png\",\n * fileName: \"image1.png\",\n * transformation: {\n * pixels: { x: 200, y: 100 },\n * emus: { x: 1828800, y: 914400 }\n * },\n * data: imageBuffer\n * });\n * const allImages = media.Array;\n * ```\n */\nexport class Media {\n private map: Map<string, MediaData>;\n\n public constructor() {\n this.map = new Map<string, MediaData>();\n }\n\n /**\n * Adds an image to the media collection.\n *\n * @param key - Unique identifier for this image\n * @param mediaData - Complete image data including file name, transformation, and raw data\n */\n public addImage(key: string, mediaData: MediaData): void {\n this.map.set(key, mediaData);\n }\n\n /**\n * Gets all images as an array.\n *\n * @returns Read-only array of all media data in the collection\n */\n public get array(): MediaData[] {\n return [...this.map.values()];\n }\n}\n","import type { FillOptions } from \"@office-open/core/drawingml\";\nimport type { SourceRectangleOptions } from \"@parts/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle\";\nimport type { EffectListOptions } from \"@parts/drawing/inline/graphic/graphic-data/pic/effects/effect-list\";\nimport type { OutlineOptions } from \"@parts/drawing/inline/graphic/graphic-data/pic/outline/outline\";\nimport type {\n ChildExtent,\n ChildOffset,\n} from \"@parts/drawing/inline/graphic/graphic-data/wpg/wpg-group\";\nimport type { WpsShapeCoreOptions } from \"@parts/drawing/inline/graphic/graphic-data/wps\";\n\nexport interface MediaDataTransformation {\n offset?: {\n pixels: {\n x: number;\n y: number;\n };\n emus?: {\n x: number;\n y: number;\n };\n };\n pixels: {\n /** Width in pixels */\n x: number;\n /** Height in pixels */\n y: number;\n };\n /** Display dimensions in EMUs (English Metric Units) */\n emus: {\n /** Width in EMUs (1 inch = 914400 EMUs) */\n x: number;\n /** Height in EMUs (1 inch = 914400 EMUs) */\n y: number;\n };\n /** Optional flip transformations */\n flip?: {\n /** Whether to flip the image vertically */\n vertical?: boolean;\n /** Whether to flip the image horizontally */\n horizontal?: boolean;\n };\n /** Optional rotation angle in degrees */\n rotation?: number;\n}\n\n/**\n * Core properties shared by all media data types.\n */\ninterface CoreMediaData {\n /** File name for the media in the package */\n fileName: string;\n /** Transformation settings for display */\n transformation: MediaDataTransformation;\n /** Raw image data */\n data: Uint8Array;\n /** Source rectangle for image cropping */\n srcRect?: SourceRectangleOptions;\n}\n\n/**\n * Regular raster image formats.\n */\ninterface RegularMediaData {\n /** Image format type */\n type: \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\";\n}\n\n/**\n * SVG image format with fallback support.\n */\ninterface SvgMediaData {\n /** SVG image type */\n type: \"svg\";\n /**\n * Fallback image for Word processors that do not support SVG.\n * This ensures the document displays correctly in all viewers.\n */\n fallback: RegularMediaData & CoreMediaData;\n}\n\nexport interface WpsMediaData {\n type: \"wps\";\n transformation: MediaDataTransformation;\n data: WpsShapeCoreOptions;\n}\n\nexport interface WpgCommonMediaData {\n outline?: OutlineOptions;\n fill?: FillOptions;\n}\n\nexport type GroupChildMediaData = (WpsMediaData | MediaData) & WpgCommonMediaData;\n\nexport interface WpgMediaData {\n type: \"wpg\";\n transformation: MediaDataTransformation;\n children: GroupChildMediaData[];\n /** Child coordinate offset */\n chOff?: ChildOffset;\n /** Child coordinate extent */\n chExt?: ChildExtent;\n /** Group fill */\n fill?: FillOptions;\n /** Group effects */\n effects?: EffectListOptions;\n}\n\n/**\n * Chart media data — references a chart part via placeholder.\n */\nexport interface ChartMediaData {\n type: \"chart\";\n transformation: MediaDataTransformation;\n chartKey: string;\n}\n\n/**\n * SmartArt media data — references a diagram data part via placeholder.\n */\nexport interface SmartArtMediaData {\n type: \"smartart\";\n transformation: MediaDataTransformation;\n smartArtKey: string;\n}\n\nexport type ExtendedMediaData =\n | MediaData\n | WpsMediaData\n | WpgMediaData\n | ChartMediaData\n | SmartArtMediaData;\n\nexport type MediaData = (RegularMediaData | SvgMediaData) & CoreMediaData;\n\n// Needed because of: https://github.com/s-panferov/awesome-typescript-loader/issues/432\n/**\n * @ignore\n */\nexport const WORKAROUND2 = \"\";\n","/**\n * Text body properties for DrawingML shapes.\n *\n * Provides CT_TextBodyProperties — defines how text is laid out within a shape,\n * including margins, alignment, autofit, vertical text, overflow, columns, and 3D.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TextBodyProperties\n *\n * @module\n */\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport { convertToEmu } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n\nimport type { Scene3DOptions } from \"../pic/three-d/scene-3d\";\nimport { createScene3D } from \"../pic/three-d/scene-3d\";\nimport type { Shape3DOptions } from \"../pic/three-d/shape-3d\";\nimport { createShape3D } from \"../pic/three-d/shape-3d\";\n\n// ─── Constants ──────────────────────────────────────────────────────────────\n\n/**\n * Text anchoring type (ST_TextAnchoringType).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TextAnchoringType\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"t\"/>\n * <xsd:enumeration value=\"ctr\"/>\n * <xsd:enumeration value=\"b\"/>\n * <xsd:enumeration value=\"just\"/>\n * <xsd:enumeration value=\"dist\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport enum VerticalAnchor {\n TOP = \"t\",\n CENTER = \"ctr\",\n BOTTOM = \"b\",\n JUSTIFY = \"just\",\n DISTRIBUTED = \"dist\",\n}\n\n/**\n * Text vertical overflow type (ST_TextVertOverflowType).\n */\nexport const TextVertOverflowType = {\n OVERFLOW: \"overflow\",\n ELLIPSIS: \"ellipsis\",\n CLIP: \"clip\",\n} as const;\n\n/**\n * Text horizontal overflow type (ST_TextHorzOverflowType).\n */\nexport const TextHorzOverflowType = {\n OVERFLOW: \"overflow\",\n CLIP: \"clip\",\n} as const;\n\n/**\n * Text vertical type (ST_TextVerticalType).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TextVerticalType\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"horz\"/>\n * <xsd:enumeration value=\"vert\"/>\n * <xsd:enumeration value=\"vert270\"/>\n * <xsd:enumeration value=\"wordArtVert\"/>\n * <xsd:enumeration value=\"eaVert\"/>\n * <xsd:enumeration value=\"mongolianVert\"/>\n * <xsd:enumeration value=\"wordArtVertRtl\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const TextVerticalType = {\n HORIZONTAL: \"horz\",\n VERTICAL: \"vert\",\n VERTICAL_270: \"vert270\",\n WORD_ART_VERTICAL: \"wordArtVert\",\n EAST_ASIAN_VERTICAL: \"eaVert\",\n MONGOLIAN_VERTICAL: \"mongolianVert\",\n WORD_ART_VERTICAL_RTL: \"wordArtVertRtl\",\n} as const;\n\n/**\n * Text body wrapping type (ST_TextWrappingType).\n *\n * This is different from text wrapping around shapes (ST_WrapText).\n */\nexport const TextBodyWrappingType = {\n NONE: \"none\",\n SQUARE: \"square\",\n} as const;\n\n// ─── Sub-element Options ────────────────────────────────────────────────────\n\n/**\n * Normal autofit options (CT_TextNormalAutofit).\n *\n * Scales text and line spacing to fit the shape.\n */\nexport interface NormalAutofitOptions {\n /** Font scale percentage (e.g., 100000 = 100%) */\n fontScale?: number;\n /** Line spacing reduction percentage */\n lnSpcReduction?: number;\n}\n\n/**\n * Preset text warp options (CT_PresetTextShape).\n */\nexport interface PresetTextShapeOptions {\n /** Preset shape type (e.g., \"textArchUp\", \"textCircle\") */\n preset: string;\n /** Optional adjustment values */\n adjustments?: { name: string; formula: string }[];\n}\n\n/**\n * Flat text options (CT_FlatText).\n */\nexport interface FlatTextOptions {\n /** Z-offset in EMUs */\n z?: number;\n}\n\n// ─── Main Options ───────────────────────────────────────────────────────────\n\n/**\n * Options for text body properties (CT_TextBodyProperties).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_TextBodyProperties\">\n * <xsd:sequence>\n * <xsd:element name=\"prstTxWarp\" type=\"CT_PresetTextShape\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_TextAutofit\" minOccurs=\"0\"/>\n * <xsd:element name=\"scene3d\" type=\"CT_Scene3D\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_Text3D\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <!-- 19 attributes -->\n * </xsd:complexType>\n * ```\n */\nexport interface BodyPropertiesOptions {\n // ── Attributes ──\n\n /** Text rotation angle in 60,000ths of a degree */\n rotation?: number;\n /** Whether to use spcFirstLastPara behavior */\n spcFirstLastPara?: boolean;\n /** Vertical text overflow behavior */\n vertOverflow?: (typeof TextVertOverflowType)[keyof typeof TextVertOverflowType];\n /** Horizontal text overflow behavior */\n horzOverflow?: (typeof TextHorzOverflowType)[keyof typeof TextHorzOverflowType];\n /** Text vertical direction */\n vert?: (typeof TextVerticalType)[keyof typeof TextVerticalType];\n /** Text wrapping type */\n wrap?: (typeof TextBodyWrappingType)[keyof typeof TextBodyWrappingType];\n /** Left inset in EMUs or universal measure (e.g., \"1cm\", \"0.5in\") */\n lIns?: number | UniversalMeasure;\n /** Top inset in EMUs or universal measure */\n tIns?: number | UniversalMeasure;\n /** Right inset in EMUs or universal measure */\n rIns?: number | UniversalMeasure;\n /** Bottom inset in EMUs or universal measure */\n bIns?: number | UniversalMeasure;\n /** Number of text columns (1-16) */\n numCol?: number;\n /** Spacing between columns in EMUs or universal measure */\n spcCol?: number | UniversalMeasure;\n /** Whether columns are right-to-left */\n rtlCol?: boolean;\n /** Whether text is from WordArt */\n fromWordArt?: boolean;\n /** Text anchor position */\n anchor?: (typeof VerticalAnchor)[keyof typeof VerticalAnchor];\n /** Whether to anchor at center */\n anchorCtr?: boolean;\n /** Whether to force anti-aliasing */\n forceAA?: boolean;\n /** Whether text is upright (default false) */\n upright?: boolean;\n /** Whether to use compatible line spacing */\n compatLnSpc?: boolean;\n\n // ── Convenience aliases (backward compatible) ──\n\n /** Vertical anchor position (alias for `anchor`) */\n verticalAnchor?: VerticalAnchor;\n /** Margins shorthand */\n margins?: {\n top?: number | UniversalMeasure;\n bottom?: number | UniversalMeasure;\n left?: number | UniversalMeasure;\n right?: number | UniversalMeasure;\n };\n\n // ── Child elements ──\n\n /** Preset text warp shape */\n prstTxWarp?: PresetTextShapeOptions;\n /** Disable autofit (EG_TextAutofit choice) */\n noAutoFit?: boolean;\n /** Normal autofit (EG_TextAutofit choice) */\n normAutofit?: NormalAutofitOptions;\n /** Shape autofit (EG_TextAutofit choice) */\n spAutoFit?: boolean;\n /** 3D scene */\n scene3d?: Scene3DOptions;\n /** 3D shape properties (EG_Text3D choice) */\n sp3d?: Shape3DOptions;\n /** Flat text (EG_Text3D choice) */\n flatTx?: FlatTextOptions;\n}\n\n// ─── Internal Helpers ───────────────────────────────────────────────────────\n\nconst filterAttrs = (\n options: Record<string, unknown>,\n): Record<string, string | number | boolean> | undefined => {\n const attrs: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(options)) {\n if (value !== undefined) {\n attrs[key] = value as string | number | boolean;\n }\n }\n return Object.keys(attrs).length > 0 ? attrs : undefined;\n};\n\n// ─── Preset Text Warp ───────────────────────────────────────────────────────\n\nconst createPresetTextShape = (options: PresetTextShapeOptions): string => {\n const adjChildren: string[] = [];\n if (options.adjustments) {\n for (const adj of options.adjustments) {\n adjChildren.push(`<a:gd name=\"${adj.name}\" fmla=\"${adj.formula}\"/>`);\n }\n }\n\n return element(\n \"a:prstTxWarp\",\n { prst: options.preset },\n adjChildren.length > 0 ? [element(\"a:avLst\", undefined, adjChildren)] : undefined,\n );\n};\n\n// ─── Main Factory ───────────────────────────────────────────────────────────\n\n/**\n * Creates a text body properties element (wps:bodyPr).\n *\n * Supports all 19 CT_TextBodyProperties attributes and all child elements\n * including preset text warp, autofit variants, 3D scene, and text 3D.\n *\n * @example\n * ```typescript\n * // Simple margins and anchor\n * createBodyProperties({\n * margins: { top: 100, bottom: 100, left: 200, right: 200 },\n * verticalAnchor: VerticalAnchor.CENTER,\n * });\n *\n * // Full options with vertical text and autofit\n * createBodyProperties({\n * vert: TextVerticalType.VERTICAL,\n * wrap: TextBodyWrappingType.NONE,\n * normAutofit: { fontScale: 80000 },\n * numCol: 2,\n * anchor: VerticalAnchor.TOP,\n * });\n * ```\n */\nexport const createBodyProperties = (options: BodyPropertiesOptions = {}): string => {\n // Resolve anchor (direct `anchor` takes precedence over `verticalAnchor`)\n const anchor = options.anchor ?? options.verticalAnchor;\n\n // Resolve margins\n const lIns = options.lIns ?? options.margins?.left;\n const tIns = options.tIns ?? options.margins?.top;\n const rIns = options.rIns ?? options.margins?.right;\n const bIns = options.bIns ?? options.margins?.bottom;\n\n const attrs = filterAttrs({\n rot: options.rotation,\n spcFirstLastPara: options.spcFirstLastPara,\n vertOverflow: options.vertOverflow,\n horzOverflow: options.horzOverflow,\n vert: options.vert,\n wrap: options.wrap,\n lIns: lIns !== undefined ? convertToEmu(lIns) : undefined,\n tIns: tIns !== undefined ? convertToEmu(tIns) : undefined,\n rIns: rIns !== undefined ? convertToEmu(rIns) : undefined,\n bIns: bIns !== undefined ? convertToEmu(bIns) : undefined,\n numCol: options.numCol,\n spcCol: options.spcCol !== undefined ? convertToEmu(options.spcCol) : undefined,\n rtlCol: options.rtlCol,\n fromWordArt: options.fromWordArt,\n anchor,\n anchorCtr: options.anchorCtr,\n forceAA: options.forceAA,\n upright: options.upright,\n compatLnSpc: options.compatLnSpc,\n });\n\n // Build children in XSD sequence order\n const children: string[] = [];\n\n // a:prstTxWarp\n if (options.prstTxWarp) {\n children.push(createPresetTextShape(options.prstTxWarp));\n }\n\n // EG_TextAutofit (mutually exclusive)\n if (options.noAutoFit) {\n children.push(`<a:noAutofit/>`);\n } else if (options.normAutofit) {\n const normAttrs = filterAttrs({\n fontScale: options.normAutofit.fontScale,\n lnSpcReduction: options.normAutofit.lnSpcReduction,\n });\n children.push(element(\"a:normAutofit\", normAttrs));\n } else if (options.spAutoFit) {\n children.push(`<a:spAutoFit/>`);\n }\n\n // a:scene3d\n if (options.scene3d) {\n children.push(createScene3D(options.scene3d));\n }\n\n // EG_Text3D (mutually exclusive)\n if (options.sp3d) {\n children.push(createShape3D(options.sp3d));\n } else if (options.flatTx) {\n const flatAttrs = filterAttrs({ z: options.flatTx.z });\n children.push(element(\"a:flatTx\", flatAttrs));\n }\n\n return element(\"wps:bodyPr\", attrs, children.length > 0 ? children : undefined);\n};\n","/**\n * Form field module for WordprocessingML documents.\n *\n * Form fields allow creating interactive controls (checkboxes, dropdown lists,\n * text inputs) within a document. Each form field is wrapped in a field code\n * region delimited by fldChar elements (begin/separate/end), with ffData\n * attached to the begin fldChar.\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_FFData, CT_FFCheckBox, CT_FFDDList, CT_FFTextInput\n *\n * @module\n */\nimport {\n attr,\n attrBool,\n attrNum,\n children as xmlChildren,\n element,\n findChild,\n} from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\n/**\n * Text input field type (ST_FFTextType).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_FFTextType\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"regular\"/>\n * <xsd:enumeration value=\"number\"/>\n * <xsd:enumeration value=\"date\"/>\n * <xsd:enumeration value=\"currentTime\"/>\n * <xsd:enumeration value=\"currentDate\"/>\n * <xsd:enumeration value=\"calculated\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const FormFieldTextType = {\n /** Regular text input */\n REGULAR: \"regular\",\n /** Numeric input */\n NUMBER: \"number\",\n /** Date input */\n DATE: \"date\",\n /** Current time */\n CURRENT_TIME: \"currentTime\",\n /** Current date */\n CURRENT_DATE: \"currentDate\",\n /** Calculated value */\n CALCULATED: \"calculated\",\n} as const;\n\n/**\n * Options for a checkbox form field.\n */\nexport interface CheckBoxOptions {\n /**\n * Checkbox size in half-points.\n *\n * Mutually exclusive with `sizeAuto`.\n */\n size?: number;\n /**\n * Whether to auto-size the checkbox to match surrounding text.\n *\n * Mutually exclusive with `size`.\n */\n sizeAuto?: boolean;\n /** Default checked state */\n default?: boolean;\n /** Current checked state */\n checked?: boolean;\n}\n\n/**\n * Options for a dropdown list form field.\n */\nexport interface DropDownListOptions {\n /** Items in the dropdown list */\n entries: string[];\n /** Index of the currently selected entry */\n result?: number;\n /** Index of the default entry */\n default?: number;\n}\n\n/**\n * Options for a text input form field.\n */\nexport interface TextInputOptions {\n /** Text input type */\n type?: (typeof FormFieldTextType)[keyof typeof FormFieldTextType];\n /**\n * Default text value (placeholder / initial state, serialized as `w:default`\n * inside `w:ffData`).\n */\n default?: string;\n /**\n * Current value the user typed into the field (the result-run text between\n * the `separate` and `end` fldChars).\n *\n * Unlike {@link default} this is NOT stored in `w:ffData`; it is captured on\n * parse for round-trip fidelity. On stringify it is rendered as the field\n * result, falling back to {@link default} when unset.\n */\n value?: string;\n /** Maximum character length */\n maxLength?: number;\n /** Format string */\n format?: string;\n}\n\n/**\n * Help or status text options.\n */\nexport interface FormFieldTextOptions {\n /** Text type: \"text\" for custom text, \"autoText\" for auto text reference */\n type: \"text\" | \"autoText\";\n /** The text value */\n value: string;\n}\n\n/**\n * Common options for all form field types.\n */\nexport interface FormFieldCommonOptions {\n /** Field name (max 65 characters) */\n name?: string;\n /** Numeric label */\n label?: number;\n /** Tab order index */\n tabIndex?: number;\n /** Whether the field is enabled */\n enabled?: boolean;\n /** Recalculate fields when exiting */\n calcOnExit?: boolean;\n /** Entry macro name */\n entryMacro?: string;\n /** Exit macro name */\n exitMacro?: string;\n /** Help text shown when the user presses F1 */\n helpText?: FormFieldTextOptions;\n /** Status bar text */\n statusText?: FormFieldTextOptions;\n}\n\n/**\n * Options for a form field definition (CT_FFData).\n *\n * Exactly one of `checkBox`, `dropDownList`, or `textInput` must be specified.\n */\nexport interface FormFieldOptions extends FormFieldCommonOptions {\n /** Checkbox form field */\n checkBox?: CheckBoxOptions;\n /** Dropdown list form field */\n dropDownList?: DropDownListOptions;\n /** Text input form field */\n textInput?: TextInputOptions;\n}\n\n/** Build a w:val-style element with a single attribute. */\nconst valElement = (name: string, val: string | number): string => `<${name} w:val=\"${val}\"/>`;\n\n/**\n * Creates a help or status text element.\n */\nconst createFormFieldText = (name: string, options: FormFieldTextOptions): string =>\n `<${name} w:type=\"${options.type}\" w:val=\"${options.value}\"/>`;\n\n/**\n * Creates a checkbox form field element (w:checkBox).\n */\nconst createCheckBox = (options: CheckBoxOptions): string => {\n const children: string[] = [];\n\n if (options.size !== undefined) {\n children.push(valElement(\"w:size\", options.size));\n } else if (options.sizeAuto !== undefined) {\n children.push(`<w:sizeAuto/>`);\n }\n\n // <w:default> is the reset/initial state Word renders the box in. Word will\n // not render the box without it, so derive it from `checked` when omitted.\n const defaultVal = options.default ?? options.checked;\n if (defaultVal !== undefined) {\n children.push(defaultVal ? `<w:default/>` : `<w:default w:val=\"0\"/>`);\n }\n if (options.checked !== undefined) {\n children.push(options.checked ? `<w:checked/>` : `<w:checked w:val=\"0\"/>`);\n }\n\n return element(\"w:checkBox\", undefined, children);\n};\n\n/**\n * Creates a dropdown list form field element (w:ddList).\n */\nconst createDropDownList = (options: DropDownListOptions): string => {\n const children: string[] = [];\n\n if (options.result !== undefined) {\n children.push(valElement(\"w:result\", options.result));\n }\n if (options.default !== undefined) {\n children.push(valElement(\"w:default\", options.default));\n }\n for (const entry of options.entries) {\n children.push(valElement(\"w:listEntry\", entry));\n }\n\n return element(\"w:ddList\", undefined, children);\n};\n\n/**\n * Creates a text input form field element (w:textInput).\n */\nconst createTextInput = (options: TextInputOptions): string => {\n const children: string[] = [];\n\n if (options.type !== undefined) {\n children.push(valElement(\"w:type\", options.type));\n }\n if (options.default !== undefined) {\n children.push(valElement(\"w:default\", options.default));\n }\n if (options.maxLength !== undefined) {\n children.push(valElement(\"w:maxLength\", options.maxLength));\n }\n if (options.format !== undefined) {\n children.push(valElement(\"w:format\", options.format));\n }\n\n return element(\"w:textInput\", undefined, children);\n};\n\n/**\n * Creates a form field data element (w:ffData).\n *\n * This element contains the definition for an interactive form field\n * (checkbox, dropdown list, or text input) within a document.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_FFData\">\n * <xsd:choice maxOccurs=\"unbounded\">\n * <xsd:element name=\"name\" type=\"CT_FFName\"/>\n * <xsd:element name=\"label\" type=\"CT_DecimalNumber\"/>\n * <xsd:element name=\"tabIndex\" type=\"CT_UnsignedDecimalNumber\"/>\n * <xsd:element name=\"enabled\" type=\"CT_OnOff\"/>\n * <xsd:element name=\"calcOnExit\" type=\"CT_OnOff\"/>\n * <xsd:element name=\"entryMacro\" type=\"CT_MacroName\"/>\n * <xsd:element name=\"exitMacro\" type=\"CT_MacroName\"/>\n * <xsd:element name=\"helpText\" type=\"CT_FFHelpText\"/>\n * <xsd:element name=\"statusText\" type=\"CT_FFStatusText\"/>\n * <xsd:choice>\n * <xsd:element name=\"checkBox\" type=\"CT_FFCheckBox\"/>\n * <xsd:element name=\"ddList\" type=\"CT_FFDDList\"/>\n * <xsd:element name=\"textInput\" type=\"CT_FFTextInput\"/>\n * </xsd:choice>\n * </xsd:choice>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Checkbox\n * createFormFieldData({\n * name: \"Check1\",\n * checkBox: { checked: true, sizeAuto: true },\n * });\n *\n * // Dropdown\n * createFormFieldData({\n * name: \"DropDown1\",\n * dropDownList: { entries: [\"Option A\", \"Option B\", \"Option C\"], result: 0 },\n * });\n *\n * // Text input\n * createFormFieldData({\n * name: \"Text1\",\n * textInput: { type: \"regular\", default: \"Enter text here\" },\n * });\n * ```\n */\nexport const createFormFieldData = (options: FormFieldOptions): string => {\n const children: string[] = [];\n\n if (options.name !== undefined) {\n children.push(valElement(\"w:name\", options.name));\n }\n if (options.label !== undefined) {\n children.push(valElement(\"w:label\", options.label));\n }\n if (options.tabIndex !== undefined) {\n children.push(valElement(\"w:tabIndex\", options.tabIndex));\n }\n // Word requires an explicit <w:enabled/> to render the field; default true.\n // (Previously emitted a val-less tag even for enabled:false, which is \"true\".)\n const enabled = options.enabled ?? true;\n children.push(enabled ? `<w:enabled/>` : `<w:enabled w:val=\"0\"/>`);\n // <w:calcOnExit> defaults to false (Word's standard).\n const calcOnExit = options.calcOnExit ?? false;\n children.push(calcOnExit ? `<w:calcOnExit/>` : `<w:calcOnExit w:val=\"0\"/>`);\n if (options.entryMacro !== undefined) {\n children.push(valElement(\"w:entryMacro\", options.entryMacro));\n }\n if (options.exitMacro !== undefined) {\n children.push(valElement(\"w:exitMacro\", options.exitMacro));\n }\n if (options.helpText) {\n children.push(createFormFieldText(\"w:helpText\", options.helpText));\n }\n if (options.statusText) {\n children.push(createFormFieldText(\"w:statusText\", options.statusText));\n }\n\n // Exactly one of the three mutually exclusive form field types\n if (options.checkBox) {\n children.push(createCheckBox(options.checkBox));\n } else if (options.dropDownList) {\n children.push(createDropDownList(options.dropDownList));\n } else if (options.textInput) {\n children.push(createTextInput(options.textInput));\n }\n\n return element(\"w:ffData\", undefined, children);\n};\n\n/**\n * Parse a w:ffData element back into FormFieldOptions.\n *\n * Inverse of {@link createFormFieldData}. Reads the common form-field metadata\n * (name, label, tabIndex, enabled, calcOnExit) and exactly one of\n * checkBox / dropDownList / textInput.\n */\nexport function parseFormFieldData(el: Element): FormFieldOptions {\n const opts: Partial<FormFieldOptions> = {};\n\n const name = findChild(el, \"w:name\");\n if (name) opts.name = attr(name, \"w:val\");\n const label = findChild(el, \"w:label\");\n if (label) {\n const v = attrNum(label, \"w:val\");\n if (v !== undefined) opts.label = v;\n }\n const tabIndex = findChild(el, \"w:tabIndex\");\n if (tabIndex) {\n const v = attrNum(tabIndex, \"w:val\");\n if (v !== undefined) opts.tabIndex = v;\n }\n const enabled = findChild(el, \"w:enabled\");\n if (enabled) opts.enabled = attrBool(enabled, \"w:val\") ?? true;\n const calcOnExit = findChild(el, \"w:calcOnExit\");\n if (calcOnExit) opts.calcOnExit = attrBool(calcOnExit, \"w:val\") ?? true;\n\n const checkBox = findChild(el, \"w:checkBox\");\n if (checkBox) {\n const cb: Partial<CheckBoxOptions> = {};\n if (findChild(checkBox, \"w:sizeAuto\")) cb.sizeAuto = true;\n const size = findChild(checkBox, \"w:size\");\n if (size) {\n const v = attrNum(size, \"w:val\");\n if (v !== undefined) cb.size = v;\n }\n const def = findChild(checkBox, \"w:default\");\n if (def) cb.default = attrBool(def, \"w:val\") ?? true;\n const checked = findChild(checkBox, \"w:checked\");\n if (checked) cb.checked = attrBool(checked, \"w:val\") ?? true;\n opts.checkBox = cb as CheckBoxOptions;\n } else {\n const ddList = findChild(el, \"w:ddList\");\n if (ddList) {\n const entries: string[] = [];\n for (const li of xmlChildren(ddList, \"w:listEntry\")) {\n entries.push(attr(li, \"w:val\") ?? \"\");\n }\n const ddl: Partial<DropDownListOptions> = { entries };\n const result = findChild(ddList, \"w:result\");\n if (result) {\n const v = attrNum(result, \"w:val\");\n if (v !== undefined) ddl.result = v;\n }\n const def = findChild(ddList, \"w:default\");\n if (def) {\n const v = attrNum(def, \"w:val\");\n if (v !== undefined) ddl.default = v;\n }\n opts.dropDownList = ddl as DropDownListOptions;\n } else {\n const textInput = findChild(el, \"w:textInput\");\n if (textInput) {\n const ti: Partial<TextInputOptions> = {};\n const type = findChild(textInput, \"w:type\");\n if (type) ti.type = attr(type, \"w:val\") as TextInputOptions[\"type\"];\n const def = findChild(textInput, \"w:default\");\n if (def) ti.default = attr(def, \"w:val\");\n const maxLength = findChild(textInput, \"w:maxLength\");\n if (maxLength) {\n const v = attrNum(maxLength, \"w:val\");\n if (v !== undefined) ti.maxLength = v;\n }\n const format = findChild(textInput, \"w:format\");\n if (format) ti.format = attr(format, \"w:val\");\n opts.textInput = ti as TextInputOptions;\n }\n }\n }\n\n return opts as FormFieldOptions;\n}\n","/**\n * Table cell components module for WordprocessingML documents.\n *\n * This module provides types and constants for table cell properties including borders,\n * grid span (column span), vertical merge, and text direction.\n *\n * Reference: http://officeopenxml.com/WPtableCell.php\n *\n * @module\n */\nimport type { BorderOptions } from \"@shared/border\";\n\n/**\n * Options for configuring table cell borders.\n *\n * Defines border settings for individual edges of a table cell.\n */\nexport interface TableCellBordersOptions {\n /** Border for the top edge of the cell */\n top?: BorderOptions;\n /** Border for the start edge (left in LTR, right in RTL) */\n start?: BorderOptions;\n /** Border for the left edge of the cell */\n left?: BorderOptions;\n /** Border for the bottom edge of the cell */\n bottom?: BorderOptions;\n /** Border for the end edge (right in LTR, left in RTL) */\n end?: BorderOptions;\n /** Border for the right edge of the cell */\n right?: BorderOptions;\n /** Diagonal border from top-left to bottom-right */\n topLeftToBottomRight?: BorderOptions;\n /** Diagonal border from top-right to bottom-left */\n topRightToBottomLeft?: BorderOptions;\n}\n\n/**\n * Vertical merge types for table cells.\n *\n * Defines the merge behavior for vertically merged cells (row span).\n */\nexport const VerticalMergeType = {\n /**\n * Cell that is merged with upper one.\n */\n CONTINUE: \"continue\",\n /**\n * Cell that is starting the vertical merge.\n */\n RESTART: \"restart\",\n} as const;\n\n/**\n * Text direction values for table cells.\n *\n * Specifies the direction in which text flows within a table cell.\n */\nexport const TextDirection = {\n /** Text flows from bottom to top, left to right */\n BOTTOM_TO_TOP_LEFT_TO_RIGHT: \"btLr\",\n /** Text flows from left to right, top to bottom (default) */\n LEFT_TO_RIGHT_TOP_TO_BOTTOM: \"lrTb\",\n /** Text flows from top to bottom, right to left */\n TOP_TO_BOTTOM_RIGHT_TO_LEFT: \"tbRl\",\n} as const;\n","/**\n * Border module for WordprocessingML documents.\n *\n * Borders are used in multiple contexts (paragraphs, tables, table cells, sections)\n * and share the same CT_Border type definition. This module provides the BorderStyle\n * constants used throughout the document structure.\n *\n * Reference: http://officeopenxml.com/WPborders.php\n *\n * @see http://officeopenxml.com/WPtableBorders.php\n * @see http://officeopenxml.com/WPtableCellProperties-Borders.php\n * @see http://officeopenxml.com/WPsectionBorders.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Border\">\n * <xsd:attribute name=\"val\" type=\"ST_Border\" use=\"required\"/>\n * <xsd:attribute name=\"color\" type=\"ST_HexColor\" use=\"optional\" default=\"auto\"/>\n * <xsd:attribute name=\"themeColor\" type=\"ST_ThemeColor\" use=\"optional\"/>\n * <xsd:attribute name=\"themeTint\" type=\"ST_UcharHexNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"themeShade\" type=\"ST_UcharHexNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"sz\" type=\"ST_EighthPointMeasure\" use=\"optional\"/>\n * <xsd:attribute name=\"space\" type=\"ST_PointMeasure\" use=\"optional\" default=\"0\"/>\n * <xsd:attribute name=\"shadow\" type=\"s:ST_OnOff\" use=\"optional\"/>\n * <xsd:attribute name=\"frame\" type=\"s:ST_OnOff\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n *\n * @module\n */\nimport type { ThemeColor } from \"@office-open/core\";\n\n/**\n * Options for configuring a border element.\n *\n * @property style - The border style (single, dashed, dotted, etc.)\n * @property color - Border color in hex format (e.g., \"FF00AA\" for purple)\n * @property size - Border thickness in eighths of a point (1/8 pt)\n * @property space - Spacing offset from the content in points\n */\nexport interface BorderOptions {\n style: (typeof BorderStyle)[keyof typeof BorderStyle];\n /** Border color, in hex (eg 'FF00AA') */\n color?: string;\n /** Theme color reference */\n themeColor?: (typeof ThemeColor)[keyof typeof ThemeColor];\n /** Theme color tint (2-char hex) */\n themeTint?: string;\n /** Theme color shade (2-char hex) */\n themeShade?: string;\n /** Border shadow */\n shadow?: boolean;\n /** Border frame */\n frame?: boolean;\n /** Size of the border in 1/8 pt */\n size?: number;\n /** Spacing offset. Values are specified in pt */\n space?: number;\n}\n\n/**\n * Table borders are defined with the <w:tblBorders> element. Child elements of this element specify the kinds of `border`:\n *\n * `bottom`, `end` (`right` in the previous version of the standard), `insideH`, `insideV`, `start` (`left` in the previous version of the standard), and `top`.\n *\n * Reference: http://officeopenxml.com/WPtableBorders.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_Border\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"single\"/>\n * <xsd:enumeration value=\"dashDotStroked\"/>\n * <xsd:enumeration value=\"dashed\"/>\n * <xsd:enumeration value=\"dashSmallGap\"/>\n * <xsd:enumeration value=\"dotDash\"/>\n * <xsd:enumeration value=\"dotDotDash\"/>\n * <xsd:enumeration value=\"dotted\"/>\n * <xsd:enumeration value=\"double\"/>\n * <xsd:enumeration value=\"doubleWave\"/>\n * <xsd:enumeration value=\"inset\"/>\n * <xsd:enumeration value=\"nil\"/>\n * <xsd:enumeration value=\"none\"/>\n * <xsd:enumeration value=\"outset\"/>\n * <xsd:enumeration value=\"thick\"/>\n * <xsd:enumeration value=\"thickThinLargeGap\"/>\n * <xsd:enumeration value=\"thickThinMediumGap\"/>\n * <xsd:enumeration value=\"thickThinSmallGap\"/>\n * <xsd:enumeration value=\"thinThickLargeGap\"/>\n * <xsd:enumeration value=\"thinThickMediumGap\"/>\n * <xsd:enumeration value=\"thinThickSmallGap\"/>\n * <xsd:enumeration value=\"thinThickThinLargeGap\"/>\n * <xsd:enumeration value=\"thinThickThinMediumGap\"/>\n * <xsd:enumeration value=\"thinThickThinSmallGap\"/>\n * <xsd:enumeration value=\"threeDEmboss\"/>\n * <xsd:enumeration value=\"threeDEngrave\"/>\n * <xsd:enumeration value=\"triple\"/>\n * <xsd:enumeration value=\"wave\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const BorderStyle = {\n /** A single line */\n SINGLE: \"single\",\n /** A line with a series of alternating thin and thick strokes */\n DASH_DOT_STROKED: \"dashDotStroked\",\n /** A dashed line */\n DASHED: \"dashed\",\n /** A dashed line with small gaps */\n DASH_SMALL_GAP: \"dashSmallGap\",\n /** A line with alternating dots and dashes */\n DOT_DASH: \"dotDash\",\n /** A line with a repeating dot - dot - dash sequence */\n DOT_DOT_DASH: \"dotDotDash\",\n /** A dotted line */\n DOTTED: \"dotted\",\n /** A double line */\n DOUBLE: \"double\",\n /** A double wavy line */\n DOUBLE_WAVE: \"doubleWave\",\n /** An inset set of lines */\n INSET: \"inset\",\n /** No border */\n NIL: \"nil\",\n /** No border */\n NONE: \"none\",\n /** An outset set of lines */\n OUTSET: \"outset\",\n /** A single line */\n THICK: \"thick\",\n /** A thick line contained within a thin line with a large-sized intermediate gap */\n THICK_THIN_LARGE_GAP: \"thickThinLargeGap\",\n /** A thick line contained within a thin line with a medium-sized intermediate gap */\n THICK_THIN_MEDIUM_GAP: \"thickThinMediumGap\",\n /** A thick line contained within a thin line with a small intermediate gap */\n THICK_THIN_SMALL_GAP: \"thickThinSmallGap\",\n /** A thin line contained within a thick line with a large-sized intermediate gap */\n THIN_THICK_LARGE_GAP: \"thinThickLargeGap\",\n /** A thick line contained within a thin line with a medium-sized intermediate gap */\n THIN_THICK_MEDIUM_GAP: \"thinThickMediumGap\",\n /** A thick line contained within a thin line with a small intermediate gap */\n THIN_THICK_SMALL_GAP: \"thinThickSmallGap\",\n /** A thin-thick-thin line with a large gap */\n THIN_THICK_THIN_LARGE_GAP: \"thinThickThinLargeGap\",\n /** A thin-thick-thin line with a medium gap */\n THIN_THICK_THIN_MEDIUM_GAP: \"thinThickThinMediumGap\",\n /** A thin-thick-thin line with a small gap */\n THIN_THICK_THIN_SMALL_GAP: \"thinThickThinSmallGap\",\n /** A three-staged gradient line, getting darker towards the paragraph */\n THREE_D_EMBOSS: \"threeDEmboss\",\n /** A three-staged gradient like, getting darker away from the paragraph */\n THREE_D_ENGRAVE: \"threeDEngrave\",\n /** A triple line */\n TRIPLE: \"triple\",\n /** A wavy line */\n WAVE: \"wave\",\n} as const;\n","/**\n * Table width module for WordprocessingML documents.\n *\n * This module provides width specifications for tables and cells.\n *\n * Reference: http://officeopenxml.com/WPtableWidth.php\n *\n * @module\n */\nimport type { Percentage, UniversalMeasure } from \"@office-open/core\";\n\n/**\n * Width type values for tables and cells.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TblWidth\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"nil\"/>\n * <xsd:enumeration value=\"pct\"/>\n * <xsd:enumeration value=\"dxa\"/>\n * <xsd:enumeration value=\"auto\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const WidthType = {\n /** Auto. */\n AUTO: \"auto\",\n /** Value is in twentieths of a point */\n DXA: \"dxa\",\n /** No (empty) value. */\n NIL: \"nil\",\n /** Value is in percentage. */\n PERCENTAGE: \"pct\",\n} as const;\n\n/**\n * Properties for specifying table or cell width.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_TblWidth\">\n * <xsd:attribute name=\"w\" type=\"ST_MeasurementOrPercent\"/>\n * <xsd:attribute name=\"type\" type=\"ST_TblWidth\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface TableWidthProperties {\n size: number | Percentage | UniversalMeasure;\n type?: (typeof WidthType)[keyof typeof WidthType];\n}\n","/**\n * Text wrapping module for DrawingML elements.\n *\n * This module provides text wrapping options for floating/anchored drawings.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @module\n */\nimport type { Distance } from \"../drawing\";\n\n/**\n * Enumeration of text wrapping types for floating drawings.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @publicApi\n */\nexport const TextWrappingType = {\n NONE: 0,\n SQUARE: 1,\n TIGHT: 2,\n TOP_AND_BOTTOM: 3,\n THROUGH: 4,\n} as const;\n\n/**\n * Enumeration of text wrapping sides for floating drawings.\n *\n * Specifies on which side(s) text can wrap around the drawing.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @publicApi\n */\nexport const TextWrappingSide = {\n /** Text wraps on both sides of the drawing */\n BOTH_SIDES: \"bothSides\",\n /** Text wraps only on the left side */\n LEFT: \"left\",\n /** Text wraps only on the right side */\n RIGHT: \"right\",\n /** Text wraps on the side with more space */\n LARGEST: \"largest\",\n} as const;\n\n/**\n * Options for configuring text wrapping around a drawing.\n */\nexport interface TextWrapping {\n type: (typeof TextWrappingType)[keyof typeof TextWrappingType];\n side?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];\n margins?: Distance;\n}\n","/**\n * Wrap Tight module for DrawingML text wrapping.\n *\n * This module provides tight text wrapping for floating drawings\n * where text wraps closely around the image shape.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { Margins } from \"../floating\";\nimport { TextWrappingSide } from \"./text-wrapping\";\nimport type { TextWrapping } from \"./text-wrapping\";\n\n/**\n * Creates a default rectangular wrap polygon matching the image extent.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_WrapPath\">\n * <xsd:sequence>\n * <xsd:element name=\"start\" type=\"a:CT_Point2D\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * <xsd:element name=\"lineTo\" type=\"a:CT_Point2D\" minOccurs=\"2\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"edited\" type=\"xsd:boolean\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n */\nconst createWrapPolygon = (cx: number, cy: number): string =>\n element(\"wp:wrapPolygon\", { edited: \"0\" }, [\n `<wp:start x=\"0\" y=\"0\"/>`,\n `<wp:lineTo x=\"0\" y=\"${-cy}\"/>`,\n `<wp:lineTo x=\"${cx}\" y=\"${-cy}\"/>`,\n `<wp:lineTo x=\"${cx}\" y=\"0\"/>`,\n `<wp:lineTo x=\"0\" y=\"0\"/>`,\n ]);\n\n/**\n * Creates tight text wrapping for a floating drawing.\n *\n * WrapTight causes text to wrap closely around the contours\n * of the drawing rather than its rectangular bounding box.\n * A default rectangular wrap polygon matching the image extent is generated.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_WrapTight\">\n * <xsd:sequence>\n * <xsd:element name=\"wrapPolygon\" type=\"CT_WrapPath\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"wrapText\" type=\"ST_WrapText\" use=\"required\"/>\n * <xsd:attribute name=\"distL\" type=\"ST_WrapDistance\"/>\n * <xsd:attribute name=\"distR\" type=\"ST_WrapDistance\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createWrapTight = (\n textWrapping: TextWrapping,\n margins: Margins = {\n bottom: 0,\n left: 0,\n right: 0,\n top: 0,\n },\n extent: { x: number; y: number },\n): string =>\n element(\n \"wp:wrapTight\",\n {\n distL: margins.left,\n distR: margins.right,\n wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES,\n },\n [createWrapPolygon(extent.x, extent.y)],\n );\n","/**\n * Wrap Through module for DrawingML text wrapping.\n *\n * This module provides \"through\" text wrapping for floating drawings\n * where text wraps through the image contours, filling any concave areas.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { Margins } from \"../floating\";\nimport { TextWrappingSide } from \"./text-wrapping\";\nimport type { TextWrapping } from \"./text-wrapping\";\n\n/**\n * Creates a default rectangular wrap polygon matching the image extent.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_WrapPath\">\n * <xsd:sequence>\n * <xsd:element name=\"start\" type=\"a:CT_Point2D\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * <xsd:element name=\"lineTo\" type=\"a:CT_Point2D\" minOccurs=\"2\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"edited\" type=\"xsd:boolean\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n */\nconst createWrapPolygon = (cx: number, cy: number): string =>\n element(\"wp:wrapPolygon\", { edited: \"0\" }, [\n `<wp:start x=\"0\" y=\"0\"/>`,\n `<wp:lineTo x=\"0\" y=\"${-cy}\"/>`,\n `<wp:lineTo x=\"${cx}\" y=\"${-cy}\"/>`,\n `<wp:lineTo x=\"${cx}\" y=\"0\"/>`,\n `<wp:lineTo x=\"0\" y=\"0\"/>`,\n ]);\n\n/**\n * Creates \"through\" text wrapping for a floating drawing.\n *\n * WrapThrough is similar to WrapTight but allows text to wrap through\n * the concave portions of the drawing shape (e.g., the inside of the letter \"O\").\n * A default rectangular wrap polygon matching the image extent is generated.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_WrapThrough\">\n * <xsd:sequence>\n * <xsd:element name=\"wrapPolygon\" type=\"CT_WrapPath\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"wrapText\" type=\"ST_WrapText\" use=\"required\"/>\n * <xsd:attribute name=\"distL\" type=\"ST_WrapDistance\"/>\n * <xsd:attribute name=\"distR\" type=\"ST_WrapDistance\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createWrapThrough = (\n textWrapping: TextWrapping,\n margins: Margins = {\n bottom: 0,\n left: 0,\n right: 0,\n top: 0,\n },\n extent: { x: number; y: number },\n): string =>\n element(\n \"wp:wrapThrough\",\n {\n distL: margins.left,\n distR: margins.right,\n wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES,\n },\n [createWrapPolygon(extent.x, extent.y)],\n );\n","/**\n * Shared constants for WordprocessingML documents.\n *\n * Provides alignment, number format, and space type constants\n * used across multiple document components.\n *\n * @module\n */\n\n// ── Alignment ──\n\n/**\n * Horizontal alignment options for floating drawings.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_AlignH.html\n *\n * @publicApi\n */\nexport const HorizontalPositionAlign = {\n CENTER: \"center\",\n INSIDE: \"inside\",\n LEFT: \"left\",\n OUTSIDE: \"outside\",\n RIGHT: \"right\",\n} as const;\n\n/**\n * Vertical alignment options for floating drawings.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_AlignV.html\n *\n * @publicApi\n */\nexport const VerticalPositionAlign = {\n BOTTOM: \"bottom\",\n CENTER: \"center\",\n INSIDE: \"inside\",\n OUTSIDE: \"outside\",\n TOP: \"top\",\n} as const;\n\n// ── Number format ──\n\n/**\n * Number format types for page numbers and list numbering.\n *\n * Reference: http://officeopenxml.com/WPnumbering-numFmt.php\n *\n * @publicApi\n */\nexport const NumberFormat = {\n AIUEO: \"aiueo\",\n AIUEO_FULL_WIDTH: \"aiueoFullWidth\",\n ARABIC_ABJAD: \"arabicAbjad\",\n ARABIC_ALPHA: \"arabicAlpha\",\n BAHT_TEXT: \"bahtText\",\n BULLET: \"bullet\",\n CARDINAL_TEXT: \"cardinalText\",\n CHICAGO: \"chicago\",\n CHINESE_COUNTING: \"chineseCounting\",\n CHINESE_COUNTING_TEN_THOUSAND: \"chineseCountingThousand\",\n CHINESE_LEGAL_SIMPLIFIED: \"chineseLegalSimplified\",\n CHOSUNG: \"chosung\",\n DECIMAL: \"decimal\",\n DECIMAL_ENCLOSED_CIRCLE: \"decimalEnclosedCircle\",\n DECIMAL_ENCLOSED_CIRCLE_CHINESE: \"decimalEnclosedCircleChinese\",\n DECIMAL_ENCLOSED_FULL_STOP: \"decimalEnclosedFullstop\",\n DECIMAL_ENCLOSED_PAREN: \"decimalEnclosedParen\",\n DECIMAL_FULL_WIDTH: \"decimalFullWidth\",\n DECIMAL_FULL_WIDTH_2: \"decimalFullWidth2\",\n DECIMAL_HALF_WIDTH: \"decimalHalfWidth\",\n DECIMAL_ZERO: \"decimalZero\",\n DOLLAR_TEXT: \"dollarText\",\n GANADA: \"ganada\",\n HEBREW_1: \"hebrew1\",\n HEBREW_2: \"hebrew2\",\n HEX: \"hex\",\n HINDI_CONSONANTS: \"hindiConsonants\",\n HINDI_COUNTING: \"hindiCounting\",\n HINDI_NUMBERS: \"hindiNumbers\",\n HINDI_VOWELS: \"hindiVowels\",\n IDEOGRAPH_DIGITAL: \"ideographDigital\",\n IDEOGRAPH_ENCLOSED_CIRCLE: \"ideographEnclosedCircle\",\n IDEOGRAPH_LEGAL_TRADITIONAL: \"ideographLegalTraditional\",\n IDEOGRAPH_TRADITIONAL: \"ideographTraditional\",\n IDEOGRAPH_ZODIAC: \"ideographZodiac\",\n IDEOGRAPH_ZODIAC_TRADITIONAL: \"ideographZodiacTraditional\",\n IROHA: \"iroha\",\n IROHA_FULL_WIDTH: \"irohaFullWidth\",\n JAPANESE_COUNTING: \"japaneseCounting\",\n JAPANESE_DIGITAL_TEN_THOUSAND: \"japaneseDigitalTenThousand\",\n JAPANESE_LEGAL: \"japaneseLegal\",\n KOREAN_COUNTING: \"koreanCounting\",\n KOREAN_DIGITAL: \"koreanDigital\",\n KOREAN_DIGITAL_2: \"koreanDigital2\",\n KOREAN_LEGAL: \"koreanLegal\",\n LOWER_LETTER: \"lowerLetter\",\n LOWER_ROMAN: \"lowerRoman\",\n NONE: \"none\",\n NUMBER_IN_DASH: \"numberInDash\",\n ORDINAL: \"ordinal\",\n ORDINAL_TEXT: \"ordinalText\",\n RUSSIAN_LOWER: \"russianLower\",\n RUSSIAN_UPPER: \"russianUpper\",\n TAIWANESE_COUNTING: \"taiwaneseCounting\",\n TAIWANESE_COUNTING_THOUSAND: \"taiwaneseCountingThousand\",\n TAIWANESE_DIGITAL: \"taiwaneseDigital\",\n THAI_COUNTING: \"thaiCounting\",\n THAI_LETTERS: \"thaiLetters\",\n THAI_NUMBERS: \"thaiNumbers\",\n UPPER_LETTER: \"upperLetter\",\n UPPER_ROMAN: \"upperRoman\",\n VIETNAMESE_COUNTING: \"vietnameseCounting\",\n} as const;\n\n// ── Space type ──\n\n/**\n * XML space handling modes.\n *\n * @publicApi\n */\nexport const SpaceType = {\n DEFAULT: \"default\",\n PRESERVE: \"preserve\",\n} as const;\n","/**\n * Floating position module for DrawingML elements.\n *\n * This module provides positioning options for floating/anchored drawings,\n * including horizontal and vertical relative positioning.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-position.php\n *\n * @module\n */\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { HorizontalPositionAlign, VerticalPositionAlign } from \"@shared/constants\";\nexport { HorizontalPositionAlign, VerticalPositionAlign } from \"@shared/constants\";\n\nimport type { TextWrapping } from \"../text-wrap\";\n\n/**\n * Horizontal Relative Positioning.\n *\n * Specifies the horizontal base from which the drawing position is calculated.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_RelFromH.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_RelFromH\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"margin\"/>\n * <xsd:enumeration value=\"page\"/>\n * <xsd:enumeration value=\"column\"/>\n * <xsd:enumeration value=\"character\"/>\n * <xsd:enumeration value=\"leftMargin\"/>\n * <xsd:enumeration value=\"rightMargin\"/>\n * <xsd:enumeration value=\"insideMargin\"/>\n * <xsd:enumeration value=\"outsideMargin\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const HorizontalPositionRelativeFrom = {\n /**\n * ## Character\n *\n * Specifies that the horizontal positioning shall be relative to the position of the anchor within its run content.\n */\n CHARACTER: \"character\",\n /**\n * ## Column\n *\n * Specifies that the horizontal positioning shall be relative to the extents of the column which contains its anchor.\n */\n COLUMN: \"column\",\n /**\n * ## Inside Margin\n *\n * Specifies that the horizontal positioning shall be relative to the inside margin of the current page (the left margin on odd pages, right on even pages).\n */\n INSIDE_MARGIN: \"insideMargin\",\n /**\n * ## Left Margin\n *\n * Specifies that the horizontal positioning shall be relative to the left margin of the page.\n */\n LEFT_MARGIN: \"leftMargin\",\n /**\n * ## Page Margin\n *\n * Specifies that the horizontal positioning shall be relative to the page margins.\n */\n MARGIN: \"margin\",\n /**\n * ## Outside Margin\n *\n * Specifies that the horizontal positioning shall be relative to the outside margin of the current page (the right margin on odd pages, left on even pages).\n */\n OUTSIDE_MARGIN: \"outsideMargin\",\n /**\n * ## Page Edge\n *\n * Specifies that the horizontal positioning shall be relative to the edge of the page.\n */\n PAGE: \"page\",\n /**\n * ## Right Margin\n *\n * Specifies that the horizontal positioning shall be relative to the right margin of the page.\n */\n RIGHT_MARGIN: \"rightMargin\",\n} as const;\n\n/**\n * Vertical Relative Positioning.\n *\n * Specifies the vertical base from which the drawing position is calculated.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_RelFromV.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_RelFromV\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"margin\"/>\n * <xsd:enumeration value=\"page\"/>\n * <xsd:enumeration value=\"paragraph\"/>\n * <xsd:enumeration value=\"line\"/>\n * <xsd:enumeration value=\"topMargin\"/>\n * <xsd:enumeration value=\"bottomMargin\"/>\n * <xsd:enumeration value=\"insideMargin\"/>\n * <xsd:enumeration value=\"outsideMargin\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const VerticalPositionRelativeFrom = {\n /**\n * ## Bottom Margin\n *\n * Specifies that the vertical positioning shall be relative to the bottom margin of the current page.\n */\n BOTTOM_MARGIN: \"bottomMargin\",\n /**\n * ## Inside Margin\n *\n * Specifies that the vertical positioning shall be relative to the inside margin of the current page.\n */\n INSIDE_MARGIN: \"insideMargin\",\n /**\n * ## Line\n *\n * Specifies that the vertical positioning shall be relative to the line containing the anchor character.\n */\n LINE: \"line\",\n /**\n * ## Page Margin\n *\n * Specifies that the vertical positioning shall be relative to the page margins.\n */\n MARGIN: \"margin\",\n /**\n * ## Outside Margin\n *\n * Specifies that the vertical positioning shall be relative to the outside margin of the current page.\n */\n OUTSIDE_MARGIN: \"outsideMargin\",\n /**\n * ## Page Edge\n *\n * Specifies that the vertical positioning shall be relative to the edge of the page.\n */\n PAGE: \"page\",\n /**\n * ## Paragraph\n *\n * Specifies that the vertical positioning shall be relative to the paragraph which contains the drawing anchor.\n */\n PARAGRAPH: \"paragraph\",\n /**\n * ## Top Margin\n *\n * Specifies that the vertical positioning shall be relative to the top margin of the current page.\n */\n TOP_MARGIN: \"topMargin\",\n} as const;\n\n/**\n * Options for horizontal positioning of a floating drawing.\n */\nexport interface HorizontalPositionOptions {\n /** The base from which horizontal position is calculated */\n relative?: (typeof HorizontalPositionRelativeFrom)[keyof typeof HorizontalPositionRelativeFrom];\n /** Alignment relative to the horizontal base */\n align?: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign];\n /** Offset in EMUs from the horizontal base, or universal measure (e.g., \"1in\", \"2cm\") */\n offset?: number | UniversalMeasure;\n}\n\n/**\n * Options for vertical positioning of a floating drawing.\n */\nexport interface VerticalPositionOptions {\n /** The base from which vertical position is calculated */\n relative?: (typeof VerticalPositionRelativeFrom)[keyof typeof VerticalPositionRelativeFrom];\n /** Alignment relative to the vertical base */\n align?: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign];\n /** Offset in EMUs from the vertical base, or universal measure (e.g., \"1in\", \"2cm\") */\n offset?: number | UniversalMeasure;\n}\n\n/**\n * Margin distances around a floating drawing in EMUs or universal measure.\n */\nexport interface Margins {\n left?: number | UniversalMeasure;\n bottom?: number | UniversalMeasure;\n top?: number | UniversalMeasure;\n right?: number | UniversalMeasure;\n}\n\n/**\n * Configuration options for a floating/anchored drawing.\n *\n * @see {@link Anchor}\n */\nexport interface Floating {\n horizontalPosition: HorizontalPositionOptions;\n verticalPosition: VerticalPositionOptions;\n allowOverlap?: boolean;\n lockAnchor?: boolean;\n behindDocument?: boolean;\n layoutInCell?: boolean;\n margins?: Margins;\n wrap?: TextWrapping;\n zIndex?: number;\n}\n","/**\n * Horizontal position module for floating drawings in WordprocessingML documents.\n *\n * This module provides horizontal positioning for floating drawing objects,\n * specifying the horizontal placement relative to a base element.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-position.php\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { HorizontalPositionAlign, HorizontalPositionRelativeFrom } from \"./floating-position\";\nimport type { HorizontalPositionOptions } from \"./floating-position\";\n\n/**\n * Creates a horizontal position element for floating drawings.\n *\n * The positionH element specifies the horizontal positioning of a floating\n * object relative to a base element (page, margin, column, etc.).\n *\n * Reference: https://www.datypic.com/sc/ooxml/e-wp_positionH-1.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PosH\">\n * <xsd:choice>\n * <xsd:element name=\"align\" type=\"ST_AlignH\"/>\n * <xsd:element name=\"posOffset\" type=\"ST_PositionOffset\"/>\n * </xsd:choice>\n * <xsd:attribute name=\"relativeFrom\" type=\"ST_RelFromH\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @param options - Horizontal position configuration\n * @returns The positionH XML string\n *\n * @example\n * ```typescript\n * // Align to the left of the page\n * createHorizontalPosition({\n * relative: HorizontalPositionRelativeFrom.PAGE,\n * align: HorizontalPositionAlign.LEFT,\n * });\n *\n * // Offset from the margin\n * createHorizontalPosition({\n * relative: HorizontalPositionRelativeFrom.MARGIN,\n * offset: 914400, // 1 inch in EMUs\n * });\n * ```\n */\nexport const createHorizontalPosition = ({\n relative,\n align,\n offset,\n}: HorizontalPositionOptions): string => {\n const child = align\n ? `<wp:align>${align}</wp:align>`\n : offset !== undefined\n ? `<wp:posOffset>${offset}</wp:posOffset>`\n : `<wp:align>${HorizontalPositionAlign.LEFT}</wp:align>`;\n\n return element(\n \"wp:positionH\",\n {\n relativeFrom: relative ?? HorizontalPositionRelativeFrom.PAGE,\n },\n [child],\n );\n};\n","/**\n * Vertical position module for floating drawings in WordprocessingML documents.\n *\n * This module provides vertical positioning for floating drawing objects,\n * specifying the vertical placement relative to a base element.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-position.php\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { VerticalPositionAlign, VerticalPositionRelativeFrom } from \"./floating-position\";\nimport type { VerticalPositionOptions } from \"./floating-position\";\n\n/**\n * Creates a vertical position element for floating drawings.\n *\n * The positionV element specifies the vertical positioning of a floating\n * object relative to a base element (page, margin, paragraph, line, etc.).\n *\n * Reference: https://www.datypic.com/sc/ooxml/e-wp_positionV-1.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PosV\">\n * <xsd:choice>\n * <xsd:element name=\"align\" type=\"ST_AlignV\"/>\n * <xsd:element name=\"posOffset\" type=\"ST_PositionOffset\"/>\n * </xsd:choice>\n * <xsd:attribute name=\"relativeFrom\" type=\"ST_RelFromV\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @param options - Vertical position configuration\n * @returns The positionV XML string\n *\n * @example\n * ```typescript\n * // Align to the top of the page\n * createVerticalPosition({\n * relative: VerticalPositionRelativeFrom.PAGE,\n * align: VerticalPositionAlign.TOP,\n * });\n *\n * // Offset from the paragraph\n * createVerticalPosition({\n * relative: VerticalPositionRelativeFrom.PARAGRAPH,\n * offset: 457200, // 0.5 inch in EMUs\n * });\n * ```\n */\nexport const createVerticalPosition = ({\n relative,\n align,\n offset,\n}: VerticalPositionOptions): string => {\n const child = align\n ? `<wp:align>${align}</wp:align>`\n : offset !== undefined\n ? `<wp:posOffset>${offset}</wp:posOffset>`\n : `<wp:align>${VerticalPositionAlign.TOP}</wp:align>`;\n\n return element(\n \"wp:positionV\",\n {\n relativeFrom: relative ?? VerticalPositionRelativeFrom.PAGE,\n },\n [child],\n );\n};\n","/**\n * Drawing parser for DOCX documents.\n *\n * Parses w:drawing elements and extracts image, chart, or SmartArt data.\n *\n * @module\n */\nimport { convertEmuToPixels } from \"@office-open/core\";\nimport { attr, attrBool, attrNum, findChild, findDeep, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { ChartOptions } from \"@parts/paragraph/run/chart-run\";\nimport type { ImageOptions } from \"@parts/paragraph/run/image-run\";\nimport type { SmartArtOptions } from \"@parts/paragraph/run/smartart-run\";\n\nimport type { DocxReadContext } from \"../../context\";\nimport type {\n Floating,\n HorizontalPositionOptions,\n Margins,\n VerticalPositionOptions,\n} from \"./floating\";\nimport { TextWrappingType } from \"./text-wrap\";\nimport type { TextWrapping } from \"./text-wrap\";\n\n/** Union type for parsed drawing child wrappers. */\nexport type DrawingChild =\n | { image: ImageOptions }\n | { chart: ChartOptions }\n | { smartArt: SmartArtOptions };\n\n/**\n * Parse a w:drawing element and dispatch to the correct parser\n * based on the graphicData URI.\n */\nexport function parseDrawingRun(el: Element, ctx: DocxReadContext): DrawingChild | undefined {\n const graphicData = findDeep(el, \"a:graphicData\")[0];\n if (!graphicData) return undefined;\n\n const uri = attr(graphicData, \"uri\") ?? \"\";\n\n if (uri.includes(\"/chart\")) {\n return parseChartDrawing(el, ctx);\n }\n if (uri.includes(\"/diagram\")) {\n return parseSmartArtDrawing(el, ctx);\n }\n return parseImageRun(el, ctx);\n}\n\n/**\n * Determine image type from file extension or MIME type.\n */\nfunction imageTypeFromPath(\n path: string,\n): \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\" {\n const ext = path.split(\".\").pop()?.toLowerCase() ?? \"\";\n switch (ext) {\n case \"jpg\":\n case \"jpeg\":\n return \"jpg\";\n case \"png\":\n return \"png\";\n case \"gif\":\n return \"gif\";\n case \"bmp\":\n return \"bmp\";\n case \"tif\":\n case \"tiff\":\n return \"tif\";\n case \"ico\":\n return \"ico\";\n case \"emf\":\n return \"emf\";\n case \"wmf\":\n return \"wmf\";\n default:\n return \"png\"; // fallback\n }\n}\n\n/**\n * Parse a w:drawing element and return image data wrapped in { image: ... }.\n */\nexport function parseImageRun(\n el: Element,\n ctx: DocxReadContext,\n): { image: ImageOptions } | undefined {\n // Try inline first, then anchor\n const inline = findDeep(el, \"wp:inline\")[0];\n const anchor = inline ? undefined : findDeep(el, \"wp:anchor\")[0];\n const parent = inline ?? anchor;\n if (!parent) return undefined;\n\n // Get extent (dimensions in EMU, convert to pixels for API)\n const extent = findChild(parent, \"wp:extent\");\n let width: number | undefined;\n let height: number | undefined;\n if (extent) {\n const cxEmu = attrNum(extent, \"cx\");\n const cyEmu = attrNum(extent, \"cy\");\n if (cxEmu !== undefined) width = convertEmuToPixels(cxEmu);\n if (cyEmu !== undefined) height = convertEmuToPixels(cyEmu);\n }\n\n // Get graphic → graphicData → blip\n const blip = findDeep(parent, \"a:blip\")[0];\n if (!blip) return undefined;\n\n const rEmbed = attr(blip, \"r:embed\");\n if (!rEmbed) return undefined;\n\n // Look up media path from relationships\n const mediaPath = ctx.docx.partRefs.media.get(rEmbed);\n if (!mediaPath) return undefined;\n\n // Read image data from ZIP\n const imageData = ctx.docx.doc.getRaw(mediaPath);\n if (!imageData) return undefined;\n\n const type = imageTypeFromPath(mediaPath);\n\n const imageOpts: Record<string, unknown> = {\n type,\n data: imageData,\n transformation: {\n ...(width !== undefined ? { width } : {}),\n ...(height !== undefined ? { height } : {}),\n },\n };\n\n // Get alt text from docPr\n const docPr = findChild(parent, \"wp:docPr\");\n if (docPr) {\n const name = attr(docPr, \"name\");\n const descr = attr(docPr, \"descr\");\n const title = attr(docPr, \"title\");\n if (name || descr || title) {\n imageOpts.altText = {\n ...(name ? { name } : {}),\n ...(descr ? { description: descr } : {}),\n ...(title ? { title } : {}),\n };\n }\n }\n\n // For anchor, extract floating properties\n if (anchor && !inline) {\n const floating: Partial<Floating> = {};\n\n // Margins (distT/distB/distL/distR on wp:anchor)\n const margins: Margins = {};\n const distT = attrNum(anchor, \"distT\");\n if (distT !== undefined) margins.top = distT;\n const distB = attrNum(anchor, \"distB\");\n if (distB !== undefined) margins.bottom = distB;\n const distL = attrNum(anchor, \"distL\");\n if (distL !== undefined) margins.left = distL;\n const distR = attrNum(anchor, \"distR\");\n if (distR !== undefined) margins.right = distR;\n if (Object.keys(margins).length > 0) floating.margins = margins;\n\n // Position H/V (relativeFrom + align/posOffset)\n const posH = findChild(anchor, \"wp:positionH\");\n if (posH) {\n const hp = readPosition(posH);\n if (hp) floating.horizontalPosition = hp as HorizontalPositionOptions;\n }\n const posV = findChild(anchor, \"wp:positionV\");\n if (posV) {\n const vp = readPosition(posV);\n if (vp) floating.verticalPosition = vp as VerticalPositionOptions;\n }\n\n // Wrap (element name → TextWrappingType number) + optional side\n const wrap = readWrap(anchor);\n if (wrap) floating.wrap = wrap;\n\n // Anchor-level flags (stringifyAnchor writes all of these)\n const allowOverlap = attrBool(anchor, \"allowOverlap\");\n if (allowOverlap !== undefined) floating.allowOverlap = allowOverlap;\n const behindDoc = attrBool(anchor, \"behindDoc\");\n if (behindDoc !== undefined) floating.behindDocument = behindDoc;\n const locked = attrBool(anchor, \"locked\");\n if (locked !== undefined) floating.lockAnchor = locked;\n const layoutInCell = attrBool(anchor, \"layoutInCell\");\n if (layoutInCell !== undefined) floating.layoutInCell = layoutInCell;\n const relativeHeight = attrNum(anchor, \"relativeHeight\");\n if (relativeHeight !== undefined) floating.zIndex = relativeHeight;\n\n if (Object.keys(floating).length > 0) {\n imageOpts.floating = floating;\n }\n }\n\n return { image: imageOpts as unknown as ImageOptions };\n}\n\n// ── Floating (anchor) parse helpers ─────────────────────────────────────────\n\n/** Map wp:positionH/V children + relativeFrom into a position-options object. */\nfunction readPosition(\n posEl: Element,\n): HorizontalPositionOptions | VerticalPositionOptions | undefined {\n const relative = attr(posEl, \"relativeFrom\");\n const alignEl = findChild(posEl, \"wp:align\");\n const posOffset = findChild(posEl, \"wp:posOffset\");\n const result: { relative?: string; align?: string; offset?: number } = {};\n if (relative) result.relative = relative;\n if (alignEl) {\n const a = textOf(alignEl);\n if (a) result.align = a;\n } else if (posOffset) {\n const val = Number(textOf(posOffset));\n if (!isNaN(val)) result.offset = val;\n }\n return Object.keys(result).length > 0\n ? (result as HorizontalPositionOptions | VerticalPositionOptions)\n : undefined;\n}\n\n/** Map the wp:anchor wrap child element into a TextWrapping ({ type, side? }). */\nfunction readWrap(anchor: Element): TextWrapping | undefined {\n const WRAP_TYPE: ReadonlyArray<[string, TextWrapping[\"type\"]]> = [\n [\"wrapNone\", TextWrappingType.NONE],\n [\"wrapSquare\", TextWrappingType.SQUARE],\n [\"wrapTight\", TextWrappingType.TIGHT],\n [\"wrapTopAndBottom\", TextWrappingType.TOP_AND_BOTTOM],\n [\"wrapThrough\", TextWrappingType.THROUGH],\n ];\n for (const [name, type] of WRAP_TYPE) {\n const el = findChild(anchor, `wp:${name}`);\n if (!el) continue;\n const wrap: TextWrapping = { type };\n const side = attr(el, \"wrapText\");\n if (side) wrap.side = side as TextWrapping[\"side\"];\n return wrap;\n }\n return undefined;\n}\n\n// ── Common helpers ──────────────────────────────────────────────────────────\n\nfunction getDrawingExtent(el: Element): { width?: number; height?: number } {\n const inline = findDeep(el, \"wp:inline\")[0];\n const anchor = inline ? undefined : findDeep(el, \"wp:anchor\")[0];\n const parent = inline ?? anchor;\n if (!parent) return {};\n\n const extent = findChild(parent, \"wp:extent\");\n if (!extent) return {};\n\n const cxEmu = attrNum(extent, \"cx\");\n const cyEmu = attrNum(extent, \"cy\");\n return {\n ...(cxEmu !== undefined ? { width: convertEmuToPixels(cxEmu) } : {}),\n ...(cyEmu !== undefined ? { height: convertEmuToPixels(cyEmu) } : {}),\n };\n}\n\n// ── Chart parsing ───────────────────────────────────────────────────────────\n\n/**\n * Look up a relationship ID in a map, with fallback for double \"rId\" prefix\n * that the library's generation code produces (e.g. \"rIdrId7\" → \"rId7\").\n */\nfunction lookupRId(map: Map<string, string>, rId: string | undefined): string | undefined {\n if (!rId) return undefined;\n const direct = map.get(rId);\n if (direct) return direct;\n // Fallback: strip one \"rId\" prefix when the value starts with \"rIdrId\"\n if (rId.startsWith(\"rIdrId\")) return map.get(rId.slice(3));\n return undefined;\n}\n\nfunction parseChartDrawing(el: Element, ctx: DocxReadContext): { chart: ChartOptions } | undefined {\n const chartRef = findDeep(el, \"c:chart\")[0];\n if (!chartRef) return undefined;\n\n const rId = attr(chartRef, \"r:id\");\n const chartPath = lookupRId(ctx.docx.partRefs.charts, rId);\n if (!chartPath) return undefined;\n\n const chartXml = ctx.docx.doc.get(chartPath);\n if (!chartXml) return undefined;\n\n const opts = parseChartXml(chartXml);\n if (!opts) return undefined;\n\n const ext = getDrawingExtent(el);\n if (ext.width !== undefined || ext.height !== undefined) {\n (opts as Record<string, unknown>).transformation = {\n ...ext,\n };\n }\n\n return { chart: opts as unknown as ChartOptions };\n}\n\n/**\n * Parse c:chartSpace element into ChartOptions.\n */\nfunction parseChartXml(el: Element): Record<string, unknown> | undefined {\n const chart = findChild(el, \"c:chart\");\n if (!chart) return undefined;\n\n const opts: Record<string, unknown> = {};\n\n // Title: c:chart → c:title → c:tx → c:rich → a:p → a:r → a:t\n const titleEl = findChild(chart, \"c:title\");\n if (titleEl) {\n const rich = findDeep(titleEl, \"c:rich\")[0];\n if (rich) {\n const t = findDeep(rich, \"a:t\")[0];\n if (t) {\n const title = textOf(t);\n if (title) opts.title = title;\n }\n }\n }\n\n // Plot area → chart type\n const plotArea = findChild(chart, \"c:plotArea\");\n if (!plotArea) return undefined;\n\n let chartType: string | undefined;\n let typeElement: Element | undefined;\n\n for (const child of plotArea.elements ?? []) {\n switch (child.name) {\n case \"c:barChart\": {\n const barDir = findChild(child, \"c:barDir\");\n chartType = barDir && attr(barDir, \"val\") === \"bar\" ? \"bar\" : \"column\";\n typeElement = child;\n break;\n }\n case \"c:lineChart\":\n chartType = \"line\";\n typeElement = child;\n break;\n case \"c:pieChart\":\n chartType = \"pie\";\n typeElement = child;\n break;\n case \"c:areaChart\":\n chartType = \"area\";\n typeElement = child;\n break;\n case \"c:scatterChart\":\n chartType = \"scatter\";\n typeElement = child;\n break;\n }\n if (chartType) break;\n }\n\n if (!chartType || !typeElement) return undefined;\n opts.type = chartType;\n\n // Parse series\n const series: { name: string; values: number[] }[] = [];\n let categories: string[] | undefined;\n\n for (const serEl of typeElement.elements ?? []) {\n if (serEl.name !== \"c:ser\") continue;\n\n // Series name: c:tx → c:strCache → c:pt → c:v\n const nameParts = extractStrCache(serEl, \"c:tx\");\n // Categories: c:cat → c:strCache → c:pt → c:v\n const cats = extractStrCache(serEl, \"c:cat\");\n if (cats.length > 0 && !categories) categories = cats;\n // Values: c:val → c:numCache → c:pt → c:v\n const vals = extractNumCache(serEl);\n\n series.push({ name: nameParts[0] ?? \"\", values: vals });\n }\n\n opts.categories = categories ?? [];\n opts.series = series;\n\n // Legend\n opts.showLegend = findChild(chart, \"c:legend\") !== undefined;\n\n // Style\n const styleEl = findChild(el, \"c:style\");\n if (styleEl) {\n const val = attrNum(styleEl, \"val\");\n if (val !== undefined) opts.style = val;\n }\n\n return opts;\n}\n\n/**\n * Extract string values from c:strCache within a container element.\n */\nfunction extractStrCache(parent: Element, containerName: string): string[] {\n const container = findChild(parent, containerName);\n if (!container) return [];\n const cache = findDeep(container, \"c:strCache\")[0];\n if (!cache) return [];\n\n const values: string[] = [];\n for (const pt of cache.elements ?? []) {\n if (pt.name !== \"c:pt\") continue;\n const v = findChild(pt, \"c:v\");\n if (v) values.push(textOf(v) ?? \"\");\n }\n return values;\n}\n\n/**\n * Extract numeric values from c:numCache within a c:val container.\n */\nfunction extractNumCache(parent: Element): number[] {\n const valEl = findChild(parent, \"c:val\");\n if (!valEl) return [];\n const cache = findDeep(valEl, \"c:numCache\")[0];\n if (!cache) return [];\n\n const values: number[] = [];\n for (const pt of cache.elements ?? []) {\n if (pt.name !== \"c:pt\") continue;\n const v = findChild(pt, \"c:v\");\n if (v) {\n const num = Number(textOf(v));\n if (!isNaN(num)) values.push(num);\n }\n }\n return values;\n}\n\n// ── SmartArt parsing ────────────────────────────────────────────────────────\n\nfunction parseSmartArtDrawing(\n el: Element,\n ctx: DocxReadContext,\n): { smartArt: SmartArtOptions } | undefined {\n const relIds = findDeep(el, \"dgm:relIds\")[0];\n if (!relIds) return undefined;\n\n const rId = attr(relIds, \"r:dm\");\n const dataPath = lookupRId(ctx.docx.partRefs.diagramData, rId);\n if (!dataPath) return undefined;\n\n const dataEl = ctx.docx.doc.get(dataPath);\n if (!dataEl) return undefined;\n\n const opts = parseSmartArtDataXml(dataEl);\n if (!opts) return undefined;\n\n const ext = getDrawingExtent(el);\n if (ext.width !== undefined || ext.height !== undefined) {\n (opts as Record<string, unknown>).transformation = {\n ...ext,\n };\n }\n\n return { smartArt: opts as unknown as SmartArtOptions };\n}\n\n/**\n * Parse dgm:dataModel element into SmartArtOptions.\n */\nfunction parseSmartArtDataXml(el: Element): Record<string, unknown> | undefined {\n const ptLst = findChild(el, \"dgm:ptLst\");\n if (!ptLst) return undefined;\n\n const opts: Record<string, unknown> = {};\n const nodeMap = new Map<string, string>(); // modelId → text\n\n for (const pt of ptLst.elements ?? []) {\n if (pt.name !== \"dgm:pt\") continue;\n const type = attr(pt, \"type\");\n const modelId = attr(pt, \"modelId\");\n\n if (type === \"doc\") {\n // Extract layout/style/color from prSet URIs\n const prSet = findChild(pt, \"dgm:prSet\");\n if (prSet) {\n const loTypeId = attr(prSet, \"loTypeId\") ?? \"\";\n const qsTypeId = attr(prSet, \"qsTypeId\") ?? \"\";\n const csTypeId = attr(prSet, \"csTypeId\") ?? \"\";\n\n const layout = loTypeId.split(\"/\").pop();\n if (layout) opts.layout = layout;\n const style = qsTypeId.split(\"/\").pop();\n if (style) opts.style = style;\n const color = csTypeId.split(\"/\").pop();\n if (color) opts.color = color;\n }\n } else if (type === \"node\" && modelId) {\n // Extract text: dgm:t → a:p → a:r → a:t\n const t = findDeep(pt, \"a:t\")[0];\n nodeMap.set(modelId, t ? (textOf(t) ?? \"\") : \"\");\n }\n }\n\n // Build tree from connections\n const cxnLst = findChild(el, \"dgm:cxnLst\");\n if (!cxnLst) {\n opts.data = { nodes: [] };\n return opts;\n }\n\n // Map: parentId → childIds\n const childrenMap = new Map<string, string[]>();\n for (const cxn of cxnLst.elements ?? []) {\n if (cxn.name !== \"dgm:cxn\") continue;\n const srcId = attr(cxn, \"srcId\");\n const destId = attr(cxn, \"destId\");\n if (!srcId || !destId || !nodeMap.has(destId)) continue;\n\n let arr = childrenMap.get(srcId);\n if (!arr) {\n arr = [];\n childrenMap.set(srcId, arr);\n }\n arr.push(destId);\n }\n\n // Root children are connected from doc node (modelId=\"0\")\n const topIds = childrenMap.get(\"0\") ?? [];\n opts.data = { nodes: topIds.map((id) => buildSmartArtNode(id, nodeMap, childrenMap)) };\n\n return opts;\n}\n\nfunction buildSmartArtNode(\n id: string,\n nodeMap: Map<string, string>,\n childrenMap: Map<string, string[]>,\n): { text: string; children?: unknown[] } {\n const text = nodeMap.get(id) ?? \"\";\n const childIds = childrenMap.get(id) ?? [];\n\n if (childIds.length === 0) return { text };\n return { text, children: childIds.map((cid) => buildSmartArtNode(cid, nodeMap, childrenMap)) };\n}\n","/**\n * Drawing descriptor for DOCX documents.\n *\n * Produces `<w:drawing>` XML directly from media data and options,\n * eliminating the Drawing/Inline/Anchor/Graphic/GraphicData/Pic XmlComponent\n * class chain (~10 instances per drawing in the old path).\n *\n * Common path (inline image/chart/smartart without advanced properties):\n * zero XmlComponent instances — pure string concatenation.\n *\n * Advanced properties (outline, fill, effects on images) and floating\n * positioning use core `create*()` + `.toXml({stack:[]})` for sub-elements\n * (lightweight BuilderElement instances, not deep hierarchies).\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_Drawing\n *\n * @module\n */\n\nimport { TargetModeType } from \"@office-open/core\";\nimport { uniqueNumericIdCreator, uniqueId } from \"@office-open/core\";\nimport type { CustomDescriptor, WriteContext } from \"@office-open/core/descriptor\";\nimport type { FillOptions } from \"@office-open/core/drawingml\";\nimport {\n calculateEffectExtent,\n createEffectDag,\n customGeometryDesc,\n effectListDesc,\n extractBlipFillMedia,\n fillDesc,\n outlineDesc,\n scene3DDesc,\n shape3DDesc,\n transform2DDesc,\n} from \"@office-open/core/drawingml\";\nimport { escapeXml } from \"@office-open/xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type {\n ChartMediaData,\n ExtendedMediaData,\n GroupChildMediaData,\n MediaData,\n MediaDataTransformation,\n SmartArtMediaData,\n WpgMediaData,\n WpsMediaData,\n} from \"@shared/media\";\n\nimport type { BodyContext, DocxReadContext } from \"../../context\";\nimport type { DocPropertiesOptions, HyperlinkOptions } from \"./doc-properties/doc-properties\";\n// Import parse function from drawing-parse.ts (parse path)\nimport { parseDrawingRun } from \"./drawing-parse\";\nimport type { Floating, HorizontalPositionOptions, VerticalPositionOptions } from \"./floating\";\nimport type { Margins } from \"./floating\";\nimport { HorizontalPositionRelativeFrom, VerticalPositionRelativeFrom } from \"./floating\";\nimport type { BlipEffectsOptions } from \"./inline/graphic/graphic-data/pic/blip/blip-effects\";\nimport type { TileOptions } from \"./inline/graphic/graphic-data/pic/blip/tile\";\nimport type { EffectListOptions } from \"./inline/graphic/graphic-data/pic/effects/effect-list\";\nimport type { OutlineOptions } from \"./inline/graphic/graphic-data/pic/outline/outline\";\nimport type { ChildOffset, ChildExtent } from \"./inline/graphic/graphic-data/wpg/wpg-group\";\n// wpg/wps types only\nimport type { BodyPropertiesOptions } from \"./inline/graphic/graphic-data/wps/body-properties\";\nimport type { NonVisualShapePropertiesOptions } from \"./inline/graphic/graphic-data/wps/non-visual-shape-properties\";\nimport type { WpsShapeCoreOptions } from \"./inline/graphic/graphic-data/wps/wps-shape\";\nimport { TextWrappingSide, TextWrappingType } from \"./text-wrap\";\nimport type { TextWrapping } from \"./text-wrap\";\n\n// Noop context for drawingml descriptors that don't use WriteContext\nconst NOOP_CTX: WriteContext = {\n addRelationship: () => \"\",\n addMedia: () => \"\",\n};\n\n// ── Options ──\n\n/**\n * Options for the drawing descriptor.\n *\n * Combines media data with optional visual properties.\n */\nexport interface DrawingDescriptorOptions {\n /** Media data (image, chart, smartart, wps, wpg) */\n mediaData: ExtendedMediaData;\n /** Non-visual document properties (name, description, hyperlinks) */\n docProperties?: DocPropertiesOptions;\n /** Floating/anchored positioning (omit for inline) */\n floating?: Floating;\n /** Shape outline */\n outline?: OutlineOptions;\n /** Shape fill */\n fill?: FillOptions;\n /** Shape effects (shadow, glow, etc.) */\n effects?: EffectListOptions;\n /** Image blip effects (brightness, contrast, etc.) */\n blipEffects?: BlipEffectsOptions;\n /** Image tile fill mode */\n tile?: TileOptions;\n}\n\n// ── ID generation ──\n\nlet _docPropsIdGen = uniqueNumericIdCreator();\n\n/** Reset the doc properties ID generator (for testing). */\nexport const resetDrawingIdGen = (): void => {\n _docPropsIdGen = uniqueNumericIdCreator();\n};\n\n// ── Constants ──\n\nconst GRAPHIC_NS = 'xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"';\nconst PIC_URI = \"http://schemas.openxmlformats.org/drawingml/2006/picture\";\nconst CHART_URI = \"http://schemas.openxmlformats.org/drawingml/2006/chart\";\nconst DGM_URI = \"http://schemas.openxmlformats.org/drawingml/2006/diagram\";\nconst WPS_URI = \"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\";\nconst WPG_URI = \"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\";\nconst HYPERLINK_REL =\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\";\n\n// ── Hyperlink handling ──\n\ninterface HyperlinkIds {\n clickId?: string;\n hoverId?: string;\n}\n\nfunction registerHyperlinks(\n hyperlink: HyperlinkOptions | undefined,\n ctx: BodyContext,\n): HyperlinkIds {\n if (!hyperlink) return {};\n const result: HyperlinkIds = {};\n if (hyperlink.click) {\n const linkId = uniqueId();\n ctx.viewWrapper.relationships.addRelationship(\n linkId,\n HYPERLINK_REL,\n hyperlink.click,\n TargetModeType.EXTERNAL,\n );\n result.clickId = `rId${linkId}`;\n }\n if (hyperlink.hover) {\n const linkId = uniqueId();\n ctx.viewWrapper.relationships.addRelationship(\n linkId,\n HYPERLINK_REL,\n hyperlink.hover,\n TargetModeType.EXTERNAL,\n );\n result.hoverId = `rId${linkId}`;\n }\n return result;\n}\n\nfunction buildHyperlinkChildren(ids: HyperlinkIds): string {\n const parts: string[] = [];\n const aNs = 'xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"';\n if (ids.clickId) parts.push(`<a:hlinkClick r:id=\"${ids.clickId}\" ${aNs}/>`);\n if (ids.hoverId) parts.push(`<a:hlinkHover r:id=\"${ids.hoverId}\" ${aNs}/>`);\n return parts.join(\"\");\n}\n\n// ── DocPr ──\n\nfunction stringifyDocPr(opts: DocPropertiesOptions | undefined, hlIds: HyperlinkIds): string {\n const id = opts?.id ?? _docPropsIdGen();\n const name = opts?.name ?? \"\";\n const attrs: string[] = [`id=\"${id}\"`, `name=\"${escapeXml(name)}\"`];\n if (opts?.description != null && opts.description !== undefined) {\n attrs.push(`descr=\"${escapeXml(opts.description)}\"`);\n }\n if (opts?.title != null && opts.title !== undefined) {\n attrs.push(`title=\"${escapeXml(opts.title)}\"`);\n }\n const hlXml = buildHyperlinkChildren(hlIds);\n if (hlXml) {\n return `<wp:docPr ${attrs.join(\" \")}>${hlXml}</wp:docPr>`;\n }\n return `<wp:docPr ${attrs.join(\" \")}/>`;\n}\n\n// ── BlipFill (image data reference) ──\n\nfunction stringifyBlipFill(\n mediaData: MediaData,\n blipEffects?: BlipEffectsOptions,\n tile?: TileOptions,\n): string {\n const fileName =\n mediaData.type === \"svg\" && \"fallback\" in mediaData\n ? mediaData.fallback.fileName\n : mediaData.fileName;\n\n const parts: string[] = [];\n\n // a:blip\n const blipAttrs: string[] = [`r:embed=\"{${escapeXml(fileName)}}\"`, 'cstate=\"none\"'];\n\n // SVG extension list\n const svgExtXml =\n mediaData.type === \"svg\"\n ? `<a:extLst><a:ext uri=\"{96DAC541-7B7A-43D3-8B79-37D633B846F1}\"><asvg:svgBlip xmlns:asvg=\"http://schemas.microsoft.com/office/drawing/2016/SVG/main\" r:embed=\"{${escapeXml(mediaData.fileName)}}\"/></a:ext></a:extLst>`\n : \"\";\n\n // Blip effects\n const blipEffectsXml = blipEffects ? buildBlipEffectsXml(blipEffects) : \"\";\n\n const blipContent = svgExtXml + blipEffectsXml;\n if (blipContent) {\n parts.push(`<a:blip ${blipAttrs.join(\" \")}>${blipContent}</a:blip>`);\n } else {\n parts.push(`<a:blip ${blipAttrs.join(\" \")}/>`);\n }\n\n // Source rectangle\n if (mediaData.srcRect) {\n const srAttrs: string[] = [];\n if (mediaData.srcRect.left !== undefined) srAttrs.push(`l=\"${mediaData.srcRect.left}\"`);\n if (mediaData.srcRect.top !== undefined) srAttrs.push(`t=\"${mediaData.srcRect.top}\"`);\n if (mediaData.srcRect.right !== undefined) srAttrs.push(`r=\"${mediaData.srcRect.right}\"`);\n if (mediaData.srcRect.bottom !== undefined) srAttrs.push(`b=\"${mediaData.srcRect.bottom}\"`);\n if (srAttrs.length) {\n parts.push(`<a:srcRect ${srAttrs.join(\" \")}/>`);\n }\n }\n\n // Tile or stretch\n if (tile) {\n const tileAttrs: string[] = [];\n if (tile.tx !== undefined) tileAttrs.push(`tx=\"${tile.tx}\"`);\n if (tile.ty !== undefined) tileAttrs.push(`ty=\"${tile.ty}\"`);\n if (tile.sx !== undefined) tileAttrs.push(`sx=\"${tile.sx}\"`);\n if (tile.sy !== undefined) tileAttrs.push(`sy=\"${tile.sy}\"`);\n const tileAttrStr = tileAttrs.length ? \" \" + tileAttrs.join(\" \") : \"\";\n parts.push(`<a:tile${tileAttrStr}/>`);\n } else {\n parts.push(\"<a:stretch><a:fillRect/></a:stretch>\");\n }\n\n return `<pic:blipFill>${parts.join(\"\")}</pic:blipFill>`;\n}\n\nfunction buildBlipEffectsXml(opts: BlipEffectsOptions): string {\n const parts: string[] = [];\n if (opts.grayscale) parts.push(\"<a:grayscl/>\");\n if (opts.luminance) {\n const a: string[] = [];\n if (opts.luminance.bright !== undefined) a.push(`bright=\"${opts.luminance.bright}%\"`);\n if (opts.luminance.contrast !== undefined) a.push(`contrast=\"${opts.luminance.contrast}%\"`);\n parts.push(`<a:lum${a.length ? \" \" + a.join(\" \") : \"\"}/>`);\n }\n if (opts.biLevel) parts.push(`<a:biLevel thresh=\"${opts.biLevel.threshold}%\"/>`);\n if (opts.blur) {\n const a: string[] = [];\n if (opts.blur.radius !== undefined) a.push(`rad=\"${opts.blur.radius}\"`);\n if (opts.blur.grow === false) a.push('grow=\"0\"');\n parts.push(`<a:blur${a.length ? \" \" + a.join(\" \") : \"\"}/>`);\n }\n return parts.join(\"\");\n}\n\n// ── Shape Properties (pic:spPr) ──\n\nfunction stringifyShapeProps(\n transform: MediaDataTransformation,\n outline?: OutlineOptions,\n fill?: FillOptions,\n effects?: EffectListOptions,\n): string {\n const parts: string[] = [];\n\n // Transform\n parts.push(\n transform2DDesc.stringify(\n {\n x: transform.offset?.emus?.x ?? 0,\n y: transform.offset?.emus?.y ?? 0,\n width: transform.emus.x,\n height: transform.emus.y,\n flipHorizontal: transform.flip?.horizontal,\n flipVertical: transform.flip?.vertical,\n rotation: transform.rotation,\n },\n NOOP_CTX,\n ) ?? \"\",\n );\n\n // Geometry (always rect — preset geometry variations not used for pic)\n parts.push('<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>');\n\n if (fill) parts.push(fillDesc.stringify(fill, NOOP_CTX) ?? \"\");\n if (outline) parts.push(outlineDesc.stringify(outline, NOOP_CTX) ?? \"\");\n if (effects) parts.push(effectListDesc.stringify(effects, NOOP_CTX) ?? \"\");\n\n return `<pic:spPr bwMode=\"auto\">${parts.join(\"\")}</pic:spPr>`;\n}\n\n// ── Non-visual picture properties (pic:nvPicPr) ──\n\nfunction stringifyNvPicPr(hlIds: HyperlinkIds): string {\n const hlXml = buildHyperlinkChildren(hlIds);\n const cNvPrClose = hlXml ? `>${hlXml}</pic:cNvPr>` : \"/>\";\n return (\n `<pic:nvPicPr><pic:cNvPr id=\"0\" name=\"\" descr=\"\"${cNvPrClose}` +\n `<pic:cNvPicPr preferRelativeResize=\"1\"><a:picLocks noChangeArrowheads=\"1\" noChangeAspect=\"1\"/></pic:cNvPicPr></pic:nvPicPr>`\n );\n}\n\n// ── WPS shape (pure string, no class instances) ──\n\nfunction stringifyGroupTransform2D(\n transform: MediaDataTransformation,\n chOff?: ChildOffset,\n chExt?: ChildExtent,\n): string {\n const attrs: string[] = [];\n if (transform.flip?.horizontal !== undefined) attrs.push(`flipH=\"${transform.flip.horizontal}\"`);\n if (transform.flip?.vertical !== undefined) attrs.push(`flipV=\"${transform.flip.vertical}\"`);\n if (transform.rotation !== undefined) attrs.push(`rot=\"${transform.rotation}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n\n const off = `<a:off x=\"${transform.offset?.emus?.x ?? 0}\" y=\"${transform.offset?.emus?.y ?? 0}\"/>`;\n const ext = `<a:ext cx=\"${transform.emus.x}\" cy=\"${transform.emus.y}\"/>`;\n const chOffXml = chOff ? `<a:chOff x=\"${chOff.x}\" y=\"${chOff.y}\"/>` : \"\";\n const chExtXml = chExt ? `<a:chExt cx=\"${chExt.cx}\" cy=\"${chExt.cy}\"/>` : \"\";\n\n return `<a:xfrm${attrStr}>${off}${ext}${chOffXml}${chExtXml}</a:xfrm>`;\n}\n\n/** WpsShape options for stringification (extends WpsShapeCoreOptions with transformation). */\ninterface WpsStringifyOptions extends WpsShapeCoreOptions {\n transformation: MediaDataTransformation;\n}\n\nfunction stringifyWpsShape(opts: WpsStringifyOptions, ctx: BodyContext): string {\n const transform = opts.transformation;\n const spPrParts: string[] = [];\n spPrParts.push(\n transform2DDesc.stringify(\n {\n x: transform.offset?.emus?.x ?? 0,\n y: transform.offset?.emus?.y ?? 0,\n width: transform.emus.x,\n height: transform.emus.y,\n flipHorizontal: transform.flip?.horizontal,\n flipVertical: transform.flip?.vertical,\n rotation: transform.rotation,\n },\n NOOP_CTX,\n ) ?? \"\",\n );\n if (opts.customGeometry) {\n spPrParts.push(customGeometryDesc.stringify(opts.customGeometry, NOOP_CTX) ?? \"\");\n } else {\n spPrParts.push('<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>');\n }\n if (opts.fill) spPrParts.push(fillDesc.stringify(opts.fill, NOOP_CTX) ?? \"\");\n if (opts.outline) spPrParts.push(outlineDesc.stringify(opts.outline, NOOP_CTX) ?? \"\");\n if (opts.effectDag) {\n spPrParts.push(createEffectDag(opts.effectDag));\n } else if (opts.effects) {\n spPrParts.push(effectListDesc.stringify(opts.effects, NOOP_CTX) ?? \"\");\n }\n if (opts.scene3d) spPrParts.push(scene3DDesc.stringify(opts.scene3d, NOOP_CTX) ?? \"\");\n if (opts.shape3d) spPrParts.push(shape3DDesc.stringify(opts.shape3d, NOOP_CTX) ?? \"\");\n\n // Non-visual shape properties — default txBox=\"1\"\n const cNvSpPr = opts.nonVisualProperties\n ? stringifyNonVisualShapeProperties(opts.nonVisualProperties)\n : '<wps:cNvSpPr txBox=\"1\"/>';\n\n // Paragraph children — pure JSON stringification\n const childXml =\n opts.children\n ?.map((c) => stringifyParagraphInline(c as ParagraphOptions | string, ctx))\n .join(\"\") ?? \"\";\n\n return (\n \"<wps:wsp>\" +\n cNvSpPr +\n `<wps:spPr bwMode=\"auto\">${spPrParts.join(\"\")}</wps:spPr>` +\n `<wps:txbx><wps:txbxContent>${childXml}</wps:txbxContent></wps:txbx>` +\n stringifyBodyPr(opts.bodyProperties) +\n \"</wps:wsp>\"\n );\n}\n\nfunction stringifyNonVisualShapeProperties(opts: NonVisualShapePropertiesOptions): string {\n if (!opts.txBox) return \"<wps:cNvSpPr/>\";\n return `<wps:cNvSpPr txBox=\"${opts.txBox}\"/>`;\n}\n\nfunction stringifyBodyPr(opts?: BodyPropertiesOptions): string {\n if (!opts) return \"<wps:bodyPr/>\";\n const attrs: string[] = [];\n if (opts.anchor !== undefined) attrs.push(`anchor=\"${opts.anchor}\"`);\n if (opts.vert !== undefined) attrs.push(`vert=\"${opts.vert}\"`);\n if (opts.wrap !== undefined) attrs.push(`wrap=\"${opts.wrap}\"`);\n if (opts.lIns !== undefined) attrs.push(`lIns=\"${opts.lIns}\"`);\n if (opts.tIns !== undefined) attrs.push(`tIns=\"${opts.tIns}\"`);\n if (opts.rIns !== undefined) attrs.push(`rIns=\"${opts.rIns}\"`);\n if (opts.bIns !== undefined) attrs.push(`bIns=\"${opts.bIns}\"`);\n if (opts.numCol !== undefined) attrs.push(`numCol=\"${opts.numCol}\"`);\n if (opts.rotation !== undefined) attrs.push(`rot=\"${opts.rotation}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n\n // Sub-elements\n const parts: string[] = [];\n if (opts.normAutofit) {\n const afAttrs: string[] = [];\n if (opts.normAutofit.fontScale !== undefined)\n afAttrs.push(`fontScale=\"${opts.normAutofit.fontScale}\"`);\n if (opts.normAutofit.lnSpcReduction !== undefined)\n afAttrs.push(`lnSpcReduction=\"${opts.normAutofit.lnSpcReduction}\"`);\n parts.push(`<a:normAutofit ${afAttrs.join(\" \")}/>`);\n }\n const body = parts.join(\"\");\n return body ? `<wps:bodyPr${attrStr}>${body}</wps:bodyPr>` : `<wps:bodyPr${attrStr}/>`;\n}\n\n// ── WPG group (pure string, no class instances) ──\n\nfunction stringifyWpgGroup(\n opts: {\n readonly children: readonly GroupChildMediaData[];\n readonly transformation: MediaDataTransformation;\n readonly chOff?: ChildOffset;\n readonly chExt?: ChildExtent;\n readonly fill?: FillOptions;\n readonly effects?: EffectListOptions;\n },\n ctx: BodyContext,\n): string {\n const transform = opts.transformation;\n const grpSpPrParts: string[] = [];\n grpSpPrParts.push(stringifyGroupTransform2D(transform, opts.chOff, opts.chExt));\n if (opts.fill) grpSpPrParts.push(fillDesc.stringify(opts.fill, NOOP_CTX) ?? \"\");\n if (opts.effects) grpSpPrParts.push(effectListDesc.stringify(opts.effects, NOOP_CTX) ?? \"\");\n\n // Children — wps shapes or pic elements\n const childXml = opts.children\n .map((child) => {\n if (child.type === \"wps\") {\n const wpsData = child as WpsMediaData & { outline?: OutlineOptions; fill?: FillOptions };\n return stringifyWpsShape(\n {\n ...wpsData.data,\n outline: wpsData.outline ?? wpsData.data.outline,\n fill: wpsData.fill ?? wpsData.data.fill,\n transformation: wpsData.transformation,\n },\n ctx,\n );\n }\n // pic child (MediaData)\n const picData = child as MediaData;\n const picParts: string[] = [];\n picParts.push(\n '<pic:nvPicPr><pic:cNvPr id=\"0\" name=\"\" descr=\"\"/><pic:cNvPicPr preferRelativeResize=\"1\"><a:picLocks noChangeAspect=\"1\"/></pic:cNvPicPr></pic:nvPicPr>',\n );\n picParts.push(\n `<pic:blipFill><a:blip r:embed=\"{${picData.fileName}}\" cstate=\"none\"/><a:stretch><a:fillRect/></a:stretch></pic:blipFill>`,\n );\n picParts.push(\n `<pic:spPr bwMode=\"auto\">${\n transform2DDesc.stringify(\n {\n x: picData.transformation.offset?.emus?.x ?? 0,\n y: picData.transformation.offset?.emus?.y ?? 0,\n width: picData.transformation.emus.x,\n height: picData.transformation.emus.y,\n },\n NOOP_CTX,\n ) ?? \"<a:xfrm/>\"\n }<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom></pic:spPr>`,\n );\n return `<pic:pic xmlns:pic=\"${PIC_URI}\">${picParts.join(\"\")}</pic:pic>`;\n })\n .join(\"\");\n\n return (\n \"<wpg:wgp>\" +\n \"<wpg:cNvGrpSpPr/>\" +\n `<wpg:grpSpPr>${grpSpPrParts.join(\"\")}</wpg:grpSpPr>` +\n childXml +\n \"</wpg:wgp>\"\n );\n}\n\n// ── Graphic data content ──\n\nfunction stringifyGraphicDataContent(\n mediaData: ExtendedMediaData,\n opts: DrawingDescriptorOptions,\n hlIds: HyperlinkIds,\n ctx: BodyContext,\n): string {\n const { outline, fill, effects, blipEffects, tile } = opts;\n const transform = mediaData.transformation;\n\n if (mediaData.type === \"chart\") {\n const md = mediaData as ChartMediaData;\n return (\n `<a:graphicData uri=\"${CHART_URI}\">` +\n `<c:chart xmlns:c=\"${CHART_URI}\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"{chart:${md.chartKey}}\"/>` +\n `</a:graphicData>`\n );\n }\n\n if (mediaData.type === \"smartart\") {\n const md = mediaData as SmartArtMediaData;\n return (\n `<a:graphicData uri=\"${DGM_URI}\">` +\n `<dgm:relIds xmlns:dgm=\"${DGM_URI}\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:dm=\"{smartart:${md.smartArtKey}}\" r:lo=\"{smartart-lo:${md.smartArtKey}}\" r:qs=\"{smartart-qs:${md.smartArtKey}}\" r:cs=\"{smartart-cs:${md.smartArtKey}}\"/>` +\n `</a:graphicData>`\n );\n }\n\n if (mediaData.type === \"wps\") {\n const md = mediaData as WpsMediaData;\n const wpsXml = stringifyWpsShape(\n {\n ...md.data,\n outline,\n fill,\n transformation: transform,\n },\n ctx,\n );\n return `<a:graphicData uri=\"${WPS_URI}\">${wpsXml}</a:graphicData>`;\n }\n\n if (mediaData.type === \"wpg\") {\n const md = mediaData as WpgMediaData;\n const wpgXml = stringifyWpgGroup(\n {\n children: md.children,\n transformation: transform,\n chOff: md.chOff,\n chExt: md.chExt,\n fill: md.fill,\n effects: md.effects,\n },\n ctx,\n );\n return `<a:graphicData uri=\"${WPG_URI}\">${wpgXml}</a:graphicData>`;\n }\n\n // Default: image (pic:pic)\n const md = mediaData as MediaData;\n return (\n `<a:graphicData uri=\"${PIC_URI}\">` +\n `<pic:pic xmlns:pic=\"${PIC_URI}\">` +\n stringifyNvPicPr(hlIds) +\n stringifyBlipFill(md, blipEffects, tile) +\n stringifyShapeProps(transform, outline, fill, effects) +\n `</pic:pic></a:graphicData>`\n );\n}\n\n// ── Position helpers (for anchor) ──\n\nfunction stringifyPositionH(opts: HorizontalPositionOptions): string {\n const rel = opts.relative ?? HorizontalPositionRelativeFrom.PAGE;\n const child = opts.align\n ? `<wp:align>${opts.align}</wp:align>`\n : opts.offset !== undefined\n ? `<wp:posOffset>${opts.offset}</wp:posOffset>`\n : \"<wp:align>left</wp:align>\";\n return `<wp:positionH relativeFrom=\"${rel}\">${child}</wp:positionH>`;\n}\n\nfunction stringifyPositionV(opts: VerticalPositionOptions): string {\n const rel = opts.relative ?? VerticalPositionRelativeFrom.PAGE;\n const child = opts.align\n ? `<wp:align>${opts.align}</wp:align>`\n : opts.offset !== undefined\n ? `<wp:posOffset>${opts.offset}</wp:posOffset>`\n : \"<wp:align>top</wp:align>\";\n return `<wp:positionV relativeFrom=\"${rel}\">${child}</wp:positionV>`;\n}\n\n// ── Text wrapping string builders ──\n\nfunction wrapPolygonStr(cx: number, cy: number): string {\n return (\n `<wp:wrapPolygon edited=\"0\">` +\n `<wp:start x=\"0\" y=\"0\"/>` +\n `<wp:lineTo x=\"0\" y=\"${-cy}\"/>` +\n `<wp:lineTo x=\"${cx}\" y=\"${-cy}\"/>` +\n `<wp:lineTo x=\"${cx}\" y=\"0\"/>` +\n `<wp:lineTo x=\"0\" y=\"0\"/>` +\n `</wp:wrapPolygon>`\n );\n}\n\nfunction wrapSquareStr(textWrapping: TextWrapping, margins?: Margins): string {\n const side = textWrapping.side ?? TextWrappingSide.BOTH_SIDES;\n const m = margins ?? {};\n const a = [\n `wrapText=\"${side}\"`,\n ...(m.top != null ? [`distT=\"${m.top}\"`] : []),\n ...(m.bottom != null ? [`distB=\"${m.bottom}\"`] : []),\n ...(m.left != null ? [`distL=\"${m.left}\"`] : []),\n ...(m.right != null ? [`distR=\"${m.right}\"`] : []),\n ].join(\" \");\n return `<wp:wrapSquare ${a}/>`;\n}\n\nfunction wrapTightStr(\n textWrapping: TextWrapping,\n margins: Margins,\n cx: number,\n cy: number,\n): string {\n const side = textWrapping.side ?? TextWrappingSide.BOTH_SIDES;\n const a = [`wrapText=\"${side}\"`];\n if (margins.left != null) a.push(`distL=\"${margins.left}\"`);\n if (margins.right != null) a.push(`distR=\"${margins.right}\"`);\n return `<wp:wrapTight ${a.join(\" \")}>${wrapPolygonStr(cx, cy)}</wp:wrapTight>`;\n}\n\nfunction wrapThroughStr(\n textWrapping: TextWrapping,\n margins: Margins,\n cx: number,\n cy: number,\n): string {\n const side = textWrapping.side ?? TextWrappingSide.BOTH_SIDES;\n const a = [`wrapText=\"${side}\"`];\n if (margins.left != null) a.push(`distL=\"${margins.left}\"`);\n if (margins.right != null) a.push(`distR=\"${margins.right}\"`);\n return `<wp:wrapThrough ${a.join(\" \")}>${wrapPolygonStr(cx, cy)}</wp:wrapThrough>`;\n}\n\nfunction wrapTopAndBottomStr(margins?: Margins): string {\n const m = margins ?? {};\n const a = [\n ...(m.top != null ? [`distT=\"${m.top}\"`] : []),\n ...(m.bottom != null ? [`distB=\"${m.bottom}\"`] : []),\n ].join(\" \");\n return a ? `<wp:wrapTopAndBottom ${a}/>` : \"<wp:wrapTopAndBottom/>\";\n}\n\n// ── Inline wrapper ──\n\nfunction stringifyInline(\n opts: DrawingDescriptorOptions,\n hlIds: HyperlinkIds,\n ctx: BodyContext,\n): string {\n const { mediaData, effects, docProperties } = opts;\n const cx = mediaData.transformation.emus.x;\n const cy = mediaData.transformation.emus.y;\n\n // Calculate effectExtent based on actual effects (shadow, glow, reflection, softEdge)\n const effectExtent = calculateEffectExtent(effects);\n const graphicDataXml = stringifyGraphicDataContent(mediaData, opts, hlIds, ctx);\n\n return (\n `<w:drawing><wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">` +\n `<wp:extent cx=\"${cx}\" cy=\"${cy}\"/>` +\n `<wp:effectExtent l=\"${effectExtent.l}\" t=\"${effectExtent.t}\" r=\"${effectExtent.r}\" b=\"${effectExtent.b}\"/>` +\n stringifyDocPr(docProperties, hlIds) +\n `<wp:cNvGraphicFramePr><a:graphicFrameLocks noChangeAspect=\"1\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"/></wp:cNvGraphicFramePr>` +\n `<a:graphic ${GRAPHIC_NS}>${graphicDataXml}</a:graphic>` +\n `</wp:inline></w:drawing>`\n );\n}\n\n// ── Anchor (floating) wrapper ──\n\nfunction stringifyAnchor(\n opts: DrawingDescriptorOptions,\n hlIds: HyperlinkIds,\n ctx: BodyContext,\n): string {\n const { mediaData, floating: rawFloating, docProperties } = opts;\n const cx = mediaData.transformation.emus.x;\n const cy = mediaData.transformation.emus.y;\n\n const floating: Required<Floating> = {\n allowOverlap: true,\n behindDocument: false,\n horizontalPosition: {},\n layoutInCell: true,\n lockAnchor: false,\n verticalPosition: {},\n zIndex: mediaData.transformation.emus.y,\n margins: {},\n wrap: { type: TextWrappingType.NONE },\n ...rawFloating,\n };\n\n const attrParts = [\n `distT=\"${floating.margins?.top ?? 0}\"`,\n `distB=\"${floating.margins?.bottom ?? 0}\"`,\n `distL=\"${floating.margins?.left ?? 0}\"`,\n `distR=\"${floating.margins?.right ?? 0}\"`,\n 'simplePos=\"0\"',\n `allowOverlap=\"${floating.allowOverlap ? 1 : 0}\"`,\n `behindDoc=\"${floating.behindDocument ? 1 : 0}\"`,\n `locked=\"${floating.lockAnchor ? 1 : 0}\"`,\n `layoutInCell=\"${floating.layoutInCell ? 1 : 0}\"`,\n `relativeHeight=\"${floating.zIndex}\"`,\n ];\n\n // Wrap\n let wrapXml: string;\n const rawWrap = rawFloating?.wrap;\n if (rawWrap?.type === TextWrappingType.SQUARE) {\n wrapXml = wrapSquareStr(rawWrap, floating.margins);\n } else if (rawWrap?.type === TextWrappingType.TIGHT) {\n wrapXml = wrapTightStr(rawWrap, floating.margins, cx, cy);\n } else if (rawWrap?.type === TextWrappingType.THROUGH) {\n wrapXml = wrapThroughStr(rawWrap, floating.margins, cx, cy);\n } else if (rawWrap?.type === TextWrappingType.TOP_AND_BOTTOM) {\n wrapXml = wrapTopAndBottomStr(floating.margins);\n } else {\n wrapXml = \"<wp:wrapNone/>\";\n }\n\n const graphicDataXml = stringifyGraphicDataContent(mediaData, opts, hlIds, ctx);\n\n return (\n `<w:drawing><wp:anchor ${attrParts.join(\" \")}>` +\n '<wp:simplePos x=\"0\" y=\"0\"/>' +\n stringifyPositionH(floating.horizontalPosition) +\n stringifyPositionV(floating.verticalPosition) +\n `<wp:extent cx=\"${cx}\" cy=\"${cy}\"/>` +\n '<wp:effectExtent l=\"0\" t=\"0\" r=\"0\" b=\"0\"/>' +\n wrapXml +\n stringifyDocPr(docProperties, hlIds) +\n '<wp:cNvGraphicFramePr><a:graphicFrameLocks noChangeAspect=\"1\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"/></wp:cNvGraphicFramePr>' +\n `<a:graphic ${GRAPHIC_NS}>${graphicDataXml}</a:graphic>` +\n `</wp:anchor></w:drawing>`\n );\n}\n\n// ── Descriptor ──\n\n/**\n * Drawing descriptor for DOCX `<w:drawing>` elements.\n *\n * Eliminates the Drawing/Inline/Anchor/Graphic/GraphicData/Pic XmlComponent\n * class chain. Inline images, charts, and smartarts produce XML via pure\n * string concatenation — zero XmlComponent instances.\n *\n * @example\n * ```typescript\n * const xml = drawingDesc.stringify({ mediaData, docProperties: opts.altText, floating: opts.floating }, ctx);\n * ```\n */\nexport const drawingDesc: CustomDescriptor<DrawingDescriptorOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n // Register blip fill media from fill options (shape fill with image)\n if (opts.fill) {\n const media = extractBlipFillMedia(opts.fill);\n if (media) {\n ctx.file.media.addImage(media.fileName, {\n data: media.data,\n fileName: media.fileName,\n type: media.type as \"png\",\n transformation: { pixels: { x: 0, y: 0 }, emus: { x: 0, y: 0 } },\n });\n }\n }\n\n // Register hyperlink relationships\n const hlIds = registerHyperlinks(opts.docProperties?.hyperlink, ctx);\n\n if (opts.floating) {\n return stringifyAnchor(opts, hlIds, ctx);\n }\n return stringifyInline(opts, hlIds, ctx);\n },\n\n parse(el, ctx) {\n const result = parseDrawingRun(el, ctx as DocxReadContext);\n return (result ?? {}) as unknown as DrawingDescriptorOptions;\n },\n};\n","/**\n * Direct XML string builders for Office MathML (OMML).\n *\n * Replaces `coerceMathInput()` + `new Math().toXml()` recursive class chain\n * with direct string concatenation — zero XmlComponent instances.\n *\n * Processes `MathInput` discriminated union directly to XML strings.\n *\n * @module\n */\n\nimport { attr, children, escapeXml, findChild, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { MathInput, MathRunPropertiesOptions } from \"@parts/paragraph/math\";\n\n// ── MathRun properties ──\n\nfunction mathRunPropsStr(opts: MathRunPropertiesOptions): string {\n const parts: string[] = [];\n if (opts.lit) parts.push('<m:lit m:val=\"1\"/>');\n if (opts.normal) parts.push('<m:nor m:val=\"1\"/>');\n if (opts.script) parts.push(`<m:scr m:val=\"${opts.script}\"/>`);\n if (opts.style) parts.push(`<m:sty m:val=\"${opts.style}\"/>`);\n if (opts.breakAlignment) parts.push(`<m:brk m:alnAt=\"${opts.breakAlignment}\"/>`);\n if (opts.align) parts.push('<m:aln m:val=\"1\"/>');\n return parts.length ? `<m:rPr>${parts.join(\"\")}</m:rPr>` : \"\";\n}\n\n// ── Children array ──\n\nfunction stringifyChildren(items: MathInput[]): string {\n return items.map(stringifyMathInput).join(\"\");\n}\n\n// ── Main recursive stringifier ──\n\nexport function stringifyMathInput(value: MathInput): string {\n // String → MathRun shorthand\n if (typeof value === \"string\") {\n return `<m:r><m:t>${escapeXml(value)}</m:t></m:r>`;\n }\n\n // Class instances — still need toXml (shouldn't happen in compile/ JSON path)\n if (typeof value !== \"object\" || value === null) return \"\";\n\n // Discriminated union: check unique keys (order matters — subSuperScript first)\n if (\"subSuperScript\" in value) {\n const opts = value.subSuperScript;\n return `<m:sSubSup><m:sSubSupPr/><m:e>${stringifyChildren(opts.children)}</m:e><m:sub>${stringifyChildren(opts.subScript)}</m:sub><m:sup>${stringifyChildren(opts.superScript)}</m:sup></m:sSubSup>`;\n }\n\n if (\"preSubSuperScript\" in value) {\n const opts = value.preSubSuperScript;\n return `<m:sPre><m:sPrePr/><m:sub>${stringifyChildren(opts.subScript)}</m:sub><m:sup>${stringifyChildren(opts.superScript)}</m:sup><m:e>${stringifyChildren(opts.children)}</m:e></m:sPre>`;\n }\n\n if (\"superScript\" in value) {\n const opts = value.superScript;\n return `<m:sSup><m:sSupPr/><m:e>${stringifyChildren(opts.children)}</m:e><m:sup>${stringifyChildren(opts.superScript)}</m:sup></m:sSup>`;\n }\n\n if (\"subScript\" in value) {\n const opts = value.subScript;\n return `<m:sSub><m:sSubPr/><m:e>${stringifyChildren(opts.children)}</m:e><m:sub>${stringifyChildren(opts.subScript)}</m:sub></m:sSub>`;\n }\n\n if (\"fraction\" in value) {\n const opts = value.fraction;\n const pr = opts.fractionType ? `<m:fPr><m:type m:val=\"${opts.fractionType}\"/></m:fPr>` : \"\";\n return `<m:f>${pr}<m:num>${stringifyChildren(opts.numerator)}</m:num><m:den>${stringifyChildren(opts.denominator)}</m:den></m:f>`;\n }\n\n if (\"radical\" in value) {\n const opts = value.radical;\n const hasDegree = opts.degree && opts.degree.length > 0;\n const pr = !hasDegree ? '<m:radPr><m:degHide m:val=\"1\"/></m:radPr>' : \"<m:radPr/>\";\n const deg = hasDegree ? `<m:deg>${stringifyChildren(opts.degree!)}</m:deg>` : \"<m:deg/>\";\n return `<m:rad>${pr}${deg}<m:e>${stringifyChildren(opts.children)}</m:e></m:rad>`;\n }\n\n if (\"sum\" in value) {\n return stringifyNAry(value.sum, \"∑\");\n }\n\n if (\"integral\" in value) {\n return stringifyNAry(value.integral, \"∫\");\n }\n\n if (\"limitLower\" in value) {\n const opts = value.limitLower;\n const pr = opts.properties ? \"\" : \"\"; // controlProperties rare — skip for now\n return `<m:limLow>${pr}<m:e>${stringifyChildren(opts.children)}</m:e><m:lim>${stringifyChildren(opts.limit)}</m:lim></m:limLow>`;\n }\n\n if (\"limitUpper\" in value) {\n const opts = value.limitUpper;\n const pr = opts.properties ? \"\" : \"\";\n return `<m:limUpp>${pr}<m:e>${stringifyChildren(opts.children)}</m:e><m:lim>${stringifyChildren(opts.limit)}</m:lim></m:limUpp>`;\n }\n\n if (\"function\" in value) {\n const opts = value.function;\n const pr = opts.properties ? \"\" : \"\";\n return `<m:func>${pr}<m:fName>${stringifyChildren(opts.name)}</m:fName><m:e>${stringifyChildren(opts.children)}</m:e></m:func>`;\n }\n\n if (\"matrix\" in value) {\n const opts = value.matrix;\n const rows = opts.rows\n .map(\n (row) =>\n `<m:mr>${row.map((cell) => `<m:e>${stringifyMathInput(cell)}</m:e>`).join(\"\")}</m:mr>`,\n )\n .join(\"\");\n // Matrix properties are complex — emit basic structure only when needed\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const prParts: string[] = [];\n if (p.baseJc) prParts.push(`<m:baseJc m:val=\"${p.baseJc as string}\"/>`);\n if (p.plcHide) prParts.push('<m:plcHide m:val=\"1\"/>');\n if (p.rSpRule) prParts.push(`<m:rSpRule m:val=\"${p.rSpRule as string}\"/>`);\n if (p.cGpRule) prParts.push(`<m:cGpRule m:val=\"${p.cGpRule as string}\"/>`);\n if (p.rSp) prParts.push(`<m:rSp m:val=\"${p.rSp as string}\"/>`);\n if (p.cSp) prParts.push(`<m:cSp m:val=\"${p.cSp as string}\"/>`);\n if (p.cGp) prParts.push(`<m:cGp m:val=\"${p.cGp as string}\"/>`);\n if (p.mcs) {\n const mcItems = (p.mcs as Array<{ count: number; mcJc: string }>)\n .map(\n (mc) =>\n `<m:mc><m:mcPr><m:count m:val=\"${mc.count}\"/><m:mcJc m:val=\"${mc.mcJc}\"/></m:mcPr></m:mc>`,\n )\n .join(\"\");\n prParts.push(`<m:mcs>${mcItems}</m:mcs>`);\n }\n if (prParts.length) pr = `<m:mPr>${prParts.join(\"\")}</m:mPr>`;\n }\n return `<m:m>${pr}${rows}</m:m>`;\n }\n\n // Bracket types\n if (\"roundBrackets\" in value) {\n return stringifyDelimiters(bracketChildren(value.roundBrackets), \"(\", \")\");\n }\n if (\"curlyBrackets\" in value) {\n return stringifyDelimiters(bracketChildren(value.curlyBrackets), \"{\", \"}\");\n }\n if (\"angledBrackets\" in value) {\n return stringifyDelimiters(bracketChildren(value.angledBrackets), \"〈\", \"〉\");\n }\n if (\"squareBrackets\" in value) {\n return stringifyDelimiters(bracketChildren(value.squareBrackets), \"[\", \"]\");\n }\n\n if (\"borderBox\" in value) {\n const opts = value.borderBox;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.hideTop) parts.push('<m:hideTop m:val=\"1\"/>');\n if (p.hideBottom) parts.push('<m:hideBot m:val=\"1\"/>');\n if (p.hideLeft) parts.push('<m:hideLeft m:val=\"1\"/>');\n if (p.hideRight) parts.push('<m:hideRight m:val=\"1\"/>');\n if (p.strikeHorizontal) parts.push('<m:strikeH m:val=\"1\"/>');\n if (p.strikeVertical) parts.push('<m:strikeV m:val=\"1\"/>');\n if (p.strikeDiagonalUp) parts.push('<m:strikeBLTR m:val=\"1\"/>');\n if (p.strikeDiagonalDown) parts.push('<m:strikeTLBR m:val=\"1\"/>');\n if (parts.length) pr = `<m:borderBoxPr>${parts.join(\"\")}</m:borderBoxPr>`;\n }\n return `<m:borderBox>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:borderBox>`;\n }\n\n if (\"box\" in value) {\n const opts = value.box;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.opEmu) parts.push('<m:opEmu m:val=\"1\"/>');\n if (p.noBreak) parts.push('<m:noBreak m:val=\"1\"/>');\n if (p.diff) parts.push('<m:diff m:val=\"1\"/>');\n if (p.aln) parts.push('<m:aln m:val=\"1\"/>');\n if (parts.length) pr = `<m:boxPr>${parts.join(\"\")}</m:boxPr>`;\n }\n return `<m:box>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:box>`;\n }\n\n if (\"groupChr\" in value) {\n const opts = value.groupChr;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.chr) parts.push(`<m:chr m:val=\"${p.chr as string}\"/>`);\n if (p.pos) parts.push(`<m:pos m:val=\"${p.pos as string}\"/>`);\n if (p.vertJc) parts.push(`<m:vertJc m:val=\"${p.vertJc as string}\"/>`);\n if (parts.length) pr = `<m:groupChrPr>${parts.join(\"\")}</m:groupChrPr>`;\n }\n return `<m:groupChr>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:groupChr>`;\n }\n\n if (\"phant\" in value) {\n const opts = value.phant;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.show !== undefined) parts.push(`<m:show m:val=\"${p.show ? 1 : 0}\"/>`);\n if (p.zeroWid) parts.push('<m:zeroWid m:val=\"1\"/>');\n if (p.zeroAsc) parts.push('<m:zeroAsc m:val=\"1\"/>');\n if (p.zeroDesc) parts.push('<m:zeroDesc m:val=\"1\"/>');\n if (p.transp) parts.push('<m:transp m:val=\"1\"/>');\n if (parts.length) pr = `<m:phantPr>${parts.join(\"\")}</m:phantPr>`;\n }\n return `<m:phant>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:phant>`;\n }\n\n if (\"eqArr\" in value) {\n const opts = value.eqArr;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.baseJc) parts.push(`<m:baseJc m:val=\"${p.baseJc as string}\"/>`);\n if (p.maxDist) parts.push('<m:maxDist m:val=\"1\"/>');\n if (p.objDist) parts.push('<m:objDist m:val=\"1\"/>');\n if (p.rSpRule) parts.push(`<m:rSpRule m:val=\"${p.rSpRule as string}\"/>`);\n if (p.rSp) parts.push(`<m:rSp m:val=\"${p.rSp as string}\"/>`);\n if (parts.length) pr = `<m:eqArrPr>${parts.join(\"\")}</m:eqArrPr>`;\n }\n const rows = opts.rows.map((row) => `<m:e>${stringifyChildren(row)}</m:e>`).join(\"\");\n return `<m:eqArr>${pr}${rows}</m:eqArr>`;\n }\n\n if (\"accent\" in value) {\n const opts = value.accent;\n const pr = opts.accentCharacter\n ? `<m:accPr><m:chr m:val=\"${opts.accentCharacter}\"/></m:accPr>`\n : \"\";\n return `<m:acc>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:acc>`;\n }\n\n if (\"bar\" in value) {\n const opts = value.bar;\n return `<m:bar><m:barPr><m:pos m:val=\"${opts.type}\"/></m:barPr><m:e>${stringifyChildren(opts.children)}</m:e></m:bar>`;\n }\n\n // Fallback: { text: string; properties?: ... } → MathRun\n if (\"text\" in value) {\n const props = value.properties ? mathRunPropsStr(value.properties) : \"\";\n return `<m:r>${props}<m:t>${escapeXml(value.text)}</m:t></m:r>`;\n }\n\n return \"\";\n}\n\n// ── N-ary operator (sum/integral) ──\n\nfunction stringifyNAry(\n opts: { children: MathInput[]; subScript?: MathInput[]; superScript?: MathInput[] },\n chr: string,\n): string {\n const hasSub = opts.subScript && opts.subScript.length > 0;\n const hasSup = opts.superScript && opts.superScript.length > 0;\n const prParts: string[] = [`<m:chr m:val=\"${chr}\"/>`];\n if (!hasSub) prParts.push('<m:subHide m:val=\"1\"/>');\n if (!hasSup) prParts.push('<m:supHide m:val=\"1\"/>');\n const pr = `<m:naryPr>${prParts.join(\"\")}</m:naryPr>`;\n const sub = hasSub ? `<m:sub>${stringifyChildren(opts.subScript!)}</m:sub>` : \"<m:sub/>\";\n const sup = hasSup ? `<m:sup>${stringifyChildren(opts.superScript!)}</m:sup>` : \"<m:sup/>\";\n return `<m:nary>${pr}${sub}${sup}<m:e>${stringifyChildren(opts.children)}</m:e></m:nary>`;\n}\n\n// ── Delimiters (brackets) ──\n\nfunction stringifyDelimiters(children: MathInput[], begChr: string, endChr: string): string {\n return `<m:d><m:dPr><m:begChr m:val=\"${begChr}\"/><m:endChr m:val=\"${endChr}\"/></m:dPr><m:e>${stringifyChildren(children)}</m:e></m:d>`;\n}\n\nfunction bracketChildren(v: MathInput[] | { children: MathInput[] }): MathInput[] {\n if (Array.isArray(v)) return v;\n return (v as { children: MathInput[] }).children;\n}\n\n// ── Top-level Math wrapper ──\n\nexport function stringifyMath(children: MathInput[]): string {\n const inner = children.map((c) => stringifyMathInput(c)).join(\"\");\n return `<m:oMath>${inner}</m:oMath>`;\n}\n\nexport function stringifyMathParagraph(children: MathInput[]): string {\n const inner = children.map((c) => stringifyMathInput(c)).join(\"\");\n return `<m:oMathPara><m:oMath>${inner}</m:oMath></m:oMathPara>`;\n}\n\n// ────────────────────────────────────────────────────────────────────────────────\n// Parse (OMML XML → MathInput)\n// ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * Parse all math children from an m:oMath (or similar container) element.\n */\nexport function parseMathChildren(el: Element): MathInput[] {\n const result: MathInput[] = [];\n for (const child of el.elements ?? []) {\n const parsed = parseMathElement(child);\n if (parsed !== undefined) result.push(parsed);\n }\n return result;\n}\n\nfunction parseMathElement(el: Element): MathInput | undefined {\n switch (el.name) {\n case \"m:r\":\n return parseMathRun(el);\n case \"m:f\":\n return parseMathFraction(el);\n case \"m:rad\":\n return parseMathRadical(el);\n case \"m:sSup\":\n return parseMathSuperScript(el);\n case \"m:sSub\":\n return parseMathSubScript(el);\n case \"m:sSubSup\":\n return parseMathSubSuperScript(el);\n case \"m:nary\":\n return parseMathNAry(el);\n case \"m:func\":\n return parseMathFunction(el);\n case \"m:d\":\n return parseMathDelimiter(el);\n case \"m:m\":\n return parseMathMatrix(el);\n case \"m:acc\":\n return parseMathAccent(el);\n case \"m:bar\":\n return parseMathBar(el);\n case \"m:borderBox\":\n return { borderBox: { children: parseMathArg(el, \"m:e\") } };\n case \"m:box\":\n return { box: { children: parseMathArg(el, \"m:e\") } };\n case \"m:groupChr\":\n return { groupChr: { children: parseMathArg(el, \"m:e\") } };\n case \"m:phant\":\n return { phant: { children: parseMathArg(el, \"m:e\") } };\n case \"m:eqArr\":\n return parseMathEqArr(el);\n case \"m:limLow\":\n return parseMathLimitLower(el);\n case \"m:limUpp\":\n return parseMathLimitUpper(el);\n // Property elements — not standalone content\n case \"m:rPr\":\n case \"m:fPr\":\n case \"m:radPr\":\n case \"m:sSupPr\":\n case \"m:sSubPr\":\n case \"m:sSubSupPr\":\n case \"m:naryPr\":\n case \"m:funcPr\":\n case \"m:dPr\":\n case \"m:mPr\":\n case \"m:accPr\":\n case \"m:barPr\":\n case \"m:borderBoxPr\":\n case \"m:boxPr\":\n case \"m:groupChrPr\":\n case \"m:phantPr\":\n case \"m:eqArrPr\":\n case \"m:limLowPr\":\n case \"m:limUppPr\":\n case \"m:ctrlPr\":\n return undefined;\n default:\n return undefined;\n }\n}\n\nfunction parseMathRun(el: Element): MathInput {\n const text = textOf(findChild(el, \"m:t\"));\n return text ?? \"\";\n}\n\nfunction parseMathFraction(el: Element): MathInput {\n return {\n fraction: {\n numerator: parseMathArg(el, \"m:num\"),\n denominator: parseMathArg(el, \"m:den\"),\n },\n };\n}\n\nfunction parseMathRadical(el: Element): MathInput {\n const degree = parseMathArg(el, \"m:deg\");\n const mathChildren = parseMathArg(el, \"m:e\");\n return {\n radical: {\n children: mathChildren,\n ...(degree.length > 0 ? { degree } : {}),\n },\n };\n}\n\nfunction parseMathSuperScript(el: Element): MathInput {\n return {\n superScript: {\n children: parseMathArg(el, \"m:e\"),\n superScript: parseMathArg(el, \"m:sup\"),\n },\n };\n}\n\nfunction parseMathSubScript(el: Element): MathInput {\n return {\n subScript: {\n children: parseMathArg(el, \"m:e\"),\n subScript: parseMathArg(el, \"m:sub\"),\n },\n };\n}\n\nfunction parseMathSubSuperScript(el: Element): MathInput {\n return {\n subSuperScript: {\n children: parseMathArg(el, \"m:e\"),\n subScript: parseMathArg(el, \"m:sub\"),\n superScript: parseMathArg(el, \"m:sup\"),\n },\n };\n}\n\nfunction parseMathNAry(el: Element): MathInput {\n const naryPr = findChild(el, \"m:naryPr\");\n const chrEl = naryPr ? findChild(naryPr, \"m:chr\") : undefined;\n const chrVal = chrEl ? attr(chrEl, \"m:val\") : undefined;\n\n const baseChildren = parseMathArg(el, \"m:e\");\n const sub = parseMathArg(el, \"m:sub\");\n const sup = parseMathArg(el, \"m:sup\");\n\n const common = {\n children: baseChildren,\n ...(sub.length > 0 ? { subScript: sub } : {}),\n ...(sup.length > 0 ? { superScript: sup } : {}),\n };\n\n if (chrVal === \"∑\") return { sum: common };\n return { integral: common };\n}\n\nfunction parseMathFunction(el: Element): MathInput {\n return {\n function: {\n name: parseMathArg(el, \"m:fName\"),\n children: parseMathArg(el, \"m:e\"),\n },\n };\n}\n\nfunction parseMathDelimiter(el: Element): MathInput {\n const dPr = findChild(el, \"m:dPr\");\n const begChrEl = dPr ? findChild(dPr, \"m:begChr\") : undefined;\n const begChr = begChrEl ? attr(begChrEl, \"m:val\") : \"(\";\n const mathChildren = parseMathArg(el, \"m:e\");\n\n switch (begChr) {\n case \"[\":\n return { squareBrackets: mathChildren };\n case \"{\":\n return { curlyBrackets: mathChildren };\n case \"<\":\n case \"⟨\":\n return { angledBrackets: mathChildren };\n default:\n return { roundBrackets: mathChildren };\n }\n}\n\nfunction parseMathMatrix(el: Element): MathInput {\n const rows: MathInput[][] = [];\n for (const mr of children(el, \"m:mr\")) {\n rows.push(parseMathArg(mr, \"m:e\"));\n }\n return { matrix: { rows } };\n}\n\nfunction parseMathAccent(el: Element): MathInput {\n const accPr = findChild(el, \"m:accPr\");\n const chrEl = accPr ? findChild(accPr, \"m:chr\") : undefined;\n const accentChar = chrEl ? attr(chrEl, \"m:val\") : undefined;\n\n return {\n accent: {\n children: parseMathArg(el, \"m:e\"),\n ...(accentChar ? { accentCharacter: accentChar } : {}),\n },\n };\n}\n\nfunction parseMathBar(el: Element): MathInput {\n const barPr = findChild(el, \"m:barPr\");\n const posEl = barPr ? findChild(barPr, \"m:pos\") : undefined;\n const pos = posEl ? attr(posEl, \"m:val\") : \"top\";\n\n return {\n bar: {\n children: parseMathArg(el, \"m:e\"),\n type: (pos as \"top\" | \"bot\") ?? \"top\",\n },\n };\n}\n\nfunction parseMathEqArr(el: Element): MathInput {\n const rows: MathInput[][] = [];\n for (const e of children(el, \"m:e\")) {\n rows.push(parseMathChildren(e));\n }\n return { eqArr: { rows } };\n}\n\nfunction parseMathLimitLower(el: Element): MathInput {\n return {\n limitLower: {\n children: parseMathArg(el, \"m:e\"),\n limit: parseMathArg(el, \"m:lim\"),\n },\n };\n}\n\nfunction parseMathLimitUpper(el: Element): MathInput {\n return {\n limitUpper: {\n children: parseMathArg(el, \"m:e\"),\n limit: parseMathArg(el, \"m:lim\"),\n },\n };\n}\n\nfunction parseMathArg(parent: Element, childName: string): MathInput[] {\n const container = findChild(parent, childName);\n if (!container) return [];\n return parseMathChildren(container);\n}\n","/**\n * Field module for WordprocessingML documents.\n *\n * This module provides support for complex fields, which are regions of text\n * that can contain dynamic content such as page numbers, dates, or mail merge fields.\n * Fields are delimited by field character elements (begin, separate, end).\n *\n * Reference: http://officeopenxml.com/WPrun.php\n *\n * @module\n */\n\nimport { element } from \"@office-open/xml\";\n\nimport type { FormFieldOptions } from \"./form-field\";\nimport { createFormFieldData } from \"./form-field\";\n\n/**\n * Field character types that delimit field regions.\n *\n * @internal\n */\nconst FieldCharacterType = {\n BEGIN: \"begin\",\n END: \"end\",\n SEPARATE: \"separate\",\n} as const;\n\n/**\n * Creates a field character element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_FldChar\">\n * <xsd:sequence>\n * <xsd:element name=\"fldData\" type=\"CT_Text\" minOccurs=\"0\"/>\n * <xsd:element name=\"ffData\" type=\"CT_FFData\" minOccurs=\"0\"/>\n * <xsd:element name=\"numberingChange\" type=\"CT_TrackChangeNumbering\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"fldCharType\" type=\"ST_FldCharType\" use=\"required\"/>\n * <xsd:attribute name=\"fldLock\" type=\"s:ST_OnOff\"/>\n * <xsd:attribute name=\"dirty\" type=\"s:ST_OnOff\"/>\n * </xsd:complexType>\n * ```\n * @internal\n */\nconst createFieldChar = (\n type: (typeof FieldCharacterType)[keyof typeof FieldCharacterType],\n dirty?: boolean,\n ffData?: string,\n fldData?: string,\n fieldLock?: boolean,\n): string => {\n const children: string[] = [];\n if (fldData !== undefined) {\n children.push(element(\"w:fldData\", { \"xml:space\": \"preserve\" }, [fldData]));\n }\n if (ffData) {\n children.push(ffData);\n }\n return element(\n \"w:fldChar\",\n {\n \"w:dirty\": dirty,\n \"w:fldLock\": fieldLock,\n \"w:fldCharType\": type,\n },\n children.length > 0 ? children : undefined,\n );\n};\n\n/**\n * Creates the beginning of a complex field.\n *\n * The Begin element marks the start of a field. A field consists of a begin character,\n * field instructions, an optional separate character, field result, and an end character.\n *\n * For form fields, pass `formField` to embed `w:ffData` within the begin `w:fldChar`.\n *\n * @param dirty - Whether the field should be recalculated\n * @param formField - Optional form field data to embed in the begin character\n *\n * @example\n * ```typescript\n * // Simple field begin\n * createBegin();\n *\n * // Form field (checkbox)\n * createBegin(false, {\n * name: \"Check1\",\n * checkBox: { checked: true, sizeAuto: true },\n * });\n * ```\n */\nexport const createBegin = (\n dirty?: boolean,\n formField?: FormFieldOptions,\n fieldLock?: boolean,\n): string =>\n createFieldChar(\n FieldCharacterType.BEGIN,\n dirty,\n formField ? createFormFieldData(formField) : undefined,\n undefined,\n fieldLock,\n );\n\n/**\n * Creates the separator between field code and field result in a complex field.\n *\n * The Separate element divides the field code (instructions) from the field result\n * (the computed value).\n */\nexport const createSeparate = (dirty?: boolean): string =>\n createFieldChar(FieldCharacterType.SEPARATE, dirty);\n\n/**\n * Creates the end of a complex field.\n *\n * The End element marks the end of a field. Every field that begins with a Begin\n * element must be terminated with an End element.\n */\nexport const createEnd = (dirty?: boolean): string =>\n createFieldChar(FieldCharacterType.END, dirty);\n","/**\n * Direct XML string builders for paragraph and run properties.\n *\n * Replaces `buildParagraphProperties() + xml()` and `buildRunProperties() + xml()`\n * with direct string concatenation — zero intermediate IXmlableObject allocation,\n * zero recursive xml() traversal. Follows PPTX/XLSX pattern.\n *\n * @module\n */\n\nimport {\n decimalNumber,\n eighthPointMeasureValue,\n hexColorValue,\n hpsMeasureValue,\n pointMeasureValue,\n signedTwipsMeasureValue,\n twipsMeasureValue,\n uCharHexNumber,\n} from \"@office-open/core\";\nimport { escapeXml } from \"@office-open/xml\";\nimport type { CnfConditionalOptions } from \"@parts/paragraph/formatting/cnf-style\";\nimport type { IndentAttributesProperties } from \"@parts/paragraph/formatting/indent\";\nimport type { SpacingProperties } from \"@parts/paragraph/formatting/spacing\";\nimport type { TabStopDefinition } from \"@parts/paragraph/formatting/tab-stop\";\nimport type { FrameOptions } from \"@parts/paragraph/frame/frame-properties\";\nimport type { ParagraphPropertiesOptions } from \"@parts/paragraph/properties\";\nimport type { EastAsianLayoutOptions } from \"@parts/paragraph/run/east-asian-layout\";\nimport type { ColorOptions } from \"@parts/paragraph/run/formatting\";\nimport type { LanguageOptions } from \"@parts/paragraph/run/language\";\nimport type {\n ParagraphRunPropertiesOptions,\n RunPropertiesChangeOptions,\n RunPropertiesOptions,\n} from \"@parts/paragraph/run/properties\";\nimport type { FontAttributesProperties } from \"@parts/paragraph/run/run-fonts\";\nimport type { BorderOptions } from \"@shared/border\";\nimport { BorderStyle } from \"@shared/border\";\nimport type { ShadingAttributesProperties } from \"@shared/shading\";\n\n// ── Inline helpers ──\n\n/** On/off: `<w:name/>` for true, `<w:name w:val=\"0\"/>` for false */\nexport function onOff(name: string, val: boolean): string {\n return val ? `<${name}/>` : `<${name} w:val=\"0\"/>`;\n}\n\n/** Build attrs string from key-value pairs, skipping undefined */\nexport function attrParts(attrs: Record<string, string | number | boolean | undefined>): string {\n const parts: string[] = [];\n for (const [key, val] of Object.entries(attrs)) {\n if (val !== undefined) parts.push(`${key}=\"${val}\"`);\n }\n return parts.join(\" \");\n}\n\n// ── Border ──\n\nexport function borderStr(name: string, opts: BorderOptions): string {\n const a = attrParts({\n \"w:val\": opts.style,\n \"w:color\": opts.color !== undefined ? hexColorValue(opts.color) : undefined,\n \"w:sz\": opts.size !== undefined ? eighthPointMeasureValue(opts.size) : undefined,\n \"w:space\": opts.space !== undefined ? pointMeasureValue(opts.space) : undefined,\n \"w:themeColor\": opts.themeColor,\n \"w:themeTint\": opts.themeTint !== undefined ? uCharHexNumber(opts.themeTint) : undefined,\n \"w:themeShade\": opts.themeShade !== undefined ? uCharHexNumber(opts.themeShade) : undefined,\n \"w:shadow\": opts.shadow !== undefined ? (opts.shadow ? 1 : 0) : undefined,\n \"w:frame\": opts.frame !== undefined ? (opts.frame ? 1 : 0) : undefined,\n });\n return `<${name} ${a}/>`;\n}\n\n// ── Shading ──\n\nexport function shadingStr(opts: ShadingAttributesProperties): string {\n const a = attrParts({\n \"w:val\": opts.type ?? \"clear\",\n \"w:color\": opts.color !== undefined ? hexColorValue(opts.color) : undefined,\n \"w:fill\": opts.fill !== undefined ? hexColorValue(opts.fill) : undefined,\n \"w:themeColor\": opts.themeColor,\n \"w:themeTint\": opts.themeTint !== undefined ? uCharHexNumber(opts.themeTint) : undefined,\n \"w:themeShade\": opts.themeShade !== undefined ? uCharHexNumber(opts.themeShade) : undefined,\n \"w:themeFill\": opts.themeFill,\n \"w:themeFillTint\":\n opts.themeFillTint !== undefined ? uCharHexNumber(opts.themeFillTint) : undefined,\n \"w:themeFillShade\":\n opts.themeFillShade !== undefined ? uCharHexNumber(opts.themeFillShade) : undefined,\n });\n return `<w:shd ${a}/>`;\n}\n\n// ── Spacing ──\n\nfunction spacingStr(opts: SpacingProperties): string {\n const a = attrParts({\n \"w:after\": opts.after,\n \"w:afterAutospacing\":\n opts.afterAutoSpacing !== undefined ? (opts.afterAutoSpacing ? 1 : 0) : undefined,\n \"w:afterLines\": opts.afterLines !== undefined ? decimalNumber(opts.afterLines) : undefined,\n \"w:before\": opts.before,\n \"w:beforeAutospacing\":\n opts.beforeAutoSpacing !== undefined ? (opts.beforeAutoSpacing ? 1 : 0) : undefined,\n \"w:beforeLines\": opts.beforeLines !== undefined ? decimalNumber(opts.beforeLines) : undefined,\n \"w:line\": opts.line,\n \"w:lineRule\": opts.lineRule,\n });\n return `<w:spacing ${a}/>`;\n}\n\n// ── Indent ──\n\nfunction indentStr(opts: IndentAttributesProperties): string {\n const a = attrParts({\n \"w:start\": opts.start !== undefined ? signedTwipsMeasureValue(opts.start) : undefined,\n \"w:startChars\": opts.startChars !== undefined ? decimalNumber(opts.startChars) : undefined,\n \"w:end\": opts.end !== undefined ? signedTwipsMeasureValue(opts.end) : undefined,\n \"w:endChars\": opts.endChars !== undefined ? decimalNumber(opts.endChars) : undefined,\n \"w:left\": opts.left !== undefined ? signedTwipsMeasureValue(opts.left) : undefined,\n \"w:leftChars\": opts.leftChars !== undefined ? decimalNumber(opts.leftChars) : undefined,\n \"w:right\": opts.right !== undefined ? signedTwipsMeasureValue(opts.right) : undefined,\n \"w:rightChars\": opts.rightChars !== undefined ? decimalNumber(opts.rightChars) : undefined,\n \"w:hanging\": opts.hanging !== undefined ? twipsMeasureValue(opts.hanging) : undefined,\n \"w:hangingChars\":\n opts.hangingChars !== undefined ? decimalNumber(opts.hangingChars) : undefined,\n \"w:firstLine\": opts.firstLine !== undefined ? twipsMeasureValue(opts.firstLine) : undefined,\n \"w:firstLineChars\":\n opts.firstLineChars !== undefined ? decimalNumber(opts.firstLineChars) : undefined,\n });\n return `<w:ind ${a}/>`;\n}\n\n// ── Tab stops ──\n\nfunction tabStopsStr(defs: TabStopDefinition[]): string {\n const items = defs.map(({ type, position, leader }) => {\n const a = attrParts({ \"w:val\": type, \"w:pos\": position, \"w:leader\": leader });\n return `<w:tab ${a}/>`;\n });\n return `<w:tabs>${items.join(\"\")}</w:tabs>`;\n}\n\n// ── CNF style ──\n\nfunction cnfStyleStr(opts: CnfConditionalOptions): string {\n const a = attrParts({\n \"w:firstRow\": opts.firstRow ? \"1\" : \"0\",\n \"w:lastRow\": opts.lastRow ? \"1\" : \"0\",\n \"w:firstColumn\": opts.firstColumn ? \"1\" : \"0\",\n \"w:lastColumn\": opts.lastColumn ? \"1\" : \"0\",\n \"w:oddVBand\": opts.oddVBand ? \"1\" : \"0\",\n \"w:evenVBand\": opts.evenVBand ? \"1\" : \"0\",\n \"w:oddHBand\": opts.oddHBand ? \"1\" : \"0\",\n \"w:evenHBand\": opts.evenHBand ? \"1\" : \"0\",\n \"w:firstRowFirstColumn\": opts.firstRowFirstColumn ? \"1\" : \"0\",\n \"w:firstRowLastColumn\": opts.firstRowLastColumn ? \"1\" : \"0\",\n \"w:lastRowFirstColumn\": opts.lastRowFirstColumn ? \"1\" : \"0\",\n \"w:lastRowLastColumn\": opts.lastRowLastColumn ? \"1\" : \"0\",\n });\n return `<w:cnfStyle ${a}/>`;\n}\n\n// ── Frame properties ──\n\nfunction framePrStr(opts: FrameOptions): string {\n const alignment = (opts as { alignment?: { x?: string; y?: string } }).alignment;\n const position = (opts as { position?: { x?: number; y?: number } }).position;\n const a = attrParts({\n \"w:xAlign\": alignment?.x,\n \"w:yAlign\": alignment?.y,\n \"w:hAnchor\": opts.anchor?.horizontal,\n \"w:anchorLock\": opts.anchorLock,\n \"w:vAnchor\": opts.anchor?.vertical,\n \"w:dropCap\": opts.dropCap,\n \"w:h\": opts.height,\n \"w:lines\": opts.lines,\n \"w:hRule\": opts.rule,\n \"w:hSpace\": opts.space?.horizontal,\n \"w:vSpace\": opts.space?.vertical,\n \"w:w\": opts.width,\n \"w:wrap\": opts.wrap,\n \"w:x\": position?.x,\n \"w:y\": position?.y,\n });\n return `<w:framePr ${a}/>`;\n}\n\n// ── Number properties ──\n\nfunction numPrStr(\n numberId: number | string,\n indentLevel: number,\n numberingChange?: { original: string; id: string; author: string; date?: string },\n): string {\n const idVal = typeof numberId === \"string\" ? `{${numberId}}` : numberId;\n const parts = [`<w:ilvl w:val=\"${Math.min(indentLevel, 9)}\"/>`, `<w:numId w:val=\"${idVal}\"/>`];\n if (numberingChange) {\n const a = attrParts({\n \"w:original\": numberingChange.original,\n \"w:id\": numberingChange.id,\n \"w:author\": numberingChange.author,\n \"w:date\": numberingChange.date,\n });\n parts.push(`<w:numberingChange ${a}/>`);\n }\n return `<w:numPr>${parts.join(\"\")}</w:numPr>`;\n}\n\n// ── Run-level formatting helpers ──\n\nfunction colorStr(colorOrOptions: string | ColorOptions): string {\n if (typeof colorOrOptions === \"string\") {\n return `<w:color w:val=\"${hexColorValue(colorOrOptions)}\"/>`;\n }\n const opts = colorOrOptions;\n const a = attrParts({\n \"w:val\": opts.val !== undefined ? hexColorValue(opts.val) : undefined,\n \"w:themeColor\": opts.themeColor,\n \"w:themeTint\": opts.themeTint !== undefined ? uCharHexNumber(opts.themeTint) : undefined,\n \"w:themeShade\": opts.themeShade !== undefined ? uCharHexNumber(opts.themeShade) : undefined,\n });\n return `<w:color ${a}/>`;\n}\n\nfunction runFontsStr(nameOrAttrs: string | FontAttributesProperties, hint?: string): string {\n if (typeof nameOrAttrs === \"string\") {\n const a = attrParts({\n \"w:ascii\": nameOrAttrs,\n \"w:cs\": nameOrAttrs,\n \"w:eastAsia\": nameOrAttrs,\n \"w:hAnsi\": nameOrAttrs,\n \"w:hint\": hint,\n });\n return `<w:rFonts ${a}/>`;\n }\n const attrs = nameOrAttrs;\n const a = attrParts({\n \"w:ascii\": attrs.ascii,\n \"w:asciiTheme\": attrs.asciiTheme,\n \"w:cs\": attrs.cs,\n \"w:cstheme\": attrs.cstheme,\n \"w:eastAsia\": attrs.eastAsia,\n \"w:eastAsiaTheme\": attrs.eastAsiaTheme,\n \"w:hAnsi\": attrs.hAnsi,\n \"w:hAnsiTheme\": attrs.hAnsiTheme,\n \"w:hint\": attrs.hint,\n });\n return `<w:rFonts ${a}/>`;\n}\n\nfunction underlineStr(type: string | undefined, color?: string): string {\n const a = attrParts({\n \"w:val\": type ?? \"single\",\n \"w:color\": color !== undefined ? hexColorValue(color) : undefined,\n });\n return `<w:u ${a}/>`;\n}\n\nfunction eastAsianLayoutStr(opts: EastAsianLayoutOptions): string {\n const a = attrParts({\n \"w:id\": opts.id !== undefined ? decimalNumber(opts.id) : undefined,\n \"w:combine\": opts.combine !== undefined ? (opts.combine ? 1 : 0) : undefined,\n \"w:combineBrackets\": opts.combineBrackets,\n \"w:vert\": opts.vert !== undefined ? (opts.vert ? 1 : 0) : undefined,\n \"w:vertCompress\": opts.vertCompress !== undefined ? (opts.vertCompress ? 1 : 0) : undefined,\n });\n return `<w:eastAsianLayout ${a}/>`;\n}\n\nfunction languageStr(opts: LanguageOptions): string {\n const a = attrParts({\n \"w:val\": opts.value,\n \"w:eastAsia\": opts.eastAsia,\n \"w:bidi\": opts.bidirectional,\n });\n return `<w:lang ${a}/>`;\n}\n\n// ════════════════════════════════════════════════════════════════════════════\n// Paragraph Properties\n// ════════════════════════════════════════════════════════════════════════════\n\nexport interface StringifyPPrResult {\n xml: string | undefined;\n numberingReferences: { reference: string; instance: number }[];\n}\n\n/**\n * Build `<w:pPr>` XML string directly from options — zero IXmlableObject allocation.\n *\n * Replaces `buildParagraphProperties() + xml()` with a single-pass string builder.\n */\nexport function stringifyParagraphProperties(\n options?: ParagraphPropertiesOptions,\n): StringifyPPrResult {\n const numberingReferences: { reference: string; instance: number }[] = [];\n\n if (!options) return { xml: undefined, numberingReferences };\n\n const parts: string[] = [];\n\n // Style / heading / bullet / numbering style references\n if (options.heading) {\n parts.push(`<w:pStyle w:val=\"${escapeXml(options.heading)}\"/>`);\n }\n\n if (options.bullet) {\n parts.push('<w:pStyle w:val=\"ListParagraph\"/>');\n }\n\n if (options.numbering) {\n if (!options.style && !options.heading) {\n if (!options.numbering.custom) {\n parts.push('<w:pStyle w:val=\"ListParagraph\"/>');\n }\n }\n }\n\n if (options.style) {\n parts.push(`<w:pStyle w:val=\"${escapeXml(options.style)}\"/>`);\n }\n\n // On/off properties\n if (options.keepNext !== undefined) parts.push(onOff(\"w:keepNext\", options.keepNext));\n if (options.keepLines !== undefined) parts.push(onOff(\"w:keepLines\", options.keepLines));\n if (options.pageBreakBefore) parts.push(\"<w:pageBreakBefore/>\");\n\n // Frame\n if (options.frame) parts.push(framePrStr(options.frame));\n\n if (options.widowControl !== undefined) parts.push(onOff(\"w:widowControl\", options.widowControl));\n\n // Numbering\n if (options.bullet) {\n parts.push(\n `<w:numPr><w:ilvl w:val=\"${Math.min(options.bullet.level, 9)}\"/><w:numId w:val=\"1\"/></w:numPr>`,\n );\n }\n\n if (options.numbering) {\n numberingReferences.push({\n instance: options.numbering.instance ?? 0,\n reference: options.numbering.reference,\n });\n\n const numId = `${options.numbering.reference}-${options.numbering.instance ?? 0}`;\n parts.push(numPrStr(numId, options.numbering.level, options.numbering.numberingChange));\n } else if (options.numbering === false) {\n parts.push(numPrStr(0, 0));\n }\n\n // Border\n if (options.border) {\n const bParts: string[] = [];\n if (options.border.top) bParts.push(borderStr(\"w:top\", options.border.top));\n if (options.border.left) bParts.push(borderStr(\"w:left\", options.border.left));\n if (options.border.bottom) bParts.push(borderStr(\"w:bottom\", options.border.bottom));\n if (options.border.right) bParts.push(borderStr(\"w:right\", options.border.right));\n if (options.border.between) bParts.push(borderStr(\"w:between\", options.border.between));\n if (options.border.bar) bParts.push(borderStr(\"w:bar\", options.border.bar));\n if (bParts.length) parts.push(`<w:pBdr>${bParts.join(\"\")}</w:pBdr>`);\n }\n\n // Thematic break\n if (options.thematicBreak) {\n parts.push(\n `<w:pBdr>${borderStr(\"w:bottom\", { color: \"auto\", size: 6, space: 1, style: BorderStyle.SINGLE })}</w:pBdr>`,\n );\n }\n\n // Shading\n if (options.shading) parts.push(shadingStr(options.shading));\n\n // Word wrap\n if (options.wordWrap) parts.push('<w:wordWrap w:val=\"0\"/>');\n\n if (options.overflowPunctuation)\n parts.push(onOff(\"w:overflowPunct\", options.overflowPunctuation));\n\n // Tab stops\n const tabDefs: TabStopDefinition[] = [\n ...(options.rightTabStop !== undefined\n ? [{ position: options.rightTabStop, type: \"right\" as const }]\n : []),\n ...(options.tabStops ? options.tabStops : []),\n ...(options.leftTabStop !== undefined\n ? [{ position: options.leftTabStop, type: \"left\" as const }]\n : []),\n ];\n if (tabDefs.length > 0) parts.push(tabStopsStr(tabDefs));\n\n if (options.bidirectional !== undefined) parts.push(onOff(\"w:bidi\", options.bidirectional));\n\n // Spacing\n if (options.spacing) parts.push(spacingStr(options.spacing));\n\n // Indent\n if (options.indent) parts.push(indentStr(options.indent));\n\n if (options.contextualSpacing !== undefined)\n parts.push(onOff(\"w:contextualSpacing\", options.contextualSpacing));\n\n // Alignment\n if (options.alignment) parts.push(`<w:jc w:val=\"${options.alignment}\"/>`);\n\n if (options.outlineLevel !== undefined)\n parts.push(`<w:outlineLvl w:val=\"${options.outlineLevel}\"/>`);\n if (options.divId !== undefined) parts.push(`<w:divId w:val=\"${options.divId}\"/>`);\n\n if (options.cnfStyle) parts.push(cnfStyleStr(options.cnfStyle));\n\n // More on/off properties\n if (options.suppressLineNumbers !== undefined)\n parts.push(onOff(\"w:suppressLineNumbers\", options.suppressLineNumbers));\n if (options.autoSpaceEastAsianText !== undefined)\n parts.push(onOff(\"w:autoSpaceDN\", options.autoSpaceEastAsianText));\n if (options.suppressAutoHyphens !== undefined)\n parts.push(onOff(\"w:suppressAutoHyphens\", options.suppressAutoHyphens));\n if (options.adjustRightInd !== undefined)\n parts.push(onOff(\"w:adjustRightInd\", options.adjustRightInd));\n if (options.snapToGrid !== undefined) parts.push(onOff(\"w:snapToGrid\", options.snapToGrid));\n if (options.mirrorIndents !== undefined)\n parts.push(onOff(\"w:mirrorIndents\", options.mirrorIndents));\n if (options.kinsoku !== undefined) parts.push(onOff(\"w:kinsoku\", options.kinsoku));\n if (options.topLinePunct !== undefined) parts.push(onOff(\"w:topLinePunct\", options.topLinePunct));\n if (options.autoSpaceDE !== undefined) parts.push(onOff(\"w:autoSpaceDE\", options.autoSpaceDE));\n\n if (options.textAlignment !== undefined)\n parts.push(`<w:textAlignment w:val=\"${options.textAlignment}\"/>`);\n if (options.textboxTightWrap !== undefined)\n parts.push(`<w:textboxTightWrap w:val=\"${options.textboxTightWrap}\"/>`);\n if (options.textDirection !== undefined)\n parts.push(`<w:textDirection w:val=\"${options.textDirection}\"/>`);\n if (options.suppressOverlap !== undefined)\n parts.push(onOff(\"w:suppressOverlap\", options.suppressOverlap));\n\n // Embedded run properties (w:rPr inside w:pPr)\n if (options.run) {\n const inner = stringifyRunPropertiesInner(options.run);\n if (inner !== undefined) {\n const extra: string[] = [];\n const runOpts = options.run as ParagraphRunPropertiesOptions;\n if (runOpts.insertion) {\n const { id, author, date } = runOpts.insertion;\n extra.push(`<w:ins w:id=\"${id}\" w:author=\"${escapeXml(author)}\" w:date=\"${date}\"/>`);\n }\n if (runOpts.deletion) {\n const { id, author, date } = runOpts.deletion;\n extra.push(`<w:del w:id=\"${id}\" w:author=\"${escapeXml(author)}\" w:date=\"${date}\"/>`);\n }\n const body = inner + extra.join(\"\");\n parts.push(`<w:rPr>${body}</w:rPr>`);\n }\n }\n\n // Revision (pPrChange)\n if (options.revision) {\n const rev = options.revision;\n const { author: _a, date: _d, id: _i, ...originalProps } = rev;\n const inner = stringifyParagraphProperties({ ...originalProps, includeIfEmpty: true });\n parts.push(\n `<w:pPrChange w:author=\"${escapeXml(rev.author)}\" w:date=\"${rev.date}\" w:id=\"${rev.id}\">${inner.xml ?? \"<w:pPr/>\"}</w:pPrChange>`,\n );\n }\n\n const body = parts.join(\"\");\n const xml = options.includeIfEmpty || body.length > 0 ? `<w:pPr>${body}</w:pPr>` : undefined;\n return { xml, numberingReferences };\n}\n\n// ════════════════════════════════════════════════════════════════════════════\n// Run Properties\n// ════════════════════════════════════════════════════════════════════════════\n\n/**\n * Build the inner content of `<w:rPr>` as a string.\n * Returns undefined if no properties are set.\n */\nexport function stringifyRunPropertiesInner(opts?: RunPropertiesOptions): string | undefined {\n if (!opts) return undefined;\n\n const parts: string[] = [];\n\n // Style\n if (opts.style) parts.push(`<w:rStyle w:val=\"${escapeXml(opts.style)}\"/>`);\n\n // Font\n if (opts.font) {\n if (typeof opts.font === \"string\") {\n parts.push(runFontsStr(opts.font));\n } else if (\"name\" in opts.font) {\n parts.push(runFontsStr(opts.font.name, opts.font.hint));\n } else {\n parts.push(runFontsStr(opts.font));\n }\n }\n\n // Bold\n if (opts.bold !== undefined) parts.push(onOff(\"w:b\", opts.bold));\n const bCs =\n (opts.boldComplexScript === undefined && opts.bold !== undefined) || opts.boldComplexScript;\n if (bCs !== undefined) parts.push(onOff(\"w:bCs\", opts.boldComplexScript ?? opts.bold!));\n\n // Italic\n if (opts.italic !== undefined) parts.push(onOff(\"w:i\", opts.italic));\n const iCs =\n (opts.italicComplexScript === undefined && opts.italic !== undefined) ||\n opts.italicComplexScript;\n if (iCs !== undefined) parts.push(onOff(\"w:iCs\", opts.italicComplexScript ?? opts.italic!));\n\n // Caps\n if (opts.smallCaps !== undefined) {\n parts.push(onOff(\"w:smallCaps\", opts.smallCaps));\n } else if (opts.allCaps !== undefined) {\n parts.push(onOff(\"w:caps\", opts.allCaps));\n }\n\n // Strike\n if (opts.strike !== undefined) parts.push(onOff(\"w:strike\", opts.strike));\n if (opts.doubleStrike !== undefined) parts.push(onOff(\"w:dstrike\", opts.doubleStrike));\n if (opts.emboss !== undefined) parts.push(onOff(\"w:emboss\", opts.emboss));\n if (opts.imprint !== undefined) parts.push(onOff(\"w:imprint\", opts.imprint));\n if (opts.outline !== undefined) parts.push(onOff(\"w:outline\", opts.outline));\n if (opts.shadow !== undefined) parts.push(onOff(\"w:shadow\", opts.shadow));\n if (opts.webHidden !== undefined) parts.push(onOff(\"w:webHidden\", opts.webHidden));\n if (opts.noProof !== undefined) parts.push(onOff(\"w:noProof\", opts.noProof));\n if (opts.snapToGrid !== undefined) parts.push(onOff(\"w:snapToGrid\", opts.snapToGrid));\n if (opts.vanish) parts.push(onOff(\"w:vanish\", opts.vanish));\n\n // Color\n if (opts.color) parts.push(colorStr(opts.color));\n\n // Character spacing\n if (opts.characterSpacing) {\n parts.push(`<w:spacing w:val=\"${signedTwipsMeasureValue(opts.characterSpacing)}\"/>`);\n }\n\n // Scale\n if (opts.scale !== undefined) parts.push(`<w:w w:val=\"${opts.scale}\"/>`);\n\n // Kern\n if (opts.kern) parts.push(`<w:kern w:val=\"${hpsMeasureValue(opts.kern)}\"/>`);\n\n // Position\n if (opts.position) parts.push(`<w:position w:val=\"${opts.position}\"/>`);\n\n // Size (points → half-points)\n if (opts.size !== undefined) parts.push(`<w:sz w:val=\"${hpsMeasureValue(opts.size * 2)}\"/>`);\n const szCs =\n opts.sizeComplexScript === undefined || opts.sizeComplexScript === true\n ? opts.size\n : opts.sizeComplexScript;\n if (szCs) parts.push(`<w:szCs w:val=\"${hpsMeasureValue((szCs as number) * 2)}\"/>`);\n\n // Highlight\n if (opts.highlight) parts.push(`<w:highlight w:val=\"${opts.highlight}\"/>`);\n if (opts.highlightComplexScript === true) {\n if (opts.highlight) parts.push(`<w:highlightCs w:val=\"${opts.highlight}\"/>`);\n } else if (opts.highlightComplexScript !== undefined && opts.highlightComplexScript !== false) {\n parts.push(`<w:highlightCs w:val=\"${opts.highlightComplexScript}\"/>`);\n }\n\n // Underline\n if (opts.underline) parts.push(underlineStr(opts.underline.type, opts.underline.color));\n\n // Effect\n if (opts.effect) parts.push(`<w:effect w:val=\"${opts.effect}\"/>`);\n\n // Border\n if (opts.border) parts.push(borderStr(\"w:bdr\", opts.border));\n\n // Shading\n if (opts.shading) parts.push(shadingStr(opts.shading));\n\n // Vertical alignment\n if (opts.subScript) parts.push('<w:vertAlign w:val=\"subscript\"/>');\n if (opts.superScript) parts.push('<w:vertAlign w:val=\"superscript\"/>');\n\n // RTL\n if (opts.rightToLeft !== undefined) parts.push(onOff(\"w:rtl\", opts.rightToLeft));\n\n // Emphasis mark\n if (opts.emphasisMark) parts.push(`<w:em w:val=\"${opts.emphasisMark.type ?? \"dot\"}\"/>`);\n\n // Language\n if (opts.language) parts.push(languageStr(opts.language));\n\n // Spec vanish\n if (opts.specVanish) parts.push(\"<w:specVanish/>\");\n\n // Math\n if (opts.math) parts.push(onOff(\"w:oMath\", opts.math));\n\n // Fit text\n if (opts.fitText !== undefined) parts.push(`<w:fitText w:val=\"${opts.fitText}\"/>`);\n\n // Complex script\n if (opts.complexScript !== undefined) parts.push(onOff(\"w:cs\", opts.complexScript));\n\n // East Asian layout\n if (opts.eastAsianLayout) parts.push(eastAsianLayoutStr(opts.eastAsianLayout));\n\n // Content part\n if (opts.contentPartRId) parts.push(`<w:contentPart r:id=\"${opts.contentPartRId}\"/>`);\n\n // Revision (rPrChange)\n if (opts.revision) {\n const rev = opts.revision as RunPropertiesChangeOptions;\n const { author: _a, date: _d, id: _i, ...originalProps } = rev;\n const inner = stringifyRunPropertiesInner(originalProps as RunPropertiesOptions);\n parts.push(\n `<w:rPrChange w:author=\"${escapeXml(rev.author)}\" w:date=\"${rev.date}\" w:id=\"${rev.id}\"><w:rPr>${inner ?? \"\"}</w:rPr></w:rPrChange>`,\n );\n }\n\n return parts.length > 0 ? parts.join(\"\") : undefined;\n}\n\n/**\n * Build `<w:rPr>` XML string directly from options — zero IXmlableObject allocation.\n *\n * Replaces `buildRunProperties() + xml()` with a single-pass string builder.\n */\nexport function stringifyRunProperties(opts?: RunPropertiesOptions): string | undefined {\n const inner = stringifyRunPropertiesInner(opts);\n return inner ? `<w:rPr>${inner}</w:rPr>` : undefined;\n}\n","/**\n * Shared inline run/paragraph stringification for DOCX descriptors.\n *\n * Used by table.ts, comments.ts, body.ts, and other descriptors that need to\n * serialize paragraph/run content. Includes JSON child dispatch for all\n * ParagraphChild variants (image, chart, hyperlink, etc.).\n *\n * Pure string concatenation — zero IXmlableObject, zero BaseXmlComponent.\n *\n * @module\n */\n\nimport { toUint8Array } from \"@office-open/core\";\nimport { TargetModeType } from \"@office-open/core\";\nimport { uniqueId } from \"@office-open/core\";\nimport { chartSpaceDesc } from \"@office-open/core/chart\";\nimport type { SourceRectangleOptions } from \"@office-open/core/drawingml\";\nimport { createDataModel } from \"@office-open/core/smartart\";\nimport { escapeXml } from \"@office-open/xml\";\nimport type { ParagraphChild, ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { ImageOptions } from \"@parts/paragraph/run/image-run\";\nimport type { RubyOptions } from \"@parts/paragraph/run/ruby\";\nimport type { RunOptions } from \"@parts/paragraph/run/run\";\nimport type { SmartArtOptions } from \"@parts/paragraph/run/smartart-run\";\nimport type { ChartMediaData, MediaData, SmartArtMediaData, WpsMediaData } from \"@shared/media\";\nimport { createTransformation } from \"@shared/media\";\n\nimport type { BodyContext } from \"../context\";\nimport { drawingDesc } from \"./drawing\";\nimport { stringifyMath } from \"./paragraph/math/stringify\";\nimport { createBegin, createSeparate, createEnd } from \"./paragraph/run/field\";\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"./paragraph/stringify\";\n\n// ── Run ──\n\nexport function stringifyRunInline(opts: RunOptions, ctx: BodyContext): string {\n const parts: string[] = [];\n\n const rPr = stringifyRunProperties(opts);\n if (rPr) parts.push(rPr);\n\n if (opts.break) {\n for (let i = 0; i < opts.break; i++) parts.push(\"<w:br/>\");\n }\n\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"string\") {\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(child)}</w:t>`);\n } else {\n // JSON child dispatch\n const jsonResult = stringifyChildDispatch(child as ParagraphChild, ctx);\n if (jsonResult !== undefined) {\n if (Array.isArray(jsonResult)) {\n parts.push(...jsonResult);\n } else {\n parts.push(jsonResult);\n }\n } else if (\"text\" in child || \"children\" in child || \"break\" in child) {\n parts.push(stringifyRunInline(child as RunOptions, ctx));\n }\n }\n }\n } else if (opts.text !== undefined) {\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(String(opts.text))}</w:t>`);\n }\n\n const rsidAttrs: string[] = [];\n if (opts.rsidRPr) rsidAttrs.push(` w:rsidRPr=\"${opts.rsidRPr}\"`);\n if (opts.rsidDel) rsidAttrs.push(` w:rsidDel=\"${opts.rsidDel}\"`);\n const attr = rsidAttrs.join(\"\");\n\n const body = parts.join(\"\");\n return body.length === 0 ? (attr ? `<w:r${attr}/>` : \"<w:r/>\") : `<w:r${attr}>${body}</w:r>`;\n}\n\n// ── Image helpers ──\n\nfunction createImageData(\n data: Uint8Array,\n transformation: ImageOptions[\"transformation\"],\n key: string,\n srcRect?: SourceRectangleOptions,\n): Pick<MediaData, \"data\" | \"fileName\" | \"transformation\" | \"srcRect\"> {\n return {\n data,\n fileName: key,\n srcRect,\n transformation: createTransformation(transformation),\n };\n}\n\nlet nextChartId = 1;\n\n// ── JSON child dispatch ──\n\n/**\n * Stringify a ParagraphChild into one or more XML strings.\n *\n * Handles side effects (media, chart, smartArt, relationship registration)\n * directly without creating temporary class instances.\n *\n * Returns `undefined` if the child is not a recognized JSON wrapper.\n */\nexport function stringifyChildDispatch(\n child: ParagraphChild,\n ctx: BodyContext,\n): string | string[] | undefined {\n // Simple break types — pure XML, no side effects\n if (\"pageBreak\" in child) return '<w:r><w:br w:type=\"page\"/></w:r>';\n if (\"columnBreak\" in child) return '<w:r><w:br w:type=\"column\"/></w:r>';\n if (\"tab\" in child) return \"<w:r><w:tab/></w:r>\";\n\n // Reference types — pure XML, no side effects\n if (\"footnoteReference\" in child)\n return `<w:r><w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr><w:footnoteReference w:id=\"${child.footnoteReference}\"/></w:r>`;\n if (\"endnoteReference\" in child)\n return `<w:r><w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr><w:endnoteReference w:id=\"${child.endnoteReference}\"/></w:r>`;\n\n // Comment markers — pure XML\n if (\"commentRangeStart\" in child)\n return `<w:commentRangeStart w:id=\"${child.commentRangeStart}\"/>`;\n if (\"commentRangeEnd\" in child) return `<w:commentRangeEnd w:id=\"${child.commentRangeEnd}\"/>`;\n if (\"commentReference\" in child)\n return `<w:r><w:rPr><w:rStyle w:val=\"CommentReference\"/></w:rPr><w:commentReference w:id=\"${child.commentReference}\"/></w:r>`;\n\n // Bookmark markers — pure XML\n if (\"bookmarkStart\" in child)\n return `<w:bookmarkStart w:id=\"${child.bookmarkStart.id}\" w:name=\"${child.bookmarkStart.name}\"/>`;\n if (\"bookmarkEnd\" in child) return `<w:bookmarkEnd w:id=\"${child.bookmarkEnd}\"/>`;\n\n // Symbol run — direct XML output.\n // <w:sym> is a self-closing element, not text: emit it directly so it is\n // not escaped into a <w:t> by the run children path.\n if (\"symbolRun\" in child) {\n const opts = child.symbolRun;\n const rPr = stringifyRunProperties(opts) ?? \"\";\n return `<w:r>${rPr}<w:sym w:char=\"${opts.char}\" w:font=\"${opts.symbolfont ?? \"Wingdings\"}\"/></w:r>`;\n }\n\n // Form field (checkbox / dropdown list / text input) — fldChar sequence.\n // Word needs the field code (instrText) between begin and separate to\n // recognize the field type and render its result.\n if (\"formField\" in child) {\n const ff = child.formField;\n let result = \"\";\n let instrCode = \"\";\n let symbolFont = false;\n if (ff.checkBox) {\n result = ff.checkBox.checked ? \"☒\" : \"☐\";\n instrCode = \"FORMCHECKBOX\";\n // U+2610/U+2612 are absent from common body fonts (Calibri/Times);\n // MS Gothic holds them and matches the SDT w14:checkbox default.\n symbolFont = true;\n } else if (ff.dropDownList) {\n const idx = ff.dropDownList.result ?? ff.dropDownList.default;\n result = idx !== undefined ? (ff.dropDownList.entries[idx] ?? \"\") : \"\";\n instrCode = \"FORMDROPDOWN\";\n } else if (ff.textInput) {\n // Prefer the user-entered value (result run) over the placeholder default.\n result = ff.textInput.value ?? ff.textInput.default ?? \"\";\n instrCode = \"FORMTEXT\";\n }\n const rPr = symbolFont\n ? '<w:rPr><w:rFonts w:ascii=\"MS Gothic\" w:hAnsi=\"MS Gothic\"/></w:rPr>'\n : \"\";\n return (\n `<w:r>${createBegin(false, ff)}</w:r>` +\n `<w:r><w:instrText xml:space=\"preserve\"> ${instrCode} </w:instrText></w:r>` +\n `<w:r>${createSeparate()}</w:r>` +\n `<w:r>${rPr}<w:t xml:space=\"preserve\">${escapeXml(result)}</w:t></w:r>` +\n `<w:r>${createEnd()}</w:r>`\n );\n }\n\n // Image — side effect: media registration\n if (\"image\" in child) {\n const opts = child.image;\n const key = `${uniqueId()}.${opts.type}`;\n const rawData = toUint8Array(opts.data) as Uint8Array;\n\n let mediaData: MediaData;\n if (opts.type === \"svg\") {\n const fallbackData = toUint8Array(opts.fallback.data) as Uint8Array;\n mediaData = {\n type: \"svg\",\n ...createImageData(rawData, opts.transformation, key, opts.srcRect),\n fallback: {\n type: opts.fallback.type,\n ...createImageData(\n fallbackData,\n opts.transformation,\n `${uniqueId()}.${opts.fallback.type}`,\n ),\n },\n } as MediaData;\n } else {\n mediaData = {\n type: opts.type,\n ...createImageData(rawData, opts.transformation, key, opts.srcRect),\n } as MediaData;\n }\n\n // Register media\n ctx.file.media.addImage(mediaData.fileName, mediaData);\n if (mediaData.type === \"svg\") {\n ctx.file.media.addImage(mediaData.fallback.fileName, mediaData.fallback);\n }\n\n // Build drawing XML via descriptor (zero XmlComponent instances)\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n },\n ctx,\n );\n return `<w:r>${drawingXml}</w:r>`;\n }\n\n // Chart — side effect: chart registration\n if (\"chart\" in child) {\n const opts = child.chart;\n const chartKey = `chart_${nextChartId++}`;\n const mediaData: ChartMediaData = {\n chartKey,\n transformation: createTransformation(opts.transformation),\n type: \"chart\",\n };\n\n // Register chart\n const chartXml = chartSpaceDesc.stringify(\n {\n categories: opts.categories,\n series: opts.series,\n showLegend: opts.showLegend,\n style: opts.style,\n title: opts.title,\n type: opts.type,\n threeD: opts.threeD,\n },\n ctx.file,\n );\n ctx.file.charts.addChart(chartKey, {\n key: chartKey,\n chartSpaceXml: chartXml ?? \"\",\n });\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n },\n ctx,\n );\n return `<w:r>${drawingXml}</w:r>`;\n }\n\n // SmartArt — side effect: smartArt registration\n if (\"smartArt\" in child) {\n const opts = child.smartArt;\n const hash = hashSmartArtData(opts);\n const smartArtKey = `smartart_${hash}`;\n const mediaData: SmartArtMediaData = {\n smartArtKey,\n transformation: createTransformation(opts.transformation),\n type: \"smartart\",\n };\n\n // Register SmartArt\n const layoutId = opts.layout ?? \"default\";\n const styleId = opts.style ?? \"simple1\";\n const colorId = opts.color ?? \"accent1_2\";\n const dataModelXml = createDataModel(opts.data.nodes, layoutId, styleId, colorId);\n\n ctx.file.smartArts.addSmartArt(smartArtKey, {\n dataModelXml,\n key: smartArtKey,\n layout: layoutId,\n style: styleId,\n color: colorId,\n });\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n },\n ctx,\n );\n return `<w:r>${drawingXml}</w:r>`;\n }\n\n // WPS Shape (WordProcessing Shape) — side effect: blip fill media registration\n if (\"wpsShape\" in child) {\n const opts = child.wpsShape;\n const mediaData: WpsMediaData = {\n data: opts,\n transformation: createTransformation(opts.transformation),\n type: \"wps\",\n };\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n outline: opts.outline,\n fill: opts.fill,\n },\n ctx,\n );\n return `<w:r>${drawingXml}</w:r>`;\n }\n\n // Ruby annotation — pure string concatenation\n if (\"ruby\" in child && typeof child.ruby === \"object\" && child.ruby !== null) {\n const r = child.ruby as RubyOptions;\n const align = r.alignment ?? \"center\";\n const hps = (r.fontSize ?? 10) * 2;\n const hpsRaise = (r.raise ?? 10) * 2;\n const hpsBaseText = (r.baseFontSize ?? 20) * 2;\n const lid = r.languageId ?? \"ja-JP\";\n\n const prParts = [\n `<w:rubyAlign w:val=\"${align}\"/>`,\n `<w:hps w:val=\"${hps}\"/>`,\n `<w:hpsRaise w:val=\"${hpsRaise}\"/>`,\n `<w:hpsBaseText w:val=\"${hpsBaseText}\"/>`,\n `<w:lid w:val=\"${lid}\"/>`,\n ];\n if (r.dirty) prParts.push(\"<w:dirty/>\");\n\n const rt = `<w:rt><w:r><w:t xml:space=\"preserve\">${escapeXml(r.text)}</w:t></w:r></w:rt>`;\n const rubyBase = `<w:rubyBase><w:r><w:t xml:space=\"preserve\">${escapeXml(r.base)}</w:t></w:r></w:rubyBase>`;\n\n return `<w:ruby><w:rubyPr>${prParts.join(\"\")}</w:rubyPr>${rt}${rubyBase}</w:ruby>`;\n }\n\n // Math — pure string concatenation\n if (\"math\" in child && typeof child.math === \"object\" && child.math !== null) {\n const mathOpts = child.math;\n const children = mathOpts.children ?? [];\n return stringifyMath(children);\n }\n\n // Inserted text run — pure function\n if (\"insertion\" in child) {\n const opts = child.insertion;\n const { id, author, date, ...runOpts } = opts;\n const runXml = stringifyRunInline(runOpts, ctx);\n return `<w:ins w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${runXml}</w:ins>`;\n }\n\n // Deleted text run — pure function\n if (\"deletion\" in child) {\n const opts = child.deletion;\n const { id, author, date, ...runOpts } = opts;\n\n const parts: string[] = [];\n const rPr = stringifyRunProperties(runOpts);\n if (rPr) parts.push(rPr);\n\n if (runOpts.break) {\n for (let i = 0; i < runOpts.break; i++) parts.push(\"<w:br/>\");\n }\n\n if (runOpts.children) {\n for (const c of runOpts.children) {\n if (typeof c === \"string\") {\n // Page number fields use delInstrText instead of instrText\n const fieldMap: Record<string, string> = {\n CURRENT: \"PAGE\",\n TOTAL_PAGES: \"NUMPAGES\",\n TOTAL_PAGES_IN_SECTION: \"SECTIONPAGES\",\n };\n const instrText = fieldMap[c];\n if (instrText) {\n parts.push(\n '<w:fldChar w:fldCharType=\"begin\"/>' +\n `<w:delInstrText xml:space=\"preserve\">${instrText}</w:delInstrText>` +\n '<w:fldChar w:fldCharType=\"separate\"/>' +\n '<w:fldChar w:fldCharType=\"end\"/>',\n );\n } else {\n parts.push(`<w:delText xml:space=\"preserve\">${escapeXml(c)}</w:delText>`);\n }\n }\n }\n } else if (runOpts.text) {\n parts.push(`<w:delText xml:space=\"preserve\">${escapeXml(String(runOpts.text))}</w:delText>`);\n }\n\n const runBody = parts.join(\"\");\n return `<w:del w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\"><w:r>${runBody}</w:r></w:del>`;\n }\n\n // Hyperlink — side effect: relationship registration\n if (\"hyperlink\" in child) {\n const hl = child.hyperlink;\n\n // Serialize children using stringifyRunInline\n const childParts: string[] = [];\n if (hl.children) {\n for (const rc of hl.children) {\n if (typeof rc === \"string\") {\n childParts.push(stringifyRunInline({ text: rc }, ctx));\n } else {\n childParts.push(stringifyRunInline(rc, ctx));\n }\n }\n }\n const body = childParts.join(\"\");\n\n if (hl.link) {\n const linkId = uniqueId();\n ctx.viewWrapper.relationships.addRelationship(\n linkId,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\",\n hl.link,\n TargetModeType.EXTERNAL,\n );\n const attrs = [`r:id=\"rId${linkId}\"`, 'w:history=\"1\"'];\n if (hl.tooltip) attrs.push(`w:tooltip=\"${escapeXml(hl.tooltip)}\"`);\n return `<w:hyperlink ${attrs.join(\" \")}>${body}</w:hyperlink>`;\n }\n if (hl.anchor) {\n const attrs = [`w:anchor=\"${escapeXml(hl.anchor)}\"`, 'w:history=\"1\"'];\n if (hl.tooltip) attrs.push(`w:tooltip=\"${escapeXml(hl.tooltip)}\"`);\n return `<w:hyperlink ${attrs.join(\" \")}>${body}</w:hyperlink>`;\n }\n return \"\";\n }\n\n // ── Proof error markers ──\n if (\"proofErr\" in child) return `<w:proofErr w:type=\"${child.proofErr}\"/>`;\n\n // ── Positional tab ──\n if (\"positionalTab\" in child) {\n const pt = child.positionalTab;\n return `<w:ptab w:alignment=\"${pt.alignment}\" w:leader=\"${pt.leader}\" w:relativeTo=\"${pt.relativeTo}\"/>`;\n }\n\n // ── Permission range markers ──\n if (\"permStart\" in child) {\n const ps = child.permStart;\n const a: string[] = [`w:id=\"${ps.id}\"`];\n if (ps.ed !== undefined) a.push(`w:ed=\"${escapeXml(String(ps.ed))}\"`);\n if (ps.editGroup !== undefined) a.push(`w:edGrp=\"${ps.editGroup}\"`);\n if (ps.colFirst !== undefined) a.push(`w:colFirst=\"${ps.colFirst}\"`);\n if (ps.colLast !== undefined) a.push(`w:colLast=\"${ps.colLast}\"`);\n return `<w:permStart ${a.join(\" \")}/>`;\n }\n if (\"permEnd\" in child) return `<w:permEnd w:id=\"${child.permEnd}\"/>`;\n\n // ── Move revision range markers ──\n if (\"moveFromRangeStart\" in child) {\n const m = child.moveFromRangeStart;\n const a: string[] = [`w:id=\"${m.id}\"`];\n if (m.name) a.push(`w:name=\"${escapeXml(m.name)}\"`);\n if (m.author) a.push(`w:author=\"${escapeXml(m.author)}\"`);\n if (m.date) a.push(`w:date=\"${m.date}\"`);\n return `<w:moveFromRangeStart ${a.join(\" \")}/>`;\n }\n if (\"moveFromRangeEnd\" in child) return `<w:moveFromRangeEnd w:id=\"${child.moveFromRangeEnd}\"/>`;\n if (\"moveToRangeStart\" in child) {\n const m = child.moveToRangeStart;\n const a: string[] = [`w:id=\"${m.id}\"`];\n if (m.name) a.push(`w:name=\"${escapeXml(m.name)}\"`);\n if (m.author) a.push(`w:author=\"${escapeXml(m.author)}\"`);\n if (m.date) a.push(`w:date=\"${m.date}\"`);\n return `<w:moveToRangeStart ${a.join(\" \")}/>`;\n }\n if (\"moveToRangeEnd\" in child) return `<w:moveToRangeEnd w:id=\"${child.moveToRangeEnd}\"/>`;\n\n // ── Move revision text runs ──\n if (\"movedFrom\" in child) {\n const opts = child.movedFrom;\n const { id, author, date, ...runOpts } = opts;\n const runXml = stringifyRunInline(runOpts, ctx);\n return `<w:moveFrom w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${runXml}</w:moveFrom>`;\n }\n if (\"movedTo\" in child) {\n const opts = child.movedTo;\n const { id, author, date, ...runOpts } = opts;\n const runXml = stringifyRunInline(runOpts, ctx);\n return `<w:moveTo w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${runXml}</w:moveTo>`;\n }\n\n // ── Custom XML range markers (track changes) ──\n if (\"customXmlInsRangeStart\" in child) {\n const o = child.customXmlInsRangeStart;\n return `<w:customXmlInsRangeStart w:id=\"${o.id}\" w:author=\"${escapeXml(o.author)}\"${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlInsRangeEnd\" in child)\n return `<w:customXmlInsRangeEnd w:id=\"${child.customXmlInsRangeEnd}\"/>`;\n if (\"customXmlDelRangeStart\" in child) {\n const o = child.customXmlDelRangeStart;\n return `<w:customXmlDelRangeStart w:id=\"${o.id}\" w:author=\"${escapeXml(o.author)}\"${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlDelRangeEnd\" in child)\n return `<w:customXmlDelRangeEnd w:id=\"${child.customXmlDelRangeEnd}\"/>`;\n if (\"customXmlMoveFromRangeStart\" in child) {\n const o = child.customXmlMoveFromRangeStart;\n return `<w:customXmlMoveFromRangeStart w:id=\"${o.id}\" w:author=\"${escapeXml(o.author)}\"${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlMoveFromRangeEnd\" in child)\n return `<w:customXmlMoveFromRangeEnd w:id=\"${child.customXmlMoveFromRangeEnd}\"/>`;\n if (\"customXmlMoveToRangeStart\" in child) {\n const o = child.customXmlMoveToRangeStart;\n return `<w:customXmlMoveToRangeStart w:id=\"${o.id}\" w:author=\"${escapeXml(o.author)}\"${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlMoveToRangeEnd\" in child)\n return `<w:customXmlMoveToRangeEnd w:id=\"${child.customXmlMoveToRangeEnd}\"/>`;\n\n // ── Simple field ──\n if (\"simpleField\" in child) {\n const sf = child.simpleField;\n if (sf.cachedValue !== undefined) {\n return `<w:fldSimple w:instr=\"${escapeXml(sf.instruction)}\"><w:r><w:t>${escapeXml(sf.cachedValue)}</w:t></w:r></w:fldSimple>`;\n }\n return `<w:fldSimple w:instr=\"${escapeXml(sf.instruction)}\"/>`;\n }\n\n // ── Complex field (PAGE/DATE/TOC/... — fldChar field without w:ffData) ──\n if (\"complexField\" in child) {\n const cf = child.complexField;\n // `separate` + the result run are emitted only when there is a cached\n // result; a result-less field round-trips as begin/instrText/end.\n const resultXml =\n cf.result !== undefined\n ? '<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>' +\n `<w:r><w:t xml:space=\"preserve\">${escapeXml(cf.result)}</w:t></w:r>`\n : \"\";\n return (\n '<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>' +\n `<w:r><w:instrText xml:space=\"preserve\">${escapeXml(cf.instruction)}</w:instrText></w:r>` +\n resultXml +\n '<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>'\n );\n }\n\n // ── Sequential identifier (SEQ field) ──\n if (\"seqIdentifier\" in child) {\n const id = child.seqIdentifier;\n return (\n \"<w:r>\" +\n '<w:fldChar w:fldCharType=\"begin\"/>' +\n `<w:instrText xml:space=\"preserve\"> SEQ ${escapeXml(id)} </w:instrText>` +\n '<w:fldChar w:fldCharType=\"separate\"/>' +\n '<w:fldChar w:fldCharType=\"end\"/>' +\n \"</w:r>\"\n );\n }\n\n // ── Page reference (PAGEREF field) ──\n if (\"pageReference\" in child) {\n const pr = child.pageReference;\n let instr = ` PAGEREF ${escapeXml(pr.bookmarkId)} `;\n if (pr.hyperlink) instr += \"\\\\h \";\n if (pr.useRelativePosition) instr += \"\\\\p \";\n return (\n \"<w:r>\" +\n '<w:fldChar w:fldCharType=\"begin\"/>' +\n `<w:instrText xml:space=\"preserve\">${instr}</w:instrText>` +\n '<w:fldChar w:fldCharType=\"end\"/>' +\n \"</w:r>\"\n );\n }\n\n // ── Bidirectional text containers ──\n if (\"dir\" in child) {\n const d = child.dir;\n const childXml = serializeDirChildren(d.children, ctx);\n return `<w:dir w:val=\"${d.val}\">${childXml}</w:dir>`;\n }\n if (\"bdo\" in child) {\n const b = child.bdo;\n const childXml = serializeDirChildren(b.children, ctx);\n return `<w:bdo w:val=\"${b.val}\">${childXml}</w:bdo>`;\n }\n\n // ── Smart tag ──\n if (\"smartTag\" in child) {\n const st = child.smartTag;\n const attrs: string[] = [];\n if (st.uri) attrs.push(`w:uri=\"${escapeXml(st.uri)}\"`);\n attrs.push(`w:element=\"${escapeXml(st.element)}\"`);\n\n const parts: string[] = [];\n if (st.properties?.length) {\n const propParts: string[] = [];\n for (const p of st.properties) {\n const pa: string[] = [];\n if (p.uri) pa.push(`w:uri=\"${escapeXml(p.uri)}\"`);\n pa.push(`w:name=\"${escapeXml(p.name)}\"`, `w:val=\"${escapeXml(p.val)}\"`);\n propParts.push(`<w:attr ${pa.join(\" \")}/>`);\n }\n parts.push(`<w:smartTagPr>${propParts.join(\"\")}</w:smartTagPr>`);\n }\n if (st.children) {\n for (const c of st.children) {\n parts.push(\n typeof c === \"string\" ? stringifyRunInline({ text: c }, ctx) : stringifyRunInline(c, ctx),\n );\n }\n }\n return `<w:smartTag ${attrs.join(\" \")}>${parts.join(\"\")}</w:smartTag>`;\n }\n\n // ── Custom XML run ──\n if (\"customXml\" in child) {\n const cx = child.customXml;\n const attrs: string[] = [`w:element=\"${escapeXml(cx.element)}\"`];\n if (cx.uri) attrs.push(`w:uri=\"${escapeXml(cx.uri)}\"`);\n\n const parts: string[] = [];\n if (cx.customXmlPr) {\n const prParts: string[] = [];\n if (cx.customXmlPr.placeholder)\n prParts.push(`<w:placeholder w:val=\"${escapeXml(cx.customXmlPr.placeholder)}\"/>`);\n if (cx.customXmlPr.attrs?.length) {\n for (const a of cx.customXmlPr.attrs) {\n const aa: string[] = [`w:name=\"${escapeXml(a.name)}\"`, `w:val=\"${escapeXml(a.val)}\"`];\n if (a.uri) aa.push(`w:uri=\"${escapeXml(a.uri)}\"`);\n prParts.push(`<w:attr ${aa.join(\" \")}/>`);\n }\n }\n if (prParts.length) parts.push(`<w:customXmlPr>${prParts.join(\"\")}</w:customXmlPr>`);\n }\n if (cx.children) {\n for (const c of cx.children) {\n if (typeof c === \"string\") {\n parts.push(stringifyRunInline({ text: c }, ctx));\n } else {\n const jr = stringifyChildDispatch(c as ParagraphChild, ctx);\n if (jr !== undefined) {\n parts.push(Array.isArray(jr) ? jr.join(\"\") : jr);\n } else {\n parts.push(stringifyRunInline(c as RunOptions, ctx));\n }\n }\n }\n }\n return `<w:customXml ${attrs.join(\" \")}>${parts.join(\"\")}</w:customXml>`;\n }\n\n return undefined;\n}\n\n/** Serialize children of Dir/Bdo containers. */\nfunction serializeDirChildren(\n children: (RunOptions | string)[] | undefined,\n ctx: BodyContext,\n): string {\n if (!children) return \"\";\n const parts: string[] = [];\n for (const c of children) {\n if (typeof c === \"string\") {\n parts.push(stringifyRunInline({ text: c }, ctx));\n } else {\n parts.push(stringifyRunInline(c, ctx));\n }\n }\n return parts.join(\"\");\n}\n\n/** Hash SmartArt data for unique key generation (duplicated from SmartArtRun). */\nfunction hashSmartArtData(options: SmartArtOptions): number {\n const data = JSON.stringify(options.data);\n let hash = 0;\n for (let i = 0; i < data.length; i++) {\n const char = data.charCodeAt(i);\n hash = ((hash << 5) - hash + char) | 0;\n }\n return Math.abs(hash);\n}\n\n// ── Paragraph ──\n\nexport function stringifyParagraphInline(\n opts: string | ParagraphOptions,\n ctx: BodyContext,\n): string {\n const resolved: ParagraphOptions = typeof opts === \"string\" ? { text: opts } : opts;\n const parts: string[] = [];\n\n const props = stringifyParagraphProperties(resolved);\n if (props.xml) parts.push(props.xml);\n\n // Register numbering references from inline paragraphs (footnotes, endnotes, etc.)\n // so that concrete numbering instances are created and placeholders get resolved.\n if (props.numberingReferences.length > 0) {\n for (const ref of props.numberingReferences) {\n ctx.file.numbering.createConcreteNumberingInstance(ref.reference, ref.instance);\n }\n }\n\n if (resolved.text !== undefined) {\n parts.push(stringifyRunInline({ text: resolved.text }, ctx));\n }\n\n if (resolved.children) {\n for (const child of resolved.children) {\n if (typeof child === \"string\") {\n parts.push(stringifyRunInline({ text: child }, ctx));\n } else if (typeof child === \"object\" && child !== null) {\n // Try JSON child dispatch first (image, chart, hyperlink, etc.)\n const jsonResult = stringifyChildDispatch(child as ParagraphChild, ctx);\n if (jsonResult !== undefined) {\n if (Array.isArray(jsonResult)) {\n parts.push(...jsonResult);\n } else {\n parts.push(jsonResult);\n }\n } else if (\"text\" in child || \"children\" in child || \"break\" in child) {\n parts.push(stringifyRunInline(child as RunOptions, ctx));\n }\n }\n }\n }\n\n const body = parts.join(\"\");\n return body ? `<w:p>${body}</w:p>` : \"<w:p/>\";\n}\n","/**\n * Direct XML string builders for table properties.\n *\n * Replaces `buildTableProperties() + xml()`, `buildTableRowProperties() + xml()`,\n * `buildTableCellProperties() + xml()`, and `new TablePropertyExceptions().toXml()`\n * with direct string concatenation — zero IXmlableObject allocation.\n *\n * @module\n */\n\nimport { xsdVerticalMergeRev } from \"@office-open/core\";\nimport {\n measurementOrPercentValue,\n signedTwipsMeasureValue,\n twipsMeasureValue,\n} from \"@office-open/core\";\nimport type { AlignmentType } from \"@parts/paragraph\";\nimport type { TableCellSpacingProperties } from \"@parts/table/table-cell-spacing\";\nimport type {\n TableCellBordersOptions,\n TextDirection,\n} from \"@parts/table/table-cell/table-cell-components\";\nimport { VerticalMergeType } from \"@parts/table/table-cell/table-cell-components\";\nimport type { TableBordersOptions } from \"@parts/table/table-properties/table-borders\";\nimport type { TableCellMarginOptions } from \"@parts/table/table-properties/table-cell-margin\";\nimport type { TableFloatOptions } from \"@parts/table/table-properties/table-float-properties\";\nimport type { TableLayoutType } from \"@parts/table/table-properties/table-layout\";\nimport type { TableLookOptions } from \"@parts/table/table-properties/table-look\";\nimport type {\n CnfStyleOptions,\n TableRowPropertiesOptionsBase,\n} from \"@parts/table/table-row/table-row-properties\";\nimport type { TableWidthProperties } from \"@parts/table/table-width\";\nimport { WidthType } from \"@parts/table/table-width\";\nimport type { ShadingAttributesProperties } from \"@shared/shading\";\nimport type { CellMergeAttributes } from \"@shared/track-revision\";\nimport type { ChangedAttributesProperties } from \"@shared/track-revision/track-revision\";\nimport type { TableVerticalAlign } from \"@shared/vertical-align\";\n\nimport { attrParts, borderStr, onOff, shadingStr } from \"../paragraph/stringify\";\n\n// ── Table width string ──\n\nfunction tableWidthStr(name: string, opts: TableWidthProperties): string {\n const type = opts.type ?? WidthType.AUTO;\n let w = opts.size;\n if (type === WidthType.PERCENTAGE && typeof w === \"number\") {\n w = `${w}%`;\n }\n const a = attrParts({\n \"w:w\": w !== undefined ? measurementOrPercentValue(w) : undefined,\n \"w:type\": type,\n });\n return `<${name} ${a}/>`;\n}\n\n// ── Cell margin string ──\n\nfunction cellMarginChildrenStr(opts: TableCellMarginOptions): string {\n const unitType = opts.marginUnitType ?? WidthType.DXA;\n const parts: string[] = [];\n if (opts.top !== undefined)\n parts.push(tableWidthStr(\"w:top\", { size: opts.top, type: unitType }));\n if (opts.left !== undefined)\n parts.push(tableWidthStr(\"w:left\", { size: opts.left, type: unitType }));\n if (opts.bottom !== undefined)\n parts.push(tableWidthStr(\"w:bottom\", { size: opts.bottom, type: unitType }));\n if (opts.right !== undefined)\n parts.push(tableWidthStr(\"w:right\", { size: opts.right, type: unitType }));\n return parts.join(\"\");\n}\n\nfunction cellMarginStr(tag: string, opts: TableCellMarginOptions): string | undefined {\n const inner = cellMarginChildrenStr(opts);\n return inner ? `<${tag}>${inner}</${tag}>` : undefined;\n}\n\n// ── Table borders string ──\n\n// CT_TblBorders — all 6 sides are optional (minOccurs=0); emit only those set.\nfunction tableBordersStr(opts: TableBordersOptions): string | undefined {\n const parts: string[] = [];\n if (opts.top) parts.push(borderStr(\"w:top\", opts.top));\n if (opts.left) parts.push(borderStr(\"w:left\", opts.left));\n if (opts.bottom) parts.push(borderStr(\"w:bottom\", opts.bottom));\n if (opts.right) parts.push(borderStr(\"w:right\", opts.right));\n if (opts.insideHorizontal) parts.push(borderStr(\"w:insideH\", opts.insideHorizontal));\n if (opts.insideVertical) parts.push(borderStr(\"w:insideV\", opts.insideVertical));\n return parts.length > 0 ? `<w:tblBorders>${parts.join(\"\")}</w:tblBorders>` : undefined;\n}\n\n// ── Cell borders string ──\n\nfunction cellBordersStr(opts: TableCellBordersOptions): string | undefined {\n const parts: string[] = [];\n if (opts.top) parts.push(borderStr(\"w:top\", opts.top));\n if (opts.start) parts.push(borderStr(\"w:start\", opts.start));\n if (opts.left) parts.push(borderStr(\"w:left\", opts.left));\n if (opts.bottom) parts.push(borderStr(\"w:bottom\", opts.bottom));\n if (opts.end) parts.push(borderStr(\"w:end\", opts.end));\n if (opts.right) parts.push(borderStr(\"w:right\", opts.right));\n if (opts.topLeftToBottomRight) parts.push(borderStr(\"w:tl2br\", opts.topLeftToBottomRight));\n if (opts.topRightToBottomLeft) parts.push(borderStr(\"w:tr2bl\", opts.topRightToBottomLeft));\n return parts.length > 0 ? `<w:tcBorders>${parts.join(\"\")}</w:tcBorders>` : undefined;\n}\n\n// ── Float properties string ──\n\nfunction floatPropertiesStr(opts: TableFloatOptions): string {\n const a = attrParts({\n \"w:horzAnchor\": opts.horizontalAnchor,\n \"w:vertAnchor\": opts.verticalAnchor,\n \"w:tblpX\":\n opts.absoluteHorizontalPosition !== undefined\n ? signedTwipsMeasureValue(opts.absoluteHorizontalPosition)\n : undefined,\n \"w:tblpXSpec\": opts.relativeHorizontalPosition,\n \"w:tblpY\":\n opts.absoluteVerticalPosition !== undefined\n ? signedTwipsMeasureValue(opts.absoluteVerticalPosition)\n : undefined,\n \"w:tblpYSpec\": opts.relativeVerticalPosition,\n \"w:bottomFromText\":\n opts.bottomFromText !== undefined ? twipsMeasureValue(opts.bottomFromText) : undefined,\n \"w:topFromText\":\n opts.topFromText !== undefined ? twipsMeasureValue(opts.topFromText) : undefined,\n \"w:leftFromText\":\n opts.leftFromText !== undefined ? twipsMeasureValue(opts.leftFromText) : undefined,\n \"w:rightFromText\":\n opts.rightFromText !== undefined ? twipsMeasureValue(opts.rightFromText) : undefined,\n });\n return `<w:tblpPr ${a}/>`;\n}\n\n// ── Table look string ──\n\nfunction tableLookStr(opts: TableLookOptions): string {\n const a = attrParts({\n \"w:firstRow\": opts.firstRow,\n \"w:lastRow\": opts.lastRow,\n \"w:firstColumn\": opts.firstColumn,\n \"w:lastColumn\": opts.lastColumn,\n \"w:noHBand\": opts.noHBand,\n \"w:noVBand\": opts.noVBand,\n });\n return `<w:tblLook ${a}/>`;\n}\n\n// ── Change/revision attribute string ──\n\nfunction changeAttrStr(tag: string, opts: ChangedAttributesProperties): string {\n const a = attrParts({ \"w:author\": opts.author, \"w:date\": opts.date, \"w:id\": opts.id });\n return `<${tag} ${a}/>`;\n}\n\n// ── Cell merge revision string ──\n\nfunction cellMergeStr(opts: CellMergeAttributes): string {\n const attrs: Record<string, string | number | boolean | undefined> = {\n \"w:author\": opts.author,\n \"w:date\": opts.date,\n \"w:id\": opts.id,\n };\n if (opts.verticalMerge !== undefined) {\n attrs[\"w:vMerge\"] = xsdVerticalMergeRev.to(opts.verticalMerge);\n }\n if (opts.verticalMergeOriginal !== undefined) {\n attrs[\"w:vMergeOrig\"] = xsdVerticalMergeRev.to(opts.verticalMergeOriginal);\n }\n const a = attrParts(attrs);\n return `<w:cellMerge ${a}/>`;\n}\n\n// ── Cell spacing string ──\n\nfunction cellSpacingStr(opts: TableCellSpacingProperties): string {\n const a = attrParts({\n \"w:type\": opts.type,\n \"w:w\": measurementOrPercentValue(opts.value),\n });\n return `<w:tblCellSpacing ${a}/>`;\n}\n\n// ── Table properties types ──\n\nexport interface TablePropertiesOptionsBase {\n width?: TableWidthProperties;\n indent?: TableWidthProperties;\n layout?: (typeof TableLayoutType)[keyof typeof TableLayoutType];\n borders?: TableBordersOptions;\n float?: TableFloatOptions;\n shading?: ShadingAttributesProperties;\n style?: string;\n alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];\n cellMargin?: TableCellMarginOptions;\n visuallyRightToLeft?: boolean;\n tableLook?: TableLookOptions;\n cellSpacing?: TableCellSpacingProperties;\n styleRowBandSize?: number;\n styleColBandSize?: number;\n caption?: string;\n description?: string;\n}\n\nexport type TablePropertiesChangeOptions = TablePropertiesOptions & ChangedAttributesProperties;\n\nexport type TablePropertiesOptions = {\n revision?: TablePropertiesChangeOptions;\n includeIfEmpty?: boolean;\n} & TablePropertiesOptionsBase;\n\n// ── Table properties change (w:tblPrChange) ──\n\nfunction stringifyTablePropertiesChangeInner(options: TablePropertiesChangeOptions): string {\n const inner = stringifyTablePropertiesInner({ ...options, includeIfEmpty: true });\n const a = attrParts({ \"w:author\": options.author, \"w:date\": options.date, \"w:id\": options.id });\n return `<w:tblPrChange ${a}><w:tblPr>${inner}</w:tblPr></w:tblPrChange>`;\n}\n\n// ── Table properties (w:tblPr) ──\n\nfunction stringifyTablePropertiesInner(options: TablePropertiesOptions): string {\n const parts: string[] = [];\n\n if (options.style) {\n parts.push(`<w:tblStyle w:val=\"${options.style}\"/>`);\n }\n\n if (options.float) {\n parts.push(floatPropertiesStr(options.float));\n if (options.float.overlap) {\n parts.push(`<w:tblOverlap w:val=\"${options.float.overlap}\"/>`);\n }\n }\n\n if (options.visuallyRightToLeft !== undefined) {\n parts.push(onOff(\"w:bidiVisual\", options.visuallyRightToLeft));\n }\n\n if (options.styleRowBandSize !== undefined) {\n parts.push(`<w:tblStyleRowBandSize w:val=\"${options.styleRowBandSize}\"/>`);\n }\n\n if (options.styleColBandSize !== undefined) {\n parts.push(`<w:tblStyleColBandSize w:val=\"${options.styleColBandSize}\"/>`);\n }\n\n if (options.width) {\n parts.push(tableWidthStr(\"w:tblW\", options.width));\n }\n\n if (options.alignment) {\n parts.push(`<w:jc w:val=\"${options.alignment}\"/>`);\n }\n\n if (options.indent) {\n parts.push(tableWidthStr(\"w:tblInd\", options.indent));\n }\n\n if (options.borders) {\n const bs = tableBordersStr(options.borders);\n if (bs) parts.push(bs);\n }\n\n if (options.shading) {\n parts.push(shadingStr(options.shading));\n }\n\n if (options.layout) {\n parts.push(`<w:tblLayout w:type=\"${options.layout}\"/>`);\n }\n\n if (options.cellMargin) {\n const cm = cellMarginStr(\"w:tblCellMar\", options.cellMargin);\n if (cm) parts.push(cm);\n }\n\n if (options.tableLook) {\n parts.push(tableLookStr(options.tableLook));\n }\n\n if (options.cellSpacing) {\n parts.push(cellSpacingStr(options.cellSpacing));\n }\n\n if (options.caption !== undefined) {\n parts.push(`<w:tblCaption w:val=\"${options.caption}\"/>`);\n }\n\n if (options.description !== undefined) {\n parts.push(`<w:tblDescription w:val=\"${options.description}\"/>`);\n }\n\n if (options.revision) {\n parts.push(stringifyTablePropertiesChangeInner(options.revision));\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTableProperties(options: TablePropertiesOptions): string | undefined {\n const inner = stringifyTablePropertiesInner(options);\n if (options.includeIfEmpty || inner) {\n return `<w:tblPr>${inner}</w:tblPr>`;\n }\n return undefined;\n}\n\n// ── Row properties types ──\n\nexport type TableRowPropertiesChangeOptions = TableRowPropertiesOptionsBase &\n ChangedAttributesProperties;\n\nexport type TableRowPropertiesOptions = TableRowPropertiesOptionsBase & {\n insertion?: ChangedAttributesProperties;\n deletion?: ChangedAttributesProperties;\n revision?: TableRowPropertiesChangeOptions;\n includeIfEmpty?: boolean;\n};\n\n// ── Row properties change (w:trPrChange) ──\n\nfunction stringifyTableRowPropertiesChangeInner(options: TableRowPropertiesChangeOptions): string {\n const inner = stringifyTableRowPropertiesInner({ ...options, includeIfEmpty: true });\n const a = attrParts({ \"w:author\": options.author, \"w:date\": options.date, \"w:id\": options.id });\n return `<w:trPrChange ${a}><w:trPr>${inner}</w:trPr></w:trPrChange>`;\n}\n\n// ── Row properties (w:trPr) ──\n\nfunction stringifyTableRowPropertiesInner(options: TableRowPropertiesOptions): string {\n const parts: string[] = [];\n\n if (options.cnfStyle !== undefined) {\n const a = attrParts({ \"w:val\": options.cnfStyle.val, \"w:changed\": options.cnfStyle.changed });\n parts.push(`<w:cnfStyle ${a}/>`);\n }\n\n if (options.divId !== undefined) {\n parts.push(`<w:divId w:val=\"${options.divId}\"/>`);\n }\n\n if (options.gridBefore !== undefined) {\n parts.push(`<w:gridBefore w:val=\"${options.gridBefore}\"/>`);\n }\n\n if (options.gridAfter !== undefined) {\n parts.push(`<w:gridAfter w:val=\"${options.gridAfter}\"/>`);\n }\n\n if (options.widthBefore) {\n parts.push(tableWidthStr(\"w:wBefore\", options.widthBefore));\n }\n\n if (options.widthAfter) {\n parts.push(tableWidthStr(\"w:wAfter\", options.widthAfter));\n }\n\n if (options.cantSplit !== undefined) {\n parts.push(onOff(\"w:cantSplit\", options.cantSplit));\n }\n\n if (options.tableHeader !== undefined) {\n parts.push(onOff(\"w:tblHeader\", options.tableHeader));\n }\n\n if (options.height) {\n const a = attrParts({\n \"w:val\": twipsMeasureValue(options.height.value),\n \"w:hRule\": options.height.rule,\n });\n parts.push(`<w:trHeight ${a}/>`);\n }\n\n if (options.cellSpacing) {\n parts.push(cellSpacingStr(options.cellSpacing));\n }\n\n if (options.rowAlignment) {\n parts.push(`<w:jc w:val=\"${options.rowAlignment}\"/>`);\n }\n\n if (options.hidden !== undefined) {\n parts.push(onOff(\"w:hidden\", options.hidden));\n }\n\n if (options.insertion) {\n parts.push(changeAttrStr(\"w:ins\", options.insertion));\n }\n\n if (options.deletion) {\n parts.push(changeAttrStr(\"w:del\", options.deletion));\n }\n\n if (options.revision) {\n parts.push(stringifyTableRowPropertiesChangeInner(options.revision));\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTableRowProperties(\n options: TableRowPropertiesOptions,\n): string | undefined {\n const inner = stringifyTableRowPropertiesInner(options);\n if (options.includeIfEmpty || inner) {\n return `<w:trPr>${inner}</w:trPr>`;\n }\n return undefined;\n}\n\n// ── Cell properties types ──\n\nexport interface TableCellPropertiesOptionsBase {\n cnfStyle?: CnfStyleOptions;\n shading?: ShadingAttributesProperties;\n margins?: TableCellMarginOptions;\n verticalAlign?: TableVerticalAlign;\n textDirection?: (typeof TextDirection)[keyof typeof TextDirection];\n verticalMerge?: (typeof VerticalMergeType)[keyof typeof VerticalMergeType];\n width?: TableWidthProperties;\n columnSpan?: number;\n rowSpan?: number;\n borders?: TableCellBordersOptions;\n horizontalMerge?: \"continue\" | \"restart\";\n noWrap?: boolean;\n fitText?: boolean;\n hideMark?: boolean;\n headers?: string[];\n insertion?: ChangedAttributesProperties;\n deletion?: ChangedAttributesProperties;\n cellMerge?: CellMergeAttributes;\n}\n\nexport type TableCellPropertiesChangeOptions = TableCellPropertiesOptionsBase &\n ChangedAttributesProperties;\n\nexport type TableCellPropertiesOptions = {\n revision?: TableCellPropertiesChangeOptions;\n includeIfEmpty?: boolean;\n} & TableCellPropertiesOptionsBase;\n\n// ── Cell properties change (w:tcPrChange) ──\n\nfunction stringifyTableCellPropertiesChangeInner(\n options: TableCellPropertiesChangeOptions,\n): string {\n const inner = stringifyTableCellPropertiesInner({ ...options, includeIfEmpty: true });\n const a = attrParts({ \"w:author\": options.author, \"w:date\": options.date, \"w:id\": options.id });\n return `<w:tcPrChange ${a}><w:tcPr>${inner}</w:tcPr></w:tcPrChange>`;\n}\n\n// ── Cell properties (w:tcPr) ──\n\nfunction stringifyTableCellPropertiesInner(options: TableCellPropertiesOptions): string {\n const parts: string[] = [];\n\n if (options.cnfStyle !== undefined) {\n const a = attrParts({ \"w:val\": options.cnfStyle.val, \"w:changed\": options.cnfStyle.changed });\n parts.push(`<w:cnfStyle ${a}/>`);\n }\n\n if (options.width) {\n parts.push(tableWidthStr(\"w:tcW\", options.width));\n }\n\n if (options.columnSpan) {\n parts.push(`<w:gridSpan w:val=\"${options.columnSpan}\"/>`);\n }\n\n if (options.verticalMerge) {\n parts.push(`<w:vMerge w:val=\"${options.verticalMerge}\"/>`);\n } else if (options.rowSpan && options.rowSpan > 1) {\n parts.push(`<w:vMerge w:val=\"${VerticalMergeType.RESTART}\"/>`);\n }\n\n if (options.borders) {\n const bs = cellBordersStr(options.borders);\n if (bs) parts.push(bs);\n }\n\n if (options.shading) {\n parts.push(shadingStr(options.shading));\n }\n\n if (options.margins) {\n const cm = cellMarginStr(\"w:tcMar\", options.margins);\n if (cm) parts.push(cm);\n }\n\n if (options.textDirection) {\n parts.push(`<w:textDirection w:val=\"${options.textDirection}\"/>`);\n }\n\n if (options.verticalAlign) {\n parts.push(`<w:vAlign w:val=\"${options.verticalAlign}\"/>`);\n }\n\n if (options.horizontalMerge !== undefined) {\n if (options.horizontalMerge === \"restart\") {\n parts.push(`<w:hMerge w:val=\"restart\"/>`);\n } else {\n parts.push(`<w:hMerge/>`);\n }\n }\n\n if (options.noWrap !== undefined) {\n parts.push(onOff(\"w:noWrap\", options.noWrap));\n }\n\n if (options.fitText !== undefined) {\n parts.push(onOff(\"w:tcFitText\", options.fitText));\n }\n\n if (options.hideMark !== undefined) {\n parts.push(onOff(\"w:hideMark\", options.hideMark));\n }\n\n if (options.headers !== undefined) {\n const headerParts = options.headers.map((h) => `<w:header w:val=\"${h}\"/>`).join(\"\");\n parts.push(`<w:headers>${headerParts}</w:headers>`);\n }\n\n if (options.insertion) {\n parts.push(changeAttrStr(\"w:cellIns\", options.insertion));\n }\n\n if (options.deletion) {\n parts.push(changeAttrStr(\"w:cellDel\", options.deletion));\n }\n\n if (options.revision) {\n parts.push(stringifyTableCellPropertiesChangeInner(options.revision));\n }\n\n if (options.cellMerge) {\n parts.push(cellMergeStr(options.cellMerge));\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTableCellProperties(\n options: TableCellPropertiesOptions,\n): string | undefined {\n const inner = stringifyTableCellPropertiesInner(options);\n if (options.includeIfEmpty || inner) {\n return `<w:tcPr>${inner}</w:tcPr>`;\n }\n return undefined;\n}\n\n// ── Table property exceptions (w:tblPrEx) ──\n\nexport interface TablePropertyExOptions {\n width?: TableWidthProperties;\n indent?: TableWidthProperties;\n layout?: (typeof TableLayoutType)[keyof typeof TableLayoutType];\n borders?: TableBordersOptions;\n shading?: ShadingAttributesProperties;\n alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];\n cellMargin?: TableCellMarginOptions;\n tableLook?: TableLookOptions;\n cellSpacing?: TableCellSpacingProperties;\n tblPrExChange?: { author: string; date?: string; id: string };\n}\n\nexport function stringifyTablePropertyExceptions(options: TablePropertyExOptions): string {\n const parts: string[] = [];\n\n if (options.width) {\n parts.push(tableWidthStr(\"w:tblW\", options.width));\n }\n\n if (options.alignment) {\n parts.push(`<w:jc w:val=\"${options.alignment}\"/>`);\n }\n\n if (options.cellSpacing) {\n parts.push(cellSpacingStr(options.cellSpacing));\n }\n\n if (options.indent) {\n parts.push(tableWidthStr(\"w:tblInd\", options.indent));\n }\n\n if (options.borders) {\n const bs = tableBordersStr(options.borders);\n if (bs) parts.push(bs);\n }\n\n if (options.shading) {\n parts.push(shadingStr(options.shading));\n }\n\n if (options.layout) {\n parts.push(`<w:tblLayout w:type=\"${options.layout}\"/>`);\n }\n\n if (options.cellMargin) {\n const cm = cellMarginStr(\"w:tblCellMar\", options.cellMargin);\n if (cm) parts.push(cm);\n }\n\n if (options.tableLook) {\n parts.push(tableLookStr(options.tableLook));\n }\n\n if (options.tblPrExChange) {\n const change = options.tblPrExChange;\n const attrs: Record<string, string | number | boolean | undefined> = {\n \"w:author\": change.author,\n \"w:id\": change.id,\n };\n if (change.date !== undefined) attrs[\"w:date\"] = change.date;\n const a = attrParts(attrs);\n parts.push(`<w:tblPrExChange ${a}/>`);\n }\n\n return `<w:tblPrEx>${parts.join(\"\")}</w:tblPrEx>`;\n}\n","/**\n * Table (w:tbl) descriptor for DOCX.\n *\n * Stringifies pure JSON TableOptions into XML using direct string\n * concatenation — zero IXmlableObject, zero xml(), zero BaseXmlComponent.\n *\n * @module\n */\n\nimport { ThemeColor } from \"@office-open/core\";\nimport { xsdVerticalMergeRev } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, attrNum, children, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport type { TableGridChangeOptions } from \"@parts/table/grid\";\nimport type { TableOptions } from \"@parts/table/table\";\nimport type { TableCellOptions } from \"@parts/table/table-cell/table-cell\";\nimport { VerticalMergeType } from \"@parts/table/table-cell/table-cell-components\";\nimport type { TableBordersOptions } from \"@parts/table/table-properties/table-borders\";\nimport type { TableLookOptions } from \"@parts/table/table-properties/table-look\";\nimport type { TableRowOptions } from \"@parts/table/table-row/table-row\";\nimport { BorderStyle } from \"@shared/border\";\nimport type { BorderOptions } from \"@shared/border\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { BodyContext, DocxReadContext } from \"../../context\";\nimport {\n stringifyTableCellProperties,\n stringifyTableProperties,\n stringifyTablePropertyExceptions,\n stringifyTableRowProperties,\n type TablePropertiesOptions,\n} from \"./stringify\";\n\n// Valid border @w:val (ST_Border / BorderStyle) and @w:themeColor (ST_ThemeColor) values.\nconst BORDER_STYLES = Object.values(BorderStyle) as readonly string[];\nconst THEME_COLORS = Object.values(ThemeColor) as readonly string[];\n\n/** Parse track-change attributes (id/author/date) from w:ins/w:del/w:cellIns/w:cellDel. */\nfunction parseChangeAttrs(el: Element): Record<string, unknown> {\n const change: Record<string, unknown> = {};\n const id = attrNum(el, \"w:id\");\n if (id !== undefined) change.id = id;\n const author = attr(el, \"w:author\");\n if (author) change.author = author;\n const date = attr(el, \"w:date\");\n if (date) change.date = date;\n return change;\n}\n\n// ── Table grid ──\n\nfunction buildTableGridXml(widths: number[], revision?: TableGridChangeOptions): string {\n const cols = widths.map((w) => `<w:gridCol w:w=\"${w}\"/>`).join(\"\");\n\n if (revision) {\n const revCols = revision.columnWidths.map((w) => `<w:gridCol w:w=\"${w}\"/>`).join(\"\");\n return `<w:tblGrid>${cols}<w:tblGridChange w:id=\"${revision.id}\"><w:tblGrid>${revCols}</w:tblGrid></w:tblGridChange></w:tblGrid>`;\n }\n\n return `<w:tblGrid>${cols}</w:tblGrid>`;\n}\n\n// ── Cell span extraction ──\n\n/** Extract column/row span from a plain-object cell. */\nfunction getCellSpans(cell: TableCellOptions): {\n columnSpan: number;\n rowSpan: number;\n} {\n return { columnSpan: cell.columnSpan ?? 1, rowSpan: cell.rowSpan ?? 1 };\n}\n\n// ── Cell children stringification ──\n\n/**\n * Stringify a cell child (SectionChild) inline.\n * Handles strings and plain objects (paragraph/table).\n */\nfunction stringifyCellChild(child: SectionChild, ctx: BodyContext): string {\n if (typeof child === \"string\") {\n return stringifyParagraphInline(child, ctx);\n }\n\n // Plain object dispatch\n if (\"paragraph\" in child) {\n return stringifyParagraphInline(child.paragraph, ctx);\n }\n if (\"table\" in child) {\n // Recursive: nested table via descriptor\n return tableDesc.stringify(child.table, ctx) ?? \"\";\n }\n\n // Fallback for other types — should not happen inside table cells\n return \"\";\n}\n\n// ── Cell stringification ──\n\nfunction stringifyTableCell(cell: TableCellOptions, ctx: BodyContext): string {\n const parts: string[] = [];\n\n const tcPr = stringifyTableCellProperties(cell);\n if (tcPr) parts.push(tcPr);\n\n const children = cell.children as SectionChild[] | undefined;\n if (children) {\n for (const child of children) {\n parts.push(stringifyCellChild(child, ctx));\n }\n }\n\n // Cells must end with a paragraph unless the last child is already one\n const last = children?.[children.length - 1];\n const endsWithParagraph =\n last && typeof last !== \"string\" && (\"paragraph\" in last || \"table\" in last);\n if (!endsWithParagraph) {\n parts.push(\"<w:p/>\");\n }\n\n return `<w:tc>${parts.join(\"\")}</w:tc>`;\n}\n\n// ── Row stringification ──\n\nfunction stringifyTableRow(\n row: TableRowOptions,\n ctx: BodyContext,\n extraCells?: { cell: TableCellOptions; columnIndex: number }[],\n): string {\n const parts: string[] = [];\n\n // Property exceptions (tblPrEx)\n if (row.propertyExceptions) {\n parts.push(stringifyTablePropertyExceptions(row.propertyExceptions));\n }\n\n // Row properties\n const trPr = stringifyTableRowProperties(row);\n if (trPr) parts.push(trPr);\n\n const prefixCount = parts.length;\n\n // Cells\n for (const cell of row.cells) {\n parts.push(stringifyTableCell(cell as TableCellOptions, ctx));\n }\n\n // Insert extra CONTINUE cells at correct positions\n if (extraCells && extraCells.length > 0) {\n for (const { cell, columnIndex } of extraCells) {\n const insertIdx = findInsertIndex(row.cells, columnIndex, prefixCount);\n parts.splice(insertIdx, 0, stringifyTableCell(cell, ctx));\n }\n }\n\n // rsid attributes\n const rsidAttrs: string[] = [];\n if (row.rsidRPr) rsidAttrs.push(` w:rsidRPr=\"${row.rsidRPr}\"`);\n if (row.rsidR) rsidAttrs.push(` w:rsidR=\"${row.rsidR}\"`);\n if (row.rsidDel) rsidAttrs.push(` w:rsidDel=\"${row.rsidDel}\"`);\n if (row.rsidTr) rsidAttrs.push(` w:rsidTr=\"${row.rsidTr}\"`);\n const attr = rsidAttrs.join(\"\");\n\n const body = parts.join(\"\");\n return body ? `<w:tr${attr}>${body}</w:tr>` : attr ? `<w:tr${attr}/>` : \"<w:tr/>\";\n}\n\n// ── Row options type ──\n\nfunction findInsertIndex(\n cells: TableRowOptions[\"cells\"],\n columnIndex: number,\n prefixCount: number,\n): number {\n let colIdx = 0;\n for (let i = 0; i < cells.length; i++) {\n const { columnSpan } = getCellSpans(cells[i] as TableCellOptions);\n colIdx += columnSpan;\n if (colIdx > columnIndex) {\n return i + prefixCount;\n }\n }\n return cells.length + prefixCount;\n}\n\n// ── Vertical merge ──\n\n/**\n * Pre-process rows to compute CONTINUE cells for vertical merge.\n */\nfunction computeVerticalMergeCells(\n rows: TableRowOptions[],\n): Map<number, { cell: TableCellOptions; columnIndex: number }[]> {\n const extraMap = new Map<number, { cell: TableCellOptions; columnIndex: number }[]>();\n for (let ri = 0; ri < rows.length - 1; ri++) {\n const cells = rows[ri].cells;\n let colIdx = 0;\n\n for (const cell of cells) {\n const typedCell = cell as TableCellOptions;\n const { columnSpan, rowSpan } = getCellSpans(typedCell);\n\n if (rowSpan > 1) {\n const continueCell: TableCellOptions = {\n borders: typedCell.borders,\n children: [],\n columnSpan,\n rowSpan: rowSpan - 1,\n verticalMerge: VerticalMergeType.CONTINUE,\n };\n\n if (!extraMap.has(ri + 1)) {\n extraMap.set(ri + 1, []);\n }\n extraMap.get(ri + 1)!.push({ cell: continueCell, columnIndex: colIdx });\n }\n\n colIdx += columnSpan;\n }\n }\n\n return extraMap;\n}\n\n// ── Descriptor ──\n\nexport const tableDesc: CustomDescriptor<TableOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [];\n\n // Table properties\n // tblPr is required in CT_Tbl (minOccurs defaults to 1) — always emit it,\n // even when empty; do not inject optional defaults (width/borders are XSD-optional).\n const tblPrOpts: TablePropertiesOptions = {\n alignment: opts.alignment,\n borders: opts.borders,\n caption: opts.caption,\n cellMargin: opts.margins,\n cellSpacing: opts.cellSpacing,\n description: opts.description,\n float: opts.float,\n indent: opts.indent,\n layout: opts.layout,\n revision: opts.revision,\n style: opts.style,\n styleColBandSize: opts.styleColBandSize,\n styleRowBandSize: opts.styleRowBandSize,\n tableLook: opts.tableLook,\n visuallyRightToLeft: opts.visuallyRightToLeft,\n width: opts.width,\n includeIfEmpty: true,\n };\n parts.push(stringifyTableProperties(tblPrOpts)!);\n\n // Table grid\n const columnWidths =\n opts.columnWidths ?? Array(Math.max(...opts.rows.map((r) => r.cells.length))).fill(100);\n parts.push(buildTableGridXml(columnWidths, opts.columnWidthsRevision));\n\n // Compute vertical merge CONTINUE cells\n const extraCells = computeVerticalMergeCells(opts.rows as TableRowOptions[]);\n\n // Rows\n for (let ri = 0; ri < opts.rows.length; ri++) {\n const row = opts.rows[ri] as TableRowOptions;\n const extras = extraCells.get(ri);\n parts.push(stringifyTableRow(row, ctx, extras));\n }\n\n return `<w:tbl>${parts.join(\"\")}</w:tbl>`;\n },\n\n parse(el, ctx) {\n return parseTableEl(el, ctx as DocxReadContext);\n },\n};\n\n// ── Parse (Element → TableOptions) ──\n\ntype ParseChildFn = (el: Element, ctx: DocxReadContext) => SectionChild;\n\n/** Callback used by table parser to parse body children. */\nlet _parseChild: ParseChildFn | undefined;\n\n/** Set the child parser callback (called from parseBody). */\nexport function setTableParseChild(fn: ParseChildFn): void {\n _parseChild = fn;\n}\n\nfunction parseTablePropertiesEl(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n\n const style = findChild(el, \"w:tblStyle\");\n if (style) {\n const val = attr(style, \"w:val\");\n if (val) opts.style = val;\n }\n\n const tblW = findChild(el, \"w:tblW\");\n if (tblW) {\n const rawSize = attr(tblW, \"w:w\");\n const type = attr(tblW, \"w:type\");\n const size = type === \"pct\" ? rawSize : attrNum(tblW, \"w:w\");\n if (size !== undefined || type) {\n opts.width = { size: size ?? 0, ...(type ? { type } : {}) };\n }\n }\n\n const jc = findChild(el, \"w:jc\");\n if (jc) {\n const val = attr(jc, \"w:val\");\n if (val) opts.alignment = val;\n }\n\n const layout = findChild(el, \"w:tblLayout\");\n if (layout) {\n const val = attr(layout, \"w:type\");\n if (val === \"autofit\" || val === \"fixed\") opts.layout = val;\n }\n\n const tblBorders = findChild(el, \"w:tblBorders\");\n if (tblBorders) {\n // XML side names → TableBordersOptions keys (insideH/insideV map to\n // insideHorizontal/insideVertical); all 6 sides are CT_TblBorders-optional.\n const SIDE_KEYS: ReadonlyArray<[string, keyof TableBordersOptions]> = [\n [\"top\", \"top\"],\n [\"left\", \"left\"],\n [\"bottom\", \"bottom\"],\n [\"right\", \"right\"],\n [\"insideH\", \"insideHorizontal\"],\n [\"insideV\", \"insideVertical\"],\n ];\n const borders: Partial<TableBordersOptions> = {};\n for (const [xmlSide, key] of SIDE_KEYS) {\n const sideEl = findChild(tblBorders, `w:${xmlSide}`);\n if (!sideEl) continue;\n // CT_Border requires w:val (style); skip malformed sides\n const style = attr(sideEl, \"w:val\");\n if (!style || !BORDER_STYLES.includes(style)) continue;\n const sideOpts: BorderOptions = { style: style as BorderOptions[\"style\"] };\n const color = attr(sideEl, \"w:color\");\n if (color) sideOpts.color = color;\n const size = attrNum(sideEl, \"w:sz\");\n if (size !== undefined) sideOpts.size = size;\n const space = attrNum(sideEl, \"w:space\");\n if (space !== undefined) sideOpts.space = space;\n const themeColor = attr(sideEl, \"w:themeColor\");\n if (themeColor && THEME_COLORS.includes(themeColor)) {\n sideOpts.themeColor = themeColor as BorderOptions[\"themeColor\"];\n }\n const themeTint = attr(sideEl, \"w:themeTint\");\n if (themeTint) sideOpts.themeTint = themeTint;\n const themeShade = attr(sideEl, \"w:themeShade\");\n if (themeShade) sideOpts.themeShade = themeShade;\n const shadow = attrBool(sideEl, \"w:shadow\");\n if (shadow !== undefined) sideOpts.shadow = shadow;\n const frame = attrBool(sideEl, \"w:frame\");\n if (frame !== undefined) sideOpts.frame = frame;\n borders[key] = sideOpts;\n }\n if (Object.keys(borders).length > 0) opts.borders = borders;\n }\n\n const tblCellMar = findChild(el, \"w:tblCellMar\");\n if (tblCellMar) {\n const margins: Record<string, unknown> = {};\n for (const side of [\"top\", \"bottom\", \"left\", \"right\"] as const) {\n const sideEl = findChild(tblCellMar, `w:${side}`);\n if (sideEl) {\n const size = attrNum(sideEl, \"w:w\");\n const type = attr(sideEl, \"w:type\");\n if (size !== undefined) {\n margins[side] = { size, type: type ?? \"dxa\" };\n }\n }\n }\n if (Object.keys(margins).length > 0) opts.margins = margins;\n }\n\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n const shading: Record<string, unknown> = {};\n const fill = attr(shd, \"w:fill\");\n if (fill) shading.fill = fill;\n const color = attr(shd, \"w:color\");\n if (color) shading.color = color;\n const val = attr(shd, \"w:val\");\n if (val) shading.type = val;\n if (Object.keys(shading).length > 0) opts.shading = shading;\n }\n\n // description → w:tblDescription/@w:val\n const tblDesc = findChild(el, \"w:tblDescription\");\n if (tblDesc) {\n const val = attr(tblDesc, \"w:val\");\n if (val) opts.description = val;\n }\n\n // float → w:tblpPr attributes\n const tblpPr = findChild(el, \"w:tblpPr\");\n if (tblpPr) {\n const floatOpts: Record<string, unknown> = {};\n const horzAnchor = attr(tblpPr, \"w:horzAnchor\");\n if (horzAnchor) floatOpts.horizontalAnchor = horzAnchor;\n const vertAnchor = attr(tblpPr, \"w:vertAnchor\");\n if (vertAnchor) floatOpts.verticalAnchor = vertAnchor;\n const tblpX = attrNum(tblpPr, \"w:tblpX\");\n if (tblpX !== undefined) floatOpts.absoluteHorizontalPosition = tblpX;\n const tblpXSpec = attr(tblpPr, \"w:tblpXSpec\");\n if (tblpXSpec) floatOpts.relativeHorizontalPosition = tblpXSpec;\n const tblpY = attrNum(tblpPr, \"w:tblpY\");\n if (tblpY !== undefined) floatOpts.absoluteVerticalPosition = tblpY;\n const tblpYSpec = attr(tblpPr, \"w:tblpYSpec\");\n if (tblpYSpec) floatOpts.relativeVerticalPosition = tblpYSpec;\n const bottomFromText = attrNum(tblpPr, \"w:bottomFromText\");\n if (bottomFromText !== undefined) floatOpts.bottomFromText = bottomFromText;\n const topFromText = attrNum(tblpPr, \"w:topFromText\");\n if (topFromText !== undefined) floatOpts.topFromText = topFromText;\n const leftFromText = attrNum(tblpPr, \"w:leftFromText\");\n if (leftFromText !== undefined) floatOpts.leftFromText = leftFromText;\n const rightFromText = attrNum(tblpPr, \"w:rightFromText\");\n if (rightFromText !== undefined) floatOpts.rightFromText = rightFromText;\n if (Object.keys(floatOpts).length > 0) opts.float = floatOpts;\n }\n\n // indent → w:tblInd/@w:w and @w:type\n const tblInd = findChild(el, \"w:tblInd\");\n if (tblInd) {\n const size = attrNum(tblInd, \"w:w\");\n const type = attr(tblInd, \"w:type\");\n if (size !== undefined) {\n opts.indent = { size, ...(type ? { type } : {}) };\n }\n }\n\n // visuallyRightToLeft → w:bidiVisual\n const bidiVisual = findChild(el, \"w:bidiVisual\");\n if (bidiVisual) opts.visuallyRightToLeft = attrBool(bidiVisual, \"w:val\") ?? true;\n\n // styleRowBandSize / styleColBandSize\n const tblStyleRowBandSize = findChild(el, \"w:tblStyleRowBandSize\");\n if (tblStyleRowBandSize) {\n const val = attrNum(tblStyleRowBandSize, \"w:val\");\n if (val !== undefined) opts.styleRowBandSize = val;\n }\n const tblStyleColBandSize = findChild(el, \"w:tblStyleColBandSize\");\n if (tblStyleColBandSize) {\n const val = attrNum(tblStyleColBandSize, \"w:val\");\n if (val !== undefined) opts.styleColBandSize = val;\n }\n\n // caption → w:tblCaption/@w:val\n const tblCaption = findChild(el, \"w:tblCaption\");\n if (tblCaption) {\n const val = attr(tblCaption, \"w:val\");\n if (val) opts.caption = val;\n }\n\n // cellSpacing → w:tblCellSpacing\n const tblCellSpacing = findChild(el, \"w:tblCellSpacing\");\n if (tblCellSpacing) {\n const type = attr(tblCellSpacing, \"w:type\");\n const w = attrNum(tblCellSpacing, \"w:w\");\n if (w !== undefined) opts.cellSpacing = { value: w, ...(type ? { type } : {}) };\n }\n\n // Revision (w:tblPrChange)\n const tblPrChange = findChild(el, \"w:tblPrChange\");\n if (tblPrChange) {\n const rev: Record<string, unknown> = {};\n const author = attr(tblPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(tblPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(tblPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerTblPr = findChild(tblPrChange, \"w:tblPr\");\n if (innerTblPr) {\n Object.assign(rev, parseTablePropertiesEl(innerTblPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev;\n }\n\n return opts;\n}\n\nfunction parseColumnWidthsEl(el: Element): number[] {\n const cols: number[] = [];\n const tblGrid = findChild(el, \"w:tblGrid\");\n if (!tblGrid) return cols;\n\n for (const col of children(tblGrid, \"w:gridCol\")) {\n const w = attrNum(col, \"w:w\");\n cols.push(w ?? 100);\n }\n\n return cols;\n}\n\nfunction parseTableRowPropertiesEl(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n\n const trHeight = findChild(el, \"w:trHeight\");\n if (trHeight) {\n const val = attrNum(trHeight, \"w:val\");\n const rule = attr(trHeight, \"w:hRule\");\n if (val !== undefined) {\n opts.height = { value: val, rule: rule ?? \"atLeast\" };\n }\n }\n\n // cnfStyle → w:cnfStyle/@w:val (+ @w:changed)\n const cnfStyle = findChild(el, \"w:cnfStyle\");\n if (cnfStyle) {\n const val = attr(cnfStyle, \"w:val\");\n if (val) {\n const cnf: Record<string, unknown> = { val };\n const changed = attrBool(cnfStyle, \"w:changed\");\n if (changed !== undefined) cnf.changed = changed;\n opts.cnfStyle = cnf;\n }\n }\n\n // divId → w:divId/@w:val\n const divId = findChild(el, \"w:divId\");\n if (divId) {\n const val = attrNum(divId, \"w:val\");\n if (val !== undefined) opts.divId = val;\n }\n\n // gridBefore / gridAfter\n const gridBefore = findChild(el, \"w:gridBefore\");\n if (gridBefore) {\n const val = attrNum(gridBefore, \"w:val\");\n if (val !== undefined) opts.gridBefore = val;\n }\n const gridAfter = findChild(el, \"w:gridAfter\");\n if (gridAfter) {\n const val = attrNum(gridAfter, \"w:val\");\n if (val !== undefined) opts.gridAfter = val;\n }\n\n // wBefore / wAfter → widthBefore / widthAfter\n const wBefore = findChild(el, \"w:wBefore\");\n if (wBefore) {\n const rawSize = attr(wBefore, \"w:w\");\n const type = attr(wBefore, \"w:type\");\n const size = type === \"pct\" ? rawSize : attrNum(wBefore, \"w:w\");\n if (size !== undefined) opts.widthBefore = { size, ...(type ? { type } : {}) };\n }\n const wAfter = findChild(el, \"w:wAfter\");\n if (wAfter) {\n const rawSize = attr(wAfter, \"w:w\");\n const type = attr(wAfter, \"w:type\");\n const size = type === \"pct\" ? rawSize : attrNum(wAfter, \"w:w\");\n if (size !== undefined) opts.widthAfter = { size, ...(type ? { type } : {}) };\n }\n\n // rowAlignment → w:jc/@w:val\n const jc = findChild(el, \"w:jc\");\n if (jc) {\n const val = attr(jc, \"w:val\");\n if (val) opts.rowAlignment = val;\n }\n\n // hidden → w:hidden\n const hidden = findChild(el, \"w:hidden\");\n if (hidden) opts.hidden = attrBool(hidden, \"w:val\") ?? true;\n\n // cellSpacing → w:tblCellSpacing\n const tblCellSpacing = findChild(el, \"w:tblCellSpacing\");\n if (tblCellSpacing) {\n const type = attr(tblCellSpacing, \"w:type\");\n const w = attrNum(tblCellSpacing, \"w:w\");\n if (w !== undefined) opts.cellSpacing = { value: w, ...(type ? { type } : {}) };\n }\n\n // insertion / deletion (track changes)\n const ins = findChild(el, \"w:ins\");\n if (ins) opts.insertion = parseChangeAttrs(ins);\n const del = findChild(el, \"w:del\");\n if (del) opts.deletion = parseChangeAttrs(del);\n\n // Revision (w:trPrChange)\n const trPrChange = findChild(el, \"w:trPrChange\");\n if (trPrChange) {\n const rev: Record<string, unknown> = {};\n const author = attr(trPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(trPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(trPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerTrPr = findChild(trPrChange, \"w:trPr\");\n if (innerTrPr) {\n Object.assign(rev, parseTableRowPropertiesEl(innerTrPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev;\n }\n\n const tblHeader = findChild(el, \"w:tblHeader\");\n if (tblHeader) {\n opts.tableHeader = attrBool(tblHeader, \"w:val\") ?? true;\n }\n\n const cantSplit = findChild(el, \"w:cantSplit\");\n if (cantSplit) {\n opts.cantSplit = attrBool(cantSplit, \"w:val\") ?? true;\n }\n\n // tblLook — conditional formatting flags (CT_TblLook)\n const tblLook = findChild(el, \"w:tblLook\");\n if (tblLook) {\n const look: TableLookOptions = {};\n const firstRow = attrBool(tblLook, \"w:firstRow\");\n if (firstRow !== undefined) look.firstRow = firstRow;\n const lastRow = attrBool(tblLook, \"w:lastRow\");\n if (lastRow !== undefined) look.lastRow = lastRow;\n const firstColumn = attrBool(tblLook, \"w:firstColumn\");\n if (firstColumn !== undefined) look.firstColumn = firstColumn;\n const lastColumn = attrBool(tblLook, \"w:lastColumn\");\n if (lastColumn !== undefined) look.lastColumn = lastColumn;\n const noHBand = attrBool(tblLook, \"w:noHBand\");\n if (noHBand !== undefined) look.noHBand = noHBand;\n const noVBand = attrBool(tblLook, \"w:noVBand\");\n if (noVBand !== undefined) look.noVBand = noVBand;\n if (Object.keys(look).length > 0) opts.tableLook = look;\n }\n\n return opts;\n}\n\nfunction parseTableCellPropertiesEl(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n\n const tcW = findChild(el, \"w:tcW\");\n if (tcW) {\n const size = attrNum(tcW, \"w:w\");\n const type = attr(tcW, \"w:type\");\n if (size !== undefined) {\n opts.width = { size, type: type ?? \"dxa\" };\n }\n }\n\n const gridSpan = findChild(el, \"w:gridSpan\");\n if (gridSpan) {\n const val = attrNum(gridSpan, \"w:val\");\n if (val !== undefined) opts.columnSpan = val;\n }\n\n const vMerge = findChild(el, \"w:vMerge\");\n if (vMerge) {\n const val = attr(vMerge, \"w:val\");\n opts.verticalMerge = val === \"restart\" ? \"restart\" : \"continue\";\n }\n\n const vAlign = findChild(el, \"w:vAlign\");\n if (vAlign) {\n const val = attr(vAlign, \"w:val\");\n if (val) opts.verticalAlign = val;\n }\n\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n const shading: Record<string, unknown> = {};\n const fill = attr(shd, \"w:fill\");\n if (fill) shading.fill = fill;\n const color = attr(shd, \"w:color\");\n if (color) shading.color = color;\n const val = attr(shd, \"w:val\");\n if (val) shading.type = val;\n if (Object.keys(shading).length > 0) opts.shading = shading;\n }\n\n const tcBorders = findChild(el, \"w:tcBorders\");\n if (tcBorders) {\n const borders: Record<string, unknown> = {};\n // XML side name → TableCellBordersOptions key (incl. start/end + diagonals)\n const SIDE_KEYS: ReadonlyArray<[string, string]> = [\n [\"top\", \"top\"],\n [\"start\", \"start\"],\n [\"left\", \"left\"],\n [\"bottom\", \"bottom\"],\n [\"end\", \"end\"],\n [\"right\", \"right\"],\n [\"tl2br\", \"topLeftToBottomRight\"],\n [\"tr2bl\", \"topRightToBottomLeft\"],\n ];\n for (const [xmlSide, key] of SIDE_KEYS) {\n const sideEl = findChild(tcBorders, `w:${xmlSide}`);\n if (sideEl) {\n const b: Record<string, unknown> = {};\n const val = attr(sideEl, \"w:val\");\n if (val) b.style = val;\n const color = attr(sideEl, \"w:color\");\n if (color) b.color = color;\n const sz = attrNum(sideEl, \"w:sz\");\n if (sz !== undefined) b.size = sz;\n borders[key] = b;\n }\n }\n if (Object.keys(borders).length > 0) opts.borders = borders;\n }\n\n const noWrap = findChild(el, \"w:noWrap\");\n if (noWrap) opts.noWrap = attrBool(noWrap, \"w:val\") ?? true;\n\n const tcMar = findChild(el, \"w:tcMar\");\n if (tcMar) {\n const margins: Record<string, unknown> = {};\n let marginUnitType: string | undefined;\n for (const side of [\"top\", \"bottom\", \"left\", \"right\"] as const) {\n const sideEl = findChild(tcMar, `w:${side}`);\n if (sideEl) {\n const size = attrNum(sideEl, \"w:w\");\n const type = attr(sideEl, \"w:type\");\n if (size !== undefined) {\n margins[side] = size;\n if (type && !marginUnitType) marginUnitType = type;\n }\n }\n }\n if (marginUnitType) margins.marginUnitType = marginUnitType;\n if (Object.keys(margins).length > 0) opts.margins = margins;\n }\n\n const textDirection = findChild(el, \"w:textDirection\");\n if (textDirection) {\n const val = attr(textDirection, \"w:val\");\n if (val) opts.textDirection = val;\n }\n\n // horizontalMerge → w:hMerge\n const hMerge = findChild(el, \"w:hMerge\");\n if (hMerge) {\n const val = attr(hMerge, \"w:val\");\n opts.horizontalMerge = val === \"restart\" ? \"restart\" : \"continue\";\n }\n\n // fitText → w:tcFitText\n const tcFitText = findChild(el, \"w:tcFitText\");\n if (tcFitText) opts.fitText = attrBool(tcFitText, \"w:val\") ?? true;\n\n // hideMark → w:hideMark\n const hideMark = findChild(el, \"w:hideMark\");\n if (hideMark) opts.hideMark = attrBool(hideMark, \"w:val\") ?? true;\n\n // headers → w:headers/w:header\n const headersEl = findChild(el, \"w:headers\");\n if (headersEl) {\n const headerVals: string[] = [];\n for (const h of headersEl.elements ?? []) {\n if (h.name !== \"w:header\") continue;\n const val = attr(h, \"w:val\");\n if (val) headerVals.push(val);\n }\n if (headerVals.length > 0) opts.headers = headerVals;\n }\n\n // insertion / deletion (track changes)\n const cellIns = findChild(el, \"w:cellIns\");\n if (cellIns) opts.insertion = parseChangeAttrs(cellIns);\n const cellDel = findChild(el, \"w:cellDel\");\n if (cellDel) opts.deletion = parseChangeAttrs(cellDel);\n\n // Revision (w:tcPrChange)\n const tcPrChange = findChild(el, \"w:tcPrChange\");\n if (tcPrChange) {\n const rev: Record<string, unknown> = {};\n const author = attr(tcPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(tcPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(tcPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerTcPr = findChild(tcPrChange, \"w:tcPr\");\n if (innerTcPr) {\n Object.assign(rev, parseTableCellPropertiesEl(innerTcPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev;\n }\n\n // cellMerge → w:cellMerge\n const cellMerge = findChild(el, \"w:cellMerge\");\n if (cellMerge) {\n const cm = parseChangeAttrs(cellMerge);\n const vMerge = attr(cellMerge, \"w:vMerge\");\n if (vMerge) cm.verticalMerge = xsdVerticalMergeRev.from(vMerge) as \"continue\" | \"restart\";\n const vMergeOrig = attr(cellMerge, \"w:vMergeOrig\");\n if (vMergeOrig) {\n cm.verticalMergeOriginal = xsdVerticalMergeRev.from(vMergeOrig) as \"continue\" | \"restart\";\n }\n if (Object.keys(cm).length > 0) opts.cellMerge = cm;\n }\n\n return opts;\n}\n\nfunction parseTableCellEl(el: Element, ctx: DocxReadContext): TableCellOptions {\n const opts: Record<string, unknown> = {};\n\n const tcPr = findChild(el, \"w:tcPr\");\n if (tcPr) {\n Object.assign(opts, parseTableCellPropertiesEl(tcPr));\n }\n\n const childElements: SectionChild[] = [];\n for (const child of el.elements ?? []) {\n switch (child.name) {\n case \"w:tcPr\":\n break;\n case \"w:p\":\n case \"w:tbl\":\n if (_parseChild) childElements.push(_parseChild(child, ctx));\n break;\n default:\n break;\n }\n }\n\n opts.children = childElements;\n return opts as unknown as TableCellOptions;\n}\n\nfunction parseTableRowEl(el: Element, ctx: DocxReadContext): TableRowOptions {\n const opts: Record<string, unknown> = {};\n\n const trPr = findChild(el, \"w:trPr\");\n if (trPr) {\n Object.assign(opts, parseTableRowPropertiesEl(trPr));\n }\n\n // rsid attributes on w:tr element\n for (const [attrName, optKey] of [\n [\"w:rsidRPr\", \"rsidRPr\"],\n [\"w:rsidR\", \"rsidR\"],\n [\"w:rsidDel\", \"rsidDel\"],\n [\"w:rsidTr\", \"rsidTr\"],\n ] as const) {\n const val = attr(el, attrName);\n if (val) opts[optKey] = val;\n }\n\n const childCells: TableCellOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:tc\") {\n childCells.push(parseTableCellEl(child, ctx));\n }\n }\n\n opts.cells = childCells;\n return opts as unknown as TableRowOptions;\n}\n\nfunction parseTableEl(el: Element, ctx: DocxReadContext): TableOptions {\n const opts: Record<string, unknown> = {};\n\n const tblPr = findChild(el, \"w:tblPr\");\n if (tblPr) {\n Object.assign(opts, parseTablePropertiesEl(tblPr));\n }\n\n const colWidths = parseColumnWidthsEl(el);\n if (colWidths.length > 0) {\n opts.columnWidths = colWidths;\n }\n\n const rows: TableRowOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:tr\") {\n rows.push(parseTableRowEl(child, ctx));\n }\n }\n\n opts.rows = rows;\n return opts as unknown as TableOptions;\n}\n","/**\n * Document attributes module for WordprocessingML documents.\n *\n * This module defines the XML namespace declarations used in OOXML documents.\n * These namespaces are required for proper document parsing and generation.\n *\n * Reference: http://officeopenxml.com/anatomyofOOXML.php\n *\n * @module\n */\n\n/**\n * XML namespace URIs used in WordprocessingML documents.\n *\n * These namespaces define the various XML schemas that can be referenced\n * in a document, including WordprocessingML, DrawingML, VML, and others.\n */\n/* CSpell:disable */\nexport const DocumentAttributeNamespaces = {\n aink: \"http://schemas.microsoft.com/office/drawing/2016/ink\",\n am3d: \"http://schemas.microsoft.com/office/drawing/2017/model3d\",\n cp: \"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\",\n cx: \"http://schemas.microsoft.com/office/drawing/2014/chartex\",\n cx1: \"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\",\n cx2: \"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\",\n cx3: \"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\",\n cx4: \"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\",\n cx5: \"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\",\n cx6: \"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\",\n cx7: \"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\",\n cx8: \"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\",\n dc: \"http://purl.org/dc/elements/1.1/\",\n dcmitype: \"http://purl.org/dc/dcmitype/\",\n dcterms: \"http://purl.org/dc/terms/\",\n m: \"http://schemas.openxmlformats.org/officeDocument/2006/math\",\n mc: \"http://schemas.openxmlformats.org/markup-compatibility/2006\",\n o: \"urn:schemas-microsoft-com:office:office\",\n r: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\",\n v: \"urn:schemas-microsoft-com:vml\",\n w: \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\",\n w10: \"urn:schemas-microsoft-com:office:word\",\n w14: \"http://schemas.microsoft.com/office/word/2010/wordml\",\n w15: \"http://schemas.microsoft.com/office/word/2012/wordml\",\n w16: \"http://schemas.microsoft.com/office/word/2018/wordml\",\n w16cex: \"http://schemas.microsoft.com/office/word/2018/wordml/cex\",\n w16cid: \"http://schemas.microsoft.com/office/word/2016/wordml/cid\",\n w16sdtdh: \"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\",\n w16se: \"http://schemas.microsoft.com/office/word/2015/wordml/symex\",\n wne: \"http://schemas.microsoft.com/office/word/2006/wordml\",\n wp: \"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\",\n wp14: \"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\",\n wpc: \"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\",\n wpg: \"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\",\n wpi: \"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\",\n wps: \"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\",\n xsi: \"http://www.w3.org/2001/XMLSchema-instance\",\n};\n/* CSpell:enable */\n\n/**\n * Type representing valid namespace keys.\n */\nexport type DocumentAttributeNamespace = keyof typeof DocumentAttributeNamespaces;\n","import { twipsMeasureValue } from \"@office-open/core\";\nimport type { PositiveUniversalMeasure } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n\n/**\n * This simple type specifies the orientation of all pages in the parent section. This information is used to determine the actual paper size to use when printing the file.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_PageOrientation_topic_ID0EKBK3.html\n *\n * ## XSD Schema\n *\n * ```xml\n * <xsd:simpleType name=\"ST_PageOrientation\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"portrait\"/>\n * <xsd:enumeration value=\"landscape\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageOrientation = {\n /**\n * ## Portrait Mode\n *\n * Specifies that pages in this section shall be printed in portrait mode.\n */\n PORTRAIT: \"portrait\",\n /**\n * ## Landscape Mode\n *\n * Specifies that pages in this section shall be printed in landscape mode, which prints the page contents with a 90 degree rotation with respect to the normal page orientation.\n */\n LANDSCAPE: \"landscape\",\n} as const;\n\nexport interface PageSizeAttributes {\n /**\n * ## Page Width\n *\n * This attribute indicates the width (in twentieths of a point) for all pages in the current section.\n *\n * ### Example\n *\n * ```xml\n * <w:pgSz w:w=\"15840\" w:h=\"12240\" />\n * ```\n *\n * All pages in this section are displayed on a page that is 15840 twentieths of a point (11\") wide.\n *\n * The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§2.18.105).\n */\n width: number | PositiveUniversalMeasure;\n /**\n * ## Page Height\n *\n * Specifies the height (in twentieths of a point) for all pages in the current section.\n *\n * ### Example\n *\n * ```xml\n * <w:pgSz w:w=\"15840\" w:h=\"12240\" />\n * ```\n *\n * All pages in this section are displayed on a page that is `12240` twentieths of a point (`8.5\"`) tall.\n *\n * The possible values for this attribute are defined by the `ST_TwipsMeasure` simple type (§2.18.105).\n */\n height: number | PositiveUniversalMeasure;\n /**\n * ## Page Orientation\n *\n * Specifies the orientation of all pages in this section.\n *\n * This information is used to determine the actual paper size to use on the printer.\n *\n * This implies that the actual paper size width and height are reversed for pages in this section. If this attribute is omitted, then portrait shall be implied.\n *\n * ### Example\n *\n * ```xml\n * <w:pgSz w:w=\"15840\" w:h=\"12240\" w:orient=\"landscape\" />\n * ```\n *\n * Although the page width is 11\", and page height is 8.5\", according to the `w` and `h` attributes, because the `orient` attribute is set to landscape, pages in this section are printed on 8.5x11\" paper in landscape mode.\n *\n * The possible values for this attribute are defined by the `ST_PageOrientation` simple type (§2.18.71).\n */\n orientation?: (typeof PageOrientation)[keyof typeof PageOrientation];\n /**\n * ## Printer Paper Code\n *\n * Specifies a printer-specific paper code for the paper type, which shall be used by the printer for pages in this section.\n *\n * This code is stored to ensure the proper paper type is chosen if the specified paper size matches the sizes of multiple paper types supported by the current printer.\n *\n * It will be sent to the printer and used by the printer to determine the appropriate paper type to use when printing.\n *\n * This value is not interpreted or modified other than storing it as specified by the printer.\n *\n * The possible values for this attribute are defined by the `ST_DecimalNumber` simple type (§2.18.16).\n */\n code?: number;\n}\n\n/**\n * This element specifies the properties (size and orientation) for all pages in the current section.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_pgSz_topic_ID0ENEDT.html?hl=pgsz%2Cpage%2Csize\n *\n * ## XSD Schema\n *\n * ```xml\n * <xsd:complexType name=\"CT_PageSz\">\n * <xsd:attribute name=\"w\" type=\"s:ST_TwipsMeasure\"/>\n * <xsd:attribute name=\"h\" type=\"s:ST_TwipsMeasure\"/>\n * <xsd:attribute name=\"orient\" type=\"ST_PageOrientation\" use=\"optional\"/>\n * <xsd:attribute name=\"code\" type=\"ST_DecimalNumber\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createPageSize = ({\n width,\n height,\n orientation,\n code,\n}: PageSizeAttributes): string => {\n const widthTwips = twipsMeasureValue(width);\n const heightTwips = twipsMeasureValue(height);\n return element(\"w:pgSz\", {\n \"w:code\": code,\n \"w:h\": orientation === PageOrientation.LANDSCAPE ? widthTwips : heightTwips,\n \"w:orient\": orientation,\n \"w:w\": orientation === PageOrientation.LANDSCAPE ? heightTwips : widthTwips,\n });\n};\n","/**\n * Page text direction module for WordprocessingML section properties.\n *\n * Defines text flow direction for pages in a section.\n *\n * Reference: http://officeopenxml.com/WPsectionPr.php\n *\n * @module\n */\n\n/**\n * Specifies the text flow direction for pages in a section.\n *\n * This controls whether text flows horizontally (left-to-right) or\n * vertically (top-to-bottom), commonly used for East Asian languages.\n */\nexport const PageTextDirectionType = {\n /** Left-to-right, top-to-bottom (standard Western text flow) */\n LEFT_TO_RIGHT_TOP_TO_BOTTOM: \"lrTb\",\n /** Top-to-bottom, right-to-left (vertical East Asian text flow) */\n TOP_TO_BOTTOM_RIGHT_TO_LEFT: \"tbRl\",\n} as const;\n","/**\n * Section properties module for WordprocessingML documents.\n *\n * Section properties define page layout including page size, margins,\n * headers/footers, columns, and page numbering.\n *\n * Reference: http://officeopenxml.com/WPsection.php\n *\n * @module\n */\nimport type { HeaderFooterEntry } from \"@parts/header-footer\";\nimport type { ChangedAttributesProperties } from \"@shared/track-revision/track-revision\";\nimport type { SectionVerticalAlign } from \"@shared/vertical-align\";\n\nimport type { ColumnsAttributes } from \"./properties/columns\";\nimport type { DocGridAttributesProperties } from \"./properties/doc-grid\";\nimport type {\n EndnotePropertiesOptions,\n FootnotePropertiesOptions,\n} from \"./properties/footnote-endnote-properties\";\nimport type { LineNumberAttributes } from \"./properties/line-number\";\nimport type { PageBordersOptions } from \"./properties/page-borders\";\nimport type { PageMarginAttributes } from \"./properties/page-margin\";\nimport type { PageNumberTypeAttributes } from \"./properties/page-number\";\nimport { PageOrientation } from \"./properties/page-size\";\nimport type { PageSizeAttributes } from \"./properties/page-size\";\nimport { PageTextDirectionType } from \"./properties/page-text-direction\";\nimport type { SectionType } from \"./properties/section-type\";\n\n/**\n * Header/footer group for specifying different headers/footers\n * for default, first, and even pages.\n */\nexport interface HeaderFooterGroup<T> {\n default?: T;\n first?: T;\n even?: T;\n}\n\nexport interface SectionPropertiesOptionsBase {\n rsidRPr?: string;\n rsidDel?: string;\n rsidR?: string;\n rsidSect?: string;\n page?: {\n size?: Partial<PageSizeAttributes>;\n margin?: PageMarginAttributes;\n pageNumbers?: PageNumberTypeAttributes;\n borders?: PageBordersOptions;\n textDirection?: (typeof PageTextDirectionType)[keyof typeof PageTextDirectionType];\n };\n grid?: Partial<DocGridAttributesProperties>;\n headerWrapperGroup?: HeaderFooterGroup<HeaderFooterEntry>;\n footerWrapperGroup?: HeaderFooterGroup<HeaderFooterEntry>;\n lineNumbers?: LineNumberAttributes;\n titlePage?: boolean;\n verticalAlign?: SectionVerticalAlign;\n column?: ColumnsAttributes;\n type?: (typeof SectionType)[keyof typeof SectionType];\n noEndnote?: boolean;\n formProtection?: boolean;\n bidi?: boolean;\n rtlGutter?: boolean;\n paperSrc?: {\n first?: number;\n other?: number;\n };\n footnotePr?: FootnotePropertiesOptions;\n endnotePr?: EndnotePropertiesOptions;\n printerSettingsId?: string;\n}\n\nexport type SectionPropertiesChangeOptions = ChangedAttributesProperties &\n SectionPropertiesOptionsBase;\n\nexport type SectionPropertiesOptions = {\n revision?: SectionPropertiesChangeOptions;\n} & SectionPropertiesOptionsBase;\n\nexport const sectionMarginDefaults = {\n TOP: 1440,\n RIGHT: 1800,\n BOTTOM: 1440,\n LEFT: 1800,\n HEADER: 851,\n FOOTER: 992,\n GUTTER: 0,\n};\n\nexport const sectionPageSizeDefaults = {\n WIDTH: 11_906,\n HEIGHT: 16_838,\n ORIENTATION: PageOrientation.PORTRAIT,\n};\n","import { decimalNumber } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n\n/**\n * Specifies the type of the current document grid, which defines the grid behavior.\n *\n * The grid can define a grid which snaps all East Asian characters to grid positions, but leaves Latin text with its default spacing; a grid which adds the specified character pitch to all characters on each row; or a grid which affects only the line pitch for the current section.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_DocGrid_topic_ID0ELYP2.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_DocGrid\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"default\"/>\n * <xsd:enumeration value=\"lines\"/>\n * <xsd:enumeration value=\"linesAndChars\"/>\n * <xsd:enumeration value=\"snapToChars\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const DocumentGridType = {\n /**\n * Specifies that no document grid shall be applied to the contents of the current section in the document.\n */\n DEFAULT: \"default\",\n /**\n * Specifies that the parent section shall have additional line pitch added to each line within it (as specified on the <docGrid> element (§2.6.5)) in order to maintain the specified number of lines per page.\n */\n LINES: \"lines\",\n /**\n * Specifies that the parent section shall have both the additional line pitch and character pitch added to each line and character within it (as specified on the <docGrid> element (§2.6.5)) in order to maintain a specific number of lines per page and characters per line.\n *\n * When this value is set, the input specified via the user interface may be allowed in exact number of line/character pitch units. */\n LINES_AND_CHARS: \"linesAndChars\",\n /**\n * Specifies that the parent section shall have both the additional line pitch and character pitch added to each line and character within it (as specified on the <docGrid> element (§2.6.5)) in order to maintain a specific number of lines per page and characters per line.\n *\n * When this value is set, the input specified via the user interface may be restricted to the number of lines per page and characters per line, with the consumer or producer translating this information based on the current font data to get the resulting line and character pitch values\n */\n SNAP_TO_CHARS: \"snapToChars\",\n} as const;\n\nexport interface DocGridAttributesProperties {\n /**\n * Specifies the type of the current document grid, which defines the grid behavior.\n *\n * The grid can define a grid which snaps all East Asian characters to grid positions, but leaves Latin text with its default spacing; a grid which adds the specified character pitch to each character on each row; or a grid which affects only the line pitch for the current section.\n */\n type?: (typeof DocumentGridType)[keyof typeof DocumentGridType];\n /**\n * Specifies the number of lines to be allowed on the document grid for the current page assuming all lines have equal line pitch applied to them. This line pitch shall not be added to any line which appears within a table cell unless the <adjustLineHeightInTable> element (§2.15.3.1) is present in the document's compatibility settings.\n *\n * This attribute is specified in twentieths of a point, and defines the pitch for each line of text on this page such that the desired number of single spaced lines of text fits on the current page.\n *\n * ```xml\n * <w:docGrid w:linePitch=\"684\" …/>\n * ```\n *\n * The `linePitch` attribute specifies that 34.2 points is to the amount of pitch allowed for each line on this page in order to maintain the specific document grid. ]\n *\n * Individual paragraphs can override the line pitch information specified for the document grid by either:\n *\n * Specifying an exact line spacing value using the `lineRule` attribute of value exact on the <spacing> element (§2.3.1.33).\n *\n * Specifying that the paragraph text shall not snap to the document grid via the <snapToGrid> element (§2.3.1.32).\n *\n * The possible values for this attribute are defined by the ST_DecimalNumber simple type (§2.18.16).\n */\n linePitch: number;\n /**\n * Specifies the number of characters to be allowed on the document grid for each line in this section.\n *\n * This attribute's value shall be specified by multiplying the difference between the desired character pitch and the character pitch for that character in the font size of the Normal font by 4096.\n *\n * This value shall then be used to add the character pitch for the specified point size to each character in the section [: This results in text in the Normal style having a specific number of characters per line. ]\n *\n * ```xml\n * <w:docGrid w:charSize=\"40960\" …/>\n * ```\n * The `charSpace` attribute specifies a value of 40960, which means that the delta between the character pitch of each character in the grid and the Normal font is 10 points, resulting in a character pitch of 11+10 = 21 points for all characters in this section. ]\n *\n * Individual runs of text can override the line pitch information specified for the document grid by specifying that the run text shall not snap to the document grid via the <snapToGrid> element (§2.3.2.32).\n *\n * The possible values for this attribute are defined by the `ST_DecimalNumber` simple type (§2.18.16).\n */\n charSpace?: number;\n}\n\n/**\n * This element specifies the settings for the document grid, which enables precise layout of full-width East Asian language characters within a document by specifying the desired number of characters per line and lines per page for all East Asian text content in this section.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_docGrid_topic_ID0EHU5S.html\n *\n * ```xml\n * <xsd:complexType name=\"CT_DocGrid\">\n * <xsd:attribute name=\"type\" type=\"ST_DocGrid\"/>\n * <xsd:attribute name=\"linePitch\" type=\"ST_DecimalNumber\"/>\n * <xsd:attribute name=\"charSpace\" type=\"ST_DecimalNumber\"/>\n * </xsd:complexType>\n * ```\n * @returns\n */\nexport const createDocumentGrid = ({\n type,\n linePitch,\n charSpace,\n}: DocGridAttributesProperties): string =>\n element(\"w:docGrid\", {\n \"w:charSpace\": charSpace ? decimalNumber(charSpace) : undefined,\n \"w:linePitch\": decimalNumber(linePitch),\n \"w:type\": type,\n });\n","import { decimalNumber } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n/**\n * Page number module for WordprocessingML section properties.\n *\n * Defines page numbering format and starting value for document sections.\n *\n * Reference: http://officeopenxml.com/WPSectionPgNumType.php\n *\n * @module\n */\nimport type { NumberFormat } from \"@shared/constants\";\n\n/**\n * Specifies the separator character between chapter number and page number.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_ChapterSep\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"hyphen\"/>\n * <xsd:enumeration value=\"period\"/>\n * <xsd:enumeration value=\"colon\"/>\n * <xsd:enumeration value=\"emDash\"/>\n * <xsd:enumeration value=\"enDash\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageNumberSeparator = {\n /** Hyphen separator (-) */\n HYPHEN: \"hyphen\",\n /** Period separator (.) */\n PERIOD: \"period\",\n /** Colon separator (:) */\n COLON: \"colon\",\n /** Em dash separator (—) */\n EM_DASH: \"emDash\",\n /** En dash separator (–) */\n EN_DASH: \"enDash\",\n} as const;\n\n/**\n * Options for configuring page numbering.\n *\n * @property start - Starting page number for the section\n * @property formatType - Number format (decimal, roman, letter, etc.)\n * @property separator - Separator between chapter and page number\n */\nexport interface PageNumberTypeAttributes {\n /** Starting page number for the section */\n start?: number;\n /** Number format (decimal, roman, letter, etc., default: decimal) */\n formatType?: (typeof NumberFormat)[keyof typeof NumberFormat];\n /** Separator between chapter and page number (default: hyphen) */\n separator?: (typeof PageNumberSeparator)[keyof typeof PageNumberSeparator];\n /** Heading style ID for chapter numbering */\n chapStyle?: number;\n}\n\n/**\n * Creates page numbering settings (pgNumType) for a document section.\n *\n * This element specifies the page numbering format and starting value\n * for all pages in a section.\n *\n * Reference: http://officeopenxml.com/WPSectionPgNumType.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PageNumber\">\n * <xsd:attribute name=\"fmt\" type=\"ST_NumberFormat\" use=\"optional\" default=\"decimal\"/>\n * <xsd:attribute name=\"start\" type=\"ST_DecimalNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"chapStyle\" type=\"ST_DecimalNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"chapSep\" type=\"ST_ChapterSep\" use=\"optional\" default=\"hyphen\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Start page numbering at 5 with lowercase roman numerals\n * createPageNumberType({\n * start: 5,\n * formatType: NumberFormat.LOWER_ROMAN\n * });\n * ```\n */\nexport const createPageNumberType = ({\n start,\n formatType,\n separator,\n chapStyle,\n}: PageNumberTypeAttributes): string =>\n element(\"w:pgNumType\", {\n \"w:chapStyle\": chapStyle === undefined ? undefined : decimalNumber(chapStyle),\n \"w:fmt\": formatType,\n \"w:chapSep\": separator,\n \"w:start\": start === undefined ? undefined : decimalNumber(start),\n });\n","/**\n * Page borders module for WordprocessingML section properties.\n *\n * Defines borders around pages in a document section.\n *\n * Reference: http://officeopenxml.com/WPsectionBorders.php\n *\n * @module\n */\nimport type { BorderOptions } from \"@shared/border\";\n\n/**\n * Specifies which pages display the page border.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_PageBorderDisplay\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"allPages\"/>\n * <xsd:enumeration value=\"firstPage\"/>\n * <xsd:enumeration value=\"notFirstPage\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageBorderDisplay = {\n /** Display border on all pages */\n ALL_PAGES: \"allPages\",\n /** Display border only on first page */\n FIRST_PAGE: \"firstPage\",\n /** Display border on all pages except first page */\n NOT_FIRST_PAGE: \"notFirstPage\",\n} as const;\n\n/**\n * Specifies whether page border is positioned relative to page edge or text.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_PageBorderOffset\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"page\"/>\n * <xsd:enumeration value=\"text\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageBorderOffsetFrom = {\n /** Position border relative to page edge */\n PAGE: \"page\",\n /** Position border relative to text (default) */\n TEXT: \"text\",\n} as const;\n\n/**\n * Specifies z-order of page border relative to intersecting objects.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_PageBorderZOrder\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"front\"/>\n * <xsd:enumeration value=\"back\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageBorderZOrder = {\n /** Display border behind page contents */\n BACK: \"back\",\n /** Display border in front of page contents (default) */\n FRONT: \"front\",\n} as const;\n\n/**\n * Options for configuring page borders.\n *\n * @property display - Which pages display the border\n * @property offsetFrom - Whether border is positioned relative to page or text\n * @property zOrder - Whether border appears in front or behind page contents\n * @property top - Top border styling\n * @property right - Right border styling\n * @property bottom - Bottom border styling\n * @property left - Left border styling\n */\nexport interface PageBordersOptions {\n /** Which pages display the border */\n display?: (typeof PageBorderDisplay)[keyof typeof PageBorderDisplay];\n /** Whether border is positioned relative to page or text (default: text) */\n offsetFrom?: (typeof PageBorderOffsetFrom)[keyof typeof PageBorderOffsetFrom];\n /** Whether border appears in front or behind page contents (default: front) */\n zOrder?: (typeof PageBorderZOrder)[keyof typeof PageBorderZOrder];\n /** Top border styling */\n top?: BorderOptions;\n /** Right border styling */\n right?: BorderOptions;\n /** Bottom border styling */\n bottom?: BorderOptions;\n /** Left border styling */\n left?: BorderOptions;\n}\n","/**\n * Page margin module for WordprocessingML section properties.\n *\n * Defines page margins for document sections.\n *\n * Reference: http://officeopenxml.com/WPsectionPr.php\n *\n * @module\n */\nimport { signedTwipsMeasureValue, twipsMeasureValue } from \"@office-open/core\";\nimport type { PositiveUniversalMeasure, UniversalMeasure } from \"@office-open/core\";\n\n/**\n * Options for configuring page margins.\n *\n * All measurements are in twips (1/20th of a point) or universal measure.\n *\n * @property top - Top margin\n * @property right - Right margin\n * @property bottom - Bottom margin\n * @property left - Left margin\n * @property header - Header margin (distance from top of page to header)\n * @property footer - Footer margin (distance from bottom of page to footer)\n * @property gutter - Gutter margin for binding\n */\nexport interface PageMarginAttributes {\n /** Top margin in twips or universal measure */\n top?: number | UniversalMeasure;\n /** Right margin in twips or universal measure */\n right?: number | PositiveUniversalMeasure;\n /** Bottom margin in twips or universal measure */\n bottom?: number | UniversalMeasure;\n /** Left margin in twips or universal measure */\n left?: number | PositiveUniversalMeasure;\n /** Header margin (distance from top of page to header) in twips or universal measure */\n header?: number | PositiveUniversalMeasure;\n /** Footer margin (distance from bottom of page to footer) in twips or universal measure */\n footer?: number | PositiveUniversalMeasure;\n /** Gutter margin for binding in twips or universal measure */\n gutter?: number | PositiveUniversalMeasure;\n}\n\n/**\n * Creates page margins (pgMar) for a document section.\n *\n * This element specifies the page margins for all pages in a section,\n * including top, bottom, left, right, header, footer, and gutter margins.\n *\n * Reference: http://officeopenxml.com/WPsectionPr.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PageMar\">\n * <xsd:attribute name=\"top\" type=\"ST_SignedTwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"right\" type=\"s:ST_TwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"bottom\" type=\"ST_SignedTwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"left\" type=\"s:ST_TwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"header\" type=\"s:ST_TwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"footer\" type=\"s:ST_TwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"gutter\" type=\"s:ST_TwipsMeasure\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Create page margins with 1 inch margins (1440 twips = 1 inch)\n * createPageMargin(1440, 1440, 1440, 1440, 720, 720, 0);\n * ```\n */\nexport const createPageMargin = (\n top: number | UniversalMeasure,\n right: number | PositiveUniversalMeasure,\n bottom: number | UniversalMeasure,\n left: number | PositiveUniversalMeasure,\n header: number | PositiveUniversalMeasure,\n footer: number | PositiveUniversalMeasure,\n gutter: number | PositiveUniversalMeasure,\n): string =>\n `<w:pgMar w:bottom=\"${signedTwipsMeasureValue(bottom)}\" w:footer=\"${twipsMeasureValue(footer)}\" w:gutter=\"${twipsMeasureValue(gutter)}\" w:header=\"${twipsMeasureValue(header)}\" w:left=\"${twipsMeasureValue(left)}\" w:right=\"${twipsMeasureValue(right)}\" w:top=\"${signedTwipsMeasureValue(top)}\"/>`;\n","import { decimalNumber, twipsMeasureValue } from \"@office-open/core\";\nimport type { PositiveUniversalMeasure } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n\n/**\n * This simple type specifies when the line numbering in the parent section shall be reset to its restart value. The line numbering increments for each line (even if the line number itself is not displayed) until it reaches the restart point specified by this element.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_LineNumberRestart_topic_ID0EUS42.html\n *\n * ## XSD Schema\n *\n * ```xml\n * <xsd:simpleType name=\"ST_LineNumberRestart\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"newPage\"/>\n * <xsd:enumeration value=\"newSection\"/>\n * <xsd:enumeration value=\"continuous\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const LineNumberRestartFormat = {\n /**\n * ## Restart Line Numbering on Each Page\n *\n * Specifies that line numbering for the parent section shall restart to the starting value whenever a new page is displayed.\n */\n NEW_PAGE: \"newPage\",\n /**\n * ## Restart Line Numbering for Each Section\n *\n * Specifies that line numbering for the parent section shall restart to the starting value whenever the parent begins.\n */\n NEW_SECTION: \"newSection\",\n /**\n * ## Continue Line Numbering From Previous Section\n *\n * Specifies that line numbering for the parent section shall continue from the line numbering from the end of the previous section, if any.\n */\n CONTINUOUS: \"continuous\",\n} as const;\n\nexport interface LineNumberAttributes {\n /**\n * Specifies the line number increments to be displayed in the current document.\n *\n * Although each line has an associated line number, only lines which are an even multiple of this value shall be displayed.\n *\n * ### Example\n *\n * ```xml\n * <w:lnNumType … w:countBy=\"5\"/>\n * ```\n *\n * This setting ensures that only lines whose number is a multiple of (e.g. 5, 10, and 15) will have a line number displayed. ]\n *\n * The possible values for this attribute are defined by the ST_DecimalNumber simple type (§2.18.16).\n */\n countBy?: number;\n /**\n * ## Line Numbering Starting Value\n *\n * Specifies the starting value used for the first line whenever the line numbering is restarted by use of the `restart` attribute.\n *\n * ### Example\n *\n * ```xml\n * <w:lnNumType w:start=\"3\" w:countBy=\"5\"/>\n * ```\n *\n * The `start` attribute specifies that line numbers shall be counted starting from the number 3.\n *\n * The possible values for this attribute are defined by the ST_DecimalNumber simple type (§2.18.16).\n */\n start?: number;\n /**\n * ## Line Numbering Restart Setting\n *\n * Specifies when the line numbering in this section shall be reset to the line number specified by the `start` attribute's value.\n *\n * The line numbering increments for each line (even if it is not displayed) until it reaches the restart point specified by this element.\n *\n * ### Example\n *\n * ```xml\n * <w:sectPr>\n * ...\n * <w:lnNumType w:restart=\"newPage\" ... />\n * </w:sectPr>\n * ```\n *\n * The value of `newPage` specifies that the line numbers shall restart at the top of each page to the value specified by the `start` attribute. In this case, `newPage` is the default, so this value could have been omitted entirely.\n *\n * The possible values for this attribute are defined by the ST_LineNumberRestart simple type (§2.18.54).\n */\n restart?: (typeof LineNumberRestartFormat)[keyof typeof LineNumberRestartFormat];\n /**\n * Specifies the distance between the text margin and the edge of any line numbers appearing in that section.\n *\n * ```xml\n * <w:lnNumType ... w:distance=\"720\"/>\n * ```\n *\n * The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§2.18.105).\n */\n distance?: number | PositiveUniversalMeasure;\n}\n\n/**\n * This element specifies the settings for line numbering to be displayed before each column of text in this section in the document.\n *\n * References:\n * - https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_lnNumType_topic_ID0EVRAT.html\n * - http://officeopenxml.com/WPsectionLineNumbering.php\n *\n * ## XSD Schema\n *\n * ```xml\n * <xsd:complexType name=\"CT_LineNumber\">\n * <xsd:attribute name=\"countBy\" type=\"ST_DecimalNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"start\" type=\"ST_DecimalNumber\" use=\"optional\" default=\"1\"/>\n * <xsd:attribute name=\"distance\" type=\"s:ST_TwipsMeasure\" use=\"optional\"/>\n * <xsd:attribute name=\"restart\" type=\"ST_LineNumberRestart\" use=\"optional\" default=\"newPage\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createLineNumberType = ({\n countBy,\n start,\n restart,\n distance,\n}: LineNumberAttributes): string =>\n element(\"w:lnNumType\", {\n \"w:countBy\": countBy === undefined ? undefined : decimalNumber(countBy),\n \"w:distance\": distance === undefined ? undefined : twipsMeasureValue(distance),\n \"w:restart\": restart,\n \"w:start\": start === undefined ? undefined : decimalNumber(start),\n });\n","/**\n * Section type module for WordprocessingML section properties.\n *\n * Defines how a section begins relative to the previous section.\n *\n * Reference: http://officeopenxml.com/WPsection.php\n *\n * @module\n */\n/**\n * Specifies the type of section break.\n *\n * This determines where the section begins relative to the previous section.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_SectionMark\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"nextPage\"/>\n * <xsd:enumeration value=\"nextColumn\"/>\n * <xsd:enumeration value=\"continuous\"/>\n * <xsd:enumeration value=\"evenPage\"/>\n * <xsd:enumeration value=\"oddPage\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const SectionType = {\n /** Section begins on the next page */\n NEXT_PAGE: \"nextPage\",\n /** Section begins on the next column */\n NEXT_COLUMN: \"nextColumn\",\n /** Section begins immediately following the previous section */\n CONTINUOUS: \"continuous\",\n /** Section begins on the next even-numbered page */\n EVEN_PAGE: \"evenPage\",\n /** Section begins on the next odd-numbered page */\n ODD_PAGE: \"oddPage\",\n} as const;\n\n/**\n * Creates section type (type) for a document section.\n *\n * This element specifies the type of section break, which determines\n * where the new section begins relative to the previous section.\n *\n * Reference: http://officeopenxml.com/WPsection.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_SectType\">\n * <xsd:attribute name=\"val\" type=\"ST_SectionMark\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Create a continuous section (no page break)\n * createSectionType(SectionType.CONTINUOUS);\n *\n * // Create a section that starts on next odd page\n * createSectionType(SectionType.ODD_PAGE);\n * ```\n */\nexport const createSectionType = (value: (typeof SectionType)[keyof typeof SectionType]): string =>\n `<w:type w:val=\"${value}\"/>`;\n","/**\n * This simple type specifies the possible types of headers and footers which may be specified for a given header or footer reference in a document. This value determines the page(s) on which the current header or footer shall be displayed.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_HdrFtr_topic_ID0E2UW2.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_HdrFtr\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"even\"/>\n * <xsd:enumeration value=\"default\"/>\n * <xsd:enumeration value=\"first\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const HeaderFooterReferenceType = {\n /** Specifies that this header or footer shall appear on every page in this section which is not overridden with a specific `even` or `first` page header/footer. In a section with all three types specified, this type shall be used on all odd numbered pages (counting from the `first` page in the section, not the section numbering). */\n DEFAULT: \"default\",\n /** Specifies that this header or footer shall appear on the first page in this section. The appearance of this header or footer is contingent on the setting of the `titlePg` element (§2.10.6). */\n FIRST: \"first\",\n /** Specifies that this header or footer shall appear on all even numbered pages in this section (counting from the first page in the section, not the section numbering). The appearance of this header or footer is contingent on the setting of the `evenAndOddHeaders` element (§2.10.1). */\n EVEN: \"even\",\n} as const;\n\n// <xsd:group name=\"EG_HdrFtrReferences\">\n// <xsd:choice>\n// <xsd:element name=\"headerReference\" type=\"CT_HdrFtrRef\" minOccurs=\"0\"/>\n// <xsd:element name=\"footerReference\" type=\"CT_HdrFtrRef\" minOccurs=\"0\"/>\n// </xsd:choice>\n// </xsd:group>\n\n// <xsd:complexType name=\"CT_HdrFtrRef\">\n// <xsd:complexContent>\n// <xsd:extension base=\"CT_Rel\">\n// <xsd:attribute name=\"type\" type=\"ST_HdrFtr\" use=\"required\"/>\n// </xsd:extension>\n// </xsd:complexContent>\n\n// <xsd:complexType name=\"CT_Rel\">\n// <xsd:attribute ref=\"r:id\" use=\"required\"/>\n// </xsd:complexType>\n\nexport interface HeaderFooterReferenceOptions {\n type?: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType];\n id?: number;\n}\n\nexport const HeaderFooterType = {\n FOOTER: \"w:footerReference\",\n HEADER: \"w:headerReference\",\n} as const;\n\nexport const createHeaderFooterReference = (\n type: (typeof HeaderFooterType)[keyof typeof HeaderFooterType],\n options: HeaderFooterReferenceOptions,\n): string =>\n `<${type} r:id=\"rId${options.id}\" w:type=\"${options.type || HeaderFooterReferenceType.DEFAULT}\"/>`;\n","/**\n * Section properties descriptor for DOCX documents.\n *\n * Produces `<w:sectPr>` XML directly from options, eliminating all\n * intermediate XmlComponent instances (create* + toXml pattern).\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_SectPr\n *\n * @module\n */\n\nimport { convertToTwip } from \"@office-open/core\";\nimport { twipsMeasureValue } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { ColumnAttributes } from \"@parts/document/body/section-properties/properties/column\";\nimport type { ColumnsAttributes } from \"@parts/document/body/section-properties/properties/columns\";\nimport type {\n EndnotePropertiesOptions,\n FootnotePropertiesOptions,\n} from \"@parts/document/body/section-properties/properties/footnote-endnote-properties\";\nimport type { PageBordersOptions } from \"@parts/document/body/section-properties/properties/page-borders\";\nimport { PageNumberSeparator } from \"@parts/document/body/section-properties/properties/page-number\";\nimport type { PageNumberTypeAttributes } from \"@parts/document/body/section-properties/properties/page-number\";\nimport type {\n SectionPropertiesChangeOptions,\n SectionPropertiesOptions,\n} from \"@parts/document/body/section-properties/section-properties\";\nimport {\n sectionMarginDefaults,\n sectionPageSizeDefaults,\n} from \"@parts/document/body/section-properties/section-properties\";\nimport type { HeaderFooterEntry } from \"@parts/header-footer\";\nimport type { BorderOptions } from \"@shared/border\";\nimport { NumberFormat } from \"@shared/constants\";\nimport type { BodyContext } from \"@shared/index\";\n\n/** Valid page-number @w:fmt values (ST_NumberFormat). */\nconst PAGE_NUMBER_FORMATS = Object.values(NumberFormat) as readonly string[];\n/** Valid page-number @w:chapSep values (ST_ChapterSep). */\nconst PAGE_NUMBER_SEPARATORS = Object.values(PageNumberSeparator) as readonly string[];\n\n// ── Border XML helper ──\n\nfunction stringifyBorderXml(tag: string, opts: BorderOptions): string {\n const attrs: string[] = [];\n if (opts.style !== undefined) attrs.push(`w:val=\"${opts.style}\"`);\n if (opts.color !== undefined) attrs.push(`w:color=\"${opts.color}\"`);\n if (opts.size !== undefined) attrs.push(`w:sz=\"${opts.size}\"`);\n if (opts.space !== undefined) attrs.push(`w:space=\"${opts.space}\"`);\n if (opts.themeColor !== undefined) attrs.push(`w:themeColor=\"${opts.themeColor}\"`);\n if (opts.themeTint !== undefined) attrs.push(`w:themeTint=\"${opts.themeTint}\"`);\n if (opts.themeShade !== undefined) attrs.push(`w:themeShade=\"${opts.themeShade}\"`);\n if (opts.shadow !== undefined) attrs.push(`w:shadow=\"${opts.shadow ? 1 : 0}\"`);\n if (opts.frame !== undefined) attrs.push(`w:frame=\"${opts.frame ? 1 : 0}\"`);\n return `<${tag} ${attrs.join(\" \")}/>`;\n}\n\n// ── Inline XML builders (replacing create* + toXml) ──\n\nfunction pageSizeXml(\n w: number | string,\n h: number | string,\n orient?: string,\n code?: number,\n): string {\n const attrs: string[] = [`w:w=\"${w}\"`, `w:h=\"${h}\"`];\n if (orient) attrs.push(`w:orient=\"${orient}\"`);\n if (code !== undefined) attrs.push(`w:code=\"${code}\"`);\n return `<w:pgSz ${attrs.join(\" \")}/>`;\n}\n\nfunction pageMarginXml(\n top: number | string,\n right: number | string,\n bottom: number | string,\n left: number | string,\n header: number | string,\n footer: number | string,\n gutter: number | string,\n): string {\n return `<w:pgMar w:top=\"${top}\" w:right=\"${right}\" w:bottom=\"${bottom}\" w:left=\"${left}\" w:header=\"${header}\" w:footer=\"${footer}\" w:gutter=\"${gutter}\"/>`;\n}\n\nfunction headerFooterRefXml(tag: string, id: number, type: string): string {\n return `<${tag} r:id=\"rId${id}\" w:type=\"${type}\"/>`;\n}\n\nfunction sectionTypeXml(val: string): string {\n return `<w:type w:val=\"${val}\"/>`;\n}\n\nfunction verticalAlignXml(val: string): string {\n return `<w:vAlign w:val=\"${val}\"/>`;\n}\n\nfunction lineNumberXml(opts: NonNullable<SectionPropertiesOptions[\"lineNumbers\"]>): string {\n const attrs: string[] = [];\n if (opts.countBy !== undefined) attrs.push(`w:countBy=\"${opts.countBy}\"`);\n if (opts.start !== undefined) attrs.push(`w:start=\"${opts.start}\"`);\n if (opts.restart !== undefined) attrs.push(`w:restart=\"${opts.restart}\"`);\n if (opts.distance !== undefined) attrs.push(`w:distance=\"${opts.distance}\"`);\n return attrs.length ? `<w:lnNumType ${attrs.join(\" \")}/>` : \"<w:lnNumType/>\";\n}\n\nfunction pageNumberXml(opts: NonNullable<PageNumberTypeAttributes>): string {\n const attrs: string[] = [];\n if (opts.start !== undefined) attrs.push(`w:start=\"${opts.start}\"`);\n if (opts.formatType !== undefined) attrs.push(`w:fmt=\"${opts.formatType}\"`);\n if (opts.separator !== undefined) attrs.push(`w:chapSep=\"${opts.separator}\"`);\n if (opts.chapStyle !== undefined) attrs.push(`w:chapStyle=\"${opts.chapStyle}\"`);\n return attrs.length ? `<w:pgNumType ${attrs.join(\" \")}/>` : \"<w:pgNumType/>\";\n}\n\nfunction docGridXml(linePitch: number, charSpace?: number, type?: string): string {\n const attrs: string[] = [`w:linePitch=\"${linePitch}\"`];\n if (charSpace !== undefined) attrs.push(`w:charSpace=\"${charSpace}\"`);\n if (type !== undefined) attrs.push(`w:type=\"${type}\"`);\n return `<w:docGrid ${attrs.join(\" \")}/>`;\n}\n\nfunction columnsXml(opts: NonNullable<SectionPropertiesOptions[\"column\"]>): string {\n const attrs: string[] = [];\n if (opts.space !== undefined) attrs.push(`w:space=\"${twipsMeasureValue(opts.space)}\"`);\n if (opts.count !== undefined) attrs.push(`w:num=\"${opts.count}\"`);\n if (opts.separate !== undefined) attrs.push(`w:sep=\"${opts.separate ? 1 : 0}\"`);\n if (opts.equalWidth !== undefined) attrs.push(`w:equalWidth=\"${opts.equalWidth ? 1 : 0}\"`);\n\n const attrStr = attrs.join(\" \");\n\n // Custom width columns — children are ColumnAttributes (Column class implements this interface)\n if (!opts.equalWidth && opts.children) {\n const colParts: string[] = [];\n for (const col of opts.children as readonly ColumnAttributes[]) {\n const colAttrs: string[] = [`w:w=\"${twipsMeasureValue(col.width)}\"`];\n if (col.space !== undefined) colAttrs.push(`w:space=\"${twipsMeasureValue(col.space)}\"`);\n colParts.push(`<w:col ${colAttrs.join(\" \")}/>`);\n }\n return `<w:cols ${attrStr}>${colParts.join(\"\")}</w:cols>`;\n }\n return `<w:cols ${attrStr}/>`;\n}\n\nfunction footnotePrXml(\n tag: string,\n opts: FootnotePropertiesOptions | EndnotePropertiesOptions,\n): string {\n const parts: string[] = [];\n if (opts.pos !== undefined) parts.push(`<w:pos w:val=\"${opts.pos}\"/>`);\n if (opts.formatType !== undefined || opts.format !== undefined) {\n const fmtAttrs: string[] = [];\n if (opts.formatType !== undefined) fmtAttrs.push(`w:fmt=\"${opts.formatType}\"`);\n if (opts.format !== undefined) fmtAttrs.push(`w:format=\"${opts.format}\"`);\n parts.push(`<w:numFmt ${fmtAttrs.join(\" \")}/>`);\n }\n if (opts.numStart !== undefined) parts.push(`<w:numStart w:val=\"${opts.numStart}\"/>`);\n if (opts.numRestart !== undefined) parts.push(`<w:numRestart w:val=\"${opts.numRestart}\"/>`);\n const body = parts.join(\"\");\n return body ? `<${tag}>${body}</${tag}>` : `<${tag}/>`;\n}\n\nfunction pageBordersXml(opts: NonNullable<PageBordersOptions>): string {\n const attrs: string[] = [];\n if (opts.display !== undefined) attrs.push(`w:display=\"${opts.display}\"`);\n if (opts.offsetFrom !== undefined) attrs.push(`w:offsetFrom=\"${opts.offsetFrom}\"`);\n if (opts.zOrder !== undefined) attrs.push(`w:zOrder=\"${opts.zOrder}\"`);\n\n const parts: string[] = [];\n if (opts.top) parts.push(stringifyBorderXml(\"w:top\", opts.top));\n if (opts.left) parts.push(stringifyBorderXml(\"w:left\", opts.left));\n if (opts.bottom) parts.push(stringifyBorderXml(\"w:bottom\", opts.bottom));\n if (opts.right) parts.push(stringifyBorderXml(\"w:right\", opts.right));\n\n const attrStr = attrs.join(\" \");\n const body = parts.join(\"\");\n if (!body && !attrStr) return \"<w:pgBorders/>\";\n return body ? `<w:pgBorders ${attrStr}>${body}</w:pgBorders>` : `<w:pgBorders ${attrStr}/>`;\n}\n\n// ── Header/footer references ──\n\nfunction appendHeaderFooterRefs(\n parts: string[],\n type: \"w:headerReference\" | \"w:footerReference\",\n group?: { default?: HeaderFooterEntry; first?: HeaderFooterEntry; even?: HeaderFooterEntry },\n): void {\n if (!group) return;\n if (group.default) parts.push(headerFooterRefXml(type, group.default.referenceId, \"default\"));\n if (group.first) parts.push(headerFooterRefXml(type, group.first.referenceId, \"first\"));\n if (group.even) parts.push(headerFooterRefXml(type, group.even.referenceId, \"even\"));\n}\n\n// ── sectPrChange (recursive) ──\n\nfunction stringifySectionPropertiesChange(opts: SectionPropertiesChangeOptions): string {\n const { author, date, id, ...inner } = opts;\n const innerXml = stringifySectionPropertiesInner(inner);\n return `<w:sectPrChange w:author=\"${author}\" w:date=\"${date}\" w:id=\"${id}\"><w:sectPr>${innerXml}</w:sectPr></w:sectPrChange>`;\n}\n\n// ── Core XML builder ──\n\nfunction stringifySectionPropertiesInner(opts: SectionPropertiesOptions): string {\n const parts: string[] = [];\n\n // Header/footer references\n appendHeaderFooterRefs(parts, \"w:headerReference\", opts.headerWrapperGroup);\n appendHeaderFooterRefs(parts, \"w:footerReference\", opts.footerWrapperGroup);\n\n // Destructure page options with defaults\n const {\n size: {\n width = sectionPageSizeDefaults.WIDTH,\n height = sectionPageSizeDefaults.HEIGHT,\n orientation = sectionPageSizeDefaults.ORIENTATION,\n code,\n } = {},\n margin: {\n top = sectionMarginDefaults.TOP,\n right = sectionMarginDefaults.RIGHT,\n bottom = sectionMarginDefaults.BOTTOM,\n left = sectionMarginDefaults.LEFT,\n header = sectionMarginDefaults.HEADER,\n footer = sectionMarginDefaults.FOOTER,\n gutter = sectionMarginDefaults.GUTTER,\n } = {},\n pageNumbers = {},\n borders,\n textDirection,\n } = opts.page ?? {};\n\n const { linePitch = 312, charSpace = 0, type: gridType = \"lines\" } = opts.grid ?? {};\n\n // Footnote/endnote properties\n if (opts.footnotePr) parts.push(footnotePrXml(\"w:footnotePr\", opts.footnotePr));\n if (opts.endnotePr) parts.push(footnotePrXml(\"w:endnotePr\", opts.endnotePr));\n\n // Section type\n if (opts.type) parts.push(sectionTypeXml(opts.type));\n\n // Page size — swap w/h when landscape\n const pgW = orientation === \"landscape\" ? convertToTwip(height) : width;\n const pgH = orientation === \"landscape\" ? convertToTwip(width) : height;\n parts.push(pageSizeXml(pgW, pgH, orientation, code));\n\n // Page margin (always present)\n parts.push(pageMarginXml(top, right, bottom, left, header, footer, gutter));\n\n // Page borders\n if (borders) parts.push(pageBordersXml(borders));\n\n // Line numbers\n if (opts.lineNumbers) parts.push(lineNumberXml(opts.lineNumbers));\n\n // Page numbers\n parts.push(pageNumberXml(pageNumbers));\n\n // Columns\n if (opts.column) parts.push(columnsXml(opts.column));\n\n // Vertical alignment\n if (opts.verticalAlign) parts.push(verticalAlignXml(opts.verticalAlign));\n\n // Boolean on/off elements — direct string output\n if (opts.titlePage !== undefined)\n parts.push(opts.titlePage ? \"<w:titlePg/>\" : '<w:titlePg w:val=\"0\"/>');\n if (textDirection) parts.push(`<w:textDirection w:val=\"${textDirection}\"/>`);\n if (opts.noEndnote !== undefined)\n parts.push(opts.noEndnote ? \"<w:noEndnote/>\" : '<w:noEndnote w:val=\"0\"/>');\n if (opts.formProtection !== undefined)\n parts.push(opts.formProtection ? \"<w:formProt/>\" : '<w:formProt w:val=\"0\"/>');\n if (opts.bidi !== undefined) parts.push(opts.bidi ? \"<w:bidi/>\" : '<w:bidi w:val=\"0\"/>');\n if (opts.rtlGutter !== undefined)\n parts.push(opts.rtlGutter ? \"<w:rtlGutter/>\" : '<w:rtlGutter w:val=\"0\"/>');\n\n // Paper source\n if (opts.paperSrc) {\n const psAttr: string[] = [];\n if (opts.paperSrc.first !== undefined) psAttr.push(`w:first=\"${opts.paperSrc.first}\"`);\n if (opts.paperSrc.other !== undefined) psAttr.push(`w:other=\"${opts.paperSrc.other}\"`);\n parts.push(`<w:paperSrc ${psAttr.join(\" \")}/>`);\n }\n\n // Printer settings\n if (opts.printerSettingsId !== undefined) {\n parts.push(`<w:printerSettings r:id=\"${opts.printerSettingsId}\"/>`);\n }\n\n // Document grid\n parts.push(docGridXml(linePitch, charSpace, gridType));\n\n // Revision (sectPrChange)\n if (opts.revision) {\n parts.push(stringifySectionPropertiesChange(opts.revision));\n }\n\n return parts.join(\"\");\n}\n\n// ── Descriptor ──\n\n/**\n * Section properties descriptor for DOCX `<w:sectPr>` elements.\n *\n * Produces complete XML directly from options — zero XmlComponent instances\n * in the hot path. All `create*()` + `.toXml()` calls eliminated in favor\n * of direct string concatenation.\n *\n * @example\n * ```typescript\n * const xml = sectionPropertiesDesc.stringify(sectPrOpts, ctx);\n * ```\n */\nexport const sectionPropertiesDesc: CustomDescriptor<SectionPropertiesOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n return stringifySectionPropertiesXml(opts);\n },\n\n parse(el, _ctx) {\n return parseSectionPropertiesEl(el);\n },\n};\n\n/** Standalone stringify — no context needed, pure options → XML. */\nexport function stringifySectionPropertiesXml(opts: SectionPropertiesOptions): string {\n const inner = stringifySectionPropertiesInner(opts);\n\n const attrs: string[] = [];\n if (opts.rsidRPr !== undefined) attrs.push(`w:rsidRPr=\"${opts.rsidRPr}\"`);\n if (opts.rsidDel !== undefined) attrs.push(`w:rsidDel=\"${opts.rsidDel}\"`);\n if (opts.rsidR !== undefined) attrs.push(`w:rsidR=\"${opts.rsidR}\"`);\n if (opts.rsidSect !== undefined) attrs.push(`w:rsidSect=\"${opts.rsidSect}\"`);\n\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n return `<w:sectPr${attrStr}>${inner}</w:sectPr>`;\n}\n\n// ── Parse (Element → SectionPropertiesOptions) ──\n\n/** Parse a w:sectPr element into SectionPropertiesOptions. */\nexport function parseSectionPropertiesEl(el: Element): Partial<SectionPropertiesOptions> {\n const opts: Record<string, unknown> = {};\n\n // rsid attributes on w:sectPr element\n for (const [attrName, optKey] of [\n [\"w:rsidR\", \"rsidR\"],\n [\"w:rsidRPr\", \"rsidRPr\"],\n [\"w:rsidDel\", \"rsidDel\"],\n [\"w:rsidSect\", \"rsidSect\"],\n ] as const) {\n const val = attr(el, attrName);\n if (val) opts[optKey] = val;\n }\n\n // Page size\n const pgSz = findChild(el, \"w:pgSz\");\n if (pgSz) {\n const page: Record<string, unknown> = {};\n const size: Record<string, unknown> = {};\n const w = attrNum(pgSz, \"w:w\");\n const h = attrNum(pgSz, \"w:h\");\n const orient = attr(pgSz, \"w:orient\");\n if (orient === \"landscape\" && w !== undefined && h !== undefined) {\n size.width = h;\n size.height = w;\n } else {\n if (w !== undefined) size.width = w;\n if (h !== undefined) size.height = h;\n }\n if (orient) size.orientation = orient;\n const code = attrNum(pgSz, \"w:code\");\n if (code !== undefined) size.code = code;\n if (Object.keys(size).length > 0) page.size = size;\n\n // Page margins\n const pgMar = findChild(el, \"w:pgMar\");\n if (pgMar) {\n const margin: Record<string, unknown> = {};\n for (const [a, o] of [\n [\"w:top\", \"top\"],\n [\"w:right\", \"right\"],\n [\"w:bottom\", \"bottom\"],\n [\"w:left\", \"left\"],\n [\"w:header\", \"header\"],\n [\"w:footer\", \"footer\"],\n [\"w:gutter\", \"gutter\"],\n ] as const) {\n const val = attrNum(pgMar, a);\n if (val !== undefined) margin[o] = val;\n }\n if (Object.keys(margin).length > 0) page.margin = margin;\n }\n\n // Page number type\n const pgNumType = findChild(el, \"w:pgNumType\");\n if (pgNumType) {\n const pageNumbers: PageNumberTypeAttributes = {};\n const start = attrNum(pgNumType, \"w:start\");\n if (start !== undefined) pageNumbers.start = start;\n const fmt = attr(pgNumType, \"w:fmt\");\n if (fmt && PAGE_NUMBER_FORMATS.includes(fmt)) {\n pageNumbers.formatType = fmt as PageNumberTypeAttributes[\"formatType\"];\n }\n const chapSep = attr(pgNumType, \"w:chapSep\");\n if (chapSep && PAGE_NUMBER_SEPARATORS.includes(chapSep)) {\n pageNumbers.separator = chapSep as PageNumberTypeAttributes[\"separator\"];\n }\n const chapStyle = attrNum(pgNumType, \"w:chapStyle\");\n if (chapStyle !== undefined) pageNumbers.chapStyle = chapStyle;\n if (Object.keys(pageNumbers).length > 0) page.pageNumbers = pageNumbers;\n }\n\n if (Object.keys(page).length > 0) opts.page = page;\n }\n\n // Columns\n const cols = findChild(el, \"w:cols\");\n if (cols) {\n const column: ColumnsAttributes = {};\n const count = attrNum(cols, \"w:num\");\n if (count !== undefined) column.count = count;\n const space = attrNum(cols, \"w:space\");\n if (space !== undefined) column.space = space;\n const separate = attrBool(cols, \"w:sep\");\n if (separate !== undefined) column.separate = separate;\n const equalWidth = attrBool(cols, \"w:equalWidth\");\n if (equalWidth !== undefined) column.equalWidth = equalWidth;\n const colChildren: ColumnAttributes[] = [];\n for (const colEl of cols.elements ?? []) {\n if (colEl.name !== \"w:col\") continue;\n const width = attrNum(colEl, \"w:w\");\n if (width === undefined) continue;\n const colAttr: ColumnAttributes = { width };\n const colSpace = attrNum(colEl, \"w:space\");\n if (colSpace !== undefined) colAttr.space = colSpace;\n colChildren.push(colAttr);\n }\n if (colChildren.length > 0) column.children = colChildren;\n if (Object.keys(column).length > 0) opts.column = column;\n }\n\n // Section type\n const type = findChild(el, \"w:type\");\n if (type) {\n const val = attr(type, \"w:val\");\n if (val) opts.type = val;\n }\n\n // Title page\n const titlePg = findChild(el, \"w:titlePg\");\n if (titlePg) opts.titlePage = attrBool(titlePg, \"w:val\") ?? true;\n\n // On/off properties\n for (const [name, optKey] of [\n [\"w:noEndnote\", \"noEndnote\"],\n [\"w:formProt\", \"formProtection\"],\n [\"w:bidi\", \"bidi\"],\n [\"w:rtlGutter\", \"rtlGutter\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n // Document grid\n const docGrid = findChild(el, \"w:docGrid\");\n if (docGrid) {\n const grid: Record<string, unknown> = {};\n const type = attr(docGrid, \"w:type\");\n if (type) grid.type = type;\n const linePitch = attrNum(docGrid, \"w:linePitch\");\n if (linePitch !== undefined) grid.linePitch = linePitch;\n const charSpace = attrNum(docGrid, \"w:charSpace\");\n if (charSpace !== undefined) grid.charSpace = charSpace;\n if (Object.keys(grid).length > 0) opts.grid = grid;\n }\n\n // Line numbers\n const lnNumType = findChild(el, \"w:lnNumType\");\n if (lnNumType) {\n const lineNumbers: Record<string, unknown> = {};\n const countBy = attrNum(lnNumType, \"w:countBy\");\n if (countBy !== undefined) lineNumbers.countBy = countBy;\n const start = attrNum(lnNumType, \"w:start\");\n if (start !== undefined) lineNumbers.start = start;\n const restart = attr(lnNumType, \"w:restart\");\n if (restart) lineNumbers.restart = restart;\n const distance = attrNum(lnNumType, \"w:distance\");\n if (distance !== undefined) lineNumbers.distance = distance;\n if (Object.keys(lineNumbers).length > 0) opts.lineNumbers = lineNumbers;\n }\n\n // Page borders\n const pgBorders = findChild(el, \"w:pgBorders\");\n if (pgBorders) {\n const borders: Record<string, unknown> = {};\n for (const side of [\"top\", \"left\", \"bottom\", \"right\"] as const) {\n const sideEl = findChild(pgBorders, `w:${side}`);\n if (sideEl) {\n const b: Record<string, unknown> = {};\n const val = attr(sideEl, \"w:val\");\n if (val) b.style = val;\n const color = attr(sideEl, \"w:color\");\n if (color) b.color = color;\n const sz = attrNum(sideEl, \"w:sz\");\n if (sz !== undefined) b.size = sz;\n const space = attrNum(sideEl, \"w:space\");\n if (space !== undefined) b.space = space;\n borders[side] = b;\n }\n }\n const display = attr(pgBorders, \"w:display\");\n if (display) borders.display = display;\n const offsetFrom = attr(pgBorders, \"w:offsetFrom\");\n if (offsetFrom) borders.offsetFrom = offsetFrom;\n const zOrder = attr(pgBorders, \"w:zOrder\");\n if (zOrder) borders.zOrder = zOrder;\n if (Object.keys(borders).length > 0) {\n const page = (opts.page ?? {}) as Record<string, unknown>;\n page.borders = borders;\n opts.page = page;\n }\n }\n\n // Vertical align\n const vAlign = findChild(el, \"w:vAlign\");\n if (vAlign) {\n const val = attr(vAlign, \"w:val\");\n if (val) opts.verticalAlign = val;\n }\n\n // Text direction\n const textDirection = findChild(el, \"w:textDirection\");\n if (textDirection) {\n const val = attr(textDirection, \"w:val\");\n if (val) {\n const page = (opts.page ?? {}) as Record<string, unknown>;\n page.textDirection = val;\n opts.page = page;\n }\n }\n\n // Footnote properties\n const footnotePr = findChild(el, \"w:footnotePr\");\n if (footnotePr) {\n opts.footnotePr = parseNotePropertiesEl(footnotePr);\n }\n\n // Endnote properties\n const endnotePr = findChild(el, \"w:endnotePr\");\n if (endnotePr) {\n opts.endnotePr = parseNotePropertiesEl(endnotePr);\n }\n\n // Paper source\n const paperSrc = findChild(el, \"w:paperSrc\");\n if (paperSrc) {\n const ps: Record<string, unknown> = {};\n const first = attrNum(paperSrc, \"w:first\");\n if (first !== undefined) ps.first = first;\n const other = attrNum(paperSrc, \"w:other\");\n if (other !== undefined) ps.other = other;\n if (Object.keys(ps).length > 0) opts.paperSrc = ps;\n }\n\n // Printer settings\n const printerSettings = findChild(el, \"w:printerSettings\");\n if (printerSettings) {\n const rId = attr(printerSettings, \"r:id\");\n if (rId) opts.printerSettingsId = rId;\n }\n\n // Header/footer references\n const headerGroup: Record<string, unknown> = {};\n const footerGroup: Record<string, unknown> = {};\n for (const child of el.elements ?? []) {\n if (child.name === \"w:headerReference\") {\n const type = attr(child, \"w:type\");\n const rId = attr(child, \"r:id\");\n if (type && rId) headerGroup[type] = { referenceId: parseInt(rId.replace(\"rId\", \"\"), 10) };\n } else if (child.name === \"w:footerReference\") {\n const type = attr(child, \"w:type\");\n const rId = attr(child, \"r:id\");\n if (type && rId) footerGroup[type] = { referenceId: parseInt(rId.replace(\"rId\", \"\"), 10) };\n }\n }\n if (Object.keys(headerGroup).length > 0) opts.headerWrapperGroup = headerGroup;\n if (Object.keys(footerGroup).length > 0) opts.footerWrapperGroup = footerGroup;\n\n return opts as unknown as SectionPropertiesOptions;\n}\n\nfunction parseNotePropertiesEl(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n\n const posEl = findChild(el, \"w:pos\");\n if (posEl) {\n const val = attr(posEl, \"w:val\");\n if (val) opts.pos = val;\n }\n\n const numFmt = findChild(el, \"w:numFmt\");\n if (numFmt) {\n const fmt = attr(numFmt, \"w:fmt\");\n if (fmt) opts.formatType = fmt;\n const format = attr(numFmt, \"w:format\");\n if (format) opts.format = format;\n }\n\n const numStart = findChild(el, \"w:numStart\");\n if (numStart) {\n const val = attrNum(numStart, \"w:val\");\n if (val !== undefined) opts.numStart = val;\n }\n\n const numRestart = findChild(el, \"w:numRestart\");\n if (numRestart) {\n const val = attr(numRestart, \"w:val\");\n if (val) opts.numRestart = val;\n }\n\n return opts;\n}\n"],"mappings":";;;;;;;;;;;;;AA+CA,MAAa,wBAAwB,aAA2D;CAC9F,MAAM;EACJ,GACE,OAAO,QAAQ,UAAU,WACrB,6BAA6B,QAAQ,KAAK,IAC1C,mBAAmB,QAAQ,KAAK;EACtC,GACE,OAAO,QAAQ,WAAW,WACtB,6BAA6B,QAAQ,MAAM,IAC3C,mBAAmB,QAAQ,MAAM;CACzC;CACA,MAAM,QAAQ;CACd,QAAQ;EACN,MAAM;GACJ,GACE,OAAO,QAAQ,QAAQ,SAAS,WAC5B,6BAA6B,QAAQ,OAAO,IAAI,IAChD,mBAAmB,QAAQ,QAAQ,QAAQ,CAAC;GAClD,GACE,OAAO,QAAQ,QAAQ,QAAQ,WAC3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