@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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-DfxK5XnG.mjs","names":["escapeAttr","NS","NS","escapeXml"],"sources":["../src/parts/paragraph/formatting/alignment.ts","../src/parts/paragraph/formatting/spacing.ts","../src/parts/paragraph/formatting/style.ts","../src/parts/paragraph/properties.ts","../src/parts/paragraph/run/run.ts","../src/parts/paragraph/run/properties.ts","../src/parts/paragraph/run/image-run.ts","../src/parts/paragraph/run/underline.ts","../src/parts/paragraph/run/emphasis-mark.ts","../src/parts/paragraph/run/positional-tab.ts","../src/parts/paragraph/run/ruby.ts","../src/parts/paragraph/run/proof-error.ts","../src/parts/table/table-properties/table-float-properties.ts","../src/parts/table/table-properties/table-layout.ts","../src/parts/table/table-properties/table-borders.ts","../src/parts/numbering/level.ts","../src/parts/numbering/numbering.ts","../src/parts/styles/factory.ts","../src/parts/styles/styles.ts","../src/parts/settings/descriptor.ts","../src/parts/table-of-contents/table-of-contents-properties.ts","../src/parts/table-of-contents/sdt-properties.ts","../src/parts/table-of-contents/toc-parse.ts","../src/parts/table-of-contents/descriptor.ts","../src/parts/fonts/font-wrapper.ts","../src/parts/textbox/shape/shape.ts","../src/body.ts","../src/parts/footnotes/descriptor.ts","../src/parts/endnotes/descriptor.ts","../src/parts/perm-start.ts","../src/parts/alt-chunk/alt-chunk-collection.ts","../src/parts/sub-doc/sub-doc-collection.ts","../src/parts/fonts/font.ts","../src/parts/fonts/descriptor.ts","../src/parts/bibliography.ts","../src/parts/glossary-document.ts","../src/parts/comments.ts","../src/parts/contenttypes.ts","../src/parts/relationships.ts","../src/parts/core-properties.ts","../src/parts/custom-properties.ts","../src/parts/app-properties.ts","../src/parts/web-settings.ts","../src/parts/styles/external-styles-factory.ts","../src/context.ts"],"sourcesContent":["/**\n * Paragraph and table alignment module for WordprocessingML documents.\n *\n * This module provides justification (alignment) options for paragraphs and tables.\n *\n * Reference: http://officeopenxml.com/WPalignment.php\n *\n * @see http://officeopenxml.com/WPtableAlignment.php\n * @see http://www.datypic.com/sc/ooxml/t-w_ST_Jc.html\n *\n * @module\n */\n/**\n * Paragraph justification (alignment) types.\n *\n * Specifies the horizontal alignment of text within a paragraph.\n *\n * Reference: http://officeopenxml.com/WPalignment.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_Jc\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"start\"/>\n * <xsd:enumeration value=\"center\"/>\n * <xsd:enumeration value=\"end\"/>\n * <xsd:enumeration value=\"both\"/>\n * <xsd:enumeration value=\"mediumKashida\"/>\n * <xsd:enumeration value=\"distribute\"/>\n * <xsd:enumeration value=\"numTab\"/>\n * <xsd:enumeration value=\"highKashida\"/>\n * <xsd:enumeration value=\"lowKashida\"/>\n * <xsd:enumeration value=\"thaiDistribute\"/>\n * <xsd:enumeration value=\"left\"/>\n * <xsd:enumeration value=\"right\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const AlignmentType = {\n /** Align Start */\n START: \"start\",\n /** Align Center */\n CENTER: \"center\",\n /** End */\n END: \"end\",\n /** Justified */\n BOTH: \"both\",\n /** Medium Kashida Length */\n MEDIUM_KASHIDA: \"mediumKashida\",\n /** Distribute All Characters Equally */\n DISTRIBUTE: \"distribute\",\n /** Align to List Tab */\n NUM_TAB: \"numTab\",\n /** Widest Kashida Length */\n HIGH_KASHIDA: \"highKashida\",\n /** Low Kashida Length */\n LOW_KASHIDA: \"lowKashida\",\n /** Thai Language Justification */\n THAI_DISTRIBUTE: \"thaiDistribute\",\n /** Align Left */\n LEFT: \"left\",\n /** Align Right */\n RIGHT: \"right\",\n /** Justified */\n JUSTIFIED: \"both\",\n} as const;\n","/**\n * Paragraph spacing module for WordprocessingML documents.\n *\n * This module provides spacing options for paragraphs including space before,\n * space after, and line spacing.\n *\n * Reference: http://officeopenxml.com/WPspacing.php\n *\n * @module\n */\n\n/**\n * Line spacing rule types.\n *\n * Specifies how the line height is calculated.\n *\n * @publicApi\n */\nexport const LineRuleType = {\n /** Line spacing is at least the specified value */\n AT_LEAST: \"atLeast\",\n /** Line spacing is exactly the specified value */\n EXACTLY: \"exactly\",\n /** Line spacing is exactly the specified value (alias for EXACTLY) */\n EXACT: \"exact\",\n /** Line spacing is automatically determined based on content */\n AUTO: \"auto\",\n} as const;\n\n/**\n * Properties for configuring paragraph spacing.\n *\n * All values are in twips (twentieths of a point) unless otherwise specified.\n */\nexport interface SpacingProperties {\n /** Spacing after the paragraph in twips */\n after?: number;\n /** Spacing before the paragraph in twips */\n before?: number;\n /** Line spacing value in twips (interpretation depends on lineRule) */\n line?: number;\n /** How to interpret the line spacing value */\n lineRule?: (typeof LineRuleType)[keyof typeof LineRuleType];\n /** Use automatic spacing before the paragraph */\n beforeAutoSpacing?: boolean;\n /** Use automatic spacing after the paragraph */\n afterAutoSpacing?: boolean;\n /** Spacing before the paragraph in line units */\n beforeLines?: number;\n /** Spacing after the paragraph in line units */\n afterLines?: number;\n}\n","/**\n * Paragraph style module for WordprocessingML documents.\n *\n * This module provides paragraph style references including heading levels.\n *\n * @module\n */\n/**\n * Built-in heading level styles.\n *\n * These are the standard heading styles available in Word documents.\n *\n * @publicApi\n */\nexport const HeadingLevel = {\n /** Heading 1 style */\n HEADING_1: \"Heading1\",\n /** Heading 2 style */\n HEADING_2: \"Heading2\",\n /** Heading 3 style */\n HEADING_3: \"Heading3\",\n /** Heading 4 style */\n HEADING_4: \"Heading4\",\n /** Heading 5 style */\n HEADING_5: \"Heading5\",\n /** Heading 6 style */\n HEADING_6: \"Heading6\",\n /** Title style */\n TITLE: \"Title\",\n} as const;\n","import type { ShadingAttributesProperties } from \"@shared/shading\";\n/**\n * Paragraph properties types for WordprocessingML documents.\n *\n * Reference: http://officeopenxml.com/WPparagraphProperties.php\n *\n * @module\n */\nimport type { ChangedAttributesProperties } from \"@shared/track-revision/track-revision\";\n\nimport type { AlignmentType } from \"./formatting/alignment\";\nimport type { BordersOptions } from \"./formatting/border\";\nimport type { CnfConditionalOptions } from \"./formatting/cnf-style\";\nimport type { IndentAttributesProperties } from \"./formatting/indent\";\nimport type { SpacingProperties } from \"./formatting/spacing\";\nimport type { HeadingLevel } from \"./formatting/style\";\nimport type { TabStopDefinition } from \"./formatting/tab-stop\";\nimport type { FrameOptions } from \"./frame/frame-properties\";\nimport type { ParagraphRunOptions } from \"./run/run\";\n\n/**\n * Vertical text alignment types for paragraphs.\n *\n * Specifies the vertical alignment of text within the paragraph.\n *\n * @publicApi\n */\nexport const TextAlignmentType = {\n /** Align text to the top */\n TOP: \"top\",\n /** Align text to the center */\n CENTER: \"center\",\n /** Align text to the baseline */\n BASELINE: \"baseline\",\n /** Align text to the bottom */\n BOTTOM: \"bottom\",\n /** Automatically determine vertical alignment */\n AUTO: \"auto\",\n} as const;\n\n/**\n * Textbox tight wrap types for paragraphs.\n *\n * Specifies how tightly text wraps around a textbox.\n *\n * @publicApi\n */\nexport const TextboxTightWrapType = {\n /** No tight wrapping */\n NONE: \"none\",\n /** Tight wrap on all lines */\n ALL_LINES: \"allLines\",\n /** Tight wrap on first and last lines */\n FIRST_AND_LAST_LINE: \"firstAndLastLine\",\n /** Tight wrap on first line only */\n FIRST_LINE_ONLY: \"firstLineOnly\",\n /** Tight wrap on last line only */\n LAST_LINE_ONLY: \"lastLineOnly\",\n} as const;\n\n/**\n * Paragraph style properties for numbering levels.\n *\n * These properties are used when defining paragraph styles within numbering level definitions.\n */\nexport interface LevelParagraphStylePropertiesOptions {\n /** Paragraph text alignment (left, right, center, justified, etc.) */\n alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];\n /** Whether to render text right-to-left for bidirectional languages */\n bidirectional?: boolean;\n /** Whether to insert a page break before this paragraph */\n pageBreakBefore?: boolean;\n /** Custom tab stop positions and alignments */\n tabStops?: TabStopDefinition[];\n /** Whether to display a horizontal line (thematic break) below the paragraph */\n thematicBreak?: boolean;\n /** Whether to prevent single lines at top/bottom of page (widow/orphan control), defaults to true */\n widowControl?: boolean;\n /** Whether to ignore spacing before/after when adjacent paragraphs have the same style */\n contextualSpacing?: boolean;\n /** Position in twips for a right-aligned tab stop */\n rightTabStop?: number;\n /** Position in twips for a left-aligned tab stop */\n leftTabStop?: number;\n /** Indentation settings for the paragraph */\n indent?: IndentAttributesProperties;\n /** Spacing before/after paragraph and between lines */\n spacing?: SpacingProperties;\n /**\n * Specifies that the paragraph (or at least part of it) should be rendered on the same page as the next paragraph when possible. If multiple paragraphs are to be kept together but they exceed a page, then the set of paragraphs begin on a new page and page breaks are used thereafter as needed.\n */\n keepNext?: boolean;\n /**\n * Specifies that all lines of the paragraph are to be kept on a single page when possible.\n */\n keepLines?: boolean;\n /** Frame properties for positioning the paragraph */\n frame?: FrameOptions;\n /** Whether to suppress line numbers for this paragraph */\n suppressLineNumbers?: boolean;\n /** Whether to allow word wrapping */\n wordWrap?: boolean;\n /** Whether to allow punctuation to extend beyond text margins */\n overflowPunctuation?: boolean;\n /**\n * This element specifies whether inter-character spacing shall automatically be adjusted between regions of numbers and regions of East Asian text in the current paragraph. These regions shall be determined by the Unicode character values of the text content within the paragraph.\n * This only works in Microsoft Word. It is not part of the ECMA-376 OOXML standard.\n */\n autoSpaceEastAsianText?: boolean;\n /** Whether to prevent text frames from overlapping */\n suppressOverlap?: boolean;\n /** Whether to disable automatic hyphenation for this paragraph */\n suppressAutoHyphens?: boolean;\n /** Whether to automatically adjust right indent for document grid */\n adjustRightInd?: boolean;\n /** Whether to snap the current paragraph to the document grid */\n snapToGrid?: boolean;\n /** Whether to swap left and right indent positions on odd pages for mirrored layouts */\n mirrorIndents?: boolean;\n /** Whether to use Kinsoku forbidden character overflow rules */\n kinsoku?: boolean;\n /** Whether to compress punctuation at the start of a line */\n topLinePunct?: boolean;\n /** Whether to automatically add space between East Asian and Latin text */\n autoSpaceDE?: boolean;\n /** Vertical text alignment within the paragraph */\n textAlignment?: (typeof TextAlignmentType)[keyof typeof TextAlignmentType];\n /** Textbox tight wrap setting */\n textboxTightWrap?: (typeof TextboxTightWrapType)[keyof typeof TextboxTightWrapType];\n /** Text direction for the paragraph (lr, rl, tb, tbV, rlV, lrV) */\n textDirection?: \"lr\" | \"rl\" | \"tb\" | \"tbV\" | \"rlV\" | \"lrV\";\n /** Outline level for table of contents and document outline (0-9) */\n outlineLevel?: number;\n /** HTML div ID reference */\n divId?: number;\n /** Conditional formatting style for table rows/cells */\n cnfStyle?: CnfConditionalOptions;\n}\n\n/**\n * Paragraph style properties options.\n *\n * These properties are used when defining paragraph styles and include\n * border, shading, and numbering options in addition to level properties.\n */\nexport type ParagraphStylePropertiesOptions = {\n /** Border settings for the paragraph */\n border?: BordersOptions;\n /** Background shading/fill color for the paragraph */\n shading?: ShadingAttributesProperties;\n /** Numbering configuration for lists, or false to remove numbering */\n numbering?:\n | {\n /** Reference ID of the numbering definition to use */\n reference: string;\n /** Level in the numbering hierarchy (0-8) */\n level: number;\n /** Instance number for multiple lists with same reference */\n instance?: number;\n /** Whether this is a custom numbering definition */\n custom?: boolean;\n /** Numbering change tracking (CT_TrackChangeNumbering) */\n numberingChange?: {\n /** Original numbering value */\n original: string;\n /** Revision ID */\n id: string;\n /** Author of the change */\n author: string;\n /** Date of the change */\n date?: string;\n };\n }\n | false;\n} & LevelParagraphStylePropertiesOptions;\n\nexport type ParagraphPropertiesOptionsBase = {\n /** Heading level (Heading1, Heading2, etc.) - applies predefined heading style */\n heading?: (typeof HeadingLevel)[keyof typeof HeadingLevel];\n /** Style ID to apply to this paragraph */\n style?: string;\n /** Bullet list configuration */\n bullet?: {\n /** Indentation level for the bullet (0-8) */\n level: number;\n };\n /**\n * Run properties to apply to all runs in the paragraph.\n * Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.3.1.29.\n */\n run?: ParagraphRunOptions;\n} & ParagraphStylePropertiesOptions;\n\nexport type ParagraphPropertiesChangeOptions = ChangedAttributesProperties &\n ParagraphPropertiesOptionsBase;\n\n/**\n * Options for configuring paragraph properties.\n *\n * These options control all aspects of paragraph formatting including\n * alignment, spacing, indentation, borders, numbering, and more.\n *\n * Reference: http://officeopenxml.com/WPparagraphProperties.php\n */\nexport type ParagraphPropertiesOptions = {\n revision?: ParagraphPropertiesChangeOptions;\n includeIfEmpty?: boolean;\n} & ParagraphPropertiesOptionsBase;\n","/**\n * Run module for WordprocessingML documents.\n *\n * A run is a region of text with a common set of properties. It is the primary\n * unit of inline content in a paragraph.\n *\n * Reference: http://officeopenxml.com/WPtext.php\n *\n * @module\n */\nimport type {\n AnnotationReference,\n CarriageReturn,\n ContinuationSeparator,\n DayLong,\n DayShort,\n EndnoteReference,\n FootnoteReferenceElement,\n LastRenderedPageBreak,\n MonthLong,\n MonthShort,\n NoBreakHyphen,\n PageNumberElement,\n Separator,\n SoftHyphen,\n Tab,\n YearLong,\n YearShort,\n} from \"./empty-children\";\nimport type { ParagraphRunPropertiesOptions, RunPropertiesOptions } from \"./properties\";\n\ninterface RunOptionsBase {\n children?: (\n | (typeof PageNumber)[keyof typeof PageNumber]\n | string\n | AnnotationReference\n | CarriageReturn\n | ContinuationSeparator\n | DayLong\n | DayShort\n | EndnoteReference\n | FootnoteReferenceElement\n | LastRenderedPageBreak\n | MonthLong\n | MonthShort\n | NoBreakHyphen\n | PageNumberElement\n | Separator\n | SoftHyphen\n | Tab\n | YearLong\n | YearShort\n | Record<string, unknown>\n )[];\n break?: number;\n text?: string;\n}\n\n/**\n * Options for creating a Run element.\n *\n * The run element specifies a region of text with a common set of properties.\n * The children property can contain various inline content elements.\n *\n * @see {@link Run}\n */\nexport type RunOptions = RunOptionsBase &\n RunPropertiesOptions & {\n /** Revision save ID for run properties (hex string, e.g. \"00123456\"). */\n rsidRPr?: string;\n /** Revision save ID when run was deleted (hex string). */\n rsidDel?: string;\n };\n\nexport type ParagraphRunOptions = RunOptionsBase & ParagraphRunPropertiesOptions;\n\n/**\n * Constants for page number field types.\n *\n * These values are used to insert dynamic page number fields into a document.\n *\n * Reference: http://officeopenxml.com/WPfields.php\n *\n * @publicApi\n */\nexport const PageNumber = {\n /** Inserts the current page number */\n CURRENT: \"CURRENT\",\n /** Inserts the total number of pages in the document */\n TOTAL_PAGES: \"TOTAL_PAGES\",\n /** Inserts the total number of pages in the current section */\n TOTAL_PAGES_IN_SECTION: \"TOTAL_PAGES_IN_SECTION\",\n /** Inserts the current section number */\n CURRENT_SECTION: \"SECTION\",\n} as const;\n","/**\n * Run properties module for WordprocessingML documents.\n *\n * This module provides the run properties (rPr) element which specifies\n * the formatting applied to a run of text.\n *\n * Reference: https://www.ecma-international.org/wp-content/uploads/ECMA-376-1_5th_edition_december_2016.zip\n * Section 17.3.2.21 (page 297)\n *\n * @module\n */\nimport type { BorderOptions } from \"@shared/border\";\nimport type { ShadingAttributesProperties } from \"@shared/shading\";\nimport type { ChangedAttributesProperties } from \"@shared/track-revision/track-revision\";\n\nimport type { EastAsianLayoutOptions } from \"./east-asian-layout\";\nimport type { EmphasisMarkType } from \"./emphasis-mark\";\nimport type { ColorOptions } from \"./formatting\";\nimport type { LanguageOptions } from \"./language\";\nimport type { FontAttributesProperties } from \"./run-fonts\";\nimport type { UnderlineType } from \"./underline\";\n\ninterface RunFontReference {\n name: string;\n hint?: string;\n}\n\n/**\n * Text animation effect types.\n *\n * Reference: http://officeopenxml.com/WPtextFormatting.php\n *\n * @publicApi\n */\nexport const TextEffect = {\n /** Blinking background animation */\n BLINK_BACKGROUND: \"blinkBackground\",\n /** Lights animation effect */\n LIGHTS: \"lights\",\n /** Black marching ants animation */\n ANTS_BLACK: \"antsBlack\",\n /** Red marching ants animation */\n ANTS_RED: \"antsRed\",\n /** Shimmer animation effect */\n SHIMMER: \"shimmer\",\n /** Sparkle animation effect */\n SPARKLE: \"sparkle\",\n /** No text effect */\n NONE: \"none\",\n} as const;\n\n/**\n * Highlight color values for text highlighting.\n *\n * Reference: http://officeopenxml.com/WPtextShading.php\n */\nexport const HighlightColor = {\n /** Black highlight */\n BLACK: \"black\",\n /** Blue highlight */\n BLUE: \"blue\",\n /** Cyan highlight */\n CYAN: \"cyan\",\n /** Dark blue highlight */\n DARK_BLUE: \"darkBlue\",\n /** Dark cyan highlight */\n DARK_CYAN: \"darkCyan\",\n /** Dark gray highlight */\n DARK_GRAY: \"darkGray\",\n /** Dark green highlight */\n DARK_GREEN: \"darkGreen\",\n /** Dark magenta highlight */\n DARK_MAGENTA: \"darkMagenta\",\n /** Dark red highlight */\n DARK_RED: \"darkRed\",\n /** Dark yellow highlight */\n DARK_YELLOW: \"darkYellow\",\n /** Green highlight */\n GREEN: \"green\",\n /** Light gray highlight */\n LIGHT_GRAY: \"lightGray\",\n /** Magenta highlight */\n MAGENTA: \"magenta\",\n /** No highlight */\n NONE: \"none\",\n /** Red highlight */\n RED: \"red\",\n /** White highlight */\n WHITE: \"white\",\n /** Yellow highlight */\n YELLOW: \"yellow\",\n} as const;\n\n/**\n * Run style properties options.\n *\n * These properties define the formatting that can be applied to a run of text,\n * including font, size, bold, italic, underline, color, and other character formatting.\n *\n * Reference: http://officeopenxml.com/WPtextFormatting.php\n */\nexport interface RunStylePropertiesOptions {\n noProof?: boolean;\n bold?: boolean;\n boldComplexScript?: boolean;\n italic?: boolean;\n italicComplexScript?: boolean;\n underline?: {\n color?: string;\n type?: (typeof UnderlineType)[keyof typeof UnderlineType];\n };\n effect?: (typeof TextEffect)[keyof typeof TextEffect];\n emphasisMark?: {\n type?: (typeof EmphasisMarkType)[keyof typeof EmphasisMarkType];\n };\n color?: string | ColorOptions;\n kern?: number;\n position?: string;\n /** Font size in points. Internally stored as half-points in XML (×2). */\n size?: number;\n sizeComplexScript?: boolean | number;\n rightToLeft?: boolean;\n smallCaps?: boolean;\n allCaps?: boolean;\n strike?: boolean;\n doubleStrike?: boolean;\n subScript?: boolean;\n superScript?: boolean;\n font?: string | RunFontReference | FontAttributesProperties;\n highlight?: (typeof HighlightColor)[keyof typeof HighlightColor];\n highlightComplexScript?: boolean | string;\n characterSpacing?: number;\n shading?: ShadingAttributesProperties;\n emboss?: boolean;\n imprint?: boolean;\n revision?: RunPropertiesChangeOptions;\n language?: LanguageOptions;\n border?: BorderOptions;\n snapToGrid?: boolean;\n vanish?: boolean;\n specVanish?: boolean;\n scale?: number;\n math?: boolean;\n outline?: boolean;\n shadow?: boolean;\n webHidden?: boolean;\n fitText?: number;\n complexScript?: boolean;\n eastAsianLayout?: EastAsianLayoutOptions;\n /** Relationship ID for a content part (w:contentPart with r:id) */\n contentPartRId?: string;\n}\n\n/**\n * Options for configuring run properties.\n *\n * Extends RunStylePropertiesOptions with a style reference.\n */\nexport type RunPropertiesOptions = {\n /** Reference to a character style by name */\n style?: string;\n} & RunStylePropertiesOptions;\n\n/**\n * Options for run properties change tracking.\n *\n * Used for revision tracking when run properties have been modified.\n */\nexport type RunPropertiesChangeOptions = {} & RunPropertiesOptions & ChangedAttributesProperties;\n\nexport type ParagraphRunPropertiesOptions = {\n insertion?: ChangedAttributesProperties;\n deletion?: ChangedAttributesProperties;\n} & RunPropertiesOptions;\n","import type { DataType } from \"@office-open/core\";\nimport type { FillOptions } from \"@office-open/core/drawingml\";\n/**\n * ImageRun types for WordprocessingML documents.\n *\n * This module provides support for inserting images into documents.\n *\n * Reference: http://officeopenxml.com/drwPicInline.php\n *\n * @module\n */\nimport type { DocPropertiesOptions } from \"@parts/drawing/doc-properties/doc-properties\";\nimport type { MediaTransformation } from \"@shared/media\";\nimport { createTransformation } from \"@shared/media\";\nimport type { MediaData } from \"@shared/media/data\";\n\nimport type { Floating } from \"../../drawing\";\nimport type { BlipEffectsOptions } from \"../../drawing/inline/graphic/graphic-data/pic/blip/blip-effects\";\nimport type { SourceRectangleOptions } from \"../../drawing/inline/graphic/graphic-data/pic/blip/source-rectangle\";\nimport type { TileOptions } from \"../../drawing/inline/graphic/graphic-data/pic/blip/tile\";\nimport type { EffectListOptions } from \"../../drawing/inline/graphic/graphic-data/pic/effects/effect-list\";\nimport type { OutlineOptions } from \"../../drawing/inline/graphic/graphic-data/pic/outline/outline\";\n\n/**\n * Core options for image configuration.\n */\ninterface CoreImageOptions {\n transformation: MediaTransformation;\n floating?: Floating;\n altText?: DocPropertiesOptions;\n outline?: OutlineOptions;\n fill?: FillOptions;\n effects?: EffectListOptions;\n blipEffects?: BlipEffectsOptions;\n srcRect?: SourceRectangleOptions;\n tile?: TileOptions;\n}\n\ninterface RegularImageOptions {\n type: \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\";\n data: DataType;\n}\n\ninterface SvgMediaOptions {\n type: \"svg\";\n data: DataType;\n /**\n * Required in case the Word processor does not support SVG.\n */\n fallback: RegularImageOptions;\n}\n\n/**\n * Options for creating an ImageRun.\n *\n * @see {@link ImageRun}\n */\nexport type ImageOptions = (RegularImageOptions | SvgMediaOptions) & CoreImageOptions;\n\nexport const createImageData = (\n data: Uint8Array,\n transformation: MediaTransformation,\n key: string,\n srcRect?: SourceRectangleOptions,\n): Pick<MediaData, \"data\" | \"fileName\" | \"transformation\" | \"srcRect\"> => ({\n data,\n fileName: key,\n srcRect,\n transformation: createTransformation(transformation),\n});\n","/**\n * Underline module for WordprocessingML documents.\n *\n * This module provides support for underlining text with various styles and colors.\n *\n * Reference: http://officeopenxml.com/WPrun.php\n *\n * @module\n */\n\n/**\n * Underline style types for text.\n *\n * Defines the various underline patterns that can be applied to text runs.\n *\n * Reference: http://officeopenxml.com/WPrun.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_Underline\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"single\"/>\n * <xsd:enumeration value=\"words\"/>\n * <xsd:enumeration value=\"double\"/>\n * <xsd:enumeration value=\"thick\"/>\n * <xsd:enumeration value=\"dotted\"/>\n * <xsd:enumeration value=\"dottedHeavy\"/>\n * <xsd:enumeration value=\"dash\"/>\n * <xsd:enumeration value=\"dashedHeavy\"/>\n * <xsd:enumeration value=\"dashLong\"/>\n * <xsd:enumeration value=\"dashLongHeavy\"/>\n * <xsd:enumeration value=\"dotDash\"/>\n * <xsd:enumeration value=\"dashDotHeavy\"/>\n * <xsd:enumeration value=\"dotDotDash\"/>\n * <xsd:enumeration value=\"dashDotDotHeavy\"/>\n * <xsd:enumeration value=\"wave\"/>\n * <xsd:enumeration value=\"wavyHeavy\"/>\n * <xsd:enumeration value=\"wavyDouble\"/>\n * <xsd:enumeration value=\"none\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const UnderlineType = {\n /** Single underline */\n SINGLE: \"single\",\n /** Underline words only (not spaces) */\n WORDS: \"words\",\n /** Double underline */\n DOUBLE: \"double\",\n /** Thick single underline */\n THICK: \"thick\",\n /** Dotted underline */\n DOTTED: \"dotted\",\n /** Heavy dotted underline */\n DOTTEDHEAVY: \"dottedHeavy\",\n /** Dashed underline */\n DASH: \"dash\",\n /** Heavy dashed underline */\n DASHEDHEAVY: \"dashedHeavy\",\n /** Long dashed underline */\n DASHLONG: \"dashLong\",\n /** Heavy long dashed underline */\n DASHLONGHEAVY: \"dashLongHeavy\",\n /** Dot-dash underline */\n DOTDASH: \"dotDash\",\n /** Heavy dot-dash underline */\n DASHDOTHEAVY: \"dashDotHeavy\",\n /** Dot-dot-dash underline */\n DOTDOTDASH: \"dotDotDash\",\n /** Heavy dot-dot-dash underline */\n DASHDOTDOTHEAVY: \"dashDotDotHeavy\",\n /** Wave underline */\n WAVE: \"wave\",\n /** Heavy wave underline */\n WAVYHEAVY: \"wavyHeavy\",\n /** Double wave underline */\n WAVYDOUBLE: \"wavyDouble\",\n /** No underline */\n NONE: \"none\",\n} as const;\n","/**\n * Emphasis mark module for WordprocessingML run properties.\n *\n * This module provides support for East Asian emphasis marks, which are\n * characters placed above or below text to emphasize it.\n *\n * Reference: http://officeopenxml.com/WPrun.php\n *\n * @module\n */\n\n/**\n * Emphasis mark types.\n *\n * Defines the types of emphasis marks that can be applied to text.\n * Emphasis marks are commonly used in East Asian typography.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_Em\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"none\"/>\n * <xsd:enumeration value=\"dot\"/>\n * <xsd:enumeration value=\"comma\"/>\n * <xsd:enumeration value=\"circle\"/>\n * <xsd:enumeration value=\"underDot\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const EmphasisMarkType = {\n /** No emphasis mark */\n NONE: \"none\",\n /** Comma emphasis mark */\n COMMA: \"comma\",\n /** Circle emphasis mark */\n CIRCLE: \"circle\",\n /** Dot emphasis mark */\n DOT: \"dot\",\n /** Under dot emphasis mark */\n UNDER_DOT: \"underDot\",\n} as const;\n","/**\n * Positional tab types for WordprocessingML documents.\n *\n * @module\n */\n\nexport const PositionalTabAlignment = {\n LEFT: \"left\",\n CENTER: \"center\",\n RIGHT: \"right\",\n} as const;\n\nexport const PositionalTabRelativeTo = {\n MARGIN: \"margin\",\n INDENT: \"indent\",\n} as const;\n\nexport const PositionalTabLeader = {\n NONE: \"none\",\n DOT: \"dot\",\n HYPHEN: \"hyphen\",\n UNDERSCORE: \"underscore\",\n MIDDLE_DOT: \"middleDot\",\n} as const;\n\nexport interface PositionalTabOptions {\n alignment: (typeof PositionalTabAlignment)[keyof typeof PositionalTabAlignment];\n relativeTo: (typeof PositionalTabRelativeTo)[keyof typeof PositionalTabRelativeTo];\n leader: (typeof PositionalTabLeader)[keyof typeof PositionalTabLeader];\n}\n","/**\n * Ruby annotation module for WordprocessingML documents.\n *\n * Ruby annotations are small text rendered above or below base text,\n * commonly used for pronunciation guides in East Asian languages (furigana\n * in Japanese, pinyin in Chinese, etc.).\n *\n * Used via the JSON API: `{ ruby: { text: \"かな\", base: \"漢字\" } }` as a\n * paragraph or run child.\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_Ruby\n *\n * @module\n */\n\n/**\n * Ruby alignment options.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_RubyAlign\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"center\"/>\n * <xsd:enumeration value=\"distributeLetter\"/>\n * <xsd:enumeration value=\"distributeSpace\"/>\n * <xsd:enumeration value=\"left\"/>\n * <xsd:enumeration value=\"right\"/>\n * <xsd:enumeration value=\"rightVertical\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const RubyAlign = {\n /** Center alignment */\n CENTER: \"center\",\n /** Distribute letters evenly */\n DISTRIBUTE_LETTER: \"distributeLetter\",\n /** Distribute space evenly */\n DISTRIBUTE_SPACE: \"distributeSpace\",\n /** Left alignment */\n LEFT: \"left\",\n /** Right alignment */\n RIGHT: \"right\",\n /** Right vertical alignment */\n RIGHT_VERTICAL: \"rightVertical\",\n} as const;\n\n/**\n * Options for a Ruby annotation.\n *\n * Used as `{ ruby: RubyOptions }` in paragraph or run children.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Ruby\">\n * <xsd:sequence>\n * <xsd:element name=\"rubyPr\" type=\"CT_RubyPr\"/>\n * <xsd:element name=\"rt\" type=\"CT_RubyContent\"/>\n * <xsd:element name=\"rubyBase\" type=\"CT_RubyContent\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Japanese furigana\n * { ruby: {\n * text: \"かな\",\n * base: \"漢字\",\n * alignment: \"center\",\n * fontSize: 20,\n * languageId: \"ja-JP\",\n * }}\n * ```\n */\nexport interface RubyOptions {\n /** Ruby annotation text (e.g., furigana, pinyin) */\n text: string;\n /** Base text being annotated */\n base: string;\n /** Ruby alignment (defaults to \"center\"). */\n alignment?: (typeof RubyAlign)[keyof typeof RubyAlign];\n /**\n * Font size for the ruby annotation text in points (e.g., 10 = 10pt).\n * Defaults to half the base text size if not specified.\n */\n fontSize?: number;\n /**\n * Vertical offset for the ruby annotation in points.\n * How far the annotation is raised above (or below) the base text.\n */\n raise?: number;\n /**\n * Font size for the base text in points.\n * Used to calculate the ruby annotation positioning.\n */\n baseFontSize?: number;\n /** Language identifier for the ruby annotation (e.g., \"ja-JP\"). */\n languageId?: string;\n /** Whether the ruby annotation is dirty (needs recalculation). */\n dirty?: boolean;\n}\n","/**\n * Proof error types for WordprocessingML documents.\n *\n * @module\n */\n\nexport const ProofErrorType = {\n SPELL_START: \"spellStart\",\n SPELL_END: \"spellEnd\",\n GRAM_START: \"gramStart\",\n GRAM_END: \"gramEnd\",\n} as const;\n\nexport type ProofErrorTypeValue = (typeof ProofErrorType)[keyof typeof ProofErrorType];\n","/**\n * Table float properties module for WordprocessingML documents.\n *\n * This module provides floating table positioning options, allowing tables\n * to float with text wrapping around them.\n *\n * Reference: http://officeopenxml.com/WPtableFloating.php\n *\n * @module\n */\n\n/**\n * Anchor types for floating table positioning.\n *\n * Specifies the base object from which positioning is determined.\n */\nexport const TableAnchorType = {\n MARGIN: \"margin\",\n PAGE: \"page\",\n TEXT: \"text\",\n} as const;\n\n/**\n * Relative horizontal position values for floating tables.\n */\nexport const RelativeHorizontalPosition = {\n CENTER: \"center\",\n INSIDE: \"inside\",\n LEFT: \"left\",\n OUTSIDE: \"outside\",\n RIGHT: \"right\",\n} as const;\n\n/**\n * Relative vertical position values for floating tables.\n */\nexport const RelativeVerticalPosition = {\n BOTTOM: \"bottom\",\n CENTER: \"center\",\n INLINE: \"inline\",\n INSIDE: \"inside\",\n OUTSIDE: \"outside\",\n TOP: \"top\",\n} as const;\n\n/**\n * Table overlap behavior types.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TblOverlap\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"never\"/>\n * <xsd:enumeration value=\"overlap\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const OverlapType = {\n NEVER: \"never\",\n OVERLAP: \"overlap\",\n} as const;\n\nexport interface TableFloatOptions {\n /* CSpell:disable */\n horizontalAnchor?: (typeof TableAnchorType)[keyof typeof TableAnchorType];\n absoluteHorizontalPosition?: number;\n relativeHorizontalPosition?: (typeof RelativeHorizontalPosition)[keyof typeof RelativeHorizontalPosition];\n verticalAnchor?: (typeof TableAnchorType)[keyof typeof TableAnchorType];\n absoluteVerticalPosition?: number;\n relativeVerticalPosition?: (typeof RelativeVerticalPosition)[keyof typeof RelativeVerticalPosition];\n bottomFromText?: number;\n topFromText?: number;\n leftFromText?: number;\n rightFromText?: number;\n overlap?: (typeof OverlapType)[keyof typeof OverlapType];\n /* CSpell:enable */\n}\n","/**\n * Table layout module for WordprocessingML documents.\n *\n * This module provides table layout algorithm settings.\n *\n * @module\n */\n\n/**\n * Table layout algorithm types.\n *\n * Specifies how the table width is calculated.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TblLayoutType\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"fixed\"/>\n * <xsd:enumeration value=\"autofit\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const TableLayoutType = {\n /** Auto-fit layout - column widths are adjusted based on content */\n AUTOFIT: \"autofit\",\n /** Fixed layout - column widths are fixed as specified */\n FIXED: \"fixed\",\n} as const;\n","/**\n * Table borders module for WordprocessingML documents.\n *\n * This module provides border options for tables.\n *\n * Reference: http://officeopenxml.com/WPtableBorders.php\n *\n * @module\n */\nimport { BorderStyle } from \"@shared/border\";\nimport type { BorderOptions } from \"@shared/border\";\n\n/**\n * Options for configuring table borders.\n *\n * Borders can be applied to the outside edges (top, bottom, left, right)\n * and inside lines (insideHorizontal, insideVertical) of the table.\n */\nexport interface TableBordersOptions {\n top?: BorderOptions;\n bottom?: BorderOptions;\n left?: BorderOptions;\n right?: BorderOptions;\n insideHorizontal?: BorderOptions;\n insideVertical?: BorderOptions;\n}\n\nconst NONE_BORDER: BorderOptions = {\n color: \"auto\",\n size: 0,\n style: BorderStyle.NONE,\n};\n\nexport const TABLE_BORDERS_NONE: TableBordersOptions = {\n bottom: NONE_BORDER,\n insideHorizontal: NONE_BORDER,\n insideVertical: NONE_BORDER,\n left: NONE_BORDER,\n right: NONE_BORDER,\n top: NONE_BORDER,\n};\n","/**\n * Numbering level definitions module for WordprocessingML documents.\n *\n * This module defines the formatting and behavior of individual levels within\n * a numbered or bulleted list hierarchy.\n *\n * Reference: http://officeopenxml.com/WPnumbering-numFmt.php\n *\n * @module\n */\nimport type { AlignmentType } from \"../paragraph/formatting\";\nimport type { LevelParagraphStylePropertiesOptions } from \"../paragraph/properties\";\nimport type { RunStylePropertiesOptions } from \"../paragraph/run/properties\";\n\n/**\n * Number format types for list levels.\n *\n * Defines the various numbering formats available for list levels, including\n * decimal, roman numerals, letters, and various international formats.\n *\n * Reference: http://officeopenxml.com/WPnumbering-numFmt.php\n *\n * @publicApi\n */\nexport const LevelFormat = {\n /** Decimal numbering (1, 2, 3...). */\n DECIMAL: \"decimal\",\n /** Uppercase roman numerals (I, II, III...). */\n UPPER_ROMAN: \"upperRoman\",\n /** Lowercase roman numerals (i, ii, iii...). */\n LOWER_ROMAN: \"lowerRoman\",\n /** Uppercase letters (A, B, C...). */\n UPPER_LETTER: \"upperLetter\",\n /** Lowercase letters (a, b, c...). */\n LOWER_LETTER: \"lowerLetter\",\n /** Ordinal numbers (1st, 2nd, 3rd...). */\n ORDINAL: \"ordinal\",\n /** Cardinal text (one, two, three...). */\n CARDINAL_TEXT: \"cardinalText\",\n /** Ordinal text (first, second, third...). */\n ORDINAL_TEXT: \"ordinalText\",\n /** Hexadecimal numbering. */\n HEX: \"hex\",\n /** Chicago Manual of Style numbering. */\n CHICAGO: \"chicago\",\n /** Ideograph digital numbering. */\n IDEOGRAPH__DIGITAL: \"ideographDigital\",\n /** Japanese counting system. */\n JAPANESE_COUNTING: \"japaneseCounting\",\n /** Japanese aiueo ordering. */\n AIUEO: \"aiueo\",\n /** Japanese iroha ordering. */\n IROHA: \"iroha\",\n /** Full-width decimal numbering. */\n DECIMAL_FULL_WIDTH: \"decimalFullWidth\",\n /** Half-width decimal numbering. */\n DECIMAL_HALF_WIDTH: \"decimalHalfWidth\",\n /** Japanese legal numbering. */\n JAPANESE_LEGAL: \"japaneseLegal\",\n /** Japanese digital ten thousand numbering. */\n JAPANESE_DIGITAL_TEN_THOUSAND: \"japaneseDigitalTenThousand\",\n /** Decimal numbers enclosed in circles. */\n DECIMAL_ENCLOSED_CIRCLE: \"decimalEnclosedCircle\",\n /** Full-width decimal numbering variant 2. */\n DECIMAL_FULL_WIDTH2: \"decimalFullWidth2\",\n /** Full-width aiueo ordering. */\n AIUEO_FULL_WIDTH: \"aiueoFullWidth\",\n /** Full-width iroha ordering. */\n IROHA_FULL_WIDTH: \"irohaFullWidth\",\n /** Decimal with leading zeros. */\n DECIMAL_ZERO: \"decimalZero\",\n /** Bullet points. */\n BULLET: \"bullet\",\n /** Korean ganada ordering. */\n GANADA: \"ganada\",\n /** Korean chosung ordering. */\n CHOSUNG: \"chosung\",\n /** Decimal enclosed with fullstop. */\n DECIMAL_ENCLOSED_FULLSTOP: \"decimalEnclosedFullstop\",\n /** Decimal enclosed in parentheses. */\n DECIMAL_ENCLOSED_PARENTHESES: \"decimalEnclosedParen\",\n /** Decimal enclosed in circles (Chinese). */\n DECIMAL_ENCLOSED_CIRCLE_CHINESE: \"decimalEnclosedCircleChinese\",\n /** Ideograph enclosed in circles. */\n IDEOGRAPH_ENCLOSED_CIRCLE: \"ideographEnclosedCircle\",\n /** Traditional ideograph numbering. */\n IDEOGRAPH_TRADITIONAL: \"ideographTraditional\",\n /** Ideograph zodiac numbering. */\n IDEOGRAPH_ZODIAC: \"ideographZodiac\",\n /** Traditional ideograph zodiac numbering. */\n IDEOGRAPH_ZODIAC_TRADITIONAL: \"ideographZodiacTraditional\",\n /** Taiwanese counting system. */\n TAIWANESE_COUNTING: \"taiwaneseCounting\",\n /** Traditional ideograph legal numbering. */\n IDEOGRAPH_LEGAL_TRADITIONAL: \"ideographLegalTraditional\",\n /** Taiwanese counting thousand system. */\n TAIWANESE_COUNTING_THOUSAND: \"taiwaneseCountingThousand\",\n /** Taiwanese digital numbering. */\n TAIWANESE_DIGITAL: \"taiwaneseDigital\",\n /** Chinese counting system. */\n CHINESE_COUNTING: \"chineseCounting\",\n /** Simplified Chinese legal numbering. */\n CHINESE_LEGAL_SIMPLIFIED: \"chineseLegalSimplified\",\n /** Chinese counting thousand system. */\n CHINESE_COUNTING_THOUSAND: \"chineseCountingThousand\",\n /** Korean digital numbering. */\n KOREAN_DIGITAL: \"koreanDigital\",\n /** Korean counting system. */\n KOREAN_COUNTING: \"koreanCounting\",\n /** Korean legal numbering. */\n KOREAN_LEGAL: \"koreanLegal\",\n /** Korean digital numbering variant 2. */\n KOREAN_DIGITAL2: \"koreanDigital2\",\n /** Vietnamese counting system. */\n VIETNAMESE_COUNTING: \"vietnameseCounting\",\n /** Russian lowercase numbering. */\n RUSSIAN_LOWER: \"russianLower\",\n /** Russian uppercase numbering. */\n RUSSIAN_UPPER: \"russianUpper\",\n /** No numbering. */\n NONE: \"none\",\n /** Number enclosed in dashes. */\n NUMBER_IN_DASH: \"numberInDash\",\n /** Hebrew numbering variant 1. */\n HEBREW1: \"hebrew1\",\n /** Hebrew numbering variant 2. */\n HEBREW2: \"hebrew2\",\n /** Arabic alpha numbering. */\n ARABIC_ALPHA: \"arabicAlpha\",\n /** Arabic abjad numbering. */\n ARABIC_ABJAD: \"arabicAbjad\",\n /** Hindi vowels. */\n HINDI_VOWELS: \"hindiVowels\",\n /** Hindi consonants. */\n HINDI_CONSONANTS: \"hindiConsonants\",\n /** Hindi numbers. */\n HINDI_NUMBERS: \"hindiNumbers\",\n /** Hindi counting system. */\n HINDI_COUNTING: \"hindiCounting\",\n /** Thai letters. */\n THAI_LETTERS: \"thaiLetters\",\n /** Thai numbers. */\n THAI_NUMBERS: \"thaiNumbers\",\n /** Thai counting system. */\n THAI_COUNTING: \"thaiCounting\",\n /** Thai Baht text. */\n BAHT_TEXT: \"bahtText\",\n /** Dollar text. */\n DOLLAR_TEXT: \"dollarText\",\n /** Custom numbering format. */\n CUSTOM: \"custom\",\n} as const;\n\n/**\n * Suffix types for list levels.\n *\n * Defines what follows the numbering text (tab, space, or nothing).\n *\n * @publicApi\n */\nexport const LevelSuffix = {\n /** No separator after the numbering. */\n NOTHING: \"nothing\",\n /** Space character after the numbering. */\n SPACE: \"space\",\n /** Tab character after the numbering. */\n TAB: \"tab\",\n} as const;\n\n/**\n * Options for configuring a numbering level.\n *\n * @property level - Level index (0-8)\n * @property format - Number format type (decimal, roman, letter, etc.)\n * @property text - Level text template with placeholders like %1, %2\n * @property alignment - Text alignment for the numbering\n * @property start - Starting number for this level\n * @property suffix - Character(s) following the numbering (tab, space, nothing)\n * @property isLegalNumberingStyle - Use legal numbering style\n * @property style - Run and paragraph style properties\n */\nexport interface LevelsOptions {\n /** Level index (0-8). */\n level: number;\n /** Number format type (decimal, roman, letter, bullet, etc.). */\n format?: (typeof LevelFormat)[keyof typeof LevelFormat];\n /** Level text template with placeholders like %1, %2. */\n text?: string;\n /** Text alignment for the numbering. */\n alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];\n /** Starting number for this level. */\n start?: number;\n /** Character(s) following the numbering. */\n suffix?: (typeof LevelSuffix)[keyof typeof LevelSuffix];\n /** Use legal numbering style (e.g., 1.1.1). */\n isLegalNumberingStyle?: boolean;\n /** Restart numbering after this level (0-based level index). */\n lvlRestart?: number;\n /** Picture bullet ID reference. */\n lvlPicBulletId?: number;\n /** Template code for the level. */\n templateCode?: string;\n /** Whether this level is tentative. */\n tentative?: boolean;\n /** Legacy spacing/indent settings. */\n legacy?: { space?: number; indent?: number };\n /** Run and paragraph style properties. */\n style?: {\n /** Run style properties for the numbering text. */\n run?: RunStylePropertiesOptions;\n /** Paragraph style properties for the level. */\n paragraph?: LevelParagraphStylePropertiesOptions;\n };\n}\n","import { uniqueNumericIdCreator, convertInchesToTwip } from \"@office-open/core\";\nimport { decimalNumber } from \"@office-open/core\";\n/**\n * Numbering module for WordprocessingML documents.\n *\n * Numbering provides support for numbered and bulleted lists.\n * Pure string serialization — no XmlComponent inheritance.\n *\n * Reference: http://officeopenxml.com/WPnumbering.php\n *\n * @module\n */\nimport { attr, attrBool, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { AlignmentType } from \"@parts/paragraph\";\nimport type { LevelParagraphStylePropertiesOptions } from \"@parts/paragraph/properties\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\n\nimport type { DocxReadContext } from \"../../context\";\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"../paragraph/stringify\";\nimport { LevelFormat } from \"./level\";\nimport type { LevelsOptions } from \"./level\";\n\n/**\n * Options for configuring numbering definitions.\n */\nexport interface NumberingOptions {\n /** Array of numbering configurations, each with levels and a reference name. */\n config: {\n levels: LevelsOptions[];\n reference: string;\n }[];\n /** Numbering cleanup ID (w:numIdMacAtCleanup) */\n numIdMacAtCleanup?: number;\n /** Picture bullet definitions for numbering (w:numPicBullet) */\n numPicBullets?: {\n numPicBulletId: number;\n pict?: string;\n }[];\n}\n\n/** Namespace attributes for w:numbering (pre-computed constant). */\nconst NUMBERING_ATTRS =\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ' +\n 'mc:Ignorable=\"w14 w15 wp14\"';\n\n/** Default bullet levels (9 levels: 0-8). */\nconst DEFAULT_BULLET_LEVELS: LevelsOptions[] = [\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 0,\n style: {\n paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: convertInchesToTwip(0.5) } },\n },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 1,\n style: {\n paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: convertInchesToTwip(1) } },\n },\n text: \"○\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 2,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 2160 } } },\n text: \"■\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 3,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 2880 } } },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 4,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 3600 } } },\n text: \"○\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 5,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 4320 } } },\n text: \"■\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 6,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 5040 } } },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 7,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 5760 } } },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 8,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 6480 } } },\n text: \"●\",\n },\n];\n\n/**\n * Numbering definitions for a WordprocessingML document.\n *\n * Pure data accumulator — no XmlComponent inheritance.\n * Serializes via `serialize()` producing a complete XML part.\n */\nexport class Numbering {\n private abstractNumberingData = new Map<\n string,\n { id: number; levels: LevelsOptions[]; extraOptions?: AbstractNumberingExtraOptions }\n >();\n private concreteNumberingData = new Map<\n string,\n {\n numId: number;\n abstractNumId: number;\n reference: string;\n instance: number;\n overrideLevels?: { num: number; start?: number }[];\n }\n >();\n private referenceConfigMap = new Map<string, LevelsOptions[]>();\n private abstractNumUniqueNumericId = uniqueNumericIdCreator();\n private concreteNumUniqueNumericId = uniqueNumericIdCreator(1);\n private _numIdMacAtCleanup?: number;\n private _numPicBullets?: { numPicBulletId: number; pict?: string }[];\n\n public constructor(options: NumberingOptions) {\n this._numIdMacAtCleanup = options.numIdMacAtCleanup;\n this._numPicBullets = options.numPicBullets;\n\n const defaultAbstractId = this.abstractNumUniqueNumericId();\n\n this.abstractNumberingData.set(\"default-bullet-numbering\", {\n id: defaultAbstractId,\n levels: DEFAULT_BULLET_LEVELS,\n });\n\n this.concreteNumberingData.set(\"default-bullet-numbering\", {\n abstractNumId: defaultAbstractId,\n instance: 0,\n numId: 1,\n overrideLevels: [{ num: 0, start: 1 }],\n reference: \"default-bullet-numbering\",\n });\n\n for (const con of options.config) {\n this.abstractNumberingData.set(con.reference, {\n id: this.abstractNumUniqueNumericId(),\n levels: con.levels,\n });\n this.referenceConfigMap.set(con.reference, con.levels);\n }\n }\n\n /** Serialize to word/numbering.xml content (with XML declaration). */\n public serialize(): string {\n const parts: string[] = [];\n parts.push(`<w:numbering ${NUMBERING_ATTRS}>`);\n\n // numPicBullet elements come first (XSD order)\n if (this._numPicBullets) {\n for (const bullet of this._numPicBullets) {\n if (bullet.pict) {\n parts.push(\n `<w:numPicBullet w:numPicBulletId=\"${bullet.numPicBulletId}\">${bullet.pict}</w:numPicBullet>`,\n );\n } else {\n parts.push(`<w:numPicBullet w:numPicBulletId=\"${bullet.numPicBulletId}\"/>`);\n }\n }\n }\n\n for (const an of this.abstractNumberingData.values()) {\n parts.push(stringifyAbstractNumbering(an.id, an.levels, an.extraOptions));\n }\n for (const cn of this.concreteNumberingData.values()) {\n parts.push(stringifyConcreteNumbering(cn));\n }\n if (this._numIdMacAtCleanup !== undefined) {\n parts.push(`<w:numIdMacAtCleanup w:val=\"${decimalNumber(this._numIdMacAtCleanup)}\"/>`);\n }\n\n parts.push(\"</w:numbering>\");\n return '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>' + parts.join(\"\");\n }\n\n /**\n * Creates a concrete numbering instance from an abstract numbering definition.\n */\n public createConcreteNumberingInstance(reference: string, instance: number): void {\n const abstractNumbering = this.abstractNumberingData.get(reference);\n if (!abstractNumbering) return;\n\n const fullReference = `${reference}-${instance}`;\n if (this.concreteNumberingData.has(fullReference)) return;\n\n const referenceConfigLevels = this.referenceConfigMap.get(reference);\n const firstLevelStartNumber = referenceConfigLevels && referenceConfigLevels[0].start;\n\n this.concreteNumberingData.set(fullReference, {\n abstractNumId: abstractNumbering.id,\n instance,\n numId: this.concreteNumUniqueNumericId(),\n overrideLevels: [\n typeof firstLevelStartNumber === \"number\" && Number.isInteger(firstLevelStartNumber)\n ? { num: 0, start: firstLevelStartNumber }\n : { num: 0, start: 1 },\n ],\n reference,\n });\n }\n\n /** Gets all concrete numbering instances. */\n public get concreteNumbering(): { numId: number; reference: string; instance: number }[] {\n return [...this.concreteNumberingData.values()];\n }\n\n /** Gets all reference configurations. */\n public get referenceConfig(): LevelsOptions[][] {\n return [...this.referenceConfigMap.values()];\n }\n}\n\n// ── Types ──\n\n/** Extra options for abstract numbering. Re-exported from abstract-numbering module. */\ninterface AbstractNumberingExtraOptions {\n nsid?: string;\n tmpl?: string;\n name?: string;\n styleLink?: string;\n numStyleLink?: string;\n}\n\n// ── Pure function serializers ──\n\nfunction stringifyAbstractNumbering(\n id: number,\n levels: LevelsOptions[],\n extraOptions?: AbstractNumberingExtraOptions,\n): string {\n const parts: string[] = [];\n parts.push(\n `<w:abstractNum w:abstractNumId=\"${decimalNumber(id)}\" w15:restartNumberingAfterBreak=\"0\">`,\n );\n\n if (extraOptions?.nsid !== undefined) {\n parts.push(`<w:nsid w:val=\"${extraOptions.nsid}\"/>`);\n }\n parts.push(`<w:multiLevelType w:val=\"hybridMultilevel\"/>`);\n if (extraOptions?.tmpl !== undefined) {\n parts.push(`<w:tmpl w:val=\"${extraOptions.tmpl}\"/>`);\n }\n if (extraOptions?.name !== undefined) {\n parts.push(`<w:name w:val=\"${extraOptions.name}\"/>`);\n }\n if (extraOptions?.styleLink !== undefined) {\n parts.push(`<w:styleLink w:val=\"${extraOptions.styleLink}\"/>`);\n }\n if (extraOptions?.numStyleLink !== undefined) {\n parts.push(`<w:numStyleLink w:val=\"${extraOptions.numStyleLink}\"/>`);\n }\n\n for (const level of levels) {\n parts.push(stringifyLevel(level));\n }\n\n parts.push(\"</w:abstractNum>\");\n return parts.join(\"\");\n}\n\nfunction stringifyConcreteNumbering(cn: {\n numId: number;\n abstractNumId: number;\n overrideLevels?: { num: number; start?: number }[];\n}): string {\n const parts: string[] = [];\n parts.push(`<w:num w:numId=\"${decimalNumber(cn.numId)}\">`);\n parts.push(`<w:abstractNumId w:val=\"${decimalNumber(cn.abstractNumId)}\"/>`);\n\n if (cn.overrideLevels) {\n for (const level of cn.overrideLevels) {\n if (level.start !== undefined) {\n parts.push(\n `<w:lvlOverride w:ilvl=\"${level.num}\"><w:startOverride w:val=\"${level.start}\"/></w:lvlOverride>`,\n );\n } else {\n parts.push(`<w:lvlOverride w:ilvl=\"${level.num}\"/>`);\n }\n }\n }\n\n parts.push(\"</w:num>\");\n return parts.join(\"\");\n}\n\nfunction stringifyLevel(opts: LevelsOptions): string {\n const children: string[] = [];\n\n children.push(`<w:start w:val=\"${decimalNumber(opts.start ?? 1)}\"/>`);\n if (opts.format) children.push(`<w:numFmt w:val=\"${opts.format}\"/>`);\n if (opts.lvlRestart !== undefined)\n children.push(`<w:lvlRestart w:val=\"${decimalNumber(opts.lvlRestart)}\"/>`);\n if (opts.suffix) children.push(`<w:suff w:val=\"${opts.suffix}\"/>`);\n if (opts.isLegalNumberingStyle) children.push(\"<w:isLgl/>\");\n if (opts.text) children.push(`<w:lvlText w:val=\"${opts.text}\"/>`);\n if (opts.lvlPicBulletId !== undefined)\n children.push(`<w:lvlPicBulletId w:val=\"${decimalNumber(opts.lvlPicBulletId)}\"/>`);\n if (opts.legacy !== undefined) {\n const legacyAttrs: string[] = [];\n if (opts.legacy.space !== undefined) legacyAttrs.push(`w:legacySpace=\"${opts.legacy.space}\"`);\n if (opts.legacy.indent !== undefined)\n legacyAttrs.push(`w:legacyIndent=\"${opts.legacy.indent}\"`);\n children.push(`<w:legacy ${legacyAttrs.join(\" \")}/>`);\n }\n children.push(`<w:lvlJc w:val=\"${opts.alignment ?? AlignmentType.START}\"/>`);\n\n // Paragraph/run properties — use compile-path pure string builders\n const pPrXml = stringifyParagraphProperties(opts.style && opts.style.paragraph).xml;\n const rPrXml = stringifyRunProperties(opts.style && opts.style.run);\n if (pPrXml) children.push(pPrXml);\n if (rPrXml) children.push(rPrXml);\n\n const lvlAttrs: string[] = [\n `w:ilvl=\"${decimalNumber(Math.min(opts.level, 9))}\"`,\n `w15:tentative=\"1\"`,\n ];\n if (opts.templateCode !== undefined) lvlAttrs.push(`w:tplc=\"${opts.templateCode}\"`);\n if (opts.tentative !== undefined) lvlAttrs.push(`w:tentative=\"${opts.tentative ? 1 : 0}\"`);\n\n return `<w:lvl ${lvlAttrs.join(\" \")}>${children.join(\"\")}</w:lvl>`;\n}\n\n// ── Parse (Element → NumberingOptions) ──\n\n/**\n * Parse w:numbering element into NumberingOptions.\n */\nexport function parseNumberingDefinitions(\n el: Element,\n parseParagraphProperties: (el: Element, ctx: DocxReadContext) => Record<string, unknown>,\n ctx: DocxReadContext,\n): NumberingOptions | undefined {\n const abstractNums = new Map<string, Element>();\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:abstractNum\") continue;\n const id = attr(child, \"w:abstractNumId\");\n if (id !== undefined) abstractNums.set(id, child);\n }\n\n const numToAbstract = new Map<string, string>();\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:num\") continue;\n const numId = attr(child, \"w:numId\");\n const abstractRef = findChild(child, \"w:abstractNumId\");\n const abstractId = abstractRef ? attr(abstractRef, \"w:val\") : undefined;\n if (numId !== undefined && abstractId !== undefined) {\n numToAbstract.set(numId, abstractId);\n }\n }\n\n const configs: NumberingOptions[\"config\"] = [];\n\n for (const [numId, abstractId] of numToAbstract) {\n const abstractEl = abstractNums.get(abstractId);\n if (!abstractEl) continue;\n\n const levels: LevelsOptions[] = [];\n for (const child of abstractEl.elements ?? []) {\n if (child.name !== \"w:lvl\") continue;\n const levelOpts = parseLevelEl(child, parseParagraphProperties, ctx);\n if (levelOpts) levels.push(levelOpts);\n }\n\n if (levels.length > 0 && levels.every((l) => l.format === LevelFormat.BULLET)) continue;\n\n if (levels.length > 0) {\n configs.push({ reference: `list_${numId}`, levels });\n }\n }\n\n if (configs.length === 0) return undefined;\n return { config: configs };\n}\n\nfunction parseLevelEl(\n el: Element,\n parseParagraphProperties: (el: Element, ctx: DocxReadContext) => Record<string, unknown>,\n ctx: DocxReadContext,\n): LevelsOptions | undefined {\n const opts: Partial<LevelsOptions> = {};\n\n const level = attrNum(el, \"w:ilvl\");\n if (level !== undefined) opts.level = level;\n\n const start = findChild(el, \"w:start\");\n if (start) {\n const val = attrNum(start, \"w:val\");\n if (val !== undefined) opts.start = val;\n }\n\n const lvlRestart = findChild(el, \"w:lvlRestart\");\n if (lvlRestart) {\n const val = attrNum(lvlRestart, \"w:val\");\n if (val !== undefined) opts.lvlRestart = val;\n }\n\n const numFmt = findChild(el, \"w:numFmt\");\n if (numFmt) {\n const val = attr(numFmt, \"w:val\");\n if (val) opts.format = val as LevelsOptions[\"format\"];\n }\n\n const suff = findChild(el, \"w:suff\");\n if (suff) {\n const val = attr(suff, \"w:val\");\n if (val) opts.suffix = val as LevelsOptions[\"suffix\"];\n }\n\n if (findChild(el, \"w:isLgl\")) opts.isLegalNumberingStyle = true;\n\n const lvlText = findChild(el, \"w:lvlText\");\n if (lvlText) {\n const val = attr(lvlText, \"w:val\");\n if (val) opts.text = val;\n }\n\n const lvlPicBulletId = findChild(el, \"w:lvlPicBulletId\");\n if (lvlPicBulletId) {\n const val = attrNum(lvlPicBulletId, \"w:val\");\n if (val !== undefined) opts.lvlPicBulletId = val;\n }\n\n // Legacy spacing (w:legacy/@w:legacySpace, @w:legacyIndent)\n const legacyEl = findChild(el, \"w:legacy\");\n if (legacyEl) {\n const legacy: NonNullable<LevelsOptions[\"legacy\"]> = {};\n const space = attrNum(legacyEl, \"w:legacySpace\");\n if (space !== undefined) legacy.space = space;\n const indent = attrNum(legacyEl, \"w:legacyIndent\");\n if (indent !== undefined) legacy.indent = indent;\n if (Object.keys(legacy).length > 0) opts.legacy = legacy;\n }\n\n const lvlJc = findChild(el, \"w:lvlJc\");\n if (lvlJc) {\n const val = attr(lvlJc, \"w:val\");\n if (val) opts.alignment = val as LevelsOptions[\"alignment\"];\n }\n\n // Level attributes (w:tplc templateCode; w:tentative — note stringify also\n // emits a fixed w15:tentative=\"1\" which we don't round-trip as it's constant)\n const tplc = attr(el, \"w:tplc\");\n if (tplc) opts.templateCode = tplc;\n const tentative = attrBool(el, \"w:tentative\");\n if (tentative !== undefined) opts.tentative = tentative;\n\n // Run + paragraph properties — reuse the complete parse helpers for full\n // fidelity (stringifyLevel delegates to stringifyRunProperties /\n // stringifyParagraphProperties, so parse must use the matching readers).\n const style: NonNullable<LevelsOptions[\"style\"]> = {};\n const rPr = findChild(el, \"w:rPr\");\n if (rPr) {\n const runOpts = parseRunProperties(rPr);\n if (Object.keys(runOpts).length > 0) style.run = runOpts;\n }\n const pPr = findChild(el, \"w:pPr\");\n if (pPr) {\n const paraOpts = parseParagraphProperties(pPr, ctx);\n if (Object.keys(paraOpts).length > 0) {\n style.paragraph = paraOpts as unknown as LevelParagraphStylePropertiesOptions;\n }\n }\n if (Object.keys(style).length > 0) opts.style = style;\n\n return Object.keys(opts).length > 0 ? (opts as LevelsOptions) : undefined;\n}\n","/**\n * Factory module for creating default document styles.\n *\n * Creates styles matching Microsoft Word's default document template.\n * Pure string generation — no XmlComponent inheritance.\n *\n * Reference: http://officeopenxml.com/WPstyles.php\n *\n * @module\n */\nimport type { ParagraphStylePropertiesOptions } from \"@parts/paragraph/properties\";\nimport type { RunStylePropertiesOptions } from \"@parts/paragraph/run/properties\";\n\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"../paragraph/stringify\";\nimport type { StylesOptions } from \"./styles\";\n\n// ── Style options interfaces ──\n\nexport interface DefaultStylesOptions {\n document?: DocumentDefaultsOptions;\n title?: BaseParagraphStyleOptions;\n subtitle?: BaseParagraphStyleOptions;\n heading1?: BaseParagraphStyleOptions;\n heading2?: BaseParagraphStyleOptions;\n heading3?: BaseParagraphStyleOptions;\n heading4?: BaseParagraphStyleOptions;\n heading5?: BaseParagraphStyleOptions;\n heading6?: BaseParagraphStyleOptions;\n heading7?: BaseParagraphStyleOptions;\n heading8?: BaseParagraphStyleOptions;\n heading9?: BaseParagraphStyleOptions;\n strong?: BaseParagraphStyleOptions;\n emphasis?: BaseParagraphStyleOptions;\n listParagraph?: BaseParagraphStyleOptions;\n quote?: BaseParagraphStyleOptions;\n intenseQuote?: BaseParagraphStyleOptions;\n hyperlink?: BaseCharacterStyleOptions;\n footnoteReference?: BaseCharacterStyleOptions;\n footnoteText?: BaseParagraphStyleOptions;\n footnoteTextChar?: BaseCharacterStyleOptions;\n endnoteReference?: BaseCharacterStyleOptions;\n endnoteText?: BaseParagraphStyleOptions;\n endnoteTextChar?: BaseCharacterStyleOptions;\n}\n\nexport interface DocumentDefaultsOptions {\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n}\n\ninterface StyleOptions {\n name?: string;\n aliases?: string;\n basedOn?: string;\n next?: string;\n link?: string;\n autoRedefine?: boolean;\n uiPriority?: number;\n semiHidden?: boolean;\n unhideWhenUsed?: boolean;\n quickFormat?: boolean;\n locked?: boolean;\n personal?: boolean;\n personalCompose?: boolean;\n personalReply?: boolean;\n}\n\nexport type BaseParagraphStyleOptions = {\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n} & StyleOptions & { id?: string };\n\nexport type BaseCharacterStyleOptions = {\n run?: RunStylePropertiesOptions;\n} & StyleOptions & { id?: string };\n\n// ── String builders ──\n\n/** Escape special XML characters. */\nfunction esc(s: string): string {\n return s\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\");\n}\n\n/** Build `<w:style>` XML for a paragraph style. */\nexport function stringifyParagraphStyle(\n opts: StyleOptions & {\n id: string;\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n },\n): string {\n const children: string[] = [];\n\n children.push(`<w:name w:val=\"${esc(opts.name ?? opts.id)}\"/>`);\n if (opts.aliases) children.push(`<w:aliases w:val=\"${esc(opts.aliases)}\"/>`);\n if (opts.basedOn) children.push(`<w:basedOn w:val=\"${esc(opts.basedOn)}\"/>`);\n if (opts.next) children.push(`<w:next w:val=\"${esc(opts.next)}\"/>`);\n if (opts.link) children.push(`<w:link w:val=\"${esc(opts.link)}\"/>`);\n if (opts.autoRedefine) children.push(\"<w:autoRedefine/>\");\n if (opts.uiPriority !== undefined) children.push(`<w:uiPriority w:val=\"${opts.uiPriority}\"/>`);\n if (opts.semiHidden) children.push(\"<w:semiHidden/>\");\n if (opts.unhideWhenUsed) children.push(\"<w:unhideWhenUsed/>\");\n if (opts.quickFormat) children.push(\"<w:qFormat/>\");\n if (opts.locked) children.push(\"<w:locked/>\");\n if (opts.personal) children.push(\"<w:personal/>\");\n if (opts.personalCompose) children.push(\"<w:personalCompose/>\");\n if (opts.personalReply) children.push(\"<w:personalReply/>\");\n\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) children.push(pPr);\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n\n return `<w:style w:type=\"paragraph\" w:styleId=\"${esc(opts.id)}\">${children.join(\"\")}</w:style>`;\n}\n\n/** Build `<w:style>` XML for a character style. */\nexport function stringifyCharacterStyle(\n opts: StyleOptions & {\n id: string;\n run?: RunStylePropertiesOptions;\n },\n): string {\n const children: string[] = [];\n\n children.push(`<w:name w:val=\"${esc(opts.name ?? opts.id)}\"/>`);\n if (opts.aliases) children.push(`<w:aliases w:val=\"${esc(opts.aliases)}\"/>`);\n if (opts.basedOn) children.push(`<w:basedOn w:val=\"${esc(opts.basedOn)}\"/>`);\n if (opts.link) children.push(`<w:link w:val=\"${esc(opts.link)}\"/>`);\n if (opts.autoRedefine) children.push(\"<w:autoRedefine/>\");\n if (opts.uiPriority !== undefined) children.push(`<w:uiPriority w:val=\"${opts.uiPriority}\"/>`);\n if (opts.semiHidden) children.push(\"<w:semiHidden/>\");\n if (opts.unhideWhenUsed) children.push(\"<w:unhideWhenUsed/>\");\n if (opts.locked) children.push(\"<w:locked/>\");\n if (opts.personal) children.push(\"<w:personal/>\");\n if (opts.personalCompose) children.push(\"<w:personalCompose/>\");\n if (opts.personalReply) children.push(\"<w:personalReply/>\");\n\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n\n return `<w:style w:type=\"character\" w:styleId=\"${esc(opts.id)}\">${children.join(\"\")}</w:style>`;\n}\n\n/** Build `<w:docDefaults>` XML matching Word's default settings. */\nfunction stringifyDocDefaults(opts: DocumentDefaultsOptions): string {\n const children: string[] = [];\n\n // rPrDefault - Word default: Calibri 11pt (22 half-points), theme fonts\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) {\n children.push(`<w:rPrDefault>${rPr}</w:rPrDefault>`);\n } else {\n // Match Word's default run properties exactly\n children.push(\n `<w:rPrDefault><w:rPr>` +\n `<w:rFonts w:asciiTheme=\"minorHAnsi\" w:eastAsiaTheme=\"minorEastAsia\" w:hAnsiTheme=\"minorHAnsi\" w:cstheme=\"minorBidi\"/>` +\n `<w:kern w:val=\"2\"/>` +\n `<w:sz w:val=\"22\"/><w:szCs w:val=\"24\"/>` +\n `<w:lang w:val=\"en-US\" w:eastAsia=\"zh-CN\" w:bidi=\"ar-SA\"/>` +\n `<w14:ligatures w14:val=\"standardContextual\"/>` +\n `</w:rPr></w:rPrDefault>`,\n );\n }\n\n // pPrDefault - Word default: spacing after 8pt (160 twips), line 1.16 (278 twips)\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) {\n children.push(`<w:pPrDefault>${pPr}</w:pPrDefault>`);\n } else {\n // Match Word's default paragraph properties exactly\n children.push(\n `<w:pPrDefault><w:pPr>` +\n `<w:spacing w:after=\"160\" w:line=\"278\" w:lineRule=\"auto\"/>` +\n `</w:pPr></w:pPrDefault>`,\n );\n }\n\n return `<w:docDefaults>${children.join(\"\")}</w:docDefaults>`;\n}\n\n// ── Factory ──\n\nlet cachedDefaultStyles: StylesOptions | null = null;\n\n/**\n * Factory for creating default document styles.\n *\n * Creates styles matching Microsoft Word's default document template.\n * Pure string generation — no XmlComponent inheritance.\n */\nexport class DefaultStylesFactory {\n public newInstance(options: DefaultStylesOptions = {}): StylesOptions {\n if (Object.keys(options).length === 0) {\n if (!cachedDefaultStyles) {\n cachedDefaultStyles = this.build({});\n }\n return cachedDefaultStyles;\n }\n return this.build(options);\n }\n\n private build(options: DefaultStylesOptions): StylesOptions {\n const importedStyles: { _raw: string }[] = [];\n\n // XML namespace attributes for styles root element (matching Word exactly)\n const initialAttributes: Record<string, string> = {\n \"xmlns:mc\": \"http://schemas.openxmlformats.org/markup-compatibility/2006\",\n \"xmlns:r\": \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\",\n \"xmlns:w\": \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\",\n \"xmlns:w14\": \"http://schemas.microsoft.com/office/word/2010/wordml\",\n \"xmlns:w15\": \"http://schemas.microsoft.com/office/word/2012/wordml\",\n \"mc:Ignorable\": \"w14 w15\",\n };\n\n importedStyles.push({ _raw: stringifyDocDefaults(options.document ?? {}) });\n\n // Latent styles - complete list from Word's default template\n // Only include styles that are NOT explicitly defined below\n importedStyles.push({\n _raw:\n `<w:latentStyles w:defLockedState=\"0\" w:defUIPriority=\"99\" w:defSemiHidden=\"0\" w:defUnhideWhenUsed=\"0\" w:defQFormat=\"0\" w:count=\"376\">` +\n `<w:lsdException w:name=\"Normal\" w:uiPriority=\"0\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 1\" w:uiPriority=\"9\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 2\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 3\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 4\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 5\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 6\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 7\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 8\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 9\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Default Paragraph Font\" w:semiHidden=\"1\" w:uiPriority=\"1\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"Normal Table\" w:semiHidden=\"1\" w:uiPriority=\"99\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"No List\" w:semiHidden=\"1\" w:uiPriority=\"99\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"Subtitle\" w:uiPriority=\"11\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Strong\" w:uiPriority=\"22\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Emphasis\" w:uiPriority=\"20\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Hyperlink\" w:semiHidden=\"1\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"FollowedHyperlink\" w:semiHidden=\"1\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"No Spacing\" w:uiPriority=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Revision\" w:semiHidden=\"1\"/>` +\n `</w:latentStyles>`,\n });\n\n // Built-in styles required by Word\n // Normal paragraph style (default for paragraphs)\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:default=\"1\" w:styleId=\"Normal\">` +\n `<w:name w:val=\"Normal\"/><w:qFormat/>` +\n `<w:pPr><w:widowControl w:val=\"0\"/></w:pPr>` +\n `</w:style>`,\n });\n\n // heading 1-9 styles with proper formatting\n const headings = [\n {\n id: \"Heading1\",\n name: \"heading 1\",\n link: \"Heading1Char\",\n sz: \"48\",\n before: \"480\",\n after: \"80\",\n outlineLvl: \"0\",\n },\n {\n id: \"Heading2\",\n name: \"heading 2\",\n link: \"Heading2Char\",\n sz: \"40\",\n before: \"160\",\n after: \"80\",\n outlineLvl: \"1\",\n },\n {\n id: \"Heading3\",\n name: \"heading 3\",\n link: \"Heading3Char\",\n sz: \"32\",\n before: \"160\",\n after: \"80\",\n outlineLvl: \"2\",\n },\n {\n id: \"Heading4\",\n name: \"heading 4\",\n link: \"Heading4Char\",\n sz: \"28\",\n before: \"80\",\n after: \"40\",\n outlineLvl: \"3\",\n },\n {\n id: \"Heading5\",\n name: \"heading 5\",\n link: \"Heading5Char\",\n sz: \"24\",\n before: \"80\",\n after: \"40\",\n outlineLvl: \"4\",\n },\n {\n id: \"Heading6\",\n name: \"heading 6\",\n link: \"Heading6Char\",\n sz: undefined,\n before: \"40\",\n after: \"0\",\n outlineLvl: \"5\",\n },\n {\n id: \"Heading7\",\n name: \"heading 7\",\n link: \"Heading7Char\",\n sz: undefined,\n before: \"40\",\n after: \"0\",\n outlineLvl: \"6\",\n },\n {\n id: \"Heading8\",\n name: \"heading 8\",\n link: \"Heading8Char\",\n sz: undefined,\n before: undefined,\n after: \"0\",\n outlineLvl: \"7\",\n },\n {\n id: \"Heading9\",\n name: \"heading 9\",\n link: \"Heading9Char\",\n sz: undefined,\n before: undefined,\n after: \"0\",\n outlineLvl: \"8\",\n },\n ];\n\n for (const h of headings) {\n const pPrParts: string[] = [`<w:keepNext/>`, `<w:keepLines/>`];\n if (h.before || h.after) {\n const sp: string[] = [];\n if (h.before) sp.push(`w:before=\"${h.before}\"`);\n if (h.after) sp.push(`w:after=\"${h.after}\"`);\n pPrParts.push(`<w:spacing ${sp.join(\" \")}/>`);\n }\n pPrParts.push(`<w:outlineLvl w:val=\"${h.outlineLvl}\"/>`);\n\n const rPrParts: string[] = [];\n // heading 1-6 use accent1 color, 7-9 use text1 color\n if (parseInt(h.outlineLvl) < 6) {\n rPrParts.push(\n `<w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/>`,\n );\n rPrParts.push(`<w:color w:val=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/>`);\n } else {\n rPrParts.push(`<w:rFonts w:cstheme=\"majorBidi\"/>`);\n rPrParts.push(`<w:color w:val=\"595959\" w:themeColor=\"text1\" w:themeTint=\"A6\"/>`);\n }\n if (h.sz) {\n rPrParts.push(`<w:sz w:val=\"${h.sz}\"/><w:szCs w:val=\"${h.sz}\"/>`);\n }\n // heading 6-9 have bold\n if (parseInt(h.outlineLvl) >= 5) {\n rPrParts.push(`<w:b/><w:bCs/>`);\n }\n\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"${h.id}\">` +\n `<w:name w:val=\"${h.name}\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:next w:val=\"Normal\"/>` +\n `<w:link w:val=\"${h.link}\"/>` +\n `<w:uiPriority w:val=\"9\"/>` +\n (parseInt(h.outlineLvl) > 0 ? `<w:semiHidden/><w:unhideWhenUsed/>` : \"\") +\n `<w:qFormat/>` +\n `<w:pPr>${pPrParts.join(\"\")}</w:pPr>` +\n `<w:rPr>${rPrParts.join(\"\")}</w:rPr>` +\n `</w:style>`,\n });\n\n // Linked character styles for headings\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"${h.link}\">` +\n `<w:name w:val=\"${h.name} Char\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:link w:val=\"${h.id}\"/>` +\n `<w:uiPriority w:val=\"9\"/>` +\n (parseInt(h.outlineLvl) > 0 ? `<w:semiHidden/>` : \"\") +\n `<w:rPr>${rPrParts.join(\"\")}</w:rPr>` +\n `</w:style>`,\n });\n }\n\n // DefaultParagraphFont character style (default for runs)\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:default=\"1\" w:styleId=\"DefaultParagraphFont\">` +\n `<w:name w:val=\"Default Paragraph Font\"/>` +\n `<w:uiPriority w:val=\"1\"/><w:semiHidden/><w:unhideWhenUsed/>` +\n `</w:style>`,\n });\n\n // Normal Table style (default for tables)\n importedStyles.push({\n _raw:\n `<w:style w:type=\"table\" w:default=\"1\" w:styleId=\"NormalTable\">` +\n `<w:name w:val=\"Normal Table\"/>` +\n `<w:uiPriority w:val=\"99\"/><w:semiHidden/><w:unhideWhenUsed/>` +\n `<w:tblPr>` +\n `<w:tblInd w:w=\"0\" w:type=\"dxa\"/>` +\n `<w:tblCellMar>` +\n `<w:top w:w=\"0\" w:type=\"dxa\"/>` +\n `<w:left w:w=\"108\" w:type=\"dxa\"/>` +\n `<w:bottom w:w=\"0\" w:type=\"dxa\"/>` +\n `<w:right w:w=\"108\" w:type=\"dxa\"/>` +\n `</w:tblCellMar>` +\n `</w:tblPr>` +\n `</w:style>`,\n });\n\n // No List numbering style (default for numbering)\n importedStyles.push({\n _raw:\n `<w:style w:type=\"numbering\" w:default=\"1\" w:styleId=\"NoList\">` +\n `<w:name w:val=\"No List\"/>` +\n `<w:uiPriority w:val=\"99\"/><w:semiHidden/><w:unhideWhenUsed/>` +\n `</w:style>`,\n });\n\n // Title style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"Title\">` +\n `<w:name w:val=\"Title\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:next w:val=\"Normal\"/>` +\n `<w:link w:val=\"TitleChar\"/>` +\n `<w:uiPriority w:val=\"10\"/>` +\n `<w:qFormat/>` +\n `<w:pPr><w:spacing w:after=\"80\" w:line=\"240\" w:lineRule=\"auto\"/><w:contextualSpacing/><w:jc w:val=\"center\"/></w:pPr>` +\n `<w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/>` +\n `<w:spacing w:val=\"-10\"/><w:kern w:val=\"28\"/><w:sz w:val=\"56\"/><w:szCs w:val=\"56\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Title Char style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"TitleChar\">` +\n `<w:name w:val=\"Title Char\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:link w:val=\"Title\"/>` +\n `<w:uiPriority w:val=\"10\"/>` +\n `<w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/>` +\n `<w:spacing w:val=\"-10\"/><w:kern w:val=\"28\"/><w:sz w:val=\"56\"/><w:szCs w:val=\"56\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Subtitle style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"Subtitle\">` +\n `<w:name w:val=\"Subtitle\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:next w:val=\"Normal\"/>` +\n `<w:link w:val=\"SubtitleChar\"/>` +\n `<w:uiPriority w:val=\"11\"/>` +\n `<w:qFormat/>` +\n `<w:pPr><w:jc w:val=\"center\"/></w:pPr>` +\n `<w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/>` +\n `<w:color w:val=\"595959\" w:themeColor=\"text1\" w:themeTint=\"A6\"/>` +\n `<w:spacing w:val=\"15\"/><w:sz w:val=\"28\"/><w:szCs w:val=\"28\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Subtitle Char style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"SubtitleChar\">` +\n `<w:name w:val=\"Subtitle Char\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:link w:val=\"Subtitle\"/>` +\n `<w:uiPriority w:val=\"11\"/>` +\n `<w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/>` +\n `<w:color w:val=\"595959\" w:themeColor=\"text1\" w:themeTint=\"A6\"/>` +\n `<w:spacing w:val=\"15\"/><w:sz w:val=\"28\"/><w:szCs w:val=\"28\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // List Paragraph style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"ListParagraph\">` +\n `<w:name w:val=\"List Paragraph\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:uiPriority w:val=\"34\"/>` +\n `<w:qFormat/>` +\n `<w:pPr><w:ind w:left=\"720\"/><w:contextualSpacing/></w:pPr>` +\n `</w:style>`,\n });\n\n // Quote style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"Quote\">` +\n `<w:name w:val=\"Quote\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:next w:val=\"Normal\"/>` +\n `<w:link w:val=\"QuoteChar\"/>` +\n `<w:uiPriority w:val=\"29\"/>` +\n `<w:qFormat/>` +\n `<w:pPr><w:spacing w:before=\"160\"/><w:jc w:val=\"center\"/></w:pPr>` +\n `<w:rPr><w:i/><w:iCs/><w:color w:val=\"404040\" w:themeColor=\"text1\" w:themeTint=\"BF\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Quote Char style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"QuoteChar\">` +\n `<w:name w:val=\"Quote Char\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:link w:val=\"Quote\"/>` +\n `<w:uiPriority w:val=\"29\"/>` +\n `<w:rPr><w:i/><w:iCs/><w:color w:val=\"404040\" w:themeColor=\"text1\" w:themeTint=\"BF\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Intense Quote style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"IntenseQuote\">` +\n `<w:name w:val=\"Intense Quote\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:next w:val=\"Normal\"/>` +\n `<w:link w:val=\"IntenseQuoteChar\"/>` +\n `<w:uiPriority w:val=\"30\"/>` +\n `<w:qFormat/>` +\n `<w:pPr><w:pBdr><w:top w:val=\"single\" w:sz=\"4\" w:space=\"10\" w:color=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/>` +\n `<w:bottom w:val=\"single\" w:sz=\"4\" w:space=\"10\" w:color=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/></w:pBdr>` +\n `<w:spacing w:before=\"360\" w:after=\"360\"/><w:ind w:left=\"864\" w:right=\"864\"/><w:jc w:val=\"center\"/></w:pPr>` +\n `<w:rPr><w:i/><w:iCs/><w:color w:val=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Intense Quote Char style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"IntenseQuoteChar\">` +\n `<w:name w:val=\"Intense Quote Char\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:link w:val=\"IntenseQuote\"/>` +\n `<w:uiPriority w:val=\"30\"/>` +\n `<w:rPr><w:i/><w:iCs/><w:color w:val=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Hyperlink character style\n importedStyles.push({\n _raw: stringifyCharacterStyle({\n id: \"Hyperlink\",\n name: \"Hyperlink\",\n basedOn: \"DefaultParagraphFont\",\n semiHidden: true,\n unhideWhenUsed: true,\n run: { color: \"0563C1\", underline: { type: \"single\" } },\n ...options.hyperlink,\n }),\n });\n\n // Footnote Reference character style\n importedStyles.push({\n _raw: stringifyCharacterStyle({\n id: \"FootnoteReference\",\n name: \"footnote reference\",\n basedOn: \"DefaultParagraphFont\",\n semiHidden: true,\n unhideWhenUsed: true,\n run: { superScript: true },\n ...options.footnoteReference,\n }),\n });\n\n // Footnote Text paragraph style\n importedStyles.push({\n _raw: stringifyParagraphStyle({\n id: \"FootnoteText\",\n name: \"footnote text\",\n basedOn: \"Normal\",\n link: \"FootnoteTextChar\",\n semiHidden: true,\n uiPriority: 99,\n unhideWhenUsed: true,\n paragraph: { spacing: { after: 0, line: 240, lineRule: \"auto\" } },\n run: { size: 20 },\n ...options.footnoteText,\n }),\n });\n\n // Footnote Text Char character style\n importedStyles.push({\n _raw: stringifyCharacterStyle({\n id: \"FootnoteTextChar\",\n name: \"Footnote Text Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"FootnoteText\",\n semiHidden: true,\n run: { size: 20 },\n ...options.footnoteTextChar,\n }),\n });\n\n // Endnote Reference character style\n importedStyles.push({\n _raw: stringifyCharacterStyle({\n id: \"EndnoteReference\",\n name: \"endnote reference\",\n basedOn: \"DefaultParagraphFont\",\n semiHidden: true,\n unhideWhenUsed: true,\n run: { superScript: true },\n ...options.endnoteReference,\n }),\n });\n\n // Endnote Text paragraph style\n importedStyles.push({\n _raw: stringifyParagraphStyle({\n id: \"EndnoteText\",\n name: \"endnote text\",\n basedOn: \"Normal\",\n link: \"EndnoteTextChar\",\n semiHidden: true,\n uiPriority: 99,\n unhideWhenUsed: true,\n paragraph: { spacing: { after: 0, line: 240, lineRule: \"auto\" } },\n run: { size: 20 },\n ...options.endnoteText,\n }),\n });\n\n // Endnote Text Char character style\n importedStyles.push({\n _raw: stringifyCharacterStyle({\n id: \"EndnoteTextChar\",\n name: \"Endnote Text Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"EndnoteText\",\n semiHidden: true,\n run: { size: 20 },\n ...options.endnoteTextChar,\n }),\n });\n\n // Intense Reference character style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"IntenseReference\">` +\n `<w:name w:val=\"Intense Reference\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:uiPriority w:val=\"32\"/>` +\n `<w:qFormat/>` +\n `<w:rPr><w:b/><w:bCs/><w:smallCaps/><w:color w:val=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/><w:spacing w:val=\"5\"/></w:rPr>` +\n `</w:style>`,\n });\n\n return { importedStyles, initialAttributes };\n }\n}\n","/**\n * Styles module for WordprocessingML documents.\n *\n * Pure collector — no XmlComponent inheritance.\n * Collects child elements as raw XML strings and serializes.\n *\n * Reference: http://officeopenxml.com/WPstyles.php\n *\n * @module\n */\nimport { attr, attrBool, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { ParagraphStylePropertiesOptions } from \"@parts/paragraph/properties\";\nimport type { RunStylePropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\nimport type {\n BaseCharacterStyleOptions,\n BaseParagraphStyleOptions,\n DefaultStylesOptions,\n DocumentDefaultsOptions,\n} from \"@parts/styles/factory\";\nimport { stringifyCharacterStyle, stringifyParagraphStyle } from \"@parts/styles/factory\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Options for configuring document styles.\n */\nexport interface StylesOptions {\n /** Default styles for document, headings, and common elements */\n default?: DefaultStylesOptions;\n /** Initial namespace attributes for the styles root element */\n initialAttributes?: Record<string, string>;\n /** Array of raw XML style elements */\n importedStyles?: { _raw: string }[];\n /** Array of custom paragraph style definitions */\n paragraphStyles?: (BaseParagraphStyleOptions & { id: string })[];\n /** Array of custom character style definitions */\n characterStyles?: (BaseCharacterStyleOptions & { id: string })[];\n}\n\n/**\n * Represents the styles definitions in a WordprocessingML document.\n *\n * Pure collector — no XmlComponent inheritance.\n * Collects child elements as raw XML strings and serializes.\n */\nexport class Styles {\n private attributes: Record<string, string> = {};\n private parts: string[] = [];\n\n public constructor(options: StylesOptions) {\n if (options.initialAttributes) {\n this.attributes = options.initialAttributes;\n }\n\n if (options.importedStyles) {\n for (const style of options.importedStyles) {\n if (style._raw) this.parts.push(style._raw);\n }\n }\n\n if (options.paragraphStyles) {\n for (const style of options.paragraphStyles) {\n this.parts.push(\n stringifyParagraphStyle({\n id: style.id,\n name: style.name ?? style.id,\n aliases: style.aliases,\n basedOn: style.basedOn,\n next: style.next,\n link: style.link,\n autoRedefine: style.autoRedefine,\n quickFormat: style.quickFormat,\n semiHidden: style.semiHidden,\n uiPriority: style.uiPriority,\n unhideWhenUsed: style.unhideWhenUsed,\n locked: style.locked,\n personal: style.personal,\n personalCompose: style.personalCompose,\n personalReply: style.personalReply,\n paragraph: style.paragraph,\n run: style.run,\n }),\n );\n }\n }\n\n if (options.characterStyles) {\n for (const style of options.characterStyles) {\n this.parts.push(\n stringifyCharacterStyle({\n id: style.id,\n name: style.name ?? style.id,\n aliases: style.aliases,\n basedOn: style.basedOn,\n link: style.link,\n autoRedefine: style.autoRedefine,\n semiHidden: style.semiHidden,\n uiPriority: style.uiPriority,\n unhideWhenUsed: style.unhideWhenUsed,\n locked: style.locked,\n personal: style.personal,\n personalCompose: style.personalCompose,\n personalReply: style.personalReply,\n run: style.run,\n }),\n );\n }\n }\n }\n\n /**\n * Serialize to word/styles.xml content (with XML declaration).\n */\n public serialize(): string {\n const attrParts: string[] = [];\n for (const [k, v] of Object.entries(this.attributes)) {\n if (v !== undefined && v !== null) attrParts.push(` ${k}=\"${v}\"`);\n }\n\n const attrs = attrParts.join(\"\");\n const body = this.parts.join(\"\");\n return `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:styles${attrs}>${body}</w:styles>`;\n }\n}\n\n// ── Parse helpers (for descriptor pipeline) ──\n\n/** Style IDs generated by DefaultStylesFactory — skip these during parsing. */\nconst BUILTIN_STYLE_IDS = new Set([\n \"Title\",\n \"Heading1\",\n \"Heading2\",\n \"Heading3\",\n \"Heading4\",\n \"Heading5\",\n \"Heading6\",\n \"Strong\",\n \"ListParagraph\",\n \"Hyperlink\",\n \"FootnoteText\",\n \"FootnoteTextChar\",\n \"EndnoteText\",\n \"EndnoteTextChar\",\n \"FootnoteReference\",\n \"EndnoteReference\",\n]);\n\n/**\n * Build a cache of style elements keyed by styleId.\n */\nexport function buildStyleCache(stylesEl: Element | undefined): Map<string, Element> {\n const cache = new Map<string, Element>();\n if (!stylesEl) return cache;\n\n for (const child of stylesEl.elements ?? []) {\n if (child.name !== \"w:style\") continue;\n const styleId = attr(child, \"w:styleId\");\n if (styleId) {\n cache.set(styleId, child);\n }\n }\n\n return cache;\n}\n\n/**\n * Build a cache of abstract numbering elements keyed by abstractNumId.\n */\nexport function buildNumberingCache(numberingEl: Element | undefined): Map<string, Element> {\n const cache = new Map<string, Element>();\n if (!numberingEl) return cache;\n\n for (const child of numberingEl.elements ?? []) {\n if (child.name !== \"w:abstractNum\") continue;\n const abstractNumId = attr(child, \"w:abstractNumId\");\n if (abstractNumId !== undefined) {\n cache.set(abstractNumId, child);\n }\n }\n\n return cache;\n}\n\n/** Parsed style — concrete shape (not Record) with a transient _type marker. */\ninterface ParsedStyle {\n _type?: string;\n id?: string;\n default?: boolean;\n customStyle?: string;\n name?: string;\n aliases?: string;\n basedOn?: string;\n next?: string;\n link?: string;\n uiPriority?: number;\n quickFormat?: boolean;\n semiHidden?: boolean;\n unhideWhenUsed?: boolean;\n autoRedefine?: boolean;\n locked?: boolean;\n personal?: boolean;\n personalCompose?: boolean;\n personalReply?: boolean;\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n}\n\n/**\n * Parse w:styles element into StylesOptions.\n *\n * Skips built-in styles that DefaultStylesFactory already generates,\n * keeping only user-defined custom styles for round-trip fidelity.\n */\nexport function parseStyleDefinitions(\n el: Element,\n parseParagraphProperties: (el: Element, ctx: DocxReadContext) => Record<string, unknown>,\n ctx: DocxReadContext,\n): StylesOptions | undefined {\n const opts: StylesOptions = {};\n const paragraphStyles: (BaseParagraphStyleOptions & { id: string })[] = [];\n const characterStyles: (BaseCharacterStyleOptions & { id: string })[] = [];\n\n for (const child of el.elements ?? []) {\n if (child.name === \"w:docDefaults\") {\n const defOpts = parseDocDefaults(child, parseParagraphProperties, ctx);\n if (defOpts) opts.default = defOpts;\n } else if (child.name === \"w:style\") {\n const styleOpts = parseStyleElement(child, parseParagraphProperties, ctx);\n // Skip styles without a type or styleId — both are required to be useful.\n if (!styleOpts?._type || !styleOpts.id) continue;\n if (BUILTIN_STYLE_IDS.has(styleOpts.id)) continue;\n\n const type = styleOpts._type;\n delete styleOpts._type;\n\n if (type === \"paragraph\") {\n paragraphStyles.push(styleOpts as BaseParagraphStyleOptions & { id: string });\n } else if (type === \"character\") {\n characterStyles.push(styleOpts as BaseCharacterStyleOptions & { id: string });\n }\n }\n }\n\n if (paragraphStyles.length > 0) opts.paragraphStyles = paragraphStyles;\n if (characterStyles.length > 0) opts.characterStyles = characterStyles;\n\n return Object.keys(opts).length > 0 ? opts : undefined;\n}\n\nfunction parseDocDefaults(\n el: Element,\n parseParagraphProperties: (el: Element, ctx: DocxReadContext) => Record<string, unknown>,\n ctx: DocxReadContext,\n): DefaultStylesOptions | undefined {\n const document: DocumentDefaultsOptions = {};\n\n const rPrDefault = findChild(el, \"w:rPrDefault\");\n if (rPrDefault) {\n const rPr = findChild(rPrDefault, \"w:rPr\");\n if (rPr) {\n const runDefaults = parseRunProperties(rPr);\n if (Object.keys(runDefaults).length > 0) document.run = runDefaults;\n }\n }\n\n const pPrDefault = findChild(el, \"w:pPrDefault\");\n if (pPrDefault) {\n const pPr = findChild(pPrDefault, \"w:pPr\");\n if (pPr) {\n // Reuse the full paragraph-properties reader (stringifyDocDefaults uses\n // stringifyParagraphProperties) instead of only reading spacing, so jc/\n // ind/etc. round-trip too.\n const paraDefaults = parseParagraphProperties(pPr, ctx);\n if (Object.keys(paraDefaults).length > 0) {\n document.paragraph = paraDefaults as unknown as ParagraphStylePropertiesOptions;\n }\n }\n }\n\n return Object.keys(document).length > 0 ? { document } : undefined;\n}\n\nfunction parseStyleElement(\n el: Element,\n parseParagraphProperties: (el: Element, ctx: DocxReadContext) => Record<string, unknown>,\n ctx: DocxReadContext,\n): ParsedStyle | undefined {\n const opts: ParsedStyle = {};\n\n const type = attr(el, \"w:type\");\n if (type) opts._type = type;\n\n const id = attr(el, \"w:styleId\");\n if (id) opts.id = id;\n\n if (attrBool(el, \"w:default\")) opts.default = true;\n if (attrBool(el, \"w:customStyle\")) opts.customStyle = \"1\";\n\n const nameEl = findChild(el, \"w:name\");\n if (nameEl) {\n const name = attr(nameEl, \"w:val\");\n if (name) opts.name = name;\n }\n\n const basedOn = findChild(el, \"w:basedOn\");\n if (basedOn) {\n const val = attr(basedOn, \"w:val\");\n if (val) opts.basedOn = val;\n }\n\n const next = findChild(el, \"w:next\");\n if (next) {\n const val = attr(next, \"w:val\");\n if (val) opts.next = val;\n }\n\n const link = findChild(el, \"w:link\");\n if (link) {\n const val = attr(link, \"w:val\");\n if (val) opts.link = val;\n }\n\n const uiPriority = findChild(el, \"w:uiPriority\");\n if (uiPriority) {\n const val = attrNum(uiPriority, \"w:val\");\n if (val !== undefined) opts.uiPriority = val;\n }\n\n if (findChild(el, \"w:qFormat\")) opts.quickFormat = true;\n if (findChild(el, \"w:semiHidden\")) opts.semiHidden = true;\n if (findChild(el, \"w:unhideWhenUsed\")) opts.unhideWhenUsed = true;\n if (findChild(el, \"w:autoRedefine\")) opts.autoRedefine = true;\n if (findChild(el, \"w:locked\")) opts.locked = true;\n if (findChild(el, \"w:personal\")) opts.personal = true;\n if (findChild(el, \"w:personalCompose\")) opts.personalCompose = true;\n if (findChild(el, \"w:personalReply\")) opts.personalReply = true;\n\n const aliases = findChild(el, \"w:aliases\");\n if (aliases) {\n const val = attr(aliases, \"w:val\");\n if (val) opts.aliases = val;\n }\n\n const pPr = findChild(el, \"w:pPr\");\n if (pPr) {\n const paraOpts = parseParagraphProperties(pPr, ctx);\n if (Object.keys(paraOpts).length > 0) {\n opts.paragraph = paraOpts as unknown as ParagraphStylePropertiesOptions;\n }\n }\n\n const rPr = findChild(el, \"w:rPr\");\n if (rPr) {\n const runOpts = parseRunProperties(rPr);\n if (Object.keys(runOpts).length > 0) opts.run = runOpts;\n }\n\n return opts;\n}\n","/**\n * Settings descriptor — produces word/settings.xml.\n *\n * Stringifies pure JSON SettingsOptions into XML without creating\n * Settings/Compatibility/DocumentProtection/etc. class instances.\n * Zero XmlComponent allocation — pure string concatenation.\n *\n * @module\n */\n\nimport { derivePasswordHash } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, findChild } from \"@office-open/xml\";\n\nimport type { FeaturesOptions } from \"../core-properties\";\nimport type {\n SettingsOptions,\n DocumentProtectionOptions,\n WriteProtectionOptions,\n MailMergeOptions,\n OdsoOptions,\n OdsoFieldMapDataOptions,\n CompatibilityOptions,\n CaptionsOptions,\n MathPropertiesOptions,\n RsidsOptions,\n ReadModeInkLockDownOptions,\n RevisionViewOptions,\n FootnotePropertiesOptions,\n EndnotePropertiesOptions,\n} from \"./settings\";\n\n// ── XML string helpers ──\n\nfunction escapeAttr(s: string): string {\n return s\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\");\n}\n\n/** Derive the namespace-prefixed val attribute from the element tag. */\nfunction valAttr(tag: string): string {\n const ns = tag.split(\":\")[0];\n return `${ns}:val`;\n}\n\nfunction onOff(tag: string, val: boolean | undefined): string {\n return val !== undefined ? `<${tag} ${valAttr(tag)}=\"${val ? 1 : 0}\"/>` : \"\";\n}\n\nfunction numVal(tag: string, val: number | undefined): string {\n return val !== undefined ? `<${tag} ${valAttr(tag)}=\"${val}\"/>` : \"\";\n}\n\nfunction strVal(tag: string, val: string | undefined): string {\n return val !== undefined ? `<${tag} ${valAttr(tag)}=\"${escapeAttr(val)}\"/>` : \"\";\n}\n\n/** Build attribute string from key-value pairs, skipping undefined. */\nfunction attrStr(attrs: Record<string, string | number | boolean | undefined>): string {\n const parts: string[] = [];\n for (const [k, v] of Object.entries(attrs)) {\n if (v !== undefined) parts.push(`${k}=\"${escapeAttr(String(v))}\"`);\n }\n return parts.join(\" \");\n}\n\n/** Self-closing element with attributes only. */\nfunction attrEl(tag: string, attrs: Record<string, string | number | boolean | undefined>): string {\n const a = attrStr(attrs);\n return a ? `<${tag} ${a}/>` : `<${tag}/>`;\n}\n\nfunction compatSetting(name: string, val: string | number): string {\n return `<w:compatSetting w:name=\"${escapeAttr(name)}\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"${val}\"/>`;\n}\n\n// ── Password derivation ──\n\ninterface DerivedPassword {\n hashValue: string;\n saltValue: string;\n spinCount: number;\n algorithmName: string;\n}\n\nfunction maybeDerive(\n password: string | undefined,\n hashValue: string | undefined,\n): DerivedPassword | undefined {\n return password !== undefined && hashValue === undefined\n ? derivePasswordHash(password)\n : undefined;\n}\n\n// ── Complex sub-elements ──\n\n/** Valid w:documentProtection/@w:edit values (ST_DocProtect). */\nconst DOC_PROTECT_EDITS = [\"none\", \"readOnly\", \"comments\", \"trackedChanges\", \"forms\"] as const;\n\nfunction stringifyDocProtect(opts: DocumentProtectionOptions): string {\n const derived = maybeDerive(opts.password, opts.hashValue);\n const attrs: Record<string, string | number> = { \"w:enforcement\": \"1\" };\n if (opts.edit !== undefined) attrs[\"w:edit\"] = opts.edit;\n if (opts.formatting !== undefined) attrs[\"w:formatting\"] = opts.formatting ? \"1\" : \"0\";\n if (opts.algorithmName ?? derived?.algorithmName)\n attrs[\"w:algorithmName\"] = opts.algorithmName ?? derived!.algorithmName;\n if (opts.hashValue ?? derived?.hashValue)\n attrs[\"w:hashValue\"] = opts.hashValue ?? derived!.hashValue;\n if (opts.saltValue ?? derived?.saltValue)\n attrs[\"w:saltValue\"] = opts.saltValue ?? derived!.saltValue;\n if (opts.hash !== undefined) attrs[\"w:hash\"] = opts.hash;\n if (opts.salt !== undefined) attrs[\"w:salt\"] = opts.salt;\n if (opts.spinCount ?? derived?.spinCount)\n attrs[\"w:spinCount\"] = opts.spinCount ?? derived!.spinCount;\n if (opts.cryptoAlgorithmClass !== undefined)\n attrs[\"w:cryptAlgorithmClass\"] = opts.cryptoAlgorithmClass;\n if (opts.cryptoAlgorithmSid !== undefined) attrs[\"w:cryptAlgorithmSid\"] = opts.cryptoAlgorithmSid;\n if (opts.cryptoAlgorithmType !== undefined)\n attrs[\"w:cryptAlgorithmType\"] = opts.cryptoAlgorithmType;\n if (opts.cryptoProvider !== undefined) attrs[\"w:cryptProvider\"] = opts.cryptoProvider;\n if (opts.cryptoProviderType !== undefined) attrs[\"w:cryptProviderType\"] = opts.cryptoProviderType;\n if (opts.cryptoProviderTypeExtension !== undefined)\n attrs[\"w:cryptProviderTypeExt\"] = opts.cryptoProviderTypeExtension;\n if (opts.cryptoProviderTypeExtensionSource !== undefined)\n attrs[\"w:cryptProviderTypeExtSource\"] = opts.cryptoProviderTypeExtensionSource;\n if (opts.algorithmExtensionId !== undefined) attrs[\"w:algIdExt\"] = opts.algorithmExtensionId;\n if (opts.algorithmExtensionSource !== undefined)\n attrs[\"w:algIdExtSource\"] = opts.algorithmExtensionSource;\n if (opts.cryptoSpinCount !== undefined) attrs[\"w:cryptSpinCount\"] = opts.cryptoSpinCount;\n return attrEl(\"w:documentProtection\", attrs);\n}\n\nfunction stringifyWriteProtect(opts: WriteProtectionOptions): string {\n const derived = maybeDerive(opts.password, opts.hashValue);\n const attrs: Record<string, string | number> = {};\n if (opts.recommended !== undefined) attrs[\"w:recommended\"] = opts.recommended ? \"1\" : \"0\";\n if (opts.hashValue ?? derived?.hashValue)\n attrs[\"w:hashValue\"] = opts.hashValue ?? derived!.hashValue;\n if (opts.saltValue ?? derived?.saltValue)\n attrs[\"w:saltValue\"] = opts.saltValue ?? derived!.saltValue;\n if (opts.hash !== undefined) attrs[\"w:hash\"] = opts.hash;\n if (opts.salt !== undefined) attrs[\"w:salt\"] = opts.salt;\n if (opts.spinCount ?? derived?.spinCount)\n attrs[\"w:spinCount\"] = opts.spinCount ?? derived!.spinCount;\n if (opts.algorithmName ?? derived?.algorithmName)\n attrs[\"w:algorithmName\"] = opts.algorithmName ?? derived!.algorithmName;\n if (opts.cryptoAlgorithmClass !== undefined)\n attrs[\"w:cryptAlgorithmClass\"] = opts.cryptoAlgorithmClass;\n if (opts.cryptoAlgorithmSid !== undefined) attrs[\"w:cryptAlgorithmSid\"] = opts.cryptoAlgorithmSid;\n if (opts.cryptoAlgorithmType !== undefined)\n attrs[\"w:cryptAlgorithmType\"] = opts.cryptoAlgorithmType;\n if (opts.cryptoProvider !== undefined) attrs[\"w:cryptProvider\"] = opts.cryptoProvider;\n if (opts.cryptoProviderType !== undefined) attrs[\"w:cryptProviderType\"] = opts.cryptoProviderType;\n if (opts.algorithmExtensionId !== undefined) attrs[\"w:algIdExt\"] = opts.algorithmExtensionId;\n if (opts.algorithmExtensionSource !== undefined)\n attrs[\"w:algIdExtSource\"] = opts.algorithmExtensionSource;\n if (opts.cryptoProviderTypeExtension !== undefined)\n attrs[\"w:cryptProviderTypeExt\"] = opts.cryptoProviderTypeExtension;\n if (opts.cryptoProviderTypeExtensionSource !== undefined)\n attrs[\"w:cryptProviderTypeExtSource\"] = opts.cryptoProviderTypeExtensionSource;\n if (opts.cryptoSpinCount !== undefined) attrs[\"w:cryptSpinCount\"] = opts.cryptoSpinCount;\n return attrEl(\"w:writeProtection\", attrs);\n}\n\nfunction stringifyRevisionView(opts: RevisionViewOptions): string {\n const attrs: Record<string, string> = {};\n if (opts.markup !== undefined) attrs[\"w:markup\"] = opts.markup ? \"true\" : \"false\";\n if (opts.comments !== undefined) attrs[\"w:comments\"] = opts.comments ? \"true\" : \"false\";\n if (opts.insDel !== undefined) attrs[\"w:insDel\"] = opts.insDel ? \"true\" : \"false\";\n if (opts.formatting !== undefined) attrs[\"w:formatting\"] = opts.formatting ? \"true\" : \"false\";\n if (opts.inkAnnotations !== undefined)\n attrs[\"w:inkAnnotations\"] = opts.inkAnnotations ? \"true\" : \"false\";\n return attrEl(\"w:revisionView\", attrs);\n}\n\nfunction stringifyMailMerge(opts: MailMergeOptions): string {\n const p: string[] = [];\n p.push(strVal(\"w:mainDocumentType\", opts.mainDocumentType));\n p.push(onOff(\"w:linkToQuery\", opts.linkToQuery));\n p.push(strVal(\"w:dataType\", opts.dataType));\n p.push(strVal(\"w:connectString\", opts.connectString));\n p.push(strVal(\"w:query\", opts.query));\n if (opts.dataSource !== undefined) p.push(attrEl(\"w:dataSource\", { \"r:id\": opts.dataSource }));\n if (opts.headerSource !== undefined)\n p.push(attrEl(\"w:headerSource\", { \"r:id\": opts.headerSource }));\n p.push(onOff(\"w:doNotSuppressBlankLines\", opts.doNotSuppressBlankLines));\n p.push(strVal(\"w:destination\", opts.destination));\n p.push(strVal(\"w:addressFieldName\", opts.addressFieldName));\n p.push(strVal(\"w:mailSubject\", opts.mailSubject));\n p.push(onOff(\"w:mailAsAttachment\", opts.mailAsAttachment));\n p.push(onOff(\"w:viewMergedData\", opts.viewMergedData));\n p.push(numVal(\"w:activeRecord\", opts.activeRecord));\n p.push(numVal(\"w:checkErrors\", opts.checkErrors));\n if (opts.odso !== undefined) p.push(stringifyOdso(opts.odso));\n p.push(onOff(\"w:active\", opts.active));\n if (opts.recipients !== undefined) p.push(attrEl(\"w:recipients\", { \"r:id\": opts.recipients }));\n return `<w:mailMerge>${p.join(\"\")}</w:mailMerge>`;\n}\n\nfunction stringifyOdso(opts: OdsoOptions): string {\n const p: string[] = [];\n p.push(strVal(\"w:udl\", opts.udl));\n p.push(strVal(\"w:table\", opts.table));\n if (opts.src !== undefined) p.push(attrEl(\"w:src\", { \"r:id\": opts.src }));\n p.push(numVal(\"w:colDelim\", opts.colDelim));\n p.push(strVal(\"w:type\", opts.type));\n p.push(onOff(\"w:fHdr\", opts.fHdr));\n if (opts.fieldMapData !== undefined) {\n for (const fm of opts.fieldMapData) p.push(stringifyOdsoFieldMap(fm));\n }\n if (opts.recipientData !== undefined) {\n for (const rd of opts.recipientData) p.push(attrEl(\"w:recipientData\", { \"r:id\": rd }));\n }\n p.push(strVal(\"w:uniqueTag\", opts.uniqueTag));\n return `<w:odso>${p.join(\"\")}</w:odso>`;\n}\n\nfunction stringifyOdsoFieldMap(opts: OdsoFieldMapDataOptions): string {\n const p: string[] = [];\n p.push(strVal(\"w:type\", opts.type));\n p.push(strVal(\"w:name\", opts.name));\n p.push(strVal(\"w:mappedName\", opts.mappedName));\n p.push(numVal(\"w:column\", opts.column));\n p.push(strVal(\"w:lid\", opts.lid));\n p.push(onOff(\"w:dynamicAddress\", opts.dynamicAddress));\n return `<w:fieldMapData>${p.join(\"\")}</w:fieldMapData>`;\n}\n\nfunction stringifyFootnotePr(opts: FootnotePropertiesOptions): string {\n const p: string[] = [];\n if (opts.pos !== undefined) p.push(attrEl(\"w:pos\", { \"w:val\": opts.pos }));\n if (opts.numFmt !== undefined || opts.format !== undefined) {\n const a: Record<string, string> = {};\n if (opts.numFmt !== undefined) a[\"w:val\"] = opts.numFmt;\n if (opts.format !== undefined) a[\"w:format\"] = opts.format;\n p.push(attrEl(\"w:numFmt\", a));\n }\n p.push(numVal(\"w:numStart\", opts.numStart));\n p.push(strVal(\"w:numRestart\", opts.numRestart));\n return `<w:footnotePr>${p.join(\"\")}</w:footnotePr>`;\n}\n\nfunction stringifyEndnotePr(opts: EndnotePropertiesOptions): string {\n const p: string[] = [];\n if (opts.pos !== undefined) p.push(attrEl(\"w:pos\", { \"w:val\": opts.pos }));\n if (opts.numFmt !== undefined || opts.format !== undefined) {\n const a: Record<string, string> = {};\n if (opts.numFmt !== undefined) a[\"w:val\"] = opts.numFmt;\n if (opts.format !== undefined) a[\"w:format\"] = opts.format;\n p.push(attrEl(\"w:numFmt\", a));\n }\n p.push(numVal(\"w:numStart\", opts.numStart));\n p.push(strVal(\"w:numRestart\", opts.numRestart));\n return `<w:endnotePr>${p.join(\"\")}</w:endnotePr>`;\n}\n\nfunction stringifyRsids(opts: RsidsOptions): string {\n const p: string[] = [];\n if (opts.rsidRoot !== undefined) p.push(attrEl(\"w:rsidRoot\", { \"w:val\": opts.rsidRoot }));\n if (opts.rsids !== undefined) {\n for (const rsid of opts.rsids) p.push(attrEl(\"w:rsid\", { \"w:val\": rsid }));\n }\n return `<w:rsids>${p.join(\"\")}</w:rsids>`;\n}\n\nfunction stringifyReadModeInkLockDown(opts: ReadModeInkLockDownOptions): string {\n return attrEl(\"w:readModeInkLockDown\", {\n \"w:actualPg\": opts.actualPg === false ? \"0\" : \"1\",\n \"w:w\": opts.w,\n \"w:h\": opts.h,\n \"w:fontSz\": opts.fontSz,\n });\n}\n\nfunction stringifyCaptions(opts: CaptionsOptions): string {\n const p: string[] = [];\n for (const cap of opts.captions) {\n const attrs: Record<string, string | number> = { \"w:name\": cap.name };\n if (cap.pos !== undefined) attrs[\"w:pos\"] = cap.pos;\n if (cap.chapNum !== undefined) attrs[\"w:chapNum\"] = cap.chapNum ? \"1\" : \"0\";\n if (cap.heading !== undefined) attrs[\"w:heading\"] = cap.heading;\n if (cap.noLabel !== undefined) attrs[\"w:noLabel\"] = cap.noLabel ? \"1\" : \"0\";\n if (cap.numFmt !== undefined) attrs[\"w:numFmt\"] = cap.numFmt;\n if (cap.sep !== undefined) attrs[\"w:sep\"] = cap.sep;\n p.push(attrEl(\"w:caption\", attrs));\n }\n if (opts.autoCaptions?.length) {\n const acXml = opts.autoCaptions\n .map((ac) => attrEl(\"w:autoCaption\", { \"w:name\": ac.name, \"w:caption\": ac.caption }))\n .join(\"\");\n p.push(`<w:autoCaptions>${acXml}</w:autoCaptions>`);\n }\n return `<w:captions>${p.join(\"\")}</w:captions>`;\n}\n\nfunction stringifyMathPr(opts: MathPropertiesOptions): string {\n const p: string[] = [];\n if (opts.mathFont !== undefined) p.push(attrEl(\"m:mathFont\", { \"m:val\": opts.mathFont }));\n if (opts.brkBin !== undefined) p.push(attrEl(\"m:brkBin\", { \"m:val\": opts.brkBin }));\n if (opts.brkBinSub !== undefined) p.push(attrEl(\"m:brkBinSub\", { \"m:val\": opts.brkBinSub }));\n p.push(onOff(\"m:smallFrac\", opts.smallFrac));\n p.push(onOff(\"m:dispDef\", opts.dispDef));\n p.push(numVal(\"m:lMargin\", opts.lMargin));\n p.push(numVal(\"m:rMargin\", opts.rMargin));\n if (opts.defJc !== undefined) p.push(attrEl(\"m:defJc\", { \"m:val\": opts.defJc }));\n p.push(numVal(\"m:wrapIndent\", opts.wrapIndent));\n if (opts.intLim !== undefined) p.push(attrEl(\"m:intLim\", { \"m:val\": opts.intLim }));\n if (opts.naryLim !== undefined) p.push(attrEl(\"m:naryLim\", { \"m:val\": opts.naryLim }));\n return `<m:mathPr>${p.join(\"\")}</m:mathPr>`;\n}\n\nfunction stringifyColorSchemeMapping(\n opts: NonNullable<SettingsOptions[\"colorSchemeMapping\"]>,\n): string {\n const attrs: Record<string, string> = {};\n if (opts.bg1 !== undefined) attrs[\"w:bg1\"] = opts.bg1;\n if (opts.t1 !== undefined) attrs[\"w:t1\"] = opts.t1;\n if (opts.bg2 !== undefined) attrs[\"w:bg2\"] = opts.bg2;\n if (opts.t2 !== undefined) attrs[\"w:t2\"] = opts.t2;\n if (opts.accent1 !== undefined) attrs[\"w:accent1\"] = opts.accent1;\n if (opts.accent2 !== undefined) attrs[\"w:accent2\"] = opts.accent2;\n if (opts.accent3 !== undefined) attrs[\"w:accent3\"] = opts.accent3;\n if (opts.accent4 !== undefined) attrs[\"w:accent4\"] = opts.accent4;\n if (opts.accent5 !== undefined) attrs[\"w:accent5\"] = opts.accent5;\n if (opts.accent6 !== undefined) attrs[\"w:accent6\"] = opts.accent6;\n if (opts.hyperlink !== undefined) attrs[\"w:hyperlink\"] = opts.hyperlink;\n if (opts.followedHyperlink !== undefined) attrs[\"w:followedHyperlink\"] = opts.followedHyperlink;\n return attrEl(\"w:clrSchemeMapping\", attrs);\n}\n\n// ── Compatibility ──\n\nfunction stringifyCompatibility(opts: CompatibilityOptions): string {\n const p: string[] = [];\n // Individual compat on/off elements (XSD order)\n if (opts.useSingleBorderforContiguousCells)\n p.push(onOff(\"w:useSingleBorderforContiguousCells\", true));\n if (opts.wordPerfectJustification) p.push(onOff(\"w:wpJustification\", true));\n if (opts.noTabStopForHangingIndent) p.push(onOff(\"w:noTabHangInd\", true));\n if (opts.noLeading) p.push(onOff(\"w:noLeading\", true));\n if (opts.spaceForUnderline) p.push(onOff(\"w:spaceForUL\", true));\n if (opts.noColumnBalance) p.push(onOff(\"w:noColumnBalance\", true));\n if (opts.balanceSingleByteDoubleByteWidth)\n p.push(onOff(\"w:balanceSingleByteDoubleByteWidth\", true));\n if (opts.noExtraLineSpacing) p.push(onOff(\"w:noExtraLineSpacing\", true));\n if (opts.doNotLeaveBackslashAlone) p.push(onOff(\"w:doNotLeaveBackslashAlone\", true));\n if (opts.underlineTrailingSpaces) p.push(onOff(\"w:ulTrailSpace\", true));\n if (opts.doNotExpandShiftReturn) p.push(onOff(\"w:doNotExpandShiftReturn\", true));\n if (opts.spacingInWholePoints) p.push(onOff(\"w:spacingInWholePoints\", true));\n if (opts.lineWrapLikeWord6) p.push(onOff(\"w:lineWrapLikeWord6\", true));\n if (opts.printBodyTextBeforeHeader) p.push(onOff(\"w:printBodyTextBeforeHeader\", true));\n if (opts.printColorsBlack) p.push(onOff(\"w:printColBlack\", true));\n if (opts.spaceWidth) p.push(onOff(\"w:wpSpaceWidth\", true));\n if (opts.showBreaksInFrames) p.push(onOff(\"w:showBreaksInFrames\", true));\n if (opts.subFontBySize) p.push(onOff(\"w:subFontBySize\", true));\n if (opts.suppressBottomSpacing) p.push(onOff(\"w:suppressBottomSpacing\", true));\n if (opts.suppressTopSpacing) p.push(onOff(\"w:suppressTopSpacing\", true));\n if (opts.suppressSpacingAtTopOfPage) p.push(onOff(\"w:suppressSpacingAtTopOfPage\", true));\n if (opts.suppressTopSpacingWP) p.push(onOff(\"w:suppressTopSpacingWP\", true));\n if (opts.suppressSpBfAfterPgBrk) p.push(onOff(\"w:suppressSpBfAfterPgBrk\", true));\n if (opts.swapBordersFacingPages) p.push(onOff(\"w:swapBordersFacingPages\", true));\n if (opts.convertMailMergeEsc) p.push(onOff(\"w:convMailMergeEsc\", true));\n if (opts.truncateFontHeightsLikeWP6) p.push(onOff(\"w:truncateFontHeightsLikeWP6\", true));\n if (opts.macWordSmallCaps) p.push(onOff(\"w:mwSmallCaps\", true));\n if (opts.usePrinterMetrics) p.push(onOff(\"w:usePrinterMetrics\", true));\n if (opts.doNotSuppressParagraphBorders) p.push(onOff(\"w:doNotSuppressParagraphBorders\", true));\n if (opts.wrapTrailSpaces) p.push(onOff(\"w:wrapTrailSpaces\", true));\n if (opts.footnoteLayoutLikeWW8) p.push(onOff(\"w:footnoteLayoutLikeWW8\", true));\n if (opts.shapeLayoutLikeWW8) p.push(onOff(\"w:shapeLayoutLikeWW8\", true));\n if (opts.alignTablesRowByRow) p.push(onOff(\"w:alignTablesRowByRow\", true));\n if (opts.forgetLastTabAlignment) p.push(onOff(\"w:forgetLastTabAlignment\", true));\n if (opts.adjustLineHeightInTable) p.push(onOff(\"w:adjustLineHeightInTable\", true));\n if (opts.autoSpaceLikeWord95) p.push(onOff(\"w:autoSpaceLikeWord95\", true));\n if (opts.noSpaceRaiseLower) p.push(onOff(\"w:noSpaceRaiseLower\", true));\n if (opts.doNotUseHTMLParagraphAutoSpacing)\n p.push(onOff(\"w:doNotUseHTMLParagraphAutoSpacing\", true));\n if (opts.layoutRawTableWidth) p.push(onOff(\"w:layoutRawTableWidth\", true));\n if (opts.layoutTableRowsApart) p.push(onOff(\"w:layoutTableRowsApart\", true));\n if (opts.useWord97LineBreakRules) p.push(onOff(\"w:useWord97LineBreakRules\", true));\n if (opts.doNotBreakWrappedTables) p.push(onOff(\"w:doNotBreakWrappedTables\", true));\n if (opts.doNotSnapToGridInCell) p.push(onOff(\"w:doNotSnapToGridInCell\", true));\n if (opts.selectFieldWithFirstOrLastCharacter)\n p.push(onOff(\"w:selectFldWithFirstOrLastChar\", true));\n if (opts.applyBreakingRules) p.push(onOff(\"w:applyBreakingRules\", true));\n if (opts.doNotWrapTextWithPunctuation) p.push(onOff(\"w:doNotWrapTextWithPunct\", true));\n if (opts.doNotUseEastAsianBreakRules) p.push(onOff(\"w:doNotUseEastAsianBreakRules\", true));\n if (opts.useWord2002TableStyleRules) p.push(onOff(\"w:useWord2002TableStyleRules\", true));\n if (opts.growAutofit) p.push(onOff(\"w:growAutofit\", true));\n if (opts.useFELayout) p.push(onOff(\"w:useFELayout\", true));\n if (opts.useNormalStyleForList) p.push(onOff(\"w:useNormalStyleForList\", true));\n if (opts.doNotUseIndentAsNumberingTabStop)\n p.push(onOff(\"w:doNotUseIndentAsNumberingTabStop\", true));\n if (opts.useAlternateEastAsianLineBreakRules)\n p.push(onOff(\"w:useAltKinsokuLineBreakRules\", true));\n if (opts.allowSpaceOfSameStyleInTable) p.push(onOff(\"w:allowSpaceOfSameStyleInTable\", true));\n if (opts.doNotSuppressIndentation) p.push(onOff(\"w:doNotSuppressIndentation\", true));\n if (opts.doNotAutofitConstrainedTables) p.push(onOff(\"w:doNotAutofitConstrainedTables\", true));\n if (opts.autofitToFirstFixedWidthCell) p.push(onOff(\"w:autofitToFirstFixedWidthCell\", true));\n if (opts.underlineTabInNumberingList) p.push(onOff(\"w:underlineTabInNumList\", true));\n if (opts.displayHangulFixedWidth) p.push(onOff(\"w:displayHangulFixedWidth\", true));\n if (opts.splitPgBreakAndParaMark) p.push(onOff(\"w:splitPgBreakAndParaMark\", true));\n if (opts.doNotVerticallyAlignCellWithSp) p.push(onOff(\"w:doNotVertAlignCellWithSp\", true));\n if (opts.doNotBreakConstrainedForcedTable)\n p.push(onOff(\"w:doNotBreakConstrainedForcedTable\", true));\n if (opts.ignoreVerticalAlignmentInTextboxes) p.push(onOff(\"w:doNotVertAlignInTxbx\", true));\n if (opts.useAnsiKerningPairs) p.push(onOff(\"w:useAnsiKerningPairs\", true));\n if (opts.cachedColumnBalance) p.push(onOff(\"w:cachedColBalance\", true));\n // compatSetting elements last (XSD order)\n if (opts.version) p.push(compatSetting(\"compatibilityMode\", opts.version));\n if (opts.overrideTableStyleFontSizeAndJustification)\n p.push(compatSetting(\"overrideTableStyleFontSizeAndJustification\", 1));\n if (opts.enableOpenTypeFeatures) p.push(compatSetting(\"enableOpenTypeFeatures\", 1));\n if (opts.doNotFlipMirrorIndents) p.push(compatSetting(\"doNotFlipMirrorIndents\", 1));\n return p.length ? `<w:compat>${p.join(\"\")}</w:compat>` : \"\";\n}\n\n// ── Namespace attributes ──\n\nconst SETTINGS_NS =\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ' +\n 'mc:Ignorable=\"w14 w15 wp14\"';\n\n// ── Descriptor ──\n\nexport const settingsDesc: CustomDescriptor<SettingsOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [];\n\n // XSD CT_Settings sequence order\n if (opts.writeProtection !== undefined) p.push(stringifyWriteProtect(opts.writeProtection));\n if (opts.view !== undefined) p.push(attrEl(\"w:view\", { \"w:val\": opts.view }));\n if (opts.zoom !== undefined)\n p.push(attrEl(\"w:zoom\", { \"w:percent\": opts.zoom.percent ?? 100, \"w:val\": opts.zoom.val }));\n p.push(onOff(\"w:removePersonalInformation\", opts.removePersonalInformation));\n p.push(onOff(\"w:removeDateAndTime\", opts.removeDateAndTime));\n p.push(onOff(\"w:displayBackgroundShape\", opts.displayBackgroundShape));\n p.push(onOff(\"w:doNotDisplayPageBoundaries\", opts.doNotDisplayPageBoundaries));\n p.push(onOff(\"w:printPostScriptOverText\", opts.printPostScriptOverText));\n p.push(onOff(\"w:printFractionalCharacterWidth\", opts.printFractionalCharacterWidth));\n p.push(onOff(\"w:printFormsData\", opts.printFormsData));\n p.push(onOff(\"w:embedTrueTypeFonts\", opts.embedTrueTypeFonts));\n p.push(onOff(\"w:embedSystemFonts\", opts.embedSystemFonts));\n p.push(onOff(\"w:saveSubsetFonts\", opts.saveSubsetFonts));\n p.push(onOff(\"w:saveFormsData\", opts.saveFormsData));\n p.push(onOff(\"w:mirrorMargins\", opts.mirrorMargins));\n p.push(onOff(\"w:alignBordersAndEdges\", opts.alignBordersAndEdges));\n p.push(onOff(\"w:bordersDoNotSurroundHeader\", opts.bordersDoNotSurroundHeader));\n p.push(onOff(\"w:bordersDoNotSurroundFooter\", opts.bordersDoNotSurroundFooter));\n p.push(onOff(\"w:gutterAtTop\", opts.gutterAtTop));\n p.push(onOff(\"w:hideSpellingErrors\", opts.hideSpellingErrors));\n p.push(onOff(\"w:hideGrammaticalErrors\", opts.hideGrammaticalErrors));\n\n // activeWritingStyle\n if (opts.activeWritingStyle !== undefined) {\n for (const ws of opts.activeWritingStyle) {\n const attrs: Record<string, string | number | boolean> = {};\n if (ws.lang !== undefined) attrs[\"w:lang\"] = ws.lang;\n if (ws.vendorID !== undefined) attrs[\"w:vendorID\"] = ws.vendorID;\n if (ws.dllVersion !== undefined) attrs[\"w:dllVersion\"] = ws.dllVersion;\n if (ws.nlCheck !== undefined) attrs[\"w:nlCheck\"] = ws.nlCheck;\n if (ws.checkStyle !== undefined) attrs[\"w:checkStyle\"] = ws.checkStyle;\n if (ws.appCheck !== undefined) attrs[\"w:appCheck\"] = ws.appCheck;\n if (ws.appName !== undefined) attrs[\"w:appName\"] = ws.appName;\n p.push(attrEl(\"w:activeWritingStyle\", attrs));\n }\n }\n\n // proofState\n if (opts.proofState !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.proofState.spelling !== undefined) attrs[\"w:spelling\"] = opts.proofState.spelling;\n if (opts.proofState.grammar !== undefined) attrs[\"w:grammar\"] = opts.proofState.grammar;\n p.push(attrEl(\"w:proofState\", attrs));\n }\n\n p.push(onOff(\"w:formsDesign\", opts.formsDesign));\n\n if (opts.attachedTemplate !== undefined)\n p.push(attrEl(\"w:attachedTemplate\", { \"r:id\": opts.attachedTemplate }));\n p.push(onOff(\"w:linkStyles\", opts.linkStyles));\n\n // stylePaneFormatFilter\n if (opts.stylePaneFormatFilter !== undefined) {\n const f = opts.stylePaneFormatFilter;\n const attrs: Record<string, string> = {};\n const flags: [keyof typeof f, string][] = [\n [\"allStyles\", \"w:allStyles\"],\n [\"customStyles\", \"w:customStyles\"],\n [\"stylesInUse\", \"w:stylesInUse\"],\n [\"headingStyles\", \"w:headingStyles\"],\n [\"numberingStyles\", \"w:numberingStyles\"],\n [\"tableStyles\", \"w:tableStyles\"],\n [\"directFormattingOnRuns\", \"w:directFormattingOnRuns\"],\n [\"directFormattingOnParagraphs\", \"w:directFormattingOnParagraphs\"],\n [\"directFormattingOnNumbering\", \"w:directFormattingOnNumbering\"],\n [\"directFormattingOnTables\", \"w:directFormattingOnTables\"],\n [\"clearFormatting\", \"w:clearFormatting\"],\n [\"top3HeadingStyles\", \"w:top3HeadingStyles\"],\n [\"visibleStyles\", \"w:visibleStyles\"],\n [\"alternateStyleNames\", \"w:alternateStyleNames\"],\n ];\n for (const [prop, xmlKey] of flags) {\n if (f[prop] !== undefined) attrs[xmlKey] = f[prop] ? \"1\" : \"0\";\n }\n p.push(attrEl(\"w:stylePaneFormatFilter\", attrs));\n }\n\n p.push(strVal(\"w:stylePaneSortMethod\", opts.stylePaneSortMethod));\n p.push(strVal(\"w:documentType\", opts.documentType));\n\n if (opts.revisionView !== undefined) p.push(stringifyRevisionView(opts.revisionView));\n p.push(onOff(\"w:trackRevisions\", opts.trackRevisions));\n p.push(onOff(\"w:doNotTrackMoves\", opts.doNotTrackMoves));\n p.push(onOff(\"w:doNotTrackFormatting\", opts.doNotTrackFormatting));\n\n if (opts.mailMerge !== undefined) p.push(stringifyMailMerge(opts.mailMerge));\n if (opts.documentProtection !== undefined) p.push(stringifyDocProtect(opts.documentProtection));\n\n p.push(onOff(\"w:autoFormatOverride\", opts.autoFormatOverride));\n p.push(onOff(\"w:styleLockTheme\", opts.styleLockTheme));\n p.push(onOff(\"w:styleLockQFSet\", opts.styleLockQFSet));\n\n // defaultTabStop — optional (CT_Settings minOccurs=0); emit only when set\n if (opts.defaultTabStop !== undefined) p.push(numVal(\"w:defaultTabStop\", opts.defaultTabStop)!);\n\n // hyphenation\n p.push(onOff(\"w:autoHyphenation\", opts.hyphenation?.autoHyphenation));\n p.push(numVal(\"w:consecutiveHyphenLimit\", opts.hyphenation?.consecutiveHyphenLimit));\n p.push(numVal(\"w:hyphenationZone\", opts.hyphenation?.hyphenationZone));\n p.push(onOff(\"w:doNotHyphenateCaps\", opts.hyphenation?.doNotHyphenateCaps));\n\n p.push(onOff(\"w:showEnvelope\", opts.showEnvelope));\n p.push(numVal(\"w:summaryLength\", opts.summaryLength));\n p.push(strVal(\"w:clickAndTypeStyle\", opts.clickAndTypeStyle));\n p.push(strVal(\"w:defaultTableStyle\", opts.defaultTableStyle));\n p.push(onOff(\"w:evenAndOddHeaders\", opts.evenAndOddHeaders));\n p.push(onOff(\"w:bookFoldRevPrinting\", opts.bookFoldRevPrinting));\n p.push(onOff(\"w:bookFoldPrinting\", opts.bookFoldPrinting));\n p.push(numVal(\"w:bookFoldPrintingSheets\", opts.bookFoldPrintingSheets));\n p.push(numVal(\"w:drawingGridHorizontalSpacing\", opts.drawingGridHorizontalSpacing));\n p.push(numVal(\"w:drawingGridVerticalSpacing\", opts.drawingGridVerticalSpacing));\n p.push(numVal(\"w:displayHorizontalDrawingGridEvery\", opts.displayHorizontalDrawingGridEvery));\n p.push(numVal(\"w:displayVerticalDrawingGridEvery\", opts.displayVerticalDrawingGridEvery));\n p.push(numVal(\"w:drawingGridHorizontalOrigin\", opts.drawingGridHorizontalOrigin));\n p.push(numVal(\"w:drawingGridVerticalOrigin\", opts.drawingGridVerticalOrigin));\n p.push(\n onOff(\"w:doNotUseMarginsForDrawingGridOrigin\", opts.doNotUseMarginsForDrawingGridOrigin),\n );\n p.push(onOff(\"w:doNotShadeFormData\", opts.doNotShadeFormData));\n\n // characterSpacingControl — optional (CT_Settings minOccurs=0); emit only when set\n if (opts.characterSpacingControl !== undefined) {\n p.push(strVal(\"w:characterSpacingControl\", opts.characterSpacingControl)!);\n }\n\n p.push(onOff(\"w:noPunctuationKerning\", opts.noPunctuationKerning));\n p.push(onOff(\"w:printTwoOnOne\", opts.printTwoOnOne));\n p.push(onOff(\"w:strictFirstAndLastChars\", opts.strictFirstAndLastChars));\n\n if (opts.noLineBreaksAfter !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.noLineBreaksAfter.lang !== undefined) attrs[\"w:lang\"] = opts.noLineBreaksAfter.lang;\n if (opts.noLineBreaksAfter.val !== undefined) attrs[\"w:val\"] = opts.noLineBreaksAfter.val;\n p.push(attrEl(\"w:noLineBreaksAfter\", attrs));\n }\n if (opts.noLineBreaksBefore !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.noLineBreaksBefore.lang !== undefined)\n attrs[\"w:lang\"] = opts.noLineBreaksBefore.lang;\n if (opts.noLineBreaksBefore.val !== undefined) attrs[\"w:val\"] = opts.noLineBreaksBefore.val;\n p.push(attrEl(\"w:noLineBreaksBefore\", attrs));\n }\n\n p.push(onOff(\"w:savePreviewPicture\", opts.savePreviewPicture));\n p.push(onOff(\"w:doNotValidateAgainstSchema\", opts.doNotValidateAgainstSchema));\n p.push(onOff(\"w:saveInvalidXml\", opts.saveInvalidXml));\n p.push(onOff(\"w:ignoreMixedContent\", opts.ignoreMixedContent));\n p.push(onOff(\"w:alwaysShowPlaceholderText\", opts.alwaysShowPlaceholderText));\n p.push(onOff(\"w:doNotDemarcateInvalidXml\", opts.doNotDemarcateInvalidXml));\n p.push(onOff(\"w:saveXmlDataOnly\", opts.saveXmlDataOnly));\n p.push(onOff(\"w:useXSLTWhenSaving\", opts.useXSLTWhenSaving));\n\n if (opts.saveThroughXslt !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.saveThroughXslt.id !== undefined) attrs[\"r:id\"] = opts.saveThroughXslt.id;\n if (opts.saveThroughXslt.val !== undefined) attrs[\"w:val\"] = opts.saveThroughXslt.val;\n if (opts.saveThroughXslt.solutionID !== undefined)\n attrs[\"w:solutionID\"] = opts.saveThroughXslt.solutionID;\n p.push(attrEl(\"w:saveThroughXslt\", attrs));\n }\n\n p.push(onOff(\"w:showXMLTags\", opts.showXMLTags));\n p.push(onOff(\"w:alwaysMergeEmptyNamespace\", opts.alwaysMergeEmptyNamespace));\n p.push(onOff(\"w:updateFields\", opts.updateFields));\n\n if (opts.hdrShapeDefaults !== undefined) p.push(\"<w:hdrShapeDefaults/>\");\n if (opts.footnotePr !== undefined) p.push(stringifyFootnotePr(opts.footnotePr));\n if (opts.endnotePr !== undefined) p.push(stringifyEndnotePr(opts.endnotePr));\n\n // Compatibility — optional (CT_Settings minOccurs=0); emit only when configured\n const compatXml = stringifyCompatibility({\n ...opts.compatibility,\n version: opts.compatibility?.version ?? opts.compatibilityModeVersion,\n });\n if (compatXml) p.push(compatXml);\n\n // docVars\n if (opts.docVars?.length) {\n const vars = opts.docVars\n .map((v) => attrEl(\"w:docVar\", { \"w:name\": v.name, \"w:val\": v.val }))\n .join(\"\");\n p.push(`<w:docVars>${vars}</w:docVars>`);\n }\n\n if (opts.rsids !== undefined) p.push(stringifyRsids(opts.rsids));\n if (opts.mathPr !== undefined) p.push(stringifyMathPr(opts.mathPr));\n\n if (opts.attachedSchema !== undefined) {\n for (const schema of opts.attachedSchema) p.push(strVal(\"w:attachedSchema\", schema)!);\n }\n\n if (opts.colorSchemeMapping !== undefined)\n p.push(stringifyColorSchemeMapping(opts.colorSchemeMapping));\n if (opts.themeFontLang !== undefined)\n p.push(attrEl(\"w:themeFontLang\", { \"w:val\": opts.themeFontLang }));\n p.push(onOff(\"w:doNotIncludeSubdocsInStats\", opts.doNotIncludeSubdocsInStats));\n p.push(onOff(\"w:doNotAutoCompressPictures\", opts.doNotAutoCompressPictures));\n if (opts.forceUpgrade !== undefined) p.push(\"<w:forceUpgrade/>\");\n if (opts.captions !== undefined) p.push(stringifyCaptions(opts.captions));\n if (opts.readModeInkLockDown !== undefined)\n p.push(stringifyReadModeInkLockDown(opts.readModeInkLockDown));\n\n if (opts.smartTagType !== undefined) {\n for (const st of opts.smartTagType) {\n const attrs: Record<string, string> = {};\n if (st.namespace !== undefined) attrs[\"w:namespace\"] = st.namespace;\n if (st.namespaceuri !== undefined) attrs[\"w:namespaceuri\"] = st.namespaceuri;\n if (st.name !== undefined) attrs[\"w:name\"] = st.name;\n if (st.url !== undefined) attrs[\"w:url\"] = st.url;\n p.push(attrEl(\"w:smartTagType\", attrs));\n }\n }\n\n p.push(onOff(\"w:doNotEmbedSmartTags\", opts.doNotEmbedSmartTags));\n if (opts.shapeDefaults !== undefined) p.push(\"<w:shapeDefaults/>\");\n p.push(strVal(\"w:decimalSymbol\", opts.decimalSymbol));\n p.push(strVal(\"w:listSeparator\", opts.listSeparator));\n\n const body = p.join(\"\");\n return `<w:settings ${SETTINGS_NS}>${body}</w:settings>`;\n },\n\n parse(el, _ctx) {\n const opts: Record<string, unknown> = {};\n\n // evenAndOddHeaderAndFooters → w:evenAndOddHeaders\n const eohEl = findChild(el, \"w:evenAndOddHeaders\");\n if (eohEl) {\n const val = attr(eohEl, \"w:val\");\n opts.evenAndOddHeaderAndFooters = val !== \"false\" && val !== \"0\" && val !== \"off\";\n }\n\n // view → w:view/@w:val\n const viewEl = findChild(el, \"w:view\");\n if (viewEl) {\n const val = attr(viewEl, \"w:val\");\n if (val) opts.view = val;\n }\n\n // zoom → w:zoom/@w:percent, @w:val\n const zoomEl = findChild(el, \"w:zoom\");\n if (zoomEl) {\n const zoom: Record<string, unknown> = {};\n const percent = attr(zoomEl, \"w:percent\");\n if (percent) zoom.percent = parseInt(percent, 10);\n const val = attr(zoomEl, \"w:val\");\n if (val) zoom.val = val;\n if (Object.keys(zoom).length > 0) opts.zoom = zoom;\n }\n\n // defaultTabStop → w:defaultTabStop/@w:val\n const tabStopEl = findChild(el, \"w:defaultTabStop\");\n if (tabStopEl) {\n const val = attr(tabStopEl, \"w:val\");\n if (val) opts.defaultTabStop = parseInt(val, 10);\n }\n\n // features.trackRevisions → w:trackRevisions (onOff: read w:val)\n const trackRevEl = findChild(el, \"w:trackRevisions\");\n if (trackRevEl) {\n const features: FeaturesOptions = (opts.features as FeaturesOptions | undefined) ?? {};\n features.trackRevisions = attrBool(trackRevEl, \"w:val\") ?? true;\n opts.features = features;\n }\n\n // features.updateFields → w:updateFields (onOff: read w:val)\n const updateFieldsEl = findChild(el, \"w:updateFields\");\n if (updateFieldsEl) {\n const features: FeaturesOptions = (opts.features as FeaturesOptions | undefined) ?? {};\n features.updateFields = attrBool(updateFieldsEl, \"w:val\") ?? true;\n opts.features = features;\n }\n\n // compatibilityModeVersion → w:compat/w:compatSetting\n const compatEl = findChild(el, \"w:compat\");\n if (compatEl) {\n for (const child of compatEl.elements ?? []) {\n if (child.name === \"w:compatSetting\") {\n const name = attr(child, \"w:name\");\n if (name === \"compatibilityMode\") {\n const val = attr(child, \"w:val\");\n if (val) opts.compatabilityModeVersion = parseInt(val, 10);\n }\n }\n }\n }\n\n // docVars → w:docVars/w:docVar\n const docVarsEl = findChild(el, \"w:docVars\");\n if (docVarsEl) {\n const vars: Array<{ name: string; val: string }> = [];\n for (const child of docVarsEl.elements ?? []) {\n if (child.name === \"w:docVar\") {\n const name = attr(child, \"w:name\");\n const val = attr(child, \"w:val\");\n if (name && val) vars.push({ name, val });\n }\n }\n if (vars.length > 0) opts.docVars = vars;\n }\n\n // characterSpacingControl → w:characterSpacingControl/@w:val\n const cscEl = findChild(el, \"w:characterSpacingControl\");\n if (cscEl) {\n const val = attr(cscEl, \"w:val\");\n if (val) opts.characterSpacingControl = val;\n }\n\n // displayBackgroundShape → w:displayBackgroundShape (presence)\n if (findChild(el, \"w:displayBackgroundShape\")) {\n opts.displayBackgroundShape = true;\n }\n\n // embedTrueTypeFonts → w:embedTrueTypeFonts (presence)\n if (findChild(el, \"w:embedTrueTypeFonts\")) {\n opts.embedTrueTypeFonts = true;\n }\n\n // embedSystemFonts → w:embedSystemFonts (presence)\n if (findChild(el, \"w:embedSystemFonts\")) {\n opts.embedSystemFonts = true;\n }\n\n // saveSubsetFonts → w:saveSubsetFonts (presence)\n if (findChild(el, \"w:saveSubsetFonts\")) {\n opts.saveSubsetFonts = true;\n }\n\n // removePersonalInformation → w:removePersonalInformation (presence)\n if (findChild(el, \"w:removePersonalInformation\")) {\n opts.removePersonalInformation = true;\n }\n\n // removeDateAndTime → w:removeDateAndTime (presence)\n if (findChild(el, \"w:removeDateAndTime\")) {\n opts.removeDateAndTime = true;\n }\n\n // hideSpellingErrors → w:hideSpellingErrors (presence)\n if (findChild(el, \"w:hideSpellingErrors\")) {\n opts.hideSpellingErrors = true;\n }\n\n // hideGrammaticalErrors → w:hideGrammaticalErrors (presence)\n if (findChild(el, \"w:hideGrammaticalErrors\")) {\n opts.hideGrammaticalErrors = true;\n }\n\n // mirrorMargins → w:mirrorMargins (presence)\n if (findChild(el, \"w:mirrorMargins\")) {\n opts.mirrorMargins = true;\n }\n\n // saveFormsData → w:saveFormsData (presence)\n if (findChild(el, \"w:saveFormsData\")) {\n opts.saveFormsData = true;\n }\n\n // alignBordersAndEdges → w:alignBordersAndEdges (presence)\n if (findChild(el, \"w:alignBordersAndEdges\")) {\n opts.alignBordersAndEdges = true;\n }\n\n // bordersDoNotSurroundHeader → w:bordersDoNotSurroundHeader (presence)\n if (findChild(el, \"w:bordersDoNotSurroundHeader\")) {\n opts.bordersDoNotSurroundHeader = true;\n }\n\n // bordersDoNotSurroundFooter → w:bordersDoNotSurroundFooter (presence)\n if (findChild(el, \"w:bordersDoNotSurroundFooter\")) {\n opts.bordersDoNotSurroundFooter = true;\n }\n\n // gutterAtTop → w:gutterAtTop (presence)\n if (findChild(el, \"w:gutterAtTop\")) {\n opts.gutterAtTop = true;\n }\n\n // formsDesign → w:formsDesign (presence)\n if (findChild(el, \"w:formsDesign\")) {\n opts.formsDesign = true;\n }\n\n // linkStyles → w:linkStyles (presence)\n if (findChild(el, \"w:linkStyles\")) {\n opts.linkStyles = true;\n }\n\n // autoHyphenation → w:autoHyphenation\n const autoHyphEl = findChild(el, \"w:autoHyphenation\");\n if (autoHyphEl) {\n const hyphenation = (opts.hyphenation as Record<string, unknown>) ?? {};\n hyphenation.autoHyphenation = true;\n opts.hyphenation = hyphenation;\n }\n\n // doNotHyphenateCaps → w:doNotHyphenateCaps\n const noHyphCapsEl = findChild(el, \"w:doNotHyphenateCaps\");\n if (noHyphCapsEl) {\n const hyphenation = (opts.hyphenation as Record<string, unknown>) ?? {};\n hyphenation.doNotHyphenateCaps = true;\n opts.hyphenation = hyphenation;\n }\n\n // consecutiveHyphenLimit → w:consecutiveHyphenLimit/@w:val\n const consHyphEl = findChild(el, \"w:consecutiveHyphenLimit\");\n if (consHyphEl) {\n const val = attr(consHyphEl, \"w:val\");\n if (val) {\n const hyphenation = (opts.hyphenation as Record<string, unknown>) ?? {};\n hyphenation.consecutiveHyphenLimit = parseInt(val, 10);\n opts.hyphenation = hyphenation;\n }\n }\n\n // hyphenationZone → w:hyphenationZone/@w:val\n const hyphZoneEl = findChild(el, \"w:hyphenationZone\");\n if (hyphZoneEl) {\n const val = attr(hyphZoneEl, \"w:val\");\n if (val) {\n const hyphenation = (opts.hyphenation as Record<string, unknown>) ?? {};\n hyphenation.hyphenationZone = parseInt(val, 10);\n opts.hyphenation = hyphenation;\n }\n }\n\n // attachedTemplate → w:attachedTemplate/@r:id\n const attachedTplEl = findChild(el, \"w:attachedTemplate\");\n if (attachedTplEl) {\n const val = attr(attachedTplEl, \"r:id\");\n if (val) opts.attachedTemplate = val;\n }\n\n // stylePaneSortMethod → w:stylePaneSortMethod/@w:val\n const spsmEl = findChild(el, \"w:stylePaneSortMethod\");\n if (spsmEl) {\n const val = attr(spsmEl, \"w:val\");\n if (val) opts.stylePaneSortMethod = val;\n }\n\n // documentType → w:documentType/@w:val\n const docTypeEl = findChild(el, \"w:documentType\");\n if (docTypeEl) {\n const val = attr(docTypeEl, \"w:val\");\n if (val) opts.documentType = val;\n }\n\n // defaultTableStyle → w:defaultTableStyle/@w:val\n const defTblStyleEl = findChild(el, \"w:defaultTableStyle\");\n if (defTblStyleEl) {\n const val = attr(defTblStyleEl, \"w:val\");\n if (val) opts.defaultTableStyle = val;\n }\n\n // stylePaneFormatFilter → w:stylePaneFormatFilter (complex attributes)\n const spffEl = findChild(el, \"w:stylePaneFormatFilter\");\n if (spffEl) {\n const filter: Record<string, boolean> = {};\n const flags: [string, string][] = [\n [\"allStyles\", \"w:allStyles\"],\n [\"customStyles\", \"w:customStyles\"],\n [\"stylesInUse\", \"w:stylesInUse\"],\n [\"headingStyles\", \"w:headingStyles\"],\n [\"numberingStyles\", \"w:numberingStyles\"],\n [\"tableStyles\", \"w:tableStyles\"],\n [\"directFormattingOnRuns\", \"w:directFormattingOnRuns\"],\n [\"directFormattingOnParagraphs\", \"w:directFormattingOnParagraphs\"],\n [\"directFormattingOnNumbering\", \"w:directFormattingOnNumbering\"],\n [\"directFormattingOnTables\", \"w:directFormattingOnTables\"],\n [\"clearFormatting\", \"w:clearFormatting\"],\n [\"top3HeadingStyles\", \"w:top3HeadingStyles\"],\n [\"visibleStyles\", \"w:visibleStyles\"],\n [\"alternateStyleNames\", \"w:alternateStyleNames\"],\n ];\n for (const [prop, xmlKey] of flags) {\n const v = attr(spffEl, xmlKey);\n if (v !== undefined) filter[prop] = v !== \"0\" && v !== \"false\" && v !== \"off\";\n }\n if (Object.keys(filter).length > 0) opts.stylePaneFormatFilter = filter;\n }\n\n // clickAndTypeStyle → w:clickAndTypeStyle/@w:val\n const catEl = findChild(el, \"w:clickAndTypeStyle\");\n if (catEl) {\n const val = attr(catEl, \"w:val\");\n if (val) opts.clickAndTypeStyle = val;\n }\n\n // activeWritingStyle → iterate w:activeWritingStyle children\n const awsList: Array<Record<string, unknown>> = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:activeWritingStyle\") continue;\n const entry: Record<string, unknown> = {};\n const lang = attr(child, \"w:lang\");\n if (lang) entry.lang = lang;\n const vendorID = attr(child, \"w:vendorID\");\n if (vendorID) entry.vendorID = vendorID;\n const dllVersion = attr(child, \"w:dllVersion\");\n if (dllVersion) entry.dllVersion = dllVersion;\n const nlCheck = attr(child, \"w:nlCheck\");\n if (nlCheck !== undefined) entry.nlCheck = nlCheck !== \"0\" && nlCheck !== \"false\";\n const checkStyle = attr(child, \"w:checkStyle\");\n if (checkStyle !== undefined) entry.checkStyle = checkStyle !== \"0\" && checkStyle !== \"false\";\n const appCheck = attr(child, \"w:appCheck\");\n if (appCheck) entry.appCheck = appCheck;\n const appName = attr(child, \"w:appName\");\n if (appName) entry.appName = appName;\n if (Object.keys(entry).length > 0) awsList.push(entry);\n }\n if (awsList.length > 0) opts.activeWritingStyle = awsList;\n\n // proofState → w:proofState/@w:spelling, @w:grammar\n const proofEl = findChild(el, \"w:proofState\");\n if (proofEl) {\n const proof: Record<string, unknown> = {};\n const spelling = attr(proofEl, \"w:spelling\");\n if (spelling) proof.spelling = spelling;\n const grammar = attr(proofEl, \"w:grammar\");\n if (grammar) proof.grammar = grammar;\n if (Object.keys(proof).length > 0) opts.proofState = proof;\n }\n\n // documentProtection → w:documentProtection (written under features)\n const docProtEl = findChild(el, \"w:documentProtection\");\n if (docProtEl) {\n const prot: DocumentProtectionOptions = {};\n const edit = attr(docProtEl, \"w:edit\");\n if (edit && (DOC_PROTECT_EDITS as readonly string[]).includes(edit)) {\n prot.edit = edit as DocumentProtectionOptions[\"edit\"];\n }\n const enforcement = attr(docProtEl, \"w:enforcement\");\n if (enforcement !== undefined) {\n // Only include documentProtection if enforcement is set\n const hash = attr(docProtEl, \"w:hash\");\n if (hash) prot.hash = hash;\n const salt = attr(docProtEl, \"w:salt\");\n if (salt) prot.salt = salt;\n const cryptProviderType = attr(docProtEl, \"w:cryptProviderType\");\n if (cryptProviderType) prot.cryptoProviderType = cryptProviderType;\n const cryptAlgorithmClass = attr(docProtEl, \"w:cryptAlgorithmClass\");\n if (cryptAlgorithmClass) prot.cryptoAlgorithmClass = cryptAlgorithmClass;\n const cryptAlgorithmType = attr(docProtEl, \"w:cryptAlgorithmType\");\n if (cryptAlgorithmType) prot.cryptoAlgorithmType = cryptAlgorithmType;\n const cryptAlgorithmSid = attr(docProtEl, \"w:cryptAlgorithmSid\");\n if (cryptAlgorithmSid) prot.cryptoAlgorithmSid = parseInt(cryptAlgorithmSid, 10);\n const cryptSpinCount = attr(docProtEl, \"w:cryptSpinCount\");\n if (cryptSpinCount) prot.cryptoSpinCount = parseInt(cryptSpinCount, 10);\n const hashValue = attr(docProtEl, \"w:hashValue\");\n if (hashValue) prot.hashValue = hashValue;\n const saltValue = attr(docProtEl, \"w:saltValue\");\n if (saltValue) prot.saltValue = saltValue;\n const spinCount = attr(docProtEl, \"w:spinCount\");\n if (spinCount) prot.spinCount = parseInt(spinCount, 10);\n const algorithmName = attr(docProtEl, \"w:algorithmName\");\n if (algorithmName) prot.algorithmName = algorithmName;\n const formatting = attr(docProtEl, \"w:formatting\");\n if (formatting !== undefined) prot.formatting = formatting === \"1\" || formatting === \"true\";\n }\n if (Object.keys(prot).length > 0) {\n const features: FeaturesOptions = (opts.features as FeaturesOptions | undefined) ?? {};\n features.documentProtection = prot;\n opts.features = features;\n }\n }\n\n // doNotTrackMoves → w:doNotTrackMoves (onOff: read w:val)\n const noMovesEl = findChild(el, \"w:doNotTrackMoves\");\n if (noMovesEl) opts.doNotTrackMoves = attrBool(noMovesEl, \"w:val\") ?? true;\n\n // doNotTrackFormatting → w:doNotTrackFormatting (onOff: read w:val)\n const noFmtEl = findChild(el, \"w:doNotTrackFormatting\");\n if (noFmtEl) opts.doNotTrackFormatting = attrBool(noFmtEl, \"w:val\") ?? true;\n\n return opts as unknown as SettingsOptions;\n },\n};\n","/**\n * Table of Contents Properties module.\n *\n * This module defines configuration options for table of contents generation,\n * including field switches and style mappings.\n *\n * Reference: http://officeopenxml.com/WPtableOfContents.php\n *\n * @module\n */\n\n/**\n * Represents a style-to-level mapping for table of contents entries.\n *\n * StyleLevel associates a paragraph style name with a TOC level, allowing\n * custom styles to be included in the table of contents at specific levels.\n *\n * @publicApi\n */\nexport class StyleLevel {\n /** The name of the paragraph style. */\n public styleName: string;\n /** The TOC level (1-9) to assign to this style. */\n public level: number;\n\n public constructor(styleName: string, level: number) {\n this.styleName = styleName;\n this.level = level;\n }\n}\n\n/**\n * Options for configuring a Table of Contents.\n *\n * These options control which content is included in the TOC and how it is formatted.\n * Options correspond to field switches in the TOC field code.\n *\n * Reference:\n * - https://www.ecma-international.org/publications/standards/Ecma-376.htm (Part 1, Page 1251)\n * - http://officeopenxml.com/WPtableOfContents.php\n */\nexport interface TableOfContentsOptions {\n /**\n * \\a option - Includes captioned items, but omits caption labels and numbers.\n * The identifier designated by text in this switch's field-argument corresponds to the caption label.\n * Use captionLabelIncludingNumbers (\\c) to build a table of captions with labels and numbers.\n */\n captionLabel?: string;\n\n /**\n * \\b option - Includes entries only from the portion of the document marked by\n * the bookmark named by text in this switch's field-argument.\n */\n entriesFromBookmark?: string;\n\n /**\n * \\c option - Includes figures, tables, charts, and other items that are numbered\n * by a SEQ field (§17.16.5.56). The sequence identifier designated by text in this switch's\n * field-argument, which corresponds to the caption label, shall match the identifier in the\n * corresponding SEQ field.\n */\n captionLabelIncludingNumbers?: string;\n\n /**\n * \\d option - When used with \\s, the text in this switch's field-argument defines\n * the separator between sequence and page numbers. The default separator is a hyphen (-).\n */\n sequenceAndPageNumbersSeparator?: string;\n\n /**\n * \\f option - Includes only those TC fields whose identifier exactly matches the\n * text in this switch's field-argument (which is typically a letter).\n */\n tcFieldIdentifier?: string;\n\n /**\n * \\h option - Makes the table of contents entries hyperlinks.\n */\n hyperlink?: boolean;\n\n /**\n * \\l option - Includes TC fields that assign entries to one of the levels specified\n * by text in this switch's field-argument as a range having the form startLevel-endLevel,\n * where startLevel and endLevel are integers, and startLevel has a value equal-to or less-than endLevel.\n * TC fields that assign entries to lower levels are skipped.\n */\n tcFieldLevelRange?: string;\n\n /**\n * \\n option - Without field-argument, omits page numbers from the table of contents.\n * Page numbers are omitted from all levels unless a range of entry levels is specified by\n * text in this switch's field-argument. A range is specified as for \\l.\n */\n pageNumbersEntryLevelsRange?: string;\n\n /**\n * \\o option - Uses paragraphs formatted with all or the specified range of builtin\n * heading styles. Headings in a style range are specified by text in this switch's\n * field-argument using the notation specified as for \\l, where each integer corresponds\n * to the style with a style ID of HeadingX (e.g. 1 corresponds to Heading1).\n * If no heading range is specified, all heading levels used in the document are listed.\n */\n headingStyleRange?: string;\n\n /**\n * \\p option - Text in this switch's field-argument specifies a sequence of characters\n * that separate an entry and its page number. The default is a tab with leader dots.\n */\n entryAndPageNumberSeparator?: string;\n\n /**\n * \\s option - For entries numbered with a SEQ field (§17.16.5.56), adds a prefix to the page number.\n * The prefix depends on the type of entry. text in this switch's field-argument shall match the\n * identifier in the SEQ field.\n */\n seqFieldIdentifierForPrefix?: string;\n\n /**\n * \\t field-argument Uses paragraphs formatted with styles other than the built-in heading styles.\n * Text in this switch's field-argument specifies those styles as a set of comma-separated doublets,\n * with each doublet being a comma-separated set of style name and table of content level.\n * \\t can be combined with \\o.\n */\n stylesWithLevels?: StyleLevel[];\n\n /**\n * \\u Uses the applied paragraph outline level.\n */\n useAppliedParagraphOutlineLevel?: boolean;\n\n /**\n * \\w Preserves tab entries within table entries.\n */\n preserveTabInEntries?: boolean;\n\n /**\n * \\x Preserves newline characters within table entries.\n */\n preserveNewLineInEntries?: boolean;\n\n /**\n * \\z Hides tab leader and page numbers in web page view (§17.18.102).\n */\n hideTabAndPageNumbersInWebView?: boolean;\n}\n","/**\n * Structured Document Tag Properties module.\n *\n * Represents CT_SdtPr — the properties of a structured document tag (content control).\n * Supports all SDT types defined in the OOXML specification: comboBox, dropDownList,\n * date, text, equation,richText, picture, citation, group, bibliography, docPartObj,\n * docPartList.\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_SdtPr\n *\n * @module\n */\n\n// ─── Lock ───────────────────────────────────────────────────────────────────\n\n/**\n * SDT lock type (ST_Lock).\n */\nexport const SdtLock = {\n /** Lock the SDT itself (cannot delete the control) */\n SDT_LOCKED: \"sdtLocked\",\n /** Lock the content (cannot edit content within the control) */\n CONTENT_LOCKED: \"contentLocked\",\n /** No locking */\n UNLOCKED: \"unlocked\",\n /** Lock both SDT and content */\n SDT_CONTENT_LOCKED: \"sdtContentLocked\",\n} as const;\n\n// ─── Supporting Types ───────────────────────────────────────────────────────\n\n/**\n * A list item for comboBox or dropDownList SDTs (CT_SdtListItem).\n */\nexport interface SdtListItem {\n /** Display text shown in the UI */\n displayText?: string;\n /** Underlying value */\n value?: string;\n}\n\n/**\n * Options for comboBox SDT type (CT_SdtComboBox).\n */\nexport interface SdtComboBoxOptions {\n /** List items */\n items?: SdtListItem[];\n /** Last selected value */\n lastValue?: string;\n}\n\n/**\n * Options for dropDownList SDT type (CT_SdtDropDownList).\n */\nexport interface SdtDropDownListOptions {\n /** List items */\n items?: SdtListItem[];\n /** Last selected value */\n lastValue?: string;\n}\n\n/**\n * Date mapping type (ST_SdtDateMappingType).\n */\nexport const SdtDateMappingType = {\n TEXT: \"text\",\n DATE: \"date\",\n DATE_TIME: \"dateTime\",\n} as const;\n\n/**\n * Options for date SDT type (CT_SdtDate).\n */\nexport interface SdtDateOptions {\n /** Date format string (e.g., \"yyyy-MM-dd\") */\n dateFormat?: string;\n /** Language ID (e.g., \"en-US\") */\n languageId?: string;\n /** How the date value is stored */\n storeMappedDataAs?: (typeof SdtDateMappingType)[keyof typeof SdtDateMappingType];\n /** Calendar type */\n calendar?: string;\n /** Full date value (ISO 8601) */\n fullDate?: string;\n}\n\n/**\n * Options for plain text SDT type (CT_SdtText).\n */\nexport interface SdtTextOptions {\n /** Whether the text control supports multiple lines */\n multiLine?: boolean;\n}\n\n/**\n * Symbol for a checkbox content control state (CT_SdtCheckboxSymbol).\n *\n * `val` is a hex Unicode code point (e.g., \"2612\" for ☒); `font` defaults to\n * \"MS Gothic\" per the OOXML specification.\n */\nexport interface SdtCheckboxSymbol {\n /** Hex Unicode code point of the symbol (e.g., \"2612\") */\n val: string;\n /** Font face; defaults to \"MS Gothic\" */\n font?: string;\n}\n\n/**\n * Options for a checkbox content control (CT_SdtCheckbox, w14:checkbox).\n *\n * Word 2010+ content control checkbox. When present, the SDT renders the\n * current state symbol instead of its declared children.\n */\nexport interface SdtCheckboxOptions {\n /** Whether the checkbox is checked (default: false) */\n checked?: boolean;\n /** Symbol for the checked state (default: ☒ 0x2612, MS Gothic) */\n checkedState?: SdtCheckboxSymbol;\n /** Symbol for the unchecked state (default: ☐ 0x2610, MS Gothic) */\n uncheckedState?: SdtCheckboxSymbol;\n}\n\n/**\n * Data binding options (CT_DataBinding).\n */\nexport interface SdtDataBindingOptions {\n /** XML namespace prefix mappings */\n prefixMappings?: string;\n /** XPath expression (required) */\n xpath: string;\n /** Custom XML store item ID (required) */\n storeItemID: string;\n}\n\n/**\n * Options for CT_SdtPr — structured document tag properties.\n */\nexport interface SdtPropertiesOptions {\n /** Display name */\n alias?: string;\n /** Application-specific tag */\n tag?: string;\n /** Unique ID */\n id?: number;\n /** Lock behavior */\n lock?: (typeof SdtLock)[keyof typeof SdtLock];\n /** Whether the control is temporary */\n temporary?: boolean;\n /** Whether the placeholder text is currently shown */\n showingPlaceholder?: boolean;\n /** Data binding to custom XML */\n dataBinding?: SdtDataBindingOptions;\n /** Numeric label */\n label?: number;\n /** Tab order index */\n tabIndex?: number;\n\n // ─── Type discriminators (xsd:choice, at most one) ───\n\n /** Equation SDT */\n equation?: boolean;\n /** ComboBox SDT (allows free-text entry) */\n comboBox?: SdtComboBoxOptions;\n /** Date SDT */\n date?: SdtDateOptions;\n /** Document part object SDT */\n docPartObj?: {\n gallery?: string;\n category?: string;\n unique?: boolean;\n };\n /** Document part list SDT */\n docPartList?: {\n gallery?: string;\n category?: string;\n unique?: boolean;\n };\n /** DropDownList SDT (selection only) */\n dropDownList?: SdtDropDownListOptions;\n /** Picture SDT */\n picture?: boolean;\n /** Rich text SDT */\n richText?: boolean;\n /** Plain text SDT */\n text?: SdtTextOptions;\n /** Citation SDT */\n citation?: boolean;\n /** Group SDT */\n group?: boolean;\n /** Bibliography SDT */\n bibliography?: boolean;\n /** Checkbox content control SDT (Word 2010+, w14:checkbox) */\n checkbox?: SdtCheckboxOptions;\n}\n","/**\n * Table of Contents parser for DOCX documents.\n *\n * Parses TOC-type SDT elements into TOC options.\n *\n * @module\n */\nimport { attr, children, findChild, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type {\n StyleLevel,\n TableOfContentsOptions,\n} from \"@parts/table-of-contents/table-of-contents-properties\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Try to parse a w:sdt element as a TOC.\n * Returns { alias, ...tocOptions } if it's a TOC, or undefined otherwise.\n *\n * Detects TOC in two ways:\n * 1. SDT with w:docPartObj > w:docPartGallery = \"Table of Contents\" (Word-generated)\n * 2. SDT whose content contains a TOC field instruction (library-generated)\n */\nexport function parseToc(\n el: Element,\n _ctx: DocxReadContext,\n):\n | ({\n alias?: string;\n } & TableOfContentsOptions)\n | undefined {\n const sdtPr = findChild(el, \"w:sdtPr\");\n if (!sdtPr) return undefined;\n\n // Detection method 1: docPartObj with gallery \"Table of Contents\"\n const docPartObj = findChild(sdtPr, \"w:docPartObj\");\n let isToc = false;\n\n if (docPartObj) {\n const gallery = findChild(docPartObj, \"w:docPartGallery\");\n if (gallery && textOf(gallery) === \"Table of Contents\") {\n isToc = true;\n }\n }\n\n // Detection method 2: scan content for TOC field instruction\n if (!isToc) {\n const sdtContent = findChild(el, \"w:sdtContent\");\n if (sdtContent) {\n isToc = hasTocFieldInstruction(sdtContent);\n }\n }\n\n if (!isToc) return undefined;\n\n // It's a TOC SDT\n const alias = (() => {\n const aliasEl = findChild(sdtPr, \"w:alias\");\n return aliasEl ? attr(aliasEl, \"w:val\") : undefined;\n })();\n\n // Parse field instruction from content to extract TOC options\n const tocOpts: Record<string, unknown> = {};\n const sdtContent = findChild(el, \"w:sdtContent\");\n\n if (sdtContent) {\n // Look for field instructions\n for (const p of children(sdtContent, \"w:p\")) {\n for (const r of children(p, \"w:r\")) {\n for (const instrText of children(r, \"w:instrText\")) {\n const instruction = textOf(instrText).trim();\n parseTocFieldInstruction(instruction, tocOpts);\n }\n }\n }\n }\n\n return { alias, ...tocOpts } as { alias?: string } & TableOfContentsOptions;\n}\n\n/**\n * Check whether an element tree contains a TOC field instruction\n * (w:instrText with text starting with \"TOC\").\n */\nfunction hasTocFieldInstruction(el: Element): boolean {\n for (const p of children(el, \"w:p\")) {\n for (const r of children(p, \"w:r\")) {\n for (const instrText of children(r, \"w:instrText\")) {\n const instruction = textOf(instrText)?.trim();\n if (instruction?.startsWith(\"TOC\")) return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Parse a TOC field instruction string (e.g., ' TOC \\o \"1-3\" \\h \\z ')\n * into TableOfContentsOptions properties.\n */\nfunction parseTocFieldInstruction(instruction: string, opts: Record<string, unknown>): void {\n if (!instruction.startsWith(\"TOC\")) return;\n\n const rest = instruction.slice(3).trim();\n const switches = parseFieldSwitches(rest);\n\n if (switches[\"a\"]) opts.captionLabel = switches[\"a\"];\n if (switches[\"b\"]) opts.entriesFromBookmark = switches[\"b\"];\n if (switches[\"c\"]) opts.captionLabelIncludingNumbers = switches[\"c\"];\n if (switches[\"d\"]) opts.sequenceAndPageNumbersSeparator = switches[\"d\"];\n if (switches[\"f\"]) opts.tcFieldIdentifier = switches[\"f\"];\n if (\"h\" in switches) opts.hyperlink = true;\n if (switches[\"l\"]) opts.tcFieldLevelRange = switches[\"l\"];\n if (switches[\"n\"]) opts.pageNumbersEntryLevelsRange = switches[\"n\"];\n if (switches[\"o\"]) opts.headingStyleRange = switches[\"o\"];\n if (switches[\"p\"]) opts.entryAndPageNumberSeparator = switches[\"p\"];\n if (switches[\"s\"]) opts.seqFieldIdentifierForPrefix = switches[\"s\"];\n if (switches[\"t\"]) {\n // \\t \"Style1,1,Style2,2\" -> stylesWithLevels pairs\n const parts = switches[\"t\"]!.split(\",\");\n const stylesWithLevels: StyleLevel[] = [];\n for (let i = 0; i + 1 < parts.length; i += 2) {\n const styleName = parts[i];\n const level = parseInt(parts[i + 1], 10);\n if (styleName && !Number.isNaN(level)) stylesWithLevels.push({ styleName, level });\n }\n if (stylesWithLevels.length > 0) opts.stylesWithLevels = stylesWithLevels;\n }\n if (\"u\" in switches) opts.useAppliedParagraphOutlineLevel = true;\n if (\"w\" in switches) opts.preserveTabInEntries = true;\n if (\"x\" in switches) opts.preserveNewLineInEntries = true;\n if (\"z\" in switches) opts.hideTabAndPageNumbersInWebView = true;\n}\n\n/**\n * Parse field switches like \\o \"1-3\" \\h \\z into a map.\n */\nfunction parseFieldSwitches(text: string): Record<string, string | undefined> {\n const result: Record<string, string | undefined> = {};\n let i = 0;\n\n while (i < text.length) {\n // Skip whitespace\n while (i < text.length && text[i] === \" \") i++;\n if (i >= text.length) break;\n\n // Expect backslash\n if (text[i] !== \"\\\\\") {\n i++;\n continue;\n }\n i++;\n\n // Read switch name\n const nameStart = i;\n while (i < text.length && /[a-zA-Z]/.test(text[i])) i++;\n const name = text.slice(nameStart, i);\n if (!name) continue;\n\n // Skip whitespace\n while (i < text.length && text[i] === \" \") i++;\n\n // Read argument (quoted or unquoted)\n if (i < text.length && text[i] === '\"') {\n i++;\n const argStart = i;\n while (i < text.length && text[i] !== '\"') i++;\n result[name] = text.slice(argStart, i);\n if (i < text.length) i++; // skip closing quote\n } else if (i < text.length && text[i] !== \"\\\\\") {\n const argStart = i;\n while (i < text.length && text[i] !== \" \" && text[i] !== \"\\\\\") i++;\n const arg = text.slice(argStart, i).trim();\n if (arg) result[name] = arg;\n else result[name] = undefined;\n } else {\n result[name] = undefined;\n }\n }\n\n return result;\n}\n","/**\n * Table of Contents stringifier for DOCX.\n *\n * Produces `<w:sdt>` XML containing a TOC field code, replacing\n * `new TableOfContents(alias, options).toXml(ctx)` with direct\n * string concatenation — zero XmlComponent instances.\n *\n * @module\n */\n\nimport { escapeXml } from \"@office-open/xml\";\nimport type { TableOfContentsOptions } from \"@parts/table-of-contents/table-of-contents-properties\";\n\n// ── Field instruction string ──\n\nfunction tocInstructionStr(opts: TableOfContentsOptions): string {\n let instr = \"TOC\";\n\n if (opts.captionLabel) instr += ` \\\\a \"${opts.captionLabel}\"`;\n if (opts.entriesFromBookmark) instr += ` \\\\b \"${opts.entriesFromBookmark}\"`;\n if (opts.captionLabelIncludingNumbers) instr += ` \\\\c \"${opts.captionLabelIncludingNumbers}\"`;\n if (opts.sequenceAndPageNumbersSeparator)\n instr += ` \\\\d \"${opts.sequenceAndPageNumbersSeparator}\"`;\n if (opts.tcFieldIdentifier) instr += ` \\\\f \"${opts.tcFieldIdentifier}\"`;\n if (opts.hyperlink) instr += \" \\\\h\";\n if (opts.tcFieldLevelRange) instr += ` \\\\l \"${opts.tcFieldLevelRange}\"`;\n if (opts.pageNumbersEntryLevelsRange) instr += ` \\\\n \"${opts.pageNumbersEntryLevelsRange}\"`;\n if (opts.headingStyleRange) instr += ` \\\\o \"${opts.headingStyleRange}\"`;\n if (opts.entryAndPageNumberSeparator) instr += ` \\\\p \"${opts.entryAndPageNumberSeparator}\"`;\n if (opts.seqFieldIdentifierForPrefix) instr += ` \\\\s \"${opts.seqFieldIdentifierForPrefix}\"`;\n if (opts.stylesWithLevels?.length) {\n const styles = opts.stylesWithLevels.map((sl) => `${sl.styleName},${sl.level}`).join(\",\");\n instr += ` \\\\t \"${styles}\"`;\n }\n if (opts.useAppliedParagraphOutlineLevel) instr += \" \\\\u\";\n if (opts.preserveTabInEntries) instr += \" \\\\w\";\n if (opts.preserveNewLineInEntries) instr += \" \\\\x\";\n if (opts.hideTabAndPageNumbersInWebView) instr += \" \\\\z\";\n\n return instr;\n}\n\n// ── Main stringifier ──\n\nexport function stringifyTableOfContents(\n alias: string = \"Table of Contents\",\n options: TableOfContentsOptions = {},\n): string {\n const instr = tocInstructionStr(options);\n const aliasAttr = alias ? ` w:val=\"${escapeXml(alias)}\"` : \"\";\n\n // SDT properties: alias + docPartObj\n const sdtPr =\n `<w:sdtPr>` +\n `<w:alias${aliasAttr}/>` +\n `<w:docPartObj><w:docPartGallery w:val=\"Table of Contents\"/></w:docPartObj>` +\n `</w:sdtPr>`;\n\n // SDT content: begin paragraph (with field instruction) + end paragraph\n const content =\n `<w:sdtContent>` +\n `<w:p><w:r><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:cstheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cs=\"Times New Roman\"/></w:rPr><w:fldChar w:fldCharType=\"begin\" w:dirty=\"1\"/></w:r>` +\n `<w:r><w:instrText xml:space=\"preserve\"> ${instr} </w:instrText></w:r>` +\n `<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r></w:p>` +\n `<w:p><w:r><w:fldChar w:fldCharType=\"end\"/></w:r></w:p>` +\n `</w:sdtContent>`;\n\n return `<w:sdt>${sdtPr}${content}</w:sdt>`;\n}\n","import { Relationships } from \"@office-open/core\";\nimport { uniqueUuid } from \"@office-open/core\";\n\n/**\n * Font Wrapper module for WordprocessingML documents.\n *\n * Manages font table relationships for embedded fonts.\n * Pure data container — no XmlComponent dependency.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_fonts.html\n *\n * @module\n */\nimport type { ViewWrapper } from \"../../context\";\nimport type { EmbeddedFontOptions } from \"./font-table\";\n\n/**\n * Font options extended with a unique font key.\n */\nexport type EmbeddedFontOptionsWithKey = EmbeddedFontOptions & { fontKey: string };\n\n/**\n * Wrapper class for managing embedded font relationships.\n *\n * Each font is assigned a unique key for obfuscation.\n * The actual font table XML is generated by `fontTableDesc.stringify()`.\n *\n * @example\n * ```typescript\n * const fontWrapper = new FontWrapper([\n * { name: \"CustomFont\", data: fontBuffer }\n * ]);\n * ```\n */\nexport class FontWrapper implements ViewWrapper {\n public relationships: Relationships;\n public fontOptionsWithKey: EmbeddedFontOptionsWithKey[] = [];\n\n public constructor(public options: EmbeddedFontOptions[]) {\n this.fontOptionsWithKey = options.map((o) => ({ ...o, fontKey: uniqueUuid() }));\n this.relationships = new Relationships();\n\n for (let i = 0; i < options.length; i++) {\n this.relationships.addRelationship(\n i + 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/font\",\n `fonts/${options[i].name}.odttf`,\n );\n }\n }\n}\n","/**\n * VML shape module for WordprocessingML documents.\n *\n * Provides the VmlShapeStyle type and style-to-key mapping used by compile/\n * and parse paths. Runtime shape construction has been migrated to the\n * descriptor pipeline.\n *\n * References:\n * - https://c-rex.net/samples/ooxml/e1/Part3/OOXML_P3_Primer_OfficeArt_topic_ID0ELU5O.html\n * - http://webapp.docx4java.org/OnlineDemo/ecma376/VML/shape.html\n *\n * @module\n */\nimport type { LengthUnit } from \"../types\";\n\n/**\n * Maps VmlShapeStyle property names to their corresponding CSS-style property names.\n * Used internally for converting TypeScript-friendly property names to VML style attributes.\n */\nexport const styleToKeyMap: Record<keyof VmlShapeStyle, string> = {\n flip: \"flip\",\n height: \"height\",\n left: \"left\",\n marginBottom: \"margin-bottom\",\n marginLeft: \"margin-left\",\n marginRight: \"margin-right\",\n marginTop: \"margin-top\",\n position: \"position\",\n positionHorizontal: \"mso-position-horizontal\",\n positionHorizontalRelative: \"mso-position-horizontal-relative\",\n positionVertical: \"mso-position-vertical\",\n positionVerticalRelative: \"mso-position-vertical-relative\",\n rotation: \"rotation\",\n top: \"top\",\n visibility: \"visibility\",\n width: \"width\",\n wrapDistanceBottom: \"mso-wrap-distance-bottom\",\n wrapDistanceLeft: \"mso-wrap-distance-left\",\n wrapDistanceRight: \"mso-wrap-distance-right\",\n wrapDistanceTop: \"mso-wrap-distance-top\",\n wrapEdited: \"mso-wrap-edited\",\n wrapStyle: \"mso-wrap-style\",\n zIndex: \"z-index\",\n};\n\n/**\n * VML shape styling properties for WordprocessingML documents.\n *\n * These properties map to CSS-style attributes on VML shape elements and control\n * the shape's appearance, layout, and interaction with surrounding text.\n */\nexport interface VmlShapeStyle {\n /** Specifies that the orientation of a shape is flipped. Default is no value. */\n flip?: \"x\" | \"y\" | \"xy\" | \"yx\";\n /** Specifies the height of the containing block of the shape. Default is 0. */\n height?: LengthUnit;\n /** Specifies the position of the left of the containing block relative to the element left of it. Default is 0. */\n left?: LengthUnit;\n /** Specifies the position of the bottom of the containing block relative to the shape anchor. Default is 0. */\n marginBottom?: LengthUnit;\n /** Specifies the position of the left of the containing block relative to the shape anchor. Default is 0. */\n marginLeft?: LengthUnit;\n /** Specifies the position of the right of the containing block relative to the shape anchor. Default is 0. */\n marginRight?: LengthUnit;\n /** Specifies the position of the top of the containing block relative to the shape anchor. Default is 0. */\n marginTop?: LengthUnit;\n /** Specifies the horizontal positioning data. Default is absolute. */\n positionHorizontal?: \"absolute\" | \"left\" | \"center\" | \"right\" | \"inside\" | \"outside\";\n /** Specifies relative horizontal position data. Default is text. */\n positionHorizontalRelative?: \"margin\" | \"page\" | \"text\" | \"char\";\n /** Specifies the vertical positioning data. Default is absolute. */\n positionVertical?: \"absolute\" | \"left\" | \"center\" | \"right\" | \"inside\" | \"outside\";\n /** Specifies relative vertical position data. Default is text. */\n positionVerticalRelative?: \"margin\" | \"page\" | \"text\" | \"char\";\n /** Specifies the distance from the bottom of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceBottom?: number;\n /** Specifies the distance from the left side of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceLeft?: number;\n /** Specifies the distance from the right side of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceRight?: number;\n /** Specifies the distance from the top of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceTop?: number;\n /** Specifies whether the wrap coordinates were customized by the user. Default is false. */\n wrapEdited?: boolean;\n /** Specifies the wrapping mode for text in shapes. Default is square. */\n wrapStyle?: \"square\" | \"none\";\n /** Specifies the type of positioning used to place an element. Default is static. */\n position?: \"static\" | \"absolute\" | \"relative\";\n /** Specifies the angle that a shape is rotated, in degrees. Default is 0. */\n rotation?: number;\n /** Specifies the position of the top of the containing block. Default is 0. */\n top?: LengthUnit;\n /** Specifies whether a shape is displayed. Default is inherit. */\n visibility?: \"hidden\" | \"inherit\";\n /** Specifies the width of the containing block of the shape. Default is 0. */\n width: LengthUnit;\n /** Specifies the display order of overlapping shapes. Default is 0. */\n zIndex?: \"auto\" | number;\n}\n","/**\n * Body-level stringification for DOCX documents.\n *\n * Converts pure JSON options to XML strings for document body content.\n * Pure string concatenation — zero IXmlableObject, zero BaseXmlComponent.\n *\n * @module\n */\n\nimport { toUint8Array } from \"@office-open/core\";\nimport { uniqueId } from \"@office-open/core\";\nimport { hexColorValue, uCharHexNumber } from \"@office-open/core\";\nimport { ThemeColor } from \"@office-open/core\";\nimport { attr, attrBool, attrNum, escapeXml, findChild, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { sectionPropertiesDesc } from \"@parts/document/body/section-properties/descriptor\";\nimport type { DocumentBackgroundOptions } from \"@parts/document/document-background\";\nimport { parseDrawingRun } from \"@parts/drawing/drawing-parse\";\nimport { FontWrapper } from \"@parts/fonts/font-wrapper\";\nimport type { BordersOptions } from \"@parts/paragraph/formatting/border\";\nimport type { IndentAttributesProperties } from \"@parts/paragraph/formatting/indent\";\nimport { LineRuleType } from \"@parts/paragraph/formatting/spacing\";\nimport type { SpacingProperties } from \"@parts/paragraph/formatting/spacing\";\nimport { HeadingLevel } from \"@parts/paragraph/formatting/style\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport { parseFormFieldData } from \"@parts/paragraph/run/form-field\";\nimport type { FormFieldOptions } from \"@parts/paragraph/run/form-field\";\nimport type { RunOptions } from \"@parts/paragraph/run/run\";\nimport { parseRun, parseRunProperties, parsedRunToOptions } from \"@parts/paragraph/run/run-parse\";\nimport { parseSdtProperties } from \"@parts/sdt/sdt-parse\";\nimport { stringifyTableOfContents } from \"@parts/table-of-contents/descriptor\";\nimport type { VmlShapeStyle } from \"@parts/textbox/shape/shape\";\nimport { styleToKeyMap } from \"@parts/textbox/shape/shape\";\nimport type { BorderOptions } from \"@shared/border\";\nimport { BorderStyle } from \"@shared/border\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { DocxReadContext, DocxWriteContext, BodyContext } from \"./context\";\nimport { tableDesc, altChunkDesc, subDocDesc, sdtBlockDesc, customXmlBlockDesc } from \"./parts\";\nimport { parseCustomXmlPr } from \"./parts/bodychildren\";\nimport { stringifyChildDispatch } from \"./parts/inline\";\nimport { parseMathChildren } from \"./parts/paragraph/math/stringify\";\nimport type { ParagraphChild } from \"./parts/paragraph/paragraph\";\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"./parts/paragraph/stringify\";\n\nexport type { BodyContext } from \"./context\";\n\n// ── Run ──\n\n/**\n * Mapping from empty child property name to self-closing XML element.\n *\n * These are single-key objects like `{ noBreakHyphen: true }` that map to\n * self-closing XML elements with no attributes.\n *\n * XSD reference: EG_RunInnerContent group in wml.xsd.\n */\nconst EMPTY_RUN_ELEMENTS: Record<string, string> = {\n noBreakHyphen: \"<w:noBreakHyphen/>\",\n softHyphen: \"<w:softHyphen/>\",\n dayShort: \"<w:dayShort/>\",\n monthShort: \"<w:monthShort/>\",\n yearShort: \"<w:yearShort/>\",\n dayLong: \"<w:dayLong/>\",\n monthLong: \"<w:monthLong/>\",\n yearLong: \"<w:yearLong/>\",\n annotationRef: \"<w:annotationRef/>\",\n footnoteRef: \"<w:footnoteRef/>\",\n endnoteRef: \"<w:endnoteRef/>\",\n separator: \"<w:separator/>\",\n continuationSeparator: \"<w:continuationSeparator/>\",\n pgNum: \"<w:pgNum/>\",\n carriageReturn: \"<w:cr/>\",\n lastRenderedPageBreak: \"<w:lastRenderedPageBreak/>\",\n};\n\n/**\n * Stringify a run (w:r) from pure JSON options.\n *\n * Handles text, children, breaks, and run properties.\n */\nexport function stringifyRun(opts: RunOptions, ctx: BodyContext): string {\n const parts: string[] = [];\n\n // Pre-scan children for commentReference — needs CommentReference style in rPr\n let commentRefStyle = false;\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"object\" && child !== null && \"commentReference\" in child) {\n commentRefStyle = true;\n break;\n }\n }\n }\n\n // Run properties — inject CommentReference style if needed\n const runOpts = commentRefStyle ? { ...opts, style: \"CommentReference\" as const } : opts;\n const rPr = stringifyRunProperties(runOpts);\n if (rPr) parts.push(rPr);\n\n // Breaks\n if (opts.break) {\n for (let i = 0; i < opts.break; i++) {\n parts.push(\"<w:br/>\");\n }\n }\n\n // Children or text\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"string\") {\n // Simple text string — direct output\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(child)}</w:t>`);\n } else if (typeof child === \"object\" && child !== null) {\n // Simple run-level elements — bare content, no <w:r> wrapper\n if (\"tab\" in child) {\n parts.push(\"<w:tab/>\");\n continue;\n }\n if (\"pageBreak\" in child) {\n parts.push('<w:br w:type=\"page\"/>');\n continue;\n }\n if (\"columnBreak\" in child) {\n parts.push('<w:br w:type=\"column\"/>');\n continue;\n }\n if (\"commentReference\" in child) {\n parts.push(`<w:commentReference w:id=\"${Number(child.commentReference)}\"/>`);\n continue;\n }\n\n // Empty run elements — self-closing XML with no attributes\n // { noBreakHyphen: true } → <w:noBreakHyphen/>, etc.\n const emptyXml = EMPTY_RUN_ELEMENTS[Object.keys(child)[0]];\n if (emptyXml) {\n parts.push(emptyXml);\n continue;\n }\n\n // JSON child dispatch (images, charts, 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 {\n // Fallback: treat as IXmlableObject-like — should not happen in JSON path\n throw new Error(`Unsupported run child type: ${Object.keys(child).join(\", \")}`);\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 // rsid attributes on <w:r>\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// ── Paragraph ──\n\n/**\n * Stringify a paragraph (w:p) from pure JSON options or string.\n *\n * Handles paragraph properties, numbering registration, and run children.\n */\nexport function stringifyParagraph(\n opts: string | ParagraphOptions,\n ctx: BodyContext,\n sectionPropertiesXml?: string,\n): string {\n const resolved: ParagraphOptions = typeof opts === \"string\" ? { text: opts } : opts;\n const parts: string[] = [];\n\n // Build paragraph properties — direct string output, zero IXmlableObject allocation\n const props = stringifyParagraphProperties(resolved);\n\n // Register numbering references\n if (!(ctx.viewWrapper instanceof FontWrapper)) {\n for (const ref of props.numberingReferences) {\n ctx.file.numbering.createConcreteNumberingInstance(ref.reference, ref.instance);\n }\n }\n\n // Paragraph properties XML\n if (props.xml) {\n if (sectionPropertiesXml) {\n // Insert sectPr before closing </w:pPr>\n parts.push(props.xml.replace(\"</w:pPr>\", sectionPropertiesXml + \"</w:pPr>\"));\n } else {\n parts.push(props.xml);\n }\n } else if (sectionPropertiesXml) {\n // No pPr but we need sectPr — wrap in pPr\n parts.push(`<w:pPr>${sectionPropertiesXml}</w:pPr>`);\n }\n\n // Text shorthand\n if (resolved.text !== undefined) {\n parts.push(stringifyRun({ text: resolved.text }, ctx));\n }\n\n // Children\n if (resolved.children) {\n for (const child of resolved.children) {\n if (typeof child === \"string\") {\n parts.push(stringifyRun({ text: child }, ctx));\n } else if (typeof child === \"object\" && child !== null) {\n // Try JSON child dispatch first (image, chart, pageBreak, 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 // RunOptions-like plain object\n parts.push(stringifyRun(child, ctx));\n } else {\n throw new Error(`Unsupported paragraph child type: ${Object.keys(child).join(\", \")}`);\n }\n }\n }\n }\n\n const body = parts.join(\"\");\n return body ? `<w:p>${body}</w:p>` : \"<w:p/>\";\n}\n\n// ── Body child dispatch ──\n\n/**\n * Stringify a body-level child element.\n *\n * Dispatches to the appropriate stringifier based on the child type.\n * Pure JSON API — no class instance support.\n */\nexport function stringifyBodyChild(child: SectionChild, ctx: BodyContext): string {\n // Plain object dispatch — all via descriptors\n if (\"paragraph\" in child) {\n return stringifyParagraph(child.paragraph, ctx);\n }\n if (\"table\" in child) {\n return tableDesc.stringify(child.table, ctx) ?? \"\";\n }\n if (\"toc\" in child) {\n const { alias, ...options } = child.toc;\n return stringifyTableOfContents(alias, options);\n }\n if (\"textbox\" in child) {\n return stringifyTextbox(child.textbox, ctx);\n }\n if (\"sdt\" in child) {\n return sdtBlockDesc.stringify(child.sdt, ctx) ?? \"\";\n }\n if (\"altChunk\" in child) {\n return altChunkDesc.stringify(child.altChunk, ctx) ?? \"\";\n }\n if (\"subDoc\" in child) {\n return subDocDesc.stringify(child.subDoc, ctx) ?? \"\";\n }\n if (\"customXml\" in child) {\n return customXmlBlockDesc.stringify(child.customXml, ctx) ?? \"\";\n }\n if (\"rawXml\" in child) {\n return child.rawXml;\n }\n\n throw new Error(\"Unknown section child type\");\n}\n\n// ── Document background (pure function, no XmlComponent) ──\n\n/** Re-export styleToKeyMap for use in stringifyTextboxStyle. */\nconst vmlStyleMap = styleToKeyMap;\n\nfunction stringifyDocumentBackground(opts: DocumentBackgroundOptions, ctx: BodyContext): string {\n const attrs: string[] = [];\n if (opts.color !== undefined) attrs.push(`w:color=\"${hexColorValue(opts.color)}\"`);\n if (opts.themeColor !== undefined) attrs.push(`w:themeColor=\"${opts.themeColor}\"`);\n if (opts.themeShade !== undefined)\n attrs.push(`w:themeShade=\"${uCharHexNumber(opts.themeShade)}\"`);\n if (opts.themeTint !== undefined) attrs.push(`w:themeTint=\"${uCharHexNumber(opts.themeTint)}\"`);\n const attrStr = attrs.join(\" \");\n\n if (opts.image) {\n const fileName = `${uniqueId()}.${opts.image.type}`;\n const rawData = toUint8Array(opts.image.data) as Uint8Array;\n\n // Register media\n ctx.file.media.addImage(fileName, {\n type: opts.image.type as \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\",\n data: rawData,\n fileName,\n transformation: { emus: { x: 0, y: 0 }, pixels: { x: 0, y: 0 } },\n });\n\n const vmlBg = `<v:background id=\"_x0000_s1025\"><v:fill r:id=\"{${fileName}}\" o:title=\"${fileName}\" recolor=\"t\" type=\"frame\"/></v:background>`;\n return `<w:background ${attrStr}>${vmlBg}</w:background>`;\n }\n\n return `<w:background ${attrStr}/>`;\n}\n\n// ── Textbox (pure function, no XmlComponent) ──\n\nfunction stringifyTextbox(\n opts: Omit<ParagraphOptions, \"style\" | \"children\"> & {\n style?: VmlShapeStyle;\n children?: SectionChild[];\n },\n ctx: BodyContext,\n): string {\n // Destructure to separate VML style/children from paragraph properties\n const { style, children, ...paraOpts } = opts;\n const props = stringifyParagraphProperties(paraOpts);\n const pPrXml = props.xml ?? \"\";\n\n // VML shape style string\n const styleStr = style\n ? Object.entries(style)\n .map(([k, v]) => `${vmlStyleMap[k as keyof VmlShapeStyle]}:${v}`)\n .join(\";\")\n : undefined;\n\n // Shape attributes\n const shapeAttrs: string[] = [`id=\"_x0000_s${uniqueId()}\"`, `type=\"#_x0000_t202\"`];\n if (styleStr) shapeAttrs.push(`style=\"${styleStr}\"`);\n\n // Textbox content — serialize children via stringifyBodyChild\n const contentParts: string[] = [];\n if (children) {\n for (const c of children) {\n contentParts.push(stringifyBodyChild(c, ctx));\n }\n }\n const txbxContent = contentParts.join(\"\");\n\n const vmlTextbox = `<v:textbox style=\"mso-fit-shape-to-text:t;\" insetmode=\"auto\"><w:txbxContent>${txbxContent}</w:txbxContent></v:textbox>`;\n const vshape = `<v:shape ${shapeAttrs.join(\" \")}>${vmlTextbox}</v:shape>`;\n\n return `<w:p>${pPrXml}<w:pict>${vshape}</w:pict></w:p>`;\n}\n\n// ── Document body ──\n\n/** Document-level namespace string (cached). */\nconst DOC_NS =\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ' +\n 'xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" ' +\n 'xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" ' +\n 'xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" ' +\n 'xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" ' +\n 'xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" ' +\n 'xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" ' +\n 'xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" ' +\n 'xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" ' +\n 'xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" ' +\n 'xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" ' +\n 'xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" ' +\n 'xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" ' +\n 'xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" ' +\n 'xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" ' +\n 'xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" ' +\n 'xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\"';\n\n/**\n * Stringify the complete document.xml from context data.\n *\n * This is the pure JSON path — iterates raw section children via\n * `stringifyBodyChild()` while reusing existing SectionProperties\n * instances for sectPr XML (which are already created with correct\n * header/footer references).\n *\n * Produces the complete `<w:document>` element including namespaces,\n * background, body content with interleaved section properties.\n */\nexport function stringifyDocumentXml(ctx: DocxWriteContext, docCtx: BodyContext): string {\n const sections = ctx._options.sections;\n const bodySections = ctx.sectionProperties;\n const parts: string[] = [];\n\n // <w:document> open tag\n parts.push(`<w:document ${DOC_NS} mc:Ignorable=\"w14 w15 wp14\">`);\n\n // Background (if any)\n if (ctx._options.background) {\n parts.push(stringifyDocumentBackground(ctx._options.background, docCtx));\n }\n\n // <w:body>\n const bodyParts: string[] = [];\n\n for (let si = 0; si < sections.length; si++) {\n const section = sections[si];\n\n // Serialize section children using stringifyBodyChild()\n if (section.children) {\n for (const child of section.children) {\n bodyParts.push(stringifyBodyChild(child, docCtx));\n }\n }\n\n // Section properties — pure function, no XmlComponent instance\n const sectPrOpts = bodySections[si];\n if (sectPrOpts) {\n const sectPrXml = sectionPropertiesDesc.stringify(sectPrOpts, docCtx) ?? \"\";\n if (si < sections.length - 1) {\n // Non-last section: embed sectPr in a paragraph's pPr\n bodyParts.push(`<w:p><w:pPr>${sectPrXml}</w:pPr></w:p>`);\n } else {\n // Last section: body-level sectPr\n bodyParts.push(sectPrXml);\n }\n }\n }\n\n parts.push(`<w:body>${bodyParts.join(\"\")}</w:body>`);\n parts.push(\"</w:document>\");\n\n return parts.join(\"\");\n}\n\n// ────────────────────────────────────────────────────────────────────────────────\n// Parse (XML → JSON options)\n// ────────────────────────────────────────────────────────────────────────────────\n\nconst HEADING_MAP: Record<string, string> = {\n Heading1: HeadingLevel.HEADING_1,\n Heading2: HeadingLevel.HEADING_2,\n Heading3: HeadingLevel.HEADING_3,\n Heading4: HeadingLevel.HEADING_4,\n Heading5: HeadingLevel.HEADING_5,\n Heading6: HeadingLevel.HEADING_6,\n Title: HeadingLevel.TITLE,\n};\n\n/** Valid w:spacing/@w:lineRule values (ST_LineSpacingRule). */\nconst LINE_RULES = Object.values(LineRuleType) as readonly string[];\n/** Valid border @w:val values (ST_Border). */\nconst BORDER_STYLES = Object.values(BorderStyle) as readonly string[];\n/** Valid border @w:themeColor values (ST_ThemeColor). */\nconst THEME_COLORS = Object.values(ThemeColor) as readonly string[];\n\n/**\n * Reverse of inline.ts's deleted-page-number field map: maps a w:delInstrText\n * field code to the PageNumber placeholder a deletion run uses on the stringify\n * side, so deleted page-number fields round-trip instead of being dropped.\n */\nconst DELETED_PAGE_FIELD: Record<string, string> = {\n PAGE: \"CURRENT\",\n NUMPAGES: \"TOTAL_PAGES\",\n SECTIONPAGES: \"TOTAL_PAGES_IN_SECTION\",\n};\n\n/**\n * Parse w:pPr element into paragraph properties (without children).\n */\nexport function parseParagraphProperties(\n el: Element,\n ctx: DocxReadContext,\n): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n\n // Style / heading\n const pStyle = findChild(el, \"w:pStyle\");\n if (pStyle) {\n const styleVal = attr(pStyle, \"w:val\");\n if (styleVal) {\n if (HEADING_MAP[styleVal]) {\n opts.heading = HEADING_MAP[styleVal];\n } else {\n opts.style = styleVal;\n }\n }\n }\n\n // Alignment\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 // Spacing\n const spacing = findChild(el, \"w:spacing\");\n if (spacing) {\n const sp: SpacingProperties = {};\n const before = attrNum(spacing, \"w:before\");\n if (before !== undefined) sp.before = before;\n const after = attrNum(spacing, \"w:after\");\n if (after !== undefined) sp.after = after;\n const line = attrNum(spacing, \"w:line\");\n if (line !== undefined) sp.line = line;\n const lineRule = attr(spacing, \"w:lineRule\");\n if (lineRule && (LINE_RULES as readonly string[]).includes(lineRule)) {\n sp.lineRule = lineRule as SpacingProperties[\"lineRule\"];\n }\n const beforeAutoSpacing = attrBool(spacing, \"w:beforeAutospacing\");\n if (beforeAutoSpacing !== undefined) sp.beforeAutoSpacing = beforeAutoSpacing;\n const afterAutoSpacing = attrBool(spacing, \"w:afterAutospacing\");\n if (afterAutoSpacing !== undefined) sp.afterAutoSpacing = afterAutoSpacing;\n const beforeLines = attrNum(spacing, \"w:beforeLines\");\n if (beforeLines !== undefined) sp.beforeLines = beforeLines;\n const afterLines = attrNum(spacing, \"w:afterLines\");\n if (afterLines !== undefined) sp.afterLines = afterLines;\n if (Object.keys(sp).length > 0) opts.spacing = sp;\n }\n\n // Indent\n const ind = findChild(el, \"w:ind\");\n if (ind) {\n const indentObj: IndentAttributesProperties = {};\n const left = attrNum(ind, \"w:left\");\n if (left !== undefined) indentObj.left = left;\n const leftChars = attrNum(ind, \"w:leftChars\");\n if (leftChars !== undefined) indentObj.leftChars = leftChars;\n const right = attrNum(ind, \"w:right\");\n if (right !== undefined) indentObj.right = right;\n const rightChars = attrNum(ind, \"w:rightChars\");\n if (rightChars !== undefined) indentObj.rightChars = rightChars;\n const start = attrNum(ind, \"w:start\");\n if (start !== undefined) indentObj.start = start;\n const startChars = attrNum(ind, \"w:startChars\");\n if (startChars !== undefined) indentObj.startChars = startChars;\n const end = attrNum(ind, \"w:end\");\n if (end !== undefined) indentObj.end = end;\n const endChars = attrNum(ind, \"w:endChars\");\n if (endChars !== undefined) indentObj.endChars = endChars;\n const hanging = attrNum(ind, \"w:hanging\");\n if (hanging !== undefined) indentObj.hanging = hanging;\n const hangingChars = attrNum(ind, \"w:hangingChars\");\n if (hangingChars !== undefined) indentObj.hangingChars = hangingChars;\n const firstLine = attrNum(ind, \"w:firstLine\");\n if (firstLine !== undefined) indentObj.firstLine = firstLine;\n const firstLineChars = attrNum(ind, \"w:firstLineChars\");\n if (firstLineChars !== undefined) indentObj.firstLineChars = firstLineChars;\n if (Object.keys(indentObj).length > 0) opts.indent = indentObj;\n }\n\n // Numbering (w:numPr)\n const numPr = findChild(el, \"w:numPr\");\n if (numPr) {\n const ilvl = findChild(numPr, \"w:ilvl\");\n const level = ilvl ? (attrNum(ilvl, \"w:val\") ?? 0) : 0;\n const numIdEl = findChild(numPr, \"w:numId\");\n const numId = numIdEl ? attr(numIdEl, \"w:val\") : undefined;\n if (numId !== undefined && ctx.numberingCache.size > 0) {\n const numEl = ctx.docx.numbering;\n if (numEl) {\n let abstractNumId: string | undefined;\n for (const child of numEl.elements ?? []) {\n if (child.name !== \"w:num\") continue;\n if (attr(child, \"w:numId\") === numId) {\n const absRef = findChild(child, \"w:abstractNumId\");\n abstractNumId = absRef ? attr(absRef, \"w:val\") : undefined;\n break;\n }\n }\n if (abstractNumId !== undefined) {\n opts.numbering = { reference: `list_${numId}`, level };\n } else {\n opts.bullet = { level };\n }\n } else {\n opts.bullet = { level };\n }\n } else {\n opts.bullet = { level };\n }\n }\n\n // Tab stops\n const tabs = findChild(el, \"w:tabs\");\n if (tabs) {\n const tabStops: Record<string, unknown>[] = [];\n for (const tab of tabs.elements ?? []) {\n if (tab.name !== \"w:tab\") continue;\n const tabObj: Record<string, unknown> = {};\n const pos = attrNum(tab, \"w:pos\");\n if (pos !== undefined) tabObj.position = pos;\n const val = attr(tab, \"w:val\");\n if (val) tabObj.type = val;\n const leader = attr(tab, \"w:leader\");\n if (leader) tabObj.leader = leader;\n tabStops.push(tabObj);\n }\n if (tabStops.length > 0) opts.tabStops = tabStops;\n }\n\n // On/off properties\n for (const [name, optKey] of [\n [\"w:keepNext\", \"keepNext\"],\n [\"w:keepLines\", \"keepLines\"],\n [\"w:pageBreakBefore\", \"pageBreakBefore\"],\n [\"w:widowControl\", \"widowControl\"],\n [\"w:suppressLineNumbers\", \"suppressLineNumbers\"],\n [\"w:contextualSpacing\", \"contextualSpacing\"],\n [\"w:bidi\", \"bidirectional\"],\n [\"w:wordWrap\", \"wordWrap\"],\n [\"w:suppressAutoHyphens\", \"suppressAutoHyphens\"],\n [\"w:adjustRightInd\", \"adjustRightInd\"],\n [\"w:snapToGrid\", \"snapToGrid\"],\n [\"w:mirrorIndents\", \"mirrorIndents\"],\n [\"w:kinsoku\", \"kinsoku\"],\n [\"w:topLinePunct\", \"topLinePunct\"],\n [\"w:autoSpaceDE\", \"autoSpaceDE\"],\n [\"w:autoSpaceDN\", \"autoSpaceEastAsianText\"],\n [\"w:overflowPunct\", \"overflowPunctuation\"],\n [\"w:suppressOverlap\", \"suppressOverlap\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n // Thematic break\n const pBdr = findChild(el, \"w:pBdr\");\n if (pBdr) {\n const border: BordersOptions = {};\n for (const side of [\"top\", \"bottom\", \"left\", \"right\", \"between\", \"bar\"] as const) {\n const sideEl = findChild(pBdr, `w:${side}`);\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 border[side] = sideOpts;\n }\n if (Object.keys(border).length > 0) opts.border = border;\n }\n\n // Shading\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n const shdObj: Record<string, unknown> = {};\n const fill = attr(shd, \"w:fill\");\n if (fill) shdObj.fill = fill;\n const color = attr(shd, \"w:color\");\n if (color) shdObj.color = color;\n const val = attr(shd, \"w:val\");\n if (val) shdObj.type = val;\n if (Object.keys(shdObj).length > 0) opts.shading = shdObj;\n }\n\n // Text alignment\n const textAlignment = findChild(el, \"w:textAlignment\");\n if (textAlignment) {\n const val = attr(textAlignment, \"w:val\");\n if (val) opts.textAlignment = val;\n }\n\n // Outline level\n const outlineLvl = findChild(el, \"w:outlineLvl\");\n if (outlineLvl) {\n const val = attrNum(outlineLvl, \"w:val\");\n if (val !== undefined) opts.outlineLevel = val;\n }\n\n // Run properties (paragraph-level defaults)\n const rPr = findChild(el, \"w:rPr\");\n if (rPr) {\n opts.run = parseRunProperties(rPr);\n }\n\n // Frame properties\n const framePr = findChild(el, \"w:framePr\");\n if (framePr) {\n const frame: Record<string, unknown> = {};\n for (const [attrName, optName] of [\n [\"w:dropCap\", \"dropCap\"],\n [\"w:lines\", \"lines\"],\n [\"w:wrap\", \"wrap\"],\n [\"w:vAnchor\", \"vAnchor\"],\n [\"w:hAnchor\", \"hAnchor\"],\n [\"w:x\", \"x\"],\n [\"w:y\", \"y\"],\n [\"w:hRule\", \"hRule\"],\n [\"w:hSpace\", \"hSpace\"],\n [\"w:vSpace\", \"vSpace\"],\n ] as const) {\n const val = attr(framePr, attrName);\n if (val !== undefined) frame[optName] = val;\n }\n // Alignment (xAlign/yAlign)\n const xAlign = attr(framePr, \"w:xAlign\");\n const yAlign = attr(framePr, \"w:yAlign\");\n if (xAlign || yAlign) {\n const alignment: Record<string, unknown> = {};\n if (xAlign) alignment.x = xAlign;\n if (yAlign) alignment.y = yAlign;\n frame.alignment = alignment;\n }\n // Anchor (hAnchor/vAnchor)\n const hAnchor = attr(framePr, \"w:hAnchor\");\n const vAnchor = attr(framePr, \"w:vAnchor\");\n if (hAnchor || vAnchor) {\n const anchor: Record<string, unknown> = {};\n if (hAnchor) anchor.horizontal = hAnchor;\n if (vAnchor) anchor.vertical = vAnchor;\n frame.anchor = anchor;\n }\n // Anchor lock\n const anchorLock = attrBool(framePr, \"w:anchorLock\");\n if (anchorLock !== undefined) frame.anchorLock = anchorLock;\n const w = attrNum(framePr, \"w:w\");\n if (w !== undefined) frame.width = w;\n const h = attrNum(framePr, \"w:h\");\n if (h !== undefined) frame.height = h;\n if (Object.keys(frame).length > 0) opts.frame = frame;\n }\n\n return opts;\n}\n\n/**\n * Concatenate `<w:t>` text in a run element.\n *\n * Used to capture a textInput form field's current value from the result run\n * (the runs between the `separate` and `end` fldChars). Only `<w:t>` is read —\n * `<w:tab>`/`<w:br>` in results are ignored as rare for user-entered text.\n */\nfunction collectRunText(el: Element): string {\n let text = \"\";\n for (const c of el.elements ?? []) {\n if (c.name === \"w:t\") text += textOf(c);\n }\n return text;\n}\n\n/** Concatenate `<w:t>` text across all `<w:r>` children of a container (rt/rubyBase). */\nfunction collectRunsText(el: Element): string {\n let text = \"\";\n for (const r of el.elements ?? []) {\n if (r.name === \"w:r\") text += collectRunText(r);\n }\n return text;\n}\n\n/**\n * Parse the inline children of a smartTag/customXml container (recursive).\n *\n * Handles runs and nested smartTag/customXml. Form fields, hyperlinks and\n * other paragraph-level constructs are rare inside these containers and are\n * not handled here.\n */\nfunction parseContainerChildren(el: Element, ctx: DocxReadContext): unknown[] {\n const children: unknown[] = [];\n for (const sub of el.elements ?? []) {\n switch (sub.name) {\n case \"w:r\": {\n const parsed = parseRun(sub, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null) children.push(runOpts);\n break;\n }\n case \"w:smartTag\":\n children.push({ smartTag: parseSmartTagInline(sub, ctx) });\n break;\n case \"w:customXml\":\n children.push({ customXml: parseCustomXmlInline(sub, ctx) });\n break;\n default:\n break;\n }\n }\n return children;\n}\n\n/** Parse a w:smartTag element into its ParagraphChild form. */\nfunction parseSmartTagInline(el: Element, ctx: DocxReadContext): Record<string, unknown> {\n const st: Record<string, unknown> = {};\n const element = attr(el, \"w:element\");\n if (element) st.element = element;\n const uri = attr(el, \"w:uri\");\n if (uri) st.uri = uri;\n const pr = findChild(el, \"w:smartTagPr\");\n if (pr) {\n const props: Array<{ uri?: string; name: string; val: string }> = [];\n for (const a of pr.elements ?? []) {\n if (a.name !== \"w:attr\") continue;\n const prop: { uri?: string; name: string; val: string } = {\n name: attr(a, \"w:name\") ?? \"\",\n val: attr(a, \"w:val\") ?? \"\",\n };\n const auri = attr(a, \"w:uri\");\n if (auri) prop.uri = auri;\n props.push(prop);\n }\n if (props.length > 0) st.properties = props;\n }\n const content = parseContainerChildren(el, ctx);\n if (content.length > 0) st.children = content;\n return st;\n}\n\n/** Parse an inline w:customXml element into its ParagraphChild form. */\nfunction parseCustomXmlInline(el: Element, ctx: DocxReadContext): Record<string, unknown> {\n const cx: Record<string, unknown> = {};\n const element = attr(el, \"w:element\");\n if (element) cx.element = element;\n const uri = attr(el, \"w:uri\");\n if (uri) cx.uri = uri;\n const pr = findChild(el, \"w:customXmlPr\");\n if (pr) {\n const parsed = parseCustomXmlPr(pr);\n if (parsed.placeholder !== undefined || parsed.attributes !== undefined) {\n cx.customXmlPr = parsed;\n }\n }\n const content = parseContainerChildren(el, ctx);\n if (content.length > 0) cx.children = content;\n return cx;\n}\n\n/** Parse a move-revision range start (w:moveFromRangeStart / w:moveToRangeStart). */\nfunction parseMoveRangeStart(\n el: Element,\n): { id: number; name?: string; author?: string; date?: string } | null {\n const id = attrNum(el, \"w:id\");\n if (id === undefined) return null;\n const m: { id: number; name?: string; author?: string; date?: string } = { id };\n const name = attr(el, \"w:name\");\n if (name !== undefined) m.name = name;\n const author = attr(el, \"w:author\");\n if (author !== undefined) m.author = author;\n const date = attr(el, \"w:date\");\n if (date !== undefined) m.date = date;\n return m;\n}\n\n/** Parse a customXml range start (Ins/Del/MoveFrom/MoveTo). */\nfunction parseCustomXmlRangeStart(\n el: Element,\n): { id: number; author?: string; date?: string } | null {\n const id = attrNum(el, \"w:id\");\n if (id === undefined) return null;\n const m: { id: number; author?: string; date?: string } = { id };\n const author = attr(el, \"w:author\");\n if (author !== undefined) m.author = author;\n const date = attr(el, \"w:date\");\n if (date !== undefined) m.date = date;\n return m;\n}\n\n/**\n * Parse a w:p element into ParagraphOptions.\n */\n/**\n * Parse run-level children shared by paragraphs and inline-SDT content.\n * Includes the field accumulator that collapses form/complex fields spanning\n * multiple w:r runs into a single child.\n */\nfunction parseRunLevelChildren(elements: Element[] | undefined, ctx: DocxReadContext): unknown[] {\n const childList: unknown[] = [];\n\n // Field accumulator: a field (form field OR plain complex field) spans\n // several w:r elements (begin fldChar → instrText → separate → result → end).\n // - Form fields (checkBox/ddList/textInput) carry w:ffData on the begin\n // fldChar; their state lives there, and only a textInput's result is\n // captured (as `value`).\n // - Plain complex fields (PAGE/DATE/TOC/HYPERLINK...) have no ffData; their\n // instrText + result are captured as a complexField child for round-trip.\n // The whole field collapses to a single child.\n let fieldKind: \"form\" | \"complex\" | null = null;\n let pendingFormField: FormFieldOptions | null = null;\n let pendingInstruction = \"\";\n let pendingResult = \"\";\n // True once the `separate` fldChar is seen: subsequent runs (up to `end`)\n // are the field's result.\n let collectingResult = false;\n\n for (const child of elements ?? []) {\n switch (child.name) {\n case \"w:pPr\":\n break;\n case \"w:r\": {\n // Field: fldChar markers + the instrText/result runs between them.\n const fldCharEl = findChild(child, \"w:fldChar\");\n if (fldCharEl) {\n const fctype = attr(fldCharEl, \"w:fldCharType\");\n if (fctype === \"begin\") {\n const ffDataEl = findChild(fldCharEl, \"w:ffData\");\n if (ffDataEl) {\n fieldKind = \"form\";\n pendingFormField = parseFormFieldData(ffDataEl);\n } else {\n fieldKind = \"complex\";\n pendingInstruction = \"\";\n pendingResult = \"\";\n }\n collectingResult = false;\n } else if (fctype === \"separate\") {\n collectingResult = true;\n } else if (fctype === \"end\" && fieldKind) {\n if (fieldKind === \"form\" && pendingFormField) {\n childList.push({ formField: pendingFormField });\n } else if (fieldKind === \"complex\") {\n const cf: { instruction: string; result?: string } = {\n instruction: pendingInstruction,\n };\n if (pendingResult) cf.result = pendingResult;\n childList.push({ complexField: cf });\n }\n fieldKind = null;\n pendingFormField = null;\n collectingResult = false;\n }\n break;\n }\n if (fieldKind) {\n if (fieldKind === \"complex\") {\n // Collect instrText (begin→separate) and result text (separate→end).\n if (collectingResult) {\n pendingResult += collectRunText(child);\n } else {\n const instrEl = findChild(child, \"w:instrText\");\n if (instrEl) pendingInstruction += textOf(instrEl);\n }\n } else if (collectingResult && pendingFormField?.textInput) {\n // Capture a textInput's current value; checkbox/dropdown results\n // are discarded (their state is in w:ffData).\n const text = collectRunText(child);\n if (text) {\n const ti = pendingFormField.textInput;\n ti.value = (ti.value ?? \"\") + text;\n }\n }\n break; // instrText / result — handled by field state above\n }\n\n const drawingEl = findChild(child, \"w:drawing\");\n if (drawingEl) {\n const drawingChild = parseDrawingRun(drawingEl, ctx);\n if (drawingChild) {\n childList.push(drawingChild);\n break;\n }\n }\n const parsed = parseRun(child, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null) childList.push(runOpts);\n break;\n }\n case \"w:hyperlink\": {\n const hl: Record<string, unknown> = {};\n const rId = attr(child, \"r:id\");\n if (rId) {\n const target = ctx.docx.partRefs.hyperlinks.get(rId);\n if (target) hl.link = target;\n }\n const anchor = attr(child, \"w:anchor\");\n if (anchor) hl.anchor = anchor;\n const tooltip = attr(child, \"w:tooltip\");\n if (tooltip) hl.tooltip = tooltip;\n\n const linkRuns: unknown[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:r\") {\n const parsed = parseRun(sub, ctx);\n const runOpts = parsedRunToOptions(parsed);\n linkRuns.push(runOpts);\n }\n }\n if (linkRuns.length > 0) {\n hl.children = linkRuns;\n childList.push({ hyperlink: hl });\n }\n break;\n }\n case \"w:bookmarkStart\": {\n const id = attrNum(child, \"w:id\");\n const name = attr(child, \"w:name\");\n if (id !== undefined && name) {\n childList.push({ bookmarkStart: { id, name } });\n }\n break;\n }\n case \"w:bookmarkEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ bookmarkEnd: id });\n break;\n }\n case \"w:commentRangeStart\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ commentRangeStart: id });\n break;\n }\n case \"w:commentRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ commentRangeEnd: id });\n break;\n }\n case \"w:commentReference\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ commentReference: id });\n break;\n }\n case \"m:oMath\": {\n const mathChildren = parseMathChildren(child);\n childList.push({ math: { children: mathChildren } });\n break;\n }\n case \"w:ins\": {\n const insRun = findChild(child, \"w:r\");\n if (insRun) {\n const parsed = parseRun(insRun, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\n childList.push({\n insertion: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n ...(runOpts as Record<string, unknown>),\n },\n });\n }\n }\n break;\n }\n case \"w:del\": {\n // Deleted page-number fields emit w:delInstrText (not w:instrText);\n // reverse inline.ts's field map so they round-trip as a children\n // placeholder instead of being dropped.\n let delFieldPlaceholder: string | undefined;\n for (const sub of child.elements ?? []) {\n if (sub.name !== \"w:r\") continue;\n const delInstrEl = findChild(sub, \"w:delInstrText\");\n if (delInstrEl) {\n delFieldPlaceholder = DELETED_PAGE_FIELD[(textOf(delInstrEl) ?? \"\").trim()];\n if (delFieldPlaceholder) break;\n }\n }\n if (delFieldPlaceholder) {\n childList.push({\n deletion: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n children: [delFieldPlaceholder],\n },\n });\n break;\n }\n const delRun = findChild(child, \"w:r\");\n if (delRun) {\n const parsed = parseRun(delRun, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\n childList.push({\n deletion: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n ...(runOpts as Record<string, unknown>),\n },\n });\n }\n }\n break;\n }\n case \"w:moveFrom\": {\n const runEl = findChild(child, \"w:r\");\n if (runEl) {\n const parsed = parseRun(runEl, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\n childList.push({\n movedFrom: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n ...(runOpts as Record<string, unknown>),\n },\n });\n }\n }\n break;\n }\n case \"w:moveTo\": {\n const runEl = findChild(child, \"w:r\");\n if (runEl) {\n const parsed = parseRun(runEl, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\n childList.push({\n movedTo: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n ...(runOpts as Record<string, unknown>),\n },\n });\n }\n }\n break;\n }\n case \"w:fldSimple\": {\n const instruction = attr(child, \"w:instr\");\n if (instruction) {\n const sf: { instruction: string; cachedValue?: string } = { instruction };\n // cachedValue: concatenate the result-run <w:t> text (one or more\n // <w:r> children between the fldSimple tags).\n let cachedValue = \"\";\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:r\") cachedValue += collectRunText(sub);\n }\n if (cachedValue) sf.cachedValue = cachedValue;\n childList.push({ simpleField: sf });\n }\n break;\n }\n case \"w:smartTag\": {\n const st = parseSmartTagInline(child, ctx);\n if (st.element) childList.push({ smartTag: st });\n break;\n }\n case \"w:customXml\": {\n const cx = parseCustomXmlInline(child, ctx);\n if (cx.element) childList.push({ customXml: cx });\n break;\n }\n // ── Bidirectional containers (reuse the smartTag/customXml child parser) ──\n case \"w:dir\": {\n const val = attr(child, \"w:val\");\n if (val) {\n const dir: Record<string, unknown> = { val };\n const content = parseContainerChildren(child, ctx);\n if (content.length > 0) dir.children = content;\n childList.push({ dir });\n }\n break;\n }\n case \"w:bdo\": {\n const val = attr(child, \"w:val\");\n if (val) {\n const bdo: Record<string, unknown> = { val };\n const content = parseContainerChildren(child, ctx);\n if (content.length > 0) bdo.children = content;\n childList.push({ bdo });\n }\n break;\n }\n // ── Ruby annotation (East Asian pronunciation guides) ──\n case \"w:ruby\": {\n const ruby: Record<string, unknown> = {};\n const pr = findChild(child, \"w:rubyPr\");\n if (pr) {\n const alignEl = findChild(pr, \"w:rubyAlign\");\n if (alignEl) {\n const v = attr(alignEl, \"w:val\");\n if (v) ruby.alignment = v;\n }\n // hps / hpsRaise / hpsBaseText are half-points; the API uses points.\n const hpsEl = findChild(pr, \"w:hps\");\n if (hpsEl) {\n const v = attrNum(hpsEl, \"w:val\");\n if (v !== undefined) ruby.fontSize = v / 2;\n }\n const hpsRaiseEl = findChild(pr, \"w:hpsRaise\");\n if (hpsRaiseEl) {\n const v = attrNum(hpsRaiseEl, \"w:val\");\n if (v !== undefined) ruby.raise = v / 2;\n }\n const hpsBaseEl = findChild(pr, \"w:hpsBaseText\");\n if (hpsBaseEl) {\n const v = attrNum(hpsBaseEl, \"w:val\");\n if (v !== undefined) ruby.baseFontSize = v / 2;\n }\n const lidEl = findChild(pr, \"w:lid\");\n if (lidEl) {\n const v = attr(lidEl, \"w:val\");\n if (v) ruby.languageId = v;\n }\n if (findChild(pr, \"w:dirty\")) ruby.dirty = true;\n }\n const rt = findChild(child, \"w:rt\");\n if (rt) ruby.text = collectRunsText(rt);\n const rubyBase = findChild(child, \"w:rubyBase\");\n if (rubyBase) ruby.base = collectRunsText(rubyBase);\n // text and base are required by CT_Ruby; drop if either is missing.\n if (ruby.text !== undefined && ruby.base !== undefined) {\n childList.push({ ruby });\n }\n break;\n }\n // ── Range markers: proof errors, positional tabs, permissions, revisions ──\n case \"w:proofErr\": {\n const type = attr(child, \"w:type\");\n if (type) childList.push({ proofErr: type });\n break;\n }\n case \"w:ptab\": {\n const alignment = attr(child, \"w:alignment\");\n const leader = attr(child, \"w:leader\");\n const relativeTo = attr(child, \"w:relativeTo\");\n if (alignment !== undefined && leader !== undefined && relativeTo !== undefined) {\n childList.push({ positionalTab: { alignment, leader, relativeTo } });\n }\n break;\n }\n case \"w:permStart\": {\n const id = attr(child, \"w:id\");\n if (id !== undefined) {\n const ps: Record<string, unknown> = { id };\n const ed = attr(child, \"w:ed\");\n if (ed !== undefined) ps.ed = ed;\n const editGroup = attr(child, \"w:edGrp\");\n if (editGroup !== undefined) ps.editGroup = editGroup;\n const colFirst = attrNum(child, \"w:colFirst\");\n if (colFirst !== undefined) ps.colFirst = colFirst;\n const colLast = attrNum(child, \"w:colLast\");\n if (colLast !== undefined) ps.colLast = colLast;\n childList.push({ permStart: ps });\n }\n break;\n }\n case \"w:permEnd\": {\n const id = attr(child, \"w:id\");\n if (id !== undefined) childList.push({ permEnd: id });\n break;\n }\n case \"w:moveFromRangeStart\": {\n const m = parseMoveRangeStart(child);\n if (m) childList.push({ moveFromRangeStart: m });\n break;\n }\n case \"w:moveFromRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ moveFromRangeEnd: id });\n break;\n }\n case \"w:moveToRangeStart\": {\n const m = parseMoveRangeStart(child);\n if (m) childList.push({ moveToRangeStart: m });\n break;\n }\n case \"w:moveToRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ moveToRangeEnd: id });\n break;\n }\n case \"w:customXmlInsRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlInsRangeStart: m });\n break;\n }\n case \"w:customXmlInsRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlInsRangeEnd: id });\n break;\n }\n case \"w:customXmlDelRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlDelRangeStart: m });\n break;\n }\n case \"w:customXmlDelRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlDelRangeEnd: id });\n break;\n }\n case \"w:customXmlMoveFromRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlMoveFromRangeStart: m });\n break;\n }\n case \"w:customXmlMoveFromRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlMoveFromRangeEnd: id });\n break;\n }\n case \"w:customXmlMoveToRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlMoveToRangeStart: m });\n break;\n }\n case \"w:customXmlMoveToRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlMoveToRangeEnd: id });\n break;\n }\n case \"w:sdt\": {\n const sdtPr = findChild(child, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtProperties(sdtPr) : {};\n const sdtEndPr = findChild(child, \"w:sdtEndPr\");\n const endProperties = sdtEndPr ? parseRunProperties(sdtEndPr) : undefined;\n const sdtContent = findChild(child, \"w:sdtContent\");\n const sdtChildren = parseRunLevelChildren(sdtContent?.elements, ctx);\n const sdt: { properties: unknown; children?: unknown[]; endProperties?: unknown } = {\n properties,\n };\n if (sdtChildren.length > 0) sdt.children = sdtChildren;\n if (endProperties) sdt.endProperties = endProperties;\n childList.push({ sdt });\n break;\n }\n default:\n break;\n }\n }\n\n return childList;\n}\n\nexport function parseParagraph(el: Element, ctx: DocxReadContext): ParagraphOptions {\n const opts: Record<string, unknown> = {};\n\n const pPr = findChild(el, \"w:pPr\");\n if (pPr) {\n Object.assign(opts, parseParagraphProperties(pPr, ctx));\n }\n\n const childList = parseRunLevelChildren(el.elements, ctx);\n\n // Simple text optimization\n if (childList.length > 0) {\n const allStrings = childList.every(\n (c) =>\n typeof c === \"object\" &&\n c !== null &&\n \"text\" in (c as Record<string, unknown>) &&\n Object.keys(c as Record<string, unknown>).length === 1,\n );\n if (allStrings) {\n const combined = childList.map((c) => (c as Record<string, unknown>).text as string).join(\"\");\n if (combined && Object.keys(opts).length === 0) {\n return combined as unknown as ParagraphOptions;\n }\n if (combined) {\n opts.text = combined;\n return opts as ParagraphOptions;\n }\n }\n\n opts.children = childList as (RunOptions | string)[];\n }\n\n return opts as ParagraphOptions;\n}\n","/**\n * Footnotes descriptor — produces word/footnotes.xml.\n *\n * Generates the complete `<w:footnotes>` element including:\n * - Separator footnote (id=-1)\n * - Continuation separator footnote (id=0)\n * - User footnotes with auto-injected footnoteRef in first paragraph\n *\n * Reference: http://officeopenxml.com/WPfootnotes.php, CT_Footnotes / CT_FtnEdn\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum } from \"@office-open/xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\n\nimport { parseParagraph } from \"../../body\";\nimport type { BodyContext, DocxReadContext } from \"../../context\";\n\n// ── Input ──\n\nexport interface FootnotesData {\n notes: Map<number, (ParagraphOptions | string)[]>;\n}\n\n// ── Constants ──\n\nconst NS =\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\n/** XML for the footnoteRef run — auto-injected at start of first paragraph. */\nconst FOOTNOTE_REF_RUN =\n '<w:r><w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr><w:footnoteRef/></w:r>';\n\n/** Separator footnote (id=-1). */\nconst SEPARATOR_FOOTNOTE =\n '<w:footnote w:type=\"separator\" w:id=\"-1\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:separator/></w:r>\" +\n \"</w:p>\" +\n \"</w:footnote>\";\n\n/** Continuation separator footnote (id=0). */\nconst CONTINUATION_SEPARATOR_FOOTNOTE =\n '<w:footnote w:type=\"continuationSeparator\" w:id=\"0\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:continuationSeparator/></w:r>\" +\n \"</w:p>\" +\n \"</w:footnote>\";\n\n// ── Descriptor ──\n\nexport const footnotesDesc: CustomDescriptor<FootnotesData, BodyContext> = {\n kind: \"custom\",\n\n stringify(data, ctx) {\n const parts: string[] = [\n `<w:footnotes ${NS} mc:Ignorable=\"w14 w15 wp14\">`,\n SEPARATOR_FOOTNOTE,\n CONTINUATION_SEPARATOR_FOOTNOTE,\n ];\n\n for (const [id, paragraphs] of data.notes) {\n parts.push(`<w:footnote w:id=\"${id}\">`);\n for (let i = 0; i < paragraphs.length; i++) {\n const pXml = stringifyParagraphInline(paragraphs[i], ctx);\n if (i === 0) {\n // Insert footnoteRef after <w:p> or <w:p ...>\n const openIdx = pXml.indexOf(\">\");\n if (openIdx !== -1) {\n parts.push(pXml.slice(0, openIdx + 1) + FOOTNOTE_REF_RUN + pXml.slice(openIdx + 1));\n } else {\n parts.push(pXml);\n }\n } else {\n parts.push(pXml);\n }\n }\n parts.push(\"</w:footnote>\");\n }\n\n parts.push(\"</w:footnotes>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const notes = new Map<number, (ParagraphOptions | string)[]>();\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:footnote\") continue;\n const id = attrNum(child, \"w:id\");\n if (id === undefined) continue;\n // Skip system footnotes (separator id=-1, continuationSeparator id=0)\n const type = attr(child, \"w:type\");\n if (type || id < 1) continue;\n\n const paragraphs: (ParagraphOptions | string)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:p\") {\n paragraphs.push(parseParagraph(sub, ctx as DocxReadContext));\n }\n }\n notes.set(id, paragraphs);\n }\n return { notes } as FootnotesData;\n },\n};\n","/**\n * Endnotes descriptor — produces word/endnotes.xml.\n *\n * Generates the complete `<w:endnotes>` element including:\n * - Separator endnote (id=-1)\n * - Continuation separator endnote (id=0)\n * - User endnotes with auto-injected endnoteRef in first paragraph\n *\n * Reference: http://officeopenxml.com/WPfootnotes.php, CT_Endnotes / CT_FtnEdn\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum } from \"@office-open/xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\n\nimport { parseParagraph } from \"../../body\";\nimport type { BodyContext, DocxReadContext } from \"../../context\";\n\n// ── Input ──\n\nexport interface EndnotesData {\n notes: Map<number, (ParagraphOptions | string)[]>;\n}\n\n// ── Constants ──\n\nconst NS =\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\n/** XML for the endnoteRef run — auto-injected at start of first paragraph. */\nconst ENDNOTE_REF_RUN =\n '<w:r><w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr><w:endnoteRef/></w:r>';\n\n/** Separator endnote (id=-1). */\nconst SEPARATOR_ENDNOTE =\n '<w:endnote w:type=\"separator\" w:id=\"-1\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:separator/></w:r>\" +\n \"</w:p>\" +\n \"</w:endnote>\";\n\n/** Continuation separator endnote (id=0). */\nconst CONTINUATION_SEPARATOR_ENDNOTE =\n '<w:endnote w:type=\"continuationSeparator\" w:id=\"0\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:continuationSeparator/></w:r>\" +\n \"</w:p>\" +\n \"</w:endnote>\";\n\n// ── Descriptor ──\n\nexport const endnotesDesc: CustomDescriptor<EndnotesData, BodyContext> = {\n kind: \"custom\",\n\n stringify(data, ctx) {\n const parts: string[] = [\n `<w:endnotes ${NS} mc:Ignorable=\"w14 w15 wp14\">`,\n SEPARATOR_ENDNOTE,\n CONTINUATION_SEPARATOR_ENDNOTE,\n ];\n\n for (const [id, paragraphs] of data.notes) {\n parts.push(`<w:endnote w:id=\"${id}\">`);\n for (let i = 0; i < paragraphs.length; i++) {\n const pXml = stringifyParagraphInline(paragraphs[i], ctx);\n if (i === 0) {\n // Insert endnoteRef after <w:p> or <w:p ...>\n const openIdx = pXml.indexOf(\">\");\n if (openIdx !== -1) {\n parts.push(pXml.slice(0, openIdx + 1) + ENDNOTE_REF_RUN + pXml.slice(openIdx + 1));\n } else {\n parts.push(pXml);\n }\n } else {\n parts.push(pXml);\n }\n }\n parts.push(\"</w:endnote>\");\n }\n\n parts.push(\"</w:endnotes>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const notes = new Map<number, (ParagraphOptions | string)[]>();\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:endnote\") continue;\n const id = attrNum(child, \"w:id\");\n if (id === undefined) continue;\n // Skip system endnotes (separator id=-1, continuationSeparator id=0)\n const type = attr(child, \"w:type\");\n if (type || id < 1) continue;\n\n const paragraphs: (ParagraphOptions | string)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:p\") {\n paragraphs.push(parseParagraph(sub, ctx as DocxReadContext));\n }\n }\n notes.set(id, paragraphs);\n }\n return { notes } as EndnotesData;\n },\n};\n","/**\n * Permission range markers for WordprocessingML document protection.\n *\n * These elements mark editable ranges within a protected document.\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_PermStart, CT_PermEnd\n *\n * @module\n */\n\n/**\n * Editing group values for permission ranges.\n *\n * Defines who can edit within a permission range.\n *\n * Reference: ISO/IEC 29500-4, ST_EdGrp\n */\nexport const EditGroupType = {\n NONE: \"none\",\n EVERYONE: \"everyone\",\n ADMINISTRATORS: \"administrators\",\n CONTRIBUTORS: \"contributors\",\n EDITORS: \"editors\",\n OWNERS: \"owners\",\n CURRENT: \"current\",\n} as const;\n\nexport type EditGroup = (typeof EditGroupType)[keyof typeof EditGroupType];\n\n/**\n * Options for creating a permission start marker.\n */\nexport interface PermStartOptions {\n /** Unique identifier for this permission range (typically a number) */\n id: string | number;\n /** Editing group that can edit this range */\n edGroup?: EditGroup;\n /** Individual user who can edit this range */\n ed?: string;\n /** First column this range covers (for table cells) */\n colFirst?: number;\n /** Last column this range covers (for table cells) */\n colLast?: number;\n}\n","/**\n * AltChunk collection module for managing alternative format content parts.\n *\n * @module\n */\n\n/**\n * Stores alternative format chunk data for later serialization by the compiler.\n */\nexport interface AltChunkData {\n /** Unique key for this alt chunk (e.g., relId) */\n key: string;\n /** Raw content data */\n data: Uint8Array;\n /** Part sub-path within word/ (e.g., \"afchunks/afchunk1.html\") */\n path: string;\n /** File extension (e.g., \"html\", \"rtf\", \"txt\") */\n extension: string;\n /** MIME content type (e.g., \"text/html\", \"application/rtf\") */\n contentType: string;\n}\n\n/**\n * Manages alternative format chunk parts in a document.\n *\n * Stores external content (HTML, RTF, plain text) that will be\n * serialized into separate parts in the DOCX package.\n */\nexport class AltChunkCollection {\n private map: Map<string, AltChunkData>;\n\n public constructor() {\n this.map = new Map<string, AltChunkData>();\n }\n\n public addAltChunk(key: string, data: AltChunkData): void {\n this.map.set(key, data);\n }\n\n public get array(): AltChunkData[] {\n return [...this.map.values()];\n }\n}\n","/**\n * Sub-document collection module for managing sub-document parts.\n *\n * @module\n */\n\n/**\n * Stores sub-document data for later serialization by the compiler.\n */\nexport interface SubDocData {\n /** Raw document data (.docx bytes) */\n data: Uint8Array;\n /** Part sub-path within word/ (e.g., \"subdocs/subdoc1.docx\") */\n path: string;\n}\n\n/**\n * Manages sub-document parts in a document.\n */\nexport class SubDocCollection {\n private map: Map<string, SubDocData>;\n\n public constructor() {\n this.map = new Map<string, SubDocData>();\n }\n\n public addSubDoc(key: string, data: SubDocData): void {\n this.map.set(key, data);\n }\n\n public get array(): SubDocData[] {\n return [...this.map.values()];\n }\n}\n","/**\n * Font module for WordprocessingML documents.\n *\n * Provides support for font definitions and embedded fonts.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_font-1.html\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nconst createStringElement = (name: string, value: string): string =>\n element(name, { \"w:val\": value });\n\n/**\n * Options for a font relationship (embedded font).\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_embedRegular-1.html\n *\n * @property id - Relationship to Part\n * @property fontKey - Embedded Font Obfuscation Key (GUID)\n * @property subsetted - Whether the embedded font is subsetted\n */\nexport interface FontRelationshipOptions {\n /** Relationship to Part */\n id: string;\n /** Embedded Font Obfuscation Key (GUID) */\n fontKey?: string;\n /** Whether the embedded font is subsetted */\n subsetted?: boolean;\n}\n\n/**\n * Character set constants for font definitions.\n * Maps character set names to their hexadecimal identifiers.\n *\n * @publicApi\n */\nexport const CharacterSet = {\n ANSI: \"00\",\n ARABIC: \"B2\",\n BALTIC: \"BA\",\n CHINESEBIG5: \"88\",\n DEFAULT: \"01\",\n EASTEUROPE: \"EE\",\n GB_2312: \"86\",\n GREEK: \"A1\",\n HANGUL: \"81\",\n HEBREW: \"B1\",\n JIS: \"80\",\n JOHAB: \"82\",\n MAC: \"4D\",\n OEM: \"FF\",\n RUSSIAN: \"CC\",\n SYMBOL: \"02\",\n THAI: \"DE\",\n TURKISH: \"A2\",\n VIETNAMESE: \"A3\",\n} as const;\n\n/**\n * Options for defining a font in the document.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_font-1.html\n *\n * @property name - Font name (required)\n * @property altName - Alternative font name\n * @property panose1 - PANOSE-1 classification\n * @property charset - Character set identifier\n * @property family - Font family\n * @property notTrueType - Whether this is not a TrueType font\n * @property pitch - Font pitch\n * @property sig - Font signature (Unicode and code page ranges)\n * @property embedRegular - Embedded regular font relationship\n * @property embedBold - Embedded bold font relationship\n * @property embedItalic - Embedded italic font relationship\n * @property embedBoldItalic - Embedded bold-italic font relationship\n */\nexport interface FontEntry {\n /** Font name (required) */\n name: string;\n /** Alternative font name */\n altName?: string;\n /** PANOSE-1 classification */\n panose1?: string;\n /** Character set identifier */\n charset?: (typeof CharacterSet)[keyof typeof CharacterSet];\n /** Font family */\n family?: string;\n /** Whether this is not a TrueType font */\n notTrueType?: boolean;\n /** Font pitch */\n pitch?: string;\n /** Font signature (Unicode and code page ranges) */\n sig?: {\n /** Unicode Subset Bitfield 0 */\n usb0: string;\n /** Unicode Subset Bitfield 1 */\n usb1: string;\n /** Unicode Subset Bitfield 2 */\n usb2: string;\n /** Unicode Subset Bitfield 3 */\n usb3: string;\n /** Code Page Bitfield 0 */\n csb0: string;\n /** Code Page Bitfield 1 */\n csb1: string;\n };\n /** Embedded regular font relationship */\n embedRegular?: FontRelationshipOptions;\n /** Embedded bold font relationship */\n embedBold?: FontRelationshipOptions;\n /** Embedded italic font relationship */\n embedItalic?: FontRelationshipOptions;\n /** Embedded bold-italic font relationship */\n embedBoldItalic?: FontRelationshipOptions;\n}\n\n/**\n * Creates a font relationship element for embedding fonts.\n */\nconst createFontRelationship = (\n { id, fontKey, subsetted }: FontRelationshipOptions,\n name: string,\n): string => {\n const attrs: Record<string, string | undefined> = { \"r:id\": id };\n if (fontKey) {\n attrs[\"w:fontKey\"] = `{${fontKey}}`;\n }\n const children = subsetted ? [`<w:subsetted/>`] : undefined;\n return element(name, attrs, children);\n};\n\n/**\n * Creates a font element with the specified options.\n *\n * This function builds a complete font definition including optional embedded font files,\n * font signature, character set, and other font properties.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_font-1.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Font\">\n * <xsd:sequence>\n * <xsd:element name=\"altName\" type=\"CT_String\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"panose1\" type=\"CT_Panose\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"charset\" type=\"CT_Charset\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"family\" type=\"CT_FontFamily\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"notTrueType\" type=\"CT_OnOff\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"pitch\" type=\"CT_Pitch\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"sig\" type=\"CT_FontSig\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"embedRegular\" type=\"CT_FontRel\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"embedBold\" type=\"CT_FontRel\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"embedItalic\" type=\"CT_FontRel\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"embedBoldItalic\" type=\"CT_FontRel\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"name\" type=\"s:ST_String\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * const font = createFont({\n * name: \"Arial\",\n * family: \"swiss\",\n * pitch: \"variable\",\n * charset: CharacterSet.ANSI\n * });\n * ```\n */\nexport const createFont = ({\n name,\n altName,\n panose1,\n charset,\n family,\n notTrueType,\n pitch,\n sig,\n embedRegular,\n embedBold,\n embedItalic,\n embedBoldItalic,\n}: FontEntry): string => {\n const children: string[] = [];\n\n // http://www.datypic.com/sc/ooxml/e-w_altName-1.html\n if (altName) children.push(createStringElement(\"w:altName\", altName));\n // http://www.datypic.com/sc/ooxml/e-w_panose1-1.html\n if (panose1) children.push(createStringElement(\"w:panose1\", panose1));\n // http://www.datypic.com/sc/ooxml/e-w_charset-1.html\n if (charset) children.push(createStringElement(\"w:charset\", charset));\n // http://www.datypic.com/sc/ooxml/e-w_family-1.html\n if (family) children.push(createStringElement(\"w:family\", family));\n // http://www.datypic.com/sc/ooxml/e-w_notTrueType-1.html\n if (notTrueType) children.push(`<w:notTrueType/>`);\n if (pitch) children.push(createStringElement(\"w:pitch\", pitch));\n // http://www.datypic.com/sc/ooxml/e-w_sig-1.html\n if (sig) {\n children.push(\n `<w:sig w:csb0=\"${sig.csb0}\" w:csb1=\"${sig.csb1}\" w:usb0=\"${sig.usb0}\" w:usb1=\"${sig.usb1}\" w:usb2=\"${sig.usb2}\" w:usb3=\"${sig.usb3}\"/>`,\n );\n }\n // http://www.datypic.com/sc/ooxml/e-w_embedRegular-1.html\n if (embedRegular) children.push(createFontRelationship(embedRegular, \"w:embedRegular\"));\n // http://www.datypic.com/sc/ooxml/e-w_embedBold-1.html\n if (embedBold) children.push(createFontRelationship(embedBold, \"w:embedBold\"));\n // http://www.datypic.com/sc/ooxml/e-w_embedItalic-1.html\n if (embedItalic) children.push(createFontRelationship(embedItalic, \"w:embedItalic\"));\n // http://www.datypic.com/sc/ooxml/e-w_embedBoldItalic-1.html\n if (embedBoldItalic) children.push(createFontRelationship(embedBoldItalic, \"w:embedBoldItalic\"));\n\n return element(\"w:font\", { \"w:name\": name }, children);\n};\n","/**\n * Font table descriptor — produces word/fontTable.xml.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_fonts.html, CT_FontsList\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, escapeXml, findChild } from \"@office-open/xml\";\nimport type { EmbeddedFontOptionsWithKey } from \"@parts/fonts/font-wrapper\";\n\n// ── Input ──\n\nexport interface FontTableInput {\n fonts: EmbeddedFontOptionsWithKey[];\n}\n\n// ── XML helpers ──\n\nconst NS =\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" ' +\n 'xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" ' +\n 'xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" ' +\n 'xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" ' +\n 'xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\"';\n\n/** Default font signature for regular embedded fonts. */\nconst DEFAULT_SIG = {\n usb0: \"E0002AFF\",\n usb1: \"C000247B\",\n usb2: \"00000009\",\n usb3: \"00000000\",\n csb0: \"000001FF\",\n csb1: \"00000000\",\n};\n\nfunction fontXml(font: EmbeddedFontOptionsWithKey, index: number): string {\n const parts: string[] = [`<w:font w:name=\"${escapeXml(font.name)}\">`];\n\n // Default charset, family, pitch, sig for regular embedded font\n if (font.characterSet) {\n parts.push(`<w:charset w:val=\"${escapeXml(font.characterSet)}\"/>`);\n }\n parts.push(`<w:family w:val=\"auto\"/>`);\n parts.push(`<w:pitch w:val=\"variable\"/>`);\n parts.push(\n `<w:sig w:usb0=\"${DEFAULT_SIG.usb0}\" w:usb1=\"${DEFAULT_SIG.usb1}\" ` +\n `w:usb2=\"${DEFAULT_SIG.usb2}\" w:usb3=\"${DEFAULT_SIG.usb3}\" ` +\n `w:csb0=\"${DEFAULT_SIG.csb0}\" w:csb1=\"${DEFAULT_SIG.csb1}\"/>`,\n );\n // Embedded regular font\n parts.push(`<w:embedRegular r:id=\"rId${index + 1}\" w:fontKey=\"{${font.fontKey}}\"/>`);\n\n parts.push(\"</w:font>\");\n return parts.join(\"\");\n}\n\n// ── Descriptor ──\n\nexport const fontTableDesc: CustomDescriptor<FontTableInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const parts: string[] = [\n `<w:fonts ${NS} mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh\">`,\n ];\n for (let i = 0; i < opts.fonts.length; i++) {\n parts.push(fontXml(opts.fonts[i], i));\n }\n parts.push(\"</w:fonts>\");\n return parts.join(\"\");\n },\n\n parse(el, _ctx) {\n const fonts: Record<string, unknown>[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:font\") continue;\n const font: Record<string, unknown> = {};\n const name = child.attributes?.[\"w:name\"];\n if (name) font.name = String(name);\n\n // charset → w:charset/@w:val\n const charsetEl = findChild(child, \"w:charset\");\n if (charsetEl) {\n const val = attr(charsetEl, \"w:val\");\n if (val) font.characterSet = val;\n }\n\n // family → w:family/@w:val\n const familyEl = findChild(child, \"w:family\");\n if (familyEl) {\n const val = attr(familyEl, \"w:val\");\n if (val) font.family = val;\n }\n\n // pitch → w:pitch/@w:val\n const pitchEl = findChild(child, \"w:pitch\");\n if (pitchEl) {\n const val = attr(pitchEl, \"w:val\");\n if (val) font.pitch = val;\n }\n\n // sig → w:sig attributes\n const sigEl = findChild(child, \"w:sig\");\n if (sigEl) {\n const sig: Record<string, string> = {};\n for (const key of [\"usb0\", \"usb1\", \"usb2\", \"usb3\", \"csb0\", \"csb1\"] as const) {\n const val = attr(sigEl, `w:${key}`);\n if (val) sig[key] = val;\n }\n if (Object.keys(sig).length > 0) font.sig = sig;\n }\n\n // fontKey → w:embedRegular/@w:fontKey (strip curly braces)\n for (const embedTag of [\n \"w:embedRegular\",\n \"w:embedBold\",\n \"w:embedItalic\",\n \"w:embedBoldItalic\",\n ] as const) {\n const embedEl = findChild(child, embedTag);\n if (embedEl) {\n const rawKey = attr(embedEl, \"w:fontKey\");\n if (rawKey) {\n // Strip wrapping curly braces: {{...}} → ...\n font.fontKey = rawKey.replace(/^\\{\\{|\\}\\}$/g, \"\").replace(/^\\{|\\}$/g, \"\");\n }\n break; // Use first embed element found\n }\n }\n\n fonts.push(font);\n }\n return { fonts } as unknown as FontTableInput;\n },\n};\n","/**\n * Bibliography module for WordprocessingML documents.\n *\n * Provides types for bibliography sources.\n * XML generation is handled by the descriptor pipeline (bibliographyDesc).\n *\n * Reference: ISO/IEC 29500-4, shared-bibliography.xsd, CT_Sources, CT_SourceType\n *\n * @module\n */\n\n/**\n * Options for a single bibliography source entry.\n *\n * Maps to CT_SourceType in the bibliography XSD schema.\n * All fields are optional — include only the relevant ones for each source type.\n *\n * @property type - Source type (Book, JournalArticle, ConferenceProceedings, etc.)\n * @property title - Title of the work\n * @property author - Author names (plain text, semicolon-separated)\n * @property year - Publication year\n * @property month - Publication month\n * @property day - Publication day\n * @property bookTitle - Title of the book (for book sections, articles in collections)\n * @property journal - Journal name (JournalName in XSD)\n * @property volume - Volume number\n * @property issue - Issue number\n * @property pages - Page range\n * @property publisher - Publisher name\n * @property city - City of publication\n * @property url - URL for internet sources\n * @property edition - Edition number or description\n * @property institution - Institution (for theses, reports)\n */\nexport interface SourceTypeOptions {\n type?: string;\n title?: string;\n author?: string;\n year?: string;\n month?: string;\n day?: string;\n bookTitle?: string;\n journal?: string;\n volume?: string;\n issue?: string;\n pages?: string;\n publisher?: string;\n city?: string;\n url?: string;\n edition?: string;\n institution?: string;\n}\n\n/**\n * Options for creating a bibliography container.\n *\n * @property sources - Array of bibliography source entries\n * @property styleName - Bibliography style name (e.g., \"APA\", \"Chicago\", \"IEEE\")\n */\nexport interface BibliographyOptions {\n sources: SourceTypeOptions[];\n styleName?: string;\n}\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { findChild, textOf } from \"@office-open/xml\";\n\nfunction escapeXml(s: string): string {\n return s\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\");\n}\n\nconst SOURCE_FIELDS: readonly (readonly [string, keyof SourceTypeOptions])[] = [\n [\"SourceType\", \"type\"],\n [\"Title\", \"title\"],\n [\"Author\", \"author\"],\n [\"Year\", \"year\"],\n [\"Month\", \"month\"],\n [\"Day\", \"day\"],\n [\"BookTitle\", \"bookTitle\"],\n [\"JournalName\", \"journal\"],\n [\"Volume\", \"volume\"],\n [\"Issue\", \"issue\"],\n [\"Pages\", \"pages\"],\n [\"Publisher\", \"publisher\"],\n [\"City\", \"city\"],\n [\"URL\", \"url\"],\n [\"Edition\", \"edition\"],\n [\"Institution\", \"institution\"],\n] as const;\n\nexport const bibliographyDesc: CustomDescriptor<BibliographyOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const attrParts: string[] = [\n 'xmlns:b=\"http://schemas.openxmlformats.org/officeDocument/2006/bibliography\"',\n ];\n if (opts.styleName !== undefined) {\n attrParts.push(`StyleName=\"${escapeXml(opts.styleName)}\"`);\n }\n\n const parts: string[] = [`<b:Sources ${attrParts.join(\" \")}>`];\n\n for (const source of opts.sources) {\n const sourceParts: string[] = [];\n for (const [tagName, key] of SOURCE_FIELDS) {\n const value = source[key];\n if (value !== undefined) {\n sourceParts.push(`<b:${tagName}>${escapeXml(value)}</b:${tagName}>`);\n }\n }\n parts.push(`<b:Source>${sourceParts.join(\"\")}</b:Source>`);\n }\n\n parts.push(\"</b:Sources>\");\n return parts.join(\"\");\n },\n\n parse(el, _ctx) {\n const opts: Record<string, unknown> = {};\n\n // StyleName attribute\n const styleName = el.attributes?.[\"StyleName\"];\n if (styleName) opts.styleName = styleName;\n\n // Parse b:Source children\n const sources: Record<string, unknown>[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"b:Source\") continue;\n const source: Record<string, unknown> = {};\n for (const [, key] of SOURCE_FIELDS) {\n const xmlChild = findChild(child, `b:${SOURCE_FIELDS.find((f) => f[1] === key)![0]}`);\n if (xmlChild) {\n const val = textOf(xmlChild);\n if (val) source[key] = val;\n }\n }\n sources.push(source);\n }\n opts.sources = sources;\n\n return opts as unknown as BibliographyOptions;\n },\n};\n","/**\n * Glossary document component — stores building block definitions.\n *\n * Generates word/glossary/document.xml containing Quick Parts entries\n * that appear in Word's Insert > Quick Parts gallery.\n *\n * @module\n */\n\nimport type { SectionChild } from \"@shared/section\";\n\n/** Gallery type for building blocks (ST_DocPartGallery) */\nexport const DocPartGallery = {\n PLACEHOLDER: \"placeholder\",\n DEFAULT: \"default\",\n DOC_PARTS: \"docParts\",\n COVER_PAGE: \"coverPg\",\n EQUATIONS: \"eq\",\n FOOTERS: \"ftrs\",\n HEADERS: \"hdrs\",\n PAGE_NUMBERS: \"pgNum\",\n TABLES: \"tbls\",\n WATERMARKS: \"watermarks\",\n AUTO_TEXT: \"autoTxt\",\n TEXT_BOX: \"txtBox\",\n PAGE_NUMBERS_TOP: \"pgNumT\",\n PAGE_NUMBERS_BOTTOM: \"pgNumB\",\n PAGE_NUMBERS_MARGIN: \"pgNumMargins\",\n TABLE_OF_CONTENTS: \"tblOfContents\",\n BIBLIOGRAPHY: \"bib\",\n CUSTOM_QUICK_PARTS: \"custQuickParts\",\n CUSTOM_COVER_PAGE: \"custCoverPg\",\n CUSTOM_EQUATIONS: \"custEq\",\n CUSTOM_FOOTERS: \"custFtrs\",\n CUSTOM_HEADERS: \"custHdrs\",\n CUSTOM_PAGE_NUMBERS: \"custPgNum\",\n CUSTOM_TABLES: \"custTbls\",\n CUSTOM_WATERMARKS: \"custWatermarks\",\n CUSTOM_AUTO_TEXT: \"custAutoTxt\",\n CUSTOM_TEXT_BOX: \"custTxtBox\",\n CUSTOM_PAGE_NUMBERS_TOP: \"custPgNumT\",\n CUSTOM_PAGE_NUMBERS_BOTTOM: \"custPgNumB\",\n CUSTOM_PAGE_NUMBERS_MARGIN: \"custPgNumMargins\",\n CUSTOM_TABLE_OF_CONTENTS: \"custTblOfContents\",\n CUSTOM_BIBLIOGRAPHY: \"custBib\",\n CUSTOM1: \"custom1\",\n CUSTOM2: \"custom2\",\n CUSTOM3: \"custom3\",\n CUSTOM4: \"custom4\",\n CUSTOM5: \"custom5\",\n} as const;\n\nexport type DocPartGallery = (typeof DocPartGallery)[keyof typeof DocPartGallery];\n\n/** Building block type (ST_DocPartType) */\nexport const DocPartType = {\n NONE: \"none\",\n NORMAL: \"normal\",\n AUTO_EXPAND: \"autoExp\",\n TOOLBAR: \"toolbar\",\n SPELLER: \"speller\",\n FORM_FIELD: \"formFld\",\n BUILDING_BLOCK_PLACEHOLDER: \"bbPlcHdr\",\n} as const;\n\nexport type DocPartType = (typeof DocPartType)[keyof typeof DocPartType];\n\n/** Building block behavior (ST_DocPartBehavior) */\nexport const DocPartBehavior = {\n CONTENT: \"content\",\n PARAGRAPH: \"p\",\n PAGE: \"pg\",\n} as const;\n\nexport type DocPartBehavior = (typeof DocPartBehavior)[keyof typeof DocPartBehavior];\n\n/** A single building block (CT_DocPart) */\nexport interface DocPartOptions {\n /** Building block name (required) */\n name: string;\n /** Gallery category (required) */\n gallery: DocPartGallery;\n /** Category name within the gallery */\n category?: string;\n /** Building block types */\n types?: DocPartType[];\n /** Whether all building block types are included (w:all attribute) */\n allTypes?: boolean;\n /** Insertion behaviors */\n behaviors?: DocPartBehavior[];\n /** Description */\n description?: string;\n /** GUID for this building block */\n guid?: string;\n /** Whether the name is decorated (built-in) */\n decorated?: boolean;\n /** Body content — paragraphs, tables, etc. */\n children: SectionChild[];\n}\n\n/** Glossary document options */\nexport interface GlossaryDocumentOptions {\n /** Building blocks */\n parts: DocPartOptions[];\n}\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, findChild } from \"@office-open/xml\";\n\nimport { parseParagraph } from \"../body\";\nimport type { BodyContext, DocxReadContext } from \"../context\";\n\nconst GLOSSARY_NS =\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\nfunction glossaryEscapeAttr(text: string): string {\n return text\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\");\n}\n\nfunction docPartPrXml(part: GlossaryDocumentOptions[\"parts\"][number]): string {\n const prParts: string[] = [];\n prParts.push(\n `<w:name w:val=\"${glossaryEscapeAttr(part.name)}\"${part.decorated ? ' w:decorated=\"1\"' : \"\"}/>`,\n );\n if (part.category || part.gallery) {\n const catParts: string[] = [];\n if (part.category) {\n catParts.push(`<w:name w:val=\"${glossaryEscapeAttr(part.category)}\"/>`);\n }\n catParts.push(`<w:gallery w:val=\"${part.gallery}\"/>`);\n prParts.push(`<w:category>${catParts.join(\"\")}</w:category>`);\n }\n if (part.types && part.types.length > 0) {\n const typeXml = part.types.map((t) => `<w:type w:val=\"${t}\"/>`).join(\"\");\n const allAttr = part.allTypes ? ' w:all=\"1\"' : \"\";\n prParts.push(`<w:types${allAttr}>${typeXml}</w:types>`);\n }\n if (part.behaviors && part.behaviors.length > 0) {\n const behaviorXml = part.behaviors.map((b) => `<w:behavior w:val=\"${b}\"/>`).join(\"\");\n prParts.push(`<w:behaviors>${behaviorXml}</w:behaviors>`);\n }\n if (part.description) {\n prParts.push(`<w:description w:val=\"${glossaryEscapeAttr(part.description)}\"/>`);\n }\n if (part.guid) {\n prParts.push(`<w:guid w:val=\"${glossaryEscapeAttr(part.guid)}\"/>`);\n }\n return `<w:docPartPr>${prParts.join(\"\")}</w:docPartPr>`;\n}\n\nexport const glossaryDesc: CustomDescriptor<GlossaryDocumentOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const partsXml = opts.parts\n .map((part) => {\n const bodyContent = ((part.children ?? []) as SectionChild[])\n .map((child) => ctx.stringifyChild(child, ctx))\n .join(\"\");\n\n return `<w:docPart>${docPartPrXml(part)}<w:docPartBody>${bodyContent}</w:docPartBody></w:docPart>`;\n })\n .join(\"\");\n\n return `<w:glossaryDocument ${GLOSSARY_NS}><w:docParts>${partsXml}</w:docParts></w:glossaryDocument>`;\n },\n\n parse(el, ctx) {\n const dctx = ctx as DocxReadContext;\n const parts: Record<string, unknown>[] = [];\n\n const docPartsEl = findChild(el, \"w:docParts\");\n if (!docPartsEl) return { parts } as unknown as GlossaryDocumentOptions;\n\n for (const docPart of docPartsEl.elements ?? []) {\n if (docPart.name !== \"w:docPart\") continue;\n const part: Record<string, unknown> = {};\n\n // Parse w:docPartPr\n const pr = findChild(docPart, \"w:docPartPr\");\n if (pr) {\n // name\n const name = findChild(pr, \"w:name\");\n if (name) {\n part.name = attr(name, \"w:val\") ?? \"\";\n const decorated = attr(name, \"w:decorated\");\n if (decorated === \"1\") part.decorated = true;\n }\n\n // category\n const category = findChild(pr, \"w:category\");\n if (category) {\n const catName = findChild(category, \"w:name\");\n if (catName) part.category = attr(catName, \"w:val\");\n const gallery = findChild(category, \"w:gallery\");\n if (gallery) part.gallery = attr(gallery, \"w:val\");\n }\n\n // types\n const types = findChild(pr, \"w:types\");\n if (types) {\n const typeList: string[] = [];\n for (const t of types.elements ?? []) {\n if (t.name === \"w:type\") {\n const val = attr(t, \"w:val\");\n if (val) typeList.push(val);\n }\n }\n if (typeList.length > 0) part.types = typeList;\n const allAttr = attr(types, \"w:all\");\n if (allAttr === \"1\") part.allTypes = true;\n }\n\n // behaviors\n const behaviors = findChild(pr, \"w:behaviors\");\n if (behaviors) {\n const behaviorList: string[] = [];\n for (const b of behaviors.elements ?? []) {\n if (b.name === \"w:behavior\") {\n const val = attr(b, \"w:val\");\n if (val) behaviorList.push(val);\n }\n }\n if (behaviorList.length > 0) part.behaviors = behaviorList;\n }\n\n // description\n const desc = findChild(pr, \"w:description\");\n if (desc) {\n const val = attr(desc, \"w:val\");\n if (val) part.description = val;\n }\n\n // guid\n const guid = findChild(pr, \"w:guid\");\n if (guid) {\n const val = attr(guid, \"w:val\");\n if (val) part.guid = val;\n }\n }\n\n // Parse w:docPartBody children\n const body = findChild(docPart, \"w:docPartBody\");\n if (body) {\n const childList: unknown[] = [];\n for (const sub of body.elements ?? []) {\n if (sub.name === \"w:p\") {\n childList.push({ paragraph: parseParagraph(sub, dctx) });\n }\n }\n if (childList.length > 0) part.children = childList;\n }\n\n parts.push(part);\n }\n\n return { parts } as unknown as GlossaryDocumentOptions;\n },\n};\n","/**\n * Comments descriptor — produces word/comments.xml.\n *\n * Stringifies pure JSON CommentsOptions into XML without creating\n * Comment/Comments class instances.\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum } from \"@office-open/xml\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { CommentsOptions, CommentOptions } from \"@parts/paragraph/run/comment-run\";\n\nimport { parseParagraph } from \"../body\";\nimport type { BodyContext } from \"../context\";\nimport type { DocxReadContext } from \"../context\";\nimport { stringifyParagraphInline } from \"./inline\";\n\n// ── XML helpers ──\n\nfunction escapeAttr(s: string): string {\n return s\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\");\n}\n\nconst COMMENTS_NS =\n 'xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" ' +\n 'xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" ' +\n 'xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" ' +\n 'xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" ' +\n 'xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" ' +\n 'xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" ' +\n 'xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" ' +\n 'xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" ' +\n 'xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" ' +\n 'xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" ' +\n 'xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" ' +\n 'xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" ' +\n 'xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" ' +\n 'xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" ' +\n 'xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" ' +\n 'xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\n// ── Comment stringification ──\n\nfunction stringifyComment(opts: CommentOptions, ctx: BodyContext): string {\n const dateStr =\n typeof opts.date === \"string\" ? opts.date : (opts.date ?? new Date()).toISOString();\n const attrs: string[] = [`w:id=\"${opts.id}\"`, `w:date=\"${escapeAttr(dateStr)}\"`];\n if (opts.author !== undefined) attrs.push(`w:author=\"${escapeAttr(opts.author)}\"`);\n if (opts.initials !== undefined) attrs.push(`w:initials=\"${escapeAttr(opts.initials)}\"`);\n\n const parts: string[] = [];\n for (const child of opts.children) {\n parts.push(stringifyParagraphInline(child as string | ParagraphOptions, ctx));\n }\n\n return `<w:comment ${attrs.join(\" \")}>${parts.join(\"\")}</w:comment>`;\n}\n\n// ── Descriptor ──\n\nexport const commentsDesc: CustomDescriptor<CommentsOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [`<w:comments ${COMMENTS_NS}>`];\n\n for (const child of opts.children) {\n parts.push(stringifyComment(child, ctx));\n }\n\n parts.push(\"</w:comments>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const comments: Record<string, unknown>[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:comment\") continue;\n const id = attrNum(child, \"w:id\");\n if (id === undefined) continue;\n const comment: Record<string, unknown> = { id };\n const date = attr(child, \"w:date\");\n if (date) comment.date = date;\n const author = attr(child, \"w:author\");\n if (author) comment.author = author;\n const initials = attr(child, \"w:initials\");\n if (initials) comment.initials = initials;\n\n const children: unknown[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:p\") {\n children.push(parseParagraph(sub, ctx as DocxReadContext));\n }\n }\n comment.children = children;\n comments.push(comment);\n }\n return { children: comments } as unknown as CommentsOptions;\n },\n};\n","/**\n * Content types descriptor — produces [Content_Types].xml.\n *\n * Reference: OPC, Content_Types.xsd\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\n\nexport interface ContentTypeDefault {\n extension: string;\n contentType: string;\n}\n\nexport interface ContentTypeOverride {\n partName: string;\n contentType: string;\n}\n\nexport interface ContentTypesInput {\n defaults: ContentTypeDefault[];\n overrides: ContentTypeOverride[];\n}\n\nfunction defaultXml(ext: string, ct: string): string {\n return `<Default Extension=\"${ext}\" ContentType=\"${ct}\"/>`;\n}\n\nfunction overrideXml(partName: string, ct: string): string {\n return `<Override PartName=\"${partName}\" ContentType=\"${ct}\"/>`;\n}\n\nexport const contentTypesDesc: CustomDescriptor<ContentTypesInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [\n '<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">',\n ];\n for (const d of opts.defaults) {\n p.push(defaultXml(d.extension, d.contentType));\n }\n for (const o of opts.overrides) {\n p.push(overrideXml(o.partName, o.contentType));\n }\n p.push(\"</Types>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const defaults: ContentTypeDefault[] = [];\n const overrides: ContentTypeOverride[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"Default\") {\n const ext = child.attributes?.[\"Extension\"];\n const ct = child.attributes?.[\"ContentType\"];\n if (ext && ct) defaults.push({ extension: String(ext), contentType: String(ct) });\n } else if (child.name === \"Override\") {\n const pn = child.attributes?.[\"PartName\"];\n const ct = child.attributes?.[\"ContentType\"];\n if (pn && ct) overrides.push({ partName: String(pn), contentType: String(ct) });\n }\n }\n return { defaults, overrides } as unknown as ContentTypesInput;\n },\n};\n\n/** Helper to build the standard DOCX content types with dynamic overrides. */\nexport function buildContentTypes(\n extras: {\n headerCount?: number;\n footerCount?: number;\n chartCount?: number;\n smartArtCount?: number;\n hasBibliography?: boolean;\n hasGlossary?: boolean;\n hasWebSettings?: boolean;\n altChunks?: { path: string; contentType: string }[];\n subDocs?: { path: string }[];\n } = {},\n): ContentTypesInput {\n const defaults: ContentTypeDefault[] = [\n { extension: \"png\", contentType: \"image/png\" },\n { extension: \"jpeg\", contentType: \"image/jpeg\" },\n { extension: \"jpg\", contentType: \"image/jpeg\" },\n { extension: \"bmp\", contentType: \"image/bmp\" },\n { extension: \"gif\", contentType: \"image/gif\" },\n { extension: \"tif\", contentType: \"image/tiff\" },\n { extension: \"tiff\", contentType: \"image/tiff\" },\n { extension: \"emf\", contentType: \"image/x-emf\" },\n { extension: \"wmf\", contentType: \"image/x-wmf\" },\n { extension: \"ico\", contentType: \"image/x-icon\" },\n { extension: \"svg\", contentType: \"image/svg+xml\" },\n { extension: \"rels\", contentType: \"application/vnd.openxmlformats-package.relationships+xml\" },\n { extension: \"xml\", contentType: \"application/xml\" },\n {\n extension: \"odttf\",\n contentType: \"application/vnd.openxmlformats-officedocument.obfuscatedFont\",\n },\n ];\n\n const overrides: ContentTypeOverride[] = [\n {\n partName: \"/word/document.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\",\n },\n {\n partName: \"/word/styles.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\",\n },\n {\n partName: \"/docProps/core.xml\",\n contentType: \"application/vnd.openxmlformats-package.core-properties+xml\",\n },\n {\n partName: \"/docProps/custom.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.custom-properties+xml\",\n },\n {\n partName: \"/docProps/app.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.extended-properties+xml\",\n },\n {\n partName: \"/word/numbering.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml\",\n },\n {\n partName: \"/word/footnotes.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml\",\n },\n {\n partName: \"/word/endnotes.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml\",\n },\n {\n partName: \"/word/settings.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\",\n },\n {\n partName: \"/word/comments.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml\",\n },\n {\n partName: \"/word/fontTable.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\",\n },\n ];\n\n for (let i = 1; i <= (extras.headerCount ?? 0); i++) {\n overrides.push({\n partName: `/word/header${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml\",\n });\n }\n for (let i = 1; i <= (extras.footerCount ?? 0); i++) {\n overrides.push({\n partName: `/word/footer${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml\",\n });\n }\n for (let i = 1; i <= (extras.chartCount ?? 0); i++) {\n overrides.push({\n partName: `/word/charts/chart${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\",\n });\n }\n for (let i = 1; i <= (extras.smartArtCount ?? 0); i++) {\n overrides.push({\n partName: `/word/diagrams/data${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml\",\n });\n overrides.push({\n partName: `/word/diagrams/layout${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml\",\n });\n overrides.push({\n partName: `/word/diagrams/quickStyle${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml\",\n });\n overrides.push({\n partName: `/word/diagrams/colors${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml\",\n });\n overrides.push({\n partName: `/word/diagrams/drawing${i}.xml`,\n contentType: \"application/vnd.ms-office.drawingml.diagramDrawing+xml\",\n });\n }\n if (extras.hasBibliography) {\n overrides.push({\n partName: \"/word/bibliography.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.bibliography+xml\",\n });\n }\n if (extras.hasGlossary) {\n overrides.push({\n partName: \"/word/glossary/document.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.glossary+xml\",\n });\n }\n if (extras.hasWebSettings) {\n overrides.push({\n partName: \"/word/webSettings.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\",\n });\n }\n for (const ac of extras.altChunks ?? []) {\n overrides.push({\n partName: ac.path.startsWith(\"/\") ? ac.path : `/${ac.path}`,\n contentType: ac.contentType,\n });\n }\n for (const sd of extras.subDocs ?? []) {\n overrides.push({\n partName: sd.path.startsWith(\"/\") ? sd.path : `/${sd.path}`,\n contentType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\",\n });\n }\n\n return { defaults, overrides };\n}\n","/**\n * Relationships descriptor — produces .rels XML files.\n *\n * Reference: OPC, Relationships.xsd\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml } from \"@office-open/xml\";\n\nexport interface RelationshipEntry {\n id: number | string;\n type: string;\n target: string;\n targetMode?: string;\n}\n\nexport interface RelationshipsInput {\n relationships: RelationshipEntry[];\n}\n\nexport const relationshipsDesc: CustomDescriptor<RelationshipsInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [\n '<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">',\n ];\n for (const rel of opts.relationships) {\n const targetModeAttr = rel.targetMode ? ` TargetMode=\"${escapeXml(rel.targetMode)}\"` : \"\";\n p.push(\n `<Relationship Id=\"rId${rel.id}\" Type=\"${escapeXml(rel.type)}\" Target=\"${escapeXml(rel.target)}\"${targetModeAttr}/>`,\n );\n }\n p.push(\"</Relationships>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const relationships: RelationshipEntry[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"Relationship\") continue;\n const id = child.attributes?.[\"Id\"];\n const type = child.attributes?.[\"Type\"];\n const target = child.attributes?.[\"Target\"];\n const targetMode = child.attributes?.[\"TargetMode\"];\n if (id && type && target) {\n const numId = String(id).replace(\"rId\", \"\");\n relationships.push({\n id: Number(numId) || id,\n type: String(type),\n target: String(target),\n targetMode: targetMode ? String(targetMode) : undefined,\n });\n }\n }\n return { relationships } as unknown as RelationshipsInput;\n },\n};\n","import type { BibliographyOptions } from \"@parts/bibliography\";\n/**\n * Core Properties module for WordprocessingML documents.\n *\n * Provides the DocumentOptions interface for document metadata.\n * XML generation is handled by the descriptor pipeline (corePropertiesDesc).\n *\n * Reference: ISO-IEC29500-4_2016 shared-documentPropertiesCore.xsd\n *\n * @module\n */\nimport type { ContentTypesInput } from \"@parts/contenttypes\";\nimport type { EmbeddedFontOptions } from \"@parts/fonts/font-table\";\nimport type { GlossaryDocumentOptions } from \"@parts/glossary-document\";\nimport type { CommentsOptions } from \"@parts/paragraph/run/comment-run\";\nimport type { HyphenationOptions } from \"@parts/settings\";\nimport type { CompatibilityOptions } from \"@parts/settings/compatibility\";\nimport type {\n DocumentProtectionOptions,\n SettingsOptions,\n WriteProtectionOptions,\n} from \"@parts/settings/settings\";\nimport type { SectionOptions } from \"@shared/section\";\n\nimport type { AppPropertiesOptions } from \"./app-properties\";\nimport type { CustomPropertyOptions } from \"./custom-properties\";\nimport type { DocumentBackgroundOptions } from \"./document\";\nimport type { NumberingOptions } from \"./numbering\";\nimport type { ParagraphOptions } from \"./paragraph\";\nimport type { StylesOptions } from \"./styles\";\nimport type { WebSettingsOptions } from \"./web-settings\";\n\n/**\n * Document-level feature toggles parsed from settings.xml.\n *\n * @property trackRevisions - Track changes\n * @property updateFields - Update fields on open\n * @property documentProtection - Document write protection\n */\nexport interface FeaturesOptions {\n trackRevisions?: boolean;\n updateFields?: boolean;\n documentProtection?: DocumentProtectionOptions;\n}\n\n/**\n * Options for configuring document properties.\n *\n * @property sections - Document section configurations\n * @property title - Document title\n * @property subject - Document subject\n * @property creator - Document creator/author\n * @property keywords - Document keywords for searchability\n * @property description - Document description\n * @property lastModifiedBy - User who last modified the document\n * @property revision - Revision number\n * @property externalStyles - External stylesheet reference\n * @property styles - Document styles configuration\n * @property numbering - Numbering configuration\n * @property comments - Document comments configuration\n * @property bibliography - Document bibliography sources\n * @property footnotes - Document footnotes\n * @property background - Document background settings\n * @property features - Document features like track changes\n * @property compatabilityModeVersion - Compatibility mode version\n * @property compatibility - Compatibility settings\n * @property customProperties - Custom document properties\n * @property evenAndOddHeaderAndFooters - Enable different headers/footers for even/odd pages\n * @property defaultTabStop - Default tab stop width\n * @property fonts - Font configurations\n * @property hyphenation - Hyphenation settings\n */\nexport interface DocumentOptions {\n sections: SectionOptions[];\n title?: string;\n subject?: string;\n creator?: string;\n keywords?: string;\n description?: string;\n lastModifiedBy?: string;\n revision?: number;\n externalStyles?: string;\n styles?: StylesOptions;\n numbering?: NumberingOptions;\n comments?: CommentsOptions;\n bibliography?: BibliographyOptions;\n footnotes?: Readonly<\n Record<\n string,\n {\n children: (ParagraphOptions | string)[];\n }\n >\n >;\n endnotes?: Readonly<\n Record<\n string,\n {\n children: (ParagraphOptions | string)[];\n }\n >\n >;\n background?: DocumentBackgroundOptions;\n features?: FeaturesOptions;\n compatabilityModeVersion?: number;\n compatibility?: CompatibilityOptions;\n customProperties?: CustomPropertyOptions[];\n evenAndOddHeaderAndFooters?: boolean;\n defaultTabStop?: number;\n fonts?: EmbeddedFontOptions[];\n hyphenation?: HyphenationOptions;\n /** Controls whether punctuation is compressed at line ends */\n characterSpacingControl?: \"compressPunctuation\" | \"doNotCompress\";\n /** Default document view mode */\n view?: \"none\" | \"print\" | \"outline\" | \"masterPages\" | \"normal\" | \"web\";\n /** Default zoom level (percentage) and type */\n zoom?: {\n percent?: number;\n val?: \"none\" | \"fullPage\" | \"bestFit\" | \"textFit\";\n };\n /** Write protection recommendation (not enforcement) */\n writeProtection?: WriteProtectionOptions;\n /** Whether to display the background shape in print layout */\n displayBackgroundShape?: boolean;\n /** Whether to embed TrueType fonts in the document */\n embedTrueTypeFonts?: boolean;\n /** Whether to embed system fonts in the document */\n embedSystemFonts?: boolean;\n /** Whether to save only a subset of the embedded fonts */\n saveSubsetFonts?: boolean;\n /** Document variables (key-value pairs stored in the document) */\n docVars?: { name: string; val: string }[];\n /** Theme color scheme remapping */\n colorSchemeMapping?: SettingsOptions[\"colorSchemeMapping\"];\n /** Mail merge configuration */\n mailMerge?: SettingsOptions[\"mailMerge\"];\n /** Glossary document — building blocks (Quick Parts) */\n glossary?: GlossaryDocumentOptions;\n /** Additional document settings passed through to the settings.xml part */\n settings?: SettingsOptions;\n /** Web settings for browser rendering (word/webSettings.xml) */\n webSettings?: WebSettingsOptions;\n /** Content types from [Content_Types].xml (parse path only) */\n contentTypes?: ContentTypesInput;\n /** Extended properties (docProps/app.xml) */\n appProperties?: AppPropertiesOptions;\n}\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml } from \"@office-open/xml\";\n\n/** Subset of DocumentOptions used for core properties XML. */\nexport interface CorePropertiesInput {\n title?: string;\n subject?: string;\n creator?: string;\n keywords?: string;\n description?: string;\n lastModifiedBy?: string;\n revision?: number;\n}\n\nexport const corePropertiesDesc: CustomDescriptor<CorePropertiesInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const now = new Date().toISOString();\n const p: string[] = [\n '<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\"' +\n ' xmlns:dc=\"http://purl.org/dc/elements/1.1/\"' +\n ' xmlns:dcterms=\"http://purl.org/dc/terms/\"' +\n ' xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\"' +\n ' xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">',\n ];\n if (opts.title) p.push(`<dc:title>${escapeXml(opts.title)}</dc:title>`);\n if (opts.subject) p.push(`<dc:subject>${escapeXml(opts.subject)}</dc:subject>`);\n if (opts.creator) p.push(`<dc:creator>${escapeXml(opts.creator)}</dc:creator>`);\n if (opts.keywords) p.push(`<cp:keywords>${escapeXml(opts.keywords)}</cp:keywords>`);\n if (opts.description) p.push(`<dc:description>${escapeXml(opts.description)}</dc:description>`);\n if (opts.lastModifiedBy)\n p.push(`<cp:lastModifiedBy>${escapeXml(opts.lastModifiedBy)}</cp:lastModifiedBy>`);\n if (opts.revision !== undefined) p.push(`<cp:revision>${opts.revision}</cp:revision>`);\n p.push(`<dcterms:created xsi:type=\"dcterms:W3CDTF\">${now}</dcterms:created>`);\n p.push(`<dcterms:modified xsi:type=\"dcterms:W3CDTF\">${now}</dcterms:modified>`);\n p.push(\"</cp:coreProperties>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: CorePropertiesInput = {};\n for (const child of el.elements ?? []) {\n if (typeof child.name !== \"string\") continue;\n const text = child.elements?.[0]?.text;\n if (typeof text !== \"string\") continue;\n switch (child.name) {\n case \"dc:title\":\n result.title = text;\n break;\n case \"dc:subject\":\n result.subject = text;\n break;\n case \"dc:creator\":\n result.creator = text;\n break;\n case \"cp:keywords\":\n result.keywords = text;\n break;\n case \"dc:description\":\n result.description = text;\n break;\n case \"cp:lastModifiedBy\":\n result.lastModifiedBy = text;\n break;\n case \"cp:revision\":\n result.revision = Number(text);\n break;\n }\n }\n return result;\n },\n};\n","/**\n * Custom Properties module for WordprocessingML documents.\n *\n * Provides the CustomPropertyOptions interface.\n * XML generation is handled by the descriptor pipeline (customPropertiesDesc).\n *\n * Reference: ISO-IEC29500-4_2016 shared-documentPropertiesCustom.xsd\n *\n * @module\n */\n\n/**\n * Options for creating a custom property.\n *\n * @property name - The property name\n * @property value - The property value (as string)\n */\nexport interface CustomPropertyOptions {\n /** The property name */\n name: string;\n /** The property value (as string) */\n value: string;\n}\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, escapeXml, textOf } from \"@office-open/xml\";\n\nexport interface CustomPropertiesInput {\n properties: CustomPropertyOptions[];\n}\n\nexport const customPropertiesDesc: CustomDescriptor<CustomPropertiesInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [\n '<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties\"' +\n ' xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">',\n ];\n let pid = 2;\n for (const prop of opts.properties) {\n p.push(\n `<property fmtid=\"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}\" pid=\"${pid}\" name=\"${escapeXml(prop.name)}\">` +\n `<vt:lpwstr>${escapeXml(prop.value)}</vt:lpwstr>` +\n `</property>`,\n );\n pid++;\n }\n p.push(\"</Properties>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const properties: CustomPropertyOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"property\") continue;\n const name = attr(child, \"name\");\n if (!name) continue;\n\n // Find the value element (vt:lpwstr, vt:lpstr, vt:i4, etc.)\n const valueEl = child.elements?.find((e) => e.name?.startsWith(\"vt:\"));\n const value = valueEl ? (textOf(valueEl) ?? \"\") : \"\";\n properties.push({ name, value });\n }\n return { properties } as unknown as CustomPropertiesInput;\n },\n};\n","/**\n * App (Extended) Properties module for WordprocessingML documents.\n *\n * Provides the AppPropertiesOptions interface and the appPropertiesDesc\n * descriptor for docProps/app.xml (CT_Properties).\n *\n * Reference: ISO-IEC29500-2_2016 shared-documentPropertiesExtended.xsd\n *\n * @module\n */\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml } from \"@office-open/xml\";\n\n/**\n * Options for docProps/app.xml extended properties (CT_Properties).\n *\n * Only the scalar (string/number/boolean) child elements are modelled.\n * Structured vector/blob elements (HeadingPairs, TitlesOfParts, HLinks,\n * DigSig, PresentationFormat) are intentionally omitted.\n *\n * Property order follows the CT_Properties xsd:all sequence so the\n * emitted XML matches the reference schema ordering.\n */\nexport interface AppPropertiesOptions {\n /** Template name */\n template?: string;\n /** Manager name */\n manager?: string;\n /** Company name */\n company?: string;\n /** Page count */\n pages?: number;\n /** Word count */\n words?: number;\n /** Character count */\n characters?: number;\n /** Line count */\n lines?: number;\n /** Paragraph count */\n paragraphs?: number;\n /** Notes count */\n notes?: number;\n /** Slides count */\n slides?: number;\n /** Total editing time (minutes) */\n totalTime?: number;\n /** Hidden slides count */\n hiddenSlides?: number;\n /** Multimedia clips count */\n mmClips?: number;\n /** Characters including spaces */\n charactersWithSpaces?: number;\n /** Document security level */\n docSecurity?: number;\n /** Hyperlink base URL */\n hyperlinkBase?: string;\n /** Application name */\n application?: string;\n /** Application version */\n appVersion?: string;\n /** Whether the document is scaled/cropped */\n scaleCrop?: boolean;\n /** Whether links are up to date */\n linksUpToDate?: boolean;\n /** Whether the document is shared */\n sharedDoc?: boolean;\n /** Whether hyperlinks changed */\n hyperlinksChanged?: boolean;\n}\n\n/** Subset of AppPropertiesOptions accepted by stringify. */\nexport type AppPropertiesInput = AppPropertiesOptions;\n\nexport const appPropertiesDesc: CustomDescriptor<AppPropertiesInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n // xsd:all is unordered, but emit in schema order for readability.\n const p: string[] = [\n '<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\"' +\n ' xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">',\n ];\n\n // Schema order: Template, Manager, Company, Pages, Words, Characters,\n // PresentationFormat, Lines, Paragraphs, Slides, Notes, TotalTime,\n // HiddenSlides, MMClips, ScaleCrop, HeadingPairs, TitlesOfParts,\n // LinksUpToDate, CharactersWithSpaces, SharedDoc, HyperlinkBase, HLinks,\n // HyperlinksChanged, DigSig, Application, AppVersion, DocSecurity.\n if (opts.template !== undefined) p.push(`<Template>${escapeXml(opts.template)}</Template>`);\n if (opts.manager !== undefined) p.push(`<Manager>${escapeXml(opts.manager)}</Manager>`);\n if (opts.company !== undefined) p.push(`<Company>${escapeXml(opts.company)}</Company>`);\n if (opts.pages !== undefined) p.push(`<Pages>${opts.pages}</Pages>`);\n if (opts.words !== undefined) p.push(`<Words>${opts.words}</Words>`);\n if (opts.characters !== undefined) p.push(`<Characters>${opts.characters}</Characters>`);\n if (opts.lines !== undefined) p.push(`<Lines>${opts.lines}</Lines>`);\n if (opts.paragraphs !== undefined) p.push(`<Paragraphs>${opts.paragraphs}</Paragraphs>`);\n if (opts.slides !== undefined) p.push(`<Slides>${opts.slides}</Slides>`);\n if (opts.notes !== undefined) p.push(`<Notes>${opts.notes}</Notes>`);\n if (opts.totalTime !== undefined) p.push(`<TotalTime>${opts.totalTime}</TotalTime>`);\n if (opts.hiddenSlides !== undefined)\n p.push(`<HiddenSlides>${opts.hiddenSlides}</HiddenSlides>`);\n if (opts.mmClips !== undefined) p.push(`<MMClips>${opts.mmClips}</MMClips>`);\n if (opts.scaleCrop !== undefined) p.push(`<ScaleCrop>${opts.scaleCrop ? 1 : 0}</ScaleCrop>`);\n if (opts.linksUpToDate !== undefined)\n p.push(`<LinksUpToDate>${opts.linksUpToDate ? 1 : 0}</LinksUpToDate>`);\n if (opts.charactersWithSpaces !== undefined)\n p.push(`<CharactersWithSpaces>${opts.charactersWithSpaces}</CharactersWithSpaces>`);\n if (opts.sharedDoc !== undefined) p.push(`<SharedDoc>${opts.sharedDoc ? 1 : 0}</SharedDoc>`);\n if (opts.hyperlinkBase !== undefined)\n p.push(`<HyperlinkBase>${escapeXml(opts.hyperlinkBase)}</HyperlinkBase>`);\n if (opts.hyperlinksChanged !== undefined)\n p.push(`<HyperlinksChanged>${opts.hyperlinksChanged ? 1 : 0}</HyperlinksChanged>`);\n if (opts.application !== undefined)\n p.push(`<Application>${escapeXml(opts.application)}</Application>`);\n if (opts.appVersion !== undefined)\n p.push(`<AppVersion>${escapeXml(opts.appVersion)}</AppVersion>`);\n if (opts.docSecurity !== undefined) p.push(`<DocSecurity>${opts.docSecurity}</DocSecurity>`);\n\n p.push(\"</Properties>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: AppPropertiesOptions = {};\n for (const child of el.elements ?? []) {\n if (typeof child.name !== \"string\") continue;\n const text = child.elements?.[0]?.text;\n switch (child.name) {\n case \"Template\":\n if (typeof text === \"string\") result.template = text;\n break;\n case \"Manager\":\n if (typeof text === \"string\") result.manager = text;\n break;\n case \"Company\":\n if (typeof text === \"string\") result.company = text;\n break;\n case \"Pages\":\n if (typeof text === \"string\") result.pages = Number(text);\n break;\n case \"Words\":\n if (typeof text === \"string\") result.words = Number(text);\n break;\n case \"Characters\":\n if (typeof text === \"string\") result.characters = Number(text);\n break;\n case \"Lines\":\n if (typeof text === \"string\") result.lines = Number(text);\n break;\n case \"Paragraphs\":\n if (typeof text === \"string\") result.paragraphs = Number(text);\n break;\n case \"Slides\":\n if (typeof text === \"string\") result.slides = Number(text);\n break;\n case \"Notes\":\n if (typeof text === \"string\") result.notes = Number(text);\n break;\n case \"TotalTime\":\n if (typeof text === \"string\") result.totalTime = Number(text);\n break;\n case \"HiddenSlides\":\n if (typeof text === \"string\") result.hiddenSlides = Number(text);\n break;\n case \"MMClips\":\n if (typeof text === \"string\") result.mmClips = Number(text);\n break;\n case \"ScaleCrop\":\n if (typeof text === \"string\") result.scaleCrop = text === \"1\" || text === \"true\";\n break;\n case \"LinksUpToDate\":\n if (typeof text === \"string\") result.linksUpToDate = text === \"1\" || text === \"true\";\n break;\n case \"CharactersWithSpaces\":\n if (typeof text === \"string\") result.charactersWithSpaces = Number(text);\n break;\n case \"SharedDoc\":\n if (typeof text === \"string\") result.sharedDoc = text === \"1\" || text === \"true\";\n break;\n case \"HyperlinkBase\":\n if (typeof text === \"string\") result.hyperlinkBase = text;\n break;\n case \"HyperlinksChanged\":\n if (typeof text === \"string\") result.hyperlinksChanged = text === \"1\" || text === \"true\";\n break;\n case \"Application\":\n if (typeof text === \"string\") result.application = text;\n break;\n case \"AppVersion\":\n if (typeof text === \"string\") result.appVersion = text;\n break;\n case \"DocSecurity\":\n if (typeof text === \"string\") result.docSecurity = Number(text);\n break;\n }\n }\n return result;\n },\n};\n","/**\n * Web Settings module for WordprocessingML documents.\n *\n * Provides types for web settings configuration.\n * XML generation is handled by the descriptor pipeline (webSettingsDesc).\n *\n * Reference: http://officeopenxml.com/WPwebSettings.php\n *\n * @module\n */\n\nimport type { FramesetOptions } from \"@parts/frameset\";\n\n/**\n * Border options for div elements.\n */\nexport interface DivBorderOptions {\n top?: { style: string; color?: string; size?: number };\n left?: { style: string; color?: string; size?: number };\n bottom?: { style: string; color?: string; size?: number };\n right?: { style: string; color?: string; size?: number };\n}\n\n/**\n * Options for a div element (CT_Div).\n */\nexport interface DivOptions {\n /** Unique div identifier (required by CT_Div/@id) */\n id: number;\n marginLeft: number;\n marginRight: number;\n marginTop: number;\n marginBottom: number;\n /** Mark as HTML blockquote element */\n blockQuote?: boolean;\n /** Mark as HTML body element */\n bodyDiv?: boolean;\n border?: DivBorderOptions;\n children?: DivOptions[];\n}\n\n/**\n * Screen size types for web settings target.\n */\nexport const TargetScreenSize = {\n SIZE_544X376: \"544x376\",\n SIZE_640X480: \"640x480\",\n SIZE_720X512: \"720x512\",\n SIZE_800X600: \"800x600\",\n SIZE_1024X768: \"1024x768\",\n SIZE_1152X882: \"1152x882\",\n SIZE_1152X900: \"1152x900\",\n SIZE_1280X1024: \"1280x1024\",\n SIZE_1600X1200: \"1600x1200\",\n SIZE_1800X1440: \"1800x1440\",\n SIZE_1920X1200: \"1920x1200\",\n} as const;\n\n/**\n * Options for web settings (CT_WebSettings).\n */\nexport interface WebSettingsOptions {\n /** Frameset definition for web layout */\n frameset?: FramesetOptions;\n /** Div elements for HTML div formatting */\n divs?: DivOptions[];\n /** Character encoding for web output */\n encoding?: string;\n /** Optimize document rendering for web browser */\n optimizeForBrowser?: boolean;\n /** Rely on VML for graphics display */\n relyOnVML?: boolean;\n /** Allow PNG image format in web output */\n allowPNG?: boolean;\n /** Do not rely on CSS for formatting */\n doNotRelyOnCSS?: boolean;\n /** Do not save as single web file */\n doNotSaveAsSingleFile?: boolean;\n /** Do not organize supporting files in folders */\n doNotOrganizeInFolder?: boolean;\n /** Do not use long file names for supporting files */\n doNotUseLongFileNames?: boolean;\n /** Pixels per inch for web output */\n pixelsPerInch?: number;\n /** Target screen size */\n targetScreenSz?: (typeof TargetScreenSize)[keyof typeof TargetScreenSize] | string;\n /** Save smart tags as XML */\n saveSmartTagsAsXml?: boolean;\n}\n\n// ── Descriptor ──\n\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 { FrameOptions, FramesetSplitbarOptions } from \"@parts/frameset\";\n\n/** Subset of WebSettingsOptions for descriptor stringify. */\nexport interface WebSettingsInput {\n frameset?: FramesetOptions;\n divs?: DivOptions[];\n encoding?: string;\n optimizeForBrowser?: boolean;\n relyOnVML?: boolean;\n allowPNG?: boolean;\n doNotRelyOnCSS?: boolean;\n doNotSaveAsSingleFile?: boolean;\n doNotOrganizeInFolder?: boolean;\n doNotUseLongFileNames?: boolean;\n pixelsPerInch?: number;\n targetScreenSz?: string;\n saveSmartTagsAsXml?: boolean;\n}\n\nconst WS_NS =\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\"';\n\nfunction wsOnOff(tag: string, val: boolean): string {\n return `<${tag} w:val=\"${val ? \"true\" : \"false\"}\"/>`;\n}\n\nfunction wsStringVal(tag: string, val: string): string {\n return `<${tag} w:val=\"${wsEscapeAttr(val)}\"/>`;\n}\n\nfunction wsNumVal(tag: string, val: number): string {\n return `<${tag} w:val=\"${val}\"/>`;\n}\n\nfunction wsEscapeAttr(s: string): string {\n return s\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\");\n}\n\n// ── Parse helpers (for descriptor parse path) ──\n\nfunction parseFramesetEl(el: Element): FramesetOptions {\n const opts: Record<string, unknown> = {};\n\n const sz = findChild(el, \"w:sz\");\n if (sz) {\n const val = attr(sz, \"w:val\");\n if (val) opts.size = val;\n }\n\n const splitbar = findChild(el, \"w:framesetSplitbar\");\n if (splitbar) opts.splitbar = parseSplitbarEl(splitbar);\n\n const layout = findChild(el, \"w:frameLayout\");\n if (layout) {\n const val = attr(layout, \"w:val\");\n if (val === \"rows\" || val === \"cols\") opts.layout = val;\n }\n\n const title = findChild(el, \"w:title\");\n if (title) {\n const val = attr(title, \"w:val\");\n if (val) opts.title = val;\n }\n\n const children: (FramesetOptions | FrameOptions)[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:frameset\") {\n children.push(parseFramesetEl(child));\n } else if (child.name === \"w:frame\") {\n children.push(parseFrameEl(child));\n }\n }\n if (children.length > 0) opts.children = children;\n\n return opts as unknown as FramesetOptions;\n}\n\nfunction parseSplitbarEl(el: Element): FramesetSplitbarOptions {\n const opts: Record<string, unknown> = {};\n\n const w = findChild(el, \"w:w\");\n if (w) {\n const val = attrNum(w, \"w:w\");\n if (val !== undefined) opts.width = val;\n }\n\n const color = findChild(el, \"w:color\");\n if (color) {\n const val = attr(color, \"w:val\");\n if (val) opts.color = val;\n }\n\n if (findChild(el, \"w:noBorder\")) opts.noBorder = true;\n if (findChild(el, \"w:flatBorders\")) opts.flatBorders = true;\n\n return opts as unknown as FramesetSplitbarOptions;\n}\n\nfunction parseFrameEl(el: Element): FrameOptions {\n const opts: Record<string, unknown> = {};\n\n const sz = findChild(el, \"w:sz\");\n if (sz) {\n const val = attr(sz, \"w:val\");\n if (val) opts.size = val;\n }\n\n const name = findChild(el, \"w:name\");\n if (name) {\n const val = attr(name, \"w:val\");\n if (val) opts.name = val;\n }\n\n const title = findChild(el, \"w:title\");\n if (title) {\n const val = attr(title, \"w:val\");\n if (val) opts.title = val;\n }\n\n const source = findChild(el, \"w:sourceFileName\");\n if (source) {\n const val = attr(source, \"r:id\");\n if (val) opts.sourceRId = val;\n }\n\n const marW = findChild(el, \"w:marW\");\n if (marW) {\n const val = attrNum(marW, \"w:val\");\n if (val !== undefined) opts.marginWidth = val;\n }\n\n const marH = findChild(el, \"w:marH\");\n if (marH) {\n const val = attrNum(marH, \"w:val\");\n if (val !== undefined) opts.marginHeight = val;\n }\n\n const scrollbar = findChild(el, \"w:scrollbar\");\n if (scrollbar) {\n const val = attr(scrollbar, \"w:val\");\n if (val === \"on\" || val === \"off\" || val === \"auto\") opts.scrollbar = val;\n }\n\n if (findChild(el, \"w:noResizeAllowed\")) opts.noResizeAllowed = true;\n if (findChild(el, \"w:linkedToFile\")) opts.linkedToFile = true;\n\n const longDesc = findChild(el, \"w:longDesc\");\n if (longDesc) {\n const val = attr(longDesc, \"r:id\");\n if (val) opts.longDescRId = val;\n }\n\n return opts as unknown as FrameOptions;\n}\n\nfunction parseDivsEl(el: Element): DivOptions[] {\n const result: DivOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:div\") {\n result.push(parseDivEl(child));\n }\n }\n return result;\n}\n\nfunction parseDivEl(el: Element): DivOptions {\n const id = attrNum(el, \"w:id\") ?? 0;\n const opts: Record<string, unknown> = { id };\n\n const marLeft = findChild(el, \"w:marLeft\");\n if (marLeft) {\n const val = attrNum(marLeft, \"w:val\");\n if (val !== undefined) opts.marginLeft = val;\n }\n\n const marRight = findChild(el, \"w:marRight\");\n if (marRight) {\n const val = attrNum(marRight, \"w:val\");\n if (val !== undefined) opts.marginRight = val;\n }\n\n const marTop = findChild(el, \"w:marTop\");\n if (marTop) {\n const val = attrNum(marTop, \"w:val\");\n if (val !== undefined) opts.marginTop = val;\n }\n\n const marBottom = findChild(el, \"w:marBottom\");\n if (marBottom) {\n const val = attrNum(marBottom, \"w:val\");\n if (val !== undefined) opts.marginBottom = val;\n }\n\n const blockQuote = findChild(el, \"w:blockQuote\");\n if (blockQuote) {\n const val = attr(blockQuote, \"w:val\");\n opts.blockQuote = val !== \"off\";\n }\n\n const bodyDiv = findChild(el, \"w:bodyDiv\");\n if (bodyDiv) {\n const val = attr(bodyDiv, \"w:val\");\n opts.bodyDiv = val !== \"off\";\n }\n\n const divBdr = findChild(el, \"w:divBdr\");\n if (divBdr) {\n opts.border = parseDivBorderEl(divBdr);\n }\n\n const divsChild = findChild(el, \"w:divsChild\");\n if (divsChild) {\n const children = parseDivsEl(divsChild);\n if (children.length > 0) opts.children = children;\n }\n\n return opts as unknown as DivOptions;\n}\n\nfunction parseDivBorderEl(el: Element): DivBorderOptions {\n const opts: Record<string, unknown> = {};\n\n for (const side of [\"top\", \"left\", \"bottom\", \"right\"] as const) {\n const sideEl = findChild(el, `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 opts[side] = b;\n }\n }\n\n return opts as unknown as DivBorderOptions;\n}\n\nfunction wsDivBorderXml(b: NonNullable<DivOptions[\"border\"]>): string {\n const parts: string[] = [\"<w:divBdr>\"];\n const sides: [string, NonNullable<DivOptions[\"border\"]>[\"top\"]][] = [\n [\"w:top\", b.top],\n [\"w:left\", b.left],\n [\"w:bottom\", b.bottom],\n [\"w:right\", b.right],\n ];\n for (const [tag, side] of sides) {\n if (!side) continue;\n const attrParts: string[] = [`w:val=\"${wsEscapeAttr(side.style)}\"`];\n if (side.color) attrParts.push(`w:color=\"${wsEscapeAttr(side.color)}\"`);\n if (side.size !== undefined) attrParts.push(`w:sz=\"${side.size}\"`);\n parts.push(`<${tag} ${attrParts.join(\" \")}/>`);\n }\n parts.push(\"</w:divBdr>\");\n return parts.join(\"\");\n}\n\nfunction wsDivXml(d: DivOptions): string {\n const parts: string[] = [`<w:div w:id=\"${d.id}\">`];\n if (d.blockQuote !== undefined)\n parts.push(wsStringVal(\"w:blockQuote\", d.blockQuote ? \"on\" : \"off\"));\n if (d.bodyDiv !== undefined) parts.push(wsStringVal(\"w:bodyDiv\", d.bodyDiv ? \"on\" : \"off\"));\n parts.push(wsNumVal(\"w:marLeft\", d.marginLeft));\n parts.push(wsNumVal(\"w:marRight\", d.marginRight));\n parts.push(wsNumVal(\"w:marTop\", d.marginTop));\n parts.push(wsNumVal(\"w:marBottom\", d.marginBottom));\n if (d.border) parts.push(wsDivBorderXml(d.border));\n if (d.children?.length) {\n parts.push(\"<w:divsChild>\");\n for (const child of d.children) parts.push(wsDivXml(child));\n parts.push(\"</w:divsChild>\");\n }\n parts.push(\"</w:div>\");\n return parts.join(\"\");\n}\n\nexport function framesetXml(fs: FramesetOptions): string {\n const parts: string[] = [\"<w:frameset>\"];\n if (fs.size !== undefined) parts.push(wsStringVal(\"w:sz\", fs.size));\n if (fs.splitbar) {\n parts.push(\"<w:framesetSplitbar>\");\n if (fs.splitbar.width !== undefined)\n parts.push(`<w:w w:w=\"${fs.splitbar.width}\" w:type=\"dxa\"/>`);\n if (fs.splitbar.color !== undefined) parts.push(wsStringVal(\"w:color\", fs.splitbar.color));\n if (fs.splitbar.noBorder) parts.push(\"<w:noBorder/>\");\n if (fs.splitbar.flatBorders) parts.push(\"<w:flatBorders/>\");\n parts.push(\"</w:framesetSplitbar>\");\n }\n if (fs.layout !== undefined) parts.push(`<w:frameLayout w:val=\"${fs.layout}\"/>`);\n if (fs.title !== undefined) parts.push(wsStringVal(\"w:title\", fs.title));\n if (fs.children) {\n for (const child of fs.children) {\n if (\"children\" in child || \"layout\" in child || \"splitbar\" in child) {\n parts.push(framesetXml(child as FramesetOptions));\n } else {\n parts.push(frameXml(child as FrameOptions));\n }\n }\n }\n parts.push(\"</w:frameset>\");\n return parts.join(\"\");\n}\n\nexport function frameXml(f: FrameOptions): string {\n const parts: string[] = [\"<w:frame>\"];\n if (f.size !== undefined) parts.push(wsStringVal(\"w:sz\", f.size));\n if (f.name !== undefined) parts.push(wsStringVal(\"w:name\", f.name));\n if (f.title !== undefined) parts.push(wsStringVal(\"w:title\", f.title));\n if (f.sourceRId !== undefined)\n parts.push(`<w:sourceFileName r:id=\"${wsEscapeAttr(f.sourceRId)}\"/>`);\n if (f.marginWidth !== undefined) parts.push(wsNumVal(\"w:marW\", f.marginWidth));\n if (f.marginHeight !== undefined) parts.push(wsNumVal(\"w:marH\", f.marginHeight));\n if (f.scrollbar !== undefined) parts.push(`<w:scrollbar w:val=\"${f.scrollbar}\"/>`);\n if (f.noResizeAllowed) parts.push(\"<w:noResizeAllowed/>\");\n if (f.linkedToFile) parts.push(\"<w:linkedToFile/>\");\n if (f.longDescRId !== undefined)\n parts.push(`<w:longDesc r:id=\"${wsEscapeAttr(f.longDescRId)}\"/>`);\n parts.push(\"</w:frame>\");\n return parts.join(\"\");\n}\n\nexport const webSettingsDesc: CustomDescriptor<WebSettingsInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [`<w:webSettings ${WS_NS}>`];\n\n if (opts.frameset !== undefined) p.push(framesetXml(opts.frameset));\n if (opts.divs?.length) {\n p.push(\"<w:divs>\");\n for (const d of opts.divs) p.push(wsDivXml(d));\n p.push(\"</w:divs>\");\n }\n if (opts.encoding !== undefined) p.push(wsStringVal(\"w:encoding\", opts.encoding));\n if (opts.optimizeForBrowser !== undefined)\n p.push(wsOnOff(\"w:optimizeForBrowser\", opts.optimizeForBrowser));\n if (opts.relyOnVML !== undefined) p.push(wsOnOff(\"w:relyOnVML\", opts.relyOnVML));\n if (opts.allowPNG !== undefined) p.push(wsOnOff(\"w:allowPNG\", opts.allowPNG));\n if (opts.doNotRelyOnCSS !== undefined) p.push(wsOnOff(\"w:doNotRelyOnCSS\", opts.doNotRelyOnCSS));\n if (opts.doNotSaveAsSingleFile !== undefined)\n p.push(wsOnOff(\"w:doNotSaveAsSingleFile\", opts.doNotSaveAsSingleFile));\n if (opts.doNotOrganizeInFolder !== undefined)\n p.push(wsOnOff(\"w:doNotOrganizeInFolder\", opts.doNotOrganizeInFolder));\n if (opts.doNotUseLongFileNames !== undefined)\n p.push(wsOnOff(\"w:doNotUseLongFileNames\", opts.doNotUseLongFileNames));\n if (opts.pixelsPerInch !== undefined) p.push(wsNumVal(\"w:pixelsPerInch\", opts.pixelsPerInch));\n if (opts.targetScreenSz !== undefined)\n p.push(wsStringVal(\"w:targetScreenSz\", opts.targetScreenSz));\n if (opts.saveSmartTagsAsXml !== undefined)\n p.push(wsOnOff(\"w:saveSmartTagsAsXml\", opts.saveSmartTagsAsXml));\n\n p.push(\"</w:webSettings>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const opts: Record<string, unknown> = {};\n\n // Frameset\n const frameset = findChild(el, \"w:frameset\");\n if (frameset) {\n opts.frameset = parseFramesetEl(frameset);\n }\n\n // Divs\n const divs = findChild(el, \"w:divs\");\n if (divs) {\n const parsed = parseDivsEl(divs);\n if (parsed.length > 0) opts.divs = parsed;\n }\n\n // Encoding\n const encoding = findChild(el, \"w:encoding\");\n if (encoding) {\n const val = attr(encoding, \"w:val\");\n if (val) opts.encoding = val;\n }\n\n // Boolean fields\n for (const [name, optKey] of [\n [\"w:optimizeForBrowser\", \"optimizeForBrowser\"],\n [\"w:relyOnVML\", \"relyOnVML\"],\n [\"w:allowPNG\", \"allowPNG\"],\n [\"w:doNotRelyOnCSS\", \"doNotRelyOnCSS\"],\n [\"w:doNotSaveAsSingleFile\", \"doNotSaveAsSingleFile\"],\n [\"w:doNotOrganizeInFolder\", \"doNotOrganizeInFolder\"],\n [\"w:doNotUseLongFileNames\", \"doNotUseLongFileNames\"],\n [\"w:saveSmartTagsAsXml\", \"saveSmartTagsAsXml\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n // Pixels per inch\n const ppi = findChild(el, \"w:pixelsPerInch\");\n if (ppi) {\n const val = attrNum(ppi, \"w:val\");\n if (val !== undefined) opts.pixelsPerInch = val;\n }\n\n // Target screen size\n const targetSz = findChild(el, \"w:targetScreenSz\");\n if (targetSz) {\n const val = attr(targetSz, \"w:val\");\n if (val) opts.targetScreenSz = val;\n }\n\n return opts as unknown as WebSettingsInput;\n },\n};\n","/**\n * External styles factory module for WordprocessingML documents.\n *\n * Parses styles from external XML and returns raw XML strings.\n * No XmlComponent dependency.\n *\n * Reference: http://officeopenxml.com/WPstyles.php\n *\n * @module\n */\nimport { js2xml, xml2js } from \"@office-open/xml\";\nimport type { Element as XMLElement } from \"@office-open/xml\";\n\nimport type { StylesOptions } from \"./styles\";\n\n/**\n * Factory for creating styles from external XML sources.\n *\n * Parses styles from XML (typically from a styles.xml file)\n * and returns raw XML strings for each style element.\n */\nexport class ExternalStylesFactory {\n /**\n * Creates new Styles based on the given XML data.\n *\n * Parses the styles XML and converts each child to a raw XML string.\n */\n public newInstance(xmlData: string): StylesOptions {\n const xmlObj = xml2js(xmlData, { compact: false }) as XMLElement;\n\n let stylesXmlElement: XMLElement | undefined;\n for (const xmlElm of xmlObj.elements || []) {\n if (xmlElm.name === \"w:styles\") {\n stylesXmlElement = xmlElm;\n }\n }\n\n if (stylesXmlElement === undefined) {\n return { importedStyles: [], initialAttributes: {} };\n }\n\n const stylesElements = stylesXmlElement.elements || [];\n\n return {\n importedStyles: stylesElements.map((childElm) => ({\n _raw: js2xml({ elements: [childElm] }),\n })),\n initialAttributes: (stylesXmlElement.attributes as Record<string, string>) ?? {},\n };\n }\n}\n","/**\n * DOCX compilation context.\n *\n * DocxWriteContext holds all mutable state needed during document compilation.\n * generateDocument() creates a DocxWriteContext internally.\n *\n * @module\n */\n\nimport { Relationships } from \"@office-open/core\";\nimport { ChartCollection } from \"@office-open/core/chart\";\nimport type { ReadContext, WriteContext } from \"@office-open/core/descriptor\";\nimport { SmartArtCollection } from \"@office-open/core/smartart\";\nimport type { Element } from \"@office-open/xml\";\nimport { AltChunkCollection } from \"@parts/alt-chunk/alt-chunk-collection\";\nimport type { DocumentOptions } from \"@parts/core-properties\";\nimport type { SectionPropertiesOptions } from \"@parts/document/body/section-properties/section-properties\";\nimport { FontWrapper } from \"@parts/fonts/font-wrapper\";\nimport type { GlossaryDocumentOptions } from \"@parts/glossary-document\";\nimport type { HeaderFooterEntry } from \"@parts/header-footer\";\nimport { Numbering } from \"@parts/numbering\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { SettingsOptions } from \"@parts/settings/settings\";\nimport { Styles } from \"@parts/styles\";\nimport { ExternalStylesFactory } from \"@parts/styles/external-styles-factory\";\nimport { DefaultStylesFactory } from \"@parts/styles/factory\";\nimport { SubDocCollection } from \"@parts/sub-doc/sub-doc-collection\";\nimport type { WebSettingsOptions } from \"@parts/web-settings\";\nimport { Media } from \"@shared/media\";\nimport type { SectionOptions } from \"@shared/section\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { DocxDocument } from \"./parse\";\n\n/** Interface for document view wrappers — provides relationships access. */\nexport interface ViewWrapper {\n relationships: Relationships;\n}\n\n// ── BodyContext ──\n\n/**\n * Context for body-level stringification.\n *\n * Pure JSON pipeline context — extends WriteContext for descriptor compatibility.\n * No dependency on XmlComponent Context (compile/ uses zero toXml calls).\n */\nexport interface BodyContext extends WriteContext {\n /** The root write context with all mutable document state. */\n fileData: DocxWriteContext;\n /** Alias for fileData — some descriptor internals access context.file. */\n file: DocxWriteContext;\n /** Current view wrapper for relationship access. */\n viewWrapper: { relationships: Relationships };\n /** Stringify a body-level child element — injected to break circular imports. */\n stringifyChild: (child: SectionChild, ctx: BodyContext) => string;\n}\n\n// ── DocxWriteContext ──\n\nexport class DocxWriteContext implements WriteContext {\n private _currentRelationshipId = 1;\n\n // --- Accessed by XmlComponent via context.file.* during toXml() ---\n declare public document: { relationships: Relationships };\n declare public numbering: Numbering;\n declare public media: Media;\n declare public charts: ChartCollection;\n declare public smartArts: SmartArtCollection;\n declare public altChunks: AltChunkCollection;\n declare public subDocs: SubDocCollection;\n declare public comments: { relationships: Relationships };\n declare public footNotes: {\n relationships: Relationships;\n notes: Map<number, (ParagraphOptions | string)[]>;\n };\n declare public endnotes: {\n relationships: Relationships;\n notes: Map<number, (ParagraphOptions | string)[]>;\n };\n\n // --- Additional state used by the compiler ---\n declare public fileRelationships: Relationships;\n declare public _settingsOptions: SettingsOptions;\n declare public styles: Styles;\n declare public fontTable: FontWrapper;\n declare public glossaryOptions: GlossaryDocumentOptions | undefined;\n declare public webSettings: WebSettingsOptions | undefined;\n\n // --- Section properties (one per section, raw options for descriptor pipeline) ---\n private _sectionProperties: SectionPropertiesOptions[] = [];\n public get sectionProperties(): readonly SectionPropertiesOptions[] {\n return this._sectionProperties;\n }\n\n // --- WriteContext interface (core descriptor pipeline) ---\n\n public addRelationship(_type: string, _target: string, _mode?: string): string {\n const id = this._currentRelationshipId++;\n return `rId${id}`;\n }\n\n public addMedia(_data: Uint8Array, _type: string): string {\n // DOCX media registration goes through Media.addImage() in compiler.\n return \"\";\n }\n\n // --- Internal tracking ---\n private _headers: HeaderFooterEntry[] = [];\n private _footers: HeaderFooterEntry[] = [];\n\n // --- Original input preserved for descriptor usage ---\n declare public _options: DocumentOptions;\n\n constructor(options: DocumentOptions) {\n this._options = options;\n\n this.numbering = new Numbering(options.numbering ? options.numbering : { config: [] });\n\n this.comments = { relationships: new Relationships() };\n this.fileRelationships = new Relationships();\n this.footNotes = { relationships: new Relationships(), notes: new Map() };\n this.endnotes = { relationships: new Relationships(), notes: new Map() };\n this.document = { relationships: new Relationships() };\n this._settingsOptions = {\n compatibility: options.compatibility,\n compatibilityModeVersion: options.compatabilityModeVersion,\n defaultTabStop: options.defaultTabStop,\n evenAndOddHeaders: options.evenAndOddHeaderAndFooters ? true : false,\n characterSpacingControl: options.characterSpacingControl,\n hyphenation: {\n autoHyphenation: options.hyphenation?.autoHyphenation,\n consecutiveHyphenLimit: options.hyphenation?.consecutiveHyphenLimit,\n doNotHyphenateCaps: options.hyphenation?.doNotHyphenateCaps,\n hyphenationZone: options.hyphenation?.hyphenationZone,\n },\n trackRevisions: options.features?.trackRevisions,\n updateFields: options.features?.updateFields,\n documentProtection: options.features?.documentProtection,\n view: options.view,\n zoom: options.zoom,\n writeProtection: options.writeProtection,\n displayBackgroundShape:\n options.displayBackgroundShape ?? (options.background?.image ? true : undefined),\n embedTrueTypeFonts: options.embedTrueTypeFonts,\n embedSystemFonts: options.embedSystemFonts,\n saveSubsetFonts: options.saveSubsetFonts,\n docVars: options.docVars,\n colorSchemeMapping: options.colorSchemeMapping,\n mailMerge: options.mailMerge,\n ...options.settings,\n };\n\n this.media = new Media();\n this.charts = new ChartCollection();\n this.smartArts = new SmartArtCollection();\n this.altChunks = new AltChunkCollection();\n this.subDocs = new SubDocCollection();\n\n if (options.externalStyles !== undefined) {\n const defaultFactory = new DefaultStylesFactory();\n const defaultStyles = defaultFactory.newInstance(options.styles?.default);\n const externalFactory = new ExternalStylesFactory();\n const externalStyles = externalFactory.newInstance(options.externalStyles);\n // Skip docDefaults AND latentStyles from default factory —\n // external styles already provide them; XSD requires docDefaults → latentStyles → style sequence\n const defaultStyleElements = defaultStyles.importedStyles!.slice(2);\n this.styles = new Styles({\n ...externalStyles,\n importedStyles: [...externalStyles.importedStyles!, ...defaultStyleElements],\n });\n } else if (options.styles) {\n const stylesFactory = new DefaultStylesFactory();\n const defaultStyles = stylesFactory.newInstance(options.styles.default);\n this.styles = new Styles({\n ...defaultStyles,\n ...options.styles,\n });\n } else {\n const stylesFactory = new DefaultStylesFactory();\n this.styles = new Styles(stylesFactory.newInstance());\n }\n\n // Register numbering references from custom paragraph/character styles.\n // Style definitions may contain numbering properties whose concrete instances\n // are never created through the body paragraph processing path.\n if (options.styles?.paragraphStyles) {\n for (const style of options.styles.paragraphStyles) {\n const num = style.paragraph?.numbering;\n if (num) {\n this.numbering.createConcreteNumberingInstance(num.reference, num.instance ?? 0);\n }\n }\n }\n\n this.addDefaultRelationships();\n\n for (const section of options.sections) {\n this.addSection(section);\n }\n\n if (options.footnotes) {\n for (const key in options.footnotes) {\n this.footNotes.notes.set(parseFloat(key), options.footnotes[key].children);\n }\n }\n\n if (options.endnotes) {\n for (const key in options.endnotes) {\n this.endnotes.notes.set(parseFloat(key), options.endnotes[key].children);\n }\n }\n\n this.fontTable = new FontWrapper(options.fonts ?? []);\n this.glossaryOptions = options.glossary;\n this.webSettings = options.webSettings ?? undefined;\n\n if (options.glossary) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument\",\n \"glossary/document.xml\",\n );\n }\n\n if (this.webSettings) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings\",\n \"webSettings.xml\",\n );\n }\n }\n\n get headers(): HeaderFooterEntry[] {\n return this._headers;\n }\n\n get footers(): HeaderFooterEntry[] {\n return this._footers;\n }\n\n // --- Private helpers ---\n\n private addSection({ headers = {}, footers = {}, properties }: SectionOptions): void {\n const sectPrOptions: SectionPropertiesOptions = {\n ...properties,\n footerWrapperGroup: {\n default: footers.default ? this.createFooter(footers.default) : undefined,\n even: footers.even ? this.createFooter(footers.even) : undefined,\n first: footers.first ? this.createFooter(footers.first) : undefined,\n },\n headerWrapperGroup: {\n default: headers.default ? this.createHeader(headers.default) : undefined,\n even: headers.even ? this.createHeader(headers.even) : undefined,\n first: headers.first ? this.createHeader(headers.first) : undefined,\n },\n };\n this._sectionProperties.push(sectPrOptions);\n }\n\n private createHeader(header: SectionChild[]): HeaderFooterEntry {\n const referenceId = this._currentRelationshipId++;\n const entry: HeaderFooterEntry = {\n children: header,\n relationships: new Relationships(),\n referenceId,\n };\n this.addHeaderToDocument(entry);\n return entry;\n }\n\n private createFooter(footer: SectionChild[]): HeaderFooterEntry {\n const referenceId = this._currentRelationshipId++;\n const entry: HeaderFooterEntry = {\n children: footer,\n relationships: new Relationships(),\n referenceId,\n };\n this.addFooterToDocument(entry);\n return entry;\n }\n\n private addHeaderToDocument(header: HeaderFooterEntry): void {\n this._headers.push(header);\n this.document.relationships.addRelationship(\n header.referenceId,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header\",\n `header${this._headers.length}.xml`,\n );\n }\n\n private addFooterToDocument(footer: HeaderFooterEntry): void {\n this._footers.push(footer);\n this.document.relationships.addRelationship(\n footer.referenceId,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer\",\n `footer${this._footers.length}.xml`,\n );\n }\n\n private addDefaultRelationships(): void {\n this.fileRelationships.addRelationship(\n 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\",\n \"word/document.xml\",\n );\n this.fileRelationships.addRelationship(\n 2,\n \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\",\n \"docProps/core.xml\",\n );\n this.fileRelationships.addRelationship(\n 3,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\",\n \"docProps/app.xml\",\n );\n this.fileRelationships.addRelationship(\n 4,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties\",\n \"docProps/custom.xml\",\n );\n\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\",\n \"styles.xml\",\n );\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering\",\n \"numbering.xml\",\n );\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes\",\n \"footnotes.xml\",\n );\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes\",\n \"endnotes.xml\",\n );\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\",\n \"settings.xml\",\n );\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments\",\n \"comments.xml\",\n );\n if (this._options.bibliography) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/bibliography\",\n \"bibliography.xml\",\n );\n }\n }\n}\n\n// ── DocxReadContext ──\n\n/**\n * DOCX-specific read context.\n *\n * Holds references to the parsed DocxDocument and cached style/numbering data\n * used throughout the DOCX parsing pipeline. Implements ReadContext for\n * descriptor pipeline compatibility.\n */\nexport class DocxReadContext implements ReadContext {\n constructor(\n public docx: DocxDocument,\n public styleCache: Map<string, Element>,\n public numberingCache: Map<string, Element>,\n ) {}\n\n resolveRelationship(rId: string): string | undefined {\n return (\n this.docx.partRefs.headers.get(rId) ??\n this.docx.partRefs.footers.get(rId) ??\n this.docx.partRefs.media.get(rId) ??\n this.docx.partRefs.charts.get(rId) ??\n this.docx.partRefs.diagramData.get(rId) ??\n this.docx.partRefs.afChunks.get(rId) ??\n this.docx.partRefs.subDocs.get(rId) ??\n this.docx.partRefs.hyperlinks.get(rId)\n );\n }\n\n getPart(path: string): Element | undefined {\n return this.docx.doc.get(path);\n }\n\n getRaw(path: string): Uint8Array | undefined {\n return this.docx.doc.getRaw(path);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,gBAAgB;;CAE3B,OAAO;;CAEP,QAAQ;;CAER,KAAK;;CAEL,MAAM;;CAEN,gBAAgB;;CAEhB,YAAY;;CAEZ,SAAS;;CAET,cAAc;;CAEd,aAAa;;CAEb,iBAAiB;;CAEjB,MAAM;;CAEN,OAAO;;CAEP,WAAW;AACb;;;;;;;;;;;;;;;;;;;;AClDA,MAAa,eAAe;;CAE1B,UAAU;;CAEV,SAAS;;CAET,OAAO;;CAEP,MAAM;AACR;;;;;;;;;;;;;;;;;ACbA,MAAa,eAAe;;CAE1B,WAAW;;CAEX,WAAW;;CAEX,WAAW;;CAEX,WAAW;;CAEX,WAAW;;CAEX,WAAW;;CAEX,OAAO;AACT;;;;;;;;;;ACFA,MAAa,oBAAoB;;CAE/B,KAAK;;CAEL,QAAQ;;CAER,UAAU;;CAEV,QAAQ;;CAER,MAAM;AACR;;;;;;;;AASA,MAAa,uBAAuB;;CAElC,MAAM;;CAEN,WAAW;;CAEX,qBAAqB;;CAErB,iBAAiB;;CAEjB,gBAAgB;AAClB;;;;;;;;;;;;AC2BA,MAAa,aAAa;;CAExB,SAAS;;CAET,aAAa;;CAEb,wBAAwB;;CAExB,iBAAiB;AACnB;;;;;;;;;;AC5DA,MAAa,aAAa;;CAExB,kBAAkB;;CAElB,QAAQ;;C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